routine automatically selects which way to write out results based upon file extension
Type | Intent | Optional | 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 |
subroutine write_data(array, filename, state, dict, overwrite) !! routine automatically selects which way to write out results based upon file extension use sim_state_mod, only : settings_t use tomlf, only : toml_table, get_value use constants, only : sp !> simulation state type(settings_t), intent(IN) :: state !> array to write out real(kind=sp), intent(IN) :: array(:,:,:) !> filename to save array as character(*), intent(IN) :: filename !> dictionary of metadata type(toml_table), optional, intent(INOUT) :: dict !> overwrite flag logical, optional, intent(IN) :: overwrite Logical :: over_write integer :: pos if(present(overwrite))then over_write = overwrite else over_write = state%overwrite end if pos = index(filename, ".nrrd") if(pos > 0)then if(present(dict))then call nrrd_write(array, filename, over_write, dict) else call nrrd_write(array, filename, over_write) end if return end if pos = index(filename, ".raw") if(pos > 0)then call raw_write(array, filename, over_write) return end if pos = index(filename, ".dat") if(pos > 0)then call raw_write(array, filename, over_write) return end if error stop "File type not supported!" end subroutine write_data