# Which Fortran compilers are usable on Raspberry Pi?

**URL:** <https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073>\
**Category:** Uncategorized\
**Created:** [January 24, 2023, 10:28am UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073 "2023-01-24T10:28:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaikunzhang](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/zaikunzhang/32/785_2.png) [@zaikunzhang](https://fortran-lang.discourse.group/u/zaikunzhang)\
**Post date:** [January 24, 2023, 10:28am UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/1 "2023-01-24T10:28:46Z")

</div>

Which Fortran compilers are usable on Raspberry Pi, e.g., [model 4B](https://www.raspberrypi.com/products/raspberry-pi-4-model-b/)?

Here is the information about such a model with the recommended Raspberry Pi OS, [which is 32-bit](https://www.raspberrypi.com/software/operating-systems/).

```auto
$ uname -a && lscpu
Linux Pi-1 5.15.61-v7l+ #1579 SMP Fri Aug 26 11:13:03 BST 2022 armv7l GNU/Linux
Architecture: armv7l
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Vendor ID: ARM
Model: 3
Model name: Cortex-A72
Stepping: r0p3
CPU max MHz: 1800.0000
CPU min MHz: 600.0000
BogoMIPS: 108.00
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec store bypass: Not affected
Vulnerability Spectre v1: Mitigation; __user pointer sanitization
Vulnerability Spectre v2: Vulnerable
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Flags: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32

```

`gfortran` is readily available by a simple `sudo apt install gfortran`, which is great. Do you know other compilers that are compatible with Raspberry Pi? Thank you very much.

---

<div class="post-metadata">

**Author:** ![rwmsu](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@rwmsu](https://fortran-lang.discourse.group/u/rwmsu)\
**Post date:** [January 24, 2023, 1:09pm UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/2 "2023-01-24T13:09:04Z")

</div>

I think ARM has a version of FLANG/CLANG that runs on LInux. Don’t know what it would take to get it to run on a PI (if it does at all). DuckDuckGo is your friend

---

<div class="post-metadata">

**Author:** ![zaikunzhang](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/zaikunzhang/32/785_2.png) [@zaikunzhang](https://fortran-lang.discourse.group/u/zaikunzhang)\
**Post date:** [January 24, 2023, 1:10pm UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/3 "2023-01-24T13:10:57Z")

</div>

Thank you @rwmsu . I had a try, but failed. The installer complained something like “incorrect binary file format”. I am not sure whether it is due to the fact that the OS is 32-bit.

---

<div class="post-metadata">

**Author:** ![nbehrnd](https://avatars.discourse-cdn.com/v4/letter/n/e0b2c6/32.png) [@nbehrnd](https://fortran-lang.discourse.group/u/nbehrnd)\
**Post date:** [January 24, 2023, 6:21pm UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/4 "2023-01-24T18:21:52Z")

</div>

What is the operational system put on the memory chip/available to you? From the characteristic red swirl shown top left on the home page of Raspbian/Rasperry Pi OS [here](https://www.raspbian.org/) tailored to the device, one can assume the OS is an off-spring of Linux Debian. Running `synaptics` (maybe this requires once a `sudo apt-get install synaptics`) likely offers you `gfortran` (.or. `gcc`). As by today, Debian 12/bookworm (branch testing) reached version 12.2.0-14 (release/package for both).

For a more detailed view _per release of the OS_, see e.g., the table compiled by [distrowatch](https://distrowatch.com/table.php?distribution=raspios); it states gcc 10.2.1 is offered for the OS shipped by 2022-09-26.

---

<div class="post-metadata">

**Author:** ![zaikunzhang](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/zaikunzhang/32/785_2.png) [@zaikunzhang](https://fortran-lang.discourse.group/u/zaikunzhang)\
**Post date:** [January 24, 2023, 11:57pm UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/5 "2023-01-24T23:57:23Z")

</div>

Thank you @nbehrnd . The OS is the “[Raspberry Pi OS, the recommended operating system for most users](https://www.raspberrypi.com/software/operating-systems/)”. It is based on Debian.

As you said, `gfortran` is readily available with `apt`. I hope to know whether there is any other, in case someone here has some experience.

---

<div class="post-metadata">

**Author:** ![rwmsu](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@rwmsu](https://fortran-lang.discourse.group/u/rwmsu)\
**Post date:** [January 25, 2023, 1:22pm UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/6 "2023-01-25T13:22:58Z")

</div>

I think there is a 64 bit version of the Raspberry Pi OS but I don’t know if its officially maintained. Installing that instead of the 32 bit version might be an option.

---

<div class="post-metadata">

**Author:** ![zaikunzhang](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/zaikunzhang/32/785_2.png) [@zaikunzhang](https://fortran-lang.discourse.group/u/zaikunzhang)\
**Post date:** [February 9, 2023, 6:57am UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/7 "2023-02-09T06:57:16Z")

</div>

Update:

With the 64-bit Raspberry OS and Raspberry Pi 4B, the [Arm Fortran compiler](https://developer.arm.com/downloads/-/arm-compiler-for-linux) and nvfortran work in addition to gfortran. However, nvfortran does not support some intrinsic, e.g., `date_and_time`, `random_number`, complaining `Illegal instruction`.

---

<div class="post-metadata">

**Author:** ![gronki](https://avatars.discourse-cdn.com/v4/letter/g/a88e4f/32.png) [@gronki](https://fortran-lang.discourse.group/u/gronki)\
**Post date:** [February 10, 2023, 12:18pm UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/8 "2023-02-10T12:18:18Z")

</div>

Gfortran works pretty okay, make sure to use `-O3 -funsafe-math-optimizations` to take advantage of vectorization. With 32-bit OS you should explicitly enable hardware flags.

Rpi 3B flags I used:

```auto
-mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard

```

For flags regarding your board, check out the website: [GCC compiler optimization for ARM-based systems · GitHub](https://gist.github.com/fm4dd/c663217935dc17f0fc73c9c81b0aa845)

---

<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:** [March 14, 2024, 4:28pm UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/9 "2024-03-14T16:28:07Z")

</div>

I have just installed a [Raspberry Pi OS](https://www.raspberrypi.com/software/) (which is a 64-bit Linux Debian 12) on:

- a [Raspberry Pi 3B](https://www.raspberrypi.com/products/raspberry-pi-3-model-b/) (Quad Core 1.2GHz Broadcom BCM2837 64bit CPU + 1 GB RAM)
- and a [Raspberry Pi 4B](https://www.raspberrypi.com/products/raspberry-pi-4-model-b/) (Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.8GHz + 4 GB RAM).

I have GFortran 12.2.0, git, CMake and fpm. On the Rasp3B, it took more than 10 minutes to build fpm… 🐢 (I feared it was frozen as I have no fan for cooling 😁 but was patient)

I have cloned, built and run successfully gtk-fortran with CMake (including the PLplot examples) and ForColormap with fpm.

---

<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:** [March 14, 2024, 7:31pm UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/10 "2024-03-14T19:31:11Z")

</div>

I wonder if we can install and run OpenCoarrays on a Raspberry?

Well, of course, it is useless if you don’t have a decent cooling system! When I tried to build gtk-fortran in parallel on the four cores of my Rasp3B with `make -j`, I froze the system arriving at 82% (which took maybe 2 or 3 minutes)… I unplugged it, waited for cooling then rebooted and used a simple `make` to burn only one core.

(Hum… It sounds weird to _freeze_ a system while _burning_ 4 CPUs… 😁)

---

<div class="post-metadata">

**Author:** ![rwmsu](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@rwmsu](https://fortran-lang.discourse.group/u/rwmsu)\
**Post date:** [March 14, 2024, 8:07pm UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/11 "2024-03-14T20:07:26Z")

</div>

I think the Dilbert cartoon on the front of this book might be the answer to your problem. 😄

> **[Advanced Programming in the Unix Environment: Stevens, W. Richard, Rago, Stephen...](https://www.amazon.com/Advanced-Programming-UNIX-Environment-2nd/dp/0201433079)**
>
> Advanced Programming in the Unix Environment \[Stevens, W. Richard, Rago, Stephen A.\] on Amazon.com. \*FREE\* shipping on qualifying offers. Advanced Programming in the Unix Environment

---

<div class="post-metadata">

**Author:** ![interkosmos](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/interkosmos/32/296_2.png) [@interkosmos](https://fortran-lang.discourse.group/u/interkosmos)\
**Post date:** [March 14, 2024, 9:50pm UTC](https://fortran-lang.discourse.group/t/which-fortran-compilers-are-usable-on-raspberry-pi/5073/12 "2024-03-14T21:50:20Z")

</div>

![unixwizard](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/6/6d4184816020e28c816cf0b353b97dbb1d39e524.gif)
