From 8d044840a1e0f2196115da64dad61789b6c7f47b Mon Sep 17 00:00:00 2001 From: william-dawson Date: Mon, 16 Nov 2020 19:23:49 +0900 Subject: [PATCH] Initial offset feature and fixed file bug (#162) --- Source/Fortran/LoggingModule.F90 | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Source/Fortran/LoggingModule.F90 b/Source/Fortran/LoggingModule.F90 index eb166de6..2cb24664 100644 --- a/Source/Fortran/LoggingModule.F90 +++ b/Source/Fortran/LoggingModule.F90 @@ -8,7 +8,8 @@ MODULE LoggingModule INTEGER :: CurrentLevel = 0 LOGICAL :: IsActive = .FALSE. INTEGER :: UNIT = 6 - LOGICAL :: file_open = .TRUE. + LOGICAL :: file_open = .FALSE. + INTEGER :: initial_offset = 0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PUBLIC :: ActivateLogger PUBLIC :: DeactivateLogger @@ -18,6 +19,8 @@ MODULE LoggingModule PUBLIC :: WriteElement PUBLIC :: WriteHeader PUBLIC :: WriteListElement +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + PUBLIC :: SetInitialOffset !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! INTERFACE WriteListElement MODULE PROCEDURE WriteListElement_bool @@ -58,6 +61,7 @@ SUBROUTINE ActivateLogger(start_document_in, file_name_in, unit_in) IF (PRESENT(start_document_in)) THEN IF (start_document_in) THEN WRITE(UNIT, '(A3)') "---" + initial_offset = 1 END IF END IF END SUBROUTINE ActivateLogger @@ -69,6 +73,7 @@ SUBROUTINE DeactivateLogger CLOSE(UNIT) END IF UNIT = 6 + CurrentLevel = 0 END SUBROUTINE DeactivateLogger !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Call this subroutine when you enter into a section with verbose output @@ -80,6 +85,14 @@ END SUBROUTINE EnterSubLog SUBROUTINE ExitSubLog CurrentLevel = CurrentLevel - 1 END SUBROUTINE ExitSubLog +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !> Set a manual initial offset spacing. + SUBROUTINE SetInitialOffset(offset) + !> Number of spaces to offset + INTEGER, INTENT(IN) :: offset + + initial_offset = offset + END SUBROUTINE SetInitialOffset !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Write out a header to the log. SUBROUTINE WriteHeader(header_value) @@ -251,11 +264,14 @@ END SUBROUTINE WriteListElement_string !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Writes out the indentation needed for this level SUBROUTINE WriteIndent - INTEGER :: counter + INTEGER :: II - DO counter=1,CurrentLevel*2 + DO II=1,initial_offset + WRITE(UNIT,'(A1)',ADVANCE='NO') " " + END DO + DO II=1,CurrentLevel*2 WRITE(UNIT,'(A1)',ADVANCE='NO') " " END DO END SUBROUTINE WriteIndent !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -END MODULE LoggingModule +END MODULE LoggingModule \ No newline at end of file