Updates the state of the plume from its state vector. The state vector is a real array containing the value of each of the plume's properties at each of the locations on the grid used in discretization.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(plume), | intent(inout) | :: | this | |||
real(kind=r8), | intent(in), | dimension(:) | :: | state_vector | A real array containing the data describing the state of the plume. |
|
class(scalar_field), | intent(in), | optional | :: | ice_thickness | The ice thickness which, if present, will be used to update the calculation of the melt rate. |
subroutine plume_update(this, state_vector, ice_thickness)
!* Author: Christopher MacMackin
! Date: April 2016
!
! Updates the state of the plume from its state vector. The state
! vector is a real array containing the value of each of the plume's
! properties at each of the locations on the grid used in discretization.
!
class(plume), intent(inout) :: this
real(r8), dimension(:), intent(in) :: state_vector
!! A real array containing the data describing the state of the
!! plume.
class(scalar_field), optional, intent(in) :: ice_thickness
!! The ice thickness which, if present, will be used to update
!! the calculation of the melt rate.
integer :: i
!TODO: Add some assertion-like checks that the state vector is the right size
call this%thickness%set_from_raw(state_vector(1:this%thickness_size))
i = 1 + this%thickness_size
call this%velocity%set_from_raw(state_vector(i:i + this%velocity_size - 1))
i = i + this%velocity_size
call this%velocity_dx%set_from_raw(state_vector(i:i + this%velocity_size - 1))
i = i + this%velocity_size
call this%temperature%set_from_raw(state_vector(i:i + this%temperature_size - 1))
i = i + this%temperature_size
call this%temperature_dx%set_from_raw(state_vector(i:i + this%temperature_size - 1))
i = i + this%temperature_size
call this%salinity%set_from_raw(state_vector(i:i + this%salinity_size - 1))
i = i + this%salinity_size
call this%salinity_dx%set_from_raw(state_vector(i:i + this%salinity_size - 1))
if (present(ice_thickness)) then
call this%melt_formulation%solve_for_melt(this%velocity, &
-ice_thickness/this%r_val, &
this%temperature, &
this%salinity, &
this%thickness, &
this%time)
end if
#ifdef DEBUG
call logger%debug('plume%update','Updated state of plume.')
#endif
end subroutine plume_update