8 ms·
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
by wycy 8y ago
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 https://gitlab.com/bwearley/f-clap
- brootstrap 8y agoVery 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!
- tejassanap 8y agoDo you know of any learning opportunities such as internships where one can learn and apply Fortran?
- C1sc0cat 8y agoAt a Guess CERN and places like that
- tejassanap 8y agoThe 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
- m_mueller 8y agoLook up for jobs in weather agencies, climate research, ocean model research and computational physics.
- tejassanap 8y agoThanks.
- jacquesm 8y agoAnd lots of Finite Element Analysis packages still use Fortran under the hood.
- pge 8y agoalso a lot of computational fluid dynamics modeling (naval, aeronautical, automotive, etc.)
- int_19h 8y agoI'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.
- m_mueller 8y agoFortran 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.
- septc 8y agoJust 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)?
- nouseforaname 8y agoMaybe universities. My mechanical engineering program taught fortran and had beowulf clusters running what was (presumably) fortran.
- rootbear 8y agoIt's still used at NASA. The NASA Center for Climate Simulation at Goddard does much of their climate work in Fortran.
- rch 8y agoCome to Boulder: https://www.ucar.edu/opportunities/careers https://www.ucar.edu/opportunities/careers https://www.txcorp.com/careers-at-tech-x https://www.txcorp.com/careers-at-tech-x http://radiasoft.net/about/careers/ http://radiasoft.net/about/careers/
- msaharia 8y agoHuh. Don't think I have seen NCAR here before!
- pmulv 8y agoI 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!
- C1sc0cat 8y agoFixed format was gone in the late 70's (for new developments)
- wycy 8y agoI 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.
- ewgoforth 8y agoI 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.
- C1sc0cat 8y agoAh I was using Salfords f77 which I think allowed freeformat
- Loic 8y agoI 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.
- danso 8y agoWhat’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?
- wycy 8y agoThe 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.
- rootbear 8y agoThis. 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...
- sevensor 8y agoA 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.
- milancurcic 8y agoArray-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).
- danso 8y ago
- agumonkey 8y agosimilarly modern COBOL is different
- Koshkin 8y agoAs long as there's backward compatibility, you can call it evolution of the language. (Otherwise I do not know what to call it.)
- Koshkin 8y ago> Fortran is still a thing > completely different Sound like a contradiction to me...
- coldtea 8y agoWhat's the big contradiction? A language can still be a thing after decades while looking very different. Ever heard of the Ship of Theseus?
- techbio 8y agoI 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.
- vertex-four 8y agoThat 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?
- maxxxxx 8y agoThis really doesn't look like the FORTRAN77 code I once wrote. Looks like a regular modern language.
- msla 8y ago“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.
- gnufx 8y agoHoare 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.
- mamcx 8y agoIs modern fortran available for iOS/android?
- wycy 8y agoI 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.
- ngmc 8y agoNice, 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 https://github.com/flang-compiler/flang
- noobermin 8y agoDude, 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/ http://docopt.org/
- wycy 8y agoInteresting, I've never seen this before. Seems like it would be easy enough for me to add this as an alternate means of initialization.
- tomrod 8y agoSame. 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!
- dboreham 8y agoFixed columns was Fortran IV
- wycy 8y agoFrom 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 https://en.wikipedia.org/wiki/Fortran#Fortran_90
- WalterBright 8y agoFortran-10 is old school, not Fortran-77. https://github.com/DigitalMars/Empire-for-PDP-10 https://github.com/DigitalMars/Empire-for-PDP-10 Fortran-77 is for young whippersnappers.
- wycy 8y agoThat 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
- walshemj 8y agoShockingly 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
- wahern 8y agoIf 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.
- WalterBright 8y ago> Shockingly Bad <hangs head in shame>
- wahern 8y agoIt'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.
- RhysU 8y agoThere'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 https://github.com/RhysU/namelist_cli