00001 !
00002 ! $Id: scalars.h,v 1.12 2005/10/10 13:40:18 pmarches Exp $
00003 !
00004 ! This is include file "scalars.h"
00005 !---------------------------------
00006 !
00007 ! The following common block contains time variables and indices
00008 ! for 2D (k-indices) and 3D (n-indices) computational engines. Since
00009 ! they are changed together, they are placed into the same cache line
00010 ! despite their mixed type, so that only one cachene is being
00011 ! invalidated and has to be propagated accross the cluster.
00012 !
00013 ! Note that the real values are placed first into the common block
00014 ! before the integer variables. This is done to prevent the
00015 ! possibility of misallignment of the 8-byte objects in the case
00016 ! when an uneven number of 4-byte integers is placed before a 8-byte
00017 ! real (in the case when default real size is set to 8bytes).
00018 ! Thought misallignment is not formally a violation of fortran
00019 ! standard, it may cause performance degradation and/or make compiler
00020 ! issue a warning message (Sun, DEC Alpha) or even crash (Alpha).
00021 !
00022 ! time Time since initialization [seconds];
00023 ! time_start Initialization time [seconds];
00024 ! tdays Time since initialization [days];
00025 ! dt Time step for 3D primitive equations [seconds];
00026 ! dtfast Time step for 2D (barotropic) mode [seconds];
00027 !
00028 real dt, dtfast, time, time_start, tdays
00029 integer iic, kstp, krhs, knew, next_kstp
00030 #ifdef SOLVE3D
00031 & , iif, nstp, nrhs, nnew, nbstep3d
00032 #endif
00033 #ifdef FLOATS
00034 & , nfp1, nf, nfm1, nfm2, nfm3
00035 #endif
00036 logical PREDICTOR_2D_STEP
00037 common /time_indices/ dt,dtfast, time,time_start, tdays,
00038 & iic, kstp, krhs, knew, next_kstp,
00039 #ifdef SOLVE3D
00040 & iif, nstp, nrhs, nnew, nbstep3d,
00041 #endif
00042 #ifdef FLOATS
00043 & nfp1, nf, nfm1, nfm2, nfm3,
00044 #endif
00045 & PREDICTOR_2D_STEP
00046
00047 !
00048 ! Slowly changing variables: these are typically set in the beginning
00049 ! of the run and either remain unchanged, or are changing only in
00050 ! association with the I/0.
00051 !
00052 ! xl, el Physical size (m) of domain box in the XI-,ETA-directions.
00053 !
00054 ! Tcline Width (m) of surface or bottom boundary layer in which
00055 ! higher vertical resolution is required during stretching.
00056 ! theta_s S-coordinate surface control parameter, [0<theta_s<20].
00057 ! theta_b S-coordinate bottom control parameter, [0<theta_b<1].
00058 ! hc S-coordinate parameter, hc=min(hmin,Tcline).
00059 !
00060 ! sc_r S-coordinate independent variable, [-1 < sc < 0] at
00061 ! vertical RHO-points
00062 ! sc_w S-coordinate independent variable, [-1 < sc < 0] at
00063 ! vertical W-points.
00064 ! Cs_r Set of S-curves used to stretch the vertical coordinate
00065 ! lines that follow the topography at vertical RHO-points.
00066 ! Cs_w Set of S-curves used to stretch the vertical coordinate
00067 ! lines that follow the topography at vertical W-points.
00068 !
00069 ! rho0 Boussinesque Approximation Mean density [kg/m^3].
00070 ! R0 Background constant density anomaly [kg/m^3] used in
00071 ! linear equation of state.
00072 ! T0,S0 Background temperature (Celsius) and salinity [PSU]
00073 ! values used in analytical fields;
00074 ! Tcoef Thermal expansion coefficient in linear EOS;
00075 ! Scoef Saline contraction coefficient in linear EOS;
00076 !
00077 ! rdrg Linear bottom drag coefficient.
00078 ! rdrg2 Quadratic bottom drag coefficient.
00079 ! Cdb_max Maximum bottom drag coefficient allowed.
00080 ! Cdb_min Minimum bottom drag coefficient to avoid the
00081 ! law-of-the-wall to extend indefinitely.
00082 ! Zob Bottom roughness (m).
00083 !
00084 ! gamma2 Slipperiness parameter, either 1. (free-slip)
00085 !
00086 ! ntstart Starting timestep in evolving the 3D primitive equations;
00087 ! usually 1, if not a restart run.
00088 ! ntimes Number of timesteps for the 3D primitive equations in
00089 ! the current run.
00090 ! ndtfast Number of timesteps for 2-D equations between each "dt".
00091 !
00092 ! nrst Number of timesteps between storage of restart fields.
00093 ! nwrt Number of timesteps between writing of fields into
00094 ! history file.
00095 ! ninfo Number of timesteps between print of single line
00096 ! information to standard output.
00097 ! nsta Number of timesteps between storage of station data.
00098 ! navg Number of timesteps between storage of time-averaged
00099 ! fields.
00100 ! ntsavg Starting timestep for accumulation of output time-
00101 ! averaged fields.
00102 ! nrrec Counter of restart time records to read from disk,
00103 ! the last is used as the initial conditions.
00104 !
00105 ! ldefhis Logical switch used to create the history file.
00106 ! If TRUE, a new history file is created. If FALSE,
00107 ! data is appended to an existing history file.
00108 ! levsfrc Deepest level to apply surface momentum stress as
00109 ! bodyforce.
00110 ! levbfrc Shallowest level to apply bottom momentum stress as
00111 ! bodyforce.
00112 ! got_tini Logical switch used at initialisation
00113 ! If TRUE, the tracer is present in the initial file
00114 ! If FALSE, the tracer needs an analytical value
00115 !
00116 ! got_inised Logical switch used at initialisation of sediments
00117 ! If TRUE, the sediment var. is in the initial file
00118 ! If FALSE, the sed. var. gets analytical value from file
00119 !
00120 ! got_inibed Logical switch used at initialisation of ripple height, length
00121 ! If TRUE, the ripple var. is in the initial file
00122 ! If FALSE, the ripple var. is obtained from file (ifdef also SEDIMENT)
00123 ! the ripple var. is set in ana_bsedim (ifndef SEDIMENT)
00124 !
00125 real time_avg, rho0
00126 & , rdrg, rdrg2, Cdb_min, Cdb_max, Zob
00127 & , xl, el, visc2, visc4, gamma2
00128 #ifdef SOLVE3D
00129 real theta_s, theta_b, Tcline, hc
00130 real sc_w(0:N), Cs_w(0:N), sc_r(N), Cs_r(N)
00131 real rx0, rx1
00132 real tnu2(NT),tnu4(NT)
00133 # ifdef MY25_MIXING
00134 real Akq_bak, q2nu2, q2nu4
00135 # endif
00136 # ifndef NONLIN_EOS
00137 real R0,T0,S0, Tcoef, Scoef
00138 # endif
00139 real weight(6,0:NWEIGHT)
00140
00141 #endif
00142 #if defined SPONGE || \
00143 defined TNUDGING || defined M2NUDGING || \
00144 defined M3NUDGING || defined ZNUDGING
00145 real x_sponge, v_sponge
00146 #endif
00147 #if defined T_FRC_BRY || defined M2_FRC_BRY || \
00148 defined M3_FRC_BRY || defined Z_FRC_BRY || \
00149 defined TNUDGING || defined M2NUDGING || \
00150 defined M3NUDGING || defined ZNUDGING
00151 real tauT_in, tauT_out, tauM_in, tauM_out
00152 #endif
00153 integer numthreads, ntstart, ntimes, ninfo
00154 & , ndtfast,nfast, nrrec, nrst, nwrt
00155 #ifdef AVERAGES
00156 & , ntsavg, navg
00157 #endif
00158 #ifdef BODYFORCE
00159 & , levbfrc, levsfrc
00160 #endif
00161 #ifdef FLOATS
00162 integer nflt, nrpfflt
00163 #endif
00164 #if defined DIAGNOSTICS_TS
00165 integer nwrtdia
00166 # ifdef AVERAGES
00167 integer ntsdia_avg, nwrtdia_avg
00168 # endif
00169 #endif
00170 #if defined DIAGNOSTICS_UV
00171 integer nwrtdiaM
00172 # ifdef AVERAGES
00173 integer ntsdiaM_avg, nwrtdiaM_avg
00174 # endif
00175 #endif
00176 #ifdef DIAGNOSTICS_BIO
00177 integer nwrtdiabio
00178 # ifdef AVERAGES
00179 integer ntsdiabio_avg, nwrtdiabio_avg
00180 # endif
00181 #endif
00182 #ifdef STATIONS
00183 integer nsta, nrpfsta
00184 #endif
00185
00186 logical ldefhis
00187 #ifdef SOLVE3D
00188 logical got_tini(NT)
00189 #endif
00190 #ifdef SEDIMENT
00191 logical got_inised(3)
00192 #endif
00193 #ifdef BBL
00194 logical got_inibed(2)
00195 #endif
00196 #ifdef FLOATS
00197 logical ldefflt
00198 #endif
00199 #if defined DIAGNOSTICS_TS
00200 logical ldefdia
00201 # ifdef AVERAGES
00202 logical ldefdia_avg
00203 # endif
00204 #endif
00205 #if defined DIAGNOSTICS_UV
00206 logical ldefdiaM
00207 # ifdef AVERAGES
00208 logical ldefdiaM_avg
00209 # endif
00210 #endif
00211 #ifdef DIAGNOSTICS_BIO
00212 logical ldefdiabio
00213 # ifdef AVERAGES
00214 logical ldefdiabio_avg
00215 # endif
00216 #endif
00217 #ifdef STATIONS
00218 logical ldefsta
00219 #endif
00220
00221 common /scalars_main/
00222 & time_avg, rho0, rdrg, rdrg2
00223 & , Zob, Cdb_min, Cdb_max
00224 & , xl, el, visc2, visc4, gamma2
00225 #ifdef SOLVE3D
00226 & , theta_s, theta_b, Tcline, hc
00227 & , sc_w, Cs_w, sc_r, Cs_r
00228 & , rx0, rx1, tnu2, tnu4
00229 # ifdef MY25_MIXING
00230 & , Akq_bak, q2nu2, q2nu4
00231 # endif
00232 # ifndef NONLIN_EOS
00233 & , R0,T0,S0, Tcoef, Scoef
00234 # endif
00235 & , weight
00236 #endif
00237 #if defined SPONGE || \
00238 defined TNUDGING || defined M2NUDGING || \
00239 defined M3NUDGING || defined ZNUDGING
00240 & , x_sponge, v_sponge
00241 #endif
00242 #if defined T_FRC_BRY || defined M2_FRC_BRY || \
00243 defined M3_FRC_BRY || defined Z_FRC_BRY || \
00244 defined TNUDGING || defined M2NUDGING || \
00245 defined M3NUDGING || defined ZNUDGING
00246 & , tauT_in, tauT_out, tauM_in, tauM_out
00247 #endif
00248 & , numthreads, ntstart, ntimes, ninfo
00249 & , ndtfast,nfast, nrrec, nrst, nwrt
00250 #ifdef AVERAGES
00251 & , ntsavg, navg
00252 #endif
00253 #ifdef BODYFORCE
00254 & , levbfrc, levsfrc
00255 #endif
00256 #ifdef FLOATS
00257 & , nflt, nrpfflt
00258 #endif
00259 #ifdef STATIONS
00260 & , nsta, nrpfsta
00261 #endif
00262 & , ldefhis
00263 #ifdef SOLVE3D
00264 & , got_tini
00265 #endif
00266 #ifdef SEDIMENT
00267 & , got_inised
00268 #endif
00269 #ifdef BBL
00270 & , got_inibed
00271 #endif
00272 #ifdef FLOATS
00273 & , ldefflt
00274 #endif
00275 #if defined DIAGNOSTICS_TS
00276 & , ldefdia, nwrtdia
00277 # ifdef AVERAGES
00278 & , ldefdia_avg
00279 & , nwrtdia_avg
00280 & , ntsdia_avg
00281 # endif
00282 #endif
00283 #if defined DIAGNOSTICS_UV
00284 & , ldefdiaM, nwrtdiaM
00285 # ifdef AVERAGES
00286 & , ldefdiaM_avg
00287 & , nwrtdiaM_avg
00288 & , ntsdiaM_avg
00289 # endif
00290 #endif
00291 #ifdef DIAGNOSTICS_BIO
00292 & , ldefdiabio, nwrtdiabio
00293 # ifdef AVERAGES
00294 & , ldefdiabio_avg
00295 & , nwrtdiabio_avg
00296 & , ntsdiabio_avg
00297 # endif
00298 #endif
00299 #ifdef STATIONS
00300 & , ldefsta
00301 #endif
00302
00303 # if defined SOLVE3D && !defined LMD_MIXING \
00304 && !defined MY2_MIXING && !defined MY25_MIXING
00305 real Akv_bak
00306 real Akt_bak(NT)
00307 common /scalars_akt/ Akv_bak, Akt_bak
00308 # endif
00309 !
00310 ! This following common block contains a set of globally accessable
00311 ! variables in order to allow information exchange between parallel
00312 ! threads working on different subdomains.
00313 !
00314 ! Global summation variables are declared with 16 byte precision
00315 ! to avoid accumulation of roundoff errors, since roundoff error
00316 ! depends on the order of summation, which is undeterministic in
00317 ! the case of summation between the parallel threads; not doing so
00318 ! would make itimpossible to pass an ETALON CHECK test if there is
00319 ! a feedback of these sums into the dynamics of the model, such as
00320 ! in the case when global mass conservation is enforced.
00321 !
00322 ! One sunny spring day, sometime in 1989 an american tourist, who
00323 ! happened to be an attorney, was walking along a Moscow street.
00324 ! Because it was the period of 'Perestroika' (which literally means
00325 ! 'remodelling'), so that a lot of construction was going on in
00326 ! Moscow, dozens of holes and trenches were open on the street. He
00327 ! felt into one of them, broke his leg, ended up in a hospital and
00328 ! complaining: In my country if a construction firm would not place
00329 ! little red flags around the construction zone to warn passers-by
00330 ! about the danger, I will sue em for their negligence! The doctor,
00331 ! who was performing surgery on his leg replied to him: Did not you
00332 ! see the one big red flag above the whole country in the first place?
00333 !
00334 ! WARNING: FRAGILE ALIGNMENT SEQUENCE: In the following common block:
00335 ! since real objects are grouped in pairs and integer*4 are grouped
00336 ! in quartets, it is guaranteed that 16 Byte objects are aligned
00337 ! in 16 Byte boundaries and 8 Byte objects are aligned in 8 Byte
00338 ! boundaries. Removing or introduction of variables with violation
00339 ! of parity, as well as changing the sequence of variables in the
00340 ! common block may cause violation of alignment.
00341 !
00342 logical synchro_flag
00343 common /sync_flag/ synchro_flag
00344
00345 integer may_day_flag ! This is a shared variable among nested grids
00346 integer tile_count, first_time, bc_count
00347 #ifdef BIOLOGY
00348 & , bio_count
00349 #endif
00350 common /communicators_i/
00351 & may_day_flag, tile_count, first_time, bc_count
00352 #ifdef BIOLOGY
00353 & , bio_count
00354 #endif
00355
00356 real hmin, hmax, grdmin, grdmax, Cu_min, Cu_max
00357 common /communicators_r/
00358 & hmin, hmax, grdmin, grdmax, Cu_min, Cu_max
00359
00360 real*QUAD volume, avgke, avgpe, avgkp, bc_crss
00361 #ifdef OBC_VOLCONS
00362 & , bc_flux, ubar_xs
00363 #endif
00364 #ifdef BIOLOGY
00365 & , global_sum(0:2*NT+1)
00366 #endif
00367 common /communicators_rq/
00368 & volume, avgke, avgpe, avgkp, bc_crss
00369 #ifdef OBC_VOLCONS
00370 & , bc_flux, ubar_xs
00371 #endif
00372 #ifdef BIOLOGY
00373 & , global_sum
00374 #endif
00375 !
00376 ! The following common block contains process counters and model
00377 ! timers. These are used to measure CPU time consumed by different
00378 ! parallel threads during the whole run, as well as in various
00379 ! parallel regions, if so is needed. These variables are used purely
00380 ! for diagnostic/performance measurements purposes and do not affect
00381 ! the model results.
00382 !
00383 real*4 CPU_time(0:31,0:NPP)
00384 integer proc(0:31,0:NPP),trd_count
00385 common /timers/CPU_time,proc,trd_count
00386
00387 #ifdef MPI
00388 !
00389 ! MPI rlated variables
00390 ! === ====== =========
00391 !
00392 logical EAST_INTER, WEST_INTER, NORTH_INTER, SOUTH_INTER
00393 integer mynode, ii,jj, p_W,p_E,p_S,p_N, p_SW,p_SE, p_NW,p_NE
00394 common /comm_setup/ mynode, ii,jj, p_W,p_E,p_S,p_N, p_SW,p_SE,
00395 & p_NW,p_NE, EAST_INTER, WEST_INTER, NORTH_INTER, SOUTH_INTER
00396
00397 #endif
00398
00399 !
00400 ! Physical constants:
00401 ! ======== ==========
00402
00403 real pi, deg2rad, rad2deg
00404 parameter (pi=3.14159265358979323846, deg2rad=pi/180.,
00405 & rad2deg=180./pi)
00406 !
00407 ! Earth radius [m]; Aceleration of gravity [m/s^2], duration
00408 ! of the day in seconds and its inverse; Julian offset day.
00409
00410 real Eradius, g, day2sec,sec2day, jul_off,
00411 & year2day,day2year
00412 parameter (Eradius=6371315.0, day2sec=86400.,
00413 & sec2day=1./86400., jul_off=2440000.,
00414 & year2day=365.25, day2year=1./365.25)
00415 !
00416 ! Acceleration of gravity (nondimensional for Soliton problem)
00417 !
00418 #ifdef SOLITON
00419 parameter (g=1.)
00420 #else
00421 parameter (g=9.81)
00422 #endif
00423 !
00424 ! Specific heat [Joules/kg/degC] for seawater, it is approximately
00425 ! 4000, and varies only slightly (see Gill, 1982, Appendix 3).
00426 !
00427 real Cp
00428 parameter (Cp=3985.0)
00429
00430 real vonKar
00431 parameter (vonKar=0.41)
00432
00433