fortran and columns
From: jakeh (todo_at_doto.com)
Date: 01/29/04
- Next message: Gary Strand: "Re: Bugs at my web site"
- Previous message: James Giles: "Re: Bugs at my web site"
- Next in thread: Charles Russell: "Re: fortran and columns"
- Reply: Charles Russell: "Re: fortran and columns"
- Reply: Athanasios Migdalas: "Re: fortran and columns"
- Reply: Richard Maine: "Re: fortran and columns"
- Reply: ts: "Re: fortran and columns"
- Reply: miller: "Re: fortran and columns"
- Reply: John Mansell: "Re: fortran and columns"
- Reply: Theodore W. Hall: "Re: fortran and columns"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Jan 2004 16:24:19 -0500
Hi, i'm trying to get the following program to work properly. I believe
it's not working right, because i don't know how fortran works with
respect to columns. i know the program has to start off in column 7, but
are there specific rules for do statements and if statement with regards
to columns or any other column rules other than the programming starting
in column 7? The program is from a book by the way.
Thanks
DIMENSION V(0:20,0:20)
DATA PIE/3.14159/
DATA A,B/1.0,1.0/
DATA V1,V2,V3,V4/0.0,10.0,20.0,-10.0/
NX=4
NY=4
H=A/FLOAT(NX)
DO 10 I=1,NX-1
DO 10 J=1,NY-1
V(I,J)=(V1+V2+V3+V4)/4.0
10 CONTINUE
DO 20 I=1,NX-1
V(I,0)=V1
V(I,NY)=V3
20 CONTINUE
DO 30 J=1,NY-1
V(0,J)=V4
V(NX,J)=V2
30 CONTINUE
V(0,0)=(V1+V4)/2.0
V(NX,0)=(V1+V2)/2.0
V(0,NY)=(V3+V4)/2.0
V(NX,NY)=(V2+V3)/2.0
T=COS(PIE/NX)+COS(PIE/NY)
W=(8.0-SQRT(64.0-16.0*T*T))/(T*T)
WRITE(6,40) W
40 FORMAT(2X,'SOR FACTOR OMEGA=',F10.6)
W4=4/4.0
NCOUNT=0
50 RMIN=0.0
DO 70 I=1,NX-1
X=H*FLOAT(I)
DO 70 J=1,NY-1
Y=H*FLOAT(J)
G=-36.0*PIE*X*(Y-1.0)
R=W4*(V(I+1,J)+V(I-1,J)+V(I,J+1)+V(I,J-1)-4.0*V(I,J)-G*H*H)
RMIN=RMIN+ABS(R)
V(I,J)=V(I,J)+R
70 CONTINUE
RMIN=RMIN/FLOAT(NX*NY)
IF(RMIN.GE.0.0001) THEN
NCOUNT=NCOUNT+1
IF(NCOUNT.LT.100) THEN
GO TO 50
ELSE
WRITE(6,80)
80 FORMAT(2X,'SOLUTION DOES NOT CONVERGE IN 100 ITERATIONS')
GO TO 100
ENDIF
ENDIF
WRITE(6,90) NCOUNT
90 FORMAT(2X,'SOLUTION CONVERGES IN',2X,I3,2X,'ITERATIONS',/)
100 CONTINUE
DO 120 I=1,NX-1
DO 120 J=1,NY-1
WRITE(6,110) I,J,V(I,J)
110 FORMAT(2X,'I=',I3,2X,'J=',I3,2X,'V=',E12.6,/)
120 CONTINUE
DO 150 I=1,NX-1
X=H*FLOAT(I)
DO 150 J=1,NY-1
Y=H*FLOAT(J)
SUM=0.0
DO 130 M=1,10
FM=FLOAT(M)
DO 130 N=1,10
FN=FLOAT(N)
FACTOR1=(FM*PIE/A)**2+(FN*PIE/B)**2
FACTOR2=((-1.0)**(M+N))*144.0*A*B/(PIE*FM*FN)
FACTOR3=1.0-(1.0-(-1.0)**N)/B
FACTOR=FACTOR2*FACTOR3/FACTOR1
SUM=SUM+FACTOR*SIN(FM*PIE*X/A)*SIN(FN*PIE*Y/B)
130 CONTINUE
VH=SUM
C1=4.0*V1/PIE
C2=4.0*V2/PIE
C3=4.0*V3/PIE
C4=4.0*V4/PIE
SUM=0.0
DO 140 K=1,10
N=2*K-1
AN=FLOAT(N)
A1=SIN(AN*PIE*X/B)
A2=SINH(AN*PIE*(A-Y)/B)
A3=AN*SINH(AN*PIE*A/B)
TERM1=C1*A1*A2/A3
B1=SINH(AN*PIE*X/A)
B2=SIN(AN*PIE*Y/A)
B3=AN*SINH(AN*PIE*B/A)
TERM2=C2*B1*B2/B3
D1=SIN(AN*PIE*X/B)
D2=SINH(AN*PIE*Y/B)
D3=AN*SINH(AN*PIE*A/B)
TERM3=C3*D1*D2/D3
E1=SINH(AN*PIE*(B-X)/A)
E2=SIN(AN*PIE*Y/A)
E3=AN*SINH(AN*PIE*B/A)
TERM4=C4*E1*E2/E3
TERM=TERM1+TERM2+TERM3+TERM4
SUM=SUM+TERM
140 CONTINUE
VI=SUM
V(I,J)=VH+VI
150 CONTINUE
DO 160 I=1,NX-1
DO 160 J=1,NY-1
WRITE(6,110) I,J,V(I,J)
160 CONTINUE
STOP
END
- Next message: Gary Strand: "Re: Bugs at my web site"
- Previous message: James Giles: "Re: Bugs at my web site"
- Next in thread: Charles Russell: "Re: fortran and columns"
- Reply: Charles Russell: "Re: fortran and columns"
- Reply: Athanasios Migdalas: "Re: fortran and columns"
- Reply: Richard Maine: "Re: fortran and columns"
- Reply: ts: "Re: fortran and columns"
- Reply: miller: "Re: fortran and columns"
- Reply: John Mansell: "Re: fortran and columns"
- Reply: Theodore W. Hall: "Re: fortran and columns"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|