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

Annotation of /MITgcm_contrib/heimbach/OpenAD/code_shallow_openad/the_model_main.F

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


Revision 1.15 - (hide annotations) (download)
Thu Dec 19 16:09:59 2013 UTC (12 years, 10 months ago) by utke
Branch: MAIN
CVS Tags: HEAD
Changes since 1.14: +1 -1 lines
FILE REMOVED
stale

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

  ViewVC Help
Powered by ViewVC 1.1.22