diff --git a/mathmech/mm/include/mathmech/stat_print.h b/mathmech/mm/include/mathmech/stat_print.h index 4254b9d..864110f 100644 --- a/mathmech/mm/include/mathmech/stat_print.h +++ b/mathmech/mm/include/mathmech/stat_print.h @@ -18,9 +18,8 @@ int printing_agl (const char *input, const char *output, const int *connect, /** * @brief function that prints agglomerates to output file * @code - * printing_agl (input_file, output_file, number_of_molecules, true_label_molecules, - * num_of_molecules_in_agglomerates, agglomerates, statistic, max_depth, - * type_of_agglomerate); + * printing_agl (input, output, connect, _system_info, true_label_mol, num_mol_agl, + * agl, stat, max_depth, type_agl); * @endcode * * @param input input file name diff --git a/mathmech/mm/include/mathmech/stat_select.h b/mathmech/mm/include/mathmech/stat_select.h index f6f46ac..aca7637 100644 --- a/mathmech/mm/include/mathmech/stat_select.h +++ b/mathmech/mm/include/mathmech/stat_select.h @@ -16,7 +16,7 @@ int create_matrix (const system_info _system_info, const atom_info *_atom_info, /** * @brief function that creates connectivity matrix * @code - * int create_matrix (_system_info, _atom_info, num_of_inter, crit, connect); + * create_matrix (_system_info, _atom_info, num_of_inter, crit, connect); * @endcode * * @param _system_info system information structure diff --git a/mathmech/mm/include/mathmech/summary_stat.h b/mathmech/mm/include/mathmech/summary_stat.h index ed120f7..e266b74 100644 --- a/mathmech/mm/include/mathmech/summary_stat.h +++ b/mathmech/mm/include/mathmech/summary_stat.h @@ -5,11 +5,29 @@ #ifndef SUMMARY_STAT_H #define SUMMARY_STAT_H +#include + + /** * @fn summary_statistic */ +int summary_statistic (const char *filename, const system_info _system_info, + const int max_depth, const int *type_agl, const int *stat_all); +/** + * @brief function that prints summary statistic + * @code + * summary_statistic (filename, _system_info, max_depth, type_agl, stat_all); + * @endcode + * + * @param filename output file name + * @param _system_info system information structure + * @param num_mol number of molecules + * @param max_depth maximum depth for check cycles in graph analyze + * @param type_agl massive of number of agglomerate types + * @param stat_all massive of summary statistic + * + * @return 0 - exit without errors + */ -int summary_statistic (const char *, const int, const int, const int, const int *, - const int *); -#endif /* SUMMARY_STAT_H */ \ No newline at end of file +#endif /* SUMMARY_STAT_H */ diff --git a/mathmech/mm/src/summary_stat.c b/mathmech/mm/src/summary_stat.c index 3f6575e..96e4f35 100644 --- a/mathmech/mm/src/summary_stat.c +++ b/mathmech/mm/src/summary_stat.c @@ -4,28 +4,15 @@ #include +#include +#include + /** * @fn summary_statistic */ -int summary_statistic (const char *filename, const int step, const int num_mol, +int summary_statistic (const char *filename, const system_info _system_info, const int max_depth, const int *type_agl, const int *stat_all) -/** - * @brief function that prints summary statistic - * @code - * summary_statistic (filename, number_of_step, number_of_molecules, max_depth, - * type_of_agglomerate, summary_statistic); - * @endcode - * - * @param filename output file name - * @param step number of steps - * @param num_mol number of molecules - * @param max_depth maximum depth for check cycles in graph analyze - * @param type_agl massive of number of agglomerate types - * @param stat_all massive of summary statistic - * - * @return 0 - exit without errors - */ { float conc, p, pn, type[2], x, y; int i, index; @@ -38,7 +25,7 @@ int summary_statistic (const char *filename, const int step, const int num_mol, */ index = 0; - for (i=0; i +#include "add_main.h" #include #include +#include /** * @fn error_checking */ -int error_checking (const float *cell, const int from, const char *input, - const int max_depth, const int num_of_inter, const char *output, - const int to, const int type_inter) -/** - * @brief function that checks errors in input variables - * @code - * error_checking (cell, from, input, max_depth, num_of_inter, output, to, - * type_inter); - * @endcode - * - * @param cell massive of cell size - * @param from first trajectory step - * @param input mask of trajectory files - * @param max_depth max depth for check cycles in graph analyze - * @param num_of_inter number of different interactions - * @param output output file name - * @param to last trajectory step - * @param type_inter number of atoms for interactions - * - * @return 11 - error in 'type_inter' - * @return 12 - error in 'cell' - * @return 13 - error in 'to' or 'from' - * @return 14 - error in 'num_of_inter' - * @return 15 - error in 'input' - * @return 16 - error in 'output' - * @return 19 - error in 'max_depth' - * @return 0 - exit without errors - */ +int error_checking (const system_info _system_info, const char *input, const int max_depth, + const int num_of_inter, const char *output, const int type_inter) { if ((type_inter == 0) || (type_inter > 4)) return 11; - if ((cell[0] == 0.0) || (cell[1] == 0.0) || (cell[2] == 0.0)) + if ((_system_info.cell[0] == 0.0) || (_system_info.cell[1] == 0.0) || (_system_info.cell[2] == 0.0)) return 12; - if ((to == -1) || (from == -1)) + if ((_system_info.to == -1) || (_system_info.from == -1)) return 13; if (num_of_inter == 0) return 14; @@ -63,31 +39,9 @@ int error_checking (const float *cell, const int from, const char *input, * @fn printing_head */ int printing_head (const char *output, const int log, const int quiet, - const char *input, const int from, const int to, const float *cell, + const char *input, const system_info _system_info, const int type_inter, const int *label_atom, const int num_of_inter, const float *crit, const int max_depth) -/** - * @brief function that prints header in output file - * @code - * printing_head (output, log, quiet, input, from, to, cell, type_inter, label_atom, - * num_of_inter, crit, max_depth); - * @endcode - * - * @param output output file nams - * @param log status of log-mode - * @param quiet status of quiet-mode - * @param input mask of trajectory files - * @param from first trajectory step - * @param to last trajectory step - * @param cell massive of cell size - * @param type_inter number of atoms for interactions - * @param label_atom massive of atom types for interactions - * @param num_of_inter number of different interactions - * @param crit massive of criteria - * @param max_depth maximum depth for check cycles in graph analyze - * - * @return 0 - exit without errors - */ { int i, j; FILE *f_out; @@ -97,8 +51,9 @@ int printing_head (const char *output, const int log, const int quiet, fprintf (f_out, "CONFIGURATION\n"); fprintf (f_out, "LOG=%i\nQUIET=%i\n", log, quiet); - fprintf (f_out, "MASK=%s\nFIRST=%i\nLAST=%i\n", input, from, to); - fprintf (f_out, "CELL=%.4f,%.4f,%.4f\n", cell[0], cell[1], cell[2]); + fprintf (f_out, "MASK=%s\nFIRST=%i\nLAST=%i\n", input, _system_info.from, _system_info.to); + fprintf (f_out, "CELL=%.4f,%.4f,%.4f\n", _system_info.cell[0], _system_info.cell[1], + _system_info.cell[2]); fprintf (f_out, "ATOMS=%i", label_atom[0]); for (i=1; i + + /** * @fn error_checking */ +int error_checking (const system_info _system_info, const char *input, const int max_depth, + const int num_of_inter, const char *output, const int type_inter); +/** + * @brief function that checks errors in input variables + * @code + * error_checking (_system_info, input, max_depth, num_of_inter, output, type_inter); + * @endcode + * + * @param _system_info system information structure + * @param input mask of trajectory files + * @param max_depth max depth for check cycles in graph analyze + * @param num_of_inter number of different interactions + * @param output output file name + * @param type_inter number of atoms for interactions + * + * @return 11 - error in 'type_inter' + * @return 12 - error in 'cell' + * @return 13 - error in 'to' or 'from' + * @return 14 - error in 'num_of_inter' + * @return 15 - error in 'input' + * @return 16 - error in 'output' + * @return 19 - error in 'max_depth' + * @return 0 - exit without errors + */ + + /** * @fn printing_head */ +int printing_head (const char *output, const int log, const int quiet, + const char *input, const system_info _system_info, + const int type_inter, const int *label_atom, + const int num_of_inter, const float *crit, const int max_depth); +/** + * @brief function that prints header in output file + * @code + * printing_head (output, log, quiet, input, _system_info, type_inter, label_atom, + * num_of_inter, crit, max_depth); + * @endcode + * + * @param output output file nams + * @param log status of log-mode + * @param quiet status of quiet-mode + * @param input mask of trajectory files + * @param _system_info system information structure + * @param type_inter number of atoms for interactions + * @param label_atom massive of atom types for interactions + * @param num_of_inter number of different interactions + * @param crit massive of criteria + * @param max_depth maximum depth for check cycles in graph analyze + * + * @return 0 - exit without errors + */ + + /** * @fn print_message */ +int print_message (const int quiet, FILE *std_output, const int log, FILE *f_log, + const int mode, const char *str); +/** + * @brief function that prints message in log and stdout + * @code + * print_message (quiet, stdout, log, f_log, 0, str); + * @endcode + * + * @param quiet status of quiet-mode + * @param std_output stdout + * @param log status of log-mode + * @param f_log log file + * @param mode number of message in "messages.c" + * @param str additional text in message + * + * @return 0 - exit without errors + */ + + /** * @fn set_defaults */ +int set_defaults (system_info *_system_info, char *input, int *log, int *max_depth, + int *num_of_inter, char *output, int *type_inter, int *quiet); +/** + * @brief function that sets default values of variables + * @code + * set_defaults (&_system_info, input, &log, &max_depth, &num_of_inter, output, + * &type_inter, &quiet); + * @endcode + * + * @param _system_info system information structure + * @param input mask of trajectory files + * @param log status of log-mode + * @param max_depth maximum depth for check cycles in graph analyze + * @param num_of_inter number of different interactions + * @param output output file name + * @param type_inter number of atoms for interactions + * @param quiet status of quiet-mode + * + * @return 0 - exit without errors + */ -int error_checking (const float *, const int, const char *, const int, const int, - const char *, const int, const int); -int printing_head (const char *, const int, const int, const char *, const int, - const int, const float *, const int, const int *, const int, - const float *, const int); -int print_message (const int, FILE *, const int, FILE *, const int, const char *); -int set_defaults (float *, int *, char *, int *, int *, int *, char *, int *, - int *, int *); -#endif /* ADD_MAIN_H */ \ No newline at end of file +#endif /* ADD_MAIN_H */ diff --git a/mathmech/statgen/src/main.c b/mathmech/statgen/src/main.c index a74ee00..bea5554 100644 --- a/mathmech/statgen/src/main.c +++ b/mathmech/statgen/src/main.c @@ -16,6 +16,7 @@ #include #include #include +#include /** @@ -36,42 +37,37 @@ int main (int argc, char *argv[]) FILE *f_inp, *f_log; char input[256], logfile[256], output[256]; - float cell[3], *coords, *crit; - int *agl, *connect, from, *label_atom, *label_mol, log, max_depth, num_atoms, - num_mol, *num_mol_agl, num_of_inter, *stat, *stat_all, step, to, - *true_label_mol, *type_agl, *type_atoms, type_inter, quiet; + float *crit; + int *agl, *connect, *label_atom, log, max_depth, *num_mol_agl, num_of_inter, *stat, + *stat_all, *true_label_mol, *type_agl, type_inter, quiet; + atom_info *_atom_info; + system_info _system_info; /* input mask of trajectory files * logfile log file name * output output file name * - * cell massive of cell size - * coords massive of coordinates * crit massive of criteria * * agl massive of agglomerates * connect connectivity graph for all molecules - * from first trajectory step * label_atom massive of atom types for interactions - * label_mol massive of numbers of molecule for atoms * log status of log-mode * max_depth maximum depth for check cycles in graph analyze - * num_atoms number of atoms - * num_mol number of molecules * num_mol_agl massive of number of molecules in agglomerates * num_of_inter number of different interactions * stat massive of statistic * stat_all massive of summary statistic - * step $(to - from + 1) - * to last trajectory step * true_label_mol massive of true numbers of molecule for atoms * type_agl massive of number of agglomerate types - * type_atoms massive of atom types * type_inter number of atoms for interactions * quiet status of quiet-mode + * + * _atom_info atom information structure + * _system_info system information structure */ - set_defaults (cell, &from, input, &log, &max_depth, &num_of_inter, output, &to, + set_defaults (&_system_info, input, &log, &max_depth, &num_of_inter, output, &type_inter, &quiet); // reading number of interactions @@ -125,20 +121,19 @@ int main (int argc, char *argv[]) else if ((argv[i][0] == '-') && (argv[i][1] == 's') && (argv[i][2] == '\0')) // steps { - sscanf (argv[i+1], "%i,%i", &from, &to); - if (from > to) + sscanf (argv[i+1], "%i,%i", &_system_info.from, &_system_info.to); + if (_system_info.from > _system_info.to) { - to += from; - from = to - from; - to -= from; + _system_info.to += _system_info.from; + _system_info.from = _system_info.to - _system_info.from; + _system_info.to -= _system_info.from; } - step = to - from + 1; i++; } else if ((argv[i][0] == '-') && (argv[i][1] == 'c') && (argv[i][2] == '\0')) // cell size { - sscanf (argv[i+1], "%f,%f,%f", &cell[0], &cell[1], &cell[2]); + sscanf (argv[i+1], "%f,%f,%f", &_system_info.cell[0], &_system_info.cell[1], &_system_info.cell[2]); i++; } else if ((argv[i][0] == '-') && (argv[i][1] == 'a') && (argv[i][2] == '\0')) @@ -227,7 +222,7 @@ int main (int argc, char *argv[]) print_message (quiet, stdout, log, f_log, 1, argv[0]); // error checking - error = error_checking (cell, from, input, max_depth, num_of_inter, output, to, + error = error_checking (_system_info, input, max_depth, num_of_inter, output, type_inter); if (error != 0) { @@ -239,7 +234,7 @@ int main (int argc, char *argv[]) // processing // initial variables - sprintf (filename, "%s.%03i", input, from); + sprintf (filename, "%s.%03i", input, _system_info.from); print_message (quiet, stdout, log, f_log, 3, filename); f_inp = fopen (filename, "r"); if (f_inp == NULL) @@ -247,13 +242,11 @@ int main (int argc, char *argv[]) print_message (quiet, stderr, log, f_log, 18, filename); return 2; } - fscanf (f_inp, "%i", &num_atoms); + fscanf (f_inp, "%i", &_system_info.num_atoms); fclose (f_inp); - coords = (float *) malloc (3 * 8 * num_atoms * sizeof (float)); - label_mol = (int *) malloc (8 * num_atoms * sizeof (int)); - true_label_mol = (int *) malloc (num_atoms * sizeof (int)); + _atom_info = (atom_info *) malloc (8 * _system_info.num_atoms * sizeof (atom_info)); + true_label_mol = (int *) malloc (_system_info.num_atoms * sizeof (int)); type_agl = (int *) malloc ((max_depth + 2) * sizeof (int)); - type_atoms = (int *) malloc (8 * num_atoms * sizeof (int)); // temporary declaration of variables agl = (int *) malloc (2 * 2 * sizeof (int)); connect = (int *) malloc (2 * 2 * sizeof (int)); @@ -261,11 +254,9 @@ int main (int argc, char *argv[]) stat = (int *) malloc (2 * sizeof (int)); stat_all = (int *) malloc (2 * sizeof (int)); // error checking - if ((coords == NULL) || - (label_mol == NULL) || + if ((_atom_info == NULL) || (true_label_mol == NULL) || (type_agl == NULL) || - (type_atoms == NULL) || (agl == NULL) || (connect == NULL) || (num_mol_agl == NULL) || @@ -280,8 +271,9 @@ int main (int argc, char *argv[]) type_agl[i] = 0; sprintf (tmp_str, "%6cOutput file: '%s';\n%6cLog: %i;\n%6cQuiet: %i;\n\ %6cMask: %s;\n%6cFirst step: %i;\n%6cLast step: %i;\n%6cCell size: %.4f, %.4f, %.4f;\n\ -%6cSelect atoms: %i", ' ', output, ' ', log, ' ', quiet, ' ', input, ' ', from, -' ' , to, ' ', cell[0], cell[1], cell[2], ' ' , label_atom[0]); +%6cSelect atoms: %i", ' ', output, ' ', log, ' ', quiet, ' ', input, ' ', _system_info.from, +' ' , _system_info.to, ' ', _system_info.cell[0], _system_info.cell[1], _system_info.cell[2], +' ' , label_atom[0]); for (i=1; i