diff --git a/cicecore/cicedyn/analysis/ice_history.F90 b/cicecore/cicedyn/analysis/ice_history.F90 index a6eabe2db..99b04afb9 100644 --- a/cicecore/cicedyn/analysis/ice_history.F90 +++ b/cicecore/cicedyn/analysis/ice_history.F90 @@ -1535,17 +1535,17 @@ subroutine init_hist (dt) call define_hist_field(n_sitemptop,"sitemptop","K",tstr2D, tcstr, & "sea ice surface temperature", & - "none", c1, c0, & + "none", c1, Tffresh, & ns1, f_sitemptop, avg_ice_present=.true., mask_ice_free_points=.true.) call define_hist_field(n_sitempsnic,"sitempsnic","K",tstr2D, tcstr, & "snow ice interface temperature", & - "surface temperature when no snow present", c1, c0, & + "surface temperature when no snow present", c1, Tffresh, & ns1, f_sitempsnic, avg_ice_present=.true., mask_ice_free_points=.true.) call define_hist_field(n_sitempbot,"sitempbot","K",tstr2D, tcstr, & "sea ice bottom temperature", & - "none", c1, c0, & + "none", c1, Tffresh, & ns1, f_sitempbot, avg_ice_present=.true., mask_ice_free_points=.true.) call define_hist_field(n_siu,"siu","m/s",ustr2D, ucstr, & @@ -2753,22 +2753,18 @@ subroutine accum_hist (dt) worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice(i,j,iblk) > puny) & - worka(i,j) = aice(i,j,iblk)*(trcr(i,j,nt_Tsfc,iblk)+Tffresh) + worka(i,j) = aice(i,j,iblk)*trcr(i,j,nt_Tsfc,iblk) enddo enddo call accum_hist_field(n_sitemptop, iblk, worka(:,:), a2D) endif + ! Tsnice is already multiplied by aicen in icepack. if (f_sitempsnic(1:1) /= 'x') then worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (vsno(i,j,iblk) > puny .and. aice_init(i,j,iblk) > puny) then - worka(i,j) = aice(i,j,iblk)*(Tsnice(i,j,iblk)/aice_init(i,j,iblk)+Tffresh) - else - worka(i,j) = aice(i,j,iblk)*(trcr(i,j,nt_Tsfc,iblk)+Tffresh) - endif + worka(i,j) = Tsnice(i,j,iblk) enddo enddo call accum_hist_field(n_sitempsnic, iblk, worka(:,:), a2D) @@ -2778,8 +2774,7 @@ subroutine accum_hist (dt) worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice_init(i,j,iblk) > puny) & - worka(i,j) = aice(i,j,iblk)*(Tbot(i,j,iblk)/aice_init(i,j,iblk)+Tffresh) + worka(i,j) = aice(i,j,iblk)*Tbot(i,j,iblk) enddo enddo call accum_hist_field(n_sitempbot, iblk, worka(:,:), a2D) @@ -3705,33 +3700,40 @@ subroutine accum_hist (dt) do n = 1, num_avail_hist_fields_2D if (avail_hist_fields(n)%vhistfreq == histfreq(ns)) then - do j = jlo, jhi - do i = ilo, ihi - if (.not. tmask(i,j,iblk)) then ! mask out land points - a2D(i,j,n,iblk) = spval_dbl - else ! convert units - a2D(i,j,n,iblk) = avail_hist_fields(n)%cona*a2D(i,j,n,iblk) & - * ravgct + avail_hist_fields(n)%conb - endif - enddo ! i - enddo ! j - - ! Only average for timesteps when ice present + ! Only average when/where ice present if (avail_hist_fields(n)%avg_ice_present) then do j = jlo, jhi do i = ilo, ihi - if (tmask(i,j,iblk)) then - a2D(i,j,n,iblk) = & - a2D(i,j,n,iblk)*avgct(ns)*ravgip(i,j) + if (.not. tmask(i,j,iblk)) then + a2D(i,j,n,iblk) = spval_dbl + else ! convert units + a2D(i,j,n,iblk) = avail_hist_fields(n)%cona*a2D(i,j,n,iblk) & + * ravgip(i,j) + avail_hist_fields(n)%conb endif - ! Mask ice-free points - if (avail_hist_fields(n)%mask_ice_free_points) then - if (ravgip(i,j) == c0) a2D(i,j,n,iblk) = spval_dbl + enddo ! i + enddo ! j + else + do j = jlo, jhi + do i = ilo, ihi + if (.not. tmask(i,j,iblk)) then ! mask out land points + a2D(i,j,n,iblk) = spval_dbl + else ! convert units + a2D(i,j,n,iblk) = avail_hist_fields(n)%cona*a2D(i,j,n,iblk) & + * ravgct + avail_hist_fields(n)%conb endif enddo ! i enddo ! j endif + ! Mask ice-free points + if (avail_hist_fields(n)%mask_ice_free_points) then + do j = jlo, jhi + do i = ilo, ihi + if (ravgip(i,j) == c0) a2D(i,j,n,iblk) = spval_dbl + enddo ! i + enddo ! j + endif + ! CMIP albedo: also mask points below horizon if (index(avail_hist_fields(n)%vname,'sialb') /= 0) then do j = jlo, jhi @@ -3838,30 +3840,33 @@ subroutine accum_hist (dt) nn = n2D + n if (avail_hist_fields(nn)%vhistfreq == histfreq(ns)) then - do k = 1, ncat_hist - do j = jlo, jhi - do i = ilo, ihi - if (.not. tmask(i,j,iblk)) then ! mask out land points - a3Dc(i,j,k,n,iblk) = spval_dbl - else ! convert units - a3Dc(i,j,k,n,iblk) = avail_hist_fields(nn)%cona*a3Dc(i,j,k,n,iblk) & - * ravgct + avail_hist_fields(nn)%conb + if (avail_hist_fields(nn)%avg_ice_present) then + do k = 1, ncat_hist + do j = jlo, jhi + do i = ilo, ihi + if (.not. tmask(i,j,iblk)) then ! mask out land points + a3Dc(i,j,k,n,iblk) = spval_dbl + else ! convert units + a3Dc(i,j,k,n,iblk) = avail_hist_fields(nn)%cona*a3Dc(i,j,k,n,iblk) & + * ravgipn(i,j,k) + avail_hist_fields(nn)%conb + endif + enddo ! i + enddo ! j + enddo ! k + else + do k = 1, ncat_hist + do j = jlo, jhi + do i = ilo, ihi + if (.not. tmask(i,j,iblk)) then ! mask out land points + a3Dc(i,j,k,n,iblk) = spval_dbl + else ! convert units + a3Dc(i,j,k,n,iblk) = avail_hist_fields(nn)%cona*a3Dc(i,j,k,n,iblk) & + * ravgct + avail_hist_fields(nn)%conb + endif + enddo ! i + enddo ! j + enddo ! k endif - enddo ! i - enddo ! j - enddo ! k - if (avail_hist_fields(nn)%avg_ice_present) then - do k = 1, ncat_hist - do j = jlo, jhi - do i = ilo, ihi - if (tmask(i,j,iblk)) then - a3Dc(i,j,k,n,iblk) = & - a3Dc(i,j,k,n,iblk)*avgct(ns)*ravgipn(i,j,k) - endif - enddo ! i - enddo ! j - enddo ! k - endif endif @@ -3885,6 +3890,7 @@ subroutine accum_hist (dt) enddo ! k endif enddo ! n + do n = 1, num_avail_hist_fields_3Db nn = n3Dzcum + n if (avail_hist_fields(nn)%vhistfreq == histfreq(ns)) then diff --git a/cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90 b/cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90 index d7720cd1e..2d6c5915a 100644 --- a/cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90 @@ -1287,9 +1287,15 @@ subroutine ice_hist_field_def(ncid, hfield, lprecision, dimids, ns) .and.TRIM(hfield%vname(1:9))/='sistreave' & .and.TRIM(hfield%vname(1:9))/='sistremax' & .and.TRIM(hfield%vname(1:4))/='sigP') then - status = nf90_put_att(ncid,varid,'cell_methods','time: mean') - call ice_check_nc(status, subname// ' ERROR: defining cell methods for '//hfield%vname, & - file=__FILE__, line=__LINE__) + if (hfield%avg_ice_present) then + status = nf90_put_att(ncid,varid,'cell_methods','area: time: mean where sea ice (mask=siconc)') + call ice_check_nc(status, subname// ' ERROR: defining cell methods for '//hfield%vname, & + file=__FILE__, line=__LINE__) + else + status = nf90_put_att(ncid,varid,'cell_methods','time: mean') + call ice_check_nc(status, subname// ' ERROR: defining cell methods for '//hfield%vname, & + file=__FILE__, line=__LINE__) + endif endif endif diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_history_write.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_history_write.F90 index d935f2577..f4c6e51db 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_history_write.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_history_write.F90 @@ -1428,8 +1428,14 @@ subroutine ice_hist_field_def(File, hfield,lprecision, dimids, ns) .and.TRIM(hfield%vname(1:9))/='sistreave' & .and.TRIM(hfield%vname(1:9))/='sistremax' & .and.TRIM(hfield%vname(1:4))/='sigP') then - call ice_pio_check(pio_put_att(File,varid,'cell_methods','time: mean'), & - subname//' ERROR: defining att cell_methods',file=__FILE__,line=__LINE__) + if (hfield%avg_ice_present) then + call ice_pio_check(pio_put_att(File,varid,'cell_methods', & + 'area: time: mean where sea ice (mask=siconc)'), & + subname//' ERROR: defining att cell_methods',file=__FILE__,line=__LINE__) + else + call ice_pio_check(pio_put_att(File,varid,'cell_methods','time: mean'), & + subname//' ERROR: defining att cell_methods',file=__FILE__,line=__LINE__) + endif endif endif diff --git a/icepack b/icepack index a5b5ebe63..4954a6f90 160000 --- a/icepack +++ b/icepack @@ -1 +1 @@ -Subproject commit a5b5ebe63f986dbda86d5b2ef91426811619d018 +Subproject commit 4954a6f9033f78e5c32bf33780384cbf2d0843e6