/[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.70 - (hide annotations) (download)
Mon Dec 15 18:40:10 2003 UTC (20 years, 5 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint52f_post, hrcube_1, checkpoint52e_pre, checkpoint52e_post, checkpoint52f_pre, checkpoint52d_post
Changes since 1.69: +1 -8 lines
move "call seaice_write_pickup" to packages_write_pickup with other pkgs

1 jmc 1.70 C $Header: /u/gcmpack/MITgcm/model/src/the_model_main.F,v 1.69 2003/12/14 23:18:49 jmc Exp $
2 cnh 1.41 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 adcroft 1.43 C !INTRODUCTION: Kernel dynamical routines
11 cnh 1.42 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 stephd 1.59 C | | |-PTRACERS_READPARMS :: multiple tracer package, see pkg/ptracers
95     C | | |-GCHEM_READPARMS :: tracer interface package, see pkg/gchem
96 cnh 1.42 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 stephd 1.59 C | | |-GCHEM_INIT_FIXED :: tracer interface pachage, see pkg/gchem
107 cnh 1.42 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 mlosch 1.46 C | | | |-INI_PRESSURE :: Compute model initial hydrostatic pressure
149 cnh 1.42 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 edhill 1.63 C | | |-PACKAGES_INIT_VARIABLES :: Does initialisation of time evolving
178     C | | | | :: package data.
179 cnh 1.42 C | | | |
180 edhill 1.63 C | | | |-GMREDI_INIT :: GM package. ( see pkg/gmredi )
181     C | | | |-KPP_INIT :: KPP package. ( see pkg/kpp )
182 cnh 1.42 C | | | |-KPP_OPEN_DIAGS
183 edhill 1.63 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 cnh 1.42 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 edhill 1.63 C/\ | |-FORWARD_STEP :: Step forward a time-step ( AT LAST !!! )
218 cnh 1.42 C/\ | | |
219 edhill 1.63 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/\ | | | |
227     C/\ | | | |-EXCH :: Sync forcing. in overlap regions.
228     C/\ | | |-SEAICE_MODEL :: Compute sea-ice terms. ( pkg/seaice )
229 dimitri 1.68 C/\ | | |-FREEZE :: Limit surface temperature.
230 edhill 1.63 C/\ | | |-GCHEM_FIELD_LOAD :: load tracer forcing fields (pkg/gchem)
231 cnh 1.42 C/\ | | |
232 edhill 1.63 C/\ | | |-THERMODYNAMICS :: theta, salt + tracer equations driver.
233 cnh 1.42 C/\ | | | |
234 edhill 1.63 C/\ | | | |-INTEGRATE_FOR_W :: Integrate for vertical velocity.
235     C/\ | | | |-OBCS_APPLY_W :: Open bndy. package ( see pkg/obcs ).
236     C/\ | | | |-FIND_RHO :: Calculates [rho(S,T,z)-RhoConst] of a slice
237     C/\ | | | |-GRAD_SIGMA :: Calculate isoneutral gradients
238     C/\ | | | |-CALC_IVDC :: Set Implicit Vertical Diffusivity for Convection
239 cnh 1.42 C/\ | | | |
240     C/\ | | | |-OBCS_CALC :: Open bndy. package ( see pkg/obcs ).
241 edhill 1.63 C/\ | | | |-EXTERNAL_FORCING_SURF:: Accumulates appropriately dimensioned
242     C/\ | | | | | :: forcing terms.
243     C/\ | | | | |-PTRACERS_FORCING_SURF :: Tracer package ( see pkg/ptracers ).
244 cnh 1.42 C/\ | | | |
245     C/\ | | | |-GMREDI_CALC_TENSOR :: GM package ( see pkg/gmredi ).
246     C/\ | | | |-GMREDI_CALC_TENSOR_DUMMY :: GM package ( see pkg/gmredi ).
247     C/\ | | | |-KPP_CALC :: KPP package ( see pkg/kpp ).
248     C/\ | | | |-KPP_CALC_DUMMY :: KPP package ( see pkg/kpp ).
249     C/\ | | | |-AIM_DO_ATMOS_PHYSICS :: Intermed. atmos package ( see pkg/aim ).
250     C/\ | | | |-GAD_ADVECTION :: Generalised advection driver (multi-dim
251     C/\ | | | | advection case) (see pkg/gad).
252     C/\ | | | |-CALC_COMMON_FACTORS :: Calculate common data (such as volume flux)
253     C/\ | | | |-CALC_DIFFUSIVITY :: Calculate net vertical diffusivity
254     C/\ | | | | |
255     C/\ | | | | |-GMREDI_CALC_DIFF :: GM package ( see pkg/gmredi ).
256     C/\ | | | | |-KPP_CALC_DIFF :: KPP package ( see pkg/kpp ).
257     C/\ | | | |
258     C/\ | | | |-CALC_GT :: Calculate the temperature tendency terms
259     C/\ | | | | |
260     C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
261 dimitri 1.56 C/\ | | | | | | :: ( see pkg/gad )
262     C/\ | | | | | |-KPP_TRANSPORT_T :: KPP non-local transport ( see pkg/kpp ).
263     C/\ | | | | |
264 cnh 1.42 C/\ | | | | |-EXTERNAL_FORCING_T :: Problem specific forcing for temperature.
265     C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
266     C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gt for free-surface height.
267     C/\ | | | |
268     C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
269     C/\ | | | |
270     C/\ | | | |-CALC_GS :: Calculate the salinity tendency terms
271     C/\ | | | | |
272     C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
273 dimitri 1.56 C/\ | | | | | | :: ( see pkg/gad )
274     C/\ | | | | | |-KPP_TRANSPORT_S :: KPP non-local transport ( see pkg/kpp ).
275     C/\ | | | | |
276 cnh 1.42 C/\ | | | | |-EXTERNAL_FORCING_S :: Problem specific forcing for salt.
277     C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
278     C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
279     C/\ | | | |
280     C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
281     C/\ | | | |
282     C/\ | | | |-CALC_GTR1 :: Calculate other tracer(s) tendency terms
283     C/\ | | | | |
284     C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
285 dimitri 1.57 C/\ | | | | | :: ( see pkg/gad )
286 dimitri 1.56 C/\ | | | | |
287 cnh 1.42 C/\ | | | | |-EXTERNAL_FORCING_TR:: Problem specific forcing for tracer.
288     C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
289     C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
290     C/\ | | | |
291     C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
292 dimitri 1.56 C/\ | | | |
293 edhill 1.63 C/\ | | | |-PTRACERS_INTEGRATE :: Integrate other tracer(s) ( see pkg/ptracers ).
294 dimitri 1.56 C/\ | | | | |
295     C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
296 dimitri 1.57 C/\ | | | | | | :: ( see pkg/gad )
297     C/\ | | | | | |-KPP_TRANSPORT_PTR:: KPP non-local transport ( see pkg/kpp ).
298     C/\ | | | | |
299 dimitri 1.56 C/\ | | | | |-PTRACERS_FORCING :: Problem specific forcing for tracer.
300 stephd 1.59 C/\ | | | | |-GCHEM_FORCING_INT :: tracer forcing for gchem pkg (if all
301     C/\ | | | | | tendancy terms calcualted together)
302 dimitri 1.56 C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
303     C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
304     C/\ | | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
305     C/\ | | | |
306 cnh 1.42 C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ).
307     C/\ | | | |
308     C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation.
309     C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ).
310     C/\ | | | |
311 edhill 1.63 C/\ | | | |-AIM_AIM2DYN_EXCHANGES :: Inetermed. atmos (see pkg/aim).
312 cnh 1.42 C/\ | | | |-EXCH :: Update overlaps
313     C/\ | | |
314 edhill 1.63 C/\ | | |-DYNAMICS :: Momentum equations driver.
315 cnh 1.42 C/\ | | | |
316     C/\ | | | |-CALC_GRAD_PHI_SURF :: Calculate the gradient of the surface
317     C/\ | | | | Potential anomaly.
318     C/\ | | | |-CALC_VISCOSITY :: Calculate net vertical viscosity
319     C/\ | | | | |-KPP_CALC_VISC :: KPP package ( see pkg/kpp ).
320     C/\ | | | |
321     C/\ | | | |-CALC_PHI_HYD :: Integrate the hydrostatic relation.
322     C/\ | | | |-MOM_FLUXFORM :: Flux form mom eqn. package ( see
323     C/\ | | | | pkg/mom_fluxform ).
324     C/\ | | | |-MOM_VECINV :: Vector invariant form mom eqn. package ( see
325     C/\ | | | | pkg/mom_vecinv ).
326     C/\ | | | |-TIMESTEP :: Step momentum fields forward in time
327     C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ).
328     C/\ | | | |
329     C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation.
330     C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ).
331     C/\ | | | |
332     C/\ | | | |-TIMEAVE_CUMUL_1T :: Time averaging package ( see pkg/timeave ).
333     C/\ | | | |-TIMEAVE_CUMUATE :: Time averaging package ( see pkg/timeave ).
334     C/\ | | | |-DEBUG_STATS_RL :: Quick debug package ( see pkg/debug ).
335     C/\ | | |
336     C/\ | | |-CALC_GW :: vert. momentum tendency terms ( NH, QH only ).
337     C/\ | | |
338     C/\ | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
339     C/\ | | |
340     C/\ | | |-UPDATE_CG2D :: Update 2d conjugate grad. for Free-Surf.
341     C/\ | | |
342     C/\ | | |-SOLVE_FOR_PRESSURE :: Find surface pressure.
343     C/\ | | | |-CALC_DIV_GHAT :: Form the RHS of the surface pressure eqn.
344     C/\ | | | |-CG2D :: Two-dim pre-con. conjugate-gradient.
345     C/\ | | | |-CG3D :: Three-dim pre-con. conjugate-gradient solver.
346     C/\ | | |
347     C/\ | | |-THE_CORRECTION_STEP :: Step forward to next time step.
348     C/\ | | | |
349     C/\ | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure
350     C/\ | | | |-CORRECTION_STEP :: Pressure correction to momentum
351     C/\ | | | |-CYCLE_TRACER :: Move tracers forward in time.
352     C/\ | | | |-OBCS_APPLY :: Open bndy package. see pkg/obcs
353     C/\ | | | |-SHAP_FILT_APPLY :: Shapiro filter package. see pkg/shap_filt
354     C/\ | | | |-ZONAL_FILT_APPLY :: FFT filter package. see pkg/zonal_filt
355     C/\ | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing.
356     C/\ | | | | |-FIND_RHO :: Find adjacent densities.
357     C/\ | | | | |-CONVECT :: Mix static instability.
358     C/\ | | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
359     C/\ | | | |
360     C/\ | | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
361     C/\ | | |
362     C/\ | | |-DO_FIELDS_BLOCKING_EXCHANGES :: Sync up overlap regions.
363     C/\ | | | |-EXCH
364     C/\ | | |
365 stephd 1.59 C/\ | | |-GCHEM_FORCING_SEP :: tracer forcing for gchem pkg (if
366     C/\ | | | tracer dependent tendencies calculated
367     C/\ | | | separatly)
368     C/\ | | |
369 cnh 1.42 C/\ | | |-FLT_MAIN :: Float package ( pkg/flt ).
370     C/\ | | |
371     C/\ | | |-MONITOR :: Monitor package ( pkg/monitor ).
372     C/\ | | |
373     C/\ | | |-DO_THE_MODEL_IO :: Standard diagnostic I/O.
374     C/\ | | | |-WRITE_STATE :: Core state I/O
375     C/\ | | | |-TIMEAVE_STATV_WRITE :: Time averages. see pkg/timeave
376     C/\ | | | |-AIM_WRITE_DIAGS :: Intermed. atmos diags. see pkg/aim
377     C/\ | | | |-GMREDI_DIAGS :: GM diags. see pkg/gmredi
378     C/\ | | | |-KPP_DO_DIAGS :: KPP diags. see pkg/kpp
379 dimitri 1.49 C/\ | | | |-SBO_CALC :: SBO diags. see pkg/sbo
380     C/\ | | | |-SBO_DIAGS :: SBO diags. see pkg/sbo
381 stephd 1.59 C/\ | | | |-GCHEM_DIAGS :: gchem diags. see pkg/gchem
382 cnh 1.42 C/\ | | |
383     C/\ | | |-WRITE_CHECKPOINT :: Do I/O for restart files.
384     C/\ | |
385     C/\ | |-COST_TILE :: Cost function package. ( see pkg/cost )
386     C<===|=|
387     C<===|=| **************************
388     C<===|=| END MAIN TIMESTEPPING LOOP
389     C<===|=| **************************
390     C<===|=|
391     C | |-COST_FINAL :: Cost function package. ( see pkg/cost )
392     C |
393     C |-WRITE_CHECKPOINT :: Final state storage, for restart.
394     C |
395     C |-TIMER_PRINTALL :: Computational timing summary
396     C |
397     C |-COMM_STATS :: Summarise inter-proc and inter-thread communication
398     C :: events.
399     C \ev
400     C
401 cnh 1.41 C
402     CEOI
403    
404 cnh 1.1
405 edhill 1.61 #include "AD_CONFIG.h"
406 edhill 1.60 #include "PACKAGES_CONFIG.h"
407 adcroft 1.18 #include "CPP_OPTIONS.h"
408 cnh 1.1
409 cnh 1.41 CBOP
410    
411     C !ROUTINE: THE_MODEL_MAIN
412    
413     C !INTERFACE:
414 cnh 1.1 SUBROUTINE THE_MODEL_MAIN(myThid)
415 adcroft 1.24 IMPLICIT NONE
416 cnh 1.41
417     C !DESCRIPTION: \bv
418     C *==========================================================*
419     C | SUBROUTINE THE_MODEL_MAIN
420     C | o Master controlling routine for model using the MITgcm
421     C | UV parallel wrapper.
422     C *==========================================================*
423     C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel
424     C | wrapper with a single integer argument "myThid". This
425     C | variable identifies the thread number of an instance of
426     C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works
427     C | on a particular region of the models domain and
428     C | synchronises with other instances as necessary. The
429     C | routine has to "understand" the MITgcm parallel
430     C | environment and the numerical algorithm. Editing this
431     C | routine is best done with some knowledge of both aspects.
432     C | Notes
433     C | =====
434     C | C*P* comments indicating place holders for which code is
435     C | presently being developed.
436     C *==========================================================*
437     C \ev
438    
439     C !CALLING SEQUENCE:
440     C THE_MODEL_MAIN()
441     C |
442     C |
443     C |--INITIALISE_FIXED
444     C | o Set model configuration (fixed arrays)
445     C | Topography, hydrography, timestep, grid, etc..
446     C |
447     C |--CTRL_UNPACK o Derivative mode. Unpack control vector.
448     C |
449     C |--ADTHE_MAIN_LOOP o Main timestepping loop for combined
450     C | prognostic and reverse mode integration.
451     C |
452     C |--CTRL_PACK o Derivative mode. Unpack control vector.
453     C |
454     C |--GRDCHK_MAIN o Gradient check control routine.
455     C |
456     C |--THE_MAIN_LOOP o Main timestepping loop for pure prognostic
457     C | integration.
458     C |
459     C |--WRITE_CHECKPOINT o Write retsart information.
460     C |
461     C |--TIMER_PRINTALL o Print out timing statistics.
462     C |
463     C |--COMM_STATS o Print out communication statistics.
464    
465     C !USES:
466 cnh 1.1 C == Global variables ===
467     #include "SIZE.h"
468     #include "EEPARAMS.h"
469     #include "PARAMS.h"
470 adcroft 1.26 #include "DYNVARS.h"
471 adcroft 1.27 #ifdef ALLOW_NONHYDROSTATIC
472 heimbach 1.65 # include "CG3D.h"
473 adcroft 1.27 #endif
474 cnh 1.1
475 heimbach 1.65 #ifdef ALLOW_ECCO_OPTIMIZATION
476     # include "optim.h"
477     #endif
478 heimbach 1.37 #ifdef ALLOW_AUTODIFF_TAMC
479 heimbach 1.65 # include "tamc.h"
480 heimbach 1.37 #endif
481    
482 cnh 1.41 C !INPUT/OUTPUT PARAMETERS:
483 cnh 1.1 C == Routine arguments ==
484     C myThid - Thread number for this instance of the routine.
485 cnh 1.6 INTEGER myThid
486 cnh 1.1
487 cnh 1.41 C !LOCAL VARIABLES:
488 cnh 1.1 C == Local variables ==
489 cnh 1.7 C Note: Under the multi-threaded model myCurrentIter and
490     C myCurrentTime are local variables passed around as routine
491     C arguments. Although this is fiddly it saves the need to
492     C impose additional synchronisation points when they are
493     C updated.
494 jmc 1.34 C myCurrentTime - Time counter for this thread
495     C myCurrentIter - Iteration counter for this thread
496     INTEGER myCurrentIter
497     _RL myCurrentTime
498 heimbach 1.51 logical exst
499 heimbach 1.52 logical lastdiva
500 heimbach 1.65 #ifndef ALLOW_ECCO_OPTIMIZATION
501     integer optimcycle
502     #endif
503 cnh 1.41 CEOP
504 heimbach 1.53 c-- set default:
505 heimbach 1.65 #ifndef ALLOW_ECCO_OPTIMIZATION
506     optimcycle = 0
507     #endif
508 heimbach 1.53 lastdiva = .TRUE.
509 cnh 1.1
510 edhill 1.66 #ifdef ALLOW_DEBUG
511 adcroft 1.54 IF (debugMode) CALL DEBUG_ENTER('THE_MODEL_MAIN',myThid)
512     #endif
513    
514 adcroft 1.19 C-- This timer encompasses the whole code
515 heimbach 1.45 CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid)
516 adcroft 1.19
517 edhill 1.66 #ifdef ALLOW_DEBUG
518 adcroft 1.54 IF (debugMode) CALL DEBUG_CALL('INITIALISE_FIXED',myThid)
519     #endif
520    
521 adcroft 1.32 C-- Set model configuration (fixed arrays)
522 heimbach 1.45 CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
523 adcroft 1.32 CALL INITIALISE_FIXED( myThid )
524 heimbach 1.45 CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
525 adcroft 1.26
526 jmc 1.34 myCurrentTime = startTime
527     myCurrentIter = nIter0
528    
529 heimbach 1.64 #if ( defined (ALLOW_ADMTLM) )
530 heimbach 1.58 c
531     CALL TIMER_START('ADMTLM_DRIVER [THE_MODEL_MAIN]',mythid)
532     CALL ADMTLM_DRIVER ( myThid )
533     CALL TIMER_STOP ('ADMTLM_DRIVER [THE_MODEL_MAIN]',mythid)
534     c
535 heimbach 1.64 #elif ( defined (ALLOW_AUTODIFF))
536 heimbach 1.37
537 heimbach 1.65 # ifndef EXCLUDE_CTRL_PACK
538 heimbach 1.37 _BEGIN_MASTER( mythid )
539     IF (myProcId .eq. 0) THEN
540 heimbach 1.52 inquire( file='costfinal', exist=exst )
541 heimbach 1.67 IF ( .NOT. exst .AND. niter0 .EQ. 0 ) THEN
542 heimbach 1.51 CALL TIMER_START('CTRL_UNPACK [THE_MODEL_MAIN]',mythid)
543 heimbach 1.65 CALL CTRL_UNPACK( .TRUE. , mythid )
544 heimbach 1.51 CALL TIMER_STOP ('CTRL_UNPACK [THE_MODEL_MAIN]',mythid)
545 heimbach 1.65 IF ( optimcycle.EQ.0 .AND. mycurrentiter.EQ.niter0 ) THEN
546     CALL TIMER_START('CTRL_PACK [THE_MODEL_MAIN]',mythid)
547     CALL CTRL_PACK( .TRUE. , mythid )
548     CALL TIMER_STOP ('CTRL_PACK [THE_MODEL_MAIN]',mythid)
549     ENDIF
550 heimbach 1.51 ENDIF
551 heimbach 1.37 ENDIF
552     _END_MASTER( mythid )
553     _BARRIER
554 heimbach 1.65 # endif /* EXCLUDE_CTRL_PACK */
555 heimbach 1.37
556 heimbach 1.44 CALL COST_DEPENDENT_INIT ( mythid )
557     _BARRIER
558    
559 heimbach 1.58 # if ( defined (ALLOW_TANGENTLINEAR_RUN) )
560     c
561     CALL TIMER_START('G_THE_MAIN_LOOP [TANGENT RUN]',mythid)
562     CALL G_THE_MAIN_LOOP ( myCurrentTime, myCurrentIter, myThid )
563     CALL TIMER_STOP ('G_THE_MAIN_LOOP [TANGENT RUN]',mythid)
564     c
565     # elif ( defined (ALLOW_ADJOINT_RUN) || \
566     defined (ALLOW_ECCO_OPTIMIZATION) )
567 heimbach 1.55 c
568     # ifdef ALLOW_DIVIDED_ADJOINT
569 heimbach 1.52 c-- The following assumes the TAF option '-pure'
570     inquire( file='costfinal', exist=exst )
571     IF ( .NOT. exst) THEN
572     CALL TIMER_START('MDTHE_MAIN_LOOP [MD RUN]', mythid)
573     CALL MDTHE_MAIN_LOOP ( myCurrentTime, myCurrentIter, mythid )
574     CALL TIMER_STOP ('MDTHE_MAIN_LOOP [MD RUN]', mythid)
575     CALL COST_FINAL_STORE ( mythid, lastdiva )
576     ELSE
577     CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
578     CALL ADTHE_MAIN_LOOP ( mythid )
579     CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
580     CALL COST_FINAL_RESTORE ( mythid, lastdiva )
581     ENDIF
582     c--
583 heimbach 1.55 # else /* ALLOW_DIVIDED_ADJOINT undef */
584 heimbach 1.52 CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
585 heimbach 1.39 CALL ADTHE_MAIN_LOOP ( mythid )
586 heimbach 1.52 CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
587 heimbach 1.55 # endif /* ALLOW_DIVIDED_ADJOINT */
588 heimbach 1.58 c
589 heimbach 1.52 # endif
590 heimbach 1.44
591 heimbach 1.65 # ifndef EXCLUDE_CTRL_PACK
592 heimbach 1.44 _BEGIN_MASTER( mythid )
593 heimbach 1.52 IF ( myProcId .eq. 0 .AND. lastdiva ) THEN
594 heimbach 1.53 CALL TIMER_START('CTRL_PACK [THE_MODEL_MAIN]',mythid)
595 heimbach 1.65 call CTRL_PACK( .FALSE. , mythid )
596 heimbach 1.53 CALL TIMER_STOP ('CTRL_PACK [THE_MODEL_MAIN]',mythid)
597 heimbach 1.44 ENDIF
598     _END_MASTER( mythid )
599     _BARRIER
600 heimbach 1.65 # endif /* EXCLUDE_CTRL_PACK */
601    
602 heimbach 1.44
603 heimbach 1.64 # ifdef ALLOW_GRDCHK
604 heimbach 1.52 IF ( useGrdchk .AND. lastdiva ) THEN
605     CALL TIMER_START('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid)
606     CALL GRDCHK_MAIN( mythid )
607     CALL TIMER_STOP ('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid)
608     _BARRIER
609     ENDIF
610 heimbach 1.58 # endif
611 heimbach 1.52
612 heimbach 1.58 #else /* ALL AD-related undef */
613 heimbach 1.37
614 edhill 1.66 #ifdef ALLOW_DEBUG
615 adcroft 1.54 IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid)
616     #endif
617    
618 adcroft 1.32 C-- Call time stepping loop of full model
619 heimbach 1.45 CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
620 heimbach 1.44 CALL THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid )
621 heimbach 1.45 CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
622 adcroft 1.12
623 heimbach 1.58 #endif /* ALLOW_TANGENTLINEAR_RUN ALLOW_ADJOINT_RUN ALLOW_ADMTLM_RUN */
624 dimitri 1.50
625     C-- Final checkpoint (in case the in-loop checkpoint was missed)
626     CALL TIMER_START('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid)
627 jmc 1.69 CALL PACKAGES_WRITE_PICKUP(
628     I .TRUE., myCurrentTime, myCurrentIter, myThid )
629 dimitri 1.50 CALL WRITE_CHECKPOINT(
630 jmc 1.69 I .TRUE., myCurrentTime, myCurrentIter, myThid )
631 dimitri 1.50 CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid)
632 adcroft 1.19
633 heimbach 1.45 CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid)
634 cnh 1.7
635 adcroft 1.19 C-- Write timer statistics
636 cnh 1.20 IF ( myThid .EQ. 1 ) THEN
637     CALL TIMER_PRINTALL( myThid )
638     CALL COMM_STATS
639     ENDIF
640 adcroft 1.54
641 edhill 1.66 #ifdef ALLOW_DEBUG
642 adcroft 1.54 IF (debugMode) CALL DEBUG_LEAVE('THE_MODEL_MAIN',myThid)
643     #endif
644 cnh 1.1
645     RETURN
646     END

  ViewVC Help
Powered by ViewVC 1.1.22