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 ) |
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 |
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 |
|
yctrlposunpack = '.opt' |
89 |
|
yctrlpospack = '.opt' |
90 |
|
ctrlname = 'ecco_ctrl' |
91 |
|
costname = 'ecco_cost' |
92 |
|
scalname = ' ' |
93 |
|
maskname = ' ' |
94 |
|
metaname = ' ' |
95 |
|
coldStart = .false. |
96 |
|
|
97 |
modeldataunit = 14 |
modeldataunit = 14 |
98 |
scrunit1 = 11 |
scrunit1 = 11 |
140 |
|
|
141 |
rewind( scrunit1 ) |
rewind( scrunit1 ) |
142 |
read(unit = scrunit1, nml = optim) |
read(unit = scrunit1, nml = optim) |
143 |
|
read(unit = scrunit1, nml = m1qn3) |
144 |
close( scrunit1 ) |
close( scrunit1 ) |
145 |
print*, ' OPTIM_READPARMS: Minimization options have been read.' |
print*, ' OPTIM_READPARMS: Minimization options have been read.' |
146 |
|
|
149 |
epsx = eps |
epsx = eps |
150 |
epsg = eps |
epsg = eps |
151 |
endif |
endif |
152 |
|
c always force cold start for the 0th cycle |
153 |
|
if ( optimcycle .eq. 0 ) coldStart=.true. |
154 |
|
|
155 |
call optim_readdata ( nn, ctrlname, .true., ff, vv) |
c read header from costname rather than ctrlname, because the |
156 |
|
c cost function value in costname is what we need, ctrlname only |
157 |
|
c contains a valid cost function value for the 0th iteration |
158 |
|
call optim_readdata ( nn, costname, .true., ff, vv) |
159 |
|
|
160 |
if ( dfminFrac.lt.0.0 .or. dfminFrac.ge.1.0) then |
if ( dfminFrac.lt.0.0 .or. dfminFrac.ge.1.0) then |
161 |
print*, ' OPTIM_READPARMS: dfminFrac = ', dfminFrac, |
print*, ' OPTIM_READPARMS: dfminFrac = ', dfminFrac, |
164 |
endif |
endif |
165 |
if ( dfminFrac.ne.0.0 ) dfminFrac = 1.0 - dfminFrac |
if ( dfminFrac.ne.0.0 ) dfminFrac = 1.0 - dfminFrac |
166 |
if ( fmin.eq.UNSET_RL ) then |
if ( fmin.eq.UNSET_RL ) then |
167 |
if ( optimcycle .eq. 0 ) then |
if ( coldStart ) then |
168 |
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 |
169 |
fmin = dfminFrac*ff |
fmin = dfminFrac*ff |
170 |
else |
else |
172 |
fmin = ff |
fmin = ff |
173 |
endif |
endif |
174 |
endif |
endif |
175 |
if ( optimcycle.eq.0 ) then |
if ( coldStart ) then |
176 |
if ( fmin.le.0.0 ) then |
if ( fmin.le.0.0 ) then |
177 |
print*, ' OPTIM_READPARMS: fmin = ', fmin, ' should be > 0' |
print '(A,E12.6,A)', ' OPTIM_READPARMS: fmin = ', fmin, |
178 |
|
& ' should be > 0' |
179 |
stop 'S/R OPTIM_READPARMS: ABNORMAL END' |
stop 'S/R OPTIM_READPARMS: ABNORMAL END' |
180 |
endif |
endif |
181 |
if ( fmin.lt.ff ) then |
if ( fmin.gt.ff ) then |
182 |
print*, ' OPTIM_READPARMS: fmin = ', fmin, |
print '(A,E12.6,A,E12.6)', ' OPTIM_READPARMS: fmin = ', fmin, |
183 |
& ' should be < ff = ', ff |
& ' should be < ff = ', ff |
184 |
stop 'S/R OPTIM_READPARMS: ABNORMAL END' |
stop 'S/R OPTIM_READPARMS: ABNORMAL END' |
185 |
endif |
endif |
190 |
print*, ' OPTIM_READPARMS: Iteration number = ', optimcycle |
print*, ' OPTIM_READPARMS: Iteration number = ', optimcycle |
191 |
print*, ' number of control variables = ', nn |
print*, ' number of control variables = ', nn |
192 |
print*, ' cost function value in ', ctrlname, ' = ', ff |
print*, ' cost function value in ', ctrlname, ' = ', ff |
193 |
|
if ( coldStart ) then |
194 |
|
print*, ' expected cost function minimum = ', fmin |
195 |
|
print*, ' expected cost function decrease = ', ff-fmin |
196 |
|
endif |
197 |
print '(a,4a,i4.4)', |
print '(a,4a,i4.4)', |
198 |
& ' Data will be read from the following file: ', |
& ' Data will be read from the following file: ', |
199 |
& ctrlname,'_',yctrlid(1:10),'.opt', optimcycle |
& ctrlname,'_',yctrlid(1:10),'.opt', optimcycle |