-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnewtest.f
52 lines (36 loc) · 1.45 KB
/
newtest.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
C Lines that begin with C or an asterisk in column 1
C are treated as comments and ignored by compiler.
C Fortran 77 source code is fixed form and all caps.
C Column 7 is where source code lines are located.
C Main procedure is a PROGRAM and is named.
PROGRAM NEWTEST
C Declare A and B as double precision
C numeric variables, 15 digits.
DOUBLE PRECISION A, B
C Write to device #6(standard output for gfortran).
C Statement labelled 201 defines content to write.
WRITE (6, 201)
201 FORMAT ('PLEASE ENTER A NUMBER: ')
C Read from device #5(standard input for
C gfortran) into A; asterisk indicates that
C input can be any acceptable numeric format.
READ (5,*) A
C Call double precision function (starts with a D)
C for double precision variables.
B = DSQRT(A)
C Output result to standard output.
C The 2F15.5 is a format notation meaning
C to use the following pattern on every two
C variables the WRITE statement must output,
C use floating point notation, reserve
C 15 columns for outputting each variable
C value, and show five significant figures
C after the decimal point. Try something different,
C like 2F20.15 or 2E20.15 to see the advantage of
C using double precision variables.
WRITE (6, 202) A, B
202 FORMAT ('THE SQUARE ROOT OF A IS B', 2F15.5)
C Stop program execution.
STOP
C End of source code.
END