Skip to content

Commit

Permalink
got redef function working with async
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed May 17, 2016
1 parent cf375e1 commit 7e01a84
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/clib/pio_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,26 +711,23 @@ int sync_file_handler(iosystem_desc_t *ios)
* @param ios pointer to the iosystem_desc_t.
* @return PIO_NOERR for success, error code otherwise.
*/
int enddef_file_handler(iosystem_desc_t *ios)
int change_def_file_handler(iosystem_desc_t *ios, int msg)
{
int ncid;
int mpierr;
int ret;

int my_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
LOG((1, "%d enddef_file_handler\n", my_rank));
LOG((1, "change_def_file_handler"));

/* Get the parameters for this function that the comp master
* task is broadcasting. */
if ((mpierr = MPI_Bcast(&ncid, 1, MPI_INT, 0, ios->intercomm)))
return PIO_EIO;

/* Call the sync file function. */
if ((ret = PIOc_enddef(ncid)))
return ret;
/* Call the function. */
ret = (msg == PIO_MSG_ENDDEF) ? PIOc_enddef(ncid) : PIOc_redef(ncid);

LOG((1, "%d enddef_file_handler succeeded!\n", my_rank));
LOG((1, "change_def_file_handler succeeded!"));
return PIO_NOERR;
}

Expand Down Expand Up @@ -1281,7 +1278,8 @@ int pio_msg_handler(int io_rank, int component_count, iosystem_desc_t *iosys)
sync_file_handler(my_iosys);
break;
case PIO_MSG_ENDDEF:
enddef_file_handler(my_iosys);
case PIO_MSG_REDEF:
change_def_file_handler(my_iosys, msg);
break;
case PIO_MSG_OPEN_FILE:
open_file_handler(my_iosys);
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_intercomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ main(int argc, char **argv)
if (verbose)
printf("%d test_intercomm file created ncid = %d\n", my_rank, ncid);

/* /\* End define mode, then re-enter it. *\/ */
if ((ret = PIOc_enddef(ncid)))
ERR(ret);
if (verbose)
printf("%d test_intercomm calling redef\n", my_rank);
if ((ret = PIOc_redef(ncid)))
ERR(ret);

/* Test the inq_format function. */
int myformat;
if ((ret = PIOc_inq_format(ncid, &myformat)))
Expand Down

0 comments on commit 7e01a84

Please sign in to comment.