|
地板
楼主 |
发表于 2018-8-1 11:58:00
|
只看该作者
我试了一下,可以了,谢谢你了。
如果你方便的话,能帮我看一下,下面另一个程序么?
ITER 函数里的这一句real , save :: AK00 , AK10是按照你说的方法加的,但是它运行后还是出现浮点异常
PROGRAM ELLIPEHL
COMMON /COM1/ENDA,A1,A2,A3,Z,HM0,DH
COMMON /COMEK/EK,BX,BY,PTR
REAL*8 RX,RY,KA,KB
DATA N,PAI,Z,E1,EDA0,RX,RY,X0,XE,W0,US/65,3.14159265,0.68,2.21E11,0.02,0.03,0.06,-2.5,1.5,1000.,3./
OPEN(8,FILE='FILM.DAT',STATUS='UNKNOWN')
OPEN(10,FILE='PRESSURE.DAT',STATUS='UNKNOWN')
EK=RX/RY
AA=0.5*(1./RX+1./RY)
BB=0.5*ABS(1./RX-1./RY)
CALL HERTZELLIPTIC(RX,RY,KA,KB)
EA=KA*(1.5*W0/AA/E1)**(1./3.0)
EB=KB*(1.5*W0/AA/E1)**(1./3.0)
PH=1.5*W0/(EA*EB*PAI)
WRITE(*,*)"N,X0,XE,W0,PH,E1,EDA0,RX,US=",N,X0,XE,W0,PH,E1,EDA0,RX,US
MM=N-1
U=EDA0*US/(E1*RX)
A1=ALOG(EDA0)+9.67
A2=5.1E-9*PH
A3=0.59/(PH*1.E-9)
BX=EB
BY=EA
IF(RX.GT.RY) THEN
BX=EA
BY=EB
ENDIF
W=W0/(E1*RX**2)
PTR=3*W*(RX/BY)*(RX/BX)**2/(PAI**2)
ALFA=Z*5.1E-9*A1
G=ALFA*E1
AHM=1.0-EXP(-0.68*1.03)
HM0=3.63*(RX/BX)**2*G**0.49*U**0.68*W**(-0.073)*AHM
ENDA=12.*U*(E1/PH)*(RX/BX)**3
WRITE(*,*)' Wait please'
CALL SUBAK(MM)
CALL MULTI(N,X0,XE)
STOP
END
SUBROUTINE MULTI(N,X0,XE)
DIMENSION X(65),Y(65),H(4500),RO(4500),EPS(4500),EDA(4500),P(4500),POLD(4500),V(4500)
COMMON /COM1/ENDA,A1,A2,A3,Z,HM0,DH
COMMON /COMEK/EK,BX,BY,PTR
DATA MK,G00/1,2.0943951/
G0=G00*BY/BX
NX=N
NY=N
NN=(N+1)/2
CALL INITI(N,DX,X0,XE,X,Y,P,POLD)
CALL HREE(N,DX,G0,X,Y,H,RO,EPS,EDA,P,V)
14 KK=15
CALL ITER(N,KK,DX,G0,X,Y,H,RO,EPS,EDA,P,V)
MK=MK+1
CALL ERP(N,ER,P,POLD)
WRITE(*,*)'ER=',ER
IF(ER.GT.1.E-5.AND.DH.GT.1.E-7)THEN
IF(MK.GE.10)THEN
WRITE(*,*)'ER,DH=',ER,DH
MK=1
DH=0.5*DH
ENDIF
GOTO 14
ENDIF
IF(DH.LE.1.E-7)WRITE(*,*)'Pressures are not convergent!!!'
CALL OUTPUT(N,DX,X,Y,H,P)
RETURN
END
SUBROUTINE ERP(N,ER,P,POLD)
DIMENSION P(N,N),POLD(N,N)
ER=0.0
SUM=0.0
NN=(N+1)/2
DO 10 I=1,N
DO 10 J=1,NN
ER=ER+ABS(P(I,J)-POLD(I,J))
SUM=SUM+P(I,J)
10 CONTINUE
ER=ER/SUM
DO I=1,N
DO J=1,N
POLD(I,J)=P(I,J)
ENDDO
ENDDO
RETURN
END
SUBROUTINE INITI(N,DX,X0,XE,X,Y,P,POLD)
COMMON /COMEK/EK,BX,BY,PTR
DIMENSION X(N),Y(N),P(N,N),POLD(N,N)
NN=(N+1)/2
DX=(XE-X0)/(N-1.)
Y0=-0.5*(XE-X0)
DO 5 I=1,N
X(I)=X0+(I-1)*DX
Y(I)=Y0+(I-1)*DX
5 CONTINUE
DO 10 I=1,N
D=1.-X(I)*X(I)
DO 10 J=1,NN
C=D-(BX/BY)**2*Y(J)*Y(J)
IF(C.LE.0.0)P(I,J)=0.0
10 IF(C.GT.0.0)P(I,J)=SQRT(C)
DO 20 I=1,N
DO 20 J=NN+1,N
JJ=N-J+1
20 P(I,J)=P(I,JJ)
DO I=1,N
DO J=1,N
POLD(I,J)=P(I,J)
ENDDO
ENDDO
RETURN
END
SUBROUTINE HREE(N,DX,G0,X,Y,H,RO,EPS,EDA,P,V)
DIMENSION X(N),Y(N),P(N,N),H(N,N),RO(N,N),EPS(N,N),EDA(N,N),V(N,N)
COMMON /COM1/ENDA,A1,A2,A3,Z,HM0,DH/COMAK/AK(0:65,0:65)
COMMON /COMEK/EK,BX,BY,PTR
DATA KK,PAI,PAI1/0,3.14159265,0.2026423/
NN=(N+1)/2
CALL VI(N,DX,P,V)
HMIN=1.E3
DO 30 I=1,N
DO 30 J=1,NN
RAD=X(I)*X(I)+EK*Y(J)*Y(J)
W1=0.5*RAD
H0=W1+V(I,J)
IF(H0.LT.HMIN)HMIN=H0
30 H(I,J)=H0
W1=0.0
DO 40 I=1,N
DO 40 J=1,N
40 W1=W1+P(I,J)
W1=DX*DX*W1/G0
DW=1.-W1
IF(KK.NE.0)GOTO 50
KK=1
DH=0.1*HM0
H00=-HMIN+HM0
50 IF(DW.LT.0.0)H00=H00+DH
IF(DW.GT.0.0)H00=H00-DH
DO 60 I=1,N
DO 60 J=1,NN
H(I,J)=H00+H(I,J)
IF(P(I,J).LT.0.0)P(I,J)=0.0
EDA1=EXP(A1*(-1.+(1.+A2*P(I,J))**Z))
EDA(I,J)=EDA1
RO(I,J)=(A3+1.34*P(I,J))/(A3+P(I,J))
60 EPS(I,J)=RO(I,J)*H(I,J)**3/(ENDA*EDA1)
DO 70 J=NN+1,N
JJ=N-J+1
DO 70 I=1,N
H(I,J)=H(I,JJ)
RO(I,J)=RO(I,JJ)
EDA(I,J)=EDA(I,JJ)
70 EPS(I,J)=EPS(I,JJ)
RETURN
END
SUBROUTINE ITER(N,KK,DX,G0,X,Y,H,RO,EPS,EDA,P,V)
real , save :: AK00 , AK10
DIMENSION X(N),Y(N),P(N,N),H(N,N),RO(N,N),EPS(N,N),EDA(N,N),V(N,N)
COMMON /COMAK/AK(0:65,0:65)
COMMON /COMEK/EK,BX,BY,PTR
DATA KG1,PAI/0,3.14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)+XM*ALOG(A3)+YP*ALOG(A4)
10 AK(J,I)=AK(I,J)
RETURN
END
SUBROUTINE OUTPUT(N,DX,X,Y,H,P)
DIMENSION X(N),Y(N),H(N,N),P(N,N)
NN=(N+1)/2
A=0.0
WRITE(8,110)A,(Y(I),I=1,N)
DO I=1,N
WRITE(8,110)X(I),(H(I,J),J=1,N)
ENDDO
WRITE(10,110)A,(Y(I),I=1,N)
DO I=1,N
WRITE(10,110)X(I),(P(I,J),J=1,N)
ENDDO
110 FORMAT(66(E12.6,1X))
RETURN
END
SUBROUTINE HERTZELLIPTIC(RX,RY,KA,KB)
IMPLICIT NONE
REAL*8, EXTERNAL :: EE,KE
REAL*8 RX,RY,BPA,BMA,CTH,THT,PAI,E1,KA,KB
DATA PAI/3.1415926/
BPA=0.5*(1./RX+1./RY)
BMA=0.5*ABS(1./RX-1./RY)
CTH=BMA/BPA
THT=ACOS(CTH)*180.0/PAI
CALL CACUE(CTH,E1)
KA=(2.*EE(E1)/(PAI*(1-E1**2)))**(1/3.)
KB=KA*(1.-E1**2)**(1/2.)
END SUBROUTINE
SUBROUTINE CACUE(CTH,E1)
IMPLICIT NONE
REAL*8, EXTERNAL :: EE,KE
REAL*8, EXTERNAL :: FAB
INTEGER FLG,I
REAL*8 PAI,CTH,E1,E11,E12,DX,A,B,A1,A2,A3,A4,A5,T1,T2,T3,T4,T5,ER0
DATA PAI,DX,FLG,I,T1,T5,ER0/3.1415926,0.0001,1,1,1.E-30,1.,1.E-12/
IF(CTH.LT.1.E-6)THEN
E1=0.
RETURN
ENDIF
IF(CTH.GT.0.9999999999)THEN
E1=1.
RETURN
ENDIF
A1=FAB(T1,CTH)
A5=FAB(T5,CTH)
DO WHILE(FLG.EQ.1)
T3=T1+I*DX
A3=FAB(T3,CTH)
I=I+1
IF((A1*A3.LT.0.).AND.(A3*A5.LT.0.)) THEN
FLG=0
END IF
END DO
DO WHILE((T3-T1).GT.ER0)
T2=(T1+T3)/2.
A2=FAB(T2,CTH)
IF(A2.GT.0.) T1=T2
IF(A2.LT.0.) T3=T2
IF(A2.EQ.0.)THEN
E11=T2
EXIT
END IF
END DO
E11=T2
DO WHILE((T5-T3).GT.ER0)
T4=(T3+T5)/2.
A4=FAB(T4,CTH)
IF(A4.GT.0.) T5=T4
IF(A4.LT.0.) T3=T4
IF(A4.EQ.0.)THEN
E12=T2
EXIT
END IF
END DO
E12=T4
E1=E11
IF(E11.LT.E12) E1=E12
RETURN
END SUBROUTINE
REAL*8 FUNCTION FAB(E1,CTH)
IMPLICIT NONE
REAL*8 E1,CTH,T1,T2
REAL*8, EXTERNAL :: EE,KE
T1=EE(E1)
T2=KE(E1)
FAB=2*(1-E1**2)*(T1-T2)+(1.-CTH)*E1**2*T1
END FUNCTION
REAL*8 FUNCTION KE(E1)
IMPLICIT NONE
INTEGER N,I,FLG
REAL*8 E1,PAI,H,T,T1,T2,S1,S2,P,Q
PAI=3.1415926
IF(E1.EQ.1) THEN
KE=1.E10
RETURN
ENDIF
IF(E1.LT.1.E-20) THEN
KE=PAI/2.
RETURN
ENDIF
N=1
H=PAI/2.
Q=SQRT(1.-E1*E1*SIN(H)*SIN(H))
IF(Q.LT.1.E-35) Q=1.E35
Q=1./Q
T1=.5*H*(1+Q)
S1=T1
FLG=1
DO WHILE(FLG.EQ.1)
P=0.
DO I=0,N-1
T=(I+0.5)*H
Q=SQRT(1.-E1*E1*SIN(T)*SIN(T))
IF(Q.LT.1.E-35) Q=1.E35
Q=1./Q
P=P+Q
END DO
T2=(T1+H*P)/2.
S2=(4.*T2-T1)/3.
IF(ABS(S2-S1).LT.ABS(S2)*1.E-7) FLG=0
T1=T2
S1=S2
N=N+N
H=.5*H
END DO
KE=S2
RETURN
END FUNCTION
REAL*8 FUNCTION EE(E1)
IMPLICIT NONE
INTEGER N,I,FLG
REAL*8 E1,PAI,H,T,T1,T2,S1,S2,P,Q
PAI=3.1415926
N=1
H=PAI/2.
IF(E1.EQ.1) THEN
EE=1.
RETURN
ENDIF
IF(E1.LT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