parray_iwp.F90.in 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. !
  2. ! PArray
  3. !
  4. !
  5. ! Template for PArray routines with integer arguments.
  6. !
  7. ! To generate kind specific versions, use:
  8. !
  9. ! sed -e 's/<wp>/1/g' parray_iwp.f90 > parray_i1.f90
  10. ! sed -e 's/<wp>/2/g' parray_iwp.f90 > parray_i2.f90
  11. ! sed -e 's/<wp>/4/g' parray_iwp.f90 > parray_i4.f90
  12. ! sed -e 's/<wp>/8/g' parray_iwp.f90 > parray_i8.f90
  13. !
  14. module PArray_i<wp>
  15. implicit none
  16. ! --- in/out -------------------------
  17. private
  18. public :: pa_Init, pa_Done, pa_SetShape, pa_SetCopy
  19. ! --- interfaces ---------------------------
  20. interface pa_Init
  21. module procedure pa_Init_i<wp>_1d
  22. module procedure pa_Init_i<wp>_2d
  23. module procedure pa_Init_i<wp>_3d
  24. module procedure pa_Init_i<wp>_4d
  25. module procedure pa_Init_i<wp>_5d
  26. module procedure pa_Init_i<wp>_6d
  27. module procedure pa_Init_i<wp>_7d
  28. end interface
  29. interface pa_Done
  30. module procedure pa_Done_i<wp>_1d
  31. module procedure pa_Done_i<wp>_2d
  32. module procedure pa_Done_i<wp>_3d
  33. module procedure pa_Done_i<wp>_4d
  34. module procedure pa_Done_i<wp>_5d
  35. module procedure pa_Done_i<wp>_6d
  36. module procedure pa_Done_i<wp>_7d
  37. end interface
  38. interface pa_SetShape
  39. module procedure pa_SetShape_i<wp>_1d_shp
  40. module procedure pa_SetShape_i<wp>_1d_n
  41. module procedure pa_SetShape_i<wp>_2d_shp
  42. module procedure pa_SetShape_i<wp>_2d_n
  43. module procedure pa_SetShape_i<wp>_3d_shp
  44. module procedure pa_SetShape_i<wp>_3d_n
  45. module procedure pa_SetShape_i<wp>_4d_shp
  46. module procedure pa_SetShape_i<wp>_4d_n
  47. module procedure pa_SetShape_i<wp>_5d_shp
  48. module procedure pa_SetShape_i<wp>_5d_n
  49. module procedure pa_SetShape_i<wp>_6d_shp
  50. module procedure pa_SetShape_i<wp>_6d_n
  51. module procedure pa_SetShape_i<wp>_7d_shp
  52. module procedure pa_SetShape_i<wp>_7d_n
  53. end interface
  54. interface pa_SetCopy
  55. module procedure pa_SetCopy_i<wp>_1d
  56. module procedure pa_SetCopy_i<wp>_2d
  57. module procedure pa_SetCopy_i<wp>_3d
  58. module procedure pa_SetCopy_i<wp>_4d
  59. module procedure pa_SetCopy_i<wp>_5d
  60. module procedure pa_SetCopy_i<wp>_6d
  61. module procedure pa_SetCopy_i<wp>_7d
  62. end interface
  63. contains
  64. ! =========================================================
  65. ! ===
  66. ! === integer(<wp>)
  67. ! ===
  68. ! =========================================================
  69. ! *******************************************
  70. ! ***
  71. ! *** integer(<wp>) 1D
  72. ! ***
  73. ! *******************************************
  74. subroutine pa_Init_i<wp>_1d( x )
  75. ! --- in/out ---------------------------
  76. integer(<wp>), pointer :: x(:)
  77. ! --- begin ---------------------------
  78. nullify( x )
  79. end subroutine pa_Init_i<wp>_1d
  80. ! ***
  81. subroutine pa_Done_i<wp>_1d( x )
  82. ! --- in/out ---------------------------
  83. integer(<wp>), pointer :: x(:)
  84. ! --- begin ---------------------------
  85. if ( associated(x) ) deallocate( x )
  86. end subroutine pa_Done_i<wp>_1d
  87. ! ***
  88. subroutine pa_SetShape_i<wp>_1d_shp( x, n )
  89. ! --- in/out ---------------------------
  90. integer(<wp>), pointer :: x(:)
  91. integer, intent(in) :: n(1)
  92. ! --- begin ---------------------------
  93. if ( associated(x) ) then
  94. if ( any( shape(x) /= n ) ) deallocate( x )
  95. end if
  96. if ( .not. associated(x) ) allocate( x(n(1)) )
  97. end subroutine pa_SetShape_i<wp>_1d_shp
  98. ! ***
  99. subroutine pa_SetShape_i<wp>_1d_n( x, n1 )
  100. ! --- in/out ---------------------------
  101. integer(<wp>), pointer :: x(:)
  102. integer, intent(in) :: n1
  103. ! --- begin ---------------------------
  104. if ( associated(x) ) then
  105. if ( size(x) /= n1 ) deallocate( x )
  106. end if
  107. if ( .not. associated(x) ) allocate( x(n1) )
  108. end subroutine pa_SetShape_i<wp>_1d_n
  109. ! ***
  110. subroutine pa_SetCopy_i<wp>_1d( x, y )
  111. ! --- in/out ---------------------------
  112. integer(<wp>), pointer :: x(:)
  113. integer(<wp>), intent(in) :: y(:)
  114. ! --- begin ---------------------------
  115. call pa_SetShape( x, shape(y) )
  116. x = y
  117. end subroutine pa_SetCopy_i<wp>_1d
  118. ! *******************************************
  119. ! ***
  120. ! *** integer(<wp>) 2D
  121. ! ***
  122. ! *******************************************
  123. subroutine pa_Init_i<wp>_2d( x )
  124. ! --- in/out ---------------------------
  125. integer(<wp>), pointer :: x(:,:)
  126. ! --- begin ---------------------------
  127. nullify( x )
  128. end subroutine pa_Init_i<wp>_2d
  129. ! ***
  130. subroutine pa_Done_i<wp>_2d( x )
  131. ! --- in/out ---------------------------
  132. integer(<wp>), pointer :: x(:,:)
  133. ! --- begin ---------------------------
  134. if ( associated(x) ) deallocate( x )
  135. end subroutine pa_Done_i<wp>_2d
  136. ! ***
  137. subroutine pa_SetShape_i<wp>_2d_shp( x, n )
  138. ! --- in/out ---------------------------
  139. integer(<wp>), pointer :: x(:,:)
  140. integer, intent(in) :: n(2)
  141. ! --- begin ---------------------------
  142. if ( associated(x) ) then
  143. if ( any( shape(x) /= n ) ) deallocate( x )
  144. end if
  145. if ( .not. associated(x) ) allocate( x(n(1),n(2)) )
  146. end subroutine pa_SetShape_i<wp>_2d_shp
  147. ! ***
  148. subroutine pa_SetShape_i<wp>_2d_n( x, n1, n2 )
  149. ! --- in/out ---------------------------
  150. integer(<wp>), pointer :: x(:,:)
  151. integer, intent(in) :: n1, n2
  152. ! --- begin ---------------------------
  153. call pa_SetShape( x, (/n1,n2/) )
  154. end subroutine pa_SetShape_i<wp>_2d_n
  155. ! ***
  156. subroutine pa_SetCopy_i<wp>_2d( x, y )
  157. ! --- in/out ---------------------------
  158. integer(<wp>), pointer :: x(:,:)
  159. integer(<wp>), intent(in) :: y(:,:)
  160. ! --- begin ---------------------------
  161. call pa_SetShape( x, shape(y) )
  162. x = y
  163. end subroutine pa_SetCopy_i<wp>_2d
  164. ! *******************************************
  165. ! ***
  166. ! *** integer(<wp>) 3D
  167. ! ***
  168. ! *******************************************
  169. subroutine pa_Init_i<wp>_3d( x )
  170. ! --- in/out ---------------------------
  171. integer(<wp>), pointer :: x(:,:,:)
  172. ! --- begin ---------------------------
  173. nullify( x )
  174. end subroutine pa_Init_i<wp>_3d
  175. ! ***
  176. subroutine pa_Done_i<wp>_3d( x )
  177. ! --- in/out ---------------------------
  178. integer(<wp>), pointer :: x(:,:,:)
  179. ! --- begin ---------------------------
  180. if ( associated(x) ) deallocate( x )
  181. end subroutine pa_Done_i<wp>_3d
  182. ! ***
  183. subroutine pa_SetShape_i<wp>_3d_shp( x, n )
  184. ! --- in/out ---------------------------
  185. integer(<wp>), pointer :: x(:,:,:)
  186. integer, intent(in) :: n(3)
  187. ! --- begin ---------------------------
  188. if ( associated(x) ) then
  189. if ( any( shape(x) /= n ) ) deallocate( x )
  190. end if
  191. if ( .not. associated(x) ) allocate( x(n(1),n(2),n(3)) )
  192. end subroutine pa_SetShape_i<wp>_3d_shp
  193. ! ***
  194. subroutine pa_SetShape_i<wp>_3d_n( x, n1, n2, n3 )
  195. ! --- in/out ---------------------------
  196. integer(<wp>), pointer :: x(:,:,:)
  197. integer, intent(in) :: n1, n2, n3
  198. ! --- begin ---------------------------
  199. call pa_SetShape( x, (/n1,n2,n3/) )
  200. end subroutine pa_SetShape_i<wp>_3d_n
  201. ! ***
  202. subroutine pa_SetCopy_i<wp>_3d( x, y )
  203. ! --- in/out ---------------------------
  204. integer(<wp>), pointer :: x(:,:,:)
  205. integer(<wp>), intent(in) :: y(:,:,:)
  206. ! --- begin ---------------------------
  207. call pa_SetShape( x, shape(y) )
  208. x = y
  209. end subroutine pa_SetCopy_i<wp>_3d
  210. ! *******************************************
  211. ! ***
  212. ! *** integer(<wp>) 4D
  213. ! ***
  214. ! *******************************************
  215. subroutine pa_Init_i<wp>_4d( x )
  216. ! --- in/out ---------------------------
  217. integer(<wp>), pointer :: x(:,:,:,:)
  218. ! --- begin ---------------------------
  219. nullify( x )
  220. end subroutine pa_Init_i<wp>_4d
  221. ! ***
  222. subroutine pa_Done_i<wp>_4d( x )
  223. ! --- in/out ---------------------------
  224. integer(<wp>), pointer :: x(:,:,:,:)
  225. ! --- begin ---------------------------
  226. if ( associated(x) ) deallocate( x )
  227. end subroutine pa_Done_i<wp>_4d
  228. ! ***
  229. subroutine pa_SetShape_i<wp>_4d_shp( x, n )
  230. ! --- in/out ---------------------------
  231. integer(<wp>), pointer :: x(:,:,:,:)
  232. integer, intent(in) :: n(4)
  233. ! --- begin ---------------------------
  234. if ( associated(x) ) then
  235. if ( any( shape(x) /= n ) ) deallocate( x )
  236. end if
  237. if ( .not. associated(x) ) allocate( x(n(1),n(2),n(3),n(4)) )
  238. end subroutine pa_SetShape_i<wp>_4d_shp
  239. ! ***
  240. subroutine pa_SetShape_i<wp>_4d_n( x, n1, n2, n3, n4 )
  241. ! --- in/out ---------------------------
  242. integer(<wp>), pointer :: x(:,:,:,:)
  243. integer, intent(in) :: n1, n2, n3, n4
  244. ! --- begin ---------------------------
  245. call pa_SetShape( x, (/n1,n2,n3,n4/) )
  246. end subroutine pa_SetShape_i<wp>_4d_n
  247. ! ***
  248. subroutine pa_SetCopy_i<wp>_4d( x, y )
  249. ! --- in/out ---------------------------
  250. integer(<wp>), pointer :: x(:,:,:,:)
  251. integer(<wp>), intent(in) :: y(:,:,:,:)
  252. ! --- begin ---------------------------
  253. call pa_SetShape( x, shape(y) )
  254. x = y
  255. end subroutine pa_SetCopy_i<wp>_4d
  256. ! *******************************************
  257. ! ***
  258. ! *** integer(<wp>) 5D
  259. ! ***
  260. ! *******************************************
  261. subroutine pa_Init_i<wp>_5d( x )
  262. ! --- in/out ---------------------------
  263. integer(<wp>), pointer :: x(:,:,:,:,:)
  264. ! --- begin ---------------------------
  265. nullify( x )
  266. end subroutine pa_Init_i<wp>_5d
  267. ! ***
  268. subroutine pa_Done_i<wp>_5d( x )
  269. ! --- in/out ---------------------------
  270. integer(<wp>), pointer :: x(:,:,:,:,:)
  271. ! --- begin ---------------------------
  272. if ( associated(x) ) deallocate( x )
  273. end subroutine pa_Done_i<wp>_5d
  274. ! ***
  275. subroutine pa_SetShape_i<wp>_5d_shp( x, n )
  276. ! --- in/out ---------------------------
  277. integer(<wp>), pointer :: x(:,:,:,:,:)
  278. integer, intent(in) :: n(5)
  279. ! --- begin ---------------------------
  280. if ( associated(x) ) then
  281. if ( any( shape(x) /= n ) ) deallocate( x )
  282. end if
  283. if ( .not. associated(x) ) allocate( x(n(1),n(2),n(3),n(4),n(5)) )
  284. end subroutine pa_SetShape_i<wp>_5d_shp
  285. ! ***
  286. subroutine pa_SetShape_i<wp>_5d_n( x, n1, n2, n3, n4, n5 )
  287. ! --- in/out ---------------------------
  288. integer(<wp>), pointer :: x(:,:,:,:,:)
  289. integer, intent(in) :: n1, n2, n3, n4, n5
  290. ! --- begin ---------------------------
  291. call pa_SetShape( x, (/n1,n2,n3,n4,n5/) )
  292. end subroutine pa_SetShape_i<wp>_5d_n
  293. ! ***
  294. subroutine pa_SetCopy_i<wp>_5d( x, y )
  295. ! --- in/out ---------------------------
  296. integer(<wp>), pointer :: x(:,:,:,:,:)
  297. integer(<wp>), intent(in) :: y(:,:,:,:,:)
  298. ! --- begin ---------------------------
  299. call pa_SetShape( x, shape(y) )
  300. x = y
  301. end subroutine pa_SetCopy_i<wp>_5d
  302. ! *******************************************
  303. ! ***
  304. ! *** integer(<wp>) 6D
  305. ! ***
  306. ! *******************************************
  307. subroutine pa_Init_i<wp>_6d( x )
  308. ! --- in/out ---------------------------
  309. integer(<wp>), pointer :: x(:,:,:,:,:,:)
  310. ! --- begin ---------------------------
  311. nullify( x )
  312. end subroutine pa_Init_i<wp>_6d
  313. ! ***
  314. subroutine pa_Done_i<wp>_6d( x )
  315. ! --- in/out ---------------------------
  316. integer(<wp>), pointer :: x(:,:,:,:,:,:)
  317. ! --- begin ---------------------------
  318. if ( associated(x) ) deallocate( x )
  319. end subroutine pa_Done_i<wp>_6d
  320. ! ***
  321. subroutine pa_SetShape_i<wp>_6d_shp( x, n )
  322. ! --- in/out ---------------------------
  323. integer(<wp>), pointer :: x(:,:,:,:,:,:)
  324. integer, intent(in) :: n(6)
  325. ! --- begin ---------------------------
  326. if ( associated(x) ) then
  327. if ( any( shape(x) /= n ) ) deallocate( x )
  328. end if
  329. if ( .not. associated(x) ) allocate( x(n(1),n(2),n(3),n(4),n(5),n(6)) )
  330. end subroutine pa_SetShape_i<wp>_6d_shp
  331. ! ***
  332. subroutine pa_SetShape_i<wp>_6d_n( x, n1, n2, n3, n4, n5, n6 )
  333. ! --- in/out ---------------------------
  334. integer(<wp>), pointer :: x(:,:,:,:,:,:)
  335. integer, intent(in) :: n1, n2, n3, n4, n5, n6
  336. ! --- begin ---------------------------
  337. call pa_SetShape( x, (/n1,n2,n3,n4,n5,n6/) )
  338. end subroutine pa_SetShape_i<wp>_6d_n
  339. ! ***
  340. subroutine pa_SetCopy_i<wp>_6d( x, y )
  341. ! --- in/out ---------------------------
  342. integer(<wp>), pointer :: x(:,:,:,:,:,:)
  343. integer(<wp>), intent(in) :: y(:,:,:,:,:,:)
  344. ! --- begin ---------------------------
  345. call pa_SetShape( x, shape(y) )
  346. x = y
  347. end subroutine pa_SetCopy_i<wp>_6d
  348. ! *******************************************
  349. ! ***
  350. ! *** integer(<wp>) 7D
  351. ! ***
  352. ! *******************************************
  353. subroutine pa_Init_i<wp>_7d( x )
  354. ! --- in/out ---------------------------
  355. integer(<wp>), pointer :: x(:,:,:,:,:,:,:)
  356. ! --- begin ---------------------------
  357. nullify( x )
  358. end subroutine pa_Init_i<wp>_7d
  359. ! ***
  360. subroutine pa_Done_i<wp>_7d( x )
  361. ! --- in/out ---------------------------
  362. integer(<wp>), pointer :: x(:,:,:,:,:,:,:)
  363. ! --- begin ---------------------------
  364. if ( associated(x) ) deallocate( x )
  365. end subroutine pa_Done_i<wp>_7d
  366. ! ***
  367. subroutine pa_SetShape_i<wp>_7d_shp( x, n )
  368. ! --- in/out ---------------------------
  369. integer(<wp>), pointer :: x(:,:,:,:,:,:,:)
  370. integer, intent(in) :: n(7)
  371. ! --- begin ---------------------------
  372. if ( associated(x) ) then
  373. if ( any( shape(x) /= n ) ) deallocate( x )
  374. end if
  375. if ( .not. associated(x) ) allocate( x(n(1),n(2),n(3),n(4),n(5),n(6),n(7)) )
  376. end subroutine pa_SetShape_i<wp>_7d_shp
  377. ! ***
  378. subroutine pa_SetShape_i<wp>_7d_n( x, n1, n2, n3, n4, n5, n6, n7 )
  379. ! --- in/out ---------------------------
  380. integer(<wp>), pointer :: x(:,:,:,:,:,:,:)
  381. integer, intent(in) :: n1, n2, n3, n4, n5, n6, n7
  382. ! --- begin ---------------------------
  383. call pa_SetShape( x, (/n1,n2,n3,n4,n5,n6,n7/) )
  384. end subroutine pa_SetShape_i<wp>_7d_n
  385. ! ***
  386. subroutine pa_SetCopy_i<wp>_7d( x, y )
  387. ! --- in/out ---------------------------
  388. integer(<wp>), pointer :: x(:,:,:,:,:,:,:)
  389. integer(<wp>), intent(in) :: y(:,:,:,:,:,:,:)
  390. ! --- begin ---------------------------
  391. call pa_SetShape( x, shape(y) )
  392. x = y
  393. end subroutine pa_SetCopy_i<wp>_7d
  394. end module PArray_i<wp>