Skip to content

Commit

Permalink
Fix to icepack warning strings
Browse files Browse the repository at this point in the history
Comments out bgc aborts that could just be warnings
Fixes icepack setaborts subroutine to "add" warning strings
Fixes missing "add" to some bgc warning messages
Avoids division by small number in update vertical bio tracers

Code was seg faulting with debug_compile=true around icepack write statements
  • Loading branch information
njeffery committed Mar 28, 2024
1 parent 8934f44 commit c090b4b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 17 deletions.
57 changes: 44 additions & 13 deletions columnphysics/icepack_algae.F90
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ subroutine zbio (dt, nblyr, &
call icepack_warnings_add(warnstr)
enddo
endif
call icepack_warnings_add(warnstr)
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
!call icepack_warnings_add(warnstr)
!call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//" zbio: Carbon conservation failure after z_biogeochemistry")
endif

Expand Down Expand Up @@ -674,7 +674,7 @@ subroutine skl_biogeochemistry (dt, &
nn,nbtrcr,cinit(nn)
call icepack_warnings_add(warnstr)
call icepack_warnings_add(subname//' cinit < c0')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
!call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
return
endif
enddo ! nbtrcr
Expand Down Expand Up @@ -798,7 +798,7 @@ subroutine skl_biogeochemistry (dt, &
write(warnstr,*) subname, 'congel, meltb: ',congel,meltb
call icepack_warnings_add(warnstr)
call icepack_warnings_add(subname//' N not conserved in skl_bgc')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
!call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
elseif (cinit(nn) < c0) then
write(warnstr,*) subname, 'sk_bgc < 0 after algal fluxes, nn,cinit,flux_bio',&
nn,cinit(nn),flux_bio(nn)
Expand All @@ -811,7 +811,7 @@ subroutine skl_biogeochemistry (dt, &
write(warnstr,*) subname, 'congel, meltb: ',congel,meltb
call icepack_warnings_add(warnstr)
call icepack_warnings_add(subname//'sk_bgc < 0 after algal fluxes')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
!call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
endif

if (icepack_warnings_aborted(subname)) return
Expand Down Expand Up @@ -1089,7 +1089,7 @@ subroutine z_biogeochemistry (n_cat, dt, &
write(warnstr,*) subname, trcrn(bio_index(m) + k-1)
call icepack_warnings_add(warnstr)
call icepack_warnings_add(subname//' zbgc initialization error')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
!call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
endif
if (icepack_warnings_aborted(subname)) return
enddo !k
Expand Down Expand Up @@ -1360,7 +1360,7 @@ subroutine z_biogeochemistry (n_cat, dt, &
write(warnstr,*) subname,'Category,mm:',n_cat,mm
call icepack_warnings_add(warnstr)
call icepack_warnings_add(subname//'zbgc FCT tracer solution failed')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
!call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
endif
if (icepack_warnings_aborted(subname)) return

Expand Down Expand Up @@ -1453,7 +1453,7 @@ subroutine z_biogeochemistry (n_cat, dt, &
write(warnstr,*) subname, react(k,m),iphin_N(k),biomat_brine(k,m)
call icepack_warnings_add(warnstr)
call icepack_warnings_add(subname//' C in algal_dyn not conserved')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
!call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
elseif (abs(bio_tmp) < accuracy) then
flux_bio(m) = flux_bio(m) + bio_tmp*dz(k)*hbri/dt
bio_tmp = c0
Expand All @@ -1469,7 +1469,7 @@ subroutine z_biogeochemistry (n_cat, dt, &
write(warnstr,*) subname, react(k,m),iphin_N(k),biomat_brine(k,m)
call icepack_warnings_add(warnstr)
call icepack_warnings_add(subname//' very large bgc value')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
!call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
elseif (bio_tmp < c0) then
write(warnstr,*) subname, 'negative bgc'
call icepack_warnings_add(warnstr)
Expand All @@ -1488,7 +1488,7 @@ subroutine z_biogeochemistry (n_cat, dt, &
write(warnstr,*) subname, 'exp_ret( m),exp_ret( m)',exp_ret( m),exp_ret( m)
call icepack_warnings_add(warnstr)
call icepack_warnings_add(subname//'negative bgc')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
!call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
endif
trcrn(bio_index(m)+k-1) = max(c0, bio_tmp)
if (icepack_warnings_aborted()) then
Expand Down Expand Up @@ -2254,6 +2254,7 @@ subroutine algal_dyn (dt, n_doc, n_dic, &
write(warnstr,*) subname, 'DOC_r(k),DOC_s(k),k'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, DOC_r(k),DOC_s(k),k
call icepack_warnings_add(warnstr)
end do
do k = 1,n_dic
write(warnstr,*) subname, 'DICin'
Expand All @@ -2267,8 +2268,8 @@ subroutine algal_dyn (dt, n_doc, n_dic, &
write(warnstr,*) subname, 'DIC_r(k),DIC_s(k),k'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, DIC_r(k),DIC_s(k),k
call icepack_warnings_add(warnstr)
end do
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Zoo'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, Zoo
Expand Down Expand Up @@ -2790,46 +2791,76 @@ subroutine check_conservation_FCT (C_init, C_new, C_low, S_top, &

if (minval(C_low) < c0) then
write(warnstr,*) subname, 'Positivity of zbgc low order solution failed: C_low:',C_low
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(warnstr)
!call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
endif

if (abs(diff_dt) > accuracyC ) then
write(warnstr,*) subname, ''
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Conservation of zbgc low order solution failed: diff_dt:'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, diff_dt
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Total initial tracer'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, C_init_tot
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Total final1 tracer'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, C_new_tot
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'bottom final tracer'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, C_new(nblyr+1)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'top final tracer'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, C_new(1)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Near bottom final tracer'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, C_new(nblyr)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Near top final tracer'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, C_new(2)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Top flux*dt into ice:'
call icepack_warnings_add(warnstr)
var_tmp = S_top*dt
write(warnstr,*) subname, var_tmp
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Bottom flux*dt into ice:'
call icepack_warnings_add(warnstr)
var_tmp = S_bot*dt
write(warnstr,*) subname, var_tmp
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Remaining bot flux*dt into ice:'
call icepack_warnings_add(warnstr)
var_tmp = L_bot*C_new(nblyr+1)*dt
write(warnstr,*) subname, var_tmp
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'S_bot*dt + L_bot*C_new(nblyr+1)*dt'
call icepack_warnings_add(warnstr)
var_tmp = S_bot*dt + L_bot*C_new(nblyr+1)*dt
write(warnstr,*) subname, var_tmp
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'fluxbio*dt:'
call icepack_warnings_add(warnstr)
var_tmp = fluxbio*dt
write(warnstr,*) subname, var_tmp
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'fluxbio:'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, fluxbio
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Remaining top flux*dt into ice:'
call icepack_warnings_add(warnstr)
var_tmp = L_top*C_new(1)*dt
write(warnstr,*) subname, var_tmp
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(warnstr)
!call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
endif

end subroutine check_conservation_FCT
Expand Down
2 changes: 1 addition & 1 deletion columnphysics/icepack_therm_itd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ subroutine linear_itd (ncat, hin_max, &

write(warnstr,*) subname, &
'ITD Thermodynamics: hicen_init(n+1) <= hicen_init(n)'
call icepack_warnings_setabort(.true.)
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(warnstr)

endif
Expand Down
10 changes: 8 additions & 2 deletions columnphysics/icepack_warnings.F90
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ subroutine icepack_warnings_setabort(abortflag,file,line)

if (abortflag) then
write(warnstr,*) subname,abortflag
if (present(file)) write(warnstr,*) trim(warnstr)//' :file '//trim(file)
if (present(line)) write(warnstr,*) trim(warnstr)//' :line ',line
call icepack_warnings_add(warnstr)
if (present(file)) then
write(warnstr,*) trim(warnstr)//' :file '//trim(file)
call icepack_warnings_add(warnstr)
endif
if (present(line)) then
write(warnstr,*) trim(warnstr)//' :line ',line
call icepack_warnings_add(warnstr)
endif
endif

warning_abort = abortflag
Expand Down
2 changes: 1 addition & 1 deletion columnphysics/icepack_zbgc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2231,7 +2231,7 @@ subroutine update_vertical_bio_tracers(nbiolyr, trc, h1, h2, trc0, zspace)
!rnilyr = real(nilyr,dbl_kind)
z2a = c0
z2b = c0
if (h2 > c0) then
if (h2 > puny) then
! loop over new grid cells
do k2 = 1, nbiolyr

Expand Down

0 comments on commit c090b4b

Please sign in to comment.