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

Derived type components in a NAMELIST group?

OP1
New Contributor III
1,580 Views

Using IVF 11.1, the code shown below does not compile. Does this restriction (no derived type components in a NAMELIST group) still apply for later versions of IVF?

Thanks,
Olivier

[fortran]PROGRAM TEST IMPLICIT NONE TYPE T_TEST INTEGER :: I END TYPE T_TEST TYPE(T_TEST) :: T NAMELIST / OUPS / T%I END PROGRAM TEST


[/fortran]
0 Kudos
3 Replies
Steven_L_Intel1
Employee
1,580 Views
Yes, it still applies. The Fortran standard allows only "variable-name" in the namelist object list. You can, however, put T in the namelist and reference T%I in namelist input (and it is shown on output).
0 Kudos
OP1
New Contributor III
1,580 Views
Thanks Steve for this clarification.Obviously this is nothing more than a convenience feature that can be easily worked around as you indicated, butis there any fundamental reason for this not being allowed?

Olivier
0 Kudos
Steven_L_Intel1
Employee
1,580 Views
It would be a major departure from the language to allow things that are not whole variables in such contexts as NAMELIST, COMMON, etc. But I also think it is due to the age of NAMELIST, which first appeared in IBM FORTRAN compilers in the 1970s, long before derived types. Having implemented NAMELIST for VAX Fortran, what you're asking for is sort of a degenerate case of what is already allowed. The only difference is that you want to restrict access to specific components in the type. You can't put A(3) in a NAMELIST either.

I have not seen any attempt by the standards committee to extend NAMELIST beyond the initial featureset, other than allowing namelist I/O in more contexts (such as internal files.) You can already reference T%I in input, and when you outuput the namelist, the values of all components are written.
0 Kudos
Reply