home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!wupost!usc!rpi!ghost.dsi.unimi.it!itnsg1.cineca.it!ditolla
- From: ditolla@itnsg1.cineca.it (Francesco Di Tolla)
- Subject: Re: C vs. FORTRAN
- Message-ID: <1992Sep4.075353.16079@itnsg1.cineca.it>
- Organization: Laboratorio di Fisica Computazionale, INFM. Trento Italia
- References: <DWISEMAN.92Sep3164036@spsd630a.erim.org>
- Date: Fri, 4 Sep 1992 07:53:53 GMT
- Lines: 67
-
- dwiseman@spsd630a.erim.org (Dave Wiseman) writes:
-
-
- >Help!
-
- >I have a (two) simple programs, one in fortran, and one in C. I have compiled
- >them both optimized, and timed the results. The fortran version takes .1 s
- >to run, and the C version takes 12.5s to run. I know (hope) that there is a
- >simple remedy for this. The project that I am working on has to do many
- >sines and cosines, and I'd prefer to keep the entire program in C, and not
- >mix the languages. What can I do to improve the speed of the C version?
-
- > Dave Wiseman
- > dwiseman@erim.org
-
- >-------------------------------------------------------------------------------
- >#include <stdio.h>
- >#include <math.h>
-
- >main (argc,argv)
- > int argc;
- > char **argv;
- >{
- > double angle,delta,the_sin,the_cos;
- > int i;
- >
- > angle = 0.0;
- > delta = 0.01;
- >
- > for (i=0; i<1000000; i++)
- > {
- > the_sin = sin(angle);
- > the_cos = cos(angle);
- > angle += delta;
- > }
- >}
- >-------------------------------------------------------------------------------
- > program test
-
- > real*8 angle,delta,the_sin,the_cos
- > integer*4 i
-
- > angle = 0.0
- > delta = 0.01
-
- > do I=1,1000000
- > the_sin = dsin(angle)
- > the_cos = dcos(angle)
- > angle = angle + delta
- > enddo
-
- > end
- >-------------------------------------------------------------------------------
- >--
- >David Wiseman dwiseman@erim.org
- >Environmental Research Institute of Michigan
-
- Are you shure your fortran program is performing any computation?
-
- By
- Franz
-
- --
- --------------------------------------------------------------------------
- | Francesco D. Di Tolla | Bitnet: ditolla@itncisca.bitnet |
- | Dip. di Fisica Univ. di Trento | Internet: ditolla@itnsg1.cineca.it |
- | I-38050 Povo (TN) - Italy | Decnet: itnvax::ditolla (37.65) |
-