| 57 |
_RL adxx(nmax) |
_RL adxx(nmax) |
| 58 |
#endif |
#endif |
| 59 |
|
|
| 60 |
logical coldStart |
CML logical coldStart |
| 61 |
c formal parameters of m1qn3 |
c formal parameters of m1qn3 |
| 62 |
integer reverse |
integer reverse |
| 63 |
integer impres,imode(3),omode,niter,nsim,iz(5),indic |
integer impres,imode(3),omode,niter,nsim,iz(5),indic |
| 138 |
rzs(1)=UNSET_RS |
rzs(1)=UNSET_RS |
| 139 |
dzs(1)=UNSET_RL |
dzs(1)=UNSET_RL |
| 140 |
|
|
| 141 |
coldStart=.false. |
c-- first read the model output into xx, adxx, and cost function |
| 142 |
|
c value into objf |
| 143 |
|
do i = 1,nn |
| 144 |
|
xx(i) = 0. |
| 145 |
|
adxx(i) = 0. |
| 146 |
|
enddo |
| 147 |
|
c |
| 148 |
|
print *, ' OPTIM_SUB: read model state' |
| 149 |
|
call optim_readdata( nn, ctrlname, .false., objf, xx ) |
| 150 |
|
call optim_readdata( nn, costname, .false., objf, adxx ) |
| 151 |
|
print *, ' OPTIM_SUB after reading ', |
| 152 |
|
& ctrlname, ' and ', costname, ':' |
| 153 |
|
print *, ' OPTIM_SUB nn = ', nn |
| 154 |
|
print *, ' OPTIM_SUB objf = ', objf |
| 155 |
|
print *, ' OPTIM_SUB xx(1) = ', xx(1) |
| 156 |
|
print *, ' OPTIM_SUB adxx(1) = ', adxx(1) |
| 157 |
|
|
| 158 |
|
c compute expected decrease of cost function from objf and fmin; |
| 159 |
|
c this value is only used for a cold start of m1qn3_offline, for a |
| 160 |
|
c warm start df1 is overwritten with data from a restart file |
| 161 |
|
df1=objf-fmin |
| 162 |
|
if ( df1 .le. 0. ) then |
| 163 |
|
print *, ' OPTIM_SUB: df1 = objf-fmin = ', df1, ' should be > 0.' |
| 164 |
|
stop 'ABNORMAL in S/R OPTIM_SUB' |
| 165 |
|
endif |
| 166 |
|
|
| 167 |
|
c global variable coldStart is set in s/r optim_readparms |
| 168 |
|
c the default is false, always set it to true for the 0th cycle |
| 169 |
if ( optimcycle .eq. 0 ) coldStart=.true. |
if ( optimcycle .eq. 0 ) coldStart=.true. |
| 170 |
if ( coldStart ) then |
if ( coldStart ) then |
| 171 |
c-- cold start |
c-- cold start |
| 175 |
c that needs to be initialized here to make sure that we have a |
c that needs to be initialized here to make sure that we have a |
| 176 |
c clean start |
c clean start |
| 177 |
reentry = 0 |
reentry = 0 |
|
c ff has be read in optim_readparms, so we do not read it here again |
|
|
objf = ff |
|
|
df1 = objf-fmin |
|
| 178 |
c open output file for m1qn3 |
c open output file for m1qn3 |
| 179 |
open(io,file=fname_m1qn3,status='unknown') |
open(io,file=fname_m1qn3,status='unknown') |
| 180 |
else |
else |
| 188 |
c re-open output file for m1qn3 |
c re-open output file for m1qn3 |
| 189 |
open(io,file=fname_m1qn3,status='old',position='append') |
open(io,file=fname_m1qn3,status='old',position='append') |
| 190 |
endif |
endif |
|
c-- read the model output into xx,adxx |
|
|
if ( indic .eq. 4 ) then |
|
|
do i = 1,nn |
|
|
xx(i) = 0. |
|
|
adxx(i) = 0. |
|
|
enddo |
|
|
c |
|
|
print *, ' OPTIM_SUB: read model state' |
|
|
call optim_readdata( nn, ctrlname, .false., objf, xx ) |
|
|
call optim_readdata( nn, costname, .false., objf, adxx ) |
|
|
print *, ' OPTIM_SUB after reading nn, objf = ', nn, objf, |
|
|
& xx(1), adxx(1) |
|
|
else |
|
|
print *, ' OPTIM_SUB: indic = ', indic, ' is not possible' |
|
|
stop 'ABNORMAL in S/R OPTIM_SUB' |
|
|
endif |
|
| 191 |
|
|
| 192 |
c-- call the minimizer, a slightly modified version of m1qn3 v3.3 |
c-- call the minimizer, a slightly modified version of m1qn3 v3.3 |
| 193 |
c (Gilbert & Lemarechal, 1989), downloaded in April 2012. |
c (Gilbert & Lemarechal, 1989), downloaded in April 2012. |