02.05.2014 Views

Patrick Corde & Anne Fouilloux

Patrick Corde & Anne Fouilloux

Patrick Corde & Anne Fouilloux

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Corrigés 245<br />

Corrigé de l’exercice 11<br />

1 program tri_matrice<br />

2 implicit none<br />

3 integer, parameter :: n=10, m=3<br />

4 real, dimension(n,m) :: mat<br />

5 integer :: ios<br />

6 integer :: i, j<br />

7 ! Lecture de la matrice à trier.<br />

8 open( unit=1, &<br />

9 file="exo6.matrice", &<br />

10 form="unformatted", &<br />

11 status="old", &<br />

12 action="read", &<br />

13 position="rewind", &<br />

14 iostat=ios )<br />

15 if ( ios /= 0 ) stop "Erreur à l’ouverture du fichier &<br />

16 &""exo6.matrice"""<br />

17 read( unit=1 ) mat; close( unit=1 )<br />

18 call tri( mat, n, m ) ! Tri de la matrice lue.<br />

19 ! Écriture de la matrice triée.<br />

20 open( unit=1, file="exo11.matrice_triee", &<br />

21 form="formatted", status="replace", &<br />

22 action="write", position="rewind", &<br />

23 iostat=ios )<br />

24 if ( ios /= 0 ) stop "Erreur à l’ouverture du fichier &<br />

25 &""exo11.matrice_triee"""<br />

26 do i=1,n<br />

27 write( unit=1, fmt=’(3F7.3)’ ) mat(i,:)<br />

28 end do<br />

29 close( unit=1 )<br />

30 end program tri_matrice<br />

INSTITUT DU DÉVELOPPEMENT<br />

ET DES RESSOURCES<br />

EN INFORMATIQUE SCIENTIFIQUE<br />

Cours langage Fortran – 27 janvier 2006<br />

<strong>Patrick</strong> <strong>Corde</strong> et <strong>Anne</strong> <strong>Fouilloux</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!