diff --git a/.github/actions/build_run_model/action.yml b/.github/actions/build_run_model/action.yml index 31bb34fb9..f4311c26b 100644 --- a/.github/actions/build_run_model/action.yml +++ b/.github/actions/build_run_model/action.yml @@ -22,6 +22,11 @@ inputs: description: 'arguments to use when running specified program' required: false default: '' + compiler: + description: 'compiler to use when building and running model' + type: string + required: false + default: gfortran use-mpi: description: 'specify whether to run program without MPI, with MPI, or with MPIF08' type: string @@ -32,6 +37,10 @@ inputs: type: number required: false default: 2 + +defaults: + run: + shell: bash -elo pipefail {0} runs: using: "composite" @@ -40,44 +49,56 @@ runs: - name: Creating Makefile template :) run: | cd build_templates - cp mkmf.template.gfortran mkmf.template - echo 'FFLAGS = -g -Wuninitialized -Wunused -ffree-line-length-none -fbounds-check -fbacktrace -ffpe-trap=invalid,zero,overflow $(INCS)' >> mkmf.template - shell: bash + case ${{ inputs.compiler }} in + gfortran) + cp mkmf.template.gfortran mkmf.template + echo 'FFLAGS = -g -Wuninitialized -Wunused -ffree-line-length-none -fbounds-check -fbacktrace -ffpe-trap=invalid,zero,overflow $(INCS)' >> mkmf.template + ;; + nvhpc) + cp mkmf.template.nvhpc mkmf.template + echo 'FFLAGS = -gopt -C -traceback -Ktrap=fp -Mbackslash -Kieee $(INCS)' >> mkmf.template + ;; + *) + echo "Unknown or unsupported compiler: ${{ inputs.compiler }}" >&2 + exit 1 + ;; + esac + shell: bash -elo pipefail {0} # Steps to compile and build model - name: Building ${{ inputs.model }} model (use-mpi=nompi) if: ${{ inputs.use-mpi == 'nompi' }} run: | cd ${{ inputs.models-directory }}/${{ inputs.model }}/work ./quickbuild.sh nompi - shell: bash + shell: bash -elo pipefail {0} - name: Building ${{ inputs.model }} model (use-mpi=mpi) if: ${{ inputs.use-mpi == 'mpi' }} run: | cd ${{ inputs.models-directory }}/${{ inputs.model }}/work ./quickbuild.sh - shell: bash + shell: bash -elo pipefail {0} - name: Building ${{ inputs.model }} model (use-mpi=mpif08) if: ${{ inputs.use-mpi == 'mpif08' }} run: | cd ${{ inputs.models-directory }}/${{ inputs.model }}/work ./quickbuild.sh mpif08 - shell: bash + shell: bash -elo pipefail {0} # Steps to run the specified run-program with mpi options - name: Running ${{ inputs.model }} ${{ inputs.run-program }} program (use-mpi=nompi) if: ${{ inputs.use-mpi == 'nompi' }} run: | cd ${{ inputs.models-directory }}/${{ inputs.model }}/work/ ./${{ inputs.run-program }} ${{ inputs.run-program-args }} - shell: bash + shell: bash -elo pipefail {0} - name: Running ${{ inputs.model }} ${{ inputs.run-program }} program (use-mpi=mpi) if: ${{ inputs.use-mpi == 'mpi' }} run: | cd ${{ inputs.models-directory }}/${{ inputs.model }}/work/ mpirun -n ${{ inputs.mpi-n-tasks }} ./${{ inputs.run-program }} ${{ inputs.run-program-args }} - shell: bash + shell: bash -elo pipefail {0} - name: Running ${{ inputs.model }} ${{ inputs.run-program }} program (use-mpi=mpif08) if: ${{ inputs.use-mpi == 'mpif08' }} run: | cd ${{ inputs.models-directory }}/${{ inputs.model }}/work/ mpirun -n ${{ inputs.mpi-n-tasks }} ./${{ inputs.run-program }} ${{ inputs.run-program-args }} - shell: bash + shell: bash -elo pipefail {0} diff --git a/.github/workflows/cirrus_action_on_pull_request.yml b/.github/workflows/cirrus_action_on_pull_request.yml new file mode 100644 index 000000000..d5617945c --- /dev/null +++ b/.github/workflows/cirrus_action_on_pull_request.yml @@ -0,0 +1,247 @@ +name: CIRRUS Action on Pull Request + +on: + pull_request: + types: [ opened, reopened, synchronize, ready_for_review ] + +jobs: + # Job 1 + build-run-lorenz_96-mpi-gfortran: + + # Runner instance OS + runs-on: + group: cirrus-4x8 + + # The 'ncarcisl' containers initialize their software environment + # through 'sourcing' a common configuration file (/container/config_env.sh). + # This is done by starting a bash *login* shell (bash -l [...]) + defaults: + run: + shell: bash -elo pipefail {0} + + # Deploy container on top of runner instance + container: + image: ncarcisl/hpcdev-x86_64:almalinux9-gcc-openmpi-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set checked out repo as a safe git directory + run: git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }} + + - name: Source container config file and modify mkmf to use 4 cores for compilation + run: | + source "/container/config_env.sh" + cd build_templates + sed -i 's|exec '\''make'\'', '\''-f'\'', \$opt_m if \$opt_x;|exec '\''make'\'', '\''-j'\'', '\''4'\'', '\''-f'\'', \$opt_m if \$opt_x;|' mkmf + + - name: Build and run lorenz_96 with mpi + uses: ./.github/actions/build_run_model + with: + model: lorenz_96 + run-program: ./filter + compiler: gfortran + use-mpi: mpi + mpi-n-tasks: 4 + + # Job 2 + build-run-lorenz_96-nompi-gfortran: + + # Runner instance OS + runs-on: + group: cirrus-4x8 + + defaults: + run: + shell: bash -elo pipefail {0} + + # Deploy container on top of runner instance + container: + image: ncarcisl/hpcdev-x86_64:almalinux9-gcc-openmpi-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set checked out repo as a safe git directory + run: git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }} + + - name: Source container config file and modify mkmf to use 4 cores for compilation + run: | + source "/container/config_env.sh" + cd build_templates + sed -i 's|exec '\''make'\'', '\''-f'\'', \$opt_m if \$opt_x;|exec '\''make'\'', '\''-j'\'', '\''4'\'', '\''-f'\'', \$opt_m if \$opt_x;|' mkmf + + - name: Build and run lorenz_63 with no mpi + uses: ./.github/actions/build_run_model + with: + model: lorenz_96 + run-program: ./filter + compiler: gfortran + use-mpi: nompi + + # Job 3 + build-run-lorenz_96-mpif08-gfortran: + + # Runner instance OS + runs-on: + group: cirrus-4x8 + + defaults: + run: + shell: bash -elo pipefail {0} + + # Deploy container on top of runner instance + container: + image: ncarcisl/hpcdev-x86_64:almalinux9-gcc-openmpi-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set checked out repo as a safe git directory + run: git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }} + + - name: Source container config file and modify mkmf to use 4 cores for compilation + run: | + source "/container/config_env.sh" + cd build_templates + sed -i 's|exec '\''make'\'', '\''-f'\'', \$opt_m if \$opt_x;|exec '\''make'\'', '\''-j'\'', '\''4'\'', '\''-f'\'', \$opt_m if \$opt_x;|' mkmf + + - name: Build and run lorenz_96 with mpif08 + uses: ./.github/actions/build_run_model + with: + model: lorenz_96 + run-program: ./filter + compiler: gfortran + use-mpi: mpif08 + mpi-n-tasks: 4 + + # Job 4 + build-run-lorenz_96-mpi-nvhpc: + + # Runner instance OS + runs-on: + group: cirrus-4x8 + + # The 'ncarcisl' containers initialize their software environment + # through 'sourcing' a common configuration file (/container/config_env.sh). + # This is done by starting a bash *login* shell (bash -l [...]) + defaults: + run: + shell: bash -elo pipefail {0} + + # Deploy container on top of runner instance + container: + image: ncarcisl/hpcdev-x86_64:almalinux9-nvhpc-openmpi-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set checked out repo as a safe git directory + run: git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }} + + # nvhpc requires some modifications to not use the ftn wrapper for derecho + - name: Source container config file and modify mkmf to use 4 cores for compilation + run: | + source "/container/config_env.sh" + cd build_templates + sed -i 's/MPIFC = ftn/MPIFC = mpif90/' mkmf.template.nvhpc + sed -i 's/MPILD = ftn/MPILD = mpif90/' mkmf.template.nvhpc + sed -i 's/LD = ftn/LD = nvfortran/' mkmf.template.nvhpc + sed -i 's/FC = ftn/FC = nvfortran/' mkmf.template.nvhpc + sed -i 's|exec '\''make'\'', '\''-f'\'', \$opt_m if \$opt_x;|exec '\''make'\'', '\''-j'\'', '\''4'\'', '\''-f'\'', \$opt_m if \$opt_x;|' mkmf + + - name: Build and run lorenz_96 with mpi + uses: ./.github/actions/build_run_model + with: + model: lorenz_96 + run-program: ./filter + compiler: nvhpc + use-mpi: mpi + mpi-n-tasks: 4 + + # Job 5 + build-run-lorenz_96-nompi-nvhpc: + + # Runner instance OS + runs-on: + group: cirrus-4x8 + + defaults: + run: + shell: bash -elo pipefail {0} + + # Deploy container on top of runner instance + container: + image: ncarcisl/hpcdev-x86_64:almalinux9-nvhpc-openmpi-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set checked out repo as a safe git directory + run: git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }} + + # nvhpc requires some modifications to not use the ftn wrapper for derecho + - name: Source container config file and modify mkmf to use 4 cores for compilation + run: | + source "/container/config_env.sh" + cd build_templates + sed -i 's/MPIFC = ftn/MPIFC = mpif90/' mkmf.template.nvhpc + sed -i 's/MPILD = ftn/MPILD = mpif90/' mkmf.template.nvhpc + sed -i 's/LD = ftn/LD = nvfortran/' mkmf.template.nvhpc + sed -i 's/FC = ftn/FC = nvfortran/' mkmf.template.nvhpc + sed -i 's|exec '\''make'\'', '\''-f'\'', \$opt_m if \$opt_x;|exec '\''make'\'', '\''-j'\'', '\''4'\'', '\''-f'\'', \$opt_m if \$opt_x;|' mkmf + + - name: Build and run lorenz_63 with no mpi + uses: ./.github/actions/build_run_model + with: + model: lorenz_96 + run-program: ./filter + compiler: nvhpc + use-mpi: nompi + + # Job 6 + build-run-lorenz_96-mpif08-nvhpc: + + # Runner instance OS + runs-on: + group: cirrus-4x8 + + defaults: + run: + shell: bash -elo pipefail {0} + + # Deploy container on top of runner instance + container: + image: ncarcisl/hpcdev-x86_64:almalinux9-nvhpc-openmpi-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set checked out repo as a safe git directory + run: git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }} + + # nvhpc requires some modifications to not use the ftn wrapper for derecho + - name: Source container config file and modify mkmf to use 4 cores for compilation + run: | + source "/container/config_env.sh" + cd build_templates + sed -i 's/MPIFC = ftn/MPIFC = mpif90/' mkmf.template.nvhpc + sed -i 's/MPILD = ftn/MPILD = mpif90/' mkmf.template.nvhpc + sed -i 's/LD = ftn/LD = nvfortran/' mkmf.template.nvhpc + sed -i 's/FC = ftn/FC = nvfortran/' mkmf.template.nvhpc + sed -i 's|exec '\''make'\'', '\''-f'\'', \$opt_m if \$opt_x;|exec '\''make'\'', '\''-j'\'', '\''4'\'', '\''-f'\'', \$opt_m if \$opt_x;|' mkmf + + - name: Build and run lorenz_96 with mpif08 + uses: ./.github/actions/build_run_model + with: + model: lorenz_96 + run-program: ./filter + compiler: nvhpc + use-mpi: mpif08 + mpi-n-tasks: 4