src/axl_async_bbapi.c
/* HACK
 *
 * Return a unique ID number for this node (tied to the hostname).
 *
 * The IBM BB API requires the user assign a unique node ID for the
 * 'contribid' when you start up the library.  IBM assumes you'd specify
 * the MPI rank here, but the bbapi, nor AXL, explicitly requires MPI.
 * Therefore, we return the numbers at the end of our hostname:
 * "sierra123" would return 123.
 *
 * This result is stored in id.  Returns 0 on success, nonzero otherwise. */
HACK
Return a unique ID number for this node (tied to the hostname).

The IBM BB API requires the user assign a unique node ID for the
'contribid' when you start up the library.  IBM assumes you'd specify
the MPI rank here, but the bbapi, nor AXL, explicitly requires MPI.
Therefore, we return the numbers at the end of our hostname:
"sierra123" would return 123.

This result is stored in id.  Returns 0 on success, nonzero otherwise.
HACK Return a unique ID number for this node ( tied to the hostname ) . The IBM BB API requires the user assign a unique node ID for the ' contribid ' when you start up the library . IBM assumes you ' d specify the MPI rank here but the bbapi nor AXL explicitly requires MPI . Therefore we return the numbers at the end of our hostname : " sierra123 " would return 123 . This result is stored in id . Returns 0 on success nonzero otherwise .
static int axl_get_unique_node_id(int* id)
{
    char hostname[256] = {0}; 
    int rc = gethostname(hostname, sizeof(hostname));
    if (rc) {
        fprintf(stderr, "Hostname too long\n");
        return 1;
    }
    size_t len = strlen(hostname);
    rc = 1;
    int i;
    int sawnum = 0;
    for (i = len - 1; i >= 0; i--) {
        if (isdigit(hostname[i])) {
            sawnum = 1;
        } else {
            if (sawnum) {
                *id = atoi(&hostname[i + 1]);
                rc = 0;
                break;
            }
        }
    }
    return rc;
}
static int axl_get_unique_node_id ( int * id ) { char hostname [ 256 ] = { 0 } ; int rc = gethostname ( hostname , sizeof ( hostname ) ) ; if ( rc ) { fprintf ( stderr , " \n " ) ; return 1 ; } size_t len = strlen ( hostname ) ; rc = 1 ; int i ; int sawnum = 0 ; for ( i = len - 1 ; i >= 0 ; i -- ) { if ( isdigit ( hostname [ i ] ) ) { sawnum = 1 ; } else { if ( sawnum ) { * id = atoi ( & hostname [ i + 1 ] ) ; rc = 0 ; break ; } } } return rc ; }
HACK
 Return a unique ID number for this node (tied to the hostname).
HACK Return a unique ID number for this node ( tied to the hostname ) .
/* Max hostname + \0 */ /* Look from the back of the string to find the beginning of our number */ /*
                 * We were seeing a number, but now we've hit a non-digit.
                 * We're done.
                 */