/[MITgcm]/MITgcm_contrib/heimbach/OpenAD/code_shallow_openad2/the_model_main.F
ViewVC logotype

Contents of /MITgcm_contrib/heimbach/OpenAD/code_shallow_openad2/the_model_main.F

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


Revision 1.5 - (show annotations) (download)
Thu Dec 19 16:10:15 2013 UTC (12 years, 10 months ago) by utke
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +1 -1 lines
FILE REMOVED
stale

1 C $Header: /u/gcmpack/MITgcm_contrib/heimbach/OpenAD/code_shallow_openad2/the_model_main.F,v 1.4 2006/11/09 21:45:19 utke Exp $
2
3 CBOI
4 C
5 C !TITLE: MITGCM KERNEL CODE SYNOPSIS
6 C !AUTHORS: mitgcm developers ( support@mitgcm.org )
7 C !AFFILIATION: Massachussetts Institute of Technology
8 C !DATE:
9 C !INTRODUCTION: Kernel dynamical routines
10 C This document summarises MITgcm code under the model/ subdirectory.
11 C The code under model/ ( src/ and inc/ ) contains most of
12 C the driver routines for the baseline forms of the kernel equations in the
13 C MITgcm algorithm. Numerical code for much of the baseline forms of
14 C these equations is also under the model/ directory. Other numerical code
15 C used for the kernel equations is contained in packages in the pkg/
16 C directory tree.
17 C Code for auxilliary equations and alternate dicretizations of the kernel
18 C equations and algorithm can also be found in the pkg/ directory tree.
19 C
20 C \subsection{Getting Help and Reporting Errors and Problems}
21 C If you have questions please e-mail support@mitgcm.org. We also welcome
22 C reports of errors and inconsistencies in the code or in the accompanying
23 C documentation. Please feel free to send these
24 C to support@mitgcm.org. For further information and to review
25 C problems reported to support@mitgcm.org please visit http://mitgcm.org.
26 C
27 C \subsection{MITgcm Kernel Code Calling Sequence}
28 C \bv
29 C
30 C Invocation from WRAPPER level...
31 C :
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 innvocation 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 | | :: By default kernel parameters are read from file
48 C | | :: "data" in directory in which code executes.
49 C | |
50 C | |-MON_INIT :: Initialises monitor pacakge ( see pkg/monitor )
51 C | |
52 C | |-INI_GRID :: Control grid array (vert. and hori.) initialisation.
53 C | | | :: Grid arrays are held and described in GRID.h.
54 C | | |
55 C | | |-INI_VERTICAL_GRID :: Initialise vertical grid arrays.
56 C | | |
57 C | | |-INI_CARTESIAN_GRID :: Cartesian horiz. grid initialisation
58 C | | | :: (calculate grid from kernel parameters).
59 C | | |
60 C | | |-INI_SPHERICAL_POLAR_GRID :: Spherical polar horiz. grid
61 C | | | :: initialisation (calculate grid from
62 C | | | :: kernel parameters).
63 C | | |
64 C | | |-INI_CURVILINEAR_GRID :: General orthogonal, structured horiz.
65 C | | :: grid initialisations. ( input from raw
66 C | | :: grid files, LONC.bin, DXF.bin etc... )
67 C | |
68 C | |-INI_DEPTHS :: Read (from "bathyFile") or set bathymetry/orgography.
69 C | |
70 C | |-INI_MASKS_ETC :: Derive horizontal and vertical cell fractions and
71 C | | :: land masking for solid-fluid boundaries.
72 C | |
73 C | |-INI_LINEAR_PHSURF :: Set ref. surface Bo_surf
74 C | |
75 C | |-INI_CORI :: Set coriolis term. zero, f-plane, beta-plane,
76 C | | :: sphere optins are coded.
77 C | |
78 C | |-PACAKGES_BOOT :: Start up the optional package environment.
79 C | | :: Runtime selection of active packages.
80 C | |
81 C | |-PACKAGES_READPARMS :: Call active package internal parameter load.
82 C | | |
83 C | | |-GMREDI_READPARMS :: GM Package. see pkg/gmredi
84 C | | |-KPP_READPARMS :: KPP Package. see pkg/kpp
85 C | | |-SHAP_FILT_READPARMS :: Shapiro filter package. see pkg/shap_filt
86 C | | |-OBCS_READPARMS :: Open bndy package. see pkg/obcs
87 C | | |-AIM_READPARMS :: Intermediate Atmos. pacakage. see pkg/aim
88 C | | |-COST_READPARMS :: Cost function package. see pkg/cost
89 C | | |-CTRL_INIT :: Control vector support package. see pkg/ctrl
90 C | | |-OPTIM_READPARMS :: Optimisation support package. see pkg/ctrl
91 C | | |-GRDCHK_READPARMS :: Gradient check package. see pkg/grdchk
92 C | | |-ECCO_READPARMS :: ECCO Support Package. see pkg/ecco
93 C | | |-PTRACERS_READPARMS :: multiple tracer package, see pkg/ptracers
94 C | | |-GCHEM_READPARMS :: tracer interface package, see pkg/gchem
95 C | |
96 C | |-PACKAGES_CHECK
97 C | | |
98 C | | |-KPP_CHECK :: KPP Package. pkg/kpp
99 C | | |-OBCS_CHECK :: Open bndy Pacakge. pkg/obcs
100 C | | |-GMREDI_CHECK :: GM Package. pkg/gmredi
101 C | |
102 C | |-PACKAGES_INIT_FIXED
103 C | | |-OBCS_INIT_FIXED :: Open bndy Package. see pkg/obcs
104 C | | |-FLT_INIT :: Floats Package. see pkg/flt
105 C | | |-GCHEM_INIT_FIXED :: tracer interface pachage, see pkg/gchem
106 C | |
107 C | |-ZONAL_FILT_INIT :: FFT filter Package. see pkg/zonal_filt
108 C | |
109 C | |-INI_CG2D :: 2d con. grad solver initialisation.
110 C | |
111 C | |-INI_CG3D :: 3d con. grad solver initialisation.
112 C | |
113 C | |-CONFIG_SUMMARY :: Provide synopsis of kernel setup.
114 C | :: Includes annotated table of kernel
115 C | :: parameter settings.
116 C |
117 C |-CTRL_UNPACK :: Control vector support package. see pkg/ctrl
118 C |
119 C |-ADTHE_MAIN_LOOP :: Derivative evaluating form of main time stepping loop
120 C ! :: Auotmatically gerenrated by TAMC/TAF.
121 C |
122 C |-CTRL_PACK :: Control vector support package. see pkg/ctrl
123 C |
124 C |-GRDCHK_MAIN :: Gradient check package. see pkg/grdchk
125 C |
126 C |-THE_MAIN_LOOP :: Main timestepping loop routine.
127 C | |
128 C | |-INITIALISE_VARIA :: Set the initial conditions for time evolving
129 C | | | :: variables
130 C | | |
131 C | | |-INI_LINEAR_PHISURF :: Set ref. surface Bo_surf
132 C | | |
133 C | | |-INI_CORI :: Set coriolis term. zero, f-plane, beta-plane,
134 C | | | :: sphere optins are coded.
135 C | | |
136 C | | |-INI_CG2D :: 2d con. grad solver initialisation.
137 C | | |-INI_CG3D :: 3d con. grad solver initialisation.
138 C | | |-INI_MIXING :: Initialise diapycnal diffusivity.
139 C | | |-INI_DYNVARS :: Initialise to zero all DYNVARS.h arrays (dynamical
140 C | | | :: fields).
141 C | | |
142 C | | |-INI_FIELDS :: Control initialising model fields to non-zero
143 C | | | |-INI_VEL :: Initialize 3D flow field.
144 C | | | |-INI_THETA :: Set model initial temperature field.
145 C | | | |-INI_SALT :: Set model initial salinity field.
146 C | | | |-INI_PSURF :: Set model initial free-surface height/pressure.
147 C | | | |-INI_PRESSURE :: Compute model initial hydrostatic pressure
148 C | | | |-READ_CHECKPOINT :: Read the checkpoint
149 C | | |
150 C | | |-THE_CORRECTION_STEP :: Step forward to next time step.
151 C | | | | :: Here applied to move restart conditions
152 C | | | | :: (saved in mid timestep) to correct level in
153 C | | | | :: time (only used for pre-c35).
154 C | | | |
155 C | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure
156 C | | | |-CORRECTION_STEP :: Pressure correction to momentum
157 C | | | |-CYCLE_TRACER :: Move tracers forward in time.
158 C | | | |-OBCS_APPLY :: Open bndy package. see pkg/obcs
159 C | | | |-SHAP_FILT_APPLY :: Shapiro filter package. see pkg/shap_filt
160 C | | | |-ZONAL_FILT_APPLY :: FFT filter package. see pkg/zonal_filt
161 C | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing.
162 C | | | | |-FIND_RHO :: Find adjacent densities.
163 C | | | | |-CONVECT :: Mix static instability.
164 C | | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
165 C | | | |
166 C | | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
167 C | | |
168 C | | |-CONVECTIVE_ADJUSTMENT_INI :: Control static instability mixing
169 C | | | | :: Extra time history interactions.
170 C | | | |
171 C | | | |-FIND_RHO :: Find adjacent densities.
172 C | | | |-CONVECT :: Mix static instability.
173 C | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
174 C | | |
175 C | | |-PACKAGES_INIT_VARIABLES :: Does initialisation of time evolving
176 C | | | | :: package data.
177 C | | | |
178 C | | | |-GMREDI_INIT :: GM package. ( see pkg/gmredi )
179 C | | | |-KPP_INIT :: KPP package. ( see pkg/kpp )
180 C | | | |-KPP_OPEN_DIAGS
181 C | | | |-OBCS_INIT_VARIABLES :: Open bndy. package. ( see pkg/obcs )
182 C | | | |-PTRACERS_INIT :: multi. tracer package,(see pkg/ptracers)
183 C | | | |-GCHEM_INIT : : tracer interface pkg (see pkh/gchem)
184 C | | | |-AIM_INIT :: Interm. atmos package. ( see pkg/aim )
185 C | | | |-CTRL_MAP_INI :: Control vector package.( see pkg/ctrl )
186 C | | | |-COST_INIT :: Cost function package. ( see pkg/cost )
187 C | | | |-ECCO_INIT :: ECCO support package. ( see pkg/ecco )
188 C | | | |-INI_FORCING :: Set model initial forcing fields.
189 C | | | | :: Either set in-line or from file as shown.
190 C | | | |-READ_FLD_XY_RS(zonalWindFile)
191 C | | | |-READ_FLD_XY_RS(meridWindFile)
192 C | | | |-READ_FLD_XY_RS(surfQFile)
193 C | | | |-READ_FLD_XY_RS(EmPmRfile)
194 C | | | |-READ_FLD_XY_RS(thetaClimFile)
195 C | | | |-READ_FLD_XY_RS(saltClimFile)
196 C | | | |-READ_FLD_XY_RS(surfQswFile)
197 C | | |
198 C | | |-CALC_SURF_DR :: Calculate the new surface level thickness.
199 C | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
200 C | | |-UPDATE_CG2D :: Update 2d conjugate grad. for Free-Surf.
201 C | | |-STATE_SUMMARY :: Summarize model prognostic variables.
202 C | | |-TIMEAVE_STATVARS :: Time averaging package ( see pkg/timeave ).
203 C | |
204 C | |-WRITE_STATE :: Controlling routine for IO to dump model state.
205 C | | |-WRITE_REC_XYZ_RL :: Single file I/O
206 C | | |-WRITE_FLD_XYZ_RL :: Multi-file I/O
207 C | |
208 C | |-MONITOR :: Monitor state ( see pkg/monitor )
209 C | |-CTRL_MAP_FORCING :: Control vector support package. ( see pkg/ctrl )
210 C====|>|
211 C====|>| ****************************
212 C====|>| BEGIN MAIN TIMESTEPPING LOOP
213 C====|>| ****************************
214 C====|>|
215 C/\ | |-FORWARD_STEP :: Step forward a time-step ( AT LAST !!! )
216 C/\ | | |
217 C/\ | | |-DUMMY_IN_STEPPING :: autodiff package ( pkg/autoduff ).
218 C/\ | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
219 C/\ | | |-CALC_SURF_DR :: Calculate the new surface level thickness.
220 C/\ | | |-EXF_GETFORCING :: External forcing package. ( pkg/exf )
221 C/\ | | |-EXTERNAL_FIELDS_LOAD :: Control loading time dep. external data.
222 C/\ | | | | :: Simple interpolcation between end-points
223 C/\ | | | | :: for forcing datasets.
224 C/\ | | | |
225 C/\ | | | |-EXCH :: Sync forcing. in overlap regions.
226 C/\ | | |-SEAICE_MODEL :: Compute sea-ice terms. ( pkg/seaice )
227 C/\ | | |-FREEZE :: Limit surface temperature.
228 C/\ | | |-GCHEM_FIELD_LOAD :: load tracer forcing fields (pkg/gchem)
229 C/\ | | |
230 C/\ | | |-THERMODYNAMICS :: theta, salt + tracer equations driver.
231 C/\ | | | |
232 C/\ | | | |-INTEGRATE_FOR_W :: Integrate for vertical velocity.
233 C/\ | | | |-OBCS_APPLY_W :: Open bndy. package ( see pkg/obcs ).
234 C/\ | | | |-FIND_RHO :: Calculates [rho(S,T,z)-RhoConst] of a slice
235 C/\ | | | |-GRAD_SIGMA :: Calculate isoneutral gradients
236 C/\ | | | |-CALC_IVDC :: Set Implicit Vertical Diffusivity for Convection
237 C/\ | | | |
238 C/\ | | | |-OBCS_CALC :: Open bndy. package ( see pkg/obcs ).
239 C/\ | | | |-EXTERNAL_FORCING_SURF:: Accumulates appropriately dimensioned
240 C/\ | | | | | :: forcing terms.
241 C/\ | | | | |-PTRACERS_FORCING_SURF :: Tracer package ( see pkg/ptracers ).
242 C/\ | | | |
243 C/\ | | | |-GMREDI_CALC_TENSOR :: GM package ( see pkg/gmredi ).
244 C/\ | | | |-GMREDI_CALC_TENSOR_DUMMY :: GM package ( see pkg/gmredi ).
245 C/\ | | | |-KPP_CALC :: KPP package ( see pkg/kpp ).
246 C/\ | | | |-KPP_CALC_DUMMY :: KPP package ( see pkg/kpp ).
247 C/\ | | | |-AIM_DO_ATMOS_PHYSICS :: Intermed. atmos package ( see pkg/aim ).
248 C/\ | | | |-GAD_ADVECTION :: Generalised advection driver (multi-dim
249 C/\ | | | | advection case) (see pkg/gad).
250 C/\ | | | |-CALC_COMMON_FACTORS :: Calculate common data (such as volume flux)
251 C/\ | | | |-CALC_DIFFUSIVITY :: Calculate net vertical diffusivity
252 C/\ | | | | |
253 C/\ | | | | |-GMREDI_CALC_DIFF :: GM package ( see pkg/gmredi ).
254 C/\ | | | | |-KPP_CALC_DIFF :: KPP package ( see pkg/kpp ).
255 C/\ | | | |
256 C/\ | | | |-CALC_GT :: Calculate the temperature tendency terms
257 C/\ | | | | |
258 C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
259 C/\ | | | | | | :: ( see pkg/gad )
260 C/\ | | | | | |-KPP_TRANSPORT_T :: KPP non-local transport ( see pkg/kpp ).
261 C/\ | | | | |
262 C/\ | | | | |-EXTERNAL_FORCING_T :: Problem specific forcing for temperature.
263 C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
264 C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gt for free-surface height.
265 C/\ | | | |
266 C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
267 C/\ | | | |
268 C/\ | | | |-CALC_GS :: Calculate the salinity tendency terms
269 C/\ | | | | |
270 C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
271 C/\ | | | | | | :: ( see pkg/gad )
272 C/\ | | | | | |-KPP_TRANSPORT_S :: KPP non-local transport ( see pkg/kpp ).
273 C/\ | | | | |
274 C/\ | | | | |-EXTERNAL_FORCING_S :: Problem specific forcing for salt.
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/\ | | | |
280 C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
281 C/\ | | | |
282 C/\ | | | |-PTRACERS_INTEGRATE :: Integrate other tracer(s) ( see pkg/ptracers ).
283 C/\ | | | | |
284 C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package
285 C/\ | | | | | | :: ( see pkg/gad )
286 C/\ | | | | | |-KPP_TRANSPORT_PTR:: KPP non-local transport ( see pkg/kpp ).
287 C/\ | | | | |
288 C/\ | | | | |-PTRACERS_FORCING :: Problem specific forcing for tracer.
289 C/\ | | | | |-GCHEM_FORCING_INT :: tracer forcing for gchem pkg (if all
290 C/\ | | | | | tendancy terms calcualted together)
291 C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time.
292 C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
293 C/\ | | | | |-TIMESTEP_TRACER :: Step tracer field forward in time
294 C/\ | | | |
295 C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ).
296 C/\ | | | |
297 C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation.
298 C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ).
299 C/\ | | | |
300 C/\ | | | |-AIM_AIM2DYN_EXCHANGES :: Inetermed. atmos (see pkg/aim).
301 C/\ | | | |-EXCH :: Update overlaps
302 C/\ | | |
303 C/\ | | |-DYNAMICS :: Momentum equations driver.
304 C/\ | | | |
305 C/\ | | | |-CALC_GRAD_PHI_SURF :: Calculate the gradient of the surface
306 C/\ | | | | Potential anomaly.
307 C/\ | | | |-CALC_VISCOSITY :: Calculate net vertical viscosity
308 C/\ | | | | |-KPP_CALC_VISC :: KPP package ( see pkg/kpp ).
309 C/\ | | | |
310 C/\ | | | |-CALC_PHI_HYD :: Integrate the hydrostatic relation.
311 C/\ | | | |-MOM_FLUXFORM :: Flux form mom eqn. package ( see
312 C/\ | | | | pkg/mom_fluxform ).
313 C/\ | | | |-MOM_VECINV :: Vector invariant form mom eqn. package ( see
314 C/\ | | | | pkg/mom_vecinv ).
315 C/\ | | | |-TIMESTEP :: Step momentum fields forward in time
316 C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ).
317 C/\ | | | |
318 C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation.
319 C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ).
320 C/\ | | | |
321 C/\ | | | |-TIMEAVE_CUMUL_1T :: Time averaging package ( see pkg/timeave ).
322 C/\ | | | |-TIMEAVE_CUMUATE :: Time averaging package ( see pkg/timeave ).
323 C/\ | | | |-DEBUG_STATS_RL :: Quick debug package ( see pkg/debug ).
324 C/\ | | |
325 C/\ | | |-CALC_GW :: vert. momentum tendency terms ( NH, QH only ).
326 C/\ | | |
327 C/\ | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
328 C/\ | | |
329 C/\ | | |-UPDATE_CG2D :: Update 2d conjugate grad. for Free-Surf.
330 C/\ | | |
331 C/\ | | |-SOLVE_FOR_PRESSURE :: Find surface pressure.
332 C/\ | | | |-CALC_DIV_GHAT :: Form the RHS of the surface pressure eqn.
333 C/\ | | | |-CG2D :: Two-dim pre-con. conjugate-gradient.
334 C/\ | | | |-CG3D :: Three-dim pre-con. conjugate-gradient solver.
335 C/\ | | |
336 C/\ | | |-THE_CORRECTION_STEP :: Step forward to next time step.
337 C/\ | | | |
338 C/\ | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure
339 C/\ | | | |-CORRECTION_STEP :: Pressure correction to momentum
340 C/\ | | | |-CYCLE_TRACER :: Move tracers forward in time.
341 C/\ | | | |-OBCS_APPLY :: Open bndy package. see pkg/obcs
342 C/\ | | | |-SHAP_FILT_APPLY :: Shapiro filter package. see pkg/shap_filt
343 C/\ | | | |-ZONAL_FILT_APPLY :: FFT filter package. see pkg/zonal_filt
344 C/\ | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing.
345 C/\ | | | | |-FIND_RHO :: Find adjacent densities.
346 C/\ | | | | |-CONVECT :: Mix static instability.
347 C/\ | | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
348 C/\ | | | |
349 C/\ | | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
350 C/\ | | |
351 C/\ | | |-DO_FIELDS_BLOCKING_EXCHANGES :: Sync up overlap regions.
352 C/\ | | | |-EXCH
353 C/\ | | |
354 C/\ | | |-GCHEM_FORCING_SEP :: tracer forcing for gchem pkg (if
355 C/\ | | | tracer dependent tendencies calculated
356 C/\ | | | separatly)
357 C/\ | | |
358 C/\ | | |-FLT_MAIN :: Float package ( pkg/flt ).
359 C/\ | | |
360 C/\ | | |-MONITOR :: Monitor package ( pkg/monitor ).
361 C/\ | | |
362 C/\ | | |-DO_THE_MODEL_IO :: Standard diagnostic I/O.
363 C/\ | | | |-WRITE_STATE :: Core state I/O
364 C/\ | | | |-TIMEAVE_STATV_WRITE :: Time averages. see pkg/timeave
365 C/\ | | | |-AIM_WRITE_DIAGS :: Intermed. atmos diags. see pkg/aim
366 C/\ | | | |-GMREDI_DIAGS :: GM diags. see pkg/gmredi
367 C/\ | | | |-KPP_DO_DIAGS :: KPP diags. see pkg/kpp
368 C/\ | | | |-SBO_CALC :: SBO diags. see pkg/sbo
369 C/\ | | | |-SBO_DIAGS :: SBO diags. see pkg/sbo
370 C/\ | | | |-SEAICE_DO_DIAGS :: SEAICE diags. see pkg/seaice
371 C/\ | | | |-GCHEM_DIAGS :: gchem diags. see pkg/gchem
372 C/\ | | |
373 C/\ | | |-WRITE_CHECKPOINT :: Do I/O for restart files.
374 C/\ | |
375 C/\ | |-COST_TILE :: Cost function package. ( see pkg/cost )
376 C<===|=|
377 C<===|=| **************************
378 C<===|=| END MAIN TIMESTEPPING LOOP
379 C<===|=| **************************
380 C<===|=|
381 C | |-COST_FINAL :: Cost function package. ( see pkg/cost )
382 C |
383 C |-WRITE_CHECKPOINT :: Final state storage, for restart.
384 C |
385 C |-TIMER_PRINTALL :: Computational timing summary
386 C |
387 C |-COMM_STATS :: Summarise inter-proc and inter-thread communication
388 C :: events.
389 C \ev
390 C
391 C
392 CEOI
393
394
395 #include "AD_CONFIG.h"
396 #include "PACKAGES_CONFIG.h"
397 #include "CPP_OPTIONS.h"
398
399 CBOP
400
401 C !ROUTINE: THE_MODEL_MAIN
402
403 C !INTERFACE:
404 SUBROUTINE THE_MODEL_MAIN(myThid)
405 IMPLICIT NONE
406
407 C !DESCRIPTION: \bv
408 C *==========================================================*
409 C | SUBROUTINE THE_MODEL_MAIN
410 C | o Master controlling routine for model using the MITgcm
411 C | UV parallel wrapper.
412 C *==========================================================*
413 C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel
414 C | wrapper with a single integer argument "myThid". This
415 C | variable identifies the thread number of an instance of
416 C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works
417 C | on a particular region of the models domain and
418 C | synchronises with other instances as necessary. The
419 C | routine has to "understand" the MITgcm parallel
420 C | environment and the numerical algorithm. Editing this
421 C | routine is best done with some knowledge of both aspects.
422 C | Notes
423 C | =====
424 C | C*P* comments indicating place holders for which code is
425 C | presently being developed.
426 C *==========================================================*
427 C \ev
428
429 C !CALLING SEQUENCE:
430 C THE_MODEL_MAIN()
431 C |
432 C |
433 C |--INITIALISE_FIXED
434 C | o Set model configuration (fixed arrays)
435 C | Topography, hydrography, timestep, grid, etc..
436 C |
437 C |--CTRL_UNPACK o Derivative mode. Unpack control vector.
438 C |
439 C |--ADTHE_MAIN_LOOP o Main timestepping loop for combined
440 C | prognostic and reverse mode integration.
441 C |
442 C |--CTRL_PACK o Derivative mode. Unpack control vector.
443 C |
444 C |--GRDCHK_MAIN o Gradient check control routine.
445 C |
446 C |--THE_MAIN_LOOP o Main timestepping loop for pure prognostic
447 C | integration.
448 C |
449 C |--WRITE_CHECKPOINT o Write retsart information.
450 C |
451 C |--TIMER_PRINTALL o Print out timing statistics.
452 C |
453 C |--COMM_STATS o Print out communication statistics.
454
455 C !USES:
456 C == Global variables ===
457
458 use active_module
459
460 use OpenAD_rev
461 use OpenAD_tape
462 use OpenAD_checkpoints
463
464
465 #include "SIZE.h"
466 #include "EEPARAMS.h"
467 #include "PARAMS.h"
468 #include "DYNVARS.h"
469 #include "ctrl.h"
470 #include "cost.h"
471
472 #ifdef ALLOW_AUTODIFF_TAMC
473 # include "tamc.h"
474 #endif
475 #ifdef ALLOW_CTRL
476 # include "optim.h"
477 #endif
478
479 C !INPUT/OUTPUT PARAMETERS:
480 C == Routine arguments ==
481 C myThid - Thread number for this instance of the routine.
482 INTEGER myThid
483
484 C !LOCAL VARIABLES:
485 C == Local variables ==
486 C Note: Under the multi-threaded model myCurrentIter and
487 C myCurrentTime are local variables passed around as routine
488 C arguments. Although this is fiddly it saves the need to
489 C impose additional synchronisation points when they are
490 C updated.
491 C myCurrentTime - Time counter for this thread
492 C myCurrentIter - Iteration counter for this thread
493 INTEGER myCurrentIter
494 _RL myCurrentTime
495 logical exst
496 logical lastdiva
497 _RL foo(1-olx:snx+olx,1-oly:sny+oly,nr,nsx,nsy)
498 CEOP
499 c-- set default:
500 lastdiva = .TRUE.
501
502 c set the execution mode
503 our_rev_mode%arg_store=.FALSE.
504 our_rev_mode%arg_restore=.FALSE.
505 our_rev_mode%res_store=.FALSE.
506 our_rev_mode%res_restore=.FALSE.
507 our_rev_mode%plain=.TRUE.
508 our_rev_mode%tape=.FALSE.
509 our_rev_mode%adjoint=.FALSE.
510 our_rev_mode%switchedToCheckpoint=.FALSE.
511 c initialize the tape
512 call tape_init()
513 c initialize the checkpoint areas
514 call cp_init()
515
516 #ifdef ALLOW_DEBUG
517 IF (debugMode) CALL DEBUG_ENTER('THE_MODEL_MAIN',myThid)
518 #endif
519
520 C-- This timer encompasses the whole code
521 CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid)
522
523 #ifdef ALLOW_DEBUG
524 IF (debugMode) CALL DEBUG_CALL('INITIALISE_FIXED',myThid)
525 #endif
526
527 C-- Set model configuration (fixed arrays)
528 CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
529 CALL OpenAD_INITIALISE_FIXED( myThid )
530 CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
531
532 myCurrentTime = startTime
533 myCurrentIter = nIter0
534
535 #if ( defined (ALLOW_ADMTLM) )
536 c
537 STOP 'should never get here; ADMTLM_DSVD calls ADMTLM_DRIVER'
538 c
539 #elif ( defined (ALLOW_AUTODIFF))
540
541 # ifndef EXCLUDE_CTRL_PACK
542 _BEGIN_MASTER( mythid )
543 IF (myProcId .eq. 0) THEN
544 inquire( file='costfinal', exist=exst )
545 IF ( .NOT. exst ) THEN
546 IF ( optimcycle.NE.0 ) THEN
547 CALL TIMER_START('CTRL_UNPACK [THE_MODEL_MAIN]',mythid)
548 CALL CTRL_UNPACK( .TRUE. , mythid )
549 CALL TIMER_STOP ('CTRL_UNPACK [THE_MODEL_MAIN]',mythid)
550 ENDIF
551 ENDIF
552 ENDIF
553 _END_MASTER( mythid )
554 _BARRIER
555 # endif /* EXCLUDE_CTRL_PACK */
556
557 # ifdef ALLOW_COST
558 CALL COST_DEPENDENT_INIT ( mythid )
559 _BARRIER
560 # endif
561
562 # if ( defined (ALLOW_TANGENTLINEAR_RUN) )
563 c
564 CALL TIMER_START('G_THE_MAIN_LOOP [TANGENT RUN]',mythid)
565 CALL G_THE_MAIN_LOOP ( myCurrentTime, myCurrentIter, myThid )
566 CALL TIMER_STOP ('G_THE_MAIN_LOOP [TANGENT RUN]',mythid)
567 c
568 # elif ( defined (ALLOW_ADJOINT_RUN) || \
569 defined (ALLOW_ECCO_OPTIMIZATION) )
570 c
571 # ifdef ALLOW_DIVIDED_ADJOINT
572 c-- The following assumes the TAF option '-pure'
573 inquire( file='costfinal', exist=exst )
574 IF ( .NOT. exst) THEN
575 CALL TIMER_START('MDTHE_MAIN_LOOP [MD RUN]', mythid)
576 CALL MDTHE_MAIN_LOOP ( myCurrentTime, myCurrentIter, mythid )
577 CALL TIMER_STOP ('MDTHE_MAIN_LOOP [MD RUN]', mythid)
578 CALL COST_FINAL_STORE ( mythid, lastdiva )
579 ELSE
580 CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
581 CALL ADTHE_MAIN_LOOP ( myCurrentTime, myCurrentIter, mythid )
582 CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
583 CALL COST_FINAL_RESTORE ( mythid, lastdiva )
584 ENDIF
585 c--
586 # else /* ALLOW_DIVIDED_ADJOINT undef */
587 CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
588 CALL ADTHE_MAIN_LOOP ( myCurrentTime, myCurrentIter, mythid )
589 cph CALL ADTHE_MAIN_LOOP ( mythid )
590 CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid)
591 # endif /* ALLOW_DIVIDED_ADJOINT */
592 c
593 # else /* forward run only within AD setting */
594
595 #ifdef ALLOW_DEBUG
596 IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid)
597 #endif
598 C-- Call time stepping loop of full model
599 CALL TIMER_START('THE_MAIN_LOOP (F) [THE_MODEL_MAIN]',myThid)
600 our_rev_mode%plain=.FALSE.
601 our_rev_mode%tape=.TRUE.
602 call timeratio()
603 CALL OpenAD_THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid )
604 CALL TIMER_STOP ('THE_MAIN_LOOP (F) [THE_MODEL_MAIN]',myThid)
605 CALL TIMER_START('THE_MAIN_LOOP (A) [THE_MODEL_MAIN]',myThid)
606 our_rev_mode%arg_store=.FALSE.
607 our_rev_mode%arg_restore=.FALSE.
608 our_rev_mode%plain=.FALSE.
609 our_rev_mode%tape=.FALSE.
610 our_rev_mode%adjoint=.TRUE.
611 fc%d=1.0
612 call timeratio()
613 CALL OpenAD_THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid )
614 call timeratio()
615
616 do i1=1-olx,snx+olx
617 do i2=1-oly,sny+oly
618 do i3=1,nr
619 do i4=1,nsx
620 do i5=1,nsy
621 write (*,'(A,5(I3,A),EN26.16E3,A,EN26.16E3)') 'JU: (',
622 +i1,',',i2,',',i3,',',i4,',',i5,') salt/theta ',
623 +xx_salt(i1,i2,i3,i4,i5)%d,'/',xx_theta(i1,i2,i3,i4,i5)%d
624 end do
625 end do
626 end do
627 end do
628 end do
629 foo=xx_theta%d
630 call write_rec_xyz_rl('thetaResult',foo,1,0,1)
631 foo=xx_salt%d
632 call write_rec_xyz_rl('saltResult',foo,1,0,1)
633 our_rev_mode%plain=.TRUE.
634 our_rev_mode%tape=.FALSE.
635 our_rev_mode%adjoint=.FALSE.
636 CALL TIMER_STOP ('THE_MAIN_LOOP (A) [THE_MODEL_MAIN]',myThid)
637
638 # endif
639
640 # ifndef EXCLUDE_CTRL_PACK
641 _BEGIN_MASTER( mythid )
642 IF ( myProcId .eq. 0 .AND. lastdiva ) THEN
643 CALL TIMER_START('CTRL_PACK [THE_MODEL_MAIN]',mythid)
644 call CTRL_PACK( .FALSE. , mythid )
645 CALL TIMER_STOP ('CTRL_PACK [THE_MODEL_MAIN]',mythid)
646 IF ( optimcycle.EQ.0 .AND. mycurrentiter.EQ.niter0 ) THEN
647 CALL TIMER_START('CTRL_PACK [THE_MODEL_MAIN]',mythid)
648 CALL CTRL_PACK( .TRUE. , mythid )
649 CALL TIMER_STOP ('CTRL_PACK [THE_MODEL_MAIN]',mythid)
650 ENDIF
651 ENDIF
652 _END_MASTER( mythid )
653 _BARRIER
654 # endif /* EXCLUDE_CTRL_PACK */
655
656
657 # ifdef ALLOW_GRDCHK
658 IF ( useGrdchk .AND. lastdiva ) THEN
659 CALL TIMER_START('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid)
660 CALL GRDCHK_MAIN( mythid )
661 CALL TIMER_STOP ('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid)
662 _BARRIER
663 ENDIF
664 # endif
665
666 #else /* ALL AD-related undef */
667
668 #ifdef ALLOW_DEBUG
669 IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid)
670 #endif
671 C-- Call time stepping loop of full model
672 CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
673 CALL THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid )
674 CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid)
675
676 #endif /* ALLOW_TANGENTLINEAR_RUN ALLOW_ADJOINT_RUN ALLOW_ADMTLM */
677
678 C-- Final checkpoint (in case the in-loop checkpoint was missed)
679 CALL TIMER_START('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid)
680 CALL PACKAGES_WRITE_PICKUP(
681 I .TRUE., myCurrentTime, myCurrentIter, myThid )
682 CALL WRITE_CHECKPOINT(
683 I .TRUE., myCurrentTime, myCurrentIter, myThid )
684 CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MODEL_MAIN]',myThid)
685
686 CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid)
687
688 #ifdef ALLOW_DIAGNOSTICS
689 IF (useDiagnostics) THEN
690 C Close all diagnostics output files
691 CALL DIAGSTATS_CLOSE_IO( myThid )
692 ENDIF
693 #endif
694
695 #ifdef ALLOW_MNC
696 IF (useMNC) THEN
697 C Close all open NetCDF files
698 _BEGIN_MASTER( mythid )
699 CALL MNC_FILE_CLOSE_ALL( myThid )
700 _END_MASTER( mythid )
701 ENDIF
702 #endif
703
704 C-- Write timer statistics
705 IF ( myThid .EQ. 1 ) THEN
706 CALL TIMER_PRINTALL( myThid )
707 CALL COMM_STATS
708 ENDIF
709
710 #ifdef ALLOW_DEBUG
711 IF (debugMode) CALL DEBUG_LEAVE('THE_MODEL_MAIN',myThid)
712 #endif
713
714 RETURN
715 END

  ViewVC Help
Powered by ViewVC 1.1.22