From ed4f8cd95865a85048392ffce9903dacb22cdf43 Mon Sep 17 00:00:00 2001 From: Gaurav Dhingra Date: Tue, 18 Mar 2025 12:53:26 +0530 Subject: [PATCH 1/4] CI: add build and validation of POT3D with LFortran compiler --- .github/workflows/CI.yml | 44 ++++++++++++++++++++++++++++++------- ci/environment_lfortran.yml | 8 +++++++ 2 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 ci/environment_lfortran.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 47ae7c4..d50fe2a 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} @@ -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 From ed9f278cee8e849c87e91960e17bf4aecea54c60 Mon Sep 17 00:00:00 2001 From: Gaurav Dhingra Date: Tue, 18 Mar 2025 12:55:09 +0530 Subject: [PATCH 2/4] add shell script for build and run with LFortran compiler --- tests/pot3d/build_and_run_lfortran.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 tests/pot3d/build_and_run_lfortran.sh diff --git a/tests/pot3d/build_and_run_lfortran.sh b/tests/pot3d/build_and_run_lfortran.sh new file mode 100755 index 0000000..e604302 --- /dev/null +++ b/tests/pot3d/build_and_run_lfortran.sh @@ -0,0 +1,20 @@ +set -ex +git clean -dfx + +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 From 0f7bb88705f91d6574fd751bccf47214571b5060 Mon Sep 17 00:00:00 2001 From: Gaurav Dhingra Date: Tue, 18 Mar 2025 13:05:10 +0530 Subject: [PATCH 3/4] add file for build and run with LFortran compiler --- tests/pot3d/build_and_run_lfortran.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/pot3d/build_and_run_lfortran.sh b/tests/pot3d/build_and_run_lfortran.sh index e604302..51b5719 100755 --- a/tests/pot3d/build_and_run_lfortran.sh +++ b/tests/pot3d/build_and_run_lfortran.sh @@ -1,5 +1,4 @@ set -ex -git clean -dfx if [[ "$(uname)" == "Linux" ]]; then CC=gcc From acf6d75639c096c767b85543b9a3444aebbc8355 Mon Sep 17 00:00:00 2001 From: Gaurav Dhingra Date: Tue, 18 Mar 2025 13:14:36 +0530 Subject: [PATCH 4/4] CI: use -O3 -march=native flags for compiling with GFortran --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d50fe2a..7f4e32c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -35,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)