Skip to content

Commit

Permalink
Simplfy code in parse_source.f90
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisfish committed Oct 11, 2023
1 parent cdafa24 commit 8932970
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/parse/parse_helpers.f90
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type(vector) function get_vector(child, key, error, context, default)
if (associated(arr))then
if(len(arr) /= 3)then
call make_error(error, &
context%report("Expected vector of size 3 for"//key, origin, "Wrong vector size"), -1)
context%report("Expected vector of size 3 for "//key, origin, "Wrong vector size"), -1)
return
end if
do j = 1, len(arr)
Expand Down
37 changes: 13 additions & 24 deletions src/parse/parse_source.f90
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,8 @@ subroutine parse_source(table, packet, dict, spectrum, context, error)

children => null()

call get_value(child, "direction", children, requested=.false., origin=origin)
if(associated(children))then
if(state%source == "point")then
print'(a)',context%report(&
"Point source needs no direction!!", origin, level=toml_level%warning)
end if
nlen = len(children)
if(nlen < 3)then
call make_error(error, &
context%report("Need a vector of size 3 for direction", origin, "expected vector of size 3"), -1)
return
end if
if(state%source == "circular")then
print'(a)',context%report(&
"Direction not yet fully tested for source type Circular. Results may not be accurate!", origin,&
level=toml_level%warning)
end if
do i = 1, len(children)
call get_value(children, i, dir(i))
end do
dirr%x = dir(1)
dirr%y = dir(2)
dirr%z = dir(3)
else
dirr = get_vector(child, "direction", error, context)
if(allocated(error))then
call get_value(child, "direction", direction, origin=origin)
if(allocated(direction))then
if(state%source == "point")then
Expand Down Expand Up @@ -123,8 +101,19 @@ subroutine parse_source(table, packet, dict, spectrum, context, error)
"No direction specified"), -1)
return
end if
else
if(state%source == "point")then
print'(a)',context%report(&
"Point source needs no direction!!", origin, level=toml_level%warning)
elseif(state%source == "circular")then
print'(a)',context%report(&
"Direction not yet fully tested for source type Circular. Results may not be accurate!", origin,&
level=toml_level%warning)
end if
return
end if


children => null()

call get_value(child, "point1", children, requested=.false., origin=origin)
Expand Down

0 comments on commit 8932970

Please sign in to comment.