~albertog/siesta/efield-2.5-jjunquera

« back to all changes in this revision

Viewing changes to Src/bands.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:
9
9
! given in the SIESTA license, as signed by all legitimate users.
10
10
!
11
11
      module band
12
 
 
13
 
      use sys, only: die
14
 
 
 
12
      use precision, only: dp
 
13
      use sys,       only: die
 
14
      use alloc,     only: re_alloc
15
15
      implicit none
16
 
 
17
 
      integer :: maxlin
18
 
      parameter (maxlin = 1000)
 
16
      private
 
17
 
 
18
      integer, public :: nbk, maxbk
 
19
 
 
20
      integer, parameter :: maxlin = 1000
 
21
 
 
22
      real(dp), pointer, save, public :: bk(:,:)
 
23
      logical, public , save          :: gamma_bands
19
24
 
20
25
      character, save :: label(maxlin)*8
21
 
      integer, save   :: lastk(maxlin), nlines
22
 
 
23
 
      public  :: initbands, bands
24
 
 
25
 
      private
26
 
 
 
26
      integer,   save :: lastk(maxlin), nlines
 
27
 
 
28
      public  :: setup_bands, bands
 
29
      
27
30
      contains
28
31
 
 
32
      subroutine setup_bands( )
 
33
        implicit none
 
34
        ! Find number of band k-points
 
35
        nullify(bk)
 
36
        nbk = 0
 
37
        maxbk = 1
 
38
        call re_alloc(bk,1,3,1,maxbk,name='bk',routine='siesta',
 
39
     .                copy=.false.)
 
40
 
 
41
        call initbands( maxbk, nbk, bk )
 
42
 
 
43
        if (nbk .gt. maxbk) then
 
44
          ! If there wasn't enough space to store bands on first call correct
 
45
          ! the dimensions and repeat the initialisation
 
46
          maxbk = max(nbk,1)
 
47
          call re_alloc(bk,1,3,1,maxbk,name='bk',routine='siesta',
 
48
     .                  copy=.false.)
 
49
          nbk = 0
 
50
          call initbands( maxbk, nbk, bk )
 
51
        endif
 
52
        
 
53
        gamma_bands = (nbk == 0)   ! Flag for use of auxiliary cell
 
54
 
 
55
      end subroutine setup_bands
 
56
 
29
57
      subroutine initbands( maxk, nk, kpoint )
30
58
C *********************************************************************
31
59
C Finds band k-points
111
139
      integer           maxk, nk
112
140
      real(dp)          kpoint(3,maxk)
113
141
      character         paste*30
114
 
      external          paste, redcel, memory
 
142
      external          paste, redcel
115
143
C *********************************************************************
116
144
 
117
145
      character 
404
432
      use parallelsubs, only : GetNodeOrbs
405
433
      use fdf
406
434
      use densematrix
407
 
      use alloc
 
435
      use alloc,        only : re_alloc, de_alloc
408
436
      use files,        only : slabel, label_length
409
437
 
410
438
      implicit          none
438
466
     .  path, temp, wk, Entropy
439
467
 
440
468
C Dynamic arrays
441
 
      real(dp), dimension(:), allocatable, save :: aux
442
 
      integer,  dimension(:), allocatable, save :: muo
 
469
      real(dp), dimension(:), pointer :: aux
 
470
      integer,  dimension(:), pointer :: muo
443
471
 
444
472
      parameter ( eV = 1.d0 / 13.60580d0 )
445
473
      save getD, Dnew, Enew, e1, e2, qk, qtot, temp, wk
473
501
      call re_alloc(Saux,1,nhs,name='Saux',routine='bands')
474
502
      call re_alloc(psi,1,nhs,name='psi',routine='bands')
475
503
      naux  = nuotot*5
476
 
      allocate(aux(naux))
477
 
      call memory('A','D',naux,'bands')
478
 
      allocate(muo(nuotot))
479
 
      call memory('A','I',nuotot,'bands')
 
504
      nullify( aux )
 
505
      call re_alloc( aux, 1, naux, name='aux', routine='bands' )
 
506
      nullify( muo )
 
507
      call re_alloc( muo, 1, nuotot, name='muo', routine='bands' )
480
508
 
481
509
C Check indxuo 
482
510
      do iuo = 1,nuotot
616
644
      endif
617
645
 
618
646
C Free local arrays 
619
 
      call memory('D','I',size(muo),'bands')
620
 
      deallocate(muo)
621
 
      call memory('D','D',size(aux),'bands')
622
 
      deallocate(aux)
 
647
      call de_alloc( muo, name='muo' )
 
648
      call de_alloc( aux, name='aux' )
623
649
 
624
650
C This is the only exit point 
625
651
  999 continue