Write a Fortran program that asks the user for the name of a data file. It then
ID: 657952 • Letter: W
Question
Write a Fortran program that asks the user for the name of a data file.
It then opens the file and reads the first line which will be the dimensions of the first two dimensional array to be read. it then dynamically allocates the matrix. it then reads the matrix one row per line. it then prints out the array row by row. it then repeats these steps for the second matrix. if the matrices can be added it will add them and print out the resulting matrix to the screen. if the matrices cannot be added it will see if they can be multiplied. if the matrices can be multiplied it will multipy them and display the resulting matrix. if it also cannot be multiplied, it will display a message saying these matrices cannot be either added or multiplied.
Explanation / Answer
real, allocatable, dimension(:,:) :: ra1,ra2,ra3
integer
print*, 'shows array manipulation using SQUARE arrays.'
print*, 'Allocate the space for the array at run time.'
print*, 'Enter a size of the your array'
read*, size
allocate(ral(size,size),ra2)(size,size),ra3(size,size))
print*, 'enter the matrix elements for the ral row by row'
call fill_array(size,ral)
print*, 'enter the matrix elements for the ra2 row by row'
call fill_array(size,ra2)
print*, 'ral'
call outputra(size,ra1)
print*,'ra2'
call outputra(size,ra2)
ra3=matul(ra1,ra2)
print*,'matual of the ra1 and ra2'
call outputra(size,ra3)
ra3=transpose(ra1)
print*,'transpose of the ra1'
call outputra(size,ra3)
deallocate(ra1,ra2,ra3)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.