Skip to content

Commit

Permalink
improvment of the File_m
Browse files Browse the repository at this point in the history
  • Loading branch information
lauvergn committed Mar 27, 2023
1 parent b4064fa commit 25ff805
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,7 @@ BaseName := QDUtilLib
.PHONY: zip
zip: cleanall
test -d $(ExtLibSAVEDIR) || (echo $(ExtLibDIR) "does not exist" ; exit 1)
cd $(ExtLibSAVEDIR) ; rm -rf $(BaseName)_devloc
mkdir $(ExtLibSAVEDIR)/$(BaseName)_devloc
cp -r * $(ExtLibSAVEDIR)/$(BaseName)_devloc
cd $(ExtLibSAVEDIR) ; zip -r Save_$(BaseName)_devloc.zip $(BaseName)_devloc
cd $(ExtLibSAVEDIR) ; rm -rf $(BaseName)_devloc
$(ExtLibSAVEDIR)/makezip.sh $(BaseName)
cd $(ExtLibSAVEDIR) ; ./cp_QDUtil.sh
@echo " done zip"
#===============================================
Expand Down
4 changes: 4 additions & 0 deletions SRC/File/File_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,13 @@ SUBROUTINE QDUtil_file_close(ffile)

inquire(unit=ffile%unit,OPENED=op)
IF (op) close(ffile%unit)
ffile%unit = 0

IF (ffile%nb_thread > 1) THEN
DO ith=0,ffile%nb_thread-1
inquire(unit=ffile%tab_unit(ith),OPENED=op)
IF (op) close(ffile%tab_unit(ith))
ffile%tab_unit(ith) = 0
END DO
END IF
ffile%init = .FALSE.
Expand Down Expand Up @@ -655,12 +657,14 @@ SUBROUTINE QDUtil_file_delete(ffile)
CALL file_open(ffile,unit)

close(unit,status='delete')
ffile%unit = 0
!write(out_unit,*) 'delete file: ',unit,file%name

IF (ffile%nb_thread > 1) THEN
DO ithread=0,ffile%nb_thread-1
nio = ffile%tab_unit(ithread)
close(nio,status='delete')
ffile%tab_unit(ithread) = 0
!write(out_unit,*) 'delete file: ',nio,ffile%tab_name_th(ithread)
END DO
END IF
Expand Down
28 changes: 21 additions & 7 deletions SRC/NumParameters/NumParameters_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ MODULE QDUtil_NumParameters_m
integer :: in_unit = INPUT_UNIT ! Unit for the ouptput files, with the ISO_FORTRAN_ENV
integer :: out_unit = OUTPUT_UNIT ! Unit for the input files, with the ISO_FORTRAN_ENV

integer, protected :: print_level = 1 ! 0 minimal, 1 default, 2 large, -1 nothing
!integer, protected :: print_level = 1 ! 0 minimal, 1 default, 2 large, -1 nothing, -2 not initialized
integer, protected :: print_level = -2 ! 0 minimal, 1 default, 2 large, -1 nothing, -2 not initialized

integer, parameter :: Name_len = 20
integer, parameter :: Name_longlen = 50
Expand All @@ -99,11 +100,17 @@ MODULE QDUtil_NumParameters_m
END INTERFACE

CONTAINS
SUBROUTINE QDUtil_set_print_level(prtlev)
SUBROUTINE QDUtil_set_print_level(prtlev,force)
IMPLICIT NONE
integer, intent(in) :: prtlev

print_level = prtlev
integer, intent(in) :: prtlev
logical, intent(in), optional :: force
logical :: force_loc

IF (present(force)) THEN
IF (force .OR. print_level < -1) print_level = prtlev
ELSE
IF (print_level < -1) print_level = prtlev
END IF

END SUBROUTINE QDUtil_set_print_level
SUBROUTINE Test_QDUtil_NumParameters()
Expand Down Expand Up @@ -163,12 +170,19 @@ SUBROUTINE Test_QDUtil_NumParameters()
END IF
CALL Flush_Test(test_var)


! print_level
CALL set_print_level(1,force=.TRUE.)

res_test = (print_level == 1)
CALL Logical_Test(test_var,test1=res_test,info='print_level=1')

CALL set_print_level(0)
CALL set_print_level(0,force=.TRUE.)
res_test = (print_level == 0)
CALL Logical_Test(test_var,test1=res_test,info='set_print_level(0)')
CALL set_print_level(2)
res_test = (print_level == 0)
CALL Logical_Test(test_var,test1=res_test,info='set_print_level(0)')
CALL set_print_level(1,force=.FALSE.)
res_test = (print_level == 0)
CALL Logical_Test(test_var,test1=res_test,info='set_print_level(0)')
CALL Flush_Test(test_var)
Expand Down

0 comments on commit 25ff805

Please sign in to comment.