mirror of
https://github.com/arcan1s/moldyn.git
synced 2025-06-28 06:41:42 +00:00
fixed agl
This commit is contained in:
@ -5,32 +5,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <mathmech/messages.h>
|
||||
#include <mathmech/var_types.h>
|
||||
|
||||
|
||||
/**
|
||||
* @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] = '#';
|
||||
|
@ -5,18 +5,83 @@
|
||||
#ifndef ADD_MAIN_H
|
||||
#define ADD_MAIN_H
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <mathmech/messages.h>
|
||||
#include <mathmech/var_types.h>
|
||||
|
||||
|
||||
/**
|
||||
* @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 */
|
||||
#endif /* ADD_MAIN_H */
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <mathmech/read_agl.h>
|
||||
#include <mathmech/select_mol.h>
|
||||
#include <mathmech/set_center.h>
|
||||
#include <mathmech/var_types.h>
|
||||
|
||||
|
||||
/**
|
||||
@ -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<argc; i++)
|
||||
{
|
||||
@ -97,7 +96,8 @@ int main(int argc, char *argv[])
|
||||
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] == 'o') && (argv[i][2] == '\0'))
|
||||
@ -132,7 +132,7 @@ int main(int argc, char *argv[])
|
||||
print_message (quiet, stdout, log, f_log, 1, argv[0]);
|
||||
|
||||
// error check
|
||||
error = error_checking (aglinp, cell, input, output);
|
||||
error = error_checking (aglinp, _system_info, input, output);
|
||||
if (error != 0)
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 17, argv[0]);
|
||||
@ -150,20 +150,14 @@ int main(int argc, char *argv[])
|
||||
print_message (quiet, stderr, log, f_log, 18, input);
|
||||
return 2;
|
||||
}
|
||||
fscanf (f_inp, "%i", &num_atoms);
|
||||
fscanf (f_inp, "%i", &_system_info.num_atoms);
|
||||
fclose (f_inp);
|
||||
ch_type_atoms = (char *) malloc (2 * num_atoms * sizeof (char));
|
||||
coords = (float *) malloc (3 * 8 * num_atoms * sizeof (float));
|
||||
label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
|
||||
needed_mol = (int *) malloc (num_atoms * sizeof (int));
|
||||
tmp_int = (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));
|
||||
needed_mol = (int *) malloc (_system_info.num_atoms * sizeof (int));
|
||||
true_label_mol = (int *) malloc (_system_info.num_atoms * sizeof (int));
|
||||
// error checking
|
||||
if ((ch_type_atoms == NULL) ||
|
||||
(coords == NULL) ||
|
||||
(label_mol == NULL) ||
|
||||
if ((_atom_info == NULL) ||
|
||||
(needed_mol == NULL) ||
|
||||
(tmp_int == NULL) ||
|
||||
(true_label_mol == NULL))
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||
@ -171,7 +165,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
sprintf (tmp_str, "%6cAglomerate file: '%s';\n%6cInput file: '%s';\n\
|
||||
%6cOutput file: '%s';\n%6cLog: %i;\n%6cQuiet: %i;\n%6cCell size: %.4f, %.4f, %.4f\n",
|
||||
' ', aglinp, ' ', input, ' ', output, ' ', log, ' ', quiet, ' ', cell[0], cell[1], cell[2]);
|
||||
' ', aglinp, ' ', input, ' ', output, ' ', log, ' ', quiet, ' ', _system_info.cell[0],
|
||||
_system_info.cell[1], _system_info.cell[2]);
|
||||
print_message (quiet, stdout, log, f_log, 5, tmp_str);
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 6, argv[0]);
|
||||
@ -187,10 +182,9 @@ int main(int argc, char *argv[])
|
||||
// reading coordinates
|
||||
print_message (quiet, stdout, log, f_log, 7, input);
|
||||
error = 1;
|
||||
error = reading_coords (2, input, num_needed_mol, needed_mol, cell, &num_mol,
|
||||
&num_atoms, true_label_mol, label_mol, tmp_int, coords,
|
||||
ch_type_atoms);
|
||||
centr_coords = (float *) malloc (3 * 8 * num_mol * sizeof (float));
|
||||
error = reading_coords (2, input, num_needed_mol, needed_mol, &_system_info,
|
||||
true_label_mol, _atom_info);
|
||||
centr_coords = (float *) malloc (3 * 8 * _system_info.num_mol * sizeof (float));
|
||||
if (centr_coords == NULL)
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||
@ -202,10 +196,10 @@ int main(int argc, char *argv[])
|
||||
if (error == 0)
|
||||
{
|
||||
sprintf (tmp_str, "%6cNumber of molecules: %i; %6cNumber of atoms: %i\n",
|
||||
' ', num_mol, ' ', num_atoms);
|
||||
' ', _system_info.num_mol, ' ', _system_info.num_atoms);
|
||||
print_message (quiet, stdout, log, f_log, 8, tmp_str);
|
||||
error = 1;
|
||||
error = set_center (num_atoms, num_mol, label_mol, coords, centr_coords);
|
||||
error = set_center (_system_info, _atom_info, centr_coords);
|
||||
}
|
||||
if (error == 0)
|
||||
{
|
||||
@ -217,8 +211,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 4, argv[0]);
|
||||
error = 1;
|
||||
error = print_structure (output, num_needed_mol, needed_mol, num_atoms,
|
||||
label_mol, ch_type_atoms, coords);
|
||||
error = print_structure (output, num_needed_mol, needed_mol, _system_info,
|
||||
_atom_info);
|
||||
}
|
||||
if (error == 0)
|
||||
print_message (quiet, stderr, log, f_log, 12, output);
|
||||
@ -227,12 +221,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 15, argv[0]);
|
||||
// free memory
|
||||
free (ch_type_atoms);
|
||||
free (_atom_info);
|
||||
free (centr_coords);
|
||||
free (coords);
|
||||
free (label_mol);
|
||||
free (needed_mol);
|
||||
free (tmp_int);
|
||||
free (true_label_mol);
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 16, argv[0]);
|
||||
|
Reference in New Issue
Block a user