http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53796
Bug #: 53796 Summary: I/O INQUIRE of RECL: If not specified in OPEN, the default value should be returned (sequential access) Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org CC: jvdeli...@gcc.gnu.org Depends on: 44292 As reported at http://www.rhinocerus.net/forum/lang-fortran/708936-inquire-get-maximum-record-length-bug-gfortran.html One has to distinguish three cases: - Direct access: The RECL= has to be given in OPEN - Stream access: No RECL= is allowed in OPEN - Sequential access: RECL= can be given in OPEN, otherwise the default is used. gfortran handles the case of RECL= given in OPEN correctly by returning that value and it handles stream access by using -1. (As the argument becomes undefined, any value would do.) Additionally, gfortran always returns -1 for sequential access instead of returning the default value. The question is only how to handle sequential access. We have two questions: a) gfortran handles (on most systems) large files, i.e. the default value would be larger than huge(0). Additionally, (cf. PR 44292) gfortran does not handle INT64 variables for RECL. Thus, which value should be returned? HUGE(kind(recl_var))? b) What should happen if the user exceeds the RECL= specified in OPEN. (Possibly, that's handled correctly, but I want to add it to the to-do list for checking.) - That is also related to the question of (a): Handling INQUIRE RECL=int32_var. >From the Fortran 2008 standard at "9.10.2.26 RECL= specifier in the INQUIRE statement": "The scalar-int-variable in the RECL= specifier is assigned the value of the record length of a connection for direct access, or the value of the maximum record length of a connection for sequential access. If the connection is for formatted input/output, the length is the number of characters for all records that contain only characters of default kind. If the connection is for unformatted input/output, the length is measured in file storage units. If there is no connection, or if the connection is for stream access, the scalar int-variable becomes undefined." For OPEN, the following applies: "The value of the RECL= specifier shall be positive. It specifies the length of each record in a file being connected for direct access, or specifies the maximum length of a record in a file being connected for sequential access. This specifier shall not appear when a file is being connected for stream access. This specifier shall appear when a file is being connected for direct access. If this specifier is omitted when a file is being connected for sequential access, the default value is processor dependent. If the file is being connected for formatted input/output, the length is the number of characters for all records that contain only characters of default kind. When a record contains any nondefault characters, the effect of the RECL= specifier is processor dependent. If the file is being connected for unformatted input/output, the length is measured in file storage units. For an existing file, the value of the RECL= specifier shall be included in the set of allowed record lengths for the le. For a new file, the processor creates the file with a set of allowed record lengths that includes the specified value."