From b8468bce231f290496442ccf55290ae5e69e04fb Mon Sep 17 00:00:00 2001
From: Katherine Rasmussen <krasmussen@lbl.gov>
Date: Tue, 3 Sep 2024 14:23:54 -0700
Subject: [PATCH 1/4] Add new Github CI actions yaml file to build with flang

---
 .github/workflows/build-with-flang.yml | 32 ++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 .github/workflows/build-with-flang.yml

diff --git a/.github/workflows/build-with-flang.yml b/.github/workflows/build-with-flang.yml
new file mode 100644
index 000000000..7bd2849dc
--- /dev/null
+++ b/.github/workflows/build-with-flang.yml
@@ -0,0 +1,32 @@
+name: Build with LLVM-Flang
+
+on: [push, pull_request]
+
+
+jobs:
+  Build:
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        os: [ubuntu-24.04]
+      fail-fast: true
+    container: gmao/llvm-flang:latest
+    env:
+      FC: flang-new
+      CC: clang
+
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v2
+
+    - uses: fortran-lang/setup-fpm@v4
+      with:
+        github-token: ${{ secrets.GITHUB_TOKEN }}
+
+    - name: Build and Test
+      if: contains(matrix.os, 'ubuntu')
+      run: |
+        fpm --version
+        export FPM_FC=$FC
+        export FPM_CC=$CC
+        fpm test --flag "-mmlir -allow-assumed-rank -O3"

From 71860db1330b3b9071b36c6e7efdd7edbf7d8fda Mon Sep 17 00:00:00 2001
From: Katherine Rasmussen <krasmussen@lbl.gov>
Date: Tue, 3 Sep 2024 14:27:26 -0700
Subject: [PATCH 2/4] Replace CI yaml file that builds with gfortran with new
 CI yaml file that builds with Flang

---
 .github/workflows/CI.yml               | 35 +++++++-------------------
 .github/workflows/build-with-flang.yml | 32 -----------------------
 2 files changed, 9 insertions(+), 58 deletions(-)
 delete mode 100644 .github/workflows/build-with-flang.yml

diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index cabff7e84..ac2e16395 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -1,4 +1,4 @@
-name: CI
+name: Build with LLVM Flang
 
 on: [push, pull_request]
 
@@ -8,11 +8,12 @@ jobs:
     runs-on: ${{ matrix.os }}
     strategy:
       matrix:
-        os: [macOS-12, ubuntu-24.04]
+        os: [ubuntu-24.04]
       fail-fast: true
+    container: gmao/llvm-flang:latest
     env:
-      FC: gfortran
-      GCC_V: 14
+      FC: flang-new
+      CC: clang
 
     steps:
     - name: Checkout code
@@ -22,28 +23,10 @@ jobs:
       with:
         github-token: ${{ secrets.GITHUB_TOKEN }}
 
-    - name: Install Dependencies MacOS
-      if: contains(matrix.os, 'mac')
-      run: |
-        brew install gcc@${GCC_V}
-        sudo ln -s $(which gfortran-${GCC_V}) $(dirname $(which gfortran-${GCC_V}))/gfortran
-
-    - name: Install on Ubuntu
-      if: contains(matrix.os, 'ubuntu')
-      run: |
-        sudo apt update
-        sudo apt install -y build-essential gfortran-14 gcc-14 g++-14
-
-    - name: Build and Test MacOS
-      if: contains(matrix.os, 'mac')
-      run: |
-        export PATH="${HOME}/.local/bin:$PATH"
-        ./setup.sh
-
-    - name: Build and Test Ubuntu
+    - name: Build and Test with LLVM Flang
       if: contains(matrix.os, 'ubuntu')
       run: |
         fpm --version
-        export FPM_FC=gfortran-14
-        export FPM_CC=gcc-14
-        fpm test
+        export FPM_FC=$FC
+        export FPM_CC=$CC
+        fpm test --flag "-mmlir -allow-assumed-rank -O3"
diff --git a/.github/workflows/build-with-flang.yml b/.github/workflows/build-with-flang.yml
deleted file mode 100644
index 7bd2849dc..000000000
--- a/.github/workflows/build-with-flang.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-name: Build with LLVM-Flang
-
-on: [push, pull_request]
-
-
-jobs:
-  Build:
-    runs-on: ${{ matrix.os }}
-    strategy:
-      matrix:
-        os: [ubuntu-24.04]
-      fail-fast: true
-    container: gmao/llvm-flang:latest
-    env:
-      FC: flang-new
-      CC: clang
-
-    steps:
-    - name: Checkout code
-      uses: actions/checkout@v2
-
-    - uses: fortran-lang/setup-fpm@v4
-      with:
-        github-token: ${{ secrets.GITHUB_TOKEN }}
-
-    - name: Build and Test
-      if: contains(matrix.os, 'ubuntu')
-      run: |
-        fpm --version
-        export FPM_FC=$FC
-        export FPM_CC=$CC
-        fpm test --flag "-mmlir -allow-assumed-rank -O3"

From d134548d02b53a8db4bb7baf43f22edd3173ebfe Mon Sep 17 00:00:00 2001
From: Katherine Rasmussen <krasmussen@lbl.gov>
Date: Tue, 3 Sep 2024 15:00:54 -0700
Subject: [PATCH 3/4] Update .github/workflows/CI.yml

Co-authored-by: Damian Rouson <rouson@lbl.gov>
---
 .github/workflows/CI.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index ac2e16395..27dbc968b 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -27,6 +27,7 @@ jobs:
       if: contains(matrix.os, 'ubuntu')
       run: |
         fpm --version
+        flang-new --version
         export FPM_FC=$FC
         export FPM_CC=$CC
         fpm test --flag "-mmlir -allow-assumed-rank -O3"

From 0221ee08dd78ce95a33d343a5f6740cf9d320dcb Mon Sep 17 00:00:00 2001
From: Katherine Rasmussen <krasmussen@lbl.gov>
Date: Tue, 3 Sep 2024 15:08:01 -0700
Subject: [PATCH 4/4] Add version check to CI

---
 .github/workflows/CI.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index 27dbc968b..021833e93 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -27,7 +27,8 @@ jobs:
       if: contains(matrix.os, 'ubuntu')
       run: |
         fpm --version
-        flang-new --version
+        $FC --version
+        $CC --version
         export FPM_FC=$FC
         export FPM_CC=$CC
         fpm test --flag "-mmlir -allow-assumed-rank -O3"
