Commit f46a3726 authored by Jorn Bruggeman's avatar Jorn Bruggeman
Browse files

fixed horizontal APIs when called with start index other than 1

parent e1f1f08e
......@@ -653,7 +653,10 @@ contains
call fatal_error('start', 'set_domain has not yet been called on this model object.')
return
elseif (self%status >= status_start_done) then
! start has been called on this model before and it must have succeeded to have this status. We are done.
! start has been called on this model before and it must have succeeded to have this status.
! Reset store (e.g., all diagnostics) by setting each variable to its fill value and return.
! (this allows masked cells to be properly initialized if the mask changes between calls to start)
call reset_store(self)
return
end if
......@@ -1772,8 +1775,8 @@ contains
subroutine get_surface_sources(self _POSTARG_HORIZONTAL_IN_, flux_pel, flux_sf)
class (type_fabm_model), intent(inout) :: self
_DECLARE_ARGUMENTS_HORIZONTAL_IN_
real(rke) _DIMENSION_HORIZONTAL_SLICE_PLUS_1_, intent(out) :: flux_pel
real(rke) _DIMENSION_HORIZONTAL_SLICE_PLUS_1_, intent(out), optional :: flux_sf
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_PLUS_1_, intent(out) :: flux_pel
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_PLUS_1_, intent(out), optional :: flux_sf
integer :: i, k
_DECLARE_HORIZONTAL_INDICES_
......@@ -1811,7 +1814,7 @@ contains
subroutine get_bottom_sources_rhs(self _POSTARG_HORIZONTAL_IN_, flux_pel, flux_ben)
class (type_fabm_model), intent(inout) :: self
_DECLARE_ARGUMENTS_HORIZONTAL_IN_
real(rke) _DIMENSION_HORIZONTAL_SLICE_PLUS_1_, intent(inout) :: flux_pel, flux_ben
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_PLUS_1_, intent(inout) :: flux_pel, flux_ben
integer :: i, k
_DECLARE_HORIZONTAL_INDICES_
......@@ -1846,7 +1849,7 @@ contains
class (type_fabm_model), intent(inout) :: self
_DECLARE_ARGUMENTS_HORIZONTAL_IN_
integer, intent(in) :: benthos_offset
real(rke) _DIMENSION_HORIZONTAL_SLICE_PLUS_2_, intent(inout) :: pp, dd
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_PLUS_2_, intent(inout) :: pp, dd
integer :: icall, i, j, k, ncopy
_DECLARE_HORIZONTAL_INDICES_
......@@ -1928,7 +1931,7 @@ contains
subroutine get_horizontal_conserved_quantities(self _POSTARG_HORIZONTAL_IN_, sums)
class (type_fabm_model), intent(inout) :: self
_DECLARE_ARGUMENTS_HORIZONTAL_IN_
real(rke) _DIMENSION_HORIZONTAL_SLICE_PLUS_1_, intent(out) :: sums
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_PLUS_1_, intent(out) :: sums
integer :: i
_DECLARE_HORIZONTAL_INDICES_
......@@ -2604,7 +2607,6 @@ contains
subroutine create_store(self)
class (type_fabm_model), intent(inout) :: self
integer :: i
type (type_variable_node), pointer :: variable_node
! Allocate memory for persistent store
......@@ -2624,14 +2626,7 @@ contains
call collect_fill_values(self%variable_register%store%interior, self%store%interior_missing_value, use_missing=.true.)
call collect_fill_values(self%variable_register%store%horizontal, self%store%horizontal_missing_value, use_missing=.true.)
! Initialize persistent store entries to fill value.
! For constant outputs, their values will be set here, and never touched again.
do i = 1, self%variable_register%store%interior%count
self%store%interior(_PREARG_LOCATION_DIMENSIONS_ i) = self%store%interior_fill_value(i)
end do
do i = 1, self%variable_register%store%horizontal%count
self%store%horizontal(_PREARG_HORIZONTAL_LOCATION_DIMENSIONS_ i) = self%store%horizontal_fill_value(i)
end do
call reset_store(self)
! Register data fields from persistent store in catalog.
variable_node => self%variable_register%catalog%interior%first
......@@ -2677,6 +2672,21 @@ contains
end subroutine create_store
subroutine reset_store(self)
class (type_fabm_model), intent(inout) :: self
integer :: i
! Initialize persistent store entries to fill value.
! For constant outputs, their values will be set here, and never touched again.
do i = 1, self%variable_register%store%interior%count
self%store%interior(_PREARG_LOCATION_DIMENSIONS_ i) = self%store%interior_fill_value(i)
end do
do i = 1, self%variable_register%store%horizontal%count
self%store%horizontal(_PREARG_HORIZONTAL_LOCATION_DIMENSIONS_ i) = self%store%horizontal_fill_value(i)
end do
end subroutine
recursive subroutine merge_indices(model, log_unit)
class (type_base_model), intent(inout) :: model
integer, intent(in), optional :: log_unit
......
......@@ -270,7 +270,7 @@ contains
subroutine fabm_get_horizontal_conserved_quantities(self _POSTARG_HORIZONTAL_IN_, sums)
class (type_model), intent(inout) :: self
_DECLARE_ARGUMENTS_HORIZONTAL_IN_
real(rke) _DIMENSION_HORIZONTAL_SLICE_PLUS_1_, intent(out) :: sums
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_PLUS_1_, intent(out) :: sums
call self%get_horizontal_conserved_quantities(_PREARG_HORIZONTAL_IN_ sums)
end subroutine
......@@ -291,7 +291,7 @@ contains
subroutine fabm_do_bottom_rhs(self _POSTARG_HORIZONTAL_IN_, flux_pel, flux_ben)
class (type_model), intent(inout) :: self
_DECLARE_ARGUMENTS_HORIZONTAL_IN_
real(rke) _DIMENSION_HORIZONTAL_SLICE_PLUS_1_, intent(inout) :: flux_pel, flux_ben
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_PLUS_1_, intent(inout) :: flux_pel, flux_ben
call self%get_bottom_sources(_PREARG_HORIZONTAL_IN_ flux_pel, flux_ben)
end subroutine
......@@ -299,15 +299,15 @@ contains
class (type_model), intent(inout) :: self
_DECLARE_ARGUMENTS_HORIZONTAL_IN_
integer, intent(in) :: benthos_offset
real(rke) _DIMENSION_HORIZONTAL_SLICE_PLUS_2_, intent(inout) :: pp, dd
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_PLUS_2_, intent(inout) :: pp, dd
call self%get_bottom_sources(_PREARG_HORIZONTAL_IN_ pp, dd, benthos_offset)
end subroutine
subroutine fabm_do_surface(self _POSTARG_HORIZONTAL_IN_, flux_pel, flux_sf)
class (type_model), intent(inout) :: self
_DECLARE_ARGUMENTS_HORIZONTAL_IN_
real(rke) _DIMENSION_HORIZONTAL_SLICE_PLUS_1_, intent(out) :: flux_pel
real(rke) _DIMENSION_HORIZONTAL_SLICE_PLUS_1_, intent(out), optional :: flux_sf
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_PLUS_1_, intent(out) :: flux_pel
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_PLUS_1_, intent(out), optional :: flux_sf
call self%get_surface_sources(_PREARG_HORIZONTAL_IN_ flux_pel, flux_sf)
end subroutine
......@@ -367,7 +367,7 @@ contains
subroutine fabm_get_drag(self _POSTARG_HORIZONTAL_IN_, drag)
class (type_model), intent(inout) :: self
_DECLARE_ARGUMENTS_HORIZONTAL_IN_
real(rke) _DIMENSION_HORIZONTAL_SLICE_, intent(out) :: drag
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_, intent(out) :: drag
_DECLARE_HORIZONTAL_INDICES_
......@@ -387,7 +387,7 @@ contains
subroutine fabm_get_albedo(self _POSTARG_HORIZONTAL_IN_, albedo)
class (type_model), intent(inout) :: self
_DECLARE_ARGUMENTS_HORIZONTAL_IN_
real(rke) _DIMENSION_HORIZONTAL_SLICE_, intent(out) :: albedo
real(rke) _DIMENSION_EXT_HORIZONTAL_SLICE_, intent(out) :: albedo
_DECLARE_HORIZONTAL_INDICES_
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment