The main documentation of the Valid_State_Integer Procedure contains additional explanation of this code listing.
define([REPLICATE_ROUTINE],[ ifelse(POINTER_TOGGLE, [TRUE], [ pushdef([TYPE], [integer,$1]) pushdef([Valid_State_Integer_P_DIM], expand(Valid_State_Integer_P_$1)) pushdef([POINTER_ONLY], []) ],[ pushdef([TYPE], [integer,$1,np]) pushdef([Valid_State_Integer_P_DIM], expand(Valid_State_Integer_NP_$1)) pushdef([POINTER_ONLY], [!]) ]) function Valid_State_Integer_P_DIM (I) result(Valid) ! Use association information. SCALAR_ONLY use Caesar_Flags_Module, only: finalize_integer_flag SCALAR_ONLY use Caesar_Logical_Class, only: ALL ! Input variable. type(TYPE) :: I ! Variable to be checked. ! Output variable. type(logical) :: Valid ! Logical state. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Start out true. Valid = .true. ! First, make sure that the variable has been allocated. POINTER_ONLY ARRAY_ONLY Valid = Valid .and. ASSOCIATED(I) POINTER_ONLY ARRAY_ONLY if (.not.Valid) return ! Make sure the variable has not been finalized. SCALAR_ONLY Valid = Valid .and. I /= finalize_integer_flag ! Check the top of the range. Valid = Valid .and. ALL(I <= HUGE(I)) ! Note that there is no explicit check for the bottom of the ! range, since there is no F90 intrinsic that returns the lowest ! negative number that an integer can take. return end function Valid_State_Integer_P_DIM popdef([TYPE]) popdef([Valid_State_Integer_P_DIM]) popdef([POINTER_ONLY]) ]) define([POINTER_TOGGLE], [TRUE]) REPLICATE define([POINTER_TOGGLE], [FALSE]) REPLICATE