Skip to content

Latest commit

 

History

History
55 lines (34 loc) · 2.15 KB

File metadata and controls

55 lines (34 loc) · 2.15 KB

How to Run an Existing .f90 File Using ifort in the Terminal

This tutorial will guide you through the process of running an existing .f90 Fortran file using the Intel Fortran Compiler (ifort) in the terminal.

Step 1: Open 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.

Step 2: Navigate to the Directory Containing Your .f90 File

  1. Use the cd (change directory) command to go to the folder where your .f90 file is stored.
    For example, if your file is on your desktop in a folder called fortran_codes, you can navigate to it like this:

    cd ~/Desktop/fortran_codes
    
  2. To verify you are in the correct directory, use the ls (list) command to see the files in the folder.

Step 3: Compile the .f90 File Using ifort

  1. Now, compile your .f90 file. Suppose your file is named program.f90. Run the following command:

    ifort program.f90 -o program.out
    

    Explanation 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.out in this case). This part is optional.
  2. If the compilation is successful, you should see no errors, and a new executable file named program.out will be created in the same directory.

Step 4: Run the Executable

  1. To run the executable that was created during compilation, use the ./ command followed by the executable file name:

    ./program.out
    

    To run the executable file and measure its runtime, use the time ./ command:

    time ./program.out
    
  2. If everything is set up correctly, this command will execute your Fortran program and display the output in the terminal.

Troubleshoot Any Errors

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.