Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 9 Controling I/O. Today’s program Review of the last quiz Q&A about last weeks topics New topic: I/O formatting.

Similar presentations


Presentation on theme: "Week 9 Controling I/O. Today’s program Review of the last quiz Q&A about last weeks topics New topic: I/O formatting."— Presentation transcript:

1 Week 9 Controling I/O

2 Today’s program Review of the last quiz Q&A about last weeks topics New topic: I/O formatting

3 I/O Keyboard Disk file Magnetic tape etc. Display Printer Disk file Magnetic tape etc. Input Output External mediaComputer’s memory real integer character etc. Convert to internal form Convert to external form

4 User interface of F programs Character-based interface read/print statements List-directed I/O “Intelligent” read read *, a, b, c, d “Reasonable” print print *, x, y, z

5 List-directed read Value separators: –, (comma) –/ (slash) –one or more consecutive blanks –end-of-record/end-of-line Be careful with character data (read the book!)

6 List-directed print It gives you a “reasonable”/readable output But… Not much control over the space between values, digits after the decimal point, etc.

7 I/O editing Keyboard Disk file Magnetic tape etc. Display Printer Disk file Magnetic tape etc. Input Output External mediaComputer’s memory real integer character etc. Convert to internal form Convert to external form

8 Format descriptors Instead of: read *, input_list print *, output_list read ch_expr, input_list print ch_expr, output_list

9 Format descriptors ch_expr is format specifier (ed_des1, ed_des2, …) edit descriptors - character-type data read "(edit_descriptor_list)", input_list print "(edit_descriptor_list)", output_list

10 Edit Descriptors Integer data iw Next w characters are to be read and interpreted as an integer read "(i9)", n read "(i3, i2, i5)", a, b, c

11 Edit Descriptors Tabs tcread at position c tlnn character before trnn character after

12 Edit Descriptors Integer data iw Next w characters are to be read and interpreted as an integer read "(i9)", n read "(i3, i2, i5)", a, b, c

13 Edit Descriptors Real data fw.d If there is a decimal point, read next w characters and interpret it as a real number If there is no decimal point, take d into account ew.d

14 Edit Descriptors Character data aw –w < len –w > len rightmost len characters stored a w = len assumed Logical data Lw t,true,.T,.true.,...

15 Output editing Essentially the same

16 More control... read (clist) input_list write (clist) output_list clistcontrol list keyword = value –unit = unit –fmt = ch_expr –iostat = io_status

17 Homework Homework # 7: Problem 9.11 from Ellis & Philips Deadline April 30. All previous homework [HW#1-6] deadline reset to April 23. Your last chance!


Download ppt "Week 9 Controling I/O. Today’s program Review of the last quiz Q&A about last weeks topics New topic: I/O formatting."

Similar presentations


Ads by Google