def loc2rank(loc, procs):
    """ Return the MPI rank using

    - loc, the tuple of subdomain location
    - procs, the tuple of number of subdomains in each direction

    loc2rank is the reverse operation of rank2loc

    """
    rank = (loc[0]*procs[1] + loc[1])*procs[2] + loc[2]
    return rank