[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-fortran
Subject: Re: iostat
From: Tobias Burnus <burnus () gmx ! de>
Date: 2006-08-22 21:23:45
Message-ID: 44EB75E1.20900 () gmx ! de
[Download RAW message or body]
Hi all,
Daniel Franke schrieb:
> I tried to work out a way to provide meaningful error messages besides "open
> failed".
Well, the easiest way is to do the following:
PROGRAM test_iostat
implicit none
character(len=200) :: str
INTEGER :: ierr
OPEN(UNIT = 42, FILE = "file", ACTION = "READ", STATUS = "OLD",
IOSTAT=ierr,iomsg=str)
if(ierr /= 0 ) WRITE (*,*) 'WARNING: Could not open file: ', trim(str)
END PROGRAM
This gives the following messages:
WARNING: Could not open file: Permission denied
and
WARNING: Could not open file: No such file or directory
Contrary to using a table of number--error relations this works with
several compilers as this is part of the Fortran 2003 standard.
(This was also suggested in the thread on c.l.fortran.)
A quick test shows that gfortran (4.1.x 20060705 and current 4.2), NAG
f95 (5.1) and sunf95 (8.3) support this option already, g95 (27 Jul) and
ifort (9.1.036) don't.
Tobias
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic