Division by zero!!!

Report or discuss software problems and other woes

Moderators: arango, robertson

Post Reply
Message
Author
fancer
Posts: 45
Joined: Fri Feb 06, 2009 5:20 pm
Location: NNSTU, The Nizhniy Novgorod State Technical University named after R.E.Alekseev, Russia

Division by zero!!!

#1 Unread post by fancer »

Hi, all!)))
I compiling ROMS and SWAN coupling application with mpif90 (I use Linux with gfrotran, but MCT did not support gfortran for Linux, but mpif90 ok - may be I wrong, but this wrote in README).
And then I build my application, arising next error:

cd Build; /usr/local/mpich2/bin/mpif90 -c -frepack-arrays -ffree-form -ffree-line-length-none -g -fbounds-check -I/root/program_files/ROMS/roms3/MCT/include ocean_coupler.f90
ocean_coupler.f90:436.32:

IF (A(i).eq.1.0_r8/0.0_r8) THEN
1
Error: Division by zero in (1)
ocean_coupler.f90:438.17:

END IF
1
Error: Expecting END DO statement at (1)
make: *** [Build/ocean_coupler.o] Error 1

In ocean_coupler.f90:
CASE ('Wlen') ! wave length
CALL AttrVect_exportRAttr (wav2ocn_AV, TRIM(code), A, Asize)
Iimport=Iimport+1
DO i=1,Asize
A(i)=MAX(0.0_r8,A(i))
IF (A(i).eq.1.0_r8/0.0_r8) THEN
A(i)=Lwave_max
END IF
END DO
scale=1.0_r8 ! m
add_offset=0.0_r8
CALL ROMS_import2d (ng, tile, &
& id, gtype, scale, add_offset, &
& Asize, A, &
& IstrR, IendR, JstrR, JendR, &
& LBi, UBi, LBj, UBj, &
& Fields(id)%ImpMin, Fields(id)%ImpMax, &
& FORCES(ng)%Lwave, &
& status)

And no one about this error in search)))
Where I wrong or this ROMS bug?

jcwarner
Posts: 1172
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: Division by zero!!!

#2 Unread post by jcwarner »

some compilers dont seem to be able to handle this.
go ahead and just comment out that line.

fancer
Posts: 45
Joined: Fri Feb 06, 2009 5:20 pm
Location: NNSTU, The Nizhniy Novgorod State Technical University named after R.E.Alekseev, Russia

Re: Division by zero!!!

#3 Unread post by fancer »

Thanks for help))))

liangliang
Posts: 61
Joined: Mon Jul 20, 2009 2:41 pm
Location: Port And Costal Engineering Laboratory

Re: Division by zero!!!

#4 Unread post by liangliang »

I have the same trouble.
If i comment out the line ,whether will it have a bad effect on the model running.

jcharris
Posts: 17
Joined: Fri Aug 14, 2009 9:30 pm
Location: University of Rhode Island

Re: Division by zero!!!

#5 Unread post by jcharris »

If I understand the situation, I have experienced this as well with gfortran 4.5.0 (20090604; experimental; trunk rev. 148180). Commenting the statement in Master/mct_roms_swan.h does fix the problem, and does not cause any problems during the simulation. However, post-processing may have an issue, depending on what you have SWAN output -- the statement prevents a +Infinity from appearing. When I have it create a Matlab output file (SWAN layout type 4) of the average wavelength, SWAN crashes. For compilers which cannot handle 1.0_r8/0.0_r8, a different form of the expression may be required.

[Although I have not thought it through, perhaps A(i)=MIN(Lwave_max,A(i)) would work?]

abever
Posts: 23
Joined: Tue Feb 17, 2004 6:15 pm
Location: Anchor QEA, LLC

Re: Division by zero!!!

#6 Unread post by abever »

If I remember correctly, I did the above fix at one point and it worked fine.

Post Reply