Skip to content

CI: add build and validation of POT3D with LFortran compiler #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 37 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:

jobs:
Compile_POT3D_with_GFortran:
name: "Build POT3D and validate"
name: "Build POT3D and validate with GFortran"
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -27,13 +27,6 @@ jobs:
micromamba-version: '2.0.4-0'
environment-file: ci/environment_gfortran.yml

- name: Verify Environment
shell: bash -e -x -l {0}
run: |
echo "Active Environment: $MAMBA_DEFAULT_ENV"
which gfortran || { echo "gfortran not found"; exit 1; }
which mpif90 || { echo "mpif90 not found"; exit 1; }

# build and validation with GFortran's optimization
- name: POT3D Build and validation with GFortran with optimization (MPI only)
shell: bash -e -x -l {0}
Expand All @@ -42,7 +35,7 @@ jobs:
cp src/mpi_c_bindings.f90 tests/pot3d/src/
cp src/mpi_wrapper.c tests/pot3d/src/
cd tests/pot3d
FC="gfortran -O3" ./build_and_run_gfortran.sh
FC="gfortran -O3 -march=native" ./build_and_run_gfortran.sh

# build and validation without GFortran's optimization
- name: POT3D Build and validation with GFortran without optimization (MPI only)
Expand All @@ -53,3 +46,38 @@ jobs:
cp src/mpi_wrapper.c tests/pot3d/src/
cd tests/pot3d
FC="gfortran" ./build_and_run_gfortran.sh

Compile_POT3D_with_LFortran:
name: "Build POT3D and validate with LFortran"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["macos-latest", "ubuntu-20.04"]
steps:
- uses: actions/checkout@v4

- name: Set up Micromamba
uses: mamba-org/setup-micromamba@v2.0.2
with:
micromamba-version: '2.0.4-0'
environment-file: ci/environment_lfortran.yml

# build and validation with LFortran's optimization
- name: POT3D Build and validation with LFortran with optimization (MPI only)
shell: bash -e -x -l {0}
run: |
cp src/mpi.f90 tests/pot3d/src/
cp src/mpi_c_bindings.f90 tests/pot3d/src/
cp src/mpi_wrapper.c tests/pot3d/src/
cd tests/pot3d
FC="lfortran --fast" ./build_and_run_lfortran.sh

# build and validation without LFortran's optimization
- name: POT3D Build and validation with GFortran without optimization (MPI only)
shell: bash -e -x -l {0}
run: |
cp src/mpi.f90 tests/pot3d/src/
cp src/mpi_c_bindings.f90 tests/pot3d/src/
cp src/mpi_wrapper.c tests/pot3d/src/
cd tests/pot3d
FC="lfortran" ./build_and_run_lfortran.sh
8 changes: 8 additions & 0 deletions ci/environment_lfortran.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: c_mpi_lfortran_env
channels:
- conda-forge
dependencies:
- lfortran=0.49.0
- make
- cmake
- openmpi=5.0.6
19 changes: 19 additions & 0 deletions tests/pot3d/build_and_run_lfortran.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set -ex

if [[ "$(uname)" == "Linux" ]]; then
CC=gcc
else
CC=clang
fi

cd src
$CC -I$CONDA_PREFIX/include -c mpi_wrapper.c
$FC -c mpi_c_bindings.f90
$FC -c mpi.f90
$FC -c psi_io.f90 --no-style-warnings --no-warnings
$FC -c --cpp --implicit-interface pot3d.F90 --no-style-warnings --no-warnings
$FC mpi_wrapper.o mpi_c_bindings.o mpi.o psi_io.o pot3d.o -o pot3d -L$CONDA_PREFIX/lib -lmpi -Wl,-rpath,$CONDA_PREFIX/lib
cp pot3d ../bin/

cd ..
./validate.sh