Edited documentation

This commit is contained in:
arcan1s
2013-07-28 04:03:28 +04:00
parent 1af86034e7
commit 7cab7c785f
48 changed files with 5349 additions and 297 deletions

View File

@ -1,3 +1,7 @@
/**
* @file
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@ -11,7 +15,16 @@
#include "set_center.h"
/**
* @fn main
*/
int main(int argc, char *argv[])
/**
* @return 1 - error in error_checking
* @return 2 - input file does not exist
* @return 3 - memory error
* @return 0 - exit without errors
*/
{
char tmp_str[2048];
int error, i, j, *tmp_int;
@ -21,25 +34,26 @@ int main(int argc, char *argv[])
float cell[3], *centr_coords, *coords, rad;
int *label_mol, log, num_atoms, num_mol, num_needed_mol, num_of_mol,
*needed_mol, quiet, *true_label_mol;
/* ch_type_atoms - massive of char types for atoms
* input - input file name
* logfile - log file name
* output - output file name
/* ch_type_atoms massive of char atom types
* input input file name
* logfile log file name
* output output file name
*
* cell - cell dimension
* centr_coords - massive of coordinates of center molecules
* coords - massive of coordinates
* rad - criterion
* cell massive of cell size
* centr_coords massive of centered coordinates
* coords massive of coordinates
* rad radius of environment sphere
*
* label_mol - massive of numbers of molecule for atoms
* log - status of log-mode
* num_atoms - number of atoms for writing coordinates
* num_mol - number of molecules for writing coordinates
* num_needed_mol - number of needed molecules
* num_of_mol - number of molecule for search
* needed_mol - massive of needed molecules
* quiet - status of quiet-mode
* true_label_mol - massive of true numbers of molecule for atoms
* 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
* num_of_mol number of molecule
* needed_mol massive of number of needed molecules
* quiet status of quiet-mode
* true_label_mol massive of true numbers of molecule for atoms
*/
set_defaults (cell, input, &log, &num_of_mol, output, &quiet, &rad);
@ -68,44 +82,44 @@ int main(int argc, char *argv[])
return 0;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'i'))
// input file
// input file
{
strcpy (input, argv[i+1]);
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'c'))
// cell size
// cell size
{
sscanf (argv[i+1], "%f,%f,%f", &cell[0], &cell[1], &cell[2]);
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'o'))
// output file
// output file
{
strcpy (output, argv[i+1]);
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'n'))
// number of molecule
// number of molecule
{
sscanf (argv[i+1], "%i", &num_of_mol);
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'r'))
// radius of environment
// radius of environment
{
sscanf (argv[i+1], "%f", &rad);
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'l'))
// log mode
// log mode
{
log = 1;
strcpy (logfile, argv[i+1]);
i++;
}
else if ((argv[i][0] == '-') && (argv[i][1] == 'q'))
// quiet mode
// quiet mode
{
quiet = 1;
}
@ -127,14 +141,14 @@ int main(int argc, char *argv[])
print_message (quiet, stdout, log, f_log, 2, argv[0]);
// processing
// initial variables
// processing
// initial variables
print_message (quiet, stdout, log, f_log, 3, input);
f_inp = fopen (input, "r");
if (f_inp == NULL)
{
print_message (quiet, stderr, log, f_log, 18, input);
return 1;
return 2;
}
fscanf (f_inp, "%i", &num_atoms);
fclose (f_inp);
@ -143,7 +157,7 @@ int main(int argc, char *argv[])
label_mol = (int *) malloc (8 * 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) ||
(coords == NULL) ||
(label_mol == NULL) ||
@ -151,7 +165,7 @@ int main(int argc, char *argv[])
(true_label_mol == NULL))
{
print_message (quiet, stderr, log, f_log, 19, argv[0]);
return 17;
return 3;
}
sprintf (tmp_str, "%6cInput file: '%s';\n%6cOutput file: '%s';\n%6cLog: %i;\n\
%6cQuiet: %i;\n%6cCell size: %.4f, %.4f, %.4f;\n%6cSelect molecule: %i;\n\
@ -161,7 +175,7 @@ int main(int argc, char *argv[])
print_message (quiet, stdout, log, f_log, 6, argv[0]);
// reading coordinates
// reading coordinates
print_message (quiet, stdout, log, f_log, 7, input);
error = reading_coords (1, input, tmp_int, tmp_int, cell, &num_mol, &num_atoms,
true_label_mol, label_mol, tmp_int, coords, ch_type_atoms);
@ -173,15 +187,15 @@ int main(int argc, char *argv[])
' ', num_mol, ' ', num_atoms);
print_message (quiet, stdout, log, f_log, 8, tmp_str);
}
// error checking
// error checking
if ((centr_coords == NULL) ||
(needed_mol == NULL))
{
print_message (quiet, stderr, log, f_log, 19, argv[0]);
return 17;
return 3;
}
// analyze
// analyze
if (error == 0)
{
error = set_center (num_atoms, num_mol, label_mol, coords, centr_coords);
@ -203,7 +217,7 @@ int main(int argc, char *argv[])
print_message (quiet, stdout, log, f_log, 13, argv[0]);
print_message (quiet, stdout, log, f_log, 15, argv[0]);
// free memory
// free memory
free (ch_type_atoms);
free (centr_coords);
free (coords);