next_inactive up previous


PArray - Pointer Array tools

ARJO SEGERS, GIJS VAN SOEST
KNMI


Date: 3 March 2009


Contents

Description

Module to facilitate allocation and deallocation of pointer arrays.

Use the module by:

    use PArray, only : ...
First define a pointer array of some type and rank:
    <type>, pointer      ::  x(:,:,...)
Yet supported:
    types   : integer(1), integer(2), integer(4), integer(8)
              real(4), real(8)
              complex(4), complex(8)
              logical
              character(len=<n>)     ! <-- <n> should be a constant !
              
    ranks   : 1 - 7
Initialize with 'pa_Init', which in fact only nullifies the pointer:
    call pa_Init( x )
Allocate memory for 'x' using one of the following calls:
    ! define the shape with an integer array:
    call pa_SetShape( x, (/2,3,4/) )
 
    ! define the shape with a series of integer arguments:
    call pa_SetShape( x, 2, 3, 4 )
 
    ! make 'x' a copy of an array 'y' with the same shape and contents;
    ! 'x' and 'y' should have the same rank:
    call pa_SetCopy( x, y )
Finally, deallocate the memory using the 'pa_Done' routine:
    call pa_Done( x )

Source files

The parray module consists of a main and a number of sub modules for different types and kinds. Each type has its own sub module; for types with multiple kinds, sub modules are generated from a template for each individual kind.

     configure             : script to create source files from template
                             and Makefile

     parray.f90.in         : template for main module

     parray_iwp.f90.in     : template for integer type
     parray_rwp.f90.in     : template for real    type
     parray_cwp.f90.in     : template for complex type
     parray_l.f90          : sub module for logical type
     parray_s.f90          : sub module for character string type

History

See CVS log.





TM5 2009-03-03