/[MITgcm]/MITgcm/model/src/the_model_main.F
ViewVC logotype

Diff of /MITgcm/model/src/the_model_main.F

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

revision 1.11 by cnh, Mon Jun 15 05:13:56 1998 UTC revision 1.44 by heimbach, Thu Jan 17 16:55:25 2002 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    C $Name$
3    
4    CBOI
5    C
6    C !TITLE: MITGCM KERNEL CODE SYNOPSIS
7    C !AUTHORS: mitgcm developers ( support@mitgcm.org )
8    C !AFFILIATION: Massachussetts Institute of Technology
9    C !DATE:
10    C !INTRODUCTION: Kernel dynamical routines
11    C This document summarises MITgcm code under the model/ subdirectory.
12    C The code under model/ ( src/ and inc/ ) contains most of
13    C the driver routines for the baseline forms of the kernel equations in the
14    C MITgcm algorithm. Numerical code for much of the baseline forms of
15    C these equations is also under the model/ directory. Other numerical code
16    C used for the kernel equations is contained in packages in the pkg/
17    C directory tree.
18    C Code for 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    | | |
146    C    | | |-INI_TR1      :: Set initial tracer 1 distribution.
147    C    | | |
148    C    | | |-THE_CORRECTION_STEP :: Step forward to next time step.
149    C    | | | |                   :: Here applied to move restart conditions
150    C    | | | |                   :: (saved in mid timestep) to correct level in
151    C    | | | |                   :: time (only used for pre-c35).
152    C    | | | |
153    C    | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure
154    C    | | | |-CORRECTION_STEP    :: Pressure correction to momentum
155    C    | | | |-CYCLE_TRACER       :: Move tracers forward in time.
156    C    | | | |-OBCS_APPLY         :: Open bndy package. see pkg/obcs
157    C    | | | |-SHAP_FILT_APPLY    :: Shapiro filter package. see pkg/shap_filt
158    C    | | | |-ZONAL_FILT_APPLY   :: FFT filter package. see pkg/zonal_filt
159    C    | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing.
160    C    | | | | |-FIND_RHO  :: Find adjacent densities.
161    C    | | | | |-CONVECT   :: Mix static instability.
162    C    | | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
163    C    | | | |
164    C    | | | |-CALC_EXACT_ETA        :: Change SSH to flow divergence.    
165    C    | | |
166    C    | | |-CONVECTIVE_ADJUSTMENT_INI :: Control static instability mixing
167    C    | | | |                         :: Extra time history interactions.
168    C    | | | |                      
169    C    | | | |-FIND_RHO  :: Find adjacent densities.
170    C    | | | |-CONVECT   :: Mix static instability.
171    C    | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
172    C    | | |
173    C    | | |-PACKAGES_INIT_VARIABLES :: Does initialisation of time evolving
174    C    | | | |                       :: package data.
175    C    | | | |
176    C    | | | |-GMREDI_INIT          :: GM package. ( see pkg/gmredi )
177    C    | | | |-KPP_INIT             :: KPP package. ( see pkg/kpp )
178    C    | | | |-KPP_OPEN_DIAGS    
179    C    | | | |-OBCS_INIT_VARIABLES  :: Open bndy. package. ( see pkg/obcs )
180    C    | | | |-AIM_INIT             :: Interm. atmos package. ( see pkg/aim )
181    C    | | | |-CTRL_MAP_INI         :: Control vector package.( see pkg/ctrl )
182    C    | | | |-COST_INIT            :: Cost function package. ( see pkg/cost )
183    C    | | | |-ECCO_INIT            :: ECCO support package. ( see pkg/ecco )
184    C    | | | |-INI_FORCING          :: Set model initial forcing fields.
185    C    | | |   |                    :: Either set in-line or from file as shown.
186    C    | | |   |-READ_FLD_XY_RS(zonalWindFile)
187    C    | | |   |-READ_FLD_XY_RS(meridWindFile)
188    C    | | |   |-READ_FLD_XY_RS(surfQFile)
189    C    | | |   |-READ_FLD_XY_RS(EmPmRfile)
190    C    | | |   |-READ_FLD_XY_RS(thetaClimFile)
191    C    | | |   |-READ_FLD_XY_RS(saltClimFile)
192    C    | | |   |-READ_FLD_XY_RS(surfQswFile)
193    C    | | |
194    C    | | |-CALC_SURF_DR   :: Calculate the new surface level thickness.
195    C    | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
196    C    | | |-UPDATE_CG2D    :: Update 2d conjugate grad. for Free-Surf.
197    C    | | |-STATE_SUMMARY    :: Summarize model prognostic variables.
198    C    | | |-TIMEAVE_STATVARS :: Time averaging package ( see pkg/timeave ).
199    C    | |
200    C    | |-WRITE_STATE      :: Controlling routine for IO to dump model state.
201    C    | | |-WRITE_REC_XYZ_RL :: Single file I/O
202    C    | | |-WRITE_FLD_XYZ_RL :: Multi-file I/O
203    C    | |
204    C    | |-MONITOR          :: Monitor state ( see pkg/monitor )
205    C    | |-CTRL_MAP_FORCING :: Control vector support package. ( see pkg/ctrl )
206    C====|>|
207    C====|>| ****************************
208    C====|>| BEGIN MAIN TIMESTEPPING LOOP
209    C====|>| ****************************
210    C====|>|
211    C/\  | |-FORWARD_STEP     :: Step forward a time-step ( AT LAST !!! )
212    C/\  | | |
213    C/\  | | |-DUMMY_IN_STEPPING :: autodiff package ( pkg/autoduff ).
214    C/\  | | |-CALC_EXACT_ETA :: Change SSH to flow divergence.
215    C/\  | | |-CALC_SURF_DR   :: Calculate the new surface level thickness.
216    C/\  | | |-EXF_GETFORCING :: External forcing package. ( pkg/exf )
217    C/\  | | |-EXTERNAL_FIELDS_LOAD :: Control loading time dep. external data.
218    C/\  | | | |                    :: Simple interpolcation between end-points
219    C/\  | | | |                    :: for forcing datasets.
220    C/\  | | | |                  
221    C/\  | | | |-EXCH :: Sync forcing. in overlap regions.
222    C/\  | | |
223    C/\  | | |-THERMODYNAMICS :: theta, salt + tracer equations driver.
224    C/\  | | | |
225    C/\  | | | |-INTEGRATE_FOR_W :: Integrate for vertical velocity.
226    C/\  | | | |-OBCS_APPLY_W    :: Open bndy. package ( see pkg/obcs ).
227    C/\  | | | |-FIND_RHO        :: Calculates [rho(S,T,z)-Rhonil] of a slice
228    C/\  | | | |-GRAD_SIGMA      :: Calculate isoneutral gradients
229    C/\  | | | |-CALC_IVDC       :: Set Implicit Vertical Diffusivity for Convection
230    C/\  | | | |
231    C/\  | | | |-OBCS_CALC            :: Open bndy. package ( see pkg/obcs ).
232    C/\  | | | |-EXTERNAL_FORCING_SURF:: Accumulates appropriately dimensioned
233    C/\  | | | |                      :: forcing terms.
234    C/\  | | | |
235    C/\  | | | |-GMREDI_CALC_TENSOR   :: GM package ( see pkg/gmredi ).
236    C/\  | | | |-GMREDI_CALC_TENSOR_DUMMY :: GM package ( see pkg/gmredi ).
237    C/\  | | | |-KPP_CALC             :: KPP package ( see pkg/kpp ).
238    C/\  | | | |-KPP_CALC_DUMMY       :: KPP package ( see pkg/kpp ).
239    C/\  | | | |-AIM_DO_ATMOS_PHYSICS :: Intermed. atmos package ( see pkg/aim ).
240    C/\  | | | |-GAD_ADVECTION        :: Generalised advection driver (multi-dim
241    C/\  | | | |                         advection case) (see pkg/gad).
242    C/\  | | | |-CALC_COMMON_FACTORS  :: Calculate common data (such as volume flux)
243    C/\  | | | |-CALC_DIFFUSIVITY     :: Calculate net vertical diffusivity
244    C/\  | | | | |
245    C/\  | | | | |-GMREDI_CALC_DIFF   :: GM package ( see pkg/gmredi ).
246    C/\  | | | | |-KPP_CALC_DIFF      :: KPP package ( see pkg/kpp ).
247    C/\  | | | |
248    C/\  | | | |-CALC_GT              :: Calculate the temperature tendency terms
249    C/\  | | | | |
250    C/\  | | | | |-GAD_CALC_RHS       :: Generalised advection package
251    C/\  | | | | |                    :: ( see pkg/gad )
252    C/\  | | | | |-EXTERNAL_FORCING_T :: Problem specific forcing for temperature.
253    C/\  | | | | |-ADAMS_BASHFORTH2   :: Extrapolate tendencies forward in time.
254    C/\  | | | | |-FREESURF_RESCALE_G :: Re-scale Gt for free-surface height.
255    C/\  | | | |
256    C/\  | | | |-TIMESTEP_TRACER      :: Step tracer field forward in time
257    C/\  | | | |
258    C/\  | | | |-CALC_GS              :: Calculate the salinity tendency terms
259    C/\  | | | | |
260    C/\  | | | | |-GAD_CALC_RHS       :: Generalised advection package
261    C/\  | | | | |                    :: ( see pkg/gad )
262    C/\  | | | | |-EXTERNAL_FORCING_S :: Problem specific forcing for salt.
263    C/\  | | | | |-ADAMS_BASHFORTH2   :: Extrapolate tendencies forward in time.
264    C/\  | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
265    C/\  | | | |
266    C/\  | | | |-TIMESTEP_TRACER      :: Step tracer field forward in time
267    C/\  | | | |
268    C/\  | | | |-CALC_GTR1            :: Calculate other tracer(s) tendency terms
269    C/\  | | | | |
270    C/\  | | | | |-GAD_CALC_RHS       :: Generalised advection package
271    C/\  | | | | |                    :: ( see pkg/gad )
272    C/\  | | | | |-EXTERNAL_FORCING_TR:: Problem specific forcing for tracer.
273    C/\  | | | | |-ADAMS_BASHFORTH2   :: Extrapolate tendencies forward in time.
274    C/\  | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height.
275    C/\  | | | |
276    C/\  | | | |-TIMESTEP_TRACER      :: Step tracer field forward in time
277    C/\  | | | |-OBCS_APPLY_TS        :: Open bndy. package (see pkg/obcs ).
278    C/\  | | | |-FREEZE               :: Limit range of temperature.
279    C/\  | | | |
280    C/\  | | | |-IMPLDIFF             :: Solve vertical implicit diffusion equation.
281    C/\  | | | |-OBCS_APPLY_TS        :: Open bndy. package (see pkg/obcs ).
282    C/\  | | | |
283    C/\  | | | |-AIM_AIM2DYN_EXCHANGES :: Inetermed. atmos (see pkg/aim).
284    C/\  | | | |-EXCH                 :: Update overlaps
285    C/\  | | |
286    C/\  | | |-DYNAMICS       :: Momentum equations driver.
287    C/\  | | | |
288    C/\  | | | |-CALC_GRAD_PHI_SURF :: Calculate the gradient of the surface
289    C/\  | | | |                       Potential anomaly.
290    C/\  | | | |-CALC_VISCOSITY     :: Calculate net vertical viscosity
291    C/\  | | | | |-KPP_CALC_VISC    :: KPP package ( see pkg/kpp ).
292    C/\  | | | |                                                      
293    C/\  | | | |-CALC_PHI_HYD       :: Integrate the hydrostatic relation.
294    C/\  | | | |-MOM_FLUXFORM       :: Flux form mom eqn. package ( see
295    C/\  | | | |                       pkg/mom_fluxform ).
296    C/\  | | | |-MOM_VECINV         :: Vector invariant form mom eqn. package ( see
297    C/\  | | | |                       pkg/mom_vecinv   ).
298    C/\  | | | |-TIMESTEP           :: Step momentum fields forward in time
299    C/\  | | | |-OBCS_APPLY_UV      :: Open bndy. package (see pkg/obcs ).
300    C/\  | | | |
301    C/\  | | | |-IMPLDIFF           :: Solve vertical implicit diffusion equation.
302    C/\  | | | |-OBCS_APPLY_UV      :: Open bndy. package (see pkg/obcs ).
303    C/\  | | | |
304    C/\  | | | |-TIMEAVE_CUMUL_1T   :: Time averaging package ( see pkg/timeave ).
305    C/\  | | | |-TIMEAVE_CUMUATE    :: Time averaging package ( see pkg/timeave ).
306    C/\  | | | |-DEBUG_STATS_RL     :: Quick debug package ( see pkg/debug ).
307    C/\  | | |
308    C/\  | | |-CALC_GW        :: vert. momentum tendency terms ( NH, QH only ).
309    C/\  | | |
310    C/\  | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction.
311    C/\  | | |
312    C/\  | | |-UPDATE_CG2D    :: Update 2d conjugate grad. for Free-Surf.
313    C/\  | | |
314    C/\  | | |-SOLVE_FOR_PRESSURE           :: Find surface pressure.
315    C/\  | | | |-CALC_DIV_GHAT     :: Form the RHS of the surface pressure eqn.
316    C/\  | | | |-CG2D              :: Two-dim pre-con. conjugate-gradient.
317    C/\  | | | |-CG3D              :: Three-dim pre-con. conjugate-gradient solver.
318    C/\  | | |
319    C/\  | | |-THE_CORRECTION_STEP          :: Step forward to next time step.
320    C/\  | | | |
321    C/\  | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure
322    C/\  | | | |-CORRECTION_STEP    :: Pressure correction to momentum
323    C/\  | | | |-CYCLE_TRACER       :: Move tracers forward in time.
324    C/\  | | | |-OBCS_APPLY         :: Open bndy package. see pkg/obcs
325    C/\  | | | |-SHAP_FILT_APPLY    :: Shapiro filter package. see pkg/shap_filt
326    C/\  | | | |-ZONAL_FILT_APPLY   :: FFT filter package. see pkg/zonal_filt
327    C/\  | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing.
328    C/\  | | | | |-FIND_RHO  :: Find adjacent densities.
329    C/\  | | | | |-CONVECT   :: Mix static instability.
330    C/\  | | | | |-TIMEAVE_CUMULATE :: Update convection statistics.
331    C/\  | | | |
332    C/\  | | | |-CALC_EXACT_ETA        :: Change SSH to flow divergence.    
333    C/\  | | |
334    C/\  | | |-DO_FIELDS_BLOCKING_EXCHANGES :: Sync up overlap regions.
335    C/\  | | | |-EXCH                                                  
336    C/\  | | |
337    C/\  | | |-FLT_MAIN         :: Float package ( pkg/flt ).
338    C/\  | | |
339    C/\  | | |-MONITOR          :: Monitor package ( pkg/monitor ).
340    C/\  | | |
341    C/\  | | |-DO_THE_MODEL_IO  :: Standard diagnostic I/O.
342    C/\  | | | |-WRITE_STATE    :: Core state I/O
343    C/\  | | | |-TIMEAVE_STATV_WRITE :: Time averages. see pkg/timeave
344    C/\  | | | |-AIM_WRITE_DIAGS     :: Intermed. atmos diags. see pkg/aim
345    C/\  | | | |-GMREDI_DIAGS        :: GM diags. see pkg/gmredi
346    C/\  | | | |-KPP_DO_DIAGS        :: KPP diags. see pkg/kpp
347    C/\  | | |
348    C/\  | | |-WRITE_CHECKPOINT :: Do I/O for restart files.
349    C/\  | |
350    C/\  | |-COST_TILE        :: Cost function package. ( see pkg/cost )
351    C<===|=|
352    C<===|=| **************************
353    C<===|=| END MAIN TIMESTEPPING LOOP
354    C<===|=| **************************
355    C<===|=|
356    C    | |-COST_FINAL       :: Cost function package. ( see pkg/cost )
357    C    |
358    C    |-WRITE_CHECKPOINT :: Final state storage, for restart.
359    C    |
360    C    |-TIMER_PRINTALL :: Computational timing summary
361    C    |
362    C    |-COMM_STATS     :: Summarise inter-proc and inter-thread communication
363    C                     :: events.
364    C \ev
365    C
366    C
367    CEOI
368    
 #include "CPP_EEOPTIONS.h"  
369    
370    #include "CPP_OPTIONS.h"
371    
372    CBOP
373    
374    C     !ROUTINE: THE_MODEL_MAIN
375    
376    C     !INTERFACE:
377        SUBROUTINE THE_MODEL_MAIN(myThid)        SUBROUTINE THE_MODEL_MAIN(myThid)
378  C     /==========================================================\        IMPLICIT NONE
379  C     | SUBROUTINE THE_MODEL_MAIN                                |  
380  C     | o Master controlling routine for model using the MITgcm  |  C     !DESCRIPTION: \bv
381  C     |   UV parallel wrapper.                                   |  C     *==========================================================*
382  C     |==========================================================|  C     | SUBROUTINE THE_MODEL_MAIN                                
383  C     | THE_MODEL_MAIN is invoked by the MITgcm UV parallel      |  C     | o Master controlling routine for model using the MITgcm  
384  C     | wrapper with a single integer argument "myThid". This    |  C     |   UV parallel wrapper.                                    
385  C     | variable identifies the thread number of an instance of  |  C     *==========================================================*
386  C     | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works    |  C     | THE_MODEL_MAIN is invoked by the MITgcm UV parallel      
387  C     | on a particular region of the models domain and          |  C     | wrapper with a single integer argument "myThid". This    
388  C     | synchronises with other instances as necessary. The      |  C     | variable identifies the thread number of an instance of  
389  C     | routine has to "understand" the MITgcm parallel          |  C     | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works    
390  C     | environment and the numerical algorithm. Editing this    |  C     | on a particular region of the models domain and          
391  C     | routine is best done with some knowledge of both aspects.|  C     | synchronises with other instances as necessary. The      
392  C     | Notes                                                    |  C     | routine has to "understand" the MITgcm parallel          
393  C     | =====                                                    |  C     | environment and the numerical algorithm. Editing this    
394  C     | C*P* comments indicating place holders for which code is |  C     | routine is best done with some knowledge of both aspects.
395  C     |      presently being developed.                          |  C     | Notes                                                    
396  C     \==========================================================/  C     | =====                                                    
397  C  C     | C*P* comments indicating place holders for which code is  
398  C     Call Tree  C     |      presently being developed.                          
399  C     =========  C     *==========================================================*
400  C      C     \ev
401  C      main ( eesupp )  
402  C       |  C     !CALLING SEQUENCE:
403  C       .  C     THE_MODEL_MAIN()
404  C       .  C       |
405  C       . Generic environment initialisation ( see eesupp/src and  C       |
406  C       .                                      eesupp/inc )        C       |--INITIALISE_FIXED
407  C       . multiple threads and/or processes are created in here  C       |   o Set model configuration (fixed arrays)
408  C       .  C       |     Topography, hydrography, timestep, grid, etc..
409  C       .  C       |
410  C       .  C       |--CTRL_UNPACK      o Derivative mode. Unpack control vector.
411  C       |  C       |
412  C       |-THE_MODEL_MAIN - Begin specific model. One instance  C       |--ADTHE_MAIN_LOOP  o Main timestepping loop for combined
413  C       |  |               of this codes exists for each thread  C       |                     prognostic and reverse mode integration.
414  C       |  |               and/or instance. Each instance manages  C       |
415  C       |  |               a specifc set of tiles.                C       |--CTRL_PACK        o Derivative mode. Unpack control vector.
416  C       |  |  C       |
417  C       |  |--INITIALISE  C       |--GRDCHK_MAIN      o Gradient check control routine.
418  C       |  |   o Set initial conditions and model configuration  C       |
419  C       |  |     Topography, hydrography, timestep, grid, etc..  C       |--THE_MAIN_LOOP    o Main timestepping loop for pure prognostic
420  C       |  |  C       |                     integration.
421  C  ==>  |  | ** Time stepping loop starts here **  C       |
422  C  |    |  |  C       |--WRITE_CHECKPOINT o Write retsart information.
423  C /|\   |  |  C       |
424  C  |    |  |--LOAD_EXTERNAL_DATA  C       |--TIMER_PRINTALL   o Print out timing statistics.
425  C /|\   |  |   o Load and/or set time dependent forcing fields  C       |
426  C  |    |  |  C       |--COMM_STATS       o Print out communication statistics.
 C /|\   |  |--DYNAMICS  
 C  |    |  |   o Evaluate "forward" terms  
 C /|\   |  |  
 C  |    |  |--DO_THE_MODEL_IO  
 C /|\   |  |   o Write model state  
 C  |    |  |  
 C /|\   |  |--SOLVE_FOR_PRESSURE  
 C  |    |  |   o Find pressure field to keep flow non-divergent  
 C /|\   |  |  
 C  |    |  |--DO_GTERM_BLOCKING_EXCHANGES  
 C /|\   |  |   o Update overlap regions  
 C  |    |  |  
 C /|\   |  |--WRITE_CHECKPOINT  
 C  |    |  |   o Write restart file(s)  
 C /|\   |  |  
 C  |    |  |  
 C  |<== |  | ** Time stepping loop finishes here **  
 C       |  |  
 C       |  |--WRITE_STATE  
 C       |  |--WRITE_CHECKPOINT  
 C       |  
 C       .  
 C       .  
 C       . Generic environment termination ( see eesupp/src and  
 C       .                                      eesupp/inc )        
 C       .  
 C       .  
427    
428    C     !USES:
429  C     == Global variables ===  C     == Global variables ===
430  #include "SIZE.h"  #include "SIZE.h"
431  #include "EEPARAMS.h"  #include "EEPARAMS.h"
432  #include "PARAMS.h"  #include "PARAMS.h"
 #include "CG2D.h"  
433  #include "DYNVARS.h"  #include "DYNVARS.h"
434    #ifdef ALLOW_NONHYDROSTATIC
435    #include "CG3D.h"
436    #endif
437    
438    #ifdef ALLOW_AUTODIFF_TAMC
439    #include "tamc.h"
440    #endif
441    
442    C     !INPUT/OUTPUT PARAMETERS:
443  C     == Routine arguments ==  C     == Routine arguments ==
444  C     myThid - Thread number for this instance of the routine.  C     myThid - Thread number for this instance of the routine.
445        INTEGER myThid          INTEGER myThid  
446    
447    C     !LOCAL VARIABLES:
448  C     == Local variables ==  C     == Local variables ==
449  C     Note: Under the multi-threaded model myCurrentIter and  C     Note: Under the multi-threaded model myCurrentIter and
450  C           myCurrentTime are local variables passed around as routine  C           myCurrentTime are local variables passed around as routine
451  C           arguments. Although this is fiddly it saves the need to  C           arguments. Although this is fiddly it saves the need to
452  C           impose additional synchronisation points when they are  C           impose additional synchronisation points when they are
453  C           updated.  C           updated.
 C     myCurrentIter - Iteration counter for this thread  
454  C     myCurrentTime - Time counter for this thread  C     myCurrentTime - Time counter for this thread
455  C     I             - Loop counter  C     myCurrentIter - Iteration counter for this thread
456        INTEGER I, myCurrentIter        INTEGER I
457        REAL    myCurrentTime        INTEGER bi,bj
458          INTEGER myCurrentIter
459          _RL     myCurrentTime
460    CEOP
461    
462    C--   This timer encompasses the whole code
463          CALL TIMER_START('ALL                [THE_MODEL_MAIN]',myThid)
464    
465    C--   Set model configuration (fixed arrays)
466          CALL TIMER_START('INITIALISE_FIXED   [THE_MODEL_MAIN]',myThid)
467          CALL INITIALISE_FIXED( myThid )
468          CALL TIMER_STOP ('INITIALISE_FIXED   [THE_MODEL_MAIN]',myThid)
469    
 C--   Set model initial conditions  
       CALL INITIALISE( myThid )  
470        myCurrentTime = startTime        myCurrentTime = startTime
471        myCurrentIter = nIter0        myCurrentIter = nIter0
472    
473  C--   Begin time stepping loop  #if ( defined (ALLOW_ADJOINT_RUN) || \
474        DO I=1, nTimeSteps        defined (ALLOW_GRADIENT_CHECK) || \
475          defined (ALLOW_ECCO_OPTIMIZATION) )
476  C--    Load forcing/external data fields  
477         CALL LOAD_EXTERNAL_FIELDS( myCurrentTime, myCurrentIter, myThid )        _BEGIN_MASTER( mythid )
478          IF (myProcId .eq. 0) THEN
479  C--    Step forward fields and calculate time tendency terms           CALL CTRL_UNPACK( mycurrentiter, mycurrenttime, mythid )
480         CALL DYNAMICS( myCurrentTime, myCurrentIter, myThid )        ENDIF
481          _END_MASTER( mythid )
482  C--    Do IO if needed.        _BARRIER
483  C      Note:  
484  C      =====        CALL COST_DEPENDENT_INIT ( mythid )
485  C      At this point model arrays hold U,V,T,S  at "time-level" N        _BARRIER
486  C      and cg2d_x at "time-level" N-1/2 where N = I+timeLevBase-1.  
487  C      By convention this is taken to be the model "state".        CALL TIMER_START('ADTHE_MAIN_LOOP          [ADJOINT RUN]', mythid)
488         CALL DO_THE_MODEL_IO( myCurrentTime, myCurrentIter, myThid )        CALL ADTHE_MAIN_LOOP ( mythid )
489          CALL TIMER_STOP ('ADTHE_MAIN_LOOP          [ADJOINT RUN]', mythid)
490  C--    Solve elliptic equation(s).        _BARRIER
491  C      Two-dimensional only for conventional hydrostatic or  
492  C      three-dimensional for non-hydrostatic and/or IGW scheme.        _BEGIN_MASTER( mythid )
493         CALL SOLVE_FOR_PRESSURE( myThid )        IF (myProcId .eq. 0) THEN
494             call CTRL_PACK( mycurrentiter, mycurrenttime, mythid )
495  C--    Do "blocking" sends and receives for tendency "overlap" terms        ENDIF
496         CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )        _END_MASTER( mythid )
497          _BARRIER
498         myCurrentIter = myCurrentIter + 1  
499         myCurrentTime = myCurrentTime + deltaTClock  #ifdef ALLOW_GRADIENT_CHECK
500          if (useGrdchk) then
501  C--    Save state for restarts           CALL TIMER_START('GRDCHK_MAIN          [ADJOINT RUN]', mythid)
502  C      Note:           CALL GRDCHK_MAIN( mythid )
503  C      =====           CALL TIMER_STOP ('GRDCHK_MAIN          [ADJOINT RUN]', mythid)
504  C      Because of the ordereing of the timestepping code and           _BARRIER
505  C      tendency term code at end of loop model arrays hold        end if
506  C      U,V,T,S  at "time-level" N but gu, gv, gs, gt, guNM1,...  #endif
507  C      at "time-level" N+1/2 (guNM1 at "time-level" N+1/2 is  
508  C      gu at "time-level" N-1/2) and cg2d_x at "time-level" N+1/2.  #elif (defined (ALLOW_TANGENTLINEAR_RUN))
509  C       where N = I+timeLevBase-1  
510  C      Thus a checkpoint contains U.0000000000, GU.0000000001 and        _BEGIN_MASTER( mythid )
511  C      cg2d_x.0000000001 in the indexing scheme used for the model        IF (myProcId .eq. 0) THEN
512  C      "state" files. This example is referred to as a checkpoint           CALL CTRL_UNPACK( mycurrentiter, mycurrenttime, mythid )
513  C      at time level 1        ENDIF
514         CALL WRITE_CHECKPOINT( .FALSE., myCurrentTime, myCurrentIter, myThid )        _END_MASTER( mythid )
515          _BARRIER
516        ENDDO  
517          CALL COST_DEPENDENT_INIT ( mythid )
518  C--   Dump for end state and final checkpoint        _BARRIER
519        CALL WRITE_STATE( myCurrentTime, myCurrentIter, myThid )  
520        CALL WRITE_CHECKPOINT( .TRUE., myCurrentTime, myCurrentIter, myThid )        CALL TIMER_START('G_THE_MAIN_LOOP          [FTL RUN]', mythid)
521          CALL G_THE_MAIN_LOOP ( myCurrentTime, myCurrentIter, myThid )
522          CALL TIMER_STOP ('G_THE_MAIN_LOOP          [FTL RUN]', mythid)
523          _BARRIER
524    
525          _BEGIN_MASTER( mythid )
526          IF (myProcId .eq. 0) THEN
527             call CTRL_PACK( mycurrentiter, mycurrenttime, mythid )
528          ENDIF
529          _END_MASTER( mythid )
530          _BARRIER
531    
532    #else /* ALLOW_ADJOINT_RUN undef */
533    
534    C--   Call time stepping loop of full model
535          CALL TIMER_START('THE_MAIN_LOOP      [THE_MODEL_MAIN]',myThid)
536          CALL THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid )
537          CALL TIMER_STOP ('THE_MAIN_LOOP      [THE_MODEL_MAIN]',myThid)
538    
539    #endif /* ALLOW_ADJOINT_RUN */
540    
541    C--   Final checkpoint (incase the in-loop checkpoint was missed)
542          CALL TIMER_START('WRITE_CHECKPOINT   [THE_MODEL_MAIN]',myThid)
543          CALL WRITE_CHECKPOINT(
544         &        .TRUE., myCurrentTime, myCurrentIter, myThid )
545          CALL TIMER_STOP ('WRITE_CHECKPOINT   [THE_MODEL_MAIN]',myThid)
546    
547          CALL TIMER_STOP ('ALL                [THE_MODEL_MAIN]',myThid)
548    
549    C--   Write timer statistics
550          IF ( myThid .EQ. 1 ) THEN
551           CALL TIMER_PRINTALL( myThid )
552           CALL COMM_STATS
553          ENDIF
554    
555        RETURN        RETURN
556        END        END

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.44

  ViewVC Help
Powered by ViewVC 1.1.22