- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In my references I could not find the reason why this snippet fails to compile:
If I move the real,parameter out of the type statement, the program compiles. What am I missing?
Thanks,
Mirko
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
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page