New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
crs_dom.F90 in branches/2013/dev_r3411_CNRS4_IOCRS/NEMOGCM/NEMO/OPA_SRC/CRS – NEMO

source: branches/2013/dev_r3411_CNRS4_IOCRS/NEMOGCM/NEMO/OPA_SRC/CRS/crs_dom.F90 @ 3622

Last change on this file since 3622 was 3622, checked in by cetlod, 11 years ago

branch 2013/dev_r3411_CNRS4_IOCRS : 1st inputs of I/O coarsening, see ticket #1009

File size: 13.7 KB
Line 
1MODULE crs_dom   
2   !!======================================================================
3   !!                         ***  MODULE crs_dom  ***
4   !!        Declare the coarse grid domain and other public variables
5   !!        then allocate them if needed.
6   !!======================================================================
7   !!  History     2012-06  Editing  (J. Simeon, G. Madec, C. Ethe) Original code
8   !!----------------------------------------------------------------------
9   USE dom_oce,  ONLY: jpk         ! For parameters in par_oce (jperio, lk_vvl) 
10   USE par_kind, ONLY: wp
11   USE par_oce,  ONLY: jpts
12
13   IMPLICIT NONE
14
15   PUBLIC crs_dom_alloc  ! Called from crsini.F90
16
17      ! Domain variables
18      INTEGER  ::  jpiglo_crs ,   &             !: 1st dimension of global coarse grid domain
19                   jpjglo_crs                   !: 2nd dimension of global coarse grid domain
20      INTEGER  ::  jpi_crs ,   &                !: 1st dimension of local coarse grid domain
21                   jpj_crs                      !: 2nd dimension of local coarse grid domain
22      INTEGER  ::  jpi_full ,  &                !: 1st dimension of local parent grid domain
23                   jpj_full                     !: 2nd dimension of local parent grid domain
24
25      INTEGER  ::  jpi_crsm1, jpj_crsm1         !: loop indices     
26      INTEGER  ::  jpiglo_crsm1, jpjglo_crsm1   !: loop indices     
27      INTEGER  ::  nperio_full, nperio_crs      !: jperio of parent and coarse grids
28      INTEGER  ::  npolj_full, npolj_crs        !: north fold mark
29      INTEGER  ::  npiglo_full, npiglo_crs      !: jpiglo
30      INTEGER  ::  npjglo_full, npjglo_crs      !: jpjglo
31      INTEGER  ::  nlci_full, nlcj_full         !: i-, j-dimension of local or sub domain on parent grid
32      INTEGER  ::  nldi_full, nldj_full         !: starting indices of internal sub-domain on parent grid
33      INTEGER  ::  nlei_full, nlej_full         !: ending indices of internal sub-domain on parent grid
34      INTEGER  ::  nlci_crs, nlcj_crs           !: i-, j-dimension of local or sub domain on coarse grid
35      INTEGER  ::  nldi_crs, nldj_crs           !: starting indices of internal sub-domain on coarse grid
36      INTEGER  ::  nlei_crs, nlej_crs           !: ending indices of internal sub-domain on coarse grid
37      INTEGER  ::  narea_full, narea_crs        !: node
38      INTEGER  ::  jpnij_full, jpnij_crs        !: =jpni*jpnj, the pe decomposition
39      INTEGER  ::  jpim1_full, jpjm1_full       !:
40      INTEGER  ::  nimpp_full, njmpp_full       !: global position of point (1,1) of subdomain on parent grid
41      INTEGER  ::  nimpp_crs, njmpp_crs         !: set to 1,1 for now .  Valid only for monoproc
42
43
44      INTEGER, DIMENSION(:), ALLOCATABLE :: mis_crs, mie_crs, mjs_crs, mje_crs
45                                                ! starting and ending indices of parent subset
46      INTEGER  :: mxbinctr, mybinctr            ! central point in grid box
47 
48      ! Masks
49      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: tmask_crs, umask_crs, vmask_crs, fmask_crs
50      REAL(wp), DIMENSION(:,:)  , ALLOCATABLE :: tmask_i_crs, rnfmsk_crs     
51
52      ! Scale factors
53      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: e1t_crs, e2t_crs, e1e2t_crs ! horizontal scale factors grid type T
54      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: e1u_crs, e2u_crs ! horizontal scale factors grid type U
55      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: e1v_crs, e2v_crs ! horizontal scale factors grid type V
56      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: e1f_crs, e2f_crs ! horizontal scale factors grid type F
57      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: e3t_crs, e3u_crs, e3v_crs, e3w_crs
58      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: fse3t_crs, fse3u_crs, fse3v_crs, fse3w_crs
59      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: fse3t_n_crs, fse3t_b_crs, fse3t_a_crs
60
61                                                                  ! vertical scale factors
62      ! Coordinates
63      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: gphit_crs, glamt_crs, gphif_crs, glamf_crs 
64      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: gphiu_crs, glamu_crs, gphiv_crs, glamv_crs 
65      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: ff_crs
66      INTEGER,  DIMENSION(:,:),   ALLOCATABLE :: mbathy_crs, mbkt_crs, mbku_crs, mbkv_crs
67      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: gdept_crs, gdepu_crs, gdepv_crs, gdepw_crs
68
69      ! Weights
70      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: facsurfv, facsurfu, facvol_t, facvol_w
71      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ocean_volume_crs_t, ocean_volume_crs_w
72      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: crs_surfu_wgt, crs_surfv_wgt, crs_surfw_wgt, crs_volt_wgt
73
74      ! CRS Namelist
75      INTEGER           :: nn_factx   = 3       !: reduction factor of x-dimension of the parent grid
76      INTEGER           :: nn_facty   = 3       !: reduction factor of y-dimension of the parent grid
77      CHARACTER(len=5)  :: cn_binref  = 'NORTH' !: NORTH = binning starts north fold (equator could be asymmetric)
78                                                !: EQUAT = binning centers at equator (north fold my have artifacts)     
79                                                !:    for even reduction factors, equator placed in bin biased south
80      INTEGER           :: nn_fcrs    = 3       !: frequence of coarsening
81      INTEGER           :: nn_msh_crs = 1       !: Organization of mesh mask output
82                                                !: 0 = no mesh mask output
83                                                !: 1 = unified mesh mask output
84                                                !: 2 = 2 separate mesh mask output
85                                                !: 3 = 3 separate mesh mask output
86      CHARACTER(len=11) :: cn_ocerstcrs         !: root name of restart files for coarsened variables
87         
88      ! Grid reduction factors
89      REAL(wp)     ::  rfactx_r                !: inverse of x-dim reduction factor
90      REAL(wp)     ::  rfacty_r                !: inverse of y-dim reduction factor
91      REAL(wp)     ::  rfactxy 
92
93      !! Horizontal grid parameters for domhgr
94      !! =====================================
95      INTEGER  ::   nphgr_msh_crs = 0   !: type of horizontal mesh
96      !                                 !  = 0 curvilinear coordinate on the sphere read in coordinate.nc
97      !                                 !  = 1 geographical mesh on the sphere with regular grid-spacing
98      !                                 !  = 2 f-plane with regular grid-spacing
99      !                                 !  = 3 beta-plane with regular grid-spacing
100      !                                 !  = 4 Mercator grid with T/U point at the equator
101     
102      ! Physical and dynamical ocean fields for output or passing to TOP, time-mean fields
103!      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE      :: tsn_crs, tsb_crs, tsa_crs
104!      REAL(wp), DIMENSION(:,:,:)  , ALLOCATABLE      :: un_crs, vn_crs, wn_crs
105!      REAL(wp), DIMENSION(:,:,:)  , ALLOCATABLE      :: ut_crs, vt_crs, wt_crs, us_crs, vs_crs, ws_crs
106!      REAL(wp), DIMENSION(:,:,:)  , ALLOCATABLE      :: rhd_crs, rhop_crs, hdivn_crs   
107!      REAL(wp), DIMENSION(:,:)    , ALLOCATABLE      :: sshb_crs, sshn_crs, ssha_crs   
108!      REAL(wp), DIMENSION(:,:)    , ALLOCATABLE      :: sshun_crs, sshvn_crs, sshfn_crs
109!      REAL(wp), DIMENSION(:,:)    , ALLOCATABLE      :: sshub_crs, sshvb_crs, sshua_crs, sshva_crs
110!      REAL(wp), DIMENSION(:,:)    , ALLOCATABLE      :: hu_crs, hv_crs
111!      REAL(wp), DIMENSION(:,:)    , ALLOCATABLE      :: hdivbt_crs
112!      REAL(wp), DIMENSION(:,:)    , ALLOCATABLE      :: ssh_b_crs, ssh_a_crs, ssh_un_crs, ssh_vn_crs        ! instantaneous fields
113
114
115      !
116      ! Surface fluxes to pass to TOP
117 !     REAL(wp), DIMENSION(:,:)  , ALLOCATABLE      ::  utau_crs, vtau_crs, wndm_crs, qsr_crs
118 !     REAL(wp), DIMENSION(:,:)  , ALLOCATABLE      ::  del_emp_crs, sum_emp_crs
119 !     REAL(wp), DIMENSION(:,:)  , ALLOCATABLE      ::  emp_crs, emp_b_crs, emps_crs
120 !     REAL(wp), DIMENSION(:,:)  , ALLOCATABLE      ::  rnf_crs, fr_i_crs, h_rnf_crs
121   
122      !
123      ! Lateral diffusivity (tracers) to pass to TOP
124!      REAL(wp)                                     ::  rldf_crs, rn_aht_0_crs, aht0_crs, ahtb0_crs
125
126!#if defined key_traldf_c3d
127!      REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:) ::   ahtt_crs, ahtu_crs, ahtv_crs, ahtw_crs   !: 3D coefficients at T-,U-,V-,W-points
128!      REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:) ::   aeiu_crs, aeiv_crs, aeiw_crs   
129!#elif defined key_traldf_c2d
130!      REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:)   ::   ahtt_crs, ahtu_crs, ahtv_crs, ahtw_crs   !: 2D coefficients at T-,U-,V-,W-points
131!      REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:)   ::   aeiu_crs, aeiv_crs, aeiw_crs   
132!#elif defined key_traldf_c1d
133!      REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:)     ::   ahtt_crs, ahtu_crs, ahtv_crs, ahtw_crs   !: 1D coefficients at T-,U-,V-,W-points
134!      REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:)     ::   aeiu_crs, aeiv_crs, aeiw_crs   
135!#else
136!      REAL(wp), PUBLIC                                ::   ahtt_crs, ahtu_crs, ahtv_crs, ahtw_crs   !: scalar coefficients at T-,U-,V-,W-points
137!#endif
138
139 
140      ! Vertical diffusion
141!      REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:)  ::  avt_crs           !: vert. diffusivity coef. [m2/s] at w-point for temp 
142!# if defined key_zdfddm
143!      REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:)  ::  avs_crs           !: salinity vertical diffusivity coeff. [m2/s] at w-point
144!# endif
145
146      ! Mixing and Mixed Layer Depth
147!      INTEGER,  PUBLIC, ALLOCATABLE, DIMENSION(:,:)    ::  nmln_crs, hmld_crs, hmlp_crs, hmlpt_crs                       
148
149      ! Direction of lateral diffusion
150
151
152
153CONTAINS
154   
155   INTEGER FUNCTION crs_dom_alloc()
156      !!-------------------------------------------------------------------
157      !!                     *** FUNCTION crs_dom_alloc ***
158      !!  ** Purpose :   Allocate public crs arrays 
159      !!-------------------------------------------------------------------
160      !! Local variables
161      INTEGER, DIMENSION(10) :: ierr
162
163      ierr(:) = 0
164
165      ! Set up bins for coarse grid, horizontal only.
166      ALLOCATE( mis_crs(jpiglo_crs) , mie_crs(jpiglo_crs) , mjs_crs(jpjglo_crs) , mje_crs(jpjglo_crs), STAT=ierr(1) )
167
168      ! Set up Mask and Mesh
169
170      ALLOCATE( tmask_crs(jpi_crs,jpj_crs,jpk) , fmask_crs(jpi_crs,jpj_crs,jpk) ,  &
171         &      umask_crs(jpi_crs,jpj_crs,jpk) , vmask_crs(jpi_crs,jpj_crs,jpk) , STAT=ierr(2))
172
173      ALLOCATE( tmask_i_crs(jpi_crs,jpj_crs), rnfmsk_crs(jpi_crs,jpj_crs), STAT=ierr(3) )
174
175      ALLOCATE( gphit_crs(jpi_crs,jpj_crs) , glamt_crs(jpi_crs,jpj_crs) , & 
176         &      gphiu_crs(jpi_crs,jpj_crs) , glamu_crs(jpi_crs,jpj_crs) , &
177         &      gphiv_crs(jpi_crs,jpj_crs) , glamv_crs(jpi_crs,jpj_crs) , &
178         &      gphif_crs(jpi_crs,jpj_crs) , glamf_crs(jpi_crs,jpj_crs) , &
179         &      ff_crs(jpi_crs,jpj_crs)    , STAT=ierr(4))
180
181      ALLOCATE( e1t_crs(jpi_crs,jpj_crs) , e2t_crs(jpi_crs,jpj_crs) , & 
182         &      e1u_crs(jpi_crs,jpj_crs) , e2u_crs(jpi_crs,jpj_crs) , & 
183         &      e1v_crs(jpi_crs,jpj_crs) , e2v_crs(jpi_crs,jpj_crs) , &
184         &      e1f_crs(jpi_crs,jpj_crs) , e2f_crs(jpi_crs,jpj_crs) , &
185         &      e1e2t_crs(jpi_crs,jpj_crs), STAT=ierr(5))
186
187      ALLOCATE( fse3t_crs(jpi_crs,jpj_crs,jpk)  , fse3w_crs(jpi_crs,jpj_crs,jpk) , & 
188         &      fse3u_crs(jpi_crs,jpj_crs,jpk)  , fse3v_crs(jpi_crs,jpj_crs,jpk) , & 
189         &      e3t_crs(jpi_crs,jpj_crs,jpk)    , e3w_crs(jpi_crs,jpj_crs,jpk)   , & 
190         &      e3u_crs(jpi_crs,jpj_crs,jpk)    , e3v_crs(jpi_crs,jpj_crs,jpk)   , &
191         &      fse3t_b_crs(jpi_crs,jpj_crs,jpk), fse3t_n_crs(jpi_crs,jpj_crs,jpk),&
192         &      fse3t_a_crs(jpi_crs,jpj_crs,jpk), STAT=ierr(6))
193
194
195      ALLOCATE( facsurfv(jpi_crs,jpj_crs,jpk) , facsurfu(jpi_crs,jpj_crs,jpk) , & 
196         &      facvol_t(jpi_crs,jpj_crs,jpk) , facvol_w(jpi_crs,jpj_crs,jpk) , &
197         &      ocean_volume_crs_t(jpi_crs,jpj_crs,jpk) , ocean_volume_crs_w(jpi_crs,jpj_crs,jpk) , STAT=ierr(7))
198
199
200      ALLOCATE( crs_surfu_wgt(jpi_crs,jpj_crs,jpk) , crs_surfv_wgt(jpi_crs,jpj_crs,jpk) , & 
201         &      crs_surfw_wgt(jpi_crs,jpj_crs,jpk) , crs_volt_wgt(jpi_crs,jpj_crs,jpk) , STAT=ierr(8))
202
203
204      ALLOCATE( mbathy_crs(jpi_crs,jpj_crs) , mbkt_crs(jpi_crs,jpj_crs) , &
205         &      mbku_crs(jpi_crs,jpj_crs)   , mbkv_crs(jpi_crs,jpj_crs) , STAT=ierr(9))
206
207      ALLOCATE( gdept_crs(jpi_crs,jpj_crs,jpk) , gdepu_crs(jpi_crs,jpj_crs,jpk) , &
208         &      gdepv_crs(jpi_crs,jpj_crs,jpk) , gdepw_crs(jpi_crs,jpj_crs,jpk) , STAT=ierr(10) )
209
210
211!      ALLOCATE( un_crs(jpi_crs,jpj_crs,jpk) ,   vn_crs(jpi_crs,jpj_crs,jpk) , &
212!         &      wn_crs(jpi_crs,jpj_crs,jpk) ,                                 &
213!         &      ut_crs(jpi_crs,jpj_crs,jpk) ,   vt_crs(jpi_crs,jpj_crs,jpk) , &
214!         &      us_crs(jpi_crs,jpj_crs,jpk) ,   vs_crs(jpi_crs,jpj_crs,jpk) , &
215!         &      wt_crs(jpi_crs,jpj_crs,jpk) ,   ws_crs(jpi_crs,jpj_crs,jpk) , &
216!         &     rhd_crs(jpi_crs,jpj_crs,jpk) , rhop_crs(jpi_crs,jpj_crs,jpk) , &
217!         &      STAT=ierr(11))
218
219!      ALLOCATE( sshb_crs(jpi_crs,jpj_crs)   , sshn_crs(jpi_crs,jpj_crs)   , &
220!         &      sshun_crs(jpi_crs,jpj_crs)  , sshvn_crs(jpi_crs,jpj_crs)  , &
221!         &      sshfn_crs(jpi_crs,jpj_crs)  , emp_crs(jpi_crs,jpj_crs)    , &
222!         &      del_emp_crs(jpi_crs,jpj_crs), sum_emp_crs(jpi_crs,jpj_crs), &
223!         &      emp_b_crs(jpi_crs,jpj_crs)  , emps_crs(jpi_crs,jpj_crs)   , &
224!         &      ssh_b_crs(jpi_crs,jpj_crs)  , ssh_a_crs(jpi_crs,jpj_crs)  , &
225!         &      STAT=ierr(12)  )
226 
227!      ALLOCATE( tsn_crs(jpi_crs,jpj_crs,jpk,jpts) , tsb_crs(jpi_crs,jpj_crs,jpk,jpts) , &
228!         &     tsa_crs(jpi_crs,jpj_crs,jpk,jpts) , STAT=ierr(13) )
229
230      crs_dom_alloc = MAXVAL(ierr)
231
232   END FUNCTION crs_dom_alloc
233   
234   !!======================================================================
235
236END MODULE crs_dom
237
Note: See TracBrowser for help on using the repository browser.