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

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

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

revision 1.27 by adcroft, Mon Mar 22 16:44:17 1999 UTC revision 1.105 by jmc, Wed Oct 14 22:29:22 2009 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    C $Name$
3    
4    CBOI
5    C
6    C !TITLE: MITGCM KERNEL CODE SYNOPSIS
7    C !AUTHORS: mitgcm developers ( support@mitgcm.org )
8    C !AFFILIATION: Massachussetts Institute of Technology
9    C !DATE:
10    C !INTRODUCTION: Kernel dynamical routines
11    C This document summarises MITgcm code under the model/ subdirectory.
12    C The code under model/ ( src/ and inc/ ) contains most of
13    C the driver routines for the baseline forms of the kernel equations in the
14    C MITgcm algorithm. Numerical code for much of the baseline forms of
15    C these equations is also under the model/ directory. Other numerical code
16    C used for the kernel equations is contained in packages in the pkg/
17    C directory tree.
18    C Code for auxilliary equations and alternate dicretizations of the kernel
19    C equations and algorithm can also be found in the pkg/ directory tree.
20    C
21    C \subsection{Getting Help and Reporting Errors and Problems}
22    C If you have questions please e-mail support@mitgcm.org. We also welcome
23    C reports of errors and inconsistencies in the code or in the accompanying
24    C documentation. Please feel free to send these
25    C to support@mitgcm.org. For further information and to review
26    C problems reported to support@mitgcm.org please visit http://mitgcm.org.
27    C
28    C \subsection{MITgcm Kernel Code Calling Sequence}
29    C \bv
30    C
31    C Invocation from WRAPPER level...
32    C  :
33    C  :
34    C  |
35    C  |-THE_MODEL_MAIN :: Primary driver for the MITgcm algorithm
36    C    |              :: Called from WRAPPER level numerical
37    C    |              :: code invocation 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 :: Initializes monitor package ( see pkg/monitor )
52    C    | |
53    C    | |-INI_GRID :: Control grid array (vert. and hori.) initialization.
54    C    | | |        :: Grid arrays are held and described in GRID.h.
55    C    | | |
56    C    | | |-INI_VERTICAL_GRID        :: Initialize vertical grid arrays.
57    C    | | |
58    C    | | |-INI_CARTESIAN_GRID       :: Cartesian horiz. grid initialization
59    C    | | |                          :: (calculate grid from kernel parameters).
60    C    | | |
61    C    | | |-INI_SPHERICAL_POLAR_GRID :: Spherical polar horiz. grid
62    C    | | |                          :: initialization (calculate grid from
63    C    | | |                          :: kernel parameters).
64    C    | | |
65    C    | | |-INI_CURVILINEAR_GRID     :: General orthogonal, structured horiz.
66    C    | |                            :: grid initializations. ( 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 options are coded.
78    C    | |
79    C    | |-PACAKGES_BOOT      :: Start up the optional package environment.
80    C    | |                    :: Runtime selection of active packages.
81    C    | |
82    C    | |-PACKAGES_READPARMS :: Call active package internal parameter load.
83    C    | | |
84    C    | | |-GMREDI_READPARMS    :: GM Package. see pkg/gmredi
85    C    | | |-KPP_READPARMS       :: KPP Package. see pkg/kpp
86    C    | | |-SHAP_FILT_READPARMS :: Shapiro filter package. see pkg/shap_filt
87    C    | | |-OBCS_READPARMS      :: Open bndy package. see pkg/obcs
88    C    | | |-AIM_READPARMS       :: Intermediate Atmos. pacakage. see pkg/aim
89    C    | | |-COST_READPARMS      :: Cost function package. see pkg/cost
90    C    | | |-CTRL_INIT           :: Control vector support package. see pkg/ctrl
91    C    | | |-OPTIM_READPARMS     :: Optimisation support package. see pkg/ctrl
92    C    | | |-GRDCHK_READPARMS    :: Gradient check package. see pkg/grdchk
93    C    | | |-ECCO_READPARMS      :: ECCO Support Package. see pkg/ecco
94    C    | | |-PTRACERS_READPARMS  :: multiple tracer package, see pkg/ptracers
95    C    | | |-GCHEM_READPARMS     :: tracer interface package, see pkg/gchem
96    C    | |
97    C    | |-PACKAGES_CHECK
98    C    | | |
99    C    | | |-KPP_CHECK           :: KPP Package. pkg/kpp
100    C    | | |-OBCS_CHECK          :: Open bndy Pacakge. pkg/obcs
101    C    | | |-GMREDI_CHECK        :: GM Package. pkg/gmredi
102    C    | |
103    C    | |-PACKAGES_INIT_FIXED
104    C    | | |-OBCS_INIT_FIXED     :: Open bndy Package. see pkg/obcs
105    C    | | |-FLT_INIT            :: Floats Package. see pkg/flt
106    C    | | |-GCHEM_INIT_FIXED    :: tracer interface pachage, see pkg/gchem
107    C    | |
108    C    | |-ZONAL_FILT_INIT       :: FFT filter Package. see pkg/zonal_filt
109    C    | |
110    C    | |-INI_CG2D              :: 2d con. grad solver initialization.
111    C    | |
112    C    | |-INI_CG3D              :: 3d con. grad solver initialization.
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 generated 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 options are coded.
136    C    | | |
137    C    | | |-INI_CG2D     :: 2d con. grad solver initialization.
138    C    | | |-INI_CG3D     :: 3d con. grad solver initialization.
139    C    | | |-INI_MIXING   :: Initialize diapycnal diffusivity.
140    C    | | |-INI_DYNVARS  :: Initialize to zero all DYNVARS.h arrays (dynamical
141    C    | | |              :: fields).
142    C    | | |
143    C    | | |-INI_FIELDS   :: Control initializing model fields to non-zero
144    C    | | | |-INI_VEL    :: Initialize 3D flow field.
145    C    | | | |-INI_THETA  :: Set model initial temperature field.
146    C    | | | |-INI_SALT   :: Set model initial salinity field.
147    C    | | | |-INI_PSURF  :: Set model initial free-surface height/pressure.
148    C    | | | |-INI_PRESSURE :: Compute model initial hydrostatic pressure
149    C    | | | |-READ_CHECKPOINT :: Read the checkpoint
150    C    | | |
151    C    | | |-THE_CORRECTION_STEP :: Step forward to next time step.
152    C    | | | |                   :: Here applied to move restart conditions
153    C    | | | |                   :: (saved in mid timestep) to correct level in
154    C    | | | |                   :: time (only used for pre-c35).
155    C    | | | |
156    C    | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure
157    C    | | | |-CORRECTION_STEP    :: Pressure correction to momentum
158    C    | | | |-CYCLE_TRACER       :: Move tracers forward in time.
159    C    | | | |-OBCS_APPLY         :: Open bndy package. see pkg/obcs
160    C    | | | |-SHAP_FILT_APPLY    :: Shapiro filter package. see pkg/shap_filt
161    C    | | | |-ZONAL_FILT_APPLY   :: FFT filter package. see pkg/zonal_filt
162    C    | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing.
163    C    | | | | |-FIND_RHO  :: Find adjacent densities.
164    C    | | | | |-CONVECT   :: Mix static instability.
165    C    | | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
166    C    | | | |
167    C    | | | |-CALC_EXACT_ETA        :: Change SSH to flow divergence.
168    C    | | |
169    C    | | |-CONVECTIVE_ADJUSTMENT_INI :: Control static instability mixing
170    C    | | | |                         :: Extra time history interactions.
171    C    | | | |
172    C    | | | |-FIND_RHO  :: Find adjacent densities.
173    C    | | | |-CONVECT   :: Mix static instability.
174    C    | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
175    C    | | |
176    C    | | |-PACKAGES_INIT_VARIABLES :: Does initialization of time evolving
177    C    | | | |                       :: package data.
178    C    | | | |
179    C    | | | |-GMREDI_INIT          :: GM package. ( see pkg/gmredi )
180    C    | | | |-KPP_INIT             :: KPP package. ( see pkg/kpp )
181    C    | | | |-KPP_OPEN_DIAGS
182    C    | | | |-OBCS_INIT_VARIABLES  :: Open bndy. package. ( see pkg/obcs )
183    C    | | | |-PTRACERS_INIT        :: multi. tracer package,(see pkg/ptracers)
184    C    | | | |-GCHEM_INIT           :: tracer interface pkg (see pkh/gchem)
185    C    | | | |-AIM_INIT             :: Interm. atmos package. ( see pkg/aim )
186    C    | | | |-CTRL_MAP_INI         :: Control vector package.( see pkg/ctrl )
187    C    | | | |-COST_INIT            :: Cost function package. ( see pkg/cost )
188    C    | | | |-ECCO_INIT            :: ECCO support package. ( see pkg/ecco )
189    C    | | | |-INI_FORCING          :: Set model initial forcing fields.
190    C    | | |   |                    :: Either set in-line or from file as shown.
191    C    | | |   |-READ_FLD_XY_RS(zonalWindFile)
192    C    | | |   |-READ_FLD_XY_RS(meridWindFile)
193    C    | | |   |-READ_FLD_XY_RS(surfQFile)
194    C    | | |   |-READ_FLD_XY_RS(EmPmRfile)
195    C    | | |   |-READ_FLD_XY_RS(thetaClimFile)
196    C    | | |   |-READ_FLD_XY_RS(saltClimFile)
197    C    | | |   |-READ_FLD_XY_RS(surfQswFile)
198    C    | | |
199    C    | | |-CALC_SURF_DR   :: Calculate the new surface level thickness.
200    C    | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
201    C    | | |-UPDATE_CG2D    :: Update 2d conjugate grad. for Free-Surf.
202    C    | | |-STATE_SUMMARY    :: Summarize model prognostic variables.
203    C    | | |-TIMEAVE_STATVARS :: Time averaging package ( see pkg/timeave ).
204    C    | |
205    C    | |-WRITE_STATE      :: Controlling routine for IO to dump model state.
206    C    | | |-WRITE_REC_XYZ_RL :: Single file I/O
207    C    | | |-WRITE_FLD_XYZ_RL :: Multi-file I/O
208    C    | |
209    C    | |-MONITOR          :: Monitor state ( see pkg/monitor )
210    C    | |-CTRL_MAP_FORCING :: Control vector support package. ( see pkg/ctrl )
211    C====|>|
212    C====|>| ****************************
213    C====|>| BEGIN MAIN TIMESTEPPING LOOP
214    C====|>| ****************************
215    C====|>|
216    C/\  | |-FORWARD_STEP     :: Step forward a time-step ( AT LAST !!! )
217    C/\  | | |
218    C/\  | | |-DUMMY_IN_STEPPING :: autodiff package ( pkg/autoduff ).
219    C/\  | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
220    C/\  | | |-CALC_SURF_DR   :: Calculate the new surface level thickness.
221    C/\  | | |-EXF_GETFORCING :: External forcing package. ( pkg/exf )
222    C/\  | | |-EXTERNAL_FIELDS_LOAD :: Control loading time dep. external data.
223    C/\  | | | |                    :: Simple interpolation between end-points
224    C/\  | | | |                    :: for forcing datasets.
225    C/\  | | | |
226    C/\  | | | |-EXCH :: Sync forcing. in overlap regions.
227    C/\  | | |-SEAICE_MODEL   :: Compute sea-ice terms. ( pkg/seaice )
228    C/\  | | |-FREEZE         :: Limit surface temperature.
229    C/\  | | |-GCHEM_FIELD_LOAD :: load tracer forcing fields (pkg/gchem)
230    C/\  | | |
231    C/\  | | |-THERMODYNAMICS :: theta, salt + tracer equations driver.
232    C/\  | | | |
233    C/\  | | | |-INTEGRATE_FOR_W :: Integrate for vertical velocity.
234    C/\  | | | |-OBCS_APPLY_W    :: Open bndy. package ( see pkg/obcs ).
235    C/\  | | | |-FIND_RHO        :: Calculates [rho(S,T,z)-RhoConst] of a slice
236    C/\  | | | |-GRAD_SIGMA      :: Calculate isoneutral gradients
237    C/\  | | | |-CALC_IVDC       :: Set Implicit Vertical Diffusivity for Convection
238    C/\  | | | |
239    C/\  | | | |-OBCS_CALC            :: Open bndy. package ( see pkg/obcs ).
240    C/\  | | | |-EXTERNAL_FORCING_SURF:: Accumulates appropriately dimensioned
241    C/\  | | | | |                    :: forcing terms.
242    C/\  | | | | |-PTRACERS_FORCING_SURF :: Tracer package ( see pkg/ptracers ).
243    C/\  | | | |
244    C/\  | | | |-GMREDI_CALC_TENSOR   :: GM package ( see pkg/gmredi ).
245    C/\  | | | |-GMREDI_CALC_TENSOR_DUMMY :: GM package ( see pkg/gmredi ).
246    C/\  | | | |-KPP_CALC             :: KPP package ( see pkg/kpp ).
247    C/\  | | | |-KPP_CALC_DUMMY       :: KPP package ( see pkg/kpp ).
248    C/\  | | | |-AIM_DO_ATMOS_PHYSICS :: Intermed. atmos package ( see pkg/aim ).
249    C/\  | | | |-GAD_ADVECTION        :: Generalised advection driver (multi-dim
250    C/\  | | | |                         advection case) (see pkg/gad).
251    C/\  | | | |-CALC_COMMON_FACTORS  :: Calculate common data (such as volume flux)
252    C/\  | | | |-CALC_DIFFUSIVITY     :: Calculate net vertical diffusivity
253    C/\  | | | | |
254    C/\  | | | | |-GMREDI_CALC_DIFF   :: GM package ( see pkg/gmredi ).
255    C/\  | | | | |-KPP_CALC_DIFF      :: KPP package ( see pkg/kpp ).
256    C/\  | | | |
257    C/\  | | | |-CALC_GT              :: Calculate the temperature tendency terms
258    C/\  | | | | |
259    C/\  | | | | |-GAD_CALC_RHS       :: Generalised advection package
260    C/\  | | | | | |                  :: ( see pkg/gad )
261    C/\  | | | | | |-KPP_TRANSPORT_T  :: KPP non-local transport ( see pkg/kpp ).
262    C/\  | | | | |
263    C/\  | | | | |-EXTERNAL_FORCING_T :: Problem specific forcing for temperature.
264    C/\  | | | | |-ADAMS_BASHFORTH2   :: Extrapolate tendencies forward in time.
265    C/\  | | | | |-FREESURF_RESCALE_G :: Re-scale Gt for free-surface height.
266    C/\  | | | |
267    C/\  | | | |-TIMESTEP_TRACER      :: Step tracer field forward in time
268    C/\  | | | |
269    C/\  | | | |-CALC_GS              :: Calculate the salinity tendency terms
270    C/\  | | | | |
271    C/\  | | | | |-GAD_CALC_RHS       :: Generalised advection package
272    C/\  | | | | | |                  :: ( see pkg/gad )
273    C/\  | | | | | |-KPP_TRANSPORT_S  :: KPP non-local transport ( see pkg/kpp ).
274    C/\  | | | | |
275    C/\  | | | | |-EXTERNAL_FORCING_S :: Problem specific forcing for salt.
276    C/\  | | | | |-ADAMS_BASHFORTH2   :: Extrapolate tendencies forward in time.
277    C/\  | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
278    C/\  | | | |
279    C/\  | | | |-TIMESTEP_TRACER      :: Step tracer field forward in time
280    C/\  | | | |
281    C/\  | | | |-TIMESTEP_TRACER      :: Step tracer field forward in time
282    C/\  | | | |
283    C/\  | | | |-PTRACERS_INTEGRATE   :: Integrate other tracer(s) (see pkg/ptracers).
284    C/\  | | | | |
285    C/\  | | | | |-GAD_CALC_RHS       :: Generalised advection package
286    C/\  | | | | | |                  :: ( see pkg/gad )
287    C/\  | | | | | |-KPP_TRANSPORT_PTR:: KPP non-local transport ( see pkg/kpp ).
288    C/\  | | | | |
289    C/\  | | | | |-PTRACERS_FORCING   :: Problem specific forcing for tracer.
290    C/\  | | | | |-GCHEM_FORCING_INT  :: tracer forcing for gchem pkg (if all
291    C/\  | | | | |                       tendency terms calcualted together)
292    C/\  | | | | |-ADAMS_BASHFORTH2   :: Extrapolate tendencies forward in time.
293    C/\  | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
294    C/\  | | | | |-TIMESTEP_TRACER    :: Step tracer field forward in time
295    C/\  | | | |
296    C/\  | | | |-OBCS_APPLY_TS        :: Open bndy. package (see pkg/obcs ).
297    C/\  | | | |
298    C/\  | | | |-IMPLDIFF             :: Solve vertical implicit diffusion equation.
299    C/\  | | | |-OBCS_APPLY_TS        :: Open bndy. package (see pkg/obcs ).
300    C/\  | | | |
301    C/\  | | | |-AIM_AIM2DYN_EXCHANGES :: Inetermed. atmos (see pkg/aim).
302    C/\  | | | |-EXCH                 :: Update overlaps
303    C/\  | | |
304    C/\  | | |-DYNAMICS       :: Momentum equations driver.
305    C/\  | | | |
306    C/\  | | | |-CALC_GRAD_PHI_SURF :: Calculate the gradient of the surface
307    C/\  | | | |                       Potential anomaly.
308    C/\  | | | |-CALC_VISCOSITY     :: Calculate net vertical viscosity
309    C/\  | | | | |-KPP_CALC_VISC    :: KPP package ( see pkg/kpp ).
310    C/\  | | | |
311    C/\  | | | |-CALC_PHI_HYD       :: Integrate the hydrostatic relation.
312    C/\  | | | |-MOM_FLUXFORM       :: Flux form mom eqn. package ( see
313    C/\  | | | |                       pkg/mom_fluxform ).
314    C/\  | | | | |-MOM_CALC_VISC    :: Calculate Horizontal Viscosities
315    C/\  | | | |-MOM_VECINV         :: Vector invariant form mom eqn. package ( see
316    C/\  | | | |                       pkg/mom_vecinv   ).
317    C/\  | | | | |-MOM_CALC_VISC    :: Calculate Horizontal Viscosities
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/\  | | |-GCHEM_FORCING_SEP :: tracer forcing for gchem pkg (if
358    C/\  | | |                      tracer dependent tendencies calculated
359    C/\  | | |                      separatly)
360    C/\  | | |
361    C/\  | | |-FLT_MAIN         :: Float package ( pkg/flt ).
362    C/\  | | |
363    C/\  | | |-MONITOR          :: Monitor package ( pkg/monitor ).
364    C/\  | | |
365    C/\  | | |-DO_THE_MODEL_IO  :: Standard diagnostic I/O.
366    C/\  | | | |-WRITE_STATE    :: Core state I/O
367    C/\  | | | |-TIMEAVE_STATV_WRITE :: Time averages. see pkg/timeave
368    C/\  | | | |-AIM_WRITE_DIAGS     :: Intermed. atmos diags. see pkg/aim
369    C/\  | | | |-GMREDI_DIAGS        :: GM diags. see pkg/gmredi
370    C/\  | | | |-KPP_DO_DIAGS        :: KPP diags. see pkg/kpp
371    C/\  | | | |-SBO_CALC            :: SBO diags. see pkg/sbo
372    C/\  | | | |-SBO_DIAGS           :: SBO diags. see pkg/sbo
373    C/\  | | | |-SEAICE_DO_DIAGS     :: SEAICE diags. see pkg/seaice
374    C/\  | | | |-GCHEM_DIAGS         :: gchem diags. see pkg/gchem
375    C/\  | | |
376    C/\  | | |-WRITE_CHECKPOINT :: Do I/O for restart files.
377    C/\  | |
378    C/\  | |-COST_TILE        :: Cost function package. ( see pkg/cost )
379    C<===|=|
380    C<===|=| **************************
381    C<===|=| END MAIN TIMESTEPPING LOOP
382    C<===|=| **************************
383    C<===|=|
384    C    | |-COST_FINAL       :: Cost function package. ( see pkg/cost )
385    C    |
386    C    |-WRITE_CHECKPOINT :: Final state storage, for restart.
387    C    |
388    C    |-TIMER_PRINTALL :: Computational timing summary
389    C    |
390    C    |-COMM_STATS     :: Summarise inter-proc and inter-thread communication
391    C                     :: events.
392    C
393    C \ev
394    C
395    C
396    CEOI
397    
398    
399    #include "AD_CONFIG.h"
400    #include "PACKAGES_CONFIG.h"
401  #include "CPP_OPTIONS.h"  #include "CPP_OPTIONS.h"
402    
403    CBOP
404    
405    C     !ROUTINE: THE_MODEL_MAIN
406    
407    C     !INTERFACE:
408        SUBROUTINE THE_MODEL_MAIN(myThid)        SUBROUTINE THE_MODEL_MAIN(myThid)
 C     /==========================================================\  
 C     | SUBROUTINE THE_MODEL_MAIN                                |  
 C     | o Master controlling routine for model using the MITgcm  |  
 C     |   UV parallel wrapper.                                   |  
 C     |==========================================================|  
 C     | THE_MODEL_MAIN is invoked by the MITgcm UV parallel      |  
 C     | wrapper with a single integer argument "myThid". This    |  
 C     | variable identifies the thread number of an instance of  |  
 C     | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works    |  
 C     | on a particular region of the models domain and          |  
 C     | synchronises with other instances as necessary. The      |  
 C     | routine has to "understand" the MITgcm parallel          |  
 C     | environment and the numerical algorithm. Editing this    |  
 C     | routine is best done with some knowledge of both aspects.|  
 C     | Notes                                                    |  
 C     | =====                                                    |  
 C     | C*P* comments indicating place holders for which code is |  
 C     |      presently being developed.                          |  
 C     \==========================================================/  
409        IMPLICIT NONE        IMPLICIT NONE
410  C  
411  C     Call Tree  C     !DESCRIPTION: \bv
412  C     =========  C     *==========================================================*
413  C      C     | SUBROUTINE THE_MODEL_MAIN
414  C      main ( eesupp )  C     | o Master controlling routine for model using the MITgcm
415    C     |   UV parallel wrapper.
416    C     *==========================================================*
417    C     | THE_MODEL_MAIN is invoked by the MITgcm UV parallel
418    C     | wrapper with a single integer argument "myThid". This
419    C     | variable identifies the thread number of an instance of
420    C     | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works
421    C     | on a particular region of the models domain and
422    C     | synchronises with other instances as necessary. The
423    C     | routine has to "understand" the MITgcm parallel
424    C     | environment and the numerical algorithm. Editing this
425    C     | routine is best done with some knowledge of both aspects.
426    C     | Notes
427    C     | =====
428    C     | C*P* comments indicating place holders for which code is
429    C     |      presently being developed.
430    C     *==========================================================*
431    C     \ev
432    
433    C     !CALLING SEQUENCE:
434    C     THE_MODEL_MAIN()
435    C       |
436    C       |
437    C       |--INITIALISE_FIXED
438    C       |   o Set model configuration (fixed arrays)
439    C       |     Topography, hydrography, timestep, grid, etc..
440    C       |
441    C       |--CTRL_UNPACK      o Derivative mode. Unpack control vector.
442    C       |
443    C       |--ADTHE_MAIN_LOOP  o Main timestepping loop for combined
444    C       |                     prognostic and reverse mode integration.
445    C       |
446    C       |--CTRL_PACK        o Derivative mode. Unpack control vector.
447    C       |
448    C       |--GRDCHK_MAIN      o Gradient check control routine.
449  C       |  C       |
450  C       .  C       |--THE_MAIN_LOOP    o Main timestepping loop for pure prognostic
451  C       .  C       |                     integration.
 C       . Generic environment initialisation ( see eesupp/src and  
 C       .                                      eesupp/inc )        
 C       . multiple threads and/or processes are created in here  
 C       .  
 C       .  
 C       .  
452  C       |  C       |
453  C       |-THE_MODEL_MAIN - Begin specific model. One instance  C       |--WRITE_CHECKPOINT o Write retsart information.
 C       |  |               of this codes exists for each thread  
 C       |  |               and/or instance. Each instance manages  
 C       |  |               a specifc set of tiles.                
 C       |  |  
 C       |  |--INITIALISE  
 C       |  |   o Set initial conditions and model configuration  
 C       |  |     Topography, hydrography, timestep, grid, etc..  
 C       |  |  
 C  ==>  |  | ** Time stepping loop starts here **  
 C  |    |  |  
 C /|\   |  |  
 C  |    |  |--LOAD_EXTERNAL_DATA  
 C /|\   |  |   o Load and/or set time dependent forcing fields  
 C  |    |  |  
 C /|\   |  |--DYNAMICS  
 C  |    |  |   o Evaluate "forward" terms  
 C /|\   |  |  
 C  |    |  |--DO_THE_MODEL_IO  
 C /|\   |  |   o Write model state  
 C  |    |  |  
 C /|\   |  |--SOLVE_FOR_PRESSURE  
 C  |    |  |   o Find pressure field to keep flow non-divergent  
 C /|\   |  |  
 C  |    |  |--DO_GTERM_BLOCKING_EXCHANGES  
 C /|\   |  |   o Update overlap regions  
 C  |    |  |  
 C /|\   |  |--WRITE_CHECKPOINT  
 C  |    |  |   o Write restart file(s)  
 C /|\   |  |  
 C  |    |  |  
 C  |<== |  | ** Time stepping loop finishes here **  
 C       |  |  
 C       |  |--WRITE_STATE  
 C       |  |--WRITE_CHECKPOINT  
454  C       |  C       |
455  C       .  C       |--TIMER_PRINTALL   o Print out timing statistics.
456  C       .  C       |
457  C       . Generic environment termination ( see eesupp/src and  C       |--COMM_STATS       o Print out communication statistics.
 C       .                                      eesupp/inc )        
 C       .  
 C       .  
458    
459    C     !USES:
460  C     == Global variables ===  C     == Global variables ===
461  #include "SIZE.h"  #include "SIZE.h"
462  #include "EEPARAMS.h"  #include "EEPARAMS.h"
463  #include "PARAMS.h"  #include "PARAMS.h"
464  #include "DYNVARS.h"  #include "DYNVARS.h"
465  #include "CG2D.h"  
466  #ifdef ALLOW_NONHYDROSTATIC  #ifdef ALLOW_AUTODIFF_TAMC
467  #include "CG3D.h"  # include "tamc.h"
468    #endif
469    #ifdef ALLOW_CTRL
470    # include "ctrl.h"
471    # include "optim.h"
472  #endif  #endif
473    
474    C     !INPUT/OUTPUT PARAMETERS:
475  C     == Routine arguments ==  C     == Routine arguments ==
476  C     myThid - Thread number for this instance of the routine.  C     myThid - Thread number for this instance of the routine.
477        INTEGER myThid          INTEGER myThid
478    
479    C     !LOCAL VARIABLES:
480  C     == Local variables ==  C     == Local variables ==
481  C     Note: Under the multi-threaded model myCurrentIter and  C     Note: Under the multi-threaded model myCurrentIter and
482  C           myCurrentTime are local variables passed around as routine  C           myCurrentTime are local variables passed around as routine
483  C           arguments. Although this is fiddly it saves the need to  C           arguments. Although this is fiddly it saves the need to
484  C           impose additional synchronisation points when they are  C           impose additional synchronisation points when they are
485  C           updated.  C           updated.
 C     myCurrentIter - Iteration counter for this thread  
486  C     myCurrentTime - Time counter for this thread  C     myCurrentTime - Time counter for this thread
487  C     I             - Loop counter  C     myCurrentIter - Iteration counter for this thread
488        INTEGER I, myCurrentIter        INTEGER myCurrentIter
489        REAL    myCurrentTime        _RL     myCurrentTime
490        CHARACTER*(30) suff        logical  exst
491          logical  lastdiva
492    CEOP
493    c--   set default:
494          lastdiva = .TRUE.
495    
496    #ifdef ALLOW_DEBUG
497          IF (debugMode) CALL DEBUG_ENTER('THE_MODEL_MAIN',myThid)
498    #endif
499    
500    #if defined(USE_PAPI) || defined(USE_PCL_FLOPS_SFP) || defined(USE_PCL_FLOPS) || defined(USE_PCL)
501          CALL TIMER_CONTROL('','INIT','THE_MODEL_MAIN',myThid)
502    #endif
503  C--   This timer encompasses the whole code  C--   This timer encompasses the whole code
504        CALL TIMER_START('ALL',myThid)        CALL TIMER_START('ALL                    [THE_MODEL_MAIN]',myThid)
505    
506    #ifdef ALLOW_DEBUG
507          IF (debugMode) CALL DEBUG_CALL('INITIALISE_FIXED',myThid)
508    #endif
509    
510        CALL TIMER_START('SPIN-UP',myThid)  C--   Set model configuration (fixed arrays)
511          CALL TIMER_START('INITIALISE_FIXED       [THE_MODEL_MAIN]',myThid)
512          CALL INITIALISE_FIXED( myThid )
513          CALL TIMER_STOP ('INITIALISE_FIXED       [THE_MODEL_MAIN]',myThid)
514    
515    #ifdef ALLOW_DEBUG
516          IF (debugMode) CALL DEBUG_LEAVE('INITIALISE_FIXED',myThid)
517    #endif
518    
 C--   Set model initial conditions  
       CALL TIMER_START('INITIALISE          [SPIN-UP]',myThid)  
       CALL INITIALISE( myThid )  
519        myCurrentTime = startTime        myCurrentTime = startTime
520        myCurrentIter = nIter0        myCurrentIter = nIter0
       CALL TIMER_STOP ('INITIALISE          [SPIN-UP]',myThid)  
521    
522  C--   Dump for start state  #if ( defined (ALLOW_ADMTLM) )
523        CALL TIMER_START('I/O (WRITE)         [SPIN-UP]',myThid)  c
524        CALL WRITE_STATE( .TRUE., myCurrentTime, myCurrentIter, myThid )        STOP 'should never get here; ADMTLM_DSVD calls ADMTLM_DRIVER'
525        CALL TIMER_STOP ('I/O (WRITE)         [SPIN-UP]',myThid)  c
526    #elif ( defined (ALLOW_AUTODIFF))
527        CALL TIMER_STOP ('SPIN-UP',myThid)  
528    # ifndef EXCLUDE_CTRL_PACK
529  C--   Begin time stepping loop        _BEGIN_MASTER( mythid )
530        CALL TIMER_START('MAIN LOOP',myThid)        IF (myProcId .eq. 0) THEN
531        DO I=1, nTimeSteps           inquire( file='costfinal', exist=exst )
532             IF ( .NOT. exst ) THEN
533  C--    Load forcing/external data fields              IF ( optimcycle.NE.0 .AND. doMainUnpack ) THEN
534         CALL TIMER_START('I/O (READ)         [MAIN LOOP]',myThid)                 CALL TIMER_START('CTRL_UNPACK   [THE_MODEL_MAIN]',mythid)
535         CALL LOAD_EXTERNAL_FIELDS( myCurrentTime, myCurrentIter, myThid )                 CALL CTRL_UNPACK( .TRUE. , mythid )
536         CALL TIMER_STOP ('I/O (READ)         [MAIN LOOP]',myThid)                 CALL TIMER_STOP ('CTRL_UNPACK   [THE_MODEL_MAIN]',mythid)
537                ENDIF
538  #ifdef INCLUDE_SHAPIRO_FILTER_CODE           ENDIF
539  C--    Step forward all tiles, filter and exchange.        ENDIF
540         CALL TIMER_START('SHAP_FILT          [MAIN LOOP]',myThid)        _END_MASTER( mythid )
541         CALL SHAP_FILT( myCurrentTime, myCurrentIter, myThid )        _BARRIER
542         CALL TIMER_STOP ('SHAP_FILT          [MAIN LOOP]',myThid)  # endif /* EXCLUDE_CTRL_PACK */
543  #endif  
544    # ifdef ALLOW_COST
545  C--    Set Open Boundaries Values        CALL COST_DEPENDENT_INIT ( mythid )
546         IF (openBoundaries) THEN        _BARRIER
547          CALL TIMER_START('OBCS               [MAIN LOOP]',myThid)  # endif
548          CALL SET_OBCS( myCurrentTime, myThid )  
549          CALL TIMER_STOP ('OBCS               [MAIN LOOP]',myThid)  # if ( defined (ALLOW_TANGENTLINEAR_RUN) )
550         ENDIF  c
551    #ifdef ALLOW_DEBUG
552  C--    Step forward fields and calculate time tendency terms        IF (debugMode) CALL DEBUG_CALL('G_THE_MAIN_LOOP',myThid)
553         CALL TIMER_START('DYNAMICS           [MAIN LOOP]',myThid)  #endif
554         CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )        CALL TIMER_START('G_THE_MAIN_LOOP           [TANGENT RUN]',mythid)
555         CALL TIMER_STOP ('DYNAMICS           [MAIN LOOP]',myThid)        CALL G_THE_MAIN_LOOP ( myCurrentTime, myCurrentIter, myThid )
556          CALL TIMER_STOP ('G_THE_MAIN_LOOP           [TANGENT RUN]',mythid)
557  #ifdef ALLOW_NONHYDROSTATIC  c
558  C--    Step forward W field in N-H algorithm  # elif ( defined (ALLOW_ADJOINT_RUN) || \
559         IF ( nonHydrostatic ) THEN           defined (ALLOW_ECCO_OPTIMIZATION) )
560          CALL TIMER_START('CALC_GW            [MAIN LOOP]',myThid)  c
561          CALL CALC_GW( myThid)  #  ifdef ALLOW_DIVIDED_ADJOINT
562          CALL TIMER_STOP ('CALC_GW            [MAIN LOOP]',myThid)  c-- The following assumes the TAF option '-pure'
563         ENDIF        inquire( file='costfinal', exist=exst )
564  #endif        IF ( .NOT. exst) THEN
565    #ifdef ALLOW_DEBUG
566  C--    Do time averages           IF (debugMode) CALL DEBUG_CALL('MDTHE_MAIN_LOOP',myThid)
567  #ifdef INCLUDE_DIAGNOSTICS_INTERFACE_CODE  #endif
568         CALL TIMER_START('I/O (WRITE)        [MAIN LOOP]',myThid)           CALL TIMER_START('MDTHE_MAIN_LOOP            [MD RUN]', mythid)
569         IF (taveFreq.GT.0.) THEN           CALL MDTHE_MAIN_LOOP ( myCurrentTime, myCurrentIter, mythid )
570          CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid )           CALL TIMER_STOP ('MDTHE_MAIN_LOOP            [MD RUN]', mythid)
571         ENDIF           CALL COST_FINAL_STORE ( mythid, lastdiva )
572         CALL TIMER_STOP ('I/O (WRITE)        [MAIN LOOP]',myThid)        ELSE
573  #endif  #ifdef ALLOW_DEBUG
574             IF (debugMode) CALL DEBUG_CALL('ADTHE_MAIN_LOOP',myThid)
575  C--    Do IO if needed.  #endif
576  C      Note:           CALL TIMER_START('ADTHE_MAIN_LOOP       [ADJOINT RUN]', mythid)
577  C      =====           CALL ADTHE_MAIN_LOOP (  mythid )
578  C      At this point model arrays hold U,V,T,S  at "time-level" N           CALL TIMER_STOP ('ADTHE_MAIN_LOOP       [ADJOINT RUN]', mythid)
579  C      and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1.           CALL COST_FINAL_RESTORE ( mythid, lastdiva )
580  C      By convention this is taken to be the model "state".        ENDIF
581         CALL TIMER_START('I/O (WRITE)        [MAIN LOOP]',myThid)  c--
582         CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid )  #  else /* ALLOW_DIVIDED_ADJOINT undef */
583         CALL TIMER_STOP ('I/O (WRITE)        [MAIN LOOP]',myThid)  #ifdef ALLOW_DEBUG
584          IF (debugMode) CALL DEBUG_CALL('ADTHE_MAIN_LOOP',myThid)
585  C--    Solve elliptic equation(s).  #endif
586  C      Two-dimensional only for conventional hydrostatic or        CALL TIMER_START('ADTHE_MAIN_LOOP          [ADJOINT RUN]', mythid)
587  C      three-dimensional for non-hydrostatic and/or IGW scheme.  #ifdef ALLOW_ECCO
588         CALL TIMER_START('SOLVE_FOR_PRESSURE [MAIN LOOP]',myThid)        CALL ADTHE_MAIN_LOOP ( myCurrentTime, mythid )
589         CALL SOLVE_FOR_PRESSURE( myThid )  #else
590         CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [MAIN LOOP]',myThid)        CALL ADTHE_MAIN_LOOP ( mythid )
591    #endif
592  C--    Do "blocking" sends and receives for tendency "overlap" terms        CALL TIMER_STOP ('ADTHE_MAIN_LOOP          [ADJOINT RUN]', mythid)
593         CALL TIMER_START('BLOCKING_EXCHANGES [MAIN LOOP]',myThid)  #  endif /* ALLOW_DIVIDED_ADJOINT */
594         CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )  c
595         CALL TIMER_STOP ('BLOCKING_EXCHANGES [MAIN LOOP]',myThid)  # else /* forward run only within AD setting */
596    
597         myCurrentIter = myCurrentIter + 1  #ifdef ALLOW_DEBUG
598         myCurrentTime = myCurrentTime + deltaTClock        IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid)
599    #endif
600  C--    Save state for restarts  C--   Call time stepping loop of full model
601  C      Note:  #ifdef ALLOW_DEBUG
602  C      =====        IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid)
603  C      Because of the ordering of the timestepping code and  #endif
604  C      tendency term code at end of loop model arrays hold        CALL TIMER_START('THE_MAIN_LOOP          [THE_MODEL_MAIN]',myThid)
605  C      U,V,T,S  at "time-level" N but gu, gv, gs, gt, guNM1,...        CALL THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid )
606  C      at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is        CALL TIMER_STOP ('THE_MAIN_LOOP          [THE_MODEL_MAIN]',myThid)
607  C      gu at "time-level" N-1/2) and cg2d_x at "time-level" N+1/2.  
608  C       where N = I+timeLevBase-1  # endif
609  C      Thus a checkpoint contains U.0000000000, GU.0000000001 and  
610  C      cg2d_x.0000000001 in the indexing scheme used for the model  # ifndef EXCLUDE_CTRL_PACK
611  C      "state" files. This example is referred to as a checkpoint        _BEGIN_MASTER( mythid )
612  C      at time level 1        IF ( myProcId .eq. 0 .AND. lastdiva .AND. doMainPack ) THEN
613         CALL TIMER_START('I/O (WRITE)        [MAIN LOOP]',myThid)           CALL TIMER_START('CTRL_PACK           [THE_MODEL_MAIN]',mythid)
614         CALL           CALL CTRL_PACK( .FALSE. , mythid )
615       & WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid )           CALL TIMER_STOP ('CTRL_PACK           [THE_MODEL_MAIN]',mythid)
616         CALL TIMER_STOP ('I/O (WRITE)        [MAIN LOOP]',myThid)           IF ( ( optimcycle.EQ.0 .OR. (.NOT. doMainUnpack) )
617         &        .AND. mycurrentiter.EQ.niter0 ) THEN
618        ENDDO              CALL TIMER_START('CTRL_PACK     [THE_MODEL_MAIN]',mythid)
619        CALL TIMER_STOP ('MAIN LOOP',myThid)              CALL CTRL_PACK( .TRUE. , mythid )
620        CALL TIMER_START('SPIN-DOWN',myThid)              CALL TIMER_STOP ('CTRL_PACK     [THE_MODEL_MAIN]',mythid)
621             ENDIF
 C--   Final checkpoint (incase the in-loop checkpoint was missed)  
       CALL TIMER_START('I/O (WRITE)         [SPIN-DOWN]',myThid)  
       CALL  
      & WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid )  
       CALL TIMER_STOP ('I/O (WRITE)         [SPIN-DOWN]',myThid)  
   
 C--   Set Open Boundaries Values  
       IF (openBoundaries) THEN  
        CALL TIMER_START('OBCS               [SPIN_DOWN]',myThid)  
        CALL SET_OBCS( myCurrentTime, myThid )  
        CALL TIMER_STOP ('OBCS               [SPIN_DOWN]',myThid)  
622        ENDIF        ENDIF
623          _END_MASTER( mythid )
624          _BARRIER
625    # endif /* EXCLUDE_CTRL_PACK */
626    
627    
628  C--   Step-forward U/V/Theta/Salt for purposes of final I/O dump  # ifdef ALLOW_GRDCHK
629        CALL TIMER_START('DYNAMICS            [SPIN-DOWN]',myThid)        IF ( useGrdchk .AND. lastdiva ) THEN
630        CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )           CALL TIMER_START('GRDCHK_MAIN         [THE_MODEL_MAIN]',mythid)
631        CALL TIMER_STOP ('DYNAMICS            [SPIN-DOWN]',myThid)           CALL GRDCHK_MAIN( mythid )
632             CALL TIMER_STOP ('GRDCHK_MAIN         [THE_MODEL_MAIN]',mythid)
633  #ifdef ALLOW_NONHYDROSTATIC           _BARRIER
       IF ( nonHydrostatic ) THEN  
 C--    Step forward W field in N-H algorithm  
        CALL TIMER_START('CALC_GW            [SPIN-DOWN]',myThid)  
        CALL CALC_GW( myThid)  
        CALL TIMER_STOP ('CALC_GW            [SPIN-DOWN]',myThid)  
634        ENDIF        ENDIF
635    # endif
636    
637    #else /* ALL AD-related undef */
638    
639    #ifdef ALLOW_DEBUG
640          IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid)
641  #endif  #endif
642    C--   Call time stepping loop of full model
643          CALL TIMER_START('THE_MAIN_LOOP          [THE_MODEL_MAIN]',myThid)
644          CALL THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid )
645          CALL TIMER_STOP ('THE_MAIN_LOOP          [THE_MODEL_MAIN]',myThid)
646    
647    #endif /* ALLOW_TANGENTLINEAR_RUN ALLOW_ADJOINT_RUN ALLOW_ADMTLM */
648    
 C--   Do time averages  
649  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
650        IF (taveFreq.GT.0.) THEN        IF (useDiagnostics) THEN
651         CALL TIMER_START('I/O (WRITE)        [SPIN-DOWN]',myThid)  C       Close all diagnostics output files
652         CALL WRITE_TIME_AVERAGES( myCurrentTime, myCurrentIter, myThid )          CALL DIAGSTATS_CLOSE_IO( myThid )
        CALL TIMER_STOP ('I/O (WRITE)        [SPIN-DOWN]',myThid)  
653        ENDIF        ENDIF
654  #endif  #endif
655    
656  C--   Dump for end state  #ifdef ALLOW_MNC
657        CALL TIMER_START('I/O (WRITE)         [SPIN-DOWN]',myThid)        IF (useMNC) THEN
658        CALL WRITE_STATE( .FALSE., myCurrentTime, myCurrentIter, myThid )  C       Close all open NetCDF files
659        CALL TIMER_STOP ('I/O (WRITE)         [SPIN-DOWN]',myThid)          _BEGIN_MASTER( mythid )
660            CALL MNC_FILE_CLOSE_ALL( myThid )
661            _END_MASTER( mythid )
662          ENDIF
663    #endif
664    
665        CALL TIMER_STOP ('SPIN-DOWN',myThid)  C--   This timer encompasses the whole code
666        CALL TIMER_STOP ('ALL',myThid)        CALL TIMER_STOP ('ALL                    [THE_MODEL_MAIN]',myThid)
667    
668  C--   Write timer statistics  C--   Write timer statistics
669        IF ( myThid .EQ. 1 ) THEN        IF ( myThid .EQ. 1 ) THEN
# Line 270  C--   Write timer statistics Line 671  C--   Write timer statistics
671         CALL COMM_STATS         CALL COMM_STATS
672        ENDIF        ENDIF
673    
674    C--   Check threads synchronization :
675          CALL BAR_CHECK( 9, myThid )
676    
677    #ifdef ALLOW_DEBUG
678          IF (debugMode) CALL DEBUG_LEAVE('THE_MODEL_MAIN',myThid)
679    #endif
680    
681        RETURN        RETURN
682        END        END

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.105

  ViewVC Help
Powered by ViewVC 1.1.22