# Unable to run fortran on MAC

**URL:** <https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760>\
**Category:** Help\
**Created:** [April 3, 2024, 12:15pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760 "2024-04-03T12:15:20Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunapaluna](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@lunapaluna](https://fortran-lang.discourse.group/u/lunapaluna)\
**Post date:** [April 3, 2024, 12:15pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/1 "2024-04-03T12:15:20Z")

</div>

I have a MacBook Pro M1 with macOS 14.4.1, I’m trying to run a code that was send to me by my supervisor and was written and was working in windows. I’m trying to run it myself in my computer with no luck. I’ve installed gfortran using both conda and homebrew. Here I’m trying with a simple example.

In the terminal, I’ve tried:

> conda activate gf  
> cd ~mypath
> 
> (gf) **➜**  **Desktop** gfortran try.f90  
> **gfortran:**  **warning:** could not understand version 14.03.00  
> ld: -rpath can only be used when targeting Mac OS X 10.5 or later  
> collect2: error: ld returned 1 exit status

Also I’ve checked the fortran version:

> (gf) **➜**  **Desktop** gfortran --version  
> **gfortran:**  **warning:** could not understand version 14.03.00  
> GNU Fortran (GCC) 11.3.0

This is whats inside my .f90 file:

```auto
program hello
  print *, "Hello, Fortran!"
end program hello

```

I’ve tried reading the forum here and applied some of the recommendations with no luck. Can someone please help me out?

---

<div class="post-metadata">

**Author:** ![blametroi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@blametroi](https://fortran-lang.discourse.group/u/blametroi)\
**Post date:** [April 3, 2024, 1:33pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/2 "2024-04-03T13:33:16Z")

</div>

That’s a linker problem not a compiler problem. My gfortrans in both homebrew and conda report they are version 13.2. Can you deactivate your conda environment and confirm your homebrew installation status? things like `which gfortran` `which ld` and `gfortran --version`?

---

<div class="post-metadata">

**Author:** ![lunapaluna](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@lunapaluna](https://fortran-lang.discourse.group/u/lunapaluna)\
**Post date:** [April 3, 2024, 1:37pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/3 "2024-04-03T13:37:51Z")

</div>

here they are with conda deactivated:

> **➜**  **Desktop** which gfortran  
> /opt/homebrew/bin/gfortran

> **➜**  **Desktop** which ld  
> /usr/bin/ld

> **➜**  **Desktop** gfortran --version  
> GNU Fortran (Homebrew GCC 13.2.0) 13.2.0  
> Copyright (C) 2023 Free Software Foundation, Inc.  
> This is free software; see the source for copying conditions. There is NO  
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

---

<div class="post-metadata">

**Author:** ![blametroi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@blametroi](https://fortran-lang.discourse.group/u/blametroi)\
**Post date:** [April 3, 2024, 1:56pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/4 "2024-04-03T13:56:03Z")

</div>

OK, that matches my setup. So from there what output do you get for `gfortran try.f90`?

---

<div class="post-metadata">

**Author:** ![lunapaluna](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@lunapaluna](https://fortran-lang.discourse.group/u/lunapaluna)\
**Post date:** [April 3, 2024, 2:16pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/5 "2024-04-03T14:16:58Z")

</div>

> [@blametroi](#):
>
> gfortran try.f90

Its not printing anything but generating a file in Desktop called a.out

---

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [April 3, 2024, 2:52pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/6 "2024-04-03T14:52:56Z")

</div>

From the Wikipedia page on [a.out](https://en.wikipedia.org/wiki/A.out):

> “a.out” remains the default output file name for executables created by certain [compilers](https://en.wikipedia.org/wiki/Compiler) and [linkers](https://en.wikipedia.org/wiki/Linker_(computing)) when no output name is specified, even though the created files actually are not in the a.out format.

```txt
$ gfortran try.f90
$ ./a.out
 Hello, Fortran!

```

To change the name of the executable use the `-o` flag, e.g.:

```txt
$ gfortran -o try try.f90

```

---

<div class="post-metadata">

**Author:** ![blametroi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@blametroi](https://fortran-lang.discourse.group/u/blametroi)\
**Post date:** [April 3, 2024, 3:03pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/7 "2024-04-03T15:03:21Z")

</div>

Good, as @ivanpribec notes, a.out is the name of the executable. Since you got no other output, it looks to me as if the compile and link worked. If you try to execute it `./a.out` it should print the hello text from your program.

Given the error messages you originally posted, it looks as if your conda environment has a mismatching gcc for your gfortran. I am assuming you loaded the xcode command line tools correctly since this latest homebrew test seems to have worked.

Do things appear to be working for you now with homebrew?

---

<div class="post-metadata">

**Author:** ![lunapaluna](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@lunapaluna](https://fortran-lang.discourse.group/u/lunapaluna)\
**Post date:** [April 3, 2024, 3:10pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/8 "2024-04-03T15:10:33Z")

</div>

It is working when I execute ./a.out, now if I try with a more complicated script it gives me the following:

> **➜**  **Desktop** cd /Users/lunapaluna/Desktop/dunes  
> **➜**  **dunes** gfortran Unsteady\_2D.f90  
> **Unsteady\_2D.f90:43:6:**  
> 43 | use dflib  
> | **1**  
> **Fatal Error:** Cannot open module file ‘ **dflib.mod** ’ for reading at **(1)**: No such file or directory  
> compilation terminated.

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [April 3, 2024, 3:18pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/9 "2024-04-03T15:18:02Z")

</div>

> [@lunapaluna](#):
>
> 43 | use dflib

DFLIB could be a library of the Digital Visual Fortran compiler (at the end of the 90’s).

---

<div class="post-metadata">

**Author:** ![lunapaluna](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@lunapaluna](https://fortran-lang.discourse.group/u/lunapaluna)\
**Post date:** [April 3, 2024, 3:21pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/10 "2024-04-03T15:21:49Z")

</div>

So I won’t be able to run this script? Or is there a way to download the library so I can use it?

---

<div class="post-metadata">

**Author:** ![blametroi](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@blametroi](https://fortran-lang.discourse.group/u/blametroi)\
**Post date:** [April 3, 2024, 3:22pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/11 "2024-04-03T15:22:39Z")

</div>

OK. Now you’re into areas I don’t know a lot about. dflib appears to be an old dec library of some sort. I don’t know how/if it could be replaced. It would have to be in your module search path, which you can extend with the -J switch on the gfortran command, or better yet with the fortran package manager dependency features, but first you have to find that library. It is probably worth a separate question as it’s not a gfortran issue at this point.

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [April 3, 2024, 3:25pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/12 "2024-04-03T15:25:21Z")

</div>

> [@blametroi](#):
>
> I don’t know how/if it could be replaced.

Maybe but with Intel compilers:

> **[DFLIB/IFLIB](https://community.intel.com/t5/Intel-Fortran-Compiler/DFLIB-IFLIB/m-p/796655)**
>
> Using IVF 8.1, and was converting a CVF program that used USE DFLIB, but USE IFLIB produces an error. When I search the Include files I find DFLIB but not IFLIB. I noticed in past forum posts thatreferences are made to IFLIB so I assume it exists....

---

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [April 3, 2024, 3:49pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/13 "2024-04-03T15:49:51Z")

</div>

Perhaps the procedures from `dflib` (assumings it’s the DEC/Intel module, and not a module from your supervisor in a different file or folder) could be replaced with open alternatives. If you modify temporarily your program like this:

```auto
program unsteady2d
! use dflib ! <-- temporarily comment out the module import
implicit none (type,external) ! <-- flag external procedures
! ...

end program

```

you should see a number of warnings pointing to the missing procedures from dflib (and perhaps others too… 🙈 ).

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [April 3, 2024, 4:21pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/14 "2024-04-03T16:21:14Z")

</div>

An [old thread](https://comp.lang.fortran.narkive.com/FqAX3EgG/graphics-lib-help) from comp.lang.fortran about what is in `dflib` could be helpful. Does the Windows program create a GUI? Is it ok if a Mac version just writes output to the terminal or to files?

To find out what is being used from the module `dflib`, on Windows try compiling the program with the `use dflib` line commented out, and look at what names the compiler says are missing. Then create a line such as

`use dflib, only: foo, bar`

where `foo, bar` are the items imported from `dflib` so that the program compiles on Windows. Then you can research whether equivalents can be created for the items imported from `dflib`.

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [April 3, 2024, 5:16pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/15 "2024-04-03T17:16:06Z")

</div>

You could find information in Google Books, for example:

> **[Digital Visual Fortran Programmer's Guide](https://books.google.fr/books?id=sGpdrVIwToUC&printsec=frontcover&hl=fr#v=onepage&q&f=false)**
>
> Digital Visual Fortran is the latest version of a major programming language tool used by scientists and engineers. Written by key technical writers from the Digital Visual Fortran product team, Digital Visual Fortran Programmer's Guide presents in...

> [@Beliavsky](#):
>
> Does the Windows program create a GUI?

When I was using Digital Visual Fortran / Compaq Visual Fortran , I was using DFLIB for the QuickWin subroutines to build GUI. Many subroutine names were ending with `QQ`, like `SETWSIZEQQ`.

---

<div class="post-metadata">

**Author:** ![lunapaluna](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@lunapaluna](https://fortran-lang.discourse.group/u/lunapaluna)\
**Post date:** [April 3, 2024, 6:18pm UTC](https://fortran-lang.discourse.group/t/unable-to-run-fortran-on-mac/7760/16 "2024-04-03T18:18:35Z")

</div>

It produces some .txt files as output, so I could try removing the dependency and see what happens. I’ll ask my supervisor if she remembers how she used it. It might be faster! Thanks for the help!
