风花雪月 发表于 2005-10-22 16:03

Fortran使用中的FAQ汇总

1.1) The language(s) and its(their) development

1.1.0) How should one spell FORTRAN/Fortran?
FORTRAN is generally the preferred spelling for discussions
of versions of the language prior to the current one ("90").
Fortran is the spelling chosen by X3J3 and WG5.
In this document a feeble effort has been made to capitalize
accordingly (e.g. vast existing software ... FORTRAN vs.
generic Fortran to mean all versions of the standard,
and specifically the modern dialect, ISO 1539:1991).

---------------------------------------
~From: walt@fortran.com (Walt Brainerd)
---------------------------------------
There was an effort to "standardize" on spelling of programming
languages just after F77 became a standard. The rule: if you say
the letters, it is all caps (APL); if you pronounce it as a word,
it is not (Cobol, Fortran, Ada). See, for example the definitive
article describing Fortran 77 in the Oct 1978 issue of the Comm.
of the ACM. The timing was such that FORTRAN got put on the
standard itself, though many always after that have referred to
it as Fortran 77. Of course, there are those who think it is
not truly Fortran if not written with all caps.

ISO 1539:1991 and its ANSI counterpart X3.198-1992 consistently
employ the spelling "Fortran" to refer to the language being
defined. Reference(s) to the older version employ "small caps"
for the "ORTRAN" characters.

Return to contents
--------------------------------------------------------------------------------

1.1.1) Where can I learn more about the history of Fortran?
-------------------------------------------------
~From: metcalf@apofort.cern.ch (Michael Metcalf )
-------------------------------------------------
The history of Fortran is documented in:
Annals of History of Computing,
6, 1, January, 1984 (whole issue)
Programming Systems and Languages
(S. Rosen ed.),
McGraw Hill, 1967,
pp 29-47 (this is Backus's original paper)
History of Prorammining Languages
(R.L. Wexelblat ed.),
Academic Press, 1981,
pp 25-74

A summary appears in:
Encyclopedia of Science and Technology,
Academic Press, 1986,
vol. 5, under 'Fortran'
and in:
Fortran 90 Explained
(Oxford, 1990).
Chapter 1 of

Return to contents
--------------------------------------------------------------------------------

1.1.2) How does Fortran 90 relate to FORTRAN '77?
With a few minor exceptions, Fortran 90 is a superset of
X3.9-1978 FORTRAN.
But this does not mean that all "77" codes will port sans changes.
Many (if not most) programmers employed constructs beyond the '77
standard, or rely on unspecified behavior (say, assuming that an
OPEN of an existing file will position the file pointer to just
past the last record already written) which has changed (that is
to say, has become specified).
This leads to the obvious question, what is new in Fortran 90?
A complete answer would require considerable text.
Some of the most obvious additions are:
1) array notation (operators, etc.)
2) dynamic memory allocation
3) derived types and operator overloading
4) keyword argument passing, INTENT (in, out, inout)
5) modules
6) modern control structures
7) free format source code form
other stuff
While it is always tricky to characterize the motives of
a large group of people, I am inclined to try
as follows:

'90 incorporates two sets of improvements:
(1) relatively minor fixups that *could* have been
done earlier
(2) relatively major changes to enable better software
engineering practices.
Sometimes a "minor" fixup has major effect, such as addition
of free form source form combined with canonization of the
MIL-STD 1753 INCLUDE.
I further go off on a limb and assert that it was the goal
of the *committee* to evolve Fortran in a fashion to enable
it to continue to be the premier language for scientific
computation.

Return to contents
--------------------------------------------------------------------------------

1.1.3) Is it a Standard? Where can I get a copy of the Fortran 90
Standard? How about electronic copies?
Fortran 90 was adopted as an International Standard by ISO
in July, 1991. It was published by them as ISO/IEC 1539:1991,
and is obtainable directly for 185 Swiss francs from:
ISO Publications
1 rue de Varembe
Case postale 56
CH-1211 Geneva 20
Switzerland
Fax: + 41 22 734 10 79
or from:
American National Standards Institute
Attn: Customer Service
11 West 42nd Street
New York, NY 10036
Phone: (212)642-4900 8:45-4:45 (EST)
Fax: (212)302-1286
BSI
2 Park Street
London W1A 2BS
DIN
Burggrafenstrasse 6
Postfach 1107
D-1000 Berlin 30
AFNOR
Tour Europe
Cedex 7
92049 Paris La Defence
SCC
1200-45 O'Connor
Ottawa
Ontario K1P 6N7

You can obtain copies for 225through:

GlobalEngineeringDocuments
2805McGawAve.
Irvine,CA.92714
(714)261−1455
(800)854−7179


InaccordancewithanofficialagreementwiththeInternational
StandardsOrganization,Unicompisnowabletodistribute
electronicversionsoftheFortran90standard:

ISO/IEC1539:1991,
Informationtechnology−−Programminglanguages−−Fortran

ThemoneyreceivedfromthiseffortwillgopartlytofundISO
activitiesandpartlytorecoverthecostsincurredbyUnicomp
inpreparingandtypesettingthestandarddocument.
ThepricesaresetbyISO.

Thedocumentcanbeobtainedinthreeversions:

1.AnASCIIversionsuitableforviewingonacomputer
terminalusinganykindofeditor.Cost:USD125.

2.APostScriptversionwithalicenseallowingthe
purchasertoprintnpapercopies.Cost:USD125+10n.

3.Completesourceinditroffwithmacrosandsoftwareto
extractandcreatetheannexes.Thesourceconstitutes
afairlyhighlevelmarked−updocument;forexample,
eachprogrambeginningandendingismarkedandthere
arefewlow−leveltypographiccommandssuchassize
andfontchanges.CostUSD1000.

Iamquiteenthusedespeciallyaboutversion(2).Ifyouwant
tohave10copiesforyourorganization,anditcosts10 to
make a printed copy, then the cost to make the 10 copies would
be 125+200, or just 32.50percopy,whichisasubstantial
savingsoverpurchasingpapercopies.

Versions(1)and(3)willbeaccompaniedbyalicenserestricting
usetooneCPUandprohibitingcopying,exceptforbackuppurposes,
etc.Theversion(2)licensewillprohibitdistributinganyofthe
printedcopiesoutsideofthepurchasingorganization.

Ifyouhavespecialrequirements,suchaswantingtodistribute
acopywitheachversionofyourcompilerorusingthesource
asapartofyourdocumentation,wecanmakespecialarrangements,
subjecttotheapprovaloftheISO.Pleaseadvisemeofyour
requirementsandwecanworkupaproposaltogether.

ISOandUnicompthinkthiswillprovidetheoftrequestedaccess
tothestandardinelectronicform.Thisisthefirsttimethis
isbeingtried,sowehopethatorganizationswillbecarefulto
observetherulesandencouragethecontinuedavailabilityof
thisandotherstandardsinelectronicform.

PaymentcanbemadebyVisaorMasterCard,orwithacheckon
aUSBankinUSfunds.Wewillacceptapurchase
orderonlyiftheamountis500 or more.

Walter S. Brainerd; Unicomp;
phone: 505-275-0800.
email: Walt Brainerd


;;; Additional note.
X3J3 working papers are often available via
ftp from:
host: ftp.ncsa.uiuc.edu
directory: x3j3
rpc wrote:
It has been a few years since I last ordered a MIL-STD, so my
information might be out-of-date. At that time, the address
to write for MIL-STDs was:
Naval Publications and forms Center, Code 3015
5801 Tabor Ave
Philadelphia, PA 19120
Phone: 1-(215)-697-4834
Use form DD1425, if possible (they will send you a copy with
your first order).
MIL-STD 1753 is a short document (about 10 pages).
And finally, note that the FORTRAN 77 standard is online at
the Fortran Market:
http://www.fortran.com/fortran/market.html
http://www.fortran.com/walt/fortran
Return to contents
--------------------------------------------------------------------------------

1.1.4) Who creates these silly standards anyway?
Typically X3J3. X3J3 is an ANSI subcommittee dedicated to Fortran.
WG5 is the ISO counterpart. WG5 owns responsibility for Fortran
on an international basis. WG5 has previously tasked X3J3 to do
the work. This arrangement continues.
WG5 is composed of Fortran users, vendors, and academics
from several ISO supporting nations. Delegates represent
*their*countries* not their companies; so several delegates
from a single company is permitted.
ANSI rules prohibit multiple voting delegates from the same company.
X3J3 is composed of users (aerospace, government labs, military,
DECUS, railroads, oil to name a few), vendors (IBM, CRI, Sun,
Convex, DEC, UNISYS, to name a few) and the odd academic
(oxford, yale, liverpool, to name a couple).
Members need not be US citizens nor must their company be US
domiciled. Being a member of a standards group is typically
involves non-trivial work.
To be effective, one should plan on at least 8 weeks of time
per year (those who are really doing the hard work do far more).
This time commitment is typically far more expensive than the
travel and membership costs.
X3J3 meetings are open to the public. There are typically 4
meetings a year, typically 3 are in the US and 1 *may* be
overseas (to precede or follow the WG5 plenary session).
Membership fees are levied by ANSI, and are on the near order
of 600(300ish cast as an ISO "tax", but mandatory for all).
In addition, attendees to a particular X3J3 meeting pay a
"meeting fee" which covers reproduction costs, snacks and etc.
The meeting fee has been about $100 for the last several meetings.
WG5 has established various goals and targets for future work.
Roughly speaking 5yrs rather than 13years are the targets for
future work.
Current work projects include cleanup and interpretations
of Fortran (90), features for future versions of the standard
(e.g. parallel processing, "object-oriented" technologies, etc.).
In addition to work done directly by X3J3, there is work on
standardized modules, and OS bindings taking place in other
organizations. X3J3 would like to keep track of such efforts,
those involved are invited to inform X3J3 early in their
development efforts if possible. X3J3 is currently working
with X3H5, DIN (varying string character) and tracking the
efforts of HPFF.
New members are always welcome. Visitors are also; though it
is very hard to get a good grip on things in only one meeting!
Contact the X3J3 chair for more information:
email: jwagener@trc.amoco.com (chair)
Upcoming meeting is: 5 Feb - 9 Feb Las Vegas
papers are often available via ftp from:
host: ftp.ncsa.uiuc.edu
directory: x3j3

Return to contents

风花雪月 发表于 2005-10-22 16:07

B) Learning Fortran

1.2.1) What are good books on Fortran?

Don't know if they are good. Inclusion in the list
is not endorsement.

On Fortran 90:

English:

Fortran 90
Counihan,
Pitman, 1991,
ISBN 0-273-03073-6.

Fortran 90 Explained
Metcalf and Reid,
Oxford University Press, 1990,
ISBN 0-19-853772-7,
about 30.

Thisbookisacomplete,auditeddescriptionofthelanguage
inamorereadablestylethanthestandarditself.
Itiskeptup−to−dateoneachprintingwithX3J3andWG5′s
latestinterpretations.
IthassevenAppendices,includinganextendedexampleprogram
thatisavailablebyftp,andacomprehensiveIndex.

Fortran90/95Explained
MichaelMetcalfandJohnReid,
OxfordUniversityPress,OxfordandNewYork,1996,
ISBN0198518889
(aboutUS33 or 16.95 pounds sterling).

Sequel to 90 explained.

Fortran 90 for Scientists and Engineers
Brian D. Hahn, Edward Arnold, 1994,
ISBN 0-340-60034-9.

Fortran 90 Handbook
Adams, Brainerd, Martin, Smith and Wagener,
McGraw-Hill, 1992,
ISBN 0-07-000406-4.

Fortran 90 Language Guide
Gehrke,
Springer, London, 1995,
ISBN 3-540-19926-8

Fortran 95 Language Guide
Gehrke,
Springer, London, 1996,
ISBN 3-540-76062-8

Fortran-90-Nachschlagewerk
Gehrke,
RRZN, 1993

Fortran 90 Programming
Ellis, Philips, Lahey,
Addison Wesley, Wokingham, 1994,
ISBN 0-201-54446-6.

Migrating to Fortran 90
James F. Kerrigan,
O'Reilly Associates,
1993, ISBN 1-56592-049-X.

Programmer's Guide to Fortran 90, second edition
Brainerd, Goldberg and Adams,
Unicomp, 1994.

Programming in Fortran 90
Morgan and Schonfelder,
Alfred Waller, Oxfordshire, 1993,
ISBN 1-872474-06-3.

Programming in Fortran 90
I.M. Smith,
Wiley,
ISBN 0471-94185-9.

Fortran 90,
Loren P. Meissner (U. of San Francisco) (c) 1995,
PWS Publishing Co.,
ISBN 0-534-93372-6

Fortran 90: A Reference Guide
Luc Chamberland,
Prentice-Hall, 1995,
ISBN 0-13-397332-8

Introducing Fortran 90
Ian Chivers and Jane Sleightholme
Springer Verlag,
ISBN 3-540-19940-3

Chinese:

Programming Language FORTRAN 90
He Xingui, Xu zuyuan, Wu gingbao and Chen mingyuan,
China Railway Publishing House, Beijing,
ISBN 7-113-01788-6/TP.187, 1994.

Dutch:

Fortran 90
W.S. Brainerd, Ch.H. Goldberg, and J.C. Adams,
translated by J.M. den Haan,
Academic Service, 1991,
ISBN 90 6233 722 8.

French:

Fortran 90; Approche par la Pratique
Lignelet,
Se'rie Informatique E'ditions, Menton, 1993,
ISBN 2-090615-01-4.

Fortran 90. Les concepts fondamentaux,
the translation of "Fortran 90 Explained" M. Metcalf, J. Reid,
translated by M. Caillet and B. Pichon,
AFNOR, Paris,
ISBN 2-12-486513-7.

Fortran 90; Initiation a` partir du Fortran 77
Aberti,
Se'rie Informatique E'ditions, Menton, 1992,
ISBN 2-090615-00-6.

Les specificites du Fortran 90,
DUBESSET, M. et VIGNES, J.,
editions Technip, 1993.
ISBN 2-7108-0652-5

Manuel complet du langage Fortran 90, et guide d'application,
LIGNELET, P.,
S.I. editions, Jan. 1995.
ISBN 2-909615-02-2

Programmer en Fortran 90,
DELANNOY, C.,
Eyrolles, 1992.
ISBN 2-212-08723-3

Savez-vous parler Fortran,
AIN, M.,
Bibliotheque des universites (de Boeck), 1994.
ISBN 2-8041-1755-3

Support de cours Fortran 90 IDRIS
Corde, P. & Delouis, H.
anonymous ftp from:

host: ftp.ifremer.fr
directory: pub/ifremer/fortran90/
file: f90_cours_4.ps.gz

Traitement de donnees numeriques avec Fortran 90,
Olagnon, M.
Masson, 1996.
ISBN 2-225-85259-6

was just published this week. Though it is in French,
the example programs

http://www.ifremer.fr/ditigo/molagnon/livref90.html

are in Fortran 90. One of them, CVIBM, deals with
conversions between IEEE and former IBM format,
and may be of some use to you.
Anonymous ftp from:

host: ftp.ifremer.fr
directory: pub/ifremer/ditigo/fortran90/livremo/
file: cvibfl.f90


German:


Fortran 90
B.Wojcieszynski and R.Wojcieszynski,
Addison-Wesley, 1993,
ISBN 3-89319-600-5.

Fortran 90: eine informelle Einf"hrung
Heisterkamp,
BI-Wissenschaftsverlag, 1991,
ISBN 3-411153-21-0.

Fortran 90, Lehr- und Arbeitsbuch fuer das erfolgreiche Programmieren
W.S. Brainerd, C.H. Goldberg, and J.C. Adams,
translated by Peter Thomas and Klaus G. Paul,
R. Olbenbourg Verlag, Muenchen, 1994,
ISBN 3-486-22102-7.

Fortran 90 Lehr- und Handbuch
T. Michel,
BI-Wissenschaftsverlag, 1994.

Fortran 90 Referenz-Handbuch: der neue Fortran-Standard
Gehrke,
Carl Hansen Verlag, 1991,
ISBN 3-446163-21-2.

Programmierung in Fortran 90
Schobert,
Oldenburg, 1991.

Software Entwicklung in Fortran 90
U"berhuber and Meditz,
Springer Verlag, 1993,
ISBN 0-387-82450-2.

Japanese:

Fortran 90 Explained
Metcalf and Reid,
translated by H. Nisimura, H. Wada, K. Nishimura, M. Takata,
Kyoritsu Shuppan Co., Ltd., 1993,
ISSN 0385-6984.


On Fortran in general:

Author Title Year
------ ----------------------------- ----
Kruger Efficient Fortran Programming 1990
Mojena/Ageloff FORTRAN 77 1990
Boyle FORTRAN 77 PDQ 1989
Bezner FORTRAN 77 1989
Tremblay PROGRAMMING IN FORTRAN 77 1988
Salmon ENGINEERS & SCIENTISTS WITH FORTRAN 77 1988
Nyhoff/Leestma FORTRAN 77 FOR ENGINEERS & SCIENTISTS 1988
McCracken/Salmon ENGINEERS & SCIENTISTS WITH FORTRAN 77 1988
Davis/Hoffman FORTRAN 77: A STRUCTURED DISCIPLINED STYLE 1988
Barnard/Skillicorn FORTRAN 77 FOR ENGINEERS AND SCIENTISTS 1988
Gregory A. Moses Engineering Applications Software Develop.. 1988
Gehrke PC-FORTRAN-Handbuch 1988
Mashaw PROGRAMMING STRUCTURED FORTRAN 77 1987
Cole FORTRAN 77: A STRUCTURED ... APPROACH 1987
Boillot UNDERSTANDING FORTRAN-77 1987
Gehrke FORTRAN-77-Handbuch 1987
Starkey/Ross FUNDAMENTAL PROGRAMMING WITH FORTRAN 77 1986
Rouse/Bugnitz INTRODUCTION TO FORTRAN 77 1986
Ratzer FORTRAN 77 COURSE 1986
Page FORTRAN 77 FOR HUMANS 1986
Lehman SOCIAL SCIENCES: ALGORITHMS & FORTRAN 77 1986
Smith FORTRAN 77: A PROBLEM-SOLVING APPROACH 1985
Shelly FORTRAN 77: AN INTRODUCTION 1985
Nickerson FUNDAMENTALS OF FORTRAN 77 PROGRAMMING 1985
Metcalf EFFECTIVE FORTRAN 77 1985
Metcalf FORTRAN Optimization 1985
McKeown STRUCTURED PROGRAMMING USING FORTRAN 77 1985
Hume FORTRAN 77 FOR SCIENTISTS & ENGINEERS 1985
Dillman PROBLEM SOLVING WITH FORTRAN 77 1985
Brainerd FORTRAN 77 FUNDAMENTALS AND STYLE 1985
Borse FORTRAN 77&NUMERICAL METHODS FOR ENGINEERS 1985
Adman FORTRAN 77 SOLUTIONS NON-SCIENTIFIC PROBS. 1985
Etter PROBLEM SOLVING WITH STRUCTURED FORTRAN 77 1984
Etter PROBLEM SOLVING USING FORTRAN 77 ?
Dyck FORTRAN 77: A STRUCTURED APPROACH ... 1984
Chivers/Clark FORTRAN 77: A HANDS ON APPROACH 1984
Adman FORTRAN 77 FOR NON-SCIENTISTS 1984
Willamson/Levesque A GUIDEBOOK TO FORTRAN ON SUPERCOMPUTER 1989
Rule FORTRAN 77: A PRACTICAL APPROACH 1983
Rouse/Bugnitz PROGRAMMING THE IBM PC: FORTRAN 77 1983
Nyhoff/Leestma PROBLEM SOLVING WITH FORTRAN 77 1983
Marateck FORTRAN 77 1983
Lehmnkuhl FORTRAN 77 1983
Law ANSI FORTRAN 77: INTRO. TO SOFTWARE DESIGN 1983
Holoien/Behforooz ... STRUCTURED PROGRAMMING WITH FORTRAN 77 1983
Grout FUNDAMENTAL..PROGRAMMING USING FORTRAN 77 1983
Fleming/Redish THE U. S. MC MASTER GLOSSARY OF FORTRAN-77 1983
Cole ANSI FORTRAN IV WITH FORTRAN 77 EXTENSIONS 1983
Wu ANSI FORTRAN IV & 77 AND BUSINESS PROGRAMS 1982
Pollack STRUCTURED FORTRAN 77 PROGRAMMING 1982
Katzan FORTRAN 77 1982
Gibson/Young INTRO TO PROGRAMMING USING FORTRAN 77 1982
Ellis STRUCTURED APPROACH FORTRAN 77 PROGRAMMING 1982
Durgin FORTRAN 77 1982
Nanney A PROBLEM-SOLVING APPROACH USING FORTRAN77 1981
Merchant FORTRAN 77: LANGUAGE AND STYLE 1981
Khailany BUSINESS PROGRAMMING FORTRAN IV/ANSI F.. 1981
Ashcroft PROGRAMMING WITH FORTRAN 77 1981
Gehrke FORTRAN-77-Sprachumfang 1981
Wagener FORTRAN 77 ?
Wagener PRINCIPLES OF FORTRAN 77 PROGRAMMING 1980
Meissner/Organick FORTRAN77 FEATURING STRUCTURED PROGRAMMING 1980
Hume/Holt PROGRAMMING FORTRAN 77 1979
Balfour PROGRAMMING IN STANDARD FORTRAN 77 1979


A free Fortran 77 book
----------------------

This excellent book is offered to the public by the
author:

Clive G. Page,
Professional Programmer's Guide to Fortran 77
Pitman, 1988
122 pages (including index)


It can be found at the anonymous FTP site:

Host: ftp.star.le.ac.uk
Directory: /pub/fortran/
file: prof77.ps.gz

There is also a Latex version available.


-----------------------------------------------
~From: Z.W.T.Mason@sussex.ac.uk (Zebedee Mason)
-----------------------------------------------

Jeffrey Templon (templon@studbolt.mit.edu) wrote:
: Hi,
:
: I just discovered this one and don't remember seeing it pointed
: to here. It's a PS copy of an out-of-print book by Clive Page,
: "Professional Programmer's Guide to Fortran 77" and what I've
: seen of it looks real good.
:
: JT

I bought it when it was in print, never needed to buy another
one since. Why can't all programming books be this short and
to the point?

Zeb.

Another free Fortran 77 book
----------------------------

Interactive Fortran 77: A Hands on Approach (second edition)
Ian D Chivers and Jane Sleightholme
Ellis Horwood, 1990
Series in Computers and their Applications
ISBN: 0-13-466764-6

Copyright (C) Ian D Chivers and Jane Sleightholme.

Legal comments:

Unless otherwise specified, Ian D Chivers and Jane Sleightholme
hold all rights, including copyright and retains such rights.
This work may be distributed in its entirety provided the work
is distributed as a whole with this copyright notice intact.

This work may not be distributed in hard copy or other machine
readable form, redistributed, transmitted or translated without
prior written authorization from Ian D Chivers and Jane Sleightholme.

Commercial use can only be allowed by specific license agreements.
The accuracy of this document cannot be guaranteed. Ian D Chivers
and Jane Sleighthome make no warranty, either express or implied,
with respect to the use of any information and assumes no liabilities
for loss or damage, whether such loss or damage is caused by error
or omission.

If this electronic book is made available anywhere other than the
original system, Ian Chivers or Jane Sleigtholme must be notified
in writing (email is acceptable) and the copyright notice must
retain intact.

PDF version:

http://www.kcl.ac.uk/kis/support/cc/fortran/f77book.pdf

Unix compressed postscript version:

http://www.kcl.ac.uk/kis/support/cc/fortran/f77book.ps.Z

PC pkzip postscript version:

http://www.kcl.ac.uk/kis/support/cc/fortran/f77ps.zip

风花雪月 发表于 2005-10-22 16:08

1.2.2) Where can I find a f90 tutorial or course?
Copyright but freely available course material is available
from Manchester Computer Centre on the World Wide Web with
the URL:

http://www.hpctec.mcc.ac.uk/hpctec/courses/Fortran90/F90course.html

The ftp address is:

host: ftp.mcc.ac.uk
directory: /pub/mantec/Fortran90

A complete Tutorial is available under WWW with
the URL:

ftp://asisftp.cern.ch/cnl/f90tutor.ps

or via anonymous ftp from:

host: cernvm.cern.ch
directory: cnl.200
file: f90tutor.ps

An ASCII copy of this material as a set of slides for a
six-hour course is available from:

metcalf@cern.ch.

Courses are available from:

Walt Brainerd, a member of X3J3,
also on HPF
email: walt@fortran.com

PSR (see above);

CETech, Inc. (also on HPF)
8196 SW Hall Blvd., Ste. 304,
Beaverton, Oregon 97008, USA.
Phone: (503)644-6106
Fax: (503)643-8425
Email: cetech@teleport.com).

Some European companies offering courses and conversion
consultancy are:

IT Independent Training Limited,
113 Liscombe, Birch Hill,
Bracknell, Berkshire, RG12 7DE, UK
tel: +44 344 860172
fax: +44 344 867992


Simulog, attn. Mr. E.Plestan,
1 rue James Joule,
F-78286 Guyancourt Cedex, France
tel: +33 1 30 12 27 00
fax: +33 1 30 12 27 27


CTS,
Prinz-Otto Str. 7c,
D-85521 Ottobrunn , Germany
tel: +49-89-6083758
fax: +49-89-6083758

Return to contents
--------------------------------------------------------------------------------


1.2.3) What constitutes good FORTRAN style?

One rendition of a FORTRAN 77 style guide is available through
anonymous ftp from ics.uci.edu (128.195.1.1). To retrieve
(please note that it's not really "anonymous", that's just
the Name that you'll be using):

% ftp ics.uci.edu
anonymous
cd pub/levine
ascii
get F77_Style_Guide
bye

If you can't access this site directly, please send an e-mail
request t

INTERNET: levine@ics.uci.edu
BITNET: levine@uci
UUCP: ...!uunet!ucivax!levine


Return to contents
--------------------------------------------------------------------------------


1.2.4) What are good Subsets of Fortran?

One is F:

Announcing the first book on the F programming language
-------------------------------------------------------

"The F programming Language", by Michael Metcalf and John Reid,
Oxford University Press, Oxford and New York, 1996,
ISBN 0-19-850026-2, (about $US30 or 16.95 pounds sterling).

The F programming language is a dramatic new development in
scientific programming. Building on the well-established strengths
of the Fortran family of languages, it is carefully crafted to be
both safe and regular, whilst retaining the enormously powerful
numerical capabilities of its parent language, Fortran 90, as well
as its data abstraction capability. Thus, an array syntax becomes
available as part of a medium-size, widely-available language for
the first time. In this respect, the language is clearly superior
to older ones such as Pascal, C, and Basic.

F is ideally suited for teaching as a first programming language,
and provides a smooth path into both Fortran 90 and High Performance
Fortran (it is a subset of both).

In the absence of a formal standard for F, this book is the defining
document for the language, setting out the complete syntax and
semantics of the language in a readable but thorough way.
It is essential reading for all F practitioners.

Compilers for F are available from Imagine1 for Windows 95, Linux
and some Unix platforms, with Windows NT, Macintosh PowerPC and 68K
families coming shortly. The compilers are based on technology from
Absoft, Fujitsu, and NAG. For details see:

http://www.imagine1.com/imagine1 or contact info@imagine1.com.


Table of Contents:
1. Why F? . . . . . . . . . . . . . . . . 1
2. Language elements . . . . . . . . . 7
3. Expressions and assignments . . . . 29
4. Control constructs . . . . . . . . 49
5. Program units and procedures . . . 61
6. Array features . . . . . . . . . . 89
7. Specification statements . . . . . 113
8. Intrinsic procedures . . . . . . . 131
9. Data transfer . . . . . . . . . . . 151
10. Operations on external files . . . 175
Appendix A. Intrinsic procedures . . . 185
Appendix B. The statements of F . . . . 191
Appendix C. Diffences from Fortran 90 . 195
Appendix D. Pointer example . . . . . 201
Appendix E. The terms of F . . . . . . 211
Appendix F. Solutions to exercises . . 221
Index . . . . . . . . . . . . . . . . . 233


Michael Metcalf works at CERN, Geneva. He is the author of a
range of publications, including the books "Effective Fortran 77"
and "Fortran 90/95 Explained" (with John Reid) (Oxford University
Press), and "Fortran Optimization" (Academic Press).
He was Editor of the Fortran 90 standard.

John Reid works for the Rutherford Appleton Laboratory and
is well known as a numerical analyst; he is a co-author of
"Direct Methods for Sparse Matrices" and "Fortran 90/95 Explained"
(Oxford University Press). He served as Secretary of X3J3 and
played a leading role in the development of Fortran 90.


Ordering information:

1) N. America: Order Department, Monday-Friday, 8:15am-5:00pm (EST)

Phone: 1-800-451-7556
Fax: 1-919-677-1303
Post: Order Department
Oxford University Press
2001 Evans Road
Cary, NC 27513
E-mail: orders@oup-usa.org
WWW: http://www.oup-usa.org/

2) UK: send order and payment t

CWO Department, OUP,
FREEPOST NH 4051, Corby, Northants
NN18 9BR - no stamp required

Phone: with a credit card, the 24-hour credit
card hotline is: +44 (0)1536 454534

Postage and packing for UK orders:
- under #20 - add #2.06,
over #20 - add #3.53,
over #50 - add #4.70.

WWW: http://www.oup.co.uk/

3) Eire, Europe, and the rest of the world,
send order and payment t

CWO Dept, OUP,
Saxon Way West, Corby,
Northants NN18 9ES, UK

Fax: credit card sales: +44 1536 746337

Postage and packing for non-UK orders:
add 10% of the total price of the books.

4) Imagine1
11930 Menaul NE, Suite 106
Albuquerque, NM 87112
Toll free phone number: 1 888 323 1758.
See also Imagine1's e-mail address and WWW URL above.

Demos available (and free for linux)

ftp swcp.com
login as anonymous and give e-mail address as password
cd ~ftp/pub/walt/Fbin
get f_linux.tar.Z (or f_solaris1.tar.Z or f_solaris2.tar.Z)

Please send problems or questions to
info@imagine1.com.
--------

Another subset is ELF,

Lahey has a native LF90 compiler for Windows and DOS:

sales@lahey.com
http://www.lahey.com

It is particularly well optimized on the Pentium.

Also on offer is elf90, a subset language that does not have old
features like storage association, is designed for teaching, and is
very cheap. Also "Prof. Loren Meissner"
can provide information, and possibly a textbook on this dialect.
But in a nutshell, elf90 is said to be f90 sans What's not in Elf90

To promote a more efficient and modern programming language the
Fortran statements listed below are not supported by the Elf90
language. If you use a Fortran 90 feature that is not supported, an
on-screen error message is provided.

ALLOCATABLE* ASSIGN BLOCK DATA
COMMON CONTINUE DATA DIMENSION*
DO LABEL DOUBLE PRECISION END
END BLOCK DATA ENTRY EQUIVALENCE
EXTERNAL GO TO (COMPUTED) GO TO (ASSIGNED)
IMPLICIT INCLUDE INTENT*
INTRINSIC OPTIONAL PARAMETER*
POINTER* SAVE* TARGET*

*Note: The ALLOCATABLE, TARGET, POINTER, INTENT, PARAMETER,
DIMENSION, and SAVE attributes are declared in type declaration
statements.

http://www.ifremer.fr/ditigo/molagnon/molagnon.html

The current updated version of this FAQ is available
from:

ftp://ftp.ifremer.fr/ifremer/ditigo/fortran90/engfaq

It can be found on WWW at URLs:

http://www.mols.susx.ac.uk/eggen/Fortran90/f90-faq.html
(thanks to Bernd Eggen),

http://www.kcl.ac.uk/kis/support/cc/fortran/engfaq.html
(thanks to Ian Chivers),

http://lenti.med.umn.edu/~mwd/f90-faq.html
(thanks to Mark Dalton),

http://www.uni-karlsruhe.de/~Fortran90/olagnon-faq.html
(thanks to Michael Hennecke),

http://www.ifremer.fr/ditigo/molagnon/fortran90/engfaq.html

Contents :
----------

1. Fortran 90 and Fortran 77
2. Available in Fortran 90:

2.1. Compilers
2.2. Code re-structurers and converters
2.3. Libraries and utilities
2.4. Tests and Benchmarks
2.5. Examples and repositories
2.6. Courses and Consultancy

3. Documentation:

3.1. Standards
3.2. Glossary
3.3. Journals
3.4. Tutorials and other documents
3.5. Books
3.6. Articles
3.7. WWW-Mosaic pages

4. Fortran 90 Benchmarking
5. Announced, foreseen, and rumours
6. Workshops, seminars, conferences
7. Developments, related languages

7.1. Standard
7.2. HPF
7.3. PVM
7.4. MPI
7.5. Parallel Programming

8. Addresses


1.0 Fortran 90 and Fortran 77:
------------------------------

Fortran 90 is, with very few exceptions, a superset of Fortran 77.
The FAQ of the Usenet group Comp.lang.fortran deals with both
standards, and may be obtained, like any FAQ, via anonymous ftp
from:

ftp://rtfm.mit.edu/pub/usenet/comp.lang.fortran/Fortran_FAQ

host: rtfm.mit.edu
directory: pub/usenet/comp.lang.fortran
file: Fortran_FAQ

It is also available on the WWW:

http://www.cis.ohio-state.edu/hypertext/faq/usenet/
fortran-faq/faq.html

The present document is an attempt to supplement that FAQ with
some specific Fortran 90 information.

Anyone interested is also invited to join the mailbase list
comp-fortran-90, by sending an e-mail message t

mailbase@mailbase.ac.uk

containing the only line:

join comp-fortran-90 firstname lastname

more info on URL:

http://www.mailbase.ac.uk/lists-a-e/comp-fortran-90/

The main extensions of Fortran 90 over Fortran 77 are:
------------------------------------------------------

o array notation (for instance, X(1:N)=R(1:N)*COS(A(1:N)))
o dynamic memory allocation (ALLOCATE, DEALLOCATE, ...)
o derived types and operator overloading
o better declarations, and prototyping possible
o MODULES, allowing users to create ``storage pools'',
or to define environment
o more of modern control structures (SELECT CASE, EXIT, ...)
o more of useful intrinsics (date, precision, arrays, ...)
o free format source code form


``Pure'' Fortran 77 is F90 compatible. Yet, it is better to convert
it to a ``mixed'' format, acceptable both as free and fixed source
form Fortran 90, which only requires replacing C by ! as the comment
character, to use & as the continuation line character, and to
append it to the continued line, to remove blanks embedded inside
constants or identifiers, and to check some intrinsics usage. Most
of this can be done automatically.

Fortran 90 allows the Fortran 77 programmer to write code faster,
to make it more legible, and to avoid many bugs. For a newcomer to
programming, it is an opportunity to learn a modern language, with
most recommended features, and yet to be in line with scientific
and industrial engineering communities where Fortran is and is
goi

风花雪月 发表于 2005-10-22 16:09

很多人问哪里可以找到Fortran编译器,有不少热心学友提供网址,特汇集在这里。虽然俺检验过这些链接,但是它们不一定总有效。
Fortran 编译器下载:
CVF 6.6
http://wwater.a365.net/SoftDown.asp?ID=11937

FTN95 (License: Free for personal use)
http://www.download.com/Silverfr ... 0.html?tag=lst-0-10


以下操作,如无特别说明,都是以CVF6.6为例。

1. 如何加大Stack size?
选Project => Settings => Link => Category: Output =>
Stack allocations
Reserve: 这里填新值(默认为1M,若需要10M,则填10000000)

2. 如何用Fortran批量生成文件?
设要生成4000个文件,文件名为AA1-AA4000,如何写循环生成文件,而不用写4000次write命令呢?

用内部文件:
character(len=80) :: filename,form
integer :: i

do i=1,4000
   select case (i)
   case (1:9)
      write(form,'(i1)') i
   case (10:99)
      write(form,'(i2)') i
   case (100:999)
      write(form,'(i3)') i
   case (1000:9999)
      write(form,'(i4)') i
   end select
   write(filename,*) "AA",trim(form),".TXT"
   open(10,file=filename)
   write(10,*) i
   close(10)
end do   

stop
end

3. 如何用Fortran动态生成输出格式?
设有一个数组data(100),输出时,希望每行输出num个数,而num由用户输入,如何实现?

用内部文件:
character(len=80) :: form
real :: data(100)
integer :: i,num

data = (/ (i,i=1,100) /)/10.0
read(*,*) num
write(form,*) "(",num,"f10.3)"
write(*,form) data

stop
end

4. MS POWERSTATION4.0是不是很垃圾?
POWERSTATION4.0是垃圾,其中Bug太多,多到不可用的地步!
在这个主题里,换了CVF后问题就没了的人已有相当的数目。
如果你用POWERSTATION4.0,遇到莫名其妙的错误,建议换CVF6.6,这是一个比较成熟的编译器。

5. 如何用F90/95生成随机数?
注意:
现在计算机产生的随机数都是伪随机数。
random_number(x) 产生一个0到1之间的随机数(x可以是向量),但是每次总是那几个数。
用了random_seed ()后,系统根据日期和时间随机地提供种子,使得随机数更随机了。

program random
   implicit none
   real :: x
   call random_seed ()   ! 系统根据日期和时间随机地提供种子
   call random_number (x)! 每次的随机数就都不一样了
   write(*,*) x
   stop
end program random

6. 函数/子程序超载的例子
设要编一个两个变量值互换的子程序swap(a,b),哑元a,b可能是实型数,整型数,数组,矩阵,字符串,派生类型等等。但是希望只用一个子程序接口swap(a,b)来实现。F90可以用类属接口来实现这种子程序超载:

module Utilities
   implicit none
   private I_Swap,R_Swap,RVec_Swap,RMat_Swap,Type_Swap
   public:: Swap

   interface Swap
      module procedure I_Swap,R_Swap,RVec_Swap,RMat_Swap,Type_Swap
   end interface

   contains

   subroutine i_swap (a,b)! 整型置换
      integer (ikind),intent(in out)::a,b
      integer (ikind)               ::t
      。。。                ! 略
   end subroutine i_swap

   subroutine r_swap (a,b)! 实型置换
      real (rkind), intent(in out)    :: a,b
      real (rkind)                  :: t
      t = a
      a = b
      b = t
      return
   end subroutine r_swap

   subroutine RVec_swap (a,b)! 实型向量置换
      real (rkind), intent(in out)    :: a(:),b(:)
      integer (ikind)               :: i
      do i=1, size(a)
         call R_Swap (a(i),b(i))
      end do
      return
   end subroutine RVec_swap

   subroutine RMat_swap (a,b)   ! 实型矩阵置换
      。。。                ! 略
   end subroutine RMat_swap

   subroutine Type_swap (a,b)   ! 派生类型置换
      。。。                ! 略
   end subroutine Type_swap

end module Utilities


7. 如何在CVF中为多行代码加注释?
见:http://www.programfan.com/club/showbbs.asp?id=124318


8. 推荐好的代码风格
根据F90子集语言ELF90和F的要求整理(部分)。
“强迫用”的语言特性:
+ F90的自由格式的源代码。
+ implicit none。
+ 子过程的哑元都要有intent属性。
+ 函数子程序的哑元必须指定为intent(in)。
+ 所有子程序和函数都放在模块(module)中,然后引用(use)该模块;或者放在program中。
+ 数组哑元要求是假定形状的,或者有固定的维数和大小。字符哑元要求是假定长度的。
+ 对于recursive function(递归函数)语句,必须有result子句。
+ 在所有派生类型(type)的定义语句中,必须用双冒号分隔符(::)。
+ 主程序要求有program语句。
+ 在程序单元的end语句中要求后跟程序单元的类型和名称。
+ 在end type语句中要求后跟类型的名称。
+ end program前必须有stop语句以表示停止执行。
+ 子过程中必须有return语句,以表示返回。
+ subroutine s( )并且call s( ),即必须有括号。

“不得用”的语言特性:
- allocatable、intent、pointer、save、dimension、parameter和target语句形式。(用属性形式代替。)
- external语句形式。(用显式的接口代替。)
- assign、赋值go to、交错return、continue、entry、和计算go to 语句。
- include文件。(用模块代替。)
- data和block data。(在类型声明语句中进行初始化或赋值。)
- common块。(将全局数据放在模块中,用模块代替。)
- equivalence。(被认为是许多难以查找的编程错误的来源。)
- double precision语句。(用real语句声明双精度的实型数。)
- 语句函数。(用内部函数代替。)
- 专用固有函数。(用类属函数代替。)
- 假定大小数组。(用假定形状数组代替。)
- do n (其中n为语句标号)。(用do和end do代替。)
- 非整数do变量和表达式。
- 同一行上多条语句。
- 逻辑型case表达式。
- 从if块外面分支到end if。
- where语句形式。(用where结构形式。)
- 在open和inquire语句中的blank= 说明符。
- 双字关键词之间要求有空格:in out,go to。不能写为inout,goto。

9. 将字符串改为大写的子程序

   subroutine UpCase (str)
   !=========================================
   !change to upper case
   !=========================================
      character(len=*),intent(in out) :: str
      integer(4)                  :: icha,LL,icval
      integer(4),parameter      :: diff = ichar('a') - ichar('A')
      LL = len_trim(str)
      do icha=1,LL
         icval = ichar(str(icha:icha))
         if (icval>=ichar('a') .and. icval<=ichar('z'))then
            str(icha:icha) = char(icval-diff)
         end if
      end do
      return
   end subroutine UpCase

10. CVF中源代码信息浏览
默认情况下,代码信息浏览是失效的(Go to Definition/Reference都不起作用),你可以将其启用:

1. Project/Settings/Fortran, 选中Generate Source Browse Information。
2. 选BrowseInfo卡页,选中Build Browse info file,点击OK。
3. Build程序。代码浏览器仅当成功Build程序后才可应用。
4. Tools/Source Browser。
5. 在Browse对话框底部,找到Case sensitive复选框。Fortran是大小写不敏感的语言,去除Case sensitive的选中。点击OK。
6. 现在可以用Browse对话框来浏览函数调用关系以及变量声明和引用关系。
7. 光标置于一个变量名或函数名中,鼠标右键:Go to Definition使光标跳到该变量声明或函数定义语句;Go to Reference使光标跳到该变量的引用或函数引用语句。

注:(Addison提供)
IVF中现在不适用,因为此技术是属于MS的,不是INTEL的,所以,intel正在与MS就有关问题进行磋商,目前的进展比较顺利,可能要在9.1以后的版本中支持,目前还没有时间表。

[ 本帖最后由 风花雪月 于 2006-9-6 07:30 编辑 ]

tnt2002 发表于 2006-2-17 09:53

老大,我英文不好。对不起

drroot 发表于 2006-3-31 17:56

书目列得很多, 我想大多人都不一定有时间全看
最好是推荐一两本Fortran90/95的好书吧...

drroot 发表于 2006-3-31 17:57

如果再加上一两本关于HPF(High Performance Fortran)设计的书, 那就更好了

dutll 发表于 2006-4-21 20:20

谢谢搂主,挺好的资料!

dundun628 发表于 2006-4-25 16:23

学习中

jiangqun18 发表于 2006-4-28 14:59

我发现这个网站实在是太好!!
我不知道笮样感谢楼主!
页: [1]
查看完整版本: Fortran使用中的FAQ汇总