/[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.12 by mlosch, Thu May 3 11:26:05 2018 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 26  c     == global variables == Line 28  c     == global variables ==
28    
29  #include "EEPARAMS.h"  #include "EEPARAMS.h"
30  #include "SIZE.h"  #include "SIZE.h"
31    #if (defined (ALLOW_GENARR2D_CONTROL) || defined (ALLOW_GENARR3D_CONTROL) || defined (ALLOW_GENTIM2D_CONTROL))
32    # include "CTRL_SIZE.h"
33    #endif
34  #include "ctrl.h"  #include "ctrl.h"
35  #include "optim.h"  #include "optim.h"
36    
# Line 41  c     == local variables == Line 46  c     == local variables ==
46        _RL            ff        _RL            ff
47        _RL            dfminFrac        _RL            dfminFrac
48    
49  #if defined (DYNAMIC)  #ifdef DYNAMIC
50        _RL            vv(nn)        _RL            vv(nn)
 #elif defined (USE_POINTER) || (MAX_INDEPEND == 0)  
       _RL            vv  
       pointer (pvv,vv(1))  
51  #else  #else
52        integer nmax        integer nmax
53        parameter( nmax = MAX_INDEPEND )        parameter( nmax = MAX_INDEPEND )
# Line 70  c     == end of interface == Line 72  c     == end of interface ==
72       &                      epsf, epsx, epsg,       &                      epsf, epsx, epsg,
73       &                      nupdate, eps       &                      nupdate, eps
74    
75          namelist /M1QN3/
76         &     coldStart
77    
78  c--   Preset the optimization parameters.  c--   Preset the optimization parameters.
79        optimcycle =  0        optimcycle =  0
80        nvars      =  0        nvars      =  0
# Line 85  c--   Preset the optimization parameters Line 90  c--   Preset the optimization parameters
90        ff         = 0.        ff         = 0.
91  cdfer      expId      = 'MIT_CE_000'  cdfer      expId      = 'MIT_CE_000'
92        yctrlid    = 'MIT_CE_000'        yctrlid    = 'MIT_CE_000'
93          yctrlposunpack      = '.opt'
94          yctrlpospack        = '.opt'
95          ctrlname            = 'ecco_ctrl'
96          costname            = 'ecco_cost'
97          scalname            = ' '
98          maskname            = ' '
99          metaname            = ' '
100          coldStart  = .false.
101    
102        modeldataunit = 14        modeldataunit = 14
103        scrunit1      = 11        scrunit1      = 11
# Line 132  c--   Read optimization parameters from Line 145  c--   Read optimization parameters from
145    
146        rewind( scrunit1 )        rewind( scrunit1 )
147        read(unit = scrunit1, nml = optim)        read(unit = scrunit1, nml = optim)
148          read(unit = scrunit1, nml = m1qn3)
149        close( scrunit1 )        close( scrunit1 )
150        print*, ' OPTIM_READPARMS: Minimization options have been read.'        print*, ' OPTIM_READPARMS: Minimization options have been read.'
151    
# Line 140  c--   Read optimization parameters from Line 154  c--   Read optimization parameters from
154          epsx = eps          epsx = eps
155          epsg = eps          epsg = eps
156        endif        endif
157    c     always force cold start for the 0th cycle
158          if ( optimcycle .eq. 0 ) coldStart=.true.
159    
160        call optim_readdata ( nn, ctrlname, .true., ff, vv)  c     read header from costname rather than ctrlname, because the
161    c     cost function value in costname is what we need, ctrlname only
162    c     contains a valid cost function value for the 0th iteration
163          call optim_readdata ( nn, costname, .true., ff, vv)
164                
165        if ( dfminFrac.lt.0.0 .or. dfminFrac.ge.1.0) then        if ( dfminFrac.lt.0.0 .or. dfminFrac.ge.1.0) then
166         print*, ' OPTIM_READPARMS: dfminFrac = ', dfminFrac,         print*, ' OPTIM_READPARMS: dfminFrac = ', dfminFrac,
# Line 150  c--   Read optimization parameters from Line 169  c--   Read optimization parameters from
169        endif        endif
170        if ( dfminFrac.ne.0.0 ) dfminFrac = 1.0 - dfminFrac        if ( dfminFrac.ne.0.0 ) dfminFrac = 1.0 - dfminFrac
171        if ( fmin.eq.UNSET_RL ) then        if ( fmin.eq.UNSET_RL ) then
172         if ( optimcycle .eq. 0 ) then         if ( coldStart ) then
173  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
174          fmin = dfminFrac*ff          fmin = dfminFrac*ff
175         else         else
# Line 158  c     otherwise we (ab-)use the file ctr Line 177  c     otherwise we (ab-)use the file ctr
177          fmin = ff          fmin = ff
178         endif         endif
179        endif        endif
180        if ( optimcycle.eq.0 ) then        if ( coldStart ) then
181        if ( fmin.le.0.0 ) then         if ( fmin.le.0.0 ) then
182         print*, ' OPTIM_READPARMS: fmin = ', fmin, ' should be > 0'          print '(A,E12.6,A)', ' OPTIM_READPARMS: fmin = ', fmin,
183         stop 'S/R OPTIM_READPARMS: ABNORMAL END'       &       ' should be > 0'
184        endif          stop 'S/R OPTIM_READPARMS: ABNORMAL END'
185        if ( fmin.lt.ff ) then         endif
186         print*, ' OPTIM_READPARMS: fmin = ', fmin,         if ( fmin.gt.ff ) then
187       &      ' should be < ff = ', ff          print '(A,E12.6,A,E12.6)', ' OPTIM_READPARMS: fmin = ', fmin,
188         stop 'S/R OPTIM_READPARMS: ABNORMAL END'       &       ' should be < ff = ', ff
189            stop 'S/R OPTIM_READPARMS: ABNORMAL END'
190           endif
191        endif        endif
192    
193  c--   Do some final printout.  c--   Do some final printout.
# Line 174  c--   Do some final printout. Line 195  c--   Do some final printout.
195        print*, ' OPTIM_READPARMS: Iteration number = ', optimcycle        print*, ' OPTIM_READPARMS: Iteration number = ', optimcycle
196        print*, ' number of control variables       = ', nn        print*, ' number of control variables       = ', nn
197        print*, ' cost function value in ', ctrlname, '  = ', ff        print*, ' cost function value in ', ctrlname, '  = ', ff
198          if ( coldStart ) then
199           print*, ' expected cost function minimum    = ', fmin
200           print*, ' expected cost function decrease   = ', ff-fmin
201          endif
202        print '(a,4a,i4.4)',        print '(a,4a,i4.4)',
203       &        ' Data will be read from the following file: ',       &     '  Data will be read from the following file: ',
204       &     ctrlname,'_',yctrlid(1:10),'.opt', optimcycle       &     ctrlname,'_',yctrlid(1:10),'.opt', optimcycle
205        print*        print*
206    

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

  ViewVC Help
Powered by ViewVC 1.1.22