fileclose Subroutine

public subroutine fileclose(lun, ier)

simple close of a LUN. On error show message and stop (by default)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: lun
integer, intent(out), optional :: ier

Source Code

subroutine fileclose(lun,ier)
integer,intent(in)    :: lun
integer,intent(out),optional :: ier
character(len=256)    :: message
integer               :: ios
    if(lun/=-1)then
        close(unit=lun,iostat=ios,iomsg=message)
        if(ios/=0)then
            if(present(ier))then
               ier=ios
            else
               call fpm_stop(4,'*fileclose*:'//trim(message))
            endif
        endif
    endif
end subroutine fileclose