diff --git a/src/LIB/SURCOUCHE/src/modd_io.f90 b/src/LIB/SURCOUCHE/src/modd_io.f90 index 9adeafca2459e842d11820c2d02d76334069e1fd..30e10a476387def21b9a305e940bd4625b81940a 100644 --- a/src/LIB/SURCOUCHE/src/modd_io.f90 +++ b/src/LIB/SURCOUCHE/src/modd_io.f90 @@ -136,7 +136,7 @@ TYPE TFILEDATA INTEGER(KIND=CDFINT) :: NNCCOMPRESS_LOSSY_NSD = 3 ! Number of Significant Digits (or Bits) TYPE(TDIMSNC), POINTER :: TNCDIMS => NULL() ! Dimensions of netCDF file INTEGER(KIND=CDFINT), DIMENSION(:), ALLOCATABLE :: NBOXNCID ! Box HDF group identifiers (used for MNHOUTPUT files) - TYPE(TDIMSNC), DIMENSION(:), POINTER :: TBOXNCDIMS => NULL() ! Box dimensions of netCDF file (used for MNHOUTPUT files) + TYPE(TDIMSNC), DIMENSION(:), POINTER :: TBOXNCDIMS => NULL() ! Box dimensions of netCDF file (used for MNHOUTPUT files) #endif ! !Fields for other files diff --git a/src/LIB/SURCOUCHE/src/modd_netcdf.f90 b/src/LIB/SURCOUCHE/src/modd_netcdf.f90 index f2e5067755b7511dea9ce44d4b599a27e00c390a..814e2c98d04e3625d4b641807dd97b07a7aafc32 100644 --- a/src/LIB/SURCOUCHE/src/modd_netcdf.f90 +++ b/src/LIB/SURCOUCHE/src/modd_netcdf.f90 @@ -1,4 +1,4 @@ -!MNH_LIC Copyright 1994-2020 CNRS, Meteo-France and Universite Paul Sabatier +!MNH_LIC Copyright 1994-2024 CNRS, Meteo-France and Universite Paul Sabatier !MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence !MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt !MNH_LIC for details. version 1. @@ -15,6 +15,8 @@ implicit none public +private :: tdimsnc_destructor + integer, parameter :: NMAXDIMNAMELGTNC4 = 16 !Datatype to store metadata of 1 dimension @@ -30,6 +32,19 @@ type tdimsnc type(tdimnc), dimension(:), pointer :: tdims => null() integer :: nmaxdims_str = 0 ! For character strings type(tdimnc), dimension(:), pointer :: tdims_str => null() ! For character strings + + contains + private + final :: tdimsnc_destructor end type tdimsnc +contains + +elemental subroutine tdimsnc_destructor( tpdimsnc) + type(tdimsnc), intent(inout) :: tpdimsnc + + if ( associated( tpdimsnc%tdims ) ) deallocate( tpdimsnc%tdims ) + if ( associated( tpdimsnc%tdims_str ) ) deallocate( tpdimsnc%tdims_str ) +end subroutine tdimsnc_destructor + end module modd_netcdf diff --git a/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 index 90c0f220f7ffd425586070b7b0f9a45dbf67e75f..e1a4a866bcc5a59c680f0031b111e246be94739f 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 @@ -696,9 +696,7 @@ TYPE(tdimsnc), POINTER :: tpdimsnc CALL PRINT_MSG(NVERB_DEBUG,'IO','IO_Iocdf_dealloc_nc4','called') -if ( Associated( tpdimsnc%tdims ) ) deallocate( tpdimsnc%tdims ) -if ( Associated( tpdimsnc%tdims_str ) ) deallocate( tpdimsnc%tdims_str ) - +! tpdimsnc components are deallocated / cleaned in the tdimsnc finalizer deallocate( tpdimsnc ) tpdimsnc => Null()