Any Fortran coder ?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Any Fortran coder ?

Post by Dann Corbit »

brianr wrote: Fri Nov 16, 2018 12:31 am
hgm wrote: Thu Nov 15, 2018 9:31 pm I think I never got beyond Fortran 60 (or something like that), before I switched to other programming languages. Fortran 77 already appeared 'after my time'... Problem used to be that you couldn't do recursion; I don't know if later Fortrans fixed that.
Tinker's great grandfather started in Fortran. I did recursion just fine with an explicit stack. It was pretty straightforward, as I recall.
Recursion has been available since Fortran90:

http://fortranwiki.org/fortran/show/recursion
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Any Fortran coder ?

Post by jdart »

I did Fortran coding on cards, circa 1972. Code it up on the official IBM coding sheet, take it to the keypunch room, punch up the cards (don't make a single mistake!) and hand it over to the operator. Come back in a few hours and see if it compiled/ran or not.

--Jon
smcracraft
Posts: 737
Joined: Wed Mar 08, 2006 8:08 pm
Location: Orange County California
Full name: Stuart Cracraft

Re: Any Fortran coder ?

Post by smcracraft »

If you work in the profession as a developer or devops or other person who codes partially or wholly for a living, I suggest you pick another language.

C and C++ are the standard languages I am aware of that most of the modern chess programs I have seen have been written in.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: Any Fortran coder ?

Post by Daniel Shawul »

smcracraft wrote: Fri Nov 16, 2018 3:33 am If you work in the profession as a developer or devops or other person who codes partially or wholly for a living, I suggest you pick another language.

C and C++ are the standard languages I am aware of that most of the modern chess programs I have seen have been written in.
I code with fortran for a living and never intend going back to C atleast for work!

FORTRAN has a better support for OpenACC and OpenMP -- and is often the first language to recieve new features
of compilers such as PGI and Intel. For example, "deep copy" of structures in OpenACC that have malloc'ed arrays
was a real pain to do in C and C++, while FORTRAN had it for a long time because arrays have their dimenstions built in them.

It can be otpimized way better than C due to absence of aliasing (c has __restrict now), pointers, known dimension of arrays etc...

When you make a living out of working on legacy fortran code, it no more feels like such an outdated language -- infact feels like the opposite.

Daniel
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Any Fortran coder ?

Post by Dann Corbit »

Lots of current stuff happens in Fortran.

Things like seismic calculations, FEM and Dynamics packages, statistical calculations, etc.

I do suspect that there is more work in C++, but I guess it also depends on exactly what kind of coding you would like to do.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
smcracraft
Posts: 737
Joined: Wed Mar 08, 2006 8:08 pm
Location: Orange County California
Full name: Stuart Cracraft

Re: Any Fortran coder ?

Post by smcracraft »

Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Any Fortran coder ?

Post by Dann Corbit »

Welcome to Java, the best programming language in the world.

On the other hand, I do have to admit that I frequently write code in the top 9, and it amounts to almost all of my coding.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Any Fortran coder ?

Post by Evert »

I worked with Fortran for about ten years, up to a few years ago. Mainly for floating point calculations though, I never really used its bitwise operators, but I seem to recall they’re overly verbose.

Fortran’s main strengths, as I see it, are its array block operations and auto-parallelisable loops. I don’t think either of those is a big help for a chess engine though.

The main weakness is probably going to be its I/O model, which is different from the C character based I/O model and more of a hassle to get to work with CECP and UCI interfaces.
ker2x
Posts: 17
Joined: Sun Nov 11, 2018 1:28 pm
Full name: Laurent Laborde

Re: Any Fortran coder ?

Post by ker2x »

smcracraft wrote: Fri Nov 16, 2018 3:33 am If you work in the profession as a developer or devops or other person who codes partially or wholly for a living, I suggest you pick another language.

C and C++ are the standard languages I am aware of that most of the modern chess programs I have seen have been written in.

Nah, i'm not a professional coder, i'm a sysadmin/dba. i know many language, C, C++, C#, asm x86_64 (a bit of 68k too), java, ruby, python, javascript, bash, awk, lisp/ocaml/clojure/F#, purebasic, gfa basic, processing, perl, go, fortran, a bit of cobol, opencl, cuda, ada, ... but i'm not mastering any. (and that's why i'm not a professional coder)

You'd be surprised by fortran, it's absurdly good. and while the langage itself may smell a bit of paraffin wax, the compilers are very modern. And while it may be difficult to find a fortran coder job, when you find one it's usually kind of amazing. i'd much prefer to work on a top 500 supercomputer cluster than a web agency selling drupal CMS to local bakery :mrgreen:

you probably only know of fixed form fortran 77 which is kind of weird to write because it was written for efficiently using punch card, not a modern terminal. but modern fortran is pretty much like any other language. it may be a bit verbose for some stuff (and compact for some others) but if you're in the java world you're not allowed to complain about another language verbosity :roll:
ker2x
Posts: 17
Joined: Sun Nov 11, 2018 1:28 pm
Full name: Laurent Laborde

Re: Any Fortran coder ?

Post by ker2x »

Evert wrote: Fri Nov 16, 2018 7:26 am I worked with Fortran for about ten years, up to a few years ago. Mainly for floating point calculations though, I never really used its bitwise operators, but I seem to recall they’re overly verbose.

Fortran’s main strengths, as I see it, are its array block operations and auto-parallelisable loops. I don’t think either of those is a big help for a chess engine though.

The main weakness is probably going to be its I/O model, which is different from the C character based I/O model and more of a hassle to get to work with CECP and UCI interfaces.
i have no problem writing code to handle the UCI interface for now, in fact the only thing i wrote in my engine for now is the UCI parser.
Which lead me to my current problem.

the read operation is blocking, so i need a thread just for this (i'll use the main thread for all the I/O).
But i can't find a way to the multithreading/multiprocessing working on both windows and linux/bsd/mac.

I only know of 2 options : cygwin, and "linux subsystem for windows" (you can run linux on windows without using a VM, it's kind of weird, i never tried it but i know that if you want to run the stockfish testing framework on windows you have to install it).

i'm also considering openMPI but it's a pain to make it works on both platform and certainly not user friendly. And i don't think it would be allowed to enter chess competition (but it could run on a 200.000 cpu cluster however, hehehe, not that i have access to any massive cluster anyway).