program salva_diretto implicit none integer i, j, k, lunrec, n integer mat(5,10) real number do i = 1, 10 do j = 1, 5 mat(j,i) = (j-1)*10 + i enddo enddo lunrec=10*4 OPEN(UNIT = 11, FILE = 'salva.dun', RECL = lunrec, ACCESS='direct', FORM = 'UNFORMATTED', STATUS="REPLACE") do j = 1, 5 WRITE(11,REC=j,IOSTAT=n) (mat(j,i),i=1,10) if (n.NE.0) then print*,' Errore scrittura record ',j end if enddo CLOSE(UNIT = 11) ! Si azzera la matrice per sicurezza mat(:,:) = 0 OPEN(UNIT = 22, FILE = 'salva.dun', RECL = lunrec, ACCESS='direct', FORM = 'UNFORMATTED', STATUS="OLD") do j = 1, 5 READ(22,REC=(6-j),IOSTAT=n) (mat(j,i),i=1,10) if (n.NE.0) then print*,' Errore lettura record ',j end if enddo CLOSE(UNIT = 22) do j = 1, 5 write(*,100) (mat(j,i),i=1,10) enddo 100 format(1x,10(i6.2)) stop end