Ran into an issue:IEEE_INVALID_FLAG, IEEE_DIVIDE_BY_ZERO

Report or discuss software problems and other woes

Moderators: arango, robertson

Post Reply
Message
Author
tao
Posts: 22
Joined: Tue Aug 13, 2024 3:09 pm
Location: south China university of technology

Ran into an issue:IEEE_INVALID_FLAG, IEEE_DIVIDE_BY_ZERO

#1 Unread post by tao »

Hello everyone,

I’m encountering a confusing error. I initially built an inaccurate model, so I replaced the original grid, ini file, obc file, and tide file. However, I encountered the following error right at the first step of running the model:

Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG, IEEE_DIVIDE_BY_ZERO

To address this issue, I have tried the following:

Checked each input file carefully and found no NaN values

Reduced DT to 50/10

Increased NDTFAST to 40

Set all boundaries to clo

Removed the tide and station sections from the .h file and recompiled

Unfortunately, none of these attempts resolved the problem.
I’m attaching my run log, .in file, and .h file below. I would really appreciate any suggestions you might have. :D

Apologies if my English is not very good, and I hope I haven’t caused any offense.
Attachments
log.txt
(60.27 KiB) Downloaded 43 times
Last edited by tao on Sat May 31, 2025 2:08 am, edited 1 time in total.

User avatar
wilkin
Posts: 934
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: Ran into an issue:IEEE_INVALID_FLAG, IEEE_DIVIDE_BY_ZERO

#2 Unread post by wilkin »

Estimated maximum CFL values U∆t/∆x for u,v,w velocity are reported in the log as Cu,Cv,Cw. At the start of your run,
Cv = NaN so you have v velocity values that are NaN (in your initial conditions) which via continuity equation make w also NaN. You
cannot have NaN values in initial (or boundary) conditions, even in the land. ROMS computes on the land values and
then masks them out by multiplying by zero, but NaN times zero is NaN. You need to ensure there are no NaN in the
initial conditions.

Code: Select all

TIME-STEP YYYY-MM-DD hh:mm:ss.ss  KINETIC_ENRG   POTEN_ENRG    TOTAL_ENRG    NET_VOLUME
                     C => (i,j,k)       Cu            Cv            Cw         Max Speed

         0 2022-01-01 00:00:00.00           NaN           NaN           NaN           NaN
                     (350,067,35)  1.582168E-02  2.485128E-02  0.000000E+00  1.742121E+00
 Found Error: 01   Line: 321      Source: ROMS/Nonlinear/main3d.F
 Found Error: 01   Line: 298      Source: ROMS/Drivers/nl_roms.h, ROMS_run
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

tao
Posts: 22
Joined: Tue Aug 13, 2024 3:09 pm
Location: south China university of technology

Re: Ran into an issue:IEEE_INVALID_FLAG, IEEE_DIVIDE_BY_ZERO

#3 Unread post by tao »

wilkin wrote: Wed May 28, 2025 2:22 pm Estimated maximum CFL values U∆t/∆x for u,v,w velocity are reported in the log as Cu,Cv,Cw. At the start of your run,
Cv = NaN so you have v velocity values that are NaN (in your initial conditions) which via continuity equation make w also NaN. You
cannot have NaN values in initial (or boundary) conditions, even in the land. ROMS computes on the land values and
then masks them out by multiplying by zero, but NaN times zero is NaN. You need to ensure there are no NaN in the
initial conditions.

Code: Select all

TIME-STEP YYYY-MM-DD hh:mm:ss.ss  KINETIC_ENRG   POTEN_ENRG    TOTAL_ENRG    NET_VOLUME
                     C => (i,j,k)       Cu            Cv            Cw         Max Speed

         0 2022-01-01 00:00:00.00           NaN           NaN           NaN           NaN
                     (350,067,35)  1.582168E-02  2.485128E-02  0.000000E+00  1.742121E+00
 Found Error: 01   Line: 321      Source: ROMS/Nonlinear/main3d.F
 Found Error: 01   Line: 298      Source: ROMS/Drivers/nl_roms.h, ROMS_run
Dear Mr. Wilkin,

Thank you very much for your kind response. Unfortunately, I had already verified this issue earlier. I used the following MATLAB script to check all of my NetCDF files, and the results showed that there are no NaN values in them. I believe the error must be caused by something else, but I have no clue what it might be.

Thank you again for your help. :D
Attachments
find_nan.m
(707 Bytes) Downloaded 26 times

User avatar
arango
Site Admin
Posts: 1383
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: Ran into an issue:IEEE_INVALID_FLAG, IEEE_DIVIDE_BY_ZERO

#4 Unread post by arango »

Check your bathymetry. It cannot be zero, since the governing equations involve division by it. There is an issue with your configuration or grid.

User avatar
wilkin
Posts: 934
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: Ran into an issue:IEEE_INVALID_FLAG, IEEE_DIVIDE_BY_ZERO

#5 Unread post by wilkin »

I agree with Hernan that there might be a problem with your grid. The TOTAL VOLUME is reported as NaN at initialization, so there must be a cell where ∆x*∆y*(h+zeta) is NaN. You have WET_DRY defined, so this should have taken care of any h=0, and min(∆z) on water points is > 0.

But do you really want WET_DRY in a grid with ~7 km resolution? If not, you might save yourself a lot of trouble by setting h = some constant (positive) value in the land mask, and #undef WET_DRY.

Your XI and ETA grid spacings vary very little, suggesting the grid is almost rectangular, and DNDX is very small. But the min DMDE is very large at -4.

Code: Select all

 GET_GRID_NF90    - reciprocal XI-grid spacing: pm
                      (Grid = 01, File: scs_2022_grid.nc)
                      (Min =  1.15250738E-04 Max =  1.30760506E-04)
  GET_GRID_NF90    - reciprocal ETA-grid spacing: pn
                      (Grid = 01, File: scs_2022_grid.nc)
                      (Min =  1.08936005E-04 Max =  1.40130211E-04)
  GET_GRID_NF90    - XI-derivative of inverse metric factor pn: dndx
                      (Grid = 01, File: scs_2022_grid.nc)
                      (Min = -9.47014087E-07 Max =  9.29923772E-07)
  GET_GRID_NF90    - ETA-derivative of inverse metric factor pm: dmde
                      (Grid = 01, File: scs_2022_grid.nc)
                      (Min = -4.58576771E+00 Max =  0.00000000E+00)
I notice you have some boundary condition temperatures and salinity = 0, so you might check that also.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

tao
Posts: 22
Joined: Tue Aug 13, 2024 3:09 pm
Location: south China university of technology

Re: Ran into an issue:IEEE_INVALID_FLAG, IEEE_DIVIDE_BY_ZERO

#6 Unread post by tao »

Thank you both very much for your kind help. I checked the grid file and, as expected, found the presence of zeros. I will proceed to modify the file. Thanks again! :D

tao
Posts: 22
Joined: Tue Aug 13, 2024 3:09 pm
Location: south China university of technology

Re: Ran into an issue:IEEE_INVALID_FLAG, IEEE_DIVIDE_BY_ZERO

#7 Unread post by tao »

Sadly, I tried modifying my grid file and the h file today, and also made corresponding changes to other related files. However, the error still hasn't gone away. That said, I believe the cause of the error lies within the grid. This is my grid file—hopefully the issue can be identified.

User avatar
wilkin
Posts: 934
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: Ran into an issue:IEEE_INVALID_FLAG, IEEE_DIVIDE_BY_ZERO

#8 Unread post by wilkin »

I suggest you try setting h = 10 where mask_rho = 0 and #undef WET_DRY. You have very small (10^-4) values of h in the land that might cause trouble.

I notice that your land/sea mask is such that the Malaysia Peninsula connects to the southern boundary. The Singapore Strait is closed.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

tao
Posts: 22
Joined: Tue Aug 13, 2024 3:09 pm
Location: south China university of technology

Re: Ran into an issue:IEEE_INVALID_FLAG, IEEE_DIVIDE_BY_ZERO

#9 Unread post by tao »

wilkin wrote: Fri May 30, 2025 3:23 pm I suggest you try setting h = 10 where mask_rho = 0 and #undef WET_DRY. You have very small (10^-4) values of h in the land that might cause trouble.

I notice that your land/sea mask is such that the Malaysia Peninsula connects to the southern boundary. The Singapore Strait is closed.
Thank you very much, Mr. Wilkin. After following your suggestions, the model started running properly. I would also like to thank Mr. arango who pointed out the issue. I truly appreciate your kind help and valuable advice. Wishing you a happy Dragon Boat Festival! :D

Post Reply