Sorry for the confusion. At its root, a pointer contains an integer giving the address in memory of some variable. However, the pointer variable carries with it a type definition telling what type variables it can point to. In Fortran you never see the underlying memory address stored with the pointer. The pointer can have any data type, including real, integer, logical, character, complex, and derived types. It can only point to targets with the same data type.

**Target is the original variable and pointer is the variable that is set equivalent to the
target (e.g. px=>x) right?**

Yes.

**Why can't you assign a pointer to an individual space in an array?**

You can if the pointer is not an array itself. For example

real, target :: a(100) real, pointer :: aptr aptr => a(50)will work just fine. The pointer variable "aptr" is equivalent to element 50 of array "a".

**Can pointers be placed anywhere in a program?**

Pointer assignments ( pa => a) are "executable" statements and can be placed anywhere that other executable statements may be placed, providing proper target and pointer declarations have been made in the preceding non-executable statement block. Once assigned, the pointer variable can be used anywhere that a normal variable would be used in executable statements. Three places that pointer variables can never be used are DATA, NAMELIST (we skipped that one), and EQUIVALENCE statements.

**What are some more functions of pointers? I'm a little unclear as to what they can do
and what they are used for.**

I'm at a loss to give you a clean example in science and engineering, without giving you a couple semesters worth of applications involving solution of partial differential equations. It boils down to a question of how you have to arrange data for modeling complex physical systems. I've talked frequently about simulating the flow of air in our classroom, but what if I wanted a program that could model the flow of air in the whole building, in fact in any building. The grid of points that I would lay down to evaluate air properties at points in the building would be very complex, and in a good program, generated at the time input specified the geometry of the building. In practice, solving the problem for the entire building is best accomplished by looking at the solution in each room and then accounting for air flows between the rooms. You have a full set of the grid points for the building, with subsets representing individual rooms. Pointers do a nice job of picking up subsets of points for each room to do the local solution steps.

If you want a computer science example, take a look at section 20.7 p. 537 in your textbook, where the author works with a linked list. Linked lists are very important in the computer science world, but have limited application when creating models of physical systems.

**Are pointers used in C++? If so, do they function the same as in C or Fortran?**

Standard C is a contained in C++ just as Fortran 77 is contained in Fortran 90, so you automatically have C pointers. C++ adds a data type called the "Reference Type", that is like a Fortran pointer.

**Can MODULEs be put at the end of the main routine. Where do they go?**

Think of them as another program unit like a SUBROUTINE, FUNCTION, or BLOCK DATA. Put them after the main program if you like, or put them after any subroutine or function. Doesn't matter.

**When you use optimization options on the compiler is there any way to tell what part of
the code the optimization has altered?**

I have seen one or two compilers polite enough to provide messages on significant restructures of your program. Generally you can assume that there are small changes almost everywhere, but to tell the difference you need to know the assembly language for your machine. This compiler and most others will print assembly language (person readable machine language) for the compilation results.

At times I'm in the business of simulating the behavior of Nuclear Power Plants during various accidents. To do this I have to solve time dependent partial differential equations. I'm doing something a lot like the Implicit Euler solution, but it is applied to a coupled system of 6 partial differential equations typically evaluated at 2000-4000 points in the reactor. Think of it as solving a system of 20,000 coupled equations for 20,000 unknowns, at each step in time. As you can imagine, this takes quite a bit of computer time. I might run the program a full day on a computer to see the results of 1000 seconds of the actual accident. So what happens if near the end of the day's computing, the computer develops problems and my program is killed? Not much if I do a restart dump.

I build into my program a subroutine with the job of watching the elapsed time since the job started or since the last restart dump occurred. How long I wait depends on how much of the calculation, I'm willing to redo. Typically I will give it an hour. When the subroutine sees that this time has passed, it calls another set of subroutines that dump the entire state of my system to the end of a disk file. This includes all of the pressures, temperatures, and other necessary fluid and metal properties stored in my blank common (its an old code), and many other variables stored in named commons giving status of valves, numbers of spatial points, and other such information. Unless the hard disk is destroyed, I can recover the state of my calculation later, and continue without re-evaluating too many solution time steps.

In addition to the above wall clock test for restart dumps, I also include tests on "simulation time" (sum of all my time steps in the Euler integration), and some special dumps based on events that I know could cause stability or convergence (of the Newton iteration) problems that would degrade my solution. When I review the results of a calculation, I may see that the numerical solution has silly behavior (usually oscillations associated with numerical instability) beyond some time. I just restart from the last dump before the troubles and calculate that interval with a smaller time step.

Know Crank-Nicholson, Forward (Explicit) and Backward (Implicit) Euler completely, including how to use it, how their errors depend on step size, and stability behavior of each. Be able to recognize the names Runge-Kutta, Adams-Bashford, and Adams-Moulton, and associate them with errors that are formally proportional to the integration step size to the fourth power (Fourth Order methods) . Also note that these higher order methods will develop instabilities at a sufficiently high time step size (you don't have to know what "sufficiently high" is).

**What percentage of the final will be new material?**

40-50%

**What do you think is the best way to prepare for it? **

Start with the review outlines. That is where I look to generate questions. Check the Web notes and examples when you don't understand a given item. I do not look at the textbook to generate the exam. You should use it in studying only to the point that it clarifies something that I have said.

**You post everything else on the class homepage. Why not the grade listings?**

I was told that is a violation of University privacy guidelines. With the right additional data another computer programmer could pick up the listing and determine exactly who did what in the class.

Systems involving more than one equation and one unknown, there is no clean way to obtain approximations to the partial derivatives needed in the iteration, based only on past function values obtained during the iteration. Say that I have values for four iterations as follows

x y f(x,y) g(x,y) ------------------------------- 1.1 2.0 2.2 5.2 .9 2.2 2.0 5.7 .7 2.4 1.7 6.5 .6 2.5 1.5 6.6Because x and y are changing simultaneously from one iteration to the next, it is very difficult (but not impossible) to construct numerical approximations to the partial derivatives (e.g. derivative of f with respect to x while y is constant) .

**What form of numerical integration do you think is the most reliable?**

For a definite integral of a known function, the trapezoidal method is the most reliable. You don't get unintended kinks from a straight line. For integration of an ODE, the Implicit Euler is the most reliable. In either case you need to watch the integration step size to be sure that you maintain accuracy that you can accept, and will need more steps than some other methods.

**What is the difference between Newton's method and the Secant method**.

Look at the Postscript file on the subject. The bottom line is that where a first derivative is needed, the Newton method uses a value obtained from an analytic (standard calculus) evaluation of the derivative, but the Secant method uses a finite difference approximation to the derivative.

**What is the general name for the method of solving ODE's that has an error proportional to the
time step size to the fourth power?**

This group of methods is called "Fourth Order Methods".