check the status after allocation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32) | :: | istat_ |
result of stat=istat in (de)allocate |
|||
character(len=*), | intent(in) | :: | message_ |
a message to be written |
||
character(len=1), | intent(in) | :: | op_ |
'a' for allocation, 'd' for deallocation |
||
integer(kind=int32), | intent(in), | optional | :: | unit_ |
optional, unit where the message will be written |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=:), | private, | allocatable | :: | add_prefix_ |
subroutine alloc_status(istat_, message_, op_, unit_)
!! check the status after allocation
!---------------------------------------------------------------------!
integer(int32) :: istat_
!! result of stat=istat in (de)allocate
character(len = *), intent(in) :: message_
!! a message to be written
character(len = 1), intent(in) :: op_
!! 'a' for allocation, 'd' for deallocation
integer(int32), optional, intent(in) :: unit_
!! optional, unit where the message will be written
!---------------------------------------------------------------------!
character(len = :), allocatable :: add_prefix_
!---------------------------------------------------------------------!
add_prefix_ = ''
if (istat_ /= 0) then
select case(op_)
case('a')
add_prefix_ = 'memory allocation: '//trim(message_)
case('d')
add_prefix_ = 'memory deallocation: '//trim(message_)
case default
call write_error &
('Incorrect op_ argument in alloc_status subroutine ('&
//trim(op_)//')')
end select
call write_error(add_prefix_, unit_)
endif
!---------------------------------------------------------------------!
end subroutine alloc_status