Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29264 ディスカッション

Derived type components in a NAMELIST group?

OP1
新規コントリビューター III
1,577件の閲覧回数

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 件の賞賛
3 返答(返信)
Steven_L_Intel1
従業員
1,577件の閲覧回数
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).
OP1
新規コントリビューター III
1,577件の閲覧回数
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
Steven_L_Intel1
従業員
1,577件の閲覧回数
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.
返信