diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 47ae7c4..7f4e32c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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: @@ -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} @@ -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) @@ -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 diff --git a/ci/environment_lfortran.yml b/ci/environment_lfortran.yml new file mode 100644 index 0000000..047eaab --- /dev/null +++ b/ci/environment_lfortran.yml @@ -0,0 +1,8 @@ +name: c_mpi_lfortran_env +channels: + - conda-forge +dependencies: + - lfortran=0.49.0 + - make + - cmake + - openmpi=5.0.6 diff --git a/tests/pot3d/build_and_run_lfortran.sh b/tests/pot3d/build_and_run_lfortran.sh new file mode 100755 index 0000000..51b5719 --- /dev/null +++ b/tests/pot3d/build_and_run_lfortran.sh @@ -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