FAQ
Hello all,

I have a shared object executable viz. *cable* which I execute as follows :

$ ansyscust71 -custom cable -p ANSYSRF

**ansyscust71 is a shell script and is a part of a software called ANSYS**


Now, I have generated a python module using a *fortran-python interface
generator called F2PY* using the same *make rules* which were used to make
*cable* when not using F2PY

I got a Python extension module named *cable_f2py* again.

From the python environment when I tried to execute *cable_f2py* ( this is
python module due to F2PY), I got a segmentation error just like how I would
get this error when I execute *cable* as follows when not using F2PY:

$ ./cable
Segmentation Fault

However, when I execute it as follows, it works

$ansyscust71 -custom cable -p ANSYSRF --> This is required for succesful
execution


Now, I dont understand how I can mimic the above way of execution from within
Python to execute *cable_f2py* which as I mentioned earlier is the result of
making and linking all the same libraries which were used while making and
linking cable

I am really confused

Can someone help me ??


Thanks in advance,

Best Regards,
Satish






--
SATISH KUMAR CHIMAKURTHI
Graduate Teaching Assistant
CFD GROUP
UNIVERSITY OF KENTUCKY
LEXINGTON
KENTUCKY - 40508
Email: skchim0 at engr.uky.edu
Mobile: 859-312-8425

Vice-President
American Institute Of Aeronautics and Astronautics
Student Chapter
University Of Kentucky

Search Discussions

  • Peter Hansen at Sep 20, 2003 at 12:04 am

    satish wrote:
    I have a shared object executable viz. *cable* which I execute as follows :
    $ ansyscust71 -custom cable -p ANSYSRF

    **ansyscust71 is a shell script and is a part of a software called ANSYS**

    Now, I have generated a python module using a *fortran-python interface
    generator called F2PY* using the same *make rules* which were used to make
    *cable* when not using F2PY

    I got a Python extension module named *cable_f2py* again.

    From the python environment when I tried to execute *cable_f2py* ( this is
    python module due to F2PY), I got a segmentation error just like how I would
    get this error when I execute *cable* as follows when not using F2PY:

    $ ./cable
    Segmentation Fault

    However, when I execute it as follows, it works

    $ansyscust71 -custom cable -p ANSYSRF --> This is required for succesful
    execution

    Now, I dont understand how I can mimic the above way of execution from within
    Python to execute *cable_f2py* which as I mentioned earlier is the result of
    making and linking all the same libraries which were used while making and
    linking cable

    I am really confused
    So are we, as most of what you describe above seems to have very little
    relationship with Python. You might need to think through your problem
    and attempt to explain it in a different way for us to help you. For
    example, you don't show *how* you try to execute it "from the python
    environment". Have you got some code to show us?

    Anyway, as a bit of a long shot, are you aware of the os.system() function,
    and the various other methods of running external executables? If
    you are already using one of those, you might want to show us how you
    use it.

    -Peter
  • Satish at Sep 20, 2003 at 12:21 pm
    Hello peter,

    Thanks for responding. I will think through my problem again and present it in
    the best possible form shortly. However, in a nutshell, what I need to do is
    *EXECUTE A PYTHON MODULE WITH A SHELL SCRIPT PROVIDED BY AN EXTERNAL PROGRAM,
    FROM WITHIN PYTHON*

    The name of the script is *ansyscust71* which is a shell script provided by a
    Finite Element software called ANSYS. ANSYS provides a number of
    customization features, as a part of which, it allows users to write fortran
    codes using ANSYS's internal functions/methods and execute the corresponding
    *shared modules* using the following command.

    $ ansyscust71 -custom cable -p ANSYSRF

    ANSYS EXECUTES SUCCESFULLY


    However, initially when I did'nt know of the above command, I executed
    *cable* as follows :

    $ ./cable

    ANSYS EXECUTED
    Segmentation Fault

    Later I did use the right command as I mentioned above, which made my module
    execute succesfully.

    *cable* is a shared module which I got after *making* my fortran code viz.
    *ansys.F90* by linking it with *ANSYS libraries* using a *Makefile* that I
    wrote for the purpose


    After this, I intended to do the same thing from python. I wrapped my fortran
    code *ansys.F90* using F2PY(Fortran to Python Interface Generator), with
    which many of the python users are familiar. I got a python module named
    *cable_f2py* succesfully.


    Sample *ansys.F90*

    SUBROUTINE ansys()
    cmd='START_OF_ANSYS'
    ncommand=len_trim(cmd)
    where=mainan(ncommand,cmd)
    END SUBROUTINE ansys

    This is just a part of *ansys.F90* which initializes ANSYS upon execution

    From python I execute the module as follows :
    import cable_f2py %cable is a python module generated by F2PY
    cable_f2py.ansys()
    ANSYS EXECUTED
    Segmentation fault

    $

    ANSYS gets initialized succesfully. However, I get a segmentation fault at the
    end and PYTHON skips the execution from that point and transfers control to
    the command prompt.

    If you remember, the same thing happened when I tried to execute *cable* as
    *./cable* initially when I did'nt use F2PY to generate the Python module


    Precisely, this is my problem.

    Does this help you to help me ??


    Thanks for your time and patience in advance,

    Regards,
    Satish

    On Friday 19 September 2003 08:04 pm, Peter Hansen wrote:
    satish wrote:
    I have a shared object executable viz. *cable* which I execute as
    follows : $ ansyscust71 -custom cable -p ANSYSRF

    **ansyscust71 is a shell script and is a part of a software called
    ANSYS**

    Now, I have generated a python module using a *fortran-python interface
    generator called F2PY* using the same *make rules* which were used to
    make *cable* when not using F2PY

    I got a Python extension module named *cable_f2py* again.

    From the python environment when I tried to execute *cable_f2py* ( this
    is python module due to F2PY), I got a segmentation error just like how I
    would get this error when I execute *cable* as follows when not using
    F2PY:

    $ ./cable
    Segmentation Fault

    However, when I execute it as follows, it works

    $ansyscust71 -custom cable -p ANSYSRF --> This is required for succesful
    execution

    Now, I dont understand how I can mimic the above way of execution from
    within Python to execute *cable_f2py* which as I mentioned earlier is the
    result of making and linking all the same libraries which were used while
    making and linking cable

    I am really confused
    So are we, as most of what you describe above seems to have very little
    relationship with Python. You might need to think through your problem
    and attempt to explain it in a different way for us to help you. For
    example, you don't show *how* you try to execute it "from the python
    environment". Have you got some code to show us?

    Anyway, as a bit of a long shot, are you aware of the os.system() function,
    and the various other methods of running external executables? If
    you are already using one of those, you might want to show us how you
    use it.

    -Peter
    --
    SATISH KUMAR CHIMAKURTHI
    Graduate Teaching Assistant
    CFD GROUP
    UNIVERSITY OF KENTUCKY
    LEXINGTON
    KENTUCKY - 40508
    Email: skchim0 at engr.uky.edu
    Mobile: 859-312-8425

    Vice-President
    American Institute Of Aeronautics and Astronautics
    Student Chapter
    University Of Kentucky

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedSep 19, '03 at 10:16p
activeSep 20, '03 at 12:21p
posts3
users2
websitepython.org

2 users in discussion

Satish: 2 posts Peter Hansen: 1 post

People

Translate

site design / logo © 2022 Grokbase