Removing a lot of unused code from input_xml.

This commit is contained in:
Patrick Shriwise 2018-10-13 02:10:40 -05:00
parent f57fa66983
commit 4fda0e1e48

View file

@ -2073,427 +2073,6 @@ contains
root = doc % document_element()
call read_plots(root % ptr)
return
! Get list pointer to XML <plot>
call get_node_list(root, "plot", node_plot_list)
! Allocate plots array
n_plots = size(node_plot_list)
allocate(plots(n_plots))
READ_PLOTS: do i = 1, n_plots
pl => plots(i)
! Get pointer to plot XML node
node_plot = node_plot_list(i)
! Copy data into plots
if (check_for_node(node_plot, "id")) then
call get_node_value(node_plot, "id", pl % id)
else
call fatal_error("Must specify plot id in plots XML file.")
end if
! Check to make sure 'id' hasn't been used
if (plot_dict % has(pl % id)) then
call fatal_error("Two or more plots use the same unique ID: " &
// to_str(pl % id))
end if
! Copy plot type
temp_str = 'slice'
if (check_for_node(node_plot, "type")) &
call get_node_value(node_plot, "type", temp_str)
temp_str = to_lower(temp_str)
select case (trim(temp_str))
case ("slice")
pl % type = PLOT_TYPE_SLICE
case ("voxel")
pl % type = PLOT_TYPE_VOXEL
case default
call fatal_error("Unsupported plot type '" // trim(temp_str) &
// "' in plot " // trim(to_str(pl % id)))
end select
! Set output file path
filename = "plot_" // trim(to_str(pl % id))
if (check_for_node(node_plot, "filename")) &
call get_node_value(node_plot, "filename", filename)
select case (pl % type)
case (PLOT_TYPE_SLICE)
pl % path_plot = trim(path_input) // trim(filename) // ".ppm"
case (PLOT_TYPE_VOXEL)
pl % path_plot = trim(path_input) // trim(filename) // ".h5"
end select
! Copy plot pixel size
if (pl % type == PLOT_TYPE_SLICE) then
if (node_word_count(node_plot, "pixels") == 2) then
call get_node_array(node_plot, "pixels", pl % pixels(1:2))
else
call fatal_error("<pixels> must be length 2 in slice plot " &
// trim(to_str(pl % id)))
end if
else if (pl % type == PLOT_TYPE_VOXEL) then
if (node_word_count(node_plot, "pixels") == 3) then
call get_node_array(node_plot, "pixels", pl % pixels(1:3))
else
call fatal_error("<pixels> must be length 3 in voxel plot " &
// trim(to_str(pl % id)))
end if
end if
! Copy plot background color
if (check_for_node(node_plot, "background")) then
if (pl % type == PLOT_TYPE_VOXEL) then
if (master) call warning("Background color ignored in voxel plot " &
// trim(to_str(pl % id)))
end if
if (node_word_count(node_plot, "background") == 3) then
call get_node_array(node_plot, "background", pl % not_found % rgb)
else
call fatal_error("Bad background RGB in plot " &
// trim(to_str(pl % id)))
end if
else
pl % not_found % rgb = (/ 255, 255, 255 /)
end if
! Copy plot basis
if (pl % type == PLOT_TYPE_SLICE) then
temp_str = 'xy'
if (check_for_node(node_plot, "basis")) &
call get_node_value(node_plot, "basis", temp_str)
temp_str = to_lower(temp_str)
select case (trim(temp_str))
case ("xy")
pl % basis = PLOT_BASIS_XY
case ("xz")
pl % basis = PLOT_BASIS_XZ
case ("yz")
pl % basis = PLOT_BASIS_YZ
case default
call fatal_error("Unsupported plot basis '" // trim(temp_str) &
// "' in plot " // trim(to_str(pl % id)))
end select
end if
! Copy plotting origin
if (node_word_count(node_plot, "origin") == 3) then
call get_node_array(node_plot, "origin", pl % origin)
else
call fatal_error("Origin must be length 3 in plot " &
// trim(to_str(pl % id)))
end if
! Copy plotting width
if (pl % type == PLOT_TYPE_SLICE) then
if (node_word_count(node_plot, "width") == 2) then
call get_node_array(node_plot, "width", pl % width(1:2))
else
call fatal_error("<width> must be length 2 in slice plot " &
// trim(to_str(pl % id)))
end if
else if (pl % type == PLOT_TYPE_VOXEL) then
if (node_word_count(node_plot, "width") == 3) then
call get_node_array(node_plot, "width", pl % width(1:3))
else
call fatal_error("<width> must be length 3 in voxel plot " &
// trim(to_str(pl % id)))
end if
end if
! Copy plot cell universe level
if (check_for_node(node_plot, "level")) then
call get_node_value(node_plot, "level", pl % level)
if (pl % level < 0) then
call fatal_error("Bad universe level in plot " &
// trim(to_str(pl % id)))
end if
else
pl % level = PLOT_LEVEL_LOWEST
end if
! Copy plot color type and initialize all colors randomly
temp_str = "cell"
if (check_for_node(node_plot, "color_by")) &
call get_node_value(node_plot, "color_by", temp_str)
temp_str = to_lower(temp_str)
select case (trim(temp_str))
case ("cell")
pl % color_by = PLOT_COLOR_CELLS
! allocate(pl % colors(n_cells))
do j = 1, n_cells
pl % colors(j) % rgb(1) = int(prn()*255)
pl % colors(j) % rgb(2) = int(prn()*255)
pl % colors(j) % rgb(3) = int(prn()*255)
end do
case ("material")
pl % color_by = PLOT_COLOR_MATS
! allocate(pl % colors(n_materials))
do j = 1, n_materials
pl % colors(j) % rgb(1) = int(prn()*255)
pl % colors(j) % rgb(2) = int(prn()*255)
pl % colors(j) % rgb(3) = int(prn()*255)
end do
case default
call fatal_error("Unsupported plot color type '" // trim(temp_str) &
// "' in plot " // trim(to_str(pl % id)))
end select
! Get the number of <color> nodes and get a list of them
call get_node_list(node_plot, "color", node_col_list)
n_cols = size(node_col_list)
! Copy user specified colors
if (n_cols /= 0) then
if (pl % type == PLOT_TYPE_VOXEL) then
if (master) call warning("Color specifications ignored in voxel &
&plot " // trim(to_str(pl % id)))
end if
do j = 1, n_cols
! Get pointer to color spec XML node
node_col = node_col_list(j)
! Check and make sure 3 values are specified for RGB
if (node_word_count(node_col, "rgb") /= 3) then
call fatal_error("Bad RGB in plot " &
// trim(to_str(pl % id)))
end if
! Ensure that there is an id for this color specification
if (check_for_node(node_col, "id")) then
call get_node_value(node_col, "id", col_id)
else
call fatal_error("Must specify id for color specification in &
&plot " // trim(to_str(pl % id)))
end if
! Add RGB
if (pl % color_by == PLOT_COLOR_CELLS) then
if (cell_dict % has(col_id)) then
col_id = cell_dict % get(col_id)
call get_node_array(node_col, "rgb", pl % colors(col_id) % rgb)
else
call fatal_error("Could not find cell " // trim(to_str(col_id)) &
// " specified in plot " // trim(to_str(pl % id)))
end if
else if (pl % color_by == PLOT_COLOR_MATS) then
if (material_dict % has(col_id)) then
col_id = material_dict % get(col_id)
call get_node_array(node_col, "rgb", pl % colors(col_id) % rgb)
else
call fatal_error("Could not find material " &
// trim(to_str(col_id)) // " specified in plot " &
// trim(to_str(pl % id)))
end if
end if
end do
end if
! Deal with meshlines
call get_node_list(node_plot, "meshlines", node_meshline_list)
n_meshlines = size(node_meshline_list)
if (n_meshlines /= 0) then
if (pl % type == PLOT_TYPE_VOXEL) then
call warning("Meshlines ignored in voxel plot " &
// trim(to_str(pl % id)))
end if
select case(n_meshlines)
case (0)
! Skip if no meshlines are specified
case (1)
! Get pointer to meshlines
node_meshlines = node_meshline_list(1)
! Check mesh type
if (check_for_node(node_meshlines, "meshtype")) then
call get_node_value(node_meshlines, "meshtype", meshtype)
else
call fatal_error("Must specify a meshtype for meshlines &
&specification in plot " // trim(to_str(pl % id)))
end if
! Ensure that there is a linewidth for this meshlines specification
if (check_for_node(node_meshlines, "linewidth")) then
call get_node_value(node_meshlines, "linewidth", &
pl % meshlines_width)
else
call fatal_error("Must specify a linewidth for meshlines &
&specification in plot " // trim(to_str(pl % id)))
end if
! Check for color
if (check_for_node(node_meshlines, "color")) then
! Check and make sure 3 values are specified for RGB
if (node_word_count(node_meshlines, "color") /= 3) then
call fatal_error("Bad RGB for meshlines color in plot " &
// trim(to_str(pl % id)))
end if
call get_node_array(node_meshlines, "color", &
pl % meshlines_color % rgb)
else
pl % meshlines_color % rgb = (/ 0, 0, 0 /)
end if
! Set mesh based on type
select case (trim(meshtype))
case ('ufs')
if (index_ufs_mesh < 0) then
call fatal_error("No UFS mesh for meshlines on plot " &
// trim(to_str(pl % id)))
end if
pl % index_meshlines_mesh = index_ufs_mesh
case ('cmfd')
if (.not. cmfd_run) then
call fatal_error("Need CMFD run to plot CMFD mesh for &
&meshlines on plot " // trim(to_str(pl % id)))
end if
pl % index_meshlines_mesh = index_cmfd_mesh
case ('entropy')
if (index_entropy_mesh < 0) then
call fatal_error("No entropy mesh for meshlines on plot " &
// trim(to_str(pl % id)))
end if
pl % index_meshlines_mesh = index_entropy_mesh
case ('tally')
! Ensure that there is a mesh id if the type is tally
if (check_for_node(node_meshlines, "id")) then
call get_node_value(node_meshlines, "id", meshid)
else
call fatal_error("Must specify a mesh id for meshlines tally &
&mesh specification in plot " // trim(to_str(pl % id)))
end if
! Check if the specified tally mesh exists
err = openmc_get_mesh_index(meshid, idx)
if (err /= 0) then
call fatal_error("Could not find mesh " &
// trim(to_str(meshid)) // " specified in meshlines for &
&plot " // trim(to_str(pl % id)))
end if
pl % index_meshlines_mesh = idx
case default
call fatal_error("Invalid type for meshlines on plot " &
// trim(to_str(pl % id)) // ": " // trim(meshtype))
end select
case default
call fatal_error("Mutliple meshlines specified in plot " &
// trim(to_str(pl % id)))
end select
end if
! Deal with masks
call get_node_list(node_plot, "mask", node_mask_list)
n_masks = size(node_mask_list)
if (n_masks /= 0) then
if (pl % type == PLOT_TYPE_VOXEL) then
if (master) call warning("Mask ignored in voxel plot " &
// trim(to_str(pl % id)))
end if
select case(n_masks)
case default
call fatal_error("Mutliple masks specified in plot " &
// trim(to_str(pl % id)))
case (1)
! Get pointer to mask
node_mask = node_mask_list(1)
! Determine how many components there are and allocate
n_comp = 0
n_comp = node_word_count(node_mask, "components")
if (n_comp == 0) then
call fatal_error("Missing <components> in mask of plot " &
// trim(to_str(pl % id)))
end if
allocate(iarray(n_comp))
call get_node_array(node_mask, "components", iarray)
! First we need to change the user-specified identifiers to indices
! in the cell and material arrays
do j=1, n_comp
col_id = iarray(j)
if (pl % color_by == PLOT_COLOR_CELLS) then
if (cell_dict % has(col_id)) then
iarray(j) = cell_dict % get(col_id)
else
call fatal_error("Could not find cell " &
// trim(to_str(col_id)) // " specified in the mask in &
&plot " // trim(to_str(pl % id)))
end if
else if (pl % color_by == PLOT_COLOR_MATS) then
if (material_dict % has(col_id)) then
iarray(j) = material_dict % get(col_id)
else
call fatal_error("Could not find material " &
// trim(to_str(col_id)) // " specified in the mask in &
&plot " // trim(to_str(pl % id)))
end if
end if
end do
! Alter colors based on mask information
do j = 1, size(pl % colors)
if (.not. any(j == iarray)) then
if (check_for_node(node_mask, "background")) then
call get_node_array(node_mask, "background", pl % colors(j) % rgb)
else
pl % colors(j) % rgb(:) = [255, 255, 255]
end if
end if
end do
deallocate(iarray)
end select
end if
! Add plot to dictionary
call plot_dict % set(pl % id, i)
end do READ_PLOTS
! Close plots XML file
call doc % clear()