Bonsoir,
je possède un algorithme qui calcule l'intégrale simple à l'aide de la méthode des trapèzes, l'algorithme marche sans difficulté, le voici:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
	SUBROUTINE QTRAP(FUNC1,A9,B9,S9)
	implicit none
	EXTERNAL FUNC1
	DOUBLE PRECISION A9,B9,S9,FUNC1
	DOUBLE PRECISION EPS,OLDS
	Integer J,JMAX
 
	PARAMETER (EPS=1.E-2, JMAX=20)
	IF((B9-A9).LT.1.E-4) THEN
	S9 = 1.E-6
	RETURN
	ENDIF
	IF(B9.EQ.0.0) THEN
	B9 = 0.001
	ENDIF
	OLDS=-1.E30
	DO J=1,JMAX
	CALL TRAPZD(FUNC1,A9,B9,S9,J)
	IF (ABS(S9-OLDS).LT.(EPS*ABS(OLDS))) RETURN
	OLDS=S9
	end do
	RETURN
	END
 
!    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
	SUBROUTINE TRAPZD(FUNC2,A8,B8,S8,N8)
	implicit none
	EXTERNAL FUNC2
	DOUBLE PRECISION A8,B8,S8
	INTEGER N8
	DOUBLE PRECISION SUM,DEL,X,FUNC2
	INTEGER J,IT,TNM
 
 
	!    This routine computes the N'th stage of refinement of an extended
	!    trapezoidal rule. FUNC is input as the name of the function to be
	!    integrated between limits A and B, also input. When called with N=1
	!    the routine returns as S the crudest estimate of the integral.
	!    Subsequent calls with N=2,3,.. will improve the accuracy of S by 
	!    adding 2**N-2 additional interior points. S should not be modified 
	!    BETWEEN SEQUENTIAL CALLS.
 
 
	IF (N8.EQ.1) THEN
	S8=0.5*(B8-A8)*(FUNC2(A8)+FUNC2(B8))
	IT = 1
 
	ELSE
 
	TNM=IT
	DEL=(B8-A8)/TNM
	X=A8+0.5*DEL
	SUM=0.
	DO J=1,IT
			SUM=SUM+FUNC2(X)
			X=X+DEL
	end do
	S8=0.5*(S8+(B8-A8)*SUM/TNM)
	IT=2*IT
	ENDIF
	RETURN
	END
Le problème est dans la variable locale IT, cette variable est déclarée comme un entier mais on ne lui a affecté aucune valeur et pourtant on l'utilise au sein du programme

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
SUBROUTINE TRAPZD(FUNC2,A8,B8,S8,N8)
	implicit none
	EXTERNAL FUNC2
	DOUBLE PRECISION A8,B8,S8
	INTEGER N8
	DOUBLE PRECISION SUM,DEL,X,FUNC2
	INTEGER J,IT,TNM


	!    This routine computes the N'th stage of refinement of an extended
	!    trapezoidal rule. FUNC is input as the name of the function to be
	!    integrated between limits A and B, also input. When called with N=1
	!    the routine returns as S the crudest estimate of the integral.
	!    Subsequent calls with N=2,3,.. will improve the accuracy of S by 
	!    adding 2**N-2 additional interior points. S should not be modified 
	!    BETWEEN SEQUENTIAL CALLS.
    
      
	IF (N8.EQ.1) THEN
	S8=0.5*(B8-A8)*(FUNC2(A8)+FUNC2(B8))
	IT = 1
      
	ELSE
        
	TNM=IT
	DEL=(B8-A8)/TNM
	X=A8+0.5*DEL
	SUM=0.
	DO J=1,IT
			SUM=SUM+FUNC2(X)
			X=X+DEL
	end do
	S8=0.5*(S8+(B8-A8)*SUM/TNM)
	IT=2*IT
	ENDIF
	RETURN
	END
svp aidez moi à comprendre quelles sont les valeurs que prend IT et comment fortran n'affiche aucune erreur malgré le fait qu'on n'a affecté aucune valeur à IT au début
merci de m'aider