# vim: set ft=c:

MPI_Comm_get_parent:
    .desc: Return the parent communicator for this process
    .skip: global_cs

MPI_Comm_join:
    .desc: Create a communicator by joining two processes connected by a socket

MPI_Comm_spawn:
    .desc: Spawn up to maxprocs instances of a single MPI application
    .extra: errtest_comm_intra
    .skip: validate-STRING_ARRAY, validate-ERROR_CODE
{ -- error_check -- info, command, maxprocs
    if (comm_ptr->rank == root) {
        MPIR_ERRTEST_INFO_OR_NULL(info, mpi_errno);
        MPIR_ERRTEST_ARGNULL(command, "command", mpi_errno);
        MPIR_ERRTEST_ARGNEG(maxprocs, "maxprocs", mpi_errno);
    }
}
{ -- handle_ptr -- info
    MPIR_Info *info_ptr = NULL;
    if (comm_ptr->rank == root) {
        MPIR_Info_get_ptr(info, info_ptr);
    }
}

MPI_Comm_spawn_multiple:
    .desc: Spawn up multiple MPI applications
    .skip: ThreadSafe
    .extra: errtest_comm_intra
    .skip: validate-STRING_ARRAY, validate-STRING_2DARRAY, validate-COMM_SIZE, validate-INFO, validate-ERROR_CODE
    .error: MPI_ERR_INFO
{ -- declare --
    MPIR_Info **array_of_info_ptrs = NULL;
}
{ -- handle_ptr -- array_of_info
    if (comm_ptr->rank == root) {
        array_of_info_ptrs = MPL_malloc(count * sizeof(MPIR_Info *), MPL_MEM_OTHER);
        for (int i = 0; i < count; i++) {
            MPIR_Info_get_ptr(array_of_info[i], array_of_info_ptrs[i]);
        }
    }
}
{ -- clean_up --
    if (array_of_info_ptrs) {
        MPL_free(array_of_info_ptrs);
    }
}
{ -- error_check --
    if (comm_ptr->rank == root) {
        MPIR_ERRTEST_ARGNULL(array_of_info, "array_of_info", mpi_errno);
        MPIR_ERRTEST_ARGNULL(array_of_commands, "array_of_commands", mpi_errno);
        MPIR_ERRTEST_ARGNULL(array_of_maxprocs, "array_of_maxprocs", mpi_errno);
        MPIR_ERRTEST_ARGNONPOS(count, "count", mpi_errno, MPI_ERR_ARG);
        for (int i = 0; i < count; i++) {
            MPIR_ERRTEST_INFO_OR_NULL(array_of_info[i], mpi_errno);
            MPIR_ERRTEST_ARGNULL(array_of_commands[i], "array_of_commands[i]", mpi_errno);
            MPIR_ERRTEST_ARGNEG(array_of_maxprocs[i], "array_of_maxprocs[i]", mpi_errno);
        }
    }
}

MPI_Open_port:
    .desc: Establish an address that can be used to establish connections between groups of MPI processes

MPI_Close_port:
    .desc: close port

MPI_Comm_accept:
    .desc: Accept a request to form a new intercommunicator
{ -- error_check -- port_name
    if (comm_ptr->rank == root) {
        MPIR_ERRTEST_ARGNULL(port_name, "port_name", mpi_errno);
    }
}

MPI_Comm_connect:
    .desc: Make a request to form a new intercommunicator
{ -- error_check -- port_name
    if (comm_ptr->rank == root) {
        MPIR_ERRTEST_ARGNULL(port_name, "port_name", mpi_errno);
    }
}

MPI_Comm_disconnect:
    .desc: Disconnect from a communicator
    .seealso: MPI_Comm_connect, MPI_Comm_join
    .extra: ignore_revoked_comm

MPI_Lookup_name:
    .desc: Lookup a port given a service name

MPI_Publish_name:
    .desc: Publish a service name for use with MPI_Comm_connect

MPI_Unpublish_name:
    .desc: Unpublish a service name published with MPI_Publish_name
