User talk:Dinosaur: Difference between revisions

(→‎Cheap Fortran: But also, a cost in time and patience before payoff pleasure.)
Line 35:
:I gather the GNU Fortran compiler is a part of the project to write a compiler for every possible language, via translation to a form of C then compiling that, rather than devising a native compiler for each case. This is interesting in its own right, but I have a nit to pick as I use the arithmetic-IF in the Binary Search algorithm and in a few other cases where a three-way-IF test is needed, and C doesn't allow for that construction. So, I'm mumbling already.
:I peeked at the F2003 status schedule, and see a lot of terse stuff that would require further study to appreciate, thus a bare "Length of names and statements" lacks obvious interpretation. But I notice mention of "recursive I/O" as one limitation I have often been troubled by. On the other hand, I don't recognise mention of some of the subtle issues that can arise, one of which was ... an allocatable array (declared locally) is passed to a subroutine, which determines the size needed and allocates it; on return the array continues to exist in the caller's context but is now alloacted storage. The Compaq compiler handled this (it was to allocate a correctly-sized array to represent a large sparse array, the analysis for this being done in the called subroutine) but the Intel compiler (I think) did not. Perhaps this would come under the phrase "Transferring an allocation"? Perhaps something else. A great deal of time can vanish in this sort of thing. [[User:Dinosaur|Dinosaur]] ([[User talk:Dinosaur|talk]]) 08:07, 25 November 2016 (UTC)
::No, GNU Fortran is a native compiler (it has nothing to do with, for instance, [http://www.netlib.org/f2c/ f2c]). As a side note, even f2c should be able to do an arithmetic if (it's easy to emulate in C with 'if' and 'goto'). However, GNU Fortran won't accept the X.Y notation, unless maybe with an option. But it is accepted by Intel Fortran and Absoft Pro Fortran.<br/>
::Length of name: they are now limited to 63 characters by the standard. I suspect many implementation already allow more. Length of statement: limited to 255 continuations lines.
::<br/>
::Regarding allocation transfer, yes, that's a possible use of the MOVE_ALLOC intrinsic. Notice that now the standard allows to pass an allocatable array as parameter. It may be allocated or unallocated upon entry of the subprogram. Even a function result may be allocatable. There is also a very useful feature: an assignment to an array will automatically allocate it to the correct size. I suggest you have a look at the standard or a good recent book on Fortran (some authors that come to mind: Metcalf, Chivers, Brainerd). The standards F2003 and F2008 may be found for $60 on the ANSI web site, or very close drafts are available at J3: in several subfolders of [http://j3-fortran.org/doc/year/ this one] (each represent a publication year), the "007" documents refer to the standard. For instance, the latest draft of the upcoming Fortran 2015 is [http://j3-fortran.org/doc/year/16/16-007r2.pdf 16/16-007r2.pdf]. The standard is the most complete reference, but it's sometimes not very easy to follow.
::<br/>
::More generally, I would suggest that whenever possible, you use standard Fortran unless of compiler extensions, especially when there is a simple equivalent standard feature. Of course, this could mean updating your program, but it would add much to portability. However, not all compilers follow fully the 2008 or even the 2003 standard, but they tend to be updated, more or less slowly. Intel is close to finish the Fortran 2003 conformance, but for instance the Absoft compiler is still quite far from it, and this may lead to some bugs. For instance, real(Z'...') has a meaning in Fortran 2003, and another meaning as an extension in Absoft (it was not allowed by the Fortran 95 standard). Allocation on assignment is not supported either, yet.
::<br/>
::To learn more on new features in F2003, have also a look at [http://www.fortran.bcs.org/2007/jubilee/newfeatures.pdf this] and [http://soliton.ae.gatech.edu/classes/ae6382/documents/fortran/New_Features_FORTRAN_2003.pdf this].
::<br/>
::[[User:Arbautjc|Arbautjc]] ([[User talk:Arbautjc|talk]]) 21:22, 25 November 2016 (UTC)
Anonymous user