我正在尝试编译一些Fortran代码,但我一直在使用FORMAT语句出错。它说我缺少括号和字符,但它看起来很好。我正在用silverfrost编译它。代码如下所示:
! PROGRAM TO SOLVE DEEP-BED DRYING MODEL
!
! BASIC STATEMENTS
!
CHARACTER*20 FiIe1, File2
COMMON AMo
COMMON /DENS/ Pmo, Pme
COMMON /THICK/ dxo, Dxe
DIMENSION AM1(50), AM2(50), T(50), Gs(51), Vs(51), Ts(51), Dx(50), X(50)
!
!To define a number of statement functions
AMe(Ts)=0.62*EXP(-1.116*(Ts-100)**0.3339)
A(Ts, Vs)=(1.2925-0.00058*Ts) * (0.9991-0.0963*Vs)
AK(Ts, Vs)=(0.00273*Ts-0.2609)*(2.0984*Vs+0.2174)
AN(Ts)=0.00222*Ts+0.9599
Ps(Ts)=0.7401-0.001505*Ts
!
!INPUT SECTION OF THE PROGR.A,M
!
PRINT*, 'Input the mass of the sample (g) :'
READ*, Wo
PRINT*, 'Input the initial moisture content (db):'
READ*, AMo
PRINT*, 'lnput the depth of the sample bed (mm):'
READ*, Xo
PRINT*, 'Input the number of layers in the bed:'
READ*, Nx
PRINT*, 'Input the steam temperature at inlet (oC):'
READ*, Tso
PRINT*, 'input the steam flow rate at inlet (kg/(m2.s)):'
READ*, Gso
PRINT*, 'lnput the expected drying time (min):'
READ*, Timeo
PRINT*, 'lnput the time interval- (min) :'
READ*, Dt
!
! TO DEFINE AND OPEN DATA FILES
!
PRINT*, 'Name for the file recording the simulation +process:'
READ*, File1
OPEN (1, FILE=File1)
PRINT*, 'Name for the file recording major data:'
READ*, File2
OPEN (2, FILE=File2)
!
! TO WRITE INPUTTED PARAMETERS IN THE DATA FILES
!
WRITE (1, *) 'Mass of sample:', Wo, ' g'
WRITE (1, *) 'Initial moisture content:', AMo, ' kg/kg'
WRITE (1, *) 'Depth of sample bed:', Xo, 'mm'
WRITE (1, *) 'Number of layers in sample bed:', Nx
WRITE (1, *) 'Steam temperature at inlet', Tso, 'deg C'
WRITE (1, *) 'Steam flow rate at inlet', Gso, 'kg/m2s'
WRITE (1, *) 'Expected drying time', Timeo, ' min'
WRITE (1, *) 'Time interval:', Dt, ' min'
!
WRITE (2, *) 'Mass of sample', Wo, 'g'
WRITE (2, *) 'Initial moisture content', AMo, 'kg/kg'
WRITE (2, *) 'Depth of sample bed', Xo, 'mm'
WRITE (2, *) 'Number of layers in sample bed', Nx
WRITE (2, *) 'Steam temperature at inlet', Tso, ' deg C'
WRITE (2, *) 'Steam flow rate at inlet', Gso, ' kg/m2*s'
WRITE (2, *) 'Expected drying time', Timeo, ' min'
WRITE (2, *) 'Time interval:', Dt, ' min'
!
!BASIC CALCULATION BASED ON THE INPUT DATA
!
Dxo=Xo/1000/Nx
Dxe=0.867*Dxo
D1=0.066
Pmo=4*(Wo/l000)/(3.14159*D1**2*(Xo/1000)*(1+AMo))
Pme=Pmo/0.867
AMeo=AMe(Tso)
NT=NINT(Timeo/Dt)
Pso=Ps(Tso)
Vso=Gso/Pso
!
!TO SET VALUES FOR SOME PHYSTCAL AND THERMODYNAMTC PROPERTIES
!
Cs=2000
Cw1=4193
Cw=4313
C=1245
!
!TO CALCULATE THE INTTIAL MOISTURE CONTENT CONSIDERING STEAM CONDENSATION
!
AMo1=AMo+(C+Cw1*AMo)/(2257000+Cs*(Tso-100))*(100-10)
!
!TO SET JUDGE CRITERION FOR TERMINATING THE DRYING OF A LAYER
!(A small difference between moisture content and equilibrium moisture content)
DM=0.0001
!
!MAJOR DERIVATION FOR DRYING SIMULATION
!
J=0
Time=0
m=1
!
WRITE(2, 100)
100 FORMAT(4H J, 9H T(min), 8H M(db),7H Gs , 10H Ts(C) ,9H Front1, 5H L1, 9H Front2, 5h L2, 9H Depth)
!
200 m5=m-1
IF (J .GT. Nt) GO to 800
!
PRINT*, ' '
PRINT*, ' '
PRINT*, 'Time inverval:', J, ' Drying time:', Time, ' min'
WRITE(1, x) ' '
WRITE(1, *) 'Time interval:', J, ' Drying time:', Time, ' min'
WRITE(*, 300)
WRITE(1, 300)
300 FORMAT(1x, 3H, I, 7H, X(i), 8H M(i), 10H T(i), 10H Gs(i), 8H Ts(i))
!
AveM=0
!
! For dried region
!
IF(m .GT. 1) THEN
DO 500 i=1, m-1
Dx(i)=Dxe
X(i)=(i-0.5)*Dxe
AM1(i)=AM2(i)
T(i)=Tso
Gs(i)=Gso
Vs(i)=Vso
Ts(i)=Tso
AveM=AveM+AM1(i)
WRITE(*, 400) i, X(i), AM1(i), T(i), Gs(i), Ts(i)
WRITE(1, 400) i, X(i), AM1(i), T(i), Gs(i), Ts(i)
400 FORMAT(1X, I3, 2X, F6.4, 2X, F6.4, 2X, F8.3, 2X, F7.3, 2X, F7.3)
500 CONTINUE
ENDIF
! Calculation of the drying front position
IF (m .EQ. l) THEN
X1=-1
No1=-1
ELSE
Xl=X(m-1)+Dx(m-1)/2
No1=m-1
ENDIF
!
IF (m .GT. Nx) GO TO 900
!
Ts(m)=Tso
Vs(m)=Vso
L=0
DO 600 i=m, Nx
IF(L .NE.0) GO TO 510
!
! For drying region
!
If (J .EQ. O) THEN
Am1(i)=AMo1
Else
AM1(i)=AM2(i)
ENDIF
Dx(i)=Dxx(AM1(i))
IF (i .EQ. 1) THEN
X(i)=Dx(i)/2
ELSE
X(i)=X(i-1)+Dx(i-1)/2+Dx(i)/2
ENDIF
!
! To define transition variables
!
AMe5=AMe(Ts(i))
A5=A(Ts(i),Vs(i))
AK5=AK(Ts(i),Vs(i))
AN5=AN(Ts(i))
Ps5=Ps(Ts(i))
P5=P(AMl(i))
Dt5=Dt* 60
!
! Derivation
!
AMmax=A5*(AMo-AMe5)/EXP((AN5-1)/AN5)+AMe5
IF (AM1(i) .GE. AMmax) THEN
AM2(i)=AM1(i)-Dt5*AK5*AN5*(AMmax-AMe5)*(ALOG(A5*(AMo-AMe5)/(AMmax-AMe5))/AK5)**((AN5-1)/AN5)/60
ELSE
AM2(i)=AM1(i)-Dt5*AK5*AN5*(AM1(i)-AMe5)*(ALOG(A5*(AMo-AMe5)/(AM1(i)-AMe5))/AK5)**((AN5-1)/AN5)/60
ENDIF
DR=(AM2(i)-AM1(i))/Dt5
!
IF (AM1(i) .GE. AMo) THEN
T(i)=100
DerT=0
ELSE
T(i)=Tso-(Tso-100)*(AM1(i)-AMeo)/(AMo-AMeo)
DerT=-(Tso-l00)/(AMo-AMeo)*DR
ENDIF
!
Gs(i)=Vs(i)*Ps5
Gs(i+l)=Gs(i)-Dx(i)*P5*DR
Vs(i+1)=Gs(i+1)/Ps5
Hv5=Hv(AMl(i), T(i))
Ts(i+1)=Ts(i)+Dx(i)*P5*(Hv5+Cs*(Ts(i)-T(i)))/(Gs(i)*Cs)*DR-Dx(i)*P5*(C+Cw*AMl(i))/(Gs(i)*Cs)*DerT
!
! To find the first layer in wet region
!
IF (Ts(i+l) .LE. l00) THEN
Ts(i+1)=100
L=i
ENDIF
!
! To check if the layer has been dried to equilibrium
!
IF ((AM2(i)-AMeo) .LE. DM) THEN
m5=i
AM2(i)=AMeo
ENDIF
GO TO 520
!
! For wet region
!
510 AM1(i)=AMo1
AM2(i)=AMo1
T(i)=100
Gs(i+l)=Gs(i)
Vs(i+1)=Vs(i)
Ts(i+1)=100
!
Dx(i)=Dxx(AM1(i))
IF (i .EQ. 1) THEN
X(i)=Dx(i)/2
ELSE
X(i)=X(i-1)+Dx(i-1)/2+Dx(i)/2
ENDIF
!
520 AveM=AveM+AM1(i)
WRITE(*, 400) i, X(i), AM1(i), T(i), Gs(i), Ts(i)
WRITE(1, 400) i, X(i), AM1(i), T(i), Gs(i), Ts(i)
600 CONTINUE
!
! Calculation of wet front position
IF (L .EQ. O) THEN
X2=-1
No2=-1
ELSE
X2=X(L)+Dx(L)/2
No2=L+1
ENDIF
!
AveM=AveM/Nx
Depth=X(Nx)+Dx(Nx)/2
!
WRITE(*, 100)
WRITE(*, 700) J, Time, AveM, Gs(Nx*1), Ts(Nx*1), XI, No1, X2, No2, Depth
WRITE (2, 700) J, Time, AveM, Gs(Nx+1), Ts(Nx*1), X1, No1, X2, No2, Depth
700 FORMAT(I4, 2X, F7.3, 2X, F6.4, 2X, F6.4, 2X, F7.3, 2X, F7.4, 2x, I3, 2X, F7.4, 2X, I3, 2x, F7.4)
!
J=J+1
Time=Time+Dt
m=m5+1
GO TO 200
!
800 PRINT*, ' '
PRINT*, 'The drying time was up to the specified time.'
PRINT*, 'The drying simulation was stopped.'
PRINT*, 'The sample was not dried to equilibrium'
WRITE(1,*) ' '
WRITE(1,*) 'The drying time was up to the specified time.'
WRITE(1,*) 'The drying simulation was stopped'
WRITE(1,*) 'The sample was not dried to equilibrium'
WRITE(1,*) ' '
WRITE(2,*) 'The drying time was up to the specified time'
WRITE(2,*) 'The drying simulation was stopped'
WRITE(2,*) 'The drying simulation was stopped'
WRITE(2,*) 'The sample was not dried to equilirbium'
GO TO 910
!
900 No2=-1
X2=-1
AveM=AveM/Nx
WRITE(*, 100)
WRITE(*, 700) J, Time, AveM, Gs(Nx+1), Ts(Nx+1), X1, No1, X2, No2, Depth
WRITE(2, 700) J, Time, AveM, Gs(Nx+1), Ts(Nx+1), X1, No1, X2, No2, Depth
!
PRINT*, ' '
PRINT*, 'The sample was dried to equilibrium'
PRINT*, 'The drying simulation was stopped.'
WRITE(1,*) ' '
WRITE(1,*) 'The sample was dried to equilibrium'
WRITE(1,*) 'The drying simulation was stopped'
WRITE(2,*) ' '
WRITE(2,*) 'The sample was not dried to equilirbium'
WRITE(2,*) 'The drying simulation was stopped'
!
910 CLOSE(1)
CLOSE(2)
END
!
!**********************************************************************************
!
! EXTERNAL FUNCTION FOR LATENT HEAT OF EVAPORATION
!
FUNCTION Hv(AM, T)
Hfg=2257000-2916.7*(T-100)
IF (AM .GE. 0.2) THEN
Hv=Hfg
ELSE
Hv=Hfg*(1+EXP(-19.9*AM))
ENDIF
RETURN
END
!
! EXTERNAL FUNCTION FOR BULK DENSITY
!
FUNCTION P(AM)
COMMON AMo/DENS/ Pmo, Pme
IF (AM .GE. AMo) THEN
P=Pmo
ELSE IF (AM .LT. 0.11) THEN
P=Pme
ELSE
P=Pmo-(Pmo-Pme)*(AMo-AM)/(AMo-0.11)
ENDIF
RETURN
END
!
! EXTERNAL FUNCTION FOR LAYER THICKNESS
!
FUNCTION Dxx(AM)
COMMON AMo/THICK/ Dxo, Dxe
IF (AM .GE. AMO) THEN
Dxx=Dxo
ELSE IF (AM .LT. 0.11) THEN
Dxx=Dxe
ELSE
Dxx=Dxo-(Dxo-Dxe)*(AMo-AM)/(AMo-0.11)
ENDIF
RETURN
END
!
!****************************************************************************************
错误如下所示:
Compiling and linking file: SHSDRYING.F95
C:\Users\steva\Desktop\SHSDRYING.F95(104) : error 58 - Unpaired right bracket(s)
C:\Users\steva\Desktop\SHSDRYING.F95(45) : error 259 - Scalar, default-kind, CHARACTER expression expected for the FILE keyword
C:\Users\steva\Desktop\SHSDRYING.F95(45) : warning 868 - Opening unit 1 may affect the operation of input from the default unit '*' - are you sure you want to do this?
C:\Users\steva\Desktop\SHSDRYING.F95(48) : warning 868 - Opening unit 2 may affect the operation of output to the default unit '*' - are you sure you want to do this?
C:\Users\steva\Desktop\SHSDRYING.F95(116) : warning 792 - Comma missing in format
C:\Users\steva\Desktop\SHSDRYING.F95(116) : warning 792 - Comma missing in format
C:\Users\steva\Desktop\SHSDRYING.F95(116) : error 270 - Missing width count for 'G' descriptor
C:\Users\steva\Desktop\SHSDRYING.F95(116) : warning 792 - Comma missing in format
C:\Users\steva\Desktop\SHSDRYING.F95(116) : error 274 - Unknown edit descriptor '(', or missing comma
C:\Users\steva\Desktop\SHSDRYING.F95(292) : warning 868 - Closing unit 1 may affect the operation of input from the default unit '*' - are you sure you want to do this?
C:\Users\steva\Desktop\SHSDRYING.F95(293) : warning 868 - Closing unit 2 may affect the operation of output to the default unit '*' - are you sure you want to do this?
C:\Users\steva\Desktop\SHSDRYING.F95(103) : error 90 - FORMAT label 100 does not exist
Compilation failed.
答案 0 :(得分:2)
单元5,6和1,2(和其他)保留...如果你使UNIT = 1变为UNIT = 21而UNIT = 2变为UNIT = 22它将起作用。
最好使用NEWUNIT
! PROGRAM TO SOLVE DEEP-BED DRYING MODEL
!
! BASIC STATEMENTS
!
PROGRAM DEEP_BED_DRYING !New
IMPLICIT NONE !New
CHARACTER*20 FiIe1, File2
COMMON AMo
COMMON /DENS/ Pmo, Pme
COMMON /THICK/ dxo, Dxe
...
OPEN (NEWUNIT=MyUnit1, FILE=File1) !New
WRITE(*,*)' Unit1=',MyUnit1 !New
...
OPEN (NEWUNIT=MyUnit2, FILE=File2) !New
WRITE(*,*)' Unit2=',MyUnit2 !New
enter code here
!WRITE(1,*) ...
WRITE(MyUnit1,*) ...
IMPLICIT NONE不是一个习惯使用的坏习惯。 为了便于阅读,我会把事情排成一行......
WRITE (1, *) 'Mass of sample:' , Wo , ' g'
WRITE (1, *) 'Initial moisture content:' , AMo , ' kg/kg'
WRITE (1, *) 'Depth of sample bed:' , Xo , 'mm'
WRITE (1, *) 'Number of layers in sample bed:' , Nx
WRITE (1, *) 'Steam temperature at inlet' , Tso , 'deg C'
WRITE (1, *) 'Steam flow rate at inlet' , Gso , 'kg/m2s'
WRITE (1, *) 'Expected drying time' , Timeo , ' min'
WRITE (1, *) 'Time interval:' , Dt , ' min'
您需要使用-132进行编译或使用行继续...
.F77或固定编译器开关(任何n列#6):
WRITE(2, 100)
100 FORMAT(4H J, 9H T(min), 8H M(db),7H Gs , 10H Ts(C) ,
!234567
& 9H Front1, 5H L1, 9H Front2, 5h L2, 9H Depth)
.F90或 - 免费编译器开关(& at the end):
WRITE(2, 100) !Here
100 FORMAT(4H J, 9H T(min), 8H M(db),7H Gs , 10H Ts(C) , &
!234567
9H Front1, 5H L1, 9H Front2, 5h L2, 9H Depth)
答案 1 :(得分:2)
程序中的FORMAT语句使用Hollerith编辑描述符,这是从Fortran 95开始从语言中删除的功能。这些都是非常容易出错的 - 应该使用字符串编辑描述符。
Hollerith编辑描述符的形式为 n Hxxx - 其中H
后面的 n 字符等同于字符文字。已识别语句(至少)的问题在于,用于关闭格式语句的括号被视为文字的一部分 - 可能是因为已从源中删除了空格或类似内容。
100 FORMAT(...9H Depth)
123456789
错误消息还标识名为File1
的变量不适合作为open语句中的FILE =说明符。这是因为File1
没有变量声明,所以假设它是REAL类型。有一个变量FiIe1
的声明。 IMPLICIT NONE
有助于发现这些拼写错误,但代码显然是使用隐式类型编写的。
这些错误表明来源来自光学字符识别或类似。如果是这样,您需要非常注意源中其他地方的OCR错误。