~nickpapior/siesta/trunk-kovalp

« back to all changes in this revision

Viewing changes to Src/denmat.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:
89
89
      use precision
90
90
      use on_main,   only : ncG2L, ncP2T, ncT2P, nbL2G, nbandsloc
91
91
      use m_mpi_utils, only : globalize_sum
 
92
      use alloc,     only : re_alloc, de_alloc
92
93
 
93
94
#ifdef MPI
94
95
      use globalise, only: setglobalise, maxft2, numft2, listft2,
133
134
     .  i, il, in, indm, indn, im, is, j, jn, m, mi, mm, mn, 
134
135
     .  n, nh, ni, nm, nn
135
136
 
136
 
      real(dp), allocatable, save ::
 
137
      real(dp), pointer ::
137
138
     .  cHrow(:), cSrow(:), chcrow(:), cscrow(:), chccCol(:),
138
139
     .  csccCol(:)
139
140
 
142
143
     .  Hmn, Smn, qout(2), fact, spinfct
143
144
 
144
145
#ifdef MPI
145
 
      real(dp) ::
146
 
     .  qtmp(nspin)
147
 
      real(dp), allocatable, save ::
 
146
      real(dp) ::  qtmp(nspin)
 
147
      real(dp), pointer ::
148
148
     .  ctmp(:,:), chcrowsave(:,:), cscrowsave(:,:), 
149
149
     .  ftG(:,:), fstG(:,:)
150
150
#else
151
 
       real(dp), allocatable :: 
152
 
     .     ft(:,:), fst(:,:)
 
151
       real(dp), pointer ::  ft(:,:), fst(:,:)
153
152
#endif
154
153
 
155
154
C Start time counter
162
161
      endif
163
162
 
164
163
C Allocate local arrays
165
 
      allocate(cHrow(nbasis))
166
 
      call memory('A','D',size(cHrow),'denmat')
167
 
      allocate(cSrow(nbasis))
168
 
      call memory('A','D',size(cSrow),'denmat')
169
 
      allocate(chcrow(nbands))
170
 
      call memory('A','D',size(chcrow),'denmat')
171
 
      allocate(cscrow(nbands))
172
 
      call memory('A','D',size(cscrow),'denmat')
173
 
      allocate(chccCol(nbands))
174
 
      call memory('A','D',size(chccCol),'denmat')
175
 
      allocate(csccCol(nbands))
176
 
      call memory('A','D',size(csccCol),'denmat')
 
164
 
 
165
      nullify( cHrow )
 
166
      call re_alloc( cHrow, 1, nbasis, name='cHrow', routine='denmat' )
 
167
      nullify( cSrow )
 
168
      call re_alloc( cSrow, 1, nbasis, name='cSrow', routine='denmat' )
 
169
      nullify( chcrow )
 
170
      call re_alloc( chcrow, 1, nbands, name='chcrow',
 
171
     &               routine='denmat' )
 
172
      nullify( cscrow )
 
173
      call re_alloc( cscrow, 1, nbands, name='cscrow',
 
174
     &               routine='denmat' )
 
175
      nullify( chccCol )
 
176
      call re_alloc( chccCol, 1, nbands, name='chccCol',
 
177
     &               routine='denmat' )
 
178
      nullify( csccCol )
 
179
      call re_alloc( csccCol, 1, nbands, name='csccCol',
 
180
     &               routine='denmat' )
 
181
 
177
182
#ifdef MPI
178
 
      allocate(chcrowsave(nhijmax,nbandsloc))
179
 
      call memory('A','D',size(chcrowsave),'denmat')
180
 
      allocate(cscrowsave(nhijmax,nbandsloc))
181
 
      call memory('A','D',size(cscrowsave),'denmat')
182
 
      allocate(ctmp(nbands,2))
183
 
      call memory('A','D',size(ctmp),'denmat')
184
 
      allocate(ftG(MaxFt2,nbasisCloc))
185
 
      call memory('A','D',size(ftG),'denmat')
186
 
      allocate(fstG(MaxFt2,nbasisCloc))
187
 
      call memory('A','D',size(fstG),'denmat')
 
183
      nullify( chcrowsave )
 
184
      call re_alloc( chcrowsave, 1, nhijmax, 1, nbandsloc,
 
185
     &               name='chcrowsave', routine='denmat' )
 
186
      nullify( cscrowsave )
 
187
      call re_alloc( cscrowsave, 1, nhijmax, 1, nbandsloc,
 
188
     &               name='cscrowsave', routine='denmat' )
 
189
      nullify( ctmp )
 
190
      call re_alloc( ctmp, 1, nbands, 1, 2,
 
191
     &               name='ctmp', routine='denmat' )
 
192
      nullify( ftG )
 
193
      call re_alloc( ftG, 1, MaxFt2, 1, nbasisCloc,
 
194
     &               name='ftG', routine='denmat' )
 
195
      nullify( fstG )
 
196
      call re_alloc( fstG, 1, MaxFt2, 1, nbasisCloc,
 
197
     &               name='fstG', routine='denmat' )
188
198
#else
189
 
      allocate(ft(nftmax,nbasisCloc))
190
 
      call memory('A','D',size(ft),'denmat')
191
 
      allocate(fst(nftmax,nbasisCloc))
192
 
      call memory('A','D',size(fst),'denmat')
 
199
      nullify( ft )
 
200
      call re_alloc( ft, 1, nftmax, 1, nbasisCloc,
 
201
     &               name='ft', routine='denmat' )
 
202
      nullify( fst )
 
203
      call re_alloc( fst, 1, nftmax, 1, nbasisCloc,
 
204
     &               name='fst', routine='denmat' )
193
205
#endif
194
206
 
195
207
C Initialize temporary arrays
442
454
 
443
455
C Deallocate local arrays
444
456
#ifdef MPI
445
 
      call memory('D','D',size(fstG),'denmat')
446
 
      deallocate(fstG)
447
 
      call memory('D','D',size(ftG),'denmat')
448
 
      deallocate(ftG)
449
 
      call memory('D','D',size(ctmp),'denmat')
450
 
      deallocate(ctmp)
451
 
      call memory('D','D',size(cscrowsave),'denmat')
452
 
      deallocate(cscrowsave)
453
 
      call memory('D','D',size(chcrowsave),'denmat')
454
 
      deallocate(chcrowsave)
 
457
      call de_alloc( fstG, name='fstG' )
 
458
      call de_alloc( ftG, name='ftG' )
 
459
      call de_alloc( ctmp, name='ctmp' )
 
460
      call de_alloc( cscrowsave, name='cscrowsave' )
 
461
      call de_alloc( chcrowsave, name='chcrowsave' )
455
462
#else
456
 
      call memory('D','D',size(fst),'denmat')
457
 
      deallocate(fst)
458
 
      call memory('D','D',size(ft),'denmat')
459
 
      deallocate(ft)
 
463
      call de_alloc( fst, name='fst' )
 
464
      call de_alloc( ft, name='ft' )
460
465
#endif
461
 
      call memory('D','D',size(csccCol),'denmat')
462
 
      deallocate(csccCol)
463
 
      call memory('D','D',size(chccCol),'denmat')
464
 
      deallocate(chccCol)
465
 
      call memory('D','D',size(cscrow),'denmat')
466
 
      deallocate(cscrow)
467
 
      call memory('D','D',size(chcrow),'denmat')
468
 
      deallocate(chcrow)
469
 
      call memory('D','D',size(cSrow),'denmat')
470
 
      deallocate(cSrow)
471
 
      call memory('D','D',size(cHrow),'denmat')
472
 
      deallocate(cHrow)
 
466
      call de_alloc( csccCol, name='csccCol' )
 
467
      call de_alloc( chccCol, name='chccCol' )
 
468
      call de_alloc( cscrow, name='cscrow' )
 
469
      call de_alloc( chcrow, name='chcrow' )
 
470
      call de_alloc( cSrow, name='cSrow' )
 
471
      call de_alloc( cHrow, name='cHrow' )
473
472
 
474
473
C Stop time counter and return ..................
475
474
      call timer('denmat',2)