1 |
C $Header: /u/gcmpack/MITgcm/model/src/the_model_main.F,v 1.122 2015/01/20 15:00:55 dgoldberg Exp $ |
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 auxiliary equations and alternate discretizations 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 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 |
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 |-THE_MODEL_MAIN :: Primary driver for the MITgcm algorithm |
35 |
C | :: Called from WRAPPER level numerical |
36 |
C | :: code invocation routine. On entry |
37 |
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 |
C |-INITIALISE_FIXED :: Set fixed model arrays such as topography, |
44 |
C | | :: grid, solver matrices etc.. |
45 |
C | | |
46 |
C | |-INI_PARMS :: Routine to set kernel model parameters. |
47 |
C | | :: Kernel parameters are read from file "data" |
48 |
C | | :: in directory in which code executes. |
49 |
C | | |
50 |
C | |-PACKAGES_BOOT :: Start up the optional package environment. |
51 |
C | | :: Runtime selection of active packages. |
52 |
C | |-PACKAGES_READPARMS :: read each package input parameter file |
53 |
C | | |- ${PKG}_READPARMS |
54 |
C | | |
55 |
C | |-SET_PARMS :: Finalise model parameter setting (if fct of pkg usage) |
56 |
C | | |
57 |
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 |
C | | |
83 |
C | |-INI_DEPTHS :: Read (from "bathyFile") or set bathymetry/orography. |
84 |
C | |-INI_MASKS_ETC :: Derive horizontal and vertical cell fractions and |
85 |
C | | :: land masking for solid-fluid boundaries. |
86 |
C | | |
87 |
C | |-PACKAGES_INIT_FIXED :: do all packages fixed-initialisation setting |
88 |
C | | |- ${PKG}_INIT_FIXED |
89 |
C | | |
90 |
C | |-INI_GLOBAL_DOMAIN :: Initialise domain related (global) quantities. |
91 |
C | |-INI_LINEAR_PHISURF :: Set ref. surface Bo_surf |
92 |
C | | |
93 |
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 |
C | | |- ${PKG}_CHECK |
103 |
C | | |
104 |
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 |
C | |
109 |
C |-CTRL_UNPACK :: Control vector support package. see pkg/ctrl |
110 |
C |-COST_DEPENDENT_INIT :: ( see pkg/cost ) |
111 |
C | |
112 |
C |-ADTHE_MAIN_LOOP :: Derivative evaluating form of main time stepping loop |
113 |
C ! :: Automatically generated by TAMC/TAF. |
114 |
C | |
115 |
C |-THE_MAIN_LOOP :: Main timestepping loop routine. |
116 |
C | | |
117 |
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 |
C | | | |
148 |
C | | |-AUTODIFF_INIT_VARIA :: (see pkg/autodiff ) |
149 |
C | | | |
150 |
C | | |-PACKAGES_INIT_VARIABLES :: Does initialisation of time evolving |
151 |
C | | | | ${PKG}_INIT_VARIA :: package data. |
152 |
C | | | |
153 |
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 |
C | | |-MONITOR :: Monitor state (see pkg/monitor) |
175 |
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 |
C====|>| **************************** |
210 |
C====|>| BEGIN MAIN TIMESTEPPING LOOP |
211 |
C====|>| **************************** |
212 |
C | |-COST_AVERAGESFIELDS :: time-averaged Cost function terms (see pkg/cost) |
213 |
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 |
C | | |
218 |
C/\ | |-FORWARD_STEP :: Step forward a time-step ( AT LAST !!! ) |
219 |
C/\ | | | |
220 |
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 |
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 |
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 |
C/\ | | |-DO_ATMOSPHERIC_PHYS :: Atmospheric physics computation |
248 |
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 |
C/\ | | | |
260 |
C/\ | | |-DO_OCEANIC_PHYS :: Oceanic (& seaice) physics computation |
261 |
C/\ | | | | |
262 |
C/\ | | | |-OBCS_CALC :: Open boundary. package (see pkg/obcs). |
263 |
C/\ | | | | |
264 |
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 |
C/\ | | |-STREAMICE_TIMESTEP :: ( see pkg/streamice ) |
305 |
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 |
C/\ | | | | |-GAD_ADVECTION :: Generalised advection driver (multi-dim |
326 |
C/\ | | | | | advection case) (see pkg/gad). |
327 |
C/\ | | | | |-CALC_ADV_FLOW :: set 3-D flow field to advect tracer |
328 |
C/\ | | | | |-APPLY_FORCING_T :: Problem specific forcing for temperature. |
329 |
C/\ | | | | |-GAD_CALC_RHS :: Calculate Advection-Diffusion tendency terms |
330 |
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 |
C/\ | | | | |-TIMESTEP_TRACER :: Step tracer field forward in time |
337 |
C/\ | | | | | |
338 |
C/\ | | | | |-GAD_IMPLICIT_R :: Solve vertical implicit Advect-Diffus. eqn. |
339 |
C/\ | | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation. |
340 |
C/\ | | | | |-CYCLE_AB_TRACER :: Cycle time-stepping arrays for tracer field |
341 |
C/\ | | | | |-CYCLE_TRACER :: Cycle time-stepping arrays for tracer field |
342 |
C/\ | | | | |
343 |
C/\ | | | |-SALT_INTEGRATE :: Step forward Prognostic Eq for Salinity. |
344 |
C/\ | | | | | same sequence of calls as in TEMP_INTEGRATE |
345 |
C/\ | | | | |
346 |
C/\ | | | |-PTRACERS_INTEGRATE :: Integrate other tracer(s) (see pkg/ptracers). |
347 |
C/\ | | | | | same sequence of calls as in TEMP_INTEGRATE |
348 |
C/\ | | | | |-OBCS_APPLY_PTRACER :: Open boundary package for pTracers |
349 |
C/\ | | | | |
350 |
C/\ | | | |-OBCS_APPLY_TS :: Open boundary package (see pkg/obcs ). |
351 |
C/\ | | | |
352 |
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 |
C/\ | | |-DYNAMICS :: Momentum equations driver. |
359 |
C/\ | | | | |
360 |
C/\ | | | |-CALC_GRAD_PHI_SURF :: Calculate the gradient of the surface |
361 |
C/\ | | | | Potential anomaly. |
362 |
C/\ | | | |-CALC_VISCOSITY :: Calculate net vertical viscosity |
363 |
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 |
C/\ | | | |-CALC_PHI_HYD :: Integrate the hydrostatic relation. |
367 |
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 |
C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation. |
375 |
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 |
C/\ | | | |
385 |
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 |
C/\ | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction. |
389 |
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 |
C/\ | | | |
394 |
C/\ | | |-SOLVE_FOR_PRESSURE :: Find surface pressure. |
395 |
C/\ | | | |-CALC_DIV_GHAT :: Form the RHS of the surface pressure eqn. |
396 |
C/\ | | | |-CG2D :: Two-dim pre-con. conjugate-gradient. |
397 |
C/\ | | | |-PRE_CG3D :: Finish to set the RHS of the 3-D pressure eqn. |
398 |
C/\ | | | |-CG3D :: Three-dim pre-con. conjugate-gradient solver. |
399 |
C/\ | | | |-POST_CG3D :: finalise solution of NH and Free-Surf pressure |
400 |
C/\ | | | |
401 |
C/\ | | |-MOMENTUM_CORRECTION_STEP :: Finalise momentum stepping |
402 |
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 |
C/\ | | | |
432 |
C/\ | | |-LONGSTEP_AVERAGE :: Averaging state vars ( see pkg/longstep ) |
433 |
C/\ | | |-LONGSTEP_THERMODYNAMICS :: Step forward tracers ( see pkg/longstep ) |
434 |
C/\ | | | |
435 |
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 |
C/\ | | | |
440 |
C/\ | | |-DO_STATEVARS_DIAGS ( 2 ) :: fill-up state variable diagnostics |
441 |
C/\ | | | |
442 |
C/\ | | |-GRIDALT_UPDATE :: ( see pkg/gridalt ) |
443 |
C/\ | | |-STEP_FIZHI_CORR :: ( see pkg/fizhi ) |
444 |
C/\ | | | |
445 |
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 |
C/\ | | | |
452 |
C/\ | | |-MONITOR :: Monitor package (pkg/monitor). |
453 |
C/\ | | | |
454 |
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 |
C/\ | | | | |-SHELFICE_WRITE_PICKUP :: Write ShelfIce pickups (pkg/shelfice) |
476 |
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 |
C | | |
489 |
C<===|=| ************************** |
490 |
C<===|=| END MAIN TIMESTEPPING LOOP |
491 |
C<===|=| ************************** |
492 |
C | | |
493 |
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 |
C | |
497 |
C |-CTRL_PACK :: Control vector support package (see pkg/ctrl) |
498 |
C | |
499 |
C |-GRDCHK_MAIN :: Gradient check package (see pkg/grdchk) |
500 |
C | |
501 |
C |-TIMER_PRINTALL :: Computational timing summary |
502 |
C | |
503 |
C |-COMM_STATS :: Summarise inter-proc and inter-thread communication |
504 |
C | :: events. |
505 |
C \ev |
506 |
C |
507 |
CEOI |
508 |
|
509 |
#include "PACKAGES_CONFIG.h" |
510 |
#include "CPP_OPTIONS.h" |
511 |
#include "AD_CONFIG.h" |
512 |
#ifdef ALLOW_AUTODIFF |
513 |
# include "AUTODIFF_OPTIONS.h" |
514 |
#endif |
515 |
#ifdef ALLOW_CTRL |
516 |
# include "CTRL_OPTIONS.h" |
517 |
#endif |
518 |
|
519 |
CBOP |
520 |
C !ROUTINE: THE_MODEL_MAIN |
521 |
|
522 |
C !INTERFACE: |
523 |
SUBROUTINE THE_MODEL_MAIN(myThid) |
524 |
|
525 |
C !DESCRIPTION: \bv |
526 |
C *==========================================================* |
527 |
C | SUBROUTINE THE_MODEL_MAIN |
528 |
C | o Master controlling routine for model using the MITgcm |
529 |
C | UV parallel wrapper. |
530 |
C *==========================================================* |
531 |
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 |
C *==========================================================* |
545 |
C \ev |
546 |
|
547 |
C !CALLING SEQUENCE: |
548 |
C THE_MODEL_MAIN() |
549 |
C | |
550 |
C | |
551 |
C |--INITIALISE_FIXED |
552 |
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 |
C |--THE_MAIN_LOOP o Main timestepping loop for pure prognostic |
561 |
C | integration. |
562 |
C | |
563 |
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 |
IMPLICIT NONE |
573 |
|
574 |
C == Global variables === |
575 |
#include "SIZE.h" |
576 |
#include "EEPARAMS.h" |
577 |
#include "PARAMS.h" |
578 |
#include "DYNVARS.h" |
579 |
|
580 |
#ifdef ALLOW_AUTODIFF |
581 |
# include "tamc.h" |
582 |
#endif |
583 |
#ifdef ALLOW_CTRL |
584 |
# include "ctrl.h" |
585 |
# include "optim.h" |
586 |
#endif |
587 |
|
588 |
C !INPUT/OUTPUT PARAMETERS: |
589 |
C == Routine arguments == |
590 |
C myThid :: Thread number for this instance of the routine. |
591 |
INTEGER myThid |
592 |
|
593 |
C !LOCAL VARIABLES: |
594 |
C == Local variables == |
595 |
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 |
LOGICAL exst |
604 |
LOGICAL lastdiva |
605 |
CEOP |
606 |
|
607 |
C-- set default: |
608 |
exst = .TRUE. |
609 |
lastdiva = .TRUE. |
610 |
|
611 |
#ifdef ALLOW_DEBUG |
612 |
IF (debugMode) CALL DEBUG_ENTER('THE_MODEL_MAIN',myThid) |
613 |
#endif |
614 |
|
615 |
#if defined(USE_PAPI) || defined(USE_PCL_FLOPS_SFP) || defined(USE_PCL_FLOPS) || defined(USE_PCL) |
616 |
CALL TIMER_CONTROL('','INIT','THE_MODEL_MAIN',myThid) |
617 |
#endif |
618 |
C-- This timer encompasses the whole code |
619 |
CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid) |
620 |
|
621 |
#ifdef ALLOW_DEBUG |
622 |
IF (debugMode) CALL DEBUG_CALL('INITIALISE_FIXED',myThid) |
623 |
#endif |
624 |
C-- Set model configuration (fixed arrays) |
625 |
CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
626 |
CALL INITIALISE_FIXED( myThid ) |
627 |
CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
628 |
|
629 |
myTime = startTime |
630 |
myIter = nIter0 |
631 |
|
632 |
#if ( defined (ALLOW_ADMTLM) ) |
633 |
|
634 |
STOP 'should never get here; ADMTLM_DSVD calls ADMTLM_DRIVER' |
635 |
|
636 |
#elif ( defined (ALLOW_AUTODIFF)) |
637 |
|
638 |
# ifdef ALLOW_CTRL |
639 |
# ifndef EXCLUDE_CTRL_PACK |
640 |
IF ( useCTRL ) THEN |
641 |
inquire( file='costfinal', exist=exst ) |
642 |
IF ( .NOT. exst ) THEN |
643 |
IF ( (optimcycle.NE.0 .OR. .NOT.doinitxx) |
644 |
& .AND. doMainUnpack ) THEN |
645 |
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 |
ENDIF |
649 |
ENDIF |
650 |
ENDIF |
651 |
# endif /* EXCLUDE_CTRL_PACK */ |
652 |
# endif |
653 |
|
654 |
# ifdef ALLOW_COST |
655 |
CALL COST_DEPENDENT_INIT ( myThid ) |
656 |
# endif |
657 |
|
658 |
# if ( defined (ALLOW_TANGENTLINEAR_RUN) ) |
659 |
|
660 |
# ifdef ALLOW_DEBUG |
661 |
IF (debugMode) CALL DEBUG_CALL('G_THE_MAIN_LOOP',myThid) |
662 |
# 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 |
|
667 |
# elif ( defined (ALLOW_ADJOINT_RUN) || \ |
668 |
defined (ALLOW_ECCO_OPTIMIZATION) ) |
669 |
|
670 |
# ifdef ALLOW_DIVIDED_ADJOINT |
671 |
C-- The following assumes the TAF option '-pure' |
672 |
inquire( file='costfinal', exist=exst ) |
673 |
IF ( .NOT. exst) THEN |
674 |
# ifdef ALLOW_DEBUG |
675 |
IF (debugMode) CALL DEBUG_CALL('MDTHE_MAIN_LOOP',myThid) |
676 |
# 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 |
ELSE |
682 |
# ifdef ALLOW_DEBUG |
683 |
IF (debugMode) CALL DEBUG_CALL('ADTHE_MAIN_LOOP',myThid) |
684 |
# 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 |
ENDIF |
690 |
|
691 |
# else /* ALLOW_DIVIDED_ADJOINT undef */ |
692 |
# ifdef ALLOW_DEBUG |
693 |
IF (debugMode) CALL DEBUG_CALL('ADTHE_MAIN_LOOP',myThid) |
694 |
# 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 |
# endif /* ALLOW_DIVIDED_ADJOINT */ |
699 |
|
700 |
# else /* forward run only within AD setting */ |
701 |
|
702 |
# ifdef ALLOW_DEBUG |
703 |
IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid) |
704 |
# endif |
705 |
C-- Call time stepping loop of full model |
706 |
CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
707 |
CALL THE_MAIN_LOOP( myTime, myIter, myThid ) |
708 |
CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
709 |
|
710 |
# endif /* forward run only within AD setting */ |
711 |
|
712 |
# ifdef ALLOW_CTRL |
713 |
# ifndef EXCLUDE_CTRL_PACK |
714 |
IF ( useCTRL ) THEN |
715 |
IF ( lastdiva .AND. doMainPack ) THEN |
716 |
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 |
IF ( ( optimcycle.EQ.0 .OR. (.NOT. doMainUnpack) ) |
720 |
& .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 |
ENDIF |
725 |
ENDIF |
726 |
ENDIF |
727 |
# endif /* EXCLUDE_CTRL_PACK */ |
728 |
# endif |
729 |
|
730 |
# ifdef ALLOW_GRDCHK |
731 |
IF ( useGrdchk .AND. lastdiva ) THEN |
732 |
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 |
ENDIF |
736 |
# endif |
737 |
|
738 |
#else /* ALL AD-related undef */ |
739 |
|
740 |
# ifdef ALLOW_DEBUG |
741 |
IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid) |
742 |
# endif |
743 |
C-- Call time stepping loop of full model |
744 |
CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
745 |
CALL THE_MAIN_LOOP( myTime, myIter, myThid ) |
746 |
CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
747 |
|
748 |
#endif /* ALLOW_TANGENTLINEAR_RUN ALLOW_ADJOINT_RUN ALLOW_ADMTLM */ |
749 |
|
750 |
#ifdef ALLOW_STREAMICE |
751 |
IF (useStreamIce) THEN |
752 |
CALL STREAMICE_FINALIZE_PETSC |
753 |
ENDIF |
754 |
#endif |
755 |
|
756 |
#ifdef ALLOW_MNC |
757 |
IF (useMNC) THEN |
758 |
C Close all open NetCDF files |
759 |
_BEGIN_MASTER( myThid ) |
760 |
CALL MNC_FILE_CLOSE_ALL( myThid ) |
761 |
_END_MASTER( myThid ) |
762 |
ENDIF |
763 |
#endif |
764 |
|
765 |
C-- This timer encompasses the whole code |
766 |
CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid) |
767 |
|
768 |
C-- Write timer statistics |
769 |
IF ( myThid .EQ. 1 ) THEN |
770 |
CALL TIMER_PRINTALL( myThid ) |
771 |
CALL COMM_STATS |
772 |
ENDIF |
773 |
|
774 |
C-- Check threads synchronization : |
775 |
CALL BAR_CHECK( 9, myThid ) |
776 |
|
777 |
#ifdef ALLOW_DEBUG |
778 |
IF (debugMode) CALL DEBUG_LEAVE('THE_MODEL_MAIN',myThid) |
779 |
#endif |
780 |
|
781 |
RETURN |
782 |
END |