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.
agrif_user.F90 in branches/2014/dev_r4765_CNRS_agrif/NEMOGCM/NEMO/NST_SRC – NEMO

source: branches/2014/dev_r4765_CNRS_agrif/NEMOGCM/NEMO/NST_SRC/agrif_user.F90 @ 4790

Last change on this file since 4790 was 4790, checked in by rblod, 10 years ago

dev_r4765_CNRS_agrif : update AGRIF for LIM2

  • Property svn:keywords set to Id
File size: 29.4 KB
Line 
1#if defined key_agrif
2!!----------------------------------------------------------------------
3!! NEMO/NST 3.4 , NEMO Consortium (2012)
4!! $Id$
5!! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
6!!----------------------------------------------------------------------
7SUBROUTINE agrif_user
8END SUBROUTINE agrif_user
9
10SUBROUTINE agrif_before_regridding
11END SUBROUTINE agrif_before_regridding
12
13SUBROUTINE Agrif_InitWorkspace
14   !!----------------------------------------------------------------------
15   !!                 *** ROUTINE Agrif_InitWorkspace ***
16   !!----------------------------------------------------------------------
17   USE par_oce
18   USE dom_oce
19   USE Agrif_Util
20   USE nemogcm
21   !
22   IMPLICIT NONE
23   !!----------------------------------------------------------------------
24   !
25   IF( .NOT. Agrif_Root() ) THEN
26      jpni = Agrif_Parent(jpni)
27      jpnj = Agrif_Parent(jpnj)
28      jpnij = Agrif_Parent(jpnij)
29      jpiglo  = nbcellsx + 2 + 2*nbghostcells
30      jpjglo  = nbcellsy + 2 + 2*nbghostcells
31      jpi     = ( jpiglo-2*jpreci + (jpni-1+0) ) / jpni + 2*jpreci
32      jpj     = ( jpjglo-2*jprecj + (jpnj-1+0) ) / jpnj + 2*jprecj
33      jpk     = jpkdta 
34      jpim1   = jpi-1 
35      jpjm1   = jpj-1 
36      jpkm1   = jpk-1                                         
37      jpij    = jpi*jpj 
38      jpidta  = jpiglo
39      jpjdta  = jpjglo
40      jpizoom = 1
41      jpjzoom = 1
42      nperio  = 0
43      jperio  = 0
44   ENDIF
45   !
46END SUBROUTINE Agrif_InitWorkspace
47
48
49SUBROUTINE Agrif_InitValues
50   !!----------------------------------------------------------------------
51   !!                 *** ROUTINE Agrif_InitValues ***
52   !!
53   !! ** Purpose :: Declaration of variables to be interpolated
54   !!----------------------------------------------------------------------
55   USE Agrif_Util
56   USE oce 
57   USE dom_oce
58   USE nemogcm
59   USE tradmp
60   USE bdy_par
61
62   IMPLICIT NONE
63   !!----------------------------------------------------------------------
64   ! 0. Initializations
65   !-------------------
66   IF( cp_cfg == 'orca' ) THEN
67      IF ( jp_cfg == 2 .OR. jp_cfg == 025 .OR. jp_cfg == 05 &
68            &                      .OR. jp_cfg == 4 ) THEN
69         jp_cfg = -1    ! set special value for jp_cfg on fine grids
70         cp_cfg = "default"
71      ENDIF
72   ENDIF
73   ! Specific fine grid Initializations
74   ! no tracer damping on fine grids
75   ln_tradmp = .FALSE.
76   ! no open boundary on fine grids
77   lk_bdy = .FALSE.
78
79
80   CALL nemo_init  ! Initializations of each fine grid
81
82   CALL agrif_nemo_init
83   CALL Agrif_InitValues_cont_dom
84# if ! defined key_offline
85   CALL Agrif_InitValues_cont
86# endif       
87# if defined key_top
88   CALL Agrif_InitValues_cont_top
89# endif     
90END SUBROUTINE Agrif_initvalues
91
92
93SUBROUTINE Agrif_InitValues_cont_dom
94   !!----------------------------------------------------------------------
95   !!                 *** ROUTINE Agrif_InitValues_cont ***
96   !!
97   !! ** Purpose ::   Declaration of variables to be interpolated
98   !!----------------------------------------------------------------------
99   USE Agrif_Util
100   USE oce 
101   USE dom_oce
102   USE nemogcm
103   USE sol_oce
104   USE in_out_manager
105   USE agrif_opa_update
106   USE agrif_opa_interp
107   USE agrif_opa_sponge
108   !
109   IMPLICIT NONE
110   !
111   !!----------------------------------------------------------------------
112
113   ! Declaration of the type of variable which have to be interpolated
114   !---------------------------------------------------------------------
115   CALL agrif_declare_var_dom
116   !
117END SUBROUTINE Agrif_InitValues_cont_dom
118
119
120SUBROUTINE agrif_declare_var_dom
121   !!----------------------------------------------------------------------
122   !!                 *** ROUTINE agrif_declare_var ***
123   !!
124   !! ** Purpose :: Declaration of variables to be interpolated
125   !!----------------------------------------------------------------------
126   USE agrif_util
127   USE par_oce       
128   USE oce
129   IMPLICIT NONE
130   !!----------------------------------------------------------------------
131
132   ! 1. Declaration of the type of variable which have to be interpolated
133   !---------------------------------------------------------------------
134   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),e1u_id)
135   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),e2v_id)
136
137   ! 2. Type of interpolation
138   !-------------------------
139   CALL Agrif_Set_bcinterp(e1u_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
140   CALL Agrif_Set_bcinterp(e2v_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
141
142   ! 3. Location of interpolation
143   !-----------------------------
144   CALL Agrif_Set_bc(e1u_id,(/0,0/))
145   CALL Agrif_Set_bc(e2v_id,(/0,0/))
146
147   ! 5. Update type
148   !---------------
149   CALL Agrif_Set_Updatetype(e1u_id,update1 = Agrif_Update_Copy, update2=Agrif_Update_Average)
150   CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Copy)
151
152END SUBROUTINE agrif_declare_var_dom
153
154
155# if ! defined key_offline
156
157SUBROUTINE Agrif_InitValues_cont
158   !!----------------------------------------------------------------------
159   !!                 *** ROUTINE Agrif_InitValues_cont ***
160   !!
161   !! ** Purpose ::   Declaration of variables to be interpolated
162   !!----------------------------------------------------------------------
163   USE Agrif_Util
164   USE oce 
165   USE dom_oce
166   USE nemogcm
167   USE sol_oce
168   USE lib_mpp
169   USE in_out_manager
170   USE agrif_opa_update
171   USE agrif_opa_interp
172   USE agrif_opa_sponge
173   !
174   IMPLICIT NONE
175   !
176   LOGICAL :: check_namelist
177   CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3
178   !!----------------------------------------------------------------------
179
180   ! 1. Declaration of the type of variable which have to be interpolated
181   !---------------------------------------------------------------------
182   CALL agrif_declare_var
183
184   ! 2. First interpolations of potentially non zero fields
185   !-------------------------------------------------------
186   Agrif_SpecialValue=0.
187   Agrif_UseSpecialValue = .TRUE.
188   CALL Agrif_Bc_variable(tsn_id,calledweight=1.,procname=interptsn)
189   CALL Agrif_Sponge
190   tabspongedone_tsn = .FALSE.
191   CALL Agrif_Bc_variable(tsn_sponge_id,calledweight=1.,procname=interptsn_sponge)
192   ! reset tsa to zero
193   tsa(:,:,:,:) = 0.
194
195   Agrif_UseSpecialValue = ln_spc_dyn
196   CALL Agrif_Bc_variable(un_interp_id,calledweight=1.,procname=interpun)
197   CALL Agrif_Bc_variable(vn_interp_id,calledweight=1.,procname=interpvn)
198   tabspongedone_u = .FALSE.
199   tabspongedone_v = .FALSE.
200   CALL Agrif_Bc_variable(un_sponge_id,calledweight=1.,procname=interpun_sponge)
201   tabspongedone_u = .FALSE.
202   tabspongedone_v = .FALSE.
203   CALL Agrif_Bc_variable(vn_sponge_id,calledweight=1.,procname=interpvn_sponge)
204
205#if defined key_dynspg_ts
206   CALL Agrif_Bc_variable(sshn_id,calledweight=1.,procname=interpsshn)
207   CALL Agrif_Bc_variable(unb_id,calledweight=1.,procname=interpunb)
208   CALL Agrif_Bc_variable(vnb_id,calledweight=1.,procname=interpvnb)
209   CALL Agrif_Bc_variable(ub2b_interp_id,calledweight=1.,procname=interpub2b)
210   CALL Agrif_Bc_variable(vb2b_interp_id,calledweight=1.,procname=interpvb2b)
211   ubdy_w(:) = 0.e0 ; vbdy_w(:) = 0.e0 ; hbdy_w(:) =0.e0
212   ubdy_e(:) = 0.e0 ; vbdy_e(:) = 0.e0 ; hbdy_e(:) =0.e0 
213   ubdy_n(:) = 0.e0 ; vbdy_n(:) = 0.e0 ; hbdy_n(:) =0.e0 
214   ubdy_s(:) = 0.e0 ; vbdy_s(:) = 0.e0 ; hbdy_s(:) =0.e0
215#endif
216
217   Agrif_UseSpecialValue = .FALSE. 
218   ! reset velocities to zero
219   ua(:,:,:) = 0.
220   va(:,:,:) = 0.
221
222   ! 3. Some controls
223   !-----------------
224   check_namelist = .TRUE.
225
226   IF( check_namelist ) THEN 
227
228      ! Check time steps           
229      IF( NINT(Agrif_Rhot()) * NINT(rdt) .NE. Agrif_Parent(rdt) ) THEN
230         WRITE(cl_check1,*)  NINT(Agrif_Parent(rdt))
231         WRITE(cl_check2,*)  NINT(rdt)
232         WRITE(cl_check3,*)  NINT(Agrif_Parent(rdt)/Agrif_Rhot())
233         CALL ctl_warn( 'incompatible time step between grids',   &
234               &               'parent grid value : '//cl_check1    ,   & 
235               &               'child  grid value : '//cl_check2    ,   & 
236               &               'value on child grid will be changed to : '//cl_check3 )
237         rdt=Agrif_Parent(rdt)/Agrif_Rhot()
238      ENDIF
239
240      ! Check run length
241      IF( Agrif_IRhot() * (Agrif_Parent(nitend)- &
242            Agrif_Parent(nit000)+1) .NE. (nitend-nit000+1) ) THEN
243         WRITE(cl_check1,*)  (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1
244         WRITE(cl_check2,*)   Agrif_Parent(nitend)   *Agrif_IRhot()
245         CALL ctl_warn( 'incompatible run length between grids'               ,   &
246               &              ' nit000 on fine grid will be change to : '//cl_check1,   &
247               &              ' nitend on fine grid will be change to : '//cl_check2    )
248         nit000 = (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1
249         nitend =  Agrif_Parent(nitend)   *Agrif_IRhot()
250      ENDIF
251
252      ! Check coordinates
253      IF( ln_zps ) THEN
254         ! check parameters for partial steps
255         IF( Agrif_Parent(e3zps_min) .NE. e3zps_min ) THEN
256            WRITE(*,*) 'incompatible e3zps_min between grids'
257            WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_min)
258            WRITE(*,*) 'child grid  :',e3zps_min
259            WRITE(*,*) 'those values should be identical'
260            STOP
261         ENDIF
262         IF( Agrif_Parent(e3zps_rat) /= e3zps_rat ) THEN
263            WRITE(*,*) 'incompatible e3zps_rat between grids'
264            WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_rat)
265            WRITE(*,*) 'child grid  :',e3zps_rat
266            WRITE(*,*) 'those values should be identical'                 
267            STOP
268         ENDIF
269      ENDIF
270      ! check if the bathy metry match
271      IF(ln_chk_bathy) CALL Agrif_Bc_variable(e3t_id,calledweight=1.,procname=interpe3t)
272      !
273   ENDIF
274   !
275   CALL Agrif_Update_tra(0)
276   CALL Agrif_Update_dyn(0)
277# if defined key_zdftke
278   IF( ln_agrif_tke ) THEN
279   CALL Agrif_Update_tke(0)
280   ENDIF   
281# endif
282   !
283   Agrif_UseSpecialValueInUpdate = .FALSE.
284   nbcline = 0
285   !
286END SUBROUTINE Agrif_InitValues_cont
287
288
289SUBROUTINE agrif_declare_var
290   !!----------------------------------------------------------------------
291   !!                 *** ROUTINE agrif_declarE_var ***
292   !!
293   !! ** Purpose :: Declaration of variables to be interpolated
294   !!----------------------------------------------------------------------
295   USE agrif_util
296   USE par_oce       !   ONLY : jpts
297   USE oce
298   IMPLICIT NONE
299   !!----------------------------------------------------------------------
300
301   ! 1. Declaration of the type of variable which have to be interpolated
302   !---------------------------------------------------------------------
303   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts/),tsn_id)
304   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jpts/),tsn_sponge_id)
305
306   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_interp_id)
307   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_interp_id)
308   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_update_id)
309   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_update_id)
310   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_sponge_id)
311   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_sponge_id)
312
313   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),e3t_id)
314
315   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,3/),scales_t_id)
316
317   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),unb_id)
318   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vnb_id)
319   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_interp_id)
320   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_interp_id)
321   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_update_id)
322   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_update_id)
323
324   CALL agrif_declare_variable((/2,2/),(/3,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),sshn_id)
325
326# if defined key_zdftke
327   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avt_id)
328   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avm_id)
329   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avmu_id)
330   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avmv_id)
331# endif
332
333   ! 2. Type of interpolation
334   !-------------------------
335   CALL Agrif_Set_bcinterp(tsn_id,interp=AGRIF_linear)
336
337   CALL Agrif_Set_bcinterp(un_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
338   CALL Agrif_Set_bcinterp(vn_interp_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
339
340   CALL Agrif_Set_bcinterp(tsn_sponge_id,interp=AGRIF_linear)
341
342   CALL Agrif_Set_bcinterp(sshn_id,interp=AGRIF_linear)
343   CALL Agrif_Set_bcinterp(unb_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
344   CALL Agrif_Set_bcinterp(vnb_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
345   CALL Agrif_Set_bcinterp(ub2b_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
346   CALL Agrif_Set_bcinterp(vb2b_interp_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
347
348
349   CALL Agrif_Set_bcinterp(un_sponge_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
350   CALL Agrif_Set_bcinterp(vn_sponge_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
351
352   CALL Agrif_Set_bcinterp(e3t_id,interp=AGRIF_constant)
353
354# if defined key_zdftke
355   CALL Agrif_Set_bcinterp(avt_id ,interp=AGRIF_linear)
356   CALL Agrif_Set_bcinterp(avm_id ,interp=AGRIF_linear)
357   CALL Agrif_Set_bcinterp(avmu_id,interp=AGRIF_linear)
358   CALL Agrif_Set_bcinterp(avmv_id,interp=AGRIF_linear)
359# endif
360
361
362   ! 3. Location of interpolation
363   !-----------------------------
364   CALL Agrif_Set_bc(tsn_id,(/0,1/))
365   CALL Agrif_Set_bc(un_interp_id,(/0,1/))
366   CALL Agrif_Set_bc(vn_interp_id,(/0,1/))
367
368   CALL Agrif_Set_bc(tsn_sponge_id,(/-3*Agrif_irhox(),0/))
369   CALL Agrif_Set_bc(un_sponge_id,(/-2*Agrif_irhox()-1,0/))
370   CALL Agrif_Set_bc(vn_sponge_id,(/-2*Agrif_irhox()-1,0/))
371
372   CALL Agrif_Set_bc(sshn_id,(/0,0/))
373   CALL Agrif_Set_bc(unb_id ,(/0,0/))
374   CALL Agrif_Set_bc(vnb_id ,(/0,0/))
375   CALL Agrif_Set_bc(ub2b_interp_id,(/0,0/))
376   CALL Agrif_Set_bc(vb2b_interp_id,(/0,0/))
377
378   CALL Agrif_Set_bc(e3t_id,(/-3*Agrif_irhox(),0/))   ! if west and rhox=3: column 2 to 11
379
380# if defined key_zdftke
381   CALL Agrif_Set_bc(avt_id ,(/0,1/))
382   CALL Agrif_Set_bc(avm_id ,(/0,1/))
383   CALL Agrif_Set_bc(avmu_id,(/0,1/))
384   CALL Agrif_Set_bc(avmv_id,(/0,1/))
385# endif
386
387   ! 5. Update type
388   !---------------
389   CALL Agrif_Set_Updatetype(tsn_id, update = AGRIF_Update_Average)
390
391   CALL Agrif_Set_Updatetype(scales_t_id, update = AGRIF_Update_Average)
392   CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
393   CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
394
395   CALL Agrif_Set_Updatetype(sshn_id, update = AGRIF_Update_Average)
396
397   CALL Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
398   CALL Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
399
400# if defined key_zdftke
401   CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Average)
402   CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Average)
403   CALL Agrif_Set_Updatetype(avmu_id, update = AGRIF_Update_Average)
404   CALL Agrif_Set_Updatetype(avmv_id, update = AGRIF_Update_Average)
405# endif
406   !
407END SUBROUTINE agrif_declare_var
408# endif
409
410#  if defined key_lim2
411SUBROUTINE Agrif_InitValues_cont_lim2
412   !!----------------------------------------------------------------------
413   !!                 *** ROUTINE Agrif_InitValues_cont_lim2 ***
414   !!
415   !! ** Purpose :: Initialisation of variables to be interpolated for LIM2
416   !!----------------------------------------------------------------------
417   USE Agrif_Util
418   USE ice_2
419   USE agrif_ice
420   USE in_out_manager
421   USE agrif_lim2_update
422   USE agrif_lim2_interp
423   USE lib_mpp
424   !
425   IMPLICIT NONE
426   !
427   !!----------------------------------------------------------------------
428
429   ! 1. Declaration of the type of variable which have to be interpolated
430   !---------------------------------------------------------------------
431   CALL agrif_declare_var_lim2
432
433   ! 2. First interpolations of potentially non zero fields
434   !-------------------------------------------------------
435   Agrif_SpecialValue=-9999.
436   Agrif_UseSpecialValue = .TRUE.
437   !     Call Agrif_Bc_variable(zadv ,adv_ice_id ,calledweight=1.,procname=interp_adv_ice )
438   !     Call Agrif_Bc_variable(zvel ,u_ice_id   ,calledweight=1.,procname=interp_u_ice   )
439   !     Call Agrif_Bc_variable(zvel ,v_ice_id   ,calledweight=1.,procname=interp_v_ice   )
440   Agrif_SpecialValue=0.
441   Agrif_UseSpecialValue = .FALSE.
442
443   ! 3. Some controls
444   !-----------------
445
446#   if ! defined key_lim2_vp
447   lim_nbstep = 1.
448   CALL agrif_rhg_lim2_load
449   CALL agrif_trp_lim2_load
450   lim_nbstep = 0.
451#   endif
452   !RB mandatory but why ???
453   !      IF( nbclineupdate /= nn_fsbc .AND. nn_ice == 2 )THEN
454   !         CALL ctl_warn ('With ice model on child grid, nbclineupdate is set to nn_fsbc')
455   !         nbclineupdate = nn_fsbc
456   !       ENDIF
457   CALL Agrif_Update_lim2(0)
458   !
459END SUBROUTINE Agrif_InitValues_cont_lim2
460
461SUBROUTINE agrif_declare_var_lim2
462   !!----------------------------------------------------------------------
463   !!                 *** ROUTINE agrif_declare_var_lim2 ***
464   !!
465   !! ** Purpose :: Declaration of variables to be interpolated for LIM2
466   !!----------------------------------------------------------------------
467   USE agrif_util
468   USE ice_2
469
470   IMPLICIT NONE
471   !!----------------------------------------------------------------------
472
473   ! 1. Declaration of the type of variable which have to be interpolated
474   !---------------------------------------------------------------------
475   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj, 7/),adv_ice_id )
476#   if defined key_lim2_vp
477   CALL agrif_declare_variable((/1,1/),(/3,3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),u_ice_id)
478   CALL agrif_declare_variable((/1,1/),(/3,3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),v_ice_id)
479#   else
480   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),u_ice_id)
481   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/jpi,jpj/),v_ice_id)
482#   endif
483
484   ! 2. Type of interpolation
485   !-------------------------
486   CALL Agrif_Set_bcinterp(adv_ice_id ,interp=AGRIF_linear)
487   CALL Agrif_Set_bcinterp(u_ice_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
488   CALL Agrif_Set_bcinterp(v_ice_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
489
490   ! 3. Location of interpolation
491   !-----------------------------
492   CALL Agrif_Set_bc(adv_ice_id ,(/0,1/))
493   CALL Agrif_Set_bc(u_ice_id,(/0,1/))
494   CALL Agrif_Set_bc(v_ice_id,(/0,1/))
495
496   ! 5. Update type
497   !---------------
498   CALL Agrif_Set_Updatetype(adv_ice_id , update = AGRIF_Update_Average)
499   CALL Agrif_Set_Updatetype(u_ice_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
500   CALL Agrif_Set_Updatetype(v_ice_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
501
502END SUBROUTINE agrif_declare_var_lim2
503#  endif
504
505
506# if defined key_top
507SUBROUTINE Agrif_InitValues_cont_top
508   !!----------------------------------------------------------------------
509   !!                 *** ROUTINE Agrif_InitValues_cont_top ***
510   !!
511   !! ** Purpose :: Declaration of variables to be interpolated
512   !!----------------------------------------------------------------------
513   USE Agrif_Util
514   USE oce 
515   USE dom_oce
516   USE nemogcm
517   USE par_trc
518   USE lib_mpp
519   USE trc
520   USE in_out_manager
521   USE agrif_top_update
522   USE agrif_top_interp
523   USE agrif_top_sponge
524   !
525   IMPLICIT NONE
526   !
527   CHARACTER(len=10) :: cl_check1, cl_check2, cl_check3
528   LOGICAL :: check_namelist
529   !!----------------------------------------------------------------------
530
531
532   ! 1. Declaration of the type of variable which have to be interpolated
533   !---------------------------------------------------------------------
534   CALL agrif_declare_var_top
535
536   ! 2. First interpolations of potentially non zero fields
537   !-------------------------------------------------------
538   Agrif_SpecialValue=0.
539   Agrif_UseSpecialValue = .TRUE.
540   CALL Agrif_Bc_variable(trn_id,calledweight=1.,procname=interptrn)
541   Agrif_UseSpecialValue = .FALSE.
542   CALL Agrif_Sponge
543   tabspongedone_trn = .FALSE.
544   CALL Agrif_Bc_variable(trn_sponge_id,calledweight=1.,procname=interptrn_sponge)
545   ! reset tsa to zero
546   tra(:,:,:,:) = 0.
547
548
549   ! 3. Some controls
550   !-----------------
551   check_namelist = .TRUE.
552
553   IF( check_namelist ) THEN
554# if defined key_offline
555      ! Check time steps
556      IF( NINT(Agrif_Rhot()) * NINT(rdt) .NE. Agrif_Parent(rdt) ) THEN
557         WRITE(cl_check1,*)  Agrif_Parent(rdt)
558         WRITE(cl_check2,*)  rdt
559         WRITE(cl_check3,*)  rdt*Agrif_Rhot()
560         CALL ctl_warn( 'incompatible time step between grids',   &
561               &               'parent grid value : '//cl_check1    ,   & 
562               &               'child  grid value : '//cl_check2    ,   & 
563               &               'value on child grid will be changed to  &
564               &               :'//cl_check3  )
565         rdt=rdt*Agrif_Rhot()
566      ENDIF
567
568      ! Check run length
569      IF( Agrif_IRhot() * (Agrif_Parent(nitend)- &
570            Agrif_Parent(nit000)+1) .NE. (nitend-nit000+1) ) THEN
571         WRITE(cl_check1,*)  (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1
572         WRITE(cl_check2,*)   Agrif_Parent(nitend)   *Agrif_IRhot()
573         CALL ctl_warn( 'incompatible run length between grids'               ,   &
574               &              ' nit000 on fine grid will be change to : '//cl_check1,   &
575               &              ' nitend on fine grid will be change to : '//cl_check2    )
576         nit000 = (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1
577         nitend =  Agrif_Parent(nitend)   *Agrif_IRhot()
578      ENDIF
579
580      ! Check coordinates
581      IF( ln_zps ) THEN
582         ! check parameters for partial steps
583         IF( Agrif_Parent(e3zps_min) .NE. e3zps_min ) THEN
584            WRITE(*,*) 'incompatible e3zps_min between grids'
585            WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_min)
586            WRITE(*,*) 'child grid  :',e3zps_min
587            WRITE(*,*) 'those values should be identical'
588            STOP
589         ENDIF
590         IF( Agrif_Parent(e3zps_rat) .NE. e3zps_rat ) THEN
591            WRITE(*,*) 'incompatible e3zps_rat between grids'
592            WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_rat)
593            WRITE(*,*) 'child grid  :',e3zps_rat
594            WRITE(*,*) 'those values should be identical'                 
595            STOP
596         ENDIF
597      ENDIF
598#  endif         
599      ! Check passive tracer cell
600      IF( nn_dttrc .NE. 1 ) THEN
601         WRITE(*,*) 'nn_dttrc should be equal to 1'
602      ENDIF
603   ENDIF
604
605   CALL Agrif_Update_trc(0)
606   !
607   Agrif_UseSpecialValueInUpdate = .FALSE.
608   nbcline_trc = 0
609   !
610END SUBROUTINE Agrif_InitValues_cont_top
611
612
613SUBROUTINE agrif_declare_var_top
614   !!----------------------------------------------------------------------
615   !!                 *** ROUTINE agrif_declare_var_top ***
616   !!
617   !! ** Purpose :: Declaration of TOP variables to be interpolated
618   !!----------------------------------------------------------------------
619   USE agrif_util
620   USE dom_oce
621   USE trc
622
623   IMPLICIT NONE
624
625   ! 1. Declaration of the type of variable which have to be interpolated
626   !---------------------------------------------------------------------
627   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra/),trn_id)
628   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/nlci,nlcj,jpk,jptra/),trn_sponge_id)
629
630   ! 2. Type of interpolation
631   !-------------------------
632   CALL Agrif_Set_bcinterp(trn_id,interp=AGRIF_linear)
633   CALL Agrif_Set_bcinterp(trn_sponge_id,interp=AGRIF_linear)
634
635   ! 3. Location of interpolation
636   !-----------------------------
637   CALL Agrif_Set_bc(trn_id,(/0,1/))
638   CALL Agrif_Set_bc(trn_sponge_id,(/-3*Agrif_irhox(),0/))
639
640   ! 5. Update type
641   !---------------
642   CALL Agrif_Set_Updatetype(trn_id, update = AGRIF_Update_Average)
643   !
644END SUBROUTINE agrif_declare_var_top
645# endif
646
647SUBROUTINE Agrif_detect( kg, ksizex )
648   !!----------------------------------------------------------------------
649   !!   *** ROUTINE Agrif_detect ***
650   !!----------------------------------------------------------------------
651   USE Agrif_Types
652   !
653   INTEGER, DIMENSION(2) :: ksizex
654   INTEGER, DIMENSION(ksizex(1),ksizex(2)) :: kg 
655   !!----------------------------------------------------------------------
656   !
657   RETURN
658   !
659END SUBROUTINE Agrif_detect
660
661
662SUBROUTINE agrif_nemo_init
663   !!----------------------------------------------------------------------
664   !!                     *** ROUTINE agrif_init ***
665   !!----------------------------------------------------------------------
666   USE agrif_oce 
667   USE agrif_ice
668   USE in_out_manager
669   USE lib_mpp
670   IMPLICIT NONE
671   !
672   INTEGER  ::   ios                 ! Local integer output status for namelist read
673   NAMELIST/namagrif/ nn_cln_update, rn_sponge_tra, rn_sponge_dyn, ln_spc_dyn, ln_chk_bathy,   &
674                 &    ln_agrif_tke
675   !!--------------------------------------------------------------------------------------
676   !
677   REWIND( numnam_ref )              ! Namelist namagrif in reference namelist : AGRIF zoom
678   READ  ( numnam_ref, namagrif, IOSTAT = ios, ERR = 901)
679901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namagrif in reference namelist', lwp )
680
681   REWIND( numnam_cfg )              ! Namelist namagrif in configuration namelist : AGRIF zoom
682   READ  ( numnam_cfg, namagrif, IOSTAT = ios, ERR = 902 )
683902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namagrif in configuration namelist', lwp )
684   IF(lwm) WRITE ( numond, namagrif )
685   !
686   IF(lwp) THEN                    ! control print
687      WRITE(numout,*)
688      WRITE(numout,*) 'agrif_nemo_init : AGRIF parameters'
689      WRITE(numout,*) '~~~~~~~~~~~~~~~'
690      WRITE(numout,*) '   Namelist namagrif : set AGRIF parameters'
691      WRITE(numout,*) '      baroclinic update frequency       nn_cln_update = ', nn_cln_update
692      WRITE(numout,*) '      sponge coefficient for tracers    rn_sponge_tra = ', rn_sponge_tra, ' s'
693      WRITE(numout,*) '      sponge coefficient for dynamics   rn_sponge_tra = ', rn_sponge_dyn, ' s'
694      WRITE(numout,*) '      use special values for dynamics   ln_spc_dyn    = ', ln_spc_dyn
695      WRITE(numout,*) '      check bathymetry                  ln_chk_bathy  = ', ln_chk_bathy
696      WRITE(numout,*) '      use TKE interpolation/update      ln_agrif_tke  = ', ln_agrif_tke
697      WRITE(numout,*) 
698   ENDIF
699   !
700   ! convert DOCTOR namelist name into OLD names
701   nbclineupdate = nn_cln_update
702   visc_tra      = rn_sponge_tra
703   visc_dyn      = rn_sponge_dyn
704   !
705   IF( agrif_oce_alloc()  > 0 )   CALL ctl_warn('agrif sol_oce_alloc: allocation of arrays failed')
706# if defined key_lim2
707   IF( agrif_ice_alloc()  > 0 )   CALL ctl_stop('agrif agrif_ice_alloc: allocation of arrays failed')
708# endif
709   !
710END SUBROUTINE agrif_nemo_init
711
712# if defined key_mpp_mpi
713
714SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob )
715   !!----------------------------------------------------------------------
716   !!                     *** ROUTINE Agrif_detect ***
717   !!----------------------------------------------------------------------
718   USE dom_oce
719   IMPLICIT NONE
720   !
721   INTEGER :: indglob, indloc, nprocloc, i
722   !!----------------------------------------------------------------------
723   !
724   SELECT CASE( i )
725   CASE(1)   ;   indglob = indloc + nimppt(nprocloc+1) - 1
726   CASE(2)   ;   indglob = indloc + njmppt(nprocloc+1) - 1
727   CASE DEFAULT
728      indglob = indloc
729   END SELECT
730   !
731END SUBROUTINE Agrif_InvLoc
732
733SUBROUTINE Agrif_get_proc_info( imin, imax, jmin, jmax )
734   !!----------------------------------------------------------------------
735   !!                 *** ROUTINE Agrif_get_proc_info ***
736   !!----------------------------------------------------------------------
737   USE par_oce
738   IMPLICIT NONE
739   !
740   INTEGER, INTENT(out) :: imin, imax
741   INTEGER, INTENT(out) :: jmin, jmax
742   !!----------------------------------------------------------------------
743   !
744   imin = nimppt(Agrif_Procrank+1)  ! ?????
745   jmin = njmppt(Agrif_Procrank+1)  ! ?????
746   imax = imin + jpi - 1
747   jmax = jmin + jpj - 1
748   !
749END SUBROUTINE Agrif_get_proc_info
750
751SUBROUTINE Agrif_estimate_parallel_cost(imin, imax,jmin, jmax, nbprocs, grid_cost)
752   !!----------------------------------------------------------------------
753   !!                 *** ROUTINE Agrif_estimate_parallel_cost ***
754   !!----------------------------------------------------------------------
755   USE par_oce
756   IMPLICIT NONE
757   !
758   INTEGER,  INTENT(in)  :: imin, imax
759   INTEGER,  INTENT(in)  :: jmin, jmax
760   INTEGER,  INTENT(in)  :: nbprocs
761   REAL(wp), INTENT(out) :: grid_cost
762   !!----------------------------------------------------------------------
763   !
764   grid_cost = REAL(imax-imin+1,wp)*REAL(jmax-jmin+1,wp) / REAL(nbprocs,wp)
765   !
766END SUBROUTINE Agrif_estimate_parallel_cost
767
768# endif
769
770#else
771SUBROUTINE Subcalledbyagrif
772   !!----------------------------------------------------------------------
773   !!                   *** ROUTINE Subcalledbyagrif ***
774   !!----------------------------------------------------------------------
775   WRITE(*,*) 'Impossible to be here'
776END SUBROUTINE Subcalledbyagrif
777#endif
Note: See TracBrowser for help on using the repository browser.