1 |
C $Header: /u/gcmpack/MITgcm/model/src/packages_write_pickup.F,v 1.8 2004/08/18 15:56:05 molod Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
6 |
|
7 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
8 |
CBOP |
9 |
C !ROUTINE: PACKAGES_WRITE_PICKUP |
10 |
|
11 |
C !INTERFACE: |
12 |
SUBROUTINE PACKAGES_WRITE_PICKUP( |
13 |
I modelEnd, |
14 |
I myTime, |
15 |
I myIter, |
16 |
I myThid ) |
17 |
|
18 |
C !DESCRIPTION: |
19 |
C Write pickup files for each package which needs it to restart. |
20 |
C This routine (S/R PACKAGES_WRITE_PICKUP) calls per-package |
21 |
C write-pickup (or checkpoint) routines. It writes both |
22 |
C "rolling-checkpoint" files (ckptA,ckptB) and permanent checkpoint |
23 |
C files. |
24 |
|
25 |
C !USES: |
26 |
IMPLICIT NONE |
27 |
#include "SIZE.h" |
28 |
#include "EEPARAMS.h" |
29 |
#include "PARAMS.h" |
30 |
|
31 |
LOGICAL DIFFERENT_MULTIPLE |
32 |
EXTERNAL DIFFERENT_MULTIPLE |
33 |
INTEGER IO_ERRCOUNT |
34 |
EXTERNAL IO_ERRCOUNT |
35 |
|
36 |
C !INPUT/OUTPUT PARAMETERS: |
37 |
C == Routine arguments == |
38 |
C modelEnd :: Checkpoint call at end of model run. |
39 |
C myThid :: Thread number for this instance of the routine. |
40 |
C myIter :: Iteration number |
41 |
C myTime :: Current time of simulation ( s ) |
42 |
LOGICAL modelEnd |
43 |
INTEGER myThid |
44 |
INTEGER myIter |
45 |
_RL myTime |
46 |
|
47 |
C !LOCAL VARIABLES: |
48 |
C == Local variables == |
49 |
C permCheckPoint :: Flag indicating whether a permanent checkpoint will |
50 |
C be written. |
51 |
C tempCheckPoint :: Flag indicating if it is time to write a non-permanent |
52 |
C checkpoint (that will be permanent if permCheckPoint=T) |
53 |
C oldPrc :: Temp. for holding I/O precision |
54 |
C fn :: Temp. for building file name string. |
55 |
C lgf :: Flag to indicate whether to use global file mode. |
56 |
LOGICAL permCheckPoint, tempCheckPoint |
57 |
CEOP |
58 |
|
59 |
permCheckPoint = .FALSE. |
60 |
tempCheckPoint = .FALSE. |
61 |
permCheckPoint= |
62 |
& DIFFERENT_MULTIPLE(pChkptFreq,myTime,myTime-deltaTClock) |
63 |
tempCheckPoint= |
64 |
& DIFFERENT_MULTIPLE( ChkptFreq,myTime,myTime-deltaTClock) |
65 |
|
66 |
IF ( |
67 |
& ( .NOT.modelEnd .AND. (permCheckPoint.OR.tempCheckPoint) ) |
68 |
& .OR. |
69 |
& ( modelEnd .AND. .NOT.(permCheckPoint.OR.tempCheckPoint) ) |
70 |
& ) THEN |
71 |
|
72 |
CALL PACKAGES_WRITE_PICKUP_NOW( |
73 |
& permCheckPoint, myTime, myIter, myThid ) |
74 |
|
75 |
ENDIF |
76 |
|
77 |
RETURN |
78 |
END |
79 |
|
80 |
|
81 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
82 |
CBOP |
83 |
C !ROUTINE: PACKAGES_WRITE_PICKUP_NOW |
84 |
|
85 |
C !INTERFACE: |
86 |
SUBROUTINE PACKAGES_WRITE_PICKUP_NOW( |
87 |
I permCheckPoint, |
88 |
I myTime, |
89 |
I myIter, |
90 |
I myThid ) |
91 |
|
92 |
C !DESCRIPTION: |
93 |
C Write pickup files for each package which needs it to restart and |
94 |
C do it NOW. |
95 |
|
96 |
C !USES: |
97 |
IMPLICIT NONE |
98 |
#include "SIZE.h" |
99 |
#include "EEPARAMS.h" |
100 |
#include "PARAMS.h" |
101 |
|
102 |
|
103 |
C !INPUT/OUTPUT PARAMETERS: |
104 |
C permCheckPoint :: Checkpoint is permanent |
105 |
C myThid :: Thread number for this instance of the routine. |
106 |
C myIter :: Iteration number |
107 |
C myTime :: Current time of simulation ( s ) |
108 |
LOGICAL permCheckPoint |
109 |
INTEGER myThid |
110 |
INTEGER myIter |
111 |
_RL myTime |
112 |
|
113 |
C == Common blocks == |
114 |
COMMON /PCKP_GBLFLS/ globalFile |
115 |
LOGICAL globalFile |
116 |
|
117 |
C !LOCAL VARIABLES: |
118 |
C == Local variables == |
119 |
C oldPrc :: Temp. for holding I/O precision |
120 |
C fn :: Temp. for building file name string. |
121 |
C lgf :: Flag to indicate whether to use global file mode. |
122 |
CHARACTER*(MAX_LEN_FNAM) fn |
123 |
INTEGER prec |
124 |
LOGICAL lgf |
125 |
CEOP |
126 |
|
127 |
C Going to really do some IO. Make everyone except master thread wait. |
128 |
_BARRIER |
129 |
_BEGIN_MASTER( myThid ) |
130 |
|
131 |
prec = precFloat64 |
132 |
lgf = globalFile |
133 |
|
134 |
C Create suffix to pass on to package pickup routines |
135 |
IF ( permCheckPoint ) THEN |
136 |
WRITE(fn,'(I10.10)') myIter |
137 |
ELSE |
138 |
WRITE(fn,'(A)') checkPtSuff(nCheckLev) |
139 |
ENDIF |
140 |
|
141 |
#ifdef ALLOW_CD_CODE |
142 |
IF (useCDscheme) THEN |
143 |
CALL CD_CODE_WRITE_CHECKPOINT( |
144 |
& prec, lgf, permCheckPoint, myIter, myThid) |
145 |
ENDIF |
146 |
#endif /* ALLOW_CD_CODE */ |
147 |
|
148 |
#ifdef ALLOW_OBCS |
149 |
C SPK 4/9/01: Open boundary checkpointing |
150 |
IF (useOBCS) THEN |
151 |
CALL OBCS_WRITE_CHECKPOINT( |
152 |
& prec, lgf, permCheckPoint, myIter, myThid) |
153 |
ENDIF |
154 |
#endif /* ALLOW_OBCS */ |
155 |
|
156 |
#ifdef ALLOW_SEAICE |
157 |
IF ( useSEAICE ) THEN |
158 |
CALL SEAICE_WRITE_PICKUP( |
159 |
& prec, lgf, permCheckPoint, myIter, myThid) |
160 |
ENDIF |
161 |
#endif /* ALLOW_SEAICE */ |
162 |
|
163 |
#ifdef ALLOW_THSICE |
164 |
IF (useThSIce) THEN |
165 |
CALL THSICE_WRITE_PICKUP( |
166 |
& prec, lgf, permCheckPoint, myIter, myThid) |
167 |
ENDIF |
168 |
#endif /* ALLOW_THSICE */ |
169 |
|
170 |
#ifdef COMPONENT_MODULE |
171 |
IF (useCoupler) THEN |
172 |
CALL CPL_WRITE_PICKUP( |
173 |
& prec, lgf, permCheckPoint, myIter, myThid) |
174 |
ENDIF |
175 |
#endif /* COMPONENT_MODULE */ |
176 |
|
177 |
#ifdef ALLOW_FLT |
178 |
C Write restart file for floats |
179 |
IF (useFLT) THEN |
180 |
CALL FLT_RESTART(myTime, myIter, myThid) |
181 |
ENDIF |
182 |
#endif |
183 |
|
184 |
#ifdef ALLOW_LAND |
185 |
C Write pickup file for Lnad package: |
186 |
IF (useLand) THEN |
187 |
CALL LAND_WRITE_PICKUP(fn,myTime,myIter,myThid) |
188 |
ENDIF |
189 |
#endif |
190 |
|
191 |
#ifdef ALLOW_FIZHI |
192 |
C Write pickup file for fizhi package |
193 |
IF (usefizhi) THEN |
194 |
CALL FIZHI_WRITE_PICKUP(fn,myTime,myIter,myThid) |
195 |
CALL FIZHI_WRITE_VEGTILES(fn,0,myTime,myIter,myThid) |
196 |
ENDIF |
197 |
#endif |
198 |
|
199 |
#ifdef ALLOW_GGL90 |
200 |
IF ( useGGL90 ) THEN |
201 |
CALL GGL90_WRITE_CHECKPOINT( |
202 |
& prec, lgf, permCheckPoint, myIter, myThid) |
203 |
ENDIF |
204 |
#endif /* ALLOW_GGL90 */ |
205 |
|
206 |
_END_MASTER( myThid ) |
207 |
_BARRIER |
208 |
|
209 |
#ifdef ALLOW_PTRACERS |
210 |
C Write restart file for passive tracers |
211 |
IF (usePTRACERS) THEN |
212 |
CALL PTRACERS_WRITE_CHECKPOINT(fn,myIter,myTime,myThid) |
213 |
ENDIF |
214 |
#endif /* ALLOW_PTRACERS */ |
215 |
|
216 |
RETURN |
217 |
END |
218 |
|
219 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |