Which Fortran compilers are usable on Raspberry Pi, e.g., model 4B?
Here is the information about such a model with the recommended Raspberry Pi OS, which is 32-bit.
$ 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.
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
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.
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 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; it states gcc 10.2.1 is offered for the OS shipped by 2022-09-26.
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.
With the 64-bit Raspberry OS and Raspberry Pi 4B, the Arm Fortran compiler and nvfortran work in addition to gfortran. However, nvfortran does not support some intrinsic, e.g., date_and_time, random_number, complaining Illegal instruction.
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.
I have just installed a Raspberry Pi OS (which is a 64-bit Linux Debian 12) on:
a Raspberry Pi 3B (Quad Core 1.2GHz Broadcom BCM2837 64bit CPU + 1 GB RAM)
and a Raspberry Pi 4B (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.
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… )