1 |
C $Header$ |
C $Header$ |
2 |
C $Name$ |
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 innvocation routine. On entry |
38 |
|
C | :: to THE_MODEL_MAIN separate thread and |
39 |
|
C | :: separate processes will have been established. |
40 |
|
C | :: Each thread and process will have a unique ID |
41 |
|
C | :: but as yet it will not be associated with a |
42 |
|
C | :: specific region in decomposed discrete space. |
43 |
|
C | |
44 |
|
C |-INITIALISE_FIXED :: Set fixed model arrays such as topography, |
45 |
|
C | | :: grid, solver matrices etc.. |
46 |
|
C | | |
47 |
|
C | |-INI_PARMS :: Routine to set kernel model parameters. |
48 |
|
C | | :: By default kernel parameters are read from file |
49 |
|
C | | :: "data" in directory in which code executes. |
50 |
|
C | | |
51 |
|
C | |-MON_INIT :: Initialises monitor pacakge ( see pkg/monitor ) |
52 |
|
C | | |
53 |
|
C | |-INI_GRID :: Control grid array (vert. and hori.) initialisation. |
54 |
|
C | | | :: Grid arrays are held and described in GRID.h. |
55 |
|
C | | | |
56 |
|
C | | |-INI_VERTICAL_GRID :: Initialise vertical grid arrays. |
57 |
|
C | | | |
58 |
|
C | | |-INI_CARTESIAN_GRID :: Cartesian horiz. grid initialisation |
59 |
|
C | | | :: (calculate grid from kernel parameters). |
60 |
|
C | | | |
61 |
|
C | | |-INI_SPHERICAL_POLAR_GRID :: Spherical polar horiz. grid |
62 |
|
C | | | :: initialisation (calculate grid from |
63 |
|
C | | | :: kernel parameters). |
64 |
|
C | | | |
65 |
|
C | | |-INI_CURVILINEAR_GRID :: General orthogonal, structured horiz. |
66 |
|
C | | :: grid initialisations. ( input from raw |
67 |
|
C | | :: grid files, LONC.bin, DXF.bin etc... ) |
68 |
|
C | | |
69 |
|
C | |-INI_DEPTHS :: Read (from "bathyFile") or set bathymetry/orgography. |
70 |
|
C | | |
71 |
|
C | |-INI_MASKS_ETC :: Derive horizontal and vertical cell fractions and |
72 |
|
C | | :: land masking for solid-fluid boundaries. |
73 |
|
C | | |
74 |
|
C | |-INI_LINEAR_PHSURF :: Set ref. surface Bo_surf |
75 |
|
C | | |
76 |
|
C | |-INI_CORI :: Set coriolis term. zero, f-plane, beta-plane, |
77 |
|
C | | :: sphere optins are coded. |
78 |
|
C | | |
79 |
|
C | |-PACAKGES_BOOT :: Start up the optional package environment. |
80 |
|
C | | :: Runtime selection of active packages. |
81 |
|
C | | |
82 |
|
C | |-PACKAGES_READPARMS :: Call active package internal parameter load. |
83 |
|
C | | | |
84 |
|
C | | |-GMREDI_READPARMS :: GM Package. see pkg/gmredi |
85 |
|
C | | |-KPP_READPARMS :: KPP Package. see pkg/kpp |
86 |
|
C | | |-SHAP_FILT_READPARMS :: Shapiro filter package. see pkg/shap_filt |
87 |
|
C | | |-OBCS_READPARMS :: Open bndy package. see pkg/obcs |
88 |
|
C | | |-AIM_READPARMS :: Intermediate Atmos. pacakage. see pkg/aim |
89 |
|
C | | |-COST_READPARMS :: Cost function package. see pkg/cost |
90 |
|
C | | |-CTRL_INIT :: Control vector support package. see pkg/ctrl |
91 |
|
C | | |-OPTIM_READPARMS :: Optimisation support package. see pkg/ctrl |
92 |
|
C | | |-GRDCHK_READPARMS :: Gradient check package. see pkg/grdchk |
93 |
|
C | | |-ECCO_READPARMS :: ECCO Support Package. see pkg/ecco |
94 |
|
C | | |
95 |
|
C | |-PACKAGES_CHECK |
96 |
|
C | | | |
97 |
|
C | | |-KPP_CHECK :: KPP Package. pkg/kpp |
98 |
|
C | | |-OBCS_CHECK :: Open bndy Pacakge. pkg/obcs |
99 |
|
C | | |-GMREDI_CHECK :: GM Package. pkg/gmredi |
100 |
|
C | | |
101 |
|
C | |-PACKAGES_INIT_FIXED |
102 |
|
C | | |-OBCS_INIT_FIXED :: Open bndy Package. see pkg/obcs |
103 |
|
C | | |-FLT_INIT :: Floats Package. see pkg/flt |
104 |
|
C | | |
105 |
|
C | |-ZONAL_FILT_INIT :: FFT filter Package. see pkg/zonal_filt |
106 |
|
C | | |
107 |
|
C | |-INI_CG2D :: 2d con. grad solver initialisation. |
108 |
|
C | | |
109 |
|
C | |-INI_CG3D :: 3d con. grad solver initialisation. |
110 |
|
C | | |
111 |
|
C | |-CONFIG_SUMMARY :: Provide synopsis of kernel setup. |
112 |
|
C | :: Includes annotated table of kernel |
113 |
|
C | :: parameter settings. |
114 |
|
C | |
115 |
|
C |-CTRL_UNPACK :: Control vector support package. see pkg/ctrl |
116 |
|
C | |
117 |
|
C |-ADTHE_MAIN_LOOP :: Derivative evaluating form of main time stepping loop |
118 |
|
C ! :: Auotmatically gerenrated by TAMC/TAF. |
119 |
|
C | |
120 |
|
C |-CTRL_PACK :: Control vector support package. see pkg/ctrl |
121 |
|
C | |
122 |
|
C |-GRDCHK_MAIN :: Gradient check package. see pkg/grdchk |
123 |
|
C | |
124 |
|
C |-THE_MAIN_LOOP :: Main timestepping loop routine. |
125 |
|
C | | |
126 |
|
C | |-INITIALISE_VARIA :: Set the initial conditions for time evolving |
127 |
|
C | | | :: variables |
128 |
|
C | | | |
129 |
|
C | | |-INI_LINEAR_PHISURF :: Set ref. surface Bo_surf |
130 |
|
C | | | |
131 |
|
C | | |-INI_CORI :: Set coriolis term. zero, f-plane, beta-plane, |
132 |
|
C | | | :: sphere optins are coded. |
133 |
|
C | | | |
134 |
|
C | | |-INI_CG2D :: 2d con. grad solver initialisation. |
135 |
|
C | | |-INI_CG3D :: 3d con. grad solver initialisation. |
136 |
|
C | | |-INI_MIXING :: Initialise diapycnal diffusivity. |
137 |
|
C | | |-INI_DYNVARS :: Initialise to zero all DYNVARS.h arrays (dynamical |
138 |
|
C | | | :: fields). |
139 |
|
C | | | |
140 |
|
C | | |-INI_FIELDS :: Control initialising model fields to non-zero |
141 |
|
C | | | |-INI_VEL :: Initialize 3D flow field. |
142 |
|
C | | | |-INI_THETA :: Set model initial temperature field. |
143 |
|
C | | | |-INI_SALT :: Set model initial salinity field. |
144 |
|
C | | | |-INI_PSURF :: Set model initial free-surface height/pressure. |
145 |
|
C | | | |-INI_PRESSURE :: Compute model initial hydrostatic pressure |
146 |
|
C | | | |
147 |
|
C | | |-INI_TR1 :: Set initial tracer 1 distribution. |
148 |
|
C | | | |
149 |
|
C | | |-THE_CORRECTION_STEP :: Step forward to next time step. |
150 |
|
C | | | | :: Here applied to move restart conditions |
151 |
|
C | | | | :: (saved in mid timestep) to correct level in |
152 |
|
C | | | | :: time (only used for pre-c35). |
153 |
|
C | | | | |
154 |
|
C | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure |
155 |
|
C | | | |-CORRECTION_STEP :: Pressure correction to momentum |
156 |
|
C | | | |-CYCLE_TRACER :: Move tracers forward in time. |
157 |
|
C | | | |-OBCS_APPLY :: Open bndy package. see pkg/obcs |
158 |
|
C | | | |-SHAP_FILT_APPLY :: Shapiro filter package. see pkg/shap_filt |
159 |
|
C | | | |-ZONAL_FILT_APPLY :: FFT filter package. see pkg/zonal_filt |
160 |
|
C | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing. |
161 |
|
C | | | | |-FIND_RHO :: Find adjacent densities. |
162 |
|
C | | | | |-CONVECT :: Mix static instability. |
163 |
|
C | | | | |-TIMEAVE_CUMULATE :: Update convection statistics. |
164 |
|
C | | | | |
165 |
|
C | | | |-CALC_EXACT_ETA :: Change SSH to flow divergence. |
166 |
|
C | | | |
167 |
|
C | | |-CONVECTIVE_ADJUSTMENT_INI :: Control static instability mixing |
168 |
|
C | | | | :: Extra time history interactions. |
169 |
|
C | | | | |
170 |
|
C | | | |-FIND_RHO :: Find adjacent densities. |
171 |
|
C | | | |-CONVECT :: Mix static instability. |
172 |
|
C | | | |-TIMEAVE_CUMULATE :: Update convection statistics. |
173 |
|
C | | | |
174 |
|
C | | |-PACKAGES_INIT_VARIABLES :: Does initialisation of time evolving |
175 |
|
C | | | | :: package data. |
176 |
|
C | | | | |
177 |
|
C | | | |-GMREDI_INIT :: GM package. ( see pkg/gmredi ) |
178 |
|
C | | | |-KPP_INIT :: KPP package. ( see pkg/kpp ) |
179 |
|
C | | | |-KPP_OPEN_DIAGS |
180 |
|
C | | | |-OBCS_INIT_VARIABLES :: Open bndy. package. ( see pkg/obcs ) |
181 |
|
C | | | |-AIM_INIT :: Interm. atmos package. ( see pkg/aim ) |
182 |
|
C | | | |-CTRL_MAP_INI :: Control vector package.( see pkg/ctrl ) |
183 |
|
C | | | |-COST_INIT :: Cost function package. ( see pkg/cost ) |
184 |
|
C | | | |-ECCO_INIT :: ECCO support package. ( see pkg/ecco ) |
185 |
|
C | | | |-INI_FORCING :: Set model initial forcing fields. |
186 |
|
C | | | | :: Either set in-line or from file as shown. |
187 |
|
C | | | |-READ_FLD_XY_RS(zonalWindFile) |
188 |
|
C | | | |-READ_FLD_XY_RS(meridWindFile) |
189 |
|
C | | | |-READ_FLD_XY_RS(surfQFile) |
190 |
|
C | | | |-READ_FLD_XY_RS(EmPmRfile) |
191 |
|
C | | | |-READ_FLD_XY_RS(thetaClimFile) |
192 |
|
C | | | |-READ_FLD_XY_RS(saltClimFile) |
193 |
|
C | | | |-READ_FLD_XY_RS(surfQswFile) |
194 |
|
C | | | |
195 |
|
C | | |-CALC_SURF_DR :: Calculate the new surface level thickness. |
196 |
|
C | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction. |
197 |
|
C | | |-UPDATE_CG2D :: Update 2d conjugate grad. for Free-Surf. |
198 |
|
C | | |-STATE_SUMMARY :: Summarize model prognostic variables. |
199 |
|
C | | |-TIMEAVE_STATVARS :: Time averaging package ( see pkg/timeave ). |
200 |
|
C | | |
201 |
|
C | |-WRITE_STATE :: Controlling routine for IO to dump model state. |
202 |
|
C | | |-WRITE_REC_XYZ_RL :: Single file I/O |
203 |
|
C | | |-WRITE_FLD_XYZ_RL :: Multi-file I/O |
204 |
|
C | | |
205 |
|
C | |-MONITOR :: Monitor state ( see pkg/monitor ) |
206 |
|
C | |-CTRL_MAP_FORCING :: Control vector support package. ( see pkg/ctrl ) |
207 |
|
C====|>| |
208 |
|
C====|>| **************************** |
209 |
|
C====|>| BEGIN MAIN TIMESTEPPING LOOP |
210 |
|
C====|>| **************************** |
211 |
|
C====|>| |
212 |
|
C/\ | |-FORWARD_STEP :: Step forward a time-step ( AT LAST !!! ) |
213 |
|
C/\ | | | |
214 |
|
C/\ | | |-DUMMY_IN_STEPPING :: autodiff package ( pkg/autoduff ). |
215 |
|
C/\ | | |-CALC_EXACT_ETA :: Change SSH to flow divergence. |
216 |
|
C/\ | | |-CALC_SURF_DR :: Calculate the new surface level thickness. |
217 |
|
C/\ | | |-EXF_GETFORCING :: External forcing package. ( pkg/exf ) |
218 |
|
C/\ | | |-EXTERNAL_FIELDS_LOAD :: Control loading time dep. external data. |
219 |
|
C/\ | | | | :: Simple interpolcation between end-points |
220 |
|
C/\ | | | | :: for forcing datasets. |
221 |
|
C/\ | | | | |
222 |
|
C/\ | | | |-EXCH :: Sync forcing. in overlap regions. |
223 |
|
C/\ | | |-SEAICE_MODEL :: Compute sea-ice terms. ( pkg/seaice ) |
224 |
|
C/\ | | | |
225 |
|
C/\ | | |-THERMODYNAMICS :: theta, salt + tracer equations driver. |
226 |
|
C/\ | | | | |
227 |
|
C/\ | | | |-INTEGRATE_FOR_W :: Integrate for vertical velocity. |
228 |
|
C/\ | | | |-OBCS_APPLY_W :: Open bndy. package ( see pkg/obcs ). |
229 |
|
C/\ | | | |-FIND_RHO :: Calculates [rho(S,T,z)-RhoConst] of a slice |
230 |
|
C/\ | | | |-GRAD_SIGMA :: Calculate isoneutral gradients |
231 |
|
C/\ | | | |-CALC_IVDC :: Set Implicit Vertical Diffusivity for Convection |
232 |
|
C/\ | | | | |
233 |
|
C/\ | | | |-OBCS_CALC :: Open bndy. package ( see pkg/obcs ). |
234 |
|
C/\ | | | |-EXTERNAL_FORCING_SURF:: Accumulates appropriately dimensioned |
235 |
|
C/\ | | | | :: forcing terms. |
236 |
|
C/\ | | | | |
237 |
|
C/\ | | | |-GMREDI_CALC_TENSOR :: GM package ( see pkg/gmredi ). |
238 |
|
C/\ | | | |-GMREDI_CALC_TENSOR_DUMMY :: GM package ( see pkg/gmredi ). |
239 |
|
C/\ | | | |-KPP_CALC :: KPP package ( see pkg/kpp ). |
240 |
|
C/\ | | | |-KPP_CALC_DUMMY :: KPP package ( see pkg/kpp ). |
241 |
|
C/\ | | | |-AIM_DO_ATMOS_PHYSICS :: Intermed. atmos package ( see pkg/aim ). |
242 |
|
C/\ | | | |-GAD_ADVECTION :: Generalised advection driver (multi-dim |
243 |
|
C/\ | | | | advection case) (see pkg/gad). |
244 |
|
C/\ | | | |-CALC_COMMON_FACTORS :: Calculate common data (such as volume flux) |
245 |
|
C/\ | | | |-CALC_DIFFUSIVITY :: Calculate net vertical diffusivity |
246 |
|
C/\ | | | | | |
247 |
|
C/\ | | | | |-GMREDI_CALC_DIFF :: GM package ( see pkg/gmredi ). |
248 |
|
C/\ | | | | |-KPP_CALC_DIFF :: KPP package ( see pkg/kpp ). |
249 |
|
C/\ | | | | |
250 |
|
C/\ | | | |-CALC_GT :: Calculate the temperature tendency terms |
251 |
|
C/\ | | | | | |
252 |
|
C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package |
253 |
|
C/\ | | | | | :: ( see pkg/gad ) |
254 |
|
C/\ | | | | |-EXTERNAL_FORCING_T :: Problem specific forcing for temperature. |
255 |
|
C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time. |
256 |
|
C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gt for free-surface height. |
257 |
|
C/\ | | | | |
258 |
|
C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time |
259 |
|
C/\ | | | | |
260 |
|
C/\ | | | |-CALC_GS :: Calculate the salinity tendency terms |
261 |
|
C/\ | | | | | |
262 |
|
C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package |
263 |
|
C/\ | | | | | :: ( see pkg/gad ) |
264 |
|
C/\ | | | | |-EXTERNAL_FORCING_S :: Problem specific forcing for salt. |
265 |
|
C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time. |
266 |
|
C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height. |
267 |
|
C/\ | | | | |
268 |
|
C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time |
269 |
|
C/\ | | | | |
270 |
|
C/\ | | | |-CALC_GTR1 :: Calculate other tracer(s) tendency terms |
271 |
|
C/\ | | | | | |
272 |
|
C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package |
273 |
|
C/\ | | | | | :: ( see pkg/gad ) |
274 |
|
C/\ | | | | |-EXTERNAL_FORCING_TR:: Problem specific forcing for tracer. |
275 |
|
C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time. |
276 |
|
C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height. |
277 |
|
C/\ | | | | |
278 |
|
C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time |
279 |
|
C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ). |
280 |
|
C/\ | | | |-FREEZE :: Limit range of temperature. |
281 |
|
C/\ | | | | |
282 |
|
C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation. |
283 |
|
C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ). |
284 |
|
C/\ | | | | |
285 |
|
C/\ | | | |-AIM_AIM2DYN_EXCHANGES :: Inetermed. atmos (see pkg/aim). |
286 |
|
C/\ | | | |-EXCH :: Update overlaps |
287 |
|
C/\ | | | |
288 |
|
C/\ | | |-DYNAMICS :: Momentum equations driver. |
289 |
|
C/\ | | | | |
290 |
|
C/\ | | | |-CALC_GRAD_PHI_SURF :: Calculate the gradient of the surface |
291 |
|
C/\ | | | | Potential anomaly. |
292 |
|
C/\ | | | |-CALC_VISCOSITY :: Calculate net vertical viscosity |
293 |
|
C/\ | | | | |-KPP_CALC_VISC :: KPP package ( see pkg/kpp ). |
294 |
|
C/\ | | | | |
295 |
|
C/\ | | | |-CALC_PHI_HYD :: Integrate the hydrostatic relation. |
296 |
|
C/\ | | | |-MOM_FLUXFORM :: Flux form mom eqn. package ( see |
297 |
|
C/\ | | | | pkg/mom_fluxform ). |
298 |
|
C/\ | | | |-MOM_VECINV :: Vector invariant form mom eqn. package ( see |
299 |
|
C/\ | | | | pkg/mom_vecinv ). |
300 |
|
C/\ | | | |-TIMESTEP :: Step momentum fields forward in time |
301 |
|
C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ). |
302 |
|
C/\ | | | | |
303 |
|
C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation. |
304 |
|
C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ). |
305 |
|
C/\ | | | | |
306 |
|
C/\ | | | |-TIMEAVE_CUMUL_1T :: Time averaging package ( see pkg/timeave ). |
307 |
|
C/\ | | | |-TIMEAVE_CUMUATE :: Time averaging package ( see pkg/timeave ). |
308 |
|
C/\ | | | |-DEBUG_STATS_RL :: Quick debug package ( see pkg/debug ). |
309 |
|
C/\ | | | |
310 |
|
C/\ | | |-CALC_GW :: vert. momentum tendency terms ( NH, QH only ). |
311 |
|
C/\ | | | |
312 |
|
C/\ | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction. |
313 |
|
C/\ | | | |
314 |
|
C/\ | | |-UPDATE_CG2D :: Update 2d conjugate grad. for Free-Surf. |
315 |
|
C/\ | | | |
316 |
|
C/\ | | |-SOLVE_FOR_PRESSURE :: Find surface pressure. |
317 |
|
C/\ | | | |-CALC_DIV_GHAT :: Form the RHS of the surface pressure eqn. |
318 |
|
C/\ | | | |-CG2D :: Two-dim pre-con. conjugate-gradient. |
319 |
|
C/\ | | | |-CG3D :: Three-dim pre-con. conjugate-gradient solver. |
320 |
|
C/\ | | | |
321 |
|
C/\ | | |-THE_CORRECTION_STEP :: Step forward to next time step. |
322 |
|
C/\ | | | | |
323 |
|
C/\ | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure |
324 |
|
C/\ | | | |-CORRECTION_STEP :: Pressure correction to momentum |
325 |
|
C/\ | | | |-CYCLE_TRACER :: Move tracers forward in time. |
326 |
|
C/\ | | | |-OBCS_APPLY :: Open bndy package. see pkg/obcs |
327 |
|
C/\ | | | |-SHAP_FILT_APPLY :: Shapiro filter package. see pkg/shap_filt |
328 |
|
C/\ | | | |-ZONAL_FILT_APPLY :: FFT filter package. see pkg/zonal_filt |
329 |
|
C/\ | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing. |
330 |
|
C/\ | | | | |-FIND_RHO :: Find adjacent densities. |
331 |
|
C/\ | | | | |-CONVECT :: Mix static instability. |
332 |
|
C/\ | | | | |-TIMEAVE_CUMULATE :: Update convection statistics. |
333 |
|
C/\ | | | | |
334 |
|
C/\ | | | |-CALC_EXACT_ETA :: Change SSH to flow divergence. |
335 |
|
C/\ | | | |
336 |
|
C/\ | | |-DO_FIELDS_BLOCKING_EXCHANGES :: Sync up overlap regions. |
337 |
|
C/\ | | | |-EXCH |
338 |
|
C/\ | | | |
339 |
|
C/\ | | |-FLT_MAIN :: Float package ( pkg/flt ). |
340 |
|
C/\ | | | |
341 |
|
C/\ | | |-MONITOR :: Monitor package ( pkg/monitor ). |
342 |
|
C/\ | | | |
343 |
|
C/\ | | |-DO_THE_MODEL_IO :: Standard diagnostic I/O. |
344 |
|
C/\ | | | |-WRITE_STATE :: Core state I/O |
345 |
|
C/\ | | | |-TIMEAVE_STATV_WRITE :: Time averages. see pkg/timeave |
346 |
|
C/\ | | | |-AIM_WRITE_DIAGS :: Intermed. atmos diags. see pkg/aim |
347 |
|
C/\ | | | |-GMREDI_DIAGS :: GM diags. see pkg/gmredi |
348 |
|
C/\ | | | |-KPP_DO_DIAGS :: KPP diags. see pkg/kpp |
349 |
|
C/\ | | | |-SBO_CALC :: SBO diags. see pkg/sbo |
350 |
|
C/\ | | | |-SBO_DIAGS :: SBO diags. see pkg/sbo |
351 |
|
C/\ | | | |
352 |
|
C/\ | | |-WRITE_CHECKPOINT :: Do I/O for restart files. |
353 |
|
C/\ | | |
354 |
|
C/\ | |-COST_TILE :: Cost function package. ( see pkg/cost ) |
355 |
|
C<===|=| |
356 |
|
C<===|=| ************************** |
357 |
|
C<===|=| END MAIN TIMESTEPPING LOOP |
358 |
|
C<===|=| ************************** |
359 |
|
C<===|=| |
360 |
|
C | |-COST_FINAL :: Cost function package. ( see pkg/cost ) |
361 |
|
C | |
362 |
|
C |-WRITE_CHECKPOINT :: Final state storage, for restart. |
363 |
|
C | |
364 |
|
C |-TIMER_PRINTALL :: Computational timing summary |
365 |
|
C | |
366 |
|
C |-COMM_STATS :: Summarise inter-proc and inter-thread communication |
367 |
|
C :: events. |
368 |
|
C \ev |
369 |
|
C |
370 |
|
C |
371 |
|
CEOI |
372 |
|
|
373 |
|
|
374 |
#include "CPP_OPTIONS.h" |
#include "CPP_OPTIONS.h" |
375 |
|
|
376 |
|
CBOP |
377 |
|
|
378 |
|
C !ROUTINE: THE_MODEL_MAIN |
379 |
|
|
380 |
|
C !INTERFACE: |
381 |
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 \==========================================================/ |
|
382 |
IMPLICIT NONE |
IMPLICIT NONE |
|
C |
|
|
C Call Tree |
|
|
C ========= |
|
|
C |
|
|
C main ( eesupp ) |
|
|
C | |
|
|
C . |
|
|
C . |
|
|
C . Generic environment initialisation ( see eesupp/src and |
|
|
C . eesupp/inc ) |
|
|
C . multiple threads and/or processes are created in here |
|
|
C . |
|
|
C . |
|
|
C . |
|
|
C | |
|
|
C |-THE_MODEL_MAIN - Begin specific model. One instance |
|
|
C | | of this codes exists for each thread |
|
|
C | | and/or instance. Each instance manages |
|
|
C | | a specifc set of tiles. |
|
|
C | | |
|
|
C | |--INITIALISE_FIXED |
|
|
C | | o Set model configuration (fixed arrays) |
|
|
C | | Topography, hydrography, timestep, grid, etc.. |
|
|
C | | |
|
|
C | |--THE_MAIN_LOOP |
|
|
C | | | |
|
|
C | | |--INITIALISE_VARIA |
|
|
C | | | o Set initial conditions (variable arrays) |
|
|
C | | | |
|
|
C ==> | | | ** Time stepping loop starts here ** |
|
|
C | | | | |
|
|
C /|\ | | | |
|
|
C | | | |--FORWARD_STEP |
|
|
C /|\ | | | | o Does a single forward step of the model |
|
|
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 | | | | |--SOLVE_FOR_PRESSURE |
|
|
C /|\ | | | | o Find pressure field to keep flow non-divergent |
|
|
C | | | | | |
|
|
C /|\ | | | |--THE_CORRECTION_STEP |
|
|
C | | | | | o Correct flow field with and cycle time-stepping arrays |
|
|
C /|\ | | | | |
|
|
C | | | | |--DO_GTERM_BLOCKING_EXCHANGES |
|
|
C /|\ | | | | o Update overlap regions |
|
|
C | | | | | |
|
|
C /|\ | | | |--DO_THE_MODEL_IO |
|
|
C | | | | | o Write model state |
|
|
C /|\ | | | | |
|
|
C | | | | |--WRITE_CHECKPOINT |
|
|
C /|\ | | | | o Write restart file(s) |
|
|
C | | | | |
|
|
C /|\ | | | |
|
|
C |<== | | | ** Time stepping loop finishes here ** |
|
|
C | | | |
|
|
C | | |-- |
|
|
C | | |
|
|
C | |--WRITE_STATE |
|
|
C | |--WRITE_CHECKPOINT |
|
|
C | |
|
|
C . |
|
|
C . |
|
|
C . Generic environment termination ( see eesupp/src and |
|
|
C . eesupp/inc ) |
|
|
C . |
|
|
C . |
|
383 |
|
|
384 |
|
C !DESCRIPTION: \bv |
385 |
|
C *==========================================================* |
386 |
|
C | SUBROUTINE THE_MODEL_MAIN |
387 |
|
C | o Master controlling routine for model using the MITgcm |
388 |
|
C | UV parallel wrapper. |
389 |
|
C *==========================================================* |
390 |
|
C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel |
391 |
|
C | wrapper with a single integer argument "myThid". This |
392 |
|
C | variable identifies the thread number of an instance of |
393 |
|
C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works |
394 |
|
C | on a particular region of the models domain and |
395 |
|
C | synchronises with other instances as necessary. The |
396 |
|
C | routine has to "understand" the MITgcm parallel |
397 |
|
C | environment and the numerical algorithm. Editing this |
398 |
|
C | routine is best done with some knowledge of both aspects. |
399 |
|
C | Notes |
400 |
|
C | ===== |
401 |
|
C | C*P* comments indicating place holders for which code is |
402 |
|
C | presently being developed. |
403 |
|
C *==========================================================* |
404 |
|
C \ev |
405 |
|
|
406 |
|
C !CALLING SEQUENCE: |
407 |
|
C THE_MODEL_MAIN() |
408 |
|
C | |
409 |
|
C | |
410 |
|
C |--INITIALISE_FIXED |
411 |
|
C | o Set model configuration (fixed arrays) |
412 |
|
C | Topography, hydrography, timestep, grid, etc.. |
413 |
|
C | |
414 |
|
C |--CTRL_UNPACK o Derivative mode. Unpack control vector. |
415 |
|
C | |
416 |
|
C |--ADTHE_MAIN_LOOP o Main timestepping loop for combined |
417 |
|
C | prognostic and reverse mode integration. |
418 |
|
C | |
419 |
|
C |--CTRL_PACK o Derivative mode. Unpack control vector. |
420 |
|
C | |
421 |
|
C |--GRDCHK_MAIN o Gradient check control routine. |
422 |
|
C | |
423 |
|
C |--THE_MAIN_LOOP o Main timestepping loop for pure prognostic |
424 |
|
C | integration. |
425 |
|
C | |
426 |
|
C |--WRITE_CHECKPOINT o Write retsart information. |
427 |
|
C | |
428 |
|
C |--TIMER_PRINTALL o Print out timing statistics. |
429 |
|
C | |
430 |
|
C |--COMM_STATS o Print out communication statistics. |
431 |
|
|
432 |
|
C !USES: |
433 |
C == Global variables === |
C == Global variables === |
434 |
#include "SIZE.h" |
#include "SIZE.h" |
435 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
436 |
#include "PARAMS.h" |
#include "PARAMS.h" |
437 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
|
#include "CG2D.h" |
|
438 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_NONHYDROSTATIC |
439 |
#include "CG3D.h" |
#include "CG3D.h" |
440 |
#endif |
#endif |
441 |
|
|
442 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
443 |
|
#include "tamc.h" |
444 |
|
#endif |
445 |
|
|
446 |
|
C !INPUT/OUTPUT PARAMETERS: |
447 |
C == Routine arguments == |
C == Routine arguments == |
448 |
C myThid - Thread number for this instance of the routine. |
C myThid - Thread number for this instance of the routine. |
449 |
INTEGER myThid |
INTEGER myThid |
450 |
|
|
451 |
|
C !LOCAL VARIABLES: |
452 |
C == Local variables == |
C == Local variables == |
453 |
C Note: Under the multi-threaded model myCurrentIter and |
C Note: Under the multi-threaded model myCurrentIter and |
454 |
C myCurrentTime are local variables passed around as routine |
C myCurrentTime are local variables passed around as routine |
459 |
C myCurrentIter - Iteration counter for this thread |
C myCurrentIter - Iteration counter for this thread |
460 |
INTEGER myCurrentIter |
INTEGER myCurrentIter |
461 |
_RL myCurrentTime |
_RL myCurrentTime |
462 |
|
logical exst |
463 |
|
logical lastdiva |
464 |
|
CEOP |
465 |
|
c-- set default: |
466 |
|
lastdiva = .TRUE. |
467 |
|
|
468 |
C-- This timer encompasses the whole code |
C-- This timer encompasses the whole code |
469 |
CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid) |
CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid) |
|
|
|
470 |
|
|
471 |
C-- Set model configuration (fixed arrays) |
C-- Set model configuration (fixed arrays) |
472 |
CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
473 |
CALL INITIALISE_FIXED( myThid ) |
CALL INITIALISE_FIXED( myThid ) |
474 |
CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
|
|
|
475 |
|
|
476 |
myCurrentTime = startTime |
myCurrentTime = startTime |
477 |
myCurrentIter = nIter0 |
myCurrentIter = nIter0 |
478 |
|
|
479 |
|
#if ( defined (ALLOW_ADJOINT_RUN) || \ |
480 |
|
defined (ALLOW_TANGENTLINEAR_RUN) || \ |
481 |
|
defined (ALLOW_GRADIENT_CHECK) || \ |
482 |
|
defined (ALLOW_ECCO_OPTIMIZATION) ) |
483 |
|
|
484 |
|
_BEGIN_MASTER( mythid ) |
485 |
|
IF (myProcId .eq. 0) THEN |
486 |
|
inquire( file='costfinal', exist=exst ) |
487 |
|
IF ( .NOT. exst) THEN |
488 |
|
CALL TIMER_START('CTRL_UNPACK [THE_MODEL_MAIN]',mythid) |
489 |
|
CALL CTRL_UNPACK( mycurrentiter, mycurrenttime, mythid ) |
490 |
|
CALL TIMER_STOP ('CTRL_UNPACK [THE_MODEL_MAIN]',mythid) |
491 |
|
ENDIF |
492 |
|
ENDIF |
493 |
|
_END_MASTER( mythid ) |
494 |
|
_BARRIER |
495 |
|
|
496 |
|
CALL COST_DEPENDENT_INIT ( mythid ) |
497 |
|
_BARRIER |
498 |
|
|
499 |
|
#if ( defined (ALLOW_ADJOINT_RUN) || \ |
500 |
|
defined (ALLOW_ECCO_OPTIMIZATION) ) |
501 |
|
# ifdef ALLOW_DIVIDED_ADJOINT |
502 |
|
c-- The following assumes the TAF option '-pure' |
503 |
|
inquire( file='costfinal', exist=exst ) |
504 |
|
IF ( .NOT. exst) THEN |
505 |
|
CALL TIMER_START('MDTHE_MAIN_LOOP [MD RUN]', mythid) |
506 |
|
CALL MDTHE_MAIN_LOOP ( myCurrentTime, myCurrentIter, mythid ) |
507 |
|
CALL TIMER_STOP ('MDTHE_MAIN_LOOP [MD RUN]', mythid) |
508 |
|
CALL COST_FINAL_STORE ( mythid, lastdiva ) |
509 |
|
ELSE |
510 |
|
CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
511 |
|
CALL ADTHE_MAIN_LOOP ( mythid ) |
512 |
|
CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
513 |
|
CALL COST_FINAL_RESTORE ( mythid, lastdiva ) |
514 |
|
ENDIF |
515 |
|
c-- |
516 |
|
# else |
517 |
|
CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
518 |
|
CALL ADTHE_MAIN_LOOP ( mythid ) |
519 |
|
CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
520 |
|
# endif |
521 |
|
c-- |
522 |
|
#elif (defined (ALLOW_TANGENTLINEAR_RUN)) |
523 |
|
CALL TIMER_START('G_THE_MAIN_LOOP [TANGENT RUN]',mythid) |
524 |
|
CALL G_THE_MAIN_LOOP ( myCurrentTime, myCurrentIter, myThid ) |
525 |
|
CALL TIMER_STOP ('G_THE_MAIN_LOOP [TANGENT RUN]',mythid) |
526 |
|
#endif |
527 |
|
_BARRIER |
528 |
|
|
529 |
|
_BEGIN_MASTER( mythid ) |
530 |
|
IF ( myProcId .eq. 0 .AND. lastdiva ) THEN |
531 |
|
CALL TIMER_START('CTRL_PACK [THE_MODEL_MAIN]',mythid) |
532 |
|
call CTRL_PACK( mycurrentiter, mycurrenttime, mythid ) |
533 |
|
CALL TIMER_STOP ('CTRL_PACK [THE_MODEL_MAIN]',mythid) |
534 |
|
ENDIF |
535 |
|
_END_MASTER( mythid ) |
536 |
|
_BARRIER |
537 |
|
|
538 |
|
#ifdef ALLOW_GRADIENT_CHECK |
539 |
|
IF ( useGrdchk .AND. lastdiva ) THEN |
540 |
|
CALL TIMER_START('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid) |
541 |
|
CALL GRDCHK_MAIN( mythid ) |
542 |
|
CALL TIMER_STOP ('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid) |
543 |
|
_BARRIER |
544 |
|
ENDIF |
545 |
|
#endif |
546 |
|
|
547 |
|
#else /* ALLOW_ADJOINT_RUN undef */ |
548 |
|
|
549 |
C-- Call time stepping loop of full model |
C-- Call time stepping loop of full model |
550 |
CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
551 |
CALL THE_MAIN_LOOP(myCurrentTime, myCurrentIter, myThid ) |
CALL THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid ) |
552 |
CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
553 |
|
|
554 |
|
#endif /* ALLOW_ADJOINT_RUN */ |
555 |
|
|
556 |
|
C-- Sea-ice checkpoint (in case the in-loop checkpoint was missed) |
557 |
|
#ifdef ALLOW_SEAICE |
558 |
|
IF ( useSEAICE ) |
559 |
|
& CALL SEAICE_WRITE_PICKUP( |
560 |
|
& .TRUE., myCurrentTime, myCurrentIter, myThid ) |
561 |
|
#endif |
562 |
|
|
563 |
|
C-- Final checkpoint (in case the in-loop checkpoint was missed) |
564 |
|
CALL TIMER_START('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid) |
565 |
|
CALL WRITE_CHECKPOINT( |
566 |
|
& .TRUE., myCurrentTime, myCurrentIter, myThid ) |
567 |
|
CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid) |
568 |
|
|
569 |
CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid) |
CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid) |
570 |
|
|
571 |
C-- Write timer statistics |
C-- Write timer statistics |
572 |
IF ( myThid .EQ. 1 ) THEN |
IF ( myThid .EQ. 1 ) THEN |