我正在尝试用 Fortran 创建一个程序,但是当我创建这个函数时
real(KIND=bigreal) FUNCTION ma(M)
real(KIND=bigreal) uma, M
uma = M*(1/1000)*(1/Na)
ma = uma
RETURN
END FUNCTION ma
它说该函数有这个错误
23 | real(KIND=bigreal) FUNCTION ma(M)
| 1
Error: Syntax error in data declaration at (1)
这是完整的代码,可以更好地理解问题
Program programa
integer, parameter :: bigreal = SELECTED_REAL_KIND(R=100)
real(KIND=bigreal), PARAMETER:: T = 298 !En grados Kelvin
real(KIND=bigreal), PARAMETER :: Na = 6.022E23 !Unidad mol
real(KIND=bigreal), PARAMETER :: kb = 1.38E-23 !Unidad J/k
real(KIND=bigreal), PARAMETER :: h = 6.626E-34 !Unidad J*s
real(KIND=bigreal), PARAMETER :: pi = 3.1416
real(KIND=bigreal), PARAMETER :: R = 8.31446
real :: conf
conf = S1
PRINT *, 'El valor de la constante de Avogadro es:', h
real(KIND=bigreal) FUNCTION ma(M)
real(KIND=bigreal) :: uma
real(KIND=bigreal), intent :: M
uma = M*(1/1000)*(1/Na)
ma = uma
RETURN
END FUNCTION ma
real(KIND=bigreal) FUNCTION VOL()
real(KIND=bigreal) v
v = (Na*kb*T)/100000.0
VOL = v
RETURN
END
real(KIND=bigreal) FUNCTION TRAS(V1, M1)
real(KIND=bigreal) V1, M1, q
q = (((2.0*pi*M1*kb*t)/(h**2.0))**(1.5))*V1
TRAS = q
RETURN
END FUNCTION
real(KIND=bigreal) FUNCTION Stras (Q1)
real(KIND=bigreal) Q1, s
s=kb*LOG(Q1*EXP(1.5))
Stras = s
RETURN
END FUNCTION Stras
real(KIND=bigreal) FUNCTION Gtras (Q2)
real(KIND=bigreal) g, Q2
g = kb*T*LOG(EXP(1.0)/Q2)
Gtras = g
RETURN
END FUNCTION Gtras
real(KIND=bigreal) FUNCTION U ()
real(KIND=bigreal) u1
u1 = kb*T*1.5
U = u1
RETURN
END FUNCTION U
real(KIND=bigreal) FUNCTION Sele (deg1)
real(KIND=bigreal) sel
sel = kb*LOG(deg1)
Sele = sel
RETURN
END FUNCTION Sele
real(KIND=bigreal) FUNCTION Gele (deg1)
real(KIND=bigreal) gel
gel = kb*T*LOG(EXP(1.0)/deg1)
Gele = gel
RETURN
END FUNCTION Gele
real(KIND=bigreal) FUNCTION Scombi(vtras, deg2)
real(KIND=bigreal) scomb, vtras, deg2
scomb = (2.5*R) + R*LOG(vtras*(deg2/Na))
Scombi = scomb
RETURN
END FUNCTION Scombi
real(KIND=bigreal) FUNCTION Gcombi(vtras1, deg3)
real(KIND=bigreal) gcomb, vtras1, deg3
gcomb = -kb*T*LOG(vtras*deg2)
Gcombi = gcomb
RETURN
END FUNCTION Gcombi
end Program programa
我决定使用它,因为我必须使用的值非常小
我尝试用谷歌搜索错误,但似乎没有什么用处
我解决了似乎我在打印和第一个函数之间缺少一个 Contains