Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29359 Discussions

type declaration with parameter variable does not compile

mirko_vukovic
Beginner
495 Views
Hi,

In my references I could not find the reason why this snippet fails to compile:

PROGRAM param_decl

type harmonic_efield
real,dimension(3)::E
real ::f=13.56e6,phase=0.
integer file_unit
real,parameter::twopi=6.28318530718
end type harmonic_efield

END PROGRAM param_decl

If I move the real,parameter out of the type statement, the program compiles. What am I missing?

Thanks,

Mirko
0 Kudos
1 Reply
Steven_L_Intel1
Employee
495 Views
This is not allowed in Fortran. In the declaration of a derived type, the only "component-attr-spec" attributes allowed are POINTER and DIMENSION. (ALLOCATABLE is allowed as an extension to F95.)

A PARAMETER is not a variable - it is a "named constant" and does not belong inside a TYPE declaration.

DEC Fortran (and its derivatives) does allow the PARAMETER statement (but not attribute) within a STRUCTURE declaration, but STRUCTURE is non-standard.
0 Kudos
Reply