CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Big loop problem of fortran (https://www.cfd-online.com/Forums/main/7355-big-loop-problem-fortran.html)

Wen Long March 28, 2004 23:34

Big loop problem of fortran
 
Hi, friends:

I'd like to get your advice on a mysterious problem. I have a code running ocean wave boundary layer simulation. And I'm running for 1-day realization, with time step about 0.1 sec, which I have about 864000 time steps to march in a big loop.

It runs okay on my linux PC but pretty slow. Then I turned to an SGI origion 300 with 4 CPU's in order to get results faster. Problem being it stops somewhere around 100,000 timesteps, without any error info.

I suspected it might be size of integer has a limit for loop index?

Please help me, thanks a lot

Wen


dominik March 29, 2004 08:01

Re: Big loop problem of fortran
 
first of all if your code cannot take adventage of multiprocessor machine your code will not be faster.

secondly, it can be many things... checking sizes/ranges of floating/int variables is good to start with

then the fortran compiler is differnt i guess. if e.g. you run your code on your pc using gnu see if gnu is not available on SGI too.

then, write some log file on the fly to debug easier. success!

Praveen March 29, 2004 08:48

Re: Big loop problem of fortran
 
I have experienced situations when my codes run on linux but doesnt on SGI. In all cases there was a bug in the code. Check to see that you are not exceeding your array sizes.

Jarmo Monttinen March 29, 2004 11:14

Re: Big loop problem of fortran
 
Or this could be a memory issue, ie. if you use MPI you may need to define some memory parameters. The only way I can see this being the problem though is if you save a bunch of data each time-step, some of that in the memory. But it's more likely a bug, as all compilers are slightly different. A quick check could be to compile with -O3 for maximum optimization, this has sometimes helped me to discover a bug as the optimized code does something completely different than it is supposed to do.

-- Jarmo

Wen Long March 29, 2004 11:30

Re: Big loop problem of fortran
 
Hi, dominik,Praveen and Jarmo:

Thanks a lot,

I did find a array bound exceeding bug after using both -O3 and -check_bounds option in compile, and fixed it. But the problem still persists. It's usual f77 code, no MPI things are used.

One thing I'm not familiar with SGI is that, when I run the code, the gr_top command will show me that 4 copies/threads of the code are running at the same time, and there is one at the status of sleep, when the code becomes idle. Anything wrong with the 4 CPU?

Thanks again,

wen

Wen Long March 29, 2004 11:34

Re: Big loop problem of fortran
 
Thanks, dominik:

I found g77 on that machine too, and trying that out today.

Wen

Jarmo Monttinen March 29, 2004 13:18

Re: Big loop problem of fortran
 
Going back to Dominik's message:

How is the code parallelized if you are not using MPI? This might be the problem.

See if it runs with just one processor on the SGI.

-- Jarmo

matej March 30, 2004 02:34

Re: Big loop problem of fortran
 
Wen,

I guess you are using the 'apo' (autoparallelisation) switch to make your code parallel??

If it is the case, you might need to use some directives is a source code. The apo is not that clever as it sounds.

For finding another problems try ftncheck program for finding errors in the code. It's saving me hours every day. http://www.dsm.fordham.edu/~ftnchek/

Matej

Wen Long April 1, 2004 11:48

Re: Big loop problem of fortran(monster found)
 
Thanks, all your inputs add to my experience of debugging.

After careful debugging, I found the bug. I have a variable t accumulating time with very little step, like t=t+dt, while dt=1.e-4(sec) or so.. Turns out that when t is sufficiently large, say 1/3 day, then the rounding error of float addition will actually do nothing to t, which I used to jump out of loop, since t never changes beyond 1/3 day, it goes like a dead loop spinning. Ha, fancy that,

Wen


Jarmo Monttinen April 1, 2004 12:38

Re: Big loop problem of fortran(monster found)
 
Don't you just love computers :)

But, congratulations for finding it. That didn't even take that long! I guess this is a good example why we should stick with double precision.

-- Jarmo


All times are GMT -4. The time now is 12:59.