New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
#2702 (Segmentation violation in icethd_do.F90 with nn_hls=2) – NEMO

Opened 3 years ago

Closed 3 years ago

#2702 closed Defect (fixed)

Segmentation violation in icethd_do.F90 with nn_hls=2

Reported by: acc Owned by: systeam
Priority: low Milestone:
Component: SI3 Version: trunk
Severity: minor Keywords:
Cc:

Description (last modified by nicolasmartin)

Context

The latest trunk is giving me segmentation violations with WED025 and nn_hls=2. The problem line is setting the heat content in this loop:

         ! Heat content
         DO ji = 1, npti
            jl = jcat(ji)                                                    ! categroy in which new ice is put
            zswinew  (ji) = MAX( 0._wp , SIGN( 1._wp , - za_b(ji,jl) ) )   ! 0 if old ice
         END DO

seemingly because jcat is ill-defined. jcat is set earlier in this loop:

         DO jl = 1, jpl
            DO ji = 1, npti
               IF( zh_newice(ji) > hi_max(jl-1) .AND. zh_newice(ji) <= hi_max(jl) ) THEN
                  a_i_2d(ji,jl) = a_i_2d(ji,jl) + za_newice(ji)
                  v_i_2d(ji,jl) = v_i_2d(ji,jl) + zv_newice(ji)
                  jcat(ji) = jl
               ENDIF
            END DO
         END DO

which doesn't guarantee to set jcat for all npti.

Analysis

Setting jcat=0 before this loop avoids the segmentation fault but risks an out-of-bounds on za_b

Recommendation

Ask an expert

Commit History (0)

(No commits)

Change History (5)

comment:1 Changed 3 years ago by acc

  • Summary changed from Segmentation violation in icethd_do.F90 with nn_hls to Segmentation violation in icethd_do.F90 with nn_hls=2

comment:2 Changed 3 years ago by clem

jcat should actually be defined for all npti.
The IF condition is fullfilled for one and only one jl but for all npti locations since zh_newice (i.e. ht_i_new) is defined as non-zero everywhere qlead<0

Mmmmh, the problem comes from this loop?

         DO_2D( 0, 0, 0, 0 )
            IF ( qlead(ji,jj) < 0._wp ) THEN ! cooling
...
               ht_i_new(ji,jj) = MAX( 0.01_wp, MIN( ht_i_new(ji,jj), hi_max(jpl) ) )
            ENDIF
         END_2D
         CALL lbc_lnk( 'icethd_do', zvrel, 'T', 1.0_wp, ht_i_new, 'T', 1.0_wp  )

If qlead is > 0 in the haloes maybe? Is it possible? There may be a problem with the lbc_lnk?

Setting ln_frazil to false should work at least

comment:3 Changed 3 years ago by nicolasmartin

  • Description modified (diff)

comment:4 Changed 3 years ago by acc

Still stuck with this one. Clem is right in that the problem seems to be that qlead is zero everywhere EXCEPT in the haloes which means ht_i_new is not set in the loop he identifies. I've yet to trace a cause.

comment:5 Changed 3 years ago by acc

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

Yay. Clem's changes at changeset:15053 have restored WED025 with nn_hls=2. This ticket can be closed.

Note: See TracTickets for help on using tickets.