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 @ 4785

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

dev_r4765_CNRS_agrif: First update of AGRIF for dynamic only (_flt and _ts), see ticket #1380 and associated wiki page

  • Property svn:keywords set to Id
File size: 28.1 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 = .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   ENDIF
271   !
272   CALL Agrif_Update_tra(0)
273   CALL Agrif_Update_dyn(0)
274   !
275   Agrif_UseSpecialValueInUpdate = .FALSE.
276   nbcline = 0
277   !
278END SUBROUTINE Agrif_InitValues_cont
279
280
281SUBROUTINE agrif_declare_var
282   !!----------------------------------------------------------------------
283   !!                 *** ROUTINE agrif_declarE_var ***
284   !!
285   !! ** Purpose :: Declaration of variables to be interpolated
286   !!----------------------------------------------------------------------
287   USE agrif_util
288   USE par_oce       !   ONLY : jpts
289   USE oce
290   IMPLICIT NONE
291   !!----------------------------------------------------------------------
292
293   ! 1. Declaration of the type of variable which have to be interpolated
294   !---------------------------------------------------------------------
295   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)
296   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)
297
298   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_interp_id)
299   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_interp_id)
300   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_update_id)
301   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_update_id)
302   CALL agrif_declare_variable((/1,2,0/),(/2,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),un_sponge_id)
303   CALL agrif_declare_variable((/2,1,0/),(/3,2,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),vn_sponge_id)
304
305   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/nlci,nlcj,jpk/),e3t_id)
306 
307   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)
308
309   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),unb_id)
310   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vnb_id)
311   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_interp_id)
312   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_interp_id)
313   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),ub2b_update_id)
314   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),vb2b_update_id)
315
316   CALL agrif_declare_variable((/2,2/),(/3,3/),(/'x','y'/),(/1,1/),(/nlci,nlcj/),sshn_id)
317
318
319   ! 2. Type of interpolation
320   !-------------------------
321   CALL Agrif_Set_bcinterp(tsn_id,interp=AGRIF_linear)
322 
323   CALL Agrif_Set_bcinterp(un_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
324   CALL Agrif_Set_bcinterp(vn_interp_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
325 
326   CALL Agrif_Set_bcinterp(tsn_sponge_id,interp=AGRIF_linear)
327
328   CALL Agrif_Set_bcinterp(sshn_id,interp=AGRIF_linear)
329   CALL Agrif_Set_bcinterp(unb_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
330   CALL Agrif_Set_bcinterp(vnb_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
331   CALL Agrif_Set_bcinterp(ub2b_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
332   CALL Agrif_Set_bcinterp(vb2b_interp_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
333
334
335   CALL Agrif_Set_bcinterp(un_sponge_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
336   CALL Agrif_Set_bcinterp(vn_sponge_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
337 
338   CALL Agrif_Set_bcinterp(e3t_id,interp=AGRIF_constant)
339 
340
341   ! 3. Location of interpolation
342   !-----------------------------
343   CALL Agrif_Set_bc(tsn_id,(/0,1/))
344   CALL Agrif_Set_bc(un_interp_id,(/0,1/))
345   CALL Agrif_Set_bc(vn_interp_id,(/0,1/))
346
347   CALL Agrif_Set_bc(tsn_sponge_id,(/-3*Agrif_irhox(),0/))
348   CALL Agrif_Set_bc(un_sponge_id,(/-2*Agrif_irhox()-1,0/))
349   CALL Agrif_Set_bc(vn_sponge_id,(/-2*Agrif_irhox()-1,0/))
350
351   CALL Agrif_Set_bc(sshn_id,(/0,0/))
352   CALL Agrif_Set_bc(unb_id ,(/0,0/))
353   CALL Agrif_Set_bc(vnb_id ,(/0,0/))
354   Call Agrif_Set_bc(ub2b_interp_id,(/0,0/))
355   Call Agrif_Set_bc(vb2b_interp_id,(/0,0/))
356
357   CALL Agrif_Set_bc(e3t_id,(/-3*Agrif_irhox(),0/))   ! if west and rhox=3: column 2 to 11
358
359   ! 5. Update type
360   !---------------
361   CALL Agrif_Set_Updatetype(tsn_id, update = AGRIF_Update_Average)
362
363   CALL Agrif_Set_Updatetype(scales_t_id, update = AGRIF_Update_Average)
364   CALL Agrif_Set_Updatetype(un_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
365   CALL Agrif_Set_Updatetype(vn_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
366
367   CALL Agrif_Set_Updatetype(sshn_id, update = AGRIF_Update_Average)
368
369   Call Agrif_Set_Updatetype(ub2b_update_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
370   Call Agrif_Set_Updatetype(vb2b_update_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
371
372   !
373END SUBROUTINE agrif_declare_var
374# endif
375
376#  if defined key_lim2
377SUBROUTINE Agrif_InitValues_cont_lim2
378   !!----------------------------------------------------------------------
379   !!                 *** ROUTINE Agrif_InitValues_cont_lim2 ***
380   !!
381   !! ** Purpose :: Initialisation of variables to be interpolated for LIM2
382   !!----------------------------------------------------------------------
383   USE Agrif_Util
384   USE ice_2
385   USE agrif_ice
386   USE in_out_manager
387   USE agrif_lim2_update
388   USE agrif_lim2_interp
389   USE lib_mpp
390   !
391   IMPLICIT NONE
392   !
393   REAL(wp), DIMENSION(:,:)  , ALLOCATABLE :: zvel
394   REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zadv
395   !!----------------------------------------------------------------------
396
397   ALLOCATE( zvel(jpi,jpj), zadv(jpi,jpj,7))
398
399   ! 1. Declaration of the type of variable which have to be interpolated
400   !---------------------------------------------------------------------
401   CALL agrif_declare_var_lim2
402
403   ! 2. First interpolations of potentially non zero fields
404   !-------------------------------------------------------
405   Agrif_SpecialValue=-9999.
406   Agrif_UseSpecialValue = .TRUE.
407   !     Call Agrif_Bc_variable(zadv ,adv_ice_id ,calledweight=1.,procname=interp_adv_ice )
408   !     Call Agrif_Bc_variable(zvel ,u_ice_id   ,calledweight=1.,procname=interp_u_ice   )
409   !     Call Agrif_Bc_variable(zvel ,v_ice_id   ,calledweight=1.,procname=interp_v_ice   )
410   Agrif_SpecialValue=0.
411   Agrif_UseSpecialValue = .FALSE.
412
413   ! 3. Some controls
414   !-----------------
415
416#   if ! defined key_lim2_vp
417   lim_nbstep = 1.
418   CALL agrif_rhg_lim2_load
419   CALL agrif_trp_lim2_load
420   lim_nbstep = 0.
421#   endif
422   !RB mandatory but why ???
423   !      IF( nbclineupdate /= nn_fsbc .AND. nn_ice == 2 )THEN
424   !         CALL ctl_warn ('With ice model on child grid, nbclineupdate is set to nn_fsbc')
425   !         nbclineupdate = nn_fsbc
426   !       ENDIF
427   CALL Agrif_Update_lim2(0)
428   !
429   DEALLOCATE( zvel, zadv )
430   !
431END SUBROUTINE Agrif_InitValues_cont_lim2
432
433SUBROUTINE agrif_declare_var_lim2
434   !!----------------------------------------------------------------------
435   !!                 *** ROUTINE agrif_declare_var_lim2 ***
436   !!
437   !! ** Purpose :: Declaration of variables to be interpolated for LIM2
438   !!----------------------------------------------------------------------
439   USE agrif_util
440   USE ice_2
441
442   IMPLICIT NONE
443   !!----------------------------------------------------------------------
444
445   ! 1. Declaration of the type of variable which have to be interpolated
446   !---------------------------------------------------------------------
447   CALL agrif_declare_variable((/2,2,0/),(/3,3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj, 7/),adv_ice_id )
448#   if defined key_lim2_vp
449   CALL agrif_declare_variable((/1,1/),(/3,3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),u_ice_id)
450   CALL agrif_declare_variable((/1,1/),(/3,3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),v_ice_id)
451#   else
452   CALL agrif_declare_variable((/1,2/),(/2,3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),u_ice_id)
453   CALL agrif_declare_variable((/2,1/),(/3,2/),(/'x','y'/),(/1,1/),(/jpi,jpj/),v_ice_id)
454#   endif
455
456   ! 2. Type of interpolation
457   !-------------------------
458   CALL Agrif_Set_bcinterp(adv_ice_id ,interp=AGRIF_linear)
459   Call Agrif_Set_bcinterp(u_ice_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
460   Call Agrif_Set_bcinterp(v_ice_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
461
462   ! 3. Location of interpolation
463   !-----------------------------
464   Call Agrif_Set_bc(adv_ice_id ,(/0,1/))
465   Call Agrif_Set_bc(u_ice_id,(/0,1/))
466   Call Agrif_Set_bc(v_ice_id,(/0,1/))
467
468   ! 5. Update type
469   !---------------
470   Call Agrif_Set_Updatetype(adv_ice_id , update = AGRIF_Update_Average)
471   Call Agrif_Set_Updatetype(u_ice_id,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
472   Call Agrif_Set_Updatetype(v_ice_id,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
473
474END SUBROUTINE agrif_declare_var_lim2
475#  endif
476
477
478# if defined key_top
479SUBROUTINE Agrif_InitValues_cont_top
480   !!----------------------------------------------------------------------
481   !!                 *** ROUTINE Agrif_InitValues_cont_top ***
482   !!
483   !! ** Purpose :: Declaration of variables to be interpolated
484   !!----------------------------------------------------------------------
485   USE Agrif_Util
486   USE oce 
487   USE dom_oce
488   USE nemogcm
489   USE par_trc
490   USE lib_mpp
491   USE trc
492   USE in_out_manager
493   USE agrif_top_update
494   USE agrif_top_interp
495   USE agrif_top_sponge
496   !
497   IMPLICIT NONE
498   !
499   REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE :: tabtrtemp
500   CHARACTER(len=10) :: cl_check1, cl_check2, cl_check3
501   LOGICAL :: check_namelist
502   !!----------------------------------------------------------------------
503
504   ALLOCATE( tabtrtemp(jpi,jpj,jpk,jptra) )
505
506
507   ! 1. Declaration of the type of variable which have to be interpolated
508   !---------------------------------------------------------------------
509   CALL agrif_declare_var_top
510
511   ! 2. First interpolations of potentially non zero fields
512   !-------------------------------------------------------
513   Agrif_SpecialValue=0.
514   Agrif_UseSpecialValue = .TRUE.
515   Call Agrif_Bc_variable(tabtrtemp,trn_id,calledweight=1.,procname=interptrn)
516   Call Agrif_Bc_variable(tabtrtemp,tra_id,calledweight=1.,procname=interptrn)
517   Agrif_UseSpecialValue = .FALSE.
518
519   ! 3. Some controls
520   !-----------------
521   check_namelist = .true.
522
523   IF( check_namelist ) THEN
524# if defined key_offline
525      ! Check time steps
526      IF( nint(Agrif_Rhot()) * nint(rdt) .ne. Agrif_Parent(rdt) ) THEN
527         write(cl_check1,*)  Agrif_Parent(rdt)
528         write(cl_check2,*)  rdt
529         write(cl_check3,*)  rdt*Agrif_Rhot()
530         CALL ctl_warn( 'incompatible time step between grids',   &
531         &               'parent grid value : '//cl_check1    ,   & 
532         &               'child  grid value : '//cl_check2    ,   & 
533         &               'value on child grid will be changed to  &
534         &               :'//cl_check3  )
535         rdt=rdt*Agrif_Rhot()
536      ENDIF
537
538      ! Check run length
539      IF( Agrif_IRhot() * (Agrif_Parent(nitend)- &
540           Agrif_Parent(nit000)+1) .ne. (nitend-nit000+1) ) THEN
541         WRITE(*,*) 'incompatible run length between grids'
542         WRITE(*,*) 'parent grid value : ',(Agrif_Parent(nitend)- &
543              Agrif_Parent(nit000)+1),' time step'
544         WRITE(*,*) 'child  grid value : ', &
545              (nitend-nit000+1),' time step'
546         WRITE(*,*) 'value on child grid should be : ', &
547              Agrif_IRhot() * (Agrif_Parent(nitend)- &
548              Agrif_Parent(nit000)+1)
549         CALL ctl_warn( 'incompatible run length between grids',   &
550         &              'value on child grid will be change to '  &
551         &             )
552
553
554      ENDIF
555
556      ! Check coordinates
557      IF( ln_zps ) THEN
558         ! check parameters for partial steps
559         IF( Agrif_Parent(e3zps_min) .ne. e3zps_min ) THEN
560            WRITE(*,*) 'incompatible e3zps_min between grids'
561            WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_min)
562            WRITE(*,*) 'child grid  :',e3zps_min
563            WRITE(*,*) 'those values should be identical'
564            STOP
565         ENDIF
566         IF( Agrif_Parent(e3zps_rat) .ne. e3zps_rat ) THEN
567            WRITE(*,*) 'incompatible e3zps_rat between grids'
568            WRITE(*,*) 'parent grid :',Agrif_Parent(e3zps_rat)
569            WRITE(*,*) 'child grid  :',e3zps_rat
570            WRITE(*,*) 'those values should be identical'                 
571            STOP
572         ENDIF
573      ENDIF
574#  endif         
575      ! Check passive tracer cell
576      IF( nn_dttrc .ne. 1 ) THEN
577         WRITE(*,*) 'nn_dttrc should be equal to 1'
578      ENDIF
579   ENDIF
580
581!ch   CALL Agrif_Update_trc(0)
582   nbcline_trc = 0
583   !
584   DEALLOCATE(tabtrtemp)
585   !
586END SUBROUTINE Agrif_InitValues_cont_top
587
588
589SUBROUTINE agrif_declare_var_top
590   !!----------------------------------------------------------------------
591   !!                 *** ROUTINE agrif_declare_var_top ***
592   !!
593   !! ** Purpose :: Declaration of TOP variables to be interpolated
594   !!----------------------------------------------------------------------
595   USE agrif_util
596   USE dom_oce
597   USE trc
598
599   IMPLICIT NONE
600
601   ! 1. Declaration of the type of variable which have to be interpolated
602   !---------------------------------------------------------------------
603   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra/),trn_id)
604   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra/),trb_id)
605   CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra/),tra_id)
606
607   ! 2. Type of interpolation
608   !-------------------------
609   CALL Agrif_Set_bcinterp(trn_id,interp=AGRIF_linear)
610   CALL Agrif_Set_bcinterp(tra_id,interp=AGRIF_linear)
611
612   ! 3. Location of interpolation
613   !-----------------------------
614   Call Agrif_Set_bc(trn_id,(/0,1/))
615   Call Agrif_Set_bc(tra_id,(/-3*Agrif_irhox(),0/))
616
617   ! 5. Update type
618   !---------------
619   Call Agrif_Set_Updatetype(trn_id, update = AGRIF_Update_Average)
620   Call Agrif_Set_Updatetype(trb_id, update = AGRIF_Update_Average)
621
622
623END SUBROUTINE agrif_declare_var_top
624# endif
625
626SUBROUTINE Agrif_detect( kg, ksizex )
627   !!----------------------------------------------------------------------
628   !!   *** ROUTINE Agrif_detect ***
629   !!----------------------------------------------------------------------
630   USE Agrif_Types
631   !
632   INTEGER, DIMENSION(2) :: ksizex
633   INTEGER, DIMENSION(ksizex(1),ksizex(2)) :: kg 
634   !!----------------------------------------------------------------------
635   !
636   RETURN
637   !
638END SUBROUTINE Agrif_detect
639
640
641SUBROUTINE agrif_nemo_init
642   !!----------------------------------------------------------------------
643   !!                     *** ROUTINE agrif_init ***
644   !!----------------------------------------------------------------------
645   USE agrif_oce 
646   USE agrif_ice
647   USE in_out_manager
648   USE lib_mpp
649   IMPLICIT NONE
650   !
651   INTEGER  ::   ios                 ! Local integer output status for namelist read
652   NAMELIST/namagrif/ nn_cln_update, rn_sponge_tra, rn_sponge_dyn, ln_spc_dyn
653   !!----------------------------------------------------------------------
654   !
655      REWIND( numnam_ref )              ! Namelist namagrif in reference namelist : AGRIF zoom
656      READ  ( numnam_ref, namagrif, IOSTAT = ios, ERR = 901)
657901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namagrif in reference namelist', lwp )
658
659      REWIND( numnam_cfg )              ! Namelist namagrif in configuration namelist : AGRIF zoom
660      READ  ( numnam_cfg, namagrif, IOSTAT = ios, ERR = 902 )
661902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namagrif in configuration namelist', lwp )
662      IF(lwm) WRITE ( numond, namagrif )
663   !
664   IF(lwp) THEN                    ! control print
665      WRITE(numout,*)
666      WRITE(numout,*) 'agrif_nemo_init : AGRIF parameters'
667      WRITE(numout,*) '~~~~~~~~~~~~~~~'
668      WRITE(numout,*) '   Namelist namagrif : set AGRIF parameters'
669      WRITE(numout,*) '      baroclinic update frequency       nn_cln_update = ', nn_cln_update
670      WRITE(numout,*) '      sponge coefficient for tracers    rn_sponge_tra = ', rn_sponge_tra, ' s'
671      WRITE(numout,*) '      sponge coefficient for dynamics   rn_sponge_tra = ', rn_sponge_dyn, ' s'
672      WRITE(numout,*) '      use special values for dynamics   ln_spc_dyn    = ', ln_spc_dyn
673      WRITE(numout,*) 
674   ENDIF
675   !
676   ! convert DOCTOR namelist name into OLD names
677   nbclineupdate = nn_cln_update
678   visc_tra      = rn_sponge_tra
679   visc_dyn      = rn_sponge_dyn
680   !
681   IF( agrif_oce_alloc()  > 0 )   CALL ctl_warn('agrif sol_oce_alloc: allocation of arrays failed')
682# if defined key_lim2
683   IF( agrif_ice_alloc()  > 0 )   CALL ctl_stop('agrif agrif_ice_alloc: allocation of arrays failed')
684# endif
685   !
686END SUBROUTINE agrif_nemo_init
687
688# if defined key_mpp_mpi
689
690SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob )
691   !!----------------------------------------------------------------------
692   !!                     *** ROUTINE Agrif_detect ***
693   !!----------------------------------------------------------------------
694   USE dom_oce
695   IMPLICIT NONE
696   !
697   INTEGER :: indglob, indloc, nprocloc, i
698   !!----------------------------------------------------------------------
699   !
700   SELECT CASE( i )
701   CASE(1)   ;   indglob = indloc + nimppt(nprocloc+1) - 1
702   CASE(2)   ;   indglob = indloc + njmppt(nprocloc+1) - 1
703   CASE DEFAULT
704                 indglob = indloc
705   END SELECT
706   !
707END SUBROUTINE Agrif_InvLoc
708
709SUBROUTINE Agrif_get_proc_info( imin, imax, jmin, jmax )
710   !!----------------------------------------------------------------------
711   !!                 *** ROUTINE Agrif_get_proc_info ***
712   !!----------------------------------------------------------------------
713   USE par_oce
714   IMPLICIT NONE
715   !
716   INTEGER, INTENT(out) :: imin, imax
717   INTEGER, INTENT(out) :: jmin, jmax
718   !!----------------------------------------------------------------------
719   !
720   imin = nimppt(Agrif_Procrank+1)  ! ?????
721   jmin = njmppt(Agrif_Procrank+1)  ! ?????
722   imax = imin + jpi - 1
723   jmax = jmin + jpj - 1
724   !
725END SUBROUTINE Agrif_get_proc_info
726
727SUBROUTINE Agrif_estimate_parallel_cost(imin, imax,jmin, jmax, nbprocs, grid_cost)
728   !!----------------------------------------------------------------------
729   !!                 *** ROUTINE Agrif_estimate_parallel_cost ***
730   !!----------------------------------------------------------------------
731   USE par_oce
732   IMPLICIT NONE
733   !
734   INTEGER,  INTENT(in)  :: imin, imax
735   INTEGER,  INTENT(in)  :: jmin, jmax
736   INTEGER,  INTENT(in)  :: nbprocs
737   REAL(wp), INTENT(out) :: grid_cost
738   !!----------------------------------------------------------------------
739   !
740   grid_cost = REAL(imax-imin+1,wp)*REAL(jmax-jmin+1,wp) / REAL(nbprocs,wp)
741   !
742END SUBROUTINE Agrif_estimate_parallel_cost
743
744
745# endif
746
747#else
748SUBROUTINE Subcalledbyagrif
749   !!----------------------------------------------------------------------
750   !!                   *** ROUTINE Subcalledbyagrif ***
751   !!----------------------------------------------------------------------
752   WRITE(*,*) 'Impossible to be here'
753END SUBROUTINE Subcalledbyagrif
754#endif
Note: See TracBrowser for help on using the repository browser.