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

could you combine those two subroutines please ------------------------- module

ID: 3743086 • Letter: C

Question

could you combine those two subroutines please

-------------------------

module evalFunction

contains

subroutine evalRHS(fH,P,Ar,D,g,f,L,H)

implicit none

real(8)::fH

real(8)::P,Ar,D,g,f,L

real(8)::H

real(8),parameter::Pi=3.14159

fH=P/Ar-Pi*D**2/(4*Ar)*sqrt(2*g*D/(F*L)*H)

end subroutine evalRHS

subroutine euler(fH,P,Ar,D,g,f,L,H0,dt,Tf,n)

implicit none

real(8)::H,Hold,Tf,fH,P,Ar,D,g,f,L,H0,dt,t

integer::i,n

open(44,file="diagnostics.txt")

write(41,*) "ema2 midterm euler test1"

open(41,file="results.txt")

write(41,*) "itime t_beg H_beg fH_beg H_end"

t=dt

H=H0

i=0

do i=1,n

Hold=H

call evalRHS(fH,P,Ar,D,g,f,L,H)

H=H+fH*dt

write(41,'(8X,I4,5X,F11.5,3X,F10.5,3X,F11.6,2X,F10.5)')i,t-dt,Hold,fH,H

t=t+dt

if(t>TF)then

write(44,*)"ALGORITHM_OK"

exit

end if

end do

close (41)

close (44)

end subroutine euler

end module

--------------------------------------------------------

Explanation / Answer

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
call subroutine Module_evalFunction
call subroutine Euler
Exit Sub
End if

module evalFunction

contains

subroutine evalRHS(fH,P,Ar,D,g,f,L,H)

implicit none

real(8)::fH

real(8)::P,Ar,D,g,f,L

real(8)::H

real(8),parameter::Pi=3.14159

fH=P/Ar-Pi*D**2/(4*Ar)*sqrt(2*g*D/(F*L)*H)

end subroutine evalRHS

subroutine euler(fH,P,Ar,D,g,f,L,H0,dt,Tf,n)

implicit none

real(8)::H,Hold,Tf,fH,P,Ar,D,g,f,L,H0,dt,t

integer::i,n

open(44,file="diagnostics.txt")

write(41,*) "ema2 midterm euler test1"

open(41,file="results.txt")

write(41,*) "itime t_beg H_beg fH_beg H_end"

t=dt

H=H0

i=0

do i=1,n

Hold=H

call evalRHS(fH,P,Ar,D,g,f,L,H)

H=H+fH*dt

write(41,'(8X,I4,5X,F11.5,3X,F10.5,3X,F11.6,2X,F10.5)')i,t-dt,Hold,fH,H

t=t+dt

if(t>TF)then

write(44,*)"ALGORITHM_OK"

exit

end if

end do

close (41)

close (44)

end subroutine euler

end subroutine_evalFunction

end Sub Worksheet_Change