| 1 |
utke |
1.2 |
C $Header: /u/gcmpack/MITgcm_contrib/heimbach/OpenAD/code_ad_moc/the_model_main.F,v 1.1 2008/09/15 22:16:01 utke Exp $ |
| 2 |
utke |
1.1 |
|
| 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 invocation routine. On entry |
| 37 |
|
|
C | :: to THE_MODEL_MAIN separate thread and |
| 38 |
|
|
C | :: separate processes will have been established. |
| 39 |
|
|
C | :: Each thread and process will have a unique ID |
| 40 |
|
|
C | :: but as yet it will not be associated with a |
| 41 |
|
|
C | :: specific region in decomposed discrete space. |
| 42 |
|
|
C | |
| 43 |
|
|
C |-INITIALISE_FIXED :: Set fixed model arrays such as topography, |
| 44 |
|
|
C | | :: grid, solver matrices etc.. |
| 45 |
|
|
C | | |
| 46 |
|
|
C | |-INI_PARMS :: Routine to set kernel model parameters. |
| 47 |
|
|
C | | :: By default kernel parameters are read from file |
| 48 |
|
|
C | | :: "data" in directory in which code executes. |
| 49 |
|
|
C | | |
| 50 |
|
|
C | |-MON_INIT :: Initializes monitor package ( see pkg/monitor ) |
| 51 |
|
|
C | | |
| 52 |
|
|
C | |-INI_GRID :: Control grid array (vert. and hori.) initialization. |
| 53 |
|
|
C | | | :: Grid arrays are held and described in GRID.h. |
| 54 |
|
|
C | | | |
| 55 |
|
|
C | | |-INI_VERTICAL_GRID :: Initialize vertical grid arrays. |
| 56 |
|
|
C | | | |
| 57 |
|
|
C | | |-INI_CARTESIAN_GRID :: Cartesian horiz. grid initialization |
| 58 |
|
|
C | | | :: (calculate grid from kernel parameters). |
| 59 |
|
|
C | | | |
| 60 |
|
|
C | | |-INI_SPHERICAL_POLAR_GRID :: Spherical polar horiz. grid |
| 61 |
|
|
C | | | :: initialization (calculate grid from |
| 62 |
|
|
C | | | :: kernel parameters). |
| 63 |
|
|
C | | | |
| 64 |
|
|
C | | |-INI_CURVILINEAR_GRID :: General orthogonal, structured horiz. |
| 65 |
|
|
C | | :: grid initializations. ( 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 options 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 initialization. |
| 110 |
|
|
C | | |
| 111 |
|
|
C | |-INI_CG3D :: 3d con. grad solver initialization. |
| 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 generated 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 options are coded. |
| 135 |
|
|
C | | | |
| 136 |
|
|
C | | |-INI_CG2D :: 2d con. grad solver initialization. |
| 137 |
|
|
C | | |-INI_CG3D :: 3d con. grad solver initialization. |
| 138 |
|
|
C | | |-INI_MIXING :: Initialize diapycnal diffusivity. |
| 139 |
|
|
C | | |-INI_DYNVARS :: Initialize to zero all DYNVARS.h arrays (dynamical |
| 140 |
|
|
C | | | :: fields). |
| 141 |
|
|
C | | | |
| 142 |
|
|
C | | |-INI_FIELDS :: Control initializing 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 initialization 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 interpolation 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/\ | | | | | tendency 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_CALC_VISC :: Calculate Horizontal Viscosities |
| 314 |
|
|
C/\ | | | |-MOM_VECINV :: Vector invariant form mom eqn. package ( see |
| 315 |
|
|
C/\ | | | | pkg/mom_vecinv ). |
| 316 |
|
|
C/\ | | | | |-MOM_CALC_VISC :: Calculate Horizontal Viscosities |
| 317 |
|
|
C/\ | | | |-TIMESTEP :: Step momentum fields forward in time |
| 318 |
|
|
C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ). |
| 319 |
|
|
C/\ | | | | |
| 320 |
|
|
C/\ | | | |-IMPLDIFF :: Solve vertical implicit diffusion equation. |
| 321 |
|
|
C/\ | | | |-OBCS_APPLY_UV :: Open bndy. package (see pkg/obcs ). |
| 322 |
|
|
C/\ | | | | |
| 323 |
|
|
C/\ | | | |-TIMEAVE_CUMUL_1T :: Time averaging package ( see pkg/timeave ). |
| 324 |
|
|
C/\ | | | |-TIMEAVE_CUMUATE :: Time averaging package ( see pkg/timeave ). |
| 325 |
|
|
C/\ | | | |-DEBUG_STATS_RL :: Quick debug package ( see pkg/debug ). |
| 326 |
|
|
C/\ | | | |
| 327 |
|
|
C/\ | | |-CALC_GW :: vert. momentum tendency terms ( NH, QH only ). |
| 328 |
|
|
C/\ | | | |
| 329 |
|
|
C/\ | | |-UPDATE_SURF_DR :: Update the surface-level thickness fraction. |
| 330 |
|
|
C/\ | | | |
| 331 |
|
|
C/\ | | |-UPDATE_CG2D :: Update 2d conjugate grad. for Free-Surf. |
| 332 |
|
|
C/\ | | | |
| 333 |
|
|
C/\ | | |-SOLVE_FOR_PRESSURE :: Find surface pressure. |
| 334 |
|
|
C/\ | | | |-CALC_DIV_GHAT :: Form the RHS of the surface pressure eqn. |
| 335 |
|
|
C/\ | | | |-CG2D :: Two-dim pre-con. conjugate-gradient. |
| 336 |
|
|
C/\ | | | |-CG3D :: Three-dim pre-con. conjugate-gradient solver. |
| 337 |
|
|
C/\ | | | |
| 338 |
|
|
C/\ | | |-THE_CORRECTION_STEP :: Step forward to next time step. |
| 339 |
|
|
C/\ | | | | |
| 340 |
|
|
C/\ | | | |-CALC_GRAD_PHI_SURF :: Return DDx and DDy of surface pressure |
| 341 |
|
|
C/\ | | | |-CORRECTION_STEP :: Pressure correction to momentum |
| 342 |
|
|
C/\ | | | |-CYCLE_TRACER :: Move tracers forward in time. |
| 343 |
|
|
C/\ | | | |-OBCS_APPLY :: Open bndy package. see pkg/obcs |
| 344 |
|
|
C/\ | | | |-SHAP_FILT_APPLY :: Shapiro filter package. see pkg/shap_filt |
| 345 |
|
|
C/\ | | | |-ZONAL_FILT_APPLY :: FFT filter package. see pkg/zonal_filt |
| 346 |
|
|
C/\ | | | |-CONVECTIVE_ADJUSTMENT :: Control static instability mixing. |
| 347 |
|
|
C/\ | | | | |-FIND_RHO :: Find adjacent densities. |
| 348 |
|
|
C/\ | | | | |-CONVECT :: Mix static instability. |
| 349 |
|
|
C/\ | | | | |-TIMEAVE_CUMULATE :: Update convection statistics. |
| 350 |
|
|
C/\ | | | | |
| 351 |
|
|
C/\ | | | |-CALC_EXACT_ETA :: Change SSH to flow divergence. |
| 352 |
|
|
C/\ | | | |
| 353 |
|
|
C/\ | | |-DO_FIELDS_BLOCKING_EXCHANGES :: Sync up overlap regions. |
| 354 |
|
|
C/\ | | | |-EXCH |
| 355 |
|
|
C/\ | | | |
| 356 |
|
|
C/\ | | |-GCHEM_FORCING_SEP :: tracer forcing for gchem pkg (if |
| 357 |
|
|
C/\ | | | tracer dependent tendencies calculated |
| 358 |
|
|
C/\ | | | separatly) |
| 359 |
|
|
C/\ | | | |
| 360 |
|
|
C/\ | | |-FLT_MAIN :: Float package ( pkg/flt ). |
| 361 |
|
|
C/\ | | | |
| 362 |
|
|
C/\ | | |-MONITOR :: Monitor package ( pkg/monitor ). |
| 363 |
|
|
C/\ | | | |
| 364 |
|
|
C/\ | | |-DO_THE_MODEL_IO :: Standard diagnostic I/O. |
| 365 |
|
|
C/\ | | | |-WRITE_STATE :: Core state I/O |
| 366 |
|
|
C/\ | | | |-TIMEAVE_STATV_WRITE :: Time averages. see pkg/timeave |
| 367 |
|
|
C/\ | | | |-AIM_WRITE_DIAGS :: Intermed. atmos diags. see pkg/aim |
| 368 |
|
|
C/\ | | | |-GMREDI_DIAGS :: GM diags. see pkg/gmredi |
| 369 |
|
|
C/\ | | | |-KPP_DO_DIAGS :: KPP diags. see pkg/kpp |
| 370 |
|
|
C/\ | | | |-SBO_CALC :: SBO diags. see pkg/sbo |
| 371 |
|
|
C/\ | | | |-SBO_DIAGS :: SBO diags. see pkg/sbo |
| 372 |
|
|
C/\ | | | |-SEAICE_DO_DIAGS :: SEAICE diags. see pkg/seaice |
| 373 |
|
|
C/\ | | | |-GCHEM_DIAGS :: gchem diags. see pkg/gchem |
| 374 |
|
|
C/\ | | | |
| 375 |
|
|
C/\ | | |-WRITE_CHECKPOINT :: Do I/O for restart files. |
| 376 |
|
|
C/\ | | |
| 377 |
|
|
C/\ | |-COST_TILE :: Cost function package. ( see pkg/cost ) |
| 378 |
|
|
C<===|=| |
| 379 |
|
|
C<===|=| ************************** |
| 380 |
|
|
C<===|=| END MAIN TIMESTEPPING LOOP |
| 381 |
|
|
C<===|=| ************************** |
| 382 |
|
|
C<===|=| |
| 383 |
|
|
C | |-COST_FINAL :: Cost function package. ( see pkg/cost ) |
| 384 |
|
|
C | |
| 385 |
|
|
C |-WRITE_CHECKPOINT :: Final state storage, for restart. |
| 386 |
|
|
C | |
| 387 |
|
|
C |-TIMER_PRINTALL :: Computational timing summary |
| 388 |
|
|
C | |
| 389 |
|
|
C |-COMM_STATS :: Summarise inter-proc and inter-thread communication |
| 390 |
|
|
C :: events. |
| 391 |
|
|
C |
| 392 |
|
|
C \ev |
| 393 |
|
|
C |
| 394 |
|
|
C |
| 395 |
|
|
CEOI |
| 396 |
|
|
|
| 397 |
|
|
|
| 398 |
|
|
#include "AD_CONFIG.h" |
| 399 |
|
|
#include "PACKAGES_CONFIG.h" |
| 400 |
|
|
#include "CPP_OPTIONS.h" |
| 401 |
|
|
|
| 402 |
|
|
CBOP |
| 403 |
|
|
|
| 404 |
|
|
C !ROUTINE: THE_MODEL_MAIN |
| 405 |
|
|
|
| 406 |
|
|
C !INTERFACE: |
| 407 |
|
|
SUBROUTINE THE_MODEL_MAIN(myThid) |
| 408 |
|
|
IMPLICIT NONE |
| 409 |
|
|
|
| 410 |
|
|
C !DESCRIPTION: \bv |
| 411 |
|
|
C *==========================================================* |
| 412 |
|
|
C | SUBROUTINE THE_MODEL_MAIN |
| 413 |
|
|
C | o Master controlling routine for model using the MITgcm |
| 414 |
|
|
C | UV parallel wrapper. |
| 415 |
|
|
C *==========================================================* |
| 416 |
|
|
C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel |
| 417 |
|
|
C | wrapper with a single integer argument "myThid". This |
| 418 |
|
|
C | variable identifies the thread number of an instance of |
| 419 |
|
|
C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works |
| 420 |
|
|
C | on a particular region of the models domain and |
| 421 |
|
|
C | synchronises with other instances as necessary. The |
| 422 |
|
|
C | routine has to "understand" the MITgcm parallel |
| 423 |
|
|
C | environment and the numerical algorithm. Editing this |
| 424 |
|
|
C | routine is best done with some knowledge of both aspects. |
| 425 |
|
|
C | Notes |
| 426 |
|
|
C | ===== |
| 427 |
|
|
C | C*P* comments indicating place holders for which code is |
| 428 |
|
|
C | presently being developed. |
| 429 |
|
|
C *==========================================================* |
| 430 |
|
|
C \ev |
| 431 |
|
|
|
| 432 |
|
|
C !CALLING SEQUENCE: |
| 433 |
|
|
C THE_MODEL_MAIN() |
| 434 |
|
|
C | |
| 435 |
|
|
C | |
| 436 |
|
|
C |--INITIALISE_FIXED |
| 437 |
|
|
C | o Set model configuration (fixed arrays) |
| 438 |
|
|
C | Topography, hydrography, timestep, grid, etc.. |
| 439 |
|
|
C | |
| 440 |
|
|
C |--CTRL_UNPACK o Derivative mode. Unpack control vector. |
| 441 |
|
|
C | |
| 442 |
|
|
C |--ADTHE_MAIN_LOOP o Main timestepping loop for combined |
| 443 |
|
|
C | prognostic and reverse mode integration. |
| 444 |
|
|
C | |
| 445 |
|
|
C |--CTRL_PACK o Derivative mode. Unpack control vector. |
| 446 |
|
|
C | |
| 447 |
|
|
C |--GRDCHK_MAIN o Gradient check control routine. |
| 448 |
|
|
C | |
| 449 |
|
|
C |--THE_MAIN_LOOP o Main timestepping loop for pure prognostic |
| 450 |
|
|
C | integration. |
| 451 |
|
|
C | |
| 452 |
|
|
C |--WRITE_CHECKPOINT o Write retsart information. |
| 453 |
|
|
C | |
| 454 |
|
|
C |--TIMER_PRINTALL o Print out timing statistics. |
| 455 |
|
|
C | |
| 456 |
|
|
C |--COMM_STATS o Print out communication statistics. |
| 457 |
|
|
|
| 458 |
|
|
C !USES: |
| 459 |
|
|
C == Global variables === |
| 460 |
|
|
|
| 461 |
|
|
use OAD_active |
| 462 |
|
|
use OAD_rev |
| 463 |
|
|
use OAD_tape |
| 464 |
|
|
use OAD_cp |
| 465 |
|
|
|
| 466 |
|
|
|
| 467 |
|
|
#include "SIZE.h" |
| 468 |
|
|
#include "EEPARAMS.h" |
| 469 |
|
|
#include "PARAMS.h" |
| 470 |
|
|
#include "DYNVARS.h" |
| 471 |
|
|
#include "ctrl.h" |
| 472 |
|
|
#include "cost.h" |
| 473 |
|
|
|
| 474 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
| 475 |
|
|
# include "tamc.h" |
| 476 |
|
|
#endif |
| 477 |
|
|
#ifdef ALLOW_CTRL |
| 478 |
|
|
# include "optim.h" |
| 479 |
|
|
#endif |
| 480 |
|
|
|
| 481 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
| 482 |
|
|
C == Routine arguments == |
| 483 |
|
|
C myThid - Thread number for this instance of the routine. |
| 484 |
|
|
INTEGER myThid |
| 485 |
|
|
|
| 486 |
|
|
C !LOCAL VARIABLES: |
| 487 |
|
|
C == Local variables == |
| 488 |
|
|
C Note: Under the multi-threaded model myCurrentIter and |
| 489 |
|
|
C myCurrentTime are local variables passed around as routine |
| 490 |
|
|
C arguments. Although this is fiddly it saves the need to |
| 491 |
|
|
C impose additional synchronisation points when they are |
| 492 |
|
|
C updated. |
| 493 |
|
|
C myCurrentTime - Time counter for this thread |
| 494 |
|
|
C myCurrentIter - Iteration counter for this thread |
| 495 |
|
|
INTEGER myCurrentIter |
| 496 |
|
|
_RL myCurrentTime |
| 497 |
|
|
logical exst |
| 498 |
|
|
logical lastdiva |
| 499 |
|
|
_RL foo(1-olx:snx+olx,1-oly:sny+oly,nr,nsx,nsy) |
| 500 |
|
|
_RL fooEtan(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
| 501 |
|
|
CHARACTER*(10) suff |
| 502 |
|
|
C Temprarily change precision to agree with ctrlprec |
| 503 |
|
|
INTEGER tmpprec |
| 504 |
|
|
|
| 505 |
|
|
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 |
|
|
our_rev_mode%switchedToCheckpoint=.FALSE. |
| 518 |
|
|
c initialize the tape |
| 519 |
|
|
call oad_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 |
|
|
#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 |
|
|
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 |
|
|
CALL OpenAD_INITIALISE_FIXED( myThid ) |
| 540 |
|
|
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 |
|
|
IF ( optimcycle.NE.0 .AND. doMainUnpack ) THEN |
| 557 |
|
|
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 |
|
|
CALL TIMER_START('THE_MAIN_LOOP (F) [THE_MODEL_MAIN]',myThid) |
| 610 |
|
|
our_rev_mode%plain=.FALSE. |
| 611 |
|
|
our_rev_mode%tape=.TRUE. |
| 612 |
|
|
call timeratio() |
| 613 |
|
|
CALL OpenAD_THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid ) |
| 614 |
|
|
CALL TIMER_STOP ('THE_MAIN_LOOP (F) [THE_MODEL_MAIN]',myThid) |
| 615 |
|
|
CALL TIMER_START('THE_MAIN_LOOP (A) [THE_MODEL_MAIN]',myThid) |
| 616 |
|
|
our_rev_mode%arg_store=.FALSE. |
| 617 |
|
|
our_rev_mode%arg_restore=.FALSE. |
| 618 |
|
|
our_rev_mode%plain=.FALSE. |
| 619 |
|
|
our_rev_mode%tape=.FALSE. |
| 620 |
|
|
our_rev_mode%adjoint=.TRUE. |
| 621 |
|
|
fc%d=1.0 |
| 622 |
|
|
call timeratio() |
| 623 |
|
|
CALL OpenAD_THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid ) |
| 624 |
|
|
call timeratio() |
| 625 |
|
|
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 |
|
|
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 |
|
|
write (*,'(A,5(I3,A),E25.17E3,A,E25.17E3)') 'JU: (', |
| 636 |
|
|
+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 |
|
|
end do |
| 639 |
|
|
end do |
| 640 |
|
|
end do |
| 641 |
|
|
end do |
| 642 |
|
|
end do |
| 643 |
|
|
C Temporarily change setting of writeBinaryPrec |
| 644 |
|
|
tmpprec = writeBinaryPrec |
| 645 |
|
|
writeBinaryPrec = ctrlprec |
| 646 |
|
|
WRITE(suff,'(I10.10)') 0 |
| 647 |
|
|
foo=xx_theta%d |
| 648 |
|
|
call write_fld_xyz_rl('adxx_theta.',suff,foo,myiter,1) |
| 649 |
|
|
foo=xx_salt%d |
| 650 |
|
|
call write_fld_xyz_rl('adxx_salt.',suff,foo,myiter,1) |
| 651 |
|
|
fooEtan=etan%d |
| 652 |
|
|
call write_fld_xy_rl('adxx_etan.',suff,fooEtan,myiter,1) |
| 653 |
|
|
C Change back to original writeBinaryPrec |
| 654 |
|
|
writeBinaryPrec = tmpprec |
| 655 |
|
|
our_rev_mode%plain=.TRUE. |
| 656 |
|
|
our_rev_mode%tape=.FALSE. |
| 657 |
|
|
our_rev_mode%adjoint=.FALSE. |
| 658 |
|
|
CALL TIMER_STOP ('THE_MAIN_LOOP (A) [THE_MODEL_MAIN]',myThid) |
| 659 |
|
|
|
| 660 |
|
|
# endif |
| 661 |
|
|
|
| 662 |
|
|
# ifndef EXCLUDE_CTRL_PACK |
| 663 |
|
|
_BEGIN_MASTER( mythid ) |
| 664 |
|
|
IF ( myProcId .eq. 0 .AND. lastdiva .AND. doMainPack ) THEN |
| 665 |
|
|
CALL TIMER_START('CTRL_PACK [THE_MODEL_MAIN]',mythid) |
| 666 |
|
|
CALL CTRL_PACK( .FALSE. , mythid ) |
| 667 |
|
|
CALL TIMER_STOP ('CTRL_PACK [THE_MODEL_MAIN]',mythid) |
| 668 |
|
|
IF ( ( optimcycle.EQ.0 .OR. (.NOT. doMainUnpack) ) |
| 669 |
|
|
& .AND. mycurrentiter.EQ.niter0 ) THEN |
| 670 |
|
|
CALL TIMER_START('CTRL_PACK [THE_MODEL_MAIN]',mythid) |
| 671 |
|
|
CALL CTRL_PACK( .TRUE. , mythid ) |
| 672 |
|
|
CALL TIMER_STOP ('CTRL_PACK [THE_MODEL_MAIN]',mythid) |
| 673 |
|
|
ENDIF |
| 674 |
|
|
ENDIF |
| 675 |
|
|
_END_MASTER( mythid ) |
| 676 |
|
|
_BARRIER |
| 677 |
|
|
# endif /* EXCLUDE_CTRL_PACK */ |
| 678 |
|
|
|
| 679 |
|
|
|
| 680 |
|
|
# ifdef ALLOW_GRDCHK |
| 681 |
|
|
IF ( useGrdchk .AND. lastdiva ) THEN |
| 682 |
|
|
CALL TIMER_START('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid) |
| 683 |
|
|
CALL GRDCHK_MAIN( mythid ) |
| 684 |
|
|
CALL TIMER_STOP ('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid) |
| 685 |
|
|
_BARRIER |
| 686 |
|
|
ENDIF |
| 687 |
|
|
# endif |
| 688 |
|
|
|
| 689 |
|
|
#else /* ALL AD-related undef */ |
| 690 |
|
|
|
| 691 |
|
|
#ifdef ALLOW_DEBUG |
| 692 |
|
|
IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid) |
| 693 |
|
|
#endif |
| 694 |
|
|
C-- Call time stepping loop of full model |
| 695 |
|
|
CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
| 696 |
|
|
CALL THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid ) |
| 697 |
|
|
CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
| 698 |
|
|
|
| 699 |
|
|
#endif /* ALLOW_TANGENTLINEAR_RUN ALLOW_ADJOINT_RUN ALLOW_ADMTLM */ |
| 700 |
|
|
|
| 701 |
|
|
C-- Final checkpoint (in case the in-loop checkpoint was missed) |
| 702 |
|
|
CALL TIMER_START('DO_WRITE_PICKUP [THE_MODEL_MAIN]',myThid) |
| 703 |
|
|
CALL DO_WRITE_PICKUP( |
| 704 |
|
|
I .TRUE., myCurrentTime, myCurrentIter, myThid ) |
| 705 |
|
|
CALL TIMER_STOP ('DO_WRITE_PICKUP [THE_MODEL_MAIN]',myThid) |
| 706 |
|
|
|
| 707 |
|
|
CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid) |
| 708 |
|
|
|
| 709 |
|
|
#ifdef ALLOW_DIAGNOSTICS |
| 710 |
|
|
IF (useDiagnostics) THEN |
| 711 |
|
|
C Close all diagnostics output files |
| 712 |
|
|
CALL DIAGSTATS_CLOSE_IO( myThid ) |
| 713 |
|
|
ENDIF |
| 714 |
|
|
#endif |
| 715 |
|
|
|
| 716 |
|
|
#ifdef ALLOW_MNC |
| 717 |
|
|
IF (useMNC) THEN |
| 718 |
|
|
C Close all open NetCDF files |
| 719 |
|
|
_BEGIN_MASTER( mythid ) |
| 720 |
|
|
CALL MNC_FILE_CLOSE_ALL( myThid ) |
| 721 |
|
|
_END_MASTER( mythid ) |
| 722 |
|
|
ENDIF |
| 723 |
|
|
#endif |
| 724 |
|
|
|
| 725 |
|
|
C-- Write timer statistics |
| 726 |
|
|
IF ( myThid .EQ. 1 ) THEN |
| 727 |
|
|
CALL TIMER_PRINTALL( myThid ) |
| 728 |
|
|
CALL COMM_STATS |
| 729 |
|
|
ENDIF |
| 730 |
|
|
|
| 731 |
|
|
C-- Check threads synchronization : |
| 732 |
|
|
CALL BAR_CHECK( 9, myThid ) |
| 733 |
|
|
|
| 734 |
|
|
#ifdef ALLOW_DEBUG |
| 735 |
|
|
IF (debugMode) CALL DEBUG_LEAVE('THE_MODEL_MAIN',myThid) |
| 736 |
|
|
#endif |
| 737 |
|
|
|
| 738 |
|
|
RETURN |
| 739 |
|
|
END |