diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-02 22:06:10 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-02 22:06:10 -0400 |
commit | a1c120ba49f2727dd5b42ad53444439b87232e25 (patch) | |
tree | 90bc250d726590607509d9ba652d530b3476e99f | |
parent | c2d9527e8e4f690a09bb54be4254b4ddded1927c (diff) | |
download | c++-a1c120ba49f2727dd5b42ad53444439b87232e25.tar.gz c++-a1c120ba49f2727dd5b42ad53444439b87232e25.tar.bz2 c++-a1c120ba49f2727dd5b42ad53444439b87232e25.zip |
changed method for saving metadata from filenames to a dedicated metadata file
-rw-r--r-- | src/wolff_finite.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/wolff_finite.c b/src/wolff_finite.c index 05fa154..5f56015 100644 --- a/src/wolff_finite.c +++ b/src/wolff_finite.c @@ -91,21 +91,37 @@ int main(int argc, char *argv[]) { unsigned long timestamp = (unsigned long)time(NULL); - char *filename_M = (char *)malloc(256 * sizeof(char)); - char *filename_B = (char *)malloc(256 * sizeof(char)); - char *filename_S = (char *)malloc(256 * sizeof(char)); + FILE *outfile_info = fopen("wolff_metadata.txt", "a"); + + fprintf(outfile_info, "<| \"ID\" -> %lu, \"MODEL\" -> \"%s\", \"q\" -> %" PRIq ", \"D\" -> %" PRID ", \"L\" -> %" PRIL ", \"NV\" -> %" PRIv ", \"NE\" -> %" PRIv ", \"NB\" -> %" PRIq ", \"T\" -> %.15f, \"J\" -> {", timestamp, finite_model_t_strings[model], s->q, D, L, s->nv, s->ne, s->n_bond_types, T); + + for (q_t i = 0; i < s->n_bond_types; i++) { + fprintf(outfile_info, "%.15f", s->J[i]); + if (i < s->n_bond_types - 1) { + fprintf(outfile_info, ", "); + } + } + + fprintf(outfile_info, "}, \"H\" -> {"); - sprintf(filename_M, "wolff_%s_%" PRIq "_%" PRID "_%" PRIL "_%.8f", finite_model_t_strings[model], q, D, L, T); for (q_t i = 0; i < s->q; i++) { - sprintf(filename_M + strlen(filename_M), "_%.8f", s->H[i]); + fprintf(outfile_info, "%.15f", s->H[i]); + if (i < s->q - 1) { + fprintf(outfile_info, ", "); + } } - strcpy(filename_B, filename_M); - strcpy(filename_S, filename_M); + fprintf(outfile_info, "} |>\n"); + + fclose(outfile_info); + + char *filename_M = (char *)malloc(255 * sizeof(char)); + char *filename_B = (char *)malloc(255 * sizeof(char)); + char *filename_S = (char *)malloc(255 * sizeof(char)); - sprintf(filename_M + strlen(filename_M), "_%lu_M.dat", timestamp); - sprintf(filename_B + strlen(filename_B), "_%lu_B.dat", timestamp); - sprintf(filename_S + strlen(filename_S), "_%lu_S.dat", timestamp); + sprintf(filename_M, "wolff_%lu_M.dat", timestamp); + sprintf(filename_B, "wolff_%lu_B.dat", timestamp); + sprintf(filename_S, "wolff_%lu_S.dat", timestamp); FILE *outfile_M = fopen(filename_M, "wb"); FILE *outfile_B = fopen(filename_B, "wb"); |