~albertog/siesta/efield-2.5-jjunquera

« back to all changes in this revision

Viewing changes to Src/fft3d.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:
35
35
      use parallel,     only : Node, Nodes, ProcessorY
36
36
      use parallelsubs, only : HowManyMeshPerNode
37
37
      use sys,          only : die
 
38
      use alloc,        only : re_alloc, de_alloc
38
39
#ifdef MPI
39
40
      use mpi_siesta
40
41
#endif
61
62
     .  LocalPoints, lredimension
62
63
      real(dp)
63
64
     .  scale
64
 
      real(dp), dimension(:,:), allocatable, save :: 
65
 
     .  trigs
 
65
      real(dp), dimension(:,:), pointer, save ::   trigs
66
66
#ifdef MPI
67
67
      integer
68
68
     .  n1lf, nrem, Py, Pz
69
 
      real(grid_p), dimension(:), allocatable, save :: 
70
 
     .  ft
 
69
      real(grid_p), dimension(:), pointer  ::   ft
71
70
#endif
72
71
 
73
 
      external
74
 
     .  memory
75
 
 
76
72
      save OldMesh
77
73
      data OldMesh/0,0,0/
78
74
 
108
104
C
109
105
C  Allocate trigs array
110
106
C
111
 
      if (.not.allocated(trigs)) then
 
107
      if (.not.associated(trigs)) then
112
108
        maxtrigs = 256
113
 
        allocate(trigs(maxtrigs,3))
 
109
        nullify( trigs )
 
110
        call re_alloc( trigs, 1, maxtrigs, 1, 3, name='trigs',
 
111
     &                 routine='fft' )
114
112
      endif
115
113
C
116
114
C  Initialise the tables for the FFT if the mesh has changed
133
131
C  Resize FFT array for trig factors and set OldMesh to 0 to force recalculation
134
132
C
135
133
        maxtrigs = maxmaxtrigs
136
 
        deallocate(trigs)
137
 
        allocate(trigs(maxtrigs,3))
 
134
        call re_alloc( trigs, 1, maxtrigs, 1, 3, name='trigs',
 
135
     &                 routine='fft' )
138
136
        OldMesh(1:3) = 0
139
137
        goto 10
140
138
      endif
157
155
C
158
156
C  Allocate local memory
159
157
C
160
 
      allocate(ft(2*n1lf*n2*n3l))
161
 
      call memory('A','X',2*n1lf*n2*n3l,'fft')
 
158
      nullify( ft )
 
159
      call re_alloc( ft, 1, 2*n1lf*n2*n3l, name='ft', routine='fft' )
162
160
C
163
161
C  Redistribute data to be distributed by X and Z
164
162
C
180
178
C
181
179
C  Free local memory ready for re-use
182
180
C
183
 
      call memory('D','X',size(ft),'fft')
184
 
      deallocate(ft)
 
181
      call de_alloc( ft, name='ft' )
185
182
C
186
183
C  Find new distributed x dimension
187
184
C
191
188
C
192
189
C  Allocate local memory
193
190
C
194
 
      allocate(ft(2*n1lf*n2l*n3))
195
 
      call memory('A','X',2*n1lf*n2l*n3,'fft')
 
191
      nullify( ft )   ! AG
 
192
      call re_alloc( ft, 1, 2*n1lf*n2l*n3, name='ft', routine='fft' )
196
193
C
197
194
C  Redistribute data to be distributed by X and Y
198
195
C
210
207
C
211
208
C  Free local memory
212
209
C
213
 
      call memory('D','X',size(ft),'fft')
214
 
      deallocate(ft)
 
210
      call de_alloc( ft, name='ft' )
215
211
#else
216
212
C
217
213
C  FFT in Y direction
239
235
 
240
236
      return
241
237
      end
242
 
 
 
238
!-------------------------------------
243
239
#ifdef MPI
244
240
      subroutine redistribXZ(f,n1,n2l,n3l,ft,n1lf,n2,idir,nsm,
245
241
     .  Node,Nodes)
261
257
      use mpi_siesta
262
258
      use parallel,    only : ProcessorY
263
259
      use sys,         only : die
 
260
      use alloc,       only : re_alloc, de_alloc
264
261
 
265
262
      implicit none
266
263
 
286
283
 
287
284
      logical, save :: firsttimeZ = .true.
288
285
 
289
 
      real(grid_p), dimension(:,:,:,:), allocatable, save :: 
290
 
     .  ftmp,ftmp2
 
286
      real(grid_p), dimension(:,:,:,:), pointer  :: ftmp,ftmp2
291
287
 
292
288
      if (firsttimeZ) then
293
289
C
328
324
C
329
325
C  Allocate local memory and initialise
330
326
C
331
 
      allocate(ftmp(2,n1lmax,BlockSizeYMax,n3l))
332
 
      call memory('A','X',2*n1lmax*BlockSizeYMax*n3l,'redistribXZ')
333
 
      allocate(ftmp2(2,n1lmax,BlockSizeYMax,n3l))
334
 
      call memory('A','X',2*n1lmax*BlockSizeYMax*n3l,'redistribXZ')
 
327
      nullify( ftmp )
 
328
      call re_alloc( ftmp, 1, 2, 1, n1lmax, 1, BlockSizeYMax, 1, n3l,
 
329
     &               name='ftmp', routine='redistribXZ' )
 
330
      nullify( ftmp2 )
 
331
      call re_alloc( ftmp2, 1, 2, 1, n1lmax, 1, BlockSizeYMax, 1, n3l,
 
332
     &               name='ftmp2', routine='redistribXZ' )
 
333
 
335
334
      do i = 1,n3l
336
335
        do j = 1,BlockSizeYMax
337
336
          do k = 1,n1lmax
493
492
C
494
493
C  Free local memory
495
494
C
496
 
      call memory('D','X',size(ftmp2),'redistribXZ')
497
 
      deallocate(ftmp2)
498
 
      call memory('D','X',size(ftmp),'redistribXZ')
499
 
      deallocate(ftmp)
 
495
      call de_alloc( ftmp2, name='ftmp2' )
 
496
      call de_alloc( ftmp, name='ftmp' )
500
497
 
501
 
      return
502
498
      end
503
499
 
504
500
      subroutine redistribXY(f,n1,n2l,n3l,ft,n1lf,n3,idir,nsm,
524
520
      use mpi_siesta
525
521
      use parallel,    only : ProcessorY
526
522
      use sys,         only : die
 
523
      use alloc,       only : re_alloc, de_alloc
527
524
 
528
525
      implicit none
529
526
 
549
546
 
550
547
      logical, save :: firsttimeY = .true.
551
548
 
552
 
      real(grid_p), dimension(:,:,:,:), allocatable, save :: 
553
 
     .  ftmp,ftmp2
 
549
      real(grid_p), dimension(:,:,:,:), pointer :: ftmp,ftmp2
554
550
 
555
551
      if (firsttimeY) then
556
552
C
583
579
C
584
580
C  Allocate local memory and initialise
585
581
C
586
 
      allocate(ftmp(2,n1lmax,n2l,BlockSizeZMax))
587
 
      call memory('A','X',2*n1lmax*n2l*BlockSizeZMax,'redistribXY')
588
 
      allocate(ftmp2(2,n1lmax,n2l,BlockSizeZMax))
589
 
      call memory('A','X',2*n1lmax*n2l*BlockSizeZMax,'redistribXY')
 
582
      nullify( ftmp )
 
583
      call re_alloc( ftmp, 1, 2, 1, n1lmax, 1, n2l, 1, BlockSizeZMax,
 
584
     &               name='ftmp', routine='redistribXY' )
 
585
      nullify( ftmp2 )
 
586
      call re_alloc( ftmp2, 1, 2, 1, n1lmax, 1, n2l, 1, BlockSizeZMax,
 
587
     &               name='ftmp2', routine='redistribXY' )
 
588
 
590
589
      do i = 1,BlockSizeZMax
591
590
        do j = 1,n2l
592
591
          do k = 1,n1lmax
756
755
C
757
756
C  Free local memory
758
757
C
759
 
      call memory('D','X',size(ftmp2),'redistribXY')
760
 
      deallocate(ftmp2)
761
 
      call memory('D','X',size(ftmp),'redistribXY')
762
 
      deallocate(ftmp)
 
758
      call de_alloc( ftmp2, name='ftmp2' )
 
759
      call de_alloc( ftmp, name='ftmp' )
763
760
 
764
761
      return
765
762
      end