Weeks 6-8 Questions


General Programming Practices, Fortran Language, Fortran Compiler, Unix, General Computing, Numerical Methods, Class Procedures


General Programming Practices

Fortran Language

Fortran Compiler

Unix

.

General Computing

I'm assuming there is a way to save my programs to disk. How? And what's the easiest way to copy all of the files on one disk onto another, for use as a back-up disk?

Sit down at a PC with the CAC Internet Access package. Put a floppy in the A drive, and double click the FTP icon. In an open area to the upper left you should see "[-a-]". Double click it, and you should here the A Drive working, and see a list of any files already on your floppy. Next click the connect button. Fill in the table, using "h27.ptph.psu.edu" as the Host Name, ignoring the Account box, and typing in "homework" in the remote host initial directory box. Leave the Local PC initial directory box empty. It may ask for your password again, then grind a little and display a list of files in your homework directory to the right. You can hold the left mouse button down and drag over all the file names to select them all, or hold the Cntrl key while you left click each file name that you want. Since you are just moving Fortran programs, click the button that says "ASCII", then click the arrow pointing from the Hammond machine file list to the PC floppy file list. Click exit when it is done or change the directory on Hammond and move some more.

How do you save portions of a program and then insert them into another program at a later time?

If there are portions that you want to save rather than the whole program, usually the portions are entire functions or subroutines. I create a file with the name of the subroutine (or function), say sub1.f, then using two text editor windows copy the lines from the full program file and paste them into the smaller file. Later, I can a use cut and paste again to put the code into a new program. However, I have several other options. If the portion is a full subprogram, I would never copy it into the file containing a new program. Suppose that the new program is in a file "prog.f", and it needs to call the subroutine stored in my file "sub1.f", then I would put both files in the same directory and compile with the line:

f77 prog.f sub1.f

If I have a segment of code in a file (say "seg.h"), I can use the Fortran INCLUDE statement to include the contents of "seg.h" in the program at compile time. For example let "seg.h" contain the lines:

      x = y +1
      z= y**2
then the program:

      program test
      y =3
      include 'seg.h'
      print *, x,y,z
      end
is the same as

      program test
      y =3
             x = y +1
      z= y**2    
      print *, x,y,z
      end

Numerical Methods

Class Procedures

What chapters in the text will the second exam cover?

Remember, that I never look at the text when constructing test questions. It is just meant to provide you with more examples and discussion that I give in the Web notes. That said, the Chapters that were assigned were 6,9,10,12,13,14, and 17.

Back to other 1997 Questions and Answers / Home


Maintained by John Mahaffy : jhm@psu.edu