# INTRODUCTION TO FORTRAN COMPILER, Lahey Fortran 95 Pro 55 Ch05 by waheedanjum

VIEWS: 11 PAGES: 5

• pg 1
```									                                         EASTERN MEDITERRANEAN UNIVERSITY
Department of Mechanical Engineering

CMPE 106 Fundamentals of Computing
1979

CHAPTER 5

INTRODUCTION TO FORTRAN 95 Pro 5.5

PRELIMINARY INFORMATION

Problem solution procedure with fortran program:

State the problem

Select method for solution

Draw a flow chart for the solution

Write a computer program

Compile the program and correct the
errors

Run the program and get
the results

SERKAN ABBASOGLU                                        CMPE 106 Chapter 5 Page…1/5
Flow chart symbols

Algorithms will be prepared with flow charts, which are going to be drawn with below given
symbols:

To start/end the program

To input data/output result

For calculations

For decision

For subroutines

For directions

For connections

For repetitions

SERKAN ABBASOGLU                                        CMPE 106 Chapter 5 Page…2/5
Fortran has five intrinsic data types. For each there is a corresponding form of literal
constant.

INTEGER

1 0 -999 32767 +10

for the default kind; but we may also define, for instance for a desired range of -10**4 to
+10**4.

REAL

1.5 0.25 -999.75 32767.564 +10.50

There are at least two real kinds - the default, and one with greater precision (this replaces
DOUBLE PRECISION). We might specify

for at least 9 decimal digits of precision and a range of 10*(-99) to 10**99, allowing

CHARACTER
'A string' "Another" 'A "quote"' ''
(the last being a null string). Other kinds are allowed, especially for support of non-European
languages:
2_' '
and again the kind value is given by the KIND function:
KIND('ASCII')

COMPLEX

LOGICAL

SERKAN ABBASOGLU                                            CMPE 106 Chapter 5 Page…3/5
Variable Names:

The term variable in computer terminology always means memory element. The main
nondestructive read-out.That is, if you store information in a memory cell, then the original
(previous) content of the cell will be destroyed; but, if you copy information out of (from)
memory cell, then the (original) content in the cell will remain unchanged.

If a memory location is used to store an integer constant, it is called an integer variable, if it
is used to store real constant, it is called a real variable, and if it is used to store character
constant, it is called a character variable.

In general, a variable name is denoted by 1 to 6 alphanumeric characters (except special
symbols), of which the first character must be an alphabetic character. However, Fortran
95 compilers available today accept more than six characters for variable names.

Fortran programming language uses the following implicit rule for variable names:

   If the first character is one of the six letters I, J, K, L, M, and N, then it is an integer
variable name,
   If the first character is one of the other letters, that is, one of A, ….., H, O, P, ……..Z,
then it is a real variable name.

Sometimes it is not desirable to follow the above, implicit rule for writing variables. To
override this implicit rule, Fortran provides several explicit type declaration statements.

A Fortran statement beginning with the word REAL and followed by a list of variables
separated by commas declares these variables to be REAL. A Fortran statement beginning
with the word INTEGER and followed by a list of variables separated by commas declares
these variables to be INTEGER. A Fortran statement beginning with the word
CHARACTER and followed by a list of variables separated by commas declares these
variables to be CHARACTER.

Examples:

INTEGER A, B, SUM, TIME
REAL NUMBER, MIN, MAX
CHARACTER (LEN=) NAMES,PLACES

SERKAN ABBASOGLU                                            CMPE 106 Chapter 5 Page…4/5
EXPERIMENTAL WORK

1) Draw a flowchart and calculate the average of A,B, and C inputs and write it as below;

No= (A+B+C)/3

Calculate result as below also;

Av=(A+B+C)/3

Is the results No and Av different when you give same numbers to A, B, C ?

2) Draw a flowchart and write a program that will calculate the time needed to fill a pool.
If we have 3 different water input to pool: I1 (m3/h), I2 (m3/h) and I3(m3/h) and the
volume of the pool is H x L x D (m3).Input values of I1,I2,I3 and H,L,D at the
beginning of program and give total time as below :

I_tot = I1+I2+I3
Vol= H x L x D
Tot_time = Vol/I_tot

Calculate the time as below also;

I_time = Vol/I_tot

Is the results Tot_time and I_time different when you calculate same numbers for I_tot
and Vol ?

SERKAN ABBASOGLU                                        CMPE 106 Chapter 5 Page…5/5

```
To top