7.2 Type m4 Macros

The ``type'' set of m4 macros allows intrinsic F90 types to be defined in a manner similar to defined types, making use of the kind parameter to ensure consistency and allow for double and single precision versions of the code. The type macros allow the following constructions to be used in the CÆSAR Code Package:

type(real) :: realvar1
type(real,0) :: realvar2
type(real,3) :: realvar3
type(integer,1), intent(out) :: intvar1
type(integer,4,np) :: intvar2
type(logical,1,np) :: logvar
type(character,8) :: charvar1
type(character,*,2,np) :: charvar2
type(defined) :: defvar

intvar = changetype(integer, variable)
realvar = changetype(real, variable)

This code is expanded by Gnu m4 into the following valid F90 code:

real (kind=KIND(1.0d0)) :: realvar1
real (kind=KIND(1.0d0)) :: realvar2
real (kind=KIND(1.0d0)), pointer, dimension(:,:,:) :: realvar3
integer (kind=KIND(1)), pointer, dimension(:), intent(out) :: intvar1
integer (kind=KIND(1)), dimension(:,:,:,:) :: intvar2
logical (kind=KIND(.true.)), dimension(:) :: logvar
character (len=8) :: charvar1
character (len=*), dimension(:,:) :: charvar2
type(defined) :: defvar

intvar = INT(variable, KIND(1))
realvar = REAL(variable, KIND(1.0d0))

Note that this set of m4 macros depends on the m4 commands in the settings.m4 file and on the SINGLE and UNICOS macro definitions.

m4 macros defined in the include/types.m4 file:

 changetype  Used for intrinsic type conversions.
 pnt$dim  Private macro used in type.
 real$kind  Private macro used in type and changetype.
 type  Used for intrinsic type definition. (see code listing for input/output details).

The Type m4 Macros code listing contains additional documentation.

Michael L. Hall