advertisement

5 format

63 %
37 %
advertisement
Information about 5 format
Education

Published on March 9, 2014

Author: fyjordan9

Source: slideshare.net

advertisement

Basic Scientific Programming Format

Input/Output  There are two types of input/output statements in Fortran:   List directed: format of input or output is automatically supplied by the compiler. Programmer-Formatted: format of input or output is supplied by the programmer.

Formatted Output   There are two output statements in Fortran, the print statement and the write statement. Print: print format specifier, output-list  Write: write (control_list), output-list

Format Specifier  Format specifier is one of the following:    * (an asterisk) A character constant or a character variable whose value specifies the form of the output. The label of a FORMAT statement.

  * indicates a list directed output. As for the character constant or variable, the formatting information is given the form: ‘(list of format descriptors)’ or “(list of format descriptors)” Ex: print ‘(1X, I5, F8.2)’, Number,Temperature

  The formatting information may be supplied by a format statement whose statement number is specified. form label format(list of formal descriptors) where label is an integer in the range 1 through 99999. Ex: print 20, Number,temperature 20 format(1X, I5,F8.2)

 1X, I5, F8.2 are format descriptors that specify the format in which the values of number and temperature are to be displayed.

Control Characters  Some compilers use the first character of each line of output to control vertical spacing. Control Character Effect . blank Normal spacing, advances to the next line before printing 0 Double spacing, skip one line before printing 1 Advance to top of next page before printing + Overprint the last line printed

 Print ‘(I3)’, N I3 indicates that the value to be printed is an integer, and is to be printed on the first three positions of a line. In N=15 the three position are filled with b15. So it will be interpreted as normal spacing and print on the first 2 positions of the next line 15 --

 If N=150 the first three positions will be 150. The 1 in the first position is removed and interpreted as a control character. So it will print 50 at the top of the new page.

 To avoid confusion, we can explicitly indicate for each output line what printer control is desired. 1X or “ “ normal spacing “0” for double spacing “1” for advancing to a new page “+” for overprinting. Note: in all of the following examples, 1X will be used at the beginning of each output format specifier.

Integer Output (I Descriptor)  rIw or rIw.m I: denotes integer data. w: integer constant indicating the width of the field in which the data is to be displayed. r: integer constant. Repetition indicator. m: minimum number of digits to be displayed.

Ex:  Integer:: number=3, L=5378,k=-12345 print ’(1X,2I5,I7,I10)’,number,number-3,L,kappa Or print 30, number,number-3, L, kappa 30 format (1X,2I5,I7,I10) _____3____0___5378____-12345 numbers will be right justified.

Ex:  Print ’(1X,2I5.2,I7,I10.7)’,number,number-3,L,kappa ____03___00___5378__-0012345 Print ’(1X,2I5.0,I7,I10)’,number,number-3,L,kappa _____3________5378____-12345 Print ’(1X,4I3)’,number,number-3,L,kappa ____3__0******

Real Output  rFw.d F: denotes real (floating point) data. w: integer constant indicating the total width of the field in which the data is to be displayed. d: integer constant indicating the number of digits to the right of the decimal point r: integer constant. Repetition indicator.

Ex:  Integer:: in=625, out = -19 real:: a= 7.5, b=0.182, c=625.327 print 55, in,out,a,b,c 55 format (1X,2I4,2f6.3,f8.3) __625_-19_7.500_0.182_625.327

Ex.  Real:: beta = -567.89 print 20, 123.4 print 20, beta 20 format (1X,F5.2) ***** *****

Real Output  rEw.d or rEw.dEe E: indicates that the data is to be output in exponential notation. w: integer constant indicating the total width of the field in which the data is to be displayed. d: integer constant indicating the number of digits to the right of the decimal point r: integer constant. Repetition indicator. e: number of positions for displaying the exponent.

Character Output  Character constants may be displayed by including them in the list of descriptors of a format specifier. Real:: a = 0.3, b = 7.9 print ’(1X,”a=“,F6.2,” b=“,F6.2)’,a,b _a=__0.30_b=__7.90 print ’(1X,A,F6.2,A,F6.2)’,”a=“,a,” b=“,b will produce the same output.

Positional Descriptors (X and T)  Two format descriptors can be used to provide spacing in an output line: X: inserts blanks on an output line form nX where n is the # of blanks T: similar to the tab key form Tc where c is an integer denoting the number of a space on a line at which a field is to begin.

Ex:  Print 75, “John Q. Doe”, “CPSC”,105 75 format(1X,A11,3X,A4,2X,I3) or 75 format(1X,A11,3X,T16,A4,2X,I3) _John Q. Doe___CPSC__105

Repeating groups of format descriptors    3F10.2 is eqv. to F10.2,F10.2,F10.2 ‘(1X,A,F6.2,A,F6.2)’ is eqv to ‘(1X,2(A, F6.2))’ ‘(1X,F18.2,I3,A,I3,A, F18.2,I3,A,I3,A,F8.4)’ ‘(1X,2(F18.2,2(I3,A,)),F8.4)’

The slash (/) descriptor   The slash causes the output to begin on a new line. It can be used with a repetition indicator to skip several lines.

  Print 85, “name” print 85,”--------” print* print* print 85, first_name 85 format(1X,A) Print 85, “name”,”--------”,first_name 85 format (1X,A,/1X,A,2/ 1X,A)

Add a comment

Related presentations

Related pages

DIN - Formate A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 in mm und ...

DIN-Formate Reihe A in mm, Pixel und qm Das DIN-Format A0 mit der Größe von 84,1 x 118,9 cm entspricht einem qm im Seitenverhältnis von ca. 5:7.
Read more

Papierformat – Wikipedia

August 1922 in der DIN-Norm DIN 476 festgelegten Formate. ... definiert aber eine leicht andere B-Serie: JIS B0 hat eine Fläche von 1,5 m², ...
Read more

DIN-Formate - Zentrum für Datenverarbeitung (ZDV)

DIN-Format Maße in mm Maße in Inch Bemerkung; DIN A0 Oversize ... 16.5 x 23.3 DIN A3 297 x 420 ...
Read more

Formatwandler 5 kaufen ‹ Versionsübersicht ...

Formatwandler 5 Pro Sie suchen einen Alles-Konverter für Ihre Mediensammlung? Dann empfehlen wir Formatwandler 5 Pro für Musik und Video. Konvertiert ...
Read more

FORMAT Badmöbel Set 5 - FORMAT

FORMAT Badmöbel Set 5 "Never change a winning team." Das haben wir uns auch gedacht und diese fünf fix und fertigen Badmöbelsets zusammengestellt, die ...
Read more

Seitenverhältnis – Wikipedia

Bei Negativen, Dias und Papierbildern kommt meist das 3:2-Format (Negativgröße: 36 × 24 mm, Kleinbildformat; aber auch 60 × 90 mm, ... 5 : 3 – Findet ...
Read more

Druckloser 5-Liter-Kleinspeicher FUN 5 - FORMAT

Druckloser 5-Liter-Kleinspeicher FUN 5. Mit den geringen Abmessungen das ideale Gerät bei geringem Platzbedarf. FORMAT FUN 5 ist überall dort die ...
Read more

Format 4

Format-4 Holzbearbeitungsmaschinen der Premiumklasse für Handwerk, Gewerbe und Industrie. Design, Präzision und Bedienkomfort bei exklusivster ...
Read more

Briefumschläge - C5 Format - Danksagungskarten ...

Erneuert sich meine Mitgliedschaft automatisch? Ja, Ihre Mitgliedschaft verlängert sich jedes Jahr automatisch. Sie können im Premium-Mitgliederbereich ...
Read more

RAR 5.0 archive format - WinRAR archiver, a powerful tool ...

RAR 5.0 archive format. Here we describe basic data structures of archive format introduced in RAR 5.0. If you need information about algorithms or more ...
Read more