Pour vérifier si un fichier existe en Fortran il existe la fonction fortran INQUIRE. Exemple d'utilisation avec un programme minimaliste en fortran 90 (test.f90):
program testlogical :: file_existsINQUIRE(FILE="inputs.txt", EXIST=file_exists)write(6,*) file_existsend
Après compilation et exécution du code
gfortran test.f90 -o testtest
on obtient
F si le fichier inputs.txt n'existe pasT si le fichier inputs.txt existe
Recherches associées
| Liens | 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 |
