Hi Luis-

I recommend reading and working the examples in the
PDL::PP chapter in the PDL Book.

  http://pdl.perl.org/content/pdl-book-toc.html

That should get you up the learning curve.  The
specific docs would be:

  PDL::PP   -- specific to PDL, see also the PDL
               distribution Lib/Slatec for an
               example of some other fortran bindings

  perlxstut -- how to "talk" to perl from C/XS/PP code
  perlxs    -- the gory details in reference

--Chris

On 9/4/2012 1:07 AM, Luis Mochan wrote:
I'm learning to use Inline::Pdlpp and I have several questions. Many fortran
subroutines modify their arguments, which are passed by reference. If I
call such a function with code such as

PDL::myfun($a, $b);
use Inline Pdlpp =><<'ENDPP'
     pp_def('myfun',
           Pars=>'a(); 'b(n);',
           Code=>'mysub_($P(a), $P(b), $SIZE(n));'
          );
ENDPP

can I be sure that the pdl's $a and $b (on the perl side) will be
modified if 'mysub_' modifies its first two arguments, or that they will
not be modified even if mysub_ does modify its arguments?

On the other hand, if the subroutine has many arguments and modifies
several of them, what is the best way to send back the modifications to
perl (easiest but not too inefficient)? I guess I could copy the
variables to output variables using something like
        
           Pars=>'...b(n);... [o] c(n);...',
           Code=>'
                  mysub_($P(a), $P(b), $SIZE(n));
                  ...
                  loop(n) %{ $c()=$b(); %}
                  ...
                  '
Would this work? This is related to the previous question: will $b()
(on the PP side) contain the changed values after returning from the
Fortran subroutine? In case this works, wouldn't it involve too much
copying? Is there a better/recommended way of sending the changes back
to the perl side?

One last question. Is there a simple way of sending back values that
are not in a pdl?

(Maybe all the questions could be answered with a pointer to the
relevant documentation.)

Thanks and best regards,
Luis



_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to