8 ms·
The new features of Fortran 2018 [pdf]
- deleted 8y ago[deleted]
- bberrry 8y agoWhat's the degree of backward compatibility with FORTRAN releases? I imagine most FORTRAN codebases as being huge and old, so it makes me wonder how many can adopt the latest versions.
- philshem 8y agoYou can start with an awesome-fortran list: https://github.com/rabbiabram/awesome-fortran https://github.com/rabbiabram/awesome-fortran
- jhrmnn 8y agoEach new standard usually removes a very small number of features, but Fortran 2018 is mostly a superset of Fortran 77. Most compilers retain absolute backward compatibility, so they can compile a superset of Fortran 66 to 2018, and often some custom language extensions on top.
- walshemj 8y agoOnly some of the real ancient pre FORTRAN IV stuff has been removed.
- apaprocki 8y agoThis will be of help as well: https://github.com/CodethinkLabs/fortrantools/blob/master/README.md https://github.com/CodethinkLabs/fortrantools/blob/master/RE... Most of the patches are upstreamed, but their gcc repo contains the patched versions on top of the latest gcc releases.
- wycy 8y agoIn my experience nearly all standard old code will still compile just fine, except code which relied on compiler-specific extensions and directives. Unfortunately, there does tend to be a lot of code out there using these proprietary directives. Things like metacommands [0] will need to be converted to something standard (or removed) to work with modern compilers. [0] http://www.ousob.com/ng/fortran/ng4e22.php http://www.ousob.com/ng/fortran/ng4e22.php
- pletnes 8y agoI’ve compiled fortran code from approx 1965. Works the same today. I don’t know of anything that is as compatible as standard Fortran code. That being said, quite a few vendor extensions are floating around, and often old codebases rely on a few of these.
- jsty 8y agoFortran users of HN - what are the best resources (online / books / ...) to pick up Fortran in 2019? Are there any open source codebases you'd consider as good to read through?
- dionysus8 8y agoModern Fortran by Milan Curcic seems to be a pretty good book. https://www.manning.com/books/modern-fortran https://www.manning.com/books/modern-fortran Most other ‘modern fortran’ books assume you have knowledge of older fortran versions.
- acqq 8y agoThanks! "Publication in Fall 2019 (estimated)" at the moment: "8 of 13 chapters available" Table of Contents and samples on the author's site: https://milancurcic.com/book/ https://milancurcic.com/book/ Here's author's recent series of articles "Analyzing stock price time series with modern Fortran": https://milancurcic.com/2018/11/06/analyzing-stock-price-time-series-with-modern-fortran-part1.html https://milancurcic.com/2018/11/06/analyzing-stock-price-tim...
- robochat 8y agoThis could help someone get started https://learnxinyminutes.com/docs/fortran95/ https://learnxinyminutes.com/docs/fortran95/
- wycy 8y agoI have the book Modern Fortran Explained by Metcalf. It does a great job of providing modern examples of traditional code as well as examples of the new features.
- TheRealKing 8y agoI second that. The book by Metcalf is the holy bible of Fortran.
- GnarfGnarf 8y agoAhhh... FORTRAN -- my first language: CDC 3100, 1965. What magic.
- fsagx 8y agoFORTRAN77 on a VAXCluster in 1986. Still have my copy of "FORTRAN 77 For Engineers and Scientists" just in case. It was very easy to pick up for someone who had only used AppleII or TRS-80 BASIC.
- acidburnNSA 8y agoI'm still using a program and occasionally updating it that's mostly in FORTRAN 77. Originally written in FORTRAN IV. Ah, gotta love the nuclear industry. Good code though.
- waynecochran 8y agoI used to have Fortran77 notepad for hand writing code — later I would type it in. Always began in the 8th column if I remember right?
- username223 8y agoYep -- old-school fixed-format Fortran had one column for the "c"(omment) marker, seven for the statement number (maybe 5 plus spaces on either side?), then 72 for the code before you fell off the end of the punch card.
- drfuchs 8y agoNo, you get all 7 spaces for the statement number; live it up a little! Don't know if it's still the case, but in FORTRAN IV you don't need spaces between keywords and variable names. So when the compiler sees "FORI=2" it has to look still further ahead to decide if this is a for-loop (FORI=2TO9DO) or an assignment to a variable named FORI. Decidedly not a context-free grammar; you can't even figure out the tokens without the ad-hoc parser getting involved.
- deleted 8y ago[deleted]
- jpincheira 8y agoI just love it that Fortran is #1 on the front page.
- fanf2 8y agoThe most notable thing I spotted is they have deleted the arithmetic IF from the language, which must be one of the more characteristic features of classic FORTRAN.
- whitten 8y agoI agree. The non intuitive reason stated is that there is a standard that specifies a sign for zero, and numeric IF doesn't distinguish between them, and it depends upon labels which are hard to optimize. Another notable capability is that procedures default to recursive and there is a way to state they are non_recursive.
- walshemj 8y agoFor non Fortran programmers this is what they looked like. IF ( N ) 6020, 6030, 6999 Basically GOTO 3 different labels, depending whether if N is -ve 0 or +ve I have used my first jobs standard for statement labeling - which was fairly common, 6000's for goto's 7000 and 8000 for FORMAT statements
- thanatropism 8y agoModern FORTRAN looks more like Matlab than FORTRAN 77. The syntax has been completely overhauled since at least ‘95. For a while I was translating my Matlab codes to FORTRAN; it was surprisingly easy. But I was being too naive with array resizings in Matlab and most of the speed gain (which was like 2-3 orders of magnitude) could be achieved in Matlab itself by preallocating memory. To this day I have the nervous tick of initializing arrays with zeros even in numpy.
- rufius 8y ago> To this day I have the nervous tick of initializing arrays with zeros even in numpy. I dunno - I wouldn’t call that a nervous tick. If you know or have a good idea of how much memory you need, then it only seems polite to let the runtime/OS know ahead of time. I think of it like RSVP’ing to a dinner party. Host is very appreciative when they know how many people they’re serving.
- bobbylarrybobby 8y agoIt is a tic — if you plan to fill the array anyway there’s no need to set its values on initialization
- sgillen 8y agoNo but in dynamic languages just making the array before hand can greatly increase efficiency.
- whatshisface 8y ago>To this day I have the nervous tick of initializing arrays with zeros even in numpy. The typical way to create arrays in Numpy is with `np.zeros(size)`. What is it that you're doing?
- eru 8y agoOr you can create them as outputs from your computations.
- damian2000 8y agoFortran 77 was the language I used in my first job in 92 on DOS and Unix. Can't see the benefits over other languages like C, Go, Python though. Unless you've got some specific high performance floating point ops requirements?
- username223 8y agoQuite a few scientists and engineers have those requirements. I wouldn't choose it for writing a web server or text processing, but Fortran is actually a pretty nice language for dealing with numbers and arrays. It also has decades' worth of well-tested numerical libraries, which can be very subtle and hard to get right.
- eru 8y agoThanks to the magic of computer science, we can package up a lot of those libraries for use with other languages as well.
- username223 8y agoSort of, but we haven't figured out how to make language boundaries disappear. For example, row- vs. column-major ordering of arrays is an eternal pain when communicating between C and Fortran. Numpy, R, Matlab, etc. are good scripting languages for a lot of Fortran, but if you ever need to peek under the hood...
- pjmlp 8y agoNot in C++, thanks to the power of user defined types.
- acqq 8y agoFrom: https://scicomp.stackexchange.com/questions/304/c-vs-fortran-for-hpc https://scicomp.stackexchange.com/questions/304/c-vs-fortran... "Sorry for digging up an old thread but it seems that even in 2015, Fortran is being used a lot. I just came across this (alternate link) list which basically is a list of 13 codes approved by DOE's OCLF facility to run on the 300-petaFLOPS Summit machine which will be made available to researchers in 2018. I tried to find the main language used for the code (based on a quick google search) and here is what I found: XGC Fortran SPECFEM Fortran ACME Fortran (Bunch of climate codes) DIRAC Fortran (Mostly) FLASH Fortran GTC Fortran HACC C/C++ LS-DALTON Fortran (some C) NAMD C/C++ NUCCOR Fortran NWCHEM Fortran QMCPACK C++ RAPTOR Fortran" Note: QMCPACK is written in C++ but depends on LAPACK which is again Fortran.
- cfcf14 8y agoI've been really interested in learning Fortran for a while- I work doing a lot of computational stats/ML and typically my tools are python, R, or Golang. Is there any use-case for Fortran in production settings or should I just accept it would be purely a personal satisfaction project?
- 4thaccount 8y agoIt's very fast and there is a new Manning book about to come out on Modern Fortran that is all about parallel Fortran. In addition to being fast, I find it considerably easier to read than C++ as it isn't as low level and doesn't have as much noise (at least the later versions like Fortran 90). It also makes writing numerical code easy as it was truly built for high performance scientific computing. A lot of older scientific projects run on Fortran and although I know some projects that were migrated to C++, it wasn't due to any defect from the language besides it not being taught very often in colleges now outside of some astrophysics classes where it was once a mainstay in engineering and science curriculums. There are several compilers available, but a lot of them are commercial and some are expensive. There are free versions as well of course.
- eru 8y agoThough the main reason (for a while) that Fortran compilers could produce faster code was that they were allowed to assume that variables (including arguments to your functions) don't alias each other. See http://beza1e1.tuxen.de/articles/faster_than_C.html http://beza1e1.tuxen.de/articles/faster_than_C.html
- Ragib_Zaman 8y agoI don't understand the "Though" part of this. The only reason any compiled language may be faster than another is because a compiler knows/assumes more about the code (either through users specification, or restrictions of the language).
- eru 8y ago
- tkdc926 8y agoWATFOR anyone? My first programming language in college. Spring 1969. https://dl.acm.org/citation.cfm?id=363059 https://dl.acm.org/citation.cfm?id=363059
- cicero 8y agoI used WATFIV in 1982.