Skip to content

Commit

Permalink
fixed indents
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Feb 20, 2019
1 parent 91c3ae8 commit 2c5acc9
Showing 1 changed file with 106 additions and 108 deletions.
214 changes: 106 additions & 108 deletions tests/cunit/test_perf1.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,141 +171,139 @@ int test_perf1(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank,
* PIOc_write_darray_multi() function. */
for (int test_multi = 0; test_multi < NUM_TEST_CASES_WRT_MULTI; test_multi++)
{
/* Create the filename. */
sprintf(filename, "data_%s_iotype_%d_pio_type_%d_test_multi_%d.nc",
TEST_NAME, flavor[fmt], pio_type, test_multi);

/* Select the fill value and data. */
switch (pio_type)
{
/* Create the filename. */
sprintf(filename, "data_%s_iotype_%d_pio_type_%d_test_multi_%d.nc",
TEST_NAME, flavor[fmt], pio_type, test_multi);
case PIO_INT:
test_data = test_data_int;
test_data_in = test_data_int_in;
break;
case PIO_FLOAT:
test_data = test_data_float;
test_data_in = test_data_float_in;
break;
case PIO_DOUBLE:
test_data = test_data_double;
test_data_in = test_data_double_in;
break;
default:
ERR(ERR_WRONG);
}

/* Select the fill value and data. */
switch (pio_type)
{
case PIO_INT:
test_data = test_data_int;
test_data_in = test_data_int_in;
break;
case PIO_FLOAT:
test_data = test_data_float;
test_data_in = test_data_float_in;
break;
case PIO_DOUBLE:
test_data = test_data_double;
test_data_in = test_data_double_in;
break;
default:
ERR(ERR_WRONG);
}
/* Create the netCDF output file. */
{
if ((ret = PIOc_createfile(iosysid, &ncid, &flavor[fmt], filename, PIO_CLOBBER)))
ERR(ret);

/* Define netCDF dimensions. */
for (int d = 0; d < NDIM4; d++)
if ((ret = PIOc_def_dim(ncid, dim_name[d], (PIO_Offset)dim_len[d], &dimids[d])))
ERR(ret);

/* Create the netCDF output file. */
/* Define the variables. */
for (int v = 0; v < NUM_VARS; v++)
{
if ((ret = PIOc_createfile(iosysid, &ncid, &flavor[fmt], filename, PIO_CLOBBER)))
char var_name[NC_MAX_NAME + 1];
sprintf(var_name, "var_%d", v);
if ((ret = PIOc_def_var(ncid, var_name, pio_type, NDIM4, dimids, &varid[v])))
ERR(ret);
}

/* Define netCDF dimensions. */
for (int d = 0; d < NDIM4; d++)
if ((ret = PIOc_def_dim(ncid, dim_name[d], (PIO_Offset)dim_len[d], &dimids[d])))
ERR(ret);
/* End define mode. */
if ((ret = PIOc_enddef(ncid)))
ERR(ret);
}

/* Define the variables. */
for (int v = 0; v < NUM_VARS; v++)
{
char var_name[NC_MAX_NAME + 1];
sprintf(var_name, "var_%d", v);
if ((ret = PIOc_def_var(ncid, var_name, pio_type, NDIM4, dimids, &varid[v])))
ERR(ret);
}
/* Start the clock. */
gettimeofday(&starttime, NULL);

/* End define mode. */
if ((ret = PIOc_enddef(ncid)))
ERR(ret);
}
for (int t = 0; t < NUM_TIMESTEPS; t++)
{

/* Start the clock. */
gettimeofday(&starttime, NULL);
/* Do some fake computation. */
if ((ret = do_some_computation(100000)))
ERR(ret);

for (int t = 0; t < NUM_TIMESTEPS; t++)
/* Write a timestep of data in each var. */
for (int v = 0; v < NUM_VARS; v++)
{

/* Do some fake computation. */
if ((ret = do_some_computation(100000)))
/* Set the value of the record dimension. */
if ((ret = PIOc_setframe(ncid, varid[v], t)))
ERR(ret);

/* Write a timestep of data in each var. */
for (int v = 0; v < NUM_VARS; v++)
int frame = 0;
int flushtodisk = test_multi - 1;
if (!test_multi)
{
/* Set the value of the record dimension. */
if ((ret = PIOc_setframe(ncid, varid[v], t)))
/* Write the data. */
if ((ret = PIOc_write_darray(ncid, varid[v], ioid, arraylen, test_data, NULL)))
ERR(ret);
}
else
{
/* Write the data with the _multi function. */
if ((ret = PIOc_write_darray_multi(ncid, varid, ioid, 1, arraylen, test_data, &frame,
NULL, flushtodisk)))
ERR(ret);

int frame = 0;
int flushtodisk = test_multi - 1;
if (!test_multi)
{
/* Write the data. */
if ((ret = PIOc_write_darray(ncid, varid[v], ioid, arraylen, test_data, NULL)))
ERR(ret);
}
else
{
/* Write the data with the _multi function. */
if ((ret = PIOc_write_darray_multi(ncid, varid, ioid, 1, arraylen, test_data, &frame,
NULL, flushtodisk)))
ERR(ret);
}
}
}
}

/* Close the netCDF file. */
if ((ret = PIOc_closefile(ncid)))
ERR(ret);
/* Close the netCDF file. */
if ((ret = PIOc_closefile(ncid)))
ERR(ret);

/* Stop the clock. */
gettimeofday(&endtime, NULL);
/* Stop the clock. */
gettimeofday(&endtime, NULL);

/* Compute the time delta */
startt = (1000000 * starttime.tv_sec) + starttime.tv_usec;
endt = (1000000 * endtime.tv_sec) + endtime.tv_usec;
delta = endt - startt;
printf("%lld\t%s\n", delta, filename);
/* Compute the time delta */
startt = (1000000 * starttime.tv_sec) + starttime.tv_usec;
endt = (1000000 * endtime.tv_sec) + endtime.tv_usec;
delta = endt - startt;
printf("%lld\t%s\n", delta, filename);

/* Reopen the file. */
if ((ret = PIOc_openfile(iosysid, &ncid2, &flavor[fmt], filename, PIO_NOWRITE)))
ERR(ret);
/* Reopen the file. */
if ((ret = PIOc_openfile(iosysid, &ncid2, &flavor[fmt], filename, PIO_NOWRITE)))
ERR(ret);

/* Set the record number. */
if ((ret = PIOc_setframe(ncid2, varid[0], 0)))
ERR(ret);
/* Set the record number. */
if ((ret = PIOc_setframe(ncid2, varid[0], 0)))
ERR(ret);

/* Read the data. */
/* PIOc_set_log_level(3); */
if ((ret = PIOc_read_darray(ncid2, varid[0], ioid, arraylen, test_data_in)))
ERR(ret);
/* Read the data. */
/* PIOc_set_log_level(3); */
if ((ret = PIOc_read_darray(ncid2, varid[0], ioid, arraylen, test_data_in)))
ERR(ret);

/* Check the results. */
for (int f = 0; f < arraylen; f++)
/* Check the results. */
for (int f = 0; f < arraylen; f++)
{
switch (pio_type)
{
switch (pio_type)
{
case PIO_INT:
if (test_data_int_in[f] != test_data_int[f])
return ERR_WRONG;
break;
case PIO_FLOAT:
if (test_data_float_in[f] != test_data_float[f])
return ERR_WRONG;
break;
case PIO_DOUBLE:
if (test_data_double_in[f] != test_data_double[f])
return ERR_WRONG;
break;
default:
ERR(ERR_WRONG);
}
case PIO_INT:
if (test_data_int_in[f] != test_data_int[f])
return ERR_WRONG;
break;
case PIO_FLOAT:
if (test_data_float_in[f] != test_data_float[f])
return ERR_WRONG;
break;
case PIO_DOUBLE:
if (test_data_double_in[f] != test_data_double[f])
return ERR_WRONG;
break;
default:
ERR(ERR_WRONG);
}

/* Close the netCDF file. */
if ((ret = PIOc_closefile(ncid2)))
ERR(ret);
}

/* Close the netCDF file. */
if ((ret = PIOc_closefile(ncid2)))
ERR(ret);
} /* next test multi */
} /* next iotype */

Expand Down

0 comments on commit 2c5acc9

Please sign in to comment.