Previous: Example of Simple Parallel I/O Access Next: Using NetCDF Parallel I/O in Fortran 90 Table of contents Frames User guide
2009 Unidata NetCDF Workshop for Developers and Data Providers > Parallel I/O with NetCDF

21.9 Example of Simple Parallel I/O Access (part 2)
The nc_test4/tst_parallel3.c program provides an example of parallel I/O.

 

    /* Set up slab for this process. */
    start[0] = 0;
    start[1] = mpi_rank * DIMSIZE/mpi_size;
    count[0] = DIMSIZE2;
    count[1] = DIMSIZE/mpi_size;

    /* Create some test data. */
    data      = malloc(sizeof(int)*count[1]*count[0]);
    tempdata  = data;
    for (j = 0; j < count[0];j++){
      for (i=0; i < count[1]; i++){
        *tempdata = mpi_rank*(j+1);
        tempdata ++;
      }
    }

    /* Write two dimensional integer data */
    if ((res = nc_put_vara_int(ncid, nvid, start, count, data))){
       free(data);
       BAIL(res);
    }

 


Previous: Example of Simple Parallel I/O Access Next: Using NetCDF Parallel I/O in Fortran 90 Table of contents Frames User guide
2009 Unidata NetCDF Workshop for Developers and Data Providers > Parallel I/O with NetCDF