FORTRAN 90

```FORTRAN 90
Lecturer : Rafel Hekmat Hameed
University of Babylon
Subject : Fortran 90
College of Engineering
Year : Second B.Sc.
Mechanical Engineering Dep.
EXAMPLE 4
Write a program that reads the names of five students, reading extents for
the four materials and find the average for each student and the number of lessons
in which each student failed.
program student
implicit none
integer, dimension (1:5,1:4):: degree
character (len=10)::name(5)
integer::I,j,k
real:: sum , av
data degree/45,80,56,32,50,67,32,50,56,50,54,87,54,70,40,33,56,89,36,56/
do i=1,5
k=0 ; sum=0 ;
do j=1,4
if (degree(i,j)&lt;50) then
k=k+1
endif
sum=sum+degree(I,j)
enddo
av=sum/4.0
if (k .gt. 0) then
write(*,70) name(i),k
ϭ
70 format ( 2x,a,1x,'fail in',3x,i3)
Else
Write(*,60) name(i) , av
60 format(2x,a,1x,'aveage=',f6.3)
Endif
Enddo
End
EXAMPLE 5
Write a program to find sum of elements of minor diagonal of array b its
shape (/3,3/) , and find the summation of elements upper and lower this diagonal.
each section of this example solved it in individual subroutine.
Program diagonal
Implicit none
Integer,parameter::n=3
Integer, dimension(n,n)::b
Integer::I, j, sum, sumu, suml
Call sum_diagonal (b,sum)
print*,sum
Call sum_upper (b,sumu)
Print*,sumu
Call sum_lower (b,suml)
Print*,suml
End
Subroutine sum_diagonal (b,sum)
Implicit none
integer,parameter::n=3
Integer,dimension (n,n)::b
Ϯ
Integer::I,j,sum
Do i=1,n
Do j=1,n
If(i+j .eq. n+1) sum=sum+b(I,j)
Enddo ; enddo
End
subroutine sum_upper (b,sumu)
Implicit none
integer,parameter::n=3
Integer,dimension (n,n)::b
Integer::I,j,sumu
Do i=1,n
Do j=1,n
If (i+j .lt. n+1) sumu=sumu+b(I,j)
Enddo ; enddo
End
subroutine sum_lower (b,suml)
Implicit none
integer,parameter::n=3
Integer,dimension (n,n)::b
Integer::I,j,suml
Do i=1,n
Do j=1,n
If (i+j .gt. n+1) suml=suml+b(I,j)
Enddo ; enddo
End
ϯ
EXAMPLE 6
Write a program to rotate matrix a(/4,4/) about minor diagonal, use format
statement to print your output result.
Program minor
Implicit none
Integer, parameter:: n=4
Integer, dimension (n,n):: a,z
Integer::I,j