feat/api #46

Open
Gregor Weiss wants to merge 56 commits from feat/api into main
2 changed files with 13 additions and 12 deletions
Showing only changes of commit 62c9bc1a21 - Show all commits

View file

@ -402,5 +402,5 @@
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
uchar uchar
write_eas3(bwc_data *const file, char *const filename); write_eas3(eas3_data *const file, char *const filename);
#endif #endif

View file

@ -1488,13 +1488,14 @@ read_eas3(char *const filename)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
uchar uchar
write_eas3(bwc_data *const data, char *const filename) write_eas3(eas3_data *const data, char *const filename)
{ {
/*-----------------------*\ /*-----------------------*\
! DEFINE INT VARIABLES: ! ! DEFINE INT VARIABLES: !
\*-----------------------*/ \*-----------------------*/
uint64 Lfield; uint64 Lfield;
uint64 i; uint64 i;
FILE *fp;
/*-----------------------*\ /*-----------------------*\
! DEFINE ASSERTIONS: ! ! 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- ! ! exist, discard its content. If the file cannot be creat- !
! ed, exit the bwc command-line tool. ! ! ed, exit the bwc command-line tool. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if((data->fp = fopen(filename, "wb")) == NULL) if((fp = fopen(filename, "wb")) == NULL)
{ {
// error opening file // error opening file
fprintf(stderr, "o##########################################################o\n"\ 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. ! ! Write the eas3 header to the specified file. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if(write_eas3_header(data)) if(write_eas3_header(fp, data))
{ {
//error reading eas3 header //error reading eas3 header
return 1; 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 ! ! Calculate the size of the data field used for the endian !
! conversion and write operations. ! ! conversion and write operations. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
Lfield = data->info.nX * data->info.nY * Lfield = data->params.ndim1 * data->params.ndim2 *
data->info.nZ * data->info.nTS * data->info.nPar; 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. ! ! 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. ! ! 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 // invalid read
fprintf(stderr, WRTERROR); fprintf(stderr, WRTERROR);
return 1; 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. ! ! 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. ! ! 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 // invalid read
fprintf(stderr, WRTERROR); 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.! ! Close the file pointer and return to the function caller.!
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
fclose(data->fp); fclose(fp);
data->fp = NULL; fp = NULL;
return 0; return 0;
} }