~albertog/siesta/4.1-xc

« back to all changes in this revision

Viewing changes to Src/dhscf.F

  • Committer: Alberto Garcia
  • Date: 2019-01-20 21:40:25 UTC
  • Revision ID: albertog@icmab.es-20190120214025-c60tzjcxdobl1ktu
Use "linear" ("yes/no") distribution as seed in SiestaXC

* Give SiestaXC a head start with the appropriate distribution by
  using the "yes/no" (called 'LINEAR') distribution from BSC as the
  initial one. Just specify the box (with the appropriate conversions)
  and use the new cellXC option described below to deactivate further
  internal changes.

* By settting the optional argument 'keep_input_distribution' to
  .true., the internal workload balancer in cellXC is deactivated,
  and the input distribution kept for the XC computations. This is
  advantageous when the client program has better workload-balancers
  available.
  

Show diffs side-by-side

added added

removed removed

Lines of Context:
614
614
C     Modules
615
615
      use precision,     only  : dp, grid_p
616
616
 
617
 
      use parallel, only : ProcessorY
618
 
 
619
 
!     Number of Mesh divisions of each cell vector (global)
620
 
!     The status of this variable is confusing
621
617
      use parallel,      only  : Node, Nodes
622
618
      use atmfuncs,      only  : rcut, rcore
623
619
      use units,         only  : Debye, eV, Ang
624
620
      use fdf
625
621
      use sys,           only  : die, bye
626
 
      use mesh,          only  : nsm, nsp
 
622
      use mesh,          only  : nsm, nsp, meshLim
627
623
      use parsing
628
624
      use m_iorho,       only  : write_rho
629
625
      use m_forhar,      only  : forhar
742
738
C integer ispin         : Spin index
743
739
C integer j             : General-purpose index
744
740
 
745
 
C integer JDGdistr      : J.D.Gale's parallel distribution of mesh points
746
741
C integer myBox(2,3)    : My processor's mesh box 
747
742
 
748
743
C integer nbcell        : Number of independent bulk lattice vectors
790
785
 
791
786
!     Interface to JMS's SiestaXC
792
787
      integer       :: myBox(2,3)
793
 
      integer, save :: JDGdistr=-1
794
788
      real(dp) :: stressXC(3,3)
795
789
 
796
790
C     Work arrays
1499
1493
 
1500
1494
!     Everything now is in UNIFORM, sequential form
1501
1495
 
1502
 
      if (use_bsc_cellxc) then
1503
 
 
1504
 
         call timer("BSC-CellXC",1)
 
1496
         call timer("XC",1)
1505
1497
 
1506
1498
         ! Switch to "zero/not-zero rho" distribution (miscalled 'LINEAR')
1507
1499
         if (nodes.gt.1) then
1518
1510
            call distMeshData( UNIFORM, fsrc, LINEAR, fdst, KEEP )
1519
1511
         enddo
1520
1512
 
 
1513
      if (use_bsc_cellxc) then
 
1514
 
 
1515
         call timer("BSC-CellXC",1)
1521
1516
         call bsc_cellxc( 0, 0, cell, ntml, ntml, ntpl, 0, aux3, nspin,
1522
1517
     &                    DRho_gga, Ex, Ec, DEx, DEc, Vscf_gga,
1523
1518
     &                    dummy_DVxcdn, stressl )
1524
1519
 
 
1520
         call timer("BSC-CellXC",2)
 
1521
 
 
1522
      else
 
1523
         
 
1524
         call timer("GXC-CellXC",1)
 
1525
 
 
1526
         ! Note that RG's meshLim is in blocks of nsm points, and 1-based
 
1527
         ! Example.
 
1528
         ! 1:16 17:32  (base 1)
 
1529
         ! 0:15 16:31  (base 0)
 
1530
         ! Times nsm=2:
 
1531
         ! 0:30 32:62
 
1532
         ! Add 1 to lb, and nsm to ub:
 
1533
         ! 1:32 33:64  (base 1, in units of small-points)
 
1534
 
 
1535
         myBox(1,:) = (meshLim(1,:)-1)*nsm + 1
 
1536
         myBox(2,:) = (meshLim(2,:)-1)*nsm + nsm
 
1537
         
 
1538
         call cellXC( 0, cell, ntm, myBox(1,1), myBox(2,1),
 
1539
     &                myBox(1,2), myBox(2,2),
 
1540
     &                myBox(1,3), myBox(2,3), nspin,
 
1541
     &                DRho_gga, Ex, Ec, DEx, DEc, stressXC, Vscf_gga,
 
1542
     &                keep_input_distribution = .true. )
 
1543
   !     Vscf is still sequential after the call to JMS's cellxc
 
1544
         stress = stress + stressXC
 
1545
         call timer("GXC-CellXC",2)
 
1546
         
 
1547
      endif  ! use_bsc_cellxc
 
1548
      
1525
1549
         ! Go back to uniform distribution
1526
1550
         if (nodes.gt.1) then
1527
1551
            call setMeshDistr( UNIFORM, nsm, nsp, nml, nmpl, ntml, ntpl)
1535
1559
         enddo
1536
1560
         call de_alloc( DRho_gga, 'DRho_gga', 'dhscf' )
1537
1561
         call de_alloc( Vscf_gga, 'Vscf_gga', 'dhscf' )
1538
 
         call timer("BSC-CellXC",2)
1539
 
 
1540
 
      else
1541
 
         
1542
 
         call timer("GXC-CellXC",1)
1543
 
 
1544
 
   !     This is the initial interface to JM Soler's own cellxc routine, which sets
1545
 
   !     up further distribution(s) internally. To begin, it is given the parameters
1546
 
   !     pertaining to the UNIFORM distribution of mesh points, which is in force at
1547
 
   !     this point. 
1548
 
 
1549
 
         call jms_setMeshDistr( distrID=JDGdistr, nMesh=ntm, 
1550
 
     &        nNodesX=1, nNodesY=ProcessorY, nBlock=nsm )
1551
 
         call myMeshBox( ntm, JDGdistr, myBox )
1552
 
 
1553
 
         call cellXC( 0, cell, ntm, myBox(1,1), myBox(2,1),
1554
 
     &                myBox(1,2), myBox(2,2),
1555
 
     &                myBox(1,3), myBox(2,3), nspin,
1556
 
     &                DRho, Ex, Ec, DEx, DEc, stressXC, Vscf )
1557
 
   !     Vscf is still sequential after the call to JMS's cellxc
1558
 
         stress = stress + stressXC
1559
 
         call timer("GXC-CellXC",2)
1560
 
         
1561
 
      endif ! use_bsc_cellxc
 
1562
 
 
1563
         call timer("XC",2)
1562
1564
 
1563
1565
      if ( debug_dhscf ) then
1564
1566
         write(*,debug_fmt) Node,'XC',