Save results (and plots).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical, | intent(in) | :: | results | Flag for activating results saving. |
||
character(len=*), | intent(in) | :: | output | Output files basename coming from CLI. |
||
character(len=*), | intent(in) | :: | scheme | Selected scheme: must be defined into solvers. |
||
real(kind=R_P), | intent(in) | :: | a | a coefficient. |
||
real(kind=R_P), | intent(in) | :: | b | b coefficient. |
||
real(kind=R_P), | intent(in) | :: | U0 | Initial state. |
||
logical, | intent(in) | :: | save_exact_solution | Flag for saving exact solution. |
||
real(kind=R_P), | intent(in) | :: | solution(0:,0:) | Solution at each time step. |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
subroutine save_results(results, output, scheme, a, b, U0, save_exact_solution, solution)
!< Save results (and plots).
logical, intent(in) :: results !< Flag for activating results saving.
character(*), intent(in) :: output !< Output files basename coming from CLI.
character(*), intent(in) :: scheme !< Selected scheme: must be defined into *solvers*.
real(R_P), intent(in) :: a !< *a* coefficient.
real(R_P), intent(in) :: b !< *b* coefficient.
real(R_P), intent(in) :: U0 !< Initial state.
logical, intent(in) :: save_exact_solution !< Flag for saving exact solution.
real(R_P), intent(in) :: solution(0:,0:) !< Solution at each time step.
character(len=:), allocatable :: title !< Output files title.
character(len=:), allocatable :: basename !< Output files basename.
type(integrand_lcce) :: lcce !< Linear constant coefficients field.
integer(I_P) :: rawfile !< Raw file unit for saving results.
integer(I_P) :: s !< Counter.
basename = trim(adjustl(output))//'-'//trim(strz(ubound(solution, dim=2), 10))//'-time_steps-'//trim(adjustl(scheme))
title = 'linear constant coefficients equation integration, solver='//trim(adjustl(scheme))
if (results) then
open(newunit=rawfile, file=basename//'.dat')
write(rawfile, '(A)')'TITLE="'//title//'"'
write(rawfile, '(A)')'VARIABLES="t" "u"'
write(rawfile, '(A)')'ZONE T="'//trim(adjustl(scheme))//'"'
do s=0, ubound(solution, dim=2)
write(rawfile, '(2('//FR_P//',1X))')solution(:, s)
enddo
close(rawfile)
endif
if (save_exact_solution) then
call lcce%initialize(a=a, b=b, U0=U0)
basename = trim(adjustl(output))//'-'//trim(strz(ubound(solution, dim=2), 10))//'-time_steps-exact_solution'
title = 'linear constant coefficients equation integration, solver=exact solution'
open(newunit=rawfile, file=basename//'.dat')
write(rawfile, '(A)')'TITLE="'//title//'"'
write(rawfile, '(A)')'VARIABLES="t" "u"'
write(rawfile, '(A)')'ZONE T="exact solution"'
do s=0, ubound(solution, dim=2)
write(rawfile, '(2('//FR_P//',1X))')solution(0, s), lcce%exact_solution(t=solution(0, s))
enddo
close(rawfile)
endif
endsubroutine save_results