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.


In reply to Re: perl to fortran code by tye
in thread perl to fortran code by vnpandey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.