Skip to content

Commit

Permalink
Add allocation of slmsk_save on all tasks to prevent
Browse files Browse the repository at this point in the history
seg fault. Add deallocation of other variables. Fix
print message.

Fixes ufs-community#584.
  • Loading branch information
GeorgeGayno-NOAA committed Oct 12, 2021
1 parent b8cdc88 commit 7c9cc6b
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 7c9cc6b

Please sign in to comment.