Fix bug in spec (files not closed).

Some files were not closed in spec at the end of the program. This
caused some troubles in runing the phagen-spec cycle several times.

A function (CLOSE_ALL_FILES) was added in misc.f to force opened
units in the range [7,200] to be closed before exiting the main
subroutine.
This commit is contained in:
Sylvain Tricot 2020-09-28 15:09:47 +02:00
parent cd3fb05932
commit 0ee6c2d791
8 changed files with 38 additions and 6 deletions

View File

@ -385,7 +385,7 @@ class _MSCALCULATOR(Calculator):
'NPH_M' : 2000, 'NPH_M' : 2000,
'NDIM_M' : 100000, 'NDIM_M' : 100000,
'N_TILT_M' : 11, # to change see extdir.f 'N_TILT_M' : 11, # to change see extdir.f
'N_ORD_M' : 200, 'N_ORD_M' : 250,
'NPATH_M' : 500, 'NPATH_M' : 500,
'NGR_M' : 10,}) 'NGR_M' : 10,})

View File

@ -14807,6 +14807,7 @@ c check = .true.
i = 1 i = 1
! !
write(6,*) 'Below is the bug!'
do do
! !
if ( r_real ( i ) > r_in ) then if ( r_real ( i ) > r_in ) then
@ -23986,3 +23987,13 @@ c
c--------------------------------- c---------------------------------
c c
subroutine my_test()
logical ok
integer u
do 11 u=0,100
inquire(unit=u, opened=ok)
if (ok) then
print *,"unit ", u, " is opened"
endif
11 continue
end subroutine

View File

@ -0,0 +1,12 @@
SUBROUTINE CLOSE_ALL_FILES()
IMPLICIT NONE
LOGICAL Ok
INTEGER U
DO U=7,200
INQUIRE(UNIT=U, OPENED=Ok)
IF (Ok) THEN
CLOSE(U)
ENDIF
ENDDO
END SUBROUTINE CLOSE_ALL_FILES

View File

@ -16,5 +16,6 @@ CF2PY INTEGER, INTENT(IN,COPY) :: N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_
& N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_) & N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_)
CALL DO_MAIN() CALL DO_MAIN()
CALL CLOSE_ALL_FILES()
END SUBROUTINE RUN END SUBROUTINE RUN

View File

@ -1227,10 +1227,14 @@ c ENDIF
ENDIF ENDIF
ENDIF ENDIF
C C
IF((ISOM.NE.0).OR.(NFICHLEC.EQ.1)) CLOSE(IUO1) CST IF((ISOM.NE.0).OR.(NFICHLEC.EQ.1)) CLOSE(IUO1)
IF(ISOM.NE.0) CLOSE(IUO2) IF(ISOM.NE.0) CLOSE(IUO2)
CST STOP CST STOP
return CST REMOVE STOP and add GOTO
CST Next line added for test
GOTO 999
C C
1 WRITE(IUO1,60) 1 WRITE(IUO1,60)
STOP STOP
@ -1553,7 +1557,7 @@ C
&ATOMS >>>>>>>>>>',/,10X,'<<<<<<<<<< ATOMS ',I4,' AND ',I4,' &ATOMS >>>>>>>>>>',/,10X,'<<<<<<<<<< ATOMS ',I4,' AND ',I4,'
&ARE IDENTICAL >>>>>>>>>>') &ARE IDENTICAL >>>>>>>>>>')
C C
END 999 END
C C
C======================================================================= C=======================================================================
C C

View File

@ -16,5 +16,7 @@ CF2PY INTEGER, INTENT(IN,COPY) :: N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_
& N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_) & N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_)
CALL DO_MAIN() CALL DO_MAIN()
CALL CLOSE_ALL_FILES()
end subroutine
END SUBROUTINE RUN

View File

@ -16,5 +16,6 @@ CF2PY INTEGER, INTENT(IN,COPY) :: N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_
& N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_) & N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_)
CALL MAIN_PHD_NS_MI() CALL MAIN_PHD_NS_MI()
CALL CLOSE_ALL_FILES()
END SUBROUTINE RUN END SUBROUTINE RUN

View File

@ -16,5 +16,6 @@ CF2PY INTEGER, INTENT(IN,COPY) :: N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_
& N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_) & N_TILT_M_, N_ORD_M_, NPATH_M_, NGR_M_)
CALL DO_MAIN() CALL DO_MAIN()
CALL CLOSE_ALL_FILES()
END SUBROUTINE RUN END SUBROUTINE RUN