[gmx-developers] rvec x[]

Nathan Moore nmoore at physics.umn.edu
Fri Jun 24 23:07:00 CEST 2005

Hi All,

Where is the "rvex x[]" class defined?  I assumed that it was a flat array
in the replacement for move_x below and got compiler errors:

"mvxvf.c", line 196.14: 1506-068 (W) Operation between types "double*" and
"double" is not allowed.
"mvxvf.c", line 196.9: 1506-025 (S) Operand must be a modifiable lvalue.

Also,  What does the "where();" fucntion at the bottom of move_f and
move_x do?

My code snippet follows, all suggestions welcome!  I suppose that since X
isn't flat I'll need to pass it with MPI with a type other that

thanks again for all the help!


    int i;
    int NT_status; /* Did the send work? */

    int array_length; /* length of the whole x array */
    array_length = DIM * (nsb->natoms);

    int start_element; /* index of where this node's array begins */
    start_element = nsb->index[nsb->nodeid];

    /* The number of elements each node sends */
    int *num_sent = (int *) malloc((nsb->nnodes) * sizeof(int));
    for (i = 0; i < (nsb->nnodes); i++) {
        num_sent[i] = nsb->homenr[i];

    /* The starting index of each node's block of elements */
    /* note the obvious redundancy that
start_element==starting_block[nsb->nodeid] */
    int *starting_block = (int *) malloc((nsb->nnodes) * sizeof(int));
    for (i = 0; i < (nsb->nnodes); i++) {
        starting_block[i] = nsb->index[i];

    /* The tempporary array where x elements are gathered to */
    double *temp_x = (double *) malloc(array_length * sizeof(double));

    /* pass the x array around */
    NT_status = MPI_Allgatherv(&x[start_element],
                               MPI_DOUBLE, MPI_COMM_WORLD);

    /* update the x array with the gathered temp_x array */
    for (i = 0; i < array_length; i++) {
        x[i] = temp_x[i];


More information about the gromacs.org_gmx-developers mailing list