parray_cwp.F90.in 15 KB

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