From 0714cb654176e2716704a5d766ff8a66b8ffe4a4 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Tue, 28 Jan 2014 03:45:36 +0400 Subject: [PATCH] fixed agl --- mathmech/agl/src/add_main.c | 57 +++-------------------------- mathmech/agl/src/add_main.h | 73 +++++++++++++++++++++++++++++++++++-- mathmech/agl/src/main.c | 67 +++++++++++++++------------------- 3 files changed, 104 insertions(+), 93 deletions(-) diff --git a/mathmech/agl/src/add_main.c b/mathmech/agl/src/add_main.c index 5f3c9f5..253f4b3 100644 --- a/mathmech/agl/src/add_main.c +++ b/mathmech/agl/src/add_main.c @@ -5,32 +5,16 @@ #include #include +#include /** * @fn error_checking */ -int error_checking (const char *aglinp, const float *cell, const char *input, +int error_checking (const char *aglinp, const system_info _system_info, const char *input, const char *output) -/** - * @brief function that checks errors in input variables - * @code - * error_checking (aglinp, cell, input, output); - * @endcode - * - * @param aglinp agglomerate file name - * @param cell massive of cell size - * @param input input file name - * @param output output file name - * - * @return 11 - error in 'cell' - * @return 12 - error in 'input' - * @return 13 - error in 'output' - * @return 14 - error in 'aglinp' - * @return 0 - exit without errors - */ { - 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 11; if (input[0] == '#') return 12; @@ -48,21 +32,6 @@ int error_checking (const char *aglinp, const float *cell, const char *input, */ 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 - */ { if ((quiet != 1) && (std_output != stderr)) message (0, mode, str, std_output); @@ -76,28 +45,14 @@ int print_message (const int quiet, FILE *std_output, const int log, FILE *f_log /** * @fn set_defaults */ -int set_defaults (char *aglinp, float *cell, char *input, int *log, char *output, int *quiet) -/** - * @brief function that sets default values of variables - * @code - * set_defaults (aglinp, cell, input, &log, output, &quiet); - * @endcode - * - * @param aglinp agglomerate file name - * @param cell massive of cell size - * @param input mask of trajectory files - * @param log status of log-mode - * @param output output file name - * @param quiet status of quiet-mode - * - * @return 0 - exit without errors - */ +int set_defaults (char *aglinp, system_info *_system_info, char *input, int *log, + char *output, int *quiet) { int i; aglinp[0] = '#'; for (i=0; i<3; i++) - cell[i] = 0.0; + (*_system_info).cell[i] = 0.0; input[0] = '#'; *log = 0; output[0] = '#'; diff --git a/mathmech/agl/src/add_main.h b/mathmech/agl/src/add_main.h index ba8e3ec..e016db5 100644 --- a/mathmech/agl/src/add_main.h +++ b/mathmech/agl/src/add_main.h @@ -5,18 +5,83 @@ #ifndef ADD_MAIN_H #define ADD_MAIN_H + +/** + * @file + */ + +#include + +#include +#include + + /** * @fn error_checking */ +int error_checking (const char *aglinp, const system_info _system_info, + const char *input, const char *output); +/** + * @brief function that checks errors in input variables + * @code + * error_checking (aglinp, _system_info, input, output); + * @endcode + * + * @param aglinp agglomerate file name + * @param _system_info system information structure + * @param input input file name + * @param output output file name + * + * @return 11 - error in 'cell' + * @return 12 - error in 'input' + * @return 13 - error in 'output' + * @return 14 - error in 'aglinp' + * @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 (char *aglinp, system_info *_system_info, char *input, int *log, char *output, + int *quiet); +/** + * @brief function that sets default values of variables + * @code + * set_defaults (aglinp, &_system_info, input, &log, output, &quiet); + * @endcode + * + * @param aglinp agglomerate file name + * @param _system_info system information structure + * @param input mask of trajectory files + * @param log status of log-mode + * @param output output file name + * @param quiet status of quiet-mode + * + * @return 0 - exit without errors + */ -int error_checking (const char *, const float *, const char *, const char *); -int print_message (const int, FILE *, const int, FILE *, const int, const char *); -int set_defaults (char *, float *, char *, int *, char *, int *); -#endif /* ADD_MAIN_H */ \ No newline at end of file +#endif /* ADD_MAIN_H */ diff --git a/mathmech/agl/src/main.c b/mathmech/agl/src/main.c index 4039f7f..580c13e 100644 --- a/mathmech/agl/src/main.c +++ b/mathmech/agl/src/main.c @@ -15,6 +15,7 @@ #include #include #include +#include /** @@ -30,35 +31,33 @@ int main(int argc, char *argv[]) */ { char tmp_str[2048]; - int error, i, *tmp_int; + int error, i; FILE *f_inp, *f_log; - char aglinp[256], *ch_type_atoms, input[256], logfile[256], output[256]; - float cell[3], *centr_coords, *coords; - int *label_mol, log, num_atoms, num_mol, num_needed_mol, *needed_mol, quiet, - *true_label_mol; + char aglinp[256], input[256], logfile[256], output[256]; + float *centr_coords; + int log, num_needed_mol, *needed_mol, quiet, *true_label_mol; + atom_info *_atom_info; + system_info _system_info; /* aglinp agglomerate file name - * ch_type_atoms massive of char atom types * input input file name * logfile log file name * output output file name * - * cell massive of cell size * centr_coords massive of centered coordinates - * coords massive of coordinates * - * label_mol massive of numbers of molecule for atoms * log status of log-mode - * num_atoms number of atoms - * num_mol number of molecules * num_needed_mol number of needed molecules * needed_mol massive of number of needed molecules * quiet status of quiet-mode * true_label_mol massive of true numbers of molecule for atoms + * + * _atom_info atom information structure + * _system_info system information structure */ - set_defaults (aglinp, cell, input, &log, output, &quiet); + set_defaults (aglinp, &_system_info, input, &log, output, &quiet); for (i=1; i