Fixed 0D case, reference. Put everything in the moduleOutput

This commit is contained in:
Jorge Gonzalez 2026-03-11 20:14:14 +01:00
commit 76be78c883
12 changed files with 3188 additions and 3095 deletions

View file

@ -1,6 +1,39 @@
!Contains information about output
MODULE moduleOutput
IMPLICIT NONE
! Path and folder for the output
CHARACTER(:), ALLOCATABLE:: path
CHARACTER(:), ALLOCATABLE:: folder
! Number of digits for step files
INTEGER:: iterationDigits
CHARACTER(:), ALLOCATABLE:: iterationFormat
! Triggers and counters for output
INTEGER:: triggerOutput, counterOutput = 0
INTEGER:: triggerCPUTime, counterCPUTime = 0
! logicals to activate file output
LOGICAL:: timeOutput = .FALSE.
LOGICAL:: collOutput = .FALSE.
LOGICAL:: emOutput = .FALSE.
logical:: boundaryParticleOutput = .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
integer, parameter:: fileID_reference = 40 ! Reference values
!Output for each node
TYPE, PUBLIC:: outputNode
@ -33,36 +66,68 @@ MODULE moduleOutput
END TYPE
CHARACTER(:), ALLOCATABLE:: path
CHARACTER(:), ALLOCATABLE:: folder
INTEGER:: iterationDigits
CHARACTER(:), ALLOCATABLE:: iterationFormat
INTEGER:: triggerOutput, counterOutput = 0
INTEGER:: triggerCPUTime, counterCPUTime = 0
LOGICAL:: timeOutput = .FALSE.
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 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
subroutine createOutputFolder()
implicit none
call execute_command_line('mkdir ' // path // folder )
end subroutine createOutputFolder
subroutine copyFileToOutput(fileName)
implicit none
character(*), intent(in):: fileName
call execute_command_line('cp ' // fileName // ' ' // path // folder)
end subroutine copyFileToOutput
subroutine writeCommit()
implicit none
call system('git rev-parse HEAD > ' // path // folder // '/' // 'fpakc_commit.txt')
end subroutine writeCommit
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
PURE SUBROUTINE outputNode_equal_outputNode(self, from)
IMPLICIT NONE
@ -213,43 +278,17 @@ 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)
! Write file with reference values
subroutine writeReference()
use moduleRefParam
implicit none
character(*), intent(in):: fileName
character(:), allocatable:: completePath
open (fileID_reference, file=generateFilePath('reference.csv'))
write(fileID_reference, "(*("//fmtColStr//"))") '"L_ref"','"v_ref"','"ti_ref"','"Vol_ref"','"EF_ref"','"Volt_ref"','"B_ref"'
write(fileID_reference, "(*("//fmtColReal//"))") L_ref, v_ref, ti_ref, Vol_ref, EF_ref, Volt_ref, B_ref
close(fileID_reference)
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 subroutine writeReference
END MODULE moduleOutput