Skip to content

Commit

Permalink
chgres_cube - Eliminate segmentation fault in input_data.F90 (#585)
Browse files Browse the repository at this point in the history
Problem happened when using GRIB2 data as input. Variable
'slmsk_save' was not being allocated on all MPI tasks in routine
'read_input_sfc_grib2_file'.

Fixes #584.
  • Loading branch information
GeorgeGayno-NOAA authored Oct 21, 2021
1 parent 7c31411 commit 3f85872
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions sorc/chgres_cube.fd/input_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4797,7 +4797,7 @@ subroutine read_input_sfc_grib2_file(localpet)
allocate(dummy2d_8(0,0))
allocate(dummy2d_82(0,0))
allocate(dummy2d(0,0))

allocate(slmsk_save(0,0))
endif

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down Expand Up @@ -4861,7 +4861,7 @@ subroutine read_input_sfc_grib2_file(localpet)
slmsk_save = nint(dummy2d)

deallocate(icec_save)
endif
endif ! localpet == 0

print*,"- CALL FieldScatter FOR INPUT LANDSEA MASK."
call ESMF_FieldScatter(landsea_mask_input_grid,real(dummy2d,esmf_kind_r8),rootpet=0, rc=rc)
Expand Down Expand Up @@ -5033,7 +5033,8 @@ subroutine read_input_sfc_grib2_file(localpet)
endif
enddo
enddo
endif
deallocate(dummy1d)
endif ! localpet == 0

if ((rc <= 0 .and. trim(to_upper(external_model)) /= "HRRR" .and. .not. rap_latlon) &
.or. (rc < 0 .and. (trim(to_upper(external_model)) == "HRRR" .or. rap_latlon))) then
Expand Down Expand Up @@ -5074,7 +5075,7 @@ subroutine read_input_sfc_grib2_file(localpet)
print*,'sotype ',maxval(dummy2d_8),minval(dummy2d_8)
deallocate(dummy2d_i)
deallocate(dummy3d_stype)
endif
endif ! localpet == 0


print*,"- CALL FieldScatter FOR INPUT GRID SOIL TYPE."
Expand Down Expand Up @@ -5486,11 +5487,13 @@ subroutine read_input_sfc_grib2_file(localpet)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))&
call error_handler("IN FieldScatter", rc)

print*,"- CALL FieldScatter FOR INPUT VEG TYPE."
print*,"- CALL FieldScatter FOR INPUT SOIL TYPE."
call ESMF_FieldScatter(soil_type_input_grid, dummy2d_82, rootpet=0, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))&
call error_handler("IN FieldScatter", rc)


deallocate(dummy2d_82)

print*,"- CALL FieldScatter FOR INPUT LANDSEA MASK."
call ESMF_FieldScatter(landsea_mask_input_grid,real(slmsk_save,esmf_kind_r8),rootpet=0, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))&
Expand All @@ -5511,9 +5514,11 @@ subroutine read_input_sfc_grib2_file(localpet)
call check_soilt(dummy3d,slmsk_save,tsk_save)
print*,'soilt ',maxval(dummy3d),minval(dummy3d)

deallocate(tsk_save, slmsk_save)
deallocate(tsk_save)
endif

deallocate(slmsk_save)

print*,"- CALL FieldScatter FOR INPUT SOIL TEMPERATURE."
call ESMF_FieldScatter(soil_temp_input_grid, dummy3d, rootpet=0, rc=rc)
if(ESMF_logFoundError(rcToCheck=rc,msg=ESMF_LOGERR_PASSTHRU,line=__LINE__,file=__FILE__))&
Expand Down

0 comments on commit 3f85872

Please sign in to comment.