writer_mod Module

This module defines all functions that write simulation data to the disk or pre-process data before writing. normalise_fluence. Normalises fluence by number of photons run and size of each voxel. !Does not normalise by power! write_fluence. Write out fluence in either raw or nrrd format. Default is nrrd. write_detected_photons. Write out photons detected by detectors.

Changes should only be made here if there is a bug or new data types need to be written to disk (phase information) or new file format is needed.


Uses


Interfaces

public interface nrrd_write

  • private subroutine write_3d_r8_nrrd(array, filename, overwrite, dict)

    write 3D array of float64's to .nrrd fileformat

    Arguments

    Type IntentOptional Attributes Name
    real(kind=wp), intent(in) :: array(:,:,:)

    array to be written to disk

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

    filename

    logical, intent(in) :: overwrite

    overwrite flag

    type(toml_table), intent(inout), optional :: dict

    dictionary of metadata

  • private subroutine write_3d_r4_nrrd(array, filename, overwrite, dict)

    write 3D array of float32's to .nrrd fileformat

    Arguments

    Type IntentOptional Attributes Name
    real(kind=sp), intent(in) :: array(:,:,:)

    array to be written to disk

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

    filename

    logical, intent(in) :: overwrite

    overwrite flag

    type(toml_table), intent(inout), optional :: dict

    dictionary of metadata

public interface raw_write

  • private subroutine write_3d_r8_raw(array, filename, overwrite)

    write 3D array of float64s to disk as raw binary data

    Arguments

    Type IntentOptional Attributes Name
    real(kind=wp), intent(in) :: array(:,:,:)

    array to write to disk

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

    filename to save array as

    logical, intent(in) :: overwrite

    overwrite flag

  • private subroutine write_3d_r4_raw(array, filename, overwrite)

    write 3D array of float32's to disk as raw binary data

    Arguments

    Type IntentOptional Attributes Name
    real(kind=sp), intent(in) :: array(:,:,:)

    array to write to disk

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

    filename to save array as

    logical, intent(in) :: overwrite

    overwrite flag


Functions

private function check_file(file) result(res)

Functional wrapper around inquire to check if file exits

Arguments

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

file to be checked

Return Value logical

private function get_new_file_name(file) result(res)

If file exits, get numeral to append to filename

Arguments

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

file to be checked

Return Value character(len=:), allocatable


Subroutines

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

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

public subroutine normalise_fluence(grid, array, nphotons)

normalise fluence in the Lucy 1999 way

Arguments

Type IntentOptional Attributes Name
type(cart_grid), intent(in) :: grid

grid class

real(kind=sp), intent(inout) :: array(:,:,:)

array to normalise

integer, intent(in) :: nphotons

number of photons run

private subroutine write_3d_r4_nrrd(array, filename, overwrite, dict)

write 3D array of float32's to .nrrd fileformat

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(in) :: array(:,:,:)

array to be written to disk

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

filename

logical, intent(in) :: overwrite

overwrite flag

type(toml_table), intent(inout), optional :: dict

dictionary of metadata

private subroutine write_3d_r4_raw(array, filename, overwrite)

write 3D array of float32's to disk as raw binary data

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(in) :: array(:,:,:)

array to write to disk

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

filename to save array as

logical, intent(in) :: overwrite

overwrite flag

private subroutine write_3d_r8_nrrd(array, filename, overwrite, dict)

write 3D array of float64's to .nrrd fileformat

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: array(:,:,:)

array to be written to disk

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

filename

logical, intent(in) :: overwrite

overwrite flag

type(toml_table), intent(inout), optional :: dict

dictionary of metadata

private subroutine write_3d_r8_raw(array, filename, overwrite)

write 3D array of float64s to disk as raw binary data

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: array(:,:,:)

array to write to disk

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

filename to save array as

logical, intent(in) :: overwrite

overwrite flag

public subroutine write_data(array, filename, state, dict, overwrite)

routine automatically selects which way to write out results based upon file extension

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(in) :: array(:,:,:)

array to write out

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

filename to save array as

type(settings_t), intent(in) :: state

simulation state

type(toml_table), intent(inout), optional :: dict

dictionary of metadata

logical, intent(in), optional :: overwrite

overwrite flag

public subroutine write_detected_photons(dects)

Arguments

Type IntentOptional Attributes Name
type(dect_array), intent(in) :: dects(:)

private subroutine write_hdr(u, sizes, type)

write out header information for .nrrd file format

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: u

file handle

integer, intent(in) :: sizes(:)

dimensions of data

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

data dtype