Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run time error 2

Status
Not open for further replies.

armeros

Programmer
Aug 26, 2014
23
AU
Hi guys,

Perhaps I need some help again. My program can compile but it generate run time error.
The message is

"C:\Console1\Console1\Debug\Console1.exe is not a valid Win32 application"

When I reduce the number of elements in arrays, it said

image-E57A_540184DF.jpg


What is the bug I should look for ?

Thanks a lot.
 
The error message seems pretty clear to me.

You have an array R which has at least 1 dimension, maybe 2 or 3, it does not matter because the error message is telling you that the problem is with the first dimension.

It says that you have declared the first dimension to have a maximum allowed index value of 2, yet, the index being passed to R and the reason why the program stopped, is 3.

So, look for place where you call R and inspect the value of the index in the first dimnension; you do that by simply adding write statements before call to R, just make sure you flush the output channel otherwise the data will be left in the queue.
 
I am wondering what R is. My program does not contain the array of such name. I did have array "r" (small r, not R) with one dimension, two elements, i.e., a vector of 2 elements. However, I will try to look for it. Thanks for the suggestion.

 
Oh goshhhh

salgerman , you are absolutely amazing!

By the way, what about "not a valid Win32 application" ?

When I declare A(48,48,2,48,48,48) it has this error.
But when I declare A(20,20,2,20,20,20) it can run.

What could it be ?

I'd like to thank you for your suggestion in this and the previous post. It works!
 
Fortran is case-insensitive, by the way, so r and R are the same thing.

Sounds like a memory problem.

20*20*2*20*20*20 = 6.4MB
48*48*2*48*48*48 = 509MB

what's your computer's RAM? And remeber, not all is available to you, MS-Windows alone takes a good chunk, plus every other program, browsers, etc.

 
Oh, sorry, I forgot to multiply the numbers above by the size of the type of A.

is A an integer or real?

I think integers are 4-bytes long and reals 8-bytes long...if A is real, multiply the numbers above times 8...do you have 4GB of RAM? available to be used?
 
I have 6 GB of rams, but it still cannot run when I declared that high.
 
If you're compiling 32-bit then the max size will be 2Gb. Are you using a 32 or 64 bit OS? I know you have 6Gb RAM but that doesn't imply you are running a 64bit OS. Is your program built for 32 or 64 bit? It defaults to WIN32 which is 32 bit. It will be x64 for 64bit.
 
This message from the first post
"C:\Console1\Console1\Debug\Console1.exe is not a valid Win32 application"
says, that it's 32-bit.
 
mikrom,

I used your suggestion, and it can run, but it takes time so long that I wonder if it is still running. When I do (30,30,2,30,30,30) (AND I DID NOT USE MULTIDIMENSIONal ARRAYS!), each loop is about 4 seconds. When I do (250,250,2,250,250,250), the first loop takes 1 hour and it still does not finish.
 
It seems I have to find a better way to write the code. The loop takes more than 1, maybe 2 or 3, to complete. In the less elements version, it took 160 loops to finish. It will be more than 6 days and I can't wait that long since this is only the first part of the code.
 
Are you using any kind of parallel processing? I have done it once before, it is pretty trivial to implement and reduces real running time several times. Look into OpenMP.
 
Are you using any kind of parallel processing?

No, and I heard that it is quite complicated ? I will take a look at OpenMP tomorrow and see what it is. Does it require an installation of other softwares ?

Thanks for all helps here.
 
At the time of my parallel processing needs, I was initially using G95 when I read it does not support OpenMP. G95 does support something called co-arrays; but, to make use of that, you really need to write your program in a different way...said another way, you would need to re-write an existing program.

GFortran does support OpenMP out of the box, at least on Linux; for Windows, you may have to fetch a separate download.

So, you first need to find out if your compiler supports OpenMP; if so, great, if not you may need to consider switching compilers...that's what I did.

The nice thing about OpenMP is that you do NOT need to re-write an existing program to make use of it. OpenMP directives are placed behind regular Fortran comments to the point that if the compmiler being used does not support OpenMP, the directives stay out of the way and the program compiles and runs normally in just one CPU.

Needless to say, you need to make sure that your loops can be executed in parallel, in the first place; meaning, calculations for a given iteration shouldn't need values that need to be calculated in another iteration...said another way, your loops shouldn't need to run sequentially, in some order; instead, loops should be able to be run in any order.

If it almost as you yourself made 5 copies of your program and then modify each copy to alter the outer loop so that instead of going from 1 to 250, it goes from 1-50 in one copy, 51-100 in the next, 101-150...you get the picture; then you can run your program in any order, generate the matrix, write it disk and glue it back together after the fact...OpenMP would do that for you without you having to make copies of your program or modifying your one set of nested loops...OpenMP will take care of it.

 
I use Intel Visual Fortran Compiler(it runs under Microsoft Visual Studio 2008). My computer is 32-bit, Windows 7.


However, I need help from IMSL libraries. I don't know how to incorporate the libraries in GFortran. (For GFortran, I used Geany compiler.)
 
zI tried to read these two links and it is still not clear to me how I can use openMP with my compilers.

[URL unfurl="true"]https://software.intel.com/sites/products/documentation/doclib/stdxe/2013/composerxe/compiler/fortran-mac/GUID-0E85F327-A19E-410C-8203-0A89C8F32635.htm[/url]

[URL unfurl="true"]https://software.intel.com/en-us/articles/how-to-use-intelr-compiler-openmp-compatibility-libraries-on-windows[/url]

Suppose I have pararell loops,

Code:
DO i=1,250
                DO j = 1,250
                  DO ii=1,2
                  ................................
                  ................................
                   DO k = 1,250
                     DO  = 1,250
                     .............................
                     .............................
                     END DO
                  END DO
                END DO
               END DO
             END DO

Could you please give me suggestion how to do this ?

Thank you very much.
 
I should be more specific about pseudo code

Code:
PROGRAM test
IMPLICIT NONE
REAL, PARAMETERS :: a,b,c
REAL, DIMENSION (250,250,2,250,250,250) :: X,Y
DO i=1,250
                DO j = 1,250
                  DO ii=1,2
                  ................................
                  ................................
                   DO k = 1,250
                     DO l = 1,250
                     .............................
                     .............................
                     END DO
                  END DO
                END DO
               END DO
             END DO 
END PROGRAM test
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top