checkpoint Subroutine

public subroutine checkpoint(toml_filename, filename, nphotons_run, overwrite)

Uses

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: toml_filename

filename of toml file used in simulation

character(len=*), intent(in) :: filename

name of checkpoint file to be saved

integer, intent(in) :: nphotons_run

number of photons run up to checkpoint

logical, intent(in) :: overwrite

flag which determines if file is to be overwritten or adjusted


Source Code

        subroutine checkpoint(toml_filename, filename, nphotons_run, overwrite)

            use iarray, only : jmean

            !> filename of toml file used in simulation
            character(*), intent(IN)    :: toml_filename
            !> name of checkpoint file to be saved
            character(*), intent(IN)    :: filename
            !> flag which determines if file is to be overwritten or adjusted
            logical,      intent(IN) :: overwrite
            !> number of photons run up to checkpoint
            integer,      intent(IN) :: nphotons_run

            character(len=:), allocatable :: file
            integer :: u

            if(check_file(filename) .and. .not. overwrite)then
                file = get_new_file_name(filename)
            else
                file = filename
            end if

            open(newunit=u,file=file)
            write(u,"(a,a)")"tomlfile=",toml_filename
            write(u,"(a,i0)")"photons_run=",nphotons_run
            close(u)

            open(newunit=u,file=file,access="stream",form="unformatted",position="append")
            write(u)jmean
            close(u)

        end subroutine checkpoint