The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Killed message in gcc
Discuss Killed message in gcc in the C Programming forum on Dev Shed. Killed message in gcc C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 27th, 2012, 01:21 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 2
Time spent in forums: 52 m 33 sec
Reputation 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!!!
|

December 27th, 2012, 02:08 PM
|
 |
Contributed User
|
|
|
|
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
|

December 27th, 2012, 03:27 PM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 2
Time spent in forums: 52 m 33 sec
Reputation 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?
Quote:
#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;
}
|
|

December 27th, 2012, 03:38 PM
|
 |
Contributing User
|
|
|
|
|
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!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|