Skip to content

Commit b1f52fd

Browse files
author
nhorelik
committed
Fixed bug plot color specification. Removed need for cross_sections.xml when plotting.
1 parent c27e5a4 commit b1f52fd

File tree

1 file changed

+58
-17
lines changed

1 file changed

+58
-17
lines changed

src/input_xml.F90

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module input_xml
3232
subroutine read_input_xml()
3333

3434
call read_settings_xml()
35-
call read_cross_sections_xml()
35+
if ((run_mode /= MODE_PLOTTING)) call read_cross_sections_xml()
3636
call read_geometry_xml()
3737
call read_materials_xml()
3838
call read_tallies_xml()
@@ -86,7 +86,7 @@ subroutine read_settings_xml()
8686
! settings.xml file. If no file is found there, then we check the
8787
! CROSS_SECTIONS environment variable
8888

89-
if (len_trim(cross_sections_) == 0) then
89+
if (len_trim(cross_sections_) == 0 .and. run_mode /= MODE_PLOTTING) then
9090
! No cross_sections.xml file specified in settings.xml, check environment
9191
! variable
9292
call get_environment_variable("CROSS_SECTIONS", env_variable)
@@ -1035,6 +1035,12 @@ subroutine read_materials_xml
10351035
call fatal_error()
10361036
end if
10371037

1038+
if (run_mode == MODE_PLOTTING) then
1039+
! add to the dictionary and skip xs processing
1040+
call material_dict % add_key(mat % id, i)
1041+
cycle
1042+
end if
1043+
10381044
! =======================================================================
10391045
! READ AND PARSE <density> TAG
10401046

@@ -2176,13 +2182,11 @@ subroutine read_plots_xml
21762182
else
21772183
pl % not_found % rgb = (/ 255, 255, 255 /)
21782184
end if
2179-
2185+
21802186
! Copy plot type
21812187
select case (plot_(i) % type)
21822188
case ("slice")
21832189
pl % type = PLOT_TYPE_SLICE
2184-
!case ("points")
2185-
! pl % type = PLOT_TYPE_POINTS
21862190
case default
21872191
message = "Unsupported plot type '" // plot_(i) % type &
21882192
// "' in plot " // trim(to_str(pl % id))
@@ -2267,6 +2271,7 @@ subroutine read_plots_xml
22672271
if (pl % color_by == PLOT_COLOR_CELLS) then
22682272

22692273
if (cell_dict % has_key(col_id)) then
2274+
col_id = cell_dict % get_key(col_id)
22702275
pl % colors(col_id) % rgb = plot_(i) % col_spec_(j) % rgb
22712276
else
22722277
message = "Could not find cell " // trim(to_str(col_id)) // &
@@ -2277,6 +2282,7 @@ subroutine read_plots_xml
22772282
else if (pl % color_by == PLOT_COLOR_MATS) then
22782283

22792284
if (material_dict % has_key(col_id)) then
2285+
col_id = material_dict % get_key(col_id)
22802286
pl % colors(col_id) % rgb = plot_(i) % col_spec_(j) % rgb
22812287
else
22822288
message = "Could not find material " // trim(to_str(col_id)) // &
@@ -2288,19 +2294,54 @@ subroutine read_plots_xml
22882294
end do
22892295
end if
22902296

2291-
! Alter colors based on mask information
2297+
! Deal with masks
22922298
if (associated(plot_(i) % mask_)) then
2293-
if (size(plot_(i) % mask_) > 1) then
2294-
message = "Mutliple masks" // &
2295-
" specified in plot " // trim(to_str(pl % id))
2296-
call fatal_error()
2297-
else if (.not. size(plot_(i) % mask_) == 0) then
2298-
do j=1,size(pl % colors)
2299-
if (.not. any(j .eq. plot_(i) % mask_(1) % components)) then
2300-
pl % colors(j) % rgb = plot_(i) % mask_(1) % background
2301-
end if
2302-
end do
2303-
end if
2299+
2300+
select case(size(plot_(i) % mask_))
2301+
case default
2302+
message = "Mutliple masks" // &
2303+
" specified in plot " // trim(to_str(pl % id))
2304+
call fatal_error()
2305+
case (0)
2306+
case (1)
2307+
2308+
! First we need to change the user-specified identifiers to indices in
2309+
! the cell and material arrays
2310+
do j=1,size(plot_(i) % mask_(1) % components)
2311+
col_id = plot_(i) % mask_(1) % components(j)
2312+
2313+
if (pl % color_by == PLOT_COLOR_CELLS) then
2314+
2315+
if (cell_dict % has_key(col_id)) then
2316+
plot_(i) % mask_(1) % components(j) = cell_dict % get_key(col_id)
2317+
else
2318+
message = "Could not find cell " // trim(to_str(col_id)) // &
2319+
" specified in the mask in plot " // trim(to_str(pl % id))
2320+
call fatal_error()
2321+
end if
2322+
2323+
else if (pl % color_by == PLOT_COLOR_MATS) then
2324+
2325+
if (material_dict % has_key(col_id)) then
2326+
plot_(i) % mask_(1) % components(j) = material_dict % get_key(col_id)
2327+
else
2328+
message = "Could not find material " // trim(to_str(col_id)) // &
2329+
" specified in the mask in plot " // trim(to_str(pl % id))
2330+
call fatal_error()
2331+
end if
2332+
2333+
end if
2334+
end do
2335+
2336+
! Alter colors based on mask information
2337+
do j=1,size(pl % colors)
2338+
if (.not. any(j .eq. plot_(i) % mask_(1) % components)) then
2339+
pl % colors(j) % rgb = plot_(i) % mask_(1) % background
2340+
end if
2341+
end do
2342+
2343+
end select
2344+
23042345
end if
23052346

23062347
! Add plot to dictionary

0 commit comments

Comments
 (0)