Skip to content

Commit

Permalink
Merge branch 'bugfix-fullwrite'
Browse files Browse the repository at this point in the history
Merging fullwrite
  • Loading branch information
leobago committed Jan 11, 2017
2 parents 46c807e + f813a86 commit 3302856
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* @brief Checkpointing functions for the FTI library.
*/

#define _POSIX_C_SOURCE 200809L
#include <string.h>

#include "interface.h"

/*-------------------------------------------------------------------------*/
Expand Down Expand Up @@ -106,12 +109,21 @@ int FTI_WriteCkpt(FTIT_configuration* FTI_Conf, FTIT_execution* FTI_Exec,
return FTI_NSCS;
}
for (i = 0; i < FTI_Exec->nbVar; i++) {
if (fwrite(FTI_Data[i].ptr, FTI_Data[i].eleSize, FTI_Data[i].count, fd) != FTI_Data[i].count) {
sprintf(str, "Dataset #%d could not be written.", FTI_Data[i].id);
clearerr(fd);
size_t written = 0;
int fwrite_errno;
while ( written < FTI_Data[i].count && !ferror(fd) ) {
errno = 0;
written += fwrite(((char*)FTI_Data[i].ptr)+(FTI_Data[i].eleSize*written), FTI_Data[i].eleSize, FTI_Data[i].count-written, fd);
fwrite_errno = errno;
}
if ( ferror(fd) ) {
char error_msg[FTI_BUFS];
error_msg[0] = 0;
strerror_r(fwrite_errno, error_msg, FTI_BUFS);
sprintf(str, "Dataset #%d could not be written: %s.", FTI_Data[i].id, error_msg);
FTI_Print(str, FTI_EROR);

fclose(fd);

return FTI_NSCS;
}
}
Expand Down

0 comments on commit 3302856

Please sign in to comment.