我有一个关于Fortran90
中输入文件的参数值的问题:
有关输入文件的部分是:
# If use_phyical set physical densities in baryons, CDM and neutrinos + Omega_k
use_physical = F
ombh2 = 0.022445
omch2 = 0.12055785438700001
omnuh2 = 0.000645145613
omk = 0.0
hubble = 67.0
#if use_physical = F set parameters as here
omega_baryon = 0.05
omega_cdm = 0.2685627651944076
omega_lambda = 0.6800000648055924
omega_neutrino = 0.00143717
隐含问题的参数是use_physical
,我希望每次运行都默认设置为F
(实际上,我通过改变omega_cdm
参数来进行多次运行)。
在读取输入参数的代码部分下面(请参见上文)。
write(*,*) '0) Ini%Read_Double use_physical = ', Ini%Read_Logical('use_physical', .false.)
if (Ini%Read_Logical('use_physical', .false.) .eqv. .false.) then
write(*,*) '1.1) Ini%Read_Double use_physical = ', Ini%Read_Logical('use_physical', .false.)
P%ombh2 = Ini%Read_Double('omega_baryon')*(P%H0/100)**2
P%omch2 = Ini%Read_Double('omega_cdm')*(P%H0/100)**2
P%omnuh2 = Ini%Read_Double('omega_neutrino')*(P%H0/100)**2
P%omk = ((P%H0/100)**2 - P%ombh2 - P%omch2 - P%omnuh2 - Ini%Read_Double('omega_lambda')*(P%H0/100)**2)/(P%H0/100)**2
write(*,*) 'Computing with use_physical = false'
write(*,*) '1.2) Ini%Read_Double use_physical = ', Ini%Read_Logical('use_physical', .false.)
else
write(*,*) '2) Ini%Read_Double use_physical = ', Ini%Read_Logical('use_physical', .false.)
P%ombh2 = Ini%Read_Double('ombh2')
P%omch2 = Ini%Read_Double('omch2')
P%omnuh2 = Ini%Read_Double('omnuh2')
P%omk = Ini%Read_Double('omk')
end if
在执行上面的程序时,如果我设置为use_physical = F
,则会得到以下输出(使用的是不同的write(*,*)
:]
0) Ini%Read_Double use_physical = F
1.1) Ini%Read_Double use_physical = F
Computing with use_physical = false
1.2) Ini%Read_Double use_physical = F
我不理解Ini%Read_Logical('use_physical', .false)
的值:如果use_physical = F
,它应该等于TRUE
布尔值,不是吗?
为什么下面的条件对于use_physical = F
等于true:
if (Ini%Read_Logical('use_physical', .false.) .eqv. .false.)
对我来说,应该是:
1)if (Ini%Read_Logical('use_physical', .false.) .eqv. .true.)
或等效的:
2)if (Ini%Read_Logical('use_physical', .false.))
具有1)和2)均表示use_physical = F
:但上述write(*,*)
的输出似乎相反:当if (Ini%Read_Logical('use_physical', .false.) .eqv. .false.)
时条件use_physical = F
为真。
问题1)我不明白,如果有人能找到对此问题的解释。
问题2)从您的角度来看,::返回的类型是什么?
Ini%Read_Logical('use_physical', .false.)
我尝试使用条件:
if (Ini%Read_Logical('use_physical', .false.) == 'T')
或
if (Ini%Read_Logical('use_physical', .false.) .eq. .true)
但是出现编译错误
PS:抱歉,我没有立即找到Ini%Read_Logical
例程的实现,但这是逻辑上的说法,当Ini%Read_Logical('use_physical', .false.)
时use_physical = F
为真,而不是相反。
欢迎任何帮助,致谢
我在Fortran90中有一个有关输入文件参数值的问题:有关输入文件的部分是:#如果use_phyical在重子,CDM和中微子中设置物理密度+ ...