Operators

  • Austin C Bullock

Operator interfaces

Description: Extended operators for convenient string manipulations.

Concatenation (// and +)

For x and y scalars or arrays of any compatible rank, and of any combination of type character and String:

result = x // y
result = x + y

Note

Concatenation of mixed type will return a String.

Excision (-)

For x and y scalars or arrays of any compatible rank, and of any combination of type character and String:

result = x - y

Note

Excision always returns a String value even when both arguments are of type character. This ensures that excision can be performed elementally even for character values, which would not be well-defined with a return type of character. For two scalar character values, one may simply perform the conversion result = str(x - y) to return a scalar character.

Note

String arithmetic is not associative, commutative, or distributive in general:

  • (Associative) (x + y) + z == x + (y + z) and x + (y - z) /= (x + y) - z are both .true. in general.
  • (Commutative) x + y /= y + x and x + y - z /= x - z + y are both .true. in general.
  • (Distributive) x - (y + z) /= x - y - z is .true. in general.

Repetition (**)

For x a scalar or array of any rank, and of type character or String:

result = x**ncopies
  • ncopies is of type integer

Note

The ** operator is a wrapper for the repeat intrinsic, and extended for type String.

Equivalence (==)

For x and y scalars or arrays of any compatible rank, and of any combination of type character and String:

result = (x == y)
result = (x .eq. y)

Non-equivalence (/=)

For x and y scalars or arrays of any compatible rank, and of any combination of type character and String:

result = (x /= y)
result = (x .ne. y)