0

I am attempting to compile and run a Fortran 90 program using command line (bash). In the past, when I've run gfortran /path/to/file, a file a.out and a file program_name are created, and I can run the program by using ./program_name in the command line. For reasons I don't understand, the program_name file is no longer being created, and therefore when I attempt to run ./program_name, I get an error message No such file or directory. It does not appear to matter which .f90 file I use; I get the same results.

How do I get the program to compile properly so that I can run it?

New contributor
JDoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Answer 1

6

a.out is the compiled program; it is the executable file. That is the default name gfortran uses for its output file. Typing ./a.out in your command line would execute it.

To specify another name for the program, use the -o switch followed by the name:

gfortran -o program_name further arguments…

Sign up to request clarification or add additional context in comments.

2 Comments

I'll mark this as correct, as running ./a.out does indeed produce the expected result. But any idea why things aren't working the way they used to?
The most likely explanations are that you were not executing gfortran directly, your memory is faulty, or you were executing some modified gfortran (could be as simple as script that interposed its own arguments and then executed the actual gfortran).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.