INQUIRE finds a non-existing file

Hi!

Last week I forgot to fill a CHARACTER*4 with the year ‘2008’.
As a result, the directory where my application was looking for its input
was a bogus string containing two consecutive slashes and which obviously did not exist.
Nevertheless, INQUIRE tells me that that file does exist and my program proceeds and crashes trying to read it…
Below you’ll find a narrowed down piece of code.
If you replace the part '/home/dijkva/'by an existing directory
on your machine, then you’ll probably get the same result as I get:
the first attempt via the main program tells you that ‘myfile’ does not exist.
The second attempt however suggests successful probing!
I am running:

pgf90 6.1-4 32-bit target on x86-64 Linux
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2006, STMicroelectronics, Inc. All Rights Reserved.

I did not use any fancy compile-switches. Just “pgf90”.

Is this a bug in the compiler?
When compiled with e.g. g95 both calls tell me that the file does not exist.

Regards,


Arjan

MODULE LibUtil
IMPLICIT NONE
PRIVATE
PUBLIC :: FileExists,MyRoutine
CONTAINS

   FUNCTION FileExists(Directory,FName)
   CHARACTER(*), INTENT(INOUT) :: FName,Directory
   LOGICAL :: FileExists,DumLog
   CHARACTER(256) :: MyString
   MyString = TRIM(Directory)//TRIM(FName)
   WRITE(*,'(A)') 'Just before it happens... "'//TRIM(MyString)//'"'
   INQUIRE(FILE=TRIM(MyString),EXIST=DumLog)
   FileExists = DumLog
   END FUNCTION FileExists

   SUBROUTINE MyRoutine()
   CHARACTER(256) :: FName,Directory
   LOGICAL :: DumLog
   CHARACTER :: YearStr*4
   FName = 'myfile'
!   WRITE(YearStr,'(I4)') 2008  ! this is the line that I forgot to code...
   Directory = '/home/dijkva/' // YearStr // '/'
   DumLog = FileExists(Directory,FName)
   WRITE(*,*) DumLog
   END SUBROUTINE MyRoutine

END MODULE LibUtil

   PROGRAM Test
   USE libutil
   IMPLICIT NONE
   CHARACTER(256) :: Directory,FName
   LOGICAL :: DumLog
   Directory = '/home/dijkva//'
   FName = 'myfile'
   DumLog = FileExists(Directory,FName)
   WRITE(*,*) DumLog
   CALL MyRoutine()
   END PROGRAM Test

[/code]