Print

Print


I wrote:

> > One of my compilers was perfectly happy to accept an optional dummy
> > argument as an I/O specifier, viz. "advance=adv", where "adv" was
> > an optional dummy argument.
> > 
> > Furthermore, if the actual argument associated with "adv" was not
> > present, the run-time was perfectly happy to pretend I hadn't
> > specified "advance=".
> > 
> > I found this to be rather elegant, but I suspect it isn't standard-
> > conforming behavior.  The section on I/O statements is quite large,
> > however, so I'm not sure whether there's something therein that defines
> > specifier values or variables to behave like actual arguments associated
> > with optional dummy arguments, and I missed it, or there's nothing
> > there.

And Philip Helbig wrote the following, which is what I expected to be
the case.  Does anybody know, by studying a standard, which behavior is
standard-conforming?  I suspect Philip's compiler is standard conforming,
and mine isn't.  (But it would be cool if it were the other way around!)

> PROGRAM TEST
> PRINT*, 'YES'               ! works as expected
> CALL TEST_ADV("YES")
> PRINT*
> PRINT*, 'NO'                ! works as expected
> CALL TEST_ADV("NO")
> PRINT*
> !PRINT*, 'NOTHING'           ! causes access violation and crashes
> !CALL TEST_ADV()
> !PRINT*
> !PRINT*, 'NOTHING'           ! causes access violation and crashes
> !CALL TEST_ADV
> !PRINT*
> !PRINT*, 'INVALID'           ! gives "%FOR-F-INVARGFOR, invalid argument 
>                              ! to FORTRAN Run-Time Library" and crashes
> !CALL TEST_ADV("VAN_SNYDER")
> END
> SUBROUTINE TEST_ADV(ADV)
> CHARACTER (LEN=*), OPTIONAL, INTENT(IN) :: ADV
> WRITE (*,'(T2,A)',ADVANCE=ADV) "first"
> WRITE (*,'(TR1,A)',ADVANCE="YES") "second"
> END




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%