1 |
C $Header: /u/gcmpack/MITgcm/model/src/do_the_model_io.F,v 1.63 2010/01/08 19:42:57 jmc 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 !USES: |
30 |
IMPLICIT NONE |
31 |
#include "SIZE.h" |
32 |
#include "EEPARAMS.h" |
33 |
#include "PARAMS.h" |
34 |
#include "DYNVARS.h" |
35 |
LOGICAL DIFFERENT_MULTIPLE |
36 |
EXTERNAL DIFFERENT_MULTIPLE |
37 |
|
38 |
C !INPUT/OUTPUT PARAMETERS: |
39 |
C modelEnd :: true if call at end of model run. |
40 |
C myTime :: Current time of simulation ( s ) |
41 |
C myIter :: Iteration number |
42 |
C myThid :: Thread number for this instance of the routine. |
43 |
LOGICAL modelEnd |
44 |
_RL myTime |
45 |
INTEGER myThid |
46 |
INTEGER myIter |
47 |
CEOP |
48 |
|
49 |
|
50 |
C Generaly only thread 1 does IO here. It can not start until |
51 |
C all threads fields are ready. |
52 |
IF (debugMode) THEN |
53 |
IF ( DIFFERENT_MULTIPLE(dumpFreq,myTime,deltaTClock) |
54 |
& ) THEN |
55 |
|
56 |
_BARRIER |
57 |
|
58 |
C Write "text-plots" of certain fields |
59 |
CALL PLOT_FIELD_XYZRL( uVel , 'Current uVel ', |
60 |
& Nr, myIter, myThid ) |
61 |
CALL PLOT_FIELD_XYZRL( vVel , 'Current vVel ', |
62 |
& Nr, myIter, myThid ) |
63 |
CALL PLOT_FIELD_XYZRL( theta, 'Current theta ', |
64 |
& Nr, myIter, myThid ) |
65 |
CALL PLOT_FIELD_XYRL( etaN , 'Current etaN ', |
66 |
& myIter, myThid ) |
67 |
|
68 |
ENDIF |
69 |
ENDIF |
70 |
|
71 |
C Write model state to binary file |
72 |
IF ( .NOT.useOffLine ) THEN |
73 |
CALL WRITE_STATE( myTime, myIter, myThid ) |
74 |
ENDIF |
75 |
|
76 |
#ifdef ALLOW_TIMEAVE |
77 |
C Do time averages |
78 |
IF (taveFreq.GT.0. .AND. myIter.NE.nIter0 ) THEN |
79 |
CALL TIMEAVE_STATV_WRITE( myTime, myIter, myThid ) |
80 |
ENDIF |
81 |
#endif |
82 |
|
83 |
#ifdef ALLOW_FIZHI |
84 |
IF ( useFIZHI ) |
85 |
& CALL FIZHI_WRITE_STATE( myTime, myIter, myThid ) |
86 |
#endif |
87 |
|
88 |
#ifdef ALLOW_AIM |
89 |
C Do AIM time averages |
90 |
IF ( useAIM ) |
91 |
& CALL AIM_WRITE_TAVE( myTime, myIter, myThid ) |
92 |
#endif |
93 |
#ifdef ALLOW_LAND |
94 |
C Do LAND output |
95 |
IF ( useLAND ) |
96 |
& CALL LAND_OUTPUT( myTime, myIter, myThid ) |
97 |
#endif |
98 |
|
99 |
#ifdef ALLOW_OBCS |
100 |
IF (useOBCS ) |
101 |
& CALL OBCS_OUTPUT( myTime, myIter, myThid ) |
102 |
#endif |
103 |
|
104 |
#ifdef ALLOW_GMREDI |
105 |
C Do GMRedi output. |
106 |
IF (useGMRedi .AND. myIter.NE.nIter0 .AND. .NOT.useOffLine ) |
107 |
& CALL GMREDI_OUTPUT( myTime, myIter, myThid ) |
108 |
#endif |
109 |
|
110 |
#ifdef ALLOW_KPP |
111 |
C Do KPP diagnostics. |
112 |
IF ( useKPP .AND. .NOT.useOffLine ) |
113 |
& CALL KPP_OUTPUT( myTime, myIter, myThid ) |
114 |
#endif |
115 |
|
116 |
#ifdef ALLOW_PP81 |
117 |
C Do PP81 diagnostics. |
118 |
IF ( usePP81 ) |
119 |
& CALL PP81_OUTPUT( myTime, myIter, myThid ) |
120 |
#endif |
121 |
|
122 |
#ifdef ALLOW_MY82 |
123 |
C Do MY82 diagnostics. |
124 |
IF ( useMY82 ) |
125 |
& CALL MY82_OUTPUT( myTime, myIter, myThid ) |
126 |
#endif |
127 |
|
128 |
#ifdef ALLOW_OPPS |
129 |
C-- Do OPPS diagnostics. |
130 |
IF ( useOPPS ) |
131 |
& CALL OPPS_OUTPUT( myTime, myIter, myThid ) |
132 |
#endif |
133 |
|
134 |
#ifdef ALLOW_GGL90 |
135 |
C-- Do GGL90 diagnostics. |
136 |
IF ( useGGL90 ) |
137 |
& CALL GGL90_OUTPUT( myTime, myIter, myThid ) |
138 |
#endif |
139 |
|
140 |
#ifdef ALLOW_SBO |
141 |
C Do SBO diagnostics. |
142 |
IF ( useSBO ) THEN |
143 |
CALL SBO_CALC( myTime, myIter, myThid ) |
144 |
CALL SBO_OUTPUT( myTime, myIter, myThid ) |
145 |
ENDIF |
146 |
#endif |
147 |
|
148 |
#ifdef ALLOW_SEAICE |
149 |
IF ( useSEAICE ) THEN |
150 |
CALL SEAICE_OUTPUT( myTime, myIter, myThid ) |
151 |
ENDIF |
152 |
#endif /* ALLOW_SEAICE */ |
153 |
|
154 |
#ifdef ALLOW_SHELFICE |
155 |
IF ( useShelfIce ) THEN |
156 |
CALL SHELFICE_OUTPUT( myTime, myIter, myThid ) |
157 |
ENDIF |
158 |
#endif /* ALLOW_SHELFICE */ |
159 |
|
160 |
#ifdef ALLOW_BULK_FORCE |
161 |
C Do bulkf output. |
162 |
IF ( useBulkForce .AND. myIter.NE.nIter0 ) |
163 |
& CALL BULKF_OUTPUT( myTime, myIter, myThid ) |
164 |
#endif |
165 |
|
166 |
#ifdef ALLOW_THSICE |
167 |
C Do seaice output. |
168 |
IF (useThSIce) |
169 |
& CALL THSICE_OUTPUT( myTime, myIter, myThid ) |
170 |
#endif |
171 |
|
172 |
#ifdef ALLOW_PTRACERS |
173 |
C-- Do ptracer output. |
174 |
IF ( usePTRACERS ) |
175 |
& CALL PTRACERS_OUTPUT( myTime, myIter, myThid ) |
176 |
#endif |
177 |
|
178 |
#ifdef ALLOW_MATRIX |
179 |
C-- Do matrix output |
180 |
IF (useMATRIX) |
181 |
& CALL MATRIX_OUTPUT( myTime, myIter, myThid ) |
182 |
#endif |
183 |
|
184 |
#ifdef ALLOW_GCHEM |
185 |
C-- Do GCHEM diagnostics. |
186 |
IF (useGCHEM) |
187 |
& CALL GCHEM_OUTPUT( myTime, myIter, myThid ) |
188 |
#endif |
189 |
|
190 |
#ifdef ALLOW_OFFLINE |
191 |
C-- Do Off-Line variables output |
192 |
c IF (useOffLine) |
193 |
c & CALL OFFLINE_STATE( myTime, myIter, myThid ) |
194 |
#endif |
195 |
|
196 |
#ifdef COMPONENT_MODULE |
197 |
IF ( useCoupler ) |
198 |
& CALL CPL_OUTPUT( myTime, myIter, myThid ) |
199 |
#endif |
200 |
|
201 |
C-- added by RPA |
202 |
#ifdef ALLOW_LAYERS |
203 |
IF ( useLayers ) THEN |
204 |
CALL LAYERS_CALC( myTime, myIter, myThid ) |
205 |
CALL LAYERS_OUTPUT( myTime, myIter, myThid ) |
206 |
ENDIF |
207 |
#endif /* ALLOW_LAYERS */ |
208 |
|
209 |
|
210 |
#ifdef ALLOW_DIAGNOSTICS |
211 |
IF ( useDiagnostics ) |
212 |
& CALL DIAGNOSTICS_WRITE( modelEnd, myTime, myIter, myThid ) |
213 |
#endif |
214 |
|
215 |
RETURN |
216 |
END |