parray.F90 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. !
  2. !ProTeX: 1.14-AJS
  3. !
  4. !BOI
  5. !
  6. ! !TITLE: PArray - Pointer Array tools
  7. ! !AUTHORS: Arjo Segers, Gijs van Soest
  8. ! !AFFILIATION: KNMI
  9. ! !DATE: \today
  10. !
  11. ! !INTRODUCTION: Description
  12. !
  13. ! Module to facilitate allocation and deallocation of pointer arrays.
  14. !
  15. ! Use the module by:
  16. ! \bv
  17. ! use PArray, only : ...
  18. ! \ev
  19. ! First define a pointer array of some type and rank:
  20. ! \bv
  21. ! <type>, pointer :: x(:,:,...)
  22. ! \ev
  23. ! Yet supported:
  24. ! \bv
  25. ! types : integer(1), integer(2), integer(4), integer(8)
  26. ! real(4), real(8)
  27. ! complex(4), complex(8)
  28. ! logical
  29. ! character(len=<n>) ! <-- <n> should be a constant !
  30. !
  31. ! ranks : 1 - 7
  32. ! \ev
  33. ! Initialize with '\texttt{pa\_Init}', which in fact only nullifies the pointer:
  34. ! \bv
  35. ! call pa_Init( x )
  36. ! \ev
  37. ! Allocate memory for 'x' using one of the following calls:
  38. ! \bv
  39. ! ! define the shape with an integer array:
  40. ! call pa_SetShape( x, (/2,3,4/) )
  41. !
  42. ! ! define the shape with a series of integer arguments:
  43. ! call pa_SetShape( x, 2, 3, 4 )
  44. !
  45. ! ! make 'x' a copy of an array 'y' with the same shape and contents;
  46. ! ! 'x' and 'y' should have the same rank:
  47. ! call pa_SetCopy( x, y )
  48. ! \ev
  49. ! Finally, deallocate the memory using the '\texttt{pa\_Done}' routine:
  50. ! \bv
  51. ! call pa_Done( x )
  52. ! \ev
  53. !
  54. !
  55. ! !INTRODUCTION: Source files
  56. !
  57. ! The parray module consists of a main and a number of sub modules
  58. ! for different types and kinds.
  59. ! Each type has its own sub module; for types with multiple kinds,
  60. ! sub modules are generated from a template for each individual kind.
  61. ! \bv
  62. ! configure : script to create source files from template
  63. ! and Makefile
  64. !
  65. ! parray.f90.in : template for main module
  66. !
  67. ! parray_iwp.f90.in : template for integer type
  68. ! parray_rwp.f90.in : template for real type
  69. ! parray_cwp.f90.in : template for complex type
  70. ! parray_l.f90 : sub module for logical type
  71. ! parray_s.f90 : sub module for character string type
  72. ! \ev
  73. !
  74. !
  75. ! !INTRODUCTION: History
  76. !
  77. ! See CVS log.
  78. !
  79. !EOI
  80. !
  81. module PArray
  82. use parray_i1
  83. use parray_i2
  84. use parray_i4
  85. use parray_i8
  86. use parray_r4
  87. use parray_r8
  88. use parray_c4
  89. use parray_c8
  90. use parray_l
  91. use parray_s
  92. implicit none
  93. ! --- in/out -------------------------
  94. private
  95. public :: pa_Init, pa_Done, pa_SetShape, pa_SetCopy
  96. end module PArray