def _current_sc_dir(sc_dir, grid):
    """Return current direction(s) for semicoarsening.

    Checks which directions can actually still be halved and adjusts ``sc_dir``
    if necessary for this particular grid.


    Parameters
    ----------
    grid : TensorMesh
        Current grid; a :class:`emg3d.meshes.TensorMesh` instance.

    sc_dir : int
        Direction of semicoarsening.

    Returns
    -------
    c_sc_dir : int
        Current direction of semicoarsening.

    """
    # Find out in which direction we want to half the number of cells.
    # This depends on an (optional) direction of semicoarsening, and
    # if the number of cells in a direction can still be halved.
    xsc_dir = (grid.shape_cells[0] % 2 != 0 or grid.shape_cells[0] < 3
               or sc_dir == 1)
    ysc_dir = (grid.shape_cells[1] % 2 != 0 or grid.shape_cells[1] < 3
               or sc_dir == 2)
    zsc_dir = (grid.shape_cells[2] % 2 != 0 or grid.shape_cells[2] < 3
               or sc_dir == 3)

    # Set current sc_dir depending on the above outcome.
    if xsc_dir:
        if ysc_dir:
            c_sc_dir = 6  # Only coarsen in z-direction.
        elif zsc_dir:
            c_sc_dir = 5  # Only coarsen in y-direction.
        else:
            c_sc_dir = 1  # Coarsen in y- and z-directions.
    elif ysc_dir:
        if zsc_dir:
            c_sc_dir = 4  # Only coarsen in x-direction.
        else:
            c_sc_dir = 2  # Coarsen in x- and z-directions.
    elif zsc_dir:
        c_sc_dir = 3  # Coarsen in x- and y-directions.
    else:
        c_sc_dir = 0  # Coarsen in all directions.

    return c_sc_dir