02.05.2014 Views

Patrick Corde & Anne Fouilloux

Patrick Corde & Anne Fouilloux

Patrick Corde & Anne Fouilloux

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Les itérations 75<br />

Exemple<br />

Sommation de la série P n≥1 1/n2 jusqu’à ce que le<br />

terme général soit inférieur à ɛ fois la somme partielle<br />

courante :<br />

PROGRAM iteration_while<br />

INTEGER<br />

DOUBLE PRECISION<br />

DOUBLE PRECISION, PARAMETER<br />

LOGICAL<br />

:: n<br />

:: somme<br />

:: epsilon = 1.d-3<br />

:: fini<br />

! Initialisation<br />

n=0<br />

somme=0.d0<br />

fini=.FALSE.<br />

DO WHILE (.not. fini)<br />

n=n+1<br />

somme=somme + 1d0/n**2<br />

fini=(1d0/n**2 .LT. epsilon*somme)<br />

END DO<br />

print *,"Nombre d’itérations : ", n<br />

print *,"Somme = ", somme<br />

END PROGRAM iteration_while<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!