| SimCon Home | Ref Manual Home |

Parameter and Data Specifications

Parameter Specifications

The real and complex values in parameter specifications must be converted to values of the corresponding emulation derived types. The simple Fortran 90 parameter definition:

! One parameter REAL(KIND=4),PARAMETER :: pi4_a = 3.14159265358979

Is converted, for emulation derived types with a second, attribute, component to:

! One parameter TYPE (em_real_k4),PARAMETER :: pi4_a = em_real_k4( & 3.14159265358979,1)

Multiple parameters may be written in one statement, for example:

! Two in one statement REAL*4,PARAMETER :: pi4_b = 3.14159265358979, pi4_c = 3.14159265358979

This is converted to:

! Two in one statement TYPE (em_real_k4),PARAMETER :: pi4_b = em_real_k4( & 3.14159265358979,2),pi4_c = em_real_k4(3.14159265358979,3)

Expressions may occur in the parameter specifications:

! An expression REAL*8,PARAMETER :: pi8_a = 3.14159265358979_8, pi8_b = 4*ATAN(1.0D0)

This becomes:

! An expression TYPE (em_real_k8),PARAMETER :: pi8_a = em_real_k8( & 3.14159265358979_8,4),pi8_b = em_real_k8(4*ATAN(1.0D0),5)

Parameters may occur in the parameter definitions:

! An expression involving two parameters REAL(KIND=8),PARAMETER :: dpi = pi8_a-pi8_b

In these cases, the  value  components of the existing parameters must be extracted:

! An expression involving two parameters TYPE (em_real_k8),PARAMETER :: dpi = em_real_k8(DBLE(pi8_a% & value-pi8_b%value),6)

The parameters may be specified in  PARAMETER  statements. Conversion of these is complicated by the presence of parameters of different data types and kinds in one statement:

! A FORTRAN 77 style specification with intervening integers REAL*4 pi4_d REAL*8 pi8_c INTEGER*4 i4_a,i4_b PARAMETER (pi4_d=3.14159265358979,i4_a=22/7,pi8_c=3.14159265358979D0,i4_b=3)

This is converted to:

! A FORTRAN 77 style specification with intervening integers TYPE (em_real_k4)pi4_d TYPE (em_real_k8)pi8_c INTEGER*4 i4_a,i4_b PARAMETER (pi4_d = em_real_k4(3.14159265358979,7),i4_a = 22/7, & pi8_c = em_real_k8(3.14159265358979D0,8),i4_b = 3)

And, lastly, FORTRAN IV  PARAMETER  statements, where the type and kind of the parameter is taken from that of the parameter value. These are still supported by some current compilers:

! A FORTRAN IV style specification (Supported by VMS and CVF) PARAMETER pi4_e=3.14159265358979E0,i4_c=3,pi8_d=3.14159265358979D0

In this case the parameters need to be declared as well as converted:

TYPE (em_real_k4)pi4_e INTEGER*4 i4_c TYPE (em_real_k8)pi8_d ! A FORTRAN IV style specification (Supported by VMS and CVF) PARAMETER (pi4_e = em_real_k4(3.14159265358979E0,9),i4_c = 3, & pi8_d = em_real_k8(3.14159265358979D0,10))

 

Data Specifications

Data initialisations may be written within declarations, for example:

! Simple initialisation cases REAL(KIND=4) :: x0 = 0.0 REAL*4 x1 /1.0/ REAL(KIND=4) :: x2 = 2.0, X5 = 5.0 REAL*4 x3 /3.0/, X4 /4.0/

In all cases, the literal values must be converted to objects of the corresponding emulation derived types:

! Simple initialisation cases TYPE (em_real_k4) :: x0 = em_real_k4(0.0,9) TYPE (em_real_k4)x1/em_real_k4(1.0,10)/ TYPE (em_real_k4) :: x2 = em_real_k4(2.0,11),x5 = em_real_k4( & 5.0,12) TYPE (em_real_k4)x3/em_real_k4(3.0,13)/,x4/em_real_k4(4.0,14)/

The object initialised may be an array:

! Initialisation of an array REAL*4 :: xa(3) = (/5.1,5.2,5.3/)

This is converted:

! Initialisation of an array TYPE (em_real_k4) :: xa(3) = (/em_real_k4(5.1,16),em_real_k4( & 5.2,17),em_real_k4(5.3,18)/)

The object initialised may be a component of a derived type, for example:

! Derived type to test initialistion TYPE labeled_real REAL*4 :: number CHARACTER*32 :: label END TYPE labeled_real : : ! Test of derived type initialisation TYPE (labeled_real) :: w1 = labeled_real(4.0,"w1")

The literal value for the  number  component must be converted:

! Derived type to test initialistion TYPE labeled_real TYPE (em_real_k4) :: number CHARACTER*32 :: label END TYPE labeled_real : : ! Test of derived type initialisation TYPE (labeled_real) :: w1 = labeled_real(em_real_k4(4.0,15), & "w1")

DATA statements suffer the same complication as  PARAMETER  statements in that objects of different data types may occur in one statement. The statements:

REAL(4) :: xb(3),xc(3) INTEGER(4) :: m(1:2) : : DATA xb,m,xc /3*20.0,1,2,21.1,21.2,21.3/

are converted to:

TYPE (em_real_k4) :: xb(3),xc(3) INTEGER(4) :: m(1:2) : : DATA xb,m,xc/3*em_real_k4(20.0,19),1,2,em_real_k4(21.1,20), & em_real_k4(21.2,21),em_real_k4(21.3,22)/

 

Copyright ©1995 to 2018 Software Validation Ltd. All rights reserved.