feat/api #46
2 changed files with 13 additions and 12 deletions
|
@ -402,5 +402,5 @@
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
write_eas3(bwc_data *const file, char *const filename);
|
||||
write_eas3(eas3_data *const file, char *const filename);
|
||||
#endif
|
|
@ -1488,13 +1488,14 @@ read_eas3(char *const filename)
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
write_eas3(bwc_data *const data, char *const filename)
|
||||
write_eas3(eas3_data *const data, char *const filename)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
\*-----------------------*/
|
||||
uint64 Lfield;
|
||||
uint64 i;
|
||||
FILE *fp;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
|
@ -1506,7 +1507,7 @@ write_eas3(bwc_data *const data, char *const filename)
|
|||
! exist, discard its content. If the file cannot be creat- !
|
||||
! ed, exit the bwc command-line tool. !
|
||||
\*--------------------------------------------------------*/
|
||||
if((data->fp = fopen(filename, "wb")) == NULL)
|
||||
if((fp = fopen(filename, "wb")) == NULL)
|
||||
{
|
||||
// error opening file
|
||||
fprintf(stderr, "o##########################################################o\n"\
|
||||
|
@ -1518,7 +1519,7 @@ write_eas3(bwc_data *const data, char *const filename)
|
|||
/*--------------------------------------------------------*\
|
||||
! Write the eas3 header to the specified file. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(write_eas3_header(data))
|
||||
if(write_eas3_header(fp, data))
|
||||
{
|
||||
//error reading eas3 header
|
||||
return 1;
|
||||
|
@ -1528,10 +1529,10 @@ write_eas3(bwc_data *const data, char *const filename)
|
|||
! Calculate the size of the data field used for the endian !
|
||||
! conversion and write operations. !
|
||||
\*--------------------------------------------------------*/
|
||||
Lfield = data->info.nX * data->info.nY *
|
||||
data->info.nZ * data->info.nTS * data->info.nPar;
|
||||
Lfield = data->params.ndim1 * data->params.ndim2 *
|
||||
data->params.ndim3 * data->params.nts * data->params.npar;
|
||||
|
||||
if(data->info.parameter->precision == 4)
|
||||
if(data->params.accuracy == 1)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Convert the flow field data from big endian to endian. !
|
||||
|
@ -1544,14 +1545,14 @@ write_eas3(bwc_data *const data, char *const filename)
|
|||
/*--------------------------------------------------------*\
|
||||
! Write the flow field data to the specified eas3 file. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(fwrite(data->field.f, sizeof(float), Lfield, data->fp) != Lfield)
|
||||
if(fwrite(data->field.f, sizeof(float), Lfield, fp) != Lfield)
|
||||
{
|
||||
// invalid read
|
||||
fprintf(stderr, WRTERROR);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(data->info.parameter->precision == 8)
|
||||
else if(data->params.accuracy == 2)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Convert the flow field data from big endian to endian. !
|
||||
|
@ -1564,7 +1565,7 @@ write_eas3(bwc_data *const data, char *const filename)
|
|||
/*--------------------------------------------------------*\
|
||||
! Write the flow field data to the specified eas3 file. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(fwrite(data->field.d, sizeof(double), Lfield, data->fp) != Lfield)
|
||||
if(fwrite(data->field.d, sizeof(double), Lfield, fp) != Lfield)
|
||||
{
|
||||
// invalid read
|
||||
fprintf(stderr, WRTERROR);
|
||||
|
@ -1575,7 +1576,7 @@ write_eas3(bwc_data *const data, char *const filename)
|
|||
/*--------------------------------------------------------*\
|
||||
! Close the file pointer and return to the function caller.!
|
||||
\*--------------------------------------------------------*/
|
||||
fclose(data->fp);
|
||||
data->fp = NULL;
|
||||
fclose(fp);
|
||||
fp = NULL;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue