fortran语言中的逻辑表达式

fortran语言中的逻辑表达式,fortran,fortran90,Fortran,Fortran90,*我正在尝试使用FORTRAN代码根据某些条件对数据集进行分组。 代码如下 gauche = 0.0 trans = 0.0 do i = 1, total_data !write(*,*) nombor(i), dihedral(i) if ( (0 > dihedral(i) < 120) .or. (-120 > dihedral(i) < 0) ) then gauche = gauche + 1 else trans = t

*我正在尝试使用FORTRAN代码根据某些条件对数据集进行分组。 代码如下

gauche = 0.0
trans = 0.0
do i = 1, total_data
!write(*,*) nombor(i), dihedral(i)

if  (   (0 > dihedral(i) < 120) .or. (-120 > dihedral(i) < 0)   )  then

    gauche = gauche +   1 
else
    trans = trans   +   1
endif       
end do

write(20,*) "Layer1_seg_total=  ",(gauche+trans)," ","gauche_seg= ",gauche,"trans_seg= trans
gauche=0.0
反式=0.0
i=1,总数据
!写(*,*)nombor(i),二面体(i)
如果((0>二面体(i)<120)。或(-120>二面体(i)<0)),则
笨拙=笨拙+1
其他的
反式=反式+1
恩迪夫
结束
写(20,*)“Layer1_seg_total=”,(gauche+trans),”,“gauche_seg=”,gauche,“trans_seg=trans
但当我编译时,我得到如下错误消息:

if  ((0 > dihedral(i) < 120) .or. (-120 > dihedral(i) < 0))  then
                      1
Error: Expected a right parenthesis in expression at (1)
population.f90:42.5:

else
    1
Error: Unexpected ELSE statement at (1)
population.f90:44.4:

endif  
   1
Error: Expecting END DO statement at (1)
if((0>二面体(i)<120)。或(-120>二面体(i)<0))则
1.
错误:在(1)处的表达式中应为右括号
人口.f90:42.5:
其他的
1.
错误:在(1)处出现意外的ELSE语句
人口.f90:44.4:
恩迪夫
1.
错误:在(1)处应为END DO语句
我找不到错误。有人能提出错误吗


注意:这不是赋值

Fortran 90有六个关系运算符:=、=、/=
这六个关系运算符中的每一个都接受两个表达式,比较它们的值,并生成.TRUE.或.FALSE.
因此,a>b 将测试改写为:

if  ( (0 > dihedral(i) .and. dihedral(i) < 120) .or. (-120 > dihedral(i) .and. dihedral(i) < 0) )  then
如果((0>二面体(i).和.二面体(i)<120)或(-120>二面体(i).和.二面体(i)<0)),则

Fortran 90有六个关系运算符:=、=、/=
这六个关系运算符中的每一个都接受两个表达式,比较它们的值,并生成.TRUE.或.FALSE.
因此,a>b 将测试改写为:

if  ( (0 > dihedral(i) .and. dihedral(i) < 120) .or. (-120 > dihedral(i) .and. dihedral(i) < 0) )  then
如果((0>二面体(i).和.二面体(i)<120)或(-120>二面体(i).和.二面体(i)<0)),则
这是什么

0 > dihedral(i) < 120
0>二面体(i)<120
如果它是a
a < x .and. x < b
a
如果是别的东西…

这是什么

0 > dihedral(i) < 120
0>二面体(i)<120
如果它是a
a < x .and. x < b
a

如果它是其他的…

您不能像这样组合表达式: a>ba>b.和.b不能这样组合表达式: a>ba>b.and.b正确,但从逻辑上讲表达式(0>x.and.x<120)和另一个表达式也没有意义。我认为它(0x.and.x<120)还有一个也没有意义。我认为它(0