Re: [Dev-C++] Mixed Language Programming w/Dev-Cpp
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Roger R. <rr...@us...> - 2002-10-30 14:19:52
|
Hi everybody Long time ago (1994) I worked in a simulation program using Borland C++ 3= .1 and Microsoft Fortran 5.1. The way I found to work fine was making a windows DLL from the Fortran cod= e (with Microsoft Fortran was possible) and using the DLL in a standard way from m= y C++ code. I don=B4t know if it=B4s possible with gnu Fortran compiler to make a DLL,= but if you can=B4t do it, you will have some problems with the function calling beteween C an= d Fortran, the byte ordering, etc. If you need some other help I will review my program because I don=B4t rem= ember the details Roger Send reply to: <se...@al...> From: "Scott Williams" <se...@al...> To: "Dev-Cpp-Users@Lists. Sourceforge. Net" <dev-cpp- us...@li...> Subject: [Dev-C++] Mixed Language Programming w/Dev-Cpp Date sent: Tue, 29 Oct 2002 15:33:56 -0500 > Hi, > > Wondering if anyone has experience with mixed language programming and > whether it can be done with Dev-Cpp? > > In particular, I'm writing a mathematical simulation in C (using > Dev-Cpp) and would like to make using of some existing numerical > routines in Fortran. My C knowledge is necessity-based self-taught and > so limited; don't know anything about Fortran. Neither do I know much > about using compilers/linkers/etc in command line mode (which is why I > use Dev-Cpp--I let it worry about that stuff). > > Still, I know that built-in to the gcc interface is the g77 compiler > so there must be a way to compile the fortran source to an object with > g77 and then link to & call the routines from C. Could it be as > simple as added fortran source files to my Dev-Cpp project? If so, > any thoughts on how to prototype the Fortran functions & subfunctions > to make them accessible to the C calling routines? > > BTW, I've tried f2c but have been unable to make that work. That > approach is suboptimal anyway because the resulting C code is far less > efficient than the original Fortran source. > > Perhaps specifics would help. The fortran code I'm trying to use is a > single file ode.f The entry point is the subroutine ode. Here's how > the file is laid out: > > // ode.f > > subroutine ode(f,neqn,y,t,tout,relerr,abserr,iflag,work,iwork) > implicit real*8(a-h,o-z) > > c f -- double precision subroutine f(t,y,yp) to evaluate > c derivatives yp(i)=3Ddy(i)/dt > c neqn -- number of equations to be integrated (integer*4) > c y(*) -- solution vector at t (real*8) > c t -- independent variable (real*8) > c tout -- point at which solution is desired (real*8) > c relerr,abserr -- relative and absolute error tolerances for > local c error test (real*8). at each step the code requires > c dabs(local error) .le. dabs(y)*relerr + abserr c > for each component of the local error and solution vectors c > iflag -- indicates status of integration (integer*4) c > work(*) (real*8) -- arrays to hold information internal to c > iwork(*) (integer*4) which is necessary for subsequent calls > > . . . ode calls de: > subroutine de(f,neqn,y,t,tout,relerr,abserr,iflag, > 1 yy,wt,p,yp,ypout,phi,alpha,beta,sig,v,w,g,phase1,psi,x,h,hold, > 2 start,told,delsgn,ns,nornd,k,kold,isnold) > implicit real*8(a-h,o-z) > > . . . de calls step & intrp: > subroutine step(x,y,f,neqn,h,eps,wt,start, > 1 hold,k,kold,crash,phi,p,yp,psi, > 2 alpha,beta,sig,v,w,g,phase1,ns,nornd) > implicit real*8(a-h,o-z) > > subroutine intrp(x,y,xout,yout,ypout,neqn,kold,phi,psi) > implicit real*8(a-h,o-z) > // end ode.f > > The derivative function f is written in C (and that's where I was > having probs with the f2c route). > > All help is appreciated (sorry for the long post). > > Scott > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |