ROMS
Loading...
Searching...
No Matches
mod_param.F
Go to the documentation of this file.
1#include "cppdefs.h"
2 MODULE mod_param
3!
4!git $Id$
5!================================================== Hernan G. Arango ===
6! Copyright (c) 2002-2025 The ROMS Group !
7! Licensed under a MIT/X style license !
8! See License_ROMS.md !
9!=======================================================================
10! !
11! Grid parameters: !
12! !
13! Im Number of global grid points in the XI-direction !
14! for each nested grid. !
15! Jm Number of global grid points in the ETA-direction !
16! for each nested grid. !
17! Lm Number of interior grid points in the XI-direction !
18! for each nested grid. !
19! Mm Number of internal grid points in the ETA-direction. !
20! for each nested grid. !
21! N Number of vertical levels for each nested grid. !
22! Ngrids Number of nested and/or connected grids to solve. !
23! NtileI Number of XI-direction tiles or domain partitions for !
24! each nested grid. Values used to compute tile ranges. !
25! NtileJ Number of ETA-direction tiles or domain partitions for !
26! each nested grid. Values used to compute tile ranges. !
27! NtileX Number of XI-direction tiles or domain partitions for !
28! each nested grid. Values used in parallel loops. !
29! NtileE Number of ETA-direction tiles or domain partitions for !
30! each nested grid. Values used in parallel loops. !
31! HaloBry Buffers halo size for exchanging boundary arrays. !
32! HaloSizeI Maximum halo size, in grid points, in XI-direction. !
33! HaloSizeJ Maximum halo size, in grid points, in ETA-direction. !
34! TileSide Maximun tile side length in XI- or ETA-directions. !
35! TileSize Maximum tile size. !
36! !
37! Configuration parameters: !
38! !
39! Nbico Number of balanced SSH elliptic equation iterations. !
40! Nfloats Number of floats trajectories. !
41! Nstation Number of output stations. !
42! MTC Maximum number of tidal components. !
43! !
44! State variables parameters: !
45! !
46#ifdef PROPAGATOR
47! Mstate Size of FULL state vector (water points only). !
48! Nstate Size of NODE partition state vector: Nstate=Mstate in !
49! serial applications. !
50! Nstr State vector node partition starting index. !
51! Nend State vector node partition ending index. !
52! Nsize Size of the eigenvalue problem: Nend-Nstr+1. !
53# ifdef SO_SEMI
54! Nsemi Number of time record saved in seminorm strochastic !
55! optimals adjoint state vector. !
56# endif
57#endif
58! NSA Number of state array for error covariance. !
59! NSV Number of model state variables. !
60! !
61! Tracer parameters: !
62! !
63! NAT Number of active tracer type variables (usually, !
64! NAT=2 for potential temperature and salinity). !
65! NBT Number of biological tracer type variables. !
66! NST Number of sediment tracer type variables (NCS+NNS). !
67! NPT Number of extra passive tracer type variables to !
68! advect and diffuse only (dyes, etc). !
69! MT Maximum number of tracer type variables. !
70! NT Total number of tracer type variables. !
71! NTCLM Total number of climatology tracer type variables to !
72! process. !
73! !
74! Nbed Number of sediment bed layers. !
75! NCS Number of cohesive (mud) sediment tracers. !
76! NNS Number of non-cohesive (sand) sediment tracers. !
77! !
78! Diagnostic fields parameters: !
79! !
80# if defined ECOSIM && defined BIO_OPTIC
81! NDbands Number of spectral irradiance bands. !
82# endif
83! NDbio2d Number of diagnostic 2D biology fields. !
84! NDbio3d Number of diagnostic 3D biology fields. !
85! NDbio4d Number of diagnostic 4D bio-optical fields. !
86! NDT Number of diagnostic tracer fields. !
87! NDM2d Number of diagnostic 2D momentum fields. !
88! NDM3d Number of diagnostic 3D momentum fields. !
89! NDrhs Number of diagnostic 3D right-hand-side fields. !
90! !
91! Estimated Dynamic and automatic memory parameters: !
92! !
93! BmemMax Maximum automatic memory for distributed-memory buffers !
94! (bytes). !
95! Dmem Dynamic memory requirements (array elements) !
96! !
97!=======================================================================
98!
99 USE mod_kinds
100!
101 implicit none
102!
103 PUBLIC :: allocate_param
104 PUBLIC :: deallocate_param
105 PUBLIC :: initialize_param
106!
107!-----------------------------------------------------------------------
108! Grid nesting parameters.
109!-----------------------------------------------------------------------
110!
111! Number of nested and/or connected grids to solve.
112!
113 integer :: ngrids
114!
115! Number of grid nesting layers. This parameter allows refinement and
116! composite grid combinations.
117!
118 integer :: nestlayers = 1
119!
120! Number of grids in each nested layer.
121!
122 integer, allocatable :: gridsinlayer(:) ! [NestLayers]
123!
124! Application grid number as a function of the maximum number of grids
125! in each nested layer and number of nested layers.
126!
127 integer, allocatable :: gridnumber(:,:) ! [Ngrids,NestLayers]
128!
129! Maximum automatic memory (bytes) required in distributed-memory
130! buffers due to parallel exchanges.
131!
132 real(r8), allocatable :: bmemmax(:) ! [Ngrids]
133!
134! Estimated dynamic memory requirement (number of array elements) for
135! a particular application per nested grid.
136!
137 real(r8), allocatable :: dmem(:) ! [Ngrids]
138!
139!-----------------------------------------------------------------------
140! Lower and upper bounds indices per domain partition for all grids.
141!-----------------------------------------------------------------------
142!
143! Notice that these indices have different values in periodic and
144! nesting applications, and on tiles next to the boundaries. Special
145! indices are required to process overlap regions (suffices P and T)
146! lateral boundary conditions (suffices B and M) in nested grid
147! applications. The halo indices are used in private computations
148! which include ghost-points and are limited by MAX/MIN functions
149! on the tiles next to the model boundaries. For more information
150! about all these indices, see routine "var_bounds" in file
151! "Utility/get_bounds.F".
152!
153! All the 1D array indices are of size -1:NtileI(ng)*NtileJ(ng)-1. The
154! -1 index include the values for the full (no partitions) grid.
155!
156! Notice that the starting (Imin, Jmin) and ending (Imax, Jmax) indices
157! for I/O processing are 3D arrays. The first dimension (1:4) is for
158! 1=PSI, 2=RHO, 3=u, 4=v points; the second dimension (0:1) is number
159! of ghost points (0: no ghost points, 1: Nghost points), and the
160! the third dimension is for 0:NtileI(ng)*NtileJ(ng)-1.
161!
163 integer, pointer :: tile(:) ! tile partition
164
165 integer, pointer :: lbi(:) ! lower bound I-dimension
166 integer, pointer :: ubi(:) ! upper bound I-dimension
167 integer, pointer :: lbj(:) ! lower bound J-dimension
168 integer, pointer :: ubj(:) ! upper bound J-dimension
169
170 integer :: lbij ! lower bound MIN(I,J)-dimension
171 integer :: ubij ! upper bound MAX(I,J)-dimension
172
173 integer :: edge(4,4) ! boundary edges I- or J-indices
174
175 integer, pointer :: istr(:) ! starting tile I-direction
176 integer, pointer :: iend(:) ! ending tile I-direction
177 integer, pointer :: jstr(:) ! starting tile J-direction
178 integer, pointer :: jend(:) ! ending tile J-direction
179
180 integer, pointer :: istrr(:) ! starting tile I-direction (RHO)
181 integer, pointer :: iendr(:) ! ending tile I-direction (RHO)
182 integer, pointer :: istru(:) ! starting tile I-direction (U)
183
184 integer, pointer :: jstrr(:) ! starting tile J-direction (RHO)
185 integer, pointer :: jendr(:) ! ending tile J-direction (RHO)
186 integer, pointer :: jstrv(:) ! starting tile J-direction (V)
187
188 integer, pointer :: istrb(:) ! starting obc I-direction (RHO,V)
189 integer, pointer :: iendb(:) ! ending obc I-direction (RHO,V)
190 integer, pointer :: istrm(:) ! starting obc I-direction (PSI,U)
191
192 integer, pointer :: jstrb(:) ! starting obc J-direction (RHO,U)
193 integer, pointer :: jendb(:) ! ending obc J-direction (RHO,U)
194 integer, pointer :: jstrm(:) ! starting obc J-direction (PSI,V)
195
196 integer, pointer :: istrp(:) ! starting nest I-direction (PSI,U)
197 integer, pointer :: iendp(:) ! ending nest I-direction (PSI)
198 integer, pointer :: jstrp(:) ! starting nest J-direction (PSI,V)
199 integer, pointer :: jendp(:) ! ending nest J-direction (PSI)
200
201 integer, pointer :: istrt(:) ! starting nest I-direction (RHO)
202 integer, pointer :: iendt(:) ! ending nest I-direction (RHO)
203 integer, pointer :: jstrt(:) ! starting nest J-direction (RHO)
204 integer, pointer :: jendt(:) ! ending nest J-direction (RHO)
205
206 integer, pointer :: istrm3(:) ! starting I-halo, Istr-3
207 integer, pointer :: istrm2(:) ! starting I-halo, Istr-2
208 integer, pointer :: istrm1(:) ! starting I-halo, Istr-1
209 integer, pointer :: istrum2(:) ! starting I-halo, IstrU-2
210 integer, pointer :: istrum1(:) ! starting I-halo, IstrU-1
211 integer, pointer :: iendp1(:) ! ending I-halo, Iend+1
212 integer, pointer :: iendp2(:) ! ending I-halo, Iend+2
213 integer, pointer :: iendp2i(:) ! ending I-halo, Iend+2
214 integer, pointer :: iendp3(:) ! ending I-halo, Iend+3
215
216 integer, pointer :: jstrm3(:) ! starting J-halo, Jstr-3
217 integer, pointer :: jstrm2(:) ! starting J-halo, Jstr-2
218 integer, pointer :: jstrm1(:) ! starting J-halo, Jstr-1
219 integer, pointer :: jstrvm2(:) ! starting J-halo, JstrV-2
220 integer, pointer :: jstrvm1(:) ! starting J-halo, JstrV-1
221 integer, pointer :: jendp1(:) ! ending J-halo, Jend+1
222 integer, pointer :: jendp2(:) ! ending J-halo, Jend+2
223 integer, pointer :: jendp2i(:) ! ending J-halo, Jend+2
224 integer, pointer :: jendp3(:) ! ending J-halo, Jend+3
225
226 integer, pointer :: imin(:,:,:) ! starting ghost I-direction
227 integer, pointer :: imax(:,:,:) ! ending ghost I-direction
228 integer, pointer :: jmin(:,:,:) ! starting ghost J-direction
229 integer, pointer :: jmax(:,:,:) ! ending ghost J-direction
230 END TYPE t_bounds
231
232 TYPE (t_bounds), allocatable :: bounds(:)
233#ifdef GRID_EXTRACT
234 TYPE (t_bounds), allocatable :: xtr_bounds(:)
235#endif
236!
237!-----------------------------------------------------------------------
238! Lower and upper bounds in NetCDF files.
239!-----------------------------------------------------------------------
240!
242 integer :: ilb_psi ! I-direction lower bound (PSI)
243 integer :: iub_psi ! I-direction upper bound (PSI)
244 integer :: jlb_psi ! J-direction lower bound (PSI)
245 integer :: jub_psi ! J-direction upper bound (PSI)
246
247 integer :: ilb_rho ! I-direction lower bound (RHO)
248 integer :: iub_rho ! I-direction upper bound (RHO)
249 integer :: jlb_rho ! J-direction lower bound (RHO)
250 integer :: jub_rho ! J-direction upper bound (RHO)
251
252 integer :: ilb_u ! I-direction lower bound (U)
253 integer :: iub_u ! I-direction upper bound (U)
254 integer :: jlb_u ! J-direction lower bound (U)
255 integer :: jub_u ! J-direction upper bound (U)
256
257 integer :: ilb_v ! I-direction lower bound (V)
258 integer :: iub_v ! I-direction upper bound (V)
259 integer :: jlb_v ! J-direction lower bound (V)
260 integer :: jub_v ! J-direction upper bound (V)
261
262 integer :: iorj ! number of MAX(I,J)-direction points
263
264 integer :: xi_psi ! number of I-direction points (PSI)
265 integer :: xi_rho ! number of I-direction points (RHO)
266 integer :: xi_u ! number of I-direction points (U)
267 integer :: xi_v ! number of I-direction points (V)
268
269 integer :: eta_psi ! number of J-direction points (PSI)
270 integer :: eta_rho ! number of J-direction points (RHO)
271 integer :: eta_u ! number of I-direction points (U)
272 integer :: eta_v ! number of I-direction points (V)
273
274#if (defined READ_WATER || defined WRITE_WATER) && defined MASKING
275 integer :: xy_psi ! number of IJ-water points (PSI)
276 integer :: xy_rho ! number of IJ-water points (RHO)
277 integer :: xy_u ! number of IJ-water points (U)
278 integer :: xy_v ! number of IJ-water points (V)
279#endif
280 END TYPE t_iobounds
281
282 TYPE (t_iobounds), allocatable :: iobounds(:)
283#ifdef GRID_EXTRACT
284 TYPE (t_iobounds), allocatable :: xtr_iobounds(:)
285#endif
286!
287!-----------------------------------------------------------------------
288! Domain boundary edges switches and tiles minimum and maximum
289! fractional grid coordinates.
290!-----------------------------------------------------------------------
291!
293 logical, pointer :: eastern_edge(:)
294 logical, pointer :: western_edge(:)
295 logical, pointer :: northern_edge(:)
296 logical, pointer :: southern_edge(:)
297
298 logical, pointer :: northeast_corner(:)
299 logical, pointer :: northwest_corner(:)
300 logical, pointer :: southeast_corner(:)
301 logical, pointer :: southwest_corner(:)
302
303 logical, pointer :: northeast_test(:)
304 logical, pointer :: northwest_test(:)
305 logical, pointer :: southeast_test(:)
306 logical, pointer :: southwest_test(:)
307
308 real(r8), pointer :: xmin_psi(:)
309 real(r8), pointer :: xmax_psi(:)
310 real(r8), pointer :: ymin_psi(:)
311 real(r8), pointer :: ymax_psi(:)
312
313 real(r8), pointer :: xmin_rho(:)
314 real(r8), pointer :: xmax_rho(:)
315 real(r8), pointer :: ymin_rho(:)
316 real(r8), pointer :: ymax_rho(:)
317
318 real(r8), pointer :: xmin_u(:)
319 real(r8), pointer :: xmax_u(:)
320 real(r8), pointer :: ymin_u(:)
321 real(r8), pointer :: ymax_u(:)
322
323 real(r8), pointer :: xmin_v(:)
324 real(r8), pointer :: xmax_v(:)
325 real(r8), pointer :: ymin_v(:)
326 real(r8), pointer :: ymax_v(:)
327 END TYPE t_domain
328
329 TYPE (t_domain), allocatable :: domain(:)
330#ifdef GRID_EXTRACT
331 TYPE (t_domain), allocatable :: xtr_domain(:)
332#endif
333!
334!-----------------------------------------------------------------------
335! Lateral Boundary Conditions (LBC) switches structure.
336!-----------------------------------------------------------------------
337!
338! The lateral boundary conditions are specified by logical switches
339! to facilitate applications with nested grids. It also allows to
340! set different boundary conditions between the nonlinear model and
341! the adjoint/tangent models. The LBC structure is allocated as:
342!
343! LBC(1:4, nLBCvar, Ngrids)
344!
345! where 1:4 are the number boundary edges, nLBCvar are the number
346! LBC state variables, and Ngrids is the number of nested grids.
347! For example, for free-surface gradient boundary conditions we
348! have:
349!
350! LBC(iwest, isFsur, ng) % gradient
351! LBC(ieast, isFsur, ng) % gradient
352! LBC(isouth, isFsur, ng) % gradient
353! LBC(inorth, isFsur, ng) % gradient
354!
355 integer :: nlbcvar
356!
357 TYPE t_lbc
358 logical :: acquire ! process lateral boundary data
359
360 logical :: chapman_explicit
361 logical :: chapman_implicit
362 logical :: clamped
363 logical :: closed
364 logical :: flather
365 logical :: gradient
366 logical :: mixed
367 logical :: nested
368 logical :: nudging
369 logical :: periodic
370 logical :: radiation
371 logical :: reduced
372 logical :: shchepetkin
373 END TYPE t_lbc
374
375 TYPE (t_lbc), allocatable :: lbc(:,:,:)
376
377#if defined ADJOINT || defined TANGENT || defined TL_IOMS
378 TYPE (t_lbc), allocatable :: ad_lbc(:,:,:)
379 TYPE (t_lbc), allocatable :: tl_lbc(:,:,:)
380#endif
381#ifdef SOLVE3D
382!
383!-----------------------------------------------------------------------
384! Tracer horizontal and vertical advection switches structure.
385!-----------------------------------------------------------------------
386!
387! A different advection scheme is allowed for each tracer. For
388! example, a positive-definite algorithm can be activated for salinity,
389! biological, and sediment tracers, while a different one is set for
390! temperature.
391!
392 TYPE t_adv
393 logical :: akima4 ! fourth-order Akima
394 logical :: centered2 ! second-order centered differences
395 logical :: centered4 ! fourth-order centered differences
396 logical :: hsimt ! third-order HSIMT-TVD
397 logical :: mpdata ! recursive flux corrected MPDATA
398 logical :: splines ! parabolic splines (vertical only)
399 logical :: split_u3 ! split third-order upstream
400 logical :: upstream3 ! third-order upstream bias
401 END TYPE t_adv
402
403 TYPE (t_adv), allocatable :: hadvection(:,:) ! horizontal
404 TYPE (t_adv), allocatable :: vadvection(:,:) ! vertical
405
406# if defined ADJOINT || defined TANGENT || defined TL_IOMS
407 TYPE (t_adv), allocatable :: ad_hadvection(:,:) ! horizontal
408 TYPE (t_adv), allocatable :: ad_vadvection(:,:) ! vertical
409# endif
410# if defined TANGENT || defined TL_IOMS
411 TYPE (t_adv), allocatable :: tl_hadvection(:,:) ! horizontal
412 TYPE (t_adv), allocatable :: tl_vadvection(:,:) ! vertical
413# endif
414#endif
415!
416!-----------------------------------------------------------------------
417! Field statistics STATS structure.
418!-----------------------------------------------------------------------
419!
421 integer(i8b) :: checksum ! bit sum hash
422 integer :: count ! processed values count
423
424 real(r8) :: min ! minimum value
425 real(r8) :: max ! maximum value
426 real(r8) :: avg ! arithmetic mean
427 real(r8) :: rms ! root mean square
428 END TYPE t_stats
429
430#ifdef PROPAGATOR
431!
432!-----------------------------------------------------------------------
433! Generalized Stability Theory (GST) nested grid pointers for the
434! state vector. Mostly used for memory management with the ARPACK
435! library.
436!-----------------------------------------------------------------------
437!
438 TYPE t_gst
439 real(r8), pointer :: vector(:)
440 END TYPE
441#endif
442!
443!-----------------------------------------------------------------------
444! Model grid(s) parameters.
445!-----------------------------------------------------------------------
446!
447! Number of interior RHO-points in the XI- and ETA-directions. The
448! size of models state variables (C-grid) at input and output are:
449!
450! RH0-type variables: [0:Lm+1, 0:Mm+1] ----v(i,j+1)----
451! PSI-type variables: [1:Lm+1, 1:Mm+1] | |
452! U-type variables: [1:Lm+1, 0:Mm+1] u(i,j) r(i,j) u(i+1,j)
453! V-type variables: [0:Lm+1, 1:Mm+1] | |
454! -----v(i,j)-----
455 integer, allocatable :: lm(:)
456 integer, allocatable :: mm(:)
457#ifdef GRID_EXTRACT
458 integer, allocatable :: xtr_lm(:)
459 integer, allocatable :: xtr_mm(:)
460#endif
461!
462! Global horizontal size of model arrays including padding. All the
463! model state arrays are of same size to facilitate parallelization.
464!
465 integer, allocatable :: im(:)
466 integer, allocatable :: jm(:)
467#ifdef GRID_EXTRACT
468 integer, allocatable :: xtr_im(:)
469 integer, allocatable :: xtr_jm(:)
470#endif
471!
472! Number of vertical levels. The vertical ranges of model state
473! variables are:
474! -----W(i,j,k)-----
475! RHO-, U-, V-type variables: [1:N] | |
476! W-type variables: [0:N] | r(i,j,k) |
477! | |
478! ----W(i,j,k-1)----
479 integer, allocatable :: n(:)
480!
481!-----------------------------------------------------------------------
482! Tracers parameters.
483!-----------------------------------------------------------------------
484!
485! Total number of tracer type variables, NT(:) = NAT + NBT + NPT + NST.
486! The MT corresponds to the maximum number of tracers between all
487! nested grids.
488!
489 integer, allocatable :: nt(:)
490 integer :: mt
491!
492! Total number of climatology tracer type variables to process.
493!
494 integer, allocatable :: ntclm(:)
495!
496! Number of active tracers. Usually, NAT=2 for potential temperature
497! and salinity.
498!
499 integer :: nat = 0
500!
501! Total number of inert passive tracers to advect and diffuse only
502! (like dyes, etc). This parameter is independent of the number of
503! biological and/or sediment tracers.
504!
505 integer :: npt = 0
506!
507! Number of biological tracers.
508!
509 integer :: nbt = 0
510!
511!-----------------------------------------------------------------------
512! Sediment tracers parameters.
513!-----------------------------------------------------------------------
514!
515! Number of sediment bed layes.
516!
517 integer :: nbed = 0
518!
519! Total number of sediment tracers, NST = NCS + NNS.
520!
521 integer :: nst = 0
522!
523! Number of cohesive (mud) sediments.
524!
525 integer :: ncs = 0
526!
527! Number of non-cohesive (sand) sediments.
528!
529 integer :: nns = 0
530
531#ifdef FLOATS
532!
533!-----------------------------------------------------------------------
534! Floats trajectories parameters.
535!-----------------------------------------------------------------------
536!
537! Number of trajectory time-stepping levels, [0:NFT].
538!
539 integer, parameter :: nft = 4
540!
541! Total number of floats to track.
542!
543 integer, allocatable :: nfloats(:)
544!
545! Total number of float variables to process and output.
546!
547 integer, allocatable :: nfv(:)
548#endif
549#ifdef STATIONS
550!
551!-----------------------------------------------------------------------
552! Stations parameters.
553!-----------------------------------------------------------------------
554!
555! Number of output stations.
556!
557 integer, allocatable :: nstation(:)
558#endif
559!
560!-----------------------------------------------------------------------
561! Maximum number of tidal constituents to process.
562!-----------------------------------------------------------------------
563!
564 integer :: mtc
565
566#ifdef DIAGNOSTICS
567!
568!-----------------------------------------------------------------------
569! Diagnostic fields parameters.
570!-----------------------------------------------------------------------
571!
572! Number of diagnostic tracer fields.
573!
574 integer :: ndt
575!
576! Number of diagnostic momentum fields.
577!
578 integer :: ndm2d ! 2D momentum
579 integer :: ndm3d ! 3D momentum
580!
581! Number of diagnostic biology/bio-optical fields. Currently, only
582! available for the Fennel and EcoSim models.
583!
584 integer :: ndbio2d ! 2D fields
585 integer :: ndbio3d ! 3D fields
586 integer :: ndbio4d ! 4D fields
587!
588! Number of diagnostic 3D right-hand-side fields.
589!
590 integer :: ndrhs
591
592# if defined ECOSIM && defined BIO_OPTIC
593!
594! Number of light spectral irradiance bands to process.
595!
596 integer :: ndbands
597# endif
598#endif
599
600#if defined FOUR_DVAR || defined IMPULSE
601!
602!-----------------------------------------------------------------------
603! 4DVAR parameters.
604!-----------------------------------------------------------------------
605!
606! Number of state arrays (size of additional dimension) for error
607! covariance normalization and standard deviation factors. This
608! paramenter is NSA=1 for strong constraint and NSA=2 for weak
609! constraint. In weak constraint, it contains fields for initial
610! conditions and model error covariance states.
611!
612 integer :: nsa
613#endif
614
615#if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC
616!
617! Number of biconjugate gradient algorithm iteractions.
618!
619 integer, allocatable :: nbico(:)
620#endif
621
622#if defined TIME_CONV && defined WEAK_CONSTRAINT
623!
624! Number of full state records needed for time convolutions. It is
625! assign to (ntimes(ng)/nADJ(ng))+1 in "read_phypar.F"
626!
627 integer, allocatable :: nrectc(:)
628#endif
629!
630!-----------------------------------------------------------------------
631! Model state parameters.
632!-----------------------------------------------------------------------
633!
634! Number of model state variables.
635!
636 integer, allocatable :: nsv(:)
637
638#ifdef PROPAGATOR
639!
640! Size of the full packed state vector (water points only), its
641! parallel node partition, and associated node starting and ending
642! indices.
643!
644 integer, allocatable :: mstate(:) ! full state
645 integer, allocatable :: nstate(:) ! partioned state
646 integer, allocatable :: nstr(:) ! starting index
647 integer, allocatable :: nend(:) ! ending index
648 integer, allocatable :: nsize(:) ! Nend-Nstr+1
649
650# ifdef SO_SEMI
651!
652! Number of time record saved in seminorm strochastic optimals adjoint
653! state vector.
654!
655 integer, allocatable :: nsemi(:)
656# endif
657#endif
658!
659! Set nonlinear, tangent linear, representer (finite-amplitude tangent
660! linear) and adjoint models identifiers.
661!
662 integer, parameter :: inlm = 1 ! nonlinear
663 integer, parameter :: itlm = 2 ! perturbation tangent linear
664 integer, parameter :: irpm = 3 ! finite-amplitude tangent linear
665 integer, parameter :: iadm = 4 ! adjoint
666!
667 character (len=3), dimension(4) :: kernelstring = &
668 & (/ 'NLM','TLM','RPM','ADM' /)
669!
670!-----------------------------------------------------------------------
671! Domain partition parameters.
672!-----------------------------------------------------------------------
673!
674! Number of tiles or domain partitions in the XI- and ETA-directions.
675! These values are used to compute tile ranges [Istr:Iend, Jstr:Jend].
676!
677 integer, allocatable :: ntilei(:)
678 integer, allocatable :: ntilej(:)
679!
680! Number of tiles or domain partitions in the XI- and ETA-directions.
681! These values are used to parallel loops to differentiate between
682! shared-memory and distributed-memory. Notice that in distributed
683! memory both values are set to one.
684!
685 integer, allocatable :: ntilex(:)
686 integer, allocatable :: ntilee(:)
687!
688! Maximun number of points in the halo region for exchanging state
689! boundary arrays during convolutions.
690!
691 integer, allocatable :: halobry(:)
692!
693! Maximum number of points in the halo region in the XI- and
694! ETA-directions.
695!
696 integer, allocatable :: halosizei(:)
697 integer, allocatable :: halosizej(:)
698!
699! Maximum tile side length in XI- or ETA-directions.
700!
701 integer, allocatable :: tileside(:)
702!
703! Maximum number of points in a tile partition.
704!
705 integer, allocatable :: tilesize(:)
706!
707! Set number of ghost-points in the halo region. It is used in
708! periodic, nested, and distributed-memory applications.
709!
710 integer :: nghostpoints
711!
712!-----------------------------------------------------------------------
713! Staggered C-grid location identifiers.
714!-----------------------------------------------------------------------
715!
716 integer, parameter :: p2dvar = 1 ! 2D PSI-variable
717 integer, parameter :: r2dvar = 2 ! 2D RHO-variable
718 integer, parameter :: u2dvar = 3 ! 2D U-variable
719 integer, parameter :: v2dvar = 4 ! 2D V-variable
720 integer, parameter :: p3dvar = 5 ! 3D PSI-variable
721 integer, parameter :: r3dvar = 6 ! 3D RHO-variable
722 integer, parameter :: u3dvar = 7 ! 3D U-variable
723 integer, parameter :: v3dvar = 8 ! 3D V-variable
724 integer, parameter :: w3dvar = 9 ! 3D W-variable
725 integer, parameter :: b3dvar = 10 ! 3D BED-sediment
726 integer, parameter :: l3dvar = 11 ! 3D spectral light
727 integer, parameter :: l4dvar = 12 ! 4D spectral light
728 integer, parameter :: r2dobc = 13 ! 2D OBC RHO-variable
729 integer, parameter :: u2dobc = 14 ! 2D OBC U-variable
730 integer, parameter :: v2dobc = 15 ! 2D OBC V-variable
731 integer, parameter :: r3dobc = 16 ! 3D OBC RHO-variable
732 integer, parameter :: u3dobc = 17 ! 3D OBC U-variable
733 integer, parameter :: v3dobc = 18 ! 3D OBC V-variable
734!
735 CONTAINS
736!
737 SUBROUTINE allocate_param
738!
739!=======================================================================
740! !
741! This routine allocates several variables in the module that depend !
742! on the number of nested grids. !
743! !
744!=======================================================================
745!
746!-----------------------------------------------------------------------
747! Allocate dimension parameters.
748!-----------------------------------------------------------------------
749!
750 IF (.not.allocated(lm)) THEN
751 allocate ( lm(ngrids) )
752 END IF
753 IF (.not.allocated(mm)) THEN
754 allocate ( mm(ngrids) )
755 END IF
756
757 IF (.not.allocated(im)) THEN
758 allocate ( im(ngrids) )
759 END IF
760 IF (.not.allocated(jm)) THEN
761 allocate ( jm(ngrids) )
762 END IF
763
764#ifdef GRID_EXTRACT
765 IF (.not.allocated(xtr_lm)) THEN
766 allocate ( xtr_lm(ngrids) )
767 END IF
768 IF (.not.allocated(xtr_mm)) THEN
769 allocate ( xtr_mm(ngrids) )
770 END IF
771
772 IF (.not.allocated(xtr_im)) THEN
773 allocate ( xtr_im(ngrids) )
774 END IF
775 IF (.not.allocated(xtr_jm)) THEN
776 allocate ( xtr_jm(ngrids) )
777 END IF
778#endif
779
780 IF (.not.allocated(n)) THEN
781 allocate ( n(ngrids) )
782 END IF
783
784 IF (.not.allocated(nt)) THEN
785 allocate ( nt(ngrids) )
786 END IF
787
788#if defined TIME_CONV && defined WEAK_CONSTRAINT
789 IF (.not.allocated(nrectc)) THEN
790 allocate ( nrectc(ngrids) )
791 END IF
792#endif
793
794 IF (.not.allocated(ntclm)) THEN
795 allocate ( ntclm(ngrids) )
796 END IF
797
798 IF (.not.allocated(nsv)) THEN
799 allocate ( nsv(ngrids) )
800 END IF
801
802 IF (.not.allocated(ntilei)) THEN
803 allocate ( ntilei(ngrids) )
804 END IF
805 IF (.not.allocated(ntilej)) THEN
806 allocate ( ntilej(ngrids) )
807 END IF
808
809 IF (.not.allocated(ntilex)) THEN
810 allocate ( ntilex(ngrids) )
811 END IF
812 IF (.not.allocated(ntilee)) THEN
813 allocate ( ntilee(ngrids) )
814 END IF
815
816 IF (.not.allocated(halobry)) THEN
817 allocate ( halobry(ngrids) )
818 END IF
819
820 IF (.not.allocated(halosizei)) THEN
821 allocate ( halosizei(ngrids) )
822 END IF
823 IF (.not.allocated(halosizej)) THEN
824 allocate ( halosizej(ngrids) )
825 END IF
826
827 IF (.not.allocated(tileside)) THEN
828 allocate ( tileside(ngrids) )
829 END IF
830 IF (.not.allocated(tilesize)) THEN
831 allocate ( tilesize(ngrids) )
832 END IF
833
834 IF (.not.allocated(bmemmax)) THEN
835 allocate ( bmemmax(ngrids) )
836 bmemmax=0.0_r8
837 END IF
838
839 IF (.not.allocated(dmem)) THEN
840 allocate ( dmem(ngrids) )
841 dmem=0.0_r8
842 END IF
843
844#ifdef PROPAGATOR
845 IF (.not.allocated(mstate)) THEN
846 allocate ( mstate(ngrids) )
847 END IF
848 IF (.not.allocated(nstate)) THEN
849 allocate ( nstate(ngrids) )
850 END IF
851 IF (.not.allocated(nstr)) THEN
852 allocate ( nstr(ngrids) )
853 END IF
854 IF (.not.allocated(nend)) THEN
855 allocate ( nend(ngrids) )
856 END IF
857 IF (.not.allocated(nsize)) THEN
858 allocate ( nsize(ngrids) )
859 END IF
860# ifdef SO_SEMI
861 IF (.not.allocated(nsemi)) THEN
862 allocate ( nsemi(ngrids) )
863 END IF
864# endif
865#endif
866
867#ifdef FLOATS
868 IF (.not.allocated(nfloats)) THEN
869 allocate ( nfloats(ngrids) )
870 END IF
871 IF (.not.allocated(nfv)) THEN
872 allocate ( nfv(ngrids) )
873 END IF
874#endif
875
876#ifdef STATIONS
877 IF (.not.allocated(nstation)) THEN
878 allocate ( nstation(ngrids) )
879 END IF
880#endif
881
882#if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC
883 IF (.not.allocated(nbico)) THEN
884 allocate ( nbico(ngrids) )
885 END IF
886#endif
887!
888 RETURN
889 END SUBROUTINE allocate_param
890!
892!
893!=======================================================================
894! !
895! This routine deallocates som of the variables in the module. !
896! Notice that "destroy" cannot be use to deallocate the pointer !
897! variables because of cyclic dependencies. !
898! !
899!=======================================================================
900!
901! Local variable declarations.
902!
903 integer :: ng
904
905#ifdef SUBOBJECT_DEALLOCATION
906!
907!-----------------------------------------------------------------------
908! Deallocate each variable in the derived-type T_BOUNDS structure
909! separately.
910!-----------------------------------------------------------------------
911!
912 DO ng=1,ngrids
913 IF (associated(bounds(ng)%tile)) THEN
914 deallocate ( bounds(ng)%tile )
915 END IF
916!
917 IF (associated(bounds(ng)%LBi)) THEN
918 deallocate ( bounds(ng)%LBi )
919 END IF
920
921 IF (associated(bounds(ng)%UBi)) THEN
922 deallocate ( bounds(ng)%UBi )
923 END IF
924
925 IF (associated(bounds(ng)%LBj)) THEN
926 deallocate ( bounds(ng)%LBj )
927 END IF
928
929 IF (associated(bounds(ng)%UBj)) THEN
930 deallocate ( bounds(ng)%UBj )
931 END IF
932!
933 IF (associated(bounds(ng)%Istr)) THEN
934 deallocate ( bounds(ng)%Istr )
935 END IF
936 IF (associated(bounds(ng)%Iend)) THEN
937 deallocate ( bounds(ng)%Iend )
938 END IF
939 IF (associated(bounds(ng)%Jstr)) THEN
940 deallocate ( bounds(ng)%Jstr )
941 END IF
942 IF (associated(bounds(ng)%Jend)) THEN
943 deallocate ( bounds(ng)%Jend )
944 END IF
945!
946 IF (associated(bounds(ng)%IstrR)) THEN
947 deallocate ( bounds(ng)%IstrR )
948 END IF
949 IF (associated(bounds(ng)%IendR)) THEN
950 deallocate ( bounds(ng)%IendR )
951 END IF
952 IF (associated(bounds(ng)%IstrU)) THEN
953 deallocate ( bounds(ng)%IstrU )
954 END IF
955!
956 IF (associated(bounds(ng)%JstrR)) THEN
957 deallocate ( bounds(ng)%JstrR )
958 END IF
959 IF (associated(bounds(ng)%JendR)) THEN
960 deallocate ( bounds(ng)%JendR )
961 END IF
962 IF (associated(bounds(ng)%JstrV)) THEN
963 deallocate ( bounds(ng)%JstrV )
964 END IF
965!
966 IF (associated(bounds(ng)%IstrB)) THEN
967 deallocate ( bounds(ng)%IstrB )
968 END IF
969 IF (associated(bounds(ng)%IendB)) THEN
970 deallocate ( bounds(ng)%IendB )
971 END IF
972 IF (associated(bounds(ng)%IstrM)) THEN
973 deallocate ( bounds(ng)%IstrM )
974 END IF
975!
976 IF (associated(bounds(ng)%JstrB)) THEN
977 deallocate ( bounds(ng)%JstrB )
978 END IF
979 IF (associated(bounds(ng)%JendB)) THEN
980 deallocate ( bounds(ng)%JendB )
981 END IF
982 IF (associated(bounds(ng)%JstrM)) THEN
983 deallocate ( bounds(ng)%JstrM )
984 END IF
985!
986 IF (associated(bounds(ng)%IstrP)) THEN
987 deallocate ( bounds(ng)%IstrP )
988 END IF
989 IF (associated(bounds(ng)%IendP)) THEN
990 deallocate ( bounds(ng)%IendP )
991 END IF
992 IF (associated(bounds(ng)%JstrP)) THEN
993 deallocate ( bounds(ng)%JstrP )
994 END IF
995 IF (associated(bounds(ng)%JendP)) THEN
996 deallocate ( bounds(ng)%JendP )
997 END IF
998!
999 IF (associated(bounds(ng)%IstrT)) THEN
1000 deallocate ( bounds(ng)%IstrT )
1001 END IF
1002 IF (associated(bounds(ng)%IendT)) THEN
1003 deallocate ( bounds(ng)%IendT )
1004 END IF
1005 IF (associated(bounds(ng)%JstrT)) THEN
1006 deallocate ( bounds(ng)%JstrT )
1007 END IF
1008 IF (associated(bounds(ng)%JendT)) THEN
1009 deallocate ( bounds(ng)%JendT )
1010 END IF
1011!
1012 IF (associated(bounds(ng)%Istrm3)) THEN
1013 deallocate ( bounds(ng)%Istrm3 )
1014 END IF
1015 IF (associated(bounds(ng)%Istrm2)) THEN
1016 deallocate ( bounds(ng)%Istrm2 )
1017 END IF
1018 IF (associated(bounds(ng)%Istrm1)) THEN
1019 deallocate ( bounds(ng)%Istrm1 )
1020 END IF
1021 IF (associated(bounds(ng)%IstrUm2)) THEN
1022 deallocate ( bounds(ng)%IstrUm2 )
1023 END IF
1024 IF (associated(bounds(ng)%IstrUm1)) THEN
1025 deallocate ( bounds(ng)%IstrUm1 )
1026 END IF
1027 IF (associated(bounds(ng)%Iendp1)) THEN
1028 deallocate ( bounds(ng)%Iendp1 )
1029 END IF
1030 IF (associated(bounds(ng)%Iendp2)) THEN
1031 deallocate ( bounds(ng)%Iendp2 )
1032 END IF
1033 IF (associated(bounds(ng)%Iendp2i)) THEN
1034 deallocate ( bounds(ng)%Iendp2i )
1035 END IF
1036 IF (associated(bounds(ng)%Iendp3)) THEN
1037 deallocate ( bounds(ng)%Iendp3 )
1038 END IF
1039!
1040 IF (associated(bounds(ng)%Jstrm3)) THEN
1041 deallocate ( bounds(ng)%Jstrm3 )
1042 END IF
1043 IF (associated(bounds(ng)%Jstrm2)) THEN
1044 deallocate ( bounds(ng)%Jstrm2 )
1045 END IF
1046 IF (associated(bounds(ng)%Jstrm1)) THEN
1047 deallocate ( bounds(ng)%Jstrm1 )
1048 END IF
1049 IF (associated(bounds(ng)%JstrVm2)) THEN
1050 deallocate ( bounds(ng)%JstrVm2 )
1051 END IF
1052 IF (associated(bounds(ng)%JstrVm1)) THEN
1053 deallocate ( bounds(ng)%JstrVm1 )
1054 END IF
1055 IF (associated(bounds(ng)%Jendp1)) THEN
1056 deallocate ( bounds(ng)%Jendp1 )
1057 END IF
1058 IF (associated(bounds(ng)%Jendp2)) THEN
1059 deallocate ( bounds(ng)%Jendp2 )
1060 END IF
1061 IF (associated(bounds(ng)%Jendp2i)) THEN
1062 deallocate ( bounds(ng)%Jendp2i )
1063 END IF
1064 IF (associated(bounds(ng)%Jendp3)) THEN
1065 deallocate ( bounds(ng)%Jendp3 )
1066 END IF
1067!
1068 IF (associated(bounds(ng)%Imin)) THEN
1069 deallocate ( bounds(ng)%Imin )
1070 END IF
1071 IF (associated(bounds(ng)%Imax)) THEN
1072 deallocate ( bounds(ng)%Imax )
1073 END IF
1074 IF (associated(bounds(ng)%Jmin)) THEN
1075 deallocate ( bounds(ng)%Jmin )
1076 END IF
1077 IF (associated(bounds(ng)%Jmax)) THEN
1078 deallocate ( bounds(ng)%Jmax )
1079 END IF
1080 END DO
1081!
1082!-----------------------------------------------------------------------
1083! Deallocate each variable in the derived-type T_DOMAIN structure
1084! separately.
1085!-----------------------------------------------------------------------
1086!
1087 DO ng=1,ngrids
1088 IF (associated(domain(ng)%Eastern_Edge)) THEN
1089 deallocate ( domain(ng)%Eastern_Edge )
1090 END IF
1091 IF (associated(domain(ng)%Western_Edge)) THEN
1092 deallocate ( domain(ng)%Western_Edge )
1093 END IF
1094 IF (associated(domain(ng)%Northern_Edge)) THEN
1095 deallocate ( domain(ng)%Northern_Edge )
1096 END IF
1097 IF (associated(domain(ng)%Southern_Edge)) THEN
1098 deallocate ( domain(ng)%Southern_Edge )
1099 END IF
1100!
1101 IF (associated(domain(ng)%NorthEast_Corner)) THEN
1102 deallocate ( domain(ng)%NorthEast_Corner )
1103 END IF
1104 IF (associated(domain(ng)%NorthWest_Corner)) THEN
1105 deallocate ( domain(ng)%NorthWest_Corner )
1106 END IF
1107 IF (associated(domain(ng)%SouthEast_Corner)) THEN
1108 deallocate ( domain(ng)%SouthEast_Corner )
1109 END IF
1110 IF (associated(domain(ng)%SouthWest_Corner)) THEN
1111 deallocate ( domain(ng)%SouthWest_Corner )
1112 END IF
1113!
1114 IF (associated(domain(ng)%NorthEast_Test)) THEN
1115 deallocate ( domain(ng)%NorthEast_Test )
1116 END IF
1117 IF (associated(domain(ng)%NorthWest_Test)) THEN
1118 deallocate ( domain(ng)%NorthWest_Test )
1119 END IF
1120 IF (associated(domain(ng)%SouthEast_Test)) THEN
1121 deallocate ( domain(ng)%SouthEast_Test )
1122 END IF
1123 IF (associated(domain(ng)%SouthWest_Test)) THEN
1124 deallocate ( domain(ng)%SouthWest_Test )
1125 END IF
1126!
1127 IF (associated(domain(ng)%Xmin_psi)) THEN
1128 deallocate ( domain(ng)%Xmin_psi )
1129 END IF
1130 IF (associated(domain(ng)%Xmax_psi)) THEN
1131 deallocate ( domain(ng)%Xmax_psi )
1132 END IF
1133 IF (associated(domain(ng)%Ymin_psi)) THEN
1134 deallocate ( domain(ng)%Ymin_psi )
1135 END IF
1136 IF (associated(domain(ng)%Ymax_psi)) THEN
1137 deallocate ( domain(ng)%Ymax_psi )
1138 END IF
1139!
1140 IF (associated(domain(ng)%Xmin_rho)) THEN
1141 deallocate ( domain(ng)%Xmin_rho )
1142 END IF
1143 IF (associated(domain(ng)%Xmax_rho)) THEN
1144 deallocate ( domain(ng)%Xmax_rho )
1145 END IF
1146 IF (associated(domain(ng)%Ymin_rho)) THEN
1147 deallocate ( domain(ng)%Ymin_rho )
1148 END IF
1149 IF (associated(domain(ng)%Ymax_rho)) THEN
1150 deallocate ( domain(ng)%Ymax_rho )
1151 END IF
1152!
1153 IF (associated(domain(ng)%Xmin_u)) THEN
1154 deallocate ( domain(ng)%Xmin_u )
1155 END IF
1156 IF (associated(domain(ng)%Xmax_u)) THEN
1157 deallocate ( domain(ng)%Xmax_u )
1158 END IF
1159 IF (associated(domain(ng)%Ymin_u)) THEN
1160 deallocate ( domain(ng)%Ymin_u )
1161 END IF
1162 IF (associated(domain(ng)%Ymax_u)) THEN
1163 deallocate ( domain(ng)%Ymax_u )
1164 END IF
1165!
1166 IF (associated(domain(ng)%Xmin_v)) THEN
1167 deallocate ( domain(ng)%Xmin_v )
1168 END IF
1169 IF (associated(domain(ng)%Xmax_v)) THEN
1170 deallocate ( domain(ng)%Xmax_v )
1171 END IF
1172 IF (associated(domain(ng)%Ymin_v)) THEN
1173 deallocate ( domain(ng)%Ymin_v )
1174 END IF
1175 IF (associated(domain(ng)%Ymax_v)) THEN
1176 deallocate ( domain(ng)%Ymax_v )
1177 END IF
1178 END DO
1179#endif
1180!
1181!-----------------------------------------------------------------------
1182! Deallocate derived-type module structures:
1183!-----------------------------------------------------------------------
1184!
1185 IF (allocated(bounds)) deallocate ( bounds )
1186 IF (allocated(iobounds)) deallocate ( iobounds )
1187 IF (allocated(domain)) deallocate ( domain )
1188#ifdef GRID_EXTRACT
1189 IF (allocated(xtr_bounds)) deallocate ( xtr_bounds )
1190 IF (allocated(xtr_iobounds)) deallocate ( xtr_iobounds )
1191 IF (allocated(xtr_domain)) deallocate ( xtr_domain )
1192#endif
1193#ifdef SOLVE3D
1194 IF (allocated(hadvection)) deallocate ( hadvection )
1195 IF (allocated(vadvection)) deallocate ( vadvection )
1196# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1197 IF (allocated(ad_hadvection)) deallocate ( ad_hadvection )
1198 IF (allocated(ad_vadvection)) deallocate ( ad_vadvection )
1199# endif
1200# if defined TANGENT || defined TL_IOMS
1201 IF (allocated(tl_hadvection)) deallocate ( tl_hadvection )
1202 IF (allocated(tl_vadvection)) deallocate ( tl_vadvection )
1203# endif
1204#endif
1205!
1206!-----------------------------------------------------------------------
1207! Deallocate dimension parameters.
1208!-----------------------------------------------------------------------
1209!
1210 IF (allocated(lm)) deallocate ( lm )
1211 IF (allocated(mm)) deallocate ( mm )
1212 IF (allocated(im)) deallocate ( im )
1213 IF (allocated(jm)) deallocate ( jm )
1214#ifdef GRID_EXTRACT
1215 IF (allocated(xtr_lm)) deallocate ( xtr_lm )
1216 IF (allocated(xtr_mm)) deallocate ( xtr_mm )
1217 IF (allocated(xtr_im)) deallocate ( xtr_im )
1218 IF (allocated(xtr_jm)) deallocate ( xtr_jm )
1219#endif
1220 IF (allocated(n)) deallocate ( n )
1221 IF (allocated(nt)) deallocate ( nt )
1222
1223#if defined TIME_CONV && defined WEAK_CONSTRAINT
1224 IF (allocated(nrectc)) deallocate ( nrectc )
1225#endif
1226
1227 IF (allocated(ntclm)) deallocate ( ntclm )
1228 IF (allocated(nsv)) deallocate ( nsv )
1229
1230 IF (allocated(ntilei)) deallocate ( ntilei )
1231 IF (allocated(ntilej)) deallocate ( ntilej )
1232 IF (allocated(ntilex)) deallocate ( ntilex )
1233 IF (allocated(ntilee)) deallocate ( ntilee )
1234
1235 IF (allocated(halobry)) deallocate ( halobry )
1236 IF (allocated(halosizei)) deallocate ( halosizei )
1237 IF (allocated(halosizej)) deallocate ( halosizej )
1238 IF (allocated(tileside)) deallocate ( tileside )
1239 IF (allocated(tilesize)) deallocate ( tilesize )
1240
1241 IF (allocated(bmemmax)) deallocate ( bmemmax )
1242 IF (allocated(dmem)) deallocate ( dmem )
1243
1244#ifdef PROPAGATOR
1245 IF (allocated(mstate)) deallocate ( mstate )
1246 IF (allocated(nstate)) deallocate ( nstate )
1247 IF (allocated(nstr)) deallocate ( nstr )
1248 IF (allocated(nend)) deallocate ( nend )
1249 IF (allocated(nsize)) deallocate ( nsize )
1250# ifdef SO_SEMI
1251 IF (allocated(nsemi)) deallocate ( nsemi )
1252# endif
1253#endif
1254
1255 IF (allocated(gridsinlayer)) deallocate ( gridsinlayer )
1256 IF (allocated(gridnumber)) deallocate ( gridnumber )
1257
1258#ifdef FLOATS
1259 IF (allocated(nfloats)) deallocate ( nfloats )
1260 IF (allocated(nfv)) deallocate ( nfv )
1261#endif
1262
1263#ifdef STATIONS
1264 IF (allocated(nstation)) deallocate ( nstation )
1265#endif
1266
1267#if defined BALANCE_OPERATOR && defined ZETA_ELLIPTIC
1268 IF (allocated(nbico)) deallocate ( nbico )
1269#endif
1270!
1271 RETURN
1272 END SUBROUTINE deallocate_param
1273!
1275!
1276!=======================================================================
1277! !
1278! This routine initializes several parameters in module "mod_param" !
1279! for all nested grids. !
1280! !
1281!=======================================================================
1282!
1283! Local variable declarations
1284!
1285 integer :: i_padd, j_padd, ntiles
1286 integer :: ibry, itrc, ivar, ng
1287!
1288!-----------------------------------------------------------------------
1289! Now that we know the values for the tile partitions (NtileI,NtileJ),
1290! allocate module structures.
1291!-----------------------------------------------------------------------
1292!
1293! Allocate lower and upper bounds indices structure.
1294!
1295 IF (.not.allocated(bounds)) THEN
1296 allocate ( bounds(ngrids) )
1297 DO ng=1,ngrids
1298
1299 ntiles=ntilei(ng)*ntilej(ng)-1
1300 allocate ( bounds(ng) % tile(-1:ntiles) )
1301
1302 allocate ( bounds(ng) % LBi(-1:ntiles) )
1303 allocate ( bounds(ng) % UBi(-1:ntiles) )
1304 allocate ( bounds(ng) % LBj(-1:ntiles) )
1305 allocate ( bounds(ng) % UBj(-1:ntiles) )
1306
1307 allocate ( bounds(ng) % Istr(-1:ntiles) )
1308 allocate ( bounds(ng) % Iend(-1:ntiles) )
1309 allocate ( bounds(ng) % Jstr(-1:ntiles) )
1310 allocate ( bounds(ng) % Jend(-1:ntiles) )
1311
1312 allocate ( bounds(ng) % IstrR(-1:ntiles) )
1313 allocate ( bounds(ng) % IendR(-1:ntiles) )
1314 allocate ( bounds(ng) % IstrU(-1:ntiles) )
1315 allocate ( bounds(ng) % JstrR(-1:ntiles) )
1316 allocate ( bounds(ng) % JendR(-1:ntiles) )
1317 allocate ( bounds(ng) % JstrV(-1:ntiles) )
1318
1319 allocate ( bounds(ng) % IstrB(-1:ntiles) )
1320 allocate ( bounds(ng) % IendB(-1:ntiles) )
1321 allocate ( bounds(ng) % IstrM(-1:ntiles) )
1322 allocate ( bounds(ng) % JstrB(-1:ntiles) )
1323 allocate ( bounds(ng) % JendB(-1:ntiles) )
1324 allocate ( bounds(ng) % JstrM(-1:ntiles) )
1325
1326 allocate ( bounds(ng) % IstrP(-1:ntiles) )
1327 allocate ( bounds(ng) % IendP(-1:ntiles) )
1328 allocate ( bounds(ng) % IstrT(-1:ntiles) )
1329 allocate ( bounds(ng) % IendT(-1:ntiles) )
1330 allocate ( bounds(ng) % JstrP(-1:ntiles) )
1331 allocate ( bounds(ng) % JendP(-1:ntiles) )
1332 allocate ( bounds(ng) % JstrT(-1:ntiles) )
1333 allocate ( bounds(ng) % JendT(-1:ntiles) )
1334
1335 allocate ( bounds(ng) % Istrm3(-1:ntiles) )
1336 allocate ( bounds(ng) % Istrm2(-1:ntiles) )
1337 allocate ( bounds(ng) % Istrm1(-1:ntiles) )
1338 allocate ( bounds(ng) % IstrUm2(-1:ntiles) )
1339 allocate ( bounds(ng) % IstrUm1(-1:ntiles) )
1340 allocate ( bounds(ng) % Iendp1(-1:ntiles) )
1341 allocate ( bounds(ng) % Iendp2(-1:ntiles) )
1342 allocate ( bounds(ng) % Iendp2i(-1:ntiles) )
1343 allocate ( bounds(ng) % Iendp3(-1:ntiles) )
1344
1345 allocate ( bounds(ng) % Jstrm3(-1:ntiles) )
1346 allocate ( bounds(ng) % Jstrm2(-1:ntiles) )
1347 allocate ( bounds(ng) % Jstrm1(-1:ntiles) )
1348 allocate ( bounds(ng) % JstrVm2(-1:ntiles) )
1349 allocate ( bounds(ng) % JstrVm1(-1:ntiles) )
1350 allocate ( bounds(ng) % Jendp1(-1:ntiles) )
1351 allocate ( bounds(ng) % Jendp2(-1:ntiles) )
1352 allocate ( bounds(ng) % Jendp2i(-1:ntiles) )
1353 allocate ( bounds(ng) % Jendp3(-1:ntiles) )
1354
1355 allocate ( bounds(ng) % Imin(4,0:1,0:ntiles) )
1356 allocate ( bounds(ng) % Imax(4,0:1,0:ntiles) )
1357 allocate ( bounds(ng) % Jmin(4,0:1,0:ntiles) )
1358 allocate ( bounds(ng) % Jmax(4,0:1,0:ntiles) )
1359 END DO
1360 END IF
1361
1362#ifdef GRID_EXTRACT
1363!
1364 IF (.not.allocated(xtr_bounds)) THEN
1365 allocate ( xtr_bounds(ngrids) )
1366 DO ng=1,ngrids
1367
1368 ntiles=ntilei(ng)*ntilej(ng)-1
1369 allocate ( xtr_bounds(ng) % tile(-1:ntiles) )
1370
1371 allocate ( xtr_bounds(ng) % LBi(-1:ntiles) )
1372 allocate ( xtr_bounds(ng) % UBi(-1:ntiles) )
1373 allocate ( xtr_bounds(ng) % LBj(-1:ntiles) )
1374 allocate ( xtr_bounds(ng) % UBj(-1:ntiles) )
1375
1376 allocate ( xtr_bounds(ng) % Istr(-1:ntiles) )
1377 allocate ( xtr_bounds(ng) % Iend(-1:ntiles) )
1378 allocate ( xtr_bounds(ng) % Jstr(-1:ntiles) )
1379 allocate ( xtr_bounds(ng) % Jend(-1:ntiles) )
1380
1381 allocate ( xtr_bounds(ng) % IstrR(-1:ntiles) )
1382 allocate ( xtr_bounds(ng) % IendR(-1:ntiles) )
1383 allocate ( xtr_bounds(ng) % IstrU(-1:ntiles) )
1384 allocate ( xtr_bounds(ng) % JstrR(-1:ntiles) )
1385 allocate ( xtr_bounds(ng) % JendR(-1:ntiles) )
1386 allocate ( xtr_bounds(ng) % JstrV(-1:ntiles) )
1387
1388 allocate ( xtr_bounds(ng) % IstrB(-1:ntiles) )
1389 allocate ( xtr_bounds(ng) % IendB(-1:ntiles) )
1390 allocate ( xtr_bounds(ng) % IstrM(-1:ntiles) )
1391 allocate ( xtr_bounds(ng) % JstrB(-1:ntiles) )
1392 allocate ( xtr_bounds(ng) % JendB(-1:ntiles) )
1393 allocate ( xtr_bounds(ng) % JstrM(-1:ntiles) )
1394
1395 allocate ( xtr_bounds(ng) % IstrP(-1:ntiles) )
1396 allocate ( xtr_bounds(ng) % IendP(-1:ntiles) )
1397 allocate ( xtr_bounds(ng) % IstrT(-1:ntiles) )
1398 allocate ( xtr_bounds(ng) % IendT(-1:ntiles) )
1399 allocate ( xtr_bounds(ng) % JstrP(-1:ntiles) )
1400 allocate ( xtr_bounds(ng) % JendP(-1:ntiles) )
1401 allocate ( xtr_bounds(ng) % JstrT(-1:ntiles) )
1402 allocate ( xtr_bounds(ng) % JendT(-1:ntiles) )
1403
1404 allocate ( xtr_bounds(ng) % Istrm3(-1:ntiles) )
1405 allocate ( xtr_bounds(ng) % Istrm2(-1:ntiles) )
1406 allocate ( xtr_bounds(ng) % Istrm1(-1:ntiles) )
1407 allocate ( xtr_bounds(ng) % IstrUm2(-1:ntiles) )
1408 allocate ( xtr_bounds(ng) % IstrUm1(-1:ntiles) )
1409 allocate ( xtr_bounds(ng) % Iendp1(-1:ntiles) )
1410 allocate ( xtr_bounds(ng) % Iendp2(-1:ntiles) )
1411 allocate ( xtr_bounds(ng) % Iendp2i(-1:ntiles) )
1412 allocate ( xtr_bounds(ng) % Iendp3(-1:ntiles) )
1413
1414 allocate ( xtr_bounds(ng) % Jstrm3(-1:ntiles) )
1415 allocate ( xtr_bounds(ng) % Jstrm2(-1:ntiles) )
1416 allocate ( xtr_bounds(ng) % Jstrm1(-1:ntiles) )
1417 allocate ( xtr_bounds(ng) % JstrVm2(-1:ntiles) )
1418 allocate ( xtr_bounds(ng) % JstrVm1(-1:ntiles) )
1419 allocate ( xtr_bounds(ng) % Jendp1(-1:ntiles) )
1420 allocate ( xtr_bounds(ng) % Jendp2(-1:ntiles) )
1421 allocate ( xtr_bounds(ng) % Jendp2i(-1:ntiles) )
1422 allocate ( xtr_bounds(ng) % Jendp3(-1:ntiles) )
1423
1424 allocate ( xtr_bounds(ng) % Imin(4,0:1,0:ntiles) )
1425 allocate ( xtr_bounds(ng) % Imax(4,0:1,0:ntiles) )
1426 allocate ( xtr_bounds(ng) % Jmin(4,0:1,0:ntiles) )
1427 allocate ( xtr_bounds(ng) % Jmax(4,0:1,0:ntiles) )
1428 END DO
1429 END IF
1430#endif
1431!
1432! DOMAIN structure containing boundary edges switches and fractional
1433! grid lower/upper bounds for each tile.
1434!
1435 IF (.not.allocated(domain)) THEN
1436 allocate ( domain(ngrids) )
1437 DO ng=1,ngrids
1438 ntiles=ntilei(ng)*ntilej(ng)-1
1439
1440 allocate ( domain(ng) % Eastern_Edge(-1:ntiles) )
1441 allocate ( domain(ng) % Western_Edge(-1:ntiles) )
1442 allocate ( domain(ng) % Northern_Edge(-1:ntiles) )
1443 allocate ( domain(ng) % Southern_Edge(-1:ntiles) )
1444
1445 allocate ( domain(ng) % NorthEast_Corner(-1:ntiles) )
1446 allocate ( domain(ng) % NorthWest_Corner(-1:ntiles) )
1447 allocate ( domain(ng) % SouthEast_Corner(-1:ntiles) )
1448 allocate ( domain(ng) % SouthWest_Corner(-1:ntiles) )
1449
1450 allocate ( domain(ng) % NorthEast_Test(-1:ntiles) )
1451 allocate ( domain(ng) % NorthWest_Test(-1:ntiles) )
1452 allocate ( domain(ng) % SouthEast_Test(-1:ntiles) )
1453 allocate ( domain(ng) % SouthWest_Test(-1:ntiles) )
1454
1455 allocate ( domain(ng) % Xmin_psi(0:ntiles) )
1456 allocate ( domain(ng) % Xmax_psi(0:ntiles) )
1457 allocate ( domain(ng) % Ymin_psi(0:ntiles) )
1458 allocate ( domain(ng) % Ymax_psi(0:ntiles) )
1459
1460 allocate ( domain(ng) % Xmin_rho(0:ntiles) )
1461 allocate ( domain(ng) % Xmax_rho(0:ntiles) )
1462 allocate ( domain(ng) % Ymin_rho(0:ntiles) )
1463 allocate ( domain(ng) % Ymax_rho(0:ntiles) )
1464
1465 allocate ( domain(ng) % Xmin_u(0:ntiles) )
1466 allocate ( domain(ng) % Xmax_u(0:ntiles) )
1467 allocate ( domain(ng) % Ymin_u(0:ntiles) )
1468 allocate ( domain(ng) % Ymax_u(0:ntiles) )
1469
1470 allocate ( domain(ng) % Xmin_v(0:ntiles) )
1471 allocate ( domain(ng) % Xmax_v(0:ntiles) )
1472 allocate ( domain(ng) % Ymin_v(0:ntiles) )
1473 allocate ( domain(ng) % Ymax_v(0:ntiles) )
1474 END DO
1475 END IF
1476
1477#ifdef GRID_EXTRACT
1478!
1479 IF (.not.allocated(xtr_domain)) THEN
1480 allocate ( xtr_domain(ngrids) )
1481 DO ng=1,ngrids
1482 ntiles=ntilei(ng)*ntilej(ng)-1
1483
1484 allocate ( xtr_domain(ng) % Eastern_Edge(-1:ntiles) )
1485 allocate ( xtr_domain(ng) % Western_Edge(-1:ntiles) )
1486 allocate ( xtr_domain(ng) % Northern_Edge(-1:ntiles) )
1487 allocate ( xtr_domain(ng) % Southern_Edge(-1:ntiles) )
1488
1489 allocate ( xtr_domain(ng) % NorthEast_Corner(-1:ntiles) )
1490 allocate ( xtr_domain(ng) % NorthWest_Corner(-1:ntiles) )
1491 allocate ( xtr_domain(ng) % SouthEast_Corner(-1:ntiles) )
1492 allocate ( xtr_domain(ng) % SouthWest_Corner(-1:ntiles) )
1493
1494 allocate ( xtr_domain(ng) % NorthEast_Test(-1:ntiles) )
1495 allocate ( xtr_domain(ng) % NorthWest_Test(-1:ntiles) )
1496 allocate ( xtr_domain(ng) % SouthEast_Test(-1:ntiles) )
1497 allocate ( xtr_domain(ng) % SouthWest_Test(-1:ntiles) )
1498
1499 allocate ( xtr_domain(ng) % Xmin_psi(0:ntiles) )
1500 allocate ( xtr_domain(ng) % Xmax_psi(0:ntiles) )
1501 allocate ( xtr_domain(ng) % Ymin_psi(0:ntiles) )
1502 allocate ( xtr_domain(ng) % Ymax_psi(0:ntiles) )
1503
1504 allocate ( xtr_domain(ng) % Xmin_rho(0:ntiles) )
1505 allocate ( xtr_domain(ng) % Xmax_rho(0:ntiles) )
1506 allocate ( xtr_domain(ng) % Ymin_rho(0:ntiles) )
1507 allocate ( xtr_domain(ng) % Ymax_rho(0:ntiles) )
1508
1509 allocate ( xtr_domain(ng) % Xmin_u(0:ntiles) )
1510 allocate ( xtr_domain(ng) % Xmax_u(0:ntiles) )
1511 allocate ( xtr_domain(ng) % Ymin_u(0:ntiles) )
1512 allocate ( xtr_domain(ng) % Ymax_u(0:ntiles) )
1513
1514 allocate ( xtr_domain(ng) % Xmin_v(0:ntiles) )
1515 allocate ( xtr_domain(ng) % Xmax_v(0:ntiles) )
1516 allocate ( xtr_domain(ng) % Ymin_v(0:ntiles) )
1517 allocate ( xtr_domain(ng) % Ymax_v(0:ntiles) )
1518 END DO
1519 END IF
1520#endif
1521!
1522! Allocate lower and upper bounds structure for I/O NetCDF files.
1523!
1524 IF (.not.allocated(iobounds)) THEN
1525 allocate ( iobounds(ngrids) )
1526 END IF
1527
1528#ifdef GRID_EXTRACT
1529!
1530 IF (.not.allocated(xtr_iobounds)) THEN
1531 allocate ( xtr_iobounds(ngrids) )
1532 END IF
1533#endif
1534
1535#ifdef DIAGNOSTICS
1536!
1537!-----------------------------------------------------------------------
1538! Determine number of diagnostic variables.
1539!-----------------------------------------------------------------------
1540
1541# ifdef DIAGNOSTICS_TS
1542!
1543! Tracer diagnostics.
1544!
1545 ndt=6 ! Acceleration, advection, vertical diffusion
1546# if defined TS_DIF2 || defined TS_DIF4
1547 ndt=ndt+3 ! Horizontal (total, X-, Y-) diffusion
1548# if defined MIX_GEO_TS || defined MIX_ISO_TS
1549 ndt=ndt+1 ! Horizontal S-diffusion due to rotated tensor
1550# endif
1551# endif
1552# else
1553 ndt=0 ! No tracer diagnostics
1554# endif
1555# ifdef DIAGNOSTICS_UV
1556!
1557! 2D Momentum diagnostics.
1558!
1559 ndm2d=4 ! Acceleration, 2D P-Gradient, stresses
1560# ifdef UV_ADV
1561 ndm2d=ndm2d+3 ! Horizontal total-, X-, and Y-advection
1562# endif
1563# ifdef WEC_VF
1564# ifdef UV_COR
1565 ndm2d=ndm2d+1 ! Coriolis
1566# endif
1567# ifdef BOTTOM_STREAMING
1568 ndm2d=ndm2d+1 ! Bottom streaming
1569# endif
1570# ifdef SURFACE_STREAMING
1571 ndm2d=ndm2d+1 ! Surface streaming
1572# endif
1573 ndm2d=ndm2d+8 ! zeta, zetaw, zqsp, zbeh (all 4 = prsgrd),
1574 ! K- and Horiz- VF, roller, break
1575# endif
1576# if defined VEGETATION && defined VEG_DRAG
1577 ndm2d=ndm2d+1 ! Resistance imposed on the flow by vegetation
1578# endif
1579# ifdef UV_COR
1580 ndm2d=ndm2d+1 ! Coriolis
1581# endif
1582# if defined UV_VIS2 || defined UV_VIS4
1583 ndm2d=ndm2d+3 ! Horizontal total-, X-, and Y-viscosity
1584# endif
1585# ifdef SOLVE3D
1586!
1587! 3D Momentum diagnostics and right-hand-side terms.
1588!
1589 ndm3d=3 ! Acceleration, 3D P-Gradient, vertical viscosity
1590 ndrhs=1 ! 3D P-Gradient
1591# ifdef UV_ADV
1592 ndm3d=ndm3d+4 ! Horizontal (total, X, Y) and vertical advection
1593 ndrhs=ndrhs+4
1594# endif
1595# ifdef WEC_VF
1596# ifdef UV_COR
1597 ndm3d=ndm3d+1 ! Coriolis
1598 ndrhs=ndrhs+1
1599# endif
1600# ifdef BOTTOM_STREAMING
1601 ndm3d=ndm3d+1 ! Bottom streaming
1602 ndrhs=ndrhs+1
1603# endif
1604# ifdef SURFACE_STREAMING
1605 ndm3d=ndm3d+1 ! Surface streaming
1606 ndrhs=ndrhs+1
1607# endif
1608 ndm3d=ndm3d+5 ! wave break, roller, K- Horiz and Jvert- VF
1609 ndrhs=ndrhs+5
1610# endif
1611# ifdef UV_COR
1612 ndm3d=ndm3d+1 ! Coriolis
1613 ndrhs=ndrhs+1
1614# endif
1615# if defined UV_VIS2 || defined UV_VIS4
1616 ndm3d=ndm3d+3 ! Horizontal (total, X, Y) viscosity
1617# endif
1618# ifdef BODYFORCE
1619 ndrhs=ndrhs+1 ! Vertical viscosity
1620# endif
1621# else
1622 ndm3d=0 ! No 3D momentum diagnostics
1623 ndrhs=0
1624# endif
1625# endif
1626#endif
1627!
1628!-----------------------------------------------------------------------
1629! Derived dimension parameters.
1630!-----------------------------------------------------------------------
1631!
1632 DO ng=1,ngrids
1633 i_padd=(lm(ng)+2)/2-(lm(ng)+1)/2
1634 j_padd=(mm(ng)+2)/2-(mm(ng)+1)/2
1635 im(ng)=lm(ng)+i_padd
1636 jm(ng)=mm(ng)+j_padd
1637 nt(ng)=nat+nbt+nst+npt
1638#ifdef FLOATS
1639!
1640! Number of floats variables.
1641!
1642# ifdef FLOAT_OYSTER
1643# ifdef FLOAT_VWALK
1644 nfv(ng)=nt(ng)+18
1645# else
1646 nfv(ng)=nt(ng)+16
1647# endif
1648# else
1649# ifdef FLOAT_VWALK
1650 nfv(ng)=nt(ng)+12
1651# else
1652 nfv(ng)=nt(ng)+10
1653# endif
1654# endif
1655#endif
1656!
1657! Number of state variables. The order is irrelevant for determining
1658! the "NSV" dimension.
1659!
1660#ifdef SOLVE3D
1661 nsv(ng)=5+nt(ng) ! zeta, ubar, vbar, u, v, Tvar(1:MT)
1662# ifdef ADJUST_STFLUX
1663 nsv(ng)=nsv(ng)+nt(ng) ! Tsur(1:MT)
1664# endif
1665#else
1666 nsv(ng)=3 ! zeta, ubar, vbar
1667#endif
1668#ifdef ADJUST_WSTRESS
1669 nsv(ng)=nsv(ng)+2 ! Ustr, Vstr
1670#endif
1671#ifdef WEC
1672 nsv(ng)=nsv(ng)+2 ! ubar_stokes, vbar_stokes
1673# if defined SOLVE3D
1674 nsv(ng)=nsv(ng)+2 ! u_stokes, v_stokes
1675# endif
1676#endif
1677#ifdef SOLVE3D
1678# if defined GLS_MIXING || defined MY25_MIXING
1679 nsv(ng)=nsv(ng)+1 ! TKE
1680# endif
1681 nsv(ng)=nsv(ng)+1 ! W
1682#endif
1683 END DO
1684!
1685! Set the maximum number of tracers between all nested grids. It cannot
1686! be zero. Usually, NAT=2 (temperature and salinity), but some Test
1687! Cases do not include salinity.
1688!
1689 mt=max(1,max(nat,maxval(nt)))
1690!
1691!-----------------------------------------------------------------------
1692! Allocate Lateral Boundary Conditions switches structure.
1693!-----------------------------------------------------------------------
1694!
1695! Here, "nLBCvar" is larger than needed because it includes unused
1696! state variables that need to be included because of their indices
1697! are in a particular order due to data assimilation variables
1698! associated with the state vector.
1699!
1700#ifdef SOLVE3D
1701 nlbcvar=5+mt ! zeta, ubar, vbar, u, v, Tvar(1:MT)
1702# ifdef ADJUST_STFLUX
1703 nlbcvar=nlbcvar+mt ! Tsur(1:MT); unused
1704# endif
1705#else
1706 nlbcvar=3 ! zeta, ubar, vbar
1707#endif
1708#ifdef ADJUST_WSTRESS
1709 nlbcvar=nlbcvar+2 ! Ustr, Vstr; unused
1710#endif
1711#ifdef WEC
1712 nlbcvar=nlbcvar+2 ! ubar_stokes, vbar_stokes
1713# ifdef SOLVE3D
1714 nlbcvar=nlbcvar+2 ! u_stokes, v_stokes
1715# endif
1716#endif
1717#ifdef SOLVE3D
1718# if defined GLS_MIXING || defined MY25_MIXING
1719 nlbcvar=nlbcvar+1 ! TKE
1720# endif
1721#endif
1722#ifdef ICE_MODEL
1723 nlbcvar=nlbcvar+11 ! ICE varibles up to isVice=11
1724#endif
1725!
1726 IF (.not.allocated(lbc)) THEN
1727 allocate ( lbc(4,nlbcvar,ngrids) )
1728 DO ng=1,ngrids
1729 DO ivar=1,nlbcvar
1730 DO ibry=1,4
1731 lbc(ibry,ivar,ng)%acquire = .false.
1732 lbc(ibry,ivar,ng)%Chapman_explicit = .false.
1733 lbc(ibry,ivar,ng)%Chapman_implicit = .false.
1734 lbc(ibry,ivar,ng)%clamped = .false.
1735 lbc(ibry,ivar,ng)%closed = .false.
1736 lbc(ibry,ivar,ng)%Flather = .false.
1737 lbc(ibry,ivar,ng)%gradient = .false.
1738 lbc(ibry,ivar,ng)%mixed = .false.
1739 lbc(ibry,ivar,ng)%nested = .false.
1740 lbc(ibry,ivar,ng)%nudging = .false.
1741 lbc(ibry,ivar,ng)%periodic = .false.
1742 lbc(ibry,ivar,ng)%radiation = .false.
1743 lbc(ibry,ivar,ng)%reduced = .false.
1744 lbc(ibry,ivar,ng)%Shchepetkin = .false.
1745 END DO
1746 END DO
1747 END DO
1748 END IF
1749#if defined ADJOINT || defined TANGENT || defined TL_IOMS
1750 IF (.not.allocated(ad_lbc)) THEN
1751 allocate ( ad_lbc(4,nlbcvar,ngrids) )
1752 DO ng=1,ngrids
1753 DO ivar=1,nlbcvar
1754 DO ibry=1,4
1755 ad_lbc(ibry,ivar,ng)%acquire = .false.
1756 ad_lbc(ibry,ivar,ng)%Chapman_implicit = .false.
1757 ad_lbc(ibry,ivar,ng)%Chapman_explicit = .false.
1758 ad_lbc(ibry,ivar,ng)%clamped = .false.
1759 ad_lbc(ibry,ivar,ng)%closed = .false.
1760 ad_lbc(ibry,ivar,ng)%Flather = .false.
1761 ad_lbc(ibry,ivar,ng)%gradient = .false.
1762 ad_lbc(ibry,ivar,ng)%mixed = .false.
1763 ad_lbc(ibry,ivar,ng)%nested = .false.
1764 ad_lbc(ibry,ivar,ng)%nudging = .false.
1765 ad_lbc(ibry,ivar,ng)%periodic = .false.
1766 ad_lbc(ibry,ivar,ng)%radiation = .false.
1767 ad_lbc(ibry,ivar,ng)%reduced = .false.
1768 ad_lbc(ibry,ivar,ng)%Shchepetkin = .false.
1769 END DO
1770 END DO
1771 END DO
1772 END IF
1773#endif
1774#if defined TANGENT || defined TL_IOMS
1775 IF (.not.allocated(tl_lbc)) THEN
1776 allocate ( tl_lbc(4,nlbcvar,ngrids) )
1777 DO ng=1,ngrids
1778 DO ivar=1,nlbcvar
1779 DO ibry=1,4
1780 tl_lbc(ibry,ivar,ng)%acquire = .false.
1781 tl_lbc(ibry,ivar,ng)%Chapman_implicit = .false.
1782 tl_lbc(ibry,ivar,ng)%Chapman_explicit = .false.
1783 tl_lbc(ibry,ivar,ng)%clamped = .false.
1784 tl_lbc(ibry,ivar,ng)%closed = .false.
1785 tl_lbc(ibry,ivar,ng)%Flather = .false.
1786 tl_lbc(ibry,ivar,ng)%gradient = .false.
1787 tl_lbc(ibry,ivar,ng)%mixed = .false.
1788 tl_lbc(ibry,ivar,ng)%nested = .false.
1789 tl_lbc(ibry,ivar,ng)%nudging = .false.
1790 tl_lbc(ibry,ivar,ng)%periodic =.false.
1791 tl_lbc(ibry,ivar,ng)%radiation = .false.
1792 tl_lbc(ibry,ivar,ng)%reduced = .false.
1793 tl_lbc(ibry,ivar,ng)%Shchepetkin = .false.
1794 END DO
1795 END DO
1796 END DO
1797 END IF
1798#endif
1799#ifdef SOLVE3D
1800!
1801!-----------------------------------------------------------------------
1802! Allocate rracer horizontal and vertical advection switches structure.
1803!-----------------------------------------------------------------------
1804!
1805! Nonlinear model kernel.
1806!
1807 IF (.not.allocated(hadvection)) THEN
1808 allocate ( hadvection(maxval(nt),ngrids) )
1809 DO ng=1,ngrids
1810 DO itrc=1,nt(ng)
1811 hadvection(itrc,ng)%AKIMA4 = .false.
1812 hadvection(itrc,ng)%CENTERED2 = .false.
1813 hadvection(itrc,ng)%CENTERED4 = .false.
1814 hadvection(itrc,ng)%HSIMT = .false.
1815 hadvection(itrc,ng)%MPDATA = .false.
1816 hadvection(itrc,ng)%SPLINES = .false.
1817 hadvection(itrc,ng)%SPLIT_U3 = .false.
1818 hadvection(itrc,ng)%UPSTREAM3 = .false.
1819 END DO
1820 END DO
1821 END IF
1822!
1823 IF (.not.allocated(vadvection)) THEN
1824 allocate ( vadvection(maxval(nt),ngrids) )
1825 DO ng=1,ngrids
1826 DO itrc=1,nt(ng)
1827 vadvection(itrc,ng)%AKIMA4 = .false.
1828 vadvection(itrc,ng)%CENTERED2 = .false.
1829 vadvection(itrc,ng)%CENTERED4 = .false.
1830 vadvection(itrc,ng)%HSIMT = .false.
1831 vadvection(itrc,ng)%MPDATA = .false.
1832 vadvection(itrc,ng)%SPLINES = .false.
1833 vadvection(itrc,ng)%SPLIT_U3 = .false.
1834 vadvection(itrc,ng)%UPSTREAM3 = .false.
1835 END DO
1836 END DO
1837 END IF
1838
1839# if defined ADJOINT || defined TANGENT || defined TL_IOMS
1840!
1841! Adjoint model kernel.
1842!
1843 IF (.not.allocated(ad_hadvection)) THEN
1844 allocate ( ad_hadvection(maxval(nt),ngrids) )
1845 DO ng=1,ngrids
1846 DO itrc=1,nt(ng)
1847 ad_hadvection(itrc,ng)%AKIMA4 = .false.
1848 ad_hadvection(itrc,ng)%CENTERED2 = .false.
1849 ad_hadvection(itrc,ng)%CENTERED4 = .false.
1850 ad_hadvection(itrc,ng)%HSIMT = .false.
1851 ad_hadvection(itrc,ng)%MPDATA = .false.
1852 ad_hadvection(itrc,ng)%SPLINES = .false.
1853 ad_hadvection(itrc,ng)%SPLIT_U3 = .false.
1854 ad_hadvection(itrc,ng)%UPSTREAM3 = .false.
1855 END DO
1856 END DO
1857 END IF
1858!
1859 IF (.not.allocated(ad_vadvection)) THEN
1860 allocate ( ad_vadvection(maxval(nt),ngrids) )
1861 DO ng=1,ngrids
1862 DO itrc=1,nt(ng)
1863 ad_vadvection(itrc,ng)%AKIMA4 = .false.
1864 ad_vadvection(itrc,ng)%CENTERED2 = .false.
1865 ad_vadvection(itrc,ng)%CENTERED4 = .false.
1866 ad_vadvection(itrc,ng)%HSIMT = .false.
1867 ad_vadvection(itrc,ng)%MPDATA = .false.
1868 ad_vadvection(itrc,ng)%SPLINES = .false.
1869 ad_vadvection(itrc,ng)%SPLIT_U3 = .false.
1870 ad_vadvection(itrc,ng)%UPSTREAM3 = .false.
1871 END DO
1872 END DO
1873 END IF
1874# endif
1875# if defined TANGENT || defined TL_IOMS
1876!
1877! Perturbation or finite-amplitude tangent linear model kernels.
1878!
1879 IF (.not.allocated(tl_hadvection)) THEN
1880 allocate ( tl_hadvection(maxval(nt),ngrids) )
1881 DO ng=1,ngrids
1882 DO itrc=1,nt(ng)
1883 tl_hadvection(itrc,ng)%AKIMA4 = .false.
1884 tl_hadvection(itrc,ng)%CENTERED2 = .false.
1885 tl_hadvection(itrc,ng)%CENTERED4 = .false.
1886 tl_hadvection(itrc,ng)%HSIMT = .false.
1887 tl_hadvection(itrc,ng)%MPDATA = .false.
1888 tl_hadvection(itrc,ng)%SPLINES = .false.
1889 tl_hadvection(itrc,ng)%SPLIT_U3 = .false.
1890 tl_hadvection(itrc,ng)%UPSTREAM3 = .false.
1891 END DO
1892 END DO
1893 END IF
1894!
1895 IF (.not.allocated(tl_vadvection)) THEN
1896 allocate ( tl_vadvection(maxval(nt),ngrids) )
1897 DO ng=1,ngrids
1898 DO itrc=1,nt(ng)
1899 tl_vadvection(itrc,ng)%AKIMA4 = .false.
1900 tl_vadvection(itrc,ng)%CENTERED2 = .false.
1901 tl_vadvection(itrc,ng)%CENTERED4 = .false.
1902 tl_vadvection(itrc,ng)%HSIMT = .false.
1903 tl_vadvection(itrc,ng)%MPDATA = .false.
1904 tl_vadvection(itrc,ng)%SPLINES = .false.
1905 tl_vadvection(itrc,ng)%SPLIT_U3 = .false.
1906 tl_vadvection(itrc,ng)%UPSTREAM3 = .false.
1907 END DO
1908 END DO
1909 END IF
1910# endif
1911#endif
1912!
1913 RETURN
1914 END SUBROUTINE initialize_param
1915
1916 END MODULE mod_param
integer, parameter r8
Definition mod_kinds.F:28
type(t_adv), dimension(:,:), allocatable hadvection
Definition mod_param.F:403
type(t_lbc), dimension(:,:,:), allocatable ad_lbc
Definition mod_param.F:378
type(t_adv), dimension(:,:), allocatable tl_hadvection
Definition mod_param.F:411
integer nat
Definition mod_param.F:499
integer ndrhs
Definition mod_param.F:590
integer, parameter u2dobc
Definition mod_param.F:729
integer, dimension(:), allocatable tilesize
Definition mod_param.F:705
integer, dimension(:), allocatable nbico
Definition mod_param.F:619
integer ndbio2d
Definition mod_param.F:584
integer, dimension(:), allocatable nfv
Definition mod_param.F:547
integer, dimension(:), allocatable nrectc
Definition mod_param.F:627
integer, dimension(:), allocatable nfloats
Definition mod_param.F:543
integer, parameter v3dobc
Definition mod_param.F:733
integer, dimension(:), allocatable nsv
Definition mod_param.F:636
type(t_adv), dimension(:,:), allocatable ad_hadvection
Definition mod_param.F:407
integer, parameter inlm
Definition mod_param.F:662
integer, dimension(:), allocatable im
Definition mod_param.F:465
integer nbed
Definition mod_param.F:517
integer, parameter r2dobc
Definition mod_param.F:728
integer, dimension(:), allocatable ntclm
Definition mod_param.F:494
integer, dimension(:), allocatable nstate
Definition mod_param.F:645
integer, parameter irpm
Definition mod_param.F:664
integer, dimension(:), allocatable n
Definition mod_param.F:479
integer, dimension(:), allocatable mstate
Definition mod_param.F:644
type(t_bounds), dimension(:), allocatable bounds
Definition mod_param.F:232
integer, dimension(:), allocatable nstr
Definition mod_param.F:646
integer, dimension(:,:), allocatable gridnumber
Definition mod_param.F:127
integer, parameter b3dvar
Definition mod_param.F:725
integer mtc
Definition mod_param.F:564
type(t_lbc), dimension(:,:,:), allocatable tl_lbc
Definition mod_param.F:379
integer, dimension(:), allocatable ntilex
Definition mod_param.F:685
integer, parameter r3dvar
Definition mod_param.F:721
integer, dimension(:), allocatable jm
Definition mod_param.F:466
integer, parameter r3dobc
Definition mod_param.F:731
integer, dimension(:), allocatable halobry
Definition mod_param.F:691
subroutine, public deallocate_param
Definition mod_param.F:892
real(r8), dimension(:), allocatable dmem
Definition mod_param.F:137
integer, parameter l4dvar
Definition mod_param.F:727
integer ndbio4d
Definition mod_param.F:586
integer, parameter v2dobc
Definition mod_param.F:730
integer, dimension(:), allocatable halosizei
Definition mod_param.F:696
integer ncs
Definition mod_param.F:525
type(t_iobounds), dimension(:), allocatable iobounds
Definition mod_param.F:282
integer nghostpoints
Definition mod_param.F:710
integer nbt
Definition mod_param.F:509
integer, dimension(:), allocatable halosizej
Definition mod_param.F:697
integer nlbcvar
Definition mod_param.F:355
type(t_adv), dimension(:,:), allocatable tl_vadvection
Definition mod_param.F:412
integer, parameter iadm
Definition mod_param.F:665
integer, dimension(:), allocatable nsize
Definition mod_param.F:648
integer, parameter u3dobc
Definition mod_param.F:732
integer, dimension(:), allocatable nstation
Definition mod_param.F:557
type(t_lbc), dimension(:,:,:), allocatable lbc
Definition mod_param.F:375
integer nestlayers
Definition mod_param.F:118
integer, parameter u3dvar
Definition mod_param.F:722
integer, parameter nft
Definition mod_param.F:539
type(t_domain), dimension(:), allocatable domain
Definition mod_param.F:329
integer, dimension(:), allocatable lm
Definition mod_param.F:455
integer, parameter u2dvar
Definition mod_param.F:718
integer, dimension(:), allocatable nsemi
Definition mod_param.F:655
integer ndm3d
Definition mod_param.F:579
character(len=3), dimension(4) kernelstring
Definition mod_param.F:667
integer ngrids
Definition mod_param.F:113
type(t_adv), dimension(:,:), allocatable vadvection
Definition mod_param.F:404
real(r8), dimension(:), allocatable bmemmax
Definition mod_param.F:132
integer ndt
Definition mod_param.F:574
integer, dimension(:), allocatable ntilee
Definition mod_param.F:686
integer mt
Definition mod_param.F:490
integer, parameter itlm
Definition mod_param.F:663
integer, dimension(:), allocatable nend
Definition mod_param.F:647
integer, dimension(:), allocatable ntilei
Definition mod_param.F:677
integer, parameter w3dvar
Definition mod_param.F:724
integer, parameter p2dvar
Definition mod_param.F:716
subroutine, public allocate_param
Definition mod_param.F:738
integer, dimension(:), allocatable nt
Definition mod_param.F:489
integer ndbio3d
Definition mod_param.F:585
integer, dimension(:), allocatable gridsinlayer
Definition mod_param.F:122
integer, dimension(:), allocatable mm
Definition mod_param.F:456
integer, dimension(:), allocatable tileside
Definition mod_param.F:701
integer nsa
Definition mod_param.F:612
integer, parameter r2dvar
Definition mod_param.F:717
integer nns
Definition mod_param.F:529
type(t_adv), dimension(:,:), allocatable ad_vadvection
Definition mod_param.F:408
integer, parameter l3dvar
Definition mod_param.F:726
integer npt
Definition mod_param.F:505
integer, parameter v2dvar
Definition mod_param.F:719
integer nst
Definition mod_param.F:521
integer, parameter p3dvar
Definition mod_param.F:720
subroutine, public initialize_param
Definition mod_param.F:1275
integer, parameter v3dvar
Definition mod_param.F:723
integer ndm2d
Definition mod_param.F:578
integer, dimension(:), allocatable ntilej
Definition mod_param.F:678