Page 1 of 1

Fix for ARWpost 3.0 segfault

PostPosted: Tue Feb 15, 2011 1:09 am
by prasht
ARWpost3.0 seems to have problem in reading wrfout files. I tried with CONUS wrfout file when it segfaults with below trace:

$ ./src/ARWpost-nofix.exe

ARWpost v3.0

FOUND the following input files:


Processing time --- 2005-06-04_09:00:00
Found the right date - continue
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
ARWpost-nofix.exe 0000000000430DB7 module_arrays_mp_ 151 module_arrays.f
ARWpost-nofix.exe 00000000004212D4 module_interp_mp_ 746 module_interp.f
ARWpost-nofix.exe 0000000000422B2F module_basic_arra 116 module_basic_arrays.f
ARWpost-nofix.exe 00000000004149EB process_domain_mo 279 process_domain_module.F90
ARWpost-nofix.exe 0000000000413A72 process_domain_mo 153 process_domain_module.F90
ARWpost-nofix.exe 0000000000404B08 MAIN__ 23 ARWpost.f
ARWpost-nofix.exe 000000000040393C Unknown Unknown Unknown 00007FFFF742F586 Unknown Unknown Unknown
ARWpost-nofix.exe 0000000000403839 Unknown Unknown Unknown

On debugging, it turns out to be that some of WRF variables like P_TOP (for which the code is failing) are processed through “real_array”. Each variable and its memory allocation is mapped to this real_array before further processing [keep_arrays()].

The issue here is P_TOP is *not* an array (it’s a real value)and there was no code to map this onto real_array variable. Attached is the fix for ARWpost to map single dimensional (with any number of arguments) to do that.

Below is the fix for the above issue:

--- 2011-01-20 09:49:38.923193554 +0100
+++ module_interp.f90 2011-01-21 10:45:43.527113900 +0100
@@ -697,6 +697,7 @@ MODULE module_interp
character (len=50) :: cval
integer :: iloc, itype, idm, natt, ii
integer, dimension(4) :: istart, iend
+ real, allocatable, dimension(:) :: tmp1D
real, allocatable, dimension(:,:) :: tmp2D
real, allocatable, dimension(:,:,:) :: tmp3D
integer :: local_time
@@ -735,6 +736,12 @@ MODULE module_interp
CALL NCVGT(ncid,iloc,istart,iend,tmp2D,istatus)
tmp3D(:,:,1) = tmp2D
+ ELSEIF ((idm == 2) .or. (idm == 1)) THEN
+ ALLOCATE(tmp3D(ncDims(ishape(1)),ncDims(ishape(2)),ncDims(ishape(3))))
+ ALLOCATE(tmp1D(ncDims(ishape(1))))
+ CALL NCVGT(ncid,iloc,istart,iend,tmp1D,istatus)
+ tmp3D(:,1,1) = tmp1D
IF (istatus /= 0) return

Please let me know if this is fine.


Re: Fix for ARWpost 3.0 segfault

PostPosted: Thu Mar 03, 2011 5:46 am
by sunxm
I commented line 152 of src/module_arrays.f90, recompile and everything seems all right:
!! PTOP = real_array(1,1,1)

Re: Fix for ARWpost 3.0 segfault

PostPosted: Thu Apr 19, 2018 11:56 pm
by gadheebakaran
If I commented line 151 (not 152) ARWpost.exe is not created

Re: Fix for ARWpost 3.0 segfault

PostPosted: Fri Apr 27, 2018 8:51 am
by gadheebakaran
this is not working for me