Skip to content
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

Initial unit testing implementation #89

Merged
merged 6 commits into from
May 10, 2021
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
60 changes: 46 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,64 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-10.15]
os: [ubuntu-latest, macos-latest]
mpi: [true, false]
openmp: ['enabled', 'disabled']
exclude:
# Do not build on macOS with MPI as that is having some dependency issues
- os: macos-latest
mpi: true
steps:
- name: Install dependencies - Ubuntu
run: |
sudo apt update
sudo apt install -y libnetcdff-dev mpi-default-dev
sudo apt install -y libnetcdff-dev mpi-default-dev ninja-build
if: runner.os == 'Linux'

- name: Install dependencies - macOS
run: brew install netcdf open-mpi
run: brew install netcdf open-mpi ninja
env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
if: runner.os == 'macOS'

- name: Checkout code
uses: actions/checkout@v2

- name: Setup Python for newer version of Meson
uses: actions/setup-python@v2

- name: Run Meson build step
uses: BSFishy/[email protected]
- name: Install Meson
run: python -m pip install meson==${{ env.MESON_VERSION }}

- name: Checkout code
uses: actions/checkout@v2

- name: Build
env:
CC: gcc-10
FC: gfortran-10
run: |
meson setup builddir -Dmpi=${{ matrix.mpi }} -Dopenmp=${{ matrix.openmp }} --buildtype=debugoptimized
meson compile -C builddir
- name: Test code
if: ${{ matrix.mpi == false }}
run: |
ulimit -s 65532
meson test -C builddir
- name: Upload test log
if: ${{ matrix.mpi == false }}
uses: actions/upload-artifact@v2
with:
action: build
directory: builddir
setup-options: -Dmpi=${{ matrix.mpi }}
meson-version: ${{ env.MESON_VERSION }}
name: testlog-${{ runner.os }}-gcc
path: builddir/meson-logs/testlog.txt

intel:
name: Build BLOM using Intel compilers
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
mpi: [true, false]
openmp: ['enabled', 'disabled']
# Tell Meson to use Intel compilers
env:
CC: icc
Expand All @@ -59,7 +79,6 @@ jobs:
run: |
sudo apt update
sudo apt install -y ninja-build libnetcdf-dev
- name: Cache Intel setup
id: cache-intel
uses: actions/cache@v2
Expand Down Expand Up @@ -117,5 +136,18 @@ jobs:
- name: Build with Intel compilers
run: |
source /opt/intel/oneapi/setvars.sh
meson setup builddir -Dmpi=${{ matrix.mpi }}
meson setup builddir -Dmpi=${{ matrix.mpi }} -Dopenmp=${{ matrix.openmp }} --buildtype=debugoptimized
meson compile -C builddir
- name: Test code
if: ${{ matrix.mpi == false }}
run: |
source /opt/intel/oneapi/setvars.sh
meson test -C builddir
- name: Upload test log
uses: actions/upload-artifact@v2
if: ${{ matrix.mpi == false }}
with:
name: testlog-${{ runner.os }}-intel
path: builddir/meson-logs/testlog.txt
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,25 @@ $ meson compiler -C builddir
After the first line all subsequent compiles (and changes with `meson
configure`) will utilize the Intel compiler to build and link BLOM.

### Running tests
After successfully building the code it can be a good idea to test that the code
behaves as expected and changes to the code does not affect the output.

Tests can be run with the following:

```bash
$ meson test -C builddir
```

The previous command will run all the test suites defined for BLOM. To run tests
quicker one can select a few tests to run or just a single test suite. To list
the available tests run `meson test -C builddir --list`. One can then run a
single test with:

```bash
$ meson test -C builddir "run single_column"
```

### Working with the BLOM git repository

The [BLOM wiki](https://github.com/NorESMhub/BLOM/wiki) includes instructions on how to contribute to the BLOM/iHAMOCC model system, and how to work with the BLOM git repository with your own fork on gitHub.
Expand Down
7 changes: 5 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ deps = [netcdf, omp, quadmath]
includes = [phy_inc]

# List of all sources in the project (should be added to in subfolders)
sources = [dimensions]
sources = []

# Process the following subdirectories which contain other 'meson.build' files
# that will add files to build into 'sources'
Expand Down Expand Up @@ -135,8 +135,11 @@ if get_option('parallel_netcdf')
endif
endif

# Handle Unit Testing
subdir('tests')

# Create BLOM executable
executable('blom', sources,
executable('blom', sources, dimensions,
include_directories: includes,
dependencies: deps,
link_language: 'fortran')
2 changes: 1 addition & 1 deletion phy/mod_xc_mp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ c
#else
call abort()
#endif
stop '(xchalt)'
error stop '(xchalt)'
end subroutine xchalt

subroutine xclget(aline,nl, a, i1,j1,iinc,jinc, mnflg)
Expand Down
2 changes: 1 addition & 1 deletion phy/mod_xc_sm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ c
write(lp,*) '**************************************************'
call flush(lp)
endif
stop '(xchalt)'
error stop '(xchalt)'
end subroutine xchalt

subroutine xclget(aline,nl, a, i1,j1,iinc,jinc, mnflg)
Expand Down
9 changes: 9 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore test output files
*.nc
rstdate.txt
run.status
salbud
tembud
tkebud
trcbud
trcbudtot
Loading