Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6885283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:36:55+00:00 2026-05-27T05:36:55+00:00

This assignment requires me to develop a MPI program for the parallel Odd-Even sort

  • 0

This assignment requires me to develop a MPI program for the parallel Odd-Even sort and brings together three functions:

  1. MPI_Compare_exchange() for the P2P compare and exchange operation
  2. MPI_Sort() for the parallel odd-even sort operation
  3. MPI_Is_sorted() test if the parallel array sort is done

I get these errors when compiling

OddEvenSort.c:102: error: invalid operands to binary / (have ‘int *’ and ‘int’)
OddEvenSort.c:102: error: subscripted value is neither array nor pointer
OddEvenSort.c:104: error: subscripted value is neither array nor pointer
OddEvenSort.c:112: error: subscripted value is neither array nor pointer
OddEvenSort.c:116: error: subscripted value is neither array nor pointer
OddEvenSort.c:123: error: subscripted value is neither array nor pointer

This is the code:

int MPI_Sort(int n,double * array, int root, MPI_Comm comm){

    int rank, x, m, size, a, i;
    if( rank == 0 )
    {
        array = (double *) calloc( n, sizeof(double) );
        srand( ((unsigned)time(NULL)+rank) );
        for( x = 0; x < n; x++ ) array[x]=((double)rand()/RAND_MAX)*m;
    }

    MPI_Scatter(array, n/size, MPI_DOUBLE, &a[0], n/size, MPI_DOUBLE, 0, comm );

    merge_sort(n/size,&a[0]);

    for(i=0;i<size;i++){

        if( (i+rank)%2 ==0 ){

            if( rank < size-1 ) 

                exchange(n/size,&a[0],rank,rank+1,comm);

            } else{

                if( rank > 0 ) exchange(n/size,&a[0],rank-1,rank,comm);

            }

            MPI_Barrier(comm);
        }

    MPI_Gather(&a[0], n/size, MPI_DOUBLE, array, n/size, MPI_DOUBLE, 0, comm);

    if( rank == 0 )
    {
        for( x = 0; x < n; x++ )  printf( "Output : %f\n", array[x] );

    }


}

I think it’s referring to this: &a[0] but I don’t know how to fix it. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:36:56+00:00Added an answer on May 27, 2026 at 5:36 am

    ‘a’ is defined as an int, not an array, so you can’t pass the address of element 0.

    I think what you intended was that ‘a’ is defined as a double, and of the same size as ‘array’.

    i.e

    double a[n];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this assignment due that requires the usage of FLTK. The code is
I'm working on a homework assignment that requires me to write a program that
For this assignment I had to create my own string class. I initially wrote
I've been working on this assignment, where I need to read in records and
How to set entire HTML in MSHTML? I am trying using this assignment: (Document
I obviously do not 'grok' C++. On this programming assignment, I have hit a
This is uni assignment and I have already done some stuff. Please go to
This is about a school assignment so I'm trying to do things by the
this is for an assignment at school, where I need to determine the size
This is part of a homework assignment. I've got several questions asking find the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.