Skip to content

Commit

Permalink
Merge pull request ESMCI#1592 from NCAR/ejh_createfile_int_async
Browse files Browse the repository at this point in the history
Minor change in how createfile works in async mode
  • Loading branch information
edhartnett authored Aug 23, 2019
2 parents 86ad446 + ae93759 commit 6c24f63
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
13 changes: 3 additions & 10 deletions src/clib/pio_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,9 @@ PIOc_createfile(int iosysid, int *ncidp, int *iotype, const char *filename,
if ((ret = PIOc_createfile_int(iosysid, ncidp, iotype, filename, mode, 0)))
return pio_err(ios, NULL, ret, __FILE__, __LINE__);

/* Run this on all tasks if async is not in use, but only on
* non-IO tasks if async is in use. (Because otherwise, in async
* mode, set_fill would be called twice by each IO task, since
* PIOc_createfile() will already be called on each IO task.) */
if (!ios->async || !ios->ioproc)
{
/* Set the fill mode to NOFILL. */
if ((ret = PIOc_set_fill(*ncidp, NC_NOFILL, NULL)))
return ret;
}
/* Set the fill mode to NOFILL. */
if ((ret = PIOc_set_fill(*ncidp, NC_NOFILL, NULL)))
return ret;

return ret;
}
Expand Down
20 changes: 15 additions & 5 deletions src/clib/pio_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ int set_fill_handler(iosystem_desc_t *ios)
*/
int create_file_handler(iosystem_desc_t *ios)
{
int ncid;
int ncid = 0;
int len;
int iotype;
int mode;
int use_ext_ncid;
char ncidp_present;
int mpierr;

PLOG((1, "create_file_handler comproot = %d", ios->comproot));
Expand All @@ -191,12 +193,20 @@ int create_file_handler(iosystem_desc_t *ios)
return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__);
if ((mpierr = MPI_Bcast(&mode, 1, MPI_INT, 0, ios->intercomm)))
return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__);
PLOG((1, "create_file_handler got parameters len = %d filename = %s iotype = %d mode = %d",
len, filename, iotype, mode));
if ((mpierr = MPI_Bcast(&use_ext_ncid, 1, MPI_INT, 0, ios->intercomm)))
return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__);
if ((mpierr = MPI_Bcast(&ncidp_present, 1, MPI_CHAR, 0, ios->intercomm)))
return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__);
if (ncidp_present)
if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm)))
return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__);
PLOG((1, "create_file_handler len %d filename %s iotype %d mode %d "
"use_ext_ncid %d ncidp_present %d ncid %d", len, filename, iotype, mode,
use_ext_ncid, ncidp_present, ncid));

/* Call the create file function. */
PIOc_createfile(ios->iosysid, &ncid, &iotype, filename, mode);

PIOc_createfile_int(ios->iosysid, &ncid, &iotype, filename, mode,
use_ext_ncid);

PLOG((1, "create_file_handler succeeded!"));
return PIO_NOERR;
Expand Down
13 changes: 11 additions & 2 deletions src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,7 @@ PIOc_createfile_int(int iosysid, int *ncidp, int *iotype, const char *filename,
if (!ios->ioproc)
{
int msg = PIO_MSG_CREATE_FILE;
char ncidp_present = ncidp ? 1 : 0;
size_t len = strlen(filename);

/* Send the message to the message handler. */
Expand All @@ -2014,8 +2015,16 @@ PIOc_createfile_int(int iosysid, int *ncidp, int *iotype, const char *filename,
mpierr = MPI_Bcast(&file->iotype, 1, MPI_INT, ios->compmaster, ios->intercomm);
if (!mpierr)
mpierr = MPI_Bcast(&mode, 1, MPI_INT, ios->compmaster, ios->intercomm);
PLOG((2, "len = %d filename = %s iotype = %d mode = %d", len, filename,
file->iotype, mode));
if (!mpierr)
mpierr = MPI_Bcast(&use_ext_ncid, 1, MPI_INT, ios->compmaster, ios->intercomm);
if (!mpierr)
mpierr = MPI_Bcast(&ncidp_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm);
if (ncidp_present)
if (!mpierr)
mpierr = MPI_Bcast(ncidp, 1, MPI_INT, ios->compmaster, ios->intercomm);
PLOG((2, "len %d filename %s iotype %d mode %d use_ext_ncid %d "
"ncidp_present %d", len, filename, file->iotype, mode,
use_ext_ncid, ncidp_present));
}

/* Handle MPI errors. */
Expand Down
2 changes: 0 additions & 2 deletions src/ncint/ncintdispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ NC_Dispatch NCINT_dispatcher = {
PIO_NCINT_abort,
PIO_NCINT_close,
PIO_NCINT_set_fill,
NC_NOTNC3_inq_base_pe,
NC_NOTNC3_set_base_pe,
PIO_NCINT_inq_format,
PIO_NCINT_inq_format_extended,

Expand Down

0 comments on commit 6c24f63

Please sign in to comment.