Reallocate a 1-dimensional array
FT 22.07.2021
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
double precision, | intent(inout), | DIMENSION(:), ALLOCATABLE | :: | array | ||
integer, | intent(in) | :: | new_dim |
SUBROUTINE reallocate_array_1d( array, new_dim )
!************************************
!
!# Reallocate a 1-dimensional array
!
! FT 22.07.2021
!
!************************************
IMPLICIT NONE
DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE, INTENT(IN OUT):: array
INTEGER, INTENT(IN):: new_dim
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 ), 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_1d