Overloaded Operators#

OPERATOR(.AND.) – Specify Dimension Extent#

Synopsis

ARGS = LEN .AND. IS_UNLIM

Class

Generic elemental function.

Description

Create a dimension argument that combines an extent with its unlimited status. Use the result as the right operand of .DIM..

Arguments

LENINTEGER(INT32) OR INTEGER(INT64), INTENT(IN)
Dimension extent.

IS_UNLIMLOGICAL, INTENT(IN)
Whether the dimension is unlimited.

Return

ARGStype(dimension_argument_type)
Dimension extent and unlimited status for use with .DIM..

Example

use, non_intrinsic :: nc4f
implicit none (type, external)

type(dimension_type) :: time
integer :: length
logical :: is_unlimited

length = 24
is_unlimited = .true.
time = "time" .dim. (length .and. is_unlimited)

OPERATOR(.ATT.) – Construct an Attribute#

Synopsis

ATT = NAME .ATT. VALUE

Class

Generic function.

Description

Construct an attribute_type from a name and a scalar or rank-one supported NetCDF value.

Arguments

NAMECHARACTER(LEN=*), INTENT(IN)
Attribute name.

VALUETYPE(INTEGER(INT8, INT16, INT32, INT64), REAL(REAL32, REAL64), CHARACTER), RANK(0:1), INTENT(IN)
Supported numeric scalar or vector, or a character scalar.

Return

ATTtype(attribute_type)
Constructed attribute.

Example

use, non_intrinsic :: nc4f
implicit none (type, external)

type(attribute_type) :: units
character(len=*), parameter :: unit_name = "K"

units = "units" .att. unit_name

OPERATOR(.DIM.) – Construct a Dimension#

Synopsis

DIM = NAME .DIM. LEN
DIM = NAME .DIM. ARGS

Class

Generic elemental function.

Description

Construct a limited dimension from an extent, or a limited or unlimited dimension from an argument created by .AND..

Arguments

NAMECHARACTER(LEN=*), INTENT(IN)
Dimension name.

LENINTEGER(INT32) OR INTEGER(INT64), INTENT(IN)
Extent of a limited dimension.

ARGSTYPE(DIMENSION_ARGUMENT_TYPE), INTENT(IN)
Extent and unlimited status created by .AND..

Return

DIMtype(dimension_type)
Constructed limited or unlimited dimension.

Example

use, non_intrinsic :: nc4f
implicit none (type, external)

type(dimension_type) :: latitude
integer :: length

length = 181
latitude = "latitude" .dim. length

OPERATOR(.EXISTS.) – Test an Error Result#

Synopsis

FAILED = .EXISTS. ERR

Class

Pure elemental function.

Description

Return true when an error_type represents a failed operation.

Arguments

ERRTYPE(ERROR_TYPE), INTENT(IN)
Operation result to test.

Return

FAILEDlogical
True when the error result represents a failed operation.

Example

use, non_intrinsic :: nc4f
implicit none (type, external)

type(error_type) :: error

if (.exists. error) print *, error%msg

OPERATOR(/=) – Compare Model Objects#

Synopsis

IS_DIFF = X /= Y

Class

Generic elemental function.

Description

Return true when two attributes, dimensions, or variables are not equal.

Arguments

XTYPE(ATTRIBUTE_TYPE, DIMENSION_TYPE, VARIABLE_TYPE), INTENT(IN)
First model object.

YSAME TYPE AS X, INTENT(IN)
Second model object.

Return

IS_DIFFlogical
True when the model objects differ.

Example

use, non_intrinsic :: nc4f
implicit none (type, external)

type(dimension_type) :: observed, expected

if (observed /= expected) print *, "Values differ."

OPERATOR(==) – Compare Model Objects#

Synopsis

IS_EQUAL = X == Y

Class

Generic elemental function.

Description

Return true when two attributes, dimensions, or variables are equal.

Arguments

XTYPE(ATTRIBUTE_TYPE, DIMENSION_TYPE, VARIABLE_TYPE), INTENT(IN)
First model object.

YSAME TYPE AS X, INTENT(IN)
Second model object.

Return

IS_EQUALlogical
True when the model objects are equal.

Example

use, non_intrinsic :: nc4f
implicit none (type, external)

type(dimension_type) :: reference, candidate

if (reference == candidate) print *, "Values match."