Révision 8 src/Opt_Geom.f90

Opt_Geom.f90 (revision 8)
18 18
  LOGICAL, INTENT(IN) :: Flag_Opt_Geom
19 19

  
20 20
! As this subroutine is here for debugging, debug=T !
21
  LOGICAL, PARAMETER :: debug=.TRUE.
21
  LOGICAL  :: debug
22 22
  LOGICAL :: Fini
23 23
  LOGICAL, SAVE :: FRST=.TRUE.
24 24

  
......
38 38
  REAL(KREAL), ALLOCATABLE :: Hess_local_inv(:,:) ! used in diis
39 39
  REAL(KREAL) :: NormStep, FactStep, HP
40 40

  
41
  INTERFACE
42
     function valid(string) result (isValid)
43
       CHARACTER(*), intent(in) :: string
44
       logical                  :: isValid
45
     END function VALID
46

  
47
     subroutine Egrad(E,Geom,Grad,NCoord,IGeom,IOpt,GeomCart,FOptGeom,GeomOld,GeomCart_old)
48

  
49
  ! This routines calculates the energy E and the gradient Grad of 
50
  ! a molecule with Geometry Geom (may be in internal coordinates),
51
  ! using for now, either Gaussian or Ext, more general later.
52

  
53
  use Path_module, only : Nat,AtName,Coord,dzdc,indzmat,Nom,Atome,massat,unit, &
54
       prog,NCart,XyzGeomF,IntCoordF,BTransInv, XyzGeomI, &
55
       GeomOld_all,BTransInvF,BTransInv_local,UMatF,UMat_local &
56
       , BprimT,a0,ScanCoord, Coordinate,NPrim,BMat_BakerT,BBT,BBT_inv &
57
      , Order,OrderInv, XPrimitiveF
58

  
59
  ! IntCoordF(NGeomF,NCoord),GeomOld_all(NGeomF,NCoord)
60
  ! allocated in Path.f90
61

  
62
  use Io_module
63

  
64
  ! Energy (calculated if F300K=.F., else estimated)
65
  REAL(KREAL), INTENT (OUT) :: E
66
  ! NCoord: Number of the degrees of freedom
67
  ! IGeom: index of the geometry.
68
  INTEGER(KINT), INTENT (IN) :: NCoord, IGeom, IOpt
69
  ! Geometry at which gradient is calculated (cf Factual also):
70
  REAL(KREAL), INTENT (INOUT) :: Geom(NCoord)
71
  ! Gradient calculated at Geom geometry:
72
  REAL(KREAL), INTENT (OUT) :: Grad(NCoord)
73
  ! Cartesian geometry corresponding to (Internal Geometry) Geom:
74
  REAL(KREAL), INTENT (OUT) :: GeomCart(Nat,3)
75
!!! Optional, just for geometry optimization with Baker coordinates
76
  REAL(KREAL), INTENT (IN), OPTIONAL :: GeomCart_old(Nat,3)
77
  REAL(KREAL), INTENT (INOUT), OPTIONAL :: GeomOld(NCoord)
78
! FOptGeom is a flag indicating if we are doing a geom optimization
79
! it can be omitted so that we use a local flag: Flag_Opt_Geom
80
  LOGICAL,INTENT (IN), OPTIONAL :: FOptGeom
81
! if FOptGeom is given Flag_Opt_Geom=FOptGeom, else Flag_Opt_Geom=F
82
  LOGICAL  :: Flag_Opt_Geom
83

  
84
 END subroutine Egrad
85

  
86
  END INTERFACE
87

  
88
  debug=valid('OptGeom')
89

  
41 90
    E=0.
42 91

  
43
    if (debug) WRITE(*,*) "=================== Geom Optimization =================="
92
    if (debug) Call Header("Entering Geom Optimization")
44 93

  
45 94
     ALLOCATE(GradTmp2(NCoord),GeomTmp2(NCoord),GradTmp(NCoord))
46 95
     ALLOCATE(GradOld(NCoord),GeomOld(NCoord),ZeroVec(NCoord))
......
190 239
           ! GeomCart has INTENT(OUT)
191 240
           ! GeomRef is modified in Egrag_baker, so we should not use GeomOld variable
192 241
           GeomRef=GeomOld
193
           Call EGrad_baker(E,Geom,GradTmp,NCoord,IGeom,IOpt,GeomCart,Flag_Opt_Geom, &
242
           Call EGrad(E,Geom,GradTmp,NCoord,IGeom,IOpt,GeomCart,Flag_Opt_Geom, &
194 243
                GeomRef,GeomCart_old)
195 244
           GeomCart_old=GeomCart
196 245
        ELSE
......
378 427
        END IF
379 428
        
380 429
     DEALLOCATE(GeomCart)
381
        if (debug) WRITE(*,*) "================== Geom Optimization Over================="
430

  
431
    if (debug) Call Header("Geom Optimization Over")
432

  
382 433
   END SUBROUTINE Opt_geom

Formats disponibles : Unified diff