[英]Rename file in Fortran 77
Is there a way to rename a file in fortran 77? 有没有办法在fortran 77中重命名文件? such as:
如:
RENAME(old name, new name)
or something like: 或类似的东西:
call system("rename" // trim(old name) // " " // trim(new name))
Thanks 谢谢
You can use the modFileSys library for that. 您可以使用modFileSys库。 In contrast to non-standard compiler extensions, it can be compiled with any Fortran 2003 compiler and can be used an all POSIX compatible systems.
与非标准编译器扩展相比,它可以使用任何Fortran 2003编译器进行编译,并且可以用于所有POSIX兼容系统。 You could also check for errors, if needed:
如果需要,您还可以检查错误:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.