unique_int8 Subroutine

private subroutine unique_int8(array, unique_array)

整数型の配列からユニークな要素を取得する関数

Arguments

Type IntentOptional Attributes Name
integer(kind=int8), intent(in) :: array(:)

入力配列

integer(kind=int8), intent(inout), allocatable :: unique_array(:)

ユニークな要素の配列


Calls

proc~~unique_int8~~CallsGraph proc~unique_int8 unique_int8 interface~allocate_array allocate_array proc~unique_int8->interface~allocate_array sort sort proc~unique_int8->sort proc~allocate_rank1_int16 allocate_rank1_int16 interface~allocate_array->proc~allocate_rank1_int16 proc~allocate_rank1_int32 allocate_rank1_int32 interface~allocate_array->proc~allocate_rank1_int32 proc~allocate_rank1_int64 allocate_rank1_int64 interface~allocate_array->proc~allocate_rank1_int64 proc~allocate_rank1_int8 allocate_rank1_int8 interface~allocate_array->proc~allocate_rank1_int8 proc~allocate_rank1_logical1 allocate_rank1_logical1 interface~allocate_array->proc~allocate_rank1_logical1 proc~allocate_rank1_logical4 allocate_rank1_logical4 interface~allocate_array->proc~allocate_rank1_logical4 proc~allocate_rank1_logical8 allocate_rank1_logical8 interface~allocate_array->proc~allocate_rank1_logical8 proc~allocate_rank1_real128 allocate_rank1_real128 interface~allocate_array->proc~allocate_rank1_real128 proc~allocate_rank1_real32 allocate_rank1_real32 interface~allocate_array->proc~allocate_rank1_real32 proc~allocate_rank1_real64 allocate_rank1_real64 interface~allocate_array->proc~allocate_rank1_real64 proc~allocate_rank2_int16 allocate_rank2_int16 interface~allocate_array->proc~allocate_rank2_int16 proc~allocate_rank2_int32 allocate_rank2_int32 interface~allocate_array->proc~allocate_rank2_int32 proc~allocate_rank2_int64 allocate_rank2_int64 interface~allocate_array->proc~allocate_rank2_int64 proc~allocate_rank2_int8 allocate_rank2_int8 interface~allocate_array->proc~allocate_rank2_int8 proc~allocate_rank2_logical1 allocate_rank2_logical1 interface~allocate_array->proc~allocate_rank2_logical1 proc~allocate_rank2_logical4 allocate_rank2_logical4 interface~allocate_array->proc~allocate_rank2_logical4 proc~allocate_rank2_logical8 allocate_rank2_logical8 interface~allocate_array->proc~allocate_rank2_logical8 proc~allocate_rank2_real128 allocate_rank2_real128 interface~allocate_array->proc~allocate_rank2_real128 proc~allocate_rank2_real32 allocate_rank2_real32 interface~allocate_array->proc~allocate_rank2_real32 proc~allocate_rank2_real64 allocate_rank2_real64 interface~allocate_array->proc~allocate_rank2_real64 proc~error_message error_message proc~allocate_rank1_int16->proc~error_message proc~allocate_rank1_int32->proc~error_message proc~allocate_rank1_int64->proc~error_message proc~allocate_rank1_int8->proc~error_message proc~allocate_rank1_logical1->proc~error_message proc~allocate_rank1_logical4->proc~error_message proc~allocate_rank1_logical8->proc~error_message proc~allocate_rank1_real128->proc~error_message proc~allocate_rank1_real32->proc~error_message proc~allocate_rank1_real64->proc~error_message proc~allocate_rank2_int16->proc~error_message proc~allocate_rank2_int32->proc~error_message proc~allocate_rank2_int64->proc~error_message proc~allocate_rank2_int8->proc~error_message proc~allocate_rank2_logical1->proc~error_message proc~allocate_rank2_logical4->proc~error_message proc~allocate_rank2_logical8->proc~error_message proc~allocate_rank2_real128->proc~error_message proc~allocate_rank2_real32->proc~error_message proc~allocate_rank2_real64->proc~error_message log_error log_error proc~error_message->log_error

Called by

proc~~unique_int8~~CalledByGraph proc~unique_int8 unique_int8 interface~unique unique interface~unique->proc~unique_int8 proc~get_active_region_info type_vtk%get_active_region_info proc~get_active_region_info->interface~unique proc~initialize_type_coo type_coo%initialize_type_coo proc~initialize_type_coo->interface~unique proc~initialize type_material_manager%initialize proc~initialize->proc~get_active_region_info proc~initialize_type_crs type_crs%initialize_type_crs proc~initialize_type_crs->proc~initialize_type_coo proc~construct_type_thermal_3phase_2d construct_type_thermal_3phase_2d proc~construct_type_thermal_3phase_2d->proc~initialize_type_crs proc~type_proereties_manager_initialize type_proereties_manager%type_proereties_manager_initialize proc~type_proereties_manager_initialize->proc~initialize interface~construct_type_thermal_3phase_2d construct_type_thermal_3phase_2d interface~construct_type_thermal_3phase_2d->proc~construct_type_thermal_3phase_2d interface~type_thermal_3phase_2d type_thermal_3phase_2d interface~type_thermal_3phase_2d->interface~construct_type_thermal_3phase_2d

Source Code

    subroutine unique_int8(array, unique_array)
        !> 整数型の配列からユニークな要素を取得する関数
        implicit none
        integer(int8), intent(in) :: array(:) !! 入力配列
        integer(int8), intent(inout), allocatable :: unique_array(:) !! ユニークな要素の配列
        integer(int8), allocatable :: sorted_array(:)
        integer(int32) :: i, count

        if (size(array) == 0) then
            ! 空の配列が渡された場合
            call Allocate_Array(unique_array, 0_int32)
            return
        end if

        ! 入力配列をソート(Fortranではソート関数がないため、merge sortなどを実装するか、代替手段を用いる)
        sorted_array = array
        call sort(sorted_array)

        ! ユニークな要素をカウント
        count = 1 ! 最初の要素は必ずユニーク
        do i = 2, size(sorted_array)
            if (sorted_array(i) /= sorted_array(i - 1)) count = count + 1
        end do

        ! ユニークな要素を格納
        call Allocate_Array(unique_array, count)
        unique_array(1) = sorted_array(1)
        count = 1
        do i = 2, size(sorted_array)
            if (sorted_array(i) /= sorted_array(i - 1)) then
                count = count + 1
                unique_array(count) = sorted_array(i)
            end if
        end do
    end subroutine unique_int8