how to execute shell commands

Hello,

i want to run shell commands (specifically ‘cp’ command to copy a file) inside fortran code.

In intel fortran i used SYSTEM command but this command doesn’t exist in PGI.

Is there in PGI a way to execute shell commands?

Thanks in advanced
Helios

Hi Helios,

i used SYSTEM command but this command doesn’t exist in PGI.

While SYSTEM isn’t part of the Fortran standard, we do support the lib3f library’s SYSTEM subroutine. What error are you getting?

  • Mat
% cat testsys.f90
	program testsys
	call system('ls')
	call system('touch foo.txt')
	call system('cp foo.txt foo2.txt')
	call system('ls')
	call system('rm foo*')
	call system('ls')
	end program testsys
% pgf90 testsys.f90 ; a.out
a.out  testsys.f90
a.out  foo2.txt  foo.txt  testsys.f90
a.out  testsys.f90

Sorry it was mine mistake, SYSTEM worked fine, thank you :)