[Beowulf] Fortran is Awesome
Robert G. Brown
rgb at phy.duke.edu
Fri Nov 30 09:35:21 PST 2018
On Thu, 29 Nov 2018, Paul Edmon wrote:
> Not necessarily.? I learned Fortran as part of my Numerical Methods for
> Physicists in grad school.? We had the option of using C or Fortran.? Fortran
> has proved much more useful to learn than C and I've picked up C on the side.?
> In many cases programming is a matter of logical structured thinking, if you
> can get that the rest is learning syntax for different languages.
> For people doing numerical methods, Fortran is way superior in terms of
> usability than C.? That said I would never teach Fortran in a Computer Science
> class, but in a Numerical Methods for Scientists I would go with Fortran.
That's similar to my own experience, actually -- I learned PL/1 (gasp, I
know:-) in my first programming course, used it in my second course
(writing an assembler emulator and compiler emulator in PL/1 was
entertaining), and the only other course I took in programming of any
sort was Numerical Methods, and Learned Fortran IV (and how to do e.g.
quadrature and lots more) in that course. For a long while all of my
actual programming was in F-IV as that's what the IBM 360/370 would run
and it let me use at least some of the stuff from our textbook as well
as a couple of other big books filled with F-IV numerical code, but in
the end I wrote a ton myself. I literally filled a box with cards
writing a complicated angular momentum coupling code for nuclear
scattering experiments -- two ways, one of them a short form derived by
my employer, one of them brute force -- to verify that his derivation
was correct within a single phase error.
BUT, F-IV's I/O sucked. Really. Hollerith? The branching sucked. The
line requirements (designed for first cards, then TTY lines) sucked.
The character data handling in general sucked. Its conditionals were
comparatively primitive. I continued using it across getting into grad
school and writing my dissertation and programming my dissertation, but
somewhere in the mid-late 80's I started really using PCs big time, as
they got to where I could actually run SOME stuff on them instead of
expensive, expensive mainframes or the department's expensive, expensive
mini. I got deSmet C for myself, taught myself C, and realized that
fortran -- even F77 -- was miserable and clunky compared to
Fortran-anything, if you wanted to write ANYTHING LIKE a decent UI. A
second problem with Fortran was that the MS Fortran compiler for PC-ATs
etc in the mid-80s didn't support the 8087, and if you wanted to do
anything numerical, you had to use the 8087 and its co-processor
descendants (until a few years later they put it all on one chip). C
let you inline assembler and wrap them into subroutines for your own
library to use the co-processor in code, and that's exactly what I did.
Finally, although it took me some time, I learned to use pointers. OMG.
Pointers are complete utter magic. Assembler-level programming with
upper-level commands. I built perfect data structures without wasted
space and could still use very general purpose library routines to do
numerical stuff like matrices, angular momentum sums, ODE solutions,
quadratures, AND it was remarkably easy to build a graphical front end
inside C code and visualize the results of my computations (not so much
for fortran, not at anything our grant could afford).
At this point, while I do still have all of the fortran code I ever
wrote (or very nearly) squirrelled away, I haven't written fortran in
maybe 30 years -- somewhere in the late 80's I got my first Unix
workstation and Unix and C are basically perfect matches -- and never
looked back. ALL of my serious code since then has been in C, and yes,
you can write very effective and efficient numerical code in C while
suffering far less on I/O, character data processing, UIs, APIs,
networking, integration with hardware, portability, and more. All with
a language that is a thin veneer of upper level language sensibility on
top of raw metal, where you can usually see the assembler shining
through (which helps write reasonably optimal code, actually).
Fortran arguably retains the advantage in linear algebra-based
programming and vectorization, but my own code was not that LA intensive
and parallelization was (obviously, or why am I here) more important
than vectorization in getting my work done. I had access to vector
supercomputers (at enormous cost) and even ran my stuff on them once or
twice just to benchmark it, but I could run my stuff on literally 100+
Unix workstations all over campus in the background and get real-world
GFLOPs 24x7 (for GLFOP-Years of total effort) "for free" (for the asking
very nicely, actually) while I never beat maybe 35 or 40 MFLOPs on a
Cray Y/MP, and would have had a tiny handful of hours as EVERYBODY
wanted on the Cray Y/MP.
I will not willingly code in Fortran ever again. Hell, at my age I may
never write serious C applications ever again, but if I write ANYTHING
that requires a compiler, its going to be in C. At this point I have
literally GBytes of C code I've written, stolen, modified etc and that
doesn't include actual libraries or all the stuff in subversion.
Dieharder is written in C. I realize that if I learned Fortan all over
again today, the current versions of Fortran have absorbed most of the
goodness of C while remaining strongly typed, and perhaps if I were
learning to code now I'd be more inclined to stick with Fortran if I
learned it first. But for me, C is almost perfect freedom. I don't
need no stinkin' compiler-time protections, and if I want an object,
hey, that's why God invented unions and structs -- keep your creator and
destructor and contents access overhead.
> -Paul Edmon-
> On 11/29/18 10:09 AM, Nathan Moore wrote:
> I've probably mentioned this before.? If a student only has one
> programming course, teaching fortran feels like malpractice,
> however, this book is awesome!
> Classical Fortran, Kupferschmid
> On Wed, Nov 28, 2018 at 12:15 PM Paul Edmon <pedmon at cfa.harvard.edu>
> Very true. I would never use Fortran for an OS.? From what I
> compiler writers still prefer Fortran as its easier to
> vectorize.? Thus
> if you want best vector performance from your code Fortran
> is it, mainly
> due to the easy of writing a compiler that can do so.
> In the end use the tool that's best for the job.? That's the
> moral of
> the story.
> -Paul Edmon-
> On 11/28/2018 12:17 PM, Robert G. Brown wrote:
> > On Wed, 28 Nov 2018, Paul Edmon wrote:
> >> Once C has native arrays and orders them properly, then
> we can talk :).
> > Yeah, like this.? That's really the big difference, isn't
> it? Although
> > one can argue about just what "properly" really means...
> other than "in
> > the same order that Fortran orders them" ;-)
> > ?? rgb
> >> -Paul Edmon-
> >> On 11/28/18 11:36 AM, Peter St. John wrote:
> >> ????? Maybe I'm being too serious but in the old days, Fortran
> was the
> >> ????? most mature, maintained compiler and the libraries were
> >> ????? then later, C had better compilers but the libraries were
> >> ????? great. Now, I think the only good thing about Fortran is
> >> ????? it's pretty easy to learn?
> >> Peter
> >> On Wed, Nov 28, 2018 at 11:30 AM Stu Midgley
> <sdm900 at gmail.com> wrote:
> >> ????? I agree 100% .?You can't beat bash and fortran.
> >> On Wed, Nov 28, 2018 at 9:02 AM Paul Edmon
> >> <pedmon at cfa.harvard.edu> wrote:
> >> ????? Fortran is and remains an awesome language.? More
> >> ????? people should use it:
> >> ????? -Paul Edmon-
> >> ????? _______________________________________________
> >> ????? Beowulf mailing list, Beowulf at beowulf.org sponsored
> >> ????? by Penguin Computing
> >> ????? To change your subscription (digest mode or
> >> ????? unsubscribe) visit
> >> ????? http://www.beowulf.org/mailman/listinfo/beowulf
> >> --
> >> Dr Stuart Midgley
> >> sdm900 at gmail.com
> >> _______________________________________________
> >> Beowulf mailing list, Beowulf at beowulf.org sponsored by
> >> Computing
> >> To change your subscription (digest mode or
> unsubscribe) visit
> >> http://www.beowulf.org/mailman/listinfo/beowulf
> > Robert G. Brown http://www.phy.duke.edu/~rgb/
> > Duke University Dept. of Physics, Box 90305
> > Durham, N.C. 27708-0305
> > Phone: 1-919-660-2567? Fax: 919-660-2525
> email:rgb at phy.duke.edu
> Beowulf mailing list, Beowulf at beowulf.org sponsored by
> Penguin Computing
> To change your subscription (digest mode or unsubscribe)
> visit http://www.beowulf.org/mailman/listinfo/beowulf
> - - - - - - -?? - - - - - - -?? - - - - - - -
> Nathan Moore
> Mississippi River and 44th Parallel
> - - - - - - -?? - - - - - - -?? - - - - - - -
> Beowulf mailing list, Beowulf at beowulf.org sponsored by Penguin Computing
> To change your subscription (digest mode or unsubscribe) visit http://www.be
Robert G. Brown http://www.phy.duke.edu/~rgb/
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Phone: 1-919-660-2567 Fax: 919-660-2525 email:rgb at phy.duke.edu
More information about the Beowulf