Assign CPU variable with memory checking (kind R8P, rank 7). Variable is returned not allocated if right hand side is not allocated.
use penf
real(R8P), allocatable :: a(:,:,:,:,:,:,:), b(:,:,:,:,:,:,:)
allocate(b(1:1,1:2,1:3,1:4,1:5,1:6,1:7))
call assign_allocatable(a, b)
print*, allocated(a)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R8P), | intent(inout), | allocatable | :: | lhs(:,:,:,:,:,:,:) |
Left hand side of assignement. |
|
real(kind=R8P), | 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_R8P_7D(lhs, rhs, msg, verbose) !< Assign CPU variable with memory checking (kind R8P, rank 7). !< Variable is returned not allocated if right hand side is not allocated. !< !<```fortran !< use penf !< real(R8P), allocatable :: a(:,:,:,:,:,:,:), b(:,:,:,:,:,:,:) !< allocate(b(1:1,1:2,1:3,1:4,1:5,1:6,1:7)) !< call assign_allocatable(a, b) !< print*, allocated(a) !<``` !=> T <<< real(R8P), allocatable, intent(inout) :: lhs(:,:,:,:,:,:,:) !< Left hand side of assignement. real(R8P), 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)*size(rhs,dim=2)*size(rhs,dim=3)*size(rhs,dim=4)*size(rhs,dim=5)*size(rhs,dim=6)*size(rhs,dim=7)>0) then call allocate_variable(var=lhs, & ulb=reshape([lbound(rhs,dim=1),ubound(rhs,dim=1), & lbound(rhs,dim=2),ubound(rhs,dim=2), & lbound(rhs,dim=3),ubound(rhs,dim=3), & lbound(rhs,dim=4),ubound(rhs,dim=4), & lbound(rhs,dim=5),ubound(rhs,dim=5), & lbound(rhs,dim=6),ubound(rhs,dim=6), & lbound(rhs,dim=7),ubound(rhs,dim=7)],[2,7]), & msg=msg, verbose=verbose) lhs = rhs endif endif endsubroutine assign_allocatable_R8P_7D