mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Lounge (https://www.mersenneforum.org/forumdisplay.php?f=7)
-   -   Does anyone here know Fortran? (https://www.mersenneforum.org/showthread.php?t=10117)

ShiningArcanine 2008-03-21 03:33

Does anyone here know Fortran?
 
I am interested in learning Fortran, specifically Fortran 90, so that I will be able to try to make the molecular dynamics simulations my lab uses.

If anyone here knows Fortran, how did you learn it? Are there any good books or online resources on Fortran that you can recommend? If not, then are there any books on Fortran that you read and do not recommend?

xilman 2008-03-21 09:38

[QUOTE=ShiningArcanine;129327]I am interested in learning Fortran, specifically Fortran 90, so that I will be able to try to make the molecular dynamics simulations my lab uses.

If anyone here knows Fortran, how did you learn it? Are there any good books or online resources on Fortran that you can recommend? If not, then are there any books on Fortran that you read and do not recommend?[/QUOTE]I learned FORTRAN IV over 30 years ago, initially in a course given by Oxford's Computing Teaching Centre. The only books I have a Munro's [i]FORTRAN 77[/i] and a couple of ICL 2900-series manuals. Munro is quite good, IMO, but (a) I've no idea whether it's still available and (b) is very dated.

I've several bits of advice you could try.

First, ask people associated with your lab what they recommend. Surely someone there speaks FORTRAN.

Second, if you're in range of a good bookshop go and browse their stock and ask their staff.

Third (and this is really a special case of the previous), browse Amazon and read the reviews.

FORTRAN is rather fun, in a peculiar kind of way. It's like reading Chaucer --- recognizable and almost always understandable but [i]different[/i].

I'm certain there are other FORTRAN speakers here. Wacky certainly, Bob probably.


Paul

bsquared 2008-03-21 11:40

I speak fortran 77. Or at least I used to. I used it ~10 years ago for a research project in college modeling quantum many bodied systems. I believe I learned it by reading/implementing certain routines in the book "numerical recipes in fortran 77". That, and other older editions, are available for free online here: [URL]http://www.nr.com/oldverswitcher.html[/URL]. If you have lots of other programming experience, I think the fortran syntax will be easy to pick up. If not, you may not want to start with this book.

- ben.

R.D. Silverman 2008-03-21 13:02

[QUOTE=xilman;129353]

I'm certain there are other FORTRAN speakers here. Wacky certainly, Bob probably.


Paul[/QUOTE]


Well, yes, of course. Along with Snobol, PL1, BLISS, Franz, Vax assembler, etc. etc. (all of which I have not used in MANY years)

There is an old joke from back in the 70's/early 80's.
Q:
What will be the most widely used computer language in 2050???
A:
I don't know, but it will be called Fortran.

xilman 2008-03-21 15:38

[QUOTE=R.D. Silverman;129356]Well, yes, of course. Along with Snobol, PL1, BLISS, Franz, Vax assembler, etc. etc. (all of which I have not used in MANY years)[/QUOTE]I have to admit ignorance of Snobol, PL/1 and BLISS but can admit to having used the others. I helped port Franz Lisp to a new machine.

Of all the languages I've learned over the years, my favourite is still Algol68, with BCPL a close second. They are particularly well-loved for precisely the opposite reasons: BCPL is small and clean yet has a full set of control structures; Algol68 is rich, expressive and powerfully extensible.

Of the languages I use these days, the most liked has to be Perl, for exactly the same reasons I like Algol68. In both languages it is possible to write correct and efficient programs in a clear and concise style. In both languages, it is easy to write buggy, inefficient code which requires expert cryptanalytical skills on behalf of the reader.

For the old-timers: GOD is REAL, except when declared INTEGER.

(Actually, GOD could also be declared LOGICAL but that was never part of the saying, in my experience.)


Also for old-timers: FORTRAN IV was intrinsically uncompilable because the language definition was unambiguously ambiguous. How should this fragment be compiled?

[code]
[spoiler]
DIMENSION FORMAT(10)
INTEGER X9H
X9H=2
[/spoiler]
10 FORMAT(X9H)=SIN(1.0)
WRITE(5,10)
[/code]

Hope I got that right. It's been many years since I last wrote FORTRAN IV


Paul

ET_ 2008-03-21 17:31

As I recall, Fortran90 has many of the building "blocks" of the next-generation languages, and won't be called "spaghetti" anymore.

No GOTOs, labeled subroutines, begin-end blocks: a fun if you practice any other Pascal-like programming language.

I used it a bit with 80860 math coprocessor, and it was way faster than C.

Luigi

cheesehead 2008-03-22 01:24

FORTRAN was the first language in which I wrote a program, for an IBM 1620. (There was no Roman numeral, because FORTRAN II was not yet in use where I was, though undoubtedly it was at least in development at IBM.)

How did I learn it? By reading the IBM manual, of course -- loaned to me by my mentor Graham Kendall after he showed me some of the basics.

[quote=xilman;129367]For the old-timers: GOD is REAL, except when declared INTEGER.[/quote]:-)

[quote](Actually, GOD could also be declared LOGICAL but that was never part of the saying, in my experience.)[/quote]... because the LOGICAL type did not exist in early FORTRAN, whereas the saying did.

[quote]Also for old-timers: FORTRAN IV was intrinsically uncompilable because the language definition was unambiguously ambiguous. How should this fragment be compiled?

[code]
[spoiler]
DIMENSION FORMAT(10)
INTEGER X9H
X9H=2
[/spoiler]
10 FORMAT(X9H)=SIN(1.0)
WRITE(5,10)
[/code][/quote]
In some versions of FORTRAN, including the first, [spoiler]there were a number of [I]reserved words[/I] that could be used only for designated syntax purposes. "FORMAT" would have been one of those, and "DIMENSION FORMAT(10)" would have been flagged as an invalid use of a reserved word.

Later versions relaxed some rules; perhaps "DIMENSION FORMAT(10)" could have been valid in them, but I have no direct knowledge that it was. I can imagine possibilities such as processing statement 10 as a FORMAT statement in one pass, while processing it as an assignment statement in another, but I guess that would've been too liberal for IBM.[/spoiler]

wblipp 2008-03-22 03:04

[QUOTE=ShiningArcanine;129327]If anyone here knows Fortran, how did you learn it?[/QUOTE]

Forty years ago IBM published a manual. I think was for the "F" compiler, although it might have been "G". If I recall correctly, it was sixteen pages. Everything was in there. It was incredibly dense, though. Two years later was still discovering important points hidden in subordinate clauses. The first program I wrote listed prime numbers.

William

xilman 2008-03-22 10:01

[QUOTE=cheesehead;129398][spoiler]there were a number of [I]reserved words[/I] that could be used only for designated syntax purposes. "FORMAT" would have been one of those, and "DIMENSION FORMAT(10)" would have been flagged as an invalid use of a reserved word.

Later versions relaxed some rules; perhaps "DIMENSION FORMAT(10)" could have been valid in them, but I have no direct knowledge that it was. I can imagine possibilities such as processing statement 10 as a FORMAT statement in one pass, while processing it as an assignment statement in another, but I guess that would've been too liberal for IBM.[/spoiler][/QUOTE]Every implementation of FORTRAN IV I ever came across resolved the ambiguity such that the hidden portion of my program fragment would cause a syntax error. Nonetheless, the language definition didn't resolve the ambiguity and it was left up to the implementors to do so.

I seem to remember another ambiguity in the language, something to do computed GOTO, ASSIGN or three-way IF perhaps, but the details (if the ambiguity even exists) have now gone.

Another horror I remember: changing the value of constants by passing them as arguments to SUBROUTINEs.

...
CALL FOO(42)
WRITE(5,10) 42
10 FORMAT(XI2)
...
SUBROUTINE FOO(IANSR)
IANSR = 6*9
END

Again, legal FORTRAN according to the language spec and the output could be either '42' or '54' depending on whether the implementors thought anyone would call a SUBROUTINE in this manner.

Paul

Wacky 2008-03-22 13:39

[QUOTE=cheesehead;129398]FORTRAN was the first language in which I wrote a program, for an IBM 1620. (There was no Roman numeral, because FORTRAN II was not yet in use where I was, though undoubtedly it was at least in development at IBM.)
[/QUOTE]

Newfangled machine - with transistors

160000000000

Although not my first machine, I was fortunate enough to have had access to a large one. We had 60K (characters) of core memory.

I remember when we got an upgraded compiler that had a really cool new feature. "Fortran with FORMAT".

ShiningArcanine 2008-03-22 21:58

[QUOTE=xilman;129353]I learned FORTRAN IV over 30 years ago, initially in a course given by Oxford's Computing Teaching Centre. The only books I have a Munro's [i]FORTRAN 77[/i] and a couple of ICL 2900-series manuals. Munro is quite good, IMO, but (a) I've no idea whether it's still available and (b) is very dated.

I've several bits of advice you could try.

First, ask people associated with your lab what they recommend. Surely someone there speaks FORTRAN.

Second, if you're in range of a good bookshop go and browse their stock and ask their staff.

Third (and this is really a special case of the previous), browse Amazon and read the reviews.

FORTRAN is rather fun, in a peculiar kind of way. It's like reading Chaucer --- recognizable and almost always understandable but [i]different[/i].

I'm certain there are other FORTRAN speakers here. Wacky certainly, Bob probably.


Paul[/QUOTE]
Thanks for the advice.

I am an undergraduate student in the lab and I am fairly certain that the only person who knows Fortran in the lab is my advisor, although I am not sure if advisor is the correct term when you are an undergraduate student.

I did some digging and I found a book that was used by a MIT Professor to teach a course on Fortran about a decade ago:

[url]http://www.amazon.com/FORTRAN-Scientists-Engineers-Brian-Hahn/dp/0340600349[/url]

My university's library has two copies of it on the shelves, so on Monday, I will go and pick one up.

Hey, does anyone know if it is possible to do bit shifts and bit pattern copies in Fortran? With regard to bit pattern copies, here are some functions in C that accomplish what I want to do:

[CODE]float inttofloat ( int x ) { return *(float*)&x; }
int floattoint ( float x ) { return *(int*)&x; }[/CODE]

Alternatively, the question of whether or not Fortran supports bit pattern copies could be phrased as a question of whether or not Fortran supports unions:

[CODE]float inttofloat ( int x )
{

typedef union
{

int i;
float f;

} bitC;

bitC.i = x;

return bitC.f;

}[/CODE]

[CODE]int floattoint ( float x )
{

typedef union
{

int i;
float f;

} bitC;

bitC.f = x;

return bitC.i;

}[/CODE]

I am interested in implementing Quake's InvSqrt() function (i.e. a talyor series approximation of x^(-1/2) followed by a Netwon's method approximation) in Fortran and doing so requires the ability to do bit pattern copies and right bit shifts, although only a bit pattern copy is necessary, as the bitshift can be implemented in code with division, which a good optimizing compiler should convert to a bitshift when generating assembly.


All times are UTC. The time now is 14:48.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.