Ticket #657 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

hyp2000 has a degenerate condition that causes an infinite loop

Reported by: paulf Owned by: fred and paul
Priority: major Milestone:
Component: hyp2000 Version:
Keywords: Cc:

Description

there is a rare case encountered at HVO where the code drops into an infinite loop. You will see a message similar to below:

Starting program: /home/paulf/usbor/earthworm_svn/bin/hyp2000 
 HYPOINVERSE 2000 STARTING
4/2018 VERSION 1.42 (CRE bug fix)                                     
 COMMAND? @data/z61708811_79.cmd
  1524 STATIONS READ IN.
     1 STATION DELAYS SET FOR MODEL  1
     1 STATION DELAYS SET FOR MODEL  2
 *** STOP ITERATING EVENT 2018  5 14 23  4 BECAUSE DISTANCE TO SECOND CLOSEST
 *** STATION CERB -AV-SHZ IS10000. & EXCEEDS  250. KM.
 *** ORIGIN TIME SHIFT LIMITED TO 4 MIN. IN EVENT2018  5 14 23  4

The program must be C to exit after that last line.

Change History

comment:1 Changed 7 months ago by baker

  • Status changed from new to closed
  • Resolution set to fixed

Paul found the error only occurs when the HVO trial hypocenter is supplied. He also found that Function DIS() was returning NaN in Subroutine HYLST, where the infinite loops occurs.

I enabled floating-point traps with abort for invalid operands, divide-by-zero, and overflow. I found a divide-by-zero in Subroutine HYLOC.

HYLOC assumes the current hypocenter is below the surface, i.e., not an "air quake". It tests the proposed hypocenter Z value, Z + dZ, against the maximum elevation (ELEVMAX, actually negative depth). If the proposed Z value is an "air quake" (Z + dZ < -ELEVMAX), HYLOC assumes that is because dZ has pushed the hypocenter from below the surface to above the surface. It scales the proposed hypocenter dX, dY, and dZ by a term which includes ( 1 / dZ ). If the current Z is below the surface (Z1 >= -ELEVMAX), then dZ of necessity must be negative to push the proposed Z above the surface. However, when the error occurs, dZ is zero; it is the current Z value that is above the surface. Thus, Z + dZ < -ELEVMAX, but not because dZ is negative; it is zero. Because the current Z violates the HYLOC prerequisite that the current hypocenter Z location is below the surface, that dZ must be negative (therefore, non-zero) to push the proposed hypocenter above the surface is an invalid assumption, and the divide-by-zero results.

There are two places in Subroutine HYTRA where ELEVMAX is set for the next iteration from the models being used. The bug is that in only one of those code paths (when multiple models are being used) is the Z value of the current hypocenter adjusted to -ELEVMAX if it is out-of-bounds (an "air quake"). The AVO trial hypocenter depth was out-of-bounds for one model, but not all models. When the model being used for the next iteration followed the alternate (single model) code path, and the current Z value was out-of-bounds for that model, the current Z value was not adjusted to -ELEVMAX. That caused the divide-by-zero in HYLOC, resulting in an IEEE Infinity, which led to the IEEE NaN distances, which led to the infinite loop in the distance sort for the station printout.

The fix is to adjust the current hypocenter Z value, as necessary, in both code paths in HYTRA after ELEVMAX is assigned a new value.

Fixed in r7452.

Note: See TracTickets for help on using tickets.