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

Setting the value to CLASS(*)

$
0
0

Hi All,

I am trying to create a derived data type that can at run time take on different values. The follow is a snipit of code:

PROGRAM TEST
!
TYPE FLEXIBLE
  CLASS(*),         ALLOCATABLE:: VAL
END TYPE
TYPE(FLEXIBLE)::A
!
CLASS(*),         ALLOCATABLE:: B
INTEGER:: I
!IT SEEMS LIKE TH FOLLOWING SHOULD WORK:
I=5
ALLOCATE(A%VAL,SOURCE=I)
ALLOCATE(B,SOURCE=I)
!
A%VAL=10
B=50
!
END PROGRAM

When I try to set the value to a new value, I get a compiler error. Even if I remove the A%VAL= and B= they do not seem to hold the value of I.

On a side note, what does MOLD do within an ALLOCATE statement.

Thanks as always for your help.


Viewing all articles
Browse latest Browse all 5691

Trending Articles