Trying to organise output better

This commit is contained in:
Jorge Gonzalez 2026-03-11 19:15:58 +01:00
commit 0109dc2f06
11 changed files with 196 additions and 192 deletions

View file

@ -43,6 +43,25 @@ MODULE moduleOutput
LOGICAL:: collOutput = .FALSE.
LOGICAL:: emOutput = .FALSE.
! Prefix for iteration files
character(len=*), parameter:: prefix = 'Step'
! Column separator
character(len=*), parameter:: colSep = '","'
! General format for file outputs
character(len=*), parameter:: fmtColReal = 'ES0.6E3,:,'//colSep ! Column with real
character(len=*), parameter:: fmtColInt = 'I0,:,'//colSep ! Column with integer
character(len=*), parameter:: fmtColStr = 'A,:,'//colSep ! Column with text
character(len=*), parameter:: fmtReal = 'ES14.6E3' ! Fixed size real
character(len=*), parameter:: fmtInt = 'I14' ! Fixed size real
! File IDs for different input/output
integer, parameter:: fileID_mesh = 10 ! Base id for mesh files
integer, parameter:: fileID_output = 20 ! Base id for species/collisions/EM output
integer, parameter:: fileID_boundaryParticle = 30 ! Particle boundaries
integer, parameter:: fileID_boundaryEM = 31 ! EM boundaries
CONTAINS
PURE SUBROUTINE outputNode_equal_outputNode(self, from)
IMPLICIT NONE
@ -177,7 +196,7 @@ MODULE moduleOutput
WRITE(20, "(A1, 8X, A1, 9X, A1, 7(A20))") "#","t","n","total (s)","push (s)","reset (s)", &
"collision (s)","coulomb (s)", &
"weighting (s)","EMField (s)"
WRITE(*, "(6X,A15,A)") "Creating file: ", fileName
call informFileCreation(fileName)
CLOSE(20)
END IF
@ -194,5 +213,43 @@ MODULE moduleOutput
END SUBROUTINE printTime
PURE FUNCTION formatFileName(pref, suff, extension, timeStep) RESULT(fileName)
IMPLICIT NONE
CHARACTER(*), INTENT(in):: pref, suff, extension
INTEGER, INTENT(in), OPTIONAL:: timeStep
CHARACTER (LEN=iterationDigits):: tString
CHARACTER(:), ALLOCATABLE:: fileName
IF (PRESENT(timeStep)) THEN
WRITE(tString, iterationFormat) timeStep
fileName = pref // '_' // tString // '_' // suff // '.' // extension
ELSE
fileName = pref // '_' // suff // '.' // extension
END IF
END FUNCTION formatFileName
pure function generateFilePath(filename) result(completePath)
implicit none
character(*), intent(in):: fileName
character(:), allocatable:: completePath
completePath = path // folder // '/' // fileName
end function generateFilePath
subroutine informFileCreation(filename)
implicit none
character(*), intent(in):: fileName
write(*, "(6X,A15,A)") "Creating file: ", fileName
end subroutine informFileCreation
END MODULE moduleOutput