The main documentation of the Finalize_Character Procedure contains additional explanation of this code listing.
subroutine Finalize_Character_0 (C, status) ! Use association information. use Caesar_Flags_Module, only: finalize_character_flag ! Input/Output variable. type(character,*), intent(inout) :: C ! Variable to be finalized. ! Output variable. type(Status_type), intent(out), optional :: status ! Exit status. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Verify requirements - none. ! Finalization. C = finalize_character_flag ! No errors for finalization possible for scalars. if (PRESENT(status)) status = 'Success' ! Verify guarantees - none. return end subroutine Finalize_Character_0 define([REPLICATE_ROUTINE],[ subroutine Finalize_Character_$1 (C, status) ! Input/Output variable. type(character,*,$1) :: C ! Variable to be finalized. ! Output variable. type(Status_type), intent(out), optional :: status ! Exit status. ! Internal variable. type(integer) :: deallocate_status ! Deallocation Status. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Verify requirements. VERIFY(ASSOCIATED(C),0) ! C should be associated. ! Deallocation. DEALLOCATE(C, stat=deallocate_status) ! Finalization and nullification. NULLIFY(C) ! Verify guarantees and/or set status flag. if (PRESENT(status)) then WARN_IF(deallocate_status /= 0, 3) ! Deallocation error check. WARN_IF(ASSOCIATED(C),3) ! C is now unassociated. if (deallocate_status == 0 .and. .not.ASSOCIATED(C)) then status = 'Success' else status = 'Memory Error' end if else VERIFY(deallocate_status == 0, 0) ! Deallocation error check. VERIFY(.not.ASSOCIATED(C), 0) ! C is now unassociated. end if return end subroutine Finalize_Character_$1 ]) REPLICATE_ARRAYS