Reputation: 21
I was given a task to program a task in Fortran and I can’t understand where my errors are and how to correct them. Initially, the files "A(1 2 3 2 1)", "B(1 2 3 2 1)", "T(2 2 2 2 2)", and limits from a to b "(-2 -1 0 1 2)" ;"T = 2" ;"M = 3"; Y = 5". Bottom line, you need to display all R. It is advisable that the line and its problem be directly indicated to me, because I am a rather stupid person. I will be sincerely grateful taskex1 taskex2 taskex3
All errors and warnings:
gfortran -Wall -c
2.f90:2:2:
2 | dimension A(5), A1(5), B(5), B1(5), T(5), T1(5), H(5), D(5), V(5), X(5), CC(5), CC1(5)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:31:2:
31 | 111 continue
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:32:2:
32 | if ((A(i)/B(i)).le.T(i)) then
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:33:2:
33 | A1(i) = A(i)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:34:2:
34 | B1(i) = B(i)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:35:2:
35 | T1(i) = T(i)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:36:2:
36 | else
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:37:2:
37 | T1(i) = T(i)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:38:2:
38 | B1(i) = B(i)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:39:2:
39 | A1(i) = B1(i) * T1(i)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:40:2:
40 | endif
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:43:2:
43 | n=size(X)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:44:2:
44 | S=0.0
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:45:2:
45 | do i=1, n-1
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:45:13:
16 | do i = 1, 5
| 2
......
45 | do i=1, n-1
| 1
Error: Variable 'i' at (1) cannot be redefined inside loop beginning at (2)
2.f90:46:2:
46 | S1=S
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:47:2:
47 | S=S+0.5*(X(i+1)-X(i))*(A1(i+1)+A1(i))
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:48:2:
48 | V(i)=S1
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:49:2:
49 | end do
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:50:2:
50 | V(n)=S
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:53:2:
53 | n=size(X)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:54:2:
54 | CC(i) = (1/12.) * (B1(i))**3
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:55:2:
55 | S=0.0
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:56:2:
56 | do i=1, n-1
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:56:13:
16 | do i = 1, 5
| 2
......
56 | do i=1, n-1
| 1
Error: Variable 'i' at (1) cannot be redefined inside loop beginning at (2)
2.f90:57:2:
57 | S1=S
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:58:2:
58 | S=S+0.5*(X(i+1)-X(i))*(CC(i+1)+CC(i))
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:59:2:
59 | H(i)=S1
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:60:2:
60 | end do
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:61:2:
61 | H(n)=S * (1/V(n))
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:64:2:
64 | n=size(X)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:65:2:
65 | CC1(i) = ((-T1(i))/2.) * A1(i)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:66:2:
66 | S=0.0
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:67:2:
67 | do i=1, n-1
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:67:13:
16 | do i = 1, 5
| 2
......
67 | do i=1, n-1
| 1
Error: Variable 'i' at (1) cannot be redefined inside loop beginning at (2)
2.f90:68:2:
68 | S1=S
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:69:2:
69 | S=S+0.5*(X(i+1)-X(i))*(CC1(i+1)+CC1(i))
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:70:2:
70 | D(i)=S1
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:71:2:
71 | end do
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:72:2:
72 | D(n)=S * (1/V(n)) + T
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:75:2:
75 | G = D(n) + H(n) + M
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:76:2:
76 | O1 = G - T
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:79:2:
79 | do i = X(1),X(5)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:79:18:
16 | do i = 1, 5
| 2
......
79 | do i = X(1),X(5)
| 1
Error: Variable 'i' at (1) cannot be redefined inside loop beginning at (2)
2.f90:80:2:
80 | K1(i) = ((sin(L *(B1(i)/2.)))/(L*B1(i))/2.) * (((1+L*T1(i)) * e ** (-L*T1(i) - 1)) / ((L**2) * T1(i)))
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:81:2:
81 | end do
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:84:2:
84 | do i = X(1),X(5)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:84:18:
16 | do i = 1, 5
| 2
......
84 | do i = X(1),X(5)
| 1
Error: Variable 'i' at (1) cannot be redefined inside loop beginning at (2)
2.f90:85:2:
85 | K2(i) = (-((e ** (-L*T1(i) - 1)) / ((L**2) * T1(i))))* (cos(L*(B1(i)/2.)) - ((sin(L*(B1(i)/2.)))/(L*(B1(i)/2.))))
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:86:2:
86 | end do
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:89:2:
89 | do i = X(1),X(5)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:89:18:
16 | do i = 1, 5
| 2
......
89 | do i = X(1),X(5)
| 1
Error: Variable 'i' at (1) cannot be redefined inside loop beginning at (2)
2.f90:90:2:
90 | F1(i) = -((1 - (e**(-L*T1(i))))/(L*T1(i))) * ((sin(L*(B1(i)/2.)))/((L*B1(i))/2.))
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:91:2:
91 | end do
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:94:2:
94 | do i = X(1),X(5)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:94:18:
16 | do i = 1, 5
| 2
......
94 | do i = X(1),X(5)
| 1
Error: Variable 'i' at (1) cannot be redefined inside loop beginning at (2)
2.f90:95:2:
95 | if (A1(i) .eq. 0 .and. B1(i) .eq. 0) then
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:96:2:
96 | C(i) = 0
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:97:2:
97 | else
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:98:2:
98 | C(i) = A1(i) * (K1(i) + K2(i) + F1(i) * O1)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:99:2:
99 | endif
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:100:2:
100 | end do
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:103:2:
103 | do i = X(1),X(5)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:103:18:
16 | do i = 1, 5
| 2
......
103 | do i = X(1),X(5)
| 1
Error: Variable 'i' at (1) cannot be redefined inside loop beginning at (2)
2.f90:104:2:
104 | n=size(X)
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:105:2:
105 | S=0.0
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:106:2:
106 | do i=1, n-1
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:106:13:
103 | do i = X(1),X(5)
| 2
......
106 | do i=1, n-1
| 1
Error: Variable 'i' at (1) cannot be redefined inside loop beginning at (2)
2.f90:107:2:
107 | S1=S
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:108:2:
108 | S=S+0.5*(X(i+1)-X(i))*(C(i+1)+C(i))
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:109:2:
109 | R(i)=S1
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:110:2:
110 | end do
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:111:2:
111 | R(n)=abs(S / (V(n) * M))
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:112:2:
112 | end do
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:113:2:
113 | print *, R
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:114:2:
114 | end do
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
2.f90:31:5:
31 | 111 continue
| 1
Warning: Label 111 at (1) defined but not used [-Wunused-label]
2.f90:72:2:
72 | D(n)=S * (1/V(n)) + T
| 1
Error: Incompatible ranks 0 and 1 in assignment at (1)
2.f90:76:2:
76 | O1 = G - T
| 1
Error: Incompatible ranks 0 and 1 in assignment at (1)
2.f90:79:8:
79 | do i = X(1),X(5)
| 1
Warning: Deleted feature: Start expression in DO loop at (1) must be integer
2.f90:79:14:
79 | do i = X(1),X(5)
| 1
Warning: Deleted feature: End expression in DO loop at (1) must be integer
2.f90:79:8:
79 | do i = X(1),X(5)
| 1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1) [-Wconversion]
2.f90:79:14:
79 | do i = X(1),X(5)
| 1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1) [-Wconversion]
2.f90:84:8:
84 | do i = X(1),X(5)
| 1
Warning: Deleted feature: Start expression in DO loop at (1) must be integer
2.f90:84:14:
84 | do i = X(1),X(5)
| 1
Warning: Deleted feature: End expression in DO loop at (1) must be integer
2.f90:84:8:
84 | do i = X(1),X(5)
| 1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1) [-Wconversion]
2.f90:84:14:
84 | do i = X(1),X(5)
| 1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1) [-Wconversion]
2.f90:89:8:
89 | do i = X(1),X(5)
| 1
Warning: Deleted feature: Start expression in DO loop at (1) must be integer
2.f90:89:14:
89 | do i = X(1),X(5)
| 1
Warning: Deleted feature: End expression in DO loop at (1) must be integer
2.f90:89:8:
89 | do i = X(1),X(5)
| 1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1) [-Wconversion]
2.f90:89:14:
89 | do i = X(1),X(5)
| 1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1) [-Wconversion]
2.f90:94:8:
94 | do i = X(1),X(5)
| 1
Warning: Deleted feature: Start expression in DO loop at (1) must be integer
2.f90:94:14:
94 | do i = X(1),X(5)
| 1
Warning: Deleted feature: End expression in DO loop at (1) must be integer
2.f90:94:8:
94 | do i = X(1),X(5)
| 1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1) [-Wconversion]
2.f90:94:14:
94 | do i = X(1),X(5)
| 1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1) [-Wconversion]
2.f90:103:8:
103 | do i = X(1),X(5)
| 1
Warning: Deleted feature: Start expression in DO loop at (1) must be integer
2.f90:103:14:
103 | do i = X(1),X(5)
| 1
Warning: Deleted feature: End expression in DO loop at (1) must be integer
2.f90:103:8:
103 | do i = X(1),X(5)
| 1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1) [-Wconversion]
2.f90:103:14:
103 | do i = X(1),X(5)
| 1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1) [-Wconversion]
2.f90:47:13:
16 | do i = 1, 5
| 2
......
47 | S=S+0.5*(X(i+1)-X(i))*(A1(i+1)+A1(i))
| 1
Warning: Array reference at (1) out of bounds (6 > 5) in loop beginning at (2)
2.f90:47:28:
16 | do i = 1, 5
| 2
......
47 | S=S+0.5*(X(i+1)-X(i))*(A1(i+1)+A1(i))
| 1
Warning: Array reference at (1) out of bounds (6 > 5) in loop beginning at (2)
2.f90:58:13:
16 | do i = 1, 5
| 2
......
58 | S=S+0.5*(X(i+1)-X(i))*(CC(i+1)+CC(i))
| 1
Warning: Array reference at (1) out of bounds (6 > 5) in loop beginning at (2)
2.f90:58:28:
16 | do i = 1, 5
| 2
......
58 | S=S+0.5*(X(i+1)-X(i))*(CC(i+1)+CC(i))
| 1
Warning: Array reference at (1) out of bounds (6 > 5) in loop beginning at (2)
2.f90:69:13:
16 | do i = 1, 5
| 2
......
69 | S=S+0.5*(X(i+1)-X(i))*(CC1(i+1)+CC1(i))
| 1
Warning: Array reference at (1) out of bounds (6 > 5) in loop beginning at (2)
2.f90:69:29:
16 | do i = 1, 5
| 2
......
69 | S=S+0.5*(X(i+1)-X(i))*(CC1(i+1)+CC1(i))
| 1
Warning: Array reference at (1) out of bounds (6 > 5) in loop beginning at (2)
2.f90:108:13:
16 | do i = 1, 5
| 2
......
108 | S=S+0.5*(X(i+1)-X(i))*(C(i+1)+C(i))
| 1
Warning: Array reference at (1) out of bounds (6 > 5) in loop beginning at (2)
real :: A(1:5), A1(1:5), B(1:5),B1(1:5),T(1:5),T1(1:5),H(1:5),D(1:5),V(1:5),X(1:5),CC(1:5),CC1(1:5),T,G,M,L,Y,O1,K1,K2,F1,R,C,a,b,S,S1,e
integer :: i,n
open(1, file = 'A.txt')
open(2, file = 'B.txt')
open(3, file = 'T.txt')
open(4, file = 'ab.txt')
T = 2
M = 3
Y = 5
L = (Y**2)/9.81
e = 2.718
!conditions
do i = 1,5
read (1,*) A
read (2,*) B
read (3,*) T
read (4,*) X
if (A(i).gt.0 .and. B(i).gt.0) go to 111
else
A1(i) = 0
B1(i) = 0
T1(i) = 0
endif
111 continue
if ((A(i)/B(i)).le.T(i)) then
A1(i) = A(i)
B1(i) = B(i)
T1(i) = T(i)
else
T1(i) = T(i)
B1(i) = B(i)
A1(i) = B1(i) * T1(i)
endif
!V
n=size(X)
S=0.0
do i=1, n-1
S1=S
S=S+0.5*(X(i+1)-X(i))*(A1(i+1)+A1(i))
V(i)=S1
end do
V(n)=S
!H
n=size(X)
CC(i) = (1/12.) * (B1(i))**3
S=0.0
do i=1, n-1
S1=S
S=S+0.5*(X(i+1)-X(i))*(CC(i+1)+CC(i))
H(i)=S1
end do
H(n)=S * (1/V(n))
!D
n=size(X)
CC1(i) = ((-T1(i))/2.) * A1(i)
S=0.0
do i=1, n-1
S1=S
S=S+0.5*(X(i+1)-X(i))*(CC1(i+1)+CC1(i))
D(i)=S1
end do
D(n)=S * (1/V(n)) + T
!G и O1
G = D(n) + H(n) + M
O1 = G - T
!K1
do i = X(1),X(5)
K1(i) = ((sin(L *(B1(i)/2.)))/(L*B1(i))/2.) * (((1+L*T1(i)) * e ** (-L*T1(i) - 1)) / ((L**2) * T1(i)))
end do
!K2
do i = X(1),X(5)
K2(i) = (-((e ** (-L*T1(i) - 1)) / ((L**2) * T1(i))))* (cos(L*(B1(i)/2.)) - ((sin(L*(B1(i)/2.)))/(L*(B1(i)/2.))))
end do
!F1
do i = X(1),X(5)
F1(i) = -((1 - (e**(-L*T1(i))))/(L*T1(i))) * ((sin(L*(B1(i)/2.)))/((L*B1(i))/2.))
end do
!C
do i = X(1),X(5)
if (A1(i) .eq. 0 .and. B1(i) .eq. 0) then
C(i) = 0
else
C(i) = A1(i) * (K1(i) + K2(i) + F1(i) * O1)
endif
end do
!R
do i = X(1),X(5)
n=size(X)
S=0.0
do i=1, n-1
S1=S
S=S+0.5*(X(i+1)-X(i))*(C(i+1)+C(i))
R(i)=S1
end do
R(n)=abs(S / (V(n) * M))
end do
print *, R
end do
Upvotes: 0
Views: 57