init_loop_method Function

public pure function init_loop_method(use_do_classic, use_vectorized, use_do_concurrent, use_openmp, use_mpi, num_threads) result(loop_method)

Arguments

Type IntentOptional Attributes Name
logical, intent(in), optional :: use_do_classic
logical, intent(in), optional :: use_vectorized
logical, intent(in), optional :: use_do_concurrent
logical, intent(in), optional :: use_openmp
logical, intent(in), optional :: use_mpi
integer, intent(in), optional :: num_threads

Return Value type(LoopMethod)


Source Code

    pure function init_loop_method( &
        use_do_classic, &
        use_vectorized, &
        use_do_concurrent, &
        use_openmp, &
        use_mpi, &
        num_threads) result(loop_method)
        logical, intent(in), optional :: use_do_classic, &
                                         use_vectorized, &
                                         use_do_concurrent, &
                                         use_openmp, &
                                         use_mpi
        integer, intent(in), optional :: num_threads
        type(LoopMethod) :: loop_method
        logical :: method_used

        loop_method = empty_loop_method

        method_used = .false.
        if (present(use_do_classic)) then
            if (use_do_classic) loop_method%use_do_classic = .true.

        end if

        if (present(use_vectorized)) then
            if (use_vectorized) loop_method%use_vectorized = .true.
            call check_method_used(method_used)
        end if

        if (present(use_do_concurrent)) then
            if (use_do_concurrent) loop_method%use_do_concurrent = .true.
            call check_method_used(method_used)
        end if

        if (present(use_openmp)) then
            if (use_openmp) loop_method%parallel%use_openmp = .true.
            if (present(num_threads)) then
                if (num_threads > 0) then
                    loop_method%parallel%num_threads = num_threads
                else
                    error stop "num_threads must be a positive integer"
                end if
            end if
            call check_method_used(method_used)
        end if

        if (present(use_mpi)) then
            if (use_mpi) loop_method%parallel%use_mpi = .true.
            if (present(num_threads)) then
                if (num_threads > 0) then
                    loop_method%parallel%num_threads = num_threads
                else
                    error stop "num_threads must be a positive integer"
                end if
            end if
            call check_method_used(method_used)
        end if

        if (.not. method_used) then
            loop_method = default_loop_method
        end if

    end function init_loop_method