Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

use FORTRAN functions to do the partial calculations for the sums AND read the d

ID: 644653 • Letter: U

Question

use FORTRAN functions to do the partial calculations for the sums
AND read the data from the data le named data.dat according to the following speci cations using
functions f1 and f2:
(1) internal function f1 nds the correct value to sum for devices "A", "B", and "C"
(2) external function f2 nds the correct value to sum for devices "D" and "E"
A partial FORTRAN 90 program to accomplish the goals of this problem follows:
!lab 3(b) solution by <STUDENT NAME>
program lab3_b
implicit none
character ::code
integer::ic
integer :: InputStatus,OpenStatus
real :: sumA=0.0,sumB=0.0,sumC=0.0,sumD=0.0,sumE=0.0
real v1,v2,val
integer :: low,high
print *, "lab 3(b) solution by <STUDENT NAME>"
OPEN (UNIT = 15
IF (OpenStatus > 0) STOP "*** Cannot open the file ***"
do
read(15,"(
if( )exit
if(InputStatus >0)stop "***Input Error***"
write(*,"(
select case (code)
case('A')
low=20; high=70
val=f1(ic,low,high,v1,v2)
sumA=sumA+val
case ('B')
low=30; high=60
val=
sumB=sumB+val
case ('C')
low=50; high = 90
val=
sumC=sumC+val
case ('D')
low=50
val=f2(ic,low,v1,v2)
sumD=sumD+val
case ('E')
low=30
val=
sumE=sumE+val
print *, "sumA=",sumA
print *, "sumB=",sumB
print *, "sumC=",sumC
print *, "sumD=",sumD
print *, "sumE=",sumE
contains
function f1(ic,l,h,m1,m2)
end function f1
end program lab3_b
function f2(ic,l,m1,m2)
end function f2
Starting with the above partial code, complete the solution to this problem. DO NOT USE ANY
VARIABLES BEYOND THOSE DECLARED. ADD TO, BUT DO NOT ALTER THE PARTIAL
CODE PROVIDED EXCEPT TO FILL IN YOUR INDIVIDUAL NAME IN THE PARTS BE-
TWEEN THE ANGLE BRACKETS.
Provide test results for the data le:
B352.7842 4.125
E872.2169 1.552
B233.0701-18.632
C430.2527 -8.303
E823.9633-10.777
D702.7719 4.000
E944.0838 19.593
D683.4771-10.273
A123.1718 -6.549
A172.1525 15.136
E821.1579-14.504
B384.3084 15.267
A152.1735 -3.410
E863.7962 -4.978
B252.3949 18.347
D742.8008-15.528

Explanation / Answer

function f1(ic,l,h,m1,m2)

m1=l+h

return m1


end function f1

function f2(ic,l,m1,m2)

m1=l+m2

return m1
end function f2

end program lab3_b