



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Instructions: Answer Question 1 and two others Examiners: Ms. J.English Prof. M. Gilchrist Mr. P. Clarke
What output is produced from the following Fortran90 program given the following input values 4, 7, 3, 12? NOTE: Trace your working so that partial credit may be given for incomplete or incorrect work.
PROGRAM s2007_q1a implicit none !----------------------------------------------------------- integer::O_Gara do write(, '(a)', advance = 'no') 'gimmee an integer --->' read, O_Gara if ((O_Gara < 0) .or. (O_Gara > 10) )exit if((O_Gara == 2) .or. (O_Gara > 3))then print, '…O_Callaghan’ else if(O_Gara /= 1)then print, '…ODriscoll' else print, '…O_Connell' end if if(O_Gara == 4)then print, ‘Horgan...' else if(O_Gara == 3)then print*, ‘Stringer...' end if end do !----------------------------------------------------------- stop 's2007_q1a has now ended …' END PROGRAM s2007_q1a
What is the output of the following Fortran90 program? NOTE: Trace your working so that partial credit may be given for incomplete or incorrect work.
What is the output of the following Fortran90 program? NOTE: Trace your working so that partial credit may be given for incomplete or incorrect work.
PROGRAM s2007_q1b
implicit none
integer :: m,n,p
p = 7
do m = 1,p, do n = m,p, 1 if((m == 1).or.(m == p).or.(n == m).or.(n == p)) then write(,'(i1)',advance = 'no') n else write(,'(a)',advance = 'no') '+' end if end do print * end do !------------------------------------------------------------------- stop 'q1_b.f90 ends ...'
END PROGRAM s2007_q1b
PROGRAM s2007_q1c implicit none !------------------------------------------------------------------- integer::a, b, c c = 7 do a = 1, c, 1 do b = 1, c, 1 if( (a == 1) .or. (a == c) .or. (b == 1) .or. (b == c) )then write(, 14, advance='no')a else if(a == b)then write(, 12, advance='no')'' else if(a + b == c + 1)then write(, 12, advance='no')'#' else write(, 14, advance='no')b end if end do print end do print* print* 12 format(a) 14 format(i1) !------------------------------------------------------------------- stop'q1_c ends ...' END PROGRAM s2007_q1c
The data for an important experiment are stored in the file inputData.txt. The data is raw (without any explanatory text or headings) and each line contains the following data: x , y as shown in fig. 2.1 below. We use x and y to preserve confidentiality.
Please write a Fortran90 program to connect to the file, to read the data and to transfer them to the new file myResults.dat in tabular form as shown in fig 2.2 and append below the table details of the least-square line( or the regression line) and the correlation coefficient as shown in fig 2.
The relevant formulae also included.
For data
the least-squares line y = a+bx is given by:
1 1 1
2
1 1 1
1 1
n n n
k k k k k k k n n n
k k k k k k
n n
k k k k
= = =
= = =
= =
and the correlation coefficient is given by:
1 1 1 2 2 2 2
1 1 1 1
n n n
k k k k k k k
n n n n
k k k k k k k k
− = = =
= = = =
Write a Fortran90 (^) function module for the Fortran90 function FUNCTION f(x)
y = f ( ) x = x^3 − 4 x + 2
Write a Fortran90 subroutine module to implement the Secant Method Root Finding Algorithm,
Note:
1 1 1
i i i i i i i
−
−