我有一个包含一些实数乘法事件的代码,无论输入变量如何,我总是得到该特定子程序的答案零。
所有变量都是real*4
类型声明的,并且具有类似于a = 5,b = 3.5& C = 0.0005。
我正在使用Plato IDE
`
Subroutine Load_Modulation_100()
Real*4 :: Te
Real*4 :: Ee
Real*4 :: Et
Real*4 :: QLHV
Real*4 :: mfg
Real*4 :: Qfeul
Real*4 :: mf
Real*4 :: Pe
Real*4 :: Pt
Te = 100
Ee = 28.2
mf = 0.0005
QLHV = 47141
Et = 66.8
Cpfg = 4.5
Qfeul = (mf * QLHV)
Pe = (Qfeul * (Ee / 100))
Pt = (Qfeul * (Et / 100))
Write (*,*) Pe, 'kW'
Write (*,*) Pt, 'kW'
End Subroutine Load_Modulation_100`
答案 0 :(得分:0)
可能不是这种情况,但整数截断可能是一个问题...... 我会更明确,也许可以使用一些调试。
Subroutine Load_Modulation_100()
IMPLICIT NONE
Real*4 :: Te
Real*4 :: Ee
Real*4, PARAMETER :: Et = 66.8E0
Real*4 :: QLHV
Real*4 :: mfg
Real*4 :: Qfeul
Real*4 :: mf
Real*4 :: Pe
Real*4 :: Pt
LOGICAL*4 :: IO = .TRUE.
! Te = 100 ! This is a float, it just does;t jump off the page as one
Te = 100.0E0 !
Ee = 28.2
mf = 0.0005
QLHV = 47141 ! This is a float, it just does't jump off the page as one
!Moved to parameter Et = 66.8
Cpfg = 4.5
IF(IO) WRITE(*,*)' (Ee / 100)=', (Ee / 100)
Qfeul = (mf * QLHV)
! Pe = (Qfeul * (Ee / 100))
Pe = (Qfeul * (Ee / FLOAT(100)))
! Pt = (Qfeul * (Et / 100))
Pt = (Qfeul * (Et / 100.0E0))
Write (*,*) Pe, 'kW'
Write (*,*) Pt, 'kW'
RETURN
End Subroutine Load_Modulation_100!`