1 |
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 |
C $Name: $ |
3 |
|
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 |
write(io) cold,warm,itmax,moderl,isim,jcour,d1,t,tmin,tmax, |
56 |
& gnorm,gnorms,eps1,ff,preco,precos,ys,den,dk,dk1,ps,ps2,hp0 |
57 |
c mlis3_common.h |
58 |
write(io) t_increased,indica,indicd |
59 |
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 |
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,moderl,isim,jcour,d1,t,tmin,tmax, |
79 |
& gnorm,gnorms,eps1,ff,preco,precos,ys,den,dk,dk1,ps,ps2,hp0 |
80 |
c mlis3_common.h |
81 |
read(io) t_increased,indica,indicd |
82 |
read(io) tesf,tesd,fa,fpa,fn,barmin,barmul,barmax,barr, |
83 |
& tg,fg,fpg,td,ta,d2,fp,ffn,fd,fpd,z,test,gauche,droite |
84 |
endif |
85 |
|
86 |
close(io) |
87 |
|
88 |
return |
89 |
end |