Fortran代码自动创建文件夹
(2016-02-02 20:51:45)
标签:
itfortran |
分类: 编程 |
示例代码:
! 输出路径
!----------------
module
Path
implicit
none
character(len=100) :: out_path="D:\Code\Routine
Code\Interface\2016-01-29\"
!- 查询目录文件夹状态或使用目录文件夹,允许字符串中存在空格
character(len=100) :: out_path1="D:\Code\""Routine
Code""\Interface\2016-01-29\"
!- 调用系统命令自动创建目录文件夹,字符串中空格需用引号处理
end module
Path
!----------------
!...调用系统命令自动创建目录文件夹(计算结果输出目录)
!------------------------------------------
!...程序运行所耗总时间
!------------------------------------------
write(*,'(/)')
Time_cost=ETIME(TA)
write(*,*)
'Program has used',Time_cost,'seconds of CPU time.'
write(*,*)
'This includes',TA(1),'seconds of user time
and', &
TA(2),'seconds of system time.'
write(*,*) '
'
stop '
Calculation is over'
end program
Main
!------------------------------------------
! 创建目录文件夹路径
!-----------------------
subroutine
Createfolder(path_inquire,path_create)
use
IFPORT
use
Path
implicit
none
integer(kind=4) :: istatus1,errnum
logical(kind=4) :: ierr1
character(len=100) :: path_inquire,path_create
inquire(DIRECTORY=trim(adjustl(path_inquire)), EXIST=ierr1)
print*,ierr1
if(ierr1)
then
print*,'The directory have existed and not been needed to
create'
write(*,'(/)')
else
print*,'The directory not exist and creat it'
write(*,'(/)')
istatus1=SYSTEM('md '//trim(adjustl(path_create)))
if(istatus1==-1) then
errnum=ierrno()
print*,'Error=',errnum,' inquire the Intel Visual Fortran help
document'
print*,' '
stop ' Folder creating is fail'
end if
end if
return
end
subroutine Createfolder
!-----------------------