From c090b4b20e4ec0317d2c7d742c5ab291ec7a2240 Mon Sep 17 00:00:00 2001 From: Nicole Jeffery Date: Thu, 28 Mar 2024 16:27:23 -0500 Subject: [PATCH] Fix to icepack warning strings 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 --- columnphysics/icepack_algae.F90 | 57 ++++++++++++++++++++++------- columnphysics/icepack_therm_itd.F90 | 2 +- columnphysics/icepack_warnings.F90 | 10 ++++- columnphysics/icepack_zbgc.F90 | 2 +- 4 files changed, 54 insertions(+), 17 deletions(-) diff --git a/columnphysics/icepack_algae.F90 b/columnphysics/icepack_algae.F90 index f841902f3..6163c52f1 100644 --- a/columnphysics/icepack_algae.F90 +++ b/columnphysics/icepack_algae.F90 @@ -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 @@ -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 @@ -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) @@ -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 @@ -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 @@ -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 @@ -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 @@ -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) @@ -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 @@ -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' @@ -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 @@ -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 diff --git a/columnphysics/icepack_therm_itd.F90 b/columnphysics/icepack_therm_itd.F90 index 829352fe3..0d4dd6c66 100644 --- a/columnphysics/icepack_therm_itd.F90 +++ b/columnphysics/icepack_therm_itd.F90 @@ -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 diff --git a/columnphysics/icepack_warnings.F90 b/columnphysics/icepack_warnings.F90 index 459f2dc80..231f71285 100644 --- a/columnphysics/icepack_warnings.F90 +++ b/columnphysics/icepack_warnings.F90 @@ -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 diff --git a/columnphysics/icepack_zbgc.F90 b/columnphysics/icepack_zbgc.F90 index d33b29891..a327778bd 100644 --- a/columnphysics/icepack_zbgc.F90 +++ b/columnphysics/icepack_zbgc.F90 @@ -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