/[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.4 by mlosch, Fri Apr 27 09:45:03 2012 UTC revision 1.10 by mlosch, Tue Jun 2 16:17:08 2015 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2  C $Name$  C $Name$
3    
4  c     Include ECCO_CPPOPTIONS because the ecco_ctrl,cost files  C     ECCO_CPPOPTIONS used to affect maxcvars and defined ALLOW_OBCS?_CONTROL
5  c     have headers with options for OBCS masks.  C#include "ECCO_CPPOPTIONS.h"
6  #include "ECCO_CPPOPTIONS.h"  C     now:
7    C     CTRL_OPTIONS affects maxcvars and may define ALLOW_OBCS?_CONTROL
8    #include "CTRL_OPTIONS.h"
9    
10        subroutine optim_readparms(        subroutine optim_readparms(
11       O                    nn, ff       O                    nn, ff
# Line 41  c     == local variables == Line 43  c     == local variables ==
43        _RL            ff        _RL            ff
44        _RL            dfminFrac        _RL            dfminFrac
45    
46  #if defined (DYNAMIC)  #ifdef DYNAMIC
47        _RL            vv(nn)        _RL            vv(nn)
 #elif defined (USE_POINTER) || (MAX_INDEPEND == 0)  
       _RL            vv  
       pointer (pvv,vv(1))  
48  #else  #else
49        integer nmax        integer nmax
50        parameter( nmax = MAX_INDEPEND )        parameter( nmax = MAX_INDEPEND )
# Line 70  c     == end of interface == Line 69  c     == end of interface ==
69       &                      epsf, epsx, epsg,       &                      epsf, epsx, epsg,
70       &                      nupdate, eps       &                      nupdate, eps
71    
72          namelist /M1QN3/
73         &     coldStart
74    
75  c--   Preset the optimization parameters.  c--   Preset the optimization parameters.
76        optimcycle =  0        optimcycle =  0
77        nvars      =  0        nvars      =  0
# Line 85  c--   Preset the optimization parameters Line 87  c--   Preset the optimization parameters
87        ff         = 0.        ff         = 0.
88  cdfer      expId      = 'MIT_CE_000'  cdfer      expId      = 'MIT_CE_000'
89        yctrlid    = 'MIT_CE_000'        yctrlid    = 'MIT_CE_000'
90          yctrlposunpack      = '.opt'
91          yctrlpospack        = '.opt'
92          ctrlname            = 'ecco_ctrl'
93          costname            = 'ecco_cost'
94          scalname            = ' '
95          maskname            = ' '
96          metaname            = ' '
97          coldStart  = .false.
98    
99        modeldataunit = 14        modeldataunit = 14
100        scrunit1      = 11        scrunit1      = 11
# Line 132  c--   Read optimization parameters from Line 142  c--   Read optimization parameters from
142    
143        rewind( scrunit1 )        rewind( scrunit1 )
144        read(unit = scrunit1, nml = optim)        read(unit = scrunit1, nml = optim)
145          read(unit = scrunit1, nml = m1qn3)
146        close( scrunit1 )        close( scrunit1 )
147        print*, ' OPTIM_READPARMS: Minimization options have been read.'        print*, ' OPTIM_READPARMS: Minimization options have been read.'
148    
# Line 140  c--   Read optimization parameters from Line 151  c--   Read optimization parameters from
151          epsx = eps          epsx = eps
152          epsg = eps          epsg = eps
153        endif        endif
154    c     always force cold start for the 0th cycle
155          if ( optimcycle .eq. 0 ) coldStart=.true.
156    
157        call optim_readdata ( nn, ctrlname, .true., ff, vv)  c     read header from costname rather than ctrlname, because the
158    c     cost function value in costname is what we need, ctrlname only
159    c     contains a valid cost function value for the 0th iteration
160          call optim_readdata ( nn, costname, .true., ff, vv)
161                
162        if ( dfminFrac.lt.0.0 .or. dfminFrac.ge.1.0) then        if ( dfminFrac.lt.0.0 .or. dfminFrac.ge.1.0) then
163         print*, ' OPTIM_READPARMS: dfminFrac = ', dfminFrac,         print*, ' OPTIM_READPARMS: dfminFrac = ', dfminFrac,
# Line 150  c--   Read optimization parameters from Line 166  c--   Read optimization parameters from
166        endif        endif
167        if ( dfminFrac.ne.0.0 ) dfminFrac = 1.0 - dfminFrac        if ( dfminFrac.ne.0.0 ) dfminFrac = 1.0 - dfminFrac
168        if ( fmin.eq.UNSET_RL ) then        if ( fmin.eq.UNSET_RL ) then
169         if ( optimcycle .eq. 0 ) then         if ( coldStart ) then
170  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
171          fmin = dfminFrac*ff          fmin = dfminFrac*ff
172         else         else
# Line 158  c     otherwise we (ab-)use the file ctr Line 174  c     otherwise we (ab-)use the file ctr
174          fmin = ff          fmin = ff
175         endif         endif
176        endif        endif
177        if ( optimcycle.eq.0 ) then        if ( coldStart ) then
178         if ( fmin.le.0.0 ) then         if ( fmin.le.0.0 ) then
179          print*, ' OPTIM_READPARMS: fmin = ', fmin, ' should be > 0'          print '(A,E12.6,A)', ' OPTIM_READPARMS: fmin = ', fmin,
180         &       ' should be > 0'
181          stop 'S/R OPTIM_READPARMS: ABNORMAL END'          stop 'S/R OPTIM_READPARMS: ABNORMAL END'
182         endif         endif
183         if ( fmin.lt.ff ) then         if ( fmin.gt.ff ) then
184          print*, ' OPTIM_READPARMS: fmin = ', fmin,          print '(A,E12.6,A,E12.6)', ' OPTIM_READPARMS: fmin = ', fmin,
185       &       ' should be < ff = ', ff       &       ' should be < ff = ', ff
186          stop 'S/R OPTIM_READPARMS: ABNORMAL END'          stop 'S/R OPTIM_READPARMS: ABNORMAL END'
187         endif         endif
# Line 175  c--   Do some final printout. Line 192  c--   Do some final printout.
192        print*, ' OPTIM_READPARMS: Iteration number = ', optimcycle        print*, ' OPTIM_READPARMS: Iteration number = ', optimcycle
193        print*, ' number of control variables       = ', nn        print*, ' number of control variables       = ', nn
194        print*, ' cost function value in ', ctrlname, '  = ', ff        print*, ' cost function value in ', ctrlname, '  = ', ff
195          if ( coldStart ) then
196           print*, ' expected cost function minimum    = ', fmin
197           print*, ' expected cost function decrease   = ', ff-fmin
198          endif
199        print '(a,4a,i4.4)',        print '(a,4a,i4.4)',
200       &        ' Data will be read from the following file: ',       &        ' Data will be read from the following file: ',
201       &     ctrlname,'_',yctrlid(1:10),'.opt', optimcycle       &     ctrlname,'_',yctrlid(1:10),'.opt', optimcycle

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.22