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 9206401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:10:03+00:00 2026-06-18T00:10:03+00:00

I’m supposed to send some integer number from one processor to another, and it

  • 0

I’m supposed to send some integer number from one processor to another, and it is to be done on shell server from my university…

First I created my solution code, which is going to look like (at least I think so…)

#include <stdio.h>
#include <mpi.h>

int main(int argc, char **argv)
{
    int currentRank = -1;

    MPI_Init(&argc, &argv);

    MPI_Comm_rank(MPI_COMM_WORLD, &currentRank);

    if(currentRank == 0) {
        int numberToSend = 1;
        MPI_Send(&numberToSend , 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
    }
    else if(currentRank == 1) {
        int recivedNumber;
        MPI_Recv(&recivedNumber, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
        printf("Recived number = %d\n", recivedNumber);
    }

    MPI_Finalize();

    return 0;
}

Than I should create some name.pbs file… and run it. And I can’t understand how to specify this number of processors… I tried like follow:

#PBS -l nodes=2:ppn=2 
#PBS -N cnt 
#PBS -j oe 
mpiexec ~/mpi1 

But later on still have no idea what to do with this on putty. qstat comamnd seems to do nothing… only when qstat -Q or q it shows me some ‘statistics’ but there are 0 values everywhere… it’s my first program in mpi and I really don’t understand it at all…

And when I try to run my program I get:

164900@halite:~$ ./transfer1
Fatal error in MPI_Send: Invalid rank, error stack:
MPI_Send(174): MPI_Send(buf=0x7fffd28ec640, count=1, MPI_INT, dest=1, tag=0, MPI_COMM_WORLD) failed
MPI_Send(99).: Invalid rank has value 1 but must be nonnegative and less than 1

Can anyone explain me how to run this on the server ?

  • 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-06-18T00:10:04+00:00Added an answer on June 18, 2026 at 12:10 am

    the example code works fine here, tested with OpenMPI and GCC,

    the problem is that when you run the code you need to specific the number of cores via your mpirun instance, you may havecorrectly allocated them using torque or what ever scheduler you are using but you are running the compiled code as if it were serial you need to run it with mpi heres and example with the associated output

    mpirun -np 2 ./example
    Recived number = 1
    

    with different scheduler hydra,PBS, or different MPI version you need to follow the same pattern as above and specific to your mpi run command the number of cores

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am confused How to use looping for Json response Array in another Array.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string

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.