| 1 |
mlosch |
1.2 |
C $Header: /u/gcmpack/MITgcm_contrib/mlosch/optim_m1qn3/optim_store_m1qn3.F,v 1.1 2012/04/26 11:10:06 mlosch Exp $ |
| 2 |
|
|
C $Name: $ |
| 3 |
mlosch |
1.1 |
|
| 4 |
|
|
subroutine optim_store_m1qn3( |
| 5 |
|
|
I ndz, |
| 6 |
|
|
U iz,dz,niter,nsim,epsg,df1, |
| 7 |
|
|
I optimcycle, |
| 8 |
|
|
I store) |
| 9 |
|
|
c |
| 10 |
|
|
c subroutine optim_store_m1qn3 |
| 11 |
|
|
c |
| 12 |
|
|
c Depending on the parameter store, store or restore the state of |
| 13 |
|
|
c m1qn3. The communication is mostly via common blocks in order |
| 14 |
|
|
c to keep the changes to m1qn3 to a minimum. Only iz and dz are passed |
| 15 |
|
|
c as arguments |
| 16 |
|
|
c |
| 17 |
|
|
implicit none |
| 18 |
|
|
c-- global variables |
| 19 |
|
|
#include "m1qn3_common.h" |
| 20 |
|
|
#include "m1qn3a_common.h" |
| 21 |
|
|
#include "mlis3_common.h" |
| 22 |
|
|
c-- routine arguments |
| 23 |
|
|
integer ndz |
| 24 |
|
|
integer iz(5) |
| 25 |
|
|
_RL dz(ndz) |
| 26 |
|
|
integer niter, nsim |
| 27 |
|
|
_RL epsg,df1 |
| 28 |
|
|
integer optimcycle |
| 29 |
|
|
logical store |
| 30 |
|
|
|
| 31 |
|
|
c-- local variables |
| 32 |
|
|
integer io, k |
| 33 |
|
|
character*(14) fname |
| 34 |
|
|
|
| 35 |
|
|
c-- routine body |
| 36 |
|
|
fname = ' ' |
| 37 |
|
|
io = 99 |
| 38 |
|
|
print *, 'ml-optimcycle', optimcycle |
| 39 |
|
|
if ( store ) then |
| 40 |
|
|
write(fname,'(A,I4.4)') 'OPWARM.opt',optimcycle+1 |
| 41 |
|
|
c |
| 42 |
|
|
print * |
| 43 |
|
|
print *, ' OPTIM_STORE_M1QN3: saving the state of m1qn3 in ', |
| 44 |
|
|
& fname |
| 45 |
|
|
print * |
| 46 |
|
|
c |
| 47 |
|
|
open(io,file=fname,form='unformatted',status='unknown') |
| 48 |
|
|
write(io) niter,nsim |
| 49 |
|
|
write(io) iz |
| 50 |
|
|
write(io) (dz(k),k=1,ndz) |
| 51 |
|
|
c some extra info |
| 52 |
|
|
write(io) epsg,df1 |
| 53 |
|
|
c m1qn3_common.h |
| 54 |
|
|
write(io) inmemo,id,igg,idiag,iaux,ialpha,iybar,isbar,reentry |
| 55 |
|
|
c m1qn3a_common.h |
| 56 |
|
|
write(io) cold,warm,itmax,isim,jcour,d1,t,tmin,tmax, |
| 57 |
|
|
& gnorm,gnorms,eps1,ff,dk |
| 58 |
|
|
c mlis3_common.h |
| 59 |
mlosch |
1.2 |
write(io) tesf,tesd,fa,fpa,fn,barmin,barmul,barmax,barr, |
| 60 |
|
|
& tg,fg,fpg,td,ta,d2,fp,ffn,fd,fpd,z,test,gauche,droite |
| 61 |
mlosch |
1.1 |
else |
| 62 |
|
|
write(fname,'(A,I4.4)') 'OPWARM.opt',optimcycle |
| 63 |
|
|
c |
| 64 |
|
|
print * |
| 65 |
|
|
print *, ' OPTIM_STORE_M1QN3: restoring the state'// |
| 66 |
|
|
& ' of m1qn3 from ', fname |
| 67 |
|
|
print * |
| 68 |
|
|
c |
| 69 |
|
|
open(io,file=fname,form='unformatted',status='old') |
| 70 |
|
|
read(io) niter,nsim |
| 71 |
|
|
read (io) iz |
| 72 |
|
|
read (io) (dz(k),k=1,ndz) |
| 73 |
|
|
c some extra info |
| 74 |
|
|
read (io) epsg,df1 |
| 75 |
|
|
c m1qn3_common.h |
| 76 |
|
|
read (io) inmemo,id,igg,idiag,iaux,ialpha,iybar,isbar,reentry |
| 77 |
|
|
c m1qn3a_common.h |
| 78 |
|
|
read (io) cold,warm,itmax,isim,jcour,d1,t,tmin,tmax, |
| 79 |
|
|
& gnorm,gnorms,eps1,ff,dk |
| 80 |
|
|
c mlis3_common.h |
| 81 |
mlosch |
1.2 |
read (io) tesf,tesd,fa,fpa,fn,barmin,barmul,barmax,barr, |
| 82 |
|
|
& tg,fg,fpg,td,ta,d2,fp,ffn,fd,fpd,z,test,gauche,droite |
| 83 |
mlosch |
1.1 |
endif |
| 84 |
|
|
|
| 85 |
|
|
close(io) |
| 86 |
|
|
|
| 87 |
|
|
return |
| 88 |
|
|
end |