1 |
C $Header: /u/gcmpack/MITgcm/model/src/do_the_model_io.F,v 1.67 2017/02/15 20:57:19 jahn 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: DO_THE_MODEL_IO |
10 |
|
11 |
C !INTERFACE: |
12 |
SUBROUTINE DO_THE_MODEL_IO( |
13 |
I modelEnd, |
14 |
I myTime, myIter, myThid ) |
15 |
|
16 |
C !DESCRIPTION: |
17 |
C This is the controlling routine for IO in the model main |
18 |
C time--stepping loop. Many systems do not have thread safe IO so it |
19 |
C is easier to lump everything together and do dumping of fields and |
20 |
C updating of forcing terms in a single place. The approach to IO |
21 |
C used here is that writes are only performed by thread 1 and that a |
22 |
C process only writes out its data (it does not know about anyone |
23 |
C elses data!) Reading on the other hand is assumed to be from a |
24 |
C file containing all the data for all the processes. Only the |
25 |
C portion of data of interest to this process is actually loaded. To |
26 |
C work well this assumes the existence of some reliable tool to join |
27 |
C datasets together at the end of a run -- see joinds. |
28 |
|
29 |
C !CALLING SEQUENCE: |
30 |
C DO_THE_MODEL_IO |
31 |
C | |
32 |
C |-- WRITE_STATE |
33 |
C | |
34 |
C |-- TIMEAVE_STATV_WRITE |
35 |
C | |
36 |
C |-- FIZHI_WRITE_STATE |
37 |
C | |
38 |
C |-- AIM_WRITE_TAVE |
39 |
C | |
40 |
C |-- LAND_OUTPUT |
41 |
C | |
42 |
C |-- OBCS_OUTPUT |
43 |
C | |
44 |
C |-- GMREDI_OUTPUT |
45 |
C | |
46 |
C |-- KPP_OUTPUT |
47 |
C | |
48 |
C |-- PP81_OUTPUT |
49 |
C | |
50 |
C |-- KL10_OUTPUT |
51 |
C | |
52 |
C |-- MY82_OUTPUT |
53 |
C | |
54 |
C |-- OPPS_OUTPUT |
55 |
C | |
56 |
C |-- GGL90_OUTPUT |
57 |
C | |
58 |
C |-- SBO_CALC |
59 |
C |-- SBO_OUTPUT |
60 |
C | |
61 |
C |-- SEAICE_OUTPUT |
62 |
C | |
63 |
C |-- SHELFICE_OUTPUT |
64 |
C | |
65 |
C |-- BULKF_OUTPUT |
66 |
C | |
67 |
C |-- THSICE_OUTPUT |
68 |
C | |
69 |
C |-- PTRACERS_OUTPUT |
70 |
C | |
71 |
C |-- MATRIX_OUTPUT |
72 |
C | |
73 |
C |-- GCHEM_OUTPUT |
74 |
C | |
75 |
C |-- CPL_OUTPUT |
76 |
C | |
77 |
C |-- LAYERS_CALC |
78 |
C |-- LAYERS_OUTPUT |
79 |
C | |
80 |
C |-- DIAGNOSTICS_WRITE |
81 |
|
82 |
C !USES: |
83 |
IMPLICIT NONE |
84 |
#include "SIZE.h" |
85 |
#include "EEPARAMS.h" |
86 |
#include "PARAMS.h" |
87 |
#include "DYNVARS.h" |
88 |
|
89 |
C !INPUT/OUTPUT PARAMETERS: |
90 |
C modelEnd :: true if call at end of model run. |
91 |
C myTime :: Current time of simulation ( s ) |
92 |
C myIter :: Iteration number |
93 |
C myThid :: Thread number for this instance of the routine. |
94 |
LOGICAL modelEnd |
95 |
_RL myTime |
96 |
INTEGER myThid |
97 |
INTEGER myIter |
98 |
|
99 |
C !FUNCTIONS: |
100 |
LOGICAL DIFFERENT_MULTIPLE |
101 |
EXTERNAL DIFFERENT_MULTIPLE |
102 |
CEOP |
103 |
|
104 |
C Generaly only thread 1 does IO here. It can not start until |
105 |
C all threads fields are ready. |
106 |
IF ( plotLevel.GE.debLevD ) THEN |
107 |
IF ( DIFFERENT_MULTIPLE(dumpFreq,myTime,deltaTClock) |
108 |
& ) THEN |
109 |
|
110 |
_BARRIER |
111 |
|
112 |
C Write "text-plots" of certain fields |
113 |
CALL PLOT_FIELD_XYZRL( uVel , 'Current uVel ', |
114 |
& Nr, myIter, myThid ) |
115 |
CALL PLOT_FIELD_XYZRL( vVel , 'Current vVel ', |
116 |
& Nr, myIter, myThid ) |
117 |
CALL PLOT_FIELD_XYZRL( theta, 'Current theta ', |
118 |
& Nr, myIter, myThid ) |
119 |
CALL PLOT_FIELD_XYRL( etaN , 'Current etaN ', |
120 |
& myIter, myThid ) |
121 |
|
122 |
ENDIF |
123 |
ENDIF |
124 |
|
125 |
C Write model state to binary file |
126 |
IF ( .NOT.useOffLine ) THEN |
127 |
CALL WRITE_STATE( myTime, myIter, myThid ) |
128 |
ENDIF |
129 |
|
130 |
#ifdef ALLOW_TIMEAVE |
131 |
C Do time averages |
132 |
IF (taveFreq.GT.0. .AND. myIter.NE.nIter0 ) THEN |
133 |
CALL TIMEAVE_STATV_WRITE( myTime, myIter, myThid ) |
134 |
ENDIF |
135 |
#endif |
136 |
|
137 |
#ifdef ALLOW_FIZHI |
138 |
IF ( useFIZHI ) |
139 |
& CALL FIZHI_WRITE_STATE( myTime, myIter, myThid ) |
140 |
#endif |
141 |
|
142 |
#ifdef ALLOW_AIM |
143 |
C Do AIM time averages |
144 |
IF ( useAIM ) |
145 |
& CALL AIM_WRITE_TAVE( myTime, myIter, myThid ) |
146 |
#endif |
147 |
#ifdef ALLOW_LAND |
148 |
C Do LAND output |
149 |
IF ( useLAND ) |
150 |
& CALL LAND_OUTPUT( myTime, myIter, myThid ) |
151 |
#endif |
152 |
|
153 |
#ifdef ALLOW_OBCS |
154 |
IF (useOBCS ) |
155 |
& CALL OBCS_OUTPUT( myTime, myIter, myThid ) |
156 |
#endif |
157 |
|
158 |
#ifdef ALLOW_GMREDI |
159 |
C Do GMRedi output. |
160 |
IF (useGMRedi .AND. myIter.NE.nIter0 .AND. .NOT.useOffLine ) |
161 |
& CALL GMREDI_OUTPUT( myTime, myIter, myThid ) |
162 |
#endif |
163 |
|
164 |
#ifdef ALLOW_KPP |
165 |
C Do KPP diagnostics. |
166 |
IF ( useKPP ) |
167 |
& CALL KPP_OUTPUT( myTime, myIter, myThid ) |
168 |
#endif |
169 |
|
170 |
#ifdef ALLOW_PP81 |
171 |
C Do PP81 diagnostics. |
172 |
IF ( usePP81 ) |
173 |
& CALL PP81_OUTPUT( myTime, myIter, myThid ) |
174 |
#endif |
175 |
|
176 |
#ifdef ALLOW_KL10 |
177 |
C Do KL10 diagnostics. |
178 |
IF ( useKL10 ) |
179 |
& CALL KL10_OUTPUT( myTime, myIter, myThid ) |
180 |
#endif |
181 |
|
182 |
#ifdef ALLOW_MY82 |
183 |
C Do MY82 diagnostics. |
184 |
IF ( useMY82 ) |
185 |
& CALL MY82_OUTPUT( myTime, myIter, myThid ) |
186 |
#endif |
187 |
|
188 |
#ifdef ALLOW_OPPS |
189 |
C-- Do OPPS diagnostics. |
190 |
IF ( useOPPS ) |
191 |
& CALL OPPS_OUTPUT( myTime, myIter, myThid ) |
192 |
#endif |
193 |
|
194 |
#ifdef ALLOW_GGL90 |
195 |
C-- Do GGL90 diagnostics. |
196 |
IF ( useGGL90 ) |
197 |
& CALL GGL90_OUTPUT( myTime, myIter, myThid ) |
198 |
#endif |
199 |
|
200 |
#ifdef ALLOW_SBO |
201 |
C Do SBO diagnostics. |
202 |
IF ( useSBO ) THEN |
203 |
CALL SBO_CALC( myTime, myIter, myThid ) |
204 |
CALL SBO_OUTPUT( myTime, myIter, myThid ) |
205 |
ENDIF |
206 |
#endif |
207 |
|
208 |
#ifdef ALLOW_SEAICE |
209 |
IF ( useSEAICE ) THEN |
210 |
CALL SEAICE_OUTPUT( myTime, myIter, myThid ) |
211 |
ENDIF |
212 |
#endif /* ALLOW_SEAICE */ |
213 |
|
214 |
#ifdef ALLOW_SHELFICE |
215 |
IF ( useShelfIce ) THEN |
216 |
CALL SHELFICE_OUTPUT( myTime, myIter, myThid ) |
217 |
ENDIF |
218 |
#endif /* ALLOW_SHELFICE */ |
219 |
|
220 |
#ifdef ALLOW_BULK_FORCE |
221 |
C Do bulkf output. |
222 |
IF ( useBulkForce .AND. myIter.NE.nIter0 ) |
223 |
& CALL BULKF_OUTPUT( myTime, myIter, myThid ) |
224 |
#endif |
225 |
|
226 |
#ifdef ALLOW_THSICE |
227 |
C Do seaice output. |
228 |
IF (useThSIce) |
229 |
& CALL THSICE_OUTPUT( myTime, myIter, myThid ) |
230 |
#endif |
231 |
|
232 |
#ifdef ALLOW_PTRACERS |
233 |
C-- Do ptracer output. |
234 |
IF ( usePTRACERS ) |
235 |
& CALL PTRACERS_OUTPUT( myTime, myIter, myThid ) |
236 |
#endif |
237 |
|
238 |
#ifdef ALLOW_MATRIX |
239 |
C-- Do matrix output |
240 |
IF (useMATRIX) |
241 |
& CALL MATRIX_OUTPUT( myTime, myIter, myThid ) |
242 |
#endif |
243 |
|
244 |
#ifdef ALLOW_GCHEM |
245 |
C-- Do GCHEM diagnostics. |
246 |
IF (useGCHEM) |
247 |
& CALL GCHEM_OUTPUT( myTime, myIter, myThid ) |
248 |
#endif |
249 |
|
250 |
#ifdef ALLOW_OFFLINE |
251 |
C-- Do Off-Line variables output |
252 |
c IF (useOffLine) |
253 |
c & CALL OFFLINE_STATE( myTime, myIter, myThid ) |
254 |
#endif |
255 |
|
256 |
#ifdef COMPONENT_MODULE |
257 |
IF ( useCoupler ) |
258 |
& CALL CPL_OUTPUT( myTime, myIter, myThid ) |
259 |
#endif |
260 |
|
261 |
C-- added by RPA |
262 |
#ifdef ALLOW_LAYERS |
263 |
IF ( useLayers ) THEN |
264 |
CALL LAYERS_CALC( myTime, myIter, myThid ) |
265 |
CALL LAYERS_OUTPUT( myTime, myIter, myThid ) |
266 |
ENDIF |
267 |
#endif /* ALLOW_LAYERS */ |
268 |
|
269 |
#ifdef ALLOW_DIAGNOSTICS |
270 |
IF ( useDiagnostics ) |
271 |
& CALL DIAGNOSTICS_WRITE( modelEnd, myTime, myIter, myThid ) |
272 |
#endif |
273 |
|
274 |
RETURN |
275 |
END |