In a few words you cannot. There is no built-in library for such operations in Fortran that helps you. How you approach this problem will also depend on the version of Fortran that you are using (F77, F90, F95, etc.) that you did not mention.
"On a POSIX system using the latest Fortran compiler, you can use ISO_C_BINDING to create the POSIX opendir () and readdir () (or readdir_r () if you need thread safety) interfaces that allow iteration to be written to the directory.
See this post Listing the contents of a directory in Fortran or you can also see this review from the gfortran documentation useful. There is a lot of information about performing this operation with simple Google.
Hope this helps.
source share