From 2f398491f7e7aa5b04d1b52b6f30baa80d68b012 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 5 Dec 2024 15:07:01 -0500 Subject: [PATCH 1/2] only memory leak related --- dyn_em/start_em.F | 1 + share/wrf_timeseries.F | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dyn_em/start_em.F b/dyn_em/start_em.F index 97a5bfcdcf..96057ebdfb 100644 --- a/dyn_em/start_em.F +++ b/dyn_em/start_em.F @@ -2001,6 +2001,7 @@ SUBROUTINE start_domain_em ( grid, allowed_to_read & #endif DEALLOCATE(z_at_q) +DEALLOCATE(dz8w) IF (config_flags%p_lev_diags == PRESS_DIAGS ) THEN CALL wrf_debug ( 200 , ' PLD: pressure level diags' ) diff --git a/share/wrf_timeseries.F b/share/wrf_timeseries.F index cab5a0aa10..9755ee45bc 100644 --- a/share/wrf_timeseries.F +++ b/share/wrf_timeseries.F @@ -356,10 +356,20 @@ SUBROUTINE calc_ts( grid ) ALLOCATE ( earth_u_profile(grid%max_ts_level), earth_v_profile(grid%max_ts_level) ) #endif - IF ( grid%ntsloc_domain .LE. 0 ) RETURN + IF ( grid%ntsloc_domain .LE. 0 ) THEN +#if ( EM_CORE == 1 ) + DEALLOCATE(earth_u_profile, earth_v_profile) +#endif + RETURN + END IF #if ((EM_CORE == 1) && (DA_CORE != 1)) - IF ( grid%dfi_opt /= DFI_NODFI .AND. grid%dfi_stage /= DFI_FST ) RETURN + IF ( grid%dfi_opt /= DFI_NODFI .AND. grid%dfi_stage /= DFI_FST ) THEN +#if ( EM_CORE == 1 ) + DEALLOCATE(earth_u_profile, earth_v_profile) +#endif + RETURN + END IF #endif n = grid%next_ts_time From be5b815d772cef36fc171e22bc81c45083f2c232 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 28 Jan 2025 16:48:21 -0500 Subject: [PATCH 2/2] change order to move ALLOCATE call for earth_u_profile and earth_v_profile after RETURN logic --- share/wrf_timeseries.F | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/share/wrf_timeseries.F b/share/wrf_timeseries.F index 9755ee45bc..53ccb27d1f 100644 --- a/share/wrf_timeseries.F +++ b/share/wrf_timeseries.F @@ -351,27 +351,21 @@ SUBROUTINE calc_ts( grid ) ! FALSE to output T and Q at 2-m and wind at 10-m diagnostic levels: LOGICAL, PARAMETER :: ts_model_level = .FALSE. - !Allocate the arrays for wind components -#if ( EM_CORE == 1 ) - ALLOCATE ( earth_u_profile(grid%max_ts_level), earth_v_profile(grid%max_ts_level) ) -#endif - IF ( grid%ntsloc_domain .LE. 0 ) THEN -#if ( EM_CORE == 1 ) - DEALLOCATE(earth_u_profile, earth_v_profile) -#endif RETURN END IF #if ((EM_CORE == 1) && (DA_CORE != 1)) IF ( grid%dfi_opt /= DFI_NODFI .AND. grid%dfi_stage /= DFI_FST ) THEN -#if ( EM_CORE == 1 ) - DEALLOCATE(earth_u_profile, earth_v_profile) -#endif RETURN END IF #endif + !Allocate the arrays for wind components +#if ( EM_CORE == 1 ) + ALLOCATE ( earth_u_profile(grid%max_ts_level), earth_v_profile(grid%max_ts_level) ) +#endif + n = grid%next_ts_time ALLOCATE(p8w(grid%sm32:grid%em32))