Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

perl to fortran code

by vnpandey (Scribe)
on Jul 26, 2000 at 15:14 UTC ( [id://24445]=perlquestion: print w/replies, xml ) Need Help??

vnpandey has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks As Russ had asked this question but I could not find any comments on it I am posting it again.. I would like to ask a related question: Could someone embed FORTRAN code using the XS/SWIG technique? Since gcc (as I understand it) has a FORTRAN back-end, it could compile fortran to a library just as easily as C, right? Please comment on it?? either way.. Thanks-vnpandey

Replies are listed 'Best First'.
Re: perl to fortran code
by tye (Sage) on Jul 26, 2000 at 19:51 UTC

    XS gives Perl access to C wrappers. Most C environments on systems that have FORTRAN will support calling FORTRAN routines from C. So Perl calls XS wrappers written in C which calls the FORTRAN code. Note that this is no less efficient than the "normal" case of Perl calling XS wrappers written in C which call the C code of some library.

    I would not suggest trying to remove C from the equation and write XS wrappers in FORTRAN. There may be cases where it is worthwhile to have the XS wrappers written in C call FORTRAN wrappers that then call the FORTRAN routines in some library. This would be useful if the library routines require data in a very FORTRANish format that is even a little difficult (or even impossible) to set up via C. You might also want Perl wrappers that call the XS C code. Then you can have a very Perl-like interface that is easy to use and maintain.

    The Perl wrapper accepts data in the mind-numbingly flexible ways that only a Perl routine can, standardizes it into quite simple Perl data types that make it nearly trivial to write the XS C code. The C code does minor conversions (if any) required to get that data in a format the both C and FORTRAN can handle easily, but more importantly knows how to pass data to a FORTRAN routine. The FORTRAN wrapper takes the simple data and converts it to the format expected by the library routine that was written with no expectation that it should ever making interfacing to C, much less Perl, easy.

    Sorry, I don't know any specifics about SWIG with FORTRAN.

Buzzcutbuddha: Re: perl to fortran code
by buzzcutbuddha (Chaplain) on Jul 26, 2000 at 18:43 UTC
    Is there a specific functionality you are looking for from FORTRAN that you can't achieve with Perl? Just curious really. Thanks!

    UPDATE: Is there a specific reason someone voted this --?
      Thanks..Actually there are some FORTRAN gurus(Doing research in Physics and Not CS) here who really do not want to learn perl apart form managing files etc.. which they find difficult to do in fort ran and very easy(this is not doubtable at all!!) in perl.. So they want to use similar stuff..for speed for bigger programmes it's expected that this perl to fortran code may/will help..Since they are not directly in CS field we can not expect them to learn perl to the extent they know FORTRAN.. That was the sole reason for this posting.. Regards:-vnpandey

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://24445]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-24 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found