#include "dump2analysis.h"

void Deallocate(ATOMS *a, int n){
  int i;
  
  for (i=0; i<n; i++) free(a->elem[i]);
  /* free(a->elem); */
  free(a->id);
  free(a->type);
  free(a->x);
  free(a->y);
  free(a->z);
  free(a->vx);
  free(a->vy);
  free(a->vz);
  free(a->fx);
  free(a->fy);
  free(a->fz);
}

void Allocate(ATOMS *a, int n){
  int i;
  
  a->atoms = n;
  a->elem = malloc(sizeof(char*) * n);
  for (i=0; i<n; i++) a->elem[i] = malloc(sizeof(char) * 8);
  a->id = malloc(sizeof(int) * n);
  a->type = malloc(sizeof(int) * n);
  a->x = malloc(sizeof(double) * n);
  a->y = malloc(sizeof(double) * n);
  a->z = malloc(sizeof(double) * n);
  a->vx = malloc(sizeof(double) * n);
  a->vy = malloc(sizeof(double) * n);
  a->vz = malloc(sizeof(double) * n);
  a->fx = malloc(sizeof(double) * n);
  a->fy = malloc(sizeof(double) * n);
  a->fz = malloc(sizeof(double) * n);
  for (i=0; i<n; i++){
    a->id[i] = 0;
    a->type[i] = 0;
    a->x[i] = 0.0;
    a->y[i] = 0.0;
    a->z[i] = 0.0;
    a->vx[i] = 0.0;
    a->vy[i] = 0.0;
    a->vz[i] = 0.0;
    a->fx[i] = 0.0;
    a->fy[i] = 0.0;
    a->fz[i] = 0.0;
    strcpy(a->elem[i], "");
  }

}
