init_pass_int Subroutine

private subroutine init_pass_int(current, target_level)

Uses

Initialize gs2 to the level of target_level. The init_type current contains info about the current initialization level. At the end of the subroutine, current%level is set to target_level

Arguments

Type IntentOptional Attributes Name
type(init_type), intent(inout) :: current
integer, intent(in) :: target_level

Contents

Source Code


Source Code

  subroutine init_pass_int(current, target_level)
    use fields, only: init_fields
    use mp, only: mp_abort
    implicit none
    type(init_type), intent(inout) :: current
    integer, intent(in) :: target_level
    logical :: going_up
    integer :: ilevel, offset
    if (current%level .lt. init_level_list%basic) then
       call mp_abort("gs2_init::init cannot be called before &
            & initialize_gs2 in gs2 main", .true.)
    end if

    if (current%level .eq. target_level) then
       return
    else
       going_up = current%level < target_level

       if (going_up) then
          offset = 1
       else
          offset = 0
       end if

       ! Written as a while loop in this way such that we are not sensitive to the
       ! order of entries in the init_levels array.
       do while (current%level /= target_level)
          ilevel = findloc(init_levels%level, current%level + offset, dim = 1)
          current%level = init_levels(ilevel)%change_level(current, going_up)
       end do

    end if
  end subroutine init_pass_int