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 trunk/NEMO/NST_SRC – NEMO

source: trunk/NEMO/NST_SRC/agrif_user.F90 @ 390

Last change on this file since 390 was 390, checked in by opalod, 18 years ago

RB:nemo_v1_update_038: first integration of Agrif :

add interfaces between NEMO and Agrif in new directory NST_SRC

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.3 KB
Line 
1#if defined key_AGRIF
2      SUBROUTINE Agrif_InitWorkspace
3!
4!     Modules used:
5!
6      Use par_oce
7      Use dom_oce
8      USE Agrif_Util
9!
10!     Declarations:
11!     
12      IMPLICIT NONE
13!
14!     Variables     
15!
16
17!
18!     Begin
19!
20      if ( .NOT. Agrif_Root() ) then
21         jpiglo = nbcellsx + 2 + 2*nbghostcells
22         jpjglo = nbcellsy + 2 + 2*nbghostcells
23         jpi = ( jpiglo-2*jpreci + (jpni-1+0) ) / jpni + 2*jpreci
24         jpj = ( jpjglo-2*jprecj + (jpnj-1+0) ) / jpnj + 2*jprecj
25         jpim1 = jpi-1
26         jpjm1 = jpj-1
27         jpkm1 = jpk-1                                       
28         jpij  = jpi*jpj
29         jpidta = jpiglo
30         jpjdta = jpjglo
31         jpizoom = 1
32         jpjzoom = 1
33         nperio = 0
34         jperio = 0
35      endif
36
37
38      Return
39      End Subroutine Agrif_InitWorkspace
40
41!
42      SUBROUTINE Agrif_InitValues
43!     ------------------------------------------------------------------
44!     You should declare the variable which has to be interpolated here
45!     -----------------------------------------------------------------
46!
47!     Modules used:
48
49      USE Agrif_Util
50      USE oce
51      USE dom_oce
52      USE opa
53#if   defined key_tradmp   ||   defined key_esopa
54      USE tradmp
55#endif
56      USE sol_oce
57      USE in_out_manager
58#if defined key_ice_lim
59      USE ice_oce
60#endif
61#if defined key_AGRIF
62     USE agrif_opa_update
63     USE agrif_opa_interp
64     USE agrif_opa_sponge
65#endif
66!
67!     Declarations:
68!     
69      Implicit none
70!
71!     Variables
72!
73      REAL(wp) tabtemp(jpi,jpj,jpk)
74!
75      LOGICAL check_namelist
76!
77!
78!     Begin
79!
80#if defined key_orca_r025 || defined key_orca_r05 || defined key_orca_r2 || defined key_orca_r4
81      jp_cfg = -1  ! set special value for jp_cfg on fine grids
82      cp_cfg = "default"
83#endif
84
85      Call opa_init  ! Initializations of each fine grid
86!
87!     Specific fine grid Initializations
88!
89#if defined key_tradmp || defined key_esopa
90! no tracer damping on fine grids
91      lk_tradmp = .FALSE.
92#endif
93!     
94!     Declaration of the type of variable which have to be interpolated
95!
96      Call Agrif_Set_type(un,(/1,2,0/),(/2,3,0/))
97      Call Agrif_Set_type(vn,(/2,1,0/),(/3,2,0/))
98
99      Call Agrif_Set_type(ua,(/1,2,0/),(/2,3,0/))
100      Call Agrif_Set_type(va,(/2,1,0/),(/3,2,0/))
101
102      Call Agrif_Set_type(e1u,(/1,2/),(/2,3/))
103      Call Agrif_Set_type(e2v,(/2,1/),(/3,2/))
104           
105      Call Agrif_Set_type(tn,(/2,2,0/),(/3,3,0/))
106      Call Agrif_Set_type(sn,(/2,2,0/),(/3,3,0/)) 
107
108      Call Agrif_Set_type(tb,(/2,2,0/),(/3,3,0/))
109      Call Agrif_Set_type(sb,(/2,2,0/),(/3,3,0/)) 
110     
111      Call Agrif_Set_type(ta,(/2,2,0/),(/3,3,0/))
112      Call Agrif_Set_type(sa,(/2,2,0/),(/3,3,0/))       
113           
114      Call Agrif_Set_type(sshn,(/2,2/),(/3,3/))
115      Call Agrif_Set_type(gcb,(/2,2/),(/3,3/))
116
117!
118!     Space directions for each variables
119!
120      Call Agrif_Set_raf(un,(/'x','y','N'/))
121      Call Agrif_Set_raf(vn,(/'x','y','N'/))
122     
123      Call Agrif_Set_raf(ua,(/'x','y','N'/))
124      Call Agrif_Set_raf(va,(/'x','y','N'/))
125
126      Call Agrif_Set_raf(e1u,(/'x','y'/))
127      Call Agrif_Set_raf(e2v,(/'x','y'/))
128
129      Call Agrif_Set_raf(tn,(/'x','y','N'/))
130      Call Agrif_Set_raf(sn,(/'x','y','N'/))
131     
132      Call Agrif_Set_raf(tb,(/'x','y','N'/))
133      Call Agrif_Set_raf(sb,(/'x','y','N'/))
134     
135      Call Agrif_Set_raf(ta,(/'x','y','N'/))
136      Call Agrif_Set_raf(sa,(/'x','y','N'/))     
137           
138      Call Agrif_Set_raf(sshn,(/'x','y'/))
139      Call Agrif_Set_raf(gcb,(/'x','y'/))
140
141!
142!     type of interpolation
143
144      Call Agrif_Set_bcinterp(tn,interp=AGRIF_linear)
145      Call Agrif_Set_bcinterp(sn,interp=AGRIF_linear)
146     
147      Call Agrif_Set_bcinterp(ta,interp=AGRIF_linear)
148      Call Agrif_Set_bcinterp(sa,interp=AGRIF_linear)
149               
150      Call Agrif_Set_bcinterp(un,interp1=Agrif_linear,interp2=AGRIF_ppm)
151      Call Agrif_Set_bcinterp(vn,interp1=AGRIF_ppm,interp2=Agrif_linear)
152
153      Call Agrif_Set_bcinterp(ua,interp1=Agrif_linear,interp2=AGRIF_ppm)
154      Call Agrif_Set_bcinterp(va,interp1=AGRIF_ppm,interp2=Agrif_linear)
155     
156      Call Agrif_Set_bcinterp(e1u,interp1=Agrif_linear,interp2=AGRIF_ppm)
157      Call Agrif_Set_bcinterp(e2v,interp1=AGRIF_ppm,interp2=Agrif_linear)
158
159!
160!     Location of interpolation
161!
162      Call Agrif_Set_bc(un,(/0,1/))
163      Call Agrif_Set_bc(vn,(/0,1/))
164     
165      Call Agrif_Set_bc(e1u,(/0,0/))
166      Call Agrif_Set_bc(e2v,(/0,0/))
167
168      Call Agrif_Set_bc(tn,(/0,1/))
169      Call Agrif_Set_bc(sn,(/0,1/))
170
171      Call Agrif_Set_bc(ta,(/-3*Agrif_irhox(),0/))
172      Call Agrif_Set_bc(sa,(/-3*Agrif_irhox(),0/))
173
174      Call Agrif_Set_bc(ua,(/-2*Agrif_irhox(),0/))
175      Call Agrif_Set_bc(va,(/-2*Agrif_irhox(),0/))
176
177!     Update type
178     
179      Call Agrif_Set_Updatetype(tn, update = AGRIF_Update_Average)
180      Call Agrif_Set_Updatetype(sn, update = AGRIF_Update_Average)
181     
182      Call Agrif_Set_Updatetype(tb, update = AGRIF_Update_Average)
183      Call Agrif_Set_Updatetype(sb, update = AGRIF_Update_Average)
184
185      Call Agrif_Set_Updatetype(sshn, update = AGRIF_Update_Average)
186      Call Agrif_Set_Updatetype(gcb,update = AGRIF_Update_Average)
187
188      Call Agrif_Set_Updatetype(un,update1 = Agrif_Update_Copy, update2 = Agrif_Update_Average)
189      Call Agrif_Set_Updatetype(vn,update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy)
190
191      Call Agrif_Set_Updatetype(e1u,update1 = Agrif_Update_Copy, update2=Agrif_Update_Average)
192      Call Agrif_Set_Updatetype(e2v,update1 = Agrif_Update_Average, update2=Agrif_Update_Copy)
193
194! First interpolations of potentially non zero fields
195
196       Agrif_SpecialValue=0.
197       Agrif_UseSpecialValue = .TRUE.
198       Call Agrif_Bc_variable(tabtemp,tn,calledweight=1.)
199       Call Agrif_Bc_variable(tabtemp,sn,calledweight=1.)
200       Call Agrif_Bc_variable(tabtemp,un,calledweight=1.,procname=interpu)
201       Call Agrif_Bc_variable(tabtemp,vn,calledweight=1.,procname=interpv)
202
203       Call Agrif_Bc_variable(tabtemp,ta,calledweight=1.,procname=interptn)
204       Call Agrif_Bc_variable(tabtemp,sa,calledweight=1.,procname=interpsn)
205
206       Call Agrif_Bc_variable(tabtemp,ua,calledweight=1.,procname=interpun)
207       Call Agrif_Bc_variable(tabtemp,va,calledweight=1.,procname=interpvn)
208       Agrif_UseSpecialValue = .FALSE.
209!
210
211!
212      check_namelist = .true.
213!     
214      IF( check_namelist ) then     
215!
216! check time steps           
217!
218       If( nint(Agrif_Rhot()) * nint(rdt) .ne. Agrif_Parent(rdt) ) then
219              Write(*,*) 'incompatible time step between grids'
220              Write(*,*) 'parent grid value : ',Agrif_Parent(rdt)
221              Write(*,*) 'child  grid value : ',nint(rdt)
222              Write(*,*) 'value on parent grid should be : ',rdt*Agrif_Rhot()
223              stop
224       Endif
225           
226       If( Agrif_IRhot() * (Agrif_Parent(nitend)- &
227       Agrif_Parent(nit000)+1) .ne. (nitend-nit000+1) ) then
228            Write(*,*) 'incompatible run length between grids'
229            Write(*,*) 'parent grid value : ',(Agrif_Parent(nitend)- &
230            Agrif_Parent(nit000)+1),' time step'
231            Write(*,*) 'child  grid value : ', &
232            (nitend-nit000+1),' time step'
233            Write(*,*) 'value on child grid should be : ', &
234            Agrif_IRhot() * (Agrif_Parent(nitend)- &
235            Agrif_Parent(nit000)+1)
236           stop
237       Endif           
238!
239!
240#if defined key_partial_steps                                 
241!
242! check parameters for partial steps
243!
244       If( Agrif_Parent(e3zps_min) .ne. e3zps_min ) then
245            Write(*,*) 'incompatible e3zps_min between grids'
246            Write(*,*) 'parent grid :',Agrif_Parent(e3zps_min)
247            Write(*,*) 'child grid  :',e3zps_min
248            Write(*,*) 'those values should be identical'
249            stop
250       Endif         
251!         
252       If( Agrif_Parent(e3zps_rat) .ne. e3zps_rat ) then
253            Write(*,*) 'incompatible e3zps_rat between grids'
254            Write(*,*) 'parent grid :',Agrif_Parent(e3zps_rat)
255            Write(*,*) 'child grid  :',e3zps_rat
256            Write(*,*) 'those values should be identical'                 
257            stop
258       Endif                 
259#endif       
260!           
261      ENDIF
262!
263!
264
265      Call Agrif_Update_tra(0)
266      Call Agrif_Update_dyn(0)
267     
268      nbcline = 0
269
270      Return
271      End Subroutine Agrif_InitValues
272!
273      SUBROUTINE Agrif_detect(g,sizex)
274!
275!     Modules used:
276
277      Use Agrif_Types
278!
279!
280!     Declarations:
281!     
282!
283!     Variables     
284!
285      Integer, Dimension(2) :: sizex
286      Integer, Dimension(sizex(1),sizex(2))   :: g 
287!
288!     Begin
289!
290!
291
292!
293      Return
294      End Subroutine Agrif_detect
295     
296#if defined key_mpp_mpi
297!
298!     **************************************************************************
299!!!   Subroutine Agrif_InvLoc
300!     **************************************************************************
301!
302      Subroutine Agrif_InvLoc(indloc,nprocloc,i,indglob)
303
304!     Description:
305!
306      USE dom_oce
307
308!     Declarations:
309
310!!      Implicit none
311!
312      Integer :: indglob,indloc,nprocloc,i
313!
314!
315      SELECT CASE(i)
316
317      CASE(1)
318        indglob = indloc + nimppt(nprocloc+1) - 1
319
320      CASE(2)
321        indglob = indloc + njmppt(nprocloc+1) - 1 
322
323      CASE(3)
324        indglob = indloc
325
326      CASE(4)
327        indglob = indloc
328
329      END SELECT
330!
331!
332      End Subroutine Agrif_InvLoc
333#endif
334
335             
336#else
337      subroutine Subcalledbyagrif
338         write(*,*) 'Impossible to bet here'
339      end subroutine Subcalledbyagrif
340#endif
Note: See TracBrowser for help on using the repository browser.