Hi, i am beginner in python
I am trying to run a " FORTRAN file from python using subprocess "
I wrote a python program:
import string
import subprocess as subProc
from subprocess import Popen as ProcOpen
from subprocess import PIPE
import numpy
import subprocess
userID = "pear"
serverName = "say4"
workDir = "/home/pear/2/W/fortran/"
Fortrancmd = "ifort"
jobname = "rad.for"
exeFilename = "rad"
sshConnect=userID+"@"+servername
cmd=["ssh", sshConnect, "cd %s;"%(workDir), Fortrancmd %s jobname "%s -o %s" exeFilename "%s && %s ./ %s%s"%(exeFilename)]
**#command to execute fortran files in Linux
**#ifort <filename>.for -o <filename> && ./<filename> (press enter)
**#example:ifort xxx.for -o xxx && ./xxx (press enter)
print cmd
My problem is: i usually execute a Fortran file in Linux(manually) as,
1, connect to the server
2, go to the specific folder
3, ifort xxx.for -o xxx && ./xxx (press enter) , where 'xxx.for' is my Fortran file & 'xxx' is Fortran executable file
But i required to call my fortran file(xxx.for) from python, so i used subprocess like,
cmd=["ssh", sshConnect, "cd %s;"%(workDir), Fortrancmd %s jobname "%s -o %s" exeFilename "%s && %s ./ %s%s"%(exeFilename)]
i don't know whats the error in this line, please help me.
My question is how to program in python for the manual part described above, so that it performs automatically.
Thank you in advance!