- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
When compiling and running the following code with the Intel Fortran Compiler, I get an error after entering the same (negative) integer value provided by NEWUNIT=, but gfortran runs the code without problem.
implicit none integer :: someunit = 1492, ios open (NEWUNIT = someunit, FILE = 'someting', IOSTAT = ios) print *, someunit close (someunit, STATUS = 'DELETE') read *, someunit close (someunit) stop 'Program finished properly' end
If I recall correctly, the standard says that the CLOSE statement shouldn't fail when trying to close a unit that's not connected... but the standard also says that the number for the unit must not be a negative one. So, is there a conflict in the standard and both compilers are rignt? Was it an oversight?
The output when compiling and running the code is shown below:
~$ ll `which ifort` -rwxr-xr-x 1 root root 3955056 Jan 24 07:03 /opt/intel/composer_xe_2013_sp1.2.144/bin/intel64/ifort* ~$ ifort test_close.f90 ~$ ./a.out -129 -129 forrtl: severe (32): invalid logical unit number, unit -129, file unknown Image PC Routine Line Source a.out 00000000004024D2 Unknown Unknown Unknown a.out 0000000000402356 Unknown Unknown Unknown libc.so.6 00007F07674A3B45 Unknown Unknown Unknown a.out 0000000000402249 Unknown Unknown Unknown ~$ ll `which gfortran` lrwxrwxrwx 1 root root 12 Jan 17 04:19 /usr/bin/gfortran -> gfortran-4.8* ~$ gfortran test_close.f90 ~$ ./a.out -10 -10 STOP Program finished properly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure about F03 standard but the intel documentation states
"If a CLOSE statement is specified for a unit that is not open, it has no effect."
consider using
close (someunit, IOSTAT = ios)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My question wasn't really about how to circumvent the error (since I know IOSTAT= can be used with any input/output statement), but rather if there was a bug in either compiler ---i.e., an issue or conflict in the interpretation of the standard.
--
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's a bug - I'll let the developers know. Issue ID is DPD200255119.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fixed for a release later this year.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page