1-2 COMPARISON OF FORTRAN AND C
********************************
(Thanks to Craig Burley for the excellent comments)
The world of computing sometimes adopts silly fashions, too often
good companies and products fell from grace, and lesser ones gained
the upper hand. Some new examples for the uselessness of quality
are the MS empire and Compaq buying Digital Equipment Corporation.
It seems that the fashion winds (in the US, in the UK it seems to
be different) blows now in the numerical computing world towards
C and C++. This strange trend is probably driven by people who
are not experienced numerical programmers.
Dr. John Prentice
Fortran 90 as a language of choice for science students
At Lahey
At UCD
Jerrold Wagener
Fortran 90 and Computational Science
Was available at the CSEP website
Fortran still dominates in the numerical computing world, but it seems
to lose ground. The following points may help you make up your mind.
(Partly adapted from the Fortran FAQ)
a) FORTRAN tends to meet some of the needs of scientists better.
Most notably, it has built in support for:
o Variable-dimension array arguments in subroutines.
A feature required for writing general purpose routines without
explicitly specifying the array dimensions passed to them.
Standard C lacks this important feature (some compilers like
gcc have it as non-standard extension) and the workarounds are
very cumbersome (See Appendix C).
This feature by itself is sufficient to prefer Fortran over
C in numerical computing.
o A rich set of useful generic-precision intrinsic functions.
Such functions can be highly optimized (written in assembly
language with optimized cache utilization), and they make
programs standard at a higher level (and more portable).
o Builtin complex arithmetic (arithmetic involving complex
numbers represented as having real and imaginary components).
o Array index-ranges may start and end at an arbitrary integer,
the C convention of [0,N-1] is usually inconvenient.
o Better I/O routines, e.g. the implied do facility gives
flexibility that C's standard library can't match.
The Fortran compiler directly handles the more complex
syntax involved, and as such syntax can't be easily reduced
to argument passing form, C can't implement it efficiently.
o A compiler-supported infix exponentiation operator which is
generic with respect to both precision and type, AND which
is generally handled very efficiently, including the commonly
occurring special case floating-point**small-integer.
o Fortran 90 supports an array notation that allows operations
on array sections, and using vector indices.
The new intrinsic functions allow very sophisticated array
manipulations.
The new array features are suitable for parallel processing.
o Fortran 90 supports automatic selection of numeric data types
having a specified precision and range, and makes Fortran
programs even more portable.
o Fortran extensions for parallel programming are standardized
by the High Performance Fortran (HPF) consortium.
Fortran 90 supports useful features of C (column independent code,
pointers, dynamic memory allocation, etc) and C++ (operator
overloading, primitive objects).
b) The design of FORTRAN allows maximal speed of execution:
o FORTRAN 77 lacks explicit pointers, which is one reason that
it is more amenable to automatic code optimization.
This is very important for high-performance computing.
Fortran 90 allows explicit pointers restricted to point
only to variables declared with the "target" attribute,
thus facilitating automatic optimizations.
o Fortran was designed to permit static storage allocation,
saving the time spent on creating and destroying activation
records on the stack every procedure call/return.
Recursive procedures are impossible with static allocation,
but can be simulated efficiently when needed (very rare).
o Fortran implementations may pass all variables by reference,
the fastest method.
o Fortran disallows aliasing of arguments in procedure-call
statements (CALL statements and FUNCTION references), all
passed argument lists must have distinct entries.
Fortran disallows also aliasing between COMMON (global)
variables and dummy arguments.
These restrictions allows better compiler optimizations.
c) There is a vast body of existing FORTRAN code (much of which is
publicly available and of high quality). Numerical codes are
particularly difficult to port, scientific establishments usually
do not have large otherwise idle programming staffs, etc.
so massive recoding into any new language is typically resisted
quite strongly.
d) FORTRAN 77 tends to be easier for non-experts to learn than C,
because its 'mental model of the computer' is much simpler.
For example, in FORTRAN 77 the programmer can generally avoid
learning about pointers and memory addresses, while these are
essential in C. More generally, in FORTRAN 77 the difference
between (C notation) x, &x, and often even *x is basically
hidden, while in C it's exposed. Consequently, FORTRAN 77 is
a much simpler language for people who are not experts at
computer internals.
Because of this relative simplicity, for simple programming
tasks which fall within its domain, (say writing a simple
least-squares fitting routine), FORTRAN 77 generally requires
much less computer science knowledge of the programmer than
C does, and is thus much easier to use.
Fortran 90 changes the picture somewhat, the new language is
very rich and complex, but you don't have to use or even know
about all this complexity.
e) The C standard requires only a basic double-precision mathematical
library, and this is often what you get. The FORTRAN standard, on the
other hand, requires single & double precision math, many vendors add
quad-precision (long double, REAL*16) and provide serious math support.
Single-precision calculations may be faster than double-precision
calculation even on machines where the individual machine instructions
takes about the same time because single-precision data is smaller
and so there are less 'memory cache misses'.
Quad-precision (long double) calculations are sometimes necessary to
minimize roundoff errors.
If you have only double-precision mathematical routines, the basic
mathematical primitives will take up unnecessary CPU time when used
in single-precision calculations and will be inexact if used with
'long double'.
f) FORTRAN is designed to make numerical computation easy, robust
and well-defined:
1) The order of evaluation of arithmetical expressions
is defined precisely, and can be controlled with
parentheses.
2) The implicit type declaration feature saves time/typing
(however it makes your program vulnerable to annoying
and hard to detect bugs).
3) Case insensitivity eliminates bugs due to 'miscased'
identifiers.
4) The lack of reserved words in the language gives the
programmer complete freedom to choose identifiers.
5) The one statement per line principle (of course
continuation lines are allowed with a special syntax)
makes programs more robust.
6) Added blanks (space characters) are insignificant
(except in character constants) this also contributes
to the robustness of FORTRAN programs.
7) Linking with the mathematical library doesn't require
any compiler option (in C you to have to use "-lm").
g) Last but not least, FORTRAN compilers usually emit much better
diagnostic messages.
In summary, we can say that the difference between Fortran and C,
is the difference between a language designed for numerical computations,
and a language designed for other purposes (system programming).
+---------------------------------------------+
| |
| SUMMARY OF FORTRAN ADVANTAGES |
| ============================= |
| a) Scientifically oriented |
| b) Better optimized code |
| c) A lot of existing code |
| d) Easier to learn |
| e) More efficient mathematics |
| f) Easier to use and more robust |
| g) Better diagnostics |
| |
+---------------------------------------------+
A much more important factor in the social movement than those already mentioned was the ever-increasing influence of women. This probably stood at the lowest point to which it has ever fallen, during the classic age of Greek life and thought. In the history of Thucydides, so far as it forms a connected series of events, four times only during a period of nearly seventy years does a woman cross the scene. In each instance her apparition only lasts for a moment. In three of the four instances she is a queen or a princess, and belongs either to the half-barbarous kingdoms of northern Hellas or to wholly barbarous Thrace. In the one remaining instance208— that of the woman who helps some of the trapped Thebans to make their escape from Plataea—while her deed of mercy will live for ever, her name is for ever lost.319 But no sooner did philosophy abandon physics for ethics and religion than the importance of those subjects to women was perceived, first by Socrates, and after him by Xenophon and Plato. Women are said to have attended Plato’s lectures disguised as men. Women formed part of the circle which gathered round Epicurus in his suburban retreat. Others aspired not only to learn but to teach. Arêtê, the daughter of Aristippus, handed on the Cyrenaic doctrine to her son, the younger Aristippus. Hipparchia, the wife of Crates the Cynic, earned a place among the representatives of his school. But all these were exceptions; some of them belonged to the class of Hetaerae; and philosophy, although it might address itself to them, remained unaffected by their influence. The case was widely different in Rome, where women were far more highly honoured than in Greece;320 and even if the prominent part assigned to them in the legendary history of the city be a proof, among others, of its untrustworthiness, still that such stories should be thought worth inventing and preserving is an indirect proof of the extent to which feminine influence prevailed. With the loss of political liberty, their importance, as always happens at such a conjuncture, was considerably increased. Under a personal government there is far more scope for intrigue than where law is king; and as intriguers women are at least the209 equals of men. Moreover, they profited fully by the levelling tendencies of the age. One great service of the imperial jurisconsults was to remove some of the disabilities under which women formerly suffered. According to the old law, they were placed under male guardianship through their whole life, but this restraint was first reduced to a legal fiction by compelling the guardian to do what they wished, and at last it was entirely abolished. Their powers both of inheritance and bequest were extended; they frequently possessed immense wealth; and their wealth was sometimes expended for purposes of public munificence. Their social freedom seems to have been unlimited, and they formed combinations among themselves which probably served to increase their general influence.321 The old religions of Greece and Italy were essentially oracular. While inculcating the existence of supernatural beings, and prescribing the modes according to which such beings were to be worshipped, they paid most attention to the interpretation of the signs by which either future events in general, or the consequences of particular actions, were supposed to be divinely revealed. Of these intimations, some were given to the whole world, so that he who ran might read, others were reserved for certain favoured localities, and only communicated through the appointed ministers of the god. The Delphic oracle in particular enjoyed an enormous reputation both among Greeks and barbarians for guidance afforded under the latter conditions; and during a considerable period it may even be said to have directed the course of Hellenic civilisation. It was also under this form that supernatural religion suffered most injury from the great intellectual movement which followed the Persian wars. Men who had learned to study the constant sequences of Nature for themselves, and to shape their conduct according to fixed principles of prudence or of justice, either thought it irreverent to trouble the god about questions on which they were competent to form an opinion for themselves, or did not choose to place a well-considered scheme at the mercy of his possibly interested responses. That such a revolution occurred about the middle of the fifth century B.C., seems proved by the great change of tone in reference to this subject which one perceives on passing from Aeschylus to Sophocles. That anyone should question the veracity of an oracle is a supposition which never crosses the mind of the elder dramatist. A knowledge of augury counts among the greatest benefits222 conferred by Prometheus on mankind, and the Titan brings Zeus himself to terms by his acquaintance with the secrets of destiny. Sophocles, on the other hand, evidently has to deal with a sceptical generation, despising prophecies and needing to be warned of the fearful consequences brought about by neglecting their injunctions. The stranger had a pleasant, round face, with eyes that twinkled in spite of the creases around them that showed worry. No wonder he was worried, Sandy thought: having deserted the craft they had foiled in its attempt to get the gems, the man had returned from some short foray to discover his craft replaced by another. “Thanks,” Dick retorted, without smiling. When they reached him, in the dying glow of the flashlight Dick trained on a body lying in a heap, they identified the man who had been warned by his gypsy fortune teller to “look out for a hidden enemy.” He was lying at full length in the mould and leaves. "But that is sport," she answered carelessly. On the retirement of Townshend, Walpole reigned supreme and without a rival in the Cabinet. Henry Pelham was made Secretary at War; Compton Earl of Wilmington Privy Seal. He left foreign affairs chiefly to Stanhope, now Lord Harrington, and to the Duke of Newcastle, impressing on them by all means to avoid quarrels with foreign Powers, and maintain the blessings of peace. With all the faults of Walpole, this was the praise of his political system, which system, on the meeting of Parliament in the spring of 1731, was violently attacked by Wyndham and Pulteney, on the plea that we were making ruinous treaties, and sacrificing British interests, in order to benefit Hanover, the eternal millstone round the neck of England. Pulteney and Bolingbroke carried the same attack into the pages of The Craftsman, but they failed to move Walpole, or to shake his power. The English Government, instead of treating Wilkes with a dignified indifference, was weak enough to show how deeply it was touched by him, dismissed him from his commission of Colonel of the Buckinghamshire Militia, and treated Lord Temple as an abettor of his, by depriving him of the Lord-Lieutenancy of the same county, and striking his name from the list of Privy Councillors, giving the Lord-Lieutenancy to Dashwood, now Lord Le Despencer. "I tell you what I'll do," said the Deacon, after a little consideration. "I feel as if both Si and you kin stand a little more'n you had yesterday. I'll cook two to-day. We'll send a big cupful over to Capt. McGillicuddy. That'll leave us two for to-morrer. After that we'll have to trust to Providence." "Indeed you won't," said the Surgeon decisively. "You'll go straight home, and stay there until you are well. You won't be fit for duty for at least a month yet, if then. If you went out into camp now you would have a relapse, and be dead inside of a week. The country between here and Chattanooga is dotted with the graves of men who have been sent back to the front too soon." "Adone do wud that—though you sound more as if you wur in a black temper wud me than as if you pitied me." "Wot about this gal he's married?" "Don't come any further." "Davy, it 'ud be cruel of us to go and leave him." "Insolent priest!" interrupted De Boteler, "do you dare to justify what you have done? Now, by my faith, if you had with proper humility acknowledged your fault and sued for pardon—pardon you should have had. But now, you leave this castle instantly. I will teach you that De Boteler will yet be master of his own house, and his own vassals. And here I swear (and the baron of Sudley uttered an imprecation) that, for your meddling knavery, no priest or monk shall ever again abide here. If the varlets want to shrieve, they can go to the Abbey; and if they want to hear mass, a priest can come from Winchcombe. But never shall another of your meddling fraternity abide at Sudley while Roland de Boteler is its lord." "My lord," said Edith, in her defence, "this woman has sworn falsely. The medicine I gave was a sovereign remedy, if given as I ordered. Ten drops would have saved the child's life; but the contents of the phial destroyed it. The words I uttered were prayers for the life of the child. My children, and all who know me, can bear witness that I have a custom of asking His blessing upon all I take in hand. I raised my eyes towards heaven, and muttered words; but, my lord, they were words of prayer—and I looked up as I prayed, to the footstool of the Lord. But it is in vain to contend: the malice of the wicked will triumph, and Edith Holgrave, who even in thought never harmed one of God's creatures, must be sacrificed to cover the guilt, or hide the thoughtlessness of another." "Aye, Sir Treasurer, thou hast reason to sink thy head! Thy odious poll-tax has mingled vengeance—nay, blood—with the cry of the bond." HoME古一级毛片免费观看
ENTER NUMBET 0017 cluci.com.cn liequ5.net.cn shehuo55.com.cn www.wed99.com.cn www.cishe3.net.cn www.qinbu6.com.cn www.zouju3.net.cn bakou9.net.cn baore7.com.cn 10botiyu.com.cn