histfinish_sub Subroutine

private subroutine histfinish_sub(this)

Uses

Type Bound

history_stack_t

Arguments

Type IntentOptional Attributes Name
class(history_stack_t) :: this

Source Code

    subroutine histfinish_sub(this)

        use constants, only : fileplace
        use utils,     only : str

        class(history_stack_t) :: this

        integer :: u

        select case(trim(this%type))
        case("obj")
            call execute_command_line("cat "//trim(fileplace)//this%filename//"2 >> "//trim(fileplace)//this%filename)
        case("ply")
            ! this is the easiest way to edit the vertex count as we don't know how many photons we will track when writing the header.
            ! this saves storing all photons data in RAM for duration of simulation.
            ! taken from: https://stackoverflow.com/a/11145362
        call execute_command_line("sed -i '3s#.*#element vertex "//str(this%vertex_counter)//"#' "//trim(fileplace)//this%filename)
        call execute_command_line("sed -i '7s#.*#element edge "//str(this%edge_counter)//"#' "//trim(fileplace)//this%filename)
        call execute_command_line("cat "//trim(fileplace)//this%filename//"2 >> "//trim(fileplace)//this%filename)
        case("json")
            open(newunit=u,file=trim(fileplace)//this%filename, status="old", position="append")
            write(u,"(a)") "}"
            close(u)
        case default
            error stop "No such output type "//this%type
        end select
    end subroutine histfinish_sub