modinterp.F90 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526
  1. !
  2. ! $Id: modinterp.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. !
  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. local_proc = Agrif_Procrank
  201. call Agrif_get_var_bounds_array(parent,lowerbound,upperbound,nbdim)
  202. call Agrif_ChildGrid_to_ParentGrid()
  203. !
  204. call Agrif_Childbounds(nbdim,lowerbound,upperbound, &
  205. indminglob,indmaxglob, local_proc, coords, &
  206. indminglob2,indmaxglob2,member)
  207. !
  208. if (member) then
  209. call Agrif_GlobalToLocalBounds(parentarray, &
  210. lowerbound, upperbound, &
  211. indminglob2, indmaxglob2, coords,&
  212. nbdim, local_proc, member)
  213. endif
  214. call Agrif_ParentGrid_to_ChildGrid()
  215. #else
  216. parentarray(:,1,1) = indminglob
  217. parentarray(:,2,1) = indmaxglob
  218. parentarray(:,1,2) = indminglob
  219. parentarray(:,2,2) = indmaxglob
  220. indmin = indminglob
  221. indmax = indmaxglob
  222. member = .TRUE.
  223. #endif
  224. else
  225. #if defined AGRIF_MPI
  226. s_Parent_temp = s_Parent + (indmin - pttab_Parent) * ds_Parent
  227. s_Child_temp = s_Child + (pttruetab - pttab_Child) * ds_Child
  228. #else
  229. parentarray(:,1,1) = indminglob
  230. parentarray(:,2,1) = indmaxglob
  231. parentarray(:,1,2) = indminglob
  232. parentarray(:,2,2) = indmaxglob
  233. indmin = indminglob
  234. indmax = indmaxglob
  235. member = .TRUE.
  236. s_Parent_temp = s_Parent + (indminglob - pttab_Parent) * ds_Parent
  237. s_Child_temp = s_Child + (pttab - pttab_Child) * ds_Child
  238. #endif
  239. endif
  240. !
  241. if (member) then
  242. if (.not.associated(tempP)) allocate(tempP)
  243. !
  244. call Agrif_array_allocate(tempP,parentarray(:,1,1),parentarray(:,2,1),nbdim)
  245. call Agrif_var_set_array_tozero(tempP,nbdim)
  246. call Agrif_ChildGrid_to_ParentGrid()
  247. !
  248. select case (nbdim)
  249. case(1)
  250. call procname(tempP%array1, &
  251. parentarray(1,1,2),parentarray(1,2,2),.TRUE.,nb,ndir)
  252. case(2)
  253. call procname(tempP%array2, &
  254. parentarray(1,1,2),parentarray(1,2,2), &
  255. parentarray(2,1,2),parentarray(2,2,2),.TRUE.,nb,ndir)
  256. case(3)
  257. call procname(tempP%array3, &
  258. parentarray(1,1,2),parentarray(1,2,2), &
  259. parentarray(2,1,2),parentarray(2,2,2), &
  260. parentarray(3,1,2),parentarray(3,2,2),.TRUE.,nb,ndir)
  261. case(4)
  262. call procname(tempP%array4, &
  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), &
  266. parentarray(4,1,2),parentarray(4,2,2),.TRUE.,nb,ndir)
  267. case(5)
  268. call procname(tempP%array5, &
  269. parentarray(1,1,2),parentarray(1,2,2), &
  270. parentarray(2,1,2),parentarray(2,2,2), &
  271. parentarray(3,1,2),parentarray(3,2,2), &
  272. parentarray(4,1,2),parentarray(4,2,2), &
  273. parentarray(5,1,2),parentarray(5,2,2),.TRUE.,nb,ndir)
  274. case(6)
  275. call procname(tempP%array6, &
  276. parentarray(1,1,2),parentarray(1,2,2), &
  277. parentarray(2,1,2),parentarray(2,2,2), &
  278. parentarray(3,1,2),parentarray(3,2,2), &
  279. parentarray(4,1,2),parentarray(4,2,2), &
  280. parentarray(5,1,2),parentarray(5,2,2), &
  281. parentarray(6,1,2),parentarray(6,2,2),.TRUE.,nb,ndir)
  282. end select
  283. !
  284. call Agrif_ParentGrid_to_ChildGrid()
  285. !
  286. endif
  287. #if defined AGRIF_MPI
  288. if (.not.find_list_interp) then
  289. !
  290. tab3(:,1) = indminglob2(:)
  291. tab3(:,2) = indmaxglob2(:)
  292. tab3(:,3) = indmin(:)
  293. tab3(:,4) = indmax(:)
  294. !
  295. call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,MPI_INTEGER,Agrif_mpi_comm,code)
  296. if (.not.associated(tempPextend)) allocate(tempPextend)
  297. do k=0,Agrif_Nbprocs-1
  298. do j=1,4
  299. do i=1,nbdim
  300. tab4t(i,k,j) = tab4(i,j,k)
  301. enddo
  302. enddo
  303. enddo
  304. memberin1(1) = memberin
  305. call MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall,1,MPI_LOGICAL,Agrif_mpi_comm,code)
  306. call Get_External_Data_first(tab4t(:,:,1),tab4t(:,:,2), &
  307. tab4t(:,:,3),tab4t(:,:,4), &
  308. nbdim,memberinall, coords, &
  309. sendtoproc1,recvfromproc1, &
  310. tab4t(:,:,5),tab4t(:,:,6), &
  311. tab4t(:,:,7),tab4t(:,:,8) )
  312. endif
  313. call ExchangeSameLevel(sendtoproc1,recvfromproc1,nbdim, &
  314. tab4t(:,:,3),tab4t(:,:,4),tab4t(:,:,5),tab4t(:,:,6), &
  315. tab4t(:,:,7),tab4t(:,:,8),memberin,tempP,tempPextend)
  316. #else
  317. tempPextend => tempP
  318. #endif
  319. if (.not.find_list_interp) then
  320. call Agrif_Addto_list_interp( &
  321. child%list_interp,pttab,petab, &
  322. pttab_Child,pttab_Parent,indmin,indmax, &
  323. indminglob,indmaxglob, &
  324. pttruetab,cetruetab, &
  325. memberin,nbdim &
  326. #if defined AGRIF_MPI
  327. ,indminglob2,indmaxglob2, &
  328. parentarray, &
  329. member, &
  330. tab4t,memberinall,sendtoproc1,recvfromproc1 &
  331. #endif
  332. )
  333. endif
  334. !
  335. if (memberin) then
  336. !
  337. if (.not.associated(tempC)) allocate(tempC)
  338. !
  339. call Agrif_array_allocate(tempC,pttruetab,cetruetab,nbdim)
  340. !
  341. ! Special values on the parent grid
  342. if (Agrif_UseSpecialValue) then
  343. !
  344. noraftab(1:nbdim) = child % root_var % interptab(1:nbdim) == 'N'
  345. !
  346. if (.not.associated(parentvalues)) allocate(parentvalues)
  347. !
  348. call Agrif_array_allocate(parentvalues,indmin,indmax,nbdim)
  349. call Agrif_var_full_copy_array(parentvalues,tempPextend,nbdim)
  350. !
  351. call Agrif_CheckMasknD(tempPextend,parentvalues, &
  352. indmin(1:nbdim),indmax(1:nbdim), &
  353. indmin(1:nbdim),indmax(1:nbdim), &
  354. noraftab(1:nbdim),nbdim)
  355. !
  356. call Agrif_array_deallocate(parentvalues,nbdim)
  357. !
  358. endif
  359. !
  360. ! Interpolation of the current grid
  361. !
  362. if ( memberin ) then
  363. select case(nbdim)
  364. case(1)
  365. call Agrif_Interp_1D_recursive( type_interp(1), &
  366. tempPextend%array1, &
  367. tempC%array1, &
  368. indmin(1), indmax(1), &
  369. pttruetab(1), cetruetab(1), &
  370. s_Child_temp(1), s_Parent_temp(1), &
  371. ds_Child(1), ds_Parent(1) )
  372. case(2)
  373. call Agrif_Interp_2D_recursive( type_interp(1:2), &
  374. tempPextend % array2, &
  375. tempC % array2, &
  376. indmin(1:2), indmax(1:2), &
  377. pttruetab(1:2), cetruetab(1:2), &
  378. s_Child_temp(1:2), s_Parent_temp(1:2), &
  379. ds_Child(1:2), ds_Parent(1:2) )
  380. case(3)
  381. call Agrif_Interp_3D_recursive( type_interp(1:3), &
  382. tempPextend % array3, &
  383. tempC % array3, &
  384. indmin(1:3), indmax(1:3), &
  385. pttruetab(1:3), cetruetab(1:3), &
  386. s_Child_temp(1:3), s_Parent_temp(1:3), &
  387. ds_Child(1:3), ds_Parent(1:3) )
  388. case(4)
  389. call Agrif_Interp_4D_recursive( type_interp(1:4), &
  390. tempPextend % array4, &
  391. tempC % array4, &
  392. indmin(1:4), indmax(1:4), &
  393. pttruetab(1:4), cetruetab(1:4), &
  394. s_Child_temp(1:4), s_Parent_temp(1:4), &
  395. ds_Child(1:4), ds_Parent(1:4) )
  396. case(5)
  397. call Agrif_Interp_5D_recursive( type_interp(1:5), &
  398. tempPextend % array5, &
  399. tempC % array5, &
  400. indmin(1:5), indmax(1:5), &
  401. pttruetab(1:5), cetruetab(1:5), &
  402. s_Child_temp(1:5), s_Parent_temp(1:5), &
  403. ds_Child(1:5), ds_Parent(1:5) )
  404. case(6)
  405. call Agrif_Interp_6D_recursive( type_interp(1:6), &
  406. tempPextend % array6, &
  407. tempC % array6, &
  408. indmin(1:6), indmax(1:6), &
  409. pttruetab(1:6), cetruetab(1:6), &
  410. s_Child_temp(1:6), s_Parent_temp(1:6), &
  411. ds_Child(1:6), ds_Parent(1:6) )
  412. end select
  413. !
  414. call Agrif_get_var_bounds_array(child,lowerbound,upperbound,nbdim)
  415. #if defined AGRIF_MPI
  416. call Agrif_GlobalToLocalBounds(childarray, lowerbound, upperbound, &
  417. pttruetab, cetruetab, coords, &
  418. nbdim, Agrif_Procrank, memberout)
  419. #else
  420. childarray(:,1,1) = pttruetab
  421. childarray(:,2,1) = cetruetab
  422. childarray(:,1,2) = pttruetab
  423. childarray(:,2,2) = cetruetab
  424. !cccccccccccccc memberout = .TRUE.
  425. #endif
  426. !
  427. ! Special values on the child grid
  428. if (Agrif_UseSpecialValueFineGrid) then
  429. call GiveAgrif_SpecialValueToTab_mpi( child, tempC, childarray, Agrif_SpecialValueFineGrid,nbdim )
  430. endif
  431. !
  432. endif ! ( memberin )
  433. !
  434. if (torestore) then
  435. !
  436. #if defined AGRIF_MPI
  437. !
  438. SELECT CASE (nbdim)
  439. CASE (1)
  440. do i = pttruetab(1),cetruetab(1)
  441. !hildarrayAModifier if (restore%restore1D(i) == 0) &
  442. !hildarrayAModifier child%array1(childarray(i,1,2)) = tempC%array1(i)
  443. enddo
  444. CASE (2)
  445. do i = pttruetab(1),cetruetab(1)
  446. do j = pttruetab(2),cetruetab(2)
  447. !hildarrayAModifier if (restore%restore2D(i,j) == 0) &
  448. !hildarrayAModifier child%array2(childarray(i,1,2), &
  449. !hildarrayAModifier childarray(j,2,2)) = tempC%array2(i,j)
  450. enddo
  451. enddo
  452. CASE (3)
  453. do i = pttruetab(1),cetruetab(1)
  454. do j = pttruetab(2),cetruetab(2)
  455. do k = pttruetab(3),cetruetab(3)
  456. !hildarrayAModifier if (restore%restore3D(i,j,k) == 0) &
  457. !hildarrayAModifier child%array3(childarray(i,1,2), &
  458. !hildarrayAModifier childarray(j,2,2), &
  459. !hildarrayAModifier childarray(k,3,2)) = tempC%array3(i,j,k)
  460. enddo
  461. enddo
  462. enddo
  463. CASE (4)
  464. do i = pttruetab(1),cetruetab(1)
  465. do j = pttruetab(2),cetruetab(2)
  466. do k = pttruetab(3),cetruetab(3)
  467. do l = pttruetab(4),cetruetab(4)
  468. !hildarrayAModifier if (restore%restore4D(i,j,k,l) == 0) &
  469. !hildarrayAModifier child%array4(childarray(i,1,2), &
  470. !hildarrayAModifier childarray(j,2,2), &
  471. !hildarrayAModifier childarray(k,3,2), &
  472. !hildarrayAModifier childarray(l,4,2)) = tempC%array4(i,j,k,l)
  473. enddo
  474. enddo
  475. enddo
  476. enddo
  477. CASE (5)
  478. do i = pttruetab(1),cetruetab(1)
  479. do j = pttruetab(2),cetruetab(2)
  480. do k = pttruetab(3),cetruetab(3)
  481. do l = pttruetab(4),cetruetab(4)
  482. do m = pttruetab(5),cetruetab(5)
  483. !hildarrayAModifier if (restore%restore5D(i,j,k,l,m) == 0) &
  484. !hildarrayAModifier child%array5(childarray(i,1,2), &
  485. !hildarrayAModifier childarray(j,2,2), &
  486. !hildarrayAModifier childarray(k,3,2), &
  487. !hildarrayAModifier childarray(l,4,2), &
  488. !hildarrayAModifier childarray(m,5,2)) = tempC%array5(i,j,k,l,m)
  489. enddo
  490. enddo
  491. enddo
  492. enddo
  493. enddo
  494. CASE (6)
  495. do i = pttruetab(1),cetruetab(1)
  496. do j = pttruetab(2),cetruetab(2)
  497. do k = pttruetab(3),cetruetab(3)
  498. do l = pttruetab(4),cetruetab(4)
  499. do m = pttruetab(5),cetruetab(5)
  500. do n = pttruetab(6),cetruetab(6)
  501. !hildarrayAModifier if (restore%restore6D(i,j,k,l,m,n) == 0) &
  502. !hildarrayAModifier child%array6(childarray(i,1,2), &
  503. !hildarrayAModifier childarray(j,2,2), &
  504. !hildarrayAModifier childarray(k,3,2), &
  505. !hildarrayAModifier childarray(l,4,2), &
  506. !hildarrayAModifier childarray(m,5,2), &
  507. !hildarrayAModifier childarray(n,6,2)) = tempC%array6(i,j,k,l,m,n)
  508. enddo
  509. enddo
  510. enddo
  511. enddo
  512. enddo
  513. enddo
  514. END SELECT
  515. !
  516. #else
  517. select case (nbdim)
  518. case (1)
  519. do i = pttruetab(1),cetruetab(1)
  520. if (restore%restore1D(i) == 0) &
  521. parray1(i) = tempC % array1(i)
  522. enddo
  523. case (2)
  524. do j = pttruetab(2),cetruetab(2)
  525. do i = pttruetab(1),cetruetab(1)
  526. if (restore%restore2D(i,j) == 0) &
  527. parray2(i,j) = tempC % array2(i,j)
  528. enddo
  529. enddo
  530. case (3)
  531. do k = pttruetab(3),cetruetab(3)
  532. do j = pttruetab(2),cetruetab(2)
  533. do i = pttruetab(1),cetruetab(1)
  534. if (restore%restore3D(i,j,k) == 0) &
  535. parray3(i,j,k) = tempC % array3(i,j,k)
  536. enddo
  537. enddo
  538. enddo
  539. case (4)
  540. do l = pttruetab(4),cetruetab(4)
  541. do k = pttruetab(3),cetruetab(3)
  542. do j = pttruetab(2),cetruetab(2)
  543. do i = pttruetab(1),cetruetab(1)
  544. if (restore%restore4D(i,j,k,l) == 0) &
  545. parray4(i,j,k,l) = tempC % array4(i,j,k,l)
  546. enddo
  547. enddo
  548. enddo
  549. enddo
  550. case (5)
  551. do m = pttruetab(5),cetruetab(5)
  552. do l = pttruetab(4),cetruetab(4)
  553. do k = pttruetab(3),cetruetab(3)
  554. do j = pttruetab(2),cetruetab(2)
  555. do i = pttruetab(1),cetruetab(1)
  556. if (restore%restore5D(i,j,k,l,m) == 0) &
  557. parray5(i,j,k,l,m) = tempC % array5(i,j,k,l,m)
  558. enddo
  559. enddo
  560. enddo
  561. enddo
  562. enddo
  563. case (6)
  564. do n = pttruetab(6),cetruetab(6)
  565. do m = pttruetab(5),cetruetab(5)
  566. do l = pttruetab(4),cetruetab(4)
  567. do k = pttruetab(3),cetruetab(3)
  568. do j = pttruetab(2),cetruetab(2)
  569. do i = pttruetab(1),cetruetab(1)
  570. if (restore%restore6D(i,j,k,l,m,n) == 0) &
  571. parray6(i,j,k,l,m,n) = tempC % array6(i,j,k,l,m,n)
  572. enddo
  573. enddo
  574. enddo
  575. enddo
  576. enddo
  577. enddo
  578. end select
  579. !
  580. #endif
  581. !
  582. else ! .not.to_restore
  583. !
  584. if (memberin) then
  585. !
  586. if ( .not.in_bc ) then
  587. select case(nbdim)
  588. case(1)
  589. call procname(tempC % array1( &
  590. childarray(1,1,1):childarray(1,2,1)), &
  591. childarray(1,1,2),childarray(1,2,2),.FALSE.,nb,ndir)
  592. case(2)
  593. call procname( &
  594. tempC % array2( &
  595. childarray(1,1,1):childarray(1,2,1), &
  596. childarray(2,1,1):childarray(2,2,1)), &
  597. childarray(1,1,2),childarray(1,2,2), &
  598. childarray(2,1,2),childarray(2,2,2),.FALSE.,nb,ndir)
  599. case(3)
  600. call procname( &
  601. tempC % array3( &
  602. childarray(1,1,1):childarray(1,2,1), &
  603. childarray(2,1,1):childarray(2,2,1), &
  604. childarray(3,1,1):childarray(3,2,1)), &
  605. childarray(1,1,2),childarray(1,2,2), &
  606. childarray(2,1,2),childarray(2,2,2), &
  607. childarray(3,1,2),childarray(3,2,2),.FALSE.,nb,ndir)
  608. case(4)
  609. call procname( &
  610. tempC % array4( &
  611. childarray(1,1,1):childarray(1,2,1), &
  612. childarray(2,1,1):childarray(2,2,1), &
  613. childarray(3,1,1):childarray(3,2,1), &
  614. childarray(4,1,1):childarray(4,2,1)), &
  615. childarray(1,1,2),childarray(1,2,2), &
  616. childarray(2,1,2),childarray(2,2,2), &
  617. childarray(3,1,2),childarray(3,2,2), &
  618. childarray(4,1,2),childarray(4,2,2),.FALSE.,nb,ndir)
  619. case(5)
  620. call procname( &
  621. tempC % array5( &
  622. childarray(1,1,1):childarray(1,2,1), &
  623. childarray(2,1,1):childarray(2,2,1), &
  624. childarray(3,1,1):childarray(3,2,1), &
  625. childarray(4,1,1):childarray(4,2,1), &
  626. childarray(5,1,1):childarray(5,2,1)), &
  627. childarray(1,1,2),childarray(1,2,2), &
  628. childarray(2,1,2),childarray(2,2,2), &
  629. childarray(3,1,2),childarray(3,2,2), &
  630. childarray(4,1,2),childarray(4,2,2), &
  631. childarray(5,1,2),childarray(5,2,2),.FALSE.,nb,ndir)
  632. case(6)
  633. call procname( &
  634. tempC % array6( &
  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(6,1,1):childarray(6,2,1)), &
  641. childarray(1,1,2),childarray(1,2,2), &
  642. childarray(2,1,2),childarray(2,2,2), &
  643. childarray(3,1,2),childarray(3,2,2), &
  644. childarray(4,1,2),childarray(4,2,2), &
  645. childarray(5,1,2),childarray(5,2,2), &
  646. childarray(6,1,2),childarray(6,2,2),.FALSE.,nb,ndir)
  647. end select
  648. else ! we are in_bc
  649. select case (nbdim)
  650. case (1)
  651. parray1(childarray(1,1,2):childarray(1,2,2)) = &
  652. tempC%array1(childarray(1,1,1):childarray(1,2,1))
  653. case (2)
  654. parray2(childarray(1,1,2):childarray(1,2,2), &
  655. childarray(2,1,2):childarray(2,2,2)) = &
  656. tempC%array2(childarray(1,1,1):childarray(1,2,1), &
  657. childarray(2,1,1):childarray(2,2,1))
  658. case (3)
  659. parray3(childarray(1,1,2):childarray(1,2,2), &
  660. childarray(2,1,2):childarray(2,2,2), &
  661. childarray(3,1,2):childarray(3,2,2)) = &
  662. tempC%array3(childarray(1,1,1):childarray(1,2,1), &
  663. childarray(2,1,1):childarray(2,2,1), &
  664. childarray(3,1,1):childarray(3,2,1))
  665. case (4)
  666. parray4(childarray(1,1,2):childarray(1,2,2), &
  667. childarray(2,1,2):childarray(2,2,2), &
  668. childarray(3,1,2):childarray(3,2,2), &
  669. childarray(4,1,2):childarray(4,2,2)) = &
  670. tempC%array4(childarray(1,1,1):childarray(1,2,1), &
  671. childarray(2,1,1):childarray(2,2,1), &
  672. childarray(3,1,1):childarray(3,2,1), &
  673. childarray(4,1,1):childarray(4,2,1))
  674. case (5)
  675. parray5(childarray(1,1,2):childarray(1,2,2), &
  676. childarray(2,1,2):childarray(2,2,2), &
  677. childarray(3,1,2):childarray(3,2,2), &
  678. childarray(4,1,2):childarray(4,2,2), &
  679. childarray(5,1,2):childarray(5,2,2)) = &
  680. tempC%array5(childarray(1,1,1):childarray(1,2,1), &
  681. childarray(2,1,1):childarray(2,2,1), &
  682. childarray(3,1,1):childarray(3,2,1), &
  683. childarray(4,1,1):childarray(4,2,1), &
  684. childarray(5,1,1):childarray(5,2,1))
  685. case (6)
  686. parray6(childarray(1,1,2):childarray(1,2,2), &
  687. childarray(2,1,2):childarray(2,2,2), &
  688. childarray(3,1,2):childarray(3,2,2), &
  689. childarray(4,1,2):childarray(4,2,2), &
  690. childarray(5,1,2):childarray(5,2,2), &
  691. childarray(6,1,2):childarray(6,2,2)) = &
  692. tempC%array6(childarray(1,1,1):childarray(1,2,1), &
  693. childarray(2,1,1):childarray(2,2,1), &
  694. childarray(3,1,1):childarray(3,2,1), &
  695. childarray(4,1,1):childarray(4,2,1), &
  696. childarray(5,1,1):childarray(5,2,1), &
  697. childarray(6,1,1):childarray(6,2,1))
  698. end select
  699. endif ! < (.not.in_bc)
  700. endif ! < memberin
  701. !
  702. endif
  703. call Agrif_array_deallocate(tempPextend,nbdim)
  704. call Agrif_array_deallocate(tempC,nbdim)
  705. endif
  706. !
  707. ! Deallocations
  708. #if defined AGRIF_MPI
  709. if (member) then
  710. call Agrif_array_deallocate(tempP,nbdim)
  711. endif
  712. #endif
  713. !---------------------------------------------------------------------------------------------------
  714. end subroutine Agrif_InterpnD
  715. !===================================================================================================
  716. !
  717. !===================================================================================================
  718. ! subroutine Agrif_Parentbounds
  719. !
  720. !> Calculates the bounds of the parent grid for the interpolation of the child grid
  721. !---------------------------------------------------------------------------------------------------
  722. subroutine Agrif_Parentbounds ( type_interp, nbdim, indmin, indmax, &
  723. s_Parent_temp, s_Child_temp, &
  724. s_Child, ds_Child, &
  725. s_Parent,ds_Parent, &
  726. pttruetab, cetruetab, &
  727. pttab_Child, pttab_Parent, posvar, coords )
  728. !---------------------------------------------------------------------------------------------------
  729. INTEGER, DIMENSION(6), intent(in) :: type_interp
  730. INTEGER, intent(in) :: nbdim
  731. INTEGER, DIMENSION(nbdim), intent(out) :: indmin, indmax
  732. REAL, DIMENSION(nbdim), intent(out) :: s_Parent_temp, s_child_temp
  733. REAL, DIMENSION(nbdim), intent(in) :: s_Child, ds_child
  734. REAL, DIMENSION(nbdim), intent(in) :: s_Parent,ds_Parent
  735. INTEGER, DIMENSION(nbdim), intent(in) :: pttruetab, cetruetab
  736. INTEGER, DIMENSION(nbdim), intent(in) :: pttab_Child, pttab_Parent
  737. INTEGER, DIMENSION(nbdim), intent(in) :: posvar
  738. INTEGER, DIMENSION(nbdim), intent(in) :: coords
  739. !
  740. INTEGER :: i
  741. REAL,DIMENSION(nbdim) :: dim_newmin, dim_newmax
  742. !
  743. dim_newmin = s_Child + (pttruetab - pttab_Child) * ds_Child
  744. dim_newmax = s_Child + (cetruetab - pttab_Child) * ds_Child
  745. !
  746. do i = 1,nbdim
  747. !
  748. indmin(i) = pttab_Parent(i) + agrif_int((dim_newmin(i)-s_Parent(i))/ds_Parent(i))
  749. indmax(i) = pttab_Parent(i) + agrif_ceiling((dim_newmax(i)-s_Parent(i))/ds_Parent(i))
  750. !
  751. ! Necessary for the Quadratic interpolation
  752. !
  753. if ( (pttruetab(i) == cetruetab(i)) .and. (posvar(i) == 1) ) then
  754. elseif ( coords(i) == 0 ) then ! (interptab == 'N')
  755. elseif ( (type_interp(i) == Agrif_ppm) .or. &
  756. (type_interp(i) == Agrif_eno) .or. &
  757. (type_interp(i) == Agrif_ppm_lim) .or. &
  758. (type_interp(i) == Agrif_weno) ) then
  759. indmin(i) = indmin(i) - 2
  760. indmax(i) = indmax(i) + 2
  761. if (Agrif_UseSpecialValue) then
  762. indmin(i) = indmin(i)-MaxSearch
  763. indmax(i) = indmax(i)+MaxSearch
  764. endif
  765. elseif ( (type_interp(i) /= Agrif_constant) .and. &
  766. (type_interp(i) /= Agrif_linear) ) then
  767. indmin(i) = indmin(i) - 1
  768. indmax(i) = indmax(i) + 1
  769. if (Agrif_UseSpecialValue) then
  770. indmin(i) = indmin(i)-MaxSearch
  771. indmax(i) = indmax(i)+MaxSearch
  772. endif
  773. elseif ( (type_interp(i) == Agrif_constant) .or. &
  774. (type_interp(i) == Agrif_linear) ) then
  775. if (Agrif_UseSpecialValue) then
  776. indmin(i) = indmin(i)-MaxSearch
  777. indmax(i) = indmax(i)+MaxSearch
  778. endif
  779. endif
  780. !
  781. enddo
  782. !
  783. s_Parent_temp = s_Parent + (indmin - pttab_Parent) * ds_Parent
  784. s_Child_temp = s_Child + (pttruetab - pttab_Child) * ds_Child
  785. !---------------------------------------------------------------------------------------------------
  786. end subroutine Agrif_Parentbounds
  787. !===================================================================================================
  788. !
  789. !===================================================================================================
  790. ! subroutine Agrif_Interp_1D_Recursive
  791. !
  792. !> Subroutine for the interpolation of a 1D grid variable.
  793. !> It calls Agrif_InterpBase.
  794. !---------------------------------------------------------------------------------------------------
  795. subroutine Agrif_Interp_1D_recursive ( type_interp, tabin, tabout, &
  796. indmin, indmax, &
  797. pttab_child, petab_child, &
  798. s_child, s_parent, &
  799. ds_child, ds_parent )
  800. !---------------------------------------------------------------------------------------------------
  801. integer, intent(in) :: type_interp
  802. integer, intent(in) :: indmin, indmax
  803. integer, intent(in) :: pttab_child, petab_child
  804. real, intent(in) :: s_child, s_parent
  805. real, intent(in) :: ds_child, ds_parent
  806. real, dimension( &
  807. indmin:indmax &
  808. ), intent(in) :: tabin
  809. real, dimension( &
  810. pttab_child:petab_child &
  811. ), intent(out) :: tabout
  812. !---------------------------------------------------------------------------------------------------
  813. call Agrif_InterpBase(type_interp, &
  814. tabin(indmin:indmax), &
  815. tabout(pttab_child:petab_child), &
  816. indmin, indmax, &
  817. pttab_child, petab_child, &
  818. s_parent, s_child, &
  819. ds_parent, ds_child)
  820. !---------------------------------------------------------------------------------------------------
  821. end subroutine Agrif_Interp_1D_recursive
  822. !===================================================================================================
  823. !
  824. !===================================================================================================
  825. ! subroutine Agrif_Interp_2D_Recursive
  826. !
  827. !> Subroutine for the interpolation of a 2D grid variable.
  828. !> It calls Agrif_Interp_1D_recursive and Agrif_InterpBase.
  829. !---------------------------------------------------------------------------------------------------
  830. subroutine Agrif_Interp_2D_recursive ( type_interp, tabin, tabout, &
  831. indmin, indmax, &
  832. pttab_child, petab_child, &
  833. s_child, s_parent, &
  834. ds_child, ds_parent )
  835. !---------------------------------------------------------------------------------------------------
  836. integer, dimension(2), intent(in) :: type_interp
  837. integer, dimension(2), intent(in) :: indmin, indmax
  838. integer, dimension(2), intent(in) :: pttab_child, petab_child
  839. real, dimension(2), intent(in) :: s_child, s_parent
  840. real, dimension(2), intent(in) :: ds_child, ds_parent
  841. real, dimension( &
  842. indmin(1):indmax(1), &
  843. indmin(2):indmax(2)), intent(in) :: tabin
  844. real, dimension( &
  845. pttab_child(1):petab_child(1), &
  846. pttab_child(2):petab_child(2)), intent(out) :: tabout
  847. !---------------------------------------------------------------------------------------------------
  848. real, dimension( &
  849. pttab_child(1):petab_child(1), &
  850. indmin(2):indmax(2)) :: tabtemp
  851. real, dimension( &
  852. pttab_child(2):petab_child(2), &
  853. pttab_child(1):petab_child(1)) :: tabout_trsp
  854. real, dimension( &
  855. indmin(2):indmax(2), &
  856. pttab_child(1):petab_child(1)) :: tabtemp_trsp
  857. integer :: i, j, coeffraf
  858. !---------------------------------------------------------------------------------------------------
  859. !
  860. coeffraf = nint ( ds_parent(1) / ds_child(1) )
  861. !
  862. if ((type_interp(1) == Agrif_Linear) .and. (coeffraf /= 1)) then
  863. !---CDIR NEXPAND
  864. if(.NOT. precomputedone(1)) &
  865. call Linear1dPrecompute2d( &
  866. indmax(2)-indmin(2)+1, &
  867. indmax(1)-indmin(1)+1, &
  868. petab_child(1)-pttab_child(1)+1, &
  869. s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
  870. !---CDIR NEXPAND
  871. call Linear1dAfterCompute(tabin,tabtemp,size(tabin),size(tabtemp),1)
  872. !
  873. elseif ((type_interp(1) == Agrif_PPM) .and. (coeffraf /= 1)) then
  874. !---CDIR NEXPAND
  875. if(.NOT. precomputedone(1)) &
  876. call PPM1dPrecompute2d( &
  877. indmax(2)-indmin(2)+1, &
  878. indmax(1)-indmin(1)+1, &
  879. petab_child(1)-pttab_child(1)+1, &
  880. s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
  881. !---CDIR NEXPAND
  882. call PPM1dAfterCompute(tabin,tabtemp,size(tabin),size(tabtemp),1)
  883. else
  884. do j = indmin(2),indmax(2)
  885. !
  886. !---CDIR NEXPAND
  887. call Agrif_Interp_1D_recursive(type_interp(1), &
  888. tabin(indmin(1):indmax(1),j), &
  889. tabtemp(pttab_child(1):petab_child(1),j), &
  890. indmin(1),indmax(1), &
  891. pttab_child(1),petab_child(1), &
  892. s_child(1), s_parent(1), &
  893. ds_child(1),ds_parent(1))
  894. !
  895. enddo
  896. endif
  897. coeffraf = nint(ds_parent(2)/ds_child(2))
  898. tabtemp_trsp = TRANSPOSE(tabtemp)
  899. if ((type_interp(2) == Agrif_Linear) .and. (coeffraf /= 1)) then
  900. !---CDIR NEXPAND
  901. if(.NOT. precomputedone(2)) &
  902. call Linear1dPrecompute2d( &
  903. petab_child(1)-pttab_child(1)+1, &
  904. indmax(2)-indmin(2)+1, &
  905. petab_child(2)-pttab_child(2)+1, &
  906. s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
  907. !---CDIR NEXPAND
  908. call Linear1dAfterCompute(tabtemp_trsp,tabout_trsp, &
  909. size(tabtemp_trsp),size(tabout_trsp),2)
  910. elseif ((type_interp(2) == Agrif_PPM) .and. (coeffraf /= 1)) then
  911. !---CDIR NEXPAND
  912. if(.NOT. precomputedone(2)) &
  913. call PPM1dPrecompute2d( &
  914. petab_child(1)-pttab_child(1)+1, &
  915. indmax(2)-indmin(2)+1, &
  916. petab_child(2)-pttab_child(2)+1, &
  917. s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
  918. !---CDIR NEXPAND
  919. call PPM1dAfterCompute(tabtemp_trsp, tabout_trsp, &
  920. size(tabtemp_trsp), size(tabout_trsp), 2)
  921. else
  922. do i = pttab_child(1), petab_child(1)
  923. !
  924. !---CDIR NEXPAND
  925. call Agrif_InterpBase(type_interp(2), &
  926. tabtemp_trsp(indmin(2):indmax(2), i), &
  927. tabout_trsp(pttab_child(2):petab_child(2), i), &
  928. indmin(2), indmax(2), &
  929. pttab_child(2), petab_child(2), &
  930. s_parent(2), s_child(2), &
  931. ds_parent(2), ds_child(2) )
  932. enddo
  933. endif
  934. !
  935. tabout = TRANSPOSE(tabout_trsp)
  936. !---------------------------------------------------------------------------------------------------
  937. end subroutine Agrif_Interp_2D_recursive
  938. !===================================================================================================
  939. !
  940. !===================================================================================================
  941. ! subroutine Agrif_Interp_3D_Recursive
  942. !
  943. !> Subroutine for the interpolation of a 3D grid variable.
  944. !> It calls #Agrif_Interp_2D_recursive and #Agrif_InterpBase.
  945. !---------------------------------------------------------------------------------------------------
  946. subroutine Agrif_Interp_3D_recursive ( type_interp, tabin, tabout, &
  947. indmin, indmax, &
  948. pttab_child, petab_child, &
  949. s_child, s_parent, &
  950. ds_child, ds_parent )
  951. !---------------------------------------------------------------------------------------------------
  952. integer, dimension(3), intent(in) :: type_interp
  953. integer, dimension(3), intent(in) :: indmin, indmax
  954. integer, dimension(3), intent(in) :: pttab_child, petab_child
  955. real, dimension(3), intent(in) :: s_child, s_parent
  956. real, dimension(3), intent(in) :: ds_child, ds_parent
  957. real, dimension( &
  958. indmin(1):indmax(1), &
  959. indmin(2):indmax(2), &
  960. indmin(3):indmax(3)), intent(in) :: tabin
  961. real, dimension( &
  962. pttab_child(1):petab_child(1), &
  963. pttab_child(2):petab_child(2), &
  964. pttab_child(3):petab_child(3)), intent(out) :: tabout
  965. !---------------------------------------------------------------------------------------------------
  966. real, dimension( &
  967. pttab_child(1):petab_child(1), &
  968. pttab_child(2):petab_child(2), &
  969. indmin(3):indmax(3)) :: tabtemp
  970. integer :: i, j, k, coeffraf
  971. integer :: locind_child_left, kdeb
  972. !
  973. coeffraf = nint ( ds_parent(1) / ds_child(1) )
  974. if ( (type_interp(1) == Agrif_Linear) .and. (coeffraf/=1) ) then
  975. call Linear1dPrecompute2d(indmax(2)-indmin(2)+1, &
  976. indmax(1)-indmin(1)+1, &
  977. petab_child(1)-pttab_child(1)+1, &
  978. s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
  979. precomputedone(1) = .TRUE.
  980. elseif ( (type_interp(1) == Agrif_PPM) .and. (coeffraf/=1) ) then
  981. call PPM1dPrecompute2d(indmax(2)-indmin(2)+1, &
  982. indmax(1)-indmin(1)+1, &
  983. petab_child(1)-pttab_child(1)+1, &
  984. s_parent(1),s_child(1),ds_parent(1),ds_child(1),1)
  985. precomputedone(1) = .TRUE.
  986. endif
  987. coeffraf = nint ( ds_parent(2) / ds_child(2) )
  988. if ( (type_interp(2) == Agrif_Linear) .and. (coeffraf/=1) ) then
  989. call Linear1dPrecompute2d(petab_child(1)-pttab_child(1)+1, &
  990. indmax(2)-indmin(2)+1, &
  991. petab_child(2)-pttab_child(2)+1, &
  992. s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
  993. precomputedone(2) = .TRUE.
  994. elseif ( (type_interp(2) == Agrif_PPM) .and. (coeffraf/=1) ) then
  995. call PPM1dPrecompute2d(petab_child(1)-pttab_child(1)+1, &
  996. indmax(2)-indmin(2)+1, &
  997. petab_child(2)-pttab_child(2)+1, &
  998. s_parent(2),s_child(2),ds_parent(2),ds_child(2),2)
  999. precomputedone(2) = .TRUE.
  1000. endif
  1001. !
  1002. do k = indmin(3), indmax(3)
  1003. call Agrif_Interp_2D_recursive(type_interp(1:2), &
  1004. tabin(indmin(1):indmax(1), &
  1005. indmin(2):indmax(2), k), &
  1006. tabtemp(pttab_child(1):petab_child(1), &
  1007. pttab_child(2):petab_child(2), k), &
  1008. indmin(1:2), indmax(1:2), &
  1009. pttab_child(1:2), petab_child(1:2), &
  1010. s_child(1:2), s_parent(1:2), &
  1011. ds_child(1:2), ds_parent(1:2) )
  1012. enddo
  1013. !
  1014. precomputedone(1) = .FALSE.
  1015. precomputedone(2) = .FALSE.
  1016. coeffraf = nint(ds_parent(3)/ds_child(3))
  1017. !
  1018. if ( coeffraf == 1 ) then
  1019. locind_child_left = 1 + agrif_int((s_child(3)-s_parent(3))/ds_parent(3))
  1020. kdeb = indmin(3)+locind_child_left-2
  1021. do k = pttab_child(3),petab_child(3)
  1022. kdeb = kdeb + 1
  1023. do j = pttab_child(2), petab_child(2)
  1024. do i = pttab_child(1), petab_child(1)
  1025. tabout(i,j,k) = tabtemp(i,j,kdeb)
  1026. enddo
  1027. enddo
  1028. enddo
  1029. else
  1030. do j = pttab_child(2), petab_child(2)
  1031. do i = pttab_child(1), petab_child(1)
  1032. call Agrif_InterpBase(type_interp(3), &
  1033. tabtemp(i,j,indmin(3):indmax(3)), &
  1034. tabout(i,j,pttab_child(3):petab_child(3)), &
  1035. indmin(3), indmax(3), &
  1036. pttab_child(3), petab_child(3), &
  1037. s_parent(3), s_child(3), &
  1038. ds_parent(3), ds_child(3) )
  1039. enddo
  1040. enddo
  1041. endif
  1042. !---------------------------------------------------------------------------------------------------
  1043. end subroutine Agrif_Interp_3D_recursive
  1044. !===================================================================================================
  1045. !
  1046. !===================================================================================================
  1047. ! subroutine Agrif_Interp_4D_Recursive
  1048. !
  1049. !> Subroutine for the interpolation of a 4D grid variable.
  1050. !> It calls #Agrif_Interp_3D_recursive and #Agrif_InterpBase.
  1051. !---------------------------------------------------------------------------------------------------
  1052. subroutine Agrif_Interp_4D_recursive ( type_interp, tabin, tabout, &
  1053. indmin, indmax, &
  1054. pttab_child, petab_child, &
  1055. s_child, s_parent, &
  1056. ds_child, ds_parent )
  1057. !---------------------------------------------------------------------------------------------------
  1058. integer, dimension(4), intent(in) :: type_interp
  1059. integer, dimension(4), intent(in) :: indmin, indmax
  1060. integer, dimension(4), intent(in) :: pttab_child, petab_child
  1061. real, dimension(4), intent(in) :: s_child, s_parent
  1062. real, dimension(4), intent(in) :: ds_child, ds_parent
  1063. real, dimension( &
  1064. indmin(1):indmax(1), &
  1065. indmin(2):indmax(2), &
  1066. indmin(3):indmax(3), &
  1067. indmin(4):indmax(4)), intent(in) :: tabin
  1068. real, dimension( &
  1069. pttab_child(1):petab_child(1), &
  1070. pttab_child(2):petab_child(2), &
  1071. pttab_child(3):petab_child(3), &
  1072. pttab_child(4):petab_child(4)), intent(out) :: tabout
  1073. !---------------------------------------------------------------------------------------------------
  1074. real, dimension( &
  1075. pttab_child(1):petab_child(1), &
  1076. pttab_child(2):petab_child(2), &
  1077. pttab_child(3):petab_child(3), &
  1078. indmin(4):indmax(4)) :: tabtemp
  1079. integer :: i, j, k, l
  1080. !
  1081. do l = indmin(4), indmax(4)
  1082. call Agrif_Interp_3D_recursive(type_interp(1:3), &
  1083. tabin(indmin(1):indmax(1), &
  1084. indmin(2):indmax(2), &
  1085. indmin(3):indmax(3), l), &
  1086. tabtemp(pttab_child(1):petab_child(1), &
  1087. pttab_child(2):petab_child(2), &
  1088. pttab_child(3):petab_child(3), l), &
  1089. indmin(1:3), indmax(1:3), &
  1090. pttab_child(1:3), petab_child(1:3), &
  1091. s_child(1:3), s_parent(1:3), &
  1092. ds_child(1:3), ds_parent(1:3) )
  1093. enddo
  1094. !
  1095. do k = pttab_child(3), petab_child(3)
  1096. do j = pttab_child(2), petab_child(2)
  1097. do i = pttab_child(1), petab_child(1)
  1098. call Agrif_InterpBase(type_interp(4), &
  1099. tabtemp(i,j,k,indmin(4):indmax(4)), &
  1100. tabout(i,j,k,pttab_child(4):petab_child(4)), &
  1101. indmin(4), indmax(4), &
  1102. pttab_child(4), petab_child(4), &
  1103. s_parent(4), s_child(4), &
  1104. ds_parent(4), ds_child(4) )
  1105. enddo
  1106. enddo
  1107. enddo
  1108. !---------------------------------------------------------------------------------------------------
  1109. end subroutine Agrif_Interp_4D_recursive
  1110. !===================================================================================================
  1111. !
  1112. !===================================================================================================
  1113. ! subroutine Agrif_Interp_5D_Recursive
  1114. !
  1115. !> Subroutine for the interpolation of a 5D grid variable.
  1116. !> It calls #Agrif_Interp_4D_recursive and #Agrif_InterpBase.
  1117. !---------------------------------------------------------------------------------------------------
  1118. subroutine Agrif_Interp_5D_recursive ( type_interp, tabin, tabout, &
  1119. indmin, indmax, &
  1120. pttab_child, petab_child, &
  1121. s_child, s_parent, &
  1122. ds_child, ds_parent )
  1123. !---------------------------------------------------------------------------------------------------
  1124. integer, dimension(5), intent(in) :: type_interp
  1125. integer, dimension(5), intent(in) :: indmin, indmax
  1126. integer, dimension(5), intent(in) :: pttab_child, petab_child
  1127. real, dimension(5), intent(in) :: s_child, s_parent
  1128. real, dimension(5), intent(in) :: ds_child, ds_parent
  1129. real, dimension( &
  1130. indmin(1):indmax(1), &
  1131. indmin(2):indmax(2), &
  1132. indmin(3):indmax(3), &
  1133. indmin(4):indmax(4), &
  1134. indmin(5):indmax(5)), intent(in) :: tabin
  1135. real, dimension( &
  1136. pttab_child(1):petab_child(1), &
  1137. pttab_child(2):petab_child(2), &
  1138. pttab_child(3):petab_child(3), &
  1139. pttab_child(4):petab_child(4), &
  1140. pttab_child(5):petab_child(5)), intent(out) :: tabout
  1141. !---------------------------------------------------------------------------------------------------
  1142. real, dimension( &
  1143. pttab_child(1):petab_child(1), &
  1144. pttab_child(2):petab_child(2), &
  1145. pttab_child(3):petab_child(3), &
  1146. pttab_child(4):petab_child(4), &
  1147. indmin(5):indmax(5)) :: tabtemp
  1148. integer :: i, j, k, l, m
  1149. !
  1150. do m = indmin(5), indmax(5)
  1151. call Agrif_Interp_4D_recursive(type_interp(1:4), &
  1152. tabin(indmin(1):indmax(1), &
  1153. indmin(2):indmax(2), &
  1154. indmin(3):indmax(3), &
  1155. indmin(4):indmax(4),m), &
  1156. tabtemp(pttab_child(1):petab_child(1), &
  1157. pttab_child(2):petab_child(2), &
  1158. pttab_child(3):petab_child(3), &
  1159. pttab_child(4):petab_child(4), m), &
  1160. indmin(1:4),indmax(1:4), &
  1161. pttab_child(1:4), petab_child(1:4), &
  1162. s_child(1:4), s_parent(1:4), &
  1163. ds_child(1:4), ds_parent(1:4) )
  1164. enddo
  1165. !
  1166. do l = pttab_child(4), petab_child(4)
  1167. do k = pttab_child(3), petab_child(3)
  1168. do j = pttab_child(2), petab_child(2)
  1169. do i = pttab_child(1), petab_child(1)
  1170. call Agrif_InterpBase(type_interp(5), &
  1171. tabtemp(i,j,k,l,indmin(5):indmax(5)), &
  1172. tabout(i,j,k,l,pttab_child(5):petab_child(5)), &
  1173. indmin(5), indmax(5), &
  1174. pttab_child(5), petab_child(5), &
  1175. s_parent(5), s_child(5), &
  1176. ds_parent(5), ds_child(5) )
  1177. enddo
  1178. enddo
  1179. enddo
  1180. enddo
  1181. !---------------------------------------------------------------------------------------------------
  1182. end subroutine Agrif_Interp_5D_recursive
  1183. !===================================================================================================
  1184. !
  1185. !===================================================================================================
  1186. ! subroutine Agrif_Interp_6D_Recursive
  1187. !
  1188. !> Subroutine for the interpolation of a 6D grid variable.
  1189. !> It calls #Agrif_Interp_5D_recursive and Agrif_InterpBase.
  1190. !---------------------------------------------------------------------------------------------------
  1191. subroutine Agrif_Interp_6D_recursive ( type_interp, tabin, tabout, &
  1192. indmin, indmax, &
  1193. pttab_child, petab_child, &
  1194. s_child, s_parent, &
  1195. ds_child, ds_parent )
  1196. !---------------------------------------------------------------------------------------------------
  1197. integer, dimension(6), intent(in) :: type_interp
  1198. integer, dimension(6), intent(in) :: indmin, indmax
  1199. integer, dimension(6), intent(in) :: pttab_child, petab_child
  1200. real, dimension(6), intent(in) :: s_child, s_parent
  1201. real, dimension(6), intent(in) :: ds_child, ds_parent
  1202. real, dimension( &
  1203. indmin(1):indmax(1), &
  1204. indmin(2):indmax(2), &
  1205. indmin(3):indmax(3), &
  1206. indmin(4):indmax(4), &
  1207. indmin(5):indmax(5), &
  1208. indmin(6):indmax(6)), intent(in) :: tabin
  1209. real, dimension( &
  1210. pttab_child(1):petab_child(1), &
  1211. pttab_child(2):petab_child(2), &
  1212. pttab_child(3):petab_child(3), &
  1213. pttab_child(4):petab_child(4), &
  1214. pttab_child(5):petab_child(5), &
  1215. pttab_child(6):petab_child(6)), intent(out) :: tabout
  1216. !---------------------------------------------------------------------------------------------------
  1217. real, dimension( &
  1218. pttab_child(1):petab_child(1), &
  1219. pttab_child(2):petab_child(2), &
  1220. pttab_child(3):petab_child(3), &
  1221. pttab_child(4):petab_child(4), &
  1222. pttab_child(5):petab_child(5), &
  1223. indmin(6):indmax(6)) :: tabtemp
  1224. integer :: i, j, k, l, m, n
  1225. !
  1226. do n = indmin(6), indmax(6)
  1227. call Agrif_Interp_5D_recursive(type_interp(1:5), &
  1228. tabin(indmin(1):indmax(1), &
  1229. indmin(2):indmax(2), &
  1230. indmin(3):indmax(3), &
  1231. indmin(4):indmax(4), &
  1232. indmin(5):indmax(5), n), &
  1233. tabtemp(pttab_child(1):petab_child(1), &
  1234. pttab_child(2):petab_child(2), &
  1235. pttab_child(3):petab_child(3), &
  1236. pttab_child(4):petab_child(4), &
  1237. pttab_child(5):petab_child(5), n), &
  1238. indmin(1:5),indmax(1:5), &
  1239. pttab_child(1:5), petab_child(1:5), &
  1240. s_child(1:5), s_parent(1:5), &
  1241. ds_child(1:5),ds_parent(1:5) )
  1242. enddo
  1243. !
  1244. do m = pttab_child(5), petab_child(5)
  1245. do l = pttab_child(4), petab_child(4)
  1246. do k = pttab_child(3), petab_child(3)
  1247. do j = pttab_child(2), petab_child(2)
  1248. do i = pttab_child(1), petab_child(1)
  1249. call Agrif_InterpBase(type_interp(6), &
  1250. tabtemp(i,j,k,l,m,indmin(6):indmax(6)), &
  1251. tabout(i,j,k,l,m,pttab_child(6):petab_child(6)), &
  1252. indmin(6), indmax(6), &
  1253. pttab_child(6), petab_child(6), &
  1254. s_parent(6), s_child(6), &
  1255. ds_parent(6), ds_child(6) )
  1256. enddo
  1257. enddo
  1258. enddo
  1259. enddo
  1260. enddo
  1261. !---------------------------------------------------------------------------------------------------
  1262. end subroutine Agrif_Interp_6D_recursive
  1263. !===================================================================================================
  1264. !
  1265. !===================================================================================================
  1266. ! subroutine Agrif_InterpBase
  1267. !
  1268. !> Calls the interpolation method chosen by the user (linear, lagrange, spline, etc.).
  1269. !---------------------------------------------------------------------------------------------------
  1270. subroutine Agrif_InterpBase ( type_interp, parenttab, childtab, indmin, indmax, &
  1271. pttab_child, petab_child, &
  1272. s_parent, s_child, ds_parent, ds_child )
  1273. !---------------------------------------------------------------------------------------------------
  1274. INTEGER :: type_interp
  1275. INTEGER :: indmin, indmax
  1276. INTEGER :: pttab_child, petab_child
  1277. REAL, DIMENSION(indmin:indmax), INTENT(IN) :: parenttab
  1278. REAL, DIMENSION(pttab_child:petab_child), INTENT(OUT) :: childtab
  1279. REAL :: s_parent, s_child
  1280. REAL :: ds_parent,ds_child
  1281. !
  1282. if ( (indmin == indmax) .and. (pttab_child == petab_child) ) then
  1283. !
  1284. childtab(pttab_child) = parenttab(indmin)
  1285. !
  1286. elseif (type_interp == Agrif_LINEAR) then ! Linear interpolation
  1287. !
  1288. call Agrif_basicinterp_linear1D(parenttab,childtab, &
  1289. indmax-indmin+1,petab_child-pttab_child+1, &
  1290. s_parent,s_child,ds_parent,ds_child)
  1291. !
  1292. elseif ( type_interp == Agrif_PPM ) then ! PPM interpolation
  1293. call PPM1d(parenttab,childtab, &
  1294. indmax-indmin+1,petab_child-pttab_child+1, &
  1295. s_parent,s_child,ds_parent,ds_child)
  1296. !
  1297. elseif ( type_interp == Agrif_PPM_LIM ) then ! PPM interpolation
  1298. call PPM1d_lim(parenttab,childtab, &
  1299. indmax-indmin+1,petab_child-pttab_child+1, &
  1300. s_parent,s_child,ds_parent,ds_child)
  1301. !
  1302. elseif (type_interp == Agrif_LAGRANGE) then ! Lagrange interpolation
  1303. !
  1304. call lagrange1D(parenttab,childtab, &
  1305. indmax-indmin+1,petab_child-pttab_child+1, &
  1306. s_parent,s_child,ds_parent,ds_child)
  1307. !
  1308. elseif (type_interp == Agrif_ENO) then ! Eno interpolation
  1309. !
  1310. call ENO1d(parenttab,childtab, &
  1311. indmax-indmin+1,petab_child-pttab_child+1, &
  1312. s_parent,s_child,ds_parent,ds_child)
  1313. !
  1314. elseif (type_interp == Agrif_WENO) then ! Weno interpolation
  1315. !
  1316. call WENO1d(parenttab,childtab, &
  1317. indmax-indmin+1,petab_child-pttab_child+1, &
  1318. s_parent,s_child,ds_parent,ds_child)
  1319. !
  1320. elseif (type_interp == Agrif_LINEARCONSERV) then ! Linear conservative interpolation
  1321. !
  1322. call Linear1dConserv(parenttab,childtab, &
  1323. indmax-indmin+1,petab_child-pttab_child+1, &
  1324. s_parent,s_child,ds_parent,ds_child)
  1325. !
  1326. elseif (type_interp == Agrif_LINEARCONSERVLIM) then !Linear conservative interpolation
  1327. !
  1328. call Linear1dConservLim(parenttab,childtab, &
  1329. indmax-indmin+1,petab_child-pttab_child+1, &
  1330. s_parent,s_child,ds_parent,ds_child)
  1331. !
  1332. elseif (type_interp == Agrif_CONSTANT) then
  1333. !
  1334. call Constant1d(parenttab,childtab, &
  1335. indmax-indmin+1,petab_child-pttab_child+1, &
  1336. s_parent,s_child,ds_parent,ds_child)
  1337. !
  1338. endif
  1339. !---------------------------------------------------------------------------------------------------
  1340. end subroutine Agrif_InterpBase
  1341. !===================================================================================================
  1342. !
  1343. !===================================================================================================
  1344. ! subroutine Agrif_Find_list_interp
  1345. !---------------------------------------------------------------------------------------------------
  1346. function Agrif_Find_list_interp ( list_interp, pttab, petab, pttab_Child, pttab_Parent, &
  1347. nbdim, indmin, indmax, indminglob, indmaxglob, &
  1348. pttruetab, cetruetab, memberin &
  1349. #if defined AGRIF_MPI
  1350. ,indminglob2, indmaxglob2, parentarray, &
  1351. member, tab4t, memberinall, sendtoproc1, recvfromproc1 &
  1352. #endif
  1353. ) result(find_list_interp)
  1354. !---------------------------------------------------------------------------------------------------
  1355. type(Agrif_List_Interp_Loc), pointer :: list_interp
  1356. integer, intent(in) :: nbdim
  1357. integer, dimension(nbdim), intent(in) :: pttab, petab, pttab_Child, pttab_Parent
  1358. integer, dimension(nbdim), intent(out) :: indmin, indmax
  1359. integer, dimension(nbdim), intent(out) :: indminglob, indmaxglob
  1360. integer, dimension(nbdim), intent(out) :: pttruetab, cetruetab
  1361. logical, intent(out) :: memberin
  1362. #if defined AGRIF_MPI
  1363. integer, dimension(nbdim), intent(out) :: indminglob2, indmaxglob2
  1364. integer, dimension(nbdim,2,2), intent(out) :: parentarray
  1365. logical, intent(out) :: member
  1366. integer, dimension(nbdim,0:Agrif_Nbprocs-1,8), intent(out) :: tab4t
  1367. logical, dimension(0:Agrif_Nbprocs-1), intent(out) :: memberinall
  1368. logical, dimension(0:Agrif_Nbprocs-1), intent(out) :: sendtoproc1, recvfromproc1
  1369. #endif
  1370. logical :: find_list_interp
  1371. !
  1372. integer :: i
  1373. type(Agrif_List_Interp_Loc), pointer :: parcours
  1374. type(Agrif_Interp_Loc), pointer :: pil
  1375. find_list_interp = .false.
  1376. if ( .not. associated(list_interp) ) return
  1377. parcours => list_interp
  1378. find_loop : do while ( associated(parcours) )
  1379. pil => parcours % interp_loc
  1380. do i = 1,nbdim
  1381. if ( (pttab(i) /= pil % pttab(i)) .or. &
  1382. (petab(i) /= pil % petab(i)) .or. &
  1383. (pttab_child(i) /= pil % pttab_child(i)) .or. &
  1384. (pttab_parent(i) /= pil % pttab_parent(i)) ) then
  1385. parcours => parcours % suiv
  1386. cycle find_loop
  1387. endif
  1388. enddo
  1389. indmin = pil % indmin(1:nbdim)
  1390. indmax = pil % indmax(1:nbdim)
  1391. pttruetab = pil % pttruetab(1:nbdim)
  1392. cetruetab = pil % cetruetab(1:nbdim)
  1393. #if !defined AGRIF_MPI
  1394. indminglob = pil % indminglob(1:nbdim)
  1395. indmaxglob = pil % indmaxglob(1:nbdim)
  1396. #else
  1397. indminglob = pil % indminglob2(1:nbdim)
  1398. indmaxglob = pil % indmaxglob2(1:nbdim)
  1399. indminglob2 = pil % indminglob2(1:nbdim)
  1400. indmaxglob2 = pil % indmaxglob2(1:nbdim)
  1401. parentarray = pil % parentarray(1:nbdim,:,:)
  1402. member = pil % member
  1403. tab4t = pil % tab4t(1:nbdim, 0:Agrif_Nbprocs-1, 1:8)
  1404. memberinall = pil % memberinall(0:Agrif_Nbprocs-1)
  1405. sendtoproc1 = pil % sendtoproc1(0:Agrif_Nbprocs-1)
  1406. recvfromproc1 = pil % recvfromproc1(0:Agrif_Nbprocs-1)
  1407. #endif
  1408. memberin = pil % memberin
  1409. find_list_interp = .true.
  1410. exit find_loop
  1411. enddo find_loop
  1412. !---------------------------------------------------------------------------------------------------
  1413. end function Agrif_Find_list_interp
  1414. !===================================================================================================
  1415. !
  1416. !===================================================================================================
  1417. ! subroutine Agrif_AddTo_list_interp
  1418. !---------------------------------------------------------------------------------------------------
  1419. subroutine Agrif_AddTo_list_interp ( list_interp, pttab, petab, pttab_Child, pttab_Parent, &
  1420. indmin, indmax, indminglob, indmaxglob, &
  1421. pttruetab, cetruetab, &
  1422. memberin, nbdim &
  1423. #if defined AGRIF_MPI
  1424. ,indminglob2, indmaxglob2, &
  1425. parentarray, &
  1426. member, &
  1427. tab4t, memberinall, sendtoproc1, recvfromproc1 &
  1428. #endif
  1429. )
  1430. !---------------------------------------------------------------------------------------------------
  1431. type(Agrif_List_Interp_Loc), pointer :: list_interp
  1432. integer :: nbdim
  1433. integer, dimension(nbdim) :: pttab, petab, pttab_Child, pttab_Parent
  1434. integer, dimension(nbdim) :: indmin,indmax
  1435. integer, dimension(nbdim) :: indminglob, indmaxglob
  1436. integer, dimension(nbdim) :: pttruetab, cetruetab
  1437. logical :: memberin
  1438. #if defined AGRIF_MPI
  1439. integer, dimension(nbdim,2,2) :: parentarray
  1440. logical :: member
  1441. integer, dimension(nbdim) :: indminglob2,indmaxglob2
  1442. integer, dimension(nbdim,0:Agrif_Nbprocs-1,8) :: tab4t
  1443. logical, dimension(0:Agrif_Nbprocs-1) :: memberinall
  1444. logical, dimension(0:Agrif_Nbprocs-1) :: sendtoproc1
  1445. logical, dimension(0:Agrif_Nbprocs-1) :: recvfromproc1
  1446. #endif
  1447. !
  1448. type(Agrif_List_Interp_Loc), pointer :: parcours
  1449. type(Agrif_Interp_Loc), pointer :: pil
  1450. !
  1451. allocate(parcours)
  1452. allocate(parcours % interp_loc)
  1453. pil => parcours % interp_loc
  1454. pil % pttab(1:nbdim) = pttab(1:nbdim)
  1455. pil % petab(1:nbdim) = petab(1:nbdim)
  1456. pil % pttab_child(1:nbdim) = pttab_child(1:nbdim)
  1457. pil % pttab_parent(1:nbdim) = pttab_parent(1:nbdim)
  1458. pil % indmin(1:nbdim) = indmin(1:nbdim)
  1459. pil % indmax(1:nbdim) = indmax(1:nbdim)
  1460. pil % memberin = memberin
  1461. #if !defined AGRIF_MPI
  1462. pil % indminglob(1:nbdim) = indminglob(1:nbdim)
  1463. pil % indmaxglob(1:nbdim) = indmaxglob(1:nbdim)
  1464. #else
  1465. pil % indminglob2(1:nbdim) = indminglob2(1:nbdim)
  1466. pil % indmaxglob2(1:nbdim) = indmaxglob2(1:nbdim)
  1467. pil % parentarray(1:nbdim,:,:) = parentarray(1:nbdim,:,:)
  1468. pil % member = member
  1469. allocate(pil % tab4t(nbdim, 0:Agrif_Nbprocs-1, 8))
  1470. allocate(pil % memberinall(0:Agrif_Nbprocs-1))
  1471. allocate(pil % sendtoproc1(0:Agrif_Nbprocs-1))
  1472. allocate(pil % recvfromproc1(0:Agrif_Nbprocs-1))
  1473. pil % tab4t = tab4t
  1474. pil % memberinall = memberinall
  1475. pil % sendtoproc1 = sendtoproc1
  1476. pil % recvfromproc1 = recvfromproc1
  1477. #endif
  1478. pil % pttruetab(1:nbdim) = pttruetab(1:nbdim)
  1479. pil % cetruetab(1:nbdim) = cetruetab(1:nbdim)
  1480. parcours % suiv => list_interp
  1481. list_interp => parcours
  1482. !---------------------------------------------------------------------------------------------------
  1483. end subroutine Agrif_Addto_list_interp
  1484. !===================================================================================================
  1485. !
  1486. end module Agrif_Interpolation