Fixed 0D case, reference. Put everything in the moduleOutput
This commit is contained in:
parent
0109dc2f06
commit
76be78c883
12 changed files with 3188 additions and 3095 deletions
|
|
@ -1569,35 +1569,29 @@ MODULE moduleInput
|
|||
END SUBROUTINE readParallel
|
||||
|
||||
SUBROUTINE initOutput(inputFile)
|
||||
USE moduleRefParam
|
||||
USE moduleMesh, ONLY: mesh, doubleMesh, pathMeshParticle, pathMeshColl
|
||||
USE moduleOutput, ONLY: path, folder
|
||||
USE moduleOutput, ONLY: createOutputFolder, writeReference, copyFileToOutput, writeCommit
|
||||
IMPLICIT NONE
|
||||
|
||||
CHARACTER(:), ALLOCATABLE, INTENT(in):: inputFile
|
||||
INTEGER:: fileReference = 30
|
||||
!If everything is correct, creates the output folder
|
||||
CALL EXECUTE_COMMAND_LINE('mkdir ' // path // folder )
|
||||
call createOutputFolder()
|
||||
!Copies input file to output folder
|
||||
CALL EXECUTE_COMMAND_LINE('cp ' // inputFile // ' ' // path // folder)
|
||||
call copyFileToOutput(inputFile)
|
||||
!Copies particle mesh
|
||||
IF (mesh%dimen > 0) THEN
|
||||
CALL EXECUTE_COMMAND_LINE('cp ' // pathMeshParticle // ' ' // path // folder)
|
||||
call copyFileToOutput(pathMeshParticle)
|
||||
IF (doubleMesh) THEN
|
||||
CALL EXECUTE_COMMAND_LINE('cp ' // pathMeshColl // ' ' // path // folder)
|
||||
call copyFileToOutput(pathMeshColl)
|
||||
|
||||
END IF
|
||||
|
||||
END IF
|
||||
|
||||
! Write commit of fpakc
|
||||
CALL SYSTEM('git rev-parse HEAD > ' // path // folder // '/' // 'fpakc_commit.txt')
|
||||
call writeCommit()
|
||||
|
||||
! Write file with reference values
|
||||
OPEN (fileReference, file=path // folder // '/' // 'reference.txt')
|
||||
WRITE(fileReference, "(7(1X,A20))") 'L_ref', 'v_ref', 'ti_ref', 'Vol_ref', 'EF_ref', 'Volt_ref', 'B_ref'
|
||||
WRITE(fileReference, "(7(1X,ES20.6E3))") L_ref, v_ref, ti_ref, Vol_ref, EF_ref, Volt_ref, B_ref
|
||||
CLOSE(fileReference)
|
||||
call writeReference()
|
||||
|
||||
END SUBROUTINE initOutput
|
||||
|
||||
|
|
|
|||
|
|
@ -50,18 +50,24 @@ MODULE moduleMeshOutput0D
|
|||
CLASS(meshGeneric), INTENT(in):: self
|
||||
CHARACTER(:), ALLOCATABLE:: fileName
|
||||
INTEGER:: k
|
||||
character(:), allocatable:: kString
|
||||
|
||||
fileName='OUTPUT_Collisions.dat'
|
||||
fileName = formatFileName('Output', 'Collisions', 'csv')
|
||||
IF (timeStep == tInitial) THEN
|
||||
OPEN(20, file = generateFilePath(fileName), action = 'write')
|
||||
WRITE(20, "(A1, 14X, A5, A20)") "#","t (s)","collisions"
|
||||
call informFileCreation(fileName)
|
||||
WRITE(20, "(A,A)", advance='no') "t (s)", ','
|
||||
do k = 1, nCollPairs-1
|
||||
write(20, '(A,A,I3,A,A)', advance='no') '"',"pair", k, '"', ','
|
||||
|
||||
end do
|
||||
write(20, "(A,A,I3,A)", advance='no') '"',"pair",k, '"'
|
||||
CLOSE(20)
|
||||
|
||||
END IF
|
||||
|
||||
OPEN(20, file = generateFilePath(fileName), position = 'append', action = 'write')
|
||||
WRITE(20, "("//fmtReal//", 10I20)") REAL(timeStep)*tauMin*ti_ref, (self%cells(1)%obj%tallyColl(k)%tally, k=1,nCollPairs)
|
||||
WRITE(20, "("//fmtColReal//", *("//fmtColInt//"))") REAL(timeStep)*tauMin*ti_ref, (self%cells(1)%obj%tallyColl(k)%tally, k=1,nCollPairs)
|
||||
CLOSE(20)
|
||||
|
||||
END SUBROUTINE printColl0D
|
||||
|
|
|
|||
|
|
@ -485,19 +485,22 @@ submodule(moduleMesh) boundaryParticle
|
|||
integer:: b
|
||||
character(:), allocatable:: fileName
|
||||
|
||||
fileName = formatFileName(prefix, 'boundariesParticle', 'csv', timeStep)
|
||||
call informFileCreation(fileName)
|
||||
open(fileID_boundaryParticle, file = path // folder // '/' // fileName)
|
||||
if (boundaryParticleOutput) then
|
||||
fileName = formatFileName(prefix, 'boundariesParticle', 'csv', timeStep)
|
||||
call informFileCreation(fileName)
|
||||
open(fileID_boundaryParticle, file = path // folder // '/' // fileName)
|
||||
|
||||
do b = 1, nBoundariesParticle
|
||||
if (associated(boundariesParticle(b)%obj%print)) then
|
||||
call boundariesParticle(b)%obj%print(fileID_boundaryParticle)
|
||||
do b = 1, nBoundariesParticle
|
||||
if (associated(boundariesParticle(b)%obj%print)) then
|
||||
call boundariesParticle(b)%obj%print(fileID_boundaryParticle)
|
||||
|
||||
end if
|
||||
end if
|
||||
|
||||
end do
|
||||
end do
|
||||
|
||||
close(fileID_boundaryParticle)
|
||||
close(fileID_boundaryParticle)
|
||||
|
||||
end if
|
||||
|
||||
end subroutine boundariesParticle_write
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue