1 |
mlosch |
1.6 |
C $Header: /u/gcmpack/MITgcm_contrib/mlosch/optim_m1qn3/optim_store_m1qn3.F,v 1.5 2012/05/09 09:39:39 mlosch Exp $ |
2 |
mlosch |
1.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 |
|
|
if ( store ) then |
39 |
|
|
write(fname,'(A,I4.4)') 'OPWARM.opt',optimcycle+1 |
40 |
|
|
c |
41 |
|
|
print * |
42 |
|
|
print *, ' OPTIM_STORE_M1QN3: saving the state of m1qn3 in ', |
43 |
|
|
& fname |
44 |
|
|
print * |
45 |
|
|
c |
46 |
|
|
open(io,file=fname,form='unformatted',status='unknown') |
47 |
|
|
write(io) niter,nsim |
48 |
|
|
write(io) iz |
49 |
|
|
write(io) (dz(k),k=1,ndz) |
50 |
|
|
c some extra info |
51 |
|
|
write(io) epsg,df1 |
52 |
|
|
c m1qn3_common.h |
53 |
|
|
write(io) inmemo,id,igg,idiag,iaux,ialpha,iybar,isbar,reentry |
54 |
|
|
c m1qn3a_common.h |
55 |
mlosch |
1.6 |
write(io) cold,warm,itmax,moderl,isim,jcour,d1,t,tmin,tmax, |
56 |
mlosch |
1.3 |
& gnorm,gnorms,eps1,ff,preco,precos,ys,den,dk,dk1,ps,ps2,hp0 |
57 |
mlosch |
1.1 |
c mlis3_common.h |
58 |
mlosch |
1.4 |
write(io) t_increased,indica,indicd |
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 |
mlosch |
1.4 |
read(io) iz |
72 |
|
|
read(io) (dz(k),k=1,ndz) |
73 |
mlosch |
1.1 |
c some extra info |
74 |
mlosch |
1.4 |
read(io) epsg,df1 |
75 |
mlosch |
1.1 |
c m1qn3_common.h |
76 |
mlosch |
1.4 |
read(io) inmemo,id,igg,idiag,iaux,ialpha,iybar,isbar,reentry |
77 |
mlosch |
1.1 |
c m1qn3a_common.h |
78 |
mlosch |
1.6 |
read(io) cold,warm,itmax,moderl,isim,jcour,d1,t,tmin,tmax, |
79 |
mlosch |
1.3 |
& gnorm,gnorms,eps1,ff,preco,precos,ys,den,dk,dk1,ps,ps2,hp0 |
80 |
mlosch |
1.1 |
c mlis3_common.h |
81 |
mlosch |
1.4 |
read(io) t_increased,indica,indicd |
82 |
|
|
read(io) tesf,tesd,fa,fpa,fn,barmin,barmul,barmax,barr, |
83 |
mlosch |
1.2 |
& tg,fg,fpg,td,ta,d2,fp,ffn,fd,fpd,z,test,gauche,droite |
84 |
mlosch |
1.1 |
endif |
85 |
|
|
|
86 |
|
|
close(io) |
87 |
|
|
|
88 |
|
|
return |
89 |
|
|
end |