RE: [Dev-C++] Mixed Language Programming w/Dev-Cpp
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Scott W. <se...@al...> - 2002-10-30 08:23:08
|
Well. . . there wasn't any 'code' in my message, just a sketch of the fortran subroutine prototypes I'm trying to call from c. If you read my message, you'll note the source of the 'code' is an existing numerical package. The author's standards of variable naming/white space use are of little concern to me and certainly have nothing to do with the question posed. Scott -----Original Message----- From: Daniel Glenfield [mailto:sp...@ho...] Sent: Wednesday, October 30, 2002 3:08 AM To: se...@al...; dev...@li... Subject: Re: [Dev-C++] Mixed Language Programming w/Dev-Cpp That is really ugly code! I'm sorry but please give variables meaningful names! And use Whitespace! Sorry, I've been reading Code Complete recently. Excellent book - by Steve McConnell. A bit dated in places but excellent for ALL programmers (language and experience independent). >From: "Scott Williams" Reply-To: To: "Dev-Cpp-Users@Lists. Sourceforge. >Net" Subject: [Dev-C++] Mixed Language Programming w/Dev-Cpp Date: 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)=dy(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 _________________________________________________________________ Surf the Web without missing calls! Get MSN Broadband. http://resourcecenter.msn.com/access/plans/freeactivation.asp |