News for hackers. Stuff that matters.
Re:Fortran is still a thing by wycy on Tuesday November 27, 2018 @11:57AM (#18544021)
I'm actively working on multiple Fortran projects, including one that's being written from scratch just in the last year in modern Fortran 2018.

Modern Fortran looks completely different from the old school FORTRAN77 most people probably imagine. Gone are the days of fixed-format, where the columns actually mattered, and gone are the days of unreadable ALL CAPITAL LETTERS, and gone are the days of GOTO.

I developed a Fortran implementation of Python's argparse[0] recently to use for another project. The code is nothing like the monstrous spaghetti code of days past---although I do still obsessively line up my code in columns, this isn't important.

[0] https://gitlab.com/bwearley/f-clap

Re:Fortran is still a thing by WalterBright on Tuesday November 27, 2018 @04:05PM (#18546738)
Fortran-10 is old school, not Fortran-77.

https://github.com/DigitalMars/Empire-for-PDP-10

Fortran-77 is for young whippersnappers.

Re:Fortran is still a thing by beloch on Wednesday November 28, 2018 @12:23AM (#18549481)
In the early 2000's I worked on some Fortran-77 code that we were parallelizing (As a babe, this was my first experience with Fortran-77). We were having strange bugs because it seemed like some MPI calls were just not happening and others were. There were no compiler errors or warnings. Everything was supposedly fine. However, certain properties were propagating across grid elements just fine and others weren't. e.g. A particle might cross a vertical boundary and be just fine in the next CPU's element, but if it crossed a horizontal boundary it would lose it's horizontal momentum but keep everything else.

Eventually we figured out that the lines that weren't working were just over 80 characters long and the ones that were working were under 80 characters long. The compiler we were using was adhering to the Fortran-77 spec of a maximum of 80 characters per line (because that's what would fit on a punch-card), but it was just ripping those lines out and ignoring them without raising any kind of warning. If a line of code was over 80 characters long, it was just silently ignored. All we had to do was split the lines over 80 characters up and that particular bug was squished.

In my humble opinion, if a language can trip you up because of how many characters fit on a punch-card, it qualifies as "old school".

Re:Fortran is still a thing by WalterBright on Wednesday November 28, 2018 @01:44AM (#18549709)
If you were using Hollerith punch cards, like you were supposed to, you couldn't have had that problem.
Re:Fortran is still a thing by wycy on Tuesday November 27, 2018 @04:44PM (#18547121)
That column of GOTOs in EMPIRE.FOR. That is the stuff of nightmares.

EDIT- Terrifying:

251 GOTO (21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37) I-20

Re:Fortran is still a thing by wahern on Tuesday November 27, 2018 @06:34PM (#18547904)
It's basically a switch statement, but without the benefit of descriptive case identifiers. So it's basically,

  switch (I-20) {
  case 21:
  case 22:
    ...
  }
but you have to imagine "21" as the string identifier, not the integer value. `I-20` is indexing the list of labels in the GOTO statement.

The earlier column beginning with

  GOTO (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) I
is easier to read

  switch (I) {
  case 1:
     ...
  case 2:
     ...
  }
because the integer value of I, the string labels, and their index in the list are all the same.

I've never written Fortran. I did learn to program using TI-85 BASIC, though, and am well versed in C. The GOTO in the Fortran code is possibly the easiest part for me to understand.

Re:Fortran is still a thing by walshemj on Tuesday November 27, 2018 @06:34PM (#18547903)
Shockingly Bad use of line numbers.

the convention I used was taught was always 4 digits always increasing going down the pages.

7000 and 8000 range where for input and output FORMAT statements, 6000 was used to label code 6999 was always the exit

Re:Fortran is still a thing by wahern on Tuesday November 27, 2018 @06:49PM (#18547996)
If you look at the code, they seem to follow a similar convention. But the computed GOTO described above is using a set of labels employed for what looks like an inner state machine, related to a previous inner state machine (thus the offset by 20). It seems perfectly reasonable (preferable, even) to use an entirely different domain of numeric labels, distinguished by length, for those parts of the code.
Re:Fortran is still a thing by WalterBright on Tuesday November 27, 2018 @09:34PM (#18548817)
> Shockingly Bad

<hangs head in shame>

Re:Fortran is still a thing by jungler on Thursday November 29, 2018 @01:32AM (#18558507)
My only question is: Which century is Empire "the game of"?
Re:Fortran is still a thing by danso on Tuesday November 27, 2018 @12:45PM (#18544582)
What’s the advantage of sticking to the new Fortran? Is it substantially compatible with legacy FORTRAN codebases and systems, despite having significant advances as a language?
Re:Fortran is still a thing by clord on Tuesday November 27, 2018 @02:27PM (#18545794)
Fortran has better aliasing rules than C. Most of the strangeness you have to do with restrict pointers in C are not a concern in high performance code. Because strides and dimensions and types are all laid out explicitly, the optimizer can really go to town. And with co-arrays the same syntax generalizes to multiple compute nodes.

I worked as lead on IBM’s ASTI component (part of xlf) 10 years ago, and kind of miss it sometimes.

Re:Fortran is still a thing by milancurcic on Tuesday November 27, 2018 @01:06PM (#18544850)
Array-based syntax for distributed memory parallel computing (look for coarrays) since Fortran 2008. OOP since Fortran 2003. Whole-array operations since Fortran 90. These are a few of my favorites.

New standards mark obsolescent or deprecate a few ancient features as they come out, however compilers maintain the support for these features. I'd say that the modern Fortran is almost completely backwards compatible with legacy FORTRAN, as far back as FORTRAN IV (predecessor to FORTRAN 77).

Re:Fortran is still a thing by danso on Tuesday November 27, 2018 @01:16PM (#18544967)
> I'd say that the modern Fortran is almost completely backwards compatible with legacy FORTRAN, as far back as FORTRAN IV (predecessor to FORTRAN 77).

That's very impressive! I assumed the compatibility difference was akin to what Perl 6 is to Perl 5- -- that is, not compatible at all.

Re:Fortran is still a thing by gus_massa on Tuesday November 27, 2018 @05:45PM (#18547577)
The rules for the lines formatting are different, but lucky you can write code in the "intersection format" that can be read by both http://fortranwiki.org/fortran/show/Continuation+lines

If useful if your coworkers are stuck to a old semi unknown machine and want to mix the new code with the old code and run it there too.

Re:Fortran is still a thing by wycy on Tuesday November 27, 2018 @12:56PM (#18544733)
The rationale was based primarily on 2 factors:

(1) Compatibility with legacy FORTRAN. Although it's not difficult to work with legacy FORTRAN via C, it's seamless to pass data around between legacy FORTRAN and Modern Fortran.

(2) The mathematical and array syntax. It's tough to beat Fortran's mathematical notation and easy use of multidimensional arrays.

Re:Fortran is still a thing by rootbear on Tuesday November 27, 2018 @01:10PM (#18544892)
This. As someone who once did a lot of computer graphics programming in C (not C++), I would have killed for proper arrays. Modern C, with variable length arrays, helps, but still...
Re:Fortran is still a thing by sevensor on Tuesday November 27, 2018 @07:01PM (#18548059)
A long time ago, at a university far, far away, I worked with SGI's gl library, which had FORTRAN bindings. In retrospect, that seems like a very smart idea. At the time, we stuck with the C bindings.
Re:Fortran is still a thing by maxxxxx on Tuesday November 27, 2018 @12:53PM (#18544699)
This really doesn't look like the FORTRAN77 code I once wrote. Looks like a regular modern language.
Re:Fortran is still a thing by msla on Tuesday November 27, 2018 @01:53PM (#18545403)
“I don’t know what the programming language of the year 2000 will look like, but I know it will be called FORTRAN.” – Charles Anthony Richard Hoare, circa 1982

It seems every language keeps the same name as it evolves, except Algol/C/C#/Java.

Re:Fortran is still a thing by gnufx on Tuesday November 27, 2018 @06:24PM (#18547842)
Hoare also said "ALGOL 60 is alive and well and living in FORTRAN 90". I don't have the source of that, but I think it was the answer to someone asking him about it, reported in some Fortran forum.
Re:Fortran is still a thing by RhysU on Tuesday November 27, 2018 @10:07PM (#18548976)
There's a cute namelist hack that allows parsing arguments as well as serializing them to disk using old, standard language features: https://github.com/RhysU/namelist_cli
Re:Fortran is still a thing by tejassanap on Tuesday November 27, 2018 @12:30PM (#18544424)
Do you know of any learning opportunities such as internships where one can learn and apply Fortran?
Re:Fortran is still a thing by rch on Tuesday November 27, 2018 @02:17PM (#18545673)
Re:Fortran is still a thing by msaharia on Tuesday November 27, 2018 @03:43PM (#18546480)
Huh. Don't think I have seen NCAR here before!
Re:Fortran is still a thing by m_mueller on Tuesday November 27, 2018 @12:46PM (#18544610)
Look up for jobs in weather agencies, climate research, ocean model research and computational physics.
Re:Fortran is still a thing by jacquesm on Tuesday November 27, 2018 @01:35PM (#18545192)
And lots of Finite Element Analysis packages still use Fortran under the hood.
Re:Fortran is still a thing by int_19h on Tuesday November 27, 2018 @11:17PM (#18549251)
I've noticed that Fortran comes up a lot when talking to people who do fluid dynamics simulations.

Curiously, it often does so in context of Python. One specific example I can remember was a library written in Fortran, with unit tests written in Python.

Re:Fortran is still a thing by m_mueller on Wednesday November 28, 2018 @04:13AM (#18550232)
Fortran and Python go together very well (they complement each other in just the right ways and there's all the bindings / data structure compatibility with Numpy that you need). Glue code / UI in Python, Numerics in Numpy + homegrown Fortran, that's how I'd implement a numerical model from scratch today.
Re:Fortran is still a thing by septc on Wednesday November 28, 2018 @09:54PM (#18557654)
Just out of curiosity, what do you use for calling Fortran from Python (e.g. f2py, ctypes)? Do you have any suggestion about how to combine them together (e.g., for parallel calculations)?
Re:Fortran is still a thing by m_mueller on Friday November 30, 2018 @07:43AM (#18568656)
So I haven't yet had the chance to do it myself, but yes I'd look at f2py first and how to integrate it with Numpy.
Re:Fortran is still a thing by pge on Tuesday November 27, 2018 @02:05PM (#18545530)
also a lot of computational fluid dynamics modeling (naval, aeronautical, automotive, etc.)
Re:Fortran is still a thing by tejassanap on Tuesday November 27, 2018 @12:53PM (#18544695)
Thanks.
Re:Fortran is still a thing by rootbear on Tuesday November 27, 2018 @01:29PM (#18545115)
It's still used at NASA. The NASA Center for Climate Simulation at Goddard does much of their climate work in Fortran.
Re:Fortran is still a thing by pmulv on Tuesday November 27, 2018 @02:20PM (#18545723)
I have a friend who writes modern fortran nearly everyday as an actuarial pension analyst in Manhattan. They hired him out of college having never written a "hello world" script. Hope that helps!
Re:Fortran is still a thing by RhysU on Tuesday November 27, 2018 @10:55PM (#18549178)
Dead language tallying the dead?
Re:Fortran is still a thing by kitd on Wednesday November 28, 2018 @04:18AM (#18550249)
I began my career 30 years ago writing actuarial valuations in Fortran77. Glad to see the industry hasn't changed (much).
Re:Fortran is still a thing by nouseforaname on Tuesday November 27, 2018 @12:50PM (#18544662)
Maybe universities. My mechanical engineering program taught fortran and had beowulf clusters running what was (presumably) fortran.
Re:Fortran is still a thing by C1sc0cat on Tuesday November 27, 2018 @12:32PM (#18544448)
At a Guess CERN and places like that
Re:Fortran is still a thing by tejassanap on Tuesday November 27, 2018 @12:42PM (#18544552)
The thing with such hardcore engineering stuff is that there are very few places one can learn them at, but they are also very very cool
Re:Fortran is still a thing by noobermin on Tuesday November 27, 2018 @03:57PM (#18546609)
Dude, someone (not me because I'm super busy) make a Fortran version of docopt[0] and I and everyone else will love you forever.

[0] http://docopt.org/

Re:Fortran is still a thing by wycy on Tuesday November 27, 2018 @04:34PM (#18547038)
Interesting, I've never seen this before. Seems like it would be easy enough for me to add this as an alternate means of initialization.
Re:Fortran is still a thing by tomrod on Tuesday November 27, 2018 @11:39PM (#18549327)
Same. Seems like a straightforward implementation. Only downside is I'm not sure there is a Fortran sys/regex analogue?

Time to dust off the Fortran!

Re:Fortran is still a thing by brootstrap on Tuesday November 27, 2018 @12:06PM (#18544121)
Very cool thanks for sharing the project! I used fortran in college for meteorology, had a very oldschool professor. There was another guy who taught Matlab, i liked fortran more honestly. It was the old style fortran , reading thru your repo i think this version does look much more modern.

After writing code in fortran and running on a shared cluster with a buttload of CPU and RAM, working in a software shop doing python science stuff on a mac makes me miss the speed. I didnt give a about how big my source data was , but now with python, occasionally i miss the ol static typed compiled days. I am giddy when i get to do some numpy matrix array type stuff instead of just glueing things together with python magic!

Re:Fortran is still a thing by mamcx on Tuesday November 27, 2018 @02:40PM (#18545939)
Is modern fortran available for iOS/android?
Re:Fortran is still a thing by ngmc on Tuesday November 27, 2018 @06:33PM (#18547893)
Nice, I had fun with FORTRAN 90 and f2py in a couple of atmospheric modeling classes. Anyone tried flang for iOS?

https://github.com/flang-compiler/flang

Re:Fortran is still a thing by wycy on Tuesday November 27, 2018 @02:56PM (#18546073)
I gather that gfortran can be built on Android, so presumably it's possible. I see conflicting information on whether or not it's actually possible on iOS. I've personally never seen it.
Re:Fortran is still a thing by agumonkey on Tuesday November 27, 2018 @12:49PM (#18544644)
similarly modern COBOL is different
Re:Fortran is still a thing by Koshkin on Tuesday November 27, 2018 @12:57PM (#18544742)
As long as there's backward compatibility, you can call it evolution of the language. (Otherwise I do not know what to call it.)
Re:Fortran is still a thing by C1sc0cat on Tuesday November 27, 2018 @12:31PM (#18544435)
Fixed format was gone in the late 70's (for new developments)
Re:Fortran is still a thing by wycy on Tuesday November 27, 2018 @12:39PM (#18544513)
I believe free format came about in Fortran 90, and that FORTRAN 77 was still fixed format--at least that's what a quick Google suggests. But even still, fixed-format F77 has stuck around in lots of legacy code bases for a long time. We only migrated one of our large codebases to free format a few months ago.
Re:Fortran is still a thing by ewgoforth on Tuesday November 27, 2018 @01:30PM (#18545124)
I learned Fortran IV and later Fortan 77 in the mid eighties and programmed professionally in Fortran 77 up until 2000. I was taught and programmed with fixed format. I believe that there may have been compiler switches to allow non-fixed format. I'm pretty sure that longer lines were allowed via a compiler switch.
Re:Fortran is still a thing by C1sc0cat on Wednesday November 28, 2018 @06:51AM (#18550813)
Ah I was using Salfords f77 which I think allowed freeformat
Re:Fortran is still a thing by Loic on Wednesday November 28, 2018 @03:19AM (#18550004)
I am still writing new code in fixed format. Because of the wonderful compatibility, I can do it while using a lot of new features from the recent standards which are both supported in GNU Fortran and Intel Fortran. You can call me old school, but I like the constraint of the line length in fixed format, it helps me writing clean code and reduce the "double" loops in my algorithms.
Re:Fortran is still a thing by dboreham on Tuesday November 27, 2018 @04:04PM (#18546721)
Fixed columns was Fortran IV
Re:Fortran is still a thing by wycy on Tuesday November 27, 2018 @04:37PM (#18547063)
From what I gather, fixed columns was all FORTRAN versions up to F77, since Wikipedia says free format was introduced in Fortran 90 [0]. But it may have been the case perhaps that some compilers supported proprietary directives to support this in earlier versions--I wouldn't know, though.

[0] https://en.wikipedia.org/wiki/Fortran#Fortran_90

Re:Fortran is still a thing by Koshkin on Tuesday November 27, 2018 @12:51PM (#18544676)
> Fortran is still a thing

> completely different

Sound like a contradiction to me...

Re:Fortran is still a thing by coldtea on Tuesday November 27, 2018 @01:55PM (#18545420)
What's the big contradiction?

A language can still be a thing after decades while looking very different.

Ever heard of the Ship of Theseus?

Re:Fortran is still a thing by techbio on Tuesday November 27, 2018 @02:24PM (#18545768)
I understood the Ship of Theseus to have been rebuilt with new materials, not with a new design. I suppose the interpretation is somewhat flexible but I don’t think it quite applies to this case. If a modern program doesn’t compile on an older version, I would interpret that as being a significant change in the language, the referent of “FORTRAN”. I believe GP simply didn’t develop their argument effectively. 1970’s Camaros aren’t interchangeable with 2010’s. To the public they are both Camaros, but to a mechanic they are very different.
Re:Fortran is still a thing by coldtea on Tuesday November 27, 2018 @04:12PM (#18546805)
>If a modern program doesn’t compile on an older version, I would interpret that as being a significant change in the language, the referent of “FORTRAN”.

A modern C program doesn't compile in old C compilers. That doesn't mean it's not C. You can change tons of ergonomics and keep the language the same. Or you can keep the spirit the same (which in a language are its core semantics and concepts).

>I believe GP simply didn’t develop their argument effectively.

GP just casually said it's a whole new language in the casual, everyday sense, that a e.g. you can say "it's a brand new car now" after you redid the interior and did some repairs on your 10-year old car.

(And I got in with the Ship of Theseus thing to humor the objection -- not that I really consider the GP statement to have to be taken at face value).

Re:Fortran is still a thing by Koshkin on Tuesday November 27, 2018 @04:49PM (#18547155)
Is the Medieval French "the same language" as the modern French? It is French after all, right?
Re:Fortran is still a thing by coldtea on Wednesday November 28, 2018 @04:45AM (#18550356)
Is a 80 year old person the same person and with the same ideas, abilities, look, as when he was a 15 year old person? He has the same name after all.

Same language doesn't mean you can necessarily speak it without learning the new words, forgetting some stuff that went deprecated, learning some syntactic sugar and new features. If you were born in 1400 and lived to today, you'd be going from speaking from Medieval French to modern French with hardly noticing the difference...

Re:Fortran is still a thing by Koshkin on Wednesday November 28, 2018 @06:35AM (#18550756)
Looks like Clinton was right saying that “it depends on what the meaning of ‘is’ is.”
Re:Fortran is still a thing by cbkeller on Wednesday November 28, 2018 @02:24AM (#18549829)
Well, I think that's a reasonable analogy, except that with spoken language evolution, the unintelligibility tends to be mutual, whereas with Fortran there's substantial compatibility in one direction (i.e., GFortran will happily compile anything from f77 to Fortran 2008)
Re:Fortran is still a thing by Koshkin on Tuesday November 27, 2018 @03:07PM (#18546182)
Sure, from the general public standpoint, by the sound of it, Fortran is still a thing...
Re:Fortran is still a thing by vertex-four on Tuesday November 27, 2018 @02:42PM (#18545961)
That would suggest that, for example, C11 should not be referred to as the C programming language, since it introduces some new features? Similarly, if I said “I have a Camaro” to you, would you expect that I have a 1970s car or something more recent?
Re:Fortran is still a thing by Koshkin on Tuesday November 27, 2018 @02:57PM (#18546089)
C11 still looks like (and still is) C, despite the new features. In contrast, to say that the new Fortran is the same 'thing' as the old Fortran is disingenuous. For example, the old Fortran did not support recursion (which fact I consider a feature rather than a "bug").
Re:Fortran is still a thing by slededit on Tuesday November 27, 2018 @11:37PM (#18549318)
ANSI C looks pretty different to K&R C, especially in the function declaration syntax. The only difference is Fortran had its facelift just a little later.
Re:Fortran is still a thing by coldtea on Tuesday November 27, 2018 @04:14PM (#18546831)
>For example, the old Fortran did not support recursion (which fact I consider a feature rather than a "bug").

So? C# 1.0 didn't support 90% of the cool features of C# whatever it is now, not even LINQ, the bread and butter of C# programmers.

Java up to 1.4 didn't have generics, closures, streams, modules, and tons of other stuff besides. Soon it will be getting many more.

Is it a different language for that?

Re:Fortran is still a thing by Koshkin on Tuesday November 27, 2018 @04:33PM (#18547034)
On the other hand, C was given a different name when classes were added to it.

Thing is, adding and/or removing features may have an impact on the implementation, can potentially introduce subtle changes to the semantics of the existing constructs and therefore their behavior at run time, have general performance implications (e.g. due to a change in what optimizations are possible), etc. Is it "the same language"? Not quite. It is a "super-language," at best. If it's 100% backwards compatible, that is (which is not guaranteed).