Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29284 Discussions

program doesn't call to system command

jpprieto
Beginner
1,391 Views
Hi, I'm working with a f90 program compiled with ifort. In a routine the program call to system command to create a directory
...
if(ndim>1)then
filedir='output_'//TRIM(nchar)//'/'
filecmd='mkdir -p '//TRIM(filedir)
#ifdef NOSYSTEM
if(myid==1)call PXFMKDIR(TRIM(filedir),LEN(TRIM(filedir)),O'755',info)
#else
!HERE
if(myid==1)call system(filecmd)
#endif
#ifndef WITHOUTMPI
call MPI_BARRIER(MPI_COMM_WORLD,info)
#endif
...
The program compiles in a good way and run normally, but when it tries to open the created directory stop with

forrtl: No such file or directory
forrtl: severe (29): file not found, unit 11, file /usr/local/sge/users/test/jpprieto/ramses/output_00001/info_00001.txt

I'm sure that all conditions to call system are satisfied, but the program doesn't creat the directory. The program skip the line with "call system(filecmd)".
Some body can help me?
Thanks.
0 Kudos
5 Replies
Ron_Green
Moderator
1,391 Views
JP,

use this option -save-temps

this will keep a copy of the FPP preprocessed file in your local directory. It will be named .i90 (if the source is .F90) or .i (if the source is .F )

See if your defines are correct.

But I see something else that may be a problem. if you:

USE IFPORT

then SYSTEM is a function and not a subroutine. You should have something like:

I = SYSTEM(filecmd)


0 Kudos
jpprieto
Beginner
1,391 Views
JP,

use this option -save-temps

this will keep a copy of the FPP preprocessed file in your local directory. It will be named .i90 (if the source is .F90) or .i (if the source is .F )

See if your defines are correct.

But I see something else that may be a problem. if you:

USE IFPORT

then SYSTEM is a function and not a subroutine. You should have something like:

I = SYSTEM(filecmd)


Hi. Well. Let me you know something more. This program is a modified version of other program that work in a good way. The .f90 in which system command is called wasn't modified by me, I mean, these lines are identical to the previous version, in which the system command is called and creates the directory.
About write I = SYSTEM(filecmd), this doesn't work.
I hope you can help me.
Thank you.
0 Kudos
Ron_Green
Moderator
1,391 Views
Super, I am glad it was working in a past context.

Now, let's try some coding:
Change:

if(myid==1)call system(filecmd)

to

if (myid==1) then
print "creating directory from parent dir"
i = system( 'pwd' )
print "mkdir command is", filecmd
i = system( filecmd )
print "stopping"
stop
end if

this might help you determine what is happening. the 'pwd' command will show where the code has it's current working directory, as your mkdir command is not using absolute paths but relative paths. Add to this knowledge the actual command you are issuing with filecmd.

ron
0 Kudos
jpprieto
Beginner
1,391 Views
Super, I am glad it was working in a past context.

Now, let's try some coding:
Change:

if(myid==1)call system(filecmd)

to

if (myid==1) then
print "creating directory from parent dir"
i = system( 'pwd' )
print "mkdir command is", filecmd
i = system( filecmd )
print "stopping"
stop
end if

this might help you determine what is happening. the 'pwd' command will show where the code has it's current working directory, as your mkdir command is not using absolute paths but relative paths. Add to this knowledge the actual command you are issuing with filecmd.

ron


Hi, ron.
what is the variable type of "i"? I defined it as character(LEN=80), but the program didn't compile.
So I did the following modifications:
...
if(myid==1) then
write(*,*)'creating directory from parent dir'
call system( 'pwd' )
write(*,*)'mkdir command is', filecmd
call system( filecmd )
write(*,*)'stopping'
stop
end if
...
And I got the following output:
...
creating directory from parent dir
mkdir command is
mkdir -p output_00001/

stopping
...
So, the program doesn't execute the comand "pwd" and the directory output_00001/ hadn't created.
Well, really I don't know what's up.
Thank you.

0 Kudos
Ron_Green
Moderator
1,391 Views
According to the system documentation, i should be INTEGER.

so change back to
integer :: i !..must go at top of procedure with other data declarations



i = system( 'pwd' )
and
i = system( filecmd )

You cannot 'call' system, this is incorrect and is not working.

ron
0 Kudos
Reply