Wednesday, April 3, 2013

26 - How to check an exisiting file in FORTRAN

The inquire command in FORTRAN will help us to see what is on disk, and what is currently attached to units in our code.
For checking whether a file is existing in the current directory (where our fortran code is there) or not
we need to use
inquire(file='file_name', exist=lexist)
where lexist is a logical variable. if it is .true. then the file is exisiting in the current directory!

We can also check whether a file has been opened in the code or not.
inquire(unit=11, opened=lopen)
or
inquire(file='file_name', opened=lopen)
if the file has been already opened, the logical variable lopen is .true. otherwise it is .false. . 

No comments:

Post a Comment