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.F90 in NEMO/trunk/src/OCE/CRS – NEMO

source: NEMO/trunk/src/OCE/CRS/crs.F90 @ 13286

Last change on this file since 13286 was 13286, checked in by smasson, 4 years ago

trunk: merge extra halos branch in trunk, see #2366

  • Property svn:keywords set to Id
File size: 17.4 KB
Line 
1MODULE crs   
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, C. Calone) Original code
8   !!----------------------------------------------------------------------
9   USE par_oce 
10   USE dom_oce
11   USE in_out_manager
12
13   IMPLICIT NONE
14   PUBLIC
15
16   PUBLIC crs_dom_alloc  ! Called from crsini.F90
17   PUBLIC crs_dom_alloc2  ! Called from crsini.F90
18   PUBLIC dom_grid_glo   
19   PUBLIC dom_grid_crs 
20
21      ! Domain variables
22      INTEGER  ::  jpiglo_crs ,   &             !: 1st dimension of global coarse grid domain
23                   jpjglo_crs                   !: 2nd dimension of global coarse grid domain
24      INTEGER  ::  jpi_crs ,   &                !: 1st dimension of local coarse grid domain
25                   jpj_crs                      !: 2nd dimension of local coarse grid domain
26      INTEGER  ::  jpi_full ,  &                !: 1st dimension of local parent grid domain
27                   jpj_full                     !: 2nd dimension of local parent grid domain
28
29      INTEGER  ::  nistr , njstr
30      INTEGER  ::  niend , njend
31
32      INTEGER  ::  jpi_crsm1, jpj_crsm1         !: loop indices     
33      INTEGER  ::  jpiglo_crsm1, jpjglo_crsm1   !: loop indices     
34      INTEGER  ::  nperio_full, nperio_crs      !: jperio of parent and coarse grids
35      INTEGER  ::  npolj_full, npolj_crs        !: north fold mark
36      INTEGER  ::  jpiglo_full, jpjglo_full     !: jpiglo / jpjglo
37      INTEGER  ::  npiglo, npjglo               !: jpjglo
38      INTEGER  ::  Nis0_full, Njs0_full         !: starting indices of internal sub-domain on parent grid
39      INTEGER  ::  Nie0_full, Nje0_full         !: ending indices of internal sub-domain on parent grid
40      INTEGER  ::  Nis0_crs , Njs0_crs          !: starting indices of internal sub-domain on coarse grid
41      INTEGER  ::  Nie0_crs , Nje0_crs          !: ending indices of internal sub-domain on coarse grid
42
43      INTEGER  ::  narea_full, narea_crs        !: node
44      INTEGER  ::  jpnij_full, jpnij_crs        !: =jpni*jpnj, the pe decomposition
45      INTEGER  ::  jpim1_full, jpjm1_full       !:
46      INTEGER  ::  nimpp_full, njmpp_full       !: global position of point (1,1) of subdomain on parent grid
47      INTEGER  ::  nimpp_crs, njmpp_crs         !: set to 1,1 for now .  Valid only for monoproc
48      !cc
49      INTEGER ::   noea_full, nowe_full        !: index of the local neighboring processors in
50      INTEGER ::   noso_full, nono_full        !: east, west, south and north directions
51      INTEGER ::   npne_full, npnw_full        !: index of north east and north west processor
52      INTEGER ::   npse_full, npsw_full        !: index of south east and south west processor
53      INTEGER ::   nbne_full, nbnw_full        !: logical of north east & north west processor
54      INTEGER ::   nbse_full, nbsw_full        !: logical of south east & south west processor
55      INTEGER ::   nidom_full                  !: ???
56      INTEGER ::   nproc_full                  !:number for local processor
57      INTEGER ::   nbondi_full, nbondj_full    !: mark of i- and j-direction local boundaries
58      INTEGER ::   noea_crs, nowe_crs          !: index of the local neighboring processors in
59      INTEGER ::   noso_crs, nono_crs          !: east, west, south and north directions
60      INTEGER ::   npne_crs, npnw_crs          !: index of north east and north west processor
61      INTEGER ::   npse_crs, npsw_crs          !: index of south east and south west processor
62      INTEGER ::   nbne_crs, nbnw_crs          !: logical of north east & north west processor
63      INTEGER ::   nbse_crs, nbsw_crs          !: logical of south east & south west processor
64      INTEGER ::   nidom_crs                   !: ???
65      INTEGER ::   nproc_crs                   !:number for local processor
66      INTEGER ::   nbondi_crs, nbondj_crs      !: mark of i- and j-direction local boundaries
67     
68
69      INTEGER, DIMENSION(:), ALLOCATABLE :: mis_crs, mie_crs, mis2_crs, mie2_crs  ! starting and ending i-indices of parent subset
70      INTEGER, DIMENSION(:), ALLOCATABLE :: mjs_crs, mje_crs, mjs2_crs, mje2_crs ! starting and ending  j-indices of parent subset
71      INTEGER, DIMENSION(:), ALLOCATABLE :: mjg_crs, mig_crs
72      INTEGER, DIMENSION(:), ALLOCATABLE :: mi0_crs, mi1_crs, mj0_crs, mj1_crs
73      INTEGER  :: mxbinctr, mybinctr            ! central point in grid box
74      INTEGER, DIMENSION(:), ALLOCATABLE ::    jpiall_crs,  jpiall_full   !: dimensions of every subdomain
75      INTEGER, DIMENSION(:), ALLOCATABLE ::   nis0all_crs, nis0all_full   !: first, last indoor index for each i-domain
76      INTEGER, DIMENSION(:), ALLOCATABLE ::   nie0all_crs, nie0all_full   !: first, last indoor index for each j-domain
77      INTEGER, DIMENSION(:), ALLOCATABLE ::    nimppt_crs,  nimppt_full   !: first, last indoor index for each j-domain
78      INTEGER, DIMENSION(:), ALLOCATABLE ::    jpjall_crs,  jpjall_full   !: dimensions of every subdomain
79      INTEGER, DIMENSION(:), ALLOCATABLE ::   njs0all_crs, njs0all_full   !: first, last indoor index for each i-domain
80      INTEGER, DIMENSION(:), ALLOCATABLE ::   nje0all_crs, nje0all_full   !: first, last indoor index for each j-domain
81      INTEGER, DIMENSION(:), ALLOCATABLE ::    njmppt_crs,  njmppt_full   !: first, last indoor index for each j-domain
82
83 
84      ! Masks
85      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: tmask_crs, umask_crs, vmask_crs, fmask_crs
86      REAL(wp), DIMENSION(:,:)  , ALLOCATABLE :: rnfmsk_crs
87     
88      ! Scale factors
89      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: e1t_crs, e2t_crs, e1e2t_crs ! horizontal scale factors grid type T
90      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: e1u_crs, e2u_crs ! horizontal scale factors grid type U
91      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: e1v_crs, e2v_crs ! horizontal scale factors grid type V
92      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: e1f_crs, e2f_crs ! horizontal scale factors grid type F
93      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: e3t_crs, e3u_crs, e3v_crs, e3f_crs, e3w_crs
94      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: e3t_max_crs, e3u_max_crs, e3v_max_crs, e3f_max_crs, e3w_max_crs
95     
96      ! Surface
97      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: e1e2w_crs, e2e3u_crs, e1e3v_crs
98      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: e1e2w_msk, e2e3u_msk, e1e3v_msk
99                                                                  ! vertical scale factors
100      ! Coordinates
101      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: gphit_crs, glamt_crs, gphif_crs, glamf_crs 
102      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: gphiu_crs, glamu_crs, gphiv_crs, glamv_crs 
103      REAL(wp), DIMENSION(:,:),   ALLOCATABLE :: ff_crs
104      INTEGER,  DIMENSION(:,:),   ALLOCATABLE :: mbathy_crs, mbkt_crs, mbku_crs, mbkv_crs
105      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: gdept_crs, gdepu_crs, gdepv_crs, gdepw_crs
106
107      ! Weights
108      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: facsurfv, facsurfu, facvol_t, facvol_w
109      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ocean_volume_crs_t, ocean_volume_crs_w, bt_crs, r1_bt_crs
110      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: crs_surfu_wgt, crs_surfv_wgt, crs_surfw_wgt, crs_volt_wgt
111
112      ! CRS Namelist
113      INTEGER           :: nn_factx   = 3       !: reduction factor of x-dimension of the parent grid
114      INTEGER           :: nn_facty   = 3       !: reduction factor of y-dimension of the parent grid
115      INTEGER           :: nn_binref  = 0       !: 0 = binning starts north fold (equator could be asymmetric)
116                                                !: 1 = binning centers at equator (north fold my have artifacts)     
117                                                !:    for even reduction factors, equator placed in bin biased south
118      LOGICAL           :: ln_msh_crs   = .TRUE.   !: =T Create a meshmask file for CRS
119      INTEGER           :: nn_crs_kz    =    0     !: type of Kz coarsening ( =0->VOL ; =1->MAX ; =2->MIN)
120      LOGICAL           :: ln_crs_wn    = .FALSE.  !: coarsening wn or computation using horizontal divergence
121      !
122      INTEGER           :: nrestx, nresty       !: for determining odd or even reduction factor
123
124
125      ! Grid reduction factors
126      REAL(wp)     ::  rfactx_r                !: inverse of x-dim reduction factor
127      REAL(wp)     ::  rfacty_r                !: inverse of y-dim reduction factor
128      REAL(wp)     ::  rfactxy 
129
130      ! Physical and dynamical ocean fields for output or passing to TOP, time-mean fields
131      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE      :: tsn_crs
132      REAL(wp), DIMENSION(:,:,:)  , ALLOCATABLE      :: un_crs, vn_crs, wn_crs
133      REAL(wp), DIMENSION(:,:,:)  , ALLOCATABLE      :: hdivn_crs   
134      REAL(wp), DIMENSION(:,:)    , ALLOCATABLE      :: sshn_crs   
135      !
136      ! Surface fluxes to pass to TOP
137      REAL(wp), PUBLIC, DIMENSION(:,:)  , ALLOCATABLE :: qsr_crs, fr_i_crs, wndm_crs
138      REAL(wp), PUBLIC, DIMENSION(:,:)  , ALLOCATABLE :: emp_crs, emp_b_crs, sfx_crs
139      REAL(wp), PUBLIC, DIMENSION(:,:)  , ALLOCATABLE :: utau_crs, vtau_crs
140      REAL(wp), PUBLIC, DIMENSION(:,:)  , ALLOCATABLE :: rnf_crs
141
142      ! Vertical diffusion
143      REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:)  ::  avt_crs           !: temperature vertical diffusivity coeff. [m2/s] at w-point
144      REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:)  ::  avs_crs           !: salinity    vertical diffusivity coeff. [m2/s] at w-point
145
146      ! Mixing and Mixed Layer Depth
147      INTEGER,  PUBLIC, ALLOCATABLE, DIMENSION(:,:)    ::  nmln_crs, hmld_crs, hmlp_crs, hmlpt_crs                       
148
149   !!----------------------------------------------------------------------
150   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
151   !! $Id$
152   !! Software governed by the CeCILL license (see ./LICENSE)
153   !!----------------------------------------------------------------------
154CONTAINS
155   
156   INTEGER FUNCTION crs_dom_alloc()
157      !!-------------------------------------------------------------------
158      !!                     *** FUNCTION crs_dom_alloc ***
159      !!  ** Purpose :   Allocate public crs arrays 
160      !!-------------------------------------------------------------------
161      !! Local variables
162      INTEGER, DIMENSION(17) :: ierr
163
164      ierr(:) = 0
165
166      ! Set up bins for coarse grid, horizontal only.
167     ALLOCATE( mis2_crs(jpiglo_crs), mie2_crs(jpiglo_crs),  &
168       &       mjs2_crs(jpjglo_crs), mje2_crs(jpjglo_crs),  &
169       &       mi0_crs (jpiglo_crs), mi1_crs (jpiglo_crs),  &
170       &       mj0_crs (jpjglo_crs), mj1_crs (jpjglo_crs),  &
171       &       mig_crs (jpi_crs)   , mjg_crs (jpj_crs)   ,  STAT=ierr(1) ) 
172
173
174      ! Set up Mask and Mesh
175      ALLOCATE( tmask_crs(jpi_crs,jpj_crs,jpk) , fmask_crs(jpi_crs,jpj_crs,jpk) ,  &
176         &      umask_crs(jpi_crs,jpj_crs,jpk) , vmask_crs(jpi_crs,jpj_crs,jpk) , STAT=ierr(2))
177
178      ALLOCATE( rnfmsk_crs(jpi_crs,jpj_crs), STAT=ierr(3) )
179
180      ALLOCATE( gphit_crs(jpi_crs,jpj_crs) , glamt_crs(jpi_crs,jpj_crs) , & 
181         &      gphiu_crs(jpi_crs,jpj_crs) , glamu_crs(jpi_crs,jpj_crs) , &
182         &      gphiv_crs(jpi_crs,jpj_crs) , glamv_crs(jpi_crs,jpj_crs) , &
183         &      gphif_crs(jpi_crs,jpj_crs) , glamf_crs(jpi_crs,jpj_crs) , &
184         &      ff_crs(jpi_crs,jpj_crs)    , STAT=ierr(4))
185
186      ALLOCATE( e1t_crs(jpi_crs,jpj_crs) , e2t_crs(jpi_crs,jpj_crs) , & 
187         &      e1u_crs(jpi_crs,jpj_crs) , e2u_crs(jpi_crs,jpj_crs) , & 
188         &      e1v_crs(jpi_crs,jpj_crs) , e2v_crs(jpi_crs,jpj_crs) , &
189         &      e1f_crs(jpi_crs,jpj_crs) , e2f_crs(jpi_crs,jpj_crs) , &
190         &      e1e2t_crs(jpi_crs,jpj_crs), STAT=ierr(5))
191
192      ALLOCATE( e3t_crs(jpi_crs,jpj_crs,jpk)    , e3w_crs(jpi_crs,jpj_crs,jpk)    , & 
193         &      e3u_crs(jpi_crs,jpj_crs,jpk)    , e3v_crs(jpi_crs,jpj_crs,jpk)    , &
194         &      e3f_crs(jpi_crs,jpj_crs,jpk)    , e1e2w_msk(jpi_crs,jpj_crs,jpk)  , & 
195         &      e2e3u_msk(jpi_crs,jpj_crs,jpk)  , e1e3v_msk(jpi_crs,jpj_crs,jpk)  , &
196         &      e1e2w_crs(jpi_crs,jpj_crs,jpk)  , e2e3u_crs(jpi_crs,jpj_crs,jpk)  , &
197         &      e1e3v_crs(jpi_crs,jpj_crs,jpk)  , e3t_max_crs(jpi_crs,jpj_crs,jpk), &
198         &      e3w_max_crs(jpi_crs,jpj_crs,jpk), e3u_max_crs(jpi_crs,jpj_crs,jpk), &
199         &      e3v_max_crs(jpi_crs,jpj_crs,jpk), STAT=ierr(6))
200
201
202      ALLOCATE( facsurfv(jpi_crs,jpj_crs,jpk), facsurfu(jpi_crs,jpj_crs,jpk) , & 
203         &      facvol_t(jpi_crs,jpj_crs,jpk), facvol_w(jpi_crs,jpj_crs,jpk) , &
204         &      ocean_volume_crs_t(jpi_crs,jpj_crs,jpk), ocean_volume_crs_w(jpi_crs,jpj_crs,jpk), &
205         &      bt_crs(jpi_crs,jpj_crs,jpk)  , r1_bt_crs(jpi_crs,jpj_crs,jpk) , STAT=ierr(7))
206
207
208      ALLOCATE( crs_surfu_wgt(jpi_crs,jpj_crs,jpk), crs_surfv_wgt(jpi_crs,jpj_crs,jpk) , & 
209         &      crs_surfw_wgt(jpi_crs,jpj_crs,jpk), crs_volt_wgt(jpi_crs,jpj_crs,jpk) , STAT=ierr(8))
210
211
212      ALLOCATE( mbathy_crs(jpi_crs,jpj_crs), mbkt_crs(jpi_crs,jpj_crs) , &
213         &      mbku_crs(jpi_crs,jpj_crs)  , mbkv_crs(jpi_crs,jpj_crs) , STAT=ierr(9))
214
215      ALLOCATE( gdept_crs(jpi_crs,jpj_crs,jpk), gdepu_crs(jpi_crs,jpj_crs,jpk) , &
216         &      gdepv_crs(jpi_crs,jpj_crs,jpk), gdepw_crs(jpi_crs,jpj_crs,jpk) , STAT=ierr(10) )
217
218
219      ALLOCATE( un_crs(jpi_crs,jpj_crs,jpk) , vn_crs   (jpi_crs,jpj_crs,jpk) ,     &
220         &      wn_crs(jpi_crs,jpj_crs,jpk) , hdivn_crs(jpi_crs,jpj_crs,jpk) , STAT=ierr(11))
221
222     ALLOCATE( sshn_crs(jpi_crs,jpj_crs), emp_crs (jpi_crs,jpj_crs), emp_b_crs(jpi_crs,jpj_crs), &
223         &     qsr_crs(jpi_crs ,jpj_crs), wndm_crs(jpi_crs,jpj_crs), utau_crs(jpi_crs,jpj_crs) , &
224         &     vtau_crs(jpi_crs,jpj_crs), rnf_crs(jpi_crs ,jpj_crs), &
225         &     fr_i_crs(jpi_crs,jpj_crs), sfx_crs(jpi_crs ,jpj_crs),  STAT=ierr(12)  )
226
227     ALLOCATE( tsn_crs(jpi_crs,jpj_crs,jpk,jpts), avt_crs(jpi_crs,jpj_crs,jpk),   &
228         &                                        avs_crs(jpi_crs,jpj_crs,jpk), STAT=ierr(13) )
229
230      ALLOCATE( nmln_crs(jpi_crs,jpj_crs) , hmld_crs(jpi_crs,jpj_crs) , &
231         &      hmlp_crs(jpi_crs,jpj_crs) , hmlpt_crs(jpi_crs,jpj_crs) , STAT=ierr(14) )
232         
233      ALLOCATE( nimppt_crs (jpnij) , jpiall_crs (jpnij) , nis0all_crs (jpnij) , nie0all_crs (jpnij),   &
234         &      nimppt_full(jpnij) , jpiall_full(jpnij) , nis0all_full(jpnij) , nie0all_full(jpnij),   &
235                njmppt_crs (jpnij) , jpjall_crs (jpnij) , njs0all_crs (jpnij) , nje0all_crs (jpnij),   &
236         &      njmppt_full(jpnij) , jpjall_full(jpnij) , njs0all_full(jpnij) , nje0all_full(jpnij)  , STAT=ierr(15) )
237   
238      crs_dom_alloc = MAXVAL(ierr)
239      !
240   END FUNCTION crs_dom_alloc
241
242
243   INTEGER FUNCTION crs_dom_alloc2()
244      !!-------------------------------------------------------------------
245      !!                     *** FUNCTION crs_dom_alloc ***
246      !!  ** Purpose :   Allocate public crs arrays 
247      !!-------------------------------------------------------------------
248      !! Local variables
249      INTEGER, DIMENSION(1) :: ierr
250
251      ierr(:) = 0
252     
253      ALLOCATE( mjs_crs(Nje0_crs) , mje_crs(Nje0_crs), mis_crs(Nie0_crs) , mie_crs(Nie0_crs), STAT=ierr(1) )
254      crs_dom_alloc2 = MAXVAL(ierr)
255
256   END FUNCTION crs_dom_alloc2
257
258
259   SUBROUTINE dom_grid_glo
260      !!--------------------------------------------------------------------
261      !!                       ***  MODULE dom_grid_glo  ***
262      !!
263      !! ** Purpose : +Return back to parent grid domain
264      !!---------------------------------------------------------------------
265
266      !                         Return to parent grid domain
267      jpi    = jpi_full
268      jpj    = jpj_full
269      jpim1  = jpim1_full
270      jpjm1  = jpjm1_full
271      jperio = nperio_full
272
273      npolj  = npolj_full
274      jpiglo = jpiglo_full
275      jpjglo = jpjglo_full
276
277      jpi   = jpi_full
278      jpj   = jpj_full
279      Nis0  = Nis0_full
280      Njs0  = Njs0_full
281      Nie0  = Nie0_full
282      Nje0  = Nje0_full
283      nimpp = nimpp_full
284      njmpp = njmpp_full
285     
286      jpiall (:) = jpiall_full (:)
287      nis0all(:) = nis0all_full(:)
288      nie0all(:) = nie0all_full(:)
289      nimppt (:) = nimppt_full (:)
290      jpjall (:) = jpjall_full (:)
291      njs0all(:) = njs0all_full(:)
292      nje0all(:) = nje0all_full(:)
293      njmppt (:) = njmppt_full (:)
294
295   END SUBROUTINE dom_grid_glo
296
297
298   SUBROUTINE dom_grid_crs
299      !!--------------------------------------------------------------------
300      !!                       ***  MODULE dom_grid_crs  ***
301      !!
302      !! ** Purpose :  Save the parent grid information & Switch to coarse grid domain
303      !!---------------------------------------------------------------------
304      !
305      !                        Switch to coarse grid domain
306      jpi    = jpi_crs
307      jpj    = jpj_crs
308      jpim1  = jpi_crsm1
309      jpjm1  = jpj_crsm1
310      jperio = nperio_crs
311
312      npolj  = npolj_crs
313      jpiglo = jpiglo_crs
314      jpjglo = jpjglo_crs
315
316
317      jpi   = jpi_crs
318      jpj   = jpj_crs
319      Nis0  = Nis0_crs
320      Nie0  = Nie0_crs
321      Nje0  = Nje0_crs
322      Njs0  = Njs0_crs
323      nimpp = nimpp_crs
324      njmpp = njmpp_crs
325     
326      jpiall (:) = jpiall_crs (:)
327      nis0all(:) = nis0all_crs(:)
328      nie0all(:) = nie0all_crs(:)
329      nimppt (:) = nimppt_crs (:)
330      jpjall (:) = jpjall_crs (:)
331      njs0all(:) = njs0all_crs(:)
332      nje0all(:) = nje0all_crs(:)
333      njmppt (:) = njmppt_crs (:)
334      !
335   END SUBROUTINE dom_grid_crs
336   
337   !!======================================================================
338END MODULE crs
339
Note: See TracBrowser for help on using the repository browser.