From 3dead67e237fb47b7849583a71cff11fae6aa117 Mon Sep 17 00:00:00 2001 From: Tyler Green Date: Sat, 9 Dec 2023 09:47:56 -0500 Subject: [PATCH] fix: bug fix for obs_sort_module.F90. Pointer 'next' on line 3160 (formerly 3159) was causing obsgrid to segfault situationally. A conditional statement was added on line 3158 to check wether the pointer 'next' is associated or not before going into the following block of code. This seems to have remedied the problem for now. This bug fix was stated by the user "Alpha_su" in the obsgrid forum: https://forum.mmm.ucar.edu/threads/obsgrid-exe-fails-after-a-few-seconds.13474/ --- src/obs_sort_module.F90 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/obs_sort_module.F90 b/src/obs_sort_module.F90 index 63838a6..1deb35b 100755 --- a/src/obs_sort_module.F90 +++ b/src/obs_sort_module.F90 @@ -3155,15 +3155,17 @@ SUBROUTINE output_obs ( obs , unit , file_name , num_obs , out_opt, forinput, & !ob itself is written Obsgrid may not find any valid obs to write and !thus we have an ob header without any actual obs. An ob of this format !in the OBS_DOMAIN* file will cause WRF obs nudging to crash - IF((.NOT. is_sounding) .AND. & - (.NOT. eps_equal(next%meas%height%data, obs(i)%info%elevation, 1.))) THEN - obs(i)%info%discard = .TRUE. - PRINT '(A,A,A,A,F12.2,A,F12.2,A,A,A,A)','WARNING: Ob indicates is_sounding=.FALSE. ',& - 'but the ob height does ',& - 'not match the station elevation. This ob will be omitted since Obsgrid assumes ',& - 'is_sounding=.FALSE. indicates a surface ob. Height = ', next%meas%height%data, & - ', Elevation = ', obs(i)%info%elevation,', Ob ID = ',TRIM(ADJUSTL(obs(i)%location%id)),& - ', Ob Time = ', obs(i)%valid_time%date_char + IF (ASSOCIATED (next)) THEN + IF((.NOT. is_sounding) .AND. & + (.NOT. eps_equal(next%meas%height%data, obs(i)%info%elevation, 1.))) THEN + obs(i)%info%discard = .TRUE. + PRINT '(A,A,A,A,F12.2,A,F12.2,A,A,A,A)','WARNING: Ob indicates is_sounding=.FALSE. ',& + 'but the ob height does ',& + 'not match the station elevation. This ob will be omitted since Obsgrid assumes ',& + 'is_sounding=.FALSE. indicates a surface ob. Height = ', next%meas%height%data, & + ', Elevation = ', obs(i)%info%elevation,', Ob ID = ',TRIM(ADJUSTL(obs(i)%location%id)),& + ', Ob Time = ', obs(i)%valid_time%date_char + ENDIF ENDIF !BPR END