1 |
C $Header$ |
C $Header$ |
2 |
|
|
3 |
#include "CPP_EEOPTIONS.h" |
#include "CPP_OPTIONS.h" |
4 |
|
|
5 |
SUBROUTINE THE_MODEL_MAIN(myThid) |
SUBROUTINE THE_MODEL_MAIN(myThid) |
6 |
C /==========================================================\ |
C /==========================================================\ |
22 |
C | C*P* comments indicating place holders for which code is | |
C | C*P* comments indicating place holders for which code is | |
23 |
C | presently being developed. | |
C | presently being developed. | |
24 |
C \==========================================================/ |
C \==========================================================/ |
25 |
|
IMPLICIT NONE |
26 |
C |
C |
27 |
C Call Tree |
C Call Tree |
28 |
C ========= |
C ========= |
85 |
#include "SIZE.h" |
#include "SIZE.h" |
86 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
87 |
#include "PARAMS.h" |
#include "PARAMS.h" |
|
#include "CG2D.h" |
|
88 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
89 |
#include "AVER.h" |
#include "CG2D.h" |
90 |
|
#ifdef ALLOW_NONHYDROSTATIC |
91 |
|
#include "CG3D.h" |
92 |
|
#endif |
93 |
|
|
94 |
C == Routine arguments == |
C == Routine arguments == |
95 |
C myThid - Thread number for this instance of the routine. |
C myThid - Thread number for this instance of the routine. |
106 |
C I - Loop counter |
C I - Loop counter |
107 |
INTEGER I, myCurrentIter |
INTEGER I, myCurrentIter |
108 |
REAL myCurrentTime |
REAL myCurrentTime |
109 |
|
CHARACTER*(30) suff |
110 |
|
|
111 |
|
C-- This timer encompasses the whole code |
112 |
|
CALL TIMER_START('ALL',myThid) |
113 |
|
|
114 |
|
CALL TIMER_START('SPIN-UP',myThid) |
115 |
|
|
116 |
C-- Set model initial conditions |
C-- Set model initial conditions |
117 |
|
CALL TIMER_START('INITIALISE [SPIN-UP]',myThid) |
118 |
CALL INITIALISE( myThid ) |
CALL INITIALISE( myThid ) |
119 |
myCurrentTime = startTime |
myCurrentTime = startTime |
120 |
myCurrentIter = nIter0 |
myCurrentIter = nIter0 |
121 |
|
CALL TIMER_STOP ('INITIALISE [SPIN-UP]',myThid) |
122 |
|
|
123 |
|
C-- Dump for start state |
124 |
|
CALL TIMER_START('I/O (WRITE) [SPIN-UP]',myThid) |
125 |
|
CALL WRITE_STATE( .TRUE., myCurrentTime, myCurrentIter, myThid ) |
126 |
|
CALL TIMER_STOP ('I/O (WRITE) [SPIN-UP]',myThid) |
127 |
|
|
128 |
|
CALL TIMER_STOP ('SPIN-UP',myThid) |
129 |
|
|
130 |
C-- Begin time stepping loop |
C-- Begin time stepping loop |
131 |
|
CALL TIMER_START('MAIN LOOP',myThid) |
132 |
DO I=1, nTimeSteps |
DO I=1, nTimeSteps |
133 |
|
|
134 |
C-- Load forcing/external data fields |
C-- Load forcing/external data fields |
135 |
|
CALL TIMER_START('I/O (READ) [MAIN LOOP]',myThid) |
136 |
CALL LOAD_EXTERNAL_FIELDS( myCurrentTime, myCurrentIter, myThid ) |
CALL LOAD_EXTERNAL_FIELDS( myCurrentTime, myCurrentIter, myThid ) |
137 |
|
CALL TIMER_STOP ('I/O (READ) [MAIN LOOP]',myThid) |
138 |
|
|
139 |
|
#ifdef INCLUDE_SHAPIRO_FILTER_CODE |
140 |
|
C-- Step forward all tiles, filter and exchange. |
141 |
|
CALL TIMER_START('SHAP_FILT [MAIN LOOP]',myThid) |
142 |
|
CALL SHAP_FILT( myCurrentTime, myCurrentIter, myThid ) |
143 |
|
CALL TIMER_STOP ('SHAP_FILT [MAIN LOOP]',myThid) |
144 |
|
#endif |
145 |
|
|
146 |
|
C-- Set Open Boundaries Values |
147 |
|
IF (openBoundaries) THEN |
148 |
|
CALL TIMER_START('OBCS [MAIN LOOP]',myThid) |
149 |
|
CALL SET_OBCS( myCurrentTime, myThid ) |
150 |
|
CALL TIMER_STOP ('OBCS [MAIN LOOP]',myThid) |
151 |
|
ENDIF |
152 |
|
|
153 |
C-- Step forward fields and calculate time tendency terms |
C-- Step forward fields and calculate time tendency terms |
154 |
|
CALL TIMER_START('DYNAMICS [MAIN LOOP]',myThid) |
155 |
CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid ) |
CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid ) |
156 |
|
CALL TIMER_STOP ('DYNAMICS [MAIN LOOP]',myThid) |
157 |
|
|
158 |
|
#ifdef ALLOW_NONHYDROSTATIC |
159 |
|
C-- Step forward W field in N-H algorithm |
160 |
|
IF ( nonHydrostatic ) THEN |
161 |
|
CALL TIMER_START('CALC_GW [MAIN LOOP]',myThid) |
162 |
|
CALL CALC_GW( myThid) |
163 |
|
CALL TIMER_STOP ('CALC_GW [MAIN LOOP]',myThid) |
164 |
|
ENDIF |
165 |
|
#endif |
166 |
|
|
167 |
C-- Do time averages |
C-- Do time averages |
168 |
|
#ifdef INCLUDE_DIAGNOSTICS_INTERFACE_CODE |
169 |
|
CALL TIMER_START('I/O (WRITE) [MAIN LOOP]',myThid) |
170 |
IF (taveFreq.GT.0.) THEN |
IF (taveFreq.GT.0.) THEN |
171 |
CALL DO_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid ) |
CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid ) |
172 |
ENDIF |
ENDIF |
173 |
|
CALL TIMER_STOP ('I/O (WRITE) [MAIN LOOP]',myThid) |
174 |
|
#endif |
175 |
|
|
176 |
C-- Do IO if needed. |
C-- Do IO if needed. |
177 |
C Note: |
C Note: |
179 |
C At this point model arrays hold U,V,T,S at "time-level" N |
C At this point model arrays hold U,V,T,S at "time-level" N |
180 |
C and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1. |
C and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1. |
181 |
C By convention this is taken to be the model "state". |
C By convention this is taken to be the model "state". |
182 |
|
CALL TIMER_START('I/O (WRITE) [MAIN LOOP]',myThid) |
183 |
CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid ) |
CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid ) |
184 |
|
CALL TIMER_STOP ('I/O (WRITE) [MAIN LOOP]',myThid) |
185 |
|
|
186 |
C-- Solve elliptic equation(s). |
C-- Solve elliptic equation(s). |
187 |
C Two-dimensional only for conventional hydrostatic or |
C Two-dimensional only for conventional hydrostatic or |
188 |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
189 |
|
CALL TIMER_START('SOLVE_FOR_PRESSURE [MAIN LOOP]',myThid) |
190 |
CALL SOLVE_FOR_PRESSURE( myThid ) |
CALL SOLVE_FOR_PRESSURE( myThid ) |
191 |
|
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [MAIN LOOP]',myThid) |
192 |
|
|
193 |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
194 |
|
CALL TIMER_START('BLOCKING_EXCHANGES [MAIN LOOP]',myThid) |
195 |
CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
196 |
|
CALL TIMER_STOP ('BLOCKING_EXCHANGES [MAIN LOOP]',myThid) |
197 |
|
|
198 |
myCurrentIter = myCurrentIter + 1 |
myCurrentIter = myCurrentIter + 1 |
199 |
myCurrentTime = myCurrentTime + deltaTClock |
myCurrentTime = myCurrentTime + deltaTClock |
211 |
C cg2d_x.0000000001 in the indexing scheme used for the model |
C cg2d_x.0000000001 in the indexing scheme used for the model |
212 |
C "state" files. This example is referred to as a checkpoint |
C "state" files. This example is referred to as a checkpoint |
213 |
C at time level 1 |
C at time level 1 |
214 |
CALL WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid ) |
CALL TIMER_START('I/O (WRITE) [MAIN LOOP]',myThid) |
215 |
|
CALL |
216 |
|
& WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid ) |
217 |
|
CALL TIMER_STOP ('I/O (WRITE) [MAIN LOOP]',myThid) |
218 |
|
|
219 |
ENDDO |
ENDDO |
220 |
|
CALL TIMER_STOP ('MAIN LOOP',myThid) |
221 |
|
CALL TIMER_START('SPIN-DOWN',myThid) |
222 |
|
|
223 |
C-- Final checkpoint (incase the in-loop checkpoint was missed) |
C-- Final checkpoint (incase the in-loop checkpoint was missed) |
224 |
CALL WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid ) |
CALL TIMER_START('I/O (WRITE) [SPIN-DOWN]',myThid) |
225 |
|
CALL |
226 |
|
& WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid ) |
227 |
|
CALL TIMER_STOP ('I/O (WRITE) [SPIN-DOWN]',myThid) |
228 |
|
|
229 |
|
C-- Set Open Boundaries Values |
230 |
|
IF (openBoundaries) THEN |
231 |
|
CALL TIMER_START('OBCS [SPIN_DOWN]',myThid) |
232 |
|
CALL SET_OBCS( myCurrentTime, myThid ) |
233 |
|
CALL TIMER_STOP ('OBCS [SPIN_DOWN]',myThid) |
234 |
|
ENDIF |
235 |
|
|
236 |
C-- Step-forward U/V/Theta/Salt for purposes of final I/O dump |
C-- Step-forward U/V/Theta/Salt for purposes of final I/O dump |
237 |
|
CALL TIMER_START('DYNAMICS [SPIN-DOWN]',myThid) |
238 |
CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid ) |
CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid ) |
239 |
|
CALL TIMER_STOP ('DYNAMICS [SPIN-DOWN]',myThid) |
240 |
|
|
241 |
|
#ifdef ALLOW_NONHYDROSTATIC |
242 |
|
IF ( nonHydrostatic ) THEN |
243 |
|
C-- Step forward W field in N-H algorithm |
244 |
|
CALL TIMER_START('CALC_GW [SPIN-DOWN]',myThid) |
245 |
|
CALL CALC_GW( myThid) |
246 |
|
CALL TIMER_STOP ('CALC_GW [SPIN-DOWN]',myThid) |
247 |
|
ENDIF |
248 |
|
#endif |
249 |
|
|
250 |
C-- Do time averages |
C-- Do time averages |
251 |
|
#ifdef ALLOW_DIAGNOSTICS |
252 |
IF (taveFreq.GT.0.) THEN |
IF (taveFreq.GT.0.) THEN |
253 |
CALL DO_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid ) |
CALL TIMER_START('I/O (WRITE) [SPIN-DOWN]',myThid) |
254 |
|
CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid ) |
255 |
|
CALL TIMER_STOP ('I/O (WRITE) [SPIN-DOWN]',myThid) |
256 |
ENDIF |
ENDIF |
257 |
|
#endif |
258 |
|
|
259 |
C-- Dump for end state |
C-- Dump for end state |
260 |
CALL WRITE_STATE( myCurrentTime, myCurrentIter, myThid ) |
CALL TIMER_START('I/O (WRITE) [SPIN-DOWN]',myThid) |
261 |
|
CALL WRITE_STATE( .FALSE., myCurrentTime, myCurrentIter, myThid ) |
262 |
|
CALL TIMER_STOP ('I/O (WRITE) [SPIN-DOWN]',myThid) |
263 |
|
|
264 |
|
CALL TIMER_STOP ('SPIN-DOWN',myThid) |
265 |
|
CALL TIMER_STOP ('ALL',myThid) |
266 |
|
|
267 |
|
C-- Write timer statistics |
268 |
|
IF ( myThid .EQ. 1 ) THEN |
269 |
|
CALL TIMER_PRINTALL( myThid ) |
270 |
|
CALL COMM_STATS |
271 |
|
ENDIF |
272 |
|
|
273 |
RETURN |
RETURN |
274 |
END |
END |