Re: including the NAG-Fortran Library

Valery Fine (fine@bnl.gov)
Tue, 17 Mar 1998 12:44:59 -0500


On 17 Mar 98 at 17:20, Krieg, M. wrote:

> been translated into C in combination with the ROOT Tool. Can
> anybody tell me whether this is possible and how I can do it? Is
> there any documentation

Yes it is possible as soon as one may and can call ANY subroutine
(FORTRAN ones inclkuded) from his C++ code.

This means to call some "Fortran" subroutine oe should create a C++
"wrapper" class, create his own DLL/Share library, load that into
ROOT session and call that C++ wrapper.

Jst very short example. I am willing to prepare more useful one too soon.

class AnyExternalSubrotuineWrapper {
{
private:
<define here all parameters you want to pass>

public:

AnyExternalSubrotuineWrapper(<put here the list of all parameters you want to
pass>);
void ExecuteModule(){ <name_of your favorite Fortran code>(<list of
its parameter>);
void operator()(){ExecuteModule();}
void operator()(void *f1, void *f2=0,void *f3=0,void *f4=0,
void *f5=0,void *f6=0,void *f7=0,void *f8=0,
void *f9=0,void *f10=0,void *f11=0,void *f12=0,
void *f13=0,void *f14=0,void *f15=0,void *f16=0,
void *f17=0,void *f18=0,void *f19=0,void *f20=0,
void *f21=0,void *f22=0,void *f23=0,void *f24=0);

};

From ROOT interactive session/ ROOT macro/C++ pre-compiled code one should do:

1. Create an instance of the AnyExternalSubrotuineWrapper class:

AnyExternalSubrotuineWrapper *MyNAGSubroutine = new AnyExternalSubrotuineWrapper(<list of parameters>);

2. call it:

MyNAGSubroutine(); /* with predefined parameters */

MyNAGSubroutine(<list of the new parameters); /* with the new parameters */

3. MyNAGSubroutine->ExecuteModule();

I'd like to call your attention that one may not point ALL parameters this way.

Hope this helps,
Valery



=================================================================
Dr. Valeri Faine (Fine)
------------------- Phone: +1 516 344 7806
Brookhaven National Laboratory FAX : +1 516 344 4206
Bldg. 510A /STAR mailto:fine@bnl.gov
Upton, New York, 11973-5000 http://nicewww.cern.ch/~fine
USA

Dr. Valery Fine Telex : 911621 dubna su
-----------
LCTA/Joint Inst.for Nuclear Res. Phone : +7 09621 6 40 80
141980 Dubna, Moscow region Fax : +7 09621 6 51 45
Russia mailto:fine@main1.jinr.dubna.su