"Fortran 2003: Perfect or Unreal" is the "programmer" 10th issue. I put this article here, I want to read the full text, I can find "programmers" magazine.
Fortran 2003: Perfect or illusory? (8) Wang Wei Gang, August 2004 "Fortran 2003! Object-oriented Fortran! Freedom, open Fortran! Hug Fortran 2003!" I danced, excited. Excited. "ForTran 2003? What is your mobility?" The Geophysical Department stopped me with a wide-side glasses. The desirable eyes were directly across the thick glasses. "I used Fortran 77 to finish the topic yesterday. What you said is the object of object ',' Freeders', 'Open' What is the ghost of your programmer? Can they double my SCI papers? Can I ask me to comment on the advice? "" ...... "
1. Fortran 2004, Fortran 2003, Fortran 2003, New Working Group, which was born in this new century, finally worked in the ISO, IEC Joint Working Group JTC1 / SC22 / WG5 and the United States Fortran Committee NCITS / J3 joint efforts, After you have finished editing, the final step is revised. If you don't have any accidents, for more or two years, support Fortran 2003 development tools will flood the Fortran world; those who are still sticking to the Fortran 77 position will naturally question the question from Fortran 90/95 to more Revolutionary Spirit of Fortran 2003. To learn about Fortran 2003, we need to simply review the history of the Fortran language. Between 1954 and 1957, the world's first advanced programming language - Fortran was born in IBM. The original meaning of Fortran is IBM Mathematical Formula Translation, its design is to provide researchers with a high-level language that meets mathematical thinking habits to meet the needs of scientific calculations. In the 1960s, under the context of the US Su Space Competition, under the urgent needs of high-performance computing tools in the national defense, education and scientific research, Fortran language flourished and became the king of senior languages in the computer world. ...... ...... ...... ...
2. Object-oriented Fortran is designed from the structured program to object-oriented, which is the development, evolution law of most advanced languages, and Fortran has not been awkward. In Fortran 77, it is difficult to introduce object-oriented ideas and methods due to the lack of basic support for data abstraction and data packaging. In Fortran 90/95, although we can use a derived type and module to simulate some object-oriented characteristics, it is unable to achieve true package and inheritance. Packages for data and related operations are object-oriented foundations. Traditional structured programming languages Most have simple data package capabilities (such as Record in the Pascal language, but lack support for operating packages. When we introduce an object-oriented mechanism for the structured programming language, there are generally two ideas in the grammar: one is introduced into a new syntax container, allowing users to define unified data types that encapsulate data and operations with the container. For example, C extends the concept of Class on the C language, and supports object-oriented programming in Class as a Class; the other is to knead the original data package container and the process or function of the original data package container and representation operations. Together, for example, the ADA 95 uses the concepts existing in the ADA 83, encapsulates private type and related operations in Package, creates a complete object-oriented mechanism. Fortran 2003 has been following the latter ideas for Fortran 90/95. First, Fortran 2003 introduced the concept of Procedure Pointer for the first time. Fortran 90/95 only supports normal pointers. In order to achieve a callback mechanism, the Fortran 90/95 specially introduces the syntax of the Dummy Procedure, but this syntax cannot solve the problem of embedding in the data type. In Fortran 2003, we can use process pointers to bind data and operation together: Type Point Real :: X, Y Procedure (Testif), Pointer :: Testend Type This binding is a dynamic binding of running We can assign values for the process as needed, similar to our embedding function pointer in the C language Struct. Second, if the type of operation is predicted at compile, we can use the type binding process provided by Fortran 2003, associate data and operation together: Type Point REAL: X, YCONTAINS Procedure :: test => my_teestend TYPE This, in the same module, the type and related operations are associated with each other, and the user can directly use the CALL P1% TEST or similar code to access specific operations, which is very close to the package mechanism of the ADA 95. . Compared to C or Java language, this process binding method of Fortran 2003 is close to the underlying of the language design. For example, for the MY_TEST process binding in the Point type, we must show that the first parameter of the process is Point Type: Subroutine my_test (a) Type (Point), Intent (in) :: Aend Subroutine A is equivalent to the hidden THIS parameters in the C or Java method, which is the object of the object instance of the operation. I put this display to implement this parameters is called "naked object-oriented".
Although it is slightly cumbersome, this "naked" approach has a lot of benefits. For example, we can use the NOPASS attribute in Fortran 2003 to disable the object instance, or change the location of the object instance parameter in the process parameter table by pass attribute. ...... ...... ...... ...
3. Freedom Fortran flexibility has always been a weak term in the Fortran language. Early Fortran does not even support the dynamic allocation of memory. The Fortran 90 introduces the concept of pointers, fully supports dynamic access of data, and also introduces the generic procedure to support a similar function with the C functions. On this basis, the Fortran 2003 further enhances the flexibility of the Fortran language by parameterizing the type of derived type, coverage, polymorphism. For example: Type Point (k, n) integer, kind :: k = kind (0.0d0) integer, len :: n real (kind = k) :: x, y character (len = n) :: NameEnd TYPE Based on the top Such parameterized derived type, we can define the specific type parameters of the object as needed, or dynamically specify the type parameters of the assignable memory objects during the program run, as needed. In addition to the overloading mechanism that the Fortran 90 has implemented, the Fortran 2003 also allows the type binding process in the overriding base type. More importantly, Fortran 2003 fully implements object-oriented language prerequisites through abstract type, derred binding, polymorphic entity, type selection (SELECT TYPE). Polymorphism. For example, we can declare the following abstract types: Type, Abstract :: Point Real :: X, YContains Procedure (Testif), Deferred :: Testend Testif (P) Class (POINT), INTENT (in) :: P End subroutinend interface The above code is equivalent to declaring an abstract class in the C or Java language, where the TEST process is equivalent to a pure virtual function in the C language, only the interface declaration, and does not implement code. On this basis, we can extend the specific subtype from the abstract type POINT. When the specific type of an object can be determined at runtime, we can use the class keyword (here the Class refer to a set of inheritance relationships, which is not equivalent to Class C ) to define a polymorphistic function. Pointer or assigangible object: Class (Point), Pointer :: P Now, pointer p can point to any specific type of Point extension, this way of use has been referred to in C with base class pointer reference derived class object The practice is exactly the same. When using this entity with polymorphic features, we can also use the internal process Same_TYPE_AS and EXTENDS_TYPE_OF provided by Fortran 2003 to determine the type of object, which is a simple runtime type identification (RTTI) mechanism, its function and C The TypeId keyword in the language is imitated. ...... ...... ...... ...
4. High-performance Fortran compared to other scientific calculation languages or tools, the Fortran language has always been outstanding in performance. Because the language itself is specifically optimized for numerical calculations, matrix processing and other functions, most Fortran compiler generated executable code even exceeds efficiently known C or C or C languages. In order to achieve more excellent implementation efficiency in high-performance parallel processing systems (such as IBM "dark blue" and my country's "dawn"), Fortran 95 also specializes in the advantages of HPF language, adding a number of support for parallel calculations to the Fortran language. Grammatical features (such as famous FORALL statements and pure processes). Continue to improve the computational performance of the Fortran language is of course one of the Fortran 2003 tasks. One of the most obvious examples is that Fortran 2003 introduces the Volatile property. This property is similar to the Volatile keyword in the C language or java language. The programmers who have written overcomparal or real-time applications know this meaning of "easy" keyword: In the concurrency system, if there is no help of this keyword, we must always be alert to the value of shared data. Refresh correctly. However, relatively, the parallel computing mechanism of the Fortran language itself is still not very sound. When writing concurrency or real-time programs, tasks in the ADA language (Synchronization) mechanism, or multi-thread synchronization features in the Java language can provide more powerful support for programmers. In fact, one of the purposes of the Fortran 95 and Fortran 2003 will be in parallel syntax, which eliminates the isolation between the standard Fortran language and the existing Fortran language variants that have existed and widely used, allowing the same FORTRAN code to be in different locations. transplant. At least until Fortran 2003, the Standard Fortran language has not fully replaced "high-performance" Fortran language variant represented by HPF. For the ability to adapt to high-performance parallel computing environments, Fortran variants such as HPF still have enough reasons to continue to exist and develop until a big big FORTRAN standard will truly unify them. In order to adapt to the clock accuracy of the modern CPU, the Fortran 2003 extends the function of the internal process System_Clock, allowing its count_rate parameter to an Integer or REAL type. ...... ... 5. Open Fortran traditional Fortran language seems to be not so open, this is probably from the Fortran language to only focus on scientific calculations, and ignoring the habit of language versatility. China's FORTRAN users most often complain about: Different Fortran compilers connect external programs (such as C language programs or matlab programs), different Fortran compilers have strong support for Chinese support. do not. People urgently want to develop Fortran standard experts to understand the hardships of end users, integrate Fortran into open and standardized development tracks as soon as possible. In terms of openness, Fortran 2003 brings us the first gospel to us, the new standard finally specifies the connection method of the FORTRAN language and C language. The Fortran 2003 provides an internal module named ISO_C_BINDING that defines the type constant necessary when the Fortran is connected to the C language. After reference to the ISO_C_BINDING module, we can ............ ...... ......
6. Fortran in the Tooth Tatarone emphasizes how to object-oriented, flexible and open, and the Fortran language is still a high-level programming language for scientific calculations. With a look around, we are easy to find that the most common place in the Fortran language is also the most active, knowledge-intensive, and the research in the Institute of Atmospheric Physics in the Institute of Sciences, the researchers are using the FORTRAN language to write atmospheric data analysis software; In the National High Performance Computing Center, the Fortran language is performing various scientific computing tasks on the newly installed dawn parallel computer; in a national key laboratory of molecular biology, high-energy physics, application mathematics, Fortran is research One of the most reliable tools; in the curriculum of a considerable number of science students, Fortran is the first high-level language that students enter the university classroom ... but just as the doctoral student said in this article, Most of the domestic Fortran language applications are still limited in the Fortran 77, most researchers are still writing the Fortran program using the punch card-style code style. The subtext behind this matter is: On the one hand, Fortran 77 can meet the needs of most researchers, on the other hand, researchers are not professional programmers, and it is impossible to have sufficient time to learn new languages. In this case, what reason we have to let researchers learn more complicated object-oriented syntax and turn to more powerful Fortran 95 or Fortran 2003? I personally think that Fortran 2003 brings not only fresh syntax characteristics for all Fortran users, but also a new choice and opportunity. ...... ...... ...... ...