#BabelOfCode 2024
Week 4
Language: FORTRAN

Confidence level: High

PREV WEEK: https://mastodon.social/@mcc/113867584791780280
NEXT WEEK: https://mastodon.social/@mcc/113975448813565537
RULES: https://mastodon.social/@mcc/113676228091546556

I was very excited about doing TCL this week, but I told myself the first time I get a two-dimensional array problem I'd go FORTRAN, so I guess this week is FORTRAN.

A friend of mine who did AOC2024 in December noted the early challenges this year were *very* easy. Today's definitely is. I wonder if part 2 will have any depth.

I went into this thinking: C is basically cleaned up FORTRAN, right? I know C? This should be easy, right? Right off the bat I find there will be a lot of difficulties entirely not of the kind I'm used to in programming. After a brief adventure with accidentally naming my file .f and not .f90 causing horrific and baffling errors, I run a hello world off the Internet. There's a space before the printout. Hm, how do I turn that off?

https://stackoverflow.com/a/31236043

Oh my fuck, *what*?

How to get rid of unwanted spacing in Fortran's print output?

It may look like a trivial issue, but I couldn't find any answer through googling. I have this little program : Program Test_spacing_print Integer:: N Real:: A,B N=4; A=1.0; B=100.0 prin...

Stack Overflow

I get frustrated with C all the time for being fundamentally a 70s language. It may be I'm about to learn the pain of using a *50s language*.

(Alternately, I hear modern FORTRAN has all kinds of fancy niceties like operator overloading and might not resemble traditional FORTRAN all that much. But then I have the problem if I pick up a random tutorial it's hard to guess which *decade's* standard it's teaching me from, or if it's the GNU extension, if the GNU extension is that different, etc.)

@mcc Jumping into Fortran is quite an interesting experience. I became one of 6 core developers of a Fortran physics simulation code at CERN back in 2017 until I left in 2020. We converted a lot of the code to Fortran 2003. It's not a bad language once you learn the quirks, and it's relatively easy to interface with C. (I mean, most things are.)

@veronica Where would you recommend starting to ensure I'm learning FORTRAN 2003 or FORTRAN 2023 and not something ancient and unnecessarily inconvenient?

Does anyone use GNU FORTRAN (ie, asking if they use -std=gnu, not asking if they use gfortran) in industry?

@mcc We supported GNU, Intel and the Nagfor compilers. Honestly, my best resource was the Intel Fortran forums, which are not public. I had a university Intel account though.

I also have a draft copy of one of the Fortran standards that I used for reference. It is quite tricky to find good resources online unfortunately.

@mcc
In my org we use fortran pretty heavily, but on a mix of platforms (ie some gfortran, some ifx, etc) 2023 feature use is still kind of rare, so if i were recommending for someone *here*, I'd say focus on 2003 vs 2023, but be aware you will eventually come across 2023 features. If you start from 2023, you might run into situations where features aren't available in the target environment (if it's someone elses)

I believe most of our environments are to 2018.
@veronica
@mcc @veronica One of the best books to get started is "Modern Fortran explained" by Metcalf et al.