SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
CIVIL HTI
Fortran 77
Series Lectures
Dr. A.M.K. Shaltout
2016
Example 1.
Example 2.
 Write a Fortran program to convert the length
in feet to centimeter. (Recall that lcm=lft x 30)
0.75
1.25
1.5
1.75
2.25
Usually an expression like
"x**y" results in the
compiler inserting code
equivalent to
"exp(y*log(x))".
𝑥
Math
|x|
sin x
cos x
tan x
𝑒 𝑥
ln x
log x
Input and Output Statements
 Basic instructions:
 READ – reads input from a standard input device or a specified device
or file.
 WRITE – writes data to a standard output device (screen) or to a
specified device or file.
 FORMAT – defines the input or output format.
READ Statement
 Format controlled READ:
 Syntax: READ(dev_no, format_label) variable_list
 Read a record from dev_no using format_label and assign results to
variables in variable_list
 Ex: READ(5,1000) A,B,C
1000 FORMAT(3F12.4)
 Device numbers 1-7 are defined as standard I/O devices and 1 is the
keyboard, but 5 is also commonly taken as the keyboard (used to be
card reader)
 Each READ reads one or more lines of data and any remaining data in
a line that is read is dropped if not translated to one of the variables in
the variable_list.
 Variable_list can include implied DO such as:
READ(5,1000)(A(I),I=1,10)
READ Statement – cont’d
 List-directed READ
 Syntax: READ*, variable_list
 Read enough variables from the standard input device (usually a
keyboard) to satisfy variable_list
– input items can be integer, real or character.
– characters must be enclosed in ‘ ‘.
– input items are separated by commas.
– input items must agree in type with variables in variable_list.
– as many records (lines) will be read as needed to fill variable_list and any
not used in the current line are dropped.
– each READ processes a new record (line).
 Ex: READ*,A,B,K – read line and look for floating point values for
A and B and an integer for K.
 Some compilers support:
 Syntax: READ(dev_num, *) variable_list
 Behaves just like above.
WRITE Statement
 Format controlled WRITE
 Syntax: WRITE(dev_no, format_label) variable_list
 Write variables in variable_list to output dev_no using format
specified in format statement with format_label
 Ex: WRITE(6,1000) A,B,KEY
1000 FORMAT(F12.4,E14.5,I6)
 Device number 6 is commonly the printer but can also be the screen
(standard screen is 2)
 Each WRITE produces one or more output lines as needed to write out
variable_list using format statement.
 Variable_list can include implied DO such as:
WRITE(6,2000)(A(I),I=1,10)
Output:
|----+----o----+----o----+----o----+----|
1234.5678 -0.12345E+02 12
WRITE Statement – cont’d
 List directed WRITE
 Syntax: PRINT*, variable_list
 Write variables in variable_list to standard output device using format
appropriate to variable type. Variables are separated by either spaces
or commas, depending on system used.
 Ex: PRINT*,‘X=‘,X,’Y=‘,Y,’N=‘,N
Output:
X= 4.56, Y= 15.62, N= 4
Format Specifiers
 X format code
 Syntax: nX
 Specifies n spaces to be included at this point
 I format code
 Syntax: Iw
 Specifies format for an integer using a field width of w spaces. If
integer value exceeds this space, output will consist of ****
 F format code
 Syntax: Fw.d
 Specifies format for a REAL number using a field width of w spaces
and printing d digits to the right of the decimal point.
 A format code
 Syntax: A or Aw
 Specifies format for a CHARACTER using a field width equal to the
number of characters, or using exactly w spaces (padded with blanks
to the right if characters are less than w.
Format Specifiers – cont’d
 E format code
 Syntax: Ew.d
 Print value of REAL variable using “scientific notation” with a mantissa
of d digits and a total field width of w.
 Ex:
E14.5 produces for the REAL value -1.23456789e+4:
 You must leave room for sign, leading 0,decimal point, E, sign, and 2
digits for exponent (typically at least 7 spaces)
 If specified width is too small, mantissa precision, d, will be reduced
unless d<1 in which case *** will be output.
 Using nP prefix will shift mantissa digit right by n and reduce exponent
by –n. Ex; 1PE14.5 above yields:
|----+----o----+----o----+----o----+----|
-0.12345E+05
|----+----o----+----o----+----o----+----|
-1.23456E+04
Other FORMAT Features – cont’d
 When the end of the format_specifiers in a FORMAT statement are
reached before all of the variables in the variable_list have been output,
the format_specifiers are re-scanned starting at the first left parenthesis,
(.
 Many other format specifiers are available but are not included in these
notes. These include formats for Binary, Octal and Hexidecimal data,
formats for Double Precision numbers (replace E with D), and formats for
Complex numbers.
 When formatted READ is used, any decimal point in data will override
format specifier. If no decimal is supplied, format specifier will determine
where decimal should be (even though it is not in input data)
|----+----o----+----o----+----o----+----|
Data: 123456 1.23456
READ(5,1000) A,B
1000 FORMAT(2F8.2)
Result: A=1234.56, B=1.23456
OPEN Statement
 OPEN is used to make file available to READ & WRITE
 Syntax: OPEN ([UNIT=]io_unit [,FILE=name])
 Ex:
OPEN (12,FILE=‘D:AEtest.dat’)
Opens file D:AEtest.dat for sequential read&write (default)
and specifies device number 12 for access.
 Ex:
OPEN (14,FILE=‘D:test1.dat’)
programming fortran 77 Slide02
programming fortran 77 Slide02
programming fortran 77 Slide02
programming fortran 77 Slide02

Contenu connexe

Tendances

The uncertainty principle
The uncertainty principleThe uncertainty principle
The uncertainty principle
farman53
 
Sequences and series
Sequences and seriesSequences and series
Sequences and series
mstf mstf
 
Signals and systems with matlab applications orchard publications
Signals and systems with matlab applications   orchard publicationsSignals and systems with matlab applications   orchard publications
Signals and systems with matlab applications orchard publications
Muhammad Salah
 

Tendances (20)

Frequency distribution
Frequency distributionFrequency distribution
Frequency distribution
 
Fermi Gas Model
Fermi Gas ModelFermi Gas Model
Fermi Gas Model
 
B.Sc.SemVI Unit i
B.Sc.SemVI Unit iB.Sc.SemVI Unit i
B.Sc.SemVI Unit i
 
Computational physics
Computational physicsComputational physics
Computational physics
 
Fermi Surface and its importance in Semiconductor
Fermi Surface and its importance in SemiconductorFermi Surface and its importance in Semiconductor
Fermi Surface and its importance in Semiconductor
 
The uncertainty principle
The uncertainty principleThe uncertainty principle
The uncertainty principle
 
STRUCTURE OF SODIUM D LINE
STRUCTURE OF SODIUM D  LINESTRUCTURE OF SODIUM D  LINE
STRUCTURE OF SODIUM D LINE
 
Sequences and series
Sequences and seriesSequences and series
Sequences and series
 
The Variational Method
The Variational MethodThe Variational Method
The Variational Method
 
Rank of Matrix_Normal Form .pptx
Rank of Matrix_Normal Form .pptxRank of Matrix_Normal Form .pptx
Rank of Matrix_Normal Form .pptx
 
COMPUTATIONAL CHEMISTRY
COMPUTATIONAL CHEMISTRY COMPUTATIONAL CHEMISTRY
COMPUTATIONAL CHEMISTRY
 
Pauli's Exclusion Principle.pptx
Pauli's Exclusion Principle.pptxPauli's Exclusion Principle.pptx
Pauli's Exclusion Principle.pptx
 
Mcq quantum statistics
Mcq quantum statisticsMcq quantum statistics
Mcq quantum statistics
 
Signals and systems with matlab applications orchard publications
Signals and systems with matlab applications   orchard publicationsSignals and systems with matlab applications   orchard publications
Signals and systems with matlab applications orchard publications
 
Schrödinger wave equation
Schrödinger wave equationSchrödinger wave equation
Schrödinger wave equation
 
NANO266 - Lecture 2 - The Hartree-Fock Approach
NANO266 - Lecture 2 - The Hartree-Fock ApproachNANO266 - Lecture 2 - The Hartree-Fock Approach
NANO266 - Lecture 2 - The Hartree-Fock Approach
 
Callen Solutions
Callen SolutionsCallen Solutions
Callen Solutions
 
Stirling's approximation &amp; microstate and configuration
Stirling's  approximation &amp; microstate and configurationStirling's  approximation &amp; microstate and configuration
Stirling's approximation &amp; microstate and configuration
 
Particle in 3D box
Particle in 3D boxParticle in 3D box
Particle in 3D box
 
Gradient of scalar field.pptx
Gradient of scalar field.pptxGradient of scalar field.pptx
Gradient of scalar field.pptx
 

Similaire à programming fortran 77 Slide02

Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly Language
Ahmed M. Abed
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
wingsrai
 
Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01
tabish
 
chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01
tabish
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
tabish
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)
bolovv
 

Similaire à programming fortran 77 Slide02 (20)

2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
programming fortran 77 Slide01
programming fortran 77 Slide01programming fortran 77 Slide01
programming fortran 77 Slide01
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
 
C++
C++C++
C++
 
sonam Kumari python.ppt
sonam Kumari python.pptsonam Kumari python.ppt
sonam Kumari python.ppt
 
The Easytrieve Presention by Srinimf
The Easytrieve Presention by SrinimfThe Easytrieve Presention by Srinimf
The Easytrieve Presention by Srinimf
 
Wk1to4
Wk1to4Wk1to4
Wk1to4
 
Managing I/O in c++
Managing I/O in c++Managing I/O in c++
Managing I/O in c++
 
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
 
Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly Language
 
1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx
 
7986-lect 7.pdf
7986-lect 7.pdf7986-lect 7.pdf
7986-lect 7.pdf
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overview
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
 
Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01
 
chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01
 
Chapter 1 Abap Programming Overview
Chapter 1 Abap Programming OverviewChapter 1 Abap Programming Overview
Chapter 1 Abap Programming Overview
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
 
Python basics
Python basicsPython basics
Python basics
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)
 

Plus de Ahmed Gamal

Plus de Ahmed Gamal (20)

Graduation book - BFRP
Graduation book - BFRPGraduation book - BFRP
Graduation book - BFRP
 
hti traininig 2018
hti traininig 2018hti traininig 2018
hti traininig 2018
 
Resource management
Resource managementResource management
Resource management
 
Pert2 management
Pert2 managementPert2 management
Pert2 management
 
Pert management
Pert management Pert management
Pert management
 
Lob management
Lob managementLob management
Lob management
 
Lec 2 construction management
Lec 2 construction managementLec 2 construction management
Lec 2 construction management
 
Earned value management
Earned value managementEarned value management
Earned value management
 
Crash management
Crash managementCrash management
Crash management
 
Cm ch4 scheduling
Cm ch4 schedulingCm ch4 scheduling
Cm ch4 scheduling
 
Cash flow
Cash flowCash flow
Cash flow
 
1- construction management
1-  construction management1-  construction management
1- construction management
 
تدريب 2 التجمع الخامس و نادي مدينتي
تدريب 2 التجمع الخامس و نادي مدينتيتدريب 2 التجمع الخامس و نادي مدينتي
تدريب 2 التجمع الخامس و نادي مدينتي
 
01 introduction and layout of steel (1)
01 introduction and layout of steel (1)01 introduction and layout of steel (1)
01 introduction and layout of steel (1)
 
الامن الصناعي
الامن الصناعيالامن الصناعي
الامن الصناعي
 
7 fatigue
7  fatigue7  fatigue
7 fatigue
 
5 hardness
5  hardness5  hardness
5 hardness
 
4 static shear
4  static shear4  static shear
4 static shear
 
3 bending test
3  bending test3  bending test
3 bending test
 
2 compression
2  compression2  compression
2 compression
 

Dernier

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 

programming fortran 77 Slide02

  • 1. CIVIL HTI Fortran 77 Series Lectures Dr. A.M.K. Shaltout 2016
  • 3.
  • 4.
  • 5. Example 2.  Write a Fortran program to convert the length in feet to centimeter. (Recall that lcm=lft x 30)
  • 6.
  • 7.
  • 9.
  • 10. Usually an expression like "x**y" results in the compiler inserting code equivalent to "exp(y*log(x))".
  • 11. 𝑥 Math |x| sin x cos x tan x 𝑒 𝑥 ln x log x
  • 12. Input and Output Statements  Basic instructions:  READ – reads input from a standard input device or a specified device or file.  WRITE – writes data to a standard output device (screen) or to a specified device or file.  FORMAT – defines the input or output format.
  • 13.
  • 14. READ Statement  Format controlled READ:  Syntax: READ(dev_no, format_label) variable_list  Read a record from dev_no using format_label and assign results to variables in variable_list  Ex: READ(5,1000) A,B,C 1000 FORMAT(3F12.4)  Device numbers 1-7 are defined as standard I/O devices and 1 is the keyboard, but 5 is also commonly taken as the keyboard (used to be card reader)  Each READ reads one or more lines of data and any remaining data in a line that is read is dropped if not translated to one of the variables in the variable_list.  Variable_list can include implied DO such as: READ(5,1000)(A(I),I=1,10)
  • 15. READ Statement – cont’d  List-directed READ  Syntax: READ*, variable_list  Read enough variables from the standard input device (usually a keyboard) to satisfy variable_list – input items can be integer, real or character. – characters must be enclosed in ‘ ‘. – input items are separated by commas. – input items must agree in type with variables in variable_list. – as many records (lines) will be read as needed to fill variable_list and any not used in the current line are dropped. – each READ processes a new record (line).  Ex: READ*,A,B,K – read line and look for floating point values for A and B and an integer for K.  Some compilers support:  Syntax: READ(dev_num, *) variable_list  Behaves just like above.
  • 16. WRITE Statement  Format controlled WRITE  Syntax: WRITE(dev_no, format_label) variable_list  Write variables in variable_list to output dev_no using format specified in format statement with format_label  Ex: WRITE(6,1000) A,B,KEY 1000 FORMAT(F12.4,E14.5,I6)  Device number 6 is commonly the printer but can also be the screen (standard screen is 2)  Each WRITE produces one or more output lines as needed to write out variable_list using format statement.  Variable_list can include implied DO such as: WRITE(6,2000)(A(I),I=1,10) Output: |----+----o----+----o----+----o----+----| 1234.5678 -0.12345E+02 12
  • 17. WRITE Statement – cont’d  List directed WRITE  Syntax: PRINT*, variable_list  Write variables in variable_list to standard output device using format appropriate to variable type. Variables are separated by either spaces or commas, depending on system used.  Ex: PRINT*,‘X=‘,X,’Y=‘,Y,’N=‘,N Output: X= 4.56, Y= 15.62, N= 4
  • 18. Format Specifiers  X format code  Syntax: nX  Specifies n spaces to be included at this point  I format code  Syntax: Iw  Specifies format for an integer using a field width of w spaces. If integer value exceeds this space, output will consist of ****  F format code  Syntax: Fw.d  Specifies format for a REAL number using a field width of w spaces and printing d digits to the right of the decimal point.  A format code  Syntax: A or Aw  Specifies format for a CHARACTER using a field width equal to the number of characters, or using exactly w spaces (padded with blanks to the right if characters are less than w.
  • 19. Format Specifiers – cont’d  E format code  Syntax: Ew.d  Print value of REAL variable using “scientific notation” with a mantissa of d digits and a total field width of w.  Ex: E14.5 produces for the REAL value -1.23456789e+4:  You must leave room for sign, leading 0,decimal point, E, sign, and 2 digits for exponent (typically at least 7 spaces)  If specified width is too small, mantissa precision, d, will be reduced unless d<1 in which case *** will be output.  Using nP prefix will shift mantissa digit right by n and reduce exponent by –n. Ex; 1PE14.5 above yields: |----+----o----+----o----+----o----+----| -0.12345E+05 |----+----o----+----o----+----o----+----| -1.23456E+04
  • 20. Other FORMAT Features – cont’d  When the end of the format_specifiers in a FORMAT statement are reached before all of the variables in the variable_list have been output, the format_specifiers are re-scanned starting at the first left parenthesis, (.  Many other format specifiers are available but are not included in these notes. These include formats for Binary, Octal and Hexidecimal data, formats for Double Precision numbers (replace E with D), and formats for Complex numbers.  When formatted READ is used, any decimal point in data will override format specifier. If no decimal is supplied, format specifier will determine where decimal should be (even though it is not in input data) |----+----o----+----o----+----o----+----| Data: 123456 1.23456 READ(5,1000) A,B 1000 FORMAT(2F8.2) Result: A=1234.56, B=1.23456
  • 21. OPEN Statement  OPEN is used to make file available to READ & WRITE  Syntax: OPEN ([UNIT=]io_unit [,FILE=name])  Ex: OPEN (12,FILE=‘D:AEtest.dat’) Opens file D:AEtest.dat for sequential read&write (default) and specifies device number 12 for access.  Ex: OPEN (14,FILE=‘D:test1.dat’)