mpi error from ncmpi_end_indep_data

Wei-keng Liao wkliao at eecs.northwestern.edu
Tue Dec 30 12:13:43 CST 2014


Hi, Jim

I was not able to reproduce the error. Could you try the following program?
Also, could you add an error checking for the ncmpi APIs before ncmpi_end_indep_data.
I wonder if there is an error returned from one of those APIs.

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

#define NY 4
#define NX 10
#define NDIMS 2

#define ERR \
    if (err != NC_NOERR) { \
        printf("Error at line=%d: %s\n", __LINE__, ncmpi_strerror(err)); \
    }

int main(int argc, char** argv)
{
    int rank, nprocs, err;
    int ncid, varid, dimid[2], req, st;
    MPI_Offset start[2], count[2], stride[2];
    unsigned char buffer[NY][NX];

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

    err = ncmpi_create(MPI_COMM_WORLD, "testfile.nc", NC_CLOBBER|NC_64BIT_DATA,
                       MPI_INFO_NULL, &ncid);
    ERR

    err = ncmpi_def_dim(ncid, "Y", NY,        &dimid[0]); ERR
    err = ncmpi_def_dim(ncid, "X", NX*nprocs, &dimid[1]); ERR
    err = ncmpi_def_var(ncid, "var", NC_UBYTE, NDIMS, dimid, &varid); ERR
    err = ncmpi_enddef(ncid); ERR

     start[0] = 0;     start[1] = NX*rank;
     count[0] = NY/2;  count[1] = NX/2;
    stride[0] = 2;    stride[1] = 2;
    err = ncmpi_buffer_attach(ncid, NY*NX); ERR

    err = ncmpi_begin_indep_data(ncid); ERR
    err = ncmpi_bput_vars_uchar(ncid, varid, start, count, stride,
                                &buffer[0][0], &req);
    ERR
    err = ncmpi_wait(ncid, 1, &req, &st); ERR
    err = ncmpi_end_indep_data(ncid); ERR

    err = ncmpi_buffer_detach(ncid); ERR
    err = ncmpi_close(ncid); ERR

    MPI_Finalize();
    return 0;
}


Wei-keng

On Dec 30, 2014, at 10:31 AM, Jim Edwards wrote:

> Hi Wei-keng,
> 
> I have a code block that looks like:
> 
>       ncmpi_begin_indep_data(file->fh);
> 
>       usage = 0;
> 
>       if(ios->io_rank==file->indep_rank){
> 
> ierr = ncmpi_bput_vars_uchar(file->fh, varid, start, count, stride, op, &request);;
> 
> pio_push_request(file, request);
> 
> ierr = ncmpi_inq_buffer_usage(ncid, &usage);
> 
> //	printf("%s %d %d\n",__FILE__,__LINE__,usage);
> 
>       }
> 
> 
>       ncmpi_end_indep_data(file->fh);
> 
> 
> It's generating an error message on the ncmpi_end_indep_data call:
> MPI_FILE_WRITE_AT(83): File does not exist
> 
> Regardless of the error message the write seems to work fine, any idea what's causing this?
> 
> I'm using pnetcdf svn revision 1920 with intel 15 compiler and mpich.
> 
> - Jim
> 
>    
> 
> 
> 
> 
> 
> 
> -- 
> Jim Edwards
> 
> CESM Software Engineer
> National Center for Atmospheric Research
> Boulder, CO 



More information about the parallel-netcdf mailing list