Given the functions to be computed, returns the segments that need to be propagated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
integer, | intent(in), | optional, | dimension(:) | :: | funcs_to_compute |
the indices of f to compute |
integer, | intent(out), | dimension(:), allocatable | :: | isegs_to_propagate |
segment numbers |
subroutine segs_to_propagate(me,funcs_to_compute,isegs_to_propagate) implicit none class(mission_type),intent(inout) :: me integer,dimension(:),intent(in),optional :: funcs_to_compute !! the indices of f to compute integer,dimension(:),allocatable,intent(out) :: isegs_to_propagate !! segment numbers integer :: i,j !! counters ! In this example, there are no dependencies, so we assume they ! can be propagated in any order. if (present(funcs_to_compute)) then ! this is for the "forward-backward" problem formulation: ! 1-6 7-12 13-19 20-26 ! f = [xf1-xf2, xf3-xf4, xf5-xf6, xf7-xf8, ... ] ! ! 0 1 2 ! f = [123456123456123456] ! ! 0: 1-2 ! 1: 3-4 ! 2: 5-6 ! 3: 7-8 do i = 1, size(funcs_to_compute) j = (funcs_to_compute(i)-1) / 6 ! 0,1,2,... call add_it(j*2+1,isegs_to_propagate) ! ... is this correct ? call add_it(j*2+2,isegs_to_propagate) end do ! warning: we are not accounting for fixing certain variables! ! see get_sparsity_pattern else ! propagate all the segments: isegs_to_propagate = [(i, i=1,size(me%segs))] end if !write(*,*) '' !write(*,*) 'funcs_to_compute:',funcs_to_compute !write(*,*) '' !write(*,*) 'isegs_to_propagate:',isegs_to_propagate !write(*,*) '' contains !******************************** subroutine add_it(segnum,array) implicit none integer,intent(in) :: segnum integer,dimension(:),allocatable,intent(inout) :: array if (allocated(array)) then if (.not. any(array==segnum)) then array = [array,segnum] end if else array = [segnum] ! auto LHS allocation end if end subroutine add_it !******************************** end subroutine segs_to_propagate