open (12,file='temp.log', position='APPEND')
How do we get started on the Subroutine for file input on HW8?
Best place to start is the subroutine that determines the array space required for information in the "temp.data". In that routine open the file and include a counting loop like the one in array3a.f , including the final REWIND of the unit attached to "temp.data". Exit the subroutine, allocate the space in the main program, then call a subroutine that does a simple read of the contents of "temp.data", putting the contents of each column into a different array.
Actually everything you need to know about reading the input for this homework is tucked away in array3a.f. The "DO 30 " loop demonstrates the type of READ that you will need to use to load your arrays for processing. I would consider allocating 3 arrays: one for time, say "time" (watch the times at the end of the file, you may want to write code to convert the 00.xxxx stuff following the 23.99961 entry to 24.xxxx ); one array for station number, say "nstation"; and one array to hold the centigrade temperature, say "tc" (you may also want an array to hold the equivalent Fahrenheit temperatures when they are generated). At this point assuming "temp.data" is attached to unit 11, the equivalent loop for your homework should look like:
How do I use MASK to get information for HW8?
One simple example is this. Suppose the INTEGER variable "istat" contains the number of the station for which want information. To obtain the minimum temperature (say "tmin") at that station (using arrays that I defined in the previous question), use the following simple line:
Take a look at the "1000" FORMAT in format.f . Titles involve, making a decision on exactly where you want them in the line, then constructing a FORMAT with the appropriate mix of spacing (X edit descriptors), and quoted strings. I could put this title anywhere, just by changing the unit number on the WRITE statement.
I saw "WRITE(6,2000) in sample programs. Doesn't the '6' have to be opened?
This is very old (and bad) habit on my part. The long tradition in Fortran is that Unit 6 is the default output device (same as using *). Best to just use the *.
What makes the difference when you use different descriptors like i, f, e, p? Could you explain some of these examples like 1p, e9.3, 3x,?
"i" only works if the variable to be output in that position is an INTEGER. "i5" says output an integer in the line allowing 5 spaces to do the job. If the integer is only 2 digits, the first 3 of the 5 spaces are blanks, and the last 2 contain numbers.
"f" only works if the variable is REAL, and puts out a simple decimal number like 1.1, 2.123, etc.
"e" only works if the variable is REAL, and puts out a number in exponential notation like 0.1234e+01, 0.999e-01, etc.
"p" is for use only if you get tired of the leading zero in "e" format. If the variable x contains 1.23400000, then the write:
Spend some time running format.f and looking at how each combination of WRITE and FORMAT statement produces results on the screen.
Tuesday March 26, 8:15 PM, Same room as last time (64 Willard).
Can we have some extra time on HW8?
Yes, now due Monday, March 18