/[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.47 - (show annotations) (download)
Wed Sep 25 19:36:50 2002 UTC (21 years, 8 months ago) by mlosch
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint47e_post, checkpoint46l_post, checkpoint47c_post, checkpoint46l_pre, checkpoint47d_pre, checkpoint47a_post, checkpoint47d_post, checkpoint46j_pre, checkpoint46j_post, checkpoint46k_post, branch-exfmods-tag, checkpoint47b_post, checkpoint46m_post, checkpoint46i_post, checkpoint47, checkpoint46h_post
Branch point for: branch-exfmods-curt
Changes since 1.46: +2 -2 lines
o cleaned up the use of rhoNil and rhoConst.
  - rhoNil should only appear in the LINEAR equation of state, everywhere
    else rhoNil is replaced by rhoConst, e.g. find_rho computes rho-rhoConst
    and the dynamical equations are all divided by rhoConst
o introduced new parameter rhoConstFresh, a reference density of fresh
  water, to remove the fresh water flux's dependence on rhoNil. The default
  value is 999.8 kg/m^3
o cleanup up external_forcing.F and external_forcing_surf.F
  - can now be used by both OCEANIC and OCEANICP

1 C $Header: /u/gcmpack/MITgcm/model/src/the_model_main.F,v 1.46 2002/09/18 16:38:02 mlosch 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 | |
95 C | |-PACKAGES_CHECK
96 C | | |
97 C | | |-KPP_CHECK :: KPP Package. pkg/kpp
98 C | | |-OBCS_CHECK :: Open bndy Pacakge. pkg/obcs
99 C | | |-GMREDI_CHECK :: GM Package. pkg/gmredi
100 C | |
101 C | |-PACKAGES_INIT_FIXED
102 C | | |-OBCS_INIT_FIXED :: Open bndy Package. see pkg/obcs
103 C | | |-FLT_INIT :: Floats Package. see pkg/flt
104 C | |
105 C | |-ZONAL_FILT_INIT :: FFT filter Package. see pkg/zonal_filt
106 C | |
107 C | |-INI_CG2D :: 2d con. grad solver initialisation.
108 C | |
109 C | |-INI_CG3D :: 3d con. grad solver initialisation.
110 C | |
111 C | |-CONFIG_SUMMARY :: Provide synopsis of kernel setup.
112 C | :: Includes annotated table of kernel
113 C | :: parameter settings.
114 C |
115 C |-CTRL_UNPACK :: Control vector support package. see pkg/ctrl
116 C |
117 C |-ADTHE_MAIN_LOOP :: Derivative evaluating form of main time stepping loop
118 C ! :: Auotmatically gerenrated by TAMC/TAF.
119 C |
120 C |-CTRL_PACK :: Control vector support package. see pkg/ctrl
121 C |
122 C |-GRDCHK_MAIN :: Gradient check package. see pkg/grdchk
123 C |
124 C |-THE_MAIN_LOOP :: Main timestepping loop routine.
125 C | |
126 C | |-INITIALISE_VARIA :: Set the initial conditions for time evolving
127 C | | | :: variables
128 C | | |
129 C | | |-INI_LINEAR_PHISURF :: Set ref. surface Bo_surf
130 C | | |
131 C | | |-INI_CORI :: Set coriolis term. zero, f-plane, beta-plane,
132 C | | | :: sphere optins are coded.
133 C | | |
134 C | | |-INI_CG2D :: 2d con. grad solver initialisation.
135 C | | |-INI_CG3D :: 3d con. grad solver initialisation.
136 C | | |-INI_MIXING :: Initialise diapycnal diffusivity.
137 C | | |-INI_DYNVARS :: Initialise to zero all DYNVARS.h arrays (dynamical
138 C | | | :: fields).
139 C | | |
140 C | | |-INI_FIELDS :: Control initialising model fields to non-zero
141 C | | | |-INI_VEL :: Initialize 3D flow field.
142 C | | | |-INI_THETA :: Set model initial temperature field.
143 C | | | |-INI_SALT :: Set model initial salinity field.
144 C | | | |-INI_PSURF :: Set model initial free-surface height/pressure.
145 C | | | |-INI_PRESSURE :: Compute model initial hydrostatic pressure
146 C | | |
147 C | | |-INI_TR1 :: Set initial tracer 1 distribution.
148 C | | |
149 C | | |-THE_CORRECTION_STEP :: Step forward to next time step.
150 C | | | | :: Here applied to move restart conditions
151 C | | | | :: (saved in mid timestep) to correct level in
152 C | | | | :: time (only used for pre-c35).
153 C | | | |
154 C | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure
155 C | | | |-CORRECTION_STEP :: Pressure correction to momentum
156 C | | | |-CYCLE_TRACER :: Move tracers forward in time.
157 C | | | |-OBCS_APPLY :: Open bndy package. see pkg/obcs
158 C | | | |-SHAP_FILT_APPLY :: Shapiro filter package. see pkg/shap_filt
159 C | | | |-ZONAL_FILT_APPLY :: FFT filter package. see pkg/zonal_filt
160 C | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing.
161 C | | | | |-FIND_RHO :: Find adjacent densities.
162 C | | | | |-CONVECT :: Mix static instability.
163 C | | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
164 C | | | |
165 C | | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
166 C | | |
167 C | | |-CONVECTIVE_ADJUSTMENT_INI :: Control static instability mixing
168 C | | | | :: Extra time history interactions.
169 C | | | |
170 C | | | |-FIND_RHO :: Find adjacent densities.
171 C | | | |-CONVECT :: Mix static instability.
172 C | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
173 C | | |
174 C | | |-PACKAGES_INIT_VARIABLES :: Does initialisation of time evolving
175 C | | | | :: package data.
176 C | | | |
177 C | | | |-GMREDI_INIT :: GM package. ( see pkg/gmredi )
178 C | | | |-KPP_INIT :: KPP package. ( see pkg/kpp )
179 C | | | |-KPP_OPEN_DIAGS
180 C | | | |-OBCS_INIT_VARIABLES :: Open bndy. package. ( see pkg/obcs )
181 C | | | |-AIM_INIT :: Interm. atmos package. ( see pkg/aim )
182 C | | | |-CTRL_MAP_INI :: Control vector package.( see pkg/ctrl )
183 C | | | |-COST_INIT :: Cost function package. ( see pkg/cost )
184 C | | | |-ECCO_INIT :: ECCO support package. ( see pkg/ecco )
185 C | | | |-INI_FORCING :: Set model initial forcing fields.
186 C | | | | :: Either set in-line or from file as shown.
187 C | | | |-READ_FLD_XY_RS(zonalWindFile)
188 C | | | |-READ_FLD_XY_RS(meridWindFile)
189 C | | | |-READ_FLD_XY_RS(surfQFile)
190 C | | | |-READ_FLD_XY_RS(EmPmRfile)
191 C | | | |-READ_FLD_XY_RS(thetaClimFile)
192 C | | | |-READ_FLD_XY_RS(saltClimFile)
193 C | | | |-READ_FLD_XY_RS(surfQswFile)
194 C | | |
195 C | | |-CALC_SURF_DR :: Calculate the new surface level thickness.
196 C | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
197 C | | |-UPDATE_CG2D :: Update 2d conjugate grad. for Free-Surf.
198 C | | |-STATE_SUMMARY :: Summarize model prognostic variables.
199 C | | |-TIMEAVE_STATVARS :: Time averaging package ( see pkg/timeave ).
200 C | |
201 C | |-WRITE_STATE :: Controlling routine for IO to dump model state.
202 C | | |-WRITE_REC_XYZ_RL :: Single file I/O
203 C | | |-WRITE_FLD_XYZ_RL :: Multi-file I/O
204 C | |
205 C | |-MONITOR :: Monitor state ( see pkg/monitor )
206 C | |-CTRL_MAP_FORCING :: Control vector support package. ( see pkg/ctrl )
207 C====|>|
208 C====|>| ****************************
209 C====|>| BEGIN MAIN TIMESTEPPING LOOP
210 C====|>| ****************************
211 C====|>|
212 C/\ | |-FORWARD_STEP :: Step forward a time-step ( AT LAST !!! )
213 C/\ | | |
214 C/\ | | |-DUMMY_IN_STEPPING :: autodiff package ( pkg/autoduff ).
215 C/\ | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
216 C/\ | | |-CALC_SURF_DR :: Calculate the new surface level thickness.
217 C/\ | | |-EXF_GETFORCING :: External forcing package. ( pkg/exf )
218 C/\ | | |-EXTERNAL_FIELDS_LOAD :: Control loading time dep. external data.
219 C/\ | | | | :: Simple interpolcation between end-points
220 C/\ | | | | :: for forcing datasets.
221 C/\ | | | |
222 C/\ | | | |-EXCH :: Sync forcing. in overlap regions.
223 C/\ | | |
224 C/\ | | |-THERMODYNAMICS :: theta, salt + tracer equations driver.
225 C/\ | | | |
226 C/\ | | | |-INTEGRATE_FOR_W :: Integrate for vertical velocity.
227 C/\ | | | |-OBCS_APPLY_W :: Open bndy. package ( see pkg/obcs ).
228 C/\ | | | |-FIND_RHO :: Calculates [rho(S,T,z)-RhoConst] of a slice
229 C/\ | | | |-GRAD_SIGMA :: Calculate isoneutral gradients
230 C/\ | | | |-CALC_IVDC :: Set Implicit Vertical Diffusivity for Convection
231 C/\ | | | |
232 C/\ | | | |-OBCS_CALC :: Open bndy. package ( see pkg/obcs ).
233 C/\ | | | |-EXTERNAL_FORCING_SURF:: Accumulates appropriately dimensioned
234 C/\ | | | | :: forcing terms.
235 C/\ | | | |
236 C/\ | | | |-GMREDI_CALC_TENSOR :: GM package ( see pkg/gmredi ).
237 C/\ | | | |-GMREDI_CALC_TENSOR_DUMMY :: GM package ( see pkg/gmredi ).
238 C/\ | | | |-KPP_CALC :: KPP package ( see pkg/kpp ).
239 C/\ | | | |-KPP_CALC_DUMMY :: KPP package ( see pkg/kpp ).
240 C/\ | | | |-AIM_DO_ATMOS_PHYSICS :: Intermed. atmos package ( see pkg/aim ).
241 C/\ | | | |-GAD_ADVECTION :: Generalised advection driver (multi-dim
242 C/\ | | | | advection case) (see pkg/gad).
243 C/\ | | | |-CALC_COMMON_FACTORS :: Calculate common data (such as volume flux)
244 C/\ | | | |-CALC_DIFFUSIVITY :: Calculate net vertical diffusivity
245 C/\ | | | | |
246 C/\ | | | | |-GMREDI_CALC_DIFF :: GM package ( see pkg/gmredi ).
247 C/\ | | | | |-KPP_CALC_DIFF :: KPP package ( see pkg/kpp ).
248 C/\ | | | |
249 C/\ | | | |-CALC_GT :: Calculate the temperature tendency terms
250 C/\ | | | | |
251 C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
252 C/\ | | | | | :: ( see pkg/gad )
253 C/\ | | | | |-EXTERNAL_FORCING_T :: Problem specific forcing for temperature.
254 C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
255 C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gt for free-surface height.
256 C/\ | | | |
257 C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
258 C/\ | | | |
259 C/\ | | | |-CALC_GS :: Calculate the salinity tendency terms
260 C/\ | | | | |
261 C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
262 C/\ | | | | | :: ( see pkg/gad )
263 C/\ | | | | |-EXTERNAL_FORCING_S :: Problem specific forcing for salt.
264 C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
265 C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
266 C/\ | | | |
267 C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
268 C/\ | | | |
269 C/\ | | | |-CALC_GTR1 :: Calculate other tracer(s) tendency terms
270 C/\ | | | | |
271 C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
272 C/\ | | | | | :: ( see pkg/gad )
273 C/\ | | | | |-EXTERNAL_FORCING_TR:: Problem specific forcing for tracer.
274 C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
275 C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
276 C/\ | | | |
277 C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
278 C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ).
279 C/\ | | | |-FREEZE :: Limit range of temperature.
280 C/\ | | | |
281 C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation.
282 C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ).
283 C/\ | | | |
284 C/\ | | | |-AIM_AIM2DYN_EXCHANGES :: Inetermed. atmos (see pkg/aim).
285 C/\ | | | |-EXCH :: Update overlaps
286 C/\ | | |
287 C/\ | | |-DYNAMICS :: Momentum equations driver.
288 C/\ | | | |
289 C/\ | | | |-CALC_GRAD_PHI_SURF :: Calculate the gradient of the surface
290 C/\ | | | | Potential anomaly.
291 C/\ | | | |-CALC_VISCOSITY :: Calculate net vertical viscosity
292 C/\ | | | | |-KPP_CALC_VISC :: KPP package ( see pkg/kpp ).
293 C/\ | | | |
294 C/\ | | | |-CALC_PHI_HYD :: Integrate the hydrostatic relation.
295 C/\ | | | |-MOM_FLUXFORM :: Flux form mom eqn. package ( see
296 C/\ | | | | pkg/mom_fluxform ).
297 C/\ | | | |-MOM_VECINV :: Vector invariant form mom eqn. package ( see
298 C/\ | | | | pkg/mom_vecinv ).
299 C/\ | | | |-TIMESTEP :: Step momentum fields forward in time
300 C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ).
301 C/\ | | | |
302 C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation.
303 C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ).
304 C/\ | | | |
305 C/\ | | | |-TIMEAVE_CUMUL_1T :: Time averaging package ( see pkg/timeave ).
306 C/\ | | | |-TIMEAVE_CUMUATE :: Time averaging package ( see pkg/timeave ).
307 C/\ | | | |-DEBUG_STATS_RL :: Quick debug package ( see pkg/debug ).
308 C/\ | | |
309 C/\ | | |-CALC_GW :: vert. momentum tendency terms ( NH, QH only ).
310 C/\ | | |
311 C/\ | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
312 C/\ | | |
313 C/\ | | |-UPDATE_CG2D :: Update 2d conjugate grad. for Free-Surf.
314 C/\ | | |
315 C/\ | | |-SOLVE_FOR_PRESSURE :: Find surface pressure.
316 C/\ | | | |-CALC_DIV_GHAT :: Form the RHS of the surface pressure eqn.
317 C/\ | | | |-CG2D :: Two-dim pre-con. conjugate-gradient.
318 C/\ | | | |-CG3D :: Three-dim pre-con. conjugate-gradient solver.
319 C/\ | | |
320 C/\ | | |-THE_CORRECTION_STEP :: Step forward to next time step.
321 C/\ | | | |
322 C/\ | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure
323 C/\ | | | |-CORRECTION_STEP :: Pressure correction to momentum
324 C/\ | | | |-CYCLE_TRACER :: Move tracers forward in time.
325 C/\ | | | |-OBCS_APPLY :: Open bndy package. see pkg/obcs
326 C/\ | | | |-SHAP_FILT_APPLY :: Shapiro filter package. see pkg/shap_filt
327 C/\ | | | |-ZONAL_FILT_APPLY :: FFT filter package. see pkg/zonal_filt
328 C/\ | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing.
329 C/\ | | | | |-FIND_RHO :: Find adjacent densities.
330 C/\ | | | | |-CONVECT :: Mix static instability.
331 C/\ | | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
332 C/\ | | | |
333 C/\ | | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
334 C/\ | | |
335 C/\ | | |-DO_FIELDS_BLOCKING_EXCHANGES :: Sync up overlap regions.
336 C/\ | | | |-EXCH
337 C/\ | | |
338 C/\ | | |-FLT_MAIN :: Float package ( pkg/flt ).
339 C/\ | | |
340 C/\ | | |-MONITOR :: Monitor package ( pkg/monitor ).
341 C/\ | | |
342 C/\ | | |-DO_THE_MODEL_IO :: Standard diagnostic I/O.
343 C/\ | | | |-WRITE_STATE :: Core state I/O
344 C/\ | | | |-TIMEAVE_STATV_WRITE :: Time averages. see pkg/timeave
345 C/\ | | | |-AIM_WRITE_DIAGS :: Intermed. atmos diags. see pkg/aim
346 C/\ | | | |-GMREDI_DIAGS :: GM diags. see pkg/gmredi
347 C/\ | | | |-KPP_DO_DIAGS :: KPP diags. see pkg/kpp
348 C/\ | | |
349 C/\ | | |-WRITE_CHECKPOINT :: Do I/O for restart files.
350 C/\ | |
351 C/\ | |-COST_TILE :: Cost function package. ( see pkg/cost )
352 C<===|=|
353 C<===|=| **************************
354 C<===|=| END MAIN TIMESTEPPING LOOP
355 C<===|=| **************************
356 C<===|=|
357 C | |-COST_FINAL :: Cost function package. ( see pkg/cost )
358 C |
359 C |-WRITE_CHECKPOINT :: Final state storage, for restart.
360 C |
361 C |-TIMER_PRINTALL :: Computational timing summary
362 C |
363 C |-COMM_STATS :: Summarise inter-proc and inter-thread communication
364 C :: events.
365 C \ev
366 C
367 C
368 CEOI
369
370
371 #include "CPP_OPTIONS.h"
372
373 CBOP
374
375 C !ROUTINE: THE_MODEL_MAIN
376
377 C !INTERFACE:
378 SUBROUTINE THE_MODEL_MAIN(myThid)
379 IMPLICIT NONE
380
381 C !DESCRIPTION: \bv
382 C *==========================================================*
383 C | SUBROUTINE THE_MODEL_MAIN
384 C | o Master controlling routine for model using the MITgcm
385 C | UV parallel wrapper.
386 C *==========================================================*
387 C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel
388 C | wrapper with a single integer argument "myThid". This
389 C | variable identifies the thread number of an instance of
390 C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works
391 C | on a particular region of the models domain and
392 C | synchronises with other instances as necessary. The
393 C | routine has to "understand" the MITgcm parallel
394 C | environment and the numerical algorithm. Editing this
395 C | routine is best done with some knowledge of both aspects.
396 C | Notes
397 C | =====
398 C | C*P* comments indicating place holders for which code is
399 C | presently being developed.
400 C *==========================================================*
401 C \ev
402
403 C !CALLING SEQUENCE:
404 C THE_MODEL_MAIN()
405 C |
406 C |
407 C |--INITIALISE_FIXED
408 C | o Set model configuration (fixed arrays)
409 C | Topography, hydrography, timestep, grid, etc..
410 C |
411 C |--CTRL_UNPACK o Derivative mode. Unpack control vector.
412 C |
413 C |--ADTHE_MAIN_LOOP o Main timestepping loop for combined
414 C | prognostic and reverse mode integration.
415 C |
416 C |--CTRL_PACK o Derivative mode. Unpack control vector.
417 C |
418 C |--GRDCHK_MAIN o Gradient check control routine.
419 C |
420 C |--THE_MAIN_LOOP o Main timestepping loop for pure prognostic
421 C | integration.
422 C |
423 C |--WRITE_CHECKPOINT o Write retsart information.
424 C |
425 C |--TIMER_PRINTALL o Print out timing statistics.
426 C |
427 C |--COMM_STATS o Print out communication statistics.
428
429 C !USES:
430 C == Global variables ===
431 #include "SIZE.h"
432 #include "EEPARAMS.h"
433 #include "PARAMS.h"
434 #include "DYNVARS.h"
435 #ifdef ALLOW_NONHYDROSTATIC
436 #include "CG3D.h"
437 #endif
438
439 #ifdef ALLOW_AUTODIFF_TAMC
440 #include "tamc.h"
441 #endif
442
443 C !INPUT/OUTPUT PARAMETERS:
444 C == Routine arguments ==
445 C myThid - Thread number for this instance of the routine.
446 INTEGER myThid
447
448 C !LOCAL VARIABLES:
449 C == Local variables ==
450 C Note: Under the multi-threaded model myCurrentIter and
451 C myCurrentTime are local variables passed around as routine
452 C arguments. Although this is fiddly it saves the need to
453 C impose additional synchronisation points when they are
454 C updated.
455 C myCurrentTime - Time counter for this thread
456 C myCurrentIter - Iteration counter for this thread
457 INTEGER I
458 INTEGER bi,bj
459 INTEGER myCurrentIter
460 _RL myCurrentTime
461 CEOP
462
463 C-- This timer encompasses the whole code
464 CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid)
465
466 C-- Set model configuration (fixed arrays)
467 CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
468 CALL INITIALISE_FIXED( myThid )
469 CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
470
471 myCurrentTime = startTime
472 myCurrentIter = nIter0
473
474 #if ( defined (ALLOW_ADJOINT_RUN) || \
475 defined (ALLOW_TANGENTLINEAR_RUN) || \
476 defined (ALLOW_GRADIENT_CHECK) || \
477 defined (ALLOW_ECCO_OPTIMIZATION) )
478
479 _BEGIN_MASTER( mythid )
480 IF (myProcId .eq. 0) THEN
481 CALL TIMER_START('CTRL_UNPACK [THE_MODEL_MAIN]',mythid)
482 CALL CTRL_UNPACK( mycurrentiter, mycurrenttime, mythid )
483 CALL TIMER_STOP ('CTRL_UNPACK [THE_MODEL_MAIN]',mythid)
484 ENDIF
485 _END_MASTER( mythid )
486 _BARRIER
487
488 CALL COST_DEPENDENT_INIT ( mythid )
489 _BARRIER
490
491 #if ( defined (ALLOW_ADJOINT_RUN) || \
492 defined (ALLOW_ECCO_OPTIMIZATION) )
493 CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]',mythid)
494 CALL ADTHE_MAIN_LOOP ( mythid )
495 CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]',mythid)
496 _BARRIER
497 #elif (defined (ALLOW_TANGENTLINEAR_RUN))
498 CALL TIMER_START('G_THE_MAIN_LOOP [TANGENT RUN]',mythid)
499 CALL G_THE_MAIN_LOOP ( myCurrentTime, myCurrentIter, myThid )
500 CALL TIMER_STOP ('G_THE_MAIN_LOOP [TANGENT RUN]',mythid)
501 _BARRIER
502 #endif
503
504 _BEGIN_MASTER( mythid )
505 IF (myProcId .eq. 0) THEN
506 CALL TIMER_START('CTLR_PACK [THE_MODEL_MAIN]',mythid)
507 call CTRL_PACK( mycurrentiter, mycurrenttime, mythid )
508 CALL TIMER_STOP ('CTLR_PACK [THE_MODEL_MAIN]',mythid)
509 ENDIF
510 _END_MASTER( mythid )
511 _BARRIER
512
513 #else /* ALLOW_ADJOINT_RUN undef */
514
515 C-- Call time stepping loop of full model
516 CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
517 CALL THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid )
518 CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
519
520 #endif /* ALLOW_ADJOINT_RUN */
521
522 #ifdef ALLOW_GRADIENT_CHECK
523 if (useGrdchk) then
524 CALL TIMER_START('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid)
525 CALL GRDCHK_MAIN( mythid )
526 CALL TIMER_STOP ('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid)
527 _BARRIER
528 end if
529 #endif
530
531 C-- Final checkpoint (incase the in-loop checkpoint was missed)
532 CALL TIMER_START('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid)
533 CALL WRITE_CHECKPOINT(
534 & .TRUE., myCurrentTime, myCurrentIter, myThid )
535 CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid)
536
537 CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid)
538
539 C-- Write timer statistics
540 IF ( myThid .EQ. 1 ) THEN
541 CALL TIMER_PRINTALL( myThid )
542 CALL COMM_STATS
543 ENDIF
544
545 RETURN
546 END

  ViewVC Help
Powered by ViewVC 1.1.22