Handles the memory errors (including soft limits) during the deallocation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string |
Human-readable description string of the deallocation operation, just for output purpose. |
||
integer(kind=ip), | intent(in) | :: | lfree |
amount of memory (in bytes) to free |
||
integer(kind=ip), | intent(in) | :: | istat |
return flag of deallocate |
subroutine chk_free(string, lfree, istat)
!! Handles the memory errors (including soft limits)
!! during the deallocation
implicit none
character(len=*), intent(in) :: string
!! Human-readable description string of the deallocation
!! operation, just for output purpose.
integer(ip), intent(in) :: lfree
!! amount of memory (in bytes) to free
integer(ip), intent(in) :: istat
!! return flag of deallocate
character(len=OMMP_STR_CHAR_MAX) :: msg
!! Message string for errors
real(rp) :: lfree_gb
!! memory allocated in gb
lfree_gb = lfree / 1e9
if(istat /= 0)then
write(msg, "('Deallocation error in subroutine ', a ,'. stat= ', i5)") string, istat
call fatal_error(msg)
else
usedmem = usedmem - lfree_gb
end if
end subroutine chk_free