Optional (empty) string argument
Philippe Schaffnit
P.Schaffnit@access.rwth-aachen.de
Wed Aug 15 13:06:00 GMT 2007
Hi!
I should definitly look it up myself in the standard, but I somehow
don't seem to be able to get the meaning hidden behind the technical
wording...
So, I am definitly not saying GFortan gets it wrong, but it begs to
differs with the Intel and Sun compilers (and I would personnaly
probably try to go for the safety in numbers... plus I have to admit
that I find GFortran's behaviour slightly counter-intuitive).
If you consider the following example: an empty string is handed over
twice, the last time as an optional argument: GFortran, seems to
consider that the optional argument is not present!
Can anyone comment on this?
Thanks!
Philippe
PS: this example:
!
PROGRAM Test_Optional_Empty_String
!
CHARACTER ( LEN = * ), PARAMETER :: String = " "
!
CALL First_Layer ( TRIM(String) )
!
CONTAINS
SUBROUTINE First_Layer ( Dummy )
CHARACTER ( LEN = * ), INTENT(IN) :: Dummy
CALL Second_Layer ( TRIM(Dummy) )
END SUBROUTINE First_Layer
SUBROUTINE Second_Layer ( Dummy )
CHARACTER ( LEN = * ), OPTIONAL, INTENT(IN) :: Dummy
IF ( PRESENT ( Dummy ) ) THEN
WRITE ( 6, "(//A//)" ) " Argument: |" // TRIM(Dummy) &
& // "|"
ELSE
WRITE ( 6, "(//A//)" ) " No argument:"
END IF
END SUBROUTINE Second_Layer
!
END PROGRAM Test_Optional_Empty_String
!
PPS: I am using freshly updated sources (from this morning: revision
127505)
More information about the Fortran
mailing list