View Single Post
  #2  
Old December 1st 08, 07:53 PM posted to sci.astro.research
Phillip Helbig---remove CLOTHES to reply
external usenet poster
 
Posts: 198
Default Earth to Mars Trajectory

In article , Jonathan
Thornburg writes:

Fortran is dragging a _lot_ of baggage these days.


This does depend rather strongly on where in the scientific-computing
ecosystem you look. For example, in the Cactus toolkit for the parallel
solution of hyperbolic PDEs (http://www.cactuscode.org), newly-written
physics code is something like
50% Fortran 90
30% C
15% C++
5% Fortran 77


Indeed. Weather/climate modelling is another area where Fortran is
still big. I worked in this field a bit several years ago. When I
heard that some special users have more disk space if they need more
than 100 MB, I thought "that's not so much" (even though disks were much
more expensive 15 years ago) until I realised they were talking about
100 MB of source code. Also, since I knew that these folks had a lot of
computing power, I didn't think that a couple of days on a Cray was that
much computing time, until I realised it was just the time needed for
compiling the code.

In short, if you are doing serious number crunching, you need the
efficiency of Fortran.

Note that the standard is still evolving. The last update was HUGE.

Partly this is historical inertia, but partly it's that Fortran (still)
has much better support than C/C++/Java for certain kinds of numerical
computation. For example, consider the following trivial Fortran 77
subroutine to multiply two n*n matrices:


[code deleted]

Consider that Fortran 90 has the built-in MATMUL intrinsic function:

FORTRAN

Intrinsic_Procedures

MATMUL

MATMUL (matrix-a, matrix-b)

Class: Transformational function - Generic

Performs matrix multiplication of numeric or logical matrices.

The "matrix"s can be arrays of rank one or two. At least one
argument must be rank two. The size of the first (or only)
dimension of "matrix-b" must equal the last (or only) dimension of
"matrix-a".

The type of the resulting array depends on the data types of the
arguments. The rank and shape of the result follows:

o If "matrix-a" has shape (n,m) and "matrix-b" has shape (m,k),
the result is a rank-two array with shape (n,k).

o If "matrix-a" has shape (m) and "matrix-b" has shape (m,k), the
result is a rank-one array with shape (k).

o If "matrix-a" has shape (n,m) and "matrix-b" has shape (m), the
result is a rank-one array with shape (n).


Examples:

Consider the following:

A is the matrix |2 3 4|, B is the matrix |2 3|,
|3 4 5| |3 4|
|4 5|

X is vector (1, 2), and Y is vector (1, 2, 3).


The result of MATMUL (A, B) is the matrix-matrix product AB with
the value

|29 38|
|38 50|

The result of MATMUL (X, A) is the vector-matrix product XA with
the value (8, 11, 14).

The result of MATMUL (A, Y) is the matrix-vector product AY with
the value (20, 26).

Note that all you need to code is "MATMUL(A,B)".

Built-in functions like SIN, SQRT etc will take an array as an argument
and perform the funtion on every element. I could go on and on. For
serious heavy-duty numerical computation, Fortran is the only serious
choice, both for efficiency of the code and for producing readable code.
(The latter was a disadvantage of Fortran77 and even older versions, but
even Fortran77 was more readable than C.)

Getting back to astronomy, IIRC a lot of code for processing data from
artificial satellites, space probes etc is in Fortran, as is much code
for modelling galaxy formation etc.