Show HN: A Fortran web framework
github.com
github.com
Especially because of the effort it would take to get this working on a "dead" language. Like who are you? How did you decide to work on this for the pure joy of it? Why not Cobol? Why a web framework?
That's basically it. Scientific programmers are from a different era and a different culture.
When discussing pull requests and changes, having less ego involved makes a big difference.
In the world of traditional engineering, you will still encounter senior PE's that pump out Fortran. Luckily, it usually isn't fixed form.
Also revisiting older projects can also mean visiting Fortran, and sometimes that can be fixed form (looking at you, wind hazard modelling of tornadic winds for nuclear powerplants).
> Various NumPy modules use FORTRAN 77 libraries
$ pip show tensorflow theano
Name: tensorflow
Version: 0.7.1
...
Requires: six, protobuf, wheel, numpy
---
Name: Theano
Version: 0.8.2
...
Requires: six, scipy, numpy
You are right that arithmetic in both of them is not written on Fortran, but the packages do use NumPy as you can see in the pip output.One day I wondered if there was a Fortran server, did some Googling, and found a tutorial from 8-10 years ago (http://flibs.sourceforge.net/fortran-fastcgi-nginx.html). I started out updating the tutorial, requesting some missing files and missing instructions from the authors (almost every Fortran info on the web assumes that you already know how to compile and run your program). Once I was halfway down the rabbit hole, updating this tutorial, it felt right to keep it going
Yours is a nice improvement. If you want to add to the prank, then maybe do a modern-style app or clone of popular one that would definitely delight people. Relatively small app to not take too much time. Offer them a link to the source in case they want to check it out. Let them find out it's Fortran on thdir own. Observe the reactions while recording the best ones. ;)
$ telnet em.prirun.com 8001
Trying 74.131.82.133...
Connected to em.prirun.com.
Escape character is '^]'.
Welcome to the Prime Computer 50-series emulator, running Primos rev 19.2!
Login as user guest, password pr1me
After logging in, use the Prime HELP command for assistance.
You are welcome to create a directory under GUEST for your files.
The line erase character is ?
There are other Primos revs running on ports 8001-8007
Prime manuals at: http://yagi.h-net.msu.edu/prime_manuals/prirun_scans
To report bugs or contact the author, send email to prirun@gmail.com
Enjoy your time travels! -Jim Wilcoxson aka JIMMY
Login please.
login guest
Password?
GUEST (user 2) logged in Wednesday, 22 Jun 16 16:39:52.
Welcome to PRIMOS version 19.2.
Last login Sunday, 12 Jun 16 16:37:20.
OK,[1] https://www.scipy.org/scipylib/faq.html#how-can-scipy-be-fas...
Numpy will compile f2py (to allow running fortran code in python) and I think it uses the Fortran lapack bindings in some cases if a Fortran compiler is present. However, both of those are optional. Numpy deliberately avoids requiring Fortran in any way.
Scipy, however, uses quite a bit of Fortran in addition to C and requires a Fortran compiler to build.
At any rate, as you noted, it's hardly dead. Modern Fortran is a domain-specific language, for the most part, but it's quite popular within that domain (scientific computing and HPC).
So yeah Fortran is not dead by any means. Tons of people are using it every day, but perhaps not writing code in it. Just like your OS and browser are written in C/C++ but your applications might not be.
DO I=1,10000
...
IF (QQQ .LT. RIX70) THEN
CALL IXNARF( I, J, R1, R7, XL23 )
GOTO 23
...
END IF
111 CONTINUE
...
END
IXNARF could change 'I' (because Fortran 77 passed arguments by reference not value) and sometime after line (er... "card") 23 it might jump back into the loop at 111.oh and there was like three comments in the whole several thousand lines, including my favorite at the top of one of the main loops:
C CHUGGA CHUGGA CHUGGAThen there was the proposal for a Fortran COME FROM statement.
I laughed way harder at this that it warranted.
It is impossible inside the loop, even in F77.
But if a global variable is used as a loop counter, and the variable is altered in a subroutine, then the code altering the variable is not inside the loop. At least not in the eyes of the Fortran compiler.
$ cat test.f08
program test
integer i
do i = 1,3
call sub
print *,i
end do
contains
subroutine sub
i = 3
end subroutine sub
end program test
$ gfortran --std=f2008 test.f08
$ ./a.out
3There are popular compilers, like gfortran and the Intel compiler.
My point had nothing to do with popularity. My point is that non-standard-conforming programs can have anything happen when they execute, including starting World War III (see https://www.google.com/search?q=fortran+"start+world+war"), and showing output from one compiler doesn't prove anything.
Not so long ago, supercomputers typically had Portland Group, Cray and Pathscale compilers installed. Nowadays it's pretty much Intel and gfortran.
The FOR loop become a hint that tells the compiler it can take extraordinary measures on the nested instructions.
You could do the same thing in C if you use compiler directives, or in other languages like Pascal, but there's a critical mass of Fortran code, so that's where vendors put the effort.
If memory serves, they had a trick to create simulated pointers, by declaring a one element array somewhere in memory, and then indexing way outside of its bounds in order to point into other areas of memory.
I don't remember the details, but I seem to remember there was a statement ("EQUIVALENCE"?) that facilitated this magic.
1. https://en.wikipedia.org/wiki/Nastran#Software_architecture 2. http://www.zonatech.com/ZAERO.htm
In practice, what you do is look at the assembly of your inner loops, scratch your head, and try putting "restrict" in various places that seem like they'd make sense, and then look at the assembly of your inner loop. Which requires building a mental model of what the assembly of your inner loops ought to look like, and then actually looking at it, and then running it to see if your idea of what the assembly out to look like was actually a good one.
If your expertise is in numerical methods first and assembly-level optimization second (or, like, nth), Fortran can save you a lot of ballache.
And, inertia isn't the only reason for Fortran remaining popular. Put simply: if you tell a mech.eng./physicist/whatever to write code in Fortran, whatever is produced will likely be fast and relatively readable. Do the same with C/C++, and it will be significantly slower and a horrible mess. Templates-all-the-way-down type of stuff.
Sure, a software engineer could write a C/C++ version that was elegant and as fast/faster than the Fortran code. But scientists don't have the money to hire software engineers. You're lucky if these projects are even under version control.
My freshman year I asked my professor why we had to do this one program in Fortran, and after that response, I will never refer to Fortran as "dead" without quotes.
I wrote the 'fortran+fastcgi+nginx' thingy. It has evolved into https://github.com/rlcarino/heeds. Production live runs (and a little blog post about it) may be found at http://heeds.csu.edu.ph. Some students from a university connect to the runs with their Android phones without cell data cost via Facebook's Free Basics which is available in that part of the world. Usage instructions for students are in the FAQ of https://www.facebook.com/groups/csuheeds/.
Why do it? Somebody pays for it.
Ric Carino
HEAD DIVISION
META-TAGS SECTION.
BODY DIVISION.It is proprietary, but very fast and the backend code is much simplified over COBOL.
Writing to a log file looks like:
fd ?logthis-txt reclen 80
def logthis-usr gp 80
logthis-date an 10
logthis-time an 8
open extend logthis using '/var/log/logfile.txt'
on error next sentence
else display date lj upon logthis-date
call GETIME using logthis-time
move usrid to logthis-usr
write logthis
close logthis.
You can see that a lot of the (unnecessary) typing done in COBOL has been removed.
It has its limitations as most web-frameworks do, but if you have mainframe COBOL and want to present it in the browser with fancy colors and graphics it has more pros than cons.I wrote the 'fortran+fastcgi+nginx' thingy. It has evolved into https://github.com/rlcarino/heeds. Production live runs (and a little blog post about it) may be found at http://heeds.csu.edu.ph. Some students from a university connect to the runs with their Android phones without cell data cost via Facebook's Free Basics which is available in that part of the world. Usage instructions for students are in the FAQ of https://www.facebook.com/groups/csuheeds/.
Why do it? It is a consulting gig.
Ric Carino
http://www.ibiblio.org/pub/languages/fortran/ch1-2.html
Some comparisons are dated. However, I think the older variants still have advantages in readability, more clear semantics, semantics closer to algorithm itself (esp mathematical functions), less guessing by compiler for optimizations, and maybe a few others. Those I listed seem to still be advantages over C in general or as it's commonly used.
Fortran is a really good language for number crunching. Academics who don't know how to code can build very fast number crunching tools without really any CS or hardware knowledge. This the target use case and target audience.
If you want to do low level system things with it, it'll be painful.
[1] Some fortran70 compilers had limited support for recursion it wasn't added to the official language standard until 20 years later tho.
This is the feature, not a bug. The purpose of fortran and why it is a fast efficient tool for scientists to write software is is exactly that it hides implementation details and is a bad systems language.
It allows you to define the important math parts of your program and hides the implementation part exactly so the compiler has a lot more power to optimize.