This tutorial will guide you through the process of running an existing .f90 Fortran file using the Intel Fortran Compiler (ifort) in the terminal.
- On Linux or macOS, you can find the terminal by searching for it in your application menu.
- On Windows, if you are using the Windows Subsystem for Linux (WSL) or have a similar terminal environment set up, open your terminal there.
-
Use the
cd(change directory) command to go to the folder where your.f90file is stored.
For example, if your file is on your desktop in a folder calledfortran_codes, you can navigate to it like this:cd ~/Desktop/fortran_codes -
To verify you are in the correct directory, use the
ls(list) command to see the files in the folder.
-
Now, compile your
.f90file. Suppose your file is namedprogram.f90. Run the following command:ifort program.f90 -o program.outExplanation of the command:
ifort: Calls the Intel Fortran compiler.program.f90: Specifies your source file to be compiled.-o program.out: Specifies the name of the output executable file (program.outin this case). This part is optional.
-
If the compilation is successful, you should see no errors, and a new executable file named
program.outwill be created in the same directory.
-
To run the executable that was created during compilation, use the
./command followed by the executable file name:./program.outTo run the executable file and measure its runtime, use the
time ./command:time ./program.out -
If everything is set up correctly, this command will execute your Fortran program and display the output in the terminal.
If you encounter any errors during compilation, carefully read the error messages. Common issues might include syntax errors in the Fortran code or missing dependencies.