To check if a file exists in fortran 90, there is a fortran function called INQUIRE. Example of a fortran code (called here "test.f90"):
program test
logical :: file_exists
INQUIRE(FILE="inputs.txt", EXIST=file_exists)
write(6,*) file_exists
end
Compilation
gfortran test.f90 -o test
test
will return:
F if the file inputs.txt does not exist
T if the file inputs.txt exists
References
Links | Site |
---|---|
Single command to open a file or create it and the append data | stackoverflow |
Check_that_file_exists Fortran | rosettacode |
INQUIRE Fortran 77 | Oracle Doc |