I'm trying to verify that a directory exists using Fortan90. On various sites I found:
logical :: dir_e
inquire(file='./docs/.', exist=dir_e)
if ( dir_e ) then
write(*,*) "dir exists!"
else
! workaround: it calls an extern program...
call system('mkdir docs')
end if
However, inquire returns False whether or not the directory exists and if I execute this code twice, I get an error message
cannot make dir, file already exists
If I use:
inquire(file='./docs/test', exist=dir_e)
with an existing file test, inquire returns true.
How can I check for the existence of a directory? I am using ubuntu 11.04 and the ifort compiler.
mkdir -p.file='./docs'only, that works for me also.