2

On OSX. How might I test whether fortran is installed on my machine?

$ fortran
-bash: fortran: command not found
0

3 Answers 3

2

A lot depends on the operating system that you're running. The error message that you included in your indicates that you're running the "bash" shell, which is most commonly seen on Linux systems. The most commonly used Fortran compiler on such systems is the GNU fortran compiler, which you would invoke by

$ gfortran

Try issuing that command to see what happens. If you get

gfortran: fatal error: no input files

compilation terminated.

then you've got gfortran installed on the system.

There are of course many other fortran compilers available for Linux systems, including compilers from Intel and the Portland Group. Another useful test would be to issue the command

$ man -k fortran

which should give you a list of man page entries related to Fortran. It's likely that this will help you identify any other Fortran compilers that might be on your system.

1
  • If something screwy has happened, and a Fortran compiler is on the machine but the directory containing the compiler isn't in the user's PATH, then this method will fail. As a backup, you could check to see if gfortran is installed by running find / -name gfortran (note, to search all directories, you will need to run this command as sudo or root). In order to exhaustively check your computer for fortran compilers, you would also need to check for the names of other Fortran compiler executables (ifort for the Intel Fortran Compiler, etc.). Jul 19, 2013 at 6:25
1

The bash command apropos followed by a keyword will search for commands that match the string you pass to it, provided that they're installed in your $PATH. Running apropos fort would find either gfortran or ifort if you have them, but Macs don't have any fortran compiler by default.

0

This will list all the compilers installed: dpkg --list | grep compiler Check if Fortan appears in the list or not.

3
  • -bash: dpkg: command not found
    – AJcodez
    Jul 19, 2013 at 4:28
  • 1
    dpkg is not a command that is available on OS X. Jul 19, 2013 at 6:10
  • Elegant solutions like these dont work on OS X :) Btw dpkg only knows about compilers installed from the repo/debs and anything installed by a sysadmin/user locally wont show up.
    – stali
    Jul 19, 2013 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.