/[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.123 - (hide annotations) (download)
Mon Sep 18 16:44:16 2017 UTC (6 years, 7 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, HEAD
Changes since 1.122: +5 -1 lines
- add missing CPP brackets

1 gforget 1.123 C $Header: /u/gcmpack/MITgcm/model/src/the_model_main.F,v 1.122 2015/01/20 15:00:55 dgoldberg Exp $
2 heimbach 1.85 C $Name: $
3 cnh 1.41
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 jmc 1.111 C Code for auxiliary equations and alternate discretizations of the kernel
19 cnh 1.42 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 jmc 1.111 C If you have questions please subscribe and e-mail support@mitgcm.org.
23     C We also welcome reports of errors and inconsistencies in the code or
24     C in the accompanying documentation. Please feel free to send these
25 cnh 1.42 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 jmc 1.111 C
33 cnh 1.42 C |
34     C |-THE_MODEL_MAIN :: Primary driver for the MITgcm algorithm
35     C | :: Called from WRAPPER level numerical
36 edhill 1.93 C | :: code invocation routine. On entry
37 cnh 1.42 C | :: to THE_MODEL_MAIN separate thread and
38     C | :: separate processes will have been established.
39     C | :: Each thread and process will have a unique ID
40     C | :: but as yet it will not be associated with a
41     C | :: specific region in decomposed discrete space.
42     C |
43 jmc 1.110 C |-INITIALISE_FIXED :: Set fixed model arrays such as topography,
44 cnh 1.42 C | | :: grid, solver matrices etc..
45 jmc 1.103 C | |
46 cnh 1.42 C | |-INI_PARMS :: Routine to set kernel model parameters.
47 jmc 1.111 C | | :: Kernel parameters are read from file "data"
48     C | | :: in directory in which code executes.
49 cnh 1.42 C | |
50 jmc 1.118 C | |-PACKAGES_BOOT :: Start up the optional package environment.
51 jmc 1.111 C | | :: Runtime selection of active packages.
52 jmc 1.118 C | |-PACKAGES_READPARMS :: read each package input parameter file
53 jmc 1.111 C | | |- ${PKG}_READPARMS
54 cnh 1.42 C | |
55 jmc 1.118 C | |-SET_PARMS :: Finalise model parameter setting (if fct of pkg usage)
56 cnh 1.42 C | |
57 jmc 1.118 C | |-INI_MODEL_IO :: Initialise Input/Output setting
58     C | | |-MNC_INIT :: Initialise MITgcm NetCDF interface (MNC)(see pkg/mnc)
59     C | | |-MNC_CW_INIT :: Initialise MNC grid and variable types (see pkg/mnc)
60     C | | |-MON_INIT :: Initialises monitor package ( see pkg/monitor )
61     C | |
62     C | |-INI_GRID :: Control grid array (vert. and horiz.) initialisation.
63     C | | | :: Grid arrays are held and described in GRID.h.
64     C | | |-LOAD_GRID_SPACING :: Load grid spacing (vector) from files
65     C | | |-INI_VERTICAL_GRID :: Set up vertical grid and coordinate
66     C | | |-INI_CARTESIAN_GRID :: Cartesian horiz. grid initialisation
67     C | | | :: (calculate grid from kernel parameters).
68     C | | |-INI_SPHERICAL_POLAR_GRID :: Spherical polar horiz. grid setting
69     C | | | :: (calculate grid from kernel parameters).
70     C | | |-INI_CURVILINEAR_GRID :: General orthogonal, structured horiz. grid
71     C | | | :: initialisation; input from raw grid files
72     C | | | :: (LONC.bin, LATC.bin, DXF.bin, ... ) or per
73     C | | | :: face file: horizGridFile(.faceXXX.bin)
74     C | | |-INI_CYLINDER_GRID :: Cylindrical horiz. grid setting
75     C | |
76     C | |-LOAD_REF_FILES :: Read-in reference vertical profiles (T,S,Rho)
77     C | |-INI_EOS :: Initialise Equation Of State (EOS) coefficients
78     C | |-SET_REF_STATE :: Set reference pressure/geopotential, reference
79     C | | :: stratification (for implicit IGW), vertical
80     C | | :: velocity scaling factor and anelastic ref. density
81     C | |-SET_GRID_FACTORS :: Set grid factors (fct of k) for deep-atmosphere
82 cnh 1.42 C | |
83 jmc 1.111 C | |-INI_DEPTHS :: Read (from "bathyFile") or set bathymetry/orography.
84 cnh 1.42 C | |-INI_MASKS_ETC :: Derive horizontal and vertical cell fractions and
85     C | | :: land masking for solid-fluid boundaries.
86     C | |
87 jmc 1.111 C | |-PACKAGES_INIT_FIXED :: do all packages fixed-initialisation setting
88     C | | |- ${PKG}_INIT_FIXED
89 cnh 1.42 C | |
90 jmc 1.118 C | |-INI_GLOBAL_DOMAIN :: Initialise domain related (global) quantities.
91     C | |-INI_LINEAR_PHISURF :: Set ref. surface Bo_surf
92 cnh 1.42 C | |
93 jmc 1.118 C | |-INI_CORI :: Set coriolis term. zero, f-plane, beta-plane,
94     C | | :: sphere options are coded.
95     C | |-INI_CG2D :: 2D conjugate grad solver initialisation.
96     C | |-INI_CG3D :: 3D conjugate grad solver initialisation.
97     C | |
98     C | |-CONFIG_SUMMARY :: Provide synopsis of kernel setup. Includes
99     C | | :: annotated table of kernel parameter settings.
100     C | |
101     C | |-PACKAGES_CHECK :: call each package configuration checking S/R
102 jmc 1.111 C | | |- ${PKG}_CHECK
103 cnh 1.42 C | |
104 jmc 1.118 C | |-CONFIG_CHECK :: Check config and parameter consistency.
105     C | |
106     C | |-WRITE_GRID :: write grid fields to output files
107     C | |-CPL_EXCH_CONFIGS :: exchange config with coupler-interface
108 cnh 1.42 C |
109 jmc 1.118 C |-CTRL_UNPACK :: Control vector support package. see pkg/ctrl
110     C |-COST_DEPENDENT_INIT :: ( see pkg/cost )
111 cnh 1.42 C |
112     C |-ADTHE_MAIN_LOOP :: Derivative evaluating form of main time stepping loop
113 jmc 1.111 C ! :: Automatically generated by TAMC/TAF.
114 cnh 1.42 C |
115 jmc 1.111 C |-THE_MAIN_LOOP :: Main timestepping loop routine.
116 cnh 1.42 C | |
117 jmc 1.118 C | |-INITIALISE_VARIA :: Set the initial conditions for time evolving fields
118     C | | |
119     C #ifdef ALLOW_AUTODIFF
120     C | | |-INI_DEPTHS \
121     C | | |-CTRL_DEPTH_INI \
122     C | | |-UPDATE_MASKS_ETC } ALLOW_DEPTH_CONTROL case
123     C | | |-UPDATE_CG2D /
124     C #endif
125     C | | |-INI_NLFS_VARS :: Initialise all Non-Lin Free-Surf arrays (SURFACE.h)
126     C | | |-INI_DYNVARS :: Initialise to zero all DYNVARS.h arrays
127     C | | |-INI_NH_VARS :: Initialise to zero all NH_VARS.h arrays
128     C | | |
129     C | | |-INI_FIELDS :: Control initialising model fields to non-zero
130     C | | | |-INI_VEL :: Initialize 3D flow field.
131     C | | | |-INI_THETA :: Set model initial temperature field.
132     C | | | |-INI_SALT :: Set model initial salinity field.
133     C | | | |-INI_PSURF :: Set model initial free-surface height/pressure.
134     C | | | |-READ_PICKUP :: Read in main model pickup files to restart a run.
135     C | | |
136     C | | |-INI_MIXING :: Initialise diapycnal diffusivity.
137     C | | |
138     C | | |-INI_FORCING :: Set model initial forcing fields, either
139     C | | | | :: set in-line or from file as shown here:
140     C | | | |-READ_FLD_XY_RS(zonalWindFile)
141     C | | | |-READ_FLD_XY_RS(meridWindFile)
142     C | | | |-READ_FLD_XY_RS(surfQnetFile)
143     C | | | |-READ_FLD_XY_RS(EmPmRfile)
144     C | | | |-READ_FLD_XY_RS(thetaClimFile)
145     C | | | |-READ_FLD_XY_RS(saltClimFile)
146     C | | | |-READ_FLD_XY_RS(surfQswFile)
147 cnh 1.42 C | | |
148 jmc 1.118 C | | |-AUTODIFF_INIT_VARIA :: (see pkg/autodiff )
149 cnh 1.42 C | | |
150 jmc 1.111 C | | |-PACKAGES_INIT_VARIABLES :: Does initialisation of time evolving
151     C | | | | ${PKG}_INIT_VARIA :: package data.
152 cnh 1.42 C | | |
153 jmc 1.118 C | | |-COST_INIT_VARIA :: ( see pkg/cost )
154     C | | |-CONVECTIVE_ADJUSTMENT_INI :: Apply conv. adjustment to initial state
155     C | | |
156     C | | |-CALC_R_STAR :: Calculate the new level thickness factor (r* coord)
157     C | | |-UPDATE_R_STAR :: Update the level thickness fraction (r* coord).
158     C | | |-UPDATE_SIGMA :: Update the level thickness fraction (sigma-coord).
159     C | | |-CALC_SURF_DR :: Calculate the new surface level thickness.
160     C | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
161     C | | |
162     C | | |-UPDATE_CG2D :: Update 2D conjugate grad. for Free-Surf.
163     C | | |
164     C | | |-INTEGR_CONTINUITY :: Integrate the continuity Equation
165     C | | | |-INTEGRATE_FOR_W :: Integrate for vertical velocity
166     C | | | |-OBCS_APPLY_W :: Open boundary package (see pkg/obcs).
167     C | | | |-UPDATE_ETAH :: Update Surface height/pressure
168     C | | |
169     C | | |-CALC_R_STAR :: Calculate the new level thickness factor (r* coord)
170     C | | |-CALC_SURF_DR :: Calculate the new surface level thickness.
171     C | | |
172     C | | |-STATE_SUMMARY :: Summarise model prognostic variables.
173     C | | |
174 jmc 1.111 C | | |-MONITOR :: Monitor state (see pkg/monitor)
175 jmc 1.118 C | | |
176     C | | |-DO_STATEVARS_TAVE :: Time averaging package ( see pkg/timeave ).
177     C | | | |-TIMEAVE_STATVARS :: Accumulate main model state variables
178     C | | | |-PTRACERS_TIMEAVE :: Accumulate passive tracers variables
179     C | | |
180     C | | |-DO_THE_MODEL_IO :: Controlling routine for IO
181     C | | | |-WRITE_STATE :: Write model state variables.
182     C | | | |-TIMEAVE_STATV_WRITE :: Write Time averaged output (see pkg/timeave)
183     C | | | |-FIZHI_WRITE_STATE :: Write Fizhi pkg output (see pkg/fizhi)
184     C | | | |-AIM_WRITE_TAVE :: Write AIM pkg output (see pkg/aim_v23)
185     C | | | |-LAND_OUTPUT :: Write Land pkg output (see pkg/land)
186     C | | | |-OBCS_OUTPUT :: Write OBCS pkg output (see pkg/obcs)
187     C | | | |-GMREDI_OUTPUT :: Write GM-Redi pkg output (see pkg/gmredi)
188     C | | | |-KPP_OUTPUT :: Write KPP pkg output (see pkg/kpp)
189     C | | | |-PP81_OUTPUT :: Write PP81 pkg output (see pkg/pp81)
190     C | | | |-KL10_OUTPUT :: Write KL10 pkg output (see pkg/kl10)
191     C | | | |-MY82_OUTPUT :: Write MY82 pkg output (see pkg/my82)
192     C | | | |-OPPS_OUTPUT :: Write OPPS pkg output (see pkg/opps)
193     C | | | |-GGL90_OUTPUT :: Write GGL90 pkg output (see pkg/ggl90)
194     C | | | |-SBO_CALC :: Compute SBO diagnostics (see pkg/sbo)
195     C | | | |-SBO_OUTPUT :: Write SBO pkg output (see pkg/sbo)
196     C | | | |-SEAICE_OUTPUT :: Write SeaIce pkg output (see pkg/seaice)
197     C | | | |-SHELFICE_OUTPUT :: Write ShelfIce pkg output (see pkg/shelfice)
198     C | | | |-BULKF_OUTPUT :: Write Bulk-Force output (see pkg/bulK_force)
199     C | | | |-THSICE_OUTPUT :: Write ThSIce pkg output (see pkg/thsice)
200     C | | | |-PTRACERS_OUTPUT :: Write pTracers pkg output (see pkg/ptracers)
201     C | | | |-MATRIX_OUTPUT :: Write Matrix pkg output (see pkg/matrix)
202     C | | | |-GCHEM_OUTPUT :: Write Geochemistry pkg output (see pkg/gchem)
203     C | | | |-CPL_OUTPUT :: Write Coupler-Interface output (see
204     C | | | | :: pkg/atm_compon_interf, pkg/ocn_compon_interf)
205     C | | | |-LAYERS_CALC :: Calculate layers diagnostics (see pkg/layers)
206     C | | | |-LAYERS_OUTPUT :: Write Layers pkg output (see pkg/layers)
207     C | | | |-DIAGNOSTICS_WRITE :: Write pkg/diagnostics output
208     C | | |
209 cnh 1.42 C====|>| ****************************
210     C====|>| BEGIN MAIN TIMESTEPPING LOOP
211     C====|>| ****************************
212 jmc 1.111 C | |-COST_AVERAGESFIELDS :: time-averaged Cost function terms (see pkg/cost)
213 jmc 1.118 C | |-PROFILES_INLOOP :: ( see pkg/profiles )
214     C | /
215     C | |-MAIN_DO_LOOP :: Open-AD case: Main timestepping loop routine
216     C | \ otherwise: just call FORWARD_STEP
217 jmc 1.111 C | |
218     C/\ | |-FORWARD_STEP :: Step forward a time-step ( AT LAST !!! )
219     C/\ | | |
220 jmc 1.118 C/\ | | |-AUTODIFF_INADMODE_UNSET :: Set/reset some adjoint flags
221     C/\ | | |-RESET_NLFS_VARS :: Reset some Non-Lin Free-Surf vars (Adjoint)
222     C/\ | | |-UPDATE_R_STAR :: Reset r-star factor variables (Adjoint)
223     C/\ | | |-UPDATE_SURF_DR :: Reset NLFS surface thickness vars (Adjoint)
224     C/\ | | |
225     C/\ | | |-PTRACERS_SWITCH_ONOFF :: Set/reset pTracers time-stepping switch
226     C/\ | | |-DIAGNOSTICS_SWITCH_ONOFF :: Activate/de-activate diagnostics
227     C/\ | | |-DO_STATEVARS_DIAGS ( 0 ) :: fill-up state variable diagnostics
228     C/\ | | |
229     C/\ | | |-NEST_CHILD_SETMEMO :: Nesting interface
230     C/\ | | |-NEST_PARENT_IO_1 :: Nesting interface
231     C/\ | | |
232     C/\ | | |-LOAD_FIELDS_DRIVER :: Control loading of input fields from files
233     C/\ | | |
234     C/\ | | |-BULKF_FORCING :: Calculate surface forcing (see pkg/bulk_force)
235     C/\ | | |-CHEAPAML :: Cheap AML driver ( see pkg/cheapaml )
236     C/\ | | |-CTRL_MAP_FORCING :: Control vector support package. (see pkg/ctrl)
237     C/\ | | |-DUMMY_IN_STEPPING :: Autodiff package ( pkg/autodiff ).
238 jmc 1.111 C/\ | | |
239     C/\ | | |-CPL_EXPORT_MY_DATA :: Send coupling fields to coupler
240     C/\ | | |-CPL_IMPORT_EXTERNAL_DATA :: Receive coupling fields from coupler
241     C/\ | | |
242 jmc 1.118 C/\ | | |-OASIS_PUT :: Oasis coupler interface
243     C/\ | | |-OASIS_GET :: Oasis coupler interface
244     C/\ | | |
245     C/\ | | |-EBM_DRIVER :: Calculate EBM type atmospheric forcing (see pkg/ebm)
246     C/\ | | |
247 jmc 1.111 C/\ | | |-DO_ATMOSPHERIC_PHYS :: Atmospheric physics computation
248 jmc 1.118 C/\ | | | |
249     C/\ | | | |-UPDATE_OCEAN_EXPORTS :: ( see pkg/fizhi )
250     C/\ | | | |-UPDATE_EARTH_EXPORTS :: ( see pkg/fizhi )
251     C/\ | | | |-UPDATE_CHEMISTRY_EXPORTS :: ( see pkg/fizhi )
252     C/\ | | | |-FIZHI_WRAPPER :: ( see pkg/fizhi )
253     C/\ | | | |-STEP_FIZHI_FG :: ( see pkg/fizhi )
254     C/\ | | | |-FIZHI_UPDATE_TIME :: ( see pkg/fizhi )
255     C/\ | | | |
256     C/\ | | | |-ATM_PHYS_DRIVER :: ( see pkg/atm_phys )
257     C/\ | | | |
258     C/\ | | | |-AIM_DO_PHYSICS :: ( see pkg/aim_v23 )
259 jmc 1.111 C/\ | | |
260     C/\ | | |-DO_OCEANIC_PHYS :: Oceanic (& seaice) physics computation
261 jmc 1.118 C/\ | | | |
262 jmc 1.111 C/\ | | | |-OBCS_CALC :: Open boundary. package (see pkg/obcs).
263 jmc 1.117 C/\ | | | |
264 jmc 1.118 C/\ | | | |-FRAZIL_CALC_RHS :: Compute FRAZIL tendencies ( see pkg/frazil )
265     C/\ | | | |-THSICE_MAIN :: Thermodynamic sea-ice driver (see pkg/thsice)
266     C/\ | | | |-SEAICE_MODEL :: Sea-ice model driver (see pkg/seaice )
267     C/\ | | | |-SEAICE_COST_SENSI :: Sea-ice cost-function (see pkg/seaice )
268     C/\ | | | |-SHELFICE_THERMODYNAMICS :: Compute ShelfIce thermo (pkg/shelfice)
269     C/\ | | | |-ICEFRONT_THERMODYNAMICS :: Compute IceFront thermo (pkg/icefront)
270     C/\ | | | |
271     C/\ | | | |-SALT_PLUME_DO_EXCH :: (see pkg/salt_plume )
272     C/\ | | | |-FREEZE_SURFACE :: Prevent SST to fall below TFreeze
273     C/\ | | | |-OCN_APPLY_IMPORT :: Apply imported fields from coupler
274     C/\ | | | |-EXTERNAL_FORCING_SURF:: Compute appropriately dimensioned
275     C/\ | | | | :: surface forcing terms.
276     C/\ | | | |-FIND_RHO_2D @ p(k) :: Calculate [rho(T,S,p)-Rho_0] of a slice
277     C/\ | | | |-FIND_RHO_2D @ p(k-1) :: Calculate [rho(T,S,p)-Rho_0] of a slice
278     C/\ | | | |-GRAD_SIGMA :: Calculate isoneutral gradients
279     C/\ | | | |-CALC_IVDC :: Set Implicit Vertical Diffusivity for Convection
280     C/\ | | | |-CALC_OCE_MXLAYER :: Diagnose Oceanic Mixed Layer depth
281     C/\ | | | |
282     C/\ | | | |-SALT_PLUME_CALC_DEPTH :: (see pkg/salt_plume )
283     C/\ | | | |-SALT_PLUME_VOLFRAC :: (see pkg/salt_plume )
284     C/\ | | | |-SALT_PLUME_APPLY (Temp) :: (see pkg/salt_plume )
285     C/\ | | | |-SALT_PLUME_APPLY (Salt) :: (see pkg/salt_plume )
286     C/\ | | | |-SALT_PLUME_FORCING_SURF :: (see pkg/salt_plume )
287     C/\ | | | |-KPP_CALC :: Compute KPP vertical mixing ( see pkg/kpp )
288     C/\ | | | |-PP81_CALC :: Compute PP81 vertical mixing ( see pkg/pp81 )
289     C/\ | | | |-KL10_CALC :: Compute KL10 vertical mixing ( see pkg/kl10 )
290     C/\ | | | |-MY82_CALC :: Compute MY82 vertical mixing ( see pkg/kl10 )
291     C/\ | | | |-GGL90_CALC :: Compute GGL90 vertical mixing (see pkg/ggl10)
292     C/\ | | | |-GMREDI_CALC_TENSOR :: Compute GM-Redi tensor ( see pkg/gmredi )
293     C/\ | | | |-DWNSLP_CALC_FLOW :: Compute Down-Slope flow (see pkg/down_slope)
294     C/\ | | | |-BBL_CALC_RHS :: Compute BBL tendencies ( see pkg/bbl )
295     C/\ | | | |-MYPACKAGE_CALC_RHS :: Compute mypackage tendencies (pkg/mypackage)
296     C/\ | | | |
297     C/\ | | | |-GMREDI_DO_EXCH :: ( see pkg/gmredi )
298     C/\ | | | |-KPP_DO_EXCH :: ( see pkg/kpp )
299     C/\ | | | |-DIAGS_RHO_G :: Compute some density related diagnostics
300     C/\ | | | |-DIAGS_OCEANIC_SURF_FLUX :: Diagnose oceanic surface fluxes
301     C/\ | | | |-SALT_PLUME_DIAGNOSTICS_FILL :: (see pkg/salt_plume )
302     C/\ | | | |-ECCO_PHYS :: ( see pkg/ecco )
303     C/\ | | |
304 jmc 1.119 C/\ | | |-STREAMICE_TIMESTEP :: ( see pkg/streamice )
305 jmc 1.118 C/\ | | |
306     C/\ | | |-GCHEM_CALC_TENDENCY :: geochemistry driver routine (see pkg/gchem)
307     C/\ | | |
308     C/\ | | |-LONGSTEP_AVERAGE :: Averaging state vars ( see pkg/longstep )
309     C/\ | | |-LONGSTEP_THERMODYNAMICS :: Step forward tracers ( see pkg/longstep )
310     C/\ | | |
311     C/\ | | |-THERMODYNAMICS :: theta, salt + tracer equations driver.
312     C/\ | | | | (synchronous time-stepping case)
313     C/\ | | | |-CALC_WSURF_TR :: Compute T & S Linear-Free-Surf correction
314     C/\ | | | |-PTRACERS_CALC_WSURF_TR :: Compute Tracers Linear-Free-Surf correct.
315     C/\ | | | |
316     C/\ | | | |-GMREDI_RESIDUAL_FLOW :: Get the flow field used to advect tracers
317     C/\ | | | |
318     C/\ | | | |-TEMP_INTEGRATE :: Step forward Prognostic Eq for Temperature.
319     C/\ | | | | |
320     C/\ | | | | |-ADAMS_BASHFORTH3 :: Extrapolate tracer forward in time (AB-3)
321     C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tracer forward in time (AB-2)
322     C/\ | | | | |-CALC_3D_DIFFUSIVITY :: set vertical diffusivity
323     C/\ | | | | |
324     C/\ | | | | |-GAD_SOM_ADVECT :: Second Order Moment (SOM) advection
325 jmc 1.117 C/\ | | | | |-GAD_ADVECTION :: Generalised advection driver (multi-dim
326     C/\ | | | | | advection case) (see pkg/gad).
327 jmc 1.118 C/\ | | | | |-CALC_ADV_FLOW :: set 3-D flow field to advect tracer
328     C/\ | | | | |-APPLY_FORCING_T :: Problem specific forcing for temperature.
329 jmc 1.117 C/\ | | | | |-GAD_CALC_RHS :: Calculate Advection-Diffusion tendency terms
330 jmc 1.118 C/\ | | | | |
331     C/\ | | | | |-ADAMS_BASHFORTH3 :: Extrapolate tendency forward in time (AB-3)
332     C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendency forward in time (AB-2)
333     C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gt for free-surface height.
334     C/\ | | | | |-DWNSLP_APPLY :: Add pkg/down_slope tendency
335     C/\ | | | | |
336 jmc 1.117 C/\ | | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
337 jmc 1.118 C/\ | | | | |
338     C/\ | | | | |-GAD_IMPLICIT_R :: Solve vertical implicit Advect-Diffus. eqn.
339 jmc 1.117 C/\ | | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation.
340     C/\ | | | | |-CYCLE_AB_TRACER :: Cycle time-stepping arrays for tracer field
341 jmc 1.118 C/\ | | | | |-CYCLE_TRACER :: Cycle time-stepping arrays for tracer field
342 jmc 1.117 C/\ | | | |
343 jmc 1.118 C/\ | | | |-SALT_INTEGRATE :: Step forward Prognostic Eq for Salinity.
344     C/\ | | | | | same sequence of calls as in TEMP_INTEGRATE
345 jmc 1.117 C/\ | | | |
346 edhill 1.93 C/\ | | | |-PTRACERS_INTEGRATE :: Integrate other tracer(s) (see pkg/ptracers).
347 jmc 1.118 C/\ | | | | | same sequence of calls as in TEMP_INTEGRATE
348     C/\ | | | | |-OBCS_APPLY_PTRACER :: Open boundary package for pTracers
349 jmc 1.117 C/\ | | | |
350 jmc 1.111 C/\ | | | |-OBCS_APPLY_TS :: Open boundary package (see pkg/obcs ).
351 cnh 1.42 C/\ | | |
352 jmc 1.118 C/\ | | |-LONGSTEP_AVERAGE :: Averaging state vars ( see pkg/longstep )
353     C/\ | | |-LONGSTEP_THERMODYNAMICS :: Step forward tracers ( see pkg/longstep )
354     C/\ | | |
355     C/\ | | |-DO_STAGGER_FIELDS_EXCHANGES :: Update overlap regions of arrays
356     C/\ | | | Theta & Salt (implicit IGW case)
357     C/\ | | |
358 edhill 1.63 C/\ | | |-DYNAMICS :: Momentum equations driver.
359 cnh 1.42 C/\ | | | |
360 jmc 1.110 C/\ | | | |-CALC_GRAD_PHI_SURF :: Calculate the gradient of the surface
361 cnh 1.42 C/\ | | | | Potential anomaly.
362 jmc 1.111 C/\ | | | |-CALC_VISCOSITY :: Calculate net vertical viscosity
363 jmc 1.118 C/\ | | | |-MOM_CALC_3D_STRAIN :: Calculates the strain tensor of 3D flow field
364     C/\ | | | |-OBCS_COPY_UV_N :: for Stevens bndary Conditions (see pkg/obcs)
365     C/\ | | | |
366 jmc 1.111 C/\ | | | |-CALC_PHI_HYD :: Integrate the hydrostatic relation.
367 jmc 1.118 C/\ | | | |-MOM_FLUXFORM :: Flux Form momentum eqn. (pkg/mom_fluxform)
368     C/\ | | | |-MOM_VECINV :: Vector Invariant momentum eqn (pkg/mom_vecinv)
369     C/\ | | | |-MOM_CALC_SMAG_3D :: Calculate Smagorinsky 3D (harmonic) viscosities
370     C/\ | | | |-MOM_UV_SMAG_3D :: Calculate U,V mom. tendency due to Smag 3D Visc
371     C/\ | | | |-TIMESTEP :: Step horizontal momentum fields forward in time
372     C/\ | | | |
373     C/\ | | | |-MOM_U_IMPLICIT_R :: Solve implicitly vertical Adv-Diffus equation.
374 jmc 1.111 C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation.
375 jmc 1.118 C/\ | | | |-OBCS_SAVE_UV_N :: for Stevens bndary Conditions (see pkg/obcs)
376     C/\ | | | |-OBCS_APPLY_UV :: Apply Open bndary Conditions to provisional U,V
377     C/\ | | | |-IMPLDIFF :: (CD-Scheme) Solve vertical impl. diffus. eqn
378     C/\ | | | |
379     C/\ | | | |-CALC_GW :: Vert. momentum tendency terms (Non-Hydrostatic)
380     C/\ | | | | |-MOM_W_SMAG_3D :: Calculate W mom. tendency due to Smag 3D Visc
381     C/\ | | | |-TIMESTEP_WVEL :: Step vert mom forward in time (Non-Hydrostatic)
382     C/\ | | |
383     C/\ | | |-MNC_UPDATE_TIME :: Update MNC time record (see pkg/mnc)
384 cnh 1.42 C/\ | | |
385 jmc 1.118 C/\ | | |-UPDATE_R_STAR :: Update the level thickness fraction (r* coord).
386     C/\ | | |-UPDATE_SIGMA :: Update the level thickness fraction (sigma-coord).
387     C/\ | | |-UPDATE_R_STAR :: Update the level thickness fraction.
388 cnh 1.42 C/\ | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
389 jmc 1.118 C/\ | | |-UPDATE_CG2D :: Update 2D conjugate grad. for Free-Surf.
390     C/\ | | |
391     C/\ | | |-SHAP_FILT_APPLY_UV :: Apply Shapiro Filter to provisional velocity
392     C/\ | | |-ZONAL_FILT_APPLY_UV :: Apply Zonal Filter to provisional velocity
393 cnh 1.42 C/\ | | |
394 jmc 1.111 C/\ | | |-SOLVE_FOR_PRESSURE :: Find surface pressure.
395 jmc 1.118 C/\ | | | |-CALC_DIV_GHAT :: Form the RHS of the surface pressure eqn.
396 cnh 1.42 C/\ | | | |-CG2D :: Two-dim pre-con. conjugate-gradient.
397 jmc 1.118 C/\ | | | |-PRE_CG3D :: Finish to set the RHS of the 3-D pressure eqn.
398 cnh 1.42 C/\ | | | |-CG3D :: Three-dim pre-con. conjugate-gradient solver.
399 jmc 1.118 C/\ | | | |-POST_CG3D :: finalise solution of NH and Free-Surf pressure
400 cnh 1.42 C/\ | | |
401 jmc 1.111 C/\ | | |-MOMENTUM_CORRECTION_STEP :: Finalise momentum stepping
402 jmc 1.118 C/\ | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure
403     C/\ | | | |-CORRECTION_STEP :: Pressure correction to momentum
404     C/\ | | | |-OBCS_APPLY_UV :: Open boundary package (see pkg/obcs).
405     C/\ | | | |-SHAP_FILT_APPLY_UV :: Apply Shapiro Filter to latest velocity
406     C/\ | | | |-ZONAL_FILT_APPLY_UV :: Apply Zonal Filter to latest velocity
407     C/\ | | |
408     C/\ | | |-INTEGR_CONTINUITY :: Integrate continuity equation (see above)
409     C/\ | | |
410     C/\ | | |-CALC_R_STAR :: Calculate the new level thickness factor (r* coord)
411     C/\ | | |-CALC_SURF_DR :: Calculate the new surface level thickness.
412     C/\ | | |
413     C/\ | | |-DO_STAGGER_FIELDS_EXCHANGES :: Update overlap regions of arrays
414     C/\ | | | uVel,vVel & wVel (stagger-time-step case)
415     C/\ | | |
416     C/\ | | |-DO_STATEVARS_DIAGS ( 1 ) :: fill-up state variable diagnostics
417     C/\ | | |
418     C/\ | | |-THERMODYNAMICS :: theta, salt + tracer Eq. driver (see above).
419     C/\ | | | (staggered time-stepping case)
420     C/\ | | |
421     C/\ | | |-TRACERS_CORRECTION_STEP :: Finalise tracer stepping:
422     C/\ | | | | :: apply filter, conv.adjustment
423     C/\ | | | |-TRACERS_IIGW_CORRECTION :: apply Implicit IGW adjustment to T & S
424     C/\ | | | |-SHAP_FILT_APPLY_TS :: Apply Shapiro Filter to latest T & S
425     C/\ | | | |-ZONAL_FILT_APPLY_TS :: Apply Zonal Filter to latest T & S
426     C/\ | | | |-PTRACERS_ZONAL_FILT_APPLY :: Apply Zonal Filter to pTracers
427     C/\ | | | |-SALT_FILL :: Fill up negative Salt
428     C/\ | | | |-OPPS_INTERFACE :: ( see pkg/opps )
429     C/\ | | | |-CONVECTIVE_ADJUSTMENT :: Apply convective adjustment
430     C/\ | | | |-MATRIX_STORE_TENDENCY_IMP :: ( see pkg/matrix )
431 jmc 1.111 C/\ | | |
432 jmc 1.118 C/\ | | |-LONGSTEP_AVERAGE :: Averaging state vars ( see pkg/longstep )
433     C/\ | | |-LONGSTEP_THERMODYNAMICS :: Step forward tracers ( see pkg/longstep )
434 cnh 1.42 C/\ | | |
435 jmc 1.118 C/\ | | |-GCHEM_FORCING_SEP :: Tracer forcing for gchem pkg (if tracer
436     C/\ | | | :: dependent tendencies calculated separately)
437     C/\ | | |
438     C/\ | | |-DO_FIELDS_BLOCKING_EXCHANGES :: Sync up overlap regions.
439 cnh 1.42 C/\ | | |
440 jmc 1.118 C/\ | | |-DO_STATEVARS_DIAGS ( 2 ) :: fill-up state variable diagnostics
441 stephd 1.59 C/\ | | |
442 jmc 1.118 C/\ | | |-GRIDALT_UPDATE :: ( see pkg/gridalt )
443     C/\ | | |-STEP_FIZHI_CORR :: ( see pkg/fizhi )
444 cnh 1.42 C/\ | | |
445 jmc 1.118 C/\ | | |-FLT_MAIN :: Step forward Floats (see pkg/flt)
446     C/\ | | |
447     C/\ | | |-DO_STATEVARS_TAVE :: Time averaging package (see above)
448     C/\ | | |
449     C/\ | | |-NEST_PARENT_IO_2 :: Nesting interface
450     C/\ | | |-NEST_CHILD_TRANSP :: Nesting interface
451 cnh 1.42 C/\ | | |
452 jmc 1.111 C/\ | | |-MONITOR :: Monitor package (pkg/monitor).
453     C/\ | | |
454 jmc 1.118 C/\ | | |-COST_TILE :: ( see pkg/cost )
455     C/\ | | |
456     C/\ | | |-DO_THE_MODEL_IO :: Controlling routine for IO (see above)
457     C/\ | | |
458     C/\ | | |-PTRACERS_RESET :: Re-initialize PTRACERS ( see pkg/ptracers )
459     C/\ | | |
460     C/\ | | |-DO_WRITE_PICKUP :: Controlling routine for writing files to restart
461     C/\ | | | |-PACKAGES_WRITE_PICKUP :: Write pickup files for each package
462     C/\ | | | | | :: which needs it to restart
463     C/\ | | | | |-GAD_WRITE_PICKUP :: Write Generic AdvDiff pickups for SOM
464     C/\ | | | | | :: advection scheme (pkg/generic_advdiff)
465     C/\ | | | | |-CD_CODE_WRITE_PICKUP :: Write CD-code pickups (see pkg/cd_code)
466     C/\ | | | | |-OBCS_WRITE_PICKUP :: Write OBCS pickups (see pkg/obcs)
467     C/\ | | | | |-GGL90_WRITE_PICKUP :: Write GGL90 pickups (see pkg/ggl90)
468     C/\ | | | | |-BBL_WRITE_PICKUP :: Write BBL pickups (see pkg/bbl)
469     C/\ | | | | |-CHEAPAML_WRITE_PICKUP :: Write CheapAML pickups (pkg/cheapaml)
470     C/\ | | | | |-FLT_WRITE_PICKUP :: Write Floats pickups (see pkg/flt)
471     C/\ | | | | |-PTRACERS_WRITE_PICKUP :: Write pTracers pickups (pkg/ptracers)
472     C/\ | | | | |-GCHEM_WRITE_PICKUP :: Write Geo-Chem pickups (see pkg/gchem)
473     C/\ | | | | |-SEAICE_WRITE_PICKUP :: Write SeaIce pickups (see pkg/seaice)
474     C/\ | | | | |-STREAMICE_WRITE_PICKUP :: Write StreamIce pickups (pkg/streamice)
475 dgoldberg 1.122 C/\ | | | | |-SHELFICE_WRITE_PICKUP :: Write ShelfIce pickups (pkg/shelfice)
476 jmc 1.118 C/\ | | | | |-THSICE_WRITE_PICKUP :: Write ThSIce pickups (see pkg/thsice)
477     C/\ | | | | |-LAND_WRITE_PICKUP :: Write Land pickups (see pkg/land)
478     C/\ | | | | |-ATM_PHYS_WRITE_PICKUP :: Write Atm-Phys pickups (pkg/atm_phys)
479     C/\ | | | | |-FIZHI_WRITE_PICKUP :: Write Fizhi pickups (see pkg/fizhi)
480     C/\ | | | | |-FIZHI_WRITE_VEGTILES :: Write Fizhi VegTiles (see pkg/fizhi)
481     C/\ | | | | |-FIZHI_WRITE_DATETIME :: Write Fizhi DateTime (see pkg/fizhi)
482     C/\ | | | | |-CPL_WRITE_PICKUP :: Write Coupling-Interface pickups
483     C/\ | | | | |-MYPACKAGE_WRITE_PICKUP :: Write pkg/mypackage pickups
484     C/\ | | | |
485     C/\ | | | |-WRITE_PICKUP :: Write main model pickup files.
486     C/\ | | |
487     C/\ | | |-AUTODIFF_INADMODE_SET :: Set/reset some adjoint flags
488 jmc 1.111 C | |
489 cnh 1.42 C<===|=| **************************
490     C<===|=| END MAIN TIMESTEPPING LOOP
491     C<===|=| **************************
492 jmc 1.111 C | |
493 jmc 1.118 C | |-COST_AVERAGESFIELDS :: Time-averaged Cost function terms (see pkg/cost)
494     C | |-PROFILES_INLOOP :: ( see pkg/profiles )
495     C | |-COST_FINAL :: Cost function package (see pkg/cost)
496 cnh 1.42 C |
497 jmc 1.118 C |-CTRL_PACK :: Control vector support package (see pkg/ctrl)
498 cnh 1.42 C |
499 jmc 1.118 C |-GRDCHK_MAIN :: Gradient check package (see pkg/grdchk)
500 cnh 1.42 C |
501 jmc 1.111 C |-TIMER_PRINTALL :: Computational timing summary
502     C |
503     C |-COMM_STATS :: Summarise inter-proc and inter-thread communication
504 jmc 1.118 C | :: events.
505 cnh 1.42 C \ev
506     C
507 cnh 1.41 CEOI
508    
509 edhill 1.60 #include "PACKAGES_CONFIG.h"
510 adcroft 1.18 #include "CPP_OPTIONS.h"
511 jmc 1.112 #include "AD_CONFIG.h"
512 jmc 1.116 #ifdef ALLOW_AUTODIFF
513     # include "AUTODIFF_OPTIONS.h"
514     #endif
515     #ifdef ALLOW_CTRL
516     # include "CTRL_OPTIONS.h"
517     #endif
518 dgoldberg 1.114
519 cnh 1.41 CBOP
520     C !ROUTINE: THE_MODEL_MAIN
521    
522     C !INTERFACE:
523 cnh 1.1 SUBROUTINE THE_MODEL_MAIN(myThid)
524 cnh 1.41
525     C !DESCRIPTION: \bv
526     C *==========================================================*
527 jmc 1.103 C | SUBROUTINE THE_MODEL_MAIN
528     C | o Master controlling routine for model using the MITgcm
529     C | UV parallel wrapper.
530 cnh 1.41 C *==========================================================*
531 jmc 1.103 C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel
532     C | wrapper with a single integer argument "myThid". This
533     C | variable identifies the thread number of an instance of
534     C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works
535     C | on a particular region of the models domain and
536     C | synchronises with other instances as necessary. The
537     C | routine has to "understand" the MITgcm parallel
538     C | environment and the numerical algorithm. Editing this
539     C | routine is best done with some knowledge of both aspects.
540     C | Notes
541     C | =====
542     C | C*P* comments indicating place holders for which code is
543     C | presently being developed.
544 cnh 1.41 C *==========================================================*
545     C \ev
546    
547     C !CALLING SEQUENCE:
548     C THE_MODEL_MAIN()
549     C |
550     C |
551 jmc 1.110 C |--INITIALISE_FIXED
552 cnh 1.41 C | o Set model configuration (fixed arrays)
553     C | Topography, hydrography, timestep, grid, etc..
554     C |
555     C |--CTRL_UNPACK o Derivative mode. Unpack control vector.
556     C |
557     C |--ADTHE_MAIN_LOOP o Main timestepping loop for combined
558     C | prognostic and reverse mode integration.
559     C |
560 jmc 1.111 C |--THE_MAIN_LOOP o Main timestepping loop for pure prognostic
561     C | integration.
562     C |
563 cnh 1.41 C |--CTRL_PACK o Derivative mode. Unpack control vector.
564     C |
565     C |--GRDCHK_MAIN o Gradient check control routine.
566     C |
567     C |--TIMER_PRINTALL o Print out timing statistics.
568     C |
569     C |--COMM_STATS o Print out communication statistics.
570    
571     C !USES:
572 jmc 1.111 IMPLICIT NONE
573    
574 cnh 1.1 C == Global variables ===
575     #include "SIZE.h"
576     #include "EEPARAMS.h"
577     #include "PARAMS.h"
578 adcroft 1.26 #include "DYNVARS.h"
579 cnh 1.1
580 jmc 1.116 #ifdef ALLOW_AUTODIFF
581 heimbach 1.65 # include "tamc.h"
582 heimbach 1.84 #endif
583     #ifdef ALLOW_CTRL
584 heimbach 1.92 # include "ctrl.h"
585 heimbach 1.83 # include "optim.h"
586 heimbach 1.37 #endif
587    
588 cnh 1.41 C !INPUT/OUTPUT PARAMETERS:
589 cnh 1.1 C == Routine arguments ==
590 jmc 1.111 C myThid :: Thread number for this instance of the routine.
591 jmc 1.103 INTEGER myThid
592 cnh 1.1
593 cnh 1.41 C !LOCAL VARIABLES:
594 cnh 1.1 C == Local variables ==
595 jmc 1.111 C Note: Under the multi-threaded model myIter and myTime are local
596     C variables passed around as routine arguments.
597     C Although this is fiddly it saves the need to impose
598     C additional synchronisation points when they are updated.
599     C myTime :: Time counter for this thread
600     C myIter :: Iteration counter for this thread
601     INTEGER myIter
602     _RL myTime
603 jmc 1.115 LOGICAL exst
604     LOGICAL lastdiva
605     CEOP
606 dgoldberg 1.114
607 jmc 1.115 C-- set default:
608 jmc 1.111 exst = .TRUE.
609 heimbach 1.53 lastdiva = .TRUE.
610 cnh 1.1
611 edhill 1.66 #ifdef ALLOW_DEBUG
612 jmc 1.110 IF (debugMode) CALL DEBUG_ENTER('THE_MODEL_MAIN',myThid)
613 adcroft 1.54 #endif
614    
615 ce107 1.94 #if defined(USE_PAPI) || defined(USE_PCL_FLOPS_SFP) || defined(USE_PCL_FLOPS) || defined(USE_PCL)
616 ce107 1.91 CALL TIMER_CONTROL('','INIT','THE_MODEL_MAIN',myThid)
617     #endif
618 adcroft 1.19 C-- This timer encompasses the whole code
619 heimbach 1.45 CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid)
620 adcroft 1.19
621 edhill 1.66 #ifdef ALLOW_DEBUG
622 jmc 1.110 IF (debugMode) CALL DEBUG_CALL('INITIALISE_FIXED',myThid)
623 adcroft 1.54 #endif
624 adcroft 1.32 C-- Set model configuration (fixed arrays)
625 heimbach 1.45 CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
626 adcroft 1.32 CALL INITIALISE_FIXED( myThid )
627 heimbach 1.45 CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
628 adcroft 1.26
629 jmc 1.111 myTime = startTime
630     myIter = nIter0
631 jmc 1.34
632 heimbach 1.64 #if ( defined (ALLOW_ADMTLM) )
633 jmc 1.115
634 heimbach 1.82 STOP 'should never get here; ADMTLM_DSVD calls ADMTLM_DRIVER'
635 jmc 1.115
636 heimbach 1.64 #elif ( defined (ALLOW_AUTODIFF))
637 heimbach 1.37
638 gforget 1.123 # ifdef ALLOW_CTRL
639 heimbach 1.65 # ifndef EXCLUDE_CTRL_PACK
640 gforget 1.121 IF ( useCTRL ) THEN
641 heimbach 1.52 inquire( file='costfinal', exist=exst )
642 heimbach 1.88 IF ( .NOT. exst ) THEN
643 gforget 1.109 IF ( (optimcycle.NE.0 .OR. .NOT.doinitxx)
644     & .AND. doMainUnpack ) THEN
645 jmc 1.111 CALL TIMER_START('CTRL_UNPACK [THE_MODEL_MAIN]',myThid)
646     CALL CTRL_UNPACK( .TRUE. , myThid )
647     CALL TIMER_STOP ('CTRL_UNPACK [THE_MODEL_MAIN]',myThid)
648 heimbach 1.77 ENDIF
649 heimbach 1.51 ENDIF
650 gforget 1.121 ENDIF
651 heimbach 1.65 # endif /* EXCLUDE_CTRL_PACK */
652 gforget 1.123 # endif
653 heimbach 1.37
654 heimbach 1.85 # ifdef ALLOW_COST
655 jmc 1.111 CALL COST_DEPENDENT_INIT ( myThid )
656 heimbach 1.85 # endif
657 heimbach 1.44
658 heimbach 1.58 # if ( defined (ALLOW_TANGENTLINEAR_RUN) )
659 jmc 1.115
660 jmc 1.111 # ifdef ALLOW_DEBUG
661 heimbach 1.104 IF (debugMode) CALL DEBUG_CALL('G_THE_MAIN_LOOP',myThid)
662 jmc 1.111 # endif
663     CALL TIMER_START('G_THE_MAIN_LOOP [TANGENT RUN]',myThid)
664     CALL G_THE_MAIN_LOOP ( myTime, myIter, myThid )
665     CALL TIMER_STOP ('G_THE_MAIN_LOOP [TANGENT RUN]',myThid)
666 jmc 1.115
667 heimbach 1.58 # elif ( defined (ALLOW_ADJOINT_RUN) || \
668     defined (ALLOW_ECCO_OPTIMIZATION) )
669 jmc 1.115
670 heimbach 1.55 # ifdef ALLOW_DIVIDED_ADJOINT
671 jmc 1.115 C-- The following assumes the TAF option '-pure'
672 heimbach 1.52 inquire( file='costfinal', exist=exst )
673     IF ( .NOT. exst) THEN
674 jmc 1.111 # ifdef ALLOW_DEBUG
675 heimbach 1.104 IF (debugMode) CALL DEBUG_CALL('MDTHE_MAIN_LOOP',myThid)
676 jmc 1.111 # endif
677     CALL TIMER_START('MDTHE_MAIN_LOOP [MD RUN]', myThid)
678     CALL MDTHE_MAIN_LOOP ( myTime, myIter, myThid )
679     CALL TIMER_STOP ('MDTHE_MAIN_LOOP [MD RUN]', myThid)
680     CALL COST_FINAL_STORE ( myThid, lastdiva )
681 heimbach 1.52 ELSE
682 jmc 1.111 # ifdef ALLOW_DEBUG
683 heimbach 1.104 IF (debugMode) CALL DEBUG_CALL('ADTHE_MAIN_LOOP',myThid)
684 jmc 1.111 # endif
685     CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', myThid)
686     CALL ADTHE_MAIN_LOOP ( myThid )
687     CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', myThid)
688     CALL COST_FINAL_RESTORE ( myThid, lastdiva )
689 heimbach 1.52 ENDIF
690 jmc 1.115
691 heimbach 1.55 # else /* ALLOW_DIVIDED_ADJOINT undef */
692 jmc 1.111 # ifdef ALLOW_DEBUG
693 heimbach 1.104 IF (debugMode) CALL DEBUG_CALL('ADTHE_MAIN_LOOP',myThid)
694 jmc 1.111 # endif
695     CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', myThid)
696     CALL ADTHE_MAIN_LOOP ( myThid )
697     CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', myThid)
698 heimbach 1.55 # endif /* ALLOW_DIVIDED_ADJOINT */
699 jmc 1.115
700 heimbach 1.84 # else /* forward run only within AD setting */
701    
702 jmc 1.111 # ifdef ALLOW_DEBUG
703 heimbach 1.84 IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid)
704 jmc 1.111 # endif
705 heimbach 1.84 C-- Call time stepping loop of full model
706     CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
707 jmc 1.111 CALL THE_MAIN_LOOP( myTime, myIter, myThid )
708 heimbach 1.84 CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
709    
710 jmc 1.111 # endif /* forward run only within AD setting */
711 heimbach 1.44
712 gforget 1.123 # ifdef ALLOW_CTRL
713 heimbach 1.65 # ifndef EXCLUDE_CTRL_PACK
714 gforget 1.121 IF ( useCTRL ) THEN
715 gforget 1.108 IF ( lastdiva .AND. doMainPack ) THEN
716 jmc 1.111 CALL TIMER_START('CTRL_PACK [THE_MODEL_MAIN]',myThid)
717     CALL CTRL_PACK( .FALSE. , myThid )
718     CALL TIMER_STOP ('CTRL_PACK [THE_MODEL_MAIN]',myThid)
719 heimbach 1.92 IF ( ( optimcycle.EQ.0 .OR. (.NOT. doMainUnpack) )
720 jmc 1.111 & .AND. myIter.EQ.nIter0 ) THEN
721     CALL TIMER_START('CTRL_PACK [THE_MODEL_MAIN]',myThid)
722     CALL CTRL_PACK( .TRUE. , myThid )
723     CALL TIMER_STOP ('CTRL_PACK [THE_MODEL_MAIN]',myThid)
724 heimbach 1.86 ENDIF
725 heimbach 1.44 ENDIF
726 gforget 1.121 ENDIF
727 heimbach 1.65 # endif /* EXCLUDE_CTRL_PACK */
728 gforget 1.123 # endif
729 heimbach 1.65
730 heimbach 1.64 # ifdef ALLOW_GRDCHK
731 heimbach 1.52 IF ( useGrdchk .AND. lastdiva ) THEN
732 jmc 1.111 CALL TIMER_START('GRDCHK_MAIN [THE_MODEL_MAIN]',myThid)
733     CALL GRDCHK_MAIN( myThid )
734     CALL TIMER_STOP ('GRDCHK_MAIN [THE_MODEL_MAIN]',myThid)
735 heimbach 1.52 ENDIF
736 heimbach 1.58 # endif
737 heimbach 1.52
738 heimbach 1.58 #else /* ALL AD-related undef */
739 heimbach 1.37
740 jmc 1.111 # ifdef ALLOW_DEBUG
741 adcroft 1.54 IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid)
742 jmc 1.111 # endif
743 adcroft 1.32 C-- Call time stepping loop of full model
744 heimbach 1.45 CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
745 jmc 1.111 CALL THE_MAIN_LOOP( myTime, myIter, myThid )
746 heimbach 1.45 CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
747 adcroft 1.12
748 heimbach 1.87 #endif /* ALLOW_TANGENTLINEAR_RUN ALLOW_ADJOINT_RUN ALLOW_ADMTLM */
749 dimitri 1.50
750 jmc 1.120 #ifdef ALLOW_STREAMICE
751     IF (useStreamIce) THEN
752     CALL STREAMICE_FINALIZE_PETSC
753     ENDIF
754 dgoldberg 1.114 #endif
755    
756 edhill 1.71 #ifdef ALLOW_MNC
757 edhill 1.76 IF (useMNC) THEN
758     C Close all open NetCDF files
759 jmc 1.111 _BEGIN_MASTER( myThid )
760 edhill 1.76 CALL MNC_FILE_CLOSE_ALL( myThid )
761 jmc 1.111 _END_MASTER( myThid )
762 edhill 1.76 ENDIF
763 edhill 1.71 #endif
764 cnh 1.7
765 jmc 1.103 C-- This timer encompasses the whole code
766     CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid)
767    
768 adcroft 1.19 C-- Write timer statistics
769 cnh 1.20 IF ( myThid .EQ. 1 ) THEN
770     CALL TIMER_PRINTALL( myThid )
771     CALL COMM_STATS
772     ENDIF
773 adcroft 1.54
774 jmc 1.96 C-- Check threads synchronization :
775     CALL BAR_CHECK( 9, myThid )
776    
777 edhill 1.66 #ifdef ALLOW_DEBUG
778 adcroft 1.54 IF (debugMode) CALL DEBUG_LEAVE('THE_MODEL_MAIN',myThid)
779     #endif
780 cnh 1.1
781     RETURN
782     END

  ViewVC Help
Powered by ViewVC 1.1.22