/[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.79 - (hide annotations) (download)
Fri Sep 10 12:19:30 2004 UTC (19 years, 8 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint54f_post
Changes since 1.78: +4 -1 lines
 o overhaul of IO so that we now have flags for MDSIO and/or MNC
   - all verification tests compile and run with linux_ia32_g77
   - defaults are compatible with current input files--nothing
     should change if you were not previously using MNC
   - MNC output has been added in numerous places (eg. timeave)
     but there are still a few writes not yet do-able with MNC
     (this is in progress)
   - flags now allow for either/or/both use of MDSIO and MNC and
     documentation will soon follow
   - numerous small formatting cleanups for ProTeX

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

  ViewVC Help
Powered by ViewVC 1.1.22