Harden SPHLite 0.2.1 water input parsing
This commit is contained in:
@@ -392,7 +392,7 @@ contains
|
||||
return
|
||||
end if
|
||||
do i = 1, material_count
|
||||
if (trim(material_name(i)) == trim(name)) then
|
||||
if (sph_db_name_equal(material_name(i), name)) then
|
||||
material_density(i) = density_value
|
||||
return
|
||||
end if
|
||||
@@ -408,6 +408,7 @@ contains
|
||||
real(rk), intent(in) :: thickness
|
||||
integer, intent(in) :: points
|
||||
integer, intent(out) :: ierr
|
||||
integer :: mat_index
|
||||
|
||||
ierr = SPH_SUCCESS
|
||||
if (section_count >= SPH_MAX_SECTIONS) then
|
||||
@@ -415,15 +416,56 @@ contains
|
||||
ierr = SPH_ERROR_DATABASE
|
||||
return
|
||||
end if
|
||||
mat_index = sph_db_find_material(mat_name)
|
||||
if (mat_index <= 0) then
|
||||
call sph_error_set(SPH_ERROR_DATABASE, 'section references unknown material')
|
||||
ierr = SPH_ERROR_DATABASE
|
||||
return
|
||||
end if
|
||||
section_count = section_count + 1
|
||||
section_name(section_count) = name
|
||||
section_type(section_count) = stype
|
||||
section_material_name(section_count) = mat_name
|
||||
section_material_id(section_count) = 1
|
||||
section_material_id(section_count) = mat_index
|
||||
section_thickness(section_count) = thickness
|
||||
section_integration_points(section_count) = points
|
||||
end subroutine sph_db_add_section
|
||||
|
||||
integer function sph_db_find_material(name)
|
||||
character(len=*), intent(in) :: name
|
||||
integer :: i
|
||||
|
||||
sph_db_find_material = 0
|
||||
do i = 1, material_count
|
||||
if (sph_db_name_equal(material_name(i), name)) then
|
||||
sph_db_find_material = i
|
||||
return
|
||||
end if
|
||||
end do
|
||||
end function sph_db_find_material
|
||||
|
||||
logical function sph_db_name_equal(left, right)
|
||||
character(len=*), intent(in) :: left
|
||||
character(len=*), intent(in) :: right
|
||||
|
||||
sph_db_name_equal = trim(sph_db_upper(left)) == trim(sph_db_upper(right))
|
||||
end function sph_db_name_equal
|
||||
|
||||
function sph_db_upper(text) result(out)
|
||||
character(len=*), intent(in) :: text
|
||||
character(len=len(text)) :: out
|
||||
integer :: i
|
||||
integer :: code
|
||||
|
||||
out = text
|
||||
do i = 1, len(out)
|
||||
code = ichar(out(i:i))
|
||||
if (code >= ichar('a') .and. code <= ichar('z')) then
|
||||
out(i:i) = char(code - ichar('a') + ichar('A'))
|
||||
end if
|
||||
end do
|
||||
end function sph_db_upper
|
||||
|
||||
subroutine sph_db_add_nset(name, member_count, first_member, ierr)
|
||||
character(len=*), intent(in) :: name
|
||||
integer, intent(in) :: member_count
|
||||
|
||||
Reference in New Issue
Block a user