diff --git a/src/input_xml.F90 b/src/input_xml.F90 index c39ef0412f..4b80923544 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -411,8 +411,8 @@ contains ! Check if source file exists inquire(FILE=path_source, EXIST=file_exists) if (.not. file_exists) then - call fatal_error("Binary source file '" // trim(path_source) & - &// "' does not exist!") + call fatal_error("Source file '" // trim(path_source) & + // "' does not exist!") end if else diff --git a/src/simulation.F90 b/src/simulation.F90 index e6b20ddf8f..b4a3791f0b 100644 --- a/src/simulation.F90 +++ b/src/simulation.F90 @@ -278,10 +278,12 @@ contains if (master .and. current_gen /= gen_per_batch) call print_generation() elseif (run_mode == MODE_FIXEDSOURCE) then ! For fixed-source mode, we need to sample the external source - do i = 1, work - call set_particle_seed(overall_gen*n_particles + work_index(rank) + i) - call sample_external_source(source_bank(i)) - end do + if (path_source == '') then + do i = 1, work + call set_particle_seed(overall_gen*n_particles + work_index(rank) + i) + call sample_external_source(source_bank(i)) + end do + end if end if end subroutine finalize_generation diff --git a/src/state_point.F90 b/src/state_point.F90 index 23543775cb..bf0947163b 100644 --- a/src/state_point.F90 +++ b/src/state_point.F90 @@ -990,7 +990,9 @@ contains integer(HID_T) :: dset ! data set handle integer(HID_T) :: dspace ! data space handle integer(HID_T) :: memspace ! memory space handle - integer(HSIZE_T) :: dims(1) + integer(HSIZE_T) :: dims(1) ! dimensions on one processor + integer(HSIZE_T) :: dims_all(1) ! overall dimensions + integer(HSIZE_T) :: maxdims(1) ! maximum dimensions integer(HSIZE_T) :: offset(1) ! offset of data type(c_ptr) :: f_ptr #ifdef PHDF5 @@ -1004,8 +1006,15 @@ contains dims(1) = work call h5screate_simple_f(1, dims, memspace, hdf5_err) - ! Select hyperslab for each process + ! Make sure source bank is big enough call h5dget_space_f(dset, dspace, hdf5_err) + call h5sget_simple_extent_dims_f(dspace, dims_all, maxdims, hdf5_err) + if (size(source_bank, KIND=HSIZE_T) > dims_all(1)) then + call fatal_error("Number of source sites in source file is less than & + &number of source particles per generation.") + end if + + ! Select hyperslab for each process offset(1) = work_index(rank) call h5sselect_hyperslab_f(dspace, H5S_SELECT_SET_F, offset, dims, hdf5_err)