Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

ALLOCATABLE attribute

$
0
0

I spent quite a bit of time debugging an application that in the end boils down to the code below:

PROGRAM MAIN
IMPLICIT NONE

INTEGER,ALLOCATABLE :: ARRAY(:),I

ALLOCATE(ARRAY(5))
ARRAY = [1,2,3,4,5]
WRITE(*,*) (ARRAY(I),I=1,5)

END PROGRAM MAIN

This triggers an access violation. Obviously the declaration of the variable I is incorrect (it should not be declared as allocatable), but I am surprised that the compiler lets this slide. Maybe my understanding of this is not complete. In what circumstances "INTEGER,ALLOCATABLE :: I" (without a DIMENSION statement somewhere else in the code) would be acceptable and what would it mean?

This is with 16 Update 2.


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>