Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

NEWUNIT= and CLOSE

$
0
0

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



 





 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>