~nickpapior/siesta/trunk-kovalp

« back to all changes in this revision

Viewing changes to Src/mneighb.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:
12
12
 
13
13
        use precision, only: dp
14
14
        use sys, only: die
15
 
 
16
 
        integer,  pointer, save :: jan(:)
17
 
 
18
 
        real(dp), pointer, save :: r2ij(:)
19
 
        real(dp), pointer, save :: xij(:,:)
 
15
        use alloc, only : re_alloc, de_alloc
 
16
 
 
17
        private
 
18
 
 
19
        integer,  save, public           :: maxnna = 200
 
20
        integer,  pointer, save, public  :: jan(:)
 
21
        real(dp), pointer, save, public  :: r2ij(:)
 
22
        real(dp), pointer, save, public  :: xij(:,:)
 
23
        logical,  save       :: pointers_allocated = .false.
 
24
 
 
25
        public :: mneighb, sizeup_neighbour_arrays
20
26
 
21
27
      contains
22
28
 
23
29
      subroutine mneighb( CELL, range, NA, XA, IA, ISC,
24
 
     .                    NNA, MAXNNA )
 
30
     .                    NNA )
25
31
 
26
32
C ********************************************************************
27
33
C Finds the neighbours of an atom in a cell with periodic boundary 
38
44
C                     a first call with IA = 0
39
45
C INTEGER ISC       : Single-counting switch (0=No, 1=Yes). If ISC=1,
40
46
C                     only neighbours with JA.LE.IA are included in JAN
41
 
C INTEGER MAXNNA    : Size of arrays JAN, XIJ and R2IJ
 
47
!!!!! C INTEGER MAXNNA    : Size of arrays JAN, XIJ and R2IJ
42
48
C *********** OUTPUT *************************************************
43
49
C INTEGER NNA       : Number of neighbour atoms within range of IA
44
50
C INTEGER JAN(NNA)  : Atom-index of neighbours
101
107
C    ENDDO
102
108
C ********************************************************************
103
109
 
104
 
      use precision
105
 
      use alloc
106
 
 
107
110
C Next line is non-standard but may be supressed
108
111
      implicit none
109
112
 
113
116
C Argument types and dimensions
114
117
      integer, intent(in) :: ia, isc, na
115
118
      integer, intent(out) :: nna
116
 
      integer, intent(inout) :: maxnna
117
119
      real(dp) :: cell(nx,nx), range, xa(nx,na)
118
120
 
119
121
C Internal variables
120
 
      logical, save  :: frstme        = .true.
 
122
 
121
123
      integer, save  :: iamove(1)     = 0
122
124
      real(dp), save :: celast(nx,nx) = 0.0_dp,
123
125
     .                  rglast        = 0.0_dp,
125
127
 
126
128
      logical :: samcel
127
129
      integer :: IX, JX
 
130
      logical,  save          :: first_time = .true.
128
131
 
129
132
C Nullify pointers
130
 
      if (frstme) then
 
133
      if (.not. pointers_allocated) then
131
134
        nullify(jan)
132
135
        nullify(r2ij)
133
136
        nullify(xij)
 
137
      !  Dimension arrays to initial size MAXNNA
 
138
        call re_alloc(jan,1,maxnna,name='jan')
 
139
        call re_alloc(r2ij,1,maxnna,name='r2ij')
 
140
        call re_alloc(xij,1,3,1,maxnna,name='xij')
 
141
        pointers_allocated = .true.
134
142
      endif
135
143
 
136
 
C Dimension arrays to size MAXNNA
137
 
      call re_alloc(jan,1,maxnna,name='jan')
138
 
      call re_alloc(r2ij,1,maxnna,name='r2ij')
139
 
      call re_alloc(xij,1,3,1,maxnna,name='xij')
140
 
 
141
144
C Initialization section
142
 
      IF (FRSTME .OR. IA.LE.0 .OR. range.GT.RGLAST) THEN
 
145
      IF (FIRST_TIME .OR. IA.LE.0 .OR. range.GT.RGLAST) THEN
143
146
 
144
147
C Find if cell or range have changed
145
148
        samcel = .true.
146
 
        if (frstme) then
 
149
        if (first_time) then
147
150
          samcel = .false.
148
151
        else
149
152
          do IX = 1,NX
164
167
            enddo
165
168
          enddo
166
169
          RGLAST = range
167
 
          FRSTME = .false.
 
170
          FIRST_TIME = .false.
168
171
 
169
172
C Notify to rangeR that CELL has changed
170
173
          call mranger( 'CELL', NX, CELL, range, NA, XA,
531
534
 
532
535
      logical, save :: frstme = .true.
533
536
 
534
 
      external
535
 
     .  DISMIN, DDOT, RECCEL, memory
 
537
      external  DISMIN, DDOT
536
538
 
537
539
      save
538
540
     .  IAM, IEM, IM, 
1097
1099
      ENDIF
1098
1100
 
1099
1101
      end subroutine indarr
 
1102
!
 
1103
      subroutine sizeup_neighbour_arrays(n)
 
1104
      integer, intent(in) :: n
 
1105
 
 
1106
      ! Makes sure that the neighbour arrays are at
 
1107
      ! least of size n
 
1108
 
 
1109
      if (.not. pointers_allocated) then
 
1110
        nullify(jan)
 
1111
        nullify(r2ij)
 
1112
        nullify(xij)
 
1113
        !  Dimension arrays to initial size n
 
1114
        maxnna = n
 
1115
        call re_alloc(jan,1,maxnna,name='jan')
 
1116
        call re_alloc(r2ij,1,maxnna,name='r2ij')
 
1117
        call re_alloc(xij,1,3,1,maxnna,name='xij')
 
1118
        pointers_allocated = .true.
 
1119
      else
 
1120
         if (n > maxnna) then
 
1121
            maxnna = n
 
1122
            call re_alloc(jan,1,maxnna,name='jan')
 
1123
            call re_alloc(r2ij,1,maxnna,name='r2ij')
 
1124
            call re_alloc(xij,1,3,1,maxnna,name='xij')
 
1125
         endif
 
1126
      endif
 
1127
 
 
1128
      end subroutine sizeup_neighbour_arrays
 
1129
 
1100
1130
 
1101
1131
      end module neighbour
1102
1132