[patch,fortran] F2003 Inquire features

Tobias Burnus tobias.burnus@physik.fu-berlin.de
Mon Apr 7 21:14:00 GMT 2008


> Attached is the final patch of this installment.

Thanks for the patch!

> Regression tested and NIST tested.  I am still working up test cases to
> add.
> 
> OK to commit?

OK after fixing the issues mentioned below.

Index: gcc/fortran/io.c:
| 
|        if (open->encoding->expr_type == EXPR_CONSTANT)
|  	{
| -	  static const char * encoding[] = { "UTF-8", "DEFAULT", NULL };
| +	  static const char * encoding[] = { "DEFAULT", NULL };

Add a TODO: UTF-8 there. (In the library there is already such a TODO.)


Index: libgfortran/io/inquire.c:
+	  case ROUND_UNSPECIFIED:
+	    p = "UNSPECIFIED";
+	    break;

This is wrong.

The standard mandates ("9.9.1.26 ROUND= specifier in the INQUIRE statement"):
"The scalar-default-char-variable in the ROUND= specifier is assigned
 the value UP, DOWN, ZERO, NEAREST, COMPATIBLE, or PROCESSOR_DEFINED,
 corresponding to the I/O rounding mode in effect for a connection for
 formatted input/output. If there is no connection or if the connection
 is not for formatted input/output, the scalar-default-char-variable is
 assigned the value UNDEFINED. The processor shall return the value
 PROCESSOR_DEFINED only if the I/O rounding mode currently in effect
 behaves differently than the UP, DOWN, ZERO, NEAREST, and COMPATIBLE
 modes."

Therefore, if the rounding mode has not been specified, the default
rounding mode should be returned. As we currently do not know which one
we have, we should return "PROCESSOR_DEFINED". If you replace the
string, please add also TODO there.

As soon as we figured out which rounding mode gfortran currently has
or which default rounding mode we want to have, we should return this
one instead. (Unless, it turns out that it neither of the up/down/zero/
nearest/compatible, which I do not think.) On my system I have
"COMPATIBLE"; the rounding seems to depend on the system libc's printf
and POSIX says that the rounding is system dependent, which means that
"PROCESSOR_DEFINED" is the right choice - at least for the moment.

Tobias



More information about the Fortran mailing list