/
input_xml.F90
4953 lines (4208 loc) · 177 KB
/
input_xml.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module input_xml
use, intrinsic :: ISO_C_BINDING
use algorithm, only: find
use cmfd_input, only: configure_cmfd
use cmfd_header, only: cmfd_mesh
use constants
use dict_header, only: DictIntInt, DictCharInt, DictEntryCI
use distribution_multivariate
use distribution_univariate
use endf, only: reaction_name
use error, only: fatal_error, warning, write_message
use geometry, only: calc_offsets, maximum_levels, count_instance, &
neighbor_lists
use geometry_header
use hdf5_interface
use list_header, only: ListChar, ListInt, ListReal
use material_header
use mesh_header
use message_passing
use mgxs_data, only: create_macro_xs, read_mgxs
use mgxs_header
use multipole, only: multipole_read
use nuclide_header
use output, only: title, header, print_plot
use plot_header
use random_lcg, only: prn, openmc_set_seed
use surface_header
use set_header, only: SetChar
use settings
use source_header
use stl_vector, only: VectorInt, VectorReal, VectorChar
use string, only: to_lower, to_str, str_to_int, str_to_real, &
starts_with, ends_with, tokenize, split_string, &
zero_padded, to_c_string
use summary, only: write_summary
use tally
use tally_header, only: openmc_extend_tallies
use tally_derivative_header
use tally_filter_header
use tally_filter
use timer_header, only: time_read_xs
use trigger_header
use volume_header
use xml_interface
implicit none
save
contains
!===============================================================================
! READ_INPUT_XML calls each of the separate subroutines for reading settings,
! geometry, materials, and tallies.
!===============================================================================
subroutine read_input_xml()
type(VectorReal), allocatable :: nuc_temps(:) ! List of T to read for each nuclide
type(VectorReal), allocatable :: sab_temps(:) ! List of T to read for each S(a,b)
real(8), allocatable :: material_temps(:)
call read_settings_xml()
call read_cross_sections_xml()
call read_materials_xml(material_temps)
call read_geometry_xml()
! Set up neighbor lists, convert user IDs -> indices, assign temperatures
call finalize_geometry(material_temps, nuc_temps, sab_temps)
if (run_mode /= MODE_PLOTTING) then
call time_read_xs % start()
if (run_CE) then
! Read continuous-energy cross sections
call read_ce_cross_sections(nuc_temps, sab_temps)
else
! Create material macroscopic data for MGXS
call read_mgxs()
call create_macro_xs()
end if
call time_read_xs % stop()
end if
call read_tallies_xml()
! Initialize distribcell_filters
call prepare_distribcell()
if (cmfd_run) call configure_cmfd()
if (run_mode == MODE_PLOTTING) then
! Read plots.xml if it exists
call read_plots_xml()
if (master .and. verbosity >= 5) call print_plot()
else
! Normalize atom/weight percents
call normalize_ao()
! Write summary information
if (master .and. output_summary) call write_summary()
! Warn if overlap checking is on
if (master .and. check_overlaps) &
call warning("Cell overlap checking is ON.")
end if
end subroutine read_input_xml
subroutine finalize_geometry(material_temps, nuc_temps, sab_temps)
real(8), intent(in) :: material_temps(:)
type(VectorReal), allocatable, intent(out) :: nuc_temps(:)
type(VectorReal), optional, allocatable, intent(out) :: sab_temps(:)
! Perform some final operations to set up the geometry
call adjust_indices()
call count_instance(universes(root_universe))
! After reading input and basic geometry setup is complete, build lists of
! neighboring cells for efficient tracking
call neighbor_lists()
! Assign temperatures to cells that don't have temperatures already assigned
call assign_temperatures(material_temps)
! Determine desired txemperatures for each nuclide and S(a,b) table
call get_temperatures(nuc_temps, sab_temps)
! Check to make sure there are not too many nested coordinate levels in the
! geometry since the coordinate list is statically allocated for performance
! reasons
if (maximum_levels(universes(root_universe)) > MAX_COORD) then
call fatal_error("Too many nested coordinate levels in the geometry. &
&Try increasing the maximum number of coordinate levels by &
&providing the CMake -Dmaxcoord= option.")
end if
end subroutine finalize_geometry
!===============================================================================
! READ_SETTINGS_XML reads data from a settings.xml file and parses it, checking
! for errors and placing properly-formatted data in the right data structures
!===============================================================================
subroutine read_settings_xml()
character(MAX_LINE_LEN) :: temp_str
integer :: i
integer :: n
integer :: temp_int
integer :: temp_int_array3(3)
integer(C_INT32_T) :: i_start, i_end
integer(C_INT64_T) :: seed
integer(C_INT) :: err
integer, allocatable :: temp_int_array(:)
integer :: n_tracks
logical :: file_exists
character(MAX_WORD_LEN) :: type
character(MAX_LINE_LEN) :: filename
type(XMLDocument) :: doc
type(XMLNode) :: root
type(XMLNode) :: node_mode
type(XMLNode) :: node_cutoff
type(XMLNode) :: node_entropy
type(XMLNode) :: node_ufs
type(XMLNode) :: node_sp
type(XMLNode) :: node_output
type(XMLNode) :: node_res_scat
type(XMLNode) :: node_trigger
type(XMLNode) :: node_vol
type(XMLNode) :: node_tab_leg
type(XMLNode), allocatable :: node_mesh_list(:)
type(XMLNode), allocatable :: node_source_list(:)
type(XMLNode), allocatable :: node_vol_list(:)
! Check if settings.xml exists
filename = trim(path_input) // "settings.xml"
inquire(FILE=filename, EXIST=file_exists)
if (.not. file_exists) then
if (run_mode /= MODE_PLOTTING) then
call fatal_error("Settings XML file '" // trim(filename) // "' does &
¬ exist! In order to run OpenMC, you first need a set of input &
&files; at a minimum, this includes settings.xml, geometry.xml, &
&and materials.xml. Please consult the user's guide at &
&http://mit-crpg.github.io/openmc for further information.")
else
! The settings.xml file is optional if we just want to make a plot.
return
end if
end if
! Parse settings.xml file
call doc % load_file(filename)
root = doc % document_element()
! Verbosity
if (check_for_node(root, "verbosity")) then
call get_node_value(root, "verbosity", verbosity)
end if
! To this point, we haven't displayed any output since we didn't know what
! the verbosity is. Now that we checked for it, show the title if necessary
if (master) then
if (verbosity >= 2) call title()
end if
call write_message("Reading settings XML file...", 5)
! Find if a multi-group or continuous-energy simulation is desired
if (check_for_node(root, "energy_mode")) then
call get_node_value(root, "energy_mode", temp_str)
temp_str = trim(to_lower(temp_str))
if (temp_str == "mg" .or. temp_str == "multi-group") then
run_CE = .false.
else if (temp_str == "ce" .or. temp_str == "continuous-energy") then
run_CE = .true.
end if
end if
! Look for deprecated cross_sections.xml file in settings.xml
if (check_for_node(root, "cross_sections")) then
call warning("Setting cross_sections in settings.xml has been deprecated.&
& The cross_sections are now set in materials.xml and the &
&cross_sections input to materials.xml and the OPENMC_CROSS_SECTIONS&
& environment variable will take precendent over setting &
&cross_sections in settings.xml.")
call get_node_value(root, "cross_sections", path_cross_sections)
end if
! Look for deprecated windowed_multipole file in settings.xml
if (run_mode /= MODE_PLOTTING) then
if (check_for_node(root, "multipole_library")) then
call warning("Setting multipole_library in settings.xml has been &
&deprecated. The multipole_library is now set in materials.xml and&
& the multipole_library input to materials.xml and the &
&OPENMC_MULTIPOLE_LIBRARY environment variable will take &
&precendent over setting multipole_library in settings.xml.")
call get_node_value(root, "multipole_library", path_multipole)
end if
if (.not. ends_with(path_multipole, "/")) &
path_multipole = trim(path_multipole) // "/"
end if
if (.not. run_CE) then
! Scattering Treatments
if (check_for_node(root, "max_order")) then
call get_node_value(root, "max_order", max_order)
else
! Set to default of largest int - 1, which means to use whatever is
! contained in library.
! This is largest int - 1 because for legendre scattering, a value of
! 1 is added to the order; adding 1 to huge(0) gets you the largest
! negative integer, which is not what we want.
max_order = huge(0) - 1
end if
else
max_order = 0
end if
! Check for a trigger node and get trigger information
if (check_for_node(root, "trigger")) then
node_trigger = root % child("trigger")
! Check if trigger(s) are to be turned on
call get_node_value(node_trigger, "active", trigger_on)
if (trigger_on) then
if (check_for_node(node_trigger, "max_batches") )then
call get_node_value(node_trigger, "max_batches", n_max_batches)
else
call fatal_error("The max_batches must be specified with triggers")
end if
! Get the batch interval to check triggers
if (.not. check_for_node(node_trigger, "batch_interval"))then
pred_batches = .true.
else
call get_node_value(node_trigger, "batch_interval", temp_int)
n_batch_interval = temp_int
if (n_batch_interval <= 0) then
call fatal_error("The batch interval must be greater than zero")
end if
end if
end if
end if
! Check run mode if it hasn't been set from the command line
if (run_mode == NONE) then
if (check_for_node(root, "run_mode")) then
call get_node_value(root, "run_mode", temp_str)
select case (to_lower(temp_str))
case ("eigenvalue")
run_mode = MODE_EIGENVALUE
case ("fixed source")
run_mode = MODE_FIXEDSOURCE
case ("plot")
run_mode = MODE_PLOTTING
case ("particle restart")
run_mode = MODE_PARTICLE
case ("volume")
run_mode = MODE_VOLUME
case default
call fatal_error("Unrecognized run mode: " // &
trim(temp_str) // ".")
end select
! Assume XML specifics <particles>, <batches>, etc. directly
node_mode = root
else
call warning("<run_mode> should be specified.")
! Make sure that either eigenvalue or fixed source was specified
node_mode = root % child("eigenvalue")
if (node_mode % associated()) then
if (run_mode == NONE) run_mode = MODE_EIGENVALUE
else
node_mode = root % child("fixed_source")
if (node_mode % associated()) then
if (run_mode == NONE) run_mode = MODE_FIXEDSOURCE
else
call fatal_error("<eigenvalue> or <fixed_source> not specified.")
end if
end if
end if
end if
if (run_mode == MODE_EIGENVALUE .or. run_mode == MODE_FIXEDSOURCE) then
! Read run parameters
call get_run_parameters(node_mode)
! Check number of active batches, inactive batches, and particles
if (n_batches <= n_inactive) then
call fatal_error("Number of active batches must be greater than zero.")
elseif (n_inactive < 0) then
call fatal_error("Number of inactive batches must be non-negative.")
elseif (n_particles <= 0) then
call fatal_error("Number of particles must be greater than zero.")
end if
end if
! Copy random number seed if specified
if (check_for_node(root, "seed")) then
call get_node_value(root, "seed", seed)
err = openmc_set_seed(seed)
end if
! Number of bins for logarithmic grid
if (check_for_node(root, "log_grid_bins")) then
call get_node_value(root, "log_grid_bins", n_log_bins)
if (n_log_bins < 1) then
call fatal_error("Number of bins for logarithmic grid must be &
&greater than zero.")
end if
else
n_log_bins = 8000
end if
! Number of OpenMP threads
if (check_for_node(root, "threads")) then
#ifdef _OPENMP
if (n_threads == NONE) then
call get_node_value(root, "threads", n_threads)
if (n_threads < 1) then
call fatal_error("Invalid number of threads: " // to_str(n_threads))
end if
call omp_set_num_threads(n_threads)
end if
#else
if (master) call warning("Ignoring number of threads.")
#endif
end if
! ==========================================================================
! EXTERNAL SOURCE
! Get point to list of <source> elements and make sure there is at least one
call get_node_list(root, "source", node_source_list)
n = size(node_source_list)
if (n == 0) then
! Default source is isotropic point source at origin with Watt spectrum
allocate(external_source(1))
external_source % strength = ONE
allocate(SpatialPoint :: external_source(1) % space)
select type (space => external_source(1) % space)
type is (SpatialPoint)
space % xyz(:) = [ZERO, ZERO, ZERO]
end select
allocate(Isotropic :: external_source(1) % angle)
external_source(1) % angle % reference_uvw(:) = [ZERO, ZERO, ONE]
allocate(Watt :: external_source(1) % energy)
select type(energy => external_source(1) % energy)
type is (Watt)
energy % a = 0.988e6_8
energy % b = 2.249e-6_8
end select
else
! Allocate array for sources
allocate(external_source(n))
end if
! Check if we want to write out source
if (check_for_node(root, "write_initial_source")) then
call get_node_value(root, "write_initial_source", write_initial_source)
end if
! Read each source
do i = 1, n
call external_source(i) % from_xml(node_source_list(i), path_source)
end do
! Survival biasing
if (check_for_node(root, "survival_biasing")) then
call get_node_value(root, "survival_biasing", survival_biasing)
end if
! Probability tables
if (check_for_node(root, "ptables")) then
call get_node_value(root, "ptables", urr_ptables_on)
end if
! Cutoffs
if (check_for_node(root, "cutoff")) then
node_cutoff = root % child("cutoff")
if (check_for_node(node_cutoff, "weight")) then
call get_node_value(node_cutoff, "weight", weight_cutoff)
end if
if (check_for_node(node_cutoff, "weight_avg")) then
call get_node_value(node_cutoff, "weight_avg", weight_survive)
end if
if (check_for_node(node_cutoff, "energy")) then
call get_node_value(node_cutoff, "energy", energy_cutoff)
end if
end if
! Particle trace
if (check_for_node(root, "trace")) then
call get_node_array(root, "trace", temp_int_array3)
trace_batch = temp_int_array3(1)
trace_gen = temp_int_array3(2)
trace_particle = int(temp_int_array3(3), 8)
end if
! Particle tracks
if (check_for_node(root, "track")) then
! Make sure that there are three values per particle
n_tracks = node_word_count(root, "track")
if (mod(n_tracks, 3) /= 0) then
call fatal_error("Number of integers specified in 'track' is not &
&divisible by 3. Please provide 3 integers per particle to be &
&tracked.")
end if
! Allocate space and get list of tracks
allocate(temp_int_array(n_tracks))
call get_node_array(root, "track", temp_int_array)
! Reshape into track_identifiers
allocate(track_identifiers(3, n_tracks/3))
track_identifiers = reshape(temp_int_array, [3, n_tracks/3])
end if
! Read meshes
call get_node_list(root, "mesh", node_mesh_list)
! Check for user meshes and allocate
n = size(node_mesh_list)
if (n > 0) then
err = openmc_extend_meshes(n, i_start, i_end)
end if
do i = 1, n
associate (m => meshes(i_start + i - 1))
! Instantiate mesh from XML node
call m % from_xml(node_mesh_list(i))
! Add mesh to dictionary
call mesh_dict % set(m % id, i_start + i - 1)
end associate
end do
! Shannon Entropy mesh
if (check_for_node(root, "entropy_mesh")) then
call get_node_value(root, "entropy_mesh", temp_int)
if (mesh_dict % has(temp_int)) then
index_entropy_mesh = mesh_dict % get(temp_int)
else
call fatal_error("Mesh " // to_str(temp_int) // " specified for &
&Shannon entropy does not exist.")
end if
elseif (check_for_node(root, "entropy")) then
call warning("Specifying a Shannon entropy mesh via the <entropy> element &
&is deprecated. Please create a mesh using <mesh> and then reference &
&it by specifying its ID in an <entropy_mesh> element.")
! Get pointer to entropy node
node_entropy = root % child("entropy")
err = openmc_extend_meshes(1, index_entropy_mesh)
associate (m => meshes(index_entropy_mesh))
! Assign ID
m % id = 10000
call m % from_xml(node_entropy)
end associate
end if
if (index_entropy_mesh > 0) then
associate(m => meshes(index_entropy_mesh))
if (.not. allocated(m % dimension)) then
! If the user did not specify how many mesh cells are to be used in
! each direction, we automatically determine an appropriate number of
! cells
m % n_dimension = 3
allocate(m % dimension(3))
m % dimension = ceiling((n_particles/20)**(ONE/THREE))
! Calculate width
m % width = (m % upper_right - m % lower_left) / m % dimension
end if
! Allocate space for storing number of fission sites in each mesh cell
allocate(entropy_p(1, product(m % dimension)))
end associate
! Turn on Shannon entropy calculation
entropy_on = .true.
end if
! Uniform fission source weighting mesh
if (check_for_node(root, "ufs_mesh")) then
call get_node_value(root, "ufs_mesh", temp_int)
if (mesh_dict % has(temp_int)) then
index_ufs_mesh = mesh_dict % get(temp_int)
else
call fatal_error("Mesh " // to_str(temp_int) // " specified for &
&uniform fission site method does not exist.")
end if
elseif (check_for_node(root, "uniform_fs")) then
call warning("Specifying a UFS mesh via the <uniform_fs> element &
&is deprecated. Please create a mesh using <mesh> and then reference &
&it by specifying its ID in a <ufs_mesh> element.")
! Get pointer to ufs node
node_ufs = root % child("uniform_fs")
err = openmc_extend_meshes(1, index_ufs_mesh)
! Allocate mesh object and coordinates on mesh
associate (m => meshes(index_ufs_mesh))
! Assign ID
m % id = 10001
call m % from_xml(node_ufs)
end associate
end if
if (index_ufs_mesh > 0) then
! Allocate array to store source fraction for UFS
allocate(source_frac(1, product(meshes(index_ufs_mesh) % dimension)))
! Turn on uniform fission source weighting
ufs = .true.
end if
! Check if the user has specified to write state points
if (check_for_node(root, "state_point")) then
! Get pointer to state_point node
node_sp = root % child("state_point")
! Determine number of batches at which to store state points
if (check_for_node(node_sp, "batches")) then
n_state_points = node_word_count(node_sp, "batches")
else
n_state_points = 0
end if
if (n_state_points > 0) then
! User gave specific batches to write state points
allocate(temp_int_array(n_state_points))
call get_node_array(node_sp, "batches", temp_int_array)
do i = 1, n_state_points
call statepoint_batch % add(temp_int_array(i))
end do
deallocate(temp_int_array)
else
! If neither were specified, write state point at last batch
n_state_points = 1
call statepoint_batch % add(n_batches)
end if
else
! If no <state_point> tag was present, by default write state point at
! last batch only
n_state_points = 1
call statepoint_batch % add(n_batches)
end if
! Check if the user has specified to write source points
if (check_for_node(root, "source_point")) then
! Get pointer to source_point node
node_sp = root % child("source_point")
! Determine number of batches at which to store source points
if (check_for_node(node_sp, "batches")) then
n_source_points = node_word_count(node_sp, "batches")
else
n_source_points = 0
end if
if (n_source_points > 0) then
! User gave specific batches to write source points
allocate(temp_int_array(n_source_points))
call get_node_array(node_sp, "batches", temp_int_array)
do i = 1, n_source_points
call sourcepoint_batch % add(temp_int_array(i))
end do
deallocate(temp_int_array)
else
! If neither were specified, write source points with state points
n_source_points = n_state_points
do i = 1, n_state_points
call sourcepoint_batch % add(statepoint_batch % get_item(i))
end do
end if
! Check if the user has specified to write binary source file
if (check_for_node(node_sp, "separate")) then
call get_node_value(node_sp, "separate", source_separate)
end if
if (check_for_node(node_sp, "write")) then
call get_node_value(node_sp, "write", source_write)
end if
if (check_for_node(node_sp, "overwrite_latest")) then
call get_node_value(node_sp, "overwrite_latest", source_latest)
source_separate = source_latest
end if
else
! If no <source_point> tag was present, by default we keep source bank in
! statepoint file and write it out at statepoints intervals
source_separate = .false.
n_source_points = n_state_points
do i = 1, n_state_points
call sourcepoint_batch % add(statepoint_batch % get_item(i))
end do
end if
! If source is not seperate and is to be written out in the statepoint file,
! make sure that the sourcepoint batch numbers are contained in the
! statepoint list
if (.not. source_separate) then
do i = 1, n_source_points
if (.not. statepoint_batch % contains(sourcepoint_batch % &
get_item(i))) then
call fatal_error('Sourcepoint batches are not a subset&
& of statepoint batches.')
end if
end do
end if
! Check if the user has specified to not reduce tallies at the end of every
! batch
if (check_for_node(root, "no_reduce")) then
call get_node_value(root, "no_reduce", reduce_tallies)
end if
! Check if the user has specified to use confidence intervals for
! uncertainties rather than standard deviations
if (check_for_node(root, "confidence_intervals")) then
call get_node_value(root, "confidence_intervals", confidence_intervals)
end if
! Check for output options
if (check_for_node(root, "output")) then
! Get pointer to output node
node_output = root % child("output")
! Check for summary option
if (check_for_node(node_output, "summary")) then
call get_node_value(node_output, "summary", output_summary)
end if
! Check for ASCII tallies output option
if (check_for_node(node_output, "tallies")) then
call get_node_value(node_output, "tallies", output_tallies)
end if
! Set output directory if a path has been specified
if (check_for_node(node_output, "path")) then
call get_node_value(node_output, "path", path_output)
if (.not. ends_with(path_output, "/")) &
path_output = trim(path_output) // "/"
end if
end if
! Check for cmfd run
if (check_for_node(root, "run_cmfd")) then
call get_node_value(root, "run_cmfd", cmfd_run)
end if
! Resonance scattering parameters
if (check_for_node(root, "resonance_scattering")) then
node_res_scat = root % child("resonance_scattering")
! See if resonance scattering is enabled
if (check_for_node(node_res_scat, "enable")) then
call get_node_value(node_res_scat, "enable", res_scat_on)
else
res_scat_on = .true.
end if
! Determine what method is used
if (check_for_node(node_res_scat, "method")) then
call get_node_value(node_res_scat, "method", temp_str)
select case(to_lower(temp_str))
case ('ares')
res_scat_method = RES_SCAT_ARES
case ('dbrc')
res_scat_method = RES_SCAT_DBRC
case ('wcm')
res_scat_method = RES_SCAT_WCM
case default
call fatal_error("Unrecognized resonance elastic scattering method: " &
// trim(temp_str) // ".")
end select
end if
! Minimum energy for resonance scattering
if (check_for_node(node_res_scat, "energy_min")) then
call get_node_value(node_res_scat, "energy_min", res_scat_energy_min)
end if
if (res_scat_energy_min < ZERO) then
call fatal_error("Lower resonance scattering energy bound is negative")
end if
! Maximum energy for resonance scattering
if (check_for_node(node_res_scat, "energy_max")) then
call get_node_value(node_res_scat, "energy_max", res_scat_energy_max)
end if
if (res_scat_energy_max < res_scat_energy_min) then
call fatal_error("Upper resonance scattering energy bound is below the &
&lower resonance scattering energy bound.")
end if
! Get nuclides that resonance scattering should be applied to
if (check_for_node(node_res_scat, "nuclides")) then
n = node_word_count(node_res_scat, "nuclides")
allocate(res_scat_nuclides(n))
if (n > 0) then
call get_node_array(node_res_scat, "nuclides", res_scat_nuclides)
end if
end if
end if
call get_node_list(root, "volume_calc", node_vol_list)
n = size(node_vol_list)
allocate(volume_calcs(n))
do i = 1, n
node_vol = node_vol_list(i)
call volume_calcs(i) % from_xml(node_vol)
end do
! Get temperature settings
if (check_for_node(root, "temperature_default")) then
call get_node_value(root, "temperature_default", temperature_default)
end if
if (check_for_node(root, "temperature_method")) then
call get_node_value(root, "temperature_method", temp_str)
select case (to_lower(temp_str))
case ('nearest')
temperature_method = TEMPERATURE_NEAREST
case ('interpolation')
temperature_method = TEMPERATURE_INTERPOLATION
case default
call fatal_error("Unknown temperature method: " // trim(temp_str))
end select
end if
if (check_for_node(root, "temperature_tolerance")) then
call get_node_value(root, "temperature_tolerance", temperature_tolerance)
end if
if (check_for_node(root, "temperature_multipole")) then
call get_node_value(root, "temperature_multipole", temperature_multipole)
end if
if (check_for_node(root, "temperature_range")) then
call get_node_array(root, "temperature_range", temperature_range)
end if
! Check for tabular_legendre options
if (check_for_node(root, "tabular_legendre")) then
! Get pointer to tabular_legendre node
node_tab_leg = root % child("tabular_legendre")
! Check for enable option
if (check_for_node(node_tab_leg, "enable")) then
call get_node_value(node_tab_leg, "enable", legendre_to_tabular)
end if
! Check for the number of points
if (check_for_node(node_tab_leg, "num_points")) then
call get_node_value(node_tab_leg, "num_points", &
legendre_to_tabular_points)
if (legendre_to_tabular_points <= 1 .and. (.not. run_CE)) then
call fatal_error("The 'num_points' subelement/attribute of the &
&'tabular_legendre' element must contain a value greater than 1")
end if
end if
end if
! Check whether create fission sites
if (run_mode == MODE_FIXEDSOURCE) then
if (check_for_node(root, "create_fission_neutrons")) then
call get_node_value(root, "create_fission_neutrons", &
create_fission_neutrons)
end if
end if
! Close settings XML file
call doc % clear()
end subroutine read_settings_xml
!===============================================================================
! GET_RUN_PARAMETERS
!===============================================================================
subroutine get_run_parameters(node_base)
type(XMLNode), intent(in) :: node_base
character(MAX_LINE_LEN) :: temp_str
type(XMLNode) :: node_keff_trigger
! Check number of particles
if (.not. check_for_node(node_base, "particles")) then
call fatal_error("Need to specify number of particles.")
end if
! Get number of particles if it wasn't specified as a command-line argument
if (n_particles == 0) then
call get_node_value(node_base, "particles", n_particles)
end if
! Get number of basic batches
call get_node_value(node_base, "batches", n_batches)
if (.not. trigger_on) then
n_max_batches = n_batches
end if
n_inactive = 0
gen_per_batch = 1
! Get number of inactive batches
if (run_mode == MODE_EIGENVALUE) then
call get_node_value(node_base, "inactive", n_inactive)
if (check_for_node(node_base, "generations_per_batch")) then
call get_node_value(node_base, "generations_per_batch", gen_per_batch)
end if
! Preallocate space for keff and entropy by generation
call k_generation % reserve(n_max_batches*gen_per_batch)
call entropy % reserve(n_max_batches*gen_per_batch)
! Get the trigger information for keff
if (check_for_node(node_base, "keff_trigger")) then
node_keff_trigger = node_base % child("keff_trigger")
if (check_for_node(node_keff_trigger, "type")) then
call get_node_value(node_keff_trigger, "type", temp_str)
temp_str = trim(to_lower(temp_str))
select case (temp_str)
case ('std_dev')
keff_trigger % trigger_type = STANDARD_DEVIATION
case ('variance')
keff_trigger % trigger_type = VARIANCE
case ('rel_err')
keff_trigger % trigger_type = RELATIVE_ERROR
case default
call fatal_error("Unrecognized keff trigger type " // temp_str)
end select
else
call fatal_error("Specify keff trigger type in settings XML")
end if
if (check_for_node(node_keff_trigger, "threshold")) then
call get_node_value(node_keff_trigger, "threshold", &
keff_trigger % threshold)
else
call fatal_error("Specify keff trigger threshold in settings XML")
end if
end if
end if
end subroutine get_run_parameters
!===============================================================================
! READ_GEOMETRY_XML reads data from a geometry.xml file and parses it, checking
! for errors and placing properly-formatted data in the right data structures
!===============================================================================
subroutine read_geometry_xml()
integer :: i, j, k, m, i_x, i_a, input_index
integer :: n, n_mats, n_x, n_y, n_z, n_rings, n_rlats, n_hlats
integer :: id
integer :: univ_id
integer :: n_cells_in_univ
integer :: coeffs_reqd
integer :: i_xmin, i_xmax, i_ymin, i_ymax, i_zmin, i_zmax
real(8) :: xmin, xmax, ymin, ymax, zmin, zmax
integer, allocatable :: temp_int_array(:)
real(8) :: phi, theta, psi
real(8), allocatable :: coeffs(:)
logical :: file_exists
logical :: boundary_exists
character(MAX_LINE_LEN) :: filename
character(MAX_WORD_LEN) :: word
character(MAX_WORD_LEN), allocatable :: sarray(:)
character(:), allocatable :: region_spec
type(Cell), pointer :: c
class(Surface), pointer :: s
class(Lattice), pointer :: lat
type(XMLDocument) :: doc
type(XMLNode) :: root
type(XMLNode) :: node_cell
type(XMLNode) :: node_surf
type(XMLNode) :: node_lat
type(XMLNode), allocatable :: node_cell_list(:)
type(XMLNode), allocatable :: node_surf_list(:)
type(XMLNode), allocatable :: node_rlat_list(:)
type(XMLNode), allocatable :: node_hlat_list(:)
type(VectorInt) :: tokens
type(VectorInt) :: rpn
type(VectorInt) :: fill_univ_ids ! List of fill universe IDs
type(VectorInt) :: univ_ids ! List of all universe IDs
type(DictIntInt) :: cells_in_univ_dict ! Used to count how many cells each
! universe contains
! Display output message
call write_message("Reading geometry XML file...", 5)
! Check if geometry.xml exists
filename = trim(path_input) // "geometry.xml"
inquire(FILE=filename, EXIST=file_exists)
if (.not. file_exists) then
call fatal_error("Geometry XML file '" // trim(filename) // "' does not &
&exist!")
end if
! Parse geometry.xml file
call doc % load_file(filename)
root = doc % document_element()
! ==========================================================================
! READ SURFACES FROM GEOMETRY.XML
! This variable is used to check whether at least one boundary condition was
! applied to a surface
boundary_exists = .false.
! get pointer to list of xml <surface>
call get_node_list(root, "surface", node_surf_list)
! Get number of <surface> tags
n_surfaces = size(node_surf_list)
! Check for no surfaces
if (n_surfaces == 0) then
call fatal_error("No surfaces found in geometry.xml!")
end if
xmin = INFINITY
xmax = -INFINITY
ymin = INFINITY
ymax = -INFINITY
zmin = INFINITY
zmax = -INFINITY
! Allocate cells array
allocate(surfaces(n_surfaces))
do i = 1, n_surfaces
! Get pointer to i-th surface node
node_surf = node_surf_list(i)
! Copy and interpret surface type
word = ''
if (check_for_node(node_surf, "type")) &
call get_node_value(node_surf, "type", word)
select case(to_lower(word))
case ('x-plane')
coeffs_reqd = 1
allocate(SurfaceXPlane :: surfaces(i)%obj)
case ('y-plane')