Operators & Expressions

6.1 Arithmetic

right-associative: 232 = 2**9 multiply, divide integer / truncates toward zero add, subtract (also unary)

print *, 7 / 2, 7.0 / 2, mod(7, 3), modulo(-7, 3), 2**10, 2.0**0.5

6.3 Logical

.not., .and., .or., .eqv., .neqv. ⚠️ Fortran does not guarantee short-circuit evaluation: if (i <= n .and. a(i) > 0) may evaluate a(i) even when i > n. Use nested ifs (or, in Fortran 2023, conditional expressions).

6.4 Character operator

// concatenation: full = trim(first) // " " // trim(last).

6.5 Precedence (high → low)

user-defined unary operators binary + - relational (==, <,...) .eqv. .neqv. user-defined binary operators