~nickpapior/siesta/trunk-kovalp

« back to all changes in this revision

Viewing changes to Src/cellxc.F

  • Committer: Alberto Garcia
  • Date: 2007-11-21 11:45:49 UTC
  • mfrom: (192.1.67)
  • Revision ID: Arch-1:siesta@uam.es--2006%siesta-devel--reference--2.3--patch-1
Direct merge into master branch of initial BSC changes
The changes along the BSC branches, up to the end of the restructuring
of siesta.F and associated changes, have been merged into a direct
descendant of the main development line. The BSC work originally
started as a branch of siesta-devel--reference--2.1--patch-29. Development
along 2.1 continued, and a new continuation branch 2.3 has been created
specifically for this merge.

Main patches applied:

 * ref@bsc--2007/siesta-bsc--master--2.1--base-0
   tag of siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-7

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-1
   Use of xalast in analysis routines. Exit of geometry loop

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-2
   Creation of a module to hold the siesta options

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-3
   New geometry module

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-4
   New stub module for sparse matrices

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-5
   More options for running tests

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-6
   Encapsulation of k-point handling

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-7
   Initialize iza in struct_init

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-8
   Siesta_todo slimming by M. Quero

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-9
   Fix import of no_l in born_charge

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-10
   Some conversions to Fortran90 by M. Quero

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-11
   Fourth session at the BSC

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-12
   Clarification of the scope of the stress variables

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-13
   Creation of siesta_forces

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-14
   Replacement of some allocatables by pointers and automatics

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-15
   New m_energies and m_steps modules. Back to old k-point behavior

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-16
   Merge of removal of integer and real variables from siesta_todo

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-17
   Fixes for troublesome bugs in reference code

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-18
   Final cleanup of siesta_todo

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-19
   Add character(len=*) routines to alloc.F90

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-20
   Pointers in fixed and setspatial. si2x1h test added to bsc-Makefile

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-21
   Re-organization of pulay module

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-22
   Reorganization of hsparse/xijorb calls with new neighbor module

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-23
   VPATH-aware compilation for multiple executable versions

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-24
   Allocatables to pointers  I

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-25
   Allocatables to pointers  II

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-26
   Allocatables to pointers III

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-27
   Allocatables to pointers IV -- new neighbor code + nspecies fix

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-28
   Explicit array-ness in calls in initatom and cellxc

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-29
   Fix wrong allocations in cellxc.F

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-30
   Explicit array extents in initatom.f

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-31
   Avoid shrinking of density-matrix arrays for extrapol.

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-32
   Fix typo in state_init.F

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-33
   Execute SCF loop when nscf=1

 * ref@bsc--2007/siesta-bsc--master--2.1--patch-34
   Clarify bounds of SCF loop in siesta_forces.

 * ref@bsc--2007/siesta-bsc--master--2.2--base-0
   tag of ref@bsc--2007/siesta-bsc--master--2.1--patch-31

 * ref@bsc--2007/siesta-bsc--master--2.3--base-0
   tag of ref@bsc--2007/siesta-bsc--master--2.2--base-0

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-1
   Prepare CHANGES file

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-2
   Merge patch-log for patch-30 from 2.1

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-3
   New treatment of fractional atoms in VCA. Bug fix in lmxo

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-4
   Re-enabling of kgrid update in variable-cell calculations

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-5
   Fix typo in state_init.F

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-6
   Merge filtering package by Eduardo Anglada

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-7
   Add graphite_c6_full test for more realistic vdW test

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-8
   Add patchlog for k-point fix

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-9
   Fix of zmatrix code to deal with degenerate case

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-10
   Units conversion in Util/Optical/optical.f. Scripts. Cosmetics

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-11
   Implementation of basis_enthalpy calculation. Zmatrix dependency

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-12
   Option to use fractional rc's for multiple zeta

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-13
   Sync vpath changes. Update siesta.tex

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-14
   Fix tag in MPI send/receive in mulliken

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-15
   Option to use fractional rc's for multiple zeta

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-16
   Merge of XML tester by Eduardo Anglada. Portability fixes

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-17
   Fix marenostrum-mpi.make. Syntax in compare_m.f90

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-18
   MareNostrum fixes. zdrot to blas. obj_setup. compare_m syntax

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-19
   Sync to bsc--2.1. Change banner in CHANGES to bsc--2.3

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-20
   Execute SCF loop when nscf=1

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-21
   Refinements of XML tester. New ioncat program

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-22
   Undef var in kgridinit, iohs MPI write, pdosg array bound, Origin shift

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-23
   Zmatrix optimization enhancements. Sign change in MM stress.

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-24
   Clarify bounds of SCF loop in siesta_forces.

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-25
   Avoid MP-grid permutations in trivial gamma case

 * ref@bsc--2007/siesta-bsc--master--2.3--patch-26
   Sync to reference--2.1

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--base-0
   tag of siesta@uam.es--2006/siesta-devel--reference--2.1--patch-29

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-1
   First stage of siesta.F splitting at BSC

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-2
   Created struct_init for initial geometry setup. New test force_2

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-3
   Consolidate geometry updates at the end of loop

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-4
   Initialize vol2 correctly in m_check_supercell.f

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-5
   Kgrid setup streamlined. Bands. Proximity check. Hsparse allocation 

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-6
   Work by Manuel Quero before the meeting on Feb 7th

 * siesta@uam.es--2006/siesta-bsc--reference--2.1--patch-7
   Moved the Born-effective-charge code




Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
      use xcmod,        only : nXCfunc, XCfunc, XCauth
121
121
      use xcmod,        only : XCweightX, XCweightC
122
122
      use sys,          only :die
 
123
      use alloc,        only : re_alloc, de_alloc
123
124
#ifdef MPI
124
125
C  Modules
125
126
      use parallel,     only : Node, Nodes, ProcessorY
187
188
      logical 
188
189
     .  NoLocalPoints
189
190
 
190
 
      real(grid_p), dimension(:,:,:), allocatable, save :: 
191
 
     .  bdens, bvxc
192
 
      real(grid_p), dimension(:,:), allocatable, save :: 
193
 
     .  bbuffer, dbuffer
194
 
      integer, dimension(:,:), allocatable, save :: 
195
 
     .  PMesh
 
191
      real(grid_p), dimension(:,:,:), pointer :: bdens, bvxc
 
192
      real(grid_p), dimension(:,:),   pointer :: bbuffer, dbuffer
 
193
      integer,      dimension(:,:),   pointer :: PMesh
 
194
 
196
195
#endif
197
196
 
198
197
C Local variables and arrays
207
206
     .                  DVCDN(mspin*mspin), DVXDN(mspin*mspin),
208
207
     .                  EPSC, EPSX, F1, F2, GD(3,mspin),
209
208
     .                  VOLCEL, volume, stress(3,3)
210
 
      external          GGAXC, LDAXC, RECLAT, VOLCEL, memory
 
209
      external          GGAXC, LDAXC, RECLAT, VOLCEL
211
210
 
212
211
C Start time counter (intended only for debugging and development)
213
212
      call timer( 'cellXC', 1 )
309
308
        endif
310
309
 
311
310
C Allocate memory for border densities and potential
312
 
        allocate(bdens(NSpan(1)*max(BlockSizeYMax,BlockSizeZMax),
313
 
     .           4*NN,nspin))
314
 
        call memory('A','X',NSpan(1)*max(BlockSizeYMax,BlockSizeZMax)*
315
 
     .              4*NN*nspin,'cellxc')
316
 
        allocate(bvxc(NSpan(1)*max(BlockSizeYMax,BlockSizeZMax),
317
 
     .           4*NN,nspin))
318
 
        call memory('A','X',NSpan(1)*max(BlockSizeYMax,BlockSizeZMax)*
319
 
     .              4*NN*nspin,'cellxc')
320
 
        allocate(PMesh(3,4))
321
 
        call memory('A','I',12,'cellxc')
 
311
 
 
312
        nullify( bdens )
 
313
        call re_alloc( bdens,
 
314
     &                 1, NSpan(1)*max(BlockSizeYMax,BlockSizeZMax),
 
315
     &                 1, 4*NN, 1, nspin, name='bdens',
 
316
     &                 routine='cellxc' )
 
317
        nullify( bvxc )
 
318
        call re_alloc( bvxc,
 
319
     &                 1,NSpan(1)*max(BlockSizeYMax,BlockSizeZMax),
 
320
     &                 1, 4*NN, 1, nspin, name='bvxc',
 
321
     &                 routine='cellxc' )
 
322
        nullify( PMesh )
 
323
        call re_alloc( PMesh, 1, 3, 1, 4, name='PMesh',
 
324
     &                 routine='cellxc' )
322
325
 
323
326
C Exchange density information in the Z-direction
324
327
        if (NMesh(3).ne.NMeshG(3)) then
333
336
 
334
337
C Find size of mesh at nodes to be exchanged with
335
338
          call HowManyMeshPerNode(MeshNsm,Pleft3,Nodes,NMeshPN,
336
 
     .      PMesh(1,3))
 
339
     .      PMesh(1:,3))
337
340
          call HowManyMeshPerNode(MeshNsm,Pright3,Nodes,NMeshPN,
338
 
     .      PMesh(1,4))
 
341
     .      PMesh(1:,4))
339
342
          do ix = 1,3
340
343
            PMesh(ix,3) = PMesh(ix,3)*NSM
341
344
            PMesh(ix,4) = PMesh(ix,4)*NSM
349
352
 
350
353
C Allocate arrays for data storage
351
354
          nmax = max(nrleft,nrright)
352
 
          allocate(bbuffer(nmax,2))
 
355
          nullify( bbuffer )
 
356
          call re_alloc( bbuffer, 1, nmax, 1, 2, name='bbuffer',
 
357
     &                   routine='cellxc' )
353
358
          nmax = max(nsleft,nsright)
354
 
          allocate(dbuffer(nmax,2))
 
359
          nullify( dbuffer )
 
360
          call re_alloc( dbuffer, 1, nmax, 1, 2, name='dbuffer',
 
361
     &                   routine='cellxc' )
355
362
 
356
363
C Build buffer transfer data array
357
364
          nsleft = 0
411
418
          enddo
412
419
 
413
420
C Free arrays for data storage
414
 
          deallocate(dbuffer)
415
 
          deallocate(bbuffer)
 
421
          call de_alloc( dbuffer, name='dbuffer' )
 
422
          call de_alloc( bbuffer, name='bbuffer' )
416
423
 
417
424
        endif
418
425
 
429
436
 
430
437
C Find size of mesh at nodes to be exchanged with
431
438
          call HowManyMeshPerNode(MeshNsm,Pleft2,Nodes,NMeshPN,
432
 
     .      PMesh(1,1))
 
439
     .      PMesh(1:,1))
433
440
          call HowManyMeshPerNode(MeshNsm,Pright2,Nodes,NMeshPN,
434
 
     .      PMesh(1,2))
 
441
     .      PMesh(1:,2))
435
442
          do ix = 1,3
436
443
            PMesh(ix,1) = PMesh(ix,1)*NSM
437
444
            PMesh(ix,2) = PMesh(ix,2)*NSM
445
452
 
446
453
C Allocate transfer arrays
447
454
          nmax = max(nrleft,nrright)
448
 
          allocate(bbuffer(nmax,2))
 
455
          nullify( bbuffer )
 
456
          call re_alloc( bbuffer, 1, nmax, 1, 2, name='bbuffer',
 
457
     &                   routine='cellxc' )
449
458
          nmax = max(nsleft,nsright)
450
 
          allocate(dbuffer(nmax,2))
 
459
          nullify( dbuffer )
 
460
          call re_alloc( dbuffer, 1, nmax, 1, 2, name='dbuffer',
 
461
     &                   routine='cellxc' )
451
462
 
452
463
C Fill data array for sending
453
464
          nsleft = 0
517
528
          enddo
518
529
 
519
530
C Free arrays for data storage
520
 
          deallocate(dbuffer)
521
 
          deallocate(bbuffer)
 
531
          call de_alloc( dbuffer, name='dbuffer' )
 
532
          call de_alloc( bbuffer, name='bbuffer' )
522
533
 
523
534
        endif
524
535
 
1197
1208
 
1198
1209
C Free memory
1199
1210
      if (GGA.and.Nodes.gt.1.and..not.NoLocalPoints) then
1200
 
        call memory('D','X',size(bdens),'cellxc')
1201
 
        deallocate(bdens)
1202
 
        call memory('D','X',size(bvxc),'cellxc')
1203
 
        deallocate(bvxc)
1204
 
        call memory('D','I',size(PMesh),'cellxc')
1205
 
        deallocate(PMesh)
 
1211
        call de_alloc( bdens, name='bdens' )
 
1212
        call de_alloc( bvxc, name='bvxc' )
 
1213
        call de_alloc( PMesh, name='PMesh' )
1206
1214
      endif
1207
1215
#endif
1208
1216