Reallocate a 2-dimensional array
FT 22.07.2021
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
double precision, | intent(inout), | DIMENSION(:,:), ALLOCATABLE | :: | array | ||
integer, | intent(in) | :: | new_dim | |||
integer, | intent(in) | :: | new_dim2 |
SUBROUTINE reallocate_array_2d( array, new_dim, new_dim2 )
!************************************
!
!# Reallocate a 2-dimensional array
!
! FT 22.07.2021
!
!************************************
IMPLICIT NONE
DOUBLE PRECISION, DIMENSION(:,:), ALLOCATABLE, INTENT(IN OUT):: array
INTEGER, INTENT(IN):: new_dim, new_dim2
DEALLOCATE( array, STAT= ios, ERRMSG= err_msg )
IF( ios > 0 )THEN
PRINT *, "...deallocation error in SUBROUTINE" &
// "reallocate_tmp_variable. ", &
"The error message is", err_msg, ", and IOSTAT= ", ios
STOP
ENDIF
ALLOCATE( array( new_dim, new_dim2 ), STAT= ios, ERRMSG= err_msg )
IF( ios > 0 )THEN
PRINT *, "...allocation error in SUBROUTINE" &
// "reallocate_tmp_variable. ", &
"The error message is", err_msg, ", and IOSTAT= ", ios
STOP
ENDIF
END SUBROUTINE reallocate_array_2d