root / src / egrad_ext.f90 @ 3
Historique | Voir | Annoter | Télécharger (2,34 ko)
| 1 | 1 | pfleura2 | subroutine egrad_ext(e,geomcart,gradcart) |
|---|---|---|---|
| 2 | 1 | pfleura2 | |
| 3 | 1 | pfleura2 | ! This routines calculates the energy and the gradient of |
| 4 | 1 | pfleura2 | ! a molecule, using an external code |
| 5 | 1 | pfleura2 | |
| 6 | 1 | pfleura2 | |
| 7 | 1 | pfleura2 | use Path_module, only : Nat, renum,Order,OrderInv,AtName, Coord, dzdc, indzmat,Nom,Atome, massat, unit,ProgExe |
| 8 | 1 | pfleura2 | use Io_module |
| 9 | 1 | pfleura2 | |
| 10 | 1 | pfleura2 | ! |
| 11 | 1 | pfleura2 | IMPLICIT NONE |
| 12 | 1 | pfleura2 | |
| 13 | 1 | pfleura2 | ! Energy (calculated if F300K=.F., else estimated) |
| 14 | 1 | pfleura2 | REAL(KREAL), INTENT (OUT) :: e |
| 15 | 1 | pfleura2 | ! Nb degree of freedom |
| 16 | 1 | pfleura2 | ! Geometry at which gradient is calculated (cf FActual also) |
| 17 | 1 | pfleura2 | REAL(KREAL), INTENT (IN) :: geomcart(Nat,3) |
| 18 | 1 | pfleura2 | ! Gradient calculated at Geom geometry |
| 19 | 1 | pfleura2 | REAL(KREAL), INTENT (OUT) :: gradcart(3*Nat) |
| 20 | 1 | pfleura2 | |
| 21 | 1 | pfleura2 | ! ====================================================================== |
| 22 | 1 | pfleura2 | |
| 23 | 1 | pfleura2 | |
| 24 | 1 | pfleura2 | logical :: debug |
| 25 | 1 | pfleura2 | |
| 26 | 2 | pfleura2 | REAL(KREAL) :: Pi |
| 27 | 1 | pfleura2 | |
| 28 | 2 | pfleura2 | INTEGER(KINT) :: iat, i, n3at |
| 29 | 1 | pfleura2 | |
| 30 | 1 | pfleura2 | ! |
| 31 | 1 | pfleura2 | CHARACTER(132) :: FileIn,FileOut |
| 32 | 1 | pfleura2 | |
| 33 | 2 | pfleura2 | CHARACTER(VLCHARS), SAVE :: RunCommand |
| 34 | 2 | pfleura2 | ! LOGICAL, SAVE :: FCopyRstrt=.False., FOrderChecked=.False. |
| 35 | 1 | pfleura2 | |
| 36 | 1 | pfleura2 | |
| 37 | 1 | pfleura2 | |
| 38 | 1 | pfleura2 | ! ====================================================================== |
| 39 | 1 | pfleura2 | |
| 40 | 1 | pfleura2 | LOGICAL, EXTERNAL :: valid |
| 41 | 1 | pfleura2 | |
| 42 | 1 | pfleura2 | ! ====================================================================== |
| 43 | 1 | pfleura2 | |
| 44 | 1 | pfleura2 | |
| 45 | 1 | pfleura2 | Pi=dacos(-1.0d0) |
| 46 | 1 | pfleura2 | n3at=3*nat |
| 47 | 1 | pfleura2 | |
| 48 | 1 | pfleura2 | debug=valid('EGRAD')
|
| 49 | 1 | pfleura2 | if (debug) WRITE(*,*) '================ Entering Egrad_ext ====================' |
| 50 | 1 | pfleura2 | |
| 51 | 1 | pfleura2 | RunCommand=Trim(Adjustl(ProgExe)) |
| 52 | 1 | pfleura2 | FileIn=Trim(CalcName) // Trim(ISuffix) |
| 53 | 1 | pfleura2 | FileOut=Trim(CalcName) // Trim(OSuffix) |
| 54 | 1 | pfleura2 | |
| 55 | 1 | pfleura2 | IF (DEBUG) WRITE(*,*)'RunCommand:',TRIM(RunCommand) |
| 56 | 1 | pfleura2 | |
| 57 | 1 | pfleura2 | ! we create the input file |
| 58 | 1 | pfleura2 | |
| 59 | 1 | pfleura2 | OPEN(IOTMP,File=FileIn) |
| 60 | 1 | pfleura2 | |
| 61 | 1 | pfleura2 | WRITE(IOTMP,'(1X,I10)') NAt |
| 62 | 1 | pfleura2 | WRITE(IOTMP,'(1X,A)') Coord |
| 63 | 1 | pfleura2 | |
| 64 | 1 | pfleura2 | DO I=1,Nat |
| 65 | 1 | pfleura2 | If (renum) THEN |
| 66 | 1 | pfleura2 | Iat=Order(I) |
| 67 | 1 | pfleura2 | WRITE(IOTMP,'(1X,A10,3(1X,F15.8),A)') Trim(AtName(I)),GeomCart(Iat,:) |
| 68 | 1 | pfleura2 | ELSE |
| 69 | 1 | pfleura2 | Iat=OrderInv(I) |
| 70 | 1 | pfleura2 | WRITE(IOTMP,'(1X,A10,3(1X,F15.8),A)') Trim(AtName(Iat)),GeomCart(I,:) |
| 71 | 1 | pfleura2 | END IF |
| 72 | 1 | pfleura2 | END DO |
| 73 | 1 | pfleura2 | |
| 74 | 1 | pfleura2 | call system(RunCommand) |
| 75 | 1 | pfleura2 | |
| 76 | 1 | pfleura2 | if (debug) WRITE(*,*) 'DBG EGRAD, back from calculation' |
| 77 | 1 | pfleura2 | |
| 78 | 1 | pfleura2 | OPEN(IOTMP,FILE=FileOut, STATUS='old') |
| 79 | 1 | pfleura2 | ! We first search for the forces |
| 80 | 1 | pfleura2 | READ(IOTMP,*) e |
| 81 | 1 | pfleura2 | DO I=1,Nat |
| 82 | 1 | pfleura2 | Iat=I |
| 83 | 1 | pfleura2 | IF (renum) Iat=Order(I) |
| 84 | 1 | pfleura2 | READ(IOTMP,*) GradCart(3*Iat-2:3*Iat) |
| 85 | 1 | pfleura2 | END DO |
| 86 | 1 | pfleura2 | |
| 87 | 1 | pfleura2 | CLOSE(IOTMP) |
| 88 | 1 | pfleura2 | |
| 89 | 1 | pfleura2 | |
| 90 | 1 | pfleura2 | if (debug) WRITE(*,*) '================ Egrad_ext Over ====================' |
| 91 | 1 | pfleura2 | |
| 92 | 1 | pfleura2 | RETURN |
| 93 | 1 | pfleura2 | |
| 94 | 2 | pfleura2 | !999 CONTINUE |
| 95 | 2 | pfleura2 | ! if (.NOT.Ftmp) WRITE(*,*) 'We should not be here !!!!' |
| 96 | 2 | pfleura2 | ! STOP |
| 97 | 1 | pfleura2 | ! ====================================================================== |
| 98 | 1 | pfleura2 | end subroutine egrad_ext |