def rank2loc(rank, procs):
    """ Return the tuple (k, j, i) of subdomain location

    - rank, the MPI rank
    - procs, the tuple of number of subdomains in each direction

    """

    loc = [rank // (procs[2]*procs[1]),
           (rank // procs[2]) % procs[1],
           rank % procs[2]]

    return loc