mirror of
https://github.com/arcan1s/moldyn.git
synced 2025-07-14 14:25:53 +00:00
Release envir-1.0.1
* edited shared library - deleted binary file and archive
This commit is contained in:
@ -17,5 +17,3 @@ Parametrs:
|
||||
-l - log enable
|
||||
-q - quiet enable
|
||||
-h - show this help and exit
|
||||
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#ifndef COORDS_H
|
||||
#define COORDS_H
|
||||
|
||||
int reading_coords (const char *, const int, const int *, const float *, int *,
|
||||
int *, int *, int *, int *, float *);
|
||||
int reading_coords (const int, const char *, const int, const int *,
|
||||
const float *, int *, int *, int *, int *, int *, float *,
|
||||
char *);
|
||||
|
||||
#endif /* COORDS_H */
|
@ -2,7 +2,6 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// #include "messages.h"
|
||||
|
||||
@ -70,7 +69,7 @@ int printing_head (const char *output, const int log, const int quiet,
|
||||
int print_message (const int quiet, FILE *std_output, const int log, FILE *f_log,
|
||||
const int mode, const char *str)
|
||||
{
|
||||
if (quiet != 1)
|
||||
if ((quiet != 1) && (std_output != stderr))
|
||||
message (0, mode, str, std_output);
|
||||
if (log == 1)
|
||||
message (1, mode, str, f_log);
|
||||
|
@ -1,19 +1,19 @@
|
||||
/* Library for reading coordinates from input file
|
||||
*
|
||||
* Usage:
|
||||
* reading_coords (filename, type_interaction, labels, cell,
|
||||
* &number_of_molecules, &number_of_atoms, true_label_molecule, label_molecule,
|
||||
* type_atoms, coords)
|
||||
* reading_coords (mode, filename, type_interaction, labels,
|
||||
* cell, &number_of_molecules, &number_of_atoms, true_label_molecule,
|
||||
* label_molecule, type_atoms, coords, char_type_atoms)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int reading_coords (const char *filename, const int type_inter,
|
||||
int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
const int *label_atom, const float *cell, int *num_mol,
|
||||
int *num_atoms, int *true_label_mol, int *label_mol,
|
||||
int *type_atoms, float *coords)
|
||||
int *type_atoms, float *coords, char *ch_type_atoms)
|
||||
/* filename - name of file with coordinates
|
||||
* type_inter - type interaction (number of molecules for interaction)
|
||||
* label_atom - types of atom for interaction
|
||||
@ -24,11 +24,12 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* type_atoms - massive of atom types for atoms
|
||||
* coords - massive of coordinates
|
||||
* ch_type_atoms - massive of char types for atoms
|
||||
*/
|
||||
{
|
||||
char at_symb[32], file_string[256];
|
||||
int atoms, cur_at_num, cur_at_type, cur_mol, i, j, tr_num_atoms, ref_mol, x, y;
|
||||
float cur_coords[3], not_tr_coords[750000], ref[3];
|
||||
float cur_coords[3], *not_tr_coords, ref[3];
|
||||
FILE *inp;
|
||||
/* cur_*, at_symb - temp variables
|
||||
* file_string - temp string variable
|
||||
@ -50,6 +51,7 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
|
||||
ref_mol = -1;
|
||||
fscanf (inp, "%i", &atoms);
|
||||
not_tr_coords = (float *) malloc (3 * atoms * sizeof (float));
|
||||
fgets (file_string, 256, inp);
|
||||
for (i=0; i<atoms; i++)
|
||||
{
|
||||
@ -57,12 +59,36 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
sscanf (file_string, "%i%s%f%f%f%i%i", &cur_at_num, at_symb, &cur_coords[0],
|
||||
&cur_coords[1], &cur_coords[2], &cur_at_type, &cur_mol);
|
||||
|
||||
for (j=0; j<type_inter; j++)
|
||||
if (cur_at_type == label_atom[j])
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
// for statgen
|
||||
for (j=0; j<type_inter; j++)
|
||||
if (cur_at_type == label_atom[j])
|
||||
{
|
||||
not_tr_coords[3**num_atoms+0] = cur_coords[0];
|
||||
not_tr_coords[3**num_atoms+1] = cur_coords[1];
|
||||
not_tr_coords[3**num_atoms+2] = cur_coords[2];
|
||||
|
||||
if (ref_mol != cur_mol)
|
||||
{
|
||||
ref_mol = cur_mol;
|
||||
true_label_mol[*num_mol] = ref_mol;
|
||||
*num_mol = *num_mol + 1;
|
||||
}
|
||||
label_mol[*num_atoms] = *num_mol - 1;
|
||||
type_atoms[*num_atoms] = j;
|
||||
|
||||
*num_atoms = *num_atoms + 1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// for envir
|
||||
not_tr_coords[3**num_atoms+0] = cur_coords[0];
|
||||
not_tr_coords[3**num_atoms+1] = cur_coords[1];
|
||||
not_tr_coords[3**num_atoms+2] = cur_coords[2];
|
||||
ch_type_atoms[2**num_atoms+0] = at_symb[0];
|
||||
ch_type_atoms[2**num_atoms+1] = at_symb[1];
|
||||
|
||||
if (ref_mol != cur_mol)
|
||||
{
|
||||
@ -74,7 +100,9 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
type_atoms[*num_atoms] = j;
|
||||
|
||||
*num_atoms = *num_atoms + 1;
|
||||
}
|
||||
break;
|
||||
default: return 1;
|
||||
}
|
||||
}
|
||||
fclose (inp);
|
||||
|
||||
@ -87,7 +115,7 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
// Assign initial value to reference coordinates
|
||||
ref_mol = label_mol[0];
|
||||
for (i=0; i<3; i++)
|
||||
ref[i] = coords[i];
|
||||
ref[i] = coords[3*0+i];
|
||||
|
||||
for (i=0; i<*num_atoms; i++)
|
||||
{
|
||||
@ -278,5 +306,8 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
}
|
||||
}
|
||||
|
||||
// free memory
|
||||
free (not_tr_coords);
|
||||
|
||||
return 0;
|
||||
}
|
@ -208,10 +208,7 @@ int main (int argc, char *argv[])
|
||||
type_inter);
|
||||
if (error != 0)
|
||||
{
|
||||
sprintf (tmp_str, "Something wrong (error code: %i)!\nSee 'statgen -h' for more details\n", error);
|
||||
fputs (tmp_str, stderr);
|
||||
if (log == 1)
|
||||
fputs (tmp_str, f_log);
|
||||
print_message (quiet, stderr, log, f_log, 17, argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -230,17 +227,14 @@ int main (int argc, char *argv[])
|
||||
f_inp = fopen (filename, "r");
|
||||
if (f_inp == NULL)
|
||||
{
|
||||
sprintf (tmp_str, "\nFile '%s' not found\nError", filename);
|
||||
fputs (tmp_str, stderr);
|
||||
if (log == 1)
|
||||
fputs (tmp_str, f_log);
|
||||
print_message (quiet, stderr, log, f_log, 18, filename);
|
||||
return 1;
|
||||
}
|
||||
fscanf (f_inp, "%i", &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 (8 * num_atoms * sizeof (int));
|
||||
true_label_mol = (int *) malloc (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
|
||||
@ -261,10 +255,7 @@ int main (int argc, char *argv[])
|
||||
(stat == NULL) ||
|
||||
(stat_all == NULL))
|
||||
{
|
||||
sprintf (tmp_str, "\nMemory error (error code: 17)\n");
|
||||
fputs (tmp_str, stderr);
|
||||
if (log == 1)
|
||||
fputs (tmp_str, f_log);
|
||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||
return 17;
|
||||
}
|
||||
// set type_agl to zero
|
||||
@ -303,12 +294,13 @@ int main (int argc, char *argv[])
|
||||
filename[k+3] = conv (i, 1);
|
||||
filename[k+4] = '\0';
|
||||
print_message (quiet, stdout, log, f_log, 7, filename);
|
||||
error = reading_coords (filename, type_inter, label_atom, cell, &num_mol,
|
||||
&num_atoms, true_label_mol, label_mol, type_atoms, coords);
|
||||
error = reading_coords (0, filename, type_inter, label_atom, cell, &num_mol,
|
||||
&num_atoms, true_label_mol, label_mol, type_atoms,
|
||||
coords, tmp_str);
|
||||
if (error != 1)
|
||||
{
|
||||
sprintf (tmp_str, "%6cNumber of molecules: %i; %6cNumber of atoms: %i\n",
|
||||
' ', num_mol, ' ', num_atoms);
|
||||
' ', num_mol, ' ', num_atoms);
|
||||
print_message (quiet, stdout, log, f_log, 8, tmp_str);
|
||||
}
|
||||
|
||||
@ -330,10 +322,7 @@ int main (int argc, char *argv[])
|
||||
(stat == NULL) ||
|
||||
(stat_all == NULL))
|
||||
{
|
||||
sprintf (tmp_str, "\nMemory error (error code: 18)\n");
|
||||
fputs (tmp_str, stderr);
|
||||
if (log == 1)
|
||||
fputs (tmp_str, f_log);
|
||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||
return 18;
|
||||
}
|
||||
print_message (quiet, stdout, log, f_log, 9, argv[0]);
|
||||
|
@ -77,6 +77,21 @@ int message (const int log, const int mode, const char *text, FILE *output)
|
||||
case 16:
|
||||
sprintf (out, "Exiting without errors\n");
|
||||
break;
|
||||
case 17:
|
||||
sprintf (out, "Something wrong!\nSee '%s -h' for more details\n", text);
|
||||
break;
|
||||
case 18:
|
||||
sprintf (out, "File '%s' not found\nError\n", text);
|
||||
break;
|
||||
case 19:
|
||||
sprintf (out, "Memory error\n");
|
||||
break;
|
||||
case 20:
|
||||
sprintf (out, "%6cCenter of molecules was set successfully\n", ' ');
|
||||
break;
|
||||
case 21:
|
||||
sprintf (out, "%6cEnvironment was selected successfully\n", ' ');
|
||||
break;
|
||||
}
|
||||
|
||||
fputs (out, output);
|
||||
|
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user