Assign CPU variable with memory checking (kind I8P, rank 1). Variable is returned not allocated if right hand side is not allocated.
use penf
integer(I8P), allocatable :: a(:), b(:)
allocate(b(1:1))
call assign_allocatable(a, b)
print*, allocated(a)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I8P), | intent(inout), | allocatable | :: | lhs(:) |
Left hand side of assignement. |
|
integer(kind=I8P), | intent(in), | allocatable | :: | rhs(:) |
Right hand side of assignement. |
|
character(len=*), | intent(in), | optional | :: | msg |
Message to be printed in verbose mode. |
|
logical, | intent(in), | optional | :: | verbose |
Flag to activate verbose mode. |
subroutine assign_allocatable_I8P_1D(lhs, rhs, msg, verbose) !< Assign CPU variable with memory checking (kind I8P, rank 1). !< Variable is returned not allocated if right hand side is not allocated. !< !<```fortran !< use penf !< integer(I8P), allocatable :: a(:), b(:) !< allocate(b(1:1)) !< call assign_allocatable(a, b) !< print*, allocated(a) !<``` !=> T <<< integer(I8P), allocatable, intent(inout) :: lhs(:) !< Left hand side of assignement. integer(I8P), allocatable, intent(in) :: rhs(:) !< Right hand side of assignement. character(*), intent(in), optional :: msg !< Message to be printed in verbose mode. logical, intent(in), optional :: verbose !< Flag to activate verbose mode. if (allocated(lhs)) deallocate(lhs) if (allocated(rhs)) then if (size(rhs, dim=1)>0) then call allocate_variable(var=lhs, ulb=[lbound(rhs,dim=1),ubound(rhs,dim=1)], msg=msg, verbose=verbose) lhs = rhs endif endif endsubroutine assign_allocatable_I8P_1D