1 | ! |
---|
2 | ! $Id$ |
---|
3 | ! |
---|
4 | ! AGRIF (Adaptive Grid Refinement In Fortran) |
---|
5 | ! |
---|
6 | ! Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr) |
---|
7 | ! Christophe Vouland (Christophe.Vouland@imag.fr) |
---|
8 | ! |
---|
9 | ! This program is free software; you can redistribute it and/or modify |
---|
10 | ! it under the terms of the GNU General Public License as published by |
---|
11 | ! the Free Software Foundation; either version 2 of the License, or |
---|
12 | ! (at your option) any later version. |
---|
13 | ! |
---|
14 | ! This program is distributed in the hope that it will be useful, |
---|
15 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | ! GNU General Public License for more details. |
---|
18 | ! |
---|
19 | ! You should have received a copy of the GNU General Public License |
---|
20 | ! along with this program; if not, write to the Free Software |
---|
21 | ! Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | ! |
---|
23 | ! |
---|
24 | !> Module to initialize a fine grid from its parent grid, by using a space interpolation |
---|
25 | ! |
---|
26 | module Agrif_Interpolation |
---|
27 | ! |
---|
28 | use Agrif_InterpBasic |
---|
29 | use Agrif_Arrays |
---|
30 | use Agrif_Mask |
---|
31 | use Agrif_CurgridFunctions |
---|
32 | #if defined AGRIF_MPI |
---|
33 | use Agrif_Mpp |
---|
34 | #endif |
---|
35 | ! |
---|
36 | implicit none |
---|
37 | ! |
---|
38 | logical, private:: precomputedone(7) = .FALSE. |
---|
39 | ! |
---|
40 | private :: Agrif_Parentbounds |
---|
41 | private :: Agrif_Interp_1D_recursive, Agrif_Interp_2D_recursive, Agrif_Interp_3D_recursive |
---|
42 | private :: Agrif_Interp_4D_recursive, Agrif_Interp_5D_recursive, Agrif_Interp_6D_recursive |
---|
43 | private :: Agrif_InterpBase |
---|
44 | private :: Agrif_Find_list_interp, Agrif_AddTo_list_interp |
---|
45 | ! |
---|
46 | contains |
---|
47 | ! |
---|
48 | !=================================================================================================== |
---|
49 | ! subroutine Agrif_InterpVariable |
---|
50 | ! |
---|
51 | !> Sets some arguments of subroutine Agrif_InterpnD, n being the dimension of the grid variable |
---|
52 | !--------------------------------------------------------------------------------------------------- |
---|
53 | subroutine Agrif_InterpVariable ( parent, child, torestore, procname ) |
---|
54 | !--------------------------------------------------------------------------------------------------- |
---|
55 | type(Agrif_Variable), pointer :: parent !< Variable on the parent grid |
---|
56 | type(Agrif_Variable), pointer :: child !< Variable on the child grid |
---|
57 | logical, intent(in) :: torestore !< .false. indicates that the results of the |
---|
58 | !! interpolation are applied on the whole current grid |
---|
59 | procedure() :: procname !< Data recovery procedure |
---|
60 | !--------------------------------------------------------------------------------------------------- |
---|
61 | logical :: memberin |
---|
62 | integer :: nbdim ! Number of dimensions of the current grid |
---|
63 | integer, dimension(6) :: type_interp ! Type of interpolation (linear,spline,...) |
---|
64 | integer, dimension(6) :: nb_child |
---|
65 | integer, dimension(6) :: lb_child |
---|
66 | integer, dimension(6) :: ub_child |
---|
67 | integer, dimension(6) :: lb_parent |
---|
68 | real , dimension(6) :: s_child, s_parent |
---|
69 | real , dimension(6) :: ds_child, ds_parent |
---|
70 | integer, dimension(child % root_var % nbdim,2,2) :: childarray |
---|
71 | ! |
---|
72 | nbdim = child % root_var % nbdim |
---|
73 | type_interp = child % root_var % type_interp |
---|
74 | ! |
---|
75 | call PreProcessToInterpOrUpdate( parent, child, & |
---|
76 | nb_child, ub_child, & |
---|
77 | lb_child, lb_parent, & |
---|
78 | s_child, s_parent, & |
---|
79 | ds_child, ds_parent, nbdim, interp=.true.) |
---|
80 | ! |
---|
81 | ! Call to a procedure of interpolation against the number of dimensions of the grid variable |
---|
82 | ! |
---|
83 | call Agrif_InterpnD(type_interp, parent, child, & |
---|
84 | lb_child, ub_child, & |
---|
85 | lb_child, lb_parent, & |
---|
86 | s_child, s_parent, & |
---|
87 | ds_child, ds_parent, & |
---|
88 | child, torestore, nbdim, & |
---|
89 | childarray, memberin, & |
---|
90 | .false., procname, 0, 0) |
---|
91 | !--------------------------------------------------------------------------------------------------- |
---|
92 | end subroutine Agrif_InterpVariable |
---|
93 | !=================================================================================================== |
---|
94 | ! |
---|
95 | !=================================================================================================== |
---|
96 | ! subroutine Agrif_InterpnD |
---|
97 | ! |
---|
98 | !> Interpolates a nD grid variable from its parent grid, by using a space interpolation |
---|
99 | !--------------------------------------------------------------------------------------------------- |
---|
100 | subroutine Agrif_InterpnD ( type_interp, parent, child, pttab, petab, pttab_Child, pttab_Parent, & |
---|
101 | s_Child, s_Parent, ds_Child, ds_Parent, restore, torestore, & |
---|
102 | nbdim, childarray, memberin, in_bc, procname, nb, ndir ) |
---|
103 | !--------------------------------------------------------------------------------------------------- |
---|
104 | #if defined AGRIF_MPI |
---|
105 | include 'mpif.h' |
---|
106 | #endif |
---|
107 | ! |
---|
108 | INTEGER, DIMENSION(6), INTENT(in) :: type_interp !< Type of interpolation ! (linear,...) |
---|
109 | TYPE(Agrif_Variable), pointer :: parent !< Variable of the parent grid |
---|
110 | TYPE(Agrif_Variable), pointer :: child !< Variable of the child grid |
---|
111 | INTEGER, DIMENSION(nbdim), INTENT(in) :: pttab !< Index of the first point inside the domain |
---|
112 | INTEGER, DIMENSION(nbdim), INTENT(in) :: petab !< Index of the first point inside the domain |
---|
113 | INTEGER, DIMENSION(nbdim), INTENT(in) :: pttab_Child !< Index of the first point inside the domain |
---|
114 | !< for the child grid variable |
---|
115 | INTEGER, DIMENSION(nbdim), INTENT(in) :: pttab_Parent !< Index of the first point inside the domain |
---|
116 | !< for the parent grid variable |
---|
117 | REAL, DIMENSION(nbdim), INTENT(in) :: s_Child,s_Parent !< Positions of the parent and child grids |
---|
118 | REAL, DIMENSION(nbdim), INTENT(in) :: ds_Child,ds_Parent !< Space steps of the parent and child grids |
---|
119 | TYPE(Agrif_Variable), pointer :: restore !< Indicates points where interpolation |
---|
120 | LOGICAL, INTENT(in) :: torestore !< Indicates if the array restore is used |
---|
121 | INTEGER, INTENT(in) :: nbdim |
---|
122 | LOGICAL, INTENT(out) :: memberin |
---|
123 | LOGICAL, INTENT(in) :: in_bc !< .true. if called from Agrif_CorrectVariable \n |
---|
124 | !! .false. if called from Agrif_InterpVariable |
---|
125 | procedure() :: procname !< Data recovery procedure |
---|
126 | INTEGER, INTENT(in) :: nb, ndir |
---|
127 | ! |
---|
128 | INTEGER :: i,j,k,l,m,n |
---|
129 | INTEGER, DIMENSION(nbdim) :: pttruetab,cetruetab |
---|
130 | INTEGER, DIMENSION(nbdim) :: indmin, indmax |
---|
131 | INTEGER, DIMENSION(nbdim) :: indminglob, indmaxglob |
---|
132 | #if defined AGRIF_MPI |
---|
133 | INTEGER, DIMENSION(nbdim) :: indminglob2,indmaxglob2 |
---|
134 | #endif |
---|
135 | LOGICAL, DIMENSION(nbdim) :: noraftab |
---|
136 | REAL , DIMENSION(nbdim) :: s_Child_temp,s_Parent_temp |
---|
137 | INTEGER, DIMENSION(nbdim) :: lowerbound, upperbound, coords |
---|
138 | INTEGER, DIMENSION(nbdim,2,2), INTENT(OUT) :: childarray |
---|
139 | INTEGER, DIMENSION(nbdim,2,2) :: parentarray |
---|
140 | LOGICAL :: member |
---|
141 | LOGICAL :: find_list_interp |
---|
142 | ! |
---|
143 | #if defined AGRIF_MPI |
---|
144 | ! |
---|
145 | INTEGER, PARAMETER :: etiquette = 100 |
---|
146 | INTEGER :: code, local_proc |
---|
147 | INTEGER, DIMENSION(nbdim,4) :: tab3 |
---|
148 | INTEGER, DIMENSION(nbdim,4,0:Agrif_Nbprocs-1) :: tab4 |
---|
149 | INTEGER, DIMENSION(nbdim,0:Agrif_Nbprocs-1,8) :: tab4t |
---|
150 | LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: memberinall |
---|
151 | LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc1, recvfromproc1 |
---|
152 | LOGICAL, DIMENSION(1) :: memberin1 |
---|
153 | LOGICAL :: memberout |
---|
154 | ! |
---|
155 | #endif |
---|
156 | ! |
---|
157 | type(Agrif_Variable), pointer, save :: tempC => NULL() ! Temporary child grid variable |
---|
158 | type(Agrif_Variable), pointer, save :: tempP => NULL() ! Temporary parent grid variable |
---|
159 | type(Agrif_Variable), pointer, save :: tempPextend => NULL() ! Temporary parent grid variable |
---|
160 | type(Agrif_Variable), pointer, save :: parentvalues => NULL() |
---|
161 | ! |
---|
162 | coords = child % root_var % coords |
---|
163 | ! |
---|
164 | ! Boundaries of the current grid where interpolation is done |
---|
165 | find_list_interp = & |
---|
166 | Agrif_Find_list_interp( & |
---|
167 | child % list_interp, & |
---|
168 | pttab, petab, pttab_Child, pttab_Parent, nbdim, & |
---|
169 | indmin, indmax, indminglob, indmaxglob, & |
---|
170 | pttruetab, cetruetab, memberin & |
---|
171 | #if defined AGRIF_MPI |
---|
172 | ,indminglob2, indmaxglob2, parentarray, & |
---|
173 | member, tab4t,memberinall, sendtoproc1, recvfromproc1 & |
---|
174 | #endif |
---|
175 | ) |
---|
176 | ! |
---|
177 | if (.not.find_list_interp) then |
---|
178 | ! |
---|
179 | call Agrif_get_var_bounds_array(child, lowerbound, upperbound, nbdim) |
---|
180 | call Agrif_Childbounds(nbdim, lowerbound, upperbound, & |
---|
181 | pttab, petab, Agrif_Procrank, coords, & |
---|
182 | pttruetab, cetruetab, memberin) |
---|
183 | call Agrif_Parentbounds(type_interp,nbdim,indminglob,indmaxglob, & |
---|
184 | s_Parent_temp,s_Child_temp, & |
---|
185 | s_Child,ds_Child, & |
---|
186 | s_Parent,ds_Parent, & |
---|
187 | pttab,petab, & |
---|
188 | pttab_Child,pttab_Parent, & |
---|
189 | child%root_var % posvar, coords) |
---|
190 | #if defined AGRIF_MPI |
---|
191 | if (memberin) then |
---|
192 | call Agrif_Parentbounds(type_interp,nbdim,indmin,indmax, & |
---|
193 | s_Parent_temp,s_Child_temp, & |
---|
194 | s_Child,ds_Child, & |
---|
195 | s_Parent,ds_Parent, & |
---|
196 | pttruetab,cetruetab, & |
---|
197 | pttab_Child,pttab_Parent, & |
---|
198 | child%root_var % posvar, coords) |
---|
199 | endif |
---|
200 | |
---|
201 | local_proc = Agrif_Procrank |
---|
202 | call Agrif_get_var_bounds_array(parent,lowerbound,upperbound,nbdim) |
---|
203 | call Agrif_ChildGrid_to_ParentGrid() |
---|
204 | ! |
---|
205 | call Agrif_Childbounds(nbdim,lowerbound,upperbound, & |
---|
206 | indminglob,indmaxglob, local_proc, coords, & |
---|
207 | indminglob2,indmaxglob2,member) |
---|
208 | ! |
---|
209 | if (member) then |
---|
210 | call Agrif_GlobalToLocalBounds(parentarray, & |
---|
211 | lowerbound, upperbound, & |
---|
212 | indminglob2, indmaxglob2, coords,& |
---|
213 | nbdim, local_proc, member) |
---|
214 | endif |
---|
215 | |
---|
216 | call Agrif_ParentGrid_to_ChildGrid() |
---|
217 | #else |
---|
218 | parentarray(:,1,1) = indminglob |
---|
219 | parentarray(:,2,1) = indmaxglob |
---|
220 | parentarray(:,1,2) = indminglob |
---|
221 | parentarray(:,2,2) = indmaxglob |
---|
222 | indmin = indminglob |
---|
223 | indmax = indmaxglob |
---|
224 | member = .TRUE. |
---|
225 | #endif |
---|
226 | |
---|
227 | else |
---|
228 | |
---|
229 | #if defined AGRIF_MPI |
---|
230 | s_Parent_temp = s_Parent + (indmin - pttab_Parent) * ds_Parent |
---|
231 | s_Child_temp = s_Child + (pttruetab - pttab_Child) * ds_Child |
---|
232 | #else |
---|
233 | parentarray(:,1,1) = indminglob |
---|
234 | parentarray(:,2,1) = indmaxglob |
---|
235 | parentarray(:,1,2) = indminglob |
---|
236 | parentarray(:,2,2) = indmaxglob |
---|
237 | indmin = indminglob |
---|
238 | indmax = indmaxglob |
---|
239 | member = .TRUE. |
---|
240 | s_Parent_temp = s_Parent + (indminglob - pttab_Parent) * ds_Parent |
---|
241 | s_Child_temp = s_Child + (pttab - pttab_Child) * ds_Child |
---|
242 | #endif |
---|
243 | endif |
---|
244 | ! |
---|
245 | if (member) then |
---|
246 | if (.not.associated(tempP)) allocate(tempP) |
---|
247 | ! |
---|
248 | call Agrif_array_allocate(tempP,parentarray(:,1,1),parentarray(:,2,1),nbdim) |
---|
249 | call Agrif_var_set_array_tozero(tempP,nbdim) |
---|
250 | |
---|
251 | call Agrif_ChildGrid_to_ParentGrid() |
---|
252 | ! |
---|
253 | select case (nbdim) |
---|
254 | case(1) |
---|
255 | call procname(tempP%array1, & |
---|
256 | parentarray(1,1,2),parentarray(1,2,2),.TRUE.,nb,ndir) |
---|
257 | case(2) |
---|
258 | call procname(tempP%array2, & |
---|
259 | parentarray(1,1,2),parentarray(1,2,2), & |
---|
260 | parentarray(2,1,2),parentarray(2,2,2),.TRUE.,nb,ndir) |
---|
261 | case(3) |
---|
262 | call procname(tempP%array3, & |
---|
263 | parentarray(1,1,2),parentarray(1,2,2), & |
---|
264 | parentarray(2,1,2),parentarray(2,2,2), & |
---|
265 | parentarray(3,1,2),parentarray(3,2,2),.TRUE.,nb,ndir) |
---|
266 | case(4) |
---|
267 | call procname(tempP%array4, & |
---|
268 | parentarray(1,1,2),parentarray(1,2,2), & |
---|
269 | parentarray(2,1,2),parentarray(2,2,2), & |
---|
270 | parentarray(3,1,2),parentarray(3,2,2), & |
---|
271 | parentarray(4,1,2),parentarray(4,2,2),.TRUE.,nb,ndir) |
---|
272 | case(5) |
---|
273 | call procname(tempP%array5, & |
---|
274 | parentarray(1,1,2),parentarray(1,2,2), & |
---|
275 | parentarray(2,1,2),parentarray(2,2,2), & |
---|
276 | parentarray(3,1,2),parentarray(3,2,2), & |
---|
277 | parentarray(4,1,2),parentarray(4,2,2), & |
---|
278 | parentarray(5,1,2),parentarray(5,2,2),.TRUE.,nb,ndir) |
---|
279 | case(6) |
---|
280 | call procname(tempP%array6, & |
---|
281 | parentarray(1,1,2),parentarray(1,2,2), & |
---|
282 | parentarray(2,1,2),parentarray(2,2,2), & |
---|
283 | parentarray(3,1,2),parentarray(3,2,2), & |
---|
284 | parentarray(4,1,2),parentarray(4,2,2), & |
---|
285 | parentarray(5,1,2),parentarray(5,2,2), & |
---|
286 | parentarray(6,1,2),parentarray(6,2,2),.TRUE.,nb,ndir) |
---|
287 | end select |
---|
288 | ! |
---|
289 | call Agrif_ParentGrid_to_ChildGrid() |
---|
290 | ! |
---|
291 | endif |
---|
292 | |
---|
293 | #if defined AGRIF_MPI |
---|
294 | if (.not.find_list_interp) then |
---|
295 | ! |
---|
296 | tab3(:,1) = indminglob2(:) |
---|
297 | tab3(:,2) = indmaxglob2(:) |
---|
298 | tab3(:,3) = indmin(:) |
---|
299 | tab3(:,4) = indmax(:) |
---|
300 | ! |
---|
301 | call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,MPI_INTEGER,Agrif_mpi_comm,code) |
---|
302 | |
---|
303 | if (.not.associated(tempPextend)) allocate(tempPextend) |
---|
304 | |
---|
305 | do k=0,Agrif_Nbprocs-1 |
---|
306 | do j=1,4 |
---|
307 | do i=1,nbdim |
---|
308 | tab4t(i,k,j) = tab4(i,j,k) |
---|
309 | enddo |
---|
310 | enddo |
---|
311 | enddo |
---|
312 | |
---|
313 | memberin1(1) = memberin |
---|
314 | call MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall,1,MPI_LOGICAL,Agrif_mpi_comm,code) |
---|
315 | |
---|
316 | call Get_External_Data_first(tab4t(:,:,1),tab4t(:,:,2), & |
---|
317 | tab4t(:,:,3),tab4t(:,:,4), & |
---|
318 | nbdim,memberinall, coords, & |
---|
319 | sendtoproc1,recvfromproc1, & |
---|
320 | tab4t(:,:,5),tab4t(:,:,6), & |
---|
321 | tab4t(:,:,7),tab4t(:,:,8) ) |
---|
322 | endif |
---|
323 | |
---|
324 | call ExchangeSameLevel(sendtoproc1,recvfromproc1,nbdim, & |
---|
325 | tab4t(:,:,3),tab4t(:,:,4),tab4t(:,:,5),tab4t(:,:,6), & |
---|
326 | tab4t(:,:,7),tab4t(:,:,8),memberin,tempP,tempPextend) |
---|
327 | #else |
---|
328 | tempPextend => tempP |
---|
329 | #endif |
---|
330 | |
---|
331 | if (.not.find_list_interp) then |
---|
332 | call Agrif_Addto_list_interp( & |
---|
333 | child%list_interp,pttab,petab, & |
---|
334 | pttab_Child,pttab_Parent,indmin,indmax, & |
---|
335 | indminglob,indmaxglob, & |
---|
336 | pttruetab,cetruetab, & |
---|
337 | memberin,nbdim & |
---|
338 | #if defined AGRIF_MPI |
---|
339 | ,indminglob2,indmaxglob2, & |
---|
340 | parentarray, & |
---|
341 | member, & |
---|
342 | tab4t,memberinall,sendtoproc1,recvfromproc1 & |
---|
343 | #endif |
---|
344 | ) |
---|
345 | endif |
---|
346 | ! |
---|
347 | if (memberin) then |
---|
348 | ! |
---|
349 | if (.not.associated(tempC)) allocate(tempC) |
---|
350 | ! |
---|
351 | call Agrif_array_allocate(tempC,pttruetab,cetruetab,nbdim) |
---|
352 | ! |
---|
353 | ! Special values on the parent grid |
---|
354 | if (Agrif_UseSpecialValue) then |
---|
355 | ! |
---|
356 | noraftab(1:nbdim) = child % root_var % interptab(1:nbdim) == 'N' |
---|
357 | ! |
---|
358 | if (.not.associated(parentvalues)) allocate(parentvalues) |
---|
359 | ! |
---|
360 | call Agrif_array_allocate(parentvalues,indmin,indmax,nbdim) |
---|
361 | call Agrif_var_full_copy_array(parentvalues,tempPextend,nbdim) |
---|
362 | ! |
---|
363 | call Agrif_CheckMasknD(tempPextend,parentvalues, & |
---|
364 | indmin(1:nbdim),indmax(1:nbdim), & |
---|
365 | indmin(1:nbdim),indmax(1:nbdim), & |
---|
366 | noraftab(1:nbdim),nbdim) |
---|
367 | ! |
---|
368 | call Agrif_array_deallocate(parentvalues,nbdim) |
---|
369 | ! |
---|
370 | endif |
---|
371 | ! |
---|
372 | ! Interpolation of the current grid |
---|
373 | ! |
---|
374 | if ( memberin ) then |
---|
375 | select case(nbdim) |
---|
376 | case(1) |
---|
377 | call Agrif_Interp_1D_recursive( type_interp(1), & |
---|
378 | tempPextend%array1, & |
---|
379 | tempC%array1, & |
---|
380 | indmin(1), indmax(1), & |
---|
381 | pttruetab(1), cetruetab(1), & |
---|
382 | s_Child_temp(1), s_Parent_temp(1), & |
---|
383 | ds_Child(1), ds_Parent(1) ) |
---|
384 | case(2) |
---|
385 | call Agrif_Interp_2D_recursive( type_interp(1:2), & |
---|
386 | tempPextend % array2, & |
---|
387 | tempC % array2, & |
---|
388 | indmin(1:2), indmax(1:2), & |
---|
389 | pttruetab(1:2), cetruetab(1:2), & |
---|
390 | s_Child_temp(1:2), s_Parent_temp(1:2), & |
---|
391 | ds_Child(1:2), ds_Parent(1:2) ) |
---|
392 | case(3) |
---|
393 | call Agrif_Interp_3D_recursive( type_interp(1:3), & |
---|
394 | tempPextend % array3, & |
---|
395 | tempC % array3, & |
---|
396 | indmin(1:3), indmax(1:3), & |
---|
397 | pttruetab(1:3), cetruetab(1:3), & |
---|
398 | s_Child_temp(1:3), s_Parent_temp(1:3), & |
---|
399 | ds_Child(1:3), ds_Parent(1:3) ) |
---|
400 | case(4) |
---|
401 | call Agrif_Interp_4D_recursive( type_interp(1:4), & |
---|
402 | tempPextend % array4, & |
---|
403 | tempC % array4, & |
---|
404 | indmin(1:4), indmax(1:4), & |
---|
405 | pttruetab(1:4), cetruetab(1:4), & |
---|
406 | s_Child_temp(1:4), s_Parent_temp(1:4), & |
---|
407 | ds_Child(1:4), ds_Parent(1:4) ) |
---|
408 | case(5) |
---|
409 | call Agrif_Interp_5D_recursive( type_interp(1:5), & |
---|
410 | tempPextend % array5, & |
---|
411 | tempC % array5, & |
---|
412 | indmin(1:5), indmax(1:5), & |
---|
413 | pttruetab(1:5), cetruetab(1:5), & |
---|
414 | s_Child_temp(1:5), s_Parent_temp(1:5), & |
---|
415 | ds_Child(1:5), ds_Parent(1:5) ) |
---|
416 | case(6) |
---|
417 | call Agrif_Interp_6D_recursive( type_interp(1:6), & |
---|
418 | tempPextend % array6, & |
---|
419 | tempC % array6, & |
---|
420 | indmin(1:6), indmax(1:6), & |
---|
421 | pttruetab(1:6), cetruetab(1:6), & |
---|
422 | s_Child_temp(1:6), s_Parent_temp(1:6), & |
---|
423 | ds_Child(1:6), ds_Parent(1:6) ) |
---|
424 | end select |
---|
425 | ! |
---|
426 | call Agrif_get_var_bounds_array(child,lowerbound,upperbound,nbdim) |
---|
427 | |
---|
428 | #if defined AGRIF_MPI |
---|
429 | call Agrif_GlobalToLocalBounds(childarray, lowerbound, upperbound, & |
---|
430 | pttruetab, cetruetab, coords, & |
---|
431 | nbdim, Agrif_Procrank, memberout) |
---|
432 | #else |
---|
433 | childarray(:,1,1) = pttruetab |
---|
434 | childarray(:,2,1) = cetruetab |
---|
435 | childarray(:,1,2) = pttruetab |
---|
436 | childarray(:,2,2) = cetruetab |
---|
437 | !cccccccccccccc memberout = .TRUE. |
---|
438 | #endif |
---|
439 | ! |
---|
440 | ! Special values on the child grid |
---|
441 | if (Agrif_UseSpecialValueFineGrid) then |
---|
442 | call GiveAgrif_SpecialValueToTab_mpi( child, tempC, childarray, Agrif_SpecialValueFineGrid,nbdim ) |
---|
443 | endif |
---|
444 | ! |
---|
445 | endif ! ( memberin ) |
---|
446 | ! |
---|
447 | if (torestore) then |
---|
448 | ! |
---|
449 | #if defined AGRIF_MPI |
---|
450 | ! |
---|
451 | SELECT CASE (nbdim) |
---|
452 | CASE (1) |
---|
453 | do i = pttruetab(1),cetruetab(1) |
---|
454 | !hildarrayAModifier if (restore%restore1D(i) == 0) & |
---|
455 | !hildarrayAModifier child%array1(childarray(i,1,2)) = tempC%array1(i) |
---|
456 | enddo |
---|
457 | CASE (2) |
---|
458 | do i = pttruetab(1),cetruetab(1) |
---|
459 | do j = pttruetab(2),cetruetab(2) |
---|
460 | !hildarrayAModifier if (restore%restore2D(i,j) == 0) & |
---|
461 | !hildarrayAModifier child%array2(childarray(i,1,2), & |
---|
462 | !hildarrayAModifier childarray(j,2,2)) = tempC%array2(i,j) |
---|
463 | enddo |
---|
464 | enddo |
---|
465 | CASE (3) |
---|
466 | do i = pttruetab(1),cetruetab(1) |
---|
467 | do j = pttruetab(2),cetruetab(2) |
---|
468 | do k = pttruetab(3),cetruetab(3) |
---|
469 | !hildarrayAModifier if (restore%restore3D(i,j,k) == 0) & |
---|
470 | !hildarrayAModifier child%array3(childarray(i,1,2), & |
---|
471 | !hildarrayAModifier childarray(j,2,2), & |
---|
472 | !hildarrayAModifier childarray(k,3,2)) = tempC%array3(i,j,k) |
---|
473 | enddo |
---|
474 | enddo |
---|
475 | enddo |
---|
476 | CASE (4) |
---|
477 | do i = pttruetab(1),cetruetab(1) |
---|
478 | do j = pttruetab(2),cetruetab(2) |
---|
479 | do k = pttruetab(3),cetruetab(3) |
---|
480 | do l = pttruetab(4),cetruetab(4) |
---|
481 | !hildarrayAModifier if (restore%restore4D(i,j,k,l) == 0) & |
---|
482 | !hildarrayAModifier child%array4(childarray(i,1,2), & |
---|
483 | !hildarrayAModifier childarray(j,2,2), & |
---|
484 | !hildarrayAModifier childarray(k,3,2), & |
---|
485 | !hildarrayAModifier childarray(l,4,2)) = tempC%array4(i,j,k,l) |
---|
486 | enddo |
---|
487 | enddo |
---|
488 | enddo |
---|
489 | enddo |
---|
490 | CASE (5) |
---|
491 | do i = pttruetab(1),cetruetab(1) |
---|
492 | do j = pttruetab(2),cetruetab(2) |
---|
493 | do k = pttruetab(3),cetruetab(3) |
---|
494 | do l = pttruetab(4),cetruetab(4) |
---|
495 | do m = pttruetab(5),cetruetab(5) |
---|
496 | !hildarrayAModifier if (restore%restore5D(i,j,k,l,m) == 0) & |
---|
497 | !hildarrayAModifier child%array5(childarray(i,1,2), & |
---|
498 | !hildarrayAModifier childarray(j,2,2), & |
---|
499 | !hildarrayAModifier childarray(k,3,2), & |
---|
500 | !hildarrayAModifier childarray(l,4,2), & |
---|
501 | !hildarrayAModifier childarray(m,5,2)) = tempC%array5(i,j,k,l,m) |
---|
502 | enddo |
---|
503 | enddo |
---|
504 | enddo |
---|
505 | enddo |
---|
506 | enddo |
---|
507 | CASE (6) |
---|
508 | do i = pttruetab(1),cetruetab(1) |
---|
509 | do j = pttruetab(2),cetruetab(2) |
---|
510 | do k = pttruetab(3),cetruetab(3) |
---|
511 | do l = pttruetab(4),cetruetab(4) |
---|
512 | do m = pttruetab(5),cetruetab(5) |
---|
513 | do n = pttruetab(6),cetruetab(6) |
---|
514 | !hildarrayAModifier if (restore%restore6D(i,j,k,l,m,n) == 0) & |
---|
515 | !hildarrayAModifier child%array6(childarray(i,1,2), & |
---|
516 | !hildarrayAModifier childarray(j,2,2), & |
---|
517 | !hildarrayAModifier childarray(k,3,2), & |
---|
518 | !hildarrayAModifier childarray(l,4,2), & |
---|
519 | !hildarrayAModifier childarray(m,5,2), & |
---|
520 | !hildarrayAModifier childarray(n,6,2)) = tempC%array6(i,j,k,l,m,n) |
---|
521 | enddo |
---|
522 | enddo |
---|
523 | enddo |
---|
524 | enddo |
---|
525 | enddo |
---|
526 | enddo |
---|
527 | END SELECT |
---|
528 | ! |
---|
529 | #else |
---|
530 | select case (nbdim) |
---|
531 | case (1) |
---|
532 | do i = pttruetab(1),cetruetab(1) |
---|
533 | if (restore%restore1D(i) == 0) & |
---|
534 | parray1(i) = tempC % array1(i) |
---|
535 | enddo |
---|
536 | case (2) |
---|
537 | do j = pttruetab(2),cetruetab(2) |
---|
538 | do i = pttruetab(1),cetruetab(1) |
---|
539 | if (restore%restore2D(i,j) == 0) & |
---|
540 | parray2(i,j) = tempC % array2(i,j) |
---|
541 | enddo |
---|
542 | enddo |
---|
543 | case (3) |
---|
544 | do k = pttruetab(3),cetruetab(3) |
---|
545 | do j = pttruetab(2),cetruetab(2) |
---|
546 | do i = pttruetab(1),cetruetab(1) |
---|
547 | if (restore%restore3D(i,j,k) == 0) & |
---|
548 | parray3(i,j,k) = tempC % array3(i,j,k) |
---|
549 | enddo |
---|
550 | enddo |
---|
551 | enddo |
---|
552 | case (4) |
---|
553 | do l = pttruetab(4),cetruetab(4) |
---|
554 | do k = pttruetab(3),cetruetab(3) |
---|
555 | do j = pttruetab(2),cetruetab(2) |
---|
556 | do i = pttruetab(1),cetruetab(1) |
---|
557 | if (restore%restore4D(i,j,k,l) == 0) & |
---|
558 | parray4(i,j,k,l) = tempC % array4(i,j,k,l) |
---|
559 | enddo |
---|
560 | enddo |
---|
561 | enddo |
---|
562 | enddo |
---|
563 | case (5) |
---|
564 | do m = pttruetab(5),cetruetab(5) |
---|
565 | do l = pttruetab(4),cetruetab(4) |
---|
566 | do k = pttruetab(3),cetruetab(3) |
---|
567 | do j = pttruetab(2),cetruetab(2) |
---|
568 | do i = pttruetab(1),cetruetab(1) |
---|
569 | if (restore%restore5D(i,j,k,l,m) == 0) & |
---|
570 | parray5(i,j,k,l,m) = tempC % array5(i,j,k,l,m) |
---|
571 | enddo |
---|
572 | enddo |
---|
573 | enddo |
---|
574 | enddo |
---|
575 | enddo |
---|
576 | case (6) |
---|
577 | do n = pttruetab(6),cetruetab(6) |
---|
578 | do m = pttruetab(5),cetruetab(5) |
---|
579 | do l = pttruetab(4),cetruetab(4) |
---|
580 | do k = pttruetab(3),cetruetab(3) |
---|
581 | do j = pttruetab(2),cetruetab(2) |
---|
582 | do i = pttruetab(1),cetruetab(1) |
---|
583 | if (restore%restore6D(i,j,k,l,m,n) == 0) & |
---|
584 | parray6(i,j,k,l,m,n) = tempC % array6(i,j,k,l,m,n) |
---|
585 | enddo |
---|
586 | enddo |
---|
587 | enddo |
---|
588 | enddo |
---|
589 | enddo |
---|
590 | enddo |
---|
591 | end select |
---|
592 | ! |
---|
593 | #endif |
---|
594 | ! |
---|
595 | else ! .not.to_restore |
---|
596 | ! |
---|
597 | if (memberin) then |
---|
598 | ! |
---|
599 | if ( .not.in_bc ) then |
---|
600 | select case(nbdim) |
---|
601 | case(1) |
---|
602 | call procname(tempC % array1( & |
---|
603 | childarray(1,1,1):childarray(1,2,1)), & |
---|
604 | childarray(1,1,2),childarray(1,2,2),.FALSE.,nb,ndir) |
---|
605 | case(2) |
---|
606 | call procname( & |
---|
607 | tempC % array2( & |
---|
608 | childarray(1,1,1):childarray(1,2,1), & |
---|
609 | childarray(2,1,1):childarray(2,2,1)), & |
---|
610 | childarray(1,1,2),childarray(1,2,2), & |
---|
611 | childarray(2,1,2),childarray(2,2,2),.FALSE.,nb,ndir) |
---|
612 | case(3) |
---|
613 | call procname( & |
---|
614 | tempC % array3( & |
---|
615 | childarray(1,1,1):childarray(1,2,1), & |
---|
616 | childarray(2,1,1):childarray(2,2,1), & |
---|
617 | childarray(3,1,1):childarray(3,2,1)), & |
---|
618 | childarray(1,1,2),childarray(1,2,2), & |
---|
619 | childarray(2,1,2),childarray(2,2,2), & |
---|
620 | childarray(3,1,2),childarray(3,2,2),.FALSE.,nb,ndir) |
---|
621 | case(4) |
---|
622 | call procname( & |
---|
623 | tempC % array4( & |
---|
624 | childarray(1,1,1):childarray(1,2,1), & |
---|
625 | childarray(2,1,1):childarray(2,2,1), & |
---|
626 | childarray(3,1,1):childarray(3,2,1), & |
---|
627 | childarray(4,1,1):childarray(4,2,1)), & |
---|
628 | childarray(1,1,2),childarray(1,2,2), & |
---|
629 | childarray(2,1,2),childarray(2,2,2), & |
---|
630 | childarray(3,1,2),childarray(3,2,2), & |
---|
631 | childarray(4,1,2),childarray(4,2,2),.FALSE.,nb,ndir) |
---|
632 | case(5) |
---|
633 | call procname( & |
---|
634 | tempC % array5( & |
---|
635 | childarray(1,1,1):childarray(1,2,1), & |
---|
636 | childarray(2,1,1):childarray(2,2,1), & |
---|
637 | childarray(3,1,1):childarray(3,2,1), & |
---|
638 | childarray(4,1,1):childarray(4,2,1), & |
---|
639 | childarray(5,1,1):childarray(5,2,1)), & |
---|
640 | childarray(1,1,2),childarray(1,2,2), & |
---|
641 | childarray(2,1,2),childarray(2,2,2), & |
---|
642 | childarray(3,1,2),childarray(3,2,2), & |
---|
643 | childarray(4,1,2),childarray(4,2,2), & |
---|
644 | childarray(5,1,2),childarray(5,2,2),.FALSE.,nb,ndir) |
---|
645 | case(6) |
---|
646 | call procname( & |
---|
647 | tempC % array6( & |
---|
648 | childarray(1,1,1):childarray(1,2,1), & |
---|
649 | childarray(2,1,1):childarray(2,2,1), & |
---|
650 | childarray(3,1,1):childarray(3,2,1), & |
---|
651 | childarray(4,1,1):childarray(4,2,1), & |
---|
652 | childarray(5,1,1):childarray(5,2,1), & |
---|
653 | childarray(6,1,1):childarray(6,2,1)), & |
---|
654 | childarray(1,1,2),childarray(1,2,2), & |
---|
655 | childarray(2,1,2),childarray(2,2,2), & |
---|
656 | childarray(3,1,2),childarray(3,2,2), & |
---|
657 | childarray(4,1,2),childarray(4,2,2), & |
---|
658 | childarray(5,1,2),childarray(5,2,2), & |
---|
659 | childarray(6,1,2),childarray(6,2,2),.FALSE.,nb,ndir) |
---|
660 | end select |
---|
661 | else ! we are in_bc |
---|
662 | select case (nbdim) |
---|
663 | case (1) |
---|
664 | parray1(childarray(1,1,2):childarray(1,2,2)) = & |
---|
665 | tempC%array1(childarray(1,1,1):childarray(1,2,1)) |
---|
666 | case (2) |
---|
667 | parray2(childarray(1,1,2):childarray(1,2,2), & |
---|
668 | childarray(2,1,2):childarray(2,2,2)) = & |
---|
669 | tempC%array2(childarray(1,1,1):childarray(1,2,1), & |
---|
670 | childarray(2,1,1):childarray(2,2,1)) |
---|
671 | case (3) |
---|
672 | parray3(childarray(1,1,2):childarray(1,2,2), & |
---|
673 | childarray(2,1,2):childarray(2,2,2), & |
---|
674 | childarray(3,1,2):childarray(3,2,2)) = & |
---|
675 | tempC%array3(childarray(1,1,1):childarray(1,2,1), & |
---|
676 | childarray(2,1,1):childarray(2,2,1), & |
---|
677 | childarray(3,1,1):childarray(3,2,1)) |
---|
678 | case (4) |
---|
679 | parray4(childarray(1,1,2):childarray(1,2,2), & |
---|
680 | childarray(2,1,2):childarray(2,2,2), & |
---|
681 | childarray(3,1,2):childarray(3,2,2), & |
---|
682 | childarray(4,1,2):childarray(4,2,2)) = & |
---|
683 | tempC%array4(childarray(1,1,1):childarray(1,2,1), & |
---|
684 | childarray(2,1,1):childarray(2,2,1), & |
---|
685 | childarray(3,1,1):childarray(3,2,1), & |
---|
686 | childarray(4,1,1):childarray(4,2,1)) |
---|
687 | case (5) |
---|
688 | parray5(childarray(1,1,2):childarray(1,2,2), & |
---|
689 | childarray(2,1,2):childarray(2,2,2), & |
---|
690 | childarray(3,1,2):childarray(3,2,2), & |
---|
691 | childarray(4,1,2):childarray(4,2,2), & |
---|
692 | childarray(5,1,2):childarray(5,2,2)) = & |
---|
693 | tempC%array5(childarray(1,1,1):childarray(1,2,1), & |
---|
694 | childarray(2,1,1):childarray(2,2,1), & |
---|
695 | childarray(3,1,1):childarray(3,2,1), & |
---|
696 | childarray(4,1,1):childarray(4,2,1), & |
---|
697 | childarray(5,1,1):childarray(5,2,1)) |
---|
698 | case (6) |
---|
699 | parray6(childarray(1,1,2):childarray(1,2,2), & |
---|
700 | childarray(2,1,2):childarray(2,2,2), & |
---|
701 | childarray(3,1,2):childarray(3,2,2), & |
---|
702 | childarray(4,1,2):childarray(4,2,2), & |
---|
703 | childarray(5,1,2):childarray(5,2,2), & |
---|
704 | childarray(6,1,2):childarray(6,2,2)) = & |
---|
705 | tempC%array6(childarray(1,1,1):childarray(1,2,1), & |
---|
706 | childarray(2,1,1):childarray(2,2,1), & |
---|
707 | childarray(3,1,1):childarray(3,2,1), & |
---|
708 | childarray(4,1,1):childarray(4,2,1), & |
---|
709 | childarray(5,1,1):childarray(5,2,1), & |
---|
710 | childarray(6,1,1):childarray(6,2,1)) |
---|
711 | end select |
---|
712 | endif ! < (.not.in_bc) |
---|
713 | endif ! < memberin |
---|
714 | ! |
---|
715 | endif |
---|
716 | |
---|
717 | call Agrif_array_deallocate(tempPextend,nbdim) |
---|
718 | call Agrif_array_deallocate(tempC,nbdim) |
---|
719 | |
---|
720 | endif |
---|
721 | ! |
---|
722 | ! Deallocations |
---|
723 | #if defined AGRIF_MPI |
---|
724 | if (member) then |
---|
725 | call Agrif_array_deallocate(tempP,nbdim) |
---|
726 | endif |
---|
727 | #endif |
---|
728 | !--------------------------------------------------------------------------------------------------- |
---|
729 | end subroutine Agrif_InterpnD |
---|
730 | !=================================================================================================== |
---|
731 | ! |
---|
732 | !=================================================================================================== |
---|
733 | ! subroutine Agrif_Parentbounds |
---|
734 | ! |
---|
735 | !> Calculates the bounds of the parent grid for the interpolation of the child grid |
---|
736 | !--------------------------------------------------------------------------------------------------- |
---|
737 | subroutine Agrif_Parentbounds ( type_interp, nbdim, indmin, indmax, & |
---|
738 | s_Parent_temp, s_Child_temp, & |
---|
739 | s_Child, ds_Child, & |
---|
740 | s_Parent,ds_Parent, & |
---|
741 | pttruetab, cetruetab, & |
---|
742 | pttab_Child, pttab_Parent, posvar, coords ) |
---|
743 | !--------------------------------------------------------------------------------------------------- |
---|
744 | INTEGER, DIMENSION(6), intent(in) :: type_interp |
---|
745 | INTEGER, intent(in) :: nbdim |
---|
746 | INTEGER, DIMENSION(nbdim), intent(out) :: indmin, indmax |
---|
747 | REAL, DIMENSION(nbdim), intent(out) :: s_Parent_temp, s_child_temp |
---|
748 | REAL, DIMENSION(nbdim), intent(in) :: s_Child, ds_child |
---|
749 | REAL, DIMENSION(nbdim), intent(in) :: s_Parent,ds_Parent |
---|
750 | INTEGER, DIMENSION(nbdim), intent(in) :: pttruetab, cetruetab |
---|
751 | INTEGER, DIMENSION(nbdim), intent(in) :: pttab_Child, pttab_Parent |
---|
752 | INTEGER, DIMENSION(nbdim), intent(in) :: posvar |
---|
753 | INTEGER, DIMENSION(nbdim), intent(in) :: coords |
---|
754 | ! |
---|
755 | INTEGER :: i |
---|
756 | REAL,DIMENSION(nbdim) :: dim_newmin, dim_newmax |
---|
757 | ! |
---|
758 | dim_newmin = s_Child + (pttruetab - pttab_Child) * ds_Child |
---|
759 | dim_newmax = s_Child + (cetruetab - pttab_Child) * ds_Child |
---|
760 | ! |
---|
761 | do i = 1,nbdim |
---|
762 | ! |
---|
763 | indmin(i) = pttab_Parent(i) + agrif_int((dim_newmin(i)-s_Parent(i))/ds_Parent(i)) |
---|
764 | indmax(i) = pttab_Parent(i) + agrif_ceiling((dim_newmax(i)-s_Parent(i))/ds_Parent(i)) |
---|
765 | ! |
---|
766 | ! Necessary for the Quadratic interpolation |
---|
767 | ! |
---|
768 | if ( (pttruetab(i) == cetruetab(i)) .and. (posvar(i) == 1) ) then |
---|
769 | elseif ( coords(i) == 0 ) then ! (interptab == 'N') |
---|
770 | elseif ( (type_interp(i) == Agrif_ppm) .or. & |
---|
771 | (type_interp(i) == Agrif_eno) .or. & |
---|
772 | (type_interp(i) == Agrif_ppm_lim) .or. & |
---|
773 | (type_interp(i) == Agrif_weno) ) then |
---|
774 | indmin(i) = indmin(i) - 2 |
---|
775 | indmax(i) = indmax(i) + 2 |
---|
776 | |
---|
777 | if (Agrif_UseSpecialValue) then |
---|
778 | indmin(i) = indmin(i)-MaxSearch |
---|
779 | indmax(i) = indmax(i)+MaxSearch |
---|
780 | endif |
---|
781 | |
---|
782 | elseif ( (type_interp(i) /= Agrif_constant) .and. & |
---|
783 | (type_interp(i) /= Agrif_linear) ) then |
---|
784 | indmin(i) = indmin(i) - 1 |
---|
785 | indmax(i) = indmax(i) + 1 |
---|
786 | |
---|
787 | if (Agrif_UseSpecialValue) then |
---|
788 | indmin(i) = indmin(i)-MaxSearch |
---|
789 | indmax(i) = indmax(i)+MaxSearch |
---|
790 | endif |
---|
791 | |
---|
792 | elseif ( (type_interp(i) == Agrif_constant) .or. & |
---|
793 | (type_interp(i) == Agrif_linear) ) then |
---|
794 | if (Agrif_UseSpecialValue) then |
---|
795 | indmin(i) = indmin(i)-MaxSearch |
---|
796 | indmax(i) = indmax(i)+MaxSearch |
---|
797 | endif |
---|
798 | |
---|
799 | endif |
---|
800 | ! |
---|
801 | enddo |
---|
802 | ! |
---|
803 | s_Parent_temp = s_Parent + (indmin - pttab_Parent) * ds_Parent |
---|
804 | s_Child_temp = s_Child + (pttruetab - pttab_Child) * ds_Child |
---|
805 | !--------------------------------------------------------------------------------------------------- |
---|
806 | end subroutine Agrif_Parentbounds |
---|
807 | !=================================================================================================== |
---|
808 | ! |
---|
809 | !=================================================================================================== |
---|
810 | ! subroutine Agrif_Interp_1D_Recursive |
---|
811 | ! |
---|
812 | !> Subroutine for the interpolation of a 1D grid variable. |
---|
813 | !> It calls Agrif_InterpBase. |
---|
814 | !--------------------------------------------------------------------------------------------------- |
---|
815 | subroutine Agrif_Interp_1D_recursive ( type_interp, tabin, tabout, & |
---|
816 | indmin, indmax, & |
---|
817 | pttab_child, petab_child, & |
---|
818 | s_child, s_parent, & |
---|
819 | ds_child, ds_parent ) |
---|
820 | !--------------------------------------------------------------------------------------------------- |
---|
821 | integer, intent(in) :: type_interp |
---|
822 | integer, intent(in) :: indmin, indmax |
---|
823 | integer, intent(in) :: pttab_child, petab_child |
---|
824 | real, intent(in) :: s_child, s_parent |
---|
825 | real, intent(in) :: ds_child, ds_parent |
---|
826 | real, dimension( & |
---|
827 | indmin:indmax & |
---|
828 | ), intent(in) :: tabin |
---|
829 | real, dimension( & |
---|
830 | pttab_child:petab_child & |
---|
831 | ), intent(out) :: tabout |
---|
832 | !--------------------------------------------------------------------------------------------------- |
---|
833 | call Agrif_InterpBase(type_interp, & |
---|
834 | tabin(indmin:indmax), & |
---|
835 | tabout(pttab_child:petab_child), & |
---|
836 | indmin, indmax, & |
---|
837 | pttab_child, petab_child, & |
---|
838 | s_parent, s_child, & |
---|
839 | ds_parent, ds_child) |
---|
840 | !--------------------------------------------------------------------------------------------------- |
---|
841 | end subroutine Agrif_Interp_1D_recursive |
---|
842 | !=================================================================================================== |
---|
843 | ! |
---|
844 | !=================================================================================================== |
---|
845 | ! subroutine Agrif_Interp_2D_Recursive |
---|
846 | ! |
---|
847 | !> Subroutine for the interpolation of a 2D grid variable. |
---|
848 | !> It calls Agrif_Interp_1D_recursive and Agrif_InterpBase. |
---|
849 | !--------------------------------------------------------------------------------------------------- |
---|
850 | subroutine Agrif_Interp_2D_recursive ( type_interp, tabin, tabout, & |
---|
851 | indmin, indmax, & |
---|
852 | pttab_child, petab_child, & |
---|
853 | s_child, s_parent, & |
---|
854 | ds_child, ds_parent ) |
---|
855 | !--------------------------------------------------------------------------------------------------- |
---|
856 | integer, dimension(2), intent(in) :: type_interp |
---|
857 | integer, dimension(2), intent(in) :: indmin, indmax |
---|
858 | integer, dimension(2), intent(in) :: pttab_child, petab_child |
---|
859 | real, dimension(2), intent(in) :: s_child, s_parent |
---|
860 | real, dimension(2), intent(in) :: ds_child, ds_parent |
---|
861 | real, dimension( & |
---|
862 | indmin(1):indmax(1), & |
---|
863 | indmin(2):indmax(2)), intent(in) :: tabin |
---|
864 | real, dimension( & |
---|
865 | pttab_child(1):petab_child(1), & |
---|
866 | pttab_child(2):petab_child(2)), intent(out) :: tabout |
---|
867 | !--------------------------------------------------------------------------------------------------- |
---|
868 | real, dimension( & |
---|
869 | pttab_child(1):petab_child(1), & |
---|
870 | indmin(2):indmax(2)) :: tabtemp |
---|
871 | real, dimension( & |
---|
872 | pttab_child(2):petab_child(2), & |
---|
873 | pttab_child(1):petab_child(1)) :: tabout_trsp |
---|
874 | real, dimension( & |
---|
875 | indmin(2):indmax(2), & |
---|
876 | pttab_child(1):petab_child(1)) :: tabtemp_trsp |
---|
877 | integer :: i, j, coeffraf |
---|
878 | !--------------------------------------------------------------------------------------------------- |
---|
879 | ! |
---|
880 | coeffraf = nint ( ds_parent(1) / ds_child(1) ) |
---|
881 | ! |
---|
882 | if ((type_interp(1) == Agrif_Linear) .and. (coeffraf /= 1)) then |
---|
883 | !---CDIR NEXPAND |
---|
884 | if(.NOT. precomputedone(1)) & |
---|
885 | call Linear1dPrecompute2d( & |
---|
886 | indmax(2)-indmin(2)+1, & |
---|
887 | indmax(1)-indmin(1)+1, & |
---|
888 | petab_child(1)-pttab_child(1)+1, & |
---|
889 | s_parent(1),s_child(1),ds_parent(1),ds_child(1),1) |
---|
890 | !---CDIR NEXPAND |
---|
891 | call Linear1dAfterCompute(tabin,tabtemp,size(tabin),size(tabtemp),1) |
---|
892 | ! |
---|
893 | elseif ((type_interp(1) == Agrif_PPM) .and. (coeffraf /= 1)) then |
---|
894 | !---CDIR NEXPAND |
---|
895 | if(.NOT. precomputedone(1)) & |
---|
896 | call PPM1dPrecompute2d( & |
---|
897 | indmax(2)-indmin(2)+1, & |
---|
898 | indmax(1)-indmin(1)+1, & |
---|
899 | petab_child(1)-pttab_child(1)+1, & |
---|
900 | s_parent(1),s_child(1),ds_parent(1),ds_child(1),1) |
---|
901 | !---CDIR NEXPAND |
---|
902 | call PPM1dAfterCompute(tabin,tabtemp,size(tabin),size(tabtemp),1) |
---|
903 | else |
---|
904 | do j = indmin(2),indmax(2) |
---|
905 | ! |
---|
906 | !---CDIR NEXPAND |
---|
907 | call Agrif_Interp_1D_recursive(type_interp(1), & |
---|
908 | tabin(indmin(1):indmax(1),j), & |
---|
909 | tabtemp(pttab_child(1):petab_child(1),j), & |
---|
910 | indmin(1),indmax(1), & |
---|
911 | pttab_child(1),petab_child(1), & |
---|
912 | s_child(1), s_parent(1), & |
---|
913 | ds_child(1),ds_parent(1)) |
---|
914 | ! |
---|
915 | enddo |
---|
916 | endif |
---|
917 | |
---|
918 | coeffraf = nint(ds_parent(2)/ds_child(2)) |
---|
919 | tabtemp_trsp = TRANSPOSE(tabtemp) |
---|
920 | |
---|
921 | if ((type_interp(2) == Agrif_Linear) .and. (coeffraf /= 1)) then |
---|
922 | !---CDIR NEXPAND |
---|
923 | if(.NOT. precomputedone(2)) & |
---|
924 | call Linear1dPrecompute2d( & |
---|
925 | petab_child(1)-pttab_child(1)+1, & |
---|
926 | indmax(2)-indmin(2)+1, & |
---|
927 | petab_child(2)-pttab_child(2)+1, & |
---|
928 | s_parent(2),s_child(2),ds_parent(2),ds_child(2),2) |
---|
929 | !---CDIR NEXPAND |
---|
930 | call Linear1dAfterCompute(tabtemp_trsp,tabout_trsp, & |
---|
931 | size(tabtemp_trsp),size(tabout_trsp),2) |
---|
932 | |
---|
933 | elseif ((type_interp(2) == Agrif_PPM) .and. (coeffraf /= 1)) then |
---|
934 | !---CDIR NEXPAND |
---|
935 | if(.NOT. precomputedone(2)) & |
---|
936 | call PPM1dPrecompute2d( & |
---|
937 | petab_child(1)-pttab_child(1)+1, & |
---|
938 | indmax(2)-indmin(2)+1, & |
---|
939 | petab_child(2)-pttab_child(2)+1, & |
---|
940 | s_parent(2),s_child(2),ds_parent(2),ds_child(2),2) |
---|
941 | !---CDIR NEXPAND |
---|
942 | call PPM1dAfterCompute(tabtemp_trsp, tabout_trsp, & |
---|
943 | size(tabtemp_trsp), size(tabout_trsp), 2) |
---|
944 | else |
---|
945 | do i = pttab_child(1), petab_child(1) |
---|
946 | ! |
---|
947 | !---CDIR NEXPAND |
---|
948 | call Agrif_InterpBase(type_interp(2), & |
---|
949 | tabtemp_trsp(indmin(2):indmax(2), i), & |
---|
950 | tabout_trsp(pttab_child(2):petab_child(2), i), & |
---|
951 | indmin(2), indmax(2), & |
---|
952 | pttab_child(2), petab_child(2), & |
---|
953 | s_parent(2), s_child(2), & |
---|
954 | ds_parent(2), ds_child(2) ) |
---|
955 | enddo |
---|
956 | endif |
---|
957 | ! |
---|
958 | tabout = TRANSPOSE(tabout_trsp) |
---|
959 | !--------------------------------------------------------------------------------------------------- |
---|
960 | end subroutine Agrif_Interp_2D_recursive |
---|
961 | !=================================================================================================== |
---|
962 | ! |
---|
963 | !=================================================================================================== |
---|
964 | ! subroutine Agrif_Interp_3D_Recursive |
---|
965 | ! |
---|
966 | !> Subroutine for the interpolation of a 3D grid variable. |
---|
967 | !> It calls #Agrif_Interp_2D_recursive and #Agrif_InterpBase. |
---|
968 | !--------------------------------------------------------------------------------------------------- |
---|
969 | subroutine Agrif_Interp_3D_recursive ( type_interp, tabin, tabout, & |
---|
970 | indmin, indmax, & |
---|
971 | pttab_child, petab_child, & |
---|
972 | s_child, s_parent, & |
---|
973 | ds_child, ds_parent ) |
---|
974 | !--------------------------------------------------------------------------------------------------- |
---|
975 | integer, dimension(3), intent(in) :: type_interp |
---|
976 | integer, dimension(3), intent(in) :: indmin, indmax |
---|
977 | integer, dimension(3), intent(in) :: pttab_child, petab_child |
---|
978 | real, dimension(3), intent(in) :: s_child, s_parent |
---|
979 | real, dimension(3), intent(in) :: ds_child, ds_parent |
---|
980 | real, dimension( & |
---|
981 | indmin(1):indmax(1), & |
---|
982 | indmin(2):indmax(2), & |
---|
983 | indmin(3):indmax(3)), intent(in) :: tabin |
---|
984 | real, dimension( & |
---|
985 | pttab_child(1):petab_child(1), & |
---|
986 | pttab_child(2):petab_child(2), & |
---|
987 | pttab_child(3):petab_child(3)), intent(out) :: tabout |
---|
988 | !--------------------------------------------------------------------------------------------------- |
---|
989 | real, dimension( & |
---|
990 | pttab_child(1):petab_child(1), & |
---|
991 | pttab_child(2):petab_child(2), & |
---|
992 | indmin(3):indmax(3)) :: tabtemp |
---|
993 | integer :: i, j, k, coeffraf |
---|
994 | integer :: locind_child_left, kdeb |
---|
995 | ! |
---|
996 | coeffraf = nint ( ds_parent(1) / ds_child(1) ) |
---|
997 | if ( (type_interp(1) == Agrif_Linear) .and. (coeffraf/=1) ) then |
---|
998 | call Linear1dPrecompute2d(indmax(2)-indmin(2)+1, & |
---|
999 | indmax(1)-indmin(1)+1, & |
---|
1000 | petab_child(1)-pttab_child(1)+1, & |
---|
1001 | s_parent(1),s_child(1),ds_parent(1),ds_child(1),1) |
---|
1002 | precomputedone(1) = .TRUE. |
---|
1003 | elseif ( (type_interp(1) == Agrif_PPM) .and. (coeffraf/=1) ) then |
---|
1004 | call PPM1dPrecompute2d(indmax(2)-indmin(2)+1, & |
---|
1005 | indmax(1)-indmin(1)+1, & |
---|
1006 | petab_child(1)-pttab_child(1)+1, & |
---|
1007 | s_parent(1),s_child(1),ds_parent(1),ds_child(1),1) |
---|
1008 | precomputedone(1) = .TRUE. |
---|
1009 | endif |
---|
1010 | |
---|
1011 | coeffraf = nint ( ds_parent(2) / ds_child(2) ) |
---|
1012 | if ( (type_interp(2) == Agrif_Linear) .and. (coeffraf/=1) ) then |
---|
1013 | call Linear1dPrecompute2d(petab_child(1)-pttab_child(1)+1, & |
---|
1014 | indmax(2)-indmin(2)+1, & |
---|
1015 | petab_child(2)-pttab_child(2)+1, & |
---|
1016 | s_parent(2),s_child(2),ds_parent(2),ds_child(2),2) |
---|
1017 | precomputedone(2) = .TRUE. |
---|
1018 | elseif ( (type_interp(2) == Agrif_PPM) .and. (coeffraf/=1) ) then |
---|
1019 | call PPM1dPrecompute2d(petab_child(1)-pttab_child(1)+1, & |
---|
1020 | indmax(2)-indmin(2)+1, & |
---|
1021 | petab_child(2)-pttab_child(2)+1, & |
---|
1022 | s_parent(2),s_child(2),ds_parent(2),ds_child(2),2) |
---|
1023 | precomputedone(2) = .TRUE. |
---|
1024 | endif |
---|
1025 | ! |
---|
1026 | do k = indmin(3), indmax(3) |
---|
1027 | call Agrif_Interp_2D_recursive(type_interp(1:2), & |
---|
1028 | tabin(indmin(1):indmax(1), & |
---|
1029 | indmin(2):indmax(2), k), & |
---|
1030 | tabtemp(pttab_child(1):petab_child(1), & |
---|
1031 | pttab_child(2):petab_child(2), k), & |
---|
1032 | indmin(1:2), indmax(1:2), & |
---|
1033 | pttab_child(1:2), petab_child(1:2), & |
---|
1034 | s_child(1:2), s_parent(1:2), & |
---|
1035 | ds_child(1:2), ds_parent(1:2) ) |
---|
1036 | enddo |
---|
1037 | ! |
---|
1038 | precomputedone(1) = .FALSE. |
---|
1039 | precomputedone(2) = .FALSE. |
---|
1040 | coeffraf = nint(ds_parent(3)/ds_child(3)) |
---|
1041 | ! |
---|
1042 | if ( coeffraf == 1 ) then |
---|
1043 | locind_child_left = 1 + agrif_int((s_child(3)-s_parent(3))/ds_parent(3)) |
---|
1044 | kdeb = indmin(3)+locind_child_left-2 |
---|
1045 | do k = pttab_child(3),petab_child(3) |
---|
1046 | kdeb = kdeb + 1 |
---|
1047 | do j = pttab_child(2), petab_child(2) |
---|
1048 | do i = pttab_child(1), petab_child(1) |
---|
1049 | tabout(i,j,k) = tabtemp(i,j,kdeb) |
---|
1050 | enddo |
---|
1051 | enddo |
---|
1052 | enddo |
---|
1053 | else |
---|
1054 | do j = pttab_child(2), petab_child(2) |
---|
1055 | do i = pttab_child(1), petab_child(1) |
---|
1056 | call Agrif_InterpBase(type_interp(3), & |
---|
1057 | tabtemp(i,j,indmin(3):indmax(3)), & |
---|
1058 | tabout(i,j,pttab_child(3):petab_child(3)), & |
---|
1059 | indmin(3), indmax(3), & |
---|
1060 | pttab_child(3), petab_child(3), & |
---|
1061 | s_parent(3), s_child(3), & |
---|
1062 | ds_parent(3), ds_child(3) ) |
---|
1063 | enddo |
---|
1064 | enddo |
---|
1065 | endif |
---|
1066 | !--------------------------------------------------------------------------------------------------- |
---|
1067 | end subroutine Agrif_Interp_3D_recursive |
---|
1068 | !=================================================================================================== |
---|
1069 | ! |
---|
1070 | !=================================================================================================== |
---|
1071 | ! subroutine Agrif_Interp_4D_Recursive |
---|
1072 | ! |
---|
1073 | !> Subroutine for the interpolation of a 4D grid variable. |
---|
1074 | !> It calls #Agrif_Interp_3D_recursive and #Agrif_InterpBase. |
---|
1075 | !--------------------------------------------------------------------------------------------------- |
---|
1076 | subroutine Agrif_Interp_4D_recursive ( type_interp, tabin, tabout, & |
---|
1077 | indmin, indmax, & |
---|
1078 | pttab_child, petab_child, & |
---|
1079 | s_child, s_parent, & |
---|
1080 | ds_child, ds_parent ) |
---|
1081 | !--------------------------------------------------------------------------------------------------- |
---|
1082 | integer, dimension(4), intent(in) :: type_interp |
---|
1083 | integer, dimension(4), intent(in) :: indmin, indmax |
---|
1084 | integer, dimension(4), intent(in) :: pttab_child, petab_child |
---|
1085 | real, dimension(4), intent(in) :: s_child, s_parent |
---|
1086 | real, dimension(4), intent(in) :: ds_child, ds_parent |
---|
1087 | real, dimension( & |
---|
1088 | indmin(1):indmax(1), & |
---|
1089 | indmin(2):indmax(2), & |
---|
1090 | indmin(3):indmax(3), & |
---|
1091 | indmin(4):indmax(4)), intent(in) :: tabin |
---|
1092 | real, dimension( & |
---|
1093 | pttab_child(1):petab_child(1), & |
---|
1094 | pttab_child(2):petab_child(2), & |
---|
1095 | pttab_child(3):petab_child(3), & |
---|
1096 | pttab_child(4):petab_child(4)), intent(out) :: tabout |
---|
1097 | !--------------------------------------------------------------------------------------------------- |
---|
1098 | real, dimension( & |
---|
1099 | pttab_child(1):petab_child(1), & |
---|
1100 | pttab_child(2):petab_child(2), & |
---|
1101 | pttab_child(3):petab_child(3), & |
---|
1102 | indmin(4):indmax(4)) :: tabtemp |
---|
1103 | integer :: i, j, k, l |
---|
1104 | ! |
---|
1105 | do l = indmin(4), indmax(4) |
---|
1106 | call Agrif_Interp_3D_recursive(type_interp(1:3), & |
---|
1107 | tabin(indmin(1):indmax(1), & |
---|
1108 | indmin(2):indmax(2), & |
---|
1109 | indmin(3):indmax(3), l), & |
---|
1110 | tabtemp(pttab_child(1):petab_child(1), & |
---|
1111 | pttab_child(2):petab_child(2), & |
---|
1112 | pttab_child(3):petab_child(3), l), & |
---|
1113 | indmin(1:3), indmax(1:3), & |
---|
1114 | pttab_child(1:3), petab_child(1:3), & |
---|
1115 | s_child(1:3), s_parent(1:3), & |
---|
1116 | ds_child(1:3), ds_parent(1:3) ) |
---|
1117 | enddo |
---|
1118 | ! |
---|
1119 | do k = pttab_child(3), petab_child(3) |
---|
1120 | do j = pttab_child(2), petab_child(2) |
---|
1121 | do i = pttab_child(1), petab_child(1) |
---|
1122 | call Agrif_InterpBase(type_interp(4), & |
---|
1123 | tabtemp(i,j,k,indmin(4):indmax(4)), & |
---|
1124 | tabout(i,j,k,pttab_child(4):petab_child(4)), & |
---|
1125 | indmin(4), indmax(4), & |
---|
1126 | pttab_child(4), petab_child(4), & |
---|
1127 | s_parent(4), s_child(4), & |
---|
1128 | ds_parent(4), ds_child(4) ) |
---|
1129 | enddo |
---|
1130 | enddo |
---|
1131 | enddo |
---|
1132 | !--------------------------------------------------------------------------------------------------- |
---|
1133 | end subroutine Agrif_Interp_4D_recursive |
---|
1134 | !=================================================================================================== |
---|
1135 | ! |
---|
1136 | !=================================================================================================== |
---|
1137 | ! subroutine Agrif_Interp_5D_Recursive |
---|
1138 | ! |
---|
1139 | !> Subroutine for the interpolation of a 5D grid variable. |
---|
1140 | !> It calls #Agrif_Interp_4D_recursive and #Agrif_InterpBase. |
---|
1141 | !--------------------------------------------------------------------------------------------------- |
---|
1142 | subroutine Agrif_Interp_5D_recursive ( type_interp, tabin, tabout, & |
---|
1143 | indmin, indmax, & |
---|
1144 | pttab_child, petab_child, & |
---|
1145 | s_child, s_parent, & |
---|
1146 | ds_child, ds_parent ) |
---|
1147 | !--------------------------------------------------------------------------------------------------- |
---|
1148 | integer, dimension(5), intent(in) :: type_interp |
---|
1149 | integer, dimension(5), intent(in) :: indmin, indmax |
---|
1150 | integer, dimension(5), intent(in) :: pttab_child, petab_child |
---|
1151 | real, dimension(5), intent(in) :: s_child, s_parent |
---|
1152 | real, dimension(5), intent(in) :: ds_child, ds_parent |
---|
1153 | real, dimension( & |
---|
1154 | indmin(1):indmax(1), & |
---|
1155 | indmin(2):indmax(2), & |
---|
1156 | indmin(3):indmax(3), & |
---|
1157 | indmin(4):indmax(4), & |
---|
1158 | indmin(5):indmax(5)), intent(in) :: tabin |
---|
1159 | real, dimension( & |
---|
1160 | pttab_child(1):petab_child(1), & |
---|
1161 | pttab_child(2):petab_child(2), & |
---|
1162 | pttab_child(3):petab_child(3), & |
---|
1163 | pttab_child(4):petab_child(4), & |
---|
1164 | pttab_child(5):petab_child(5)), intent(out) :: tabout |
---|
1165 | !--------------------------------------------------------------------------------------------------- |
---|
1166 | real, dimension( & |
---|
1167 | pttab_child(1):petab_child(1), & |
---|
1168 | pttab_child(2):petab_child(2), & |
---|
1169 | pttab_child(3):petab_child(3), & |
---|
1170 | pttab_child(4):petab_child(4), & |
---|
1171 | indmin(5):indmax(5)) :: tabtemp |
---|
1172 | integer :: i, j, k, l, m |
---|
1173 | ! |
---|
1174 | do m = indmin(5), indmax(5) |
---|
1175 | call Agrif_Interp_4D_recursive(type_interp(1:4), & |
---|
1176 | tabin(indmin(1):indmax(1), & |
---|
1177 | indmin(2):indmax(2), & |
---|
1178 | indmin(3):indmax(3), & |
---|
1179 | indmin(4):indmax(4),m), & |
---|
1180 | tabtemp(pttab_child(1):petab_child(1), & |
---|
1181 | pttab_child(2):petab_child(2), & |
---|
1182 | pttab_child(3):petab_child(3), & |
---|
1183 | pttab_child(4):petab_child(4), m), & |
---|
1184 | indmin(1:4),indmax(1:4), & |
---|
1185 | pttab_child(1:4), petab_child(1:4), & |
---|
1186 | s_child(1:4), s_parent(1:4), & |
---|
1187 | ds_child(1:4), ds_parent(1:4) ) |
---|
1188 | enddo |
---|
1189 | ! |
---|
1190 | do l = pttab_child(4), petab_child(4) |
---|
1191 | do k = pttab_child(3), petab_child(3) |
---|
1192 | do j = pttab_child(2), petab_child(2) |
---|
1193 | do i = pttab_child(1), petab_child(1) |
---|
1194 | call Agrif_InterpBase(type_interp(5), & |
---|
1195 | tabtemp(i,j,k,l,indmin(5):indmax(5)), & |
---|
1196 | tabout(i,j,k,l,pttab_child(5):petab_child(5)), & |
---|
1197 | indmin(5), indmax(5), & |
---|
1198 | pttab_child(5), petab_child(5), & |
---|
1199 | s_parent(5), s_child(5), & |
---|
1200 | ds_parent(5), ds_child(5) ) |
---|
1201 | enddo |
---|
1202 | enddo |
---|
1203 | enddo |
---|
1204 | enddo |
---|
1205 | !--------------------------------------------------------------------------------------------------- |
---|
1206 | end subroutine Agrif_Interp_5D_recursive |
---|
1207 | !=================================================================================================== |
---|
1208 | ! |
---|
1209 | !=================================================================================================== |
---|
1210 | ! subroutine Agrif_Interp_6D_Recursive |
---|
1211 | ! |
---|
1212 | !> Subroutine for the interpolation of a 6D grid variable. |
---|
1213 | !> It calls #Agrif_Interp_5D_recursive and Agrif_InterpBase. |
---|
1214 | !--------------------------------------------------------------------------------------------------- |
---|
1215 | subroutine Agrif_Interp_6D_recursive ( type_interp, tabin, tabout, & |
---|
1216 | indmin, indmax, & |
---|
1217 | pttab_child, petab_child, & |
---|
1218 | s_child, s_parent, & |
---|
1219 | ds_child, ds_parent ) |
---|
1220 | !--------------------------------------------------------------------------------------------------- |
---|
1221 | integer, dimension(6), intent(in) :: type_interp |
---|
1222 | integer, dimension(6), intent(in) :: indmin, indmax |
---|
1223 | integer, dimension(6), intent(in) :: pttab_child, petab_child |
---|
1224 | real, dimension(6), intent(in) :: s_child, s_parent |
---|
1225 | real, dimension(6), intent(in) :: ds_child, ds_parent |
---|
1226 | real, dimension( & |
---|
1227 | indmin(1):indmax(1), & |
---|
1228 | indmin(2):indmax(2), & |
---|
1229 | indmin(3):indmax(3), & |
---|
1230 | indmin(4):indmax(4), & |
---|
1231 | indmin(5):indmax(5), & |
---|
1232 | indmin(6):indmax(6)), intent(in) :: tabin |
---|
1233 | real, dimension( & |
---|
1234 | pttab_child(1):petab_child(1), & |
---|
1235 | pttab_child(2):petab_child(2), & |
---|
1236 | pttab_child(3):petab_child(3), & |
---|
1237 | pttab_child(4):petab_child(4), & |
---|
1238 | pttab_child(5):petab_child(5), & |
---|
1239 | pttab_child(6):petab_child(6)), intent(out) :: tabout |
---|
1240 | !--------------------------------------------------------------------------------------------------- |
---|
1241 | real, dimension( & |
---|
1242 | pttab_child(1):petab_child(1), & |
---|
1243 | pttab_child(2):petab_child(2), & |
---|
1244 | pttab_child(3):petab_child(3), & |
---|
1245 | pttab_child(4):petab_child(4), & |
---|
1246 | pttab_child(5):petab_child(5), & |
---|
1247 | indmin(6):indmax(6)) :: tabtemp |
---|
1248 | integer :: i, j, k, l, m, n |
---|
1249 | ! |
---|
1250 | do n = indmin(6), indmax(6) |
---|
1251 | call Agrif_Interp_5D_recursive(type_interp(1:5), & |
---|
1252 | tabin(indmin(1):indmax(1), & |
---|
1253 | indmin(2):indmax(2), & |
---|
1254 | indmin(3):indmax(3), & |
---|
1255 | indmin(4):indmax(4), & |
---|
1256 | indmin(5):indmax(5), n), & |
---|
1257 | tabtemp(pttab_child(1):petab_child(1), & |
---|
1258 | pttab_child(2):petab_child(2), & |
---|
1259 | pttab_child(3):petab_child(3), & |
---|
1260 | pttab_child(4):petab_child(4), & |
---|
1261 | pttab_child(5):petab_child(5), n), & |
---|
1262 | indmin(1:5),indmax(1:5), & |
---|
1263 | pttab_child(1:5), petab_child(1:5), & |
---|
1264 | s_child(1:5), s_parent(1:5), & |
---|
1265 | ds_child(1:5),ds_parent(1:5) ) |
---|
1266 | enddo |
---|
1267 | ! |
---|
1268 | do m = pttab_child(5), petab_child(5) |
---|
1269 | do l = pttab_child(4), petab_child(4) |
---|
1270 | do k = pttab_child(3), petab_child(3) |
---|
1271 | do j = pttab_child(2), petab_child(2) |
---|
1272 | do i = pttab_child(1), petab_child(1) |
---|
1273 | call Agrif_InterpBase(type_interp(6), & |
---|
1274 | tabtemp(i,j,k,l,m,indmin(6):indmax(6)), & |
---|
1275 | tabout(i,j,k,l,m,pttab_child(6):petab_child(6)), & |
---|
1276 | indmin(6), indmax(6), & |
---|
1277 | pttab_child(6), petab_child(6), & |
---|
1278 | s_parent(6), s_child(6), & |
---|
1279 | ds_parent(6), ds_child(6) ) |
---|
1280 | enddo |
---|
1281 | enddo |
---|
1282 | enddo |
---|
1283 | enddo |
---|
1284 | enddo |
---|
1285 | !--------------------------------------------------------------------------------------------------- |
---|
1286 | end subroutine Agrif_Interp_6D_recursive |
---|
1287 | !=================================================================================================== |
---|
1288 | ! |
---|
1289 | !=================================================================================================== |
---|
1290 | ! subroutine Agrif_InterpBase |
---|
1291 | ! |
---|
1292 | !> Calls the interpolation method chosen by the user (linear, lagrange, spline, etc.). |
---|
1293 | !--------------------------------------------------------------------------------------------------- |
---|
1294 | subroutine Agrif_InterpBase ( type_interp, parenttab, childtab, indmin, indmax, & |
---|
1295 | pttab_child, petab_child, & |
---|
1296 | s_parent, s_child, ds_parent, ds_child ) |
---|
1297 | !--------------------------------------------------------------------------------------------------- |
---|
1298 | INTEGER :: type_interp |
---|
1299 | INTEGER :: indmin, indmax |
---|
1300 | INTEGER :: pttab_child, petab_child |
---|
1301 | REAL, DIMENSION(indmin:indmax), INTENT(IN) :: parenttab |
---|
1302 | REAL, DIMENSION(pttab_child:petab_child), INTENT(OUT) :: childtab |
---|
1303 | REAL :: s_parent, s_child |
---|
1304 | REAL :: ds_parent,ds_child |
---|
1305 | ! |
---|
1306 | if ( (indmin == indmax) .and. (pttab_child == petab_child) ) then |
---|
1307 | ! |
---|
1308 | childtab(pttab_child) = parenttab(indmin) |
---|
1309 | ! |
---|
1310 | elseif (type_interp == Agrif_LINEAR) then ! Linear interpolation |
---|
1311 | ! |
---|
1312 | call Agrif_basicinterp_linear1D(parenttab,childtab, & |
---|
1313 | indmax-indmin+1,petab_child-pttab_child+1, & |
---|
1314 | s_parent,s_child,ds_parent,ds_child) |
---|
1315 | ! |
---|
1316 | elseif ( type_interp == Agrif_PPM ) then ! PPM interpolation |
---|
1317 | |
---|
1318 | call PPM1d(parenttab,childtab, & |
---|
1319 | indmax-indmin+1,petab_child-pttab_child+1, & |
---|
1320 | s_parent,s_child,ds_parent,ds_child) |
---|
1321 | ! |
---|
1322 | elseif ( type_interp == Agrif_PPM_LIM ) then ! PPM interpolation |
---|
1323 | |
---|
1324 | call PPM1d_lim(parenttab,childtab, & |
---|
1325 | indmax-indmin+1,petab_child-pttab_child+1, & |
---|
1326 | s_parent,s_child,ds_parent,ds_child) |
---|
1327 | ! |
---|
1328 | elseif (type_interp == Agrif_LAGRANGE) then ! Lagrange interpolation |
---|
1329 | ! |
---|
1330 | call lagrange1D(parenttab,childtab, & |
---|
1331 | indmax-indmin+1,petab_child-pttab_child+1, & |
---|
1332 | s_parent,s_child,ds_parent,ds_child) |
---|
1333 | ! |
---|
1334 | elseif (type_interp == Agrif_ENO) then ! Eno interpolation |
---|
1335 | ! |
---|
1336 | call ENO1d(parenttab,childtab, & |
---|
1337 | indmax-indmin+1,petab_child-pttab_child+1, & |
---|
1338 | s_parent,s_child,ds_parent,ds_child) |
---|
1339 | ! |
---|
1340 | elseif (type_interp == Agrif_WENO) then ! Weno interpolation |
---|
1341 | ! |
---|
1342 | call WENO1d(parenttab,childtab, & |
---|
1343 | indmax-indmin+1,petab_child-pttab_child+1, & |
---|
1344 | s_parent,s_child,ds_parent,ds_child) |
---|
1345 | ! |
---|
1346 | elseif (type_interp == Agrif_LINEARCONSERV) then ! Linear conservative interpolation |
---|
1347 | ! |
---|
1348 | call Linear1dConserv(parenttab,childtab, & |
---|
1349 | indmax-indmin+1,petab_child-pttab_child+1, & |
---|
1350 | s_parent,s_child,ds_parent,ds_child) |
---|
1351 | ! |
---|
1352 | elseif (type_interp == Agrif_LINEARCONSERVLIM) then !Linear conservative interpolation |
---|
1353 | ! |
---|
1354 | call Linear1dConservLim(parenttab,childtab, & |
---|
1355 | indmax-indmin+1,petab_child-pttab_child+1, & |
---|
1356 | s_parent,s_child,ds_parent,ds_child) |
---|
1357 | ! |
---|
1358 | elseif (type_interp == Agrif_CONSTANT) then |
---|
1359 | ! |
---|
1360 | call Constant1d(parenttab,childtab, & |
---|
1361 | indmax-indmin+1,petab_child-pttab_child+1, & |
---|
1362 | s_parent,s_child,ds_parent,ds_child) |
---|
1363 | ! |
---|
1364 | endif |
---|
1365 | !--------------------------------------------------------------------------------------------------- |
---|
1366 | end subroutine Agrif_InterpBase |
---|
1367 | !=================================================================================================== |
---|
1368 | ! |
---|
1369 | !=================================================================================================== |
---|
1370 | ! subroutine Agrif_Find_list_interp |
---|
1371 | !--------------------------------------------------------------------------------------------------- |
---|
1372 | function Agrif_Find_list_interp ( list_interp, pttab, petab, pttab_Child, pttab_Parent, & |
---|
1373 | nbdim, indmin, indmax, indminglob, indmaxglob, & |
---|
1374 | pttruetab, cetruetab, memberin & |
---|
1375 | #if defined AGRIF_MPI |
---|
1376 | ,indminglob2, indmaxglob2, parentarray, & |
---|
1377 | member, tab4t, memberinall, sendtoproc1, recvfromproc1 & |
---|
1378 | #endif |
---|
1379 | ) result(find_list_interp) |
---|
1380 | !--------------------------------------------------------------------------------------------------- |
---|
1381 | type(Agrif_List_Interp_Loc), pointer :: list_interp |
---|
1382 | integer, intent(in) :: nbdim |
---|
1383 | integer, dimension(nbdim), intent(in) :: pttab, petab, pttab_Child, pttab_Parent |
---|
1384 | integer, dimension(nbdim), intent(out) :: indmin, indmax |
---|
1385 | integer, dimension(nbdim), intent(out) :: indminglob, indmaxglob |
---|
1386 | integer, dimension(nbdim), intent(out) :: pttruetab, cetruetab |
---|
1387 | logical, intent(out) :: memberin |
---|
1388 | #if defined AGRIF_MPI |
---|
1389 | integer, dimension(nbdim), intent(out) :: indminglob2, indmaxglob2 |
---|
1390 | integer, dimension(nbdim,2,2), intent(out) :: parentarray |
---|
1391 | logical, intent(out) :: member |
---|
1392 | integer, dimension(nbdim,0:Agrif_Nbprocs-1,8), intent(out) :: tab4t |
---|
1393 | logical, dimension(0:Agrif_Nbprocs-1), intent(out) :: memberinall |
---|
1394 | logical, dimension(0:Agrif_Nbprocs-1), intent(out) :: sendtoproc1, recvfromproc1 |
---|
1395 | #endif |
---|
1396 | logical :: find_list_interp |
---|
1397 | ! |
---|
1398 | integer :: i |
---|
1399 | type(Agrif_List_Interp_Loc), pointer :: parcours |
---|
1400 | type(Agrif_Interp_Loc), pointer :: pil |
---|
1401 | |
---|
1402 | find_list_interp = .false. |
---|
1403 | |
---|
1404 | if ( .not. associated(list_interp) ) return |
---|
1405 | |
---|
1406 | parcours => list_interp |
---|
1407 | find_loop : do while ( associated(parcours) ) |
---|
1408 | |
---|
1409 | pil => parcours % interp_loc |
---|
1410 | |
---|
1411 | do i = 1,nbdim |
---|
1412 | if ( (pttab(i) /= pil % pttab(i)) .or. & |
---|
1413 | (petab(i) /= pil % petab(i)) .or. & |
---|
1414 | (pttab_child(i) /= pil % pttab_child(i)) .or. & |
---|
1415 | (pttab_parent(i) /= pil % pttab_parent(i)) ) then |
---|
1416 | parcours => parcours % suiv |
---|
1417 | cycle find_loop |
---|
1418 | endif |
---|
1419 | enddo |
---|
1420 | |
---|
1421 | indmin = pil % indmin(1:nbdim) |
---|
1422 | indmax = pil % indmax(1:nbdim) |
---|
1423 | |
---|
1424 | pttruetab = pil % pttruetab(1:nbdim) |
---|
1425 | cetruetab = pil % cetruetab(1:nbdim) |
---|
1426 | |
---|
1427 | #if !defined AGRIF_MPI |
---|
1428 | indminglob = pil % indminglob(1:nbdim) |
---|
1429 | indmaxglob = pil % indmaxglob(1:nbdim) |
---|
1430 | #else |
---|
1431 | indminglob = pil % indminglob2(1:nbdim) |
---|
1432 | indmaxglob = pil % indmaxglob2(1:nbdim) |
---|
1433 | indminglob2 = pil % indminglob2(1:nbdim) |
---|
1434 | indmaxglob2 = pil % indmaxglob2(1:nbdim) |
---|
1435 | parentarray = pil % parentarray(1:nbdim,:,:) |
---|
1436 | member = pil % member |
---|
1437 | tab4t = pil % tab4t(1:nbdim, 0:Agrif_Nbprocs-1, 1:8) |
---|
1438 | memberinall = pil % memberinall(0:Agrif_Nbprocs-1) |
---|
1439 | sendtoproc1 = pil % sendtoproc1(0:Agrif_Nbprocs-1) |
---|
1440 | recvfromproc1 = pil % recvfromproc1(0:Agrif_Nbprocs-1) |
---|
1441 | #endif |
---|
1442 | memberin = pil % memberin |
---|
1443 | find_list_interp = .true. |
---|
1444 | exit find_loop |
---|
1445 | enddo find_loop |
---|
1446 | !--------------------------------------------------------------------------------------------------- |
---|
1447 | end function Agrif_Find_list_interp |
---|
1448 | !=================================================================================================== |
---|
1449 | ! |
---|
1450 | !=================================================================================================== |
---|
1451 | ! subroutine Agrif_AddTo_list_interp |
---|
1452 | !--------------------------------------------------------------------------------------------------- |
---|
1453 | subroutine Agrif_AddTo_list_interp ( list_interp, pttab, petab, pttab_Child, pttab_Parent, & |
---|
1454 | indmin, indmax, indminglob, indmaxglob, & |
---|
1455 | pttruetab, cetruetab, & |
---|
1456 | memberin, nbdim & |
---|
1457 | #if defined AGRIF_MPI |
---|
1458 | ,indminglob2, indmaxglob2, & |
---|
1459 | parentarray, & |
---|
1460 | member, & |
---|
1461 | tab4t, memberinall, sendtoproc1, recvfromproc1 & |
---|
1462 | #endif |
---|
1463 | ) |
---|
1464 | !--------------------------------------------------------------------------------------------------- |
---|
1465 | type(Agrif_List_Interp_Loc), pointer :: list_interp |
---|
1466 | integer :: nbdim |
---|
1467 | integer, dimension(nbdim) :: pttab, petab, pttab_Child, pttab_Parent |
---|
1468 | integer, dimension(nbdim) :: indmin,indmax |
---|
1469 | integer, dimension(nbdim) :: indminglob, indmaxglob |
---|
1470 | integer, dimension(nbdim) :: pttruetab, cetruetab |
---|
1471 | logical :: memberin |
---|
1472 | #if defined AGRIF_MPI |
---|
1473 | integer, dimension(nbdim,2,2) :: parentarray |
---|
1474 | logical :: member |
---|
1475 | integer, dimension(nbdim) :: indminglob2,indmaxglob2 |
---|
1476 | integer, dimension(nbdim,0:Agrif_Nbprocs-1,8) :: tab4t |
---|
1477 | logical, dimension(0:Agrif_Nbprocs-1) :: memberinall |
---|
1478 | logical, dimension(0:Agrif_Nbprocs-1) :: sendtoproc1 |
---|
1479 | logical, dimension(0:Agrif_Nbprocs-1) :: recvfromproc1 |
---|
1480 | #endif |
---|
1481 | ! |
---|
1482 | type(Agrif_List_Interp_Loc), pointer :: parcours |
---|
1483 | type(Agrif_Interp_Loc), pointer :: pil |
---|
1484 | ! |
---|
1485 | allocate(parcours) |
---|
1486 | allocate(parcours % interp_loc) |
---|
1487 | |
---|
1488 | pil => parcours % interp_loc |
---|
1489 | |
---|
1490 | pil % pttab(1:nbdim) = pttab(1:nbdim) |
---|
1491 | pil % petab(1:nbdim) = petab(1:nbdim) |
---|
1492 | pil % pttab_child(1:nbdim) = pttab_child(1:nbdim) |
---|
1493 | pil % pttab_parent(1:nbdim) = pttab_parent(1:nbdim) |
---|
1494 | |
---|
1495 | pil % indmin(1:nbdim) = indmin(1:nbdim) |
---|
1496 | pil % indmax(1:nbdim) = indmax(1:nbdim) |
---|
1497 | |
---|
1498 | pil % memberin = memberin |
---|
1499 | #if !defined AGRIF_MPI |
---|
1500 | pil % indminglob(1:nbdim) = indminglob(1:nbdim) |
---|
1501 | pil % indmaxglob(1:nbdim) = indmaxglob(1:nbdim) |
---|
1502 | #else |
---|
1503 | pil % indminglob2(1:nbdim) = indminglob2(1:nbdim) |
---|
1504 | pil % indmaxglob2(1:nbdim) = indmaxglob2(1:nbdim) |
---|
1505 | pil % parentarray(1:nbdim,:,:) = parentarray(1:nbdim,:,:) |
---|
1506 | pil % member = member |
---|
1507 | allocate(pil % tab4t(nbdim, 0:Agrif_Nbprocs-1, 8)) |
---|
1508 | allocate(pil % memberinall(0:Agrif_Nbprocs-1)) |
---|
1509 | allocate(pil % sendtoproc1(0:Agrif_Nbprocs-1)) |
---|
1510 | allocate(pil % recvfromproc1(0:Agrif_Nbprocs-1)) |
---|
1511 | pil % tab4t = tab4t |
---|
1512 | pil % memberinall = memberinall |
---|
1513 | pil % sendtoproc1 = sendtoproc1 |
---|
1514 | pil % recvfromproc1 = recvfromproc1 |
---|
1515 | #endif |
---|
1516 | |
---|
1517 | pil % pttruetab(1:nbdim) = pttruetab(1:nbdim) |
---|
1518 | pil % cetruetab(1:nbdim) = cetruetab(1:nbdim) |
---|
1519 | |
---|
1520 | parcours % suiv => list_interp |
---|
1521 | list_interp => parcours |
---|
1522 | !--------------------------------------------------------------------------------------------------- |
---|
1523 | end subroutine Agrif_Addto_list_interp |
---|
1524 | !=================================================================================================== |
---|
1525 | ! |
---|
1526 | end module Agrif_Interpolation |
---|