python to call or start a fortran a.out

Rick Johnson rantingrickjohnson at gmail.com
Tue Aug 22 07:44:07 EDT 2017


On Monday, August 21, 2017 at 11:31:48 AM UTC-5, Chet Buell wrote:
> Need some help with updating python to call or start a
> fortran a.out executable  The problem I am having is I have
> an old Fortran based model that I need to run, in the past
> the fortran was triggered through the following python
> code:
> 
> #run fortran
> x = commands.getoutput(path+'/a.out')
> 
> Since the commands.getoutput has been depreciated it will
> not run on the newly built server that will now host this
> model. I have manually confirmed that the compiled a.out
> does run and produces the files, but the problem I am
> having is in triggering it to run with python.  The answer
> is probably so easy it is obviously being overlooked, but I
> can not seem to find it.  Any suggestions or help would be
> greatly appreciated.

> TITLE: python to call or start a fortran a.out

Please do consider the title of your posts more carefully.

The title you chose here was unfortunate, as it will not
provide an intuitive link between the problem and the
solution, therefore, it is unlikely that someone with the
same _general_ problem, will benefit from this exchange in
the future.

The _general_ problem here had nothing to with Fortran, much
less a specific file or executable named "a.out". So a
better title would have been: "How to run an executable from
Python", or: "How to spawn a subprocess from Python and
capture the result". Or even: "How to poke my OS with a
sharp stick, using Python". Perhaps the last example was a
bit too generalized, i admit, but you get the point. :-)

A good template for composing questions on internet forums
is as follows:

  MESSAGE_TITLE: "A concise, generalization of the problem here..."
    
  MESSAGE_BODY: " An elaborate and specific explanation of the problem here..."
    
Mentioning "Fortran" and "a.out" in the body of the message,
would be fine.
    
One of the happy-accidents[1] of composing thoughtful
queries, is that, many times you will happen upon the answer
to your own question during the composition process, and
even if you don't, at least you will have a much better
chance of receiving prompt and quality responses by
following this template. So either way, it's a win-win.

[1] Think "Bob Ross" here. As his most important
contribution to society was that he taught us all a very
important lesson. Namely, that all accidents can be "happy
accidents". An eternal optimist, he was...



More information about the Python-list mailing list