Internal: Reorder all columns according to index array
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(data_frame), | intent(inout) | :: | df | |||
integer, | intent(in), | dimension(:) | :: | indices |
subroutine reorder_all_columns(df, indices) type(data_frame), intent(inout) :: df integer, dimension(:), intent(in) :: indices integer :: i, j real(rk), allocatable :: real_temp(:) integer(ik), allocatable :: int_temp(:) logical, allocatable :: logical_temp(:) character(len=:), allocatable :: char_temp(:) complex(rk), allocatable :: complex_temp(:) type(column) :: col do i = 1, df % ncols() col = df % get_data_col(i) select case (col % get_type()) case (REAL_NUM) allocate (real_temp(df % nrows())) do j = 1, df % nrows() real_temp(j) = col % getr(indices(j)) end do call col % destroy() call col % new(real_temp) call df % set_data_col(i, col) deallocate (real_temp) case (INTEGER_NUM) allocate (int_temp(df % nrows())) do j = 1, df % nrows() int_temp(j) = col % geti(indices(j)) end do call col % destroy() call col % new(int_temp) call df % set_data_col(i, col) deallocate (int_temp) case (LOGICAL_NUM) allocate (logical_temp(df % nrows())) do j = 1, df % nrows() logical_temp(j) = col % getl(indices(j)) end do call col % destroy() call col % new(logical_temp) call df % set_data_col(i, col) deallocate (logical_temp) case (CHARACTER_NUM) allocate (character(len=len(col % getch(1))) :: char_temp(df % nrows())) do j = 1, df % nrows() char_temp(j) = col % getch(indices(j)) end do call col % destroy() call col % new(char_temp) call df % set_data_col(i, col) deallocate (char_temp) case (COMPLEX_NUM) allocate (complex_temp(df % nrows())) do j = 1, df % nrows() complex_temp(j) = col % getc(indices(j)) end do call col % destroy() call col % new(complex_temp) call df % set_data_col(i, col) deallocate (complex_temp) end select end do end subroutine reorder_all_columns