My apologies if this is a very stupid question; my Fortran isn't great. I'm porting some old Fortran code and have come across this subroutine definition:
SUBROUTINE SET_HYDROMODULE(HYDROMODULE)
IMPLICIT NONE
INTEGER*4 HYDROMODULE [VALUE]
...
END
Intel Fortran passes this through without blinking an eye, though with warnings for non-standard language features enabled it gives this warning:
warning #7009: Attribute syntax is not standard F95
gfortran assumes that it's an attempt at a coarray specification, though it's not a valid one.
Can someone tell me what the meaning of the [VALUE] clause is?
Edit Is it a non-standard way of specifying pass-by-value? Is it equivalent to this:
INTEGER*4, VALUE :: HYDROMODULE
I seem to see it a lot in c-interoperability code, which would suggest this.
The VALUE attribute was added in Fortran 2003, so it is not surprising that it doesn't work with Fortran 95. The Fortran Standard (2008) specifies in section 5.3.18 "VALUE attribute". From what I read there, it needs to be specified as
INTEGER*4, VALUE :: HYDROMODULE
Section 5.4.16 in the Standard defines a second form, the VALUE statement:
INTEGER*4 :: HYDROMODULE
VALUE :: HYDROMODULE
The other form you gave seems to be an Intel extension. gfortran supports the VALUE attribute (at least in version 4.9).
A quick search revealed that apart from ensuring inter-operability the VALUE attribute can indeed by used to enforce some kind of call by value, from here:
When this attribute is specified, the effect is as if the actual argument is assigned to a temporary, and the temporary is the argument associated with the dummy argument. The actual mechanism by which this happens is determined by the processor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With