forked from ludwig-cf/ludwig
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust colloid I/O to ensure backward compatability; use reference in…
… write calls
- Loading branch information
1 parent
b049f54
commit f3f22de
Showing
6 changed files
with
124 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
* Edinburgh Parallel Computing Centre | ||
* | ||
* Kevin Stratford ([email protected]) | ||
* (c) 2010-2014 The University of Edinburgh | ||
* (c) 2010-2020 The University of Edinburgh | ||
* | ||
*****************************************************************************/ | ||
|
||
|
@@ -33,7 +33,6 @@ int colloid_state_read_ascii(colloid_state_t * ps, FILE * fp) { | |
int ifail = 0; | ||
|
||
const char * isformat = "%24d\n"; | ||
const char * ivformat = "%24d %24d %24d\n"; | ||
const char * sformat = "%24le\n"; | ||
const char * vformat = "%24le %24le %24le\n"; | ||
|
||
|
@@ -45,9 +44,7 @@ int colloid_state_read_ascii(colloid_state_t * ps, FILE * fp) { | |
nread += fscanf(fp, isformat, &ps->nbonds); | ||
nread += fscanf(fp, isformat, &ps->nangles); | ||
nread += fscanf(fp, isformat, &ps->isfixedr); | ||
nread += fscanf(fp, ivformat, &ps->isfixedrxyz[0], &ps->isfixedrxyz[1], &ps->isfixedrxyz[2]); | ||
nread += fscanf(fp, isformat, &ps->isfixedv); | ||
nread += fscanf(fp, ivformat, &ps->isfixedvxyz[0], &ps->isfixedvxyz[1], &ps->isfixedvxyz[2]); | ||
nread += fscanf(fp, isformat, &ps->isfixedw); | ||
nread += fscanf(fp, isformat, &ps->isfixeds); | ||
nread += fscanf(fp, isformat, &ps->type); | ||
|
@@ -58,6 +55,12 @@ int colloid_state_read_ascii(colloid_state_t * ps, FILE * fp) { | |
|
||
nread += fscanf(fp, isformat, &ps->rng); | ||
|
||
for (n = 0; n < 3; n++) { | ||
nread += fscanf(fp, isformat, ps->isfixedrxyz + n); | ||
} | ||
for (n = 0; n < 3; n++) { | ||
nread += fscanf(fp, isformat, ps->isfixedvxyz + n); | ||
} | ||
for (n = 0; n < NPAD_INT; n++) { | ||
nread += fscanf(fp, isformat, &ps->intpad[n]); | ||
} | ||
|
@@ -133,66 +136,74 @@ int colloid_state_read_binary(colloid_state_t * ps, FILE * fp) { | |
* | ||
*****************************************************************************/ | ||
|
||
int colloid_state_write_ascii(colloid_state_t s, FILE * fp) { | ||
int colloid_state_write_ascii(const colloid_state_t * s, FILE * fp) { | ||
|
||
int n; | ||
int nwrite = 0; | ||
int ifail = 0; | ||
|
||
const char * isformat = "%24d\n"; | ||
const char * ivformat = "%24d %24d %24d\n"; | ||
const char * sformat = "%24.15e\n"; | ||
const char * vformat = "%24.15e %24.15e %24.15e\n"; | ||
|
||
assert(s); | ||
assert(fp); | ||
|
||
nwrite += fprintf(fp, isformat, s.index); | ||
nwrite += fprintf(fp, isformat, s.rebuild); | ||
nwrite += fprintf(fp, isformat, s.nbonds); | ||
nwrite += fprintf(fp, isformat, s.nangles); | ||
nwrite += fprintf(fp, isformat, s.isfixedr); | ||
nwrite += fprintf(fp, ivformat, s.isfixedrxyz[0], s.isfixedrxyz[1], s.isfixedrxyz[2]); | ||
nwrite += fprintf(fp, isformat, s.isfixedv); | ||
nwrite += fprintf(fp, ivformat, s.isfixedvxyz[0], s.isfixedvxyz[1], s.isfixedvxyz[2]); | ||
nwrite += fprintf(fp, isformat, s.isfixedw); | ||
nwrite += fprintf(fp, isformat, s.isfixeds); | ||
nwrite += fprintf(fp, isformat, s.type); | ||
nwrite += fprintf(fp, isformat, s->index); | ||
nwrite += fprintf(fp, isformat, s->rebuild); | ||
nwrite += fprintf(fp, isformat, s->nbonds); | ||
nwrite += fprintf(fp, isformat, s->nangles); | ||
nwrite += fprintf(fp, isformat, s->isfixedr); | ||
nwrite += fprintf(fp, isformat, s->isfixedv); | ||
nwrite += fprintf(fp, isformat, s->isfixedw); | ||
nwrite += fprintf(fp, isformat, s->isfixeds); | ||
nwrite += fprintf(fp, isformat, s->type); | ||
|
||
for (n = 0; n < NBOND_MAX; n++) { | ||
nwrite += fprintf(fp, isformat, s.bond[n]); | ||
nwrite += fprintf(fp, isformat, s->bond[n]); | ||
} | ||
|
||
nwrite += fprintf(fp, isformat, s.rng); | ||
nwrite += fprintf(fp, isformat, s->rng); | ||
|
||
/* isfixedrxyz and isfixedvxyz are writen as 3 x scalars as they | ||
* have replaced padding */ | ||
|
||
for (n = 0; n < 3; n++) { | ||
nwrite += fprintf(fp, isformat, s->isfixedrxyz[n]); | ||
} | ||
for (n = 0; n < 3; n++) { | ||
nwrite += fprintf(fp, isformat, s->isfixedvxyz[n]); | ||
} | ||
|
||
for (n = 0; n < NPAD_INT; n++) { | ||
nwrite += fprintf(fp, isformat, s.intpad[n]); | ||
nwrite += fprintf(fp, isformat, s->intpad[n]); | ||
} | ||
|
||
nwrite += fprintf(fp, sformat, s.a0); | ||
nwrite += fprintf(fp, sformat, s.ah); | ||
nwrite += fprintf(fp, vformat, s.r[0], s.r[1], s.r[2]); | ||
nwrite += fprintf(fp, vformat, s.v[0], s.v[1], s.v[2]); | ||
nwrite += fprintf(fp, vformat, s.w[0], s.w[1], s.w[2]); | ||
nwrite += fprintf(fp, vformat, s.s[0], s.s[1], s.s[2]); | ||
nwrite += fprintf(fp, vformat, s.m[0], s.m[1], s.m[2]); | ||
nwrite += fprintf(fp, sformat, s.b1); | ||
nwrite += fprintf(fp, sformat, s.b2); | ||
nwrite += fprintf(fp, sformat, s.c); | ||
nwrite += fprintf(fp, sformat, s.h); | ||
nwrite += fprintf(fp, vformat, s.dr[0], s.dr[1], s.dr[2]); | ||
nwrite += fprintf(fp, sformat, s.deltaphi); | ||
|
||
nwrite += fprintf(fp, sformat, s.q0); | ||
nwrite += fprintf(fp, sformat, s.q1); | ||
nwrite += fprintf(fp, sformat, s.epsilon); | ||
|
||
nwrite += fprintf(fp, sformat, s.deltaq0); | ||
nwrite += fprintf(fp, sformat, s.deltaq1); | ||
nwrite += fprintf(fp, sformat, s.sa); | ||
nwrite += fprintf(fp, sformat, s.saf); | ||
nwrite += fprintf(fp, sformat, s->a0); | ||
nwrite += fprintf(fp, sformat, s->ah); | ||
nwrite += fprintf(fp, vformat, s->r[0], s->r[1], s->r[2]); | ||
nwrite += fprintf(fp, vformat, s->v[0], s->v[1], s->v[2]); | ||
nwrite += fprintf(fp, vformat, s->w[0], s->w[1], s->w[2]); | ||
nwrite += fprintf(fp, vformat, s->s[0], s->s[1], s->s[2]); | ||
nwrite += fprintf(fp, vformat, s->m[0], s->m[1], s->m[2]); | ||
nwrite += fprintf(fp, sformat, s->b1); | ||
nwrite += fprintf(fp, sformat, s->b2); | ||
nwrite += fprintf(fp, sformat, s->c); | ||
nwrite += fprintf(fp, sformat, s->h); | ||
nwrite += fprintf(fp, vformat, s->dr[0], s->dr[1], s->dr[2]); | ||
nwrite += fprintf(fp, sformat, s->deltaphi); | ||
|
||
nwrite += fprintf(fp, sformat, s->q0); | ||
nwrite += fprintf(fp, sformat, s->q1); | ||
nwrite += fprintf(fp, sformat, s->epsilon); | ||
|
||
nwrite += fprintf(fp, sformat, s->deltaq0); | ||
nwrite += fprintf(fp, sformat, s->deltaq1); | ||
nwrite += fprintf(fp, sformat, s->sa); | ||
nwrite += fprintf(fp, sformat, s->saf); | ||
|
||
for (n = 0; n < NPAD_DBL; n++) { | ||
nwrite += fprintf(fp, sformat, s.dpad[n]); | ||
nwrite += fprintf(fp, sformat, s->dpad[n]); | ||
} | ||
|
||
/* ... should be NTOT_VAR items of format + 1 characters */ | ||
|
@@ -213,13 +224,14 @@ int colloid_state_write_ascii(colloid_state_t s, FILE * fp) { | |
* | ||
*****************************************************************************/ | ||
|
||
int colloid_state_write_binary(colloid_state_t s, FILE * fp) { | ||
int colloid_state_write_binary(const colloid_state_t * s, FILE * fp) { | ||
|
||
int nwrite; | ||
|
||
assert(s); | ||
assert(fp); | ||
|
||
nwrite = fwrite(&s, sizeof(colloid_state_t), 1, fp); | ||
nwrite = fwrite(s, sizeof(colloid_state_t), 1, fp); | ||
|
||
return (1 - nwrite); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* Edinburgh Soft Matter and Statistical Physics Group and | ||
* Edinburgh Parallel Computing Centre | ||
* | ||
* (c) 2010-2018 The University of Edinburgh | ||
* (c) 2010-2020 The University of Edinburgh | ||
* | ||
* Contributing authors: | ||
* Kevin Stratford ([email protected]) | ||
|
@@ -391,7 +391,7 @@ int colloid_io_write_buffer_ascii(FILE * fp, int nc, colloid_state_t * buf) { | |
assert(buf); | ||
|
||
for (n = 0; n < nc; n++) { | ||
ifail += colloid_state_write_ascii(buf[n], fp); | ||
ifail += colloid_state_write_ascii(buf + n, fp); | ||
} | ||
|
||
return ifail; | ||
|
@@ -556,7 +556,7 @@ static int colloid_io_write_list_ascii(colloid_io_t * cio, | |
colloids_info_cell_list_head(cio->info, ic, jc, kc, &pc); | ||
|
||
while (pc) { | ||
ifail += colloid_state_write_ascii(pc->s, fp); | ||
ifail += colloid_state_write_ascii(&pc->s, fp); | ||
pc = pc->next; | ||
} | ||
|
||
|
@@ -614,7 +614,7 @@ static int colloid_io_write_list_binary(colloid_io_t * cio, | |
colloids_info_cell_list_head(cio->info, ic, jc, kc, &pc); | ||
|
||
while (pc) { | ||
colloid_state_write_binary(pc->s, fp); | ||
colloid_state_write_binary(&pc->s, fp); | ||
pc = pc->next; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* Edinburgh Soft Matter and Statistical Physics Group and | ||
* Edinburgh Parallel Computing Centre | ||
* | ||
* (c) 2010-2018 The University of Edinburgh | ||
* (c) 2010-2020 The University of Edinburgh | ||
* | ||
* Contributing authors: | ||
* Kevin Stratford ([email protected]) | ||
|
@@ -1059,7 +1059,7 @@ __host__ int colloids_info_position_update(colloids_info_t * cinfo) { | |
if (ifail == 1) { | ||
pe_verbose(cinfo->pe, "Colloid velocity exceeded max %14.7e\n", | ||
cinfo->drmax); | ||
colloid_state_write_ascii(coll->s, stdout); | ||
colloid_state_write_ascii(&coll->s, stdout); | ||
pe_fatal(cinfo->pe, "Stopping\n"); | ||
} | ||
} | ||
|
Oops, something went wrong.