NAGware Fortran 95 compiler

Introduction:

    

        The Numerical Algorithms Group Ltd

        Wilkinson House

        Jordan Hill Road

        Oxford OX2 8DR

        infodesk@nag.co.uk      Tel: +44 1865 511245

                                Fax: +44 1865 310139

NAG offers a Fortran 95 system which behaves as a compiler but in reality translates to C (except for the PC version). The compiler is now in version 4.0 for both UNIX and MS-DOS. Both work well and include extended error checking both under compilation and execution. For early experiences please see the article "A First Encounter With F90" by Michael Metcalf in Fortran Forum, vol. 11, No. 1, pp. 24-32, March 1992. CERN had at that time a total of 80 000 code lines working with NAG's Fortran 90 compiler, version 1.1. A good service is obtained from the NAG Response Centre using electronic mail. The system is available for many systems.

Link to NAGWare Fortran 90/95 Compilers.

Compilation and execution with the NAG compiler:

You run Fortran 90/95 in about the same way as you run Fortran 77. The usual commands are, if the source code code1.f90 is in the new free form and source code code2.f is in the old fixed form.


           % f95 code1.f90 code2.f

and if you have a complete program it can be given an execution name.

          % f95 -o program program.f90

Using MS-DOS the compilation command is FTN90 and the source code is *.F90 for new free form and *.FOR for old fixed form. In order to get immediate execution you add /LGO as below.

          FTN90 PROGRAM.F90 /LGO

When you have the program in more than one file you have to first compile the various parts separately, and then link with the LINK77 command and obtain an executable program. We now show how to deal with the two program files PART1.F90 and PART2.FOR and creating a ready to run program WHOLE.EXE.

          FTN90 PART1.F90

          FTN90 PART2.FOR

         

          LINK77

          $LOAD PART1

          $LOAD PART2

          $FILE WHOLE.EXE

The symbol $ above is created automatically by the system. For additional information about f90 under UNIX we recommend the manual command

          % man f90

I here list the most important switches to the compilation command

   -c               compilation only (no linking)

   -C               index control

   -fixed           the old form of the source code

   -free            the new form of the source code

   -f77             calling convention consistent with 

		    the UNIX f77

   -g               generates information for debugging

   -Ipathname       Fortran 90 looks automatically for 

		    modules in the present directory, 

		    in directories in the I-list and in 

		    /usr/local/lib/f90 

   -l               linking of a library

   -Ldir            Add dir to the list of directories 

		    for library routines

   -o               naming the output file

   -pg              generating execution profile

   -S               produces source code in the language C

   -v               give comment about how the compilation 

		    is proceeding

   -version         gives the compiler's version number

   -w               suppresses warnings

Peculiarities in the NAG compiler

  • The compiler signals all (?) variables that have been specified but not used. The compiler therefore performs some data flow analysis.
  • The compiler interrupts the compilation if it finds that a variable that has not been assigned a value is being used. The compiler thus performs the some data flow analysis.
  • The compiler permits Swedish 8-bit characters in character strings (within apostrophes ' or citation marks ") and in comments.
  • The compiler doesn't have support for precision that is larger than the normal double precision, which means that SELECTED_REAL_KIND(15) is the highest possible.
  • Compiler error messages sometimes state only that an error occurs on a certain line.
    However, it seems that the reported line number is the correct line number.
  • Errors in FORMAT are usually not found at compilation, but only at execution.
  • The maximum unit number UNIT for input/output is 63 instead of the normal 99. This restriction is removed in version 2.1.
  • The last line should be an END with a carriage return (CR), if not you can get a compilation error! (This has been fixed in release 2.0, but it is a rather common problem in UNIX).
  • With some editors the Tab is stored as a special character, with some it is automatically replaced with a number of blanks. Prior to release 2.0 the NAG system did not accept the Tab as a special character, but it is now an extension.
  • Using MS-DOS it is necessary to first start an auxiliary system with the command DBOS. If you wish to use Windows you have to first close DBOS with the command KILL_DBOS . If you first start Windows it is possible to go to the DOS-prompter and start DBOS there.
    Also at execution of an already compiled program the DBOS system must be active. It includes among other things a floating point emulator (used if you do not have floating point in the hardware).
  • The NAG FTN90 system does not work with OS/2 as the operating system, not even using a DOS window. DBOS does not run in a simulated environment.
  • The intrinsic function SPREAD can generate too many temporary arrays, which are not deallocated soon enough (causes memory shortage).
  • The compiler warns for the use of obsolescent concepts, see Appendix 4, and also for some extensions to Fortran 90.
  • The order of the compilation switches is important. When compiling a program program.f90 and using modules in the directory /example/modules and the library libnag.a in the directory /examples/libraries we have to use the following command
    
    f90 -I/example/modules program.f90 -lnag -L/examples/libraries
    
    

System parameters

Running the NAG compiler on DEC station ULTRIX, Sun SPARC and IBM PC (MS-DOS) gives in all cases the following parameters for logical variables, integers, floating-point numbers and complex numbers. The identical values are obtained on all the three systems since all these architectures are based on the IEEE-754. Compare with the numerical inquiry functions in Appendix 5.8.

Please note that NAG has somewhat changed the system parameters in Version 2.1.

As you see NAG uses the digits 1, 2, and 3 for the KIND numbers. In order to improve the portability NAG has introduced an additional compiler switch -kind. If you use -kind=byte you will obtain the number of bytes as the KIND number, if you do not use this switch or use -kind=sequential you will use the NAG convention.


  LOGICAL            Default             byte            word

Before release 2.1

     KIND number =         2                1               2

From release 2.1

     KIND number =         3                1               3



  INTEGER            Default           int8          int16   int32

     KIND number =         3              1              2       3

          digits =        31              7             15      31

           radix =         2              2              2       2

           range =         9              2              4       9

     huge =       2147483647            127          32767  2147483647

     bit_size =           32              8             16      32



     REAL            Default           single        double

       KIND number =       1                1             2

            digits =      24               24            53

      maxexponent =      128              128          1024

      minexponent =     -125             -125         -1021

        precision =        6                6            15

            radix =        2                2             2

            range =       37               37           307

          epsilon =  0.11920929e-06  0.11920929e-06   0.2224460e-15

             tiny =  0.11754944E-37  0.11754944E-37   0.22250739-307

             huge =  0.34028235E+39  0.34028235E+39   0.17976931+309



       COMPLEX        Default          single         double

          KIND number =     1               1              2

            precision =     6               6             15

                range =    37              37            307

Back to Appendix 6
Last modified: 6 July 2000
boein@nsc.liu.se