INTRODUCTION AU LANGAGE FORTRAN

Transcription

INTRODUCTION AU LANGAGE FORTRAN
! " ! # $ % &" '
())) !" *&+,-$ &+ -+% &!
•
•
•
&& .
c
o
o
•
•
*
!
!
!
"
#
&
!
%
!
#
$
$
%
)
"
$
'(
&
''
*/ 01!+
/&-&"" /& /
,
$ !*
program &
&
!-
(
.
end
program nom
...
end
!
!!$&
subroutine
!
end
subroutine nom (arguments)
...
end
.
!*
function
!
end
type function nom (arguments)
...
end
&
'' &
&
/
0
- ,(
(
,
1
!
%
0,
,
&
/2
3
4
%
,(
(
0
,
56 678
,
/
,
/
/
&
&
(
)&
/
/
.
,
,
/
3
/
/
/
8
9
$
(0
$
3
!
(
3
/
:
'
#
6
!
*
0
!"
(
"!+
0
,
:
&
!#
!
2
#
/
/
)
/
,
/
!
;
<1!. $!. 1 =
.
2
!
/
/
&
1 ! A A !@
@/
B
>&&
?"
/
&
&
2
&
"
!!
;
!. /
.
0>
3 '/ ! $
,
%
*
!"
"! /
!
$
/
(
&
1 C!. A A C!;
/
&
-'''
<
@
" >&&
&
2
7
% 4
5
/
!
'
E
%
2
!
D
/2
-
(
/
3
#
$ . ;$ !4. 0
F
.
'(
1
123
-28
0
%
3
•
$
•
!
D
/
, ,
3
>&&
e
#
&
0.xxxxx$
/
0
'(
0.
1.0
1.
3.1415
31415e-4
1.6e-19
1e12
.001
-36.
%
%
*
D
&
!"
$ e
/
d
'(
0d0
0.d0
1.d0
1d0
3.1415d0
31415d-4
1.6d-19
1d12
-36.d0
%
% 4
5
3
/
(
! "4 ,
"!+
/
>
! "$
'(
(0.,0.)
(1.,-1.)
(1.34e-7, 4.89e-8)
)'.
'
&
-
,
,
3 /
;
'
D
1
&
&&
&
"
2
5
parameter(const1=valeur1,const2=valeur2, ...)
3
>
D
3
/
(
&;.
D
2
/
&
5 4
double
/
0
precision
q
parameter(max=1000, q=1.6d-19)
.
/
&
$
/
•
•
•
•
3 /
&
7
,
/$ &
&
3
0,
1 &
'
&
D
/
$
$
9
/
, /
&
0& $
6& 1 &1 '
56 678$
/
3
(
/
/
•
•
/
0,
/
3
-$
#
&
?
&
&
3
/
common
/ $
>
C%
0
.
8
1
7
'
program
subroutine
function
(
2
/
5
type var1, var2, var3, .....
5
/
D
3
D
,
"
5 4
integer
i,j,k
real
alpha,
beta
double
precision
x,y
complex z
'
•
0
.
#
0
/ $ &
o
o
o
o
•
•
•
$
>&& $
*/
+
*G+ *
D
! !9/&" &! & :&!! !- *
6
&&
)&
$
+ *
+
*! epsilon1
2
epsilon2
D
/
'&
5
/ &
$
/
3 integer
i,j,k,l,m,n
/
a
H
h
o
3 real
z
% ; IMPLICIT
'
&
&
"
:&
/
&
implicit type (lettre1-lettre2, lettre3, ....)
/
&
H
!
.
3
0
D
2
program
subroutine
function
5 4
implicit real (a-c,e,w-z)
real
a,b,c,e,w,x,y,z
implicit double precision (a-h,o-z)
)
double precision
i,j,k,l,m,n
&
&:!
integer$
!1<
<
implicit complex (z)
I
complex
&
implicit none
1
! %
!
!
!! %
" * !
2234
5
%
"
1 &1!
%
2
,
,
0
/
/
,
(
/
.
5
nomvar = constante
Ex : x=1.23
nomvar = autre variable Ex : x=y
nomvar = opération
%
•
•
•
Ex : x=y+3.2*z
4
=
/
'&&
7&&
/
>
=
5 4
i = i + 1
/ i
7
6
&
* &1"
'
&
7'
9
5
-
6
>
7
+
)
-
J
*
9
/
#
**
"
(
>
$
,/
**
1 (
/$
*$
>
5 4
x=a+b/c-d
x=(a+b)/(c+d)
0
/
-
!
/
7 '
&+
)&
&
(
>
3
,
&&
& +
-
,
3
& /
3
,
! ,
&&
$
3
3
&
•
•
•
•
•
3
"!+
* !"
!
#
!# !
,
&
& /
5 4
b**2
4*a*c
)a
b
3
3
c
!$
&
a
b*
!"
a*c
$
%
b**2-4*a*c
$
&&
*
!"
/
$ ,?
$
7
2/3
3
#
C#
7
&&
&&
i/j ?i
-
c
0
(
j
(
/
$
2./3$ 2/3.
$
#
2./3.
real(i)/j
K
)&
,
3
3
&&
/
&&
,(
$
(
/
5 4
i=1.3456 &&
# i
/
7
x=2/3 &&
!x
/
'
7 '
-
&
56 678
&-" !
0
&
>
D &
$ DSIN
-
,
•
•
CCLLL
,
/
/
, 3
&
3
,
/
&
0>
&
, 1 1
&
/
#
(
$ CSIN
= &! & / & >:!!
)
1
M
/
pi=4d0*datan(1d0)
6$
".
5
(
, D
!
3
SIN
z=(a*sin(x)+b*cos(y)) / (a*sinh(x)+b*cosh(y))
&
>
"!
&
5 4
#
,
& C;
&
,(
$
@
!
*
!
"!+
"
)-8
9)-8
0)-8
! '
05)
905)
005)
!'
78
9 78
-'
7)-8
97)-8
&! '
705)
9705)
& !'
7 78
97 78
& -'
)-8N
9)-8N
!>'
5: C
9 5: C
5:
9 5:
0 5:
'
'O#
9'O#
0'O#
'/ '
)E6
9)E6
!
#
-C '
6(
&
*
!
!
"
"!+
J7OC
7J7O
9J7O
" ' '$?
J-8C
7J-8
9J-8
" '$?
-7P)
7P)
97P)
-8
7-8
9-8
J59
7J59
9J59
07P)
Q'Q
Q@Q
#
6
0
0
&
3
"
&
(
&&
&
#
6
, 3
, 3
3
3
,/
R
0
&
•
,
,
,
•
'
&
0
,
&&
$
&
D
$ ,
& (
&
,
/
&
S
>&&
M &
&&
(
&&
>
$
, 1 1
D
&
>
$
,
/
>
(
$
&
,
D
5 4
1.+1e-8
1d0+1d-16
9
9
#
C
/
(
(>/
$
>
C
$
8 '
,
C
&
>
D
>
$
L
9
(
B
>M
9
>
$
3
7
'
+
'(
>
*
'Ceci
est
une
chaîne'
'/home/louisnar'
'L''apostrophe doit être doublé'
0
.
7
)3 (
character*n var
?
>M
0
3
B
'(
character*15
nom
character*100 nomfichier
5
&&
/
,
=
/
C
nomfichier='/usr/local/public/louisnar/th.mai'
nom='Louisnard'
> M 'Louisnard'
/
)
&&
,(
0
&&
%
$ 3
R
/
$
>M
nom
%
"
>M
7
3
%A
LEN(chaine)
chaîne
$ len(nom)
,(
>M
&
%A
"
%A
%A
INDEX(chaine1, chaine2)
chaine1
#
/ nom
RL
"
(
2
> M chaine2
>
$ index(nom,'nar')
,(
%
%A
chaine(m:n)
chaine m
1 >M
n
D
/
%
%
( >M
/
/
'
56 678$
//
#
(
'Bon'//'jour'
>M
'Bonjour'
2
,(
nom //'est mon nom'
>M
'Louisnard
:
•
•
•
•
•
•
•
est
mon
nom'
;
5
,
*
,
#
#
•
•
•
5
,(
$
>
$
T
&1!+ & !+$
$ ,
$
& >
56 678
,
$
& > $
>M
$
$
& >
>M
,
write
read
,
U
&&
>
0T
$
U
E
&
& >
0,
>M
(
&
0,
U
& >
/
<
'
2
5
write(unité d'écriture, formatage) liste de données
•
•
, 1 31& &
#
,
&
! !B * &"
56 678
*
$
- (
&
&
*
&
5 4
write(*,*) i,j,x,y
i,j,x,y
/
$
/
write(*,*) 'z vaut',z
> M *z vaut +$
"
/ z
write
,
write
9
,&& >
%
'
&
$ >
&
&
,
,
4
•
9 (
9
•
9
write
,
>M
write(*,'format') liste
* /
+
format
,
nn format(définition du format)
write(*,nn)
0
,
D
write
&
4
9
•
•
&
in
$
), 3 /
)
&& $
'(
$ ,
,&& >
,
>
2
/
>
i=11
j=20312
write(*,'(i6,i6)') i,j
V
,
format
10
format(i6,i6)
i=11
,
!
j=20312
write(*,10) i,j
•
•
4
;
9
&
" >&&
$
en.m
&
), 3 /
)
&& $
#
'(
,&& >
&
&$ ,
$ ,
>
2
/
&
>
>
$ &
x=-1456.2
y=1.6e-19
write(*,'(e14.5,e14.5)') x,y
&& >
4
%A
9
)
•
•
&
)
5
$
& $
,
an
& $
>M
$
>M
$
2
5 4
,&& >
>M
2
/
>
/
L
a
4
45
i=36
px=-1456.2
write(*,'(a,i4,a,e12.5)')
& 'i vaut', i, ' et x vaut', x
&& >
i vaut 36 et x vaut -0.14562E+04
%
%
&
*
&
D
&&
,
$! "
$
1 !! & 9
&
'
•
•
&
7
7 (& >
,
(
%
5
•
•
&
> 6'
&
,
68
$
$
& >
D
(
D
/
&
.
2
5
read(unité de lecture, formatage) liste de variables
•
•
,
&
#
* &"
! !B
*
$
write
%
,
/ *
>M
&
&
+ "
/
$
&
/
&
>M a
5 4
real
a,b,c
...
read(*,*) a,b,c
,
6'
b
R
,&
5
68
/
&
&
#
a$
$!
>
$% C1
c$ ,
.!
1.2 1.6e-19 32
(
,
,
D
write(*,'(a,$)') 'Entrez x :'
read(*,*) x
&& > $
6'
,
(
68
=
% 9
>M
0&
$
W
,
&
,(
D
,
3
&
#
/
%
'(
2
#
,
&
$
(
5
(
,
-B
if (condition logique) then
...
...
endif
5
&
,
(
-B
if (condition logique) then
...
...
else
...
...
endif
5
D
>M
if
(condition
logique
1)
then
&
;
...
...
else if (condition logique 2) then
...
...
else if (condition logique 3) then
...
...
else
...
...
endif
(
/
,
endif )
9&
,
$
/
else
(
-
0
-
3 logical
(
/2
.true.
.false.
(
,
'
>
'
/
56 678
' 7
x.eq.y
*
x.ne.y
*
+
'Y?
x.gt.y
*
> +
'A?
x.lt.y
*
x.ge.y
*
x.le.y
*
' X?
5
( /2
+
> +
+
+
(
5
.or.
'
.and.
5
(
.xor.
&
.not.
8
5 4
#
&
*5 +
O
2
o
$
N
,
n
"
character
...
write(*,'(a,$)')
& 'Répondez par
read(*,a)
rep
(o)ui
ou
(n)on
if
(rep.eq.'0'.or.rep.eq.'o')
write(*,*)
'Vous
répondîtes
...
else if (rep.eq.'N'.or.rep.eq.'n')
write(*,*)
'Vous
répondîtes
...
else
write(*,*)
&
'Vous répondîtes
...
endif
#
n''importe
:'
rep
then
oui'
then
non'
quoi'
,
double precision a,b,c,delta,x1,x2
...
delta=b**2-4*a*c
x1=(-b-dsqrt(delta))/2/a
x2=(-b+dsqrt(delta))/2/a
if
(delta.gt.0d0)
write(*,*)
then
x1,x2
else
if
(delta.eq.0d0)
write(*,*)
else
write(*,*)
endif
;
5
•
•
de
racines'
LOGICAL
/
.true.
(
&
$
3
&&
.false.$
,
0
#
'Pas
then
x1
(
/
,
double precision a,b,c,delta,x1,x2
logical
une_racine
logical
deux_racines
...
delta=b**2-4*a*c
une_racine=(delta.eq.0d0)
deux_racines=(delta.gt.0d0)
if
(deux_racines)
x1=(-b-dsqrt(delta))/2/a
x2=(-b+dsqrt(delta))/2/a
write(*,*)
else
if
(une_racine)
x1=-b/2/a
then
x1,x2
then
%
write(*,*)
else
write(*,*)
endif
x1
'Pas
de
racines'
.
%
/
,(
/
•
•
,
/
&
,&&
$
/
&&
>
,
DO
%
5
,
D
ENDDO
/
/
&
+
do var = deb, fin
...
...
enddo
do var = deb, fin, pas
...
...
enddo
/
3 integer
$$ *
/
/ 0&
,/
$
/
, D
,(
enddo
,
/ !
D
&
) * A $ / !YC$ /
, 2
(
) * Y $ / !AC$ /
, 2
(
0&
Y* $
+
/ !
/! >
"!
)
/
2
,
... ! affectation de n
somme=0
do
i=1,n
somme=somme+i
enddo
/
... ! affectation de n
somme=0
do
i=n,1,-1
somme=somme+i
enddo
)
/
&
/2
3
/
integer
9
0&
... ! affectation de n
somme=0
do
i=1,n,2
somme=somme+i
enddo
DO
%
5
&&
>
WHILE
/
,
&
+
do while (condition logique)
...
...
...
enddo
5
,
9
.true.
/
, &
?
,
/
.false.$ ,(
$
/
)
+
,
$
enddo
.true.
&
$
, D
2
#
I13L
"!
)
2
,
&
integer
n
double
precision
somme,
epsilon
...
!
affectation
de
epsilon
n=1
somme=0
do while (1d0/n**2 .ge. epsilon*somme)
somme=somme
+
1d0/n**2
n=n+1
enddo
#
/
"
#
,
(
.true.
/ logical
$
integer
double
logical
precision
somme,
n
epsilon
fini
...
!
affectation
de
epsilon
n=1
somme=0
fini=.false
do
while
(.not.
fini)
somme=somme
+
1d0/n**2
n=n+1
fini=(1d0/n**2 .lt. epsilon*somme)
enddo
GOTO
CONTINUE
- ,
,
&
>Z
S
/
/
$
L
&
&
@
/ >
56 678
9
$
0
2
*& >
+
1 $
/
>
/
/
>
&&
/
5
goto No de label
'
/
,
'
&
$
&
$
/
/
>
&
$
continue
5 4
#
character
...
continue
write(*,*) 'Repondez
read(*,*)
10
rep
oui
ou
non'
rep
if (rep.ne.'o'.and.rep.ne.'n') then
goto
10
endif
...
@
/
.
7
(
9
3
56 678$
&
$
$
D
type var(m1, m2, ...)
m1$ "C$
/
/
7
'
,
D
/
! ! ! :&! 56 678
&(
&
5 4
real
v(100)
double precision a(100,100)
integer i(20)
4
%
#
/
($
3 /
parameter
(max=100)
double precision a(max,max)
real v(max)
%
%
7
/
$
I
,
/
(
.
9
5 3
>
D
5 4
)
(
/
a
1
R
double precision a(max,max)
double precision b(max,max)
double precision c(max,max)
...
do
i=1,max
do
j=1,max
c(i,j)=a(i,j)+b(i,j)
enddo
enddo
#
(
double precision u(max), v(max)
double
precision
prodsca
...
prodsca=0
do
i=1,max
prodsca=prodsca + u(i)*v(i)
enddo
READ
0,
,
2
(
/
WRITE
0
.
'&
,
do
enddo
read
/
- ,
write
5
read(*,*) (var(i), i = i1, i2, i3)
write(*,*) (var(i), i = i1, i2, i3)
i
/ i i1$ i2
$ var(i)
/
D
i3
(
/
do
/
5 4
,
D
read(*,*) (v(i), i=1,n)
K
=
,
,
*! +
$
write(*,*) (a(i,j), ' ! ', j=1,n)
&
4
'
.
7
/
$
( &
B
>
(
/
9
a(100,100)
/
9
$
,(
,
b #
&&
/
(
56 678
a
&
,
'
$
/
B
.
/
,
$
b(100,100)
D
D
/
(
CC
W
/
$
56 678$ &
,
B
0$
!C
/
9
,(
(
$
,
/
/ n
$
nligne
ncolon
5 4
K
5
5
(
"C
.
/
(
,
$
0
D
@C
/ nligne
/
[
(
&&
ncolon
B
,
parameter
(mligne=50,
mcolon=80)
double precision a(mligne, mcolon)
double precision b(mligne, mcolon)
double precision c(mligne, mcolon)
integer
nligne,
ncolon
write(*,*)
'Nombre de lignes des matrices'
read(*,*)
nligne
write(*,*)
& 'Nombre de colonnes des matrices'
read(*,*)
ncolon
&
write(*,*)
do
read(*,*)
enddo
'Matrice
(a(i,j),
write(*,*)
do
read(*,*)
enddo
'Matrice
(b(i,j),
do
a
'
i=1,nligne
j=1,ncolon)
b
'
i=1,nligne
j=1,ncolon)
i=1,nligne
j=1,ncolon
do
(i,j)=a(i,j)+b(i,j)
enddo
enddo
end
A
.
.B
4
-
%
&
$
•
)
•
0
•
0
(
,
&&
&
#
&
D
>
,
(
&
'
,
&
'$?
D
!
•
%
%
5
/
'(
5
/
/
/
&
/
/
5
$
•
&&
•
&& >
> >
* * &" &+ >
&
$
&& >
(
/2
5
+ ,
,
56 678
>
/
/
D
#
U
,
!$&
!
$
,
1
*
!
,(
,
*
/ $
&
(
7
•
•
•
•
/
/
/
/
$
,
,(
56 678 */ &":&!* &" !+$
(
/
/
&
1
/
5
5
/
- J7 . & $
J J7
&
J J7
&
7 J7
&& > /!
&
> .
$$
$ $$
/ /
/
)3 /
/!
/
#
&
A 0
(
C
/
&
.
0,
,
/
,
'
$
/
•
•
&
&
o
o
/
3
$
/
&
D
!!
D%
3
subroutine nomsub(pf1, pf2, pf3, ...)
type
type
type
pf1
pf2
pf2
...
Déclaration
des
variables
locales
...
Instructions
exécutables
...
return
end
/
•
•
•
&
/
/
/
$
$
,
/
,
/
/
&
3
,
$&
/
,
/
&
/
&
$
call
,
call nomsub (v1, v2, v3, ...)
•
•
/
0E$ 0C$ 0F
/ &
D
$
L
4
3
(
(
0E$ 0C$ 0F$
&
/*E$
/*C$ /*F$
5 4
K
/
'$?
#
A$ 0
,
/
subroutine polar(x, y, r, theta)
double precision x, y, r, theta
double
double
precision
precision
pi=4*datan(1d0)
r=dsqrt(x**2+y**2)
pi
temp
!.
temp=datan(y/x)
if
(x.gt.0d0)
theta=temp
else
if
(x.lt.0d0)
theta=-temp
else
if
(x.eq.0d0)
if
(y.ge.0d0)
theta=pi/2
else
theta=-pi/2
endif
endif
then
then
then
then
return
end
&
C!
(
/
,
/
/
programm
...
double precision a, b, rho, phi
...
call polar (a, b, rho, phi)
...
end
4
7
4
•
a$ b$ rho
/
phi
polar
/
•
•
pi
/
x$ y$ r
/
temp
/
theta
'
'
,
polar 0
/
,
$ ,3
& G0 & 0 !/ &":&!* &" !
>$
/
!3
polar
/
&
/
theta$
,
,(
/
x$ y$ r
/
!$&
/
,
,
polar
call polar (x, y, rho, phi)
5
x
/
$
&
x$
,
%%
E
%%
C
/
/
( /2
6
5
•
/
9
I
E
&
#
#
0
3
W
/
0
/
o
o
•
•
C.$
(
F
/
F
,1 1
/
I
/
/ integer
&
,
LF
%/F
&&
L
%/
I1
$
!;
#
A( #
L
program
factcnp
do
call
factor(i,
write(*,*)
enddo
&
write(*,*)
'Entrez deux
read(*,*)
call
end
%/
entiers
i,
calcnp
subroutine
facti,
i,
(i,
et
j,
factor(n,
integer
double
...
return
end
i
i=1,100
ifaux)
facti
fact,
j'
j
cij)
ierr)
n,
precision
ierr
fact
subroutine calcnp (n, p, cnp, ierr)
implicit double precision (a-h,o-z)
integer
n,
p,
cnp
...
return
end
&
0, 1 1
,
,
call$
/
,
$
&
56 678$
=
,&&
5
2
&
datan$
(
,
&
pi=4*datan(1d0)
;
#
&
,
$
double precision '
datan
&
3
3
&
,
&
&
D
3
&&
&
$
/
D%
3
type
type
type
%
function
nomfonc
(pf1,
pf2,
...)
pdf1
pdf2
...
déclarations
des
variables
locale
...
instructions
exécutables
! devrait contenir quelque chose comme : nomfonc = ...
...
#
$
(
&
,
!"
return
end
3
G *
D
3
3
%
&
/
0
/
$ !
!!/ &":&!* &" !
&
/
&
?
,
/ &
,
5 4
E
&
&(
/ &
!/ !$
$
&
&!/
3
&
&
&
)
/
A/ 0
&
program
double
double
test
precision abscis,
precision
read(*,*)
r=rayon(abscis,
write(*,*)
end
ordonn, r
rayon
abscis,
ordonn
ordonn)
r
double precision function rayon (x, y)
double
precision
x,
rayon=dsqrt(x**2+y**2)
return
end
5 4
C
&
#
C"
A6
program
character
,
c,
test
litcar
do while (litcar() .ne. 'q')
write(*,*) 'On continue'
enddo
end
character function litcar()
read(*,*)
litcar
return
end
$
$
($3 &
3 1
#
/
& ! &-" !/ !!1!
&&!/
y
3
C;
!%
'
'
&
'
#
,(
/
0
/
$
0
/
/
;
A8 #
polar
&
/
&
B
$
(
J
7
$ ,
&
/
;
B
/&" & &-"
$
&
C%
,
,(
/
@
=$
/
, 1 1
*
/
&(
/
+
/ integer
real
@
$
CC real$
double precision
/
/
,
&
/
8-O
,
/
&
&
$
,
/ double precision
$
&&
3 &!!
$
.
/
polar
/
$
x
&
x
,
CCCC
3
CCC $
a
,
&&
theta
,
9,? ,
3
%
5
/
- (
CC!;
&
CC. $ , 1 1
/
3 ,
theta$
phi
@
COMMON
&
/
3
, /
&
,
,
$
/
/
&
common
common
/
>
/
&
/
common
?,
+
common/nomcom/v1, v2, v3...
?
•
•
•
•
•
•
common
parameter
5
/
D
/
(common
/
&
(
&
/
(
common$
&
D
>
?
,
&&
common
$ ,
D
/
common
(
5
5
5
D
$
M5
common$
common
>
!
+
"!
#
,
A: '(
common
,
program
test
double
real
precision
a,
pi
b
common
common
/trig/
pi
/bidon/ a, b
pi=4*datan(1d0)
...
end
subroutine truc (x,y)
common
common
/trig/
pi
/bidon/ u, v
double precision
real
u,
...
y=x*tan(pi*u/v)
...
return
end
9
,(
&
pi
v
C $
common bidon
/
&&
, 3 ! real
D I
J
/2
D
&
'
'
5
0
)&
/
u
>
0
a
$
(
D
(
.
(
/
11
&
&
3
/
1
( F0
H
/
,
1
vC
*
,
D
/
v
subroutine sub (v, ...)
type v(*)
m C$
*
D
&
&
&
subroutine sub (a, mligna, ...)
type a (mligna, *)
0
,
&
$
/
/
/
3
(
1
&
'
*
D
/
2
D
!@
5
%%
7
(
&
/
$
(
I
3
5 4
)/
$
/
-&
/
C@
3
&
/
$
$
mat
(
$
/
/
&
/
(
#
A=
,
program
parameter(mligne=10,
double precision mat
test
mcolon=20)
(mligne, mcolon)
call litmat (mat, mligne, nligne, ncolon)
end
subroutine
double
&
litmat
(a,
precision
write(*,*)
'Entrez
read(*,*)
nombre
do
ma,
a
de
(ma,
nc)
*)
lignes-colonnes'
nl,
nc
i=1,
'Ligne
(a(i,j),
write(*,*)
read(*,*)
enddo
nl,
',
nl
i
j=1,nc)
return
end
a
&
/
mat
ma$
,
C
&
,
$
D
mat
5
%%
E
E
11
!CF
5
%%
K
,
/
C U
/
C
/
&& >
,
$
litmat
/ I1
&
EXTERNAL
%
,
&
,
/
,
/
&
•
•
'(
*B
&
/
B E
*
,
/
&
K
11 &
$
/
,
/
F
&
!R
•
,
5
&
3
56 678
(
/
56 678$
5
&
&
* ' F 0,
,
real
,
subroutine integ (a, b, f, valint)
a$ b
&
,
0,
double precision$
valint
&
fF
3
56 678$
&
/I
$
external f
real f
real 5
external 9
f
f
,
#
&&
&
/
$
&
(
L5 &
/
3
[
/
&
>
$
3
valint = valint + h/2 *(f(x1+h) + f(x1))
J
56 678$
/
3
,
\
>
,
&
2
,
real function truc(x)
real
x
...
truc=...
return
end
\
(
integ
/
,
&
!
\,
call integ (1.0, 2.0, truc, somtruc)
1.0
real$ somtruc
2.0
/ real
,
' truc F0,
/
,
&
F
$
56 678 7 12
2
>
external truc
/
&
call 9
,? 2 &
$
&
real$ 2
,2
real truc
%
&
CR
,
#
A@ )
,
,(
,
.C
program
test
real
somtruc
external
real
truc
truc
call integ (1.0, 2.0, truc, somtruc)
end
subroutine
integ
(a,
b,
f,
valint)
real
a,
b,
valint
external
f
real
f
...
valint=valint + ( f(x1+h) + f(x1) )*h/2
...
return
end
real
real
...
truc=...
return
end
function
truc(x)
x
truc
f
6
&
/
&
8
(
real function truc(x,y)
'
$
/
$
&
&
3
2
/
integ
/
3
&
&
,
$
,
(
&
/
5
%%
K
I
,
,
*'
*'
&
&
U /
>
8 ]
*,'
5
U&
>
7
1
,
& > $
,
& >
?
!1B
7 &
- (
& >
,
56 678
7
#
& >
G :! & $
(3
& >
!$ , 1 1
B $
$
/
,
& * >&
,
&
& >
/
'
$
& >
( $ , 1 1
$
,
.
,
&
& >
0 3
/2
&
56 678
,
3
& >
/2
56 678
$
& $
3
& >
,
%
0
- ,
3
& >
,
B
#
;
&
U
& >
/
(
7
,
& >
2 (
* 1+$
& >
,
7
2
&
.
$
9
& >
&
>M
(
,
7
1
( $
& >
(
& > $
&
,
56 678
56 678
,
& >
,
5
open( numéro d'unité,
file=chaîne de caractère,
form=chaîne de caractères,
status=chaîne de caractères,
err=numéro de label
,
, & > $
& >
& ,
$
status='append'
%
Numéro d'unité
C
/ integer
RR 5
file=
,
'/home/louisnar/truc'
form=
>M
•
•
>M
/
& >
/
3
(
& >
>M
D
'formatted'
'unformatted'
& > &
& > /
0,
&
status=
>M
•
•
•
•
err=
'new'
'old'
'unknown'
'append'
D
& > $
& > $
& >
& >
,
0,
, (
, ,(
&
&
1
.!
/
,
,
5 4
open(10,file='ethanol')
& >
ethanol
&
$
, (
$
,
>
,
C
integer
unite
character*80
nomfich
...
unite=10
nomfich='ethanol'
open(unite,file=nomfich)
&
D
>
,(
character*80
nomfich
nomfich='bidon.dat'
open(10,file=nomfich,form='unformatted',
status='new',err=99)
...
!
(l'ouverture
a
réussi)
write(*,*)
'Fichier
',
nomfich,
& 'deja
existant'
...
&
99
3
& >
(
bidon.dat
& > /
&& >
,
?
2
%
'
7
0,
close(numéro d'unité)
0
&
>
,
,
,
& >
#
& > $
open
8
$
& >
&
;<
2
7
5
read( numéro d'unité,
format,
err=numéro de label,
end=numéro de label) liste de données
write( numéro d'unité,
format,
err=numéro de label) liste de données
•
#
#
&
& >
& > &
& $
&
$
,
$
&
&
&
,
#
U
&
$
$
&
*
..
err=numéro de label
'
,
$
/
end=numéro de label
/
,
&
$
?
! ! 1!! 0
7
,
"
/!
,
&
& >
/
2 (
&&
$ &
3
& >
,
0,
$
7
$
'unknown'$
,
,
2
status='append'
,
7
%A
5
& >
** 1!
status 'old'
(
%
9 '&
,
3
write
&&
& * > &!
write$
&
& >
& > $
/
%A
5
( truc.txt
& >
(
M
/
cat
&& >
8-O
goto
(
character*80
ligne
open(20,file='truc.txt')
10
continue
read(20,'(a)', end=99) ligne
write(*,*)
ligne
goto
10
99
continue
end
(5 2.
%H
K
/
>
$
'
(
>M
'
@C
? double precision
& > $
& >
(
?
subroutine ecritxy (x, y, nomfich)
character*80
nomfich
double
precision
x(*),
y(*)
open(20,file=nomfich)
do
i=1,n
write(20,*) sngl(x(i)), sngl(y(i))
enddo
close(20)
return
end
#
E$
x(i)
y(i)
real
56 678
(
1.345367222D-5
/
J >
sngl F
*$
1.345367222E-5
&
&
/
E
D
& >
D
1
(
J7
7P
.;
9
5
/
,
,
#
$
,
,
$
.
/
, & >
.
$
( #
$
>
(
$
& >
eau
2
373
5e7
K
/
/
&
•
•
$
,
C
& > $
$1
>M
& > $

Documents pareils