You can use the modFileSys library for this . Unlike non-standard compiler extensions, it can be compiled with any Fortran 2003 compiler and can be used by all POSIX compatible systems. You can also check for errors:
program test
use libmodfilesys_module
implicit none
integer :: error
! Renaming with error handling
call rename("old.dat", "new.dat", error=error)
if (error /= 0) then
print *, "Error happened"
end if
! Renaming without explicit error handling, stops the program
! if error happens.
call rename("old2.dat", "new2.dat")
end program test
source
share