It is unclear if the Fortran only or the C++ as well made you shiver. I am hoping it was only the Fortran, because you might need to get at least your hair wet in respect of the C++ to solve this.

I know absolutely nothing about OpenMP (update: but Google is my friend - it already tells me that ANSI C is enough, so already the water got warmer).

It appears that OpenMP is dissembled across embedded, environment variable and shared object facilities. To use Perl instead of C for all three of these requires then three separate techniques:

1) compiler directives: For this part of the interface you could translate Perl main programs to C main programs without knowledge of C using B::C (update: or perlcc) and then apply the OpenMP directives to that as directed by the OpenMP documentation.

2) Environment variables: For these, I tend to make a subroutine that gets them parametrically and then uses IPC::Open3 to create a session with whatever foreign program (could be your own C from Perl program in thes case) is being run with syntax something like:

use IPC::Open3; sub NameOfCommandInterface { # subcommand, envvar, val, envvar, val... my $subcommand = shift; my $env = ''.; while ( @_ ) { $env .= 'export ' . shift(); $env .= '="' . shift() . '";'; } my $pid = open3 my $wh, my $rh, my $eh, $env . 'NameOfCommand' or +die $!; print $wh $subcommand; close $wh; my @er = <$eh> and die ( join ('',@er )); close $eh; my @rt = <$rh>; close $rh; waitpid $pid, 0; return @rt; }
(update: strictly speaking that is a translation technique of shell to Perl rather than C to Perl of course)

3) shared objects - load those into Perl using P5NCI::Library.

That at least completes the 3 requirements to build the interfacing I found by googling - if there are more, do tell and we'll have a look for you. But (update) to address more of your questions:

"Is Perl 5 multi-threading robust enough to take such a standard?" Nothing to do with robustness - the OpenMP standard is suitable for C. You could try to take Perl's multithreading at source level and interface that to OpenMP, but I suspect the water is too cold for you there. (Update: to be clear, for an OpenMP implementation you would have to achieve the multithreading via something like the three techniques I outline above, and not by using Perl's own multithreading) Will Perl 6 support OpenMP? I presume that the modules I have mentioned will get ported to Perl 6 so I presume yes insofar as you need to build your own main glue interfacing along lines such as above.

__________________________________________________________________________________

^M Free your mind!


In reply to Re: OpenMP from Perl? by Moron
in thread OpenMP from Perl? by cdarke

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.