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

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

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


Revision 1.62 - (show annotations) (download)
Thu Oct 23 07:14:49 2003 UTC (20 years, 7 months ago) by dimitri
Branch: MAIN
CVS Tags: checkpoint51n_post
Branch point for: checkpoint51n_branch
Changes since 1.61: +36 -37 lines
o modifications to make FREEZE flux visible to pkg/kpp
  - moved surfaceTendencyTice from pkg/seaice to main code
  - FREEZE & EXTERNAL_FORCING_SURF moved to FORWARD_STEP
  - subroutine FREEZE now limits only surface temperature
    (this means new output.txt for global_ocean.90x40x15,
     global_ocean.cs32x15, and global_with_exf)
o added surface flux output variables to TIMEAVE_STATVARS

1 C $Header: /usr/local/gcmpack/MITgcm/model/src/the_model_main.F,v 1.61 2003/10/23 04:41:40 edhill Exp $
2 C $Name: $
3
4 CBOI
5 C
6 C !TITLE: MITGCM KERNEL CODE SYNOPSIS
7 C !AUTHORS: mitgcm developers ( support@mitgcm.org )
8 C !AFFILIATION: Massachussetts Institute of Technology
9 C !DATE:
10 C !INTRODUCTION: Kernel dynamical routines
11 C This document summarises MITgcm code under the model/ subdirectory.
12 C The code under model/ ( src/ and inc/ ) contains most of
13 C the driver routines for the baseline forms of the kernel equations in the
14 C MITgcm algorithm. Numerical code for much of the baseline forms of
15 C these equations is also under the model/ directory. Other numerical code
16 C used for the kernel equations is contained in packages in the pkg/
17 C directory tree.
18 C Code for auxilliary equations and alternate dicretizations of the kernel
19 C equations and algorithm can also be found in the pkg/ directory tree.
20 C
21 C \subsection{Getting Help and Reporting Errors and Problems}
22 C If you have questions please e-mail support@mitgcm.org. We also welcome
23 C reports of errors and inconsistencies in the code or in the accompanying
24 C documentation. Please feel free to send these
25 C to support@mitgcm.org. For further information and to review
26 C problems reported to support@mitgcm.org please visit http://mitgcm.org.
27 C
28 C \subsection{MITgcm Kernel Code Calling Sequence}
29 C \bv
30 C
31 C Invocation from WRAPPER level...
32 C :
33 C :
34 C |
35 C |-THE_MODEL_MAIN :: Primary driver for the MITgcm algorithm
36 C | :: Called from WRAPPER level numerical
37 C | :: code innvocation routine. On entry
38 C | :: to THE_MODEL_MAIN separate thread and
39 C | :: separate processes will have been established.
40 C | :: Each thread and process will have a unique ID
41 C | :: but as yet it will not be associated with a
42 C | :: specific region in decomposed discrete space.
43 C |
44 C |-INITIALISE_FIXED :: Set fixed model arrays such as topography,
45 C | | :: grid, solver matrices etc..
46 C | |
47 C | |-INI_PARMS :: Routine to set kernel model parameters.
48 C | | :: By default kernel parameters are read from file
49 C | | :: "data" in directory in which code executes.
50 C | |
51 C | |-MON_INIT :: Initialises monitor pacakge ( see pkg/monitor )
52 C | |
53 C | |-INI_GRID :: Control grid array (vert. and hori.) initialisation.
54 C | | | :: Grid arrays are held and described in GRID.h.
55 C | | |
56 C | | |-INI_VERTICAL_GRID :: Initialise vertical grid arrays.
57 C | | |
58 C | | |-INI_CARTESIAN_GRID :: Cartesian horiz. grid initialisation
59 C | | | :: (calculate grid from kernel parameters).
60 C | | |
61 C | | |-INI_SPHERICAL_POLAR_GRID :: Spherical polar horiz. grid
62 C | | | :: initialisation (calculate grid from
63 C | | | :: kernel parameters).
64 C | | |
65 C | | |-INI_CURVILINEAR_GRID :: General orthogonal, structured horiz.
66 C | | :: grid initialisations. ( input from raw
67 C | | :: grid files, LONC.bin, DXF.bin etc... )
68 C | |
69 C | |-INI_DEPTHS :: Read (from "bathyFile") or set bathymetry/orgography.
70 C | |
71 C | |-INI_MASKS_ETC :: Derive horizontal and vertical cell fractions and
72 C | | :: land masking for solid-fluid boundaries.
73 C | |
74 C | |-INI_LINEAR_PHSURF :: Set ref. surface Bo_surf
75 C | |
76 C | |-INI_CORI :: Set coriolis term. zero, f-plane, beta-plane,
77 C | | :: sphere optins are coded.
78 C | |
79 C | |-PACAKGES_BOOT :: Start up the optional package environment.
80 C | | :: Runtime selection of active packages.
81 C | |
82 C | |-PACKAGES_READPARMS :: Call active package internal parameter load.
83 C | | |
84 C | | |-GMREDI_READPARMS :: GM Package. see pkg/gmredi
85 C | | |-KPP_READPARMS :: KPP Package. see pkg/kpp
86 C | | |-SHAP_FILT_READPARMS :: Shapiro filter package. see pkg/shap_filt
87 C | | |-OBCS_READPARMS :: Open bndy package. see pkg/obcs
88 C | | |-AIM_READPARMS :: Intermediate Atmos. pacakage. see pkg/aim
89 C | | |-COST_READPARMS :: Cost function package. see pkg/cost
90 C | | |-CTRL_INIT :: Control vector support package. see pkg/ctrl
91 C | | |-OPTIM_READPARMS :: Optimisation support package. see pkg/ctrl
92 C | | |-GRDCHK_READPARMS :: Gradient check package. see pkg/grdchk
93 C | | |-ECCO_READPARMS :: ECCO Support Package. see pkg/ecco
94 C | | |-PTRACERS_READPARMS :: multiple tracer package, see pkg/ptracers
95 C | | |-GCHEM_READPARMS :: tracer interface package, see pkg/gchem
96 C | |
97 C | |-PACKAGES_CHECK
98 C | | |
99 C | | |-KPP_CHECK :: KPP Package. pkg/kpp
100 C | | |-OBCS_CHECK :: Open bndy Pacakge. pkg/obcs
101 C | | |-GMREDI_CHECK :: GM Package. pkg/gmredi
102 C | |
103 C | |-PACKAGES_INIT_FIXED
104 C | | |-OBCS_INIT_FIXED :: Open bndy Package. see pkg/obcs
105 C | | |-FLT_INIT :: Floats Package. see pkg/flt
106 C | | |-GCHEM_INIT_FIXED :: tracer interface pachage, see pkg/gchem
107 C | |
108 C | |-ZONAL_FILT_INIT :: FFT filter Package. see pkg/zonal_filt
109 C | |
110 C | |-INI_CG2D :: 2d con. grad solver initialisation.
111 C | |
112 C | |-INI_CG3D :: 3d con. grad solver initialisation.
113 C | |
114 C | |-CONFIG_SUMMARY :: Provide synopsis of kernel setup.
115 C | :: Includes annotated table of kernel
116 C | :: parameter settings.
117 C |
118 C |-CTRL_UNPACK :: Control vector support package. see pkg/ctrl
119 C |
120 C |-ADTHE_MAIN_LOOP :: Derivative evaluating form of main time stepping loop
121 C ! :: Auotmatically gerenrated by TAMC/TAF.
122 C |
123 C |-CTRL_PACK :: Control vector support package. see pkg/ctrl
124 C |
125 C |-GRDCHK_MAIN :: Gradient check package. see pkg/grdchk
126 C |
127 C |-THE_MAIN_LOOP :: Main timestepping loop routine.
128 C | |
129 C | |-INITIALISE_VARIA :: Set the initial conditions for time evolving
130 C | | | :: variables
131 C | | |
132 C | | |-INI_LINEAR_PHISURF :: Set ref. surface Bo_surf
133 C | | |
134 C | | |-INI_CORI :: Set coriolis term. zero, f-plane, beta-plane,
135 C | | | :: sphere optins are coded.
136 C | | |
137 C | | |-INI_CG2D :: 2d con. grad solver initialisation.
138 C | | |-INI_CG3D :: 3d con. grad solver initialisation.
139 C | | |-INI_MIXING :: Initialise diapycnal diffusivity.
140 C | | |-INI_DYNVARS :: Initialise to zero all DYNVARS.h arrays (dynamical
141 C | | | :: fields).
142 C | | |
143 C | | |-INI_FIELDS :: Control initialising model fields to non-zero
144 C | | | |-INI_VEL :: Initialize 3D flow field.
145 C | | | |-INI_THETA :: Set model initial temperature field.
146 C | | | |-INI_SALT :: Set model initial salinity field.
147 C | | | |-INI_PSURF :: Set model initial free-surface height/pressure.
148 C | | | |-INI_PRESSURE :: Compute model initial hydrostatic pressure
149 C | | |
150 C | | |-INI_TR1 :: Set initial tracer 1 distribution.
151 C | | |
152 C | | |-THE_CORRECTION_STEP :: Step forward to next time step.
153 C | | | | :: Here applied to move restart conditions
154 C | | | | :: (saved in mid timestep) to correct level in
155 C | | | | :: time (only used for pre-c35).
156 C | | | |
157 C | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure
158 C | | | |-CORRECTION_STEP :: Pressure correction to momentum
159 C | | | |-CYCLE_TRACER :: Move tracers forward in time.
160 C | | | |-OBCS_APPLY :: Open bndy package. see pkg/obcs
161 C | | | |-SHAP_FILT_APPLY :: Shapiro filter package. see pkg/shap_filt
162 C | | | |-ZONAL_FILT_APPLY :: FFT filter package. see pkg/zonal_filt
163 C | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing.
164 C | | | | |-FIND_RHO :: Find adjacent densities.
165 C | | | | |-CONVECT :: Mix static instability.
166 C | | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
167 C | | | |
168 C | | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
169 C | | |
170 C | | |-CONVECTIVE_ADJUSTMENT_INI :: Control static instability mixing
171 C | | | | :: Extra time history interactions.
172 C | | | |
173 C | | | |-FIND_RHO :: Find adjacent densities.
174 C | | | |-CONVECT :: Mix static instability.
175 C | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
176 C | | |
177 C | | |-PACKAGES_INIT_VARIABLES:: Does initialisation of time evolving
178 C | | | | package data.
179 C | | | |
180 C | | | |-GMREDI_INIT :: GM package ( see pkg/gmredi ).
181 C | | | |-KPP_INIT :: KPP package ( see pkg/kpp ).
182 C | | | |-KPP_OPEN_DIAGS
183 C | | | |-OBCS_INIT_VARIABLES :: Open bndy. package ( see pkg/obcs ).
184 C | | | |-PTRACERS_INIT :: Multi tracer package ( see pkg/ptracers ).
185 C | | | |-GCHEM_INIT :: Tracer interface pkg ( see pkh/gchem ).
186 C | | | |-AIM_INIT :: Interm. atmos package ( see pkg/aim ).
187 C | | | |-CTRL_MAP_INI :: Control vector package( see pkg/ctrl ).
188 C | | | |-COST_INIT :: Cost function package ( see pkg/cost ).
189 C | | | |-ECCO_INIT :: ECCO support package ( see pkg/ecco ).
190 C | | | |-INI_FORCING :: Set model initial forcing fields.
191 C | | | | :: Either set in-line or from file as shown.
192 C | | | |-READ_FLD_XY_RS(zonalWindFile)
193 C | | | |-READ_FLD_XY_RS(meridWindFile)
194 C | | | |-READ_FLD_XY_RS(surfQFile)
195 C | | | |-READ_FLD_XY_RS(EmPmRfile)
196 C | | | |-READ_FLD_XY_RS(thetaClimFile)
197 C | | | |-READ_FLD_XY_RS(saltClimFile)
198 C | | | |-READ_FLD_XY_RS(surfQswFile)
199 C | | |
200 C | | |-CALC_SURF_DR :: Calculate the new surface level thickness.
201 C | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
202 C | | |-UPDATE_CG2D :: Update 2d conjugate grad. for Free-Surf.
203 C | | |-STATE_SUMMARY :: Summarize model prognostic variables.
204 C | | |-TIMEAVE_STATVARS :: Time averaging package ( see pkg/timeave ).
205 C | |
206 C | |-WRITE_STATE :: Controlling routine for IO to dump model state.
207 C | | |-WRITE_REC_XYZ_RL :: Single file I/O
208 C | | |-WRITE_FLD_XYZ_RL :: Multi-file I/O
209 C | |
210 C | |-MONITOR :: Monitor state ( see pkg/monitor )
211 C | |-CTRL_MAP_FORCING :: Control vector support package. ( see pkg/ctrl )
212 C====|>|
213 C====|>| ****************************
214 C====|>| BEGIN MAIN TIMESTEPPING LOOP
215 C====|>| ****************************
216 C====|>|
217 C/\ | |-FORWARD_STEP :: Step forward a time-step ( AT LAST !!! ).
218 C/\ | | |
219 C/\ | | |-DUMMY_IN_STEPPING :: Autodiff package ( pkg/autoduff ).
220 C/\ | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
221 C/\ | | |-CALC_SURF_DR :: Calculate the new surface level thickness.
222 C/\ | | |-EXF_GETFORCING :: External forcing package ( pkg/exf ).
223 C/\ | | |-EXTERNAL_FIELDS_LOAD :: Control loading time dep. external data.
224 C/\ | | | | Simple interpolcation between end-points
225 C/\ | | | | for forcing datasets.
226 C/\ | | | |-EXCH :: Sync forcing in overlap regions.
227 C/\ | | |-SEAICE_MODEL :: Compute sea-ice terms ( pkg/seaice ).
228 C/\ | | |-FREEZE :: Limit surface temperature.
229 C/\ | | |-EXTERNAL_FORCING_SURF :: Accumulates appropriately dimensioned
230 C/\ | | | | forcing terms.
231 C/\ | | | |-PTRACERS_FORCING_SURF:: Tracer package ( see pkg/ptracers ).
232 C/\ | | |-GCHEM_FIELD_LOAD :: Load tracer forcing fields ( pkg/gchem ).
233 C/\ | | |
234 C/\ | | |-THERMODYNAMICS :: theta, salt + tracer equations driver.
235 C/\ | | | |
236 C/\ | | | |-INTEGRATE_FOR_W :: Integrate for vertical velocity.
237 C/\ | | | |-OBCS_APPLY_W :: Open bndy. package ( see pkg/obcs ).
238 C/\ | | | |-FIND_RHO :: Calculates [rho(S,T,z)-RhoConst] of a slice
239 C/\ | | | |-GRAD_SIGMA :: Calculate isoneutral gradients
240 C/\ | | | |-CALC_IVDC :: Set Implicit Vertical Diffusivity for Convection
241 C/\ | | | |
242 C/\ | | | |-OBCS_CALC :: Open bndy. package ( see pkg/obcs ).
243 C/\ | | | |
244 C/\ | | | |-GMREDI_CALC_TENSOR :: GM package ( see pkg/gmredi ).
245 C/\ | | | |-GMREDI_CALC_TENSOR_DUMMY :: GM package ( see pkg/gmredi ).
246 C/\ | | | |-KPP_CALC :: KPP package ( see pkg/kpp ).
247 C/\ | | | |-KPP_CALC_DUMMY :: KPP package ( see pkg/kpp ).
248 C/\ | | | |-AIM_DO_ATMOS_PHYSICS :: Intermed. atmos package ( see pkg/aim ).
249 C/\ | | | |-GAD_ADVECTION :: Generalised advection driver (multi-dim
250 C/\ | | | | advection case) (see pkg/gad).
251 C/\ | | | |-CALC_COMMON_FACTORS :: Calculate common data (such as volume flux)
252 C/\ | | | |-CALC_DIFFUSIVITY :: Calculate net vertical diffusivity
253 C/\ | | | | |
254 C/\ | | | | |-GMREDI_CALC_DIFF :: GM package ( see pkg/gmredi ).
255 C/\ | | | | |-KPP_CALC_DIFF :: KPP package ( see pkg/kpp ).
256 C/\ | | | |
257 C/\ | | | |-CALC_GT :: Calculate the temperature tendency terms
258 C/\ | | | | |
259 C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
260 C/\ | | | | | | :: ( see pkg/gad )
261 C/\ | | | | | |-KPP_TRANSPORT_T :: KPP non-local transport ( see pkg/kpp ).
262 C/\ | | | | |
263 C/\ | | | | |-EXTERNAL_FORCING_T :: Problem specific forcing for temperature.
264 C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
265 C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gt for free-surface height.
266 C/\ | | | |
267 C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
268 C/\ | | | |
269 C/\ | | | |-CALC_GS :: Calculate the salinity tendency terms
270 C/\ | | | | |
271 C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
272 C/\ | | | | | | :: ( see pkg/gad )
273 C/\ | | | | | |-KPP_TRANSPORT_S :: KPP non-local transport ( see pkg/kpp ).
274 C/\ | | | | |
275 C/\ | | | | |-EXTERNAL_FORCING_S :: Problem specific forcing for salt.
276 C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
277 C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
278 C/\ | | | |
279 C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
280 C/\ | | | |
281 C/\ | | | |-CALC_GTR1 :: Calculate other tracer(s) tendency terms
282 C/\ | | | | |
283 C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
284 C/\ | | | | | :: ( see pkg/gad )
285 C/\ | | | | |
286 C/\ | | | | |-EXTERNAL_FORCING_TR:: Problem specific forcing for tracer.
287 C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
288 C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
289 C/\ | | | |
290 C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
291 C/\ | | | |
292 C/\ | | | |-PTRACERS_INTEGRATE :: Integrate other tracer(s) ( pkg/ptracers ).
293 C/\ | | | | |
294 C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
295 C/\ | | | | | | :: ( see pkg/gad )
296 C/\ | | | | | |-KPP_TRANSPORT_PTR:: KPP non-local transport ( see pkg/kpp ).
297 C/\ | | | | |
298 C/\ | | | | |-PTRACERS_FORCING :: Problem specific forcing for tracer.
299 C/\ | | | | |-GCHEM_FORCING_INT :: tracer forcing for gchem pkg (if all
300 C/\ | | | | | tendancy terms calcualted together)
301 C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
302 C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
303 C/\ | | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
304 C/\ | | | |
305 C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ).
306 C/\ | | | |
307 C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation.
308 C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ).
309 C/\ | | | |
310 C/\ | | | |-AIM_AIM2DYN_EXCHANGES:: Intermediate atmosphere (see pkg/aim).
311 C/\ | | | |-EXCH :: Update overlaps
312 C/\ | | |
313 C/\ | | |-DYNAMICS :: Momentum equations driver.
314 C/\ | | | |
315 C/\ | | | |-CALC_GRAD_PHI_SURF :: Calculate the gradient of the surface
316 C/\ | | | | Potential anomaly.
317 C/\ | | | |-CALC_VISCOSITY :: Calculate net vertical viscosity
318 C/\ | | | | |-KPP_CALC_VISC :: KPP package ( see pkg/kpp ).
319 C/\ | | | |
320 C/\ | | | |-CALC_PHI_HYD :: Integrate the hydrostatic relation.
321 C/\ | | | |-MOM_FLUXFORM :: Flux form mom eqn. package ( see
322 C/\ | | | | pkg/mom_fluxform ).
323 C/\ | | | |-MOM_VECINV :: Vector invariant form mom eqn. package ( see
324 C/\ | | | | pkg/mom_vecinv ).
325 C/\ | | | |-TIMESTEP :: Step momentum fields forward in time
326 C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ).
327 C/\ | | | |
328 C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation.
329 C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ).
330 C/\ | | | |
331 C/\ | | | |-TIMEAVE_CUMUL_1T :: Time averaging package ( see pkg/timeave ).
332 C/\ | | | |-TIMEAVE_CUMUATE :: Time averaging package ( see pkg/timeave ).
333 C/\ | | | |-DEBUG_STATS_RL :: Quick debug package ( see pkg/debug ).
334 C/\ | | |
335 C/\ | | |-CALC_GW :: vert. momentum tendency terms ( NH, QH only ).
336 C/\ | | |
337 C/\ | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
338 C/\ | | |
339 C/\ | | |-UPDATE_CG2D :: Update 2d conjugate grad. for Free-Surf.
340 C/\ | | |
341 C/\ | | |-SOLVE_FOR_PRESSURE :: Find surface pressure.
342 C/\ | | | |-CALC_DIV_GHAT :: Form the RHS of the surface pressure eqn.
343 C/\ | | | |-CG2D :: Two-dim pre-con. conjugate-gradient.
344 C/\ | | | |-CG3D :: Three-dim pre-con. conjugate-gradient solver.
345 C/\ | | |
346 C/\ | | |-THE_CORRECTION_STEP :: Step forward to next time step.
347 C/\ | | | |
348 C/\ | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure
349 C/\ | | | |-CORRECTION_STEP :: Pressure correction to momentum
350 C/\ | | | |-CYCLE_TRACER :: Move tracers forward in time.
351 C/\ | | | |-OBCS_APPLY :: Open bndy package. see pkg/obcs
352 C/\ | | | |-SHAP_FILT_APPLY :: Shapiro filter package. see pkg/shap_filt
353 C/\ | | | |-ZONAL_FILT_APPLY :: FFT filter package. see pkg/zonal_filt
354 C/\ | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing.
355 C/\ | | | | |-FIND_RHO :: Find adjacent densities.
356 C/\ | | | | |-CONVECT :: Mix static instability.
357 C/\ | | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
358 C/\ | | | |
359 C/\ | | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
360 C/\ | | |
361 C/\ | | |-DO_FIELDS_BLOCKING_EXCHANGES :: Sync up overlap regions.
362 C/\ | | | |-EXCH
363 C/\ | | |
364 C/\ | | |-GCHEM_FORCING_SEP :: tracer forcing for gchem pkg (if
365 C/\ | | | tracer dependent tendencies calculated
366 C/\ | | | separatly)
367 C/\ | | |
368 C/\ | | |-FLT_MAIN :: Float package ( pkg/flt ).
369 C/\ | | |
370 C/\ | | |-MONITOR :: Monitor package ( pkg/monitor ).
371 C/\ | | |
372 C/\ | | |-DO_THE_MODEL_IO :: Standard diagnostic I/O.
373 C/\ | | | |-WRITE_STATE :: Core state I/O
374 C/\ | | | |-TIMEAVE_STATV_WRITE :: Time averages. see pkg/timeave
375 C/\ | | | |-AIM_WRITE_DIAGS :: Intermed. atmos diags. see pkg/aim
376 C/\ | | | |-GMREDI_DIAGS :: GM diags. see pkg/gmredi
377 C/\ | | | |-KPP_DO_DIAGS :: KPP diags. see pkg/kpp
378 C/\ | | | |-SBO_CALC :: SBO diags. see pkg/sbo
379 C/\ | | | |-SBO_DIAGS :: SBO diags. see pkg/sbo
380 C/\ | | | |-GCHEM_DIAGS :: gchem diags. see pkg/gchem
381 C/\ | | |
382 C/\ | | |-WRITE_CHECKPOINT :: Do I/O for restart files.
383 C/\ | |
384 C/\ | |-COST_TILE :: Cost function package. ( see pkg/cost )
385 C<===|=|
386 C<===|=| **************************
387 C<===|=| END MAIN TIMESTEPPING LOOP
388 C<===|=| **************************
389 C<===|=|
390 C | |-COST_FINAL :: Cost function package. ( see pkg/cost )
391 C |
392 C |-WRITE_CHECKPOINT :: Final state storage, for restart.
393 C |
394 C |-TIMER_PRINTALL :: Computational timing summary
395 C |
396 C |-COMM_STATS :: Summarise inter-proc and inter-thread communication
397 C :: events.
398 C \ev
399 C
400 C
401 CEOI
402
403
404 #include "AD_CONFIG.h"
405 #include "PACKAGES_CONFIG.h"
406 #include "CPP_OPTIONS.h"
407
408 CBOP
409
410 C !ROUTINE: THE_MODEL_MAIN
411
412 C !INTERFACE:
413 SUBROUTINE THE_MODEL_MAIN(myThid)
414 IMPLICIT NONE
415
416 C !DESCRIPTION: \bv
417 C *==========================================================*
418 C | SUBROUTINE THE_MODEL_MAIN
419 C | o Master controlling routine for model using the MITgcm
420 C | UV parallel wrapper.
421 C *==========================================================*
422 C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel
423 C | wrapper with a single integer argument "myThid". This
424 C | variable identifies the thread number of an instance of
425 C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works
426 C | on a particular region of the models domain and
427 C | synchronises with other instances as necessary. The
428 C | routine has to "understand" the MITgcm parallel
429 C | environment and the numerical algorithm. Editing this
430 C | routine is best done with some knowledge of both aspects.
431 C | Notes
432 C | =====
433 C | C*P* comments indicating place holders for which code is
434 C | presently being developed.
435 C *==========================================================*
436 C \ev
437
438 C !CALLING SEQUENCE:
439 C THE_MODEL_MAIN()
440 C |
441 C |
442 C |--INITIALISE_FIXED
443 C | o Set model configuration (fixed arrays)
444 C | Topography, hydrography, timestep, grid, etc..
445 C |
446 C |--CTRL_UNPACK o Derivative mode. Unpack control vector.
447 C |
448 C |--ADTHE_MAIN_LOOP o Main timestepping loop for combined
449 C | prognostic and reverse mode integration.
450 C |
451 C |--CTRL_PACK o Derivative mode. Unpack control vector.
452 C |
453 C |--GRDCHK_MAIN o Gradient check control routine.
454 C |
455 C |--THE_MAIN_LOOP o Main timestepping loop for pure prognostic
456 C | integration.
457 C |
458 C |--WRITE_CHECKPOINT o Write retsart information.
459 C |
460 C |--TIMER_PRINTALL o Print out timing statistics.
461 C |
462 C |--COMM_STATS o Print out communication statistics.
463
464 C !USES:
465 C == Global variables ===
466 #include "SIZE.h"
467 #include "EEPARAMS.h"
468 #include "PARAMS.h"
469 #include "DYNVARS.h"
470 #ifdef ALLOW_NONHYDROSTATIC
471 #include "CG3D.h"
472 #endif
473
474 #ifdef ALLOW_AUTODIFF_TAMC
475 #include "tamc.h"
476 #endif
477
478 C !INPUT/OUTPUT PARAMETERS:
479 C == Routine arguments ==
480 C myThid - Thread number for this instance of the routine.
481 INTEGER myThid
482
483 C !LOCAL VARIABLES:
484 C == Local variables ==
485 C Note: Under the multi-threaded model myCurrentIter and
486 C myCurrentTime are local variables passed around as routine
487 C arguments. Although this is fiddly it saves the need to
488 C impose additional synchronisation points when they are
489 C updated.
490 C myCurrentTime - Time counter for this thread
491 C myCurrentIter - Iteration counter for this thread
492 INTEGER myCurrentIter
493 _RL myCurrentTime
494 logical exst
495 logical lastdiva
496 CEOP
497 c-- set default:
498 lastdiva = .TRUE.
499
500 #ifndef DISABLE_DEBUGMODE
501 IF (debugMode) CALL DEBUG_ENTER('THE_MODEL_MAIN',myThid)
502 #endif
503
504 C-- This timer encompasses the whole code
505 CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid)
506
507 #ifndef DISABLE_DEBUGMODE
508 IF (debugMode) CALL DEBUG_CALL('INITIALISE_FIXED',myThid)
509 #endif
510
511 C-- Set model configuration (fixed arrays)
512 CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
513 CALL INITIALISE_FIXED( myThid )
514 CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
515
516 myCurrentTime = startTime
517 myCurrentIter = nIter0
518
519 #if ( defined (ALLOW_ADMTLM_RUN) )
520 c
521 CALL TIMER_START('ADMTLM_DRIVER [THE_MODEL_MAIN]',mythid)
522 CALL ADMTLM_DRIVER ( myThid )
523 CALL TIMER_STOP ('ADMTLM_DRIVER [THE_MODEL_MAIN]',mythid)
524 c
525 #elif ( defined (ALLOW_ADJOINT_RUN) || \
526 defined (ALLOW_TANGENTLINEAR_RUN) || \
527 defined (ALLOW_GRADIENT_CHECK) || \
528 defined (ALLOW_ECCO_OPTIMIZATION) )
529
530 _BEGIN_MASTER( mythid )
531 IF (myProcId .eq. 0) THEN
532 inquire( file='costfinal', exist=exst )
533 IF ( .NOT. exst) THEN
534 CALL TIMER_START('CTRL_UNPACK [THE_MODEL_MAIN]',mythid)
535 CALL CTRL_UNPACK( mycurrentiter, mycurrenttime, mythid )
536 CALL TIMER_STOP ('CTRL_UNPACK [THE_MODEL_MAIN]',mythid)
537 ENDIF
538 ENDIF
539 _END_MASTER( mythid )
540 _BARRIER
541
542 CALL COST_DEPENDENT_INIT ( mythid )
543 _BARRIER
544
545 # if ( defined (ALLOW_TANGENTLINEAR_RUN) )
546 c
547 CALL TIMER_START('G_THE_MAIN_LOOP [TANGENT RUN]',mythid)
548 CALL G_THE_MAIN_LOOP ( myCurrentTime, myCurrentIter, myThid )
549 CALL TIMER_STOP ('G_THE_MAIN_LOOP [TANGENT RUN]',mythid)
550 c
551 # elif ( defined (ALLOW_ADJOINT_RUN) || \
552 defined (ALLOW_ECCO_OPTIMIZATION) )
553 c
554 # ifdef ALLOW_DIVIDED_ADJOINT
555 c-- The following assumes the TAF option '-pure'
556 inquire( file='costfinal', exist=exst )
557 IF ( .NOT. exst) THEN
558 CALL TIMER_START('MDTHE_MAIN_LOOP [MD RUN]', mythid)
559 CALL MDTHE_MAIN_LOOP ( myCurrentTime, myCurrentIter, mythid )
560 CALL TIMER_STOP ('MDTHE_MAIN_LOOP [MD RUN]', mythid)
561 CALL COST_FINAL_STORE ( mythid, lastdiva )
562 ELSE
563 CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
564 CALL ADTHE_MAIN_LOOP ( mythid )
565 CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
566 CALL COST_FINAL_RESTORE ( mythid, lastdiva )
567 ENDIF
568 c--
569 # else /* ALLOW_DIVIDED_ADJOINT undef */
570 CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
571 CALL ADTHE_MAIN_LOOP ( mythid )
572 CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
573 # endif /* ALLOW_DIVIDED_ADJOINT */
574 c
575 # endif
576
577 _BEGIN_MASTER( mythid )
578 IF ( myProcId .eq. 0 .AND. lastdiva ) THEN
579 CALL TIMER_START('CTRL_PACK [THE_MODEL_MAIN]',mythid)
580 call CTRL_PACK( mycurrentiter, mycurrenttime, mythid )
581 CALL TIMER_STOP ('CTRL_PACK [THE_MODEL_MAIN]',mythid)
582 ENDIF
583 _END_MASTER( mythid )
584 _BARRIER
585 c
586
587 # ifdef ALLOW_GRADIENT_CHECK
588 IF ( useGrdchk .AND. lastdiva ) THEN
589 CALL TIMER_START('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid)
590 CALL GRDCHK_MAIN( mythid )
591 CALL TIMER_STOP ('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid)
592 _BARRIER
593 ENDIF
594 # endif
595
596 #else /* ALL AD-related undef */
597
598 #ifndef DISABLE_DEBUGMODE
599 IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid)
600 #endif
601
602 C-- Call time stepping loop of full model
603 CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
604 CALL THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid )
605 CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
606
607 #endif /* ALLOW_TANGENTLINEAR_RUN ALLOW_ADJOINT_RUN ALLOW_ADMTLM_RUN */
608
609 C-- Sea-ice checkpoint (in case the in-loop checkpoint was missed)
610 #ifdef ALLOW_SEAICE
611 IF ( useSEAICE )
612 & CALL SEAICE_WRITE_PICKUP(
613 & .TRUE., myCurrentTime, myCurrentIter, myThid )
614 #endif
615
616 C-- Final checkpoint (in case the in-loop checkpoint was missed)
617 CALL TIMER_START('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid)
618 CALL WRITE_CHECKPOINT(
619 & .TRUE., myCurrentTime, myCurrentIter, myThid )
620 CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid)
621
622 CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid)
623
624 C-- Write timer statistics
625 IF ( myThid .EQ. 1 ) THEN
626 CALL TIMER_PRINTALL( myThid )
627 CALL COMM_STATS
628 ENDIF
629
630 #ifndef DISABLE_DEBUGMODE
631 IF (debugMode) CALL DEBUG_LEAVE('THE_MODEL_MAIN',myThid)
632 #endif
633
634 RETURN
635 END

  ViewVC Help
Powered by ViewVC 1.1.22