2.3. GNU Fortran Compiler
2.3.1. Installing the Fortran Compiler
2.3.2. Using the Fortran Compiler
gfortrancompiler as follows:
scl enable devtoolset-6 'gfortran -o output_file source_file...'
-ooption is omitted, the compiler creates a file named
scl enable devtoolset-6 'gfortran -o object_file -c source_file'
-ooption is omitted, the compiler creates a file named after the source file with the
.ofile extension. To link object files together and create a binary file, run:
scl enable devtoolset-6 'gfortran -o output_file object_file...'
sclutility, causing it to be run with the Red Hat Developer Toolset binaries used in preference to the Red Hat Enterprise Linux system equivalent. This allows you to run a shell session with Red Hat Developer Toolset
scl enable devtoolset-6 'bash'
gfortranyou are using at any point, type the following at a shell prompt:
gfortranexecutable path will begin with
/opt. Alternatively, you can use the following command to confirm that the version number matches that for Red Hat Developer Toolset
Example 2.5. Compiling a Fortran Program on the Command Line
hello.fwith the following contents:
program hello print *, "Hello, World!" end program hello
gfortrancompiler from Red Hat Developer Toolset, type:
scl enable devtoolset-6 'gfortran -o hello hello.f'
helloin the current working directory.
2.3.3. Running a Fortran Program
gfortrancompiles a program, it creates an executable binary file. To run this program on the command line, change to the directory with the executable file and type:
Example 2.6. Running a Fortran Program on the Command Line
hellobinary file as shown in Example 2.5, “Compiling a Fortran Program on the Command Line”, you can run it by typing the following at a shell prompt: