Skip Navigation Links | |
Exit Print View | |
Oracle Solaris Studio 12.3: Fortran User's Guide Oracle Solaris Studio 12.3 Information Library |
2. Using Solaris Studio Fortran
2.2.2 Command-Line File Name Conventions
2.2.4 Source File Preprocessors
2.2.5 Separate Compiling and Linking
2.2.6 Consistent Compiling and Linking
2.2.7 Unrecognized Command-Line Arguments
2.3.1.2 The IGNORE_TKR Directive
2.3.1.6 The PIPELOOP[=n] Directive
2.3.1.7 The PREFETCH Directives
2.3.2 Parallelization Directives
2.3.2.1 OpenMP Parallelization Directives
2.3.2.2 Legacy Sun/Cray Parallelization Directives
2.4 Library Interfaces and system.inc
2.5.1 Determining Hardware Platform
2.5.2 Using Environment Variables
2.5.3.3 Control of Virtual Memory
2.6 User-Supplied Default Options File
4. Solaris Studio Fortran Features and Extensions
5. FORTRAN 77 Compatibility: Migrating to Solaris Studio Fortran
This section provides a quick overview of how to use the Fortran compiler to compile and run Fortran programs. A full reference to command-line options appears in the next chapter.
The very basic steps to running a Fortran application involve using an editor to create a Fortran source file with a .f, .for, .f90, .f95, .F, .F90, .F95, .f03, or .F03 filename suffix; (see Table Table 2-1), invoking the compiler to produce an executable; and finally, launching the program into execution by typing the name of the file:
Example: This program displays a message on the screen:
demo% cat greetings.f PROGRAM GREETINGS PRINT *, ’Real programmers write Fortran!’ END demo% f95 greetings.f demo% a.out Real programmers write Fortran! demo%
In this example, f95 compiles source file greetings.f and links the executable program onto the file, a.out, by default. To launch the program, the name of the executable file, a.out, is typed at the command prompt.
Traditionally, UNIX compilers write executable output to the default file called a.out. It can be awkward to have each compilation write to the same file. Moreover, if such a file already exists, it will be overwritten by the next run of the compiler. Instead, use the -o compiler option to explicitly specify the name of the executable output file:
demo% f95 -o greetings greetings.f demo% greetings Real programmers write Fortran! demo%
In the preceding example, the -o option tells the compiler to write the executable code to the file greetings. (By convention, executable files usually are given the same name as the main source file, but without an extension.)
Alternatively, the default a.out file could be renamed via the mv command after each compilation. Either way, run the program by typing the name of the executable file at a shell prompt.
The next sections of this chapter discuss the conventions used by the f95 commands, compiler source line directives, and other issues concerning the use of these compiler. The next chapter describes the command-line syntax and all the options in detail.