I have not used C++ for about 4 yrs, and only recently I hav picked it up again while doing my research on molecular dynamics for my graduate studies. I am using VISTA business with dev-C++ 4.9.9.2. Understanding that there are problems using VISTA with dev-C++, I have made the necessary corrections as posted by other users in the forum.
My prob is this: I hav managed to compile my prog, with no bugs, and run it. But the .exe screen does not show the expected output. I am not sure if my code is wrong, or due to some other problems.
The code runs normally, but you are right that you just get a blank screen, (or rather that it does not output anything for a very long time). I simply inserted a print statement in the loop where velocityVerlet(dt) is called. It them becomes obvious that whatever that function takes significant time. On my machine I got about 10 iterations a second. Of course with your full code, it may take longer. You may want to reconsider your algorithm or just accept that it takes a long time to compute and use some sort of progress reporting output.
As it happens it did not matter whether it did 10 to 1000 iterations, the answer was always 1.0, so I guess this does not work (although that may be because you cut it down of course).
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
>> But the .exe screen does not show the expected output.
Do you get "unexpected" output or "no" output. I assume teh latter from the thread title. This is the most common problem people report with Dev-C++ and is consequently dealt with in the "PLEASE READ BEFORE POSTING A QUESTION" which I assume that you read if you solved the Vista issue?
It is not really a Dev-C++ problem (or even a problem at all). It is simply that when a program terminates, its windows is closed by the operating system. All programs on Windows work that way, but people are still surprised when it happens to their own programs! ;-)
Ultimately the solution is to make your program wait for input, or make your program run in an environment that waits for input after your program terminates. You might imagine that Dev-C++ would do this for you, but it does not, and we have been answering this same query it seems like forever. As you can tell, it is a quiet day for me today do you are getting the long helpful answer rather that usual terse flame for not reading the read-first thread.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Clifford, I appreciate your prompt help, and your time and effort put in.
I understand what you mean in your reply: that the program will terminate and the output screen will disappear after only a brief (less than 1 second) moment. That can be solved by asking for an input from the user / to simulate a DOS system pause. But this is not the problem I encountered. I have to apologise for the lack of details given in my first post.
What happens is that the black output screen will appear, and in it, there is only a blinking cursor. This seems like it is expecting an input from the user, but when i type in something, the output screen does not show it.
Below is a similar case from another user in another site:
<<Hello!
I am a beginner and I downloaded Dev-C++ for a class. However, it won't compile & run the programs, even the simplest "Hello, World" code. With some codes that I write, if I just run it (not compile & run), a blank screen pops up with a blinking cursor---however, it won't let me type/do anything on that screen. With the "Hello, World" program, it won't compile and down at the bottom it says, "The system cannot find the file specified."
What can I do to solve this? Any help would be greatly appreciated.>>
In that site, initially everyone interprets the above problem to be like what you have interpreted. But eventually nobody knows how to tackle the problem. My case is slightly different in that the program is still compiled with zero errors. Even the .exe file is created, but the compile log states that the execution is terminated.
I have read the "PLEASE READ..". There is a possibility that my code is at fault, but I have rechecked it a few times. I hope to get some professional comments around here if this might be (1) installation problem, (2) configuration problem (3)still a VISTA problem (4) some others. By eliminating these, I can narrow down the possibilities.
Once again, I thank you for your help.
Jarvis
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Does the executable run correctly if you run it directly from the command line or from Explorer rather than launching it from Dev-C++?
Given the other path issues in Vista, I would suggest setting the full executable path in:
Project|Project options|Build options|Override output file name
... just to make sure Vista knows where to find your executable.
Personally, given all this nonsense with Vista I would accept that Dev-C++ has had its day and use VC++ 2008 Express or if you have a lot of Dev-C++ legacy, wxDev-C++ (which I believe works better under Vista, but may not solve your problem).
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi.. Clifford, I hav tried your suggestion, but I still get the same problem.. Suspecting it could be my prog's at fault, i deleted/modified some of the subroutines, and the program is as below.. Can help me run the following, and check if u will get a blank output screen too? Thanks in advance..
I have not used C++ for about 4 yrs, and only recently I hav picked it up again while doing my research on molecular dynamics for my graduate studies. I am using VISTA business with dev-C++ 4.9.9.2. Understanding that there are problems using VISTA with dev-C++, I have made the necessary corrections as posted by other users in the forum.
My prob is this: I hav managed to compile my prog, with no bugs, and run it. But the .exe screen does not show the expected output. I am not sure if my code is wrong, or due to some other problems.
The compile log is as below:
Compiler: Default compiler
Executing c:\ProgramFiles\Dev-Cpp\Bin\g++.exe...
c:\ProgramFiles\Dev-Cpp\Bin\g++.exe "C:\Users\Jarvis\Desktop\Version 2.cpp" -o "C:\Users\Jarvis\Desktop\Version 2.exe" -I"C:\ProgramFiles\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\ProgramFiles\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\ProgramFiles\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\ProgramFiles\Dev-Cpp\include\c++\3.4.2" -I"C:\ProgramFiles\Dev-Cpp\include" -L"C:\ProgramFiles\Dev-Cpp\lib"
Execution terminated
Compilation successful
Please kindly point out me if the information I hav provided is insufficient. I appreciate the help.
The code runs normally, but you are right that you just get a blank screen, (or rather that it does not output anything for a very long time). I simply inserted a print statement in the loop where velocityVerlet(dt) is called. It them becomes obvious that whatever that function takes significant time. On my machine I got about 10 iterations a second. Of course with your full code, it may take longer. You may want to reconsider your algorithm or just accept that it takes a long time to compute and use some sort of progress reporting output.
As it happens it did not matter whether it did 10 to 1000 iterations, the answer was always 1.0, so I guess this does not work (although that may be because you cut it down of course).
Clifford
I have to apologise, for forgetting to put down my name at the end of the last post.
Jarvis
>> But the .exe screen does not show the expected output.
Do you get "unexpected" output or "no" output. I assume teh latter from the thread title. This is the most common problem people report with Dev-C++ and is consequently dealt with in the "PLEASE READ BEFORE POSTING A QUESTION" which I assume that you read if you solved the Vista issue?
It is not really a Dev-C++ problem (or even a problem at all). It is simply that when a program terminates, its windows is closed by the operating system. All programs on Windows work that way, but people are still surprised when it happens to their own programs! ;-)
As well the advice in the read-first thread I recently (in fact just a couple of days ago so you might have read it) posted this https://sourceforge.net/forum/forum.php?thread_id=2002182&forum_id=48211 which contains some more advanced solutions which you might prefer.
Ultimately the solution is to make your program wait for input, or make your program run in an environment that waits for input after your program terminates. You might imagine that Dev-C++ would do this for you, but it does not, and we have been answering this same query it seems like forever. As you can tell, it is a quiet day for me today do you are getting the long helpful answer rather that usual terse flame for not reading the read-first thread.
Clifford
Clifford, I appreciate your prompt help, and your time and effort put in.
I understand what you mean in your reply: that the program will terminate and the output screen will disappear after only a brief (less than 1 second) moment. That can be solved by asking for an input from the user / to simulate a DOS system pause. But this is not the problem I encountered. I have to apologise for the lack of details given in my first post.
What happens is that the black output screen will appear, and in it, there is only a blinking cursor. This seems like it is expecting an input from the user, but when i type in something, the output screen does not show it.
Below is a similar case from another user in another site:
<<Hello!
I am a beginner and I downloaded Dev-C++ for a class. However, it won't compile & run the programs, even the simplest "Hello, World" code. With some codes that I write, if I just run it (not compile & run), a blank screen pops up with a blinking cursor---however, it won't let me type/do anything on that screen. With the "Hello, World" program, it won't compile and down at the bottom it says, "The system cannot find the file specified."
What can I do to solve this? Any help would be greatly appreciated.>>
In that site, initially everyone interprets the above problem to be like what you have interpreted. But eventually nobody knows how to tackle the problem. My case is slightly different in that the program is still compiled with zero errors. Even the .exe file is created, but the compile log states that the execution is terminated.
I have read the "PLEASE READ..". There is a possibility that my code is at fault, but I have rechecked it a few times. I hope to get some professional comments around here if this might be (1) installation problem, (2) configuration problem (3)still a VISTA problem (4) some others. By eliminating these, I can narrow down the possibilities.
Once again, I thank you for your help.
Jarvis
Hmmmm....
Does the executable run correctly if you run it directly from the command line or from Explorer rather than launching it from Dev-C++?
Given the other path issues in Vista, I would suggest setting the full executable path in:
... just to make sure Vista knows where to find your executable.
Personally, given all this nonsense with Vista I would accept that Dev-C++ has had its day and use VC++ 2008 Express or if you have a lot of Dev-C++ legacy, wxDev-C++ (which I believe works better under Vista, but may not solve your problem).
Clifford
Hi.. Clifford, I hav tried your suggestion, but I still get the same problem.. Suspecting it could be my prog's at fault, i deleted/modified some of the subroutines, and the program is as below.. Can help me run the following, and check if u will get a blank output screen too? Thanks in advance..
include <stdio.h>
include <cmath>
using namespace std;
double L=1000;
const int N=1000;
double r[N][3];
double v[N][3];
double a[N][3];
int main(void) {
void initialize(void);
void velocityVerlet(double);
initialize();
double dt=0.001;
for (int m=0;m<1000;m++) {
velocityVerlet(dt);
}
printf("The velocity is %f. \n", v[1][1]);
return 0;
}
void initialize() {
int n=int(ceil(pow(N,1.0/3)));
double d=L/n;
int p=0;
for (int x=0;x<n;x++) {
for (int y=0;y<n;y++) {
for (int z=0;z<n;z++) {
if (p<N) {
r[p][0]=(x+0.5)d;
r[p][1]=(y+0.5)d;
r[p][2]=(z+0.5)*d;
}
++p;
}
}
}
for (int p=0;p<N;p++) {
for (int i=0;i<3;i++)
v[p][i]=1;
}
}
void computeAcceleration() {
for (int i=0;i<N;i++) {
for (int k=0;k<3;k++)
a[i][k]=0;
}
for (int i=0;i<N-1;i++) {
for (int j=i+1;j<N;j++) {
double rij[3];
double rSqd=0;
for (int k=0;k<3;k++) {
rij[k]=r[i][k]-r[j][k];
rSqd+=rij[k]rij[k];
}
double f=24(2pow(rSqd,-7)-pow(rSqd,-4));
for (int k=0;k<3;k++) {
a[i][k]+=rij[k]f;
a[j][k]-=rij[k]*f;
}
}
}
}
void velocityVerlet(double dt) {
computeAcceleration();
for (int i=0;i<N;i++) {
for (int k=0;k<3;k++) {
r[i][k]+=v[i][k]dt+0.5a[i][k]dtdt;
v[i][k]+=0.5a[i][k]dt;
}
}
}
I know it doesn't sound or look right anymore, because of the deleting, but it can compile with the following log:
Compiler: Default compiler
Executing c:\ProgramFiles\Dev-Cpp\Bin\g++.exe...
c:\ProgramFiles\Dev-Cpp\Bin\g++.exe "C:\Users\Jarvis\Desktop\VERSION.cpp" -o "C:\Users\Jarvis\Desktop\VERSION.exe" -I"C:\ProgramFiles\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\ProgramFiles\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\ProgramFiles\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\ProgramFiles\Dev-Cpp\include\c++\3.4.2" -I"C:\ProgramFiles\Dev-Cpp\include" -L"C:\ProgramFiles\Dev-Cpp\lib"
Execution terminated
Compilation successful
Thanks!