Skip to content

Commit

Permalink
better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed May 11, 2016
1 parent af76675 commit fc48722
Showing 1 changed file with 48 additions and 36 deletions.
84 changes: 48 additions & 36 deletions src/clib/pio_nc_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,21 +391,24 @@ int PIOc_inq_dim(int ncid, int dimid, char *name, PIO_Offset *lenp)
check_netcdf(file, ierr, __FILE__, __LINE__);

/* Broadcast results to all tasks. Ignore NULL parameters. */
if (name)
{
int slen;
if (ios->iomaster)
slen = strlen(name);
if ((mpierr = MPI_Bcast(&slen, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
if ((mpierr = MPI_Bcast((void *)name, slen + 1, MPI_CHAR, ios->ioroot, ios->my_comm)))
return PIO_EIO;
if (!ierr)
{
if (name)
{
int slen;
if (ios->iomaster)
slen = strlen(name);
if ((mpierr = MPI_Bcast(&slen, 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
if ((mpierr = MPI_Bcast((void *)name, slen + 1, MPI_CHAR, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
}

if (lenp)
if ((mpierr = MPI_Bcast(lenp , 1, MPI_OFFSET, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
}

if (lenp)
if ((mpierr = MPI_Bcast(lenp , 1, MPI_OFFSET, ios->ioroot, ios->my_comm)))
return PIO_EIO;


return ierr;
}

Expand Down Expand Up @@ -533,13 +536,13 @@ int PIOc_inq_dimid(int ncid, const char *name, int *idp)

/* Broadcast and check the return code. */
if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);
check_netcdf(file, ierr, __FILE__, __LINE__);

/* Broadcast results. */
if (idp)
if ((mpierr = MPI_Bcast(idp, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);

return ierr;
}
Expand Down Expand Up @@ -632,7 +635,7 @@ int PIOc_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp,

/* Broadcast and check the return code. */
if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);
check_netcdf(file, ierr, __FILE__, __LINE__);

/* Broadcast the results for non-null pointers. */
Expand All @@ -642,30 +645,30 @@ int PIOc_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp,
if(ios->iomaster)
slen = strlen(name);
if ((mpierr = MPI_Bcast(&slen, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);
if ((mpierr = MPI_Bcast((void *)name, slen + 1, MPI_CHAR, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);
}
if (xtypep)
if ((mpierr = MPI_Bcast(xtypep, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);

if (ndimsp)
{
if ((mpierr = MPI_Bcast(ndimsp, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);
file->varlist[varid].ndims = (*ndimsp);
}
if (dimidsp)
{
if ((mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);
if ((mpierr = MPI_Bcast(dimidsp, ndims, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);
}
if (nattsp)
if ((mpierr = MPI_Bcast(nattsp, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);

return ierr;
}
Expand Down Expand Up @@ -852,13 +855,13 @@ int PIOc_inq_varid (int ncid, const char *name, int *varidp)

/* Broadcast and check the return code. */
if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);
check_netcdf(file, ierr, __FILE__, __LINE__);

/* Broadcast results to all tasks. Ignore NULL parameters. */
if (varidp)
if ((mpierr = MPI_Bcast(varidp, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);

return ierr;
}
Expand Down Expand Up @@ -946,16 +949,19 @@ int PIOc_inq_att(int ncid, int varid, const char *name, nc_type *xtypep,

/* Handle errors. */
if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
check_mpi(file, mpierr, __FILE__, __LINE__);
check_netcdf(file, ierr, __FILE__, __LINE__);

/* Broadcast results. */
if(xtypep)
if ((mpierr = MPI_Bcast(xtypep, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return PIO_EIO;
if(lenp)
if ((mpierr = MPI_Bcast(lenp, 1, MPI_OFFSET, ios->ioroot, ios->my_comm)))
return PIO_EIO;
if (!ierr)
{
if(xtypep)
if ((mpierr = MPI_Bcast(xtypep, 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
if(lenp)
if ((mpierr = MPI_Bcast(lenp, 1, MPI_OFFSET, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
}

return ierr;
}
Expand Down Expand Up @@ -1130,11 +1136,17 @@ int PIOc_inq_attid (int ncid, int varid, const char *name, int *idp)
}

/* Handle errors. */
mpierr = MPI_Bcast(&ierr , 1, MPI_INT, ios->ioroot, ios->my_comm);
if ((mpierr = MPI_Bcast(&ierr, 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
check_netcdf(file, ierr, __FILE__, __LINE__);

if (idp)
mpierr = MPI_Bcast(idp , 1, MPI_INT, ios->ioroot, ios->my_comm);
/* Broadcast results. */
if (!ierr)
{
if (idp)
if ((mpierr = MPI_Bcast(idp , 1, MPI_INT, ios->ioroot, ios->my_comm)))
check_mpi(file, mpierr, __FILE__, __LINE__);
}

return ierr;
}
Expand Down

0 comments on commit fc48722

Please sign in to comment.