"Tips for golfing in Fortran" on stackexchange

On https://codegolf.stackexchange.com/, the interested can submit their solution to a computational problem designed maximize the action/the results with minimal source code. Sometimes, the posts there are condensed on expense of readability…

Displayed a hot network question (by the metrics of stackexchange), yesterday, a thread about Tips for golfing in Fortran started. Given there is some popularity in one-liners for Perl, AWK, Python etc. (sometimes even published, e.g. Python), maybe regulars of our site would like to add and share a particularly compact motif of (contemporary) Fortran there.

3 Likes

People seem to be busy with FORTRAN77 loop structure. Using modern DO CONCURRENT we can do it in a single line for both serial and parallel (after using locality specification):

Fortran2008

do concurrent (i=1:Nx,j=1:Ny)
  ...
end do
3 Likes