# GitHub Action: Setup Fortran with Conda

**URL:** <https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869>\
**Category:** Announcements\
**Created:** [June 20, 2025, 9:59am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869 "2025-06-20T09:59:03Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [June 25, 2025, 1:10pm UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/21 "2025-06-25T13:10:33Z")

</div>

> [@urbanjost](#):
>
> I needed to skip the -fPIC switch on mswindows when using Fortran, as the executables would  
> not run

Yes, this issue affects the Flang compiler on Windows specifically. It seems the `-fPIC` flag isn’t supported on Windows, so it might be worth removing it from the default flags for `flang-new` in `fpm`.

> [@urbanjost](#):
>
> I also like to have the status flags in the markdown either in README.md or a file just for that  
> purpose in STATUS.md instead of using the github actions menu to quickly see pass/fail

With the v0.2.0 release, I added a GitHub Actions job summary table that shows the OS, compiler version, and `fpm` version. For example: [Update Fortran setup action to version v0 and remove redundant Ubuntu… · gha3mi/M\_time@5495bf2 · GitHub](https://github.com/gha3mi/M_time/actions/runs/15876790535)

Additionally, the CI workflow now generates a `STATUS.md` file and deploys it to a dedicated branch. See:[M\_time/STATUS.md at gh-pages-status · gha3mi/M\_time · GitHub](https://github.com/gha3mi/M_time/blob/gh-pages-status/STATUS.md)

Alternatively, this file can also be committed directly to the `main` branch using a GitHub Actions bot if preferred.

This step from [here](https://github.com/urbanjost/M_time/blob/main/.github/workflows/CI.yml) is now included by default in the updated setup, so it can be removed from CI configuration.

```auto
  - name: Set environment for ubuntu
    if: matrix.os == 'ubuntu-latest'
    run: |
      ulimit -c unlimited -d unlimited -f unlimited -m unlimited -s unlimited -t unlimited -v unlimited -x unlimited

```

---

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [June 26, 2025, 2:34am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/22 "2025-06-26T02:34:16Z")

</div>

An above and beyond effort. Any fpm project with test programs can add testing on multiple platforms with multiple compilers just by adding .github/workflows/\*.yml files to their project.

---

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [July 3, 2025, 10:50am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/23 "2025-07-03T10:50:21Z")

</div>

How annoying would it be to somehow include MPI?

btw, thanks so much for this; this is fantastic I am working to include this in my current CI

---

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [July 3, 2025, 10:50am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/24 "2025-07-03T10:50:59Z")

</div>

The latest version **v0.6.0** now includes:

- Support for the `nvfortran` compiler
- Versioned compiler installation by specifying: `compiler-version`
- Added support for cmake
- Fortitude linter integration via the new `linter_fortitude` job
- Simplified CI/CD workflow configuration (include only the jobs you need)
- Automatic status table generation with pull requests  
Example: [https://github.com/gha3mi/forimage#status](https://github.com/gha3mi/forimage#status)
- `latest` tag added for stable reference: `gha3mi/setup-fortran-conda@latest`
- Integrated Doxygen and FORD documentation support
- Updated `README` with usage instructions
- Various fixes and improvements
- MIT License added

I’ve also tested the action on some of my repos using `fpm`, `cmake` and `ford`: [ForImage](https://github.com/gha3mi/forimage), [ForCAD](https://github.com/gha3mi/forcad), [ForTime](https://github.com/gha3mi/fortime)

I’m also thinking about adding [Visualizing Fortran Projects with fpm: Create Stunning Module Dependency Charts](https://fortran-lang.discourse.group/t/visualizing-fortran-projects-with-fpm-create-stunning-module-dependency-charts/9838) as a new job, which could be a great addition to the README.

Contributions are always welcome!

---

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [July 3, 2025, 10:56am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/25 "2025-07-03T10:56:48Z")

</div>

I’m not sure about MPI, as I don’t have much experience with it and don’t currently have any repositories using MPI to test with. It would be great if you could provide a very simple example program to try it out.

---

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [July 3, 2025, 11:03am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/26 "2025-07-03T11:03:29Z")

</div>

MPI in a pain because of the MPI module needs to be compiled with the same compiler…in theory we could use [vapaa](https://github.com/jeffhammond/vapaa), bind to that and that binds to C? I’ll look into that and maybe try to open a PR

---

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [July 3, 2025, 11:09am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/27 "2025-07-03T11:09:54Z")

</div>

on other news, I don’t know how often people look but the fpm has been downloaded [80,295](https://anaconda.org/conda-forge/fpm) times.

---

<div class="post-metadata">

**Author:** ![FedericoPerini](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/federicoperini/32/1750_2.png) [@FedericoPerini](https://fortran-lang.discourse.group/u/FedericoPerini)\
**Post date:** [July 3, 2025, 12:52pm UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/28 "2025-07-03T12:52:00Z")

</div>

_absolutely_, not even mentioning that not depending on the non-universal Fortran `module` format would enable users to freely use MPI from Fortran regardless of the implementation that best suits their machine.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [July 3, 2025, 9:52pm UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/29 "2025-07-03T21:52:02Z")

</div>

> [@jorgeg](#):
>
> MPI in a pain because of the MPI module needs to be compiled with the same compiler…in theory we could use [vapaa](https://github.com/jeffhammond/vapaa), bind to that and that binds to C?

You can also use [GitHub - lfortran/fortran\_mpi](https://github.com/lfortran/fortran_mpi), it works with GFortran and LFortran, we used it to compile the POT3D code. But it might not be as complete as Vapaa yet.

---

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [August 11, 2025, 5:24pm UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/30 "2025-08-11T17:24:58Z")

</div>

As an update, the supported compilers are listed below.

**Ubuntu**

| Fortran Compiler | C Compiler | C++ Compiler |
| --- | --- | --- |
| gfortran | gcc | g++ |
| ifx | icx | icx |
| lfortran | ~~gcc~~ clang | ~~g++~~ clang++ |
| flang, flang-new | clang | clang++ |
| nvfortran | nvc | nvc++ |

**macOS**

| Fortran Compiler | C Compiler | C++ Compiler |
| --- | --- | --- |
| gfortran | gcc | g++ |
| lfortran | clang | clang++ |

**Windows**

| Fortran Compiler | C Compiler | C++ Compiler |
| --- | --- | --- |
| gfortran | gcc | g++ |
| ifx | icx | icx |
| lfortran | clang-cl | clang-cl |
| flang, flang-new | clang-cl | clang-cl |

The following environment variables are set automatically:

- `FC`, `CC`, `CXX`
- `FPM_FC`, `FPM_CC`, `FPM_CXX`
- `CMAKE_Fortran_COMPILER`, `CMAKE_C_COMPILER`, `CMAKE_CXX_COMPILER`

Below are the results of a simple “Hello World” test. The required build tools (`fpm`, `cmake`, `ninja` and `meson`) are preinstalled, so no additional setup is needed.

| Compiler | macos | ubuntu | windows |
| --- | --- | --- | --- |
| `flang-new` | - | fpm✔ cmake✔ meson✔ | fpm✖ cmake✔ meson✖ |
| `gfortran` | fpm✔ cmake✔ meson✔ | fpm✔ cmake✔ meson✔ | fpm✔ cmake✔ meson✔ |
| `ifx` | - | fpm✔ cmake✔ meson✔ | fpm✔ cmake✔ meson✔ |
| `lfortran` | fpm✔ cmake✔ meson✖ | fpm✔ cmake✔ meson✖ | fpm✔ cmake✖ meson✖ |
| `mpifort` | mpi\_fpm✔ | mpi\_fpm✔ | - |
| `nvfortran` | - | fpm✔ cmake✔ meson✔ | - |

Here is a minimal usage example:

```auto
name: Setup Fortran Conda CI/CD

on: [push]
permissions:
  contents: write
jobs:
  test_fpm:
    name: ${{ matrix.os }}_${{ matrix.compiler }}_fpm
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        compiler: [gfortran, ifx, lfortran, flang-new, nvfortran]
        exclude:
          - os: macos-latest
            compiler: flang-new
          - os: macos-latest
            compiler: ifx
          - os: macos-latest
            compiler: nvfortran
          - os: windows-latest
            compiler: nvfortran
    steps:
      - name: Setup Fortran
        uses: gha3mi/setup-fortran-conda@latest
        with:
          compiler: ${{ matrix.compiler }}
          platform: ${{ matrix.os }}

      - name: fpm test (debug)
        run: fpm test --compiler ${{ matrix.compiler }} --profile debug

      - name: fpm test (release)
        run: fpm test --compiler ${{ matrix.compiler }} --profile release

```

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [August 11, 2025, 7:15pm UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/31 "2025-08-11T19:15:19Z")

</div>

@Ali thank you so much for maintaining the compilers’ setup, this is the way to go.

---

<div class="post-metadata">

**Author:** ![HugoMVale](https://avatars.discourse-cdn.com/v4/letter/h/e19adc/32.png) [@HugoMVale](https://fortran-lang.discourse.group/u/HugoMVale)\
**Post date:** [August 12, 2025, 7:33pm UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/32 "2025-08-12T19:33:45Z")

</div>

Thanks a lot for implementing this GitHub Action! I am already using it.

Just a question: Why is `lfortran` paired with `gcc` in Ubuntu, but with `clang` in MacOS and Windows? Would it not be preferable to have the same pairing across OSs?

---

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [August 12, 2025, 8:47pm UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/33 "2025-08-12T20:47:44Z")

</div>

@HugoMVale thank you for using the action, happy to see it is working for you.

My priority was to get the basic hello world test with `fpm` working correctly, then run tests on some of my own repositories with both `fpm` and `CMake`. Later I added the `C/C++` compiler without considering making the pairing consistent across OSs (my mistake 😉). To be honest, I was not sure what would be the best pairing for `lfortran`. Any suggestion? I can improve this in the next version.

(I am also thinking about introducing two new variables like `c-compiler` and `cpp-compiler` so the user can choose them, but that would also require adding `c-version` and `cpp-version` and modifying the logic of the implementation. I would like to avoid that for now as it needs more time.)

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [August 13, 2025, 1:07am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/34 "2025-08-13T01:07:41Z")

</div>

> [@Ali](#):
>
> To be honest, I was not sure what would be the best pairing for `lfortran`. Any suggestion?

LFortran works with either one. Usually clang is available by default on macOS and gcc on Linux, so that seems to make the most sense?

On Windows typically clang is easier to install via conda.

---

<div class="post-metadata">

**Author:** ![hkvzjal](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/hkvzjal/32/3055_2.png) [@hkvzjal](https://fortran-lang.discourse.group/u/hkvzjal)\
**Post date:** [August 13, 2025, 6:33am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/35 "2025-08-13T06:33:58Z")

</div>

> [@certik](#):
>
> > [@Ali](#):
> >
> > To be honest, I was not sure what would be the best pairing for `lfortran`. Any suggestion?
> 
> LFortran works with either one. Usually clang is available by default on macOS and gcc on Linux, so that seems to make the most sense?

For a default settings, as an user testing different compilers, I would find it reasonable to pair Lfortran with clang systematically. For the simple reason that both are from the LLVM family. And for a CI/CD script I would find it nice that it helps verify cross-platform stability, meaning that if Lfortran is paired with clang on one platform, I would find it easier-to-follow-mentally to have the same pairing for the other platforms as to minimize the number of things to check if something goes wrong or results are too different.

---

<div class="post-metadata">

**Author:** ![HugoMVale](https://avatars.discourse-cdn.com/v4/letter/h/e19adc/32.png) [@HugoMVale](https://fortran-lang.discourse.group/u/HugoMVale)\
**Post date:** [August 13, 2025, 10:43am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/36 "2025-08-13T10:43:02Z")

</div>

That is exactly what I was thinking when I raised the question in my previous post.

---

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [August 13, 2025, 11:51am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/37 "2025-08-13T11:51:57Z")

</div>

Since LFortran works with all cases, I would follow @hkvzjal’s and @HugoMVale’s suggestion to use Clang with LFortran on all platforms as the default case. Thanks!

---

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [August 13, 2025, 5:25pm UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/38 "2025-08-13T17:25:31Z")

</div>

With the latest release (v0.10.0), clang/clang++ is now paired with LFortran on Ubuntu.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [August 14, 2025, 5:02am UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/39 "2025-08-14T05:02:22Z")

</div>

Good idea. We should update LFortran upstream to by default expect `clang` on both Linux and macOS, and only use `gcc` if the user selects (either compiler option or environment variables). Since we use LLVM as our default backend, I agree that it makes sense to just depend on Clang.

---

<div class="post-metadata">

**Author:** ![jacobwilliams](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jacobwilliams/32/10_2.png) [@jacobwilliams](https://fortran-lang.discourse.group/u/jacobwilliams)\
**Post date:** [January 25, 2026, 3:03pm UTC](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869/40 "2026-01-25T15:03:16Z")

</div>

I finally got around to trying this, and it is AMAZING! Terrific work @Ali!!

[Previous page](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869.md?page=1)

[Next page](https://fortran-lang.discourse.group/t/github-action-setup-fortran-with-conda/9869.md?page=3)
