Using Tools > Working with User Code > Fortran User Interface Reference > Specifying the Precision of Floating-Point Variables in Fortran

Your Ad Here




Specifying the Precision of Floating-Point Variables in Fortran

STAR-CCM+ simulations may be run in single- or double-precision. This defines whether generic floating-point variables are real or double precision, in Fortran terms. Coordinates, such as centroid positions, are always double-precision. The implication of this for user functions is that floating-point arguments exchanged with STAR-CCM+ must be declared with the correct precision. The convention used in this documentation for Fortran 90 is that generic floating-point variables are declared real(StarReal) and strictly double-precision variables are declared real(CoordReal). These two types are defined in the module StarRealMod in StarReal.f which should be created in the same directory as the user functions. For single-precision, for example:

      module StarRealMod
        integer, parameter :: StarInt = kind(1)
        integer, parameter :: StarReal = kind(1.0)
        integer, parameter :: CoordReal = kind(1D0)
        integer, parameter :: StarIntSize = StarInt
        integer, parameter :: StarRealSize = StarReal
        integer, parameter :: CoordRealSize = CoordReal
      end module StarRealMod

Fortran 77 is less convenient in this regard than Fortran 90. The only solutions in standard Fortran 77 are to declare all CoordReal variables as double precision and use implicit typing for StarReal variables, or else to declare the type of all variables explicitly. For the first of these, the precision of StarReal variables can then be specified by including StarReal.inc which should be created in the same directory as the user functions. For single-precision, for example:

      implicit real(a-h,o-z)
      integer StarIntSize, StarRealSize, CoordRealSize
      parameter (StarIntSize = 4)
      parameter (StarRealSize = 4)
      parameter (CoordRealSize = 8)

Return to CD-adapco STAR-CCM+ Index


Your Ad Here