modutil.F90 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. !
  2. ! $Id: modutil.F90 4779 2014-09-19 14:21:37Z rblod $
  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. !> Module Agrif_Util
  24. !!
  25. !! This module contains the two procedures called in the main program :
  26. !! - #Agrif_Init_Grids allows the initialization of the root coarse grid
  27. !! - #Agrif_Step allows the creation of the grid hierarchy and the management of the time integration.
  28. !
  29. module Agrif_Util
  30. !
  31. use Agrif_Clustering
  32. use Agrif_BcFunction
  33. use Agrif_seq
  34. !
  35. implicit none
  36. !
  37. abstract interface
  38. subroutine step_proc()
  39. end subroutine step_proc
  40. end interface
  41. !
  42. contains
  43. !
  44. !===================================================================================================
  45. ! subroutine Agrif_Step
  46. !
  47. !> Creates the grid hierarchy and manages the time integration procedure.
  48. !> It is called in the main program.
  49. !> Calls subroutines #Agrif_Regrid and #Agrif_Integrate.
  50. !---------------------------------------------------------------------------------------------------
  51. subroutine Agrif_Step ( procname )
  52. !---------------------------------------------------------------------------------------------------
  53. procedure(step_proc) :: procname !< subroutine to call on each grid
  54. type(agrif_grid), pointer :: ref_grid
  55. !
  56. ! Set the clustering variables
  57. call Agrif_clustering_def()
  58. !
  59. ! Creation and initialization of the grid hierarchy
  60. if ( Agrif_USE_ONLY_FIXED_GRIDS == 1 ) then
  61. !
  62. if ( (Agrif_Mygrid % ngridstep == 0) .AND. (.not. Agrif_regrid_has_been_done) ) then
  63. call Agrif_Regrid()
  64. Agrif_regrid_has_been_done = .TRUE.
  65. endif
  66. !
  67. else
  68. !
  69. if (mod(Agrif_Mygrid % ngridstep,Agrif_Regridding) == 0) then
  70. call Agrif_Regrid()
  71. endif
  72. !
  73. endif
  74. !
  75. ! Time integration of the grid hierarchy
  76. if (agrif_coarse) then
  77. ref_grid => agrif_coarsegrid
  78. else
  79. ref_grid => agrif_mygrid
  80. endif
  81. if ( Agrif_Parallel_sisters ) then
  82. call Agrif_Integrate_Parallel(ref_grid,procname)
  83. else
  84. call Agrif_Integrate(ref_grid,procname)
  85. endif
  86. !
  87. if ( ref_grid%child_list%nitems > 0 ) call Agrif_Instance(ref_grid)
  88. !---------------------------------------------------------------------------------------------------
  89. end subroutine Agrif_Step
  90. !===================================================================================================
  91. !
  92. !===================================================================================================
  93. ! subroutine Agrif_Step_Child
  94. !
  95. !> Apply 'procname' to each grid of the hierarchy
  96. !---------------------------------------------------------------------------------------------------
  97. subroutine Agrif_Step_Child ( procname )
  98. !---------------------------------------------------------------------------------------------------
  99. procedure(step_proc) :: procname !< subroutine to call on each grid
  100. !
  101. if ( Agrif_Parallel_sisters ) then
  102. call Agrif_Integrate_Child_Parallel(Agrif_Mygrid,procname)
  103. else
  104. call Agrif_Integrate_Child(Agrif_Mygrid,procname)
  105. endif
  106. !
  107. if ( Agrif_Mygrid%child_list%nitems > 0 ) call Agrif_Instance(Agrif_Mygrid)
  108. !---------------------------------------------------------------------------------------------------
  109. end subroutine Agrif_Step_Child
  110. !===================================================================================================
  111. !
  112. !===================================================================================================
  113. ! subroutine Agrif_Regrid
  114. !
  115. !> Creates the grid hierarchy from fixed grids and adaptive mesh refinement.
  116. !---------------------------------------------------------------------------------------------------
  117. subroutine Agrif_Regrid ( procname )
  118. !---------------------------------------------------------------------------------------------------
  119. procedure(init_proc), optional :: procname !< Initialisation subroutine (Default: Agrif_InitValues)
  120. !
  121. type(Agrif_Rectangle), pointer :: coarsegrid_fixed
  122. type(Agrif_Rectangle), pointer :: coarsegrid_moving
  123. integer :: i, j
  124. integer :: nunit
  125. logical :: BEXIST
  126. TYPE(Agrif_Rectangle) :: newrect ! Pointer on a new grid
  127. integer :: is_coarse, rhox, rhoy, rhoz, rhot
  128. !
  129. if ( Agrif_USE_ONLY_FIXED_GRIDS == 0 ) &
  130. call Agrif_detect_all(Agrif_Mygrid) ! Detection of areas to be refined
  131. !
  132. allocate(coarsegrid_fixed)
  133. allocate(coarsegrid_moving)
  134. !
  135. if ( Agrif_USE_ONLY_FIXED_GRIDS == 0 ) &
  136. call Agrif_Cluster_All(Agrif_Mygrid,coarsegrid_moving) ! Clustering
  137. !
  138. if ( Agrif_USE_FIXED_GRIDS == 1 .OR. Agrif_USE_ONLY_FIXED_GRIDS == 1 ) then
  139. !
  140. if (Agrif_Mygrid % ngridstep == 0) then
  141. !
  142. nunit = Agrif_Get_Unit()
  143. open(nunit, file='AGRIF_FixedGrids.in', form='formatted', status="old", ERR=99)
  144. if (agrif_coarse) then ! SKIP the coarse grid declaration
  145. if (Agrif_Probdim == 3) then
  146. read(nunit,*) is_coarse, rhox, rhoy, rhoz, rhot
  147. elseif (Agrif_Probdim == 2) then
  148. read(nunit,*) is_coarse, rhox, rhoy, rhot
  149. elseif (Agrif_Probdim == 2) then
  150. read(nunit,*) is_coarse, rhox, rhot
  151. endif
  152. endif
  153. ! Creation of the grid hierarchy from the Agrif_FixedGrids.in file
  154. do i = 1,Agrif_Probdim
  155. coarsegrid_fixed % imin(i) = 1
  156. coarsegrid_fixed % imax(i) = Agrif_Mygrid % nb(i) + 1
  157. enddo
  158. j = 1
  159. call Agrif_Read_Fix_Grd(coarsegrid_fixed,j,nunit)
  160. close(nunit)
  161. !
  162. call Agrif_gl_clear(Agrif_oldmygrid)
  163. !
  164. ! Creation of the grid hierarchy from coarsegrid_fixed
  165. call Agrif_Create_Grids(Agrif_Mygrid,coarsegrid_fixed)
  166. else
  167. call Agrif_gl_copy(Agrif_oldmygrid, Agrif_Mygrid % child_list)
  168. endif
  169. else
  170. call Agrif_gl_copy(Agrif_oldmygrid, Agrif_Mygrid % child_list)
  171. call Agrif_gl_clear(Agrif_Mygrid % child_list)
  172. endif
  173. !
  174. if ( Agrif_USE_ONLY_FIXED_GRIDS == 0 ) then
  175. !
  176. call Agrif_Save_All(Agrif_oldmygrid)
  177. call Agrif_Free_before_All(Agrif_oldmygrid)
  178. !
  179. ! Creation of the grid hierarchy from coarsegrid_moving
  180. call Agrif_Create_Grids(Agrif_Mygrid,coarsegrid_moving)
  181. !
  182. endif
  183. !
  184. ! Initialization of the grid hierarchy by copy or interpolation
  185. !
  186. #if defined AGRIF_MPI
  187. if ( Agrif_Parallel_sisters ) then
  188. call Agrif_Init_Hierarchy_Parallel_1(Agrif_Mygrid)
  189. call Agrif_Init_Hierarchy_Parallel_2(Agrif_Mygrid,procname)
  190. else
  191. call Agrif_Init_Hierarchy(Agrif_Mygrid,procname)
  192. endif
  193. #else
  194. call Agrif_Init_Hierarchy(Agrif_Mygrid,procname)
  195. #endif
  196. !
  197. if ( Agrif_USE_ONLY_FIXED_GRIDS == 0 ) call Agrif_Free_after_All(Agrif_oldmygrid)
  198. !
  199. Agrif_regrid_has_been_done = .TRUE.
  200. !
  201. call Agrif_Instance( Agrif_Mygrid )
  202. !
  203. deallocate(coarsegrid_fixed)
  204. deallocate(coarsegrid_moving)
  205. !
  206. return
  207. !
  208. ! Opening error
  209. !
  210. 99 INQUIRE(FILE='AGRIF_FixedGrids.in',EXIST=BEXIST)
  211. if (.not. BEXIST) then
  212. print*,'ERROR : File AGRIF_FixedGrids.in not found.'
  213. STOP
  214. else
  215. print*,'Error opening file AGRIF_FixedGrids.in'
  216. STOP
  217. endif
  218. !---------------------------------------------------------------------------------------------------
  219. end subroutine Agrif_Regrid
  220. !===================================================================================================
  221. !
  222. !===================================================================================================
  223. ! subroutine Agrif_detect_All
  224. !
  225. !> Detects areas to be refined.
  226. !---------------------------------------------------------------------------------------------------
  227. recursive subroutine Agrif_detect_all ( g )
  228. !---------------------------------------------------------------------------------------------------
  229. TYPE(Agrif_Grid), pointer :: g !< Pointer on the current grid
  230. !
  231. Type(Agrif_PGrid), pointer :: parcours ! Pointer for the recursive procedure
  232. integer, DIMENSION(3) :: size
  233. integer :: i
  234. real :: g_eps
  235. !
  236. parcours => g % child_list % first
  237. !
  238. ! To be positioned on the finer grids of the grid hierarchy
  239. !
  240. do while (associated(parcours))
  241. call Agrif_detect_all(parcours % gr)
  242. parcours => parcours % next
  243. enddo
  244. !
  245. g_eps = huge(1.)
  246. do i = 1,Agrif_Probdim
  247. g_eps = min(g_eps, g % Agrif_dx(i))
  248. enddo
  249. !
  250. g_eps = g_eps / 100.
  251. !
  252. if ( Agrif_Probdim == 1 ) g%tabpoint1D = 0
  253. if ( Agrif_Probdim == 2 ) g%tabpoint2D = 0
  254. if ( Agrif_Probdim == 3 ) g%tabpoint3D = 0
  255. !
  256. do i = 1,Agrif_Probdim
  257. if ( g%Agrif_dx(i)/Agrif_coeffref(i) < (Agrif_mind(i)-g_eps) ) return
  258. enddo
  259. !
  260. call Agrif_instance(g)
  261. !
  262. ! Detection (Agrif_detect is a users routine)
  263. !
  264. do i = 1,Agrif_Probdim
  265. size(i) = g % nb(i) + 1
  266. enddo
  267. !
  268. SELECT CASE (Agrif_Probdim)
  269. CASE (1)
  270. call Agrif_detect(g%tabpoint1D,size)
  271. CASE (2)
  272. call Agrif_detect(g%tabpoint2D,size)
  273. CASE (3)
  274. call Agrif_detect(g%tabpoint3D,size)
  275. END SELECT
  276. !
  277. ! Addition of the areas detected on the child grids
  278. !
  279. parcours => g % child_list % first
  280. !
  281. do while (associated(parcours))
  282. call Agrif_Add_detected_areas(g,parcours % gr)
  283. parcours => parcours % next
  284. enddo
  285. !---------------------------------------------------------------------------------------------------
  286. end subroutine Agrif_detect_all
  287. !===================================================================================================
  288. !
  289. !===================================================================================================
  290. ! subroutine Agrif_Add_detected_areas
  291. !
  292. !> Adds on the parent grid the areas detected on its child grids
  293. !---------------------------------------------------------------------------------------------------
  294. subroutine Agrif_Add_detected_areas ( parentgrid, childgrid )
  295. !---------------------------------------------------------------------------------------------------
  296. Type(Agrif_Grid), pointer :: parentgrid
  297. Type(Agrif_Grid), pointer :: childgrid
  298. !
  299. integer :: i,j,k
  300. !
  301. do i = 1,childgrid%nb(1)+1
  302. if ( Agrif_Probdim == 1 ) then
  303. if (childgrid%tabpoint1D(i)==1) then
  304. parentgrid%tabpoint1D(childgrid%ix(1)+(i-1)/Agrif_Coeffref(1)) = 1
  305. endif
  306. else
  307. do j=1,childgrid%nb(2)+1
  308. if (Agrif_Probdim==2) then
  309. if (childgrid%tabpoint2D(i,j)==1) then
  310. parentgrid%tabpoint2D( &
  311. childgrid%ix(1)+(i-1)/Agrif_Coeffref(1), &
  312. childgrid%ix(2)+(j-1)/Agrif_Coeffref(2)) = 1
  313. endif
  314. else
  315. do k=1,childgrid%nb(3)+1
  316. if (childgrid%tabpoint3D(i,j,k)==1) then
  317. parentgrid%tabpoint3D( &
  318. childgrid%ix(1)+(i-1)/Agrif_Coeffref(1), &
  319. childgrid%ix(2)+(j-1)/Agrif_Coeffref(2), &
  320. childgrid%ix(3)+(k-1)/Agrif_Coeffref(3)) = 1
  321. endif
  322. enddo
  323. endif
  324. enddo
  325. endif
  326. enddo
  327. !---------------------------------------------------------------------------------------------------
  328. end subroutine Agrif_Add_detected_areas
  329. !===================================================================================================
  330. !
  331. !===================================================================================================
  332. ! subroutine Agrif_Free_before_All
  333. !---------------------------------------------------------------------------------------------------
  334. recursive subroutine Agrif_Free_before_All ( gridlist )
  335. !---------------------------------------------------------------------------------------------------
  336. Type(Agrif_Grid_List), intent(inout) :: gridlist !< Grid list
  337. !
  338. Type(Agrif_PGrid), pointer :: parcours ! Pointer for the recursive procedure
  339. !
  340. parcours => gridlist % first
  341. !
  342. do while (associated(parcours))
  343. !
  344. if (.not. parcours%gr%fixed) then
  345. call Agrif_Free_data_before(parcours%gr)
  346. parcours % gr % oldgrid = .TRUE.
  347. endif
  348. !
  349. call Agrif_Free_before_all (parcours % gr % child_list)
  350. !
  351. parcours => parcours % next
  352. !
  353. enddo
  354. !---------------------------------------------------------------------------------------------------
  355. end subroutine Agrif_Free_before_All
  356. !===================================================================================================
  357. !
  358. !===================================================================================================
  359. ! subroutine Agrif_Save_All
  360. !---------------------------------------------------------------------------------------------------
  361. recursive subroutine Agrif_Save_All ( gridlist )
  362. !---------------------------------------------------------------------------------------------------
  363. type(Agrif_Grid_List), intent(inout) :: gridlist !< Grid list
  364. !
  365. type(Agrif_PGrid), pointer :: parcours ! Pointer for the recursive procedure
  366. !
  367. parcours => gridlist % first
  368. !
  369. do while (associated(parcours))
  370. !
  371. if (.not. parcours%gr%fixed) then
  372. call Agrif_Instance(parcours%gr)
  373. call Agrif_Before_Regridding()
  374. parcours % gr % oldgrid = .TRUE.
  375. endif
  376. !
  377. call Agrif_Save_All(parcours % gr % child_list)
  378. !
  379. parcours => parcours % next
  380. !
  381. enddo
  382. !---------------------------------------------------------------------------------------------------
  383. end subroutine Agrif_Save_All
  384. !===================================================================================================
  385. !
  386. !===================================================================================================
  387. ! subroutine Agrif_Free_after_All
  388. !---------------------------------------------------------------------------------------------------
  389. recursive subroutine Agrif_Free_after_All ( gridlist )
  390. !---------------------------------------------------------------------------------------------------
  391. Type(Agrif_Grid_List), intent(inout) :: gridlist !< Grid list to free
  392. !
  393. Type(Agrif_PGrid), pointer :: parcours ! Pointer for the recursive proced
  394. Type(Agrif_PGrid), pointer :: preparcours
  395. Type(Agrif_PGrid), pointer :: preparcoursini
  396. !
  397. allocate(preparcours)
  398. !
  399. preparcoursini => preparcours
  400. !
  401. nullify(preparcours % gr)
  402. !
  403. preparcours % next => gridlist % first
  404. parcours => gridlist % first
  405. !
  406. do while (associated(parcours))
  407. !
  408. if ( (.NOT. parcours%gr % fixed) .AND. (parcours%gr % oldgrid) ) then
  409. call Agrif_Free_data_after(parcours%gr)
  410. endif
  411. !
  412. call Agrif_Free_after_all( parcours%gr % child_list )
  413. !
  414. if (parcours % gr % oldgrid) then
  415. deallocate(parcours % gr)
  416. preparcours % next => parcours % next
  417. deallocate(parcours)
  418. parcours => preparcours % next
  419. else
  420. preparcours => preparcours % next
  421. parcours => parcours % next
  422. endif
  423. !
  424. enddo
  425. !
  426. deallocate(preparcoursini)
  427. !---------------------------------------------------------------------------------------------------
  428. end subroutine Agrif_Free_after_All
  429. !===================================================================================================
  430. !
  431. !===================================================================================================
  432. ! subroutine Agrif_Integrate
  433. !
  434. !> Manages the time integration of the grid hierarchy.
  435. !! Recursive subroutine and call on subroutines Agrif_Init::Agrif_Instance and #Agrif_Step
  436. !---------------------------------------------------------------------------------------------------
  437. recursive subroutine Agrif_Integrate ( g, procname )
  438. !---------------------------------------------------------------------------------------------------
  439. type(Agrif_Grid), pointer :: g !< Pointer on the current grid
  440. procedure(step_proc) :: procname !< Subroutine to call on each grid
  441. !
  442. type(Agrif_PGrid), pointer :: parcours ! Pointer for the recursive procedure
  443. integer :: nbt ! Number of time steps of the current grid
  444. integer :: i, k
  445. !
  446. ! Instanciation of the variables of the current grid
  447. ! if ( g % fixedrank /= 0 ) then
  448. call Agrif_Instance(g)
  449. ! endif
  450. !
  451. ! One step on the current grid
  452. !
  453. call procname ()
  454. !
  455. ! Number of time steps on the current grid
  456. !
  457. g%ngridstep = g % ngridstep + 1
  458. parcours => g % child_list % first
  459. !
  460. ! Recursive procedure for the time integration of the grid hierarchy
  461. do while (associated(parcours))
  462. !
  463. ! Instanciation of the variables of the current grid
  464. call Agrif_Instance(parcours % gr)
  465. !
  466. ! Number of time steps
  467. nbt = 1
  468. do i = 1,Agrif_Probdim
  469. nbt = max(nbt, parcours % gr % timeref(i))
  470. enddo
  471. !
  472. do k = 1,nbt
  473. call Agrif_Integrate(parcours % gr, procname)
  474. enddo
  475. !
  476. parcours => parcours % next
  477. !
  478. enddo
  479. !---------------------------------------------------------------------------------------------------
  480. end subroutine Agrif_Integrate
  481. !===================================================================================================
  482. !
  483. !===================================================================================================
  484. ! subroutine Agrif_Integrate_Parallel
  485. !
  486. !> Manages the time integration of the grid hierarchy in parallel
  487. !! Recursive subroutine and call on subroutines Agrif_Init::Agrif_Instance and #Agrif_Step
  488. !---------------------------------------------------------------------------------------------------
  489. recursive subroutine Agrif_Integrate_Parallel ( g, procname )
  490. !---------------------------------------------------------------------------------------------------
  491. type(Agrif_Grid), pointer :: g !< Pointer on the current grid
  492. procedure(step_proc) :: procname !< Subroutine to call on each grid
  493. !
  494. #if defined AGRIF_MPI
  495. type(Agrif_PGrid), pointer :: gridp ! Pointer for the recursive procedure
  496. integer :: nbt ! Number of time steps of the current grid
  497. integer :: i, k, is
  498. !
  499. ! Instanciation of the variables of the current grid
  500. if ( g % fixedrank /= 0 ) then
  501. call Agrif_Instance(g)
  502. endif
  503. !
  504. ! One step on the current grid
  505. call procname ()
  506. !
  507. ! Number of time steps on the current grid
  508. g % ngridstep = g % ngridstep + 1
  509. !
  510. ! Continue only if the grid has defined sequences of child integrations.
  511. if ( .not. associated(g % child_seq) ) return
  512. !
  513. do is = 1, g % child_seq % nb_seqs
  514. !
  515. ! For each sequence, a given processor does integrate only on grid.
  516. gridp => Agrif_seq_select_child(g,is)
  517. !
  518. ! Instanciation of the variables of the current grid
  519. call Agrif_Instance(gridp % gr)
  520. !
  521. ! Number of time steps
  522. nbt = 1
  523. do i = 1,Agrif_Probdim
  524. nbt = max(nbt, gridp % gr % timeref(i))
  525. enddo
  526. !
  527. do k = 1,nbt
  528. call Agrif_Integrate_Parallel(gridp % gr, procname)
  529. enddo
  530. !
  531. enddo
  532. #else
  533. call Agrif_Integrate( g, procname )
  534. #endif
  535. !---------------------------------------------------------------------------------------------------
  536. end subroutine Agrif_Integrate_Parallel
  537. !===================================================================================================
  538. !
  539. !
  540. !===================================================================================================
  541. ! subroutine Agrif_Integrate_ChildGrids
  542. !
  543. !> Manages the time integration of the grid hierarchy.
  544. !! Call the subroutine procname on each child grid of the current grid
  545. !---------------------------------------------------------------------------------------------------
  546. recursive subroutine Agrif_Integrate_ChildGrids ( procname )
  547. !---------------------------------------------------------------------------------------------------
  548. procedure(step_proc) :: procname !< Subroutine to call on each grid
  549. !
  550. type(Agrif_PGrid), pointer :: parcours ! Pointer for the recursive procedure
  551. integer :: nbt ! Number of time steps of the current grid
  552. integer :: i, k, is
  553. type(Agrif_Grid) , pointer :: save_grid
  554. type(Agrif_PGrid), pointer :: gridp ! Pointer for the recursive procedure
  555. save_grid => Agrif_Curgrid
  556. ! Number of time steps on the current grid
  557. save_grid % ngridstep = save_grid % ngridstep + 1
  558. #ifdef AGRIF_MPI
  559. if ( .not. Agrif_Parallel_sisters ) then
  560. #endif
  561. parcours => save_grid % child_list % first
  562. !
  563. ! Recursive procedure for the time integration of the grid hierarchy
  564. do while (associated(parcours))
  565. !
  566. ! Instanciation of the variables of the current grid
  567. call Agrif_Instance(parcours % gr)
  568. !
  569. ! Number of time steps
  570. nbt = 1
  571. do i = 1,Agrif_Probdim
  572. nbt = max(nbt, parcours % gr % timeref(i))
  573. enddo
  574. !
  575. do k = 1,nbt
  576. call procname()
  577. enddo
  578. !
  579. parcours => parcours % next
  580. !
  581. enddo
  582. #ifdef AGRIF_MPI
  583. else
  584. #endif
  585. ! Continue only if the grid has defined sequences of child integrations.
  586. if ( .not. associated(save_grid % child_seq) ) return
  587. !
  588. do is = 1, save_grid % child_seq % nb_seqs
  589. !
  590. ! For each sequence, a given processor does integrate only on grid.
  591. gridp => Agrif_seq_select_child(save_grid,is)
  592. !
  593. ! Instanciation of the variables of the current grid
  594. call Agrif_Instance(gridp % gr)
  595. !
  596. ! Number of time steps
  597. nbt = 1
  598. do i = 1,Agrif_Probdim
  599. nbt = max(nbt, gridp % gr % timeref(i))
  600. enddo
  601. !
  602. do k = 1,nbt
  603. call procname()
  604. enddo
  605. !
  606. enddo
  607. #ifdef AGRIF_MPI
  608. endif
  609. #endif
  610. call Agrif_Instance(save_grid)
  611. !---------------------------------------------------------------------------------------------------
  612. end subroutine Agrif_Integrate_ChildGrids
  613. !===================================================================================================
  614. !===================================================================================================
  615. ! subroutine Agrif_Integrate_Child
  616. !
  617. !> Manages the time integration of the grid hierarchy.
  618. !! Recursive subroutine and call on subroutines Agrif_Instance & Agrif_Step.
  619. !---------------------------------------------------------------------------------------------------
  620. recursive subroutine Agrif_Integrate_Child ( g, procname )
  621. !---------------------------------------------------------------------------------------------------
  622. type(Agrif_Grid), pointer :: g !< Pointer on the current grid
  623. procedure(step_proc) :: procname !< Subroutine to call on each grid
  624. !
  625. type(Agrif_PGrid), pointer :: parcours ! Pointer for the recursive procedure
  626. !
  627. ! One step on the current grid
  628. !
  629. call procname ()
  630. !
  631. ! Number of time steps on the current grid
  632. !
  633. parcours => g % child_list % first
  634. !
  635. ! Recursive procedure for the time integration of the grid hierarchy
  636. do while (associated(parcours))
  637. !
  638. ! Instanciation of the variables of the current grid
  639. call Agrif_Instance(parcours % gr)
  640. call Agrif_Integrate_Child (parcours % gr, procname)
  641. parcours => parcours % next
  642. !
  643. enddo
  644. !---------------------------------------------------------------------------------------------------
  645. end subroutine Agrif_Integrate_Child
  646. !===================================================================================================
  647. !
  648. !===================================================================================================
  649. ! subroutine Agrif_Integrate_Child_Parallel
  650. !
  651. !> Manages the time integration of the grid hierarchy.
  652. !! Recursive subroutine and call on subroutines Agrif_Instance & Agrif_Step.
  653. !---------------------------------------------------------------------------------------------------
  654. recursive subroutine Agrif_Integrate_Child_Parallel ( g, procname )
  655. !---------------------------------------------------------------------------------------------------
  656. type(Agrif_Grid), pointer :: g !< Pointer on the current grid
  657. procedure(step_proc) :: procname !< Subroutine to call on each grid
  658. !
  659. #if defined AGRIF_MPI
  660. type(Agrif_PGrid), pointer :: gridp ! Pointer for the recursive procedure
  661. integer :: is
  662. !
  663. ! Instanciation of the variables of the current grid
  664. call Agrif_Instance(g)
  665. !
  666. ! One step on the current grid
  667. call procname ()
  668. !
  669. ! Continue only if the grid has defined sequences of child integrations.
  670. if ( .not. associated(g % child_seq) ) return
  671. !
  672. do is = 1, g % child_seq % nb_seqs
  673. !
  674. ! For each sequence, a given processor does integrate only on grid.
  675. gridp => Agrif_seq_select_child(g,is)
  676. call Agrif_Integrate_Child_Parallel(gridp % gr, procname)
  677. !
  678. enddo
  679. !
  680. call Agrif_Instance(g)
  681. #else
  682. call Agrif_Integrate_Child( g, procname )
  683. #endif
  684. !---------------------------------------------------------------------------------------------------
  685. end subroutine Agrif_Integrate_Child_Parallel
  686. !===================================================================================================
  687. !
  688. !===================================================================================================
  689. ! subroutine Agrif_Init_Grids
  690. !
  691. !> Initializes the root coarse grid pointed by Agrif_Mygrid. It is called in the main program.
  692. !---------------------------------------------------------------------------------------------------
  693. subroutine Agrif_Init_Grids ( procname1, procname2 )
  694. !---------------------------------------------------------------------------------------------------
  695. procedure(typdef_proc), optional :: procname1 !< (Default: Agrif_probdim_modtype_def)
  696. procedure(alloc_proc), optional :: procname2 !< (Default: Agrif_Allocationcalls)
  697. !
  698. integer :: i, ierr_allocate, nunit
  699. integer :: is_coarse, rhox,rhoy,rhoz,rhot
  700. logical :: BEXIST
  701. !
  702. if (present(procname1)) Then
  703. call procname1()
  704. else
  705. call Agrif_probdim_modtype_def()
  706. endif
  707. !
  708. ! TEST FOR COARSE GRID (GRAND MOTHER GRID) in AGRIF_FixedGrids.in
  709. nunit = Agrif_Get_Unit()
  710. open(nunit, file='AGRIF_FixedGrids.in', form='formatted', status="old", ERR=98)
  711. if (Agrif_Probdim == 3) then
  712. read(nunit,*) is_coarse, rhox, rhoy, rhoz, rhot
  713. elseif (Agrif_Probdim == 2) then
  714. read(nunit,*) is_coarse, rhox, rhoy, rhot
  715. elseif (Agrif_Probdim == 2) then
  716. read(nunit,*) is_coarse, rhox, rhot
  717. endif
  718. if (is_coarse == -1) then
  719. agrif_coarse = .TRUE.
  720. if (Agrif_Probdim == 3) then
  721. coarse_spaceref(1:3)=(/rhox,rhoy,rhoz/)
  722. elseif (Agrif_Probdim == 2) then
  723. coarse_spaceref(1:2)=(/rhox,rhoy/)
  724. elseif (Agrif_Probdim == 2) then
  725. coarse_spaceref(1:1)=(/rhox/)
  726. endif
  727. coarse_timeref(1:Agrif_Probdim) = rhot
  728. endif
  729. close(nunit)
  730. Agrif_UseSpecialValue = .FALSE.
  731. Agrif_UseSpecialValueFineGrid = .FALSE.
  732. Agrif_SpecialValue = 0.
  733. Agrif_SpecialValueFineGrid = 0.
  734. !
  735. allocate(Agrif_Mygrid)
  736. allocate(Agrif_OldMygrid)
  737. !
  738. ! Space and time refinement factors are set to 1 on the root grid
  739. !
  740. do i = 1,Agrif_Probdim
  741. Agrif_Mygrid % spaceref(i) = coarse_spaceref(i)
  742. Agrif_Mygrid % timeref(i) = coarse_timeref(i)
  743. enddo
  744. !
  745. ! Initialization of the number of time steps
  746. Agrif_Mygrid % ngridstep = 0
  747. Agrif_Mygrid % grid_id = 0
  748. !
  749. ! No parent grid for the root coarse grid
  750. nullify(Agrif_Mygrid % parent)
  751. !
  752. ! Initialization of the minimum positions, global abscissa and space steps
  753. do i = 1, Agrif_Probdim
  754. Agrif_Mygrid % ix(i) = 1
  755. Agrif_Mygrid % Agrif_x(i) = 0.
  756. Agrif_Mygrid % Agrif_dx(i) = 1./Agrif_Mygrid % spaceref(i)
  757. Agrif_Mygrid % Agrif_dt(i) = 1./Agrif_Mygrid % timeref(i)
  758. ! Borders of the root coarse grid
  759. Agrif_Mygrid % NearRootBorder(i) = .true.
  760. Agrif_Mygrid % DistantRootBorder(i) = .true.
  761. enddo
  762. !
  763. ! The root coarse grid is a fixed grid
  764. Agrif_Mygrid % fixed = .TRUE.
  765. ! Level of the root grid
  766. Agrif_Mygrid % level = 0
  767. ! Maximum level in the hierarchy
  768. Agrif_MaxLevelLoc = 0
  769. !
  770. ! Number of the grid pointed by Agrif_Mygrid (root coarse grid)
  771. Agrif_Mygrid % rank = 1
  772. !
  773. ! Number of the root grid as a fixed grid
  774. Agrif_Mygrid % fixedrank = 0
  775. !
  776. ! Initialization of some fields of the root grid variables
  777. ierr_allocate = 0
  778. if( Agrif_NbVariables(0) > 0 ) allocate(Agrif_Mygrid % tabvars(Agrif_NbVariables(0)),stat=ierr_allocate)
  779. if( Agrif_NbVariables(1) > 0 ) allocate(Agrif_Mygrid % tabvars_c(Agrif_NbVariables(1)),stat=ierr_allocate)
  780. if( Agrif_NbVariables(2) > 0 ) allocate(Agrif_Mygrid % tabvars_r(Agrif_NbVariables(2)),stat=ierr_allocate)
  781. if( Agrif_NbVariables(3) > 0 ) allocate(Agrif_Mygrid % tabvars_l(Agrif_NbVariables(3)),stat=ierr_allocate)
  782. if( Agrif_NbVariables(4) > 0 ) allocate(Agrif_Mygrid % tabvars_i(Agrif_NbVariables(4)),stat=ierr_allocate)
  783. if (ierr_allocate /= 0) THEN
  784. STOP "*** ERROR WHEN ALLOCATING TABVARS ***"
  785. endif
  786. !
  787. ! Initialization of the other fields of the root grid variables (number of
  788. ! cells, positions, number and type of its dimensions, ...)
  789. call Agrif_Instance(Agrif_Mygrid)
  790. call Agrif_Set_numberofcells(Agrif_Mygrid)
  791. !
  792. ! Allocation of the array containing the values of the grid variables
  793. call Agrif_Allocation(Agrif_Mygrid, procname2)
  794. call Agrif_initialisations(Agrif_Mygrid)
  795. !
  796. ! Total number of fixed grids
  797. Agrif_nbfixedgrids = 0
  798. ! If a grand mother grid is declared
  799. if (agrif_coarse) then
  800. allocate(Agrif_Coarsegrid)
  801. Agrif_Coarsegrid % ngridstep = 0
  802. Agrif_Coarsegrid % grid_id = -9999
  803. do i = 1, Agrif_Probdim
  804. Agrif_Coarsegrid%spaceref(i) = coarse_spaceref(i)
  805. Agrif_Coarsegrid%timeref(i) = coarse_timeref(i)
  806. Agrif_Coarsegrid % ix(i) = 1
  807. Agrif_Coarsegrid % Agrif_x(i) = 0.
  808. Agrif_Coarsegrid % Agrif_dx(i) = 1.
  809. Agrif_Coarsegrid % Agrif_dt(i) = 1.
  810. ! Borders of the root coarse grid
  811. Agrif_Coarsegrid % NearRootBorder(i) = .true.
  812. Agrif_Coarsegrid % DistantRootBorder(i) = .true.
  813. Agrif_Coarsegrid % nb(i) =Agrif_mygrid%nb(i) / coarse_spaceref(i)
  814. enddo
  815. ! The root coarse grid is a fixed grid
  816. Agrif_Coarsegrid % fixed = .TRUE.
  817. ! Level of the root grid
  818. Agrif_Coarsegrid % level = -1
  819. Agrif_Coarsegrid % grand_mother_grid = .true.
  820. ! Number of the grid pointed by Agrif_Mygrid (root coarse grid)
  821. Agrif_Coarsegrid % rank = -9999
  822. !
  823. ! Number of the root grid as a fixed grid
  824. Agrif_Coarsegrid % fixedrank = -9999
  825. Agrif_Mygrid%parent => Agrif_Coarsegrid
  826. ! Not used but required to prevent seg fault
  827. Agrif_Coarsegrid%parent => Agrif_Mygrid
  828. call Agrif_Create_Var(Agrif_Coarsegrid)
  829. ! Reset to null
  830. Nullify(Agrif_Coarsegrid%parent)
  831. Agrif_Coarsegrid%child_list%nitems = 1
  832. allocate(Agrif_Coarsegrid%child_list%first)
  833. allocate(Agrif_Coarsegrid%child_list%last)
  834. Agrif_Coarsegrid%child_list%first%gr => Agrif_Mygrid
  835. Agrif_Coarsegrid%child_list%last%gr => Agrif_Mygrid
  836. endif
  837. return
  838. 98 INQUIRE(FILE='AGRIF_FixedGrids.in',EXIST=BEXIST)
  839. if (.not. BEXIST) then
  840. print*,'ERROR : File AGRIF_FixedGrids.in not found.'
  841. STOP
  842. else
  843. print*,'Error opening file AGRIF_FixedGrids.in'
  844. STOP
  845. endif
  846. !---------------------------------------------------------------------------------------------------
  847. end subroutine Agrif_Init_Grids
  848. !===================================================================================================
  849. !
  850. !===================================================================================================
  851. ! subroutine Agrif_Deallocation
  852. !
  853. !> Deallocates all data arrays.
  854. !---------------------------------------------------------------------------------------------------
  855. subroutine Agrif_Deallocation
  856. !---------------------------------------------------------------------------------------------------
  857. integer :: nb
  858. type(Agrif_Variable), pointer :: var
  859. type(Agrif_Variable_c), pointer :: var_c
  860. type(Agrif_Variable_l), pointer :: var_l
  861. type(Agrif_Variable_i), pointer :: var_i
  862. !
  863. do nb = 1,Agrif_NbVariables(0)
  864. !
  865. var => Agrif_Mygrid % tabvars(nb)
  866. !
  867. if ( allocated(var % array1) ) deallocate(var % array1)
  868. if ( allocated(var % array2) ) deallocate(var % array2)
  869. if ( allocated(var % array3) ) deallocate(var % array3)
  870. if ( allocated(var % array4) ) deallocate(var % array4)
  871. if ( allocated(var % array5) ) deallocate(var % array5)
  872. if ( allocated(var % array6) ) deallocate(var % array6)
  873. !
  874. if ( allocated(var % sarray1) ) deallocate(var % sarray1)
  875. if ( allocated(var % sarray2) ) deallocate(var % sarray2)
  876. if ( allocated(var % sarray3) ) deallocate(var % sarray3)
  877. if ( allocated(var % sarray4) ) deallocate(var % sarray4)
  878. if ( allocated(var % sarray5) ) deallocate(var % sarray5)
  879. if ( allocated(var % sarray6) ) deallocate(var % sarray6)
  880. !
  881. if ( allocated(var % darray1) ) deallocate(var % darray1)
  882. if ( allocated(var % darray2) ) deallocate(var % darray2)
  883. if ( allocated(var % darray3) ) deallocate(var % darray3)
  884. if ( allocated(var % darray4) ) deallocate(var % darray4)
  885. if ( allocated(var % darray5) ) deallocate(var % darray5)
  886. if ( allocated(var % darray6) ) deallocate(var % darray6)
  887. !
  888. enddo
  889. !
  890. do nb = 1,Agrif_NbVariables(1)
  891. !
  892. var_c => Agrif_Mygrid % tabvars_c(nb)
  893. !
  894. if ( allocated(var_c % carray1) ) deallocate(var_c % carray1)
  895. if ( allocated(var_c % carray2) ) deallocate(var_c % carray2)
  896. !
  897. enddo
  898. do nb = 1,Agrif_NbVariables(3)
  899. !
  900. var_l => Agrif_Mygrid % tabvars_l(nb)
  901. !
  902. if ( allocated(var_l % larray1) ) deallocate(var_l % larray1)
  903. if ( allocated(var_l % larray2) ) deallocate(var_l % larray2)
  904. if ( allocated(var_l % larray3) ) deallocate(var_l % larray3)
  905. if ( allocated(var_l % larray4) ) deallocate(var_l % larray4)
  906. if ( allocated(var_l % larray5) ) deallocate(var_l % larray5)
  907. if ( allocated(var_l % larray6) ) deallocate(var_l % larray6)
  908. !
  909. enddo
  910. !
  911. do nb = 1,Agrif_NbVariables(4)
  912. !
  913. var_i => Agrif_Mygrid % tabvars_i(nb)
  914. !
  915. if ( allocated(var_i % iarray1) ) deallocate(var_i % iarray1)
  916. if ( allocated(var_i % iarray2) ) deallocate(var_i % iarray2)
  917. if ( allocated(var_i % iarray3) ) deallocate(var_i % iarray3)
  918. if ( allocated(var_i % iarray4) ) deallocate(var_i % iarray4)
  919. if ( allocated(var_i % iarray5) ) deallocate(var_i % iarray5)
  920. if ( allocated(var_i % iarray6) ) deallocate(var_i % iarray6)
  921. !
  922. enddo
  923. !
  924. if ( allocated(Agrif_Mygrid % tabvars) ) deallocate(Agrif_Mygrid % tabvars)
  925. if ( allocated(Agrif_Mygrid % tabvars_c) ) deallocate(Agrif_Mygrid % tabvars_c)
  926. if ( allocated(Agrif_Mygrid % tabvars_r) ) deallocate(Agrif_Mygrid % tabvars_r)
  927. if ( allocated(Agrif_Mygrid % tabvars_l) ) deallocate(Agrif_Mygrid % tabvars_l)
  928. if ( allocated(Agrif_Mygrid % tabvars_i) ) deallocate(Agrif_Mygrid % tabvars_i)
  929. deallocate(Agrif_Mygrid)
  930. !---------------------------------------------------------------------------------------------------
  931. end subroutine Agrif_Deallocation
  932. !===================================================================================================
  933. !
  934. !===================================================================================================
  935. ! subroutine Agrif_Step_adj
  936. !
  937. !> creates the grid hierarchy and manages the backward time integration procedure.
  938. !> It is called in the main program.
  939. !> calls subroutines #Agrif_Regrid and #Agrif_Integrate_adj.
  940. !---------------------------------------------------------------------------------------------------
  941. subroutine Agrif_Step_adj ( procname )
  942. !---------------------------------------------------------------------------------------------------
  943. procedure(step_proc) :: procname !< Subroutine to call on each grid
  944. !
  945. ! Creation and initialization of the grid hierarchy
  946. !
  947. ! Set the clustering variables
  948. call Agrif_clustering_def()
  949. !
  950. if ( Agrif_USE_ONLY_FIXED_GRIDS .EQ. 1 ) then
  951. !
  952. if (Agrif_Mygrid % ngridstep == 0) then
  953. if (.not.Agrif_regrid_has_been_done ) then
  954. call Agrif_Regrid()
  955. endif
  956. call Agrif_Instance(Agrif_Mygrid)
  957. endif
  958. !
  959. else
  960. !
  961. if (mod(Agrif_Mygrid % ngridstep, Agrif_Regridding) == 0) then
  962. call Agrif_Regrid()
  963. call Agrif_Instance(Agrif_Mygrid)
  964. endif
  965. !
  966. endif
  967. !
  968. ! Time integration of the grid hierarchy
  969. !
  970. call Agrif_Integrate_adj (Agrif_Mygrid,procname)
  971. !
  972. if ( Agrif_Mygrid % child_list % nitems > 0 ) call Agrif_Instance(Agrif_Mygrid)
  973. !
  974. !---------------------------------------------------------------------------------------------------
  975. end subroutine Agrif_Step_adj
  976. !===================================================================================================
  977. !
  978. !===================================================================================================
  979. ! subroutine Agrif_Integrate_adj
  980. !
  981. !> Manages the backward time integration of the grid hierarchy.
  982. !! Recursive subroutine and call on subroutines Agrif_Init::Agrif_Instance and #Agrif_Step_adj
  983. !---------------------------------------------------------------------------------------------------
  984. recursive subroutine Agrif_Integrate_adj ( g, procname )
  985. !---------------------------------------------------------------------------------------------------
  986. type(Agrif_Grid), pointer :: g !< Pointer on the current grid
  987. procedure(step_proc) :: procname !< Subroutine to call on each grid
  988. !
  989. type(Agrif_pgrid), pointer :: parcours ! pointer for the recursive procedure
  990. integer :: nbt ! Number of time steps of the current grid
  991. integer :: k
  992. !
  993. ! Instanciation of the variables of the current grid
  994. if ( g%fixedrank /= 0 ) then
  995. call Agrif_Instance(g)
  996. endif
  997. !
  998. ! Number of time steps on the current grid
  999. !
  1000. g%ngridstep = g % ngridstep + 1
  1001. parcours => g % child_list % first
  1002. !
  1003. ! Recursive procedure for the time integration of the grid hierarchy
  1004. do while (associated(parcours))
  1005. !
  1006. ! Instanciation of the variables of the current grid
  1007. call Agrif_Instance(parcours % gr)
  1008. !
  1009. ! Number of time steps
  1010. nbt = 1
  1011. do k = 1,Agrif_Probdim
  1012. nbt = max(nbt, parcours % gr % timeref(k))
  1013. enddo
  1014. !
  1015. do k = nbt,1,-1
  1016. call Agrif_Integrate_adj(parcours % gr, procname)
  1017. enddo
  1018. !
  1019. parcours => parcours % next
  1020. !
  1021. enddo
  1022. !
  1023. if ( g % child_list % nitems > 0 ) call Agrif_Instance(g)
  1024. !
  1025. ! One step on the current grid
  1026. call procname ()
  1027. !
  1028. end subroutine Agrif_Integrate_adj
  1029. !===================================================================================================
  1030. !
  1031. !===================================================================================================
  1032. ! subroutine Agrif_Step_Child_adj
  1033. !
  1034. !> Apply 'procname' to each grid of the hierarchy from Child to Parent
  1035. !---------------------------------------------------------------------------------------------------
  1036. subroutine Agrif_Step_Child_adj ( procname )
  1037. !---------------------------------------------------------------------------------------------------
  1038. procedure(step_proc) :: procname !< Subroutine to call on each grid
  1039. !
  1040. call Agrif_Integrate_Child_adj(Agrif_Mygrid,procname)
  1041. !
  1042. if ( Agrif_Mygrid % child_list % nitems > 0 ) call Agrif_Instance(Agrif_Mygrid)
  1043. !
  1044. end subroutine Agrif_Step_Child_adj
  1045. !===================================================================================================
  1046. !
  1047. !===================================================================================================
  1048. ! subroutine Agrif_Integrate_Child_adj
  1049. !
  1050. !> Manages the backward time integration of the grid hierarchy.
  1051. !! Recursive subroutine and call on subroutines Agrif_Init::Agrif_Instance & Agrif_Step_adj.
  1052. !---------------------------------------------------------------------------------------------------
  1053. recursive subroutine Agrif_Integrate_Child_adj ( g, procname )
  1054. !---------------------------------------------------------------------------------------------------
  1055. type(Agrif_Grid),pointer :: g !< Pointer on the current grid
  1056. procedure(step_proc) :: procname !< Subroutine to call on each grid
  1057. !
  1058. type(Agrif_PGrid),pointer :: parcours !< Pointer for the recursive procedure
  1059. !
  1060. parcours => g % child_list % first
  1061. !
  1062. ! Recursive procedure for the time integration of the grid hierarchy
  1063. do while (associated(parcours))
  1064. !
  1065. ! Instanciation of the variables of the current grid
  1066. call Agrif_Instance(parcours % gr)
  1067. call Agrif_Integrate_Child_adj(parcours % gr, procname)
  1068. !
  1069. parcours => parcours % next
  1070. !
  1071. enddo
  1072. if ( g % child_list % nitems > 0 ) call Agrif_Instance(g)
  1073. !
  1074. ! One step on the current grid
  1075. call procname()
  1076. !---------------------------------------------------------------------------------------------------
  1077. end subroutine Agrif_Integrate_Child_adj
  1078. !===================================================================================================
  1079. !
  1080. !===================================================================================================
  1081. end module Agrif_Util