/[MITgcm]/MITgcm_contrib/mlosch/optim_m1qn3/optim_readparms.F
ViewVC logotype

Diff of /MITgcm_contrib/mlosch/optim_m1qn3/optim_readparms.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3 by mlosch, Fri Apr 27 09:09:39 2012 UTC revision 1.8 by mlosch, Thu May 10 10:25:14 2012 UTC
# Line 41  c     == local variables == Line 41  c     == local variables ==
41        _RL            ff        _RL            ff
42        _RL            dfminFrac        _RL            dfminFrac
43    
44  #if defined (DYNAMIC)  #ifdef DYNAMIC
45        _RL            vv(nn)        _RL            vv(nn)
 #elif defined (USE_POINTER) || (MAX_INDEPEND == 0)  
       _RL            vv  
       pointer (pvv,vv(1))  
46  #else  #else
47        integer nmax        integer nmax
48        parameter( nmax = MAX_INDEPEND )        parameter( nmax = MAX_INDEPEND )
# Line 70  c     == end of interface == Line 67  c     == end of interface ==
67       &                      epsf, epsx, epsg,       &                      epsf, epsx, epsg,
68       &                      nupdate, eps       &                      nupdate, eps
69    
70          namelist /M1QN3/
71         &     coldStart
72    
73  c--   Preset the optimization parameters.  c--   Preset the optimization parameters.
74        optimcycle =  0        optimcycle =  0
75        nvars      =  0        nvars      =  0
# Line 85  c--   Preset the optimization parameters Line 85  c--   Preset the optimization parameters
85        ff         = 0.        ff         = 0.
86  cdfer      expId      = 'MIT_CE_000'  cdfer      expId      = 'MIT_CE_000'
87        yctrlid    = 'MIT_CE_000'        yctrlid    = 'MIT_CE_000'
88          coldStart  = .false.
89    
90        modeldataunit = 14        modeldataunit = 14
91        scrunit1      = 11        scrunit1      = 11
# Line 132  c--   Read optimization parameters from Line 133  c--   Read optimization parameters from
133    
134        rewind( scrunit1 )        rewind( scrunit1 )
135        read(unit = scrunit1, nml = optim)        read(unit = scrunit1, nml = optim)
136          read(unit = scrunit1, nml = m1qn3)
137        close( scrunit1 )        close( scrunit1 )
138        print*, ' OPTIM_READPARMS: Minimization options have been read.'        print*, ' OPTIM_READPARMS: Minimization options have been read.'
139    
# Line 140  c--   Read optimization parameters from Line 142  c--   Read optimization parameters from
142          epsx = eps          epsx = eps
143          epsg = eps          epsg = eps
144        endif        endif
145    c     always force cold start for the 0th cycle
146          if ( optimcycle .eq. 0 ) coldStart=.true.
147    
148        call optim_readdata ( nn, ctrlname, .true., ff, vv)  c     read header from costname rather than ctrlname, because the
149    c     cost function value in costname is what we need, ctrlname only
150    c     contains a valid cost function value for the 0th iteration
151          call optim_readdata ( nn, costname, .true., ff, vv)
152                
153        if ( dfminFrac.lt.0.0 .or. dfminFrac.ge.1.0) then        if ( dfminFrac.lt.0.0 .or. dfminFrac.ge.1.0) then
154         print*, ' OPTIM_READPARMS: dfminFrac = ', dfminFrac,         print*, ' OPTIM_READPARMS: dfminFrac = ', dfminFrac,
# Line 150  c--   Read optimization parameters from Line 157  c--   Read optimization parameters from
157        endif        endif
158        if ( dfminFrac.ne.0.0 ) dfminFrac = 1.0 - dfminFrac        if ( dfminFrac.ne.0.0 ) dfminFrac = 1.0 - dfminFrac
159        if ( fmin.eq.UNSET_RL ) then        if ( fmin.eq.UNSET_RL ) then
160         if ( optimcycle .eq. 0 ) then         if ( coldStart ) then
161  c     only in this case does ff contain the actual cost function value  c     only in this case does ff contain the actual cost function value
162          fmin = dfminFrac*ff          fmin = dfminFrac*ff
163         else         else
# Line 158  c     otherwise we (ab-)use the file ctr Line 165  c     otherwise we (ab-)use the file ctr
165          fmin = ff          fmin = ff
166         endif         endif
167        endif        endif
168        if ( optimcycle.eq.0 ) then        if ( coldStart ) then
169        if ( fmin.le.0.0 ) then         if ( fmin.le.0.0 ) then
170         print*, ' OPTIM_READPARMS: fmin = ', fmin, ' should be > 0'          print '(A,E12.6,A)', ' OPTIM_READPARMS: fmin = ', fmin,
171         stop 'S/R OPTIM_READPARMS: ABNORMAL END'       &       ' should be > 0'
172        endif          stop 'S/R OPTIM_READPARMS: ABNORMAL END'
173        if ( fmin.lt.ff ) then         endif
174         print*, ' OPTIM_READPARMS: fmin = ', fmin,         if ( fmin.gt.ff ) then
175       &      ' should be < ff = ', ff          print '(A,E12.6,A,E12.6)', ' OPTIM_READPARMS: fmin = ', fmin,
176         stop 'S/R OPTIM_READPARMS: ABNORMAL END'       &       ' should be < ff = ', ff
177            stop 'S/R OPTIM_READPARMS: ABNORMAL END'
178           endif
179        endif        endif
180    
181  c--   Do some final printout.  c--   Do some final printout.
# Line 174  c--   Do some final printout. Line 183  c--   Do some final printout.
183        print*, ' OPTIM_READPARMS: Iteration number = ', optimcycle        print*, ' OPTIM_READPARMS: Iteration number = ', optimcycle
184        print*, ' number of control variables       = ', nn        print*, ' number of control variables       = ', nn
185        print*, ' cost function value in ', ctrlname, '  = ', ff        print*, ' cost function value in ', ctrlname, '  = ', ff
186          if ( coldStart ) then
187           print*, ' expected cost function minimum    = ', fmin
188           print*, ' expected cost function decrease   = ', ff-fmin
189          endif
190        print '(a,4a,i4.4)',        print '(a,4a,i4.4)',
191       &        ' Data will be read from the following file: ',       &        ' Data will be read from the following file: ',
192       &     ctrlname,'_',yctrlid(1:10),'.opt', optimcycle       &     ctrlname,'_',yctrlid(1:10),'.opt', optimcycle

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.22