主题:为什么数据在屏幕上是对的,但却输入到文件上是错的
PROGRAM YUANWG
PARAMETER(NI=50,NJ=50)
DIMENSION X(NI,NJ),Y(NI,NJ),Z(NI,NJ),THETA(NI),
& X1(NI,NJ),Y1(NI,NJ),S(100),SS(100),SSS(100),
& X2(NI,NJ),Y2(NI,NJ),X3(NI,NJ),Y3(NI,NJ)
PAI=3.1415926535897932384626
R=1.0
NX=21
NY=21
DO 4 I=1,NX
THETA(I)=PAI/2*(I-1)/FLOAT(NX-1)
WRITE(*,*)I,THETA(I),(i-1)*r/float(nx-1)
4 CONTINUE
PAUSE
open(1,file='b.dat')
DO 10 I=1,NX
X(I,1)=R*COS(THETA(I)+5*PAI/4)
Y(I,1)=R*SIN(THETA(I)+5*PAI/4)
WRITE(*,*)X(I,1),Y(I,1)
10 CONTINUE
PAUSE
DO 20 I=1,NX
X(I,NY)=R*COS(THETA(I)+PAI/4)
Y(I,NY)=R*SIN(THETA(I)+PAI/4)
WRITE(*,*)X(I,NY),Y(I,NY)
20 CONTINUE
PAUSE
DO 30 J=1,NY
X(1,J)=R*COS(THETA(J)+3*PAI/4)
Y(1,J)=R*SIN(THETA(J)+3*PAI/4)
WRITE(*,*)X(1,J),Y(1,J)
30 CONTINUE
PAUSE
DO 40 J=1,NY
X(NX,J)=R*COS(THETA(J)-PAI/4)
Y(NX,J)=R*SIN(THETA(J)-PAI/4)
WRITE(*,*)X(NX,J),Y(NX,J)
40 CONTINUE
PAUSE
*******************************************
DO 70 I=1,NX
DO 70 J=1,NY
X2(I,J)=(X(NX,J)-X(1,J))*(I-1)/FLOAT(NX-1)
Y2(I,J)=(Y(I,NY)-Y(I,1))*(J-1)/FLOAT(NY-1)
70 CONTINUE
open(2,file='t.dat')
do 102 I=1,nx
write(1,*) x(i,1),y(I,1)
write(2,*) x(I,NY),y(I,NY)
102 CONTINUE
CLOSE(1)
CLOSE(2)
open(1,file='BB.dat')
open(2,file='TT.dat')
do 103 J=1,NY
write(1,*) x(1,J),y(1,J)
write(2,*) x(NX,J),y(NX,J)
103 CONTINUE
CLOSE(1)
CLOSE(2)
OPEN(10,FILE='2D-GRID.DAT')
WRITE(11,*) 'VARIABLES= "X1", "Y1"'
WRITE(11,*) 'ZONE I=',NX,'J=',NY
DO 190 J=1,NY
DO 190 I=1,NX
WRITE(11,*)X1(I,J),Y1(I,J)
190 CONTINUE
CLOSE(11)
OPEN(10,FILE='2D-GRID1.DAT')
WRITE(10,*) 'VARIABLES= "X", "Y"'
WRITE(10,*) 'ZONE I=',NX,'J=',NY
DO 191 J=1,NY
DO 191 I=1,NX
WRITE(10,*)X2(I,J),Y2(I,J)
191 CONTINUE
CLOSE(10)
210 FORMAT(D30.18,D30.18,D30.18)
STOP
END
请注意文件“b.dat”“t.dat”
PARAMETER(NI=50,NJ=50)
DIMENSION X(NI,NJ),Y(NI,NJ),Z(NI,NJ),THETA(NI),
& X1(NI,NJ),Y1(NI,NJ),S(100),SS(100),SSS(100),
& X2(NI,NJ),Y2(NI,NJ),X3(NI,NJ),Y3(NI,NJ)
PAI=3.1415926535897932384626
R=1.0
NX=21
NY=21
DO 4 I=1,NX
THETA(I)=PAI/2*(I-1)/FLOAT(NX-1)
WRITE(*,*)I,THETA(I),(i-1)*r/float(nx-1)
4 CONTINUE
PAUSE
open(1,file='b.dat')
DO 10 I=1,NX
X(I,1)=R*COS(THETA(I)+5*PAI/4)
Y(I,1)=R*SIN(THETA(I)+5*PAI/4)
WRITE(*,*)X(I,1),Y(I,1)
10 CONTINUE
PAUSE
DO 20 I=1,NX
X(I,NY)=R*COS(THETA(I)+PAI/4)
Y(I,NY)=R*SIN(THETA(I)+PAI/4)
WRITE(*,*)X(I,NY),Y(I,NY)
20 CONTINUE
PAUSE
DO 30 J=1,NY
X(1,J)=R*COS(THETA(J)+3*PAI/4)
Y(1,J)=R*SIN(THETA(J)+3*PAI/4)
WRITE(*,*)X(1,J),Y(1,J)
30 CONTINUE
PAUSE
DO 40 J=1,NY
X(NX,J)=R*COS(THETA(J)-PAI/4)
Y(NX,J)=R*SIN(THETA(J)-PAI/4)
WRITE(*,*)X(NX,J),Y(NX,J)
40 CONTINUE
PAUSE
*******************************************
DO 70 I=1,NX
DO 70 J=1,NY
X2(I,J)=(X(NX,J)-X(1,J))*(I-1)/FLOAT(NX-1)
Y2(I,J)=(Y(I,NY)-Y(I,1))*(J-1)/FLOAT(NY-1)
70 CONTINUE
open(2,file='t.dat')
do 102 I=1,nx
write(1,*) x(i,1),y(I,1)
write(2,*) x(I,NY),y(I,NY)
102 CONTINUE
CLOSE(1)
CLOSE(2)
open(1,file='BB.dat')
open(2,file='TT.dat')
do 103 J=1,NY
write(1,*) x(1,J),y(1,J)
write(2,*) x(NX,J),y(NX,J)
103 CONTINUE
CLOSE(1)
CLOSE(2)
OPEN(10,FILE='2D-GRID.DAT')
WRITE(11,*) 'VARIABLES= "X1", "Y1"'
WRITE(11,*) 'ZONE I=',NX,'J=',NY
DO 190 J=1,NY
DO 190 I=1,NX
WRITE(11,*)X1(I,J),Y1(I,J)
190 CONTINUE
CLOSE(11)
OPEN(10,FILE='2D-GRID1.DAT')
WRITE(10,*) 'VARIABLES= "X", "Y"'
WRITE(10,*) 'ZONE I=',NX,'J=',NY
DO 191 J=1,NY
DO 191 I=1,NX
WRITE(10,*)X2(I,J),Y2(I,J)
191 CONTINUE
CLOSE(10)
210 FORMAT(D30.18,D30.18,D30.18)
STOP
END
请注意文件“b.dat”“t.dat”