Write a description (maximum four sentences) for the below subroutine. Specify what exactly the subroutine does, and what are the input/output arguments of the subroutine. [0.5] subroutine TakeLnEq(A,B) !=====================================================================================================! ! ! ! Write your description here in this box ! ! ! ! ! ! ! !=====================================================================================================! integer:: i,ix,iy,iz,ieq real (kind=8), dimension(3,3), intent(out)::A real (kind=8), dimension(3), intent(out)::B character (len=80):: str character (len=3), dimension(3):: eqn_num eqn_num(1)='1st'; eqn_num(2)='2nd'; eqn_num(3)='3rd' A=0.0; B=0.0 Do i=1,3 print*, 'Enter your ',eqn_num(i),' 3-variable linear equation.' print*, 'NOTE:' print*, '1- use real numbers for the variable coefficients (i.e. 1.0X+0.234Y+158.98Z=22.1),' print*, '2- the left side of the equation must have 3 terms (one term for each variable),' print*, '3- use capital letters for variables, and do not use any comma or space in your entry,' print*, '4- right side of the equation must be a real number only.' read(*,*) str ix=index(str,'X'); iy=index(str,'Y'); iz=index(str,'Z'); ieq=index(str,'=') if (ixiy .and. (ixiz)) read(str(iy+1:ix-1),*) A(i,1) if (ix>iz .and. (ixiy)) read(str(iz+1:ix-1),*) A(i,1) if (iyix .and. (iyiz)) read(str(ix+1:iy-1),*) A(i,2) if (iy>iz .and. (iyix)) read(str(iz+1:iy-1),*) A(i,2) if (iziy .and. (izix)) read(str(iy+1:iz-1),*) A(i,3) if (iz>ix .and. (iziy)) read(str(ix+1:iz-1),*) A(i,3) read(str(ieq+1:len_trim(str)),*) B(i) enddo end subroutine TakeLnEq
Write a description (maximum four sentences) for the below subroutine. Specify what exactly the subroutine does, and what are the input/output arguments of the subroutine. [0.5]
subroutine TakeLnEq(A,B)
!=====================================================================================================!
! !
! Write your description here in this box !
! !
! !
! !
!=====================================================================================================!
integer:: i,ix,iy,iz,ieq
real (kind=8), dimension(3,3), intent(out)::A
real (kind=8), dimension(3), intent(out)::B
character (len=80):: str
character (len=3), dimension(3):: eqn_num
eqn_num(1)='1st'; eqn_num(2)='2nd'; eqn_num(3)='3rd'
A=0.0; B=0.0
Do i=1,3
print*, 'Enter your ',eqn_num(i),' 3-variable linear equation.'
print*, 'NOTE:'
print*, '1- use real numbers for the variable coefficients (i.e. 1.0X+0.234Y+158.98Z=22.1),'
print*, '2- the left side of the equation must have 3 terms (one term for each variable),'
print*, '3- use capital letters for variables, and do not use any comma or space in your entry,'
print*, '4- right side of the equation must be a real number only.'
read(*,*) str
ix=index(str,'X'); iy=index(str,'Y'); iz=index(str,'Z'); ieq=index(str,'=')
if (ix<iy .and. ix<iz) read(str(1:ix-1),*) A(i,1)
if (ix>iy .and. (ix<iz.or.iy>iz)) read(str(iy+1:ix-1),*) A(i,1)
if (ix>iz .and. (ix<iy.or.iz>iy)) read(str(iz+1:ix-1),*) A(i,1)
if (iy<ix .and. iy<iz) read(str(1:iy-1),*) A(i,2)
if (iy>ix .and. (iy<iz.or.ix>iz)) read(str(ix+1:iy-1),*) A(i,2)
if (iy>iz .and. (iy<ix.or.iz>ix)) read(str(iz+1:iy-1),*) A(i,2)
if (iz<iy .and. iz<ix) read(str(1:iz-1),*) A(i,3)
if (iz>iy .and. (iz<ix.or.iy>ix)) read(str(iy+1:iz-1),*) A(i,3)
if (iz>ix .and. (iz<iy.or.ix>iy)) read(str(ix+1:iz-1),*) A(i,3)
read(str(ieq+1:len_trim(str)),*) B(i)
enddo
end subroutine TakeLnEq
Trending now
This is a popular solution!
Step by step
Solved in 2 steps