
The FillValue class is used to indicate empty spots in field data.
MODULE FillValue_Class
TYPE FillValue
INTERFACE isValid
INTERFACE initialize
INTERFACE finalize
INTERFACE get
INTERFACE set
INTERFACE print
INTERFACE clear
INTERFACE getValue
INTERFACE hasValue
INTERFACE ASSIGNMENT (=)
INTERFACE OPERATOR (==)
INTERFACE OPERATOR (/=)
INTERFACE OPERATOR (+)
END MODULE FillValue_Class
FUNCTION isValid(this) RESULT(result)
LOGICAL :: result
TYPE(FillValue), INTENT(in) :: this
This function checks whether the parameter this contains a valid FillValue object. It may be applied to any FillValue object at any time.
SUBROUTINE initialize(this,value)
TYPE(FillValue), INTENT(out)
:: this
REAL,
INTENT(in), OPTIONAL :: value
This subroutine initializes an (invalid) FillValue object. This subroutine should be invoked on an object before any other function or subroutine except isValid. After initialization, the parameter this contains a valid FillValue object.
If the optional parameter value is provided, it will be used as the fill value. Otherwise, the fill value is not defined which means that there is no missing data in a field.
SUBROUTINE finalize(this)
TYPE(FillValue), INTENT(inout) :: this
This subroutine finalizes the (valid) FillValue object, this. This object should have been initialized earlier in the program. After finalization, the object is invalid and should not be used anymore.
SUBROUTINE get(this,has_value,value)
TYPE(FillValue), INTENT(in)
:: this
LOGICAL,
INTENT(out), OPTIONAL :: has_value
REAL,
INTENT(out), OPTIONAL :: value
This subroutine retrieves information from the FillValue object, this. The object itself is not modified. The optional parameters determine which information will be retrieved. This subroutine can be invoked without any parameters. In this case, the subroutine is as a no-op.
SUBROUTINE set(this,has_value,value)
TYPE(FillValue), INTENT(inout)
:: this
LOGICAL,
INTENT(in), OPTIONAL :: has_value
REAL,
INTENT(in), OPTIONAL :: value
This subroutine modifies the FillValue object, this. The optional parameters determine which information is modified. This subroutine can be invoked without any parameters. In this case, the subroutine is as a no-op.
SUBROUTINE print(this)
TYPE(FillValue), INTENT(in) :: this
This subroutine is the equivalent of the Fortran PRINT statement. It prints the FillValue object, this, to the standard output unit in standardized format. The object is not modified.
SUBROUTINE clear(this)
TYPE(FillValue), INTENT(inout) :: this
This subroutine clears this FillValue object. In this state, the object can be used to indicate that no data is missing.
FUNCTION getValue(this) RESULT(result)
REAL :: result
TYPE(FillValue), INTENT(in) :: this
This function returns the value that is used to indicate missing data in a field. Note that this function should only be called when the function hasValue() return the value .TRUE..
FUNCTION hasValue(this) RESULT(result)
LOGICAL :: result
TYPE(FillValue), INTENT(in) :: this
This function checks whether the FillValue object, this, has a fill value.
ASSIGNMENT (=) <left> = <right>
This operator copies the content of the FillValue object at the right of the assignment operator to the one at the left. The latter object can be invalid before the assignment. After the assignment it is valid.
OPERATOR (==) <left> == <right>
This operator compares two FillValue objects or a FillValue object with a real number or one, two or three dimensional array of real numbers for equality. When comparing with an array, each element of the array is checked.
OPERATOR (/=) <left> /= <right>
This operator compares two FillValue objects or a FillValue object with a real number or one, two or three dimensional array of real numbers for inequality. When comparing with an array, each element of the array is checked.
This operator combines two fill values. The resulting FillValue object can be used to indicate missing data in a field that is the result of combining two fields for example by addition.
The example program shows how you can create and use a FillValue object.
PROGRAM FillValue_Class_Example
USE FillValue_Class
IMPLICIT NONE
TYPE(FillValue) :: fill
REAL, DIMENSION(1:10) :: data
CALL initialize(fill,1.0e99)
data(:) = (/ ( Real(i),i=LBound(data,1),UBound(data,1) ) /)
PRINT*,"Data before: ",data(:)
WHERE (data(:) >= 4.0 .AND. data(:) <= 6.0)
data(:) = fill
END WHERE
PRINT*,"Data after: ",data(:)
WHERE (data(:) == fill)
data(:) = -1.0
END WHERE
PRINT*,"Final data: ",data(:)
CALL finalize(fill)
END PROGRAM FillValue_Class_Example