text: #include <omp.h> 
  #include <stdio.h>
  #include <mpi.h>
  #include <stdlib.h>
  //************************************SERIAL WRITE******************************************** 
  
  void serialwrite(double* iodata, int N1, int N2, int N3, MPI_Comm cartcomm, char* FILENAME)
  {
                       
      int             iounit = 10,
                      i = 100,
                      j = 100, 
                      k = 100,
                      nprocs,myrank;   
      FILE*           in_file;   
      in_file =       fopen(FILENAME, "w+b"); 
      MPI_Comm_size(cartcomm, &nprocs);
      MPI_Comm_rank(cartcomm, &myrank);
      if (! in_file )
      {  
          printf("oops, file can't be read\n"); 
          exit(-1); 
      } 
      for(i = 0; i<nprocs; i++)
      {
          fwrite(iodata,1, N1*N2*N3*sizeof(double), in_file); 
      }
      printf("File written \n");           
      fclose(in_file); 
  }
  //************************************SERIAL READ******************************************** 
  
  void serialread(double* iodata, int N1, int N2, int N3, MPI_Comm cartcomm, char* FILENAME_read, char* FILENAME_write)
  {
                       
      int             iounit = 10,
                      i = 100,
                      j = 100, 
                      k = 100,
                      nprocs,myrank;   
      FILE*           in_file;   
      in_file =       fopen(FILENAME_read, "r+b"); 
      MPI_Comm_size(cartcomm, &nprocs);
      MPI_Comm_rank(cartcomm, &myrank);
      if (! in_file )
      {  
          printf("oops, file can't be read\n"); 
          exit(-1); 
      } 
      for(i = 0; i<nprocs; i++) 
      {
          fread(iodata,1, N1*N2*N3*sizeof(double),in_file); 
      }
      printf("File read\n");  
      test_checksum(FILENAME_read, FILENAME_write) 
      // for(i = 0; i < N1; i++) 
      // {
      //     for(j = 0; j < N2; j++)
      //     {
      //         for(k = 0; k < N3; k++)
      //         {
      //                 // *(iodata_func + i*(int)(N2*N3) + j*(int)N3 + k) = -1; // initialise all values with -1 
      //                 if (iodata[i*(N2*N3) + j*N3 + k] != 7 * i * j * k)
      //                 {
      //                     printf("Checksum test failed \n"); 
      //                 }
      //         }
      //     }
      // }          
      fclose(in_file); 
  }