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 |
|
C |
26 |
|
C Call Tree |
27 |
|
C ========= |
28 |
|
C |
29 |
|
C main ( eesupp ) |
30 |
|
C | |
31 |
|
C . |
32 |
|
C . |
33 |
|
C . Generic environment initialisation ( see eesupp/src and |
34 |
|
C . eesupp/inc ) |
35 |
|
C . multiple threads and/or processes are created in here |
36 |
|
C . |
37 |
|
C . |
38 |
|
C . |
39 |
|
C | |
40 |
|
C |-THE_MODEL_MAIN - Begin specific model. One instance |
41 |
|
C | | of this codes exists for each thread |
42 |
|
C | | and/or instance. Each instance manages |
43 |
|
C | | a specifc set of tiles. |
44 |
|
C | | |
45 |
|
C | |--INITIALISE |
46 |
|
C | | o Set initial conditions and model configuration |
47 |
|
C | | Topography, hydrography, timestep, grid, etc.. |
48 |
|
C | | |
49 |
|
C ==> | | ** Time stepping loop starts here ** |
50 |
|
C | | | |
51 |
|
C /|\ | | |
52 |
|
C | | |--LOAD_EXTERNAL_DATA |
53 |
|
C /|\ | | o Load and/or set time dependent forcing fields |
54 |
|
C | | | |
55 |
|
C /|\ | |--DYNAMICS |
56 |
|
C | | | o Evaluate "forward" terms |
57 |
|
C /|\ | | |
58 |
|
C | | |--DO_THE_MODEL_IO |
59 |
|
C /|\ | | o Write model state |
60 |
|
C | | | |
61 |
|
C /|\ | |--SOLVE_FOR_PRESSURE |
62 |
|
C | | | o Find pressure field to keep flow non-divergent |
63 |
|
C /|\ | | |
64 |
|
C | | |--DO_GTERM_BLOCKING_EXCHANGES |
65 |
|
C /|\ | | o Update overlap regions |
66 |
|
C | | | |
67 |
|
C /|\ | |--WRITE_CHECKPOINT |
68 |
|
C | | | o Write restart file(s) |
69 |
|
C /|\ | | |
70 |
|
C | | | |
71 |
|
C |<== | | ** Time stepping loop finishes here ** |
72 |
|
C | | |
73 |
|
C | |--WRITE_STATE |
74 |
|
C | |--WRITE_CHECKPOINT |
75 |
|
C | |
76 |
|
C . |
77 |
|
C . |
78 |
|
C . Generic environment termination ( see eesupp/src and |
79 |
|
C . eesupp/inc ) |
80 |
|
C . |
81 |
|
C . |
82 |
|
|
83 |
C == Global variables === |
C == Global variables === |
84 |
#include "SIZE.h" |
#include "SIZE.h" |
86 |
#include "PARAMS.h" |
#include "PARAMS.h" |
87 |
#include "CG2D.h" |
#include "CG2D.h" |
88 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
89 |
|
#include "AVER.h" |
90 |
|
|
91 |
C == Routine arguments == |
C == Routine arguments == |
92 |
C myThid - Thread number for this instance of the routine. |
C myThid - Thread number for this instance of the routine. |
104 |
INTEGER I, myCurrentIter |
INTEGER I, myCurrentIter |
105 |
REAL myCurrentTime |
REAL myCurrentTime |
106 |
|
|
107 |
|
C-- This timer encompasses the whole code |
108 |
|
CALL TIMER_START('ALL',myThid) |
109 |
|
|
110 |
|
CALL TIMER_START('SPIN-UP',myThid) |
111 |
|
|
112 |
C-- Set model initial conditions |
C-- Set model initial conditions |
113 |
|
CALL TIMER_START('INITIALISE [SPIN-UP]',myThid) |
114 |
CALL INITIALISE( myThid ) |
CALL INITIALISE( myThid ) |
115 |
myCurrentTime = startTime |
myCurrentTime = startTime |
116 |
myCurrentIter = nIter0 |
myCurrentIter = nIter0 |
117 |
|
CALL TIMER_STOP ('INITIALISE [SPIN-UP]',myThid) |
118 |
|
|
119 |
|
C-- Dump for start state |
120 |
|
CALL TIMER_START('I/O (WRITE) [SPIN-UP]',myThid) |
121 |
|
CALL WRITE_STATE( .TRUE., myCurrentTime, myCurrentIter, myThid ) |
122 |
|
CALL TIMER_STOP ('I/O (WRITE) [SPIN-UP]',myThid) |
123 |
|
|
124 |
|
CALL TIMER_STOP ('SPIN-UP',myThid) |
125 |
|
|
126 |
C-- Begin time stepping loop |
C-- Begin time stepping loop |
127 |
|
CALL TIMER_START('MAIN LOOP',myThid) |
128 |
DO I=1, nTimeSteps |
DO I=1, nTimeSteps |
129 |
|
|
130 |
C-- Load offline tracer fields |
C-- Load forcing/external data fields |
131 |
IF ( MOD(myCurrentIter,numStepsPerPickup) .EQ. 1 ) THEN |
CALL TIMER_START('I/O (READ) [MAIN LOOP]',myThid) |
132 |
C I/O |
CALL LOAD_EXTERNAL_FIELDS( myCurrentTime, myCurrentIter, myThid ) |
133 |
C o Writes to arrays are performed by their own thread (to ensure |
CALL TIMER_STOP ('I/O (READ) [MAIN LOOP]',myThid) |
134 |
C physical memory allocation will pair with thread). |
|
135 |
C o Thread 1 reads into a buffer. |
#ifdef INCLUDE_SHAPIRO_FILTER_CODE |
136 |
C CALL LOAD_OFFLINE_FIELDS( myCurrentTime, myCurrentIter, myThid ) |
C-- Step forward all tiles, filter and exchange. |
137 |
ENDIF |
CALL TIMER_START('SHAP_FILT [MAIN LOOP]',myThid) |
138 |
|
CALL SHAP_FILT( myCurrentTime, myCurrentIter, myThid ) |
139 |
|
CALL TIMER_STOP ('SHAP_FILT [MAIN LOOP]',myThid) |
140 |
|
#endif |
141 |
|
|
142 |
|
|
143 |
C-- Step forward fields and calculate time tendency terms |
C-- Step forward fields and calculate time tendency terms |
144 |
CALL DYNAMICS( myThid ) |
CALL TIMER_START('DYNAMICS [MAIN LOOP]',myThid) |
145 |
|
CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid ) |
146 |
|
CALL TIMER_STOP ('DYNAMICS [MAIN LOOP]',myThid) |
147 |
|
|
148 |
|
C-- Do time averages |
149 |
|
#ifdef INCLUDE_DIAGNOSTICS_INTERFACE_CODE |
150 |
|
CALL TIMER_START('I/O (WRITE) [MAIN LOOP]',myThid) |
151 |
|
IF (taveFreq.GT.0.) THEN |
152 |
|
CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid ) |
153 |
|
ENDIF |
154 |
|
CALL TIMER_STOP ('I/O (WRITE) [MAIN LOOP]',myThid) |
155 |
|
#endif |
156 |
|
|
157 |
C-- Do IO if needed. |
C-- Do IO if needed. |
158 |
C Note: |
C Note: |
160 |
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 |
161 |
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. |
162 |
C By convention this is taken to be the model "state". |
C By convention this is taken to be the model "state". |
163 |
|
CALL TIMER_START('I/O (WRITE) [MAIN LOOP]',myThid) |
164 |
CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid ) |
CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid ) |
165 |
|
CALL TIMER_STOP ('I/O (WRITE) [MAIN LOOP]',myThid) |
166 |
|
|
167 |
C-- Solve elliptic equation(s). |
C-- Solve elliptic equation(s). |
168 |
C Two-dimensional only for conventional hydrostatic or |
C Two-dimensional only for conventional hydrostatic or |
169 |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
170 |
|
CALL TIMER_START('SOLVE_FOR_PRESSURE [MAIN LOOP]',myThid) |
171 |
CALL SOLVE_FOR_PRESSURE( myThid ) |
CALL SOLVE_FOR_PRESSURE( myThid ) |
172 |
|
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [MAIN LOOP]',myThid) |
173 |
|
|
174 |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
175 |
|
CALL TIMER_START('BLOCKING_EXCHANGES [MAIN LOOP]',myThid) |
176 |
CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
177 |
|
CALL TIMER_STOP ('BLOCKING_EXCHANGES [MAIN LOOP]',myThid) |
178 |
|
|
179 |
myCurrentIter = myCurrentIter + 1 |
myCurrentIter = myCurrentIter + 1 |
180 |
myCurrentTime = myCurrentTime + deltaTClock |
myCurrentTime = myCurrentTime + deltaTClock |
182 |
C-- Save state for restarts |
C-- Save state for restarts |
183 |
C Note: |
C Note: |
184 |
C ===== |
C ===== |
185 |
C Because of the ordereing of the timestepping code and |
C Because of the ordering of the timestepping code and |
186 |
C tendency term code at end of loop model arrays hold |
C tendency term code at end of loop model arrays hold |
187 |
C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,... |
C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,... |
188 |
C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is |
C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is |
192 |
C cg2d_x.0000000001 in the indexing scheme used for the model |
C cg2d_x.0000000001 in the indexing scheme used for the model |
193 |
C "state" files. This example is referred to as a checkpoint |
C "state" files. This example is referred to as a checkpoint |
194 |
C at time level 1 |
C at time level 1 |
195 |
CALL WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid ) |
CALL TIMER_START('I/O (WRITE) [MAIN LOOP]',myThid) |
196 |
|
CALL |
197 |
|
& WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid ) |
198 |
|
CALL TIMER_STOP ('I/O (WRITE) [MAIN LOOP]',myThid) |
199 |
|
|
200 |
ENDDO |
ENDDO |
201 |
|
CALL TIMER_STOP ('MAIN LOOP',myThid) |
202 |
|
CALL TIMER_START('SPIN-DOWN',myThid) |
203 |
|
|
204 |
C-- Dump for end state and final checkpoint |
C-- Final checkpoint (incase the in-loop checkpoint was missed) |
205 |
CALL WRITE_STATE( myCurrentTime, myCurrentIter, myThid ) |
CALL TIMER_START('I/O (WRITE) [SPIN-DOWN]',myThid) |
206 |
CALL WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid ) |
CALL |
207 |
|
& WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid ) |
208 |
|
CALL TIMER_STOP ('I/O (WRITE) [SPIN-DOWN]',myThid) |
209 |
|
|
210 |
|
C-- Step-forward U/V/Theta/Salt for purposes of final I/O dump |
211 |
|
CALL TIMER_START('DYNAMICS [SPIN-DOWN]',myThid) |
212 |
|
CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid ) |
213 |
|
CALL TIMER_STOP ('DYNAMICS [SPIN-DOWN]',myThid) |
214 |
|
|
215 |
|
C-- Do time averages |
216 |
|
#ifdef ALLOW_DIAGNOSTICS |
217 |
|
IF (taveFreq.GT.0.) THEN |
218 |
|
CALL TIMER_START('I/O (WRITE) [SPIN-DOWN]',myThid) |
219 |
|
CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid ) |
220 |
|
CALL TIMER_STOP ('I/O (WRITE) [SPIN-DOWN]',myThid) |
221 |
|
ENDIF |
222 |
|
#endif |
223 |
|
|
224 |
|
C-- Dump for end state |
225 |
|
CALL TIMER_START('I/O (WRITE) [SPIN-DOWN]',myThid) |
226 |
|
CALL WRITE_STATE( .FALSE., myCurrentTime, myCurrentIter, myThid ) |
227 |
|
CALL TIMER_STOP ('I/O (WRITE) [SPIN-DOWN]',myThid) |
228 |
|
|
229 |
|
CALL TIMER_STOP ('SPIN-DOWN',myThid) |
230 |
|
CALL TIMER_STOP ('ALL',myThid) |
231 |
|
|
232 |
|
C-- Write timer statistics |
233 |
|
IF ( myThid .EQ. 1 ) THEN |
234 |
|
CALL TIMER_PRINTALL( myThid ) |
235 |
|
CALL COMM_STATS |
236 |
|
ENDIF |
237 |
|
|
238 |
RETURN |
RETURN |
239 |
END |
END |