Fortran as an auto-detected language

Back to Programming Languages forum

asnowmang     2021-02-05 21:43:07

Hi, is there any chance you could add Fortran detection? I noticed in the request for FreeBasic support that you said you user hackerrank API and it does have Fortran listed as a supported language.

Rodion (admin)     2021-02-11 16:48:24
User avatar

Hi! Interesting question!

I thought Fortran ceased to be used widely nowadays :)

There are three different things:

  • that Fortran is not in the language list to mark solutions - I will add it in a minute
  • that it should be autodetected when you enter or paste-in solution - for this I need to find out some "specific features" of the language and encode them in our language-detector
  • for it to be executed in "sandbox" - this requires support from hackerrank api (need to check)

You see, the last two things may depend on the fortran version heavily. I remember using MS fortran 77 long ago and fortran for VAX VMS probably. I suspect they are quite different from modern versions (I even don't know which, perhaps g77).

So if you can clarify this field to me a bit, perhaps we'll find a way to improve things.

asnowmang     2021-02-12 07:28:13

Yeah it's pretty uncommon; can make it quite fun finding help at times

As far as autodetection goes, there are four main versions: 77, 90/95, 2003/2008, and 2018. 77's easy, it has strict formatting intended for tapes and most lines start on the 7th column. Later versions can also use this formatting but it's uncommon. Easiest to just assume this formatting equals 77.

From what I understand, 95 is just 90 with high performance computing extensions, so you can just lump them together. As far as differentiating between those, 2003/2008, and 2018, that's where I'm unsure. 2003 introduces OOP so there should be some new syntax you could look for in that and 2008. I don't really know anything about 2018 though.

Rodion (admin)     2021-02-12 11:46:43
User avatar

it quite fun finding help at times

He-he, when I tried to learn it - it was a bit pre-internet age here - I downloaded some files of command line compiler and some text like manual or tutorial - from BBS. There was no much hope for any other help but luckily it was enough :)

On the other hand Fortran was somewhat popular even up to 2000 in scientific field as there were tons of libraries for various calculations. This is overtaken by Python / Matlab (Octave) / R in recent decade, though.

As far as autodetection goes, there are four main versions:

We rather want to choose some feature to distinguish "any fortran" from other languages. What version do you use by the way? E.g. if there is a word "program" in a line not ending with semicolon - this should be fortran...

asnowmang     2021-02-12 19:00:52

I downloaded some files of command line compiler and some text like manual or tutorial - from BBS. There was no much hope for any other help but luckily it was enough :)

That reminds me of when I got remote access to a VAX-11/780. No way to upload my Fortran programs so I had to retype them but something wasn't going right. Good luck finding help for that language on that platform in this time haha

This is overtaken by Python / Matlab (Octave) / R in recent decade, though.

Yeah Fortran's not used directly much these days but I have heard that it's not uncommon for the modern stuff to rely on Fortran libraries. In fact MATLAB's very existence is due to a professor wanting to provide an abstraction layer between Fortran libraries and his students

some feature to distinguish "any fortran" from other languages. What version do you use by the way?

I use F90. I think the statement implicit none would be your best catch-all, for the most part. It was introduced with F90, is pretty much ubiquitous in programs that use variables, and seems to be Fortran-specific.

That only leaves F77. It'd probably be easiest to check for the strict punch card-minded formatting (most lines start with 6 spaces) or just only do autodetection for F90 and above

Please login and solve 5 problems to be able to post at forum