Literature: Metcalf, Reid, Cohen: Modern Fortran Explained. (Oxford University Press, ); Haataja, Rahola, Ruokolainen: Fortran 95/ Fortran 95/ Explained - Metclaf. Reid. Cohen - Download as PDF File .pdf), Text File .txt) or read online. FORTRAN. provide not only a readable explanation of features, but also some rationale assimilate quickly those features in Fortran that are not in Fortran 95 ( Fortran.
|Language:||English, Spanish, Indonesian|
|Genre:||Politics & Laws|
|ePub File Size:||25.71 MB|
|PDF File Size:||14.72 MB|
|Distribution:||Free* [*Regsitration Required]|
Fortran 95/ Explained. Michael Metcalf. Formerly of CERN; Geneva, Switzerland. John Reid. JKR Associates, Oxfordshire and. Malcolm Cohen. Request PDF on ResearchGate | On Jan 1, , M. Metcalf and others published Fortran 95/ Explained. You must attribute the work to “Introduction to Programming using Fortran. 95/ /” (but not in any way that suggests that the author endorses you or your.
General code! Enter the email address you signed up with and we'll email you a reset link. Reverse communication The first pattern I will talk about is known as reverse communication Dongarra et al. Szymanski and H. The Observer pattern An alternative solution is found in the Observer pattern: Just as with the first example an alternative for reverse communication we avoid module variables that way.
Probably not: In fact, when processing, say, XML files, this kind of structure is very common: For instance, in a numerical computation of the flow of water through a network of pipes or open canals, one such task might be to regularly check if the solution is physically acceptable mass- balance errors or acceptable from an engineering point of view maximum flow velocity, 2 Another way of looking at reverse communication is that it provides a means to use co-routines, even if there is no direct support in the language for such co-operating tasks.
Flexible methods might require a lot of extra information that will become part of the data passed to the general solver.
The Observer pattern An alternative solution is found in the Observer pattern: In the example of computing the flow of water in a network of pipes the event could be the completion of a single step in the integration over time. Here are some fragments of code that accomplish this: What is done in this procedure is completely up to the particular implementation.
This is the moment in the computation to! In the example we have only one interesting type of event: But we can easily extend this to any number of event types, each associated with its own type- bound procedure. Such two-way communication can be established, though, by making the solution object an observer of the observing data object. You will need to avoid the circular module dependency by putting those parts in an extra layer, but that way a loose coupling is preserved.
The Template Method pattern Because Fortran supports polymorphic variables — variables whose type is dynamic, rather than static — we can implement the Template Method pattern in an elegant way.
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. For example, the algorithm to solve a system of ordinary differential equations ODE is pretty much fixed a loop over time, updating the solution and offering the possibility for outputting the 3 Note that the list of observers in the previous example is a polymorphic variable as well.
In the code example below, we use different methods, like Euler, Heun, to name classical methods, in a general set up: Subroutine for storing the initial values!
Function to compute the derivative! Derivative is array of! Interface function to hide the internal workings!
Function to actually compute the new values! Declaration of the functions!
Definition of the specific methods for! General code! Specific methods! We use module variables here, out of laziness!
Better would be to use a derived type with all necessary! By selecting a different constant in the construction of the solver, we select whatever method we think is suitable — nothing else in the program is influenced.
One thing should be noted: Just as with the first example an alternative for reverse communication we avoid module variables that way. But I will leave that as an exercise. If we take the object-oriented facilities of Fortran , we can in fact expand this example in a completely different way: This could be relevant for investigating which formulations describe the underlying physics better: The interfaces end interface contains The specific classes we want for this computation!
Actual implementation: This puts them all together! We only need to select the implementation at the beginning. Conclusion These examples show that Fortran offers features that help implement a large class of well- known design patterns. Sometimes the need to specify an interface in detail may make the code lengthier than seems necessary, but they make it possible for the compiler to check correct usage.
Gardner and Decyk indicate that object oriented techniques and object-oriented design patterns in particular are such a new subject in the context of Fortran that different interpretations by different authors are almost inevitable.
I agree: As they are the obvious means to achieve the isolation one requires in object-oriented programming, we must find ways to translate the concepts of object-oriented programming as found in the literature to Fortran.
This will not always be easy or perhaps even possible without sacrificing some aspect. But let us keep in mind that the various programming languages that are now claimed to be object-oriented use these concepts in different ways too.
I would like to thank Henry Gardner for reviewing the text and for supplying useful comments as well as several references to papers on this same subject. References V. Decyk and H. Dongarra, V. Eijkhout and A. Note that we have changed the dummy parameters from type Circle to class Circle. See Metcalf, Reid, and Cohen , p.
Akin, E. Cambridge University Press. Bader, Reinhold Object-Oriented Features in Fortran Chin, L. Worth and C. Greenough Clerman, Norman S. Modern Fortran: Style and Usage.
Cohen, M. Object orientation and Fortran Decyk, V. Norton, and B. Object Oriented Fortran 90 Programming. Gray, M. Roberts Computers in Physics, 11, — Holcomb, K.