The derived types used in emulation each contain a single component of the corresponding native type. This allows variables of the types to be referenced in Fortran EQUIVALENCE statements or COMMON blocks in the same way as the original variables. It also allows them to be referenced in I/O statements (READ, WRITE, PRINT etc.) without any modification of the executable code.
The code for the derived types is written in an include file included in the Fortran module module_emulate_real_arithmetic. It is shown below.
! ***************************************************************************** ! em_types.i90 7-Sep-15 John Collins ! ***************************************************************************** ! Note that all types are sequence derived types so that the variables ! can be in COMMON ! TYPE em_real_k4 SEQUENCE REAL(KIND=kr4) value END TYPE em_real_k4 ! TYPE em_real_k8 SEQUENCE REAL(KIND=kr8) value END TYPE em_real_k8 ! TYPE em_complex_k4 SEQUENCE COMPLEX(KIND=kr4) value END TYPE em_complex_k4 ! TYPE em_complex_k8 SEQUENCE COMPLEX(KIND=kr8) value END TYPE em_complex_k8 ! PUBLIC em_real_k4 PUBLIC em_real_k8 PUBLIC em_complex_k4 PUBLIC em_complex_k8 ! End of em_types.i90 *********************************************************