C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 27th, 2012, 01:21 PM
lida_marti lida_marti is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 2 lida_marti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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!!!

Reply With Quote
  #2  
Old December 27th, 2012, 02:08 PM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,905 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 4 Days 1 h 2 m 3 sec
Reputation Power: 1774
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

Reply With Quote
  #3  
Old December 27th, 2012, 03:27 PM
lida_marti lida_marti is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 2 lida_marti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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;

}


Reply With Quote
  #4  
Old December 27th, 2012, 03:38 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,458 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 4 Days 6 h 26 m 43 sec
Reputation Power: 403
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!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Killed message in gcc

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap