I am new in Fortran programming so I need a help about allocatable arrays.
This is my simple code:
PROGRAM MY_SIMPLE_CODE
IMPLICIT NONE
INTEGER :: N_TMP, ALLOC_ERR, DEALLOC_ERR
REAL, ALLOCATABLE, DIMENSION(:) :: P_POT
WRITE( *,* ) "ENTER THE VALUE FOR N_TMP:"
READ( *,* ) N_TMP
IF ( .NOT. ALLOCATED( P_POT) ) ALLOCATE( P_POT( N_TMP), STATUS = ALLOC_ERR )
IF ( ALLOC_ERR .NE. 0 ) STOP( "ERROR - ALLOCATION P_POT !!!")
IF ( ALLOCATED( P_POT) ) DEALLOCATE( P_POT, STATUS = DEALLOC_ERR )
IF ( DEALLOC_ERR .NE. 0 ) STOP( "ERROR - DEALLOCATION P_POT !!!")
END PROGRAM MY_SIMPLE_CODE
When I cobuild this code I got this error message:
Allocate-object is neither a data pointer nor an allocatable variable
What is wrong with this code?
What kind of tricky stuff can be masked in this simple code?
IDE: Code::Blocks TDM_GCC_5 1 0
OS: Win 10 X64
STATUS=term in your allocation and deallocation. That's wrong, the keyword isSTAT=.STAT=instead ofSTATUS. The error is correctly pointing atSTATUS. gfortran assumed if is a variable name. Second, theSTOPdoes not use parathesis. Remove those.