Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

how to use RENAME RENAMEFILEQQ

yjyincj
Beginner
488 Views
Hi,
I tried to use RENAME and RENAMEFILEQQ but failed. My code is pasted bellow. Please help me.

!use RENAME to rename some files
program main
use ifport
use ifcore
implicit none
logical::result,alive
character(len=72)::n,oldname,newname
integer::i,istatus
do i=1,10
select case(i)
case(1:9)
write(n,"('0',I1)") I
case(10:40)
write(n,"(I2)") I
end select
write(oldname,*)'la',trim(n)
write(newname,*)'la',trim(n),'.eq'
!result=renamefileqq(oldname,newname)
inquire(file=oldname,exist=alive)
if(alive==0)then
write(*,*) oldname," does not exist"
exit
end if
istatus=rename(oldname,newname)
!----------------------------
!or I use this line instead of the above one
!result=renamefileqq(oldname,newname)
!-----------------------------------
end do
stop
end

0 Kudos
1 Reply
Les_Neilson
Valued Contributor II
488 Views

According to the documentation rename expects a full path.

I replaced your case and internal writes with

write(oldname,'(a,i2.2)') 'la',i
write(newname,'(a,i2.2,a)') 'la',i,'.eq'

and used RenameFileQQ and it worked ok

Les

0 Kudos
Reply