/[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.58 - (hide annotations) (download)
Thu Oct 2 21:33:54 2003 UTC (20 years, 8 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint51g_post
Changes since 1.57: +22 -16 lines
Bringing code up to date for AD
o remove some IF-statements which cause excessive dependencies
o provide interface for ADM*TLM

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

  ViewVC Help
Powered by ViewVC 1.1.22