1 | ! |
---|
2 | ! $Id$ |
---|
3 | ! |
---|
4 | C Agrif (Adaptive Grid Refinement In Fortran) |
---|
5 | C |
---|
6 | C Copyright (C) 2003 Laurent Debreu (Laurent.Debreu@imag.fr) |
---|
7 | C Christophe Vouland (Christophe.Vouland@imag.fr) |
---|
8 | C |
---|
9 | C This program is free software; you can redistribute it and/or modify |
---|
10 | C it under the terms of the GNU General Public License as published by |
---|
11 | C the Free Software Foundation; either version 2 of the License, or |
---|
12 | C (at your option) any later version. |
---|
13 | C |
---|
14 | C This program is distributed in the hope that it will be useful, |
---|
15 | C but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | C GNU General Public License for more details. |
---|
18 | C |
---|
19 | C You should have received a copy of the GNU General Public License |
---|
20 | C along with this program; if not, write to the Free Software |
---|
21 | C Foundation, Inc., 59 Temple Place- Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | C |
---|
23 | C |
---|
24 | C |
---|
25 | CCC Module Agrif_Util |
---|
26 | C |
---|
27 | Module Agrif_Util |
---|
28 | C |
---|
29 | C |
---|
30 | CCC Description: |
---|
31 | CCC This module contains the two procedures called in the main program : |
---|
32 | CCC Agrif_Init_Grids allowing the initialization of the root coarse grid, and |
---|
33 | CCC Agrif_Step allowing the creation of the grid hierarchy and the management |
---|
34 | CCC of the time integration. |
---|
35 | C |
---|
36 | C Modules used: |
---|
37 | C |
---|
38 | Use Agrif_Clustering |
---|
39 | Use Agrif_bcfunction |
---|
40 | C |
---|
41 | IMPLICIT NONE |
---|
42 | C |
---|
43 | Contains |
---|
44 | C Definition of procedures contained in this module. |
---|
45 | C |
---|
46 | C ************************************************************************** |
---|
47 | CCC Subroutine Agrif_Step |
---|
48 | C ************************************************************************** |
---|
49 | C |
---|
50 | Subroutine Agrif_Step(procname) |
---|
51 | C |
---|
52 | CCC Description: |
---|
53 | CCC Subroutine to create the grid hierarchy and to manage the time integration |
---|
54 | CCC procedure. It is called in the main program. |
---|
55 | C |
---|
56 | CC Method: |
---|
57 | CC Call on subroutines Agrif_Regrid and Agrif_Integrate. |
---|
58 | C |
---|
59 | C Declarations: |
---|
60 | C |
---|
61 | Optional :: procname |
---|
62 | External :: procname |
---|
63 | C |
---|
64 | #ifdef AGRIF_MPI |
---|
65 | Integer :: code |
---|
66 | #include "mpif.h" |
---|
67 | C |
---|
68 | C |
---|
69 | If (Agrif_Mygrid % ngridstep == 0) Then |
---|
70 | Call MPI_COMM_SIZE(MPI_COMM_WORLD,Agrif_Nbprocs,code) |
---|
71 | Call MPI_COMM_RANK(MPI_COMM_WORLD,Agrif_ProcRank,code) |
---|
72 | Call MPI_COMM_GROUP(MPI_COMM_WORLD,Agrif_Group,code) |
---|
73 | endif |
---|
74 | #endif |
---|
75 | C |
---|
76 | C Creation and initialization of the grid hierarchy |
---|
77 | C |
---|
78 | C |
---|
79 | C Set the clustering variables |
---|
80 | C |
---|
81 | Call Agrif_clustering_def() |
---|
82 | C |
---|
83 | if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 1 ) then |
---|
84 | C |
---|
85 | If (Agrif_Mygrid % ngridstep == 0) then |
---|
86 | C |
---|
87 | Call Agrif_Regrid |
---|
88 | C |
---|
89 | Call Agrif_Instance |
---|
90 | & (Agrif_Mygrid) |
---|
91 | endif |
---|
92 | C |
---|
93 | else |
---|
94 | C |
---|
95 | If (mod(Agrif_Mygrid % ngridstep, Agrif_Regridding) == 0) then |
---|
96 | C |
---|
97 | Call Agrif_Regrid |
---|
98 | C |
---|
99 | Call Agrif_Instance |
---|
100 | & (Agrif_Mygrid) |
---|
101 | C |
---|
102 | endif |
---|
103 | C |
---|
104 | endif |
---|
105 | C |
---|
106 | C Time integration of the grid hierarchy |
---|
107 | C |
---|
108 | If (present(procname)) Then |
---|
109 | Call Agrif_Integrate (Agrif_Mygrid,procname) |
---|
110 | Else |
---|
111 | Call Agrif_Integrate (Agrif_Mygrid) |
---|
112 | endif |
---|
113 | C |
---|
114 | If (associated(Agrif_Mygrid%child_grids)) |
---|
115 | & Call Agrif_Instance (Agrif_Mygrid) |
---|
116 | C |
---|
117 | Return |
---|
118 | C |
---|
119 | End Subroutine Agrif_Step |
---|
120 | |
---|
121 | C ************************************************************************** |
---|
122 | CCC Subroutine Agrif_Step_Child |
---|
123 | C ************************************************************************** |
---|
124 | C |
---|
125 | Subroutine Agrif_Step_Child(procname) |
---|
126 | C |
---|
127 | CCC Description: |
---|
128 | CCC Subroutine to create the grid hierarchy and to manage the time integration |
---|
129 | CCC procedure. It is called in the main program. |
---|
130 | C |
---|
131 | CC Method: |
---|
132 | CC Call on subroutines Agrif_Regrid and Agrif_Integrate. |
---|
133 | C |
---|
134 | C Declarations: |
---|
135 | C |
---|
136 | Optional :: procname |
---|
137 | External :: procname |
---|
138 | C |
---|
139 | C Time integration of the grid hierarchy |
---|
140 | C |
---|
141 | If (present(procname)) Then |
---|
142 | Call Agrif_Integrate_Child (Agrif_Mygrid,procname) |
---|
143 | Else |
---|
144 | Call Agrif_Integrate_Child (Agrif_Mygrid) |
---|
145 | endif |
---|
146 | C |
---|
147 | If (associated(Agrif_Mygrid%child_grids)) |
---|
148 | & Call Agrif_Instance (Agrif_Mygrid) |
---|
149 | C |
---|
150 | Return |
---|
151 | C |
---|
152 | End Subroutine Agrif_Step_Child |
---|
153 | |
---|
154 | C |
---|
155 | C |
---|
156 | C |
---|
157 | C ************************************************************************** |
---|
158 | CCC Subroutine Agrif_Regrid |
---|
159 | C ************************************************************************** |
---|
160 | C |
---|
161 | Subroutine Agrif_Regrid |
---|
162 | C |
---|
163 | CCC Description: |
---|
164 | CCC Subroutine to create the grid hierarchy from fixed grids and |
---|
165 | CC adaptive mesh refinement. |
---|
166 | C |
---|
167 | CC Method: |
---|
168 | C |
---|
169 | C Declarations: |
---|
170 | C |
---|
171 | C Local variables |
---|
172 | Type(Agrif_Rectangle), Pointer :: coarsegrid_fixed |
---|
173 | Type(Agrif_Rectangle), Pointer :: coarsegrid_moving |
---|
174 | INTEGER :: j |
---|
175 | INTEGER :: nunit |
---|
176 | INTEGER :: iii |
---|
177 | Logical :: BEXIST |
---|
178 | C |
---|
179 | if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) |
---|
180 | & Call Agrif_detect_all(Agrif_Mygrid) ! Detection of areas to be refined |
---|
181 | C |
---|
182 | Allocate(coarsegrid_fixed) |
---|
183 | Allocate(coarsegrid_moving) |
---|
184 | C |
---|
185 | if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) |
---|
186 | & Call Agrif_Cluster_All(Agrif_Mygrid,coarsegrid_moving) ! Clustering |
---|
187 | C |
---|
188 | if ( Agrif_USE_FIXED_GRIDS .EQ. 1 .OR. |
---|
189 | & Agrif_USE_ONLY_FIXED_GRIDS .EQ. 1 ) then |
---|
190 | C |
---|
191 | If (Agrif_Mygrid % ngridstep == 0) Then |
---|
192 | nunit = Agrif_Get_Unit() |
---|
193 | open(nunit,file='AGRIF_FixedGrids.in',form='formatted', |
---|
194 | & status="old",ERR=99) ! Opening of the Agrif_FixedGrids.in file |
---|
195 | j = 1 |
---|
196 | C Creation of the grid hierarchy from the Agrif_FixedGrids.in file |
---|
197 | do iii = 1 , Agrif_Probdim |
---|
198 | coarsegrid_fixed % imin(iii) = 1 |
---|
199 | coarsegrid_fixed % imax(iii) = Agrif_Mygrid % nb(iii) + 1 |
---|
200 | enddo |
---|
201 | C |
---|
202 | Call Agrif_Read_Fix_Grd (coarsegrid_fixed,j,nunit) |
---|
203 | close(nunit) ! Closing of the Agrif_FixedGrids.in file |
---|
204 | C |
---|
205 | Nullify(Agrif_oldmygrid) |
---|
206 | Nullify(Agrif_Mygrid % child_grids) |
---|
207 | C |
---|
208 | C Creation of the grid hierarchy from coarsegrid_fixed |
---|
209 | Call Agrif_Create_Grids (Agrif_Mygrid,coarsegrid_fixed) |
---|
210 | Else |
---|
211 | Agrif_oldmygrid => Agrif_Mygrid % child_grids |
---|
212 | endif |
---|
213 | else |
---|
214 | Agrif_oldmygrid => Agrif_Mygrid % child_grids |
---|
215 | Nullify(Agrif_Mygrid % child_grids) |
---|
216 | endif |
---|
217 | C |
---|
218 | if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) then |
---|
219 | C |
---|
220 | Call Agrif_Free_before_All(Agrif_oldmygrid) |
---|
221 | C |
---|
222 | C Creation of the grid hierarchy from coarsegrid_moving |
---|
223 | Call Agrif_Create_Grids |
---|
224 | & (Agrif_Mygrid,coarsegrid_moving) |
---|
225 | C |
---|
226 | endif |
---|
227 | C |
---|
228 | C Initialization of the grid hierarchy by copy or interpolation |
---|
229 | C |
---|
230 | Call Agrif_Init_Hierarchy(Agrif_Mygrid) |
---|
231 | C |
---|
232 | if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 0 ) |
---|
233 | & Call Agrif_Free_after_All(Agrif_oldmygrid) |
---|
234 | C |
---|
235 | Deallocate(coarsegrid_fixed) |
---|
236 | Deallocate(coarsegrid_moving) |
---|
237 | C |
---|
238 | Return |
---|
239 | C |
---|
240 | C Opening error |
---|
241 | C |
---|
242 | 99 INQUIRE(FILE='AGRIF_FixedGrids.in',EXIST=BEXIST) |
---|
243 | If (.not. BEXIST) Then |
---|
244 | print*,'ERROR : File AGRIF_FixedGrids.in not found.' |
---|
245 | STOP |
---|
246 | Else |
---|
247 | print*,'Error opening file AGRIF_FixedGrids.in' |
---|
248 | STOP |
---|
249 | endif |
---|
250 | C |
---|
251 | End Subroutine Agrif_Regrid |
---|
252 | C |
---|
253 | C ************************************************************************** |
---|
254 | CCC Subroutine Agrif_detect_All |
---|
255 | C ************************************************************************** |
---|
256 | C |
---|
257 | Recursive Subroutine Agrif_detect_all(g) |
---|
258 | C |
---|
259 | CCC Description: |
---|
260 | CCC Subroutine to detect areas to be refined. |
---|
261 | C |
---|
262 | CC Method: |
---|
263 | C |
---|
264 | C Declarations: |
---|
265 | C |
---|
266 | |
---|
267 | C |
---|
268 | C Pointer argument |
---|
269 | TYPE(Agrif_Grid) ,pointer :: g ! Pointer on the current grid |
---|
270 | C |
---|
271 | C Local variables |
---|
272 | Type(Agrif_pgrid),pointer :: parcours ! Pointer for the recursive |
---|
273 | ! procedure |
---|
274 | INTEGER, DIMENSION(3) :: size |
---|
275 | INTEGER :: iii |
---|
276 | Real :: g_eps |
---|
277 | C |
---|
278 | parcours => g % child_grids |
---|
279 | C |
---|
280 | C To be positioned on the finer grids of the grid hierarchy |
---|
281 | C |
---|
282 | do while (associated(parcours)) |
---|
283 | Call Agrif_detect_all (parcours % gr) |
---|
284 | parcours => parcours % next |
---|
285 | enddo |
---|
286 | C |
---|
287 | g_eps = huge(1.) |
---|
288 | do iii = 1 , Agrif_Probdim |
---|
289 | g_eps=min(g_eps,g%Agrif_d(iii)) |
---|
290 | enddo |
---|
291 | C |
---|
292 | g_eps = g_eps/100. |
---|
293 | C |
---|
294 | if ( Agrif_Probdim .EQ. 1 ) g%tabpoint1D=0 |
---|
295 | if ( Agrif_Probdim .EQ. 2 ) g%tabpoint2D=0 |
---|
296 | if ( Agrif_Probdim .EQ. 3 ) g%tabpoint3D=0 |
---|
297 | C |
---|
298 | do iii = 1 , Agrif_Probdim |
---|
299 | if (g%Agrif_d(iii)/Agrif_coeffref(iii).LT. |
---|
300 | & (Agrif_mind(iii)-g_eps)) Return |
---|
301 | enddo |
---|
302 | C |
---|
303 | Call Agrif_instance(g) |
---|
304 | C |
---|
305 | C Detection (Agrif_detect is a user s routine) |
---|
306 | C |
---|
307 | do iii = 1 , Agrif_Probdim |
---|
308 | size(iii) = g%nb(iii) + 1 |
---|
309 | enddo |
---|
310 | C |
---|
311 | SELECT CASE (Agrif_Probdim) |
---|
312 | CASE (1) |
---|
313 | Call Agrif_detect(g%tabpoint1D,size) |
---|
314 | CASE (2) |
---|
315 | Call Agrif_detect(g%tabpoint2D,size) |
---|
316 | CASE (3) |
---|
317 | Call Agrif_detect(g%tabpoint3D,size) |
---|
318 | END SELECT |
---|
319 | C |
---|
320 | C Addition of the areas detected on the child grids |
---|
321 | C |
---|
322 | parcours => g % child_grids |
---|
323 | C |
---|
324 | Do while (associated(parcours)) |
---|
325 | Call Agrif_Add_detected_areas (g,parcours % gr) |
---|
326 | parcours => parcours % next |
---|
327 | enddo |
---|
328 | C |
---|
329 | Return |
---|
330 | C |
---|
331 | End Subroutine Agrif_detect_all |
---|
332 | C |
---|
333 | C |
---|
334 | C |
---|
335 | C ************************************************************************** |
---|
336 | CCC Subroutine Agrif_Add_detected_areas |
---|
337 | C ************************************************************************** |
---|
338 | C |
---|
339 | Subroutine Agrif_Add_detected_areas(parentgrid,childgrid) |
---|
340 | C |
---|
341 | CCC Description: |
---|
342 | CCC Subroutine to add on the parent grid the areas detected |
---|
343 | CC on its child grids. |
---|
344 | C |
---|
345 | CC Method: |
---|
346 | C |
---|
347 | C Declarations: |
---|
348 | C |
---|
349 | |
---|
350 | C |
---|
351 | Type(Agrif_Grid),pointer :: parentgrid,childgrid |
---|
352 | C |
---|
353 | Integer :: i,j,k |
---|
354 | C |
---|
355 | do i = 1,childgrid%nb(1)+1 |
---|
356 | if ( Agrif_Probdim .EQ. 1 ) then |
---|
357 | If (childgrid%tabpoint1D(i).EQ.1) Then |
---|
358 | parentgrid%tabpoint1D(childgrid%ix(1)+ |
---|
359 | & (i-1)/Agrif_Coeffref(1)) = 1 |
---|
360 | endif |
---|
361 | else |
---|
362 | do j=1,childgrid%nb(2)+1 |
---|
363 | if (Agrif_Probdim.EQ.2) then |
---|
364 | If (childgrid%tabpoint2D(i,j).EQ.1) Then |
---|
365 | parentgrid%tabpoint2D( |
---|
366 | & childgrid%ix(1)+(i-1)/Agrif_Coeffref(1), |
---|
367 | & childgrid%ix(2)+(j-1)/Agrif_Coeffref(2)) = 1 |
---|
368 | endif |
---|
369 | else |
---|
370 | do k=1,childgrid%nb(3)+1 |
---|
371 | If (childgrid%tabpoint3D(i,j,k).EQ.1) Then |
---|
372 | parentgrid%tabpoint3D( |
---|
373 | & childgrid%ix(1)+(i-1)/Agrif_Coeffref(1), |
---|
374 | & childgrid%ix(2)+(j-1)/Agrif_Coeffref(2), |
---|
375 | & childgrid%ix(3)+(k-1)/Agrif_Coeffref(3)) = 1 |
---|
376 | endif |
---|
377 | enddo |
---|
378 | endif |
---|
379 | enddo |
---|
380 | endif |
---|
381 | enddo |
---|
382 | C |
---|
383 | Return |
---|
384 | C |
---|
385 | End Subroutine Agrif_Add_detected_areas |
---|
386 | C |
---|
387 | C |
---|
388 | C ************************************************************************** |
---|
389 | CCC Subroutine Agrif_Free_before_All |
---|
390 | C ************************************************************************** |
---|
391 | C |
---|
392 | Recursive Subroutine Agrif_Free_before_All(g) |
---|
393 | C |
---|
394 | CCC Description: |
---|
395 | C |
---|
396 | CC Method: |
---|
397 | C |
---|
398 | C Declarations: |
---|
399 | C |
---|
400 | C Pointer argument |
---|
401 | Type(Agrif_pgrid),pointer :: g ! Pointer on the current grid |
---|
402 | C |
---|
403 | C Local pointer |
---|
404 | Type(Agrif_pgrid),pointer :: parcours ! Pointer for the recursive |
---|
405 | ! procedure |
---|
406 | C |
---|
407 | C |
---|
408 | parcours => g |
---|
409 | C |
---|
410 | Do while (associated(parcours)) |
---|
411 | If (.not. parcours%gr%fixed) Then |
---|
412 | Call Agrif_Free_data_before(parcours%gr) |
---|
413 | parcours % gr % oldgrid = .TRUE. |
---|
414 | endif |
---|
415 | C |
---|
416 | Call Agrif_Free_before_all (parcours % gr % child_grids) |
---|
417 | C |
---|
418 | parcours => parcours % next |
---|
419 | enddo |
---|
420 | C |
---|
421 | Return |
---|
422 | C |
---|
423 | C |
---|
424 | End Subroutine Agrif_Free_before_All |
---|
425 | C |
---|
426 | C |
---|
427 | C |
---|
428 | C ************************************************************************** |
---|
429 | CCC Subroutine Agrif_Free_after_All |
---|
430 | C ************************************************************************** |
---|
431 | C |
---|
432 | Recursive Subroutine Agrif_Free_after_All(g) |
---|
433 | C |
---|
434 | CCC Description: |
---|
435 | C |
---|
436 | CC Method: |
---|
437 | C |
---|
438 | C Declarations: |
---|
439 | C |
---|
440 | |
---|
441 | C |
---|
442 | C Pointer argument |
---|
443 | Type(Agrif_pgrid),pointer :: g ! Pointer on the current grid |
---|
444 | C |
---|
445 | C Local pointers |
---|
446 | TYPE(Agrif_pgrid),pointer :: parcours ! Pointer for the recursive proced |
---|
447 | Type(Agrif_pgrid),pointer :: preparcours |
---|
448 | Type(Agrif_pgrid),pointer :: preparcoursini |
---|
449 | C |
---|
450 | C |
---|
451 | Allocate(preparcours) |
---|
452 | C |
---|
453 | preparcoursini => preparcours |
---|
454 | C |
---|
455 | Nullify(preparcours % gr) |
---|
456 | C |
---|
457 | preparcours % next => g |
---|
458 | C |
---|
459 | parcours => g |
---|
460 | C |
---|
461 | Do while (associated(parcours)) |
---|
462 | C |
---|
463 | if ( (.NOT. parcours% gr% fixed) .AND. |
---|
464 | & (parcours% gr% oldgrid ) ) then |
---|
465 | Call Agrif_Free_data_after(parcours%gr) |
---|
466 | endif |
---|
467 | C |
---|
468 | Call Agrif_Free_after_all (parcours % gr % child_grids) |
---|
469 | C |
---|
470 | If (parcours % gr % oldgrid) Then |
---|
471 | Deallocate(parcours % gr) |
---|
472 | preparcours % next => parcours % next |
---|
473 | Deallocate(parcours) |
---|
474 | parcours => preparcours % next |
---|
475 | Else |
---|
476 | preparcours => preparcours % next |
---|
477 | parcours => parcours % next |
---|
478 | endif |
---|
479 | enddo |
---|
480 | C |
---|
481 | Deallocate(preparcoursini) |
---|
482 | C |
---|
483 | Return |
---|
484 | C |
---|
485 | End Subroutine Agrif_Free_after_All |
---|
486 | C |
---|
487 | C |
---|
488 | C ************************************************************************** |
---|
489 | CCC Subroutine Agrif_Integrate |
---|
490 | C ************************************************************************** |
---|
491 | C |
---|
492 | Recursive Subroutine Agrif_Integrate(g, procname) |
---|
493 | C |
---|
494 | CCC Description: |
---|
495 | CCC Subroutine to manage the time integration of the grid hierarchy. |
---|
496 | C |
---|
497 | CC Method: |
---|
498 | CC Recursive subroutine and call on subroutines Agrif_Instance & Agrif_Step |
---|
499 | C |
---|
500 | C Declarations: |
---|
501 | C |
---|
502 | |
---|
503 | C |
---|
504 | C Pointer argument |
---|
505 | Type(Agrif_Grid),pointer :: g ! Pointer on the current grid |
---|
506 | C |
---|
507 | C main procedure name |
---|
508 | Optional :: procname |
---|
509 | External :: procname |
---|
510 | C |
---|
511 | C Local pointer |
---|
512 | Type(Agrif_pgrid),pointer :: parcours ! Pointer for the recursive |
---|
513 | ! procedure |
---|
514 | C |
---|
515 | C Local scalars |
---|
516 | INTEGER :: nbt ! Number of time steps |
---|
517 | ! of the current grid |
---|
518 | INTEGER :: k |
---|
519 | INTEGER :: iii |
---|
520 | C |
---|
521 | C Instanciation of the variables of the current grid |
---|
522 | If (g%fixedrank .NE.0) Then |
---|
523 | Call Agrif_Instance |
---|
524 | & (g) |
---|
525 | End If |
---|
526 | C |
---|
527 | C One step on the current grid |
---|
528 | C |
---|
529 | If (present(procname)) Then |
---|
530 | Call procname () |
---|
531 | Else |
---|
532 | write(*,*) 'The name of the step subroutine has not ' |
---|
533 | write(*,*) 'been given in the subroutine Agrif_Integrate' |
---|
534 | stop |
---|
535 | endif |
---|
536 | C |
---|
537 | C Number of time steps on the current grid |
---|
538 | C |
---|
539 | g%ngridstep = g % ngridstep + 1 |
---|
540 | C |
---|
541 | parcours => g % child_grids |
---|
542 | C |
---|
543 | C Recursive procedure for the time integration of the grid hierarchy |
---|
544 | Do while (associated(parcours)) |
---|
545 | C |
---|
546 | C Instanciation of the variables of the current grid |
---|
547 | Call Agrif_Instance |
---|
548 | & (parcours % gr) |
---|
549 | C |
---|
550 | C Number of time steps |
---|
551 | nbt = 1 |
---|
552 | do iii = 1 , Agrif_Probdim |
---|
553 | nbt = max(nbt, parcours % gr % timeref(iii)) |
---|
554 | enddo |
---|
555 | C |
---|
556 | Do k = 1,nbt |
---|
557 | C |
---|
558 | If (present(procname)) Then |
---|
559 | Call Agrif_Integrate (parcours % gr, procname) |
---|
560 | Else |
---|
561 | Call Agrif_Integrate (parcours % gr) |
---|
562 | endif |
---|
563 | C |
---|
564 | enddo |
---|
565 | C |
---|
566 | parcours => parcours % next |
---|
567 | C |
---|
568 | enddo |
---|
569 | C |
---|
570 | C |
---|
571 | End Subroutine Agrif_Integrate |
---|
572 | |
---|
573 | C ************************************************************************** |
---|
574 | CCC Subroutine Agrif_Integrate_Child |
---|
575 | C ************************************************************************** |
---|
576 | C |
---|
577 | Recursive Subroutine Agrif_Integrate_Child(g,procname) |
---|
578 | C |
---|
579 | CCC Description: |
---|
580 | CCC Subroutine to manage the time integration of the grid hierarchy. |
---|
581 | C |
---|
582 | CC Method: |
---|
583 | CC Recursive subroutine and call on subroutines Agrif_Instance & Agrif_Step. |
---|
584 | C |
---|
585 | C Declarations: |
---|
586 | C |
---|
587 | |
---|
588 | C |
---|
589 | C Pointer argument |
---|
590 | Type(Agrif_Grid),pointer :: g ! Pointer on the current grid |
---|
591 | C |
---|
592 | C main procedure name |
---|
593 | Optional :: procname |
---|
594 | External :: procname |
---|
595 | C |
---|
596 | C Local pointer |
---|
597 | Type(Agrif_pgrid),pointer :: parcours ! Pointer for the recursive |
---|
598 | ! procedure |
---|
599 | C |
---|
600 | C One step on the current grid |
---|
601 | C |
---|
602 | If (present(procname)) Then |
---|
603 | Call procname () |
---|
604 | Else |
---|
605 | write(*,*) 'The name of the step subroutine has not ' |
---|
606 | write(*,*) 'been given in the subroutine Agrif_Integrate' |
---|
607 | stop |
---|
608 | endif |
---|
609 | C |
---|
610 | C Number of time steps on the current grid |
---|
611 | C |
---|
612 | C |
---|
613 | parcours => g % child_grids |
---|
614 | C |
---|
615 | C Recursive procedure for the time integration of the grid hierarchy |
---|
616 | Do while (associated(parcours)) |
---|
617 | C |
---|
618 | C Instanciation of the variables of the current grid |
---|
619 | Call Agrif_Instance |
---|
620 | & (parcours % gr) |
---|
621 | |
---|
622 | C |
---|
623 | If (present(procname)) Then |
---|
624 | Call Agrif_Integrate_Child (parcours % gr, procname) |
---|
625 | Else |
---|
626 | Call Agrif_Integrate_Child (parcours % gr) |
---|
627 | endif |
---|
628 | C |
---|
629 | parcours => parcours % next |
---|
630 | C |
---|
631 | enddo |
---|
632 | C |
---|
633 | C |
---|
634 | End Subroutine Agrif_Integrate_Child |
---|
635 | |
---|
636 | C |
---|
637 | C |
---|
638 | C ************************************************************************** |
---|
639 | CCC Subroutine Agrif_Init_Grids |
---|
640 | C ************************************************************************** |
---|
641 | C |
---|
642 | Subroutine Agrif_Init_Grids |
---|
643 | C |
---|
644 | CCC Description: |
---|
645 | CCC Subroutine to initialize the root coarse grid pointed by Agrif_Mygrid. |
---|
646 | CCC It is called in the main program. |
---|
647 | C |
---|
648 | C Declarations: |
---|
649 | C |
---|
650 | C |
---|
651 | INTEGER :: iii |
---|
652 | C |
---|
653 | C definition of the probdim and modtypes variables |
---|
654 | C |
---|
655 | #ifdef AGRIF_MPI |
---|
656 | #include "mpif.h" |
---|
657 | Agrif_MPIPREC = MPI_DOUBLE_PRECISION |
---|
658 | #endif |
---|
659 | Call Agrif_probdim_modtype_def() |
---|
660 | C |
---|
661 | Agrif_UseSpecialValue = .FALSE. |
---|
662 | Agrif_UseSpecialValueFineGrid = .FALSE. |
---|
663 | Agrif_SpecialValue = 0. |
---|
664 | Agrif_SpecialValueFineGrid = 0. |
---|
665 | C |
---|
666 | C Allocation of Agrif_Mygrid |
---|
667 | allocate(Agrif_Mygrid) |
---|
668 | C |
---|
669 | C Space and time refinement factors are set to 1 on the root grid |
---|
670 | C |
---|
671 | do iii = 1 , Agrif_Probdim |
---|
672 | Agrif_Mygrid % spaceref(iii) = 1 |
---|
673 | Agrif_Mygrid % timeref(iii) = 1 |
---|
674 | enddo |
---|
675 | C |
---|
676 | C Initialization of the number of time steps |
---|
677 | Agrif_Mygrid % ngridstep = 0 |
---|
678 | Agrif_Mygrid % grid_id = 0 |
---|
679 | C |
---|
680 | C No parent grid for the root coarse grid |
---|
681 | Nullify(Agrif_Mygrid % parent) |
---|
682 | C |
---|
683 | C Initialization of the minimum positions, global abscissa and space steps |
---|
684 | do iii= 1 , Agrif_Probdim |
---|
685 | Agrif_Mygrid % ix(iii) = 1 |
---|
686 | Agrif_Mygrid % Agrif_x(iii) = 0. |
---|
687 | Agrif_Mygrid % Agrif_d(iii) = 1. |
---|
688 | C Borders of the root coarse grid |
---|
689 | Agrif_Mygrid % NearRootBorder(iii) = .true. |
---|
690 | Agrif_Mygrid % DistantRootBorder(iii) = .true. |
---|
691 | enddo |
---|
692 | C |
---|
693 | C The root coarse grid is a fixed grid |
---|
694 | Agrif_Mygrid % fixed = .TRUE. |
---|
695 | C |
---|
696 | C Number of the grid pointed by Agrif_Mygrid (root coarse grid) |
---|
697 | Agrif_Mygrid % rank = 1 |
---|
698 | C |
---|
699 | C Number of the root grid as a fixed grid |
---|
700 | Agrif_Mygrid % fixedrank = 0 |
---|
701 | C |
---|
702 | C Initialization of some fields of the root grid variables |
---|
703 | Call Agrif_Create_Var (Agrif_Mygrid) |
---|
704 | C |
---|
705 | C Initialization of the other fields of the root grid variables (number of |
---|
706 | C cells, positions, number and type of its dimensions, ...) |
---|
707 | Call Agrif_Set_numberofcells(Agrif_Mygrid) |
---|
708 | C |
---|
709 | Call Agrif_Instance (Agrif_Mygrid) |
---|
710 | C |
---|
711 | C Allocation of the array containing the values of the grid variables |
---|
712 | Call Agrif_Allocation (Agrif_Mygrid) |
---|
713 | C |
---|
714 | Call Agrif_initialisations(Agrif_Mygrid) |
---|
715 | C |
---|
716 | nullify(Agrif_Mygrid % child_grids) |
---|
717 | C |
---|
718 | C Total number of fixed grids |
---|
719 | Agrif_nbfixedgrids = 0 |
---|
720 | C |
---|
721 | Call Agrif_Instance (Agrif_Mygrid) |
---|
722 | C |
---|
723 | End Subroutine Agrif_Init_Grids |
---|
724 | C |
---|
725 | C |
---|
726 | C ************************************************************************** |
---|
727 | CCC Subroutine Agrif_Deallocation |
---|
728 | C ************************************************************************** |
---|
729 | C |
---|
730 | Subroutine Agrif_Deallocation |
---|
731 | C |
---|
732 | CCC Description: |
---|
733 | CCC Subroutine to initialize the root coarse grid pointed by Agrif_Mygrid. |
---|
734 | CCC It is called in the main program. |
---|
735 | C |
---|
736 | C Declarations: |
---|
737 | C |
---|
738 | C |
---|
739 | INTEGER :: nb |
---|
740 | C |
---|
741 | C definition of the probdim and modtypes variables |
---|
742 | C |
---|
743 | do nb = 1, Agrif_NbVariables |
---|
744 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % array1) ) |
---|
745 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % array1) |
---|
746 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % array2) ) |
---|
747 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % array2) |
---|
748 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % array3) ) |
---|
749 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % array3) |
---|
750 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % array4) ) |
---|
751 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % array4) |
---|
752 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % array5) ) |
---|
753 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % array5) |
---|
754 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % array6) ) |
---|
755 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % array6) |
---|
756 | C |
---|
757 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray1) ) |
---|
758 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray1) |
---|
759 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray2) ) |
---|
760 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray2) |
---|
761 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray3) ) |
---|
762 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray3) |
---|
763 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray4) ) |
---|
764 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray4) |
---|
765 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray5) ) |
---|
766 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray5) |
---|
767 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % iarray6) ) |
---|
768 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % iarray6) |
---|
769 | C |
---|
770 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray1) ) |
---|
771 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray1) |
---|
772 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray2) ) |
---|
773 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray2) |
---|
774 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray3) ) |
---|
775 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray3) |
---|
776 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray4) ) |
---|
777 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray4) |
---|
778 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray5) ) |
---|
779 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray5) |
---|
780 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % larray6) ) |
---|
781 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % larray6) |
---|
782 | C |
---|
783 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % carray1) ) |
---|
784 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % carray1) |
---|
785 | if ( associated(Agrif_Mygrid % tabvars(nb) % var % carray2) ) |
---|
786 | & Deallocate(Agrif_Mygrid % tabvars(nb) % var % carray2) |
---|
787 | enddo |
---|
788 | C |
---|
789 | do nb = 1, Agrif_NbVariables |
---|
790 | Deallocate(Agrif_Mygrid % tabvars(nb) % var) |
---|
791 | enddo |
---|
792 | C |
---|
793 | Deallocate(Agrif_Mygrid % tabvars) |
---|
794 | C |
---|
795 | Deallocate(Agrif_Mygrid) |
---|
796 | C |
---|
797 | End Subroutine Agrif_Deallocation |
---|
798 | C |
---|
799 | End module Agrif_Util |
---|