Skip to main content

READIN.F95

	PROGRAM READIN
!
!  Purpose: To read in the elements of a 2 by 3 integer matrix
!  Modified as described on page 3 of the notes, so as to illustrate
!  the use of implied DO loops.
!
	IMPLICIT NONE
	INTEGER:: M2BY3(2,3)	! Matrix to be input
	INTEGER:: I,J		! DO loop variables
!
	DO I=1,2
	  DO J=1,3
	    WRITE(*,10,ADVANCE='NO')I,J
	    READ(*,*)M2BY3(I,J)
	  END DO
	END DO
   10	FORMAT('Enter matrix row ',I1,' and column ',I1,' : ')
!
!  Now, use an implied DO-loop to display the matrix on the screen.
	WRITE(*,20)((M2BY3(I,J),J=1,3),I=1,2)
   20	FORMAT(3I6)
!
	STOP
	END PROGRAM READIN