newbie_sunny has asked for the wisdom of the Perl Monks concerning the following question:
I have successfully wrapped a Fortran subroutine in C and run it, and then incorporated the C code into PerlXS code (see below), and everything compiles except for a warning at the make stage for the xs about "Clock skew detected. the fortran file was also compiled.
.When I tried to either link the C and Fortran codes as in the C and Fortran case it throws a lot of "undefined references" and when I run a .pl file that has the subroutine, it outputs "symbol lookup error". My question is, should I include some kind of header file? I have already installed ExtUtils::F77.pm but have only included it in the .pl file. Below I included the xs code, please assume that the .f code is a subroutine that compiles and runs.
Thanks in advance, newbie_sunny**** hfuncs.xs***** #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include <stdio.h> #include <complex.h> #include <math.h> #include "ppport.h" MODULE = hfuncs PACKAGE = hfuncs void for_sub_(int &i,double &x, double &y, int &ny) PPCODE: for_sub_(&i, &x, y, &ny); ***** test.pl **** #! /opt/perl5/bin/perl -w use ExtUtils::testlib; use ExtUtils::F77; use hfuncs; use lib "/usr/lib/perl5/site_perl/5.8.8/ExtUtils/F77"; use lib "/u0/lib/perl5/site_perl/5.8.8/ExtUtils/F77"; $i=1; $ny=3; $x = 3.14159; @y = (1.1, 2.2, 3.3); printf "Perl calling Fortran subroutine, passing\n"; printf"i= $i, x= $x\n"; printf"y[] = $y[0], $y[1], $y[2]\n"; hfuncs::for_sub_(\$i, \$x, \@y, \$ny);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Wrapping a Fortran subroutine in PerlXS code
by Anonymous Monk on Oct 21, 2009 at 06:26 UTC | |
by Anonymous Monk on Oct 21, 2009 at 06:31 UTC |