Dear Rooters,
I did check whether the arguments of the herfasy_(..) correctly
input from the C++ code. The result is postive. In fact, there is a
problem on the linkage between fortran codes. The reason I said that is
because I have been tested these codes. I changed the herfasy.f to be main
programme and input arguments the same values as the C++ code pass to
them. Then I compile it with other fortran objects by f77. However
I got the different outputs in herfasy.f for two cases ( one is directly
from changed herfasy and the other from the c++ and old herfasy.f). I
believe the linkage between the fortran objects which is setup by the
libg2c.a is different with that from the f77.
I work on the i386 Linuxes platform. If you met the same problem before,
please help me out since you know, I have a lot of subrountine and it is
difficult for me to locate the problems.
Thanks,
wang
On Wed, 4 Apr 2001, Andre Holzner wrote:
> Hi Wang,
>
> are you sure herfasy_(..) takes four real*8 arguments ?
> E.g. The usual 'real' under fortran is float& in c++
> on i386 Linuxes.
>
> Could you post the function header of herfasy.f ?
>
> Which platform are you using ?
>
> best regards,
>
> André
>
>
>
> Wang Xu wrote:
> >
> > Dear Rooters,
> > I try to link a fortran code(herasy.f) to the c++ code. The
> > fortran code by itself works fine but if it link to this c++ code, one of
> > subroutine of the fortran code dosen't give a right answer. Have you ever
> > met same problem? If you did, please give me some suggestion as soon as
> > possible.
> > (I suspicious that I didn't put correct flag when I complie these two
> > code. what I did is following:
> > f77 -c herfasy.f *.f
> > g++ -c acceptance.cxx
> > g++ herfasy.o *.o acceptance.o -L/lib -l* -lg2c)
> > Thanks,
> > wang
> > Here is the acceptance.cxx
> > #include <stdio.h>
> > #include <iostream.h>
> >
> > // ROOT include
> > #include "TROOT.h"
> > #include "TFile.h"
> > #include "TNtuple.h"
> > #include "TMath.h"
> >
> > extern "C" void herfasy_(double &,double &, double &,double &);
> >
> > int main()
> > {
> > TROOT accept("accept","accept");
> > TFile *f = new
> > TFile("/work/halla/e95001-2/wangxu/hbook/eq05/gmn_1pass_21067.root");
> > TNtuple *h1 = (TNtuple*) f->Get("h1");
> > Float_t asyt,thetat, yt, phit, deltat;
> > double Enbeam,omega,thetas,asytt;
> > Int_t nbytes;
> > Enbeam=1.727;
> > Float_t Eset=1.453;
> > Float_t thed = 25.80;
> > // Set branch addresses
> > h1->SetBranchAddress("Ethetat", &thetat); // in mr
> > h1->SetBranchAddress("Ephit", &phit); // in mr
> > h1->SetBranchAddress("Eyt", &yt); // in mm
> > h1->SetBranchAddress("Edelta", &deltat); // in %
> > TFile *acceptance = new TFile("acceptance.root", "RECREATE");
> > TNtuple *ntuple = new TNtuple("ntuple", "Asymetry Study",
> > "Ethetat:Ephit:Eyt:Edelta:asyt");
> > // Total event number
> > //Int_t nentries = (Int_t) h1->GetEntries();
> > Int_t nentries=1;
> > for(Int_t i=0; i<nentries; i++) {
> > nbytes += h1->GetEvent(i);
> > thetas=acos(cos(thed*3.1415926/180+phit/1000)*cos(thetat/1000));
> > thetas= thetas*180/3.1415926;
> > omega=Enbeam-Eset*(1+deltat/100);
> > herfasy_(Enbeam,thetas,omega,asytt);
> > asyt=asytt;
> > printf("%f\n",asyt);
> > ntuple->Fill(thetat,phit,deltat,asyt);
> > }
> > ntuple->Write();
> > f->Close();
> > acceptance->Close();
> > return(0);
> > }
>
> --
> ------------------+----------------------------------
> Andre Holzner | +41 22 76 76750
> Bureau 32 2-C13 | Building 32
> CERN | Office 2-C13
> CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/
>
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:41 MET