Skip to content
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
53 changes: 37 additions & 16 deletions .github/workflows/end-to-end-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,44 @@ jobs:
which pytest
- name: Run end-to-end tests
run: |
cmake --fresh -S./end-to-end-tests -B./build
cmake --fresh -S./end-to-end-tests -B./build \
-DCMAKE_Fortran_COMPILER=${{matrix.fortran-compiler}}
cd build
make
ctest --rerun-failed --output-on-failure .

# - name: Run python tests
# run: |
# BUILD_DIR=./build \
# PYTHONPATH=test/:scripts/ \
# pytest \
# test/capgen_test/capgen_test_reports.py \
# test/advection_test/advection_test_reports.py \
# test/ddthost_test/ddthost_test_reports.py \
# test/var_compatibility_test/var_compatibility_test_reports.py
#
# - name: Run Fortran to metadata test
# run: cd test && ./test_fortran_to_metadata.sh
#
# - name: Run offline metadata parser test
# run: cd test && ./test_offline_metadata_checker.sh
# End to end tests with memory-error detection enabled
end-to-end-tests-asan:
needs: end-to-end-tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Update repos and install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libopenmpi-dev \
gfortran-12 \
cmake \
python3 \
git \
libxml2-utils
python -m pip install --upgrade pip
pip install pytest
- name: Run end-to-end tests under AddressSanitizer
env:
# Check for memory errors (LeakSanitizer is a separate issue)
ASAN_OPTIONS: "detect_leaks=0"
run: |
cmake --fresh -S./end-to-end-tests -B./build \
-DCMAKE_Fortran_COMPILER=gfortran-12 \
-DCMAKE_Fortran_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
cd build
make
ctest --rerun-failed --output-on-failure .
27 changes: 15 additions & 12 deletions end-to-end-tests/advection/test_host.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,21 @@ subroutine test_host(retval, test_suites)
end if
end do

if (errcode == 0) then
! Run finished without error, check answers. phys_state%q points into the
! constituent array, so this has to happen before the teardown below.
if (compare_data(num_advected)) then
write(6, *) 'Answers are correct!'
else
write(6, *) 'Answers are not correct!'
errcode_final = -1
end if
end if

! The constituent tables hold pointers into the per-suite dynamic
! constituent buffers, which ccpp_final frees - tear down first.
call ccpp_deallocate_dynamic_constituents()

do sind = 1, num_suites
if (errcode == 0) then
call ccpp_final(suite_name=test_suites(sind)%suite_name, &
Expand All @@ -1145,20 +1160,8 @@ subroutine test_host(retval, test_suites)
end if
end do

call ccpp_deallocate_dynamic_constituents()
deallocate(host_constituents)

if (errcode == 0) then
! Run finished without error, check answers
if (compare_data(num_advected)) then
write(6, *) 'Answers are correct!'
errcode = 0
else
write(6, *) 'Answers are not correct!'
errcode = -1
end if
end if

! Make sure "final" flag is non-zero if "errcode" is:
if (errcode /= 0) then
errcode_final = -1 ! Notify test script that a failure occured
Expand Down
27 changes: 15 additions & 12 deletions end-to-end-tests/advection_auto_clone/test_host.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,21 @@ subroutine test_host(retval, test_suites)
end if
end do

if (errcode == 0) then
! Run finished without error, check answers. phys_state%q points into the
! constituent array, so this has to happen before the teardown below.
if (compare_data(num_advected)) then
write(6, *) 'Answers are correct!'
else
write(6, *) 'Answers are not correct!'
errcode_final = -1
end if
end if

! The constituent tables hold pointers into the per-suite dynamic
! constituent buffers, which ccpp_final frees - tear down first.
call ccpp_deallocate_dynamic_constituents()

do sind = 1, num_suites
if (errcode == 0) then
call ccpp_final(suite_name=test_suites(sind)%suite_name, &
Expand All @@ -1133,20 +1148,8 @@ subroutine test_host(retval, test_suites)
end if
end do

call ccpp_deallocate_dynamic_constituents()
deallocate(host_constituents)

if (errcode == 0) then
! Run finished without error, check answers
if (compare_data(num_advected)) then
write(6, *) 'Answers are correct!'
errcode = 0
else
write(6, *) 'Answers are not correct!'
errcode = -1
end if
end if

! Make sure "final" flag is non-zero if "errcode" is:
if (errcode /= 0) then
errcode_final = -1 ! Notify test script that a failure occured
Expand Down
5 changes: 4 additions & 1 deletion end-to-end-tests/constituents_dim/main.F90
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ program test_constituents_dim
errmsg=errmsg, errcode=errcode)
call check('ccpp_physics_final')

! The constituent tables hold pointers into the per-suite dynamic
! constituent buffers, which ccpp_final frees - tear down first.
call ccpp_deallocate_dynamic_constituents()

! ccpp_final -> suite_data_final_fields frees both suite workspaces (guarded).
call ccpp_final(suite_name=trim(ccpp_suite), errmsg=errmsg, errcode=errcode)
call check('ccpp_final')

call ccpp_deallocate_dynamic_constituents()
deallocate(host_constituents)
if (allocated(coupler_flux)) deallocate(coupler_flux)

Expand Down
39 changes: 20 additions & 19 deletions end-to-end-tests/instances_advection/main.F90
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,23 @@ program test_instances_advection

!-----------------------------------------------------------------
! 2. Build the host-registered constituent list (specific_humidity)
! and call ccpp_register_constituents per instance. Each call
! consumes the host_consts array (new_field sets const_index on
! the input objects), so we re-instantiate per instance.
! once and call ccpp_register_constituents per instance.
! host_consts must outlive the constituent tables, which keep
! pointers into it -- hence the deallocate after teardown.

@climbfuji climbfuji Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deallocate is and remains at line 252.

!-----------------------------------------------------------------
allocate(host_consts(1))
call host_consts(1)%instantiate( &
std_name='water_vapor_specific_humidity', &
long_name='Water vapor specific humidity', &
diag_name='QV', units='kg kg-1', &
vertical_dim='vertical_layer_dimension', advected=.true., &
default_value=0.0_kind_phys, mixing_ratio_type='wet', &
errcode=errcode, errmsg=errmsg)
if (errcode /= 0) then
write(error_unit, '(2a)') 'instantiate failed: ', trim(errmsg)
stop 1
end if
do ins = 1, ninstances
if (allocated(host_consts)) deallocate(host_consts)
allocate(host_consts(1))
call host_consts(1)%instantiate( &
std_name='water_vapor_specific_humidity', &
long_name='Water vapor specific humidity', &
diag_name='QV', units='kg kg-1', &
vertical_dim='vertical_layer_dimension', advected=.true., &
default_value=0.0_kind_phys, mixing_ratio_type='wet', &
errcode=errcode, errmsg=errmsg)
if (errcode /= 0) then
write(error_unit, '(2a)') 'instantiate failed: ', trim(errmsg)
stop 1
end if
call ccpp_register_constituents(host_constituents=host_consts, &
instance=ins, ninstances=ninstances, &
errmsg=errmsg, errcode=errcode)
Expand Down Expand Up @@ -235,6 +234,11 @@ program test_instances_advection
!-----------------------------------------------------------------
! 10. Teardown.
!-----------------------------------------------------------------
! The constituent tables hold pointers into the per-suite dynamic
! constituent buffers, which ccpp_final frees - tear down first.
do ins = 1, ninstances
call ccpp_deallocate_dynamic_constituents(instance=ins)
end do
do ins = 1, ninstances
call ccpp_final(suite_name=ccpp_suite, &
instance=ins, ninstances=ninstances, &
Expand All @@ -245,9 +249,6 @@ program test_instances_advection
stop 1
end if
end do
do ins = 1, ninstances
call ccpp_deallocate_dynamic_constituents(instance=ins)
end do
deallocate(host_consts)

write(6, '(a)') 'PASS: per-instance + constituents test'
Expand Down
Loading