 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Sat Dec 06, 2014 12:31 am Post subject: Re: |
|
|
LitusSaxonicum wrote: | Would that be
Code: | DOUBLE PRECISION HP
HP(L1,L2) = DSQRT(L1*L1+L2*L2) |
or
Code: | DOUBLE PRECISION HP(L1,L2) = DSQRT(L1*L1+L2*L2) |
(with or without : ? |
The former will do. The latter will fail. Clive Page has a nice section on statement functions at http://www.star.le.ac.uk/~cgp/prof77.html#tth_sEc9.2 . |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Sat Dec 06, 2014 1:56 pm Post subject: |
|
|
Thanks for that. Not that it applies to me of course, because in my religion, non-implicit types are the work of the devil. I may, of course, be the only surviving member of the Original and True Church of the sainted John Backus!
Other devilry forbidden to congregants of this Church (if I am not the only one) includes using variables from the host and using internal functions of multiline length (continuation lines don't count in this). And as for passing function names as parameters, all I can say is Get thee behind me Fortran2008, thou art an offence to mine eye etc etc.
Seriously, if you can't understand a one-liner statement function, how the heck are you ever going to get your head round the new stuff? Metcalfe said somewhere that Fortran 8X (90 to you and me) was to simplify the syntax. Ha Ha - comedian.
It seems to me that a large proportion of the changes post Fortran 77 (but not all) appear to me to be simply alternative ways of doing something that you could already do - and could do perfectly with Algol 60 a half century ago (but only on a handful of computers). A pig with lipstick is still a pig. A standardised graphics system and an improvement on i/o would have been far more useful ... something like Clearwin+.
A little tip that helps one understand that something is a function is to put that hint into the function name, as in HP_FN or if one wants to make statement functions clearer, HP_SFN (or whatever grabs you). And there are also comments, whether or not you prefer them to begin with C or !
Eddie |
|
Back to top |
|
 |
skeptic
Joined: 22 Mar 2009 Posts: 14
|
Posted: Mon Dec 08, 2014 10:22 am Post subject: |
|
|
I have been using a small group of single line statement functions (both with and without IMPLICIT NONE) for 45 years with no problems at all. |
|
Back to top |
|
 |
IanLambley
Joined: 17 Dec 2006 Posts: 506 Location: Sunderland
|
Posted: Tue Dec 09, 2014 2:54 pm Post subject: |
|
|
Eddie,
You are not alone. The use of "Implicit None" is offensive why not use it, because then, everyone knows what a variable or function starting with I,J,K,L,M,N is integer, etc. and the statement "Implicit Real*8 (A-H,O-Z)" is also very good. "Implict"s sof character, logical and complex etc are all easily understood. Perhaps St. Bede was a member of the St. Backus Church School teaching staff, he was mates with Jock Kirk and Jake Harrison!. (I'm sure you will get the meaning of that comment.)
But..... I thought that it has allways been possible to pass function names as parameters in subroutine calls as long as you declared it external in the appropriate places. "A long long time ago I can still remember" doing this in FTN77/386. Or perhaps I can't!
I feel old!
Ian |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Wed Dec 10, 2014 7:27 pm Post subject: |
|
|
Ian,
I'm having problems understanding your post, all except the last bit (I think).
In the beginning, the only names that had global scope were explicit FUNCTIONs and SUBROUTINEs, plus standard subprograms of either type (I include compiler extensions in that). All other names were local to the subprogram in which they were defined, although if given the same names in several routines it looked like they were more extensively available.
As far as I know, a statement function couldn't be used as a parameter with an EXTERNAL definition, but maybe I'm wrong. You could always use a formal FUNCTION in this way. Does it work if the subprogram which receives the name is expecting something of a different type?
Anyway, the traditional scoping rules are simple: they get more ever more complex in Fortran 90 et seq.
In Algol, the scoping rules were different, but simpler, so if we had:
begin;
entier a;
a:=3;
begin;
entier b
b:=a*a;
end;
end;
(entier is the same as INTEGER), then anything defined in an outer "begin ... end block" (such as a) is available in an inner block. Indenting was de rigeur to understand anything, and with the passage of time I've forgotten the correct usage for ; and for the equivalents to functions, sorry.
AS long as the rules are understood, it doesn't matter what they are, but it is obvious to me at least that if you have made the rules more complex you haven't made them simpler to understand!
Eddie |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|