snowhite89 0 Newbie Poster

This is MPI parallel program running using putty software..
I've done some part but I got errors... :'( can anyone tell me what's the problems?
I've done the serial part but I stuck in this parallel part.......

I was given an input file named input.txt, that contains 100000 lines of strings. Each string is
an alphanumeric strings (containing numbers, Uppercase and lowercase alphabets). The length
of each string is 100 characters.
Assuming that:
• Nlowercase = number of lowercase character in the string.
• Nuppercase = number of uppercase character in the string.
• Nnumbers = number of numbers in the string.
Aims of the project are:
1. Convert the string as follows:
(a) All alphabets in the string will be converted into LOWERCASE if Nlowercase >
Nuppercase and Nlowercase > Nnumbers.
(b) All alphabets in the string will be converted into UPPERCASE if Nuppercase >
Nlowercase and Nuppercase > Nnumbers.
(c) remain unchanged if Nnumbers > Nlowercase and Nnumbers > Nuppercase.
(d) Sort the string in alphabetical order.
(e) The sorted strings (output) should be written into a file named output.txt


#include <stdio.h>
#include <mpi.h>
void count_character();
void character_conversion();
void sort();

int main(int argc, char *argv[])
{
    const int SIZE= 100;
    char filename[SIZE];
    const int MAX_SIZE= 100;
    char character[MAX_SIZE];
    char ntemp;
    int sort;

    int lowercase= 0;
    int uppercase= 0;
    int number= 0;

    int bufsize, buf[15], count,rank,nprocs,i,nints;
    MPI_File fh;
    MPI_Status status;

    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);

    bufsize = sizeof(int)*30 / nprocs ; // local number to read
    nints = bufsize/sizeof (int);

    MPI_File_open(MPI_COMM_WORLD,"input.txt",MPI_MODE_RDONLY,MPI_INFO_NULL,&fh);
    MPI_File_seek(fh,rank*bufsize,MPI_SEEK_SET);
    MPI_File_read(fh,&buf,nints,MPI_INT,&status);
    MPI_File_close(&fh);

    if(rank == 0)
        count_character();
        character_conversion();
        sort();
        for(i=0;i<15;i++)
                printf("rank = %d " " i = %d" " \n", rank, buf[i]);
    free (buf);
    MPI_Finalize();
    return 0;
}
void count_character()
{
        for (int i=0; i<MAX_SIZE; i++)
        {
                if (isupper(character[i]))
                {
                        uppercase++;
                }
                else if (islower(character[i]))
                {
                         ++lowercase;
                }
                else if (isdigit(character[i]))
                {
                        ++number;
                }
        }
}

void character_conversion()
{
        for (int t=0; t<MAX_SIZE; t++)
        {
                if ((lowercase>uppercase) && (lowercase>number))
                {
                        character[t]= tolower(character[t]);
                }
                else if ((uppercase>lowercase) && (uppercase>number))
                {
                        character[t]= toupper(character[t]);
                }
                else if ((number>lowercase) && (number>uppercase))
                {
                        character[t];
        }
}

void sort()
{
        for (sort=0; sort<MAX_SIZE; ++sort)
        {
                ntemp = character[sort];
                int k;
                for (k= sort-1; k>=0 && character[k]> ntemp; k--)
                {
                        character[k+1]=character[k];
                }
                character[k+1] = ntemp;
        }
        for (sort=0; sort<MAX_SIZE; sort++)
        {
        outputFile<< character[sort];

        }
}