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.

Arguments de type chaîne de caractères 159<br />

Dans l’exemple ci-dessous les fonctions ICHAR/ACHAR<br />

permettent de mettre en relation un caractère et son<br />

rang dans la table des caractères ASCII.<br />

Exemple<br />

program arg_chaine<br />

implicit none<br />

character(len=10) :: ch<br />

read ’(a)’,ch<br />

call conv( ch )<br />

print *,ch<br />

end program arg_chaine<br />

subroutine conv( chaine )<br />

implicit none<br />

character(len=*) :: chaine<br />

integer i, j<br />

do i=1,len(chaine)<br />

if( ichar( chaine(i:i) ) < 97 .or. &<br />

ichar( chaine(i:i) ) > 122 ) cycle<br />

j = ichar( chaine(i:i) ) - 32<br />

chaine(i:i) = achar( j )<br />

end do<br />

end subroutine conv<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!