Statistiques
| Révision :

root / src / Space.f90

Historique | Voir | Annoter | Télécharger (3,78 ko)

1
!C
2
!C  SPACE SIMPLY LOADS THE CURRENT VALUES OF Geom AND GRAD INTO
3
!C  THE ARRAYS GeomSet AND GradSet
4
!C
5
      SUBROUTINE SPACE(MRESET,MSET,Geom,GRAD,HEAT,NVAR,GeomSet,GradSet,ESET,FRST)
6
!----------------------------------------------------------------------
7
! This routine was adapted from the public domain mopac6 diis.f 
8
!  source file (c) 2009, Stewart Computational Chemistry.
9
!  <http://www.openmopac.net/Downloads/Downloads.html>
10
!
11
!----------------------------------------------------------------------
12
!  Copyright 2003-2014 Ecole Normale Supérieure de Lyon, 
13
!  Centre National de la Recherche Scientifique,
14
!  Université Claude Bernard Lyon 1. All rights reserved.
15
!
16
!  This work is registered with the Agency for the Protection of Programs 
17
!  as IDDN.FR.001.100009.000.S.P.2014.000.30625
18
!
19
!  Authors: P. Fleurat-Lessard, P. Dayal
20
!  Contact: optnpath@gmail.com
21
!
22
! This file is part of "Opt'n Path".
23
!
24
!  "Opt'n Path" is free software: you can redistribute it and/or modify
25
!  it under the terms of the GNU Affero General Public License as
26
!  published by the Free Software Foundation, either version 3 of the License,
27
!  or (at your option) any later version.
28
!
29
!  "Opt'n Path" is distributed in the hope that it will be useful,
30
!  but WITHOUT ANY WARRANTY; without even the implied warranty of
31
!
32
!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33
!  GNU Affero General Public License for more details.
34
!
35
!  You should have received a copy of the GNU Affero General Public License
36
!  along with "Opt'n Path". If not, see <http://www.gnu.org/licenses/>.
37
!
38
! Contact The Office of Technology Licensing, valorisation@ens-lyon.fr,
39
! for commercial licensing opportunities.
40
!----------------------------------------------------------------------
41

    
42
      IMPLICIT NONE
43
      integer, parameter :: KINT = kind(1)
44
      integer, parameter :: KREAL = kind(1.0d0)
45

    
46
!      INCLUDE 'SIZES'
47

    
48
 !MSET=mth iteration, NVAR=NCOORD, MRESET=Maximum no. of iterations. 
49
      INTEGER(KINT) :: NVAR, MRESET, MSET 
50
 !Geom=geometry with NVAR coordinates. GRAD=gradients.
51
      REAL(KREAL) :: Geom(NVAR), GRAD(NVAR)
52
      REAL(KREAL) :: Heat
53
      LOGICAL :: FRST, Print=.TRUE.
54
 ! GeomSet, GradSet : a long array to store
55
      REAL(KREAL) :: GeomSet(MRESET*NVAR), GradSet(MRESET*NVAR), ESET(MRESET)
56
        ! Geom and GRAD for all iterations.
57

    
58
      INTEGER(KINT) :: I, K, NMK, MI, NI
59
      INTEGER(KINT), SAVE :: NRESET
60
!C
61
!C     UPDATE PARAMETER AND GRADIENT SUBSPACE
62
!C
63
      IF (PRINT)  WRITE(*,'(/,''       BEGIN SPACE  '')')
64
      IF(FRST)THEN
65
         NRESET=MIN(NVAR/2,MRESET)
66
             IF (NVAR .LT. 5 ) THEN ! This condition is imposed for small NVAR,
67
             ! particularly if NVAR=NCOORD is equal to 2 or 3.
68
                NRESET = NVAR-1
69
           END IF
70
         FRST=.FALSE.
71
         MSET=0
72
      ENDIF
73
!C
74
      !IF (PRINT)  WRITE(*,'(/,''       SPACE 1  '')')
75
        ! purging the very first Geom and GRAD.
76
        if (print) WRITE(*,*) "DBG Space MSET, NRESET",MSET,NRESET
77
       IF (MSET .EQ. NRESET) THEN
78
         DO 10 I=1,MSET-1
79
            MI = NVAR*(I-1)
80
            NI = NVAR*I
81
            ESET(I)=ESET(I+1)
82
            DO 10 K=1,NVAR
83
               GeomSet(MI+K) = GeomSet(NI+K)
84
   10    GradSet(MI+K) = GradSet(NI+K)
85
            MSET=NRESET-1
86
       ENDIF
87
!C
88
!C     STORE THE CURRENT POINT
89
!C
90
      !IF (PRINT)  WRITE(*,'(/,''       SPACE 2  '')')
91
        ! NVAR =  NCOORD
92
      DO  K=1,NVAR
93
         NMK = NVAR*MSET+K ! MSET corresponds mth iteration.
94
         IF (PRINT)  WRITE(*,*) 'K,NMK,MSET,NVAR',K,NMK,MSET,NVAR, &
95
              SIZE(GeomSet), SIZE(GradSet),SIZE(Geom),SIZE(GRAD)
96
         GeomSet(NMK) = Geom(K)
97
         GradSet(NMK) = GRAD(K)
98
      END DO
99
      MSET=MSET+1
100
      ESET(MSET)=HEAT
101

    
102
      IF (PRINT) WRITE (*,*) "MSET=", MSET
103
      IF (PRINT)  WRITE(*,'(/,''       END SPACE   '')')
104
!C
105
      RETURN
106
      END