*I am trying to group set of data according some condition using FORTRAN code.
The code is as below.
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
But when I compile I get error message as below:
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)
I can not trace the error. Can anyone suggest the mistake?
NOTE: this is not an assignment
Fortran 90 has six relational operators: <, <=, >, >=, ==, /=
Each of these six relational operators takes two expressions, compares their values, and yields .TRUE. or .FALSE.
Thus, a > b < c is wrong, because a < b is LOGICAL and c is REAL.
Rewrite your test as: