Fortran vs. C for numerical work (SUMMARY)

Peter Holzer hp at vmars.tuwien.ac.at
Wed Nov 28 01:08:00 AEST 1990


bglenden at mandrill.cv.nrao.edu (Brian Glendenning) writes:

>A few days ago I posted a note asking:

>>It is often stated that Fortran is better than C for numerical work. I
>>am interested in compiling both the standard list of such arguments
>>and what any counterarguments might be.

>Here is my summary of the responses I received. 

A few remarks to the summary:

>2. C has no conformant arrays, i.e. you can't do the equivalent of:

>      SUBROUTINE FOO(A, M, N)
>      REAL A(M,N)

>In C you either have to do your own indexing *(a + j*m +i) or have
>pointers to pointers *(*(a + i) + j). You can in either case
		      ^^^^^^^^^^^^^^^ You would write that as 
a [i][j] ordinarily, which is a rather nice syntax :-)

>use a macro expansion ARRAY(a,i,j) to take some of the sting out of
>the syntax.

>3. In fortran functions like sin, cos, ** are intrinsic.

>I think that ANSI C has a method by which compilers may make sin, cos
>etc intrinsic, but I don't remember how it works. Maybe a wizardly
>followup could answer this question.

No special method. An ANSI C compiler may treat any function
defined in the standard as intrinsic if the header file that
defines the function has been included.

>A ** builtin _is_ handy.

>4. Fortran has complex variables.

>If you need to do a lot of complex arithmetic this might be a show
>stopper unless you have a good source of C complex arithmetic
>routines. Even then it is not going to be as convenient as in Fortran.

Would be nice sometimes. But other special types are also handy
sometimes (e.g. very long integers), and you cannot have
everything. If you want C++ you know where to find it.

>6. C can ignore the placement of parentheses

Not anymore. The standard says that the compiler may regroup
expressions only if it does not change the result.

--
|    _  | Peter J. Holzer                       | Think of it   |
| |_|_) | Technical University Vienna           | as evolution  |
| | |   | Dept. for Real-Time Systems           | in action!    |
| __/   | hp at vmars.tuwien.ac.at                 |     Tony Rand |



More information about the Comp.lang.c mailing list