I need to delete a file from Fortran code. I am on ubuntu 12.04, x86_64 . I do not understand why the procedure described below does not work. Please help me clarify the situation (in fact, on some systems it works, but not on mine).
There is another way: I can directly invoke the unix rm -f file command, but I would like to know what is wrong with my method. Thanks.
Step 1. Make a simple script del.sh and put it in ~ / bin
$ cat del.sh [ $# -ge 1 ] && rm -f $1 $ chmod u+x del.sh; mv del.sh ~/bin
Step 2. Code Fortran, del.for:
character*100 cmd character*30 file call getarg(1,file) write(cmd,100) file 100 format('source del.sh ',a30) call system(cmd) end
Step 3. Compile and run:
$ ifort -o del del.for $ ./del file
Results:
sh: 1: source: not found
What's wrong? The simple "del.sh source file" works, but not from Fortran code ... this is confusing.
From Fortran Code:
100 format('del.sh ',a30) 100 format('bash del.sh ',a30)
works fine but
100 format('sh del.sh ',a30)
does not work. I have bash installed but no csh . Thanks.
source share