Fortran 90 from SunSoft


Forte Fortran & High Performance Computing (HPC), formerly "Sun Performance WorkShop Fortran", is the first in a family of products targeted at the developer building applications for the high performance computing market. New features are a Fortran 95 compiler, and a math library optimized for the SPARC(R) platform. It also includes support for Interval Arithmetic.

Fortran 90 on Solaris

System parameters on Solaris

The system parameters on Solaris, using the SunSoft Fortran 90 compiler are given here. Compare the corresponding table for NAG, Digital or Cray.

Sun, Digital, and Cray use the number of bytes as the KIND-parameter. SunSoft permits the values 1, 4, and 8 for logical variables (with the same result as for the default value 4), the values 1, 2, and 4 for integers, the values 4 and 8 for floating point values, and also the values 4 and 8 for complex values. The names int7, int15, and int31 are mine.

LOGICAL              Default      byte      word     double
  KIND number =            4         1         4          8

INTEGER                   int7          int15         int31
 KIND number =               1              2             4
      digits =               7             15            31
       radix =               2              2             2
       range =               2              4             9
        huge =             127          32767    2147483647
    bit_size =               8             16            32

REAL                      single          double
  KIND number =                4               8
       digits =               24              53
  maxexponent =              128            1024
  minexponent =             -125           -1021
    precision =                6              15
        radix =                2               2
        range =               37             307
      epsilon =   0.11920929E-06  0.22204460E-15
         tiny =   0.11754944E-37  0.22250739-307
         huge =   0.34028235E+39  0.17976931+309

COMPLEX                  single           double
  KIND number =               4                8
    precision =               6               15
        range =              37              307

Compilation on Solaris

You can get the compiler switches with the command f90 -flags or man f90. I here reproduce the most important of these.
-ansi:         Report non-ANSI extensions
-C:            Index check
-c:            Suppress linking, produce .o files
-e:            Recognize extended (132 character) source lines
-fast:         Specify common set of performance options
-fixed:        Interpret all Fortran source files according to 
	       fixed form rules
-flags:        Print summary of compiler options
-fnonstd:      Non-standard initialization of floating-point 
-fns:          Turn on non-standard floating point mode
-free:         Interpret all Fortran source files according 
               to free form rules
-fround:       Select the appropriate IEEE rounding mode
-g:            Generate debugging information used by dbx
-help:         Print summary of compiler options
-IX:           Passed to the linker to add X to the search path
               for include files
-LX:           Passed to the linker to add X to the library 
               search path
-lX:           Read object library (for ld)
-MX:           Add directory X to module search path
-o file:       Set name of output file
-O:            Generate optimized code
-onetrip:      Perform DO loops at least once
-p:            Prepare object code to collect data for 
               profiling with prof
-pg:           Prepare object code to collect data for 
               profiling with gprof
-qp:           Same as -p

	Produce file of type (may also be spelled -qproduce)

-Qproduce .f90:     .f90  (f90 source, Free Form)
-Qproduce .f:       .f    (f90 source, Fixed Form)
-Qproduce .lst:     .lst  (f90 listing)
-Qproduce .o:       .o    (Object file)
-Qproduce .s:       .s    (Assembler source)

-r8const:      Changes single precision constants into
               double precision constants
-S:            Product .s file only (do not assemble or link)
-s:            Strip the executable
-time:         Report the execution time for each component
-u:            Implies IMPLICIT NONE
-V:            Show version number of each invoked component
-v:            Verbose mode
-w:            Suppress compiler warning messages
-xtypemap:     Choice of precision for integers and floating point 
The following suffices may be used.
Suffix 'a':    Object library
Suffix 'il':   Inline expansion file
Suffix 'o':    Object file
Suffix 'so':   Shared object
Suffix 's':    Assembler source
Suffix 'S':    Assembler source for cpp
Suffix 'for':  f90 source (Fixed Form)
Suffix 'ftn':  f90 source (Fixed Form)
Suffix 'f':    f90 source (Fixed Form)
Suffix 'F':    not currently recognized
Suffix 'f90':  f90 source (Free Form)
Suffix 'lst':  f90 listing

Some examples on Solaris

We have some examples for Digital Unix, which have now been run also on the Sun Solaris system. Is is the rounding error program EPSILON and a summation example.

On Digital there are some simple commands to the compiler to switch precision. On Sun the command is -xtypemap, and the following combinations are permitted:

-xtypemap=real:32,double:64                       Default
-xtypemap=real:64,double:64                       Both the same
-xtypemap=real:64,double:128                      Both doubled
Also the integers can be chosen as integer:32 or integer:64. Please note that only variables specified with REAL :: VAR are affected, not those specified with REAL (KIND=any) :: VAR, and correspondingly for integers. It is not possible to use real:128 or double:32.

We first look at the program EPSILON or KAHAN. In order to obtain the desired precision we use SELECTED_REAL_KIND.

Script started on Wed Jun 06 12:48:40 2001 on Solaris 8.

water[~]> cat kahan2.f90
            PROGRAM KAHAN2
!           This program is intentionally incorrect
!           if not compiled with the Sun option "-r8const"
            IMPLICIT NONE
            REAL (KIND=DP) :: A, B, C, D, E

            A = 1.0/3.0
            B = 4.0*A - 1.0
            C = 3.0*B - 1.0
            D = 0.5*C

            E = ABS(D)

            WRITE(*,*) ' my = ', E

            END PROGRAM KAHAN2
If this program is compiled in the usual way the result will correspond to single precision, if it is compiled with -r8const the result will correspond to double precision.
water[~]> f95 kahan2.f90
water[~]> ./a.out

  my =  5.960464477539062E-8          ! Single precision result
water[~]> f95 -r8const kahan2.f90
water[~]> ./a.out
  my =  1.1102230246251565E-16        ! Double precision result
We now switch to quad precision. Here there is nothing corresponding to -r8const or -r16const, so all floating point constants have to be specified explicitly to be of the correct precision. In the example below it is however sufficient to do this with the one third assigned to A, since the other constants are all exact in binary arithmetic.
water[~]> cat kahan4.f90
            PROGRAM KAHAN4
            IMPLICIT NONE
            REAL (KIND=QP) :: A, B, C, D, E

            A = 1.0_QP/3.0_QP
            B = 4.0_QP*A - 1.0_QP
            C = 3.0_QP*B - 1.0_QP
            D = 0.5_QP*C

            E = ABS(D)

            WRITE(*,*) ' my = ', E

            END PROGRAM KAHAN4
water[~]> f95 kahan4.f90
water[~]> ./a.out
  my =  9.629649721936179265279889712924637E-35
! Quad precision result
water[~]> exit
This result is correct, we may note that 33 is the maximum permitted number of significant digits on this system.

The summation program SUMMATION works with only a a minor difference compared with on the Digital system, it prints two additional digits for the highest precision. The values are correct.

Back to Appendix 6 (of the English version)
Back to Appendix 7 (of the Swedish version)

Last modified: 7 June 2001