#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Killed message in gcc


    Hello,

    I'm having trouble when running a program. It compiles without any problem using gcc but when it's running, after some iterations, it stops and appears "killed" on the terminal. It's a program about how an ideal gas in a box evolves in time. When I increase the number of particles in the box or increase the time I want the gas to evolve it stops itself. Any help on how to solve it? Why does the killed message appears? Thanks!!!
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,379
    Rep Power
    1871
    The primary reason would be bugs in your code. Saying what is likely to be wrong would require you to post some code.

    A secondary reason may be that your program takes up too much time / memory / file handles etc.
    http://ss64.com/bash/ulimit.html
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0
    this is a function used in main called time. ax, ay, az are the position of the particles in the box and bx by and bz are their velocity. N is the number of particles. T the total time, h the time between steps. This shows a killed message when running it when N or T are big (10000) (or h small). In fact we need N to be of the order of E23, is there any way that in a normal computer we can do that?

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <time.h>
    #include "functions.h"

    double *time(double *x,double *y,double *z,double *vx,double *vy,double *vz,long int N, double h, long int T,double **bx,double **by,double **bz)
    {

    //we declare the variables
    int i, k, t, l, m;
    double **ax, **ay, **az;

    t=(int)(T/h);

    //allocation of memory
    ax= (double**) calloc(N,sizeof(double*));
    for(l=0; l<N; l++)
    {
    ax[l]= (double*) calloc(t+2,sizeof(double));
    }
    ay= (double**) calloc(N,sizeof(double*));
    for(l=0; l<N; l++)
    {
    ay[l]= (double*) calloc(t+2,sizeof(double));
    }
    az= (double**) calloc(N,sizeof(double*));
    for(l=0; l<N; l++)
    {
    az[l]= (double*) calloc(t+2,sizeof(double));
    }


    //we set the initial value of the variables
    for (i=0;i<N;i++)
    {
    ax[i][0]=x[i];
    ay[i][0]=y[i];
    az[i][0]=z[i];

    bx[i][0]=vx[i];
    by[i][0]=vy[i];
    bz[i][0]=vz[i];
    }

    //we evolve the system of particles, making them move according to their speed

    k=0;

    do{
    i=0;
    do
    {

    if (ax[i][k]>=1)
    { bx[i][k+1]=-bx[i][k];}
    else if (ax[i][k]<=0)
    { bx[i][k+1]=-bx[i][k];}
    else { bx[i][k+1]=bx[i][k];}

    if (ay[i][k]>=1)
    { by[i][k+1]=-by[i][k];}
    else if (ay[i][k]<=0)
    { by[i][k+1]=-by[i][k];}
    else { by[i][k+1]=by[i][k];}

    if (az[i][k]>=1)
    { bz[i][k+1]=-bz[i][k];}
    else if (az[i][k]<=0)
    { bz[i][k+1]=-bz[i][k];}
    else { bz[i][k+1]=bz[i][k];}

    ax[i][k+1]=ax[i][k]+bx[i][k+1]*h;
    ay[i][k+1]=ay[i][k]+by[i][k+1]*h;
    az[i][k+1]=az[i][k]+bz[i][k+1]*h;

    i++;


    } while (i<N);
    k++;
    }while ((h*k)<T);

    m=k;





    //free memory

    for(l=0; l<N; l++)
    {
    free(ax[l]);
    free(ay[l]);
    free(az[l]);

    }
    free(ax);
    free(ay);
    free(az);


    return 0;

    }
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    I suggest you simulate particles in a small box.
    With a million particles, or perhaps debug your program with 9 ideal gas particles.
    I'm certain, absolutely certain that you can figure out the size of your box for N particles to make the density you need.

    My computer has only 6e22 words of memory, so Mr. Avagadro can't work on MY computer.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo