mirror of
https://github.com/arcan1s/moldyn.git
synced 2025-07-05 10:05:46 +00:00
fixed agl
This commit is contained in:
@ -5,32 +5,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <mathmech/messages.h>
|
#include <mathmech/messages.h>
|
||||||
|
#include <mathmech/var_types.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn error_checking
|
* @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)
|
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;
|
return 11;
|
||||||
if (input[0] == '#')
|
if (input[0] == '#')
|
||||||
return 12;
|
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,
|
int print_message (const int quiet, FILE *std_output, const int log, FILE *f_log,
|
||||||
const int mode, const char *str)
|
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))
|
if ((quiet != 1) && (std_output != stderr))
|
||||||
message (0, mode, str, std_output);
|
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
|
* @fn set_defaults
|
||||||
*/
|
*/
|
||||||
int set_defaults (char *aglinp, float *cell, char *input, int *log, char *output, int *quiet)
|
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, 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 i;
|
int i;
|
||||||
|
|
||||||
aglinp[0] = '#';
|
aglinp[0] = '#';
|
||||||
for (i=0; i<3; i++)
|
for (i=0; i<3; i++)
|
||||||
cell[i] = 0.0;
|
(*_system_info).cell[i] = 0.0;
|
||||||
input[0] = '#';
|
input[0] = '#';
|
||||||
*log = 0;
|
*log = 0;
|
||||||
output[0] = '#';
|
output[0] = '#';
|
||||||
|
@ -5,18 +5,83 @@
|
|||||||
#ifndef ADD_MAIN_H
|
#ifndef ADD_MAIN_H
|
||||||
#define ADD_MAIN_H
|
#define ADD_MAIN_H
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <mathmech/messages.h>
|
||||||
|
#include <mathmech/var_types.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn error_checking
|
* @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
|
* @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
|
* @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/read_agl.h>
|
||||||
#include <mathmech/select_mol.h>
|
#include <mathmech/select_mol.h>
|
||||||
#include <mathmech/set_center.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];
|
char tmp_str[2048];
|
||||||
int error, i, *tmp_int;
|
int error, i;
|
||||||
FILE *f_inp, *f_log;
|
FILE *f_inp, *f_log;
|
||||||
|
|
||||||
char aglinp[256], *ch_type_atoms, input[256], logfile[256], output[256];
|
char aglinp[256], input[256], logfile[256], output[256];
|
||||||
float cell[3], *centr_coords, *coords;
|
float *centr_coords;
|
||||||
int *label_mol, log, num_atoms, num_mol, num_needed_mol, *needed_mol, quiet,
|
int log, num_needed_mol, *needed_mol, quiet, *true_label_mol;
|
||||||
*true_label_mol;
|
atom_info *_atom_info;
|
||||||
|
system_info _system_info;
|
||||||
|
|
||||||
/* aglinp agglomerate file name
|
/* aglinp agglomerate file name
|
||||||
* ch_type_atoms massive of char atom types
|
|
||||||
* input input file name
|
* input input file name
|
||||||
* logfile log file name
|
* logfile log file name
|
||||||
* output output file name
|
* output output file name
|
||||||
*
|
*
|
||||||
* cell massive of cell size
|
|
||||||
* centr_coords massive of centered coordinates
|
* centr_coords massive of centered coordinates
|
||||||
* coords massive of coordinates
|
|
||||||
*
|
*
|
||||||
* label_mol massive of numbers of molecule for atoms
|
|
||||||
* log status of log-mode
|
* log status of log-mode
|
||||||
* num_atoms number of atoms
|
|
||||||
* num_mol number of molecules
|
|
||||||
* num_needed_mol number of needed molecules
|
* num_needed_mol number of needed molecules
|
||||||
* needed_mol massive of number of needed molecules
|
* needed_mol massive of number of needed molecules
|
||||||
* quiet status of quiet-mode
|
* quiet status of quiet-mode
|
||||||
* true_label_mol massive of true numbers of molecule for atoms
|
* 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++)
|
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'))
|
else if ((argv[i][0] == '-') && (argv[i][1] == 'c') && (argv[i][2] == '\0'))
|
||||||
// cell size
|
// 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++;
|
i++;
|
||||||
}
|
}
|
||||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'o') && (argv[i][2] == '\0'))
|
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]);
|
print_message (quiet, stdout, log, f_log, 1, argv[0]);
|
||||||
|
|
||||||
// error check
|
// error check
|
||||||
error = error_checking (aglinp, cell, input, output);
|
error = error_checking (aglinp, _system_info, input, output);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
{
|
{
|
||||||
print_message (quiet, stderr, log, f_log, 17, argv[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);
|
print_message (quiet, stderr, log, f_log, 18, input);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
fscanf (f_inp, "%i", &num_atoms);
|
fscanf (f_inp, "%i", &_system_info.num_atoms);
|
||||||
fclose (f_inp);
|
fclose (f_inp);
|
||||||
ch_type_atoms = (char *) malloc (2 * num_atoms * sizeof (char));
|
_atom_info = (atom_info *) malloc (8 * _system_info.num_atoms * sizeof (atom_info));
|
||||||
coords = (float *) malloc (3 * 8 * num_atoms * sizeof (float));
|
needed_mol = (int *) malloc (_system_info.num_atoms * sizeof (int));
|
||||||
label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
|
true_label_mol = (int *) malloc (_system_info.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));
|
|
||||||
// error checking
|
// error checking
|
||||||
if ((ch_type_atoms == NULL) ||
|
if ((_atom_info == NULL) ||
|
||||||
(coords == NULL) ||
|
|
||||||
(label_mol == NULL) ||
|
|
||||||
(needed_mol == NULL) ||
|
(needed_mol == NULL) ||
|
||||||
(tmp_int == NULL) ||
|
|
||||||
(true_label_mol == NULL))
|
(true_label_mol == NULL))
|
||||||
{
|
{
|
||||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
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\
|
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",
|
%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, 5, tmp_str);
|
||||||
|
|
||||||
print_message (quiet, stdout, log, f_log, 6, argv[0]);
|
print_message (quiet, stdout, log, f_log, 6, argv[0]);
|
||||||
@ -187,10 +182,9 @@ int main(int argc, char *argv[])
|
|||||||
// reading coordinates
|
// reading coordinates
|
||||||
print_message (quiet, stdout, log, f_log, 7, input);
|
print_message (quiet, stdout, log, f_log, 7, input);
|
||||||
error = 1;
|
error = 1;
|
||||||
error = reading_coords (2, input, num_needed_mol, needed_mol, cell, &num_mol,
|
error = reading_coords (2, input, num_needed_mol, needed_mol, &_system_info,
|
||||||
&num_atoms, true_label_mol, label_mol, tmp_int, coords,
|
true_label_mol, _atom_info);
|
||||||
ch_type_atoms);
|
centr_coords = (float *) malloc (3 * 8 * _system_info.num_mol * sizeof (float));
|
||||||
centr_coords = (float *) malloc (3 * 8 * num_mol * sizeof (float));
|
|
||||||
if (centr_coords == NULL)
|
if (centr_coords == NULL)
|
||||||
{
|
{
|
||||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||||
@ -202,10 +196,10 @@ int main(int argc, char *argv[])
|
|||||||
if (error == 0)
|
if (error == 0)
|
||||||
{
|
{
|
||||||
sprintf (tmp_str, "%6cNumber of molecules: %i; %6cNumber of atoms: %i\n",
|
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);
|
print_message (quiet, stdout, log, f_log, 8, tmp_str);
|
||||||
error = 1;
|
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)
|
if (error == 0)
|
||||||
{
|
{
|
||||||
@ -217,8 +211,8 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
print_message (quiet, stderr, log, f_log, 4, argv[0]);
|
print_message (quiet, stderr, log, f_log, 4, argv[0]);
|
||||||
error = 1;
|
error = 1;
|
||||||
error = print_structure (output, num_needed_mol, needed_mol, num_atoms,
|
error = print_structure (output, num_needed_mol, needed_mol, _system_info,
|
||||||
label_mol, ch_type_atoms, coords);
|
_atom_info);
|
||||||
}
|
}
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
print_message (quiet, stderr, log, f_log, 12, output);
|
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]);
|
print_message (quiet, stdout, log, f_log, 15, argv[0]);
|
||||||
// free memory
|
// free memory
|
||||||
free (ch_type_atoms);
|
free (_atom_info);
|
||||||
free (centr_coords);
|
free (centr_coords);
|
||||||
free (coords);
|
|
||||||
free (label_mol);
|
|
||||||
free (needed_mol);
|
free (needed_mol);
|
||||||
free (tmp_int);
|
|
||||||
free (true_label_mol);
|
free (true_label_mol);
|
||||||
|
|
||||||
print_message (quiet, stdout, log, f_log, 16, argv[0]);
|
print_message (quiet, stdout, log, f_log, 16, argv[0]);
|
||||||
|
Reference in New Issue
Block a user