Skip to content

Commit

Permalink
Initial offset feature and fixed file bug (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
william-dawson authored Nov 16, 2020
1 parent b833530 commit 8d04484
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Source/Fortran/LoggingModule.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,6 +19,8 @@ MODULE LoggingModule
PUBLIC :: WriteElement
PUBLIC :: WriteHeader
PUBLIC :: WriteListElement
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
PUBLIC :: SetInitialOffset
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
INTERFACE WriteListElement
MODULE PROCEDURE WriteListElement_bool
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 8d04484

Please sign in to comment.