Написание параллельной программы определяющей, сколько целых чисел, имеющих в качестве простых сомножителей 2, 3 или 5, лежит в диапазоне от M до N, страница 3

                                    if (MPI_COMM_WORLD.cur++ < MPI_COMM_WORLD.pos) {

                                    char name[16];

                                    strcpy(name, "Point№");

                                    itoa(MPI_COMM_WORLD.cur, temp, 10);

                                    strcat(name, temp);

                                    printf("Пытаюсь установить сессию с ветвью %s\n", name);

                                    call(MPI_COMM_WORLD, name, MPI_COMM_WORLD.name, post_handle, 20, 20);

                                    }

                                    break;

            case RECEIVE_ANY:

                                    calculate();

                                    break;

            default:    break;

            }

}

/////////////////////////////////////////////////////////////////////////////////////////////////

void post_task()// На главной машине формируются диапазоны поиска исходя из

{                        //количества машин и исходного диапазона, и рассылаются

            STATUS_INFO info;//в кластере.

            int stations[MAX_WORKER + 1], duplicate = 0, i, j, last;

            char temp_buf[BUF_LEN], temp[sizeof(double)+1], *off, name[16];

            int number, remain, size, total, station,j1, j2;

            for (i = 1; i <= MAX_WORKER; i++)

                        MPI_COMM_WORLD.answer[i] = 0;

            name_status(MPI_COMM_WORLD, MPI_COMM_WORLD.name, &info);

            for (i = 0,j = 0; i < info.session_count; i++)

            {

                        if (info.session_data[i].state != 3)

                                    continue;

                        strcpy(name, info.session_data[i].remote_name);

                        off = name + 6;

                        if (atoi(off) == MPI_COMM_WORLD.pos && duplicate)

                                    continue;

                        stations[++j] = atoi(off);

                        if (atoi(off) == MPI_COMM_WORLD.pos)

                                    duplicate = 1;

            }

            MPI_Comm_size(MPI_COMM_WORLD, &size);

            total =  MPI_COMM_WORLD.K - MPI_COMM_WORLD.N + 1;//matrix size

            number = total/size;//task size

            remain = total%size;//remainder

            j1 = MPI_COMM_WORLD.N;        

            station = 1;

            last = 0;

            for (j = MPI_COMM_WORLD.N; j < MPI_COMM_WORLD.K;/* j++*/)

            {

                    j2 = j1 + number + remain;

                        remain = 0;

                        sprintf(temp_buf, "%d %d %d %d", 1, MPI_COMM_WORLD.N, j1, j2 - 1);

                        printf("*Выдаю задание для ветви Point№%d\n",stations[station]);

                        MPI_Send(temp_buf, strlen(temp_buf) + 1, stations[station++], MPI_COMM_WORLD);

                        j1 = j2;

                        j = j1;

            }

            MPI_COMM_WORLD.ack = size;

}