Close file.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(file_object), | intent(inout) | :: | self | File object. |
subroutine close(self)
!< Close file.
class(file_object), intent(inout) :: self !< File object.
if (self%is_initialized) then
if (self%is_connected) then
close(unit=self%file_unit)
self%file_unit = 0
self%is_connected = .false.
else
write(stderr, '(A)') 'error: file "'//self%file_name//'" is not connected, thus its unit cannot be closed'
self%error%status = ERROR_NOT_CONNECTED
endif
else
write(stderr, '(A)') 'error: file is not initialized, thus its unit cannot be closed'
self%error%status = ERROR_NOT_INITIALIZED
endif
endsubroutine close