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

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

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

revision 1.3 by mlosch, Mon May 7 12:07:09 2012 UTC revision 1.5 by mlosch, Thu May 10 10:25:14 2012 UTC
# Line 57  c     == local variables == Line 57  c     == local variables ==
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
# Line 138  c     initialise the dummy arguments tha Line 138  c     initialise the dummy arguments tha
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        if ( optimcycle .eq. 0 ) coldStart=.true.  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        if ( coldStart ) then        if ( coldStart ) then
159  c--   cold start  c--   cold start
160         print *, ' OPTIM_SUB: cold start, optimcycle =', optimcycle         print *, ' OPTIM_SUB: cold start, optimcycle =', optimcycle
# Line 148  c     this variable is the only one of t Line 163  c     this variable is the only one of t
163  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
164  c     clean start  c     clean start
165         reentry  = 0         reentry  = 0
166  c     ff has be read in optim_readparms, so we do not read it here again  c     compute expected decrease of cost function from objf and fmin;
167         objf = ff  c     this value is only used for a cold start of m1qn3_offline, for a
168         df1  = objf-fmin  c     warm start df1 is overwritten with data from a restart file
169           df1=objf-fmin
170           if ( df1 .le. 0. ) then
171            print *, ' OPTIM_SUB: df1 = objf-fmin = ', df1,
172         &       ' but should be > 0.'
173            stop 'ABNORMAL in S/R OPTIM_SUB'
174           endif
175    
176  c     open output file for m1qn3  c     open output file for m1qn3
177         open(io,file=fname_m1qn3,status='unknown')         open(io,file=fname_m1qn3,status='unknown')
178        else        else
# Line 164  c     requires restoring the state of m1 Line 186  c     requires restoring the state of m1
186  c     re-open output file for m1qn3  c     re-open output file for m1qn3
187         open(io,file=fname_m1qn3,status='old',position='append')         open(io,file=fname_m1qn3,status='old',position='append')
188        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  
189    
190  c--   call the minimizer, a slightly modified version of m1qn3 v3.3  c--   call the minimizer, a slightly modified version of m1qn3 v3.3
191  c     (Gilbert & Lemarechal, 1989), downloaded in April 2012.  c     (Gilbert & Lemarechal, 1989), downloaded in April 2012.

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

  ViewVC Help
Powered by ViewVC 1.1.22