added optional error flag in output

git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@13651 c92efa57-630b-4861-b058-cf58834340f0
This commit is contained in:
pietrodelugas 2017-07-30 16:42:40 +00:00
parent ad2ee26b91
commit 3881bdc5b9
1 changed files with 7 additions and 1 deletions

View File

@ -6,16 +6,18 @@
! or http://www.gnu.org/copyleft/gpl.txt .
!
!--------------------------------------------------------------------------
FUNCTION find_free_unit()
FUNCTION find_free_unit(ierr)
!--------------------------------------------------------------------------
!
IMPLICIT NONE
!
INTEGER :: find_free_unit
INTEGER,OPTIONAL,INTENT(OUT) :: ierr
INTEGER :: iunit
LOGICAL :: opnd
!
!
find_free_unit = -1
unit_loop: DO iunit = 99, 1, -1
!
INQUIRE( UNIT = iunit, OPENED = opnd )
@ -30,6 +32,10 @@
!
END DO unit_loop
!
IF ( PRESENT( ierr )) THEN
ierr = 1
RETURN
END IF
CALL errore( 'find_free_unit()', 'free unit not found ?!?', 1 )
!
RETURN