[J3] Is NULL(MOLD=allocatable) an allocatable variable?
Robert Corbett
rpcorbett at att.net
Fri Nov 15 00:19:20 UTC 2024
In the text that follows, all references
to parts of the Fortran standard are withrespect to J3/24-007.
In the standard as written, the value ofa function reference does not have theALLOCATABLE attribute. The NOTE inSubclause 8.5.3 states
Only variables and components can have the ALLOCATABLE attribute. The result of referencing a function whose result variable has the ALLOCATABLE attribute is a value that does not itself have the ALLOCATABLE attribute.
Intrinsic functions are magic entitiesthat do not necessarily follow thegeneral rules of the standard. Thedescription of the Result of theintrinsic function NULL (16.9.155)says that the result of the functioncan be "an unallocated allocatableentity". Because the language doesnot include allocatable procedures,the unallocated allocatable entitymust be a data entity. I suspectthat it was intended to be a dataobject, but that is not obviousfrom the text.
A strict reading of the standard aswritten makes the example you gavenonconformant. I believe that theintent of the committee at the timeFortran 2003 was produced was toallow your example. I suspect thatan interp is needed.
Robert Corbett
On Thursday, November 14, 2024 at 01:21:59 PM PST, Daniel C Chen via J3 <j3 at mailman.j3-fortran.org> wrote:
<!--#yiv2540400760 filtered {}#yiv2540400760 filtered {}#yiv2540400760 filtered {}#yiv2540400760 p.yiv2540400760MsoNormal, #yiv2540400760 li.yiv2540400760MsoNormal, #yiv2540400760 div.yiv2540400760MsoNormal {margin:0cm;font-size:11.0pt;font-family:"Aptos", sans-serif;}#yiv2540400760 .yiv2540400760MsoChpDefault {font-size:11.0pt;}#yiv2540400760 filtered {}#yiv2540400760 div.yiv2540400760WordSection1 {}-->
The standard describes the argument and the result of intrinsic NULL(MOLD) when MOLD is an allocatable variable as
“
Argument. …If MOLD is allocatable its allocation status may be allocated or unallocated. It need not be defined with a value.
Result Characteristics. If MOLD is present, the characteristics are the same as MOLD….
Result. The result is a disassociated pointer or an unallocated allocatable entity.
“
Does “allocatable entity” mean allocatable variable as the standard also says only variables and components can have the ALLOCATABLE attribute.
If so, it will make “ALLOCATE(NULL(MOLD))” a conforming code, which doesn’t seem right.
If not, what does “allocatable entity” mean? Can an “allocatable entity” have no ALLOCATABLE attribute?
Is the following code conforming? It really depends on the answer of the above question.
“
real, allocatable :: ra
call sub(NULL(ra))
Contains
Subroutine sub(arg)
real, allocatable :: arg
…
end subroutine
end
“
Thanks,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20241115/a78d9504/attachment.htm>
More information about the J3
mailing list