Http://krsna.lamost.org/popular/fortran/ The classic book of the first gossip China mathematics is mostly divided into different methods or different types.
The form of chapter appears in the form of a problem. Every individual problem is divided into several
Item: The entry is "ask", puts forward the problem of specific values;
Is "an answer", give the specific value of this problem; the entry is called "technique",
Generally, it is a common method of answering and entry.
As it is equivalent to the "algorithm" in computer science, but sometimes
When a formula or a theorem; the entry is "Note", indicating "surgery"
The basis and reasons are essentially equivalent to a certificate; since the Song Dynasty, it may
It is due to the development of typography, often coupled with the five "grass", the basis
"Surgery" gave a detailed calculation process of the answer. ...
As early as "nine chapter arithmetic", Chapter 8 Equation Chapter is linear joint cube
Solution of Cheng Group. According to Liu Micron: "It is a rack of it."
Said: "Let each behavior, the bipolar process, the three objects, all the number of things
Cheng Zi. "At the time, I was raised, and the data was placed in various lines.
Then make an operation. ... Middle School Texture Book Desolication Linear Equipment Method
I saw "9 chapters of arithmetic". ...
Mathematics is always called arithmetic in Chinese ancient times. This just reflects the Chinese ancient bossa
Characteristics of modification, calculation and mechanization. Mathematics is not only for application, even
In order to obtain specific results in pure mathematics, it is not possible.
There must be ok. ... The ideology and method of ancient Chinese arithmetic, justice with modern times
The use of machines is integrated, and it will also return to youth, and another
New appearance plays an important role in the future mathematical development.
---- Wu Wenjun [1] "Re-understanding Chinese Traditional Mathematics"
-------------------------------------------------- ------------------------------ [1] Wu Wenjun, Chinese Academy of Sciences Academician, one of the most excellent modern mathematicians in my country, in the topology The world's achievements have been achieved in the field of learning, and in recent years, it has actively promoted the development of mathematical mechanization.
Chapter 1 Objective To calculate that our book describes a language. Unfortunately, language is difficult to become our hobbies, not to mention that the Fortran language cannot follow English, and can be successfully converted to a crazy manager by certain English masters. Therefore, almost every person who has learned the programming language will have a painful memory, that is, an extreme lack of interest, because it is easy for us to forget the use of this language. Obviously, if a tool is not so obvious, do you talk about the fun of people?
Therefore, if you want to have a boring in the study process of the Fortran language, the only rescue is to find the absolute sufficient reasons to learn it, and you will rely repeatedly rely repeatedly in the process of learning. In order to convince yourself need more patience, it can endure cumbersome and agreed, ... gradually, maybe we can experience a new look at the world from the Amazing ability of the Fortran language, this probably is what we enjoy After many boring, the best return can be obtained.
So we have to take your gossip before entering the topic, and see if you learn fortran.
1.1 Beginning, finally calculating the end of the ride, we often listen to the reason why human beings can rely on the weak body, and once again repeated the madness of other fierce animals, and finally achieve the well-deserved "Wan Beast" King, this reason has many explanations, such as labor, saying is hand, saying is a brain, is a big brain, and it is true that there are various theories and evidences. It is indeed difficult to obtain the problem, so I want to propose a new The explanation is probably not subjected to immediate covering. Human evolution begins with calculation, I believe.
In the documentary of African chimpanzee, you can see the chimpanzee will use the tool, a chimpanzee family in order to live in the work, the shape of a black orangutan community, showing their brain is not very idle, but Once I saw the chimpanzee grabbed the banana, I always lost my hand, and I didn't know how to get myself, and I suddenly felt that their lack of lack of the capacity.
So I think, the origin of human beings must have a great relationship with the calculation.
Of course, these are tricks, but if human science is starting from the calculation, it should not be too controversial.
Perhaps some people say that human scientific activities should be observed, but from the perspective of animal behavior, it is difficult to define this behavior, and calculations are very defined behaviors because the most primitive calculation behavior is obvious. It should be the number.
I can imagine that when human beings are realized to realize that they are in this world, what is the impermanent and power of Sun and Moon Stars and Rain and Lei Electric! The first method that humans will rescue from this fear should be the calculation.
The calculations have led to the earliest scientific activities of humanity, namely astronomy and geometry. From the count of the sun and moon stars, it is often the operation of the celestial body, not what is unable to ponder the demon ghost; from the establishment of a clear geometry concept from the metrics of the land and the mountains, thus living in their lives The world began a real understanding. Once this kind of understanding, once it started, it could not stop. So far, it constitutes the most proud achievement of our humanity - science.
The history of science shows its foundation, that is, calculation.
If we just observe it, we will record a lot of experience, but it can't understand the meaning of these experiences, and further, after the experience has summed up, even if it is different, it will lead to different Natural understanding.
A very famous example is the problem of the movement of the solar planet.
For the ancients, the so-called planet means that the stars are obviously moving relative to the star, and the rushing people are very striking. So I started to record the operational track of these planets very early. In ancient Greek era, the most famous research on these planets is completed by Ptale, and he has calculated a record data on planets, got an extremely "successful" planetary motion model, that is, the earth is the center of the universe , Planets strictly move around the earth. Now, his observation data will not be very accurate, and his calculation will not be very accurate, until Copple, on the basis of obtaining the data of very accurate planet track, has conducted a lot Calculate, eventually got revolutionary Cape three law.
Then, Newton came, he was a calculation genius, which was through calculation, from the law of Copple, got his greatest discovery, and the law of gravitation.
Then it is calculated, we can now use the calculation of Newton Wangee gravitational formula and put your foot on the lonely sand dust of the moon.
There is also a very unique example in China's ancient science and technology, but also strongly dependent on calculations.
Compared to ancient Greece, China's ancient mathematics is almost entirely calculated-centered, open China's ancient mathematics book, a distinctive feature is almost entirely a matter of mathematical calculation, and there are very few ancient Greece. Traditional axiom, theorem and proof. In fact, ancient China has been leading the world in technology, it is difficult to say that there is no relationship with this focus on calculation. The most famous example is the calculation of the ancestral ratio, and we are now very clear, the calculation of Zhu Chong is not only for the circumference rate, but more importantly, it provides a very common calculation. Method, that is, an approximate integral calculation, and this calculation method is an important role in the advancement of ancient China. It is a model that indicates the importance of calculation.
If the calculation plays a key role in the early development of science, then we can still say that computing is still a key role in modern science and technology.
Although the modern science and technology is wide, it is wide, but where there is no figure? Even in some scientific philosophers, whether it can be calculated is a measure of a department that has become a department of science. Perhaps this statement is inevitably, but the significance of science and technology is indeed a profound problem.
We may wish to examine the status occupied by physical learning, maybe contribute to understanding this problem deeper.
Almost the nineteenth century, physics is still the main content of the experiment. After entering the 20th century, a physics revolution has quickly set up the monument of theoretical physics, which is enough to compete with traditional experimental physics. And this situation began to change during the World War II. After World War II, in addition to experimental physics and theoretical physics, the physics has been calculated, resulting in the most critical factors of this modification to the invention of electronic computers.
Before the computer has no inventions, people have to take a variety of ways to avoid too large calculation problems, and a large number of key issues, and it is not a huge calculation. Taking physics as an example, once we thoroughly solve linear problems The incoming thing is that a broader nonlinear phenomenon is far more than linear phenomena. For nonlinear issues, we have mastered the analytical methods that are extremely poor, which is forced to take directly to the road.
In addition to nonlinear problems, physics and even the entire natural scientific thinking world is atomic, that is, we can always understand a result of understanding the interaction of its composition, so we have a molecule. This kind of practice has been full of victory, but this kind of victory is also accompanied by heavy costs, that is, when we reopeically face complex phenomena, it has to be considered from its composition ingredients. It is the basic idea of statistics physics. Obviously this approach brings us a heavy computing task, because so far, our human beings have a precise resolution of a system that contains more than three, interacting members, has It is a bit a little way, let alone those who are commonplace contain thousands of members? So in a large part, our only choice is to calculate.
So we can say that the calculation is indeed a scientific cornerstone.
As for this world we live almost completely created by science and technology, there is no figure? If the calculation helps us understand the nature, we can further say that the calculation has created our lives.
Any scientific new understanding of nature is to transform to the technique used for people, the basic way is calculated. The truth is clear, when we want to make an item that has never appeared in nature, what we need is specific manufacturing data, and cannot just a bunch of formulas, where is the data come from? Of course, it can only be calculated from the formula. Therefore, we can implement computational understanding as the theoretical approach. That is, theory is to reflect the real world, but also to reflect our actual items, it all need to pass a calculated road, the theoretical armed our brain, and calculations created our world. So we can say that the history of human beings is the earliest to calculate, and the forefront of this history is still finally calculated.
1.2 Description The calculated language has long been done, but if you carefully think about it, you will find a clear analysis, clarify the problem, and decompose. , Feasible, and limited steps, obviously this kind of work is essentially mechanically, if the problem that has been solved is also handed over to the human brain, it is clear that there is a waste of manpower; from another aspect, often A question that needs to be calculated is also a problem that needs to make a huge calculation, and it is difficult to compete for humanity.
Therefore, both aspects require the human invention to calculate the machine, which directly leads to the invention of the computer.
Today, when we face problems that need to be calculated, the problem is no longer just a brain, but a brain plus a machine. So the next question is how to make the brain work together with the computer, making the brain can be used to seek the problem of algorithms, while the computer can be used to calculate.
The first requirement of this collaborative work is that people need to represent the understanding of the calculation process of the problem as a machine mechanical movement. The first understanding of the problem and its solve is to describe the description of the mathematical language very clearly. Then we look at the end of the machine.
The so-called computer is a machine that automatically performs a series of machine movements. For those machine actions, we can correspond to the basic calculation operations, which makes it possible to decompose the calculation steps of the calculation problem to a limited machine operation. The remaining problem here is that on the one hand, the mathematical language we are well known to describe the problem, on the other hand, describing the language of the machine operation, how the language corresponds to the problem.
Below we discuss a very simple example, used to explain the language translation problem in this.
Solution of a one-dollar secondary equation is a very simple mathematical problem. The form of the equation is:
Then the general formula for the solution of the equation is:
Note that our purpose is to calculate, rather than seeking to analyze, so this formula is not the end of the problem, but the beginning of the problem, that is, this formula, in the case of A, B, and C, seeking value Specific numerical solution. Because if this equation describes a parabolic movement, then we need to know the value of the solution so that we can understand and control the broth movement.
So we also need to further describe this mathematical expression as a specific evaluation process as follows:
(1) Get specific values of A, B, and C;
(2) The value calculated according to the specific value of A, B, and C;
(3) If it is greater than 0, then calculate the value of the above two formulas, two different real roots;
(4) If = 0, then calculate the formula, the value obtained is the same root of the equation;
(5) If less than 0, then calculate the value of the above two formulas, two different complex roots are obtained.
The above five calculation procedures described above are a general description of the calculation process being performed by the computer. Of course, this description is based on the mathematical thorough understanding of the problem of solving the solving of a secondary equation. So what is the language describing the operation of the computer?
We know that the so-called computer work is inherently run some basic mechanical electronic operations. Of course we can define those operations according to the algorithm, such as a signal superposition of a switching circuit, which can be appropriately defined as binary value. Addition, but it is apparent that it is impossible to rely on this physical phenomenon that can directly express more complex calculations, such as the top of the above formula. Fortunately, we rely on mathematics, you can do any complex calculation or approximately decomposition and combination with a small number of simple calculations. Therefore, we have finally expected to use computers in theory to complete computing tasks with clear solving processes.
However, when we need to submit a numerical computing task to your computer, if we always ask us to first describe the description of the computing task, it will make a copy of the computing task to the computer according to the extent to which the compute task can be understood and executed. Extremely troublesome things, the purpose of our use of the computer is to reduce their own mechanical labor work. If you submit the problem to your computer, it is obviously not in line with the original intention of our invented computers.
Therefore, after entering the 1950s, the concept of computer high-level language is proposed. The so-called advanced language is very close to the language of our usual, the language of the mathematical problem, and the so-called high-level language is given, it is not to say that the computer can Directly understand the advanced language, but put the translation of the machine language in the high-level language to the computer language itself to the computer, because this translation work is fully done after the computer itself is, of course, This translation task itself is another calculation problem that we need to give a general answer.
The first born computer in the world is the Fortran we have to give in this book.
Fortran is the earliest IBM company given in 1957, which is specifically used to submit an expression computational problem to IBM's own 704 computer. A solution of calculation issues If a computer language is used, it is called a program, and Fortran is such a language specifically used to write the program.
Due to the success of IBM's 709 computer, it also makes Fortran have spread extensive communication. At this time, Fortran's language is beginning to show it in another aspect, ie the language of language is its propagation. So most other computer manufacturers have also enabled their products to enter and understand the Fortran language.
The Fortran language can be known from its name source to communicate with some specific machines. That is, the FORTRAN statement can be translated into a machine language through a compile program configured on a particular machine, so early Fortran languages have strong features related to the machine system, which reflects some of the characteristics of specific machines, obviously if considering The essence of advanced languages is to describe the calculation process, that is, the so-called algorithm language, then these features related to the machine are meaningless, and the progress of the FORTRAN continuously updates the progress of the version, which contains constantly discarding this feature. The purpose.
An example of this historical trace of Fortran is to define the character sequences that the language can be accepted by those specific machines (that is, IBM is used to 48 characters to the computer input program card perforation device). And its card input method determines a lot of program writing format. For example, a statement in the language is usually written on one record, and a card corresponding to the perforation; each statement is read in order, corresponding to the order of the card; the format of the card is fixed, and the so-called so-called Fixed source code form.
This is the case where we have the first advanced language we have when we have initially proposed.
Soon the birth of another advanced language is Algol, this name is the abbreviation of the algorithm language, so it can be expected to have very different faces with Fortran, because this language is in the initial, not a computer manufacturing company for some kind The specific machine is designed, but is a description of the calculation process, that is, the so-called algorithm is described. Algol was earliered in 1958 Applying Mathematics and Mechanics Association in the Federal Republic of Germany. Algol's design goals obviously be high than Fortran, it hopes not only to use people to transcribe the calculation process on the machine, but also want to be able to directly use the description of the algorithm between people and people.
In order to achieve this universal purpose, Algol's characters are not defined for any specific machine, so it does not reflect the characteristics of any particular machine. In fact, the characters used by Algol are independently defined. Algol has many more unique properties in addition to this.
However, the language hasn't arrived for a long time, because Fortran has more market invasion skills, and final Fortran is still mainstream scientific computing programming language, and Algol language is unfortunately becoming an antique who will hang.
1.3 Why choose Fortran to choose what kind of language, it is a very controversial issue. In the field of scientific calculations, it is the best to use what kind of language in the field of scientific calculations. Maybe we can say that this is a problem that is benevolent, because we use the language of the language, always picking a language that is already familiar with, and is of course the language that you can do very well. But specifically, for scientific calculations, due to its own unique value standards, under this value standard, various languages can be objectively compared under this value standard.
First we have to define the tasks of yourself, what is the scientific calculation problem?
The so-called scientific calculation problem is generally included in the following three meanings:
● The problem itself and the problematic answer can be accurately described using mathematical language;
● If you want to use the usual mathematical methods to give the value answers we need, it will be very troublesome or not given;
● The problem is used as a background with certain science and technology.
We will see this connotation that is scientific calculation problem determines that it has the value criteria when selecting the calculation language.
First, a scientific calculation problem always appears in the form of a mathematical calculation problem, so the language describing the scientific calculation problem should naturally describe mathematical problems, that is, the programming language and mathematical language have comparative direct natural correspondence in expression. relationship.
The reason why a scientific calculation problem needs to be used, it is definitely because this problem has a certain amount of calculation, then the operational efficiency of the program is often the most important consideration factor when choosing a language.
It is in these two points, Fortran is a absolute winner in many languages.
In describing the natural aspects of mathematical language, Fortran can be said to be strong than any language that is still "live". Of course, in history, a fairly mathematic language like Algol, but unfortunately it lacks market survival capacity, so there is only Fortran alone. Fortran is good at describing mathematics calculations, this should be almost no dispute. It is also because of this reason, Fortran's easy learning is recognized. Any scientific and technological professionals, as long as there is a clear concept of a mathematical solution process of a specific problem, it is very easy to translate this solution process into the Fortran language.
As regards the speed of execution, some are often misleading beginners. The most typical error concept is "the fastest execution of C code". This statement comes from the specialty of the C language, because the C language is more system programming language, which is very controlled for hardware, and there is no right in the advanced language, so it is necessary to give people a C program. The fastest impression. But I forgot this speed of the system programming characteristics from the C language, and when doing scientific calculations, it does not need too much to talk to the system kernel. Therefore, the length of the C language can be said to be properly played. On the contrary, in terms of numerical calculation, C is definitely not a Fortran's opponent, because Fortran is based on scientific calculations, and the language itself is optimized for scientific calculations, and the language itself is optimized. Therefore, the operational code generated by Fortran is highly optimized. The actual operational efficiency has also shown the superiority of Fortran in scientific calculations. Whether domestic or abroad, whether it is a classic serial machine or a parallel vector, a large number of experience shows that the efficiency of C or C code is lower than the Fortran code when performing the same scientific computing task.
In addition to commonly superstitions with Efficient superstitions for C, how to face behind for Fortran. Of course, this prejudice is a source, that is, the Fortran 77 that has worked hard is a long period of time, which has lacks into the heart, so that many people have filed Fortran so far, it is what is already very backward in the Today's era.. In essence, the Fortran standard after entering the Fortran 90 era, especially the current Fortran 95 version, can say that as long as it is useful for scientific computing, C and C , now Fortran 95 is absolutely not lacking, and Fortran 95 Many of the characteristics of scientific calculations are not C and C . Even if C is most proud of object-oriented nature, Fortran 2000 will also be fully introduced. Therefore, Fortran has completely caught the trend of the programming language.
Another important aspect related to the performance of the program, is whether the program language can support the program's parallel operation. At this point, it can be said that Fortran has expressed its biggest advantage, because Fortran 95 is working to obtain parallel computing capabilities One version.
Since the size of modern scientific calculations is getting bigger, calculating parallelism is a route that has had to go, the development of modern computer hardware, which also makes parallelization actual popularization, because not only special large-scale computers are parallel, now General PCs can have multiple processors, so modern, scientific calculations have to master the programming capabilities of parallelization.
However, one of the main problems encountered in parallelization is that any process programming language is inherently using linear storage mode, that is, an array element is always stored in memory units in the memory unit in accordance with the order of array elements. Such a model determines that such a process programming language cannot really implement a description of parallel calculations. The Fortran 95 has completely changed this constraint, because in Fortran 95, the Fortran 95 establishes a new conceptual concept, such as the concept of pure process, concept, FORALL structure, etc. Effectively get rid of the constraints of linear storage modes, making the Fortran 95 a standard language describing parallel computing, especially those dedicated data parallelism languages have used Fortran as basic languages, such as high performance Fortran (High Performance Fortran, Fortran D) , Vienna Fortran, and Craft, etc. This makes the program written in the Fortran 95 can be run directly on these data parallellations, and the program written in these dedicated languages can also be transferred to the Fortran 95 platform without difficulty. Such a situation Make Fortran uncommon in the field of parallel computing. In summary, we can fully say that Fortran 95 is the best language for scientific computing. As a staff member in the field of scientific and technical science and technology, it is important to master the Fortran 95 far more important than mastery of C, C and other languages. As for those computer symbol algebrans and numerical computing software, such as Mathematica, MAPLE, MATLAB, MACSYMA, MATHCAD, and more can only be said to be scientific and calculated teaching model and auxiliary tools, because they all provide ready-made algorithms, so it can make the initial Scholars can be applied to some simple occasions, truly use them to deal with a little bigger problem, experienced users know that it is a very painful stronger. Therefore, it is ultimately free to scientifically calculate, then it is not a Fortran.
1.4 Fortran advances Under Tell, we will introduce the important progress in Fortran in history, especially the Fortran 95, which is different from Fortran 90, which can guide us to high performance Fortran parallel programming areas.
1.4.1 Fortran 95's progress in Fortran is meant to bring a lot of language characteristics to three categories:
● New language characteristics;
As the name suggestion, it is a new language introduced by Fortran.
● Outdated language characteristics;
It is still available in the latest Fortran standard, without compatibility, but is indicated as an outdated language feature, which is part of the future Fortran version will be eliminated.
● Abandoned language characteristics.
As the name suggests, it has appeared in the past Fortran version, but in the current version, it is no longer used by the language characteristics.
The following describes them.
1.4.2 New Language Features Fortran 95 Add new language components include new features and improvements to the old features. They mainly include:
● FORALL statement and structure.
● Pure process.
● Elemental process.
● Extension of WHERE structure.
● By default initialization.
● NULL inherent functions.
● CPU_TIME Inherent sub-routine.
● Inherent functions CEILING, FLOOR, MAXLOC, MINLOC extension.
● Distribute dynamically assignment of arrays.
● Name list input inside. ● Minimum domain wide format description.
● Some modifications used to support IEEE 754/854 floating point operations standards.
The following will be described below.
1. FORALL statements and structural FORALL statements and structures and pure processes These two new language components are mainly introduced in order to improve the program parallel operation efficiency above the multiprocessor system.
As long as the system supports parallel assignment, the FORALL statement, and the structure, it is natural to simultaneously assign all elements of a huge array to simultaneously assign, so that the system's parallel behavior can be fully utilized. The introduction of this new feature sufficiently shows the efforts of Fortran in parallel operations.
2. Pure process Pure is a fully introduced process attribute. Functions or sub-routines with Pure properties, except for return values, will not have any post-limits. That is, for any of its arbitrary variables or global variables, it does not change their values, pointer correlation status, and data mapping, and no input and output is performed.
Inside the Fortran 95, some of the requests must have a Pure property. Special Pure Attributes is a necessary condition for applying a FORALL statement or a structure.
3. Elemental process The progressive process is also a powerful tool for performing parallel operations. Applying a graduated erase process to an array, converting this arithmetic operation into a single operation of all elements of the array, and all a single result is combined, returning an array of the same shape.
4. The extended WHERE structure is expanded, which can contain a nested of a FORALL structure, and the FORALL structure can also include nesting of WHERE statements or structures. The cooperation of both has a powerful function.
5. By default initialization The default initialization can be applied to derived types, including dumb, which ensures that derived type objects with pointer members can always be accessed. This avoids the case where memory can be allocated, but cannot be assigned.
For pointers, the new intrinsic function null can be used to give the initial association state, or the Nullify statement can be used to obtain initialization before using the data.
6. The function of NULL's new intrinsic function NULL is primarily giving a pointer to an initial correlation.
NULL functions can be used in a type declaration statement, given the initial deinterlergery state of a pointer, or in a structural constructor, used to give the initial pending state of the pointer member.
7. CPU_TIME Solid Substalline Junior Suitable Function CPU_TIME is used to measure processor time consumed by a program or a piece of code.
The measurement results of this function are not necessarily very accurate, but it is very useful in some situations. For example, it is used to compare the running time of different code, which can be used to compare their efficiency; can also be used to detect a parallel program to truly process a variable element as an array to evaluate its parallel efficiency.
8. Inherent Functions CEILING, FLOOR, MAXLOC, MINLOC Extensions Between Fortran 90 and High Performance Fortran, some inherent functions and related functions have some incompatible, because in high performance Fortran, increase in different variable elements A DIM function.
In Fortran 95, it is relaxed for the requirements of the paragraph sequence, so that MASK and DIM appear in the variable meta sequence can be arbitrary, thereby ensuring compatibility of the Fortran 95 and high performance Fortran.
9. Dynamically assignment of the assigned array in Fortran 95, when exiting a given scope, where there is no assignable array that is reserved by using Save, automatically distribute, and the effect of using the DEAllocate statement . This prevents the possible memory omissions, thereby specifies the allocation process.
10. Note You can use annotations in the Name List Enter records to facilitate users. 11. Minimal Domain Width Format Description When using the value of the value, use the enhanced output format to edit the descriptor, you can minimize the domain width, thereby avoiding the white edge when outputting.
12. Some modifications used to support IEEE 754/854 floating point calculation standards in all previous Fortran versions, do not distinguish 0. and -0., Ie 0 and negative 0, in the Fortran 95 version, It is possible to distinguish between the two, that is, when the SIGN function is used, it can be obtained by making the first variable element of 0, and the second variable element is negative, the negative zero is obtained.
1.4.3 Outdated Language Characteristics Fortran 95 is being classified as an outdated language characteristics, or it is allowed to be used in Fortran 90, but it has been strongly used in Fortran 95 because they will be in the next Fortran version. Complete elimination. These outdated language features mainly include:
● Arithmetic IF statement.
● Some forms of DO termination.
● Alternative returns.
● Calculate the Go to statement.
● Statement function.
● DATA statement between executable statements.
● Dumb length character functions.
● Fixed source code form.
● Character * in the characteristic declaration.
The following description, and particularly note why they are extra or easy to generate errors.
1. The function of the arithmetic IF statement arithmetic IF statement can be replaced by using the IF statement or IF structure.
2. Some forms of sharing do the DO termination, or do not use the END DO statement or the continue statement to terminate, whether from a secure perspective, or from a clear angle, it is best to use without label The form of the DO structure block of the END DO statement.
3. Alternative return replacement returns to strongly rely on labels, is not worth promoting, and the same function can be implemented through the Case structure.
4. Calculate the GO to statement to calculate the GO to state can be used instead of using the CASE structure, and the CASE structure also has a more wide range of functions than calculating the GO to state. From the perspective of structured programming, the CASE structure should also be used instead of complete non-structural, with an early and system-related feature calculation GO to statement.
5. The internal function of the statement function has many features of the statement function. The statement function is very easy to confuse the assignment statement, so statement functions are not advocated.
6. DATA statement between executable statements If you use a Data statement in the executable portion of the program, it will easily produce a illusion, that is, the DATA statement can assign a value in the execution of the program, and actually, DATA statement It can only be used for the initialization of data, so the DATA statement is preferably only used for the description of the program.
7. Dumb Length Character Function Dumb Length Character Function Requirements The name of the function is declared in the calling program, which can be replaced by using sub-routines or functions with explicit interface or dynamic character length.
8. The fixed source code form fixed source code is completely determined by the early card paper strip input and output mode, and now the card paper strip input and output has long been used, so this source code must be eliminated.
9. Character * in the characteristic declaration in the form of characters declarative statement, using Character * of the character length, is completely redundant, generally advocating the form of more English habits.
1.4.4 Abandoned language features can also be used in Fortran 90 Some language features have been completely discarded by Fortran 95, so they should pay special attention to avoiding source code cannot be commissioned in the Fortran 95 system.
These language features that are discarded by the Fortran 95 include:
● Real and double precision real-in-DO variables.
● The external part of the block is branched to the END IF statement inside the block.
● PAUSE statement. ● ASSIGN statement, a label GO to statement.
● NH Edit Descriptor.
In order to be able to read the source code using Fortran 90 and earlier, the following is also a brief description. Please note that they are eliminated.
1. The DO variable real-form and double precision real-sensitive DO variables or loop-controlled DO variables are difficult to transplant, and it is also very useful. Therefore, modern Fortran versions require DO variables to scale integer variables.
2. End IF statement from the external branch of blocks from the external branch of the block from the external branch of the block to the control of the execution sequence of the block for the execution sequence of the statement, is completely unnecessary, and it is not standardized, so it has been completely eliminated. .
3. PAUSE statement PAUSE statement is used to hang a running program until the system or operation restarts run. Its features are completely redundant because the WRITE statement can send a message to any device, such as an operation console or terminal, and the READ statement can wait or receive a message from the same device. They can replace special PAUSE statements.
4. ASSIGN statement, a label GO to statement assign statement is used to give a tag of a statement to a integer variable.
Its general purpose is that in the running process of the program, you can give the integer variable to the label of the branch target statement through the Assign statement, thereby providing a dynamic branch capability.
However, the integer variable may have a tag value, but it may have a general integer value, which will easily lead to program errors, which makes it difficult to read.
In fact, the ASSIGN statement, as well as the function of the label, can be implemented by internal processes, because the Assign statement is nothing more than a reciprocal code block completes the return point after running.
The ASSIGN statement can also dynamically give a tag of a Format statement to a integer variable, then the variable can be used as a format specifier for Write, Read, and Print statements. However, this feature can also be achieved by using character type variables, arrays, and constants as format specifiers.
In short, the use of the label is always inappropriate.
5. NH Editing Descriptor Use this editing descriptor very easy to cause errors because the number of characters behind this descriptor is easy to calculate errors, and if the character constant editing descriptor is used to exercise the same function, it is not required. Calculate the number of characters.