Add 0.7.1 blast region input stabilization
This commit is contained in:
+28
-5
@@ -92,7 +92,8 @@ contains
|
||||
end subroutine sph_blast_clear_snapshot
|
||||
|
||||
subroutine sph_blast_add_region(name, center, radius, source_phase_name, &
|
||||
target_phase_name, target_set_name, scale, time_window, mode_name, ierr)
|
||||
target_phase_name, target_set_name, scale, time_window, mode_name, ierr, &
|
||||
enabled)
|
||||
character(len=*), intent(in) :: name
|
||||
real(rk), intent(in) :: center(SPH_NDIM)
|
||||
real(rk), intent(in) :: radius
|
||||
@@ -103,10 +104,12 @@ contains
|
||||
real(rk), intent(in) :: time_window
|
||||
character(len=*), intent(in) :: mode_name
|
||||
integer, intent(out) :: ierr
|
||||
logical, intent(in), optional :: enabled
|
||||
integer :: source_phase
|
||||
integer :: target_phase
|
||||
integer :: projection_mode
|
||||
logical :: is_disabled
|
||||
character(len=SPH_NAME_LEN) :: resolved_name
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (blast_region_count >= SPH_MAX_REGIONS) then
|
||||
@@ -114,6 +117,13 @@ contains
|
||||
ierr = SPH_ERROR_DATABASE
|
||||
return
|
||||
end if
|
||||
resolved_name = name
|
||||
if (len_trim(resolved_name) == 0) resolved_name = 'BLAST'
|
||||
if (sph_blast_region_name_exists(resolved_name)) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'Blast region NAME is duplicated')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
return
|
||||
end if
|
||||
if (.not. sph_blast_real_is_finite(radius) .or. radius <= 0.0_rk) then
|
||||
call sph_error_set(SPH_ERROR_INPUT, 'Blast region RADIUS must be positive')
|
||||
ierr = SPH_ERROR_INPUT
|
||||
@@ -169,10 +179,8 @@ contains
|
||||
end if
|
||||
|
||||
blast_region_count = blast_region_count + 1
|
||||
blast_region_name(blast_region_count) = name
|
||||
if (len_trim(blast_region_name(blast_region_count)) == 0) then
|
||||
blast_region_name(blast_region_count) = 'BLAST'
|
||||
end if
|
||||
if (present(enabled)) is_disabled = is_disabled .or. (.not. enabled)
|
||||
blast_region_name(blast_region_count) = resolved_name
|
||||
blast_center(:,blast_region_count) = center(:)
|
||||
blast_radius(blast_region_count) = radius
|
||||
blast_source_phase(blast_region_count) = source_phase
|
||||
@@ -184,6 +192,21 @@ contains
|
||||
blast_region_enabled(blast_region_count) = .not. is_disabled
|
||||
end subroutine sph_blast_add_region
|
||||
|
||||
logical function sph_blast_region_name_exists(name)
|
||||
character(len=*), intent(in) :: name
|
||||
integer :: i
|
||||
character(len=SPH_NAME_LEN) :: upper_name
|
||||
|
||||
upper_name = sph_blast_upper(name)
|
||||
sph_blast_region_name_exists = .false.
|
||||
do i = 1, blast_region_count
|
||||
if (trim(sph_blast_upper(blast_region_name(i))) == trim(upper_name)) then
|
||||
sph_blast_region_name_exists = .true.
|
||||
return
|
||||
end if
|
||||
end do
|
||||
end function sph_blast_region_name_exists
|
||||
|
||||
subroutine sph_blast_count_unused_regions(count)
|
||||
integer, intent(out) :: count
|
||||
integer :: i
|
||||
|
||||
@@ -756,12 +756,14 @@ contains
|
||||
real(rk) :: radius
|
||||
real(rk) :: scale
|
||||
real(rk) :: time_window
|
||||
logical :: enabled
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
center = 0.0_rk
|
||||
radius = 0.0_rk
|
||||
scale = 1.0_rk
|
||||
time_window = 0.0_rk
|
||||
enabled = .true.
|
||||
call sph_input_get_option(line, 'NAME', name)
|
||||
if (len_trim(name) == 0) name = 'BLAST'
|
||||
call sph_input_get_optional_real(line, 'X', center(1), ierr)
|
||||
@@ -803,8 +805,16 @@ contains
|
||||
call sph_input_get_option(line, 'MODE', mode_name)
|
||||
if (len_trim(mode_name) == 0) call sph_input_get_option(line, 'PROJECTION', mode_name)
|
||||
if (len_trim(mode_name) == 0) mode_name = 'RADIAL'
|
||||
call sph_input_get_option(line, 'ENABLED', value)
|
||||
if (len_trim(value) == 0) call sph_input_get_option(line, 'ACTIVE', value)
|
||||
if (len_trim(value) > 0) then
|
||||
call sph_input_parse_logical_value(value, enabled, &
|
||||
'invalid blast ENABLED option', ierr)
|
||||
if (ierr /= SPH_SUCCESS) return
|
||||
end if
|
||||
call sph_blast_add_region(name, center, radius, source_phase, &
|
||||
target_phase, target_set, scale, time_window, mode_name, ierr)
|
||||
target_phase, target_set, scale, time_window, mode_name, ierr, &
|
||||
enabled)
|
||||
end subroutine sph_input_parse_blast_region
|
||||
|
||||
subroutine sph_input_parse_shell_director(line, ierr)
|
||||
@@ -1355,6 +1365,27 @@ contains
|
||||
end if
|
||||
end subroutine sph_input_parse_real_value
|
||||
|
||||
subroutine sph_input_parse_logical_value(text, value, message, ierr)
|
||||
character(len=*), intent(in) :: text
|
||||
logical, intent(out) :: value
|
||||
character(len=*), intent(in) :: message
|
||||
integer, intent(out) :: ierr
|
||||
character(len=SPH_INPUT_FIELD_LEN) :: upper_text
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
upper_text = sph_inp_upper(adjustl(text))
|
||||
if (trim(upper_text) == 'TRUE' .or. trim(upper_text) == 'YES' .or. &
|
||||
trim(upper_text) == 'ON' .or. trim(upper_text) == '1') then
|
||||
value = .true.
|
||||
else if (trim(upper_text) == 'FALSE' .or. trim(upper_text) == 'NO' .or. &
|
||||
trim(upper_text) == 'OFF' .or. trim(upper_text) == '0') then
|
||||
value = .false.
|
||||
else
|
||||
call sph_input_set_error(message)
|
||||
ierr = SPH_ERROR_INPUT
|
||||
end if
|
||||
end subroutine sph_input_parse_logical_value
|
||||
|
||||
subroutine sph_input_set_error(message)
|
||||
character(len=*), intent(in) :: message
|
||||
character(len=SPH_INPUT_LINE_LEN) :: full_message
|
||||
|
||||
Reference in New Issue
Block a user