SlideShare a Scribd company logo
1 of 24
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)

More Related Content

What's hot

T03 a basicioprintf
T03 a basicioprintfT03 a basicioprintf
T03 a basicioprintfteach4uin
 
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]vikram mahendra
 
SAP ABAP Interview Questions-XploreSAP Online Trainings
SAP ABAP Interview Questions-XploreSAP Online TrainingsSAP ABAP Interview Questions-XploreSAP Online Trainings
SAP ABAP Interview Questions-XploreSAP Online TrainingsPooja Arani
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’eShikshak
 
Bis 345-final-exam-guide-set-1-new
Bis 345-final-exam-guide-set-1-newBis 345-final-exam-guide-set-1-new
Bis 345-final-exam-guide-set-1-newassignmentcloud85
 
9. pointer, pointer & function
9. pointer, pointer & function9. pointer, pointer & function
9. pointer, pointer & function웅식 전
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C BUBT
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAPsapdocs. info
 
Sap script system_symbol
Sap script system_symbolSap script system_symbol
Sap script system_symbolmoderngladiator
 
C Programming by Süleyman Kondakci
C Programming by Süleyman KondakciC Programming by Süleyman Kondakci
C Programming by Süleyman KondakciSüleyman Kondakci
 

What's hot (19)

T03 a basicioprintf
T03 a basicioprintfT03 a basicioprintf
T03 a basicioprintf
 
Practica dos
Practica dosPractica dos
Practica dos
 
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
 
input
inputinput
input
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
To excel or not?
To excel or not?To excel or not?
To excel or not?
 
C SLIDES PREPARED BY M V B REDDY
C SLIDES PREPARED BY  M V B REDDYC SLIDES PREPARED BY  M V B REDDY
C SLIDES PREPARED BY M V B REDDY
 
SAP ABAP Interview Questions-XploreSAP Online Trainings
SAP ABAP Interview Questions-XploreSAP Online TrainingsSAP ABAP Interview Questions-XploreSAP Online Trainings
SAP ABAP Interview Questions-XploreSAP Online Trainings
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Bis 345-final-exam-guide-set-1-new
Bis 345-final-exam-guide-set-1-newBis 345-final-exam-guide-set-1-new
Bis 345-final-exam-guide-set-1-new
 
C Programming
C ProgrammingC Programming
C Programming
 
Abap
AbapAbap
Abap
 
9. pointer, pointer & function
9. pointer, pointer & function9. pointer, pointer & function
9. pointer, pointer & function
 
A bell curve
A bell curveA bell curve
A bell curve
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
 
Sap script system_symbol
Sap script system_symbolSap script system_symbol
Sap script system_symbol
 
C Programming by Süleyman Kondakci
C Programming by Süleyman KondakciC Programming by Süleyman Kondakci
C Programming by Süleyman Kondakci
 
First c program
First c programFirst c program
First c program
 

Similar to 5 format

programming fortran 77 Slide02
programming fortran 77 Slide02programming fortran 77 Slide02
programming fortran 77 Slide02Ahmed Gamal
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdfSowmyaJyothi3
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshopBAINIDA
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageRai University
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c languageRai University
 
C programming language for beginners
C programming language for beginners C programming language for beginners
C programming language for beginners ShreyaSingh291866
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageRai University
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageRai University
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c languageRai University
 
week4_python.docx
week4_python.docxweek4_python.docx
week4_python.docxRadhe Syam
 
Managing input and output operations in c
Managing input and output operations in cManaging input and output operations in c
Managing input and output operations in cniyamathShariff
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)SURBHI SAROHA
 
Characters formats & strimgs
Characters formats  & strimgsCharacters formats  & strimgs
Characters formats & strimgsWeslley Assis
 

Similar to 5 format (20)

Introduction to Input/Output Functions in C
Introduction to Input/Output Functions in CIntroduction to Input/Output Functions in C
Introduction to Input/Output Functions in C
 
programming fortran 77 Slide02
programming fortran 77 Slide02programming fortran 77 Slide02
programming fortran 77 Slide02
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
 
C Token’s
C Token’sC Token’s
C Token’s
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
Bsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c languageBsc cs i pic u-2 datatypes and variables in c language
Bsc cs i pic u-2 datatypes and variables in c language
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
C programming language for beginners
C programming language for beginners C programming language for beginners
C programming language for beginners
 
CPP Homework help
CPP Homework helpCPP Homework help
CPP Homework help
 
Foxpro (1)
Foxpro (1)Foxpro (1)
Foxpro (1)
 
Btech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c languageBtech i pic u-2 datatypes and variables in c language
Btech i pic u-2 datatypes and variables in c language
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
Mca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c languageMca i pic u-2 datatypes and variables in c language
Mca i pic u-2 datatypes and variables in c language
 
Diploma ii cfpc u-2 datatypes and variables in c language
Diploma ii  cfpc u-2 datatypes and variables in c languageDiploma ii  cfpc u-2 datatypes and variables in c language
Diploma ii cfpc u-2 datatypes and variables in c language
 
week4_python.docx
week4_python.docxweek4_python.docx
week4_python.docx
 
Data Handling
Data Handling Data Handling
Data Handling
 
Managing input and output operations in c
Managing input and output operations in cManaging input and output operations in c
Managing input and output operations in c
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
 
Characters formats & strimgs
Characters formats  & strimgsCharacters formats  & strimgs
Characters formats & strimgs
 
Basic Analysis using Python
Basic Analysis using PythonBasic Analysis using Python
Basic Analysis using Python
 

More from fyjordan9

More from fyjordan9 (17)

17recursion
17recursion17recursion
17recursion
 
16 subroutine
16 subroutine16 subroutine
16 subroutine
 
15 functions
15 functions15 functions
15 functions
 
14 arrays
14 arrays14 arrays
14 arrays
 
13 arrays
13 arrays13 arrays
13 arrays
 
12 doloops
12 doloops12 doloops
12 doloops
 
11 doloops
11 doloops11 doloops
11 doloops
 
10 examples for if statement
10 examples for if statement10 examples for if statement
10 examples for if statement
 
9 case
9 case9 case
9 case
 
8 if
8 if8 if
8 if
 
7 files
7 files7 files
7 files
 
6 read write
6 read write6 read write
6 read write
 
4 design
4 design4 design
4 design
 
3 in out
3 in out3 in out
3 in out
 
2 int real
2 int real2 int real
2 int real
 
1 arithmetic
1 arithmetic1 arithmetic
1 arithmetic
 
PHYS303
PHYS303PHYS303
PHYS303
 

Recently uploaded

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 

Recently uploaded (20)

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 

5 format

  • 2. 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.
  • 3. 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
  • 4. 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.
  • 5.   * 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
  • 6.   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)
  • 7.  1X, I5, F8.2 are format descriptors that specify the format in which the values of number and temperature are to be displayed.
  • 8. 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
  • 9.  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 --
  • 10.  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.
  • 11.  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.
  • 12. 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.
  • 13. 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.
  • 15. 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.
  • 16. 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
  • 17. Ex.  Real:: beta = -567.89 print 20, 123.4 print 20, beta 20 format (1X,F5.2) ***** *****
  • 18. 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.
  • 19. 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.
  • 20. 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.
  • 21. 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
  • 22. 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)’
  • 23. 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.
  • 24.   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)