Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
n-claes committed Aug 18, 2023
1 parent be2f34e commit a307889
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
24 changes: 8 additions & 16 deletions src/settings/mod_settings.f08
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module mod_settings
! note: weird gfortran 8 bug here when using (len=:) for state_vector.
! This sometimes leads to wrong array allocation where every entry equals the
! one at the last index? Unable to reproduce with compiler versions >8.
character(len=str_len_arr), private, allocatable :: old_state_vector(:)
character(len=str_len_arr), private, allocatable :: derived_state_vector(:)
character(len=:), private, allocatable :: physics_type
logical, private :: state_vector_has_bfield
Expand Down Expand Up @@ -73,32 +72,22 @@ subroutine set_state_vector(this, physics_type)

this%physics_type = physics_type
call this%state_vector%assemble(physics_type)
select case(physics_type)
case("hd")
this%old_state_vector = [character(3) :: "rho", "v1", "v2", "v3", "T"]
case("hd-1d")
this%old_state_vector = [character(3) :: "rho", "v1", "T"]
case default
this%old_state_vector = [ &
character(3) :: "rho", "v1", "v2", "v3", "T", "a1", "a2", "a3" &
]
end select
call this%check_bfield()
call this%set_nb_eqs(size(this%old_state_vector))
call this%set_nb_eqs(size(this%state_vector%components))
call this%update_block_dimensions()
end subroutine set_state_vector


pure function get_state_vector(this) result(state_vector)
class(settings_t), intent(in) :: this
character(len=:), allocatable :: state_vector(:)
state_vector = this%old_state_vector
state_vector = this%state_vector%get_names()
end function get_state_vector


pure logical function state_vector_is_set(this)
class(settings_t), intent(in) :: this
state_vector_is_set = allocated(this%old_state_vector)
state_vector_is_set = allocated(this%state_vector%components)
end function state_vector_is_set


Expand Down Expand Up @@ -152,10 +141,14 @@ end subroutine update_block_dimensions

pure subroutine check_bfield(this)
use mod_get_indices, only: get_index
use mod_state_vector_names, only: sv_a1_name, sv_a2_name, sv_a3_name
class(settings_t), intent(inout) :: this

this%state_vector_has_bfield = ( &
any(get_index(names=["a1", "a2", "a3"], array=this%old_state_vector) /= 0) &
any(get_index( &
names=[sv_a1_name, sv_a2_name, sv_a3_name], &
array=this%state_vector%get_names()) /= 0 &
) &
)
end subroutine check_bfield

Expand All @@ -170,7 +163,6 @@ subroutine delete(this)
class(settings_t), intent(inout) :: this

call this%state_vector%delete()
if (allocated(this%old_state_vector)) deallocate(this%old_state_vector)
if (allocated(this%derived_state_vector)) deallocate(this%derived_state_vector)
if (allocated(this%physics_type)) deallocate(this%physics_type)
call this%io%delete()
Expand Down
2 changes: 1 addition & 1 deletion src/statevector/mod_state_vector.f08
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ subroutine set_default_basis_functions(this)
end subroutine set_default_basis_functions


function get_names(this) result(names)
pure function get_names(this) result(names)
class(state_vector_t), intent(in) :: this
character(len=:), allocatable :: names(:)
integer :: i
Expand Down
9 changes: 5 additions & 4 deletions src/statevector/mod_state_vector_component.f08
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function new_sv_component(name) result(sv_comp)
end function new_sv_component


function get_name(this) result(name)
pure function get_name(this) result(name)
class(sv_component_t), intent(in) :: this
character(:), allocatable :: name
name = this%name
Expand Down Expand Up @@ -89,8 +89,6 @@ end subroutine set_basis_function


subroutine get_spline_function(this, spline_order, spline_func)
use mod_basis_functions, only: hquad

class(sv_component_t), intent(in) :: this
integer, intent(in), optional :: spline_order
procedure(basis_function), pointer, intent(out) :: spline_func
Expand All @@ -108,7 +106,10 @@ subroutine get_spline_function(this, spline_order, spline_func)
case(2)
call this%ddspline(spline_func)
case default
call logger%error("spline order = " // str(order) // " not implemented")
call logger%error( &
"spline order = " // str(order) // " not implemented for spline " &
// trim(adjustl(this%spline_name)) &
)
return
end select
end subroutine get_spline_function
Expand Down

0 comments on commit a307889

Please sign in to comment.