Go Back   Science Forums > Physical Sciences Forums > Computer Science and Technology
Reply
 
LinkBack Thread Tools
Old 10-23-2007   #1 (permalink)
sanctus's Avatar
Resident Diabolist

Administrator

Location:
Geneva-Bern-Zürich, Switzerland;Oslo,Norway
 
sanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant future
 



Not Ranked  0 score     
abstract C++ question

How is the following possible?

1) I have a running program with the an option, say A, set to false; i.e.
Code:
A=false;
2) I set
Code:
A=true;
and get an error (it still runs but doesn't calculate because always out of bounds)

3) I set again
Code:
A=false;
and get still the same error as after 2...

This is not clear at all to me because between every numbered step (i.e. 1 and 2 and 2 and 3) there is a make clean and then a make...so it shouldn't know anything from the preceeding right?


----------------
Administrator

A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!


I don't believe in god, but I do believe in what others call utopies.
Reply With Quote
Old 10-23-2007   #2 (permalink)
alexander's Avatar
Dedicated Smart-ass

Senior Moderator
Gallery Curator
Dev Team Member

Location:
Just before 0xAA55
 
alexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond repute
Send a message via AIM to alexander
 



Not Ranked  0 score     
Re: abstract C++ question

it does not matter how many times you set a, as long as you are not accidentally redefining it (in which case you will get an error)

i can however see a possible problem with you using A in calculations, i would type cast it as int just to be on a safe side. i know posting the whole code may not be possible, but could you perhaps post more pieces that may give us a better picture of what may be happening?


----------------
Microsoft, the leader in using innovative tactics to promote irksome experience, coupled with antiquated technology that's held together by a pyramid of makeshift afterthoughts.

Apple, the leader in using irksome tactics to promote innovative experience, coupled with an antiquated core that's enhanced by state-of-the-art afterthoughts.

Linux, the leader in not using any tactics to promote user-defined experience, coupled with state-of-the-art core enhanced by innovative afterthoughts.

Reply With Quote
Old 10-23-2007   #3 (permalink)
Buffy's Avatar
Resident Slayer

Administrator

Location:
Sunnydale, CA
 
Buffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond repute
 



Not Ranked  0 score     
Re: abstract C++ question

This is the kind of bug for which a debugger is pretty much invaluable. Have you got one? You need to either have a break on change in value or step through the code starting where its "not the right value."

I had a developer not too long ago who thought he was such a hotshot that he could get by without using a debugger, just traces. He did not last long!

Step into,
Buffy


----------------
"If you do not agree with anything I say, I'll not only retract it, but deny under oath that I ever said it!"
__________________________________________________ ______________-- Tom Lehrer

"No Robbie, not Europe!"


Forum Administrator
Hypography Science Forums - Science for Boys and Girls! Its not for nothing that we hang out here.
Reply With Quote
Old 10-23-2007   #4 (permalink)
alexander's Avatar
Dedicated Smart-ass

Senior Moderator
Gallery Curator
Dev Team Member

Location:
Just before 0xAA55
 
alexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond repute
Send a message via AIM to alexander
 



Not Ranked  0 score     
Re: abstract C++ question

mmmm, GDBlicious


----------------
Microsoft, the leader in using innovative tactics to promote irksome experience, coupled with antiquated technology that's held together by a pyramid of makeshift afterthoughts.

Apple, the leader in using irksome tactics to promote innovative experience, coupled with an antiquated core that's enhanced by state-of-the-art afterthoughts.

Linux, the leader in not using any tactics to promote user-defined experience, coupled with state-of-the-art core enhanced by innovative afterthoughts.

Reply With Quote
Old 10-23-2007   #5 (permalink)
LaurieAG's Avatar
Explaining


Location:
South East Queensland, Australia
 
LaurieAG is a splendid one to beholdLaurieAG is a splendid one to beholdLaurieAG is a splendid one to beholdLaurieAG is a splendid one to beholdLaurieAG is a splendid one to beholdLaurieAG is a splendid one to behold
 



Not Ranked  0 score     
Re: abstract C++ question

Quote:
Originally Posted by sanctus View Post
This is not clear at all to me because between every numbered step (i.e. 1 and 2 and 2 and 3) there is a make clean and then a make...so it shouldn't know anything from the preceeding right?
Hi Sanctus,

It may be due to your 'A' being a restricted system variable name. Your documentation should provide a list of any restricted variable names.
Reply With Quote
Old 10-24-2007   #6 (permalink)
sanctus's Avatar
Resident Diabolist

Administrator

Location:
Geneva-Bern-Zürich, Switzerland;Oslo,Norway
 
sanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant future
 



Not Ranked  0 score     
Re: abstract C++ question

Actually the code was not written by me, I just modified some parts (nothing though related to that). The code is too complicated to post it here giving a clue...'A' is just a name of an experience to use or not for computing the likelihood...
The problem with gdb is that I run this program on different (9) machines at university, so I don't really know how to use gdb. Additionally thing is that looking at the output on the different machines there isn't really an error of compilation but one written in the code (something like "in spline # x out of bounds") so it actually keeps turning but calculates nothing because out of bounds...but why in the beginning x was in bounds and then changing from false to true back to false it is out of bounds (as it was when it was true)?


----------------
Administrator

A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!


I don't believe in god, but I do believe in what others call utopies.
Reply With Quote
Old 10-24-2007   #7 (permalink)
Buffy's Avatar
Resident Slayer

Administrator

Location:
Sunnydale, CA
 
Buffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond reputeBuffy has a reputation beyond repute
 



Not Ranked  0 score     
Re: abstract C++ question

Quote:
Originally Posted by sanctus View Post
The problem with gdb is that I run this program on different (9) machines at university, so I don't really know how to use gdb.
Learn it on the one machine that has it installed! You'll be glad you did!

Why? Well...
Quote:
Originally Posted by sanctus View Post
...there isn't really an error of compilation but one written in the code...
Debuggers are what you use when it compiles fine, but theres something in your algorithm that isn't working and you have to go in and watch what's going on in order to find where the flaw is.

But if you don't have the time to learn gdb (and really all you need to know is how to set a breakpoint and then inspect the variables that are making you miserable), then you need to "instrument" the app, which basically just means putting "writes" or "alerts" in your code at strategic places and see when x and a are changing. Put these in before and after every reference to them in the code that's not working.

Quite often when you have problems like you're describing, its either due to hidden side-effects (something is buried one level down in a function), or you've got scoping errors (x is a local variable that gets set in one place, goes out of scope and then gets recreated but now has no value).

If you were using C instead of C++, I'd also be looking for arrays that are going past their declared sizes and munging data in other variables that get allocated nearby on the heap, but you should be getting run-time errors for that (unless you were using an old generic unix "cc").

printf("It hasn't worked for the last %d loops.", i),
Buffy


----------------
"If you do not agree with anything I say, I'll not only retract it, but deny under oath that I ever said it!"
__________________________________________________ ______________-- Tom Lehrer

"No Robbie, not Europe!"


Forum Administrator
Hypography Science Forums - Science for Boys and Girls! Its not for nothing that we hang out here.
Reply With Quote
Old 10-24-2007   #8 (permalink)
alexander's Avatar
Dedicated Smart-ass

Senior Moderator
Gallery Curator
Dev Team Member

Location:
Just before 0xAA55
 
alexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond reputealexander has a reputation beyond repute
Send a message via AIM to alexander
 



Not Ranked  0 score     
Re: abstract C++ question

g++ -ggdb -o prog prog.cpp

gdb prog

run



----------------
Microsoft, the leader in using innovative tactics to promote irksome experience, coupled with antiquated technology that's held together by a pyramid of makeshift afterthoughts.

Apple, the leader in using irksome tactics to promote innovative experience, coupled with an antiquated core that's enhanced by state-of-the-art afterthoughts.

Linux, the leader in not using any tactics to promote user-defined experience, coupled with state-of-the-art core enhanced by innovative afterthoughts.

Reply With Quote
Old 10-25-2007   #9 (permalink)
sanctus's Avatar
Resident Diabolist

Administrator

Location:
Geneva-Bern-Zürich, Switzerland;Oslo,Norway
 
sanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant future
 



Not Ranked  0 score     
Re: abstract C++ question

I know the basics of gdb, so that is not the problem. The problem is that all machines are far away and on mine it takes about 1 hour to get to point where it starts calculating...so I can't try it on the machine that has it installed.

Alex to compile the program there is a makefile and I added the thing for gdb in the makefile:
Code:
FLAGS = -ggdb3 -Wall -DQT_THREAD_SUPPORT  -DPRERELEASE $(WMAPDEFINE)
//ggdb3 added by me
It works fine when not running a montecarlo simulation since then I use my machine. I also tried the following:
when you are, via ssh, on the other machines you usually write
$ qsub -l nodes=9 -l walltime=500:00:00 ./mcrun

to use 9 machines that calculate for 500h. So I tried something like (it calculated so I did it the right way then)
$ gdb qsub -l nodes=9 -l walltime=500:00:00 ./mcrun
$ run

it calculated but since it does not give real errors only try-catch error written by the original coder gdb or not doesn't change much.
Now (I said I know a little gdb, but maybe I exarated) how do I set a breakpoint so that the program stops at a given point (i.e. when the catch error comes)?


----------------
Administrator

A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!


I don't believe in god, but I do believe in what others call utopies.
Reply With Quote
Old 10-25-2007   #10 (permalink)
sanctus's Avatar
Resident Diabolist

Administrator

Location:
Geneva-Bern-Zürich, Switzerland;Oslo,Norway
 
sanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant futuresanctus has a brilliant future
 



Not Ranked  0 score     
Re: abstract C++ question

Now this is what I did:
Code:
$gdb mc_general
(gdb) break fastsplint()
Function "fastsplint()" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (fastsplint()) pending.
(gdb) exec qsub -l nodes=9 -l walltime=500:00:00 ./mcrun
(gdb) run
And then it starts and stops doing anything after:
Code:
Starting program: /usr/bin/qsub 
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0xffffe000
Any idea?


----------------
Administrator

A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!


I don't believe in god, but I do believe in what others call utopies.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Freedom is an Abstract Idea coberst Philosophy Forums 13 08-11-2009 04:10 AM
Justice is an abstract concept coberst Philosophy Forums 1 09-25-2006 03:20 PM
the quantum-gap = limit to abstract thinking UV-gap Philosophy of Science 22 03-07-2006 02:47 PM
Abstract Framework automatic existence Philosophy Forums 2 11-07-2005 08:49 AM
Vote for your favorite ABSTRACT avatar schulme Competitions 2 11-19-2004 02:40 PM

» Advertisement
» Current Poll
Who's the sexiest man alive? Johnny Depp or Robert Pattinson?
Johnny Depp - 27.27%
3 Votes
Robert Pattinson - 0%
0 Votes
Someone else (please specify) - 45.45%
5 Votes
I'm too macho to think a guy is sexy - 27.27%
3 Votes
Total Votes: 11
You may not vote on this poll.


All times are GMT -8. The time now is 06:32 AM.

Hypography?

Hypography [n.]: A combination of "hyperlink" and "bibliography" - ie, a list of links to electronic documents. Comparable to discography and bibliography, but not cartography.

We have been online since May 2000, and aim to be the best place to find and share science-related content of all kinds.

Share the love!

Please add more science to your life. Use our RSS feeds on your blog, your portal, or your favorite feedreader!


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
Copyright © 2000-2009 Hypography
Part of the Hypography - Science for Everyone Network