Using:
OS: Linux 4.16.13-300.fc28.x86_64 #1 SMP Wed May 30 14:31:00 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux (Fedora 28)
Shell: GNU bash, version 4.4.19(1)-release (x86_64-redhat-linux-gnu)
Compiler: Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 18.0.2.199 Build 20180210
The INQUIRE statement is not recognizing the file mode bits for this combination of OS/shell/compiler.
Consider the simple test which get info about two data files: temp.dat and temp_ro.dat; the first with rw attributes and the second read-only:
-rw-r--r--. 1 rudi plasmas 18 abr 11 17:33 temp.dat -r--r--r--. 1 rudi plasmas 18 jun 5 11:55 temp_ro.dat
Accessed with the following code:
program tes_inquire_2 implicit none logical :: fexist, fopen character(len= *), parameter :: file_exist= 'temp.dat' ! Existing file character(len= *), parameter :: file_ro= 'temp_ro.dat' ! Existing file, with read-only attribute character(len= 30) :: fcread, fcwrite, fcrw integer :: ios ! Existing file, with rw attributes inquire(file= file_exist, exist= fexist, opened= fopen, iostat= ios, & read= fcread, write= fcwrite, readwrite= fcrw) print'(a,/,2a)', '----------------------------------', 'About file '//file_exist//':' write(*, '(a,g0)')'File exist(?): ', fexist write(*, '(a,g0)')'File is opened(?): ', fopen write(*, '(2a)')'File can be opened for read only(?): ', trim(fcread) write(*, '(2a)')'File can be opened for write only(?): ', trim(fcwrite) write(*, '(2a)')'File can be opened for read/write(?): ', trim(fcrw) write(*, '(a,g0)')'iostatus= ', ios ! Existing file, with read-only attribute inquire(file= file_ro, exist= fexist, opened= fopen, iostat= ios, & read= fcread, write= fcwrite, readwrite= fcrw) print'(/,a,/,2a)', '----------------------------------', 'About file '//file_ro//':' write(*, '(a,g0)')'File exist(?): ', fexist write(*, '(a,g0)')'File is opened(?): ', fopen write(*, '(2a)')'File can be opened for read only(?): ', trim(fcread) write(*, '(2a)')'File can be opened for write only(?): ', trim(fcwrite) write(*, '(2a)')'File can be opened for read/write(?): ', trim(fcrw) write(*, '(a,g0)')'iostatus= ', ios end program tes_inquire_2
Compiling and running with ifort:
>ifort tes_inquire_2.f90 >./a.out ---------------------------------- About file temp.dat: File exist(?): T File is opened(?): F File can be opened for read only(?): UNKNOWN File can be opened for write only(?): UNKNOWN File can be opened for read/write(?): UNKNOWN iostatus= 0 ---------------------------------- About file temp_ro.dat: File exist(?): T File is opened(?): F File can be opened for read only(?): UNKNOWN File can be opened for write only(?): UNKNOWN File can be opened for read/write(?): UNKNOWN iostatus= 0
OTOH, gfortran will reply the correct attributes:
>gfortran tes_inquire_2.f90 >./a.out ---------------------------------- About file temp.dat: File exist(?): T File is opened(?): F File can be opened for read only(?): YES File can be opened for write only(?): YES File can be opened for read/write(?): YES iostatus= 0 ---------------------------------- About file temp_ro.dat: File exist(?): T File is opened(?): F File can be opened for read only(?): YES File can be opened for write only(?): NO File can be opened for read/write(?): YES iostatus= 0
I could not find any relevant compiler option for ifort, after a quick look at the manual...
Is this the expected behavior?