/[MITgcm]/MITgcm/model/src/the_model_main.F
ViewVC logotype

Annotation of /MITgcm/model/src/the_model_main.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.30 - (hide annotations) (download)
Fri Jul 30 15:46:49 1999 UTC (24 years, 10 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint24
Changes since 1.29: +2 -2 lines
Converted ALLOW_DIAGS to INCLUDE_DIAGNOSTICS_INTERFACE_CODE.
This allows the diagnostics I/O to happen for the very last
step of the integration. Spotted by C.E.

1 adcroft 1.30 C $Header: /u/gcmpack/models/MITgcmUV/model/src/the_model_main.F,v 1.29 1999/07/30 15:43:00 adcroft Exp $
2 cnh 1.1
3 adcroft 1.18 #include "CPP_OPTIONS.h"
4 cnh 1.1
5     SUBROUTINE THE_MODEL_MAIN(myThid)
6     C /==========================================================\
7     C | SUBROUTINE THE_MODEL_MAIN |
8     C | o Master controlling routine for model using the MITgcm |
9     C | UV parallel wrapper. |
10     C |==========================================================|
11     C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel |
12     C | wrapper with a single integer argument "myThid". This |
13     C | variable identifies the thread number of an instance of |
14     C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works |
15     C | on a particular region of the models domain and |
16     C | synchronises with other instances as necessary. The |
17     C | routine has to "understand" the MITgcm parallel |
18     C | environment and the numerical algorithm. Editing this |
19     C | routine is best done with some knowledge of both aspects.|
20     C | Notes |
21     C | ===== |
22     C | C*P* comments indicating place holders for which code is |
23     C | presently being developed. |
24     C \==========================================================/
25 adcroft 1.24 IMPLICIT NONE
26 cnh 1.10 C
27     C Call Tree
28     C =========
29     C
30     C main ( eesupp )
31     C |
32     C .
33     C .
34     C . Generic environment initialisation ( see eesupp/src and
35     C . eesupp/inc )
36     C . multiple threads and/or processes are created in here
37     C .
38     C .
39     C .
40     C |
41     C |-THE_MODEL_MAIN - Begin specific model. One instance
42     C | | of this codes exists for each thread
43     C | | and/or instance. Each instance manages
44     C | | a specifc set of tiles.
45     C | |
46     C | |--INITIALISE
47     C | | o Set initial conditions and model configuration
48     C | | Topography, hydrography, timestep, grid, etc..
49     C | |
50     C ==> | | ** Time stepping loop starts here **
51     C | | |
52     C /|\ | |
53     C | | |--LOAD_EXTERNAL_DATA
54     C /|\ | | o Load and/or set time dependent forcing fields
55     C | | |
56     C /|\ | |--DYNAMICS
57     C | | | o Evaluate "forward" terms
58     C /|\ | |
59     C | | |--DO_THE_MODEL_IO
60     C /|\ | | o Write model state
61     C | | |
62     C /|\ | |--SOLVE_FOR_PRESSURE
63     C | | | o Find pressure field to keep flow non-divergent
64     C /|\ | |
65     C | | |--DO_GTERM_BLOCKING_EXCHANGES
66     C /|\ | | o Update overlap regions
67     C | | |
68     C /|\ | |--WRITE_CHECKPOINT
69     C | | | o Write restart file(s)
70     C /|\ | |
71     C | | |
72     C |<== | | ** Time stepping loop finishes here **
73     C | |
74     C | |--WRITE_STATE
75 adcroft 1.17 C | |--WRITE_CHECKPOINT
76 cnh 1.10 C |
77     C .
78     C .
79     C . Generic environment termination ( see eesupp/src and
80     C . eesupp/inc )
81     C .
82     C .
83 cnh 1.1
84     C == Global variables ===
85     #include "SIZE.h"
86     #include "EEPARAMS.h"
87     #include "PARAMS.h"
88 adcroft 1.26 #include "DYNVARS.h"
89 cnh 1.1 #include "CG2D.h"
90 adcroft 1.27 #ifdef ALLOW_NONHYDROSTATIC
91 adcroft 1.26 #include "CG3D.h"
92 adcroft 1.27 #endif
93 cnh 1.1
94     C == Routine arguments ==
95     C myThid - Thread number for this instance of the routine.
96 cnh 1.6 INTEGER myThid
97 cnh 1.1
98     C == Local variables ==
99 cnh 1.7 C Note: Under the multi-threaded model myCurrentIter and
100     C myCurrentTime are local variables passed around as routine
101     C arguments. Although this is fiddly it saves the need to
102     C impose additional synchronisation points when they are
103     C updated.
104 cnh 1.1 C myCurrentIter - Iteration counter for this thread
105     C myCurrentTime - Time counter for this thread
106     C I - Loop counter
107     INTEGER I, myCurrentIter
108 adcroft 1.29 _RL myCurrentTime
109 cnh 1.1
110 adcroft 1.19 C-- This timer encompasses the whole code
111     CALL TIMER_START('ALL',myThid)
112    
113     CALL TIMER_START('SPIN-UP',myThid)
114    
115 cnh 1.1 C-- Set model initial conditions
116 adcroft 1.19 CALL TIMER_START('INITIALISE [SPIN-UP]',myThid)
117 cnh 1.1 CALL INITIALISE( myThid )
118     myCurrentTime = startTime
119     myCurrentIter = nIter0
120 adcroft 1.19 CALL TIMER_STOP ('INITIALISE [SPIN-UP]',myThid)
121 cnh 1.1
122 adcroft 1.15 C-- Dump for start state
123 adcroft 1.19 CALL TIMER_START('I/O (WRITE) [SPIN-UP]',myThid)
124 adcroft 1.15 CALL WRITE_STATE( .TRUE., myCurrentTime, myCurrentIter, myThid )
125 adcroft 1.19 CALL TIMER_STOP ('I/O (WRITE) [SPIN-UP]',myThid)
126    
127     CALL TIMER_STOP ('SPIN-UP',myThid)
128 adcroft 1.15
129 cnh 1.1 C-- Begin time stepping loop
130 adcroft 1.19 CALL TIMER_START('MAIN LOOP',myThid)
131 cnh 1.1 DO I=1, nTimeSteps
132 cnh 1.4
133 cnh 1.11 C-- Load forcing/external data fields
134 adcroft 1.19 CALL TIMER_START('I/O (READ) [MAIN LOOP]',myThid)
135 cnh 1.11 CALL LOAD_EXTERNAL_FIELDS( myCurrentTime, myCurrentIter, myThid )
136 adcroft 1.19 CALL TIMER_STOP ('I/O (READ) [MAIN LOOP]',myThid)
137 cnh 1.1
138 cnh 1.22 #ifdef INCLUDE_SHAPIRO_FILTER_CODE
139     C-- Step forward all tiles, filter and exchange.
140     CALL TIMER_START('SHAP_FILT [MAIN LOOP]',myThid)
141     CALL SHAP_FILT( myCurrentTime, myCurrentIter, myThid )
142     CALL TIMER_STOP ('SHAP_FILT [MAIN LOOP]',myThid)
143     #endif
144    
145 adcroft 1.28 #ifdef ALLOW_OBCS
146 adcroft 1.23 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 adcroft 1.28 #endif
153 cnh 1.22
154 cnh 1.1 C-- Step forward fields and calculate time tendency terms
155 adcroft 1.19 CALL TIMER_START('DYNAMICS [MAIN LOOP]',myThid)
156 cnh 1.8 CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )
157 adcroft 1.19 CALL TIMER_STOP ('DYNAMICS [MAIN LOOP]',myThid)
158 cnh 1.1
159 adcroft 1.26 #ifdef ALLOW_NONHYDROSTATIC
160     C-- Step forward W field in N-H algorithm
161     IF ( nonHydrostatic ) THEN
162     CALL TIMER_START('CALC_GW [MAIN LOOP]',myThid)
163     CALL CALC_GW( myThid)
164     CALL TIMER_STOP ('CALC_GW [MAIN LOOP]',myThid)
165     ENDIF
166     #endif
167    
168 adcroft 1.14 C-- Do time averages
169 cnh 1.22 #ifdef INCLUDE_DIAGNOSTICS_INTERFACE_CODE
170 adcroft 1.19 CALL TIMER_START('I/O (WRITE) [MAIN LOOP]',myThid)
171 adcroft 1.14 IF (taveFreq.GT.0.) THEN
172 adcroft 1.17 CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid )
173 adcroft 1.14 ENDIF
174 adcroft 1.19 CALL TIMER_STOP ('I/O (WRITE) [MAIN LOOP]',myThid)
175 adcroft 1.17 #endif
176 adcroft 1.14
177 cnh 1.7 C-- Do IO if needed.
178     C Note:
179     C =====
180     C At this point model arrays hold U,V,T,S at "time-level" N
181     C and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1.
182     C By convention this is taken to be the model "state".
183 adcroft 1.19 CALL TIMER_START('I/O (WRITE) [MAIN LOOP]',myThid)
184 cnh 1.7 CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid )
185 adcroft 1.19 CALL TIMER_STOP ('I/O (WRITE) [MAIN LOOP]',myThid)
186 adcroft 1.26
187 cnh 1.1 C-- Solve elliptic equation(s).
188 cnh 1.7 C Two-dimensional only for conventional hydrostatic or
189     C three-dimensional for non-hydrostatic and/or IGW scheme.
190 adcroft 1.19 CALL TIMER_START('SOLVE_FOR_PRESSURE [MAIN LOOP]',myThid)
191 cnh 1.1 CALL SOLVE_FOR_PRESSURE( myThid )
192 adcroft 1.19 CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [MAIN LOOP]',myThid)
193 cnh 1.1
194     C-- Do "blocking" sends and receives for tendency "overlap" terms
195 adcroft 1.19 CALL TIMER_START('BLOCKING_EXCHANGES [MAIN LOOP]',myThid)
196 cnh 1.1 CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
197 adcroft 1.19 CALL TIMER_STOP ('BLOCKING_EXCHANGES [MAIN LOOP]',myThid)
198 cnh 1.1
199     myCurrentIter = myCurrentIter + 1
200 cnh 1.7 myCurrentTime = myCurrentTime + deltaTClock
201 cnh 1.1
202     C-- Save state for restarts
203 cnh 1.7 C Note:
204     C =====
205 adcroft 1.12 C Because of the ordering of the timestepping code and
206 cnh 1.7 C tendency term code at end of loop model arrays hold
207     C U,V,T,S at "time-level" N but gu, gv, gs, gt, guNM1,...
208     C at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is
209     C gu at "time-level" N-1/2) and cg2d_x at "time-level" N+1/2.
210     C where N = I+timeLevBase-1
211     C Thus a checkpoint contains U.0000000000, GU.0000000001 and
212     C cg2d_x.0000000001 in the indexing scheme used for the model
213     C "state" files. This example is referred to as a checkpoint
214     C at time level 1
215 adcroft 1.19 CALL TIMER_START('I/O (WRITE) [MAIN LOOP]',myThid)
216 cnh 1.21 CALL
217     & WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid )
218 adcroft 1.19 CALL TIMER_STOP ('I/O (WRITE) [MAIN LOOP]',myThid)
219 cnh 1.1
220     ENDDO
221 adcroft 1.19 CALL TIMER_STOP ('MAIN LOOP',myThid)
222     CALL TIMER_START('SPIN-DOWN',myThid)
223 adcroft 1.13
224 adcroft 1.12 C-- Final checkpoint (incase the in-loop checkpoint was missed)
225 adcroft 1.19 CALL TIMER_START('I/O (WRITE) [SPIN-DOWN]',myThid)
226 cnh 1.21 CALL
227     & WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid )
228 adcroft 1.19 CALL TIMER_STOP ('I/O (WRITE) [SPIN-DOWN]',myThid)
229 adcroft 1.23
230 adcroft 1.28 #ifdef ALLOW_OBCS
231 adcroft 1.23 C-- Set Open Boundaries Values
232     IF (openBoundaries) THEN
233     CALL TIMER_START('OBCS [SPIN_DOWN]',myThid)
234     CALL SET_OBCS( myCurrentTime, myThid )
235     CALL TIMER_STOP ('OBCS [SPIN_DOWN]',myThid)
236     ENDIF
237 adcroft 1.28 #endif
238 adcroft 1.12
239     C-- Step-forward U/V/Theta/Salt for purposes of final I/O dump
240 adcroft 1.19 CALL TIMER_START('DYNAMICS [SPIN-DOWN]',myThid)
241 adcroft 1.12 CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )
242 adcroft 1.19 CALL TIMER_STOP ('DYNAMICS [SPIN-DOWN]',myThid)
243 adcroft 1.26
244     #ifdef ALLOW_NONHYDROSTATIC
245     IF ( nonHydrostatic ) THEN
246     C-- Step forward W field in N-H algorithm
247     CALL TIMER_START('CALC_GW [SPIN-DOWN]',myThid)
248     CALL CALC_GW( myThid)
249     CALL TIMER_STOP ('CALC_GW [SPIN-DOWN]',myThid)
250     ENDIF
251     #endif
252 adcroft 1.14
253     C-- Do time averages
254 adcroft 1.30 #ifdef INCLUDE_DIAGNOSTICS_INTERFACE_CODE
255 adcroft 1.14 IF (taveFreq.GT.0.) THEN
256 adcroft 1.19 CALL TIMER_START('I/O (WRITE) [SPIN-DOWN]',myThid)
257     CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid )
258     CALL TIMER_STOP ('I/O (WRITE) [SPIN-DOWN]',myThid)
259 adcroft 1.14 ENDIF
260 adcroft 1.17 #endif
261 adcroft 1.12
262     C-- Dump for end state
263 adcroft 1.19 CALL TIMER_START('I/O (WRITE) [SPIN-DOWN]',myThid)
264 adcroft 1.15 CALL WRITE_STATE( .FALSE., myCurrentTime, myCurrentIter, myThid )
265 adcroft 1.19 CALL TIMER_STOP ('I/O (WRITE) [SPIN-DOWN]',myThid)
266    
267     CALL TIMER_STOP ('SPIN-DOWN',myThid)
268     CALL TIMER_STOP ('ALL',myThid)
269 cnh 1.7
270 adcroft 1.19 C-- Write timer statistics
271 cnh 1.20 IF ( myThid .EQ. 1 ) THEN
272     CALL TIMER_PRINTALL( myThid )
273     CALL COMM_STATS
274     ENDIF
275 cnh 1.1
276     RETURN
277     END

  ViewVC Help
Powered by ViewVC 1.1.22