diff --git a/field_RANKSUFF_factory_module.fypp b/field_RANKSUFF_factory_module.fypp index afe096f..480f25a 100644 --- a/field_RANKSUFF_factory_module.fypp +++ b/field_RANKSUFF_factory_module.fypp @@ -188,6 +188,8 @@ USE FIELD_STATISTICS_MODULE CLASS(${ft.name}$), POINTER :: FIELD_PTR +IF(.NOT. ASSOCIATED(FIELD_PTR)) RETURN + IF (FIELD_STATISTICS_ENABLE) CALL FIELD_STATISTICS_DELETE () CALL FIELD_PTR%FINAL () diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a070f49..a88899a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,18 +26,6 @@ target_compile_definitions( main.x PRIVATE $<${HAVE_CUDA}:_CUDA> ) ## Unit tests list(APPEND TEST_FILES - test_legacy.F90 - test_field_array.F90 - gather_scatter_lastdim.F90 - reshuffle_lastdim.F90 - test_lastdim.F90 - test_statistics.F90 - test_sizeof.F90 - test_bc.F90 - reshuffle.F90 - test_wrappernosynconfinal.F90 - test_field1d.F90 - test_pinned.F90 async_host.F90 cpu_to_gpu.F90 cpu_to_gpu_delayed_init_value.F90 @@ -47,6 +35,7 @@ list(APPEND TEST_FILES final_wrapper.F90 final_wrapper_gpu.F90 gather_scatter.F90 + gather_scatter_lastdim.F90 get_dims.F90 get_stats.F90 get_view.F90 @@ -75,15 +64,27 @@ list(APPEND TEST_FILES no_transfer_get_device.F90 no_transfer_get_host.F90 pointer_to_owner_wrapper.F90 + reshuffle.F90 + reshuffle_lastdim.F90 resize_owner.F90 resize_owner2.F90 sync_device.F90 sync_host.F90 + test_bc.F90 test_crc64.F90 - wrapper_modify_gpu.F90 + test_field1d.F90 + test_field_array.F90 + test_field_delete_on_null.F90 test_gang.F90 test_get_device_data_wronly.F90 test_host_mem_pool.F90 + test_lastdim.F90 + test_legacy.F90 + test_pinned.F90 + test_sizeof.F90 + test_statistics.F90 + test_wrappernosynconfinal.F90 + wrapper_modify_gpu.F90 ) #Place-holder for failing tests diff --git a/tests/test_field_delete_on_null.F90 b/tests/test_field_delete_on_null.F90 new file mode 100644 index 0000000..2f451f5 --- /dev/null +++ b/tests/test_field_delete_on_null.F90 @@ -0,0 +1,18 @@ +! (C) Copyright 2022- ECMWF. +! (C) Copyright 2022- Meteo-France. +! +! This software is licensed under the terms of the Apache Licence Version 2.0 +! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +! In applying this licence, ECMWF does not waive the privileges and immunities +! granted to it by virtue of its status as an intergovernmental organisation +! nor does it submit to any jurisdiction. + +PROGRAM TEST_FIELD_DELETE_ON_NULL + !TEST IF CALLING FIELD_DELETE WITH A NULL POINTER IS WORKING AS IT SHOULD + + USE FIELD_MODULE + USE FIELD_FACTORY_MODULE + IMPLICIT NONE + CLASS(FIELD_1RB), POINTER :: W => NULL() + CALL FIELD_DELETE(W) +END PROGRAM