Skip to content

Commit

Permalink
Merge remote-tracking branch 'Consortium/main' into feature/updcice
Browse files Browse the repository at this point in the history
  • Loading branch information
DeniseWorthen committed Jan 4, 2023
2 parents ad8d577 + 0bf0fdc commit ce2298e
Show file tree
Hide file tree
Showing 37 changed files with 651 additions and 275 deletions.
45 changes: 37 additions & 8 deletions cicecore/cicedyn/analysis/ice_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ module ice_diagnostics
totms , & ! total ice/snow water mass (sh)
totmin , & ! total ice water mass (nh)
totmis , & ! total ice water mass (sh)
totsn , & ! total salt mass (nh)
totss , & ! total salt mass (sh)
toten , & ! total ice/snow energy (J)
totes ! total ice/snow energy (J)

Expand Down Expand Up @@ -154,14 +156,16 @@ subroutine runtime_diags (dt)
rhofresh, lfresh, lvap, ice_ref_salinity, Tffresh

character (len=char_len) :: &
snwredist
snwredist, saltflux_option

! hemispheric state quantities
real (kind=dbl_kind) :: &
umaxn, hmaxn, shmaxn, arean, snwmxn, extentn, shmaxnt, &
umaxs, hmaxs, shmaxs, areas, snwmxs, extents, shmaxst, &
etotn, mtotn, micen, msnwn, pmaxn, ketotn, &
etots, mtots, mices, msnws, pmaxs, ketots, &
stotn, &
stots, &
urmsn, albtotn, arean_alb, mpndn, ptotn, spondn, &
urmss, albtots, areas_alb, mpnds, ptots, sponds

Expand Down Expand Up @@ -226,7 +230,7 @@ subroutine runtime_diags (dt)
awtvdr_out=awtvdr, awtidr_out=awtidr, awtvdf_out=awtvdf, awtidf_out=awtidf, &
rhofresh_out=rhofresh, lfresh_out=lfresh, lvap_out=lvap, &
ice_ref_salinity_out=ice_ref_salinity,snwredist_out=snwredist, &
snwgrain_out=snwgrain)
snwgrain_out=snwgrain, saltflux_option_out=saltflux_option)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
Expand Down Expand Up @@ -512,6 +516,15 @@ subroutine runtime_diags (dt)
etots = global_sum(work1, distrb_info, &
field_loc_center, tareas)

! total salt volume
call total_salt (work2)

stotn = global_sum(work2, distrb_info, &
field_loc_center, tarean)
stots = global_sum(work2, distrb_info, &
field_loc_center, tareas)


!-----------------------------------------------------------------
! various fluxes
!-----------------------------------------------------------------
Expand Down Expand Up @@ -785,12 +798,22 @@ subroutine runtime_diags (dt)
swerrs = (fswnets - fswdns) / (fswnets - c1)

! salt mass
msltn = micen*ice_ref_salinity*p001
mslts = mices*ice_ref_salinity*p001
if (saltflux_option == 'prognostic') then
! compute the total salt mass
msltn = stotn*rhoi*p001
mslts = stots*rhoi*p001

! change in salt mass
delmsltn = rhoi*(stotn-totsn)*p001
delmslts = rhoi*(stots-totss)*p001
else
msltn = micen*ice_ref_salinity*p001
mslts = mices*ice_ref_salinity*p001

! change in salt mass
delmsltn = delmxn*ice_ref_salinity*p001
delmslts = delmxs*ice_ref_salinity*p001
! change in salt mass
delmsltn = delmxn*ice_ref_salinity*p001
delmslts = delmxs*ice_ref_salinity*p001
endif

! salt error
serrn = (sfsaltn + delmsltn) / (msltn + c1)
Expand Down Expand Up @@ -1275,7 +1298,7 @@ subroutine init_mass_diags
rhoi, rhos, rhofresh

real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks) :: &
work1
work1, work2

character(len=*), parameter :: subname = '(init_mass_diags)'

Expand Down Expand Up @@ -1310,6 +1333,12 @@ subroutine init_mass_diags
toten = global_sum(work1, distrb_info, field_loc_center, tarean)
totes = global_sum(work1, distrb_info, field_loc_center, tareas)

! north/south salt
call total_salt (work2)
totsn = global_sum(work2, distrb_info, field_loc_center, tarean)
totss = global_sum(work2, distrb_info, field_loc_center, tareas)


if (print_points) then
do n = 1, npnt
if (my_task == pmloc(n)) then
Expand Down
49 changes: 39 additions & 10 deletions cicecore/cicedyn/analysis/ice_history.F90
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ subroutine init_hist (dt)
use ice_history_fsd, only: init_hist_fsd_2D, init_hist_fsd_3Df, &
init_hist_fsd_4Df, f_afsd, f_afsdn
use ice_restart_shared, only: restart
use ice_fileunits, only: goto_nml

real (kind=dbl_kind), intent(in) :: &
dt ! time step
Expand All @@ -104,7 +105,9 @@ subroutine init_hist (dt)
cstr_got, cstr_gou, cstr_gov ! mask area name for t, u, v ocn grid (go)
character (len=25) :: &
gridstr2D, gridstr ! temporary string names
character(len=char_len) :: description
character(len=char_len) :: description
character(len=char_len_long) :: tmpstr2 ! for namelist check
character(len=char_len) :: nml_name ! text namelist name

character(len=*), parameter :: subname = '(init_hist)'

Expand Down Expand Up @@ -228,24 +231,39 @@ subroutine init_hist (dt)
file=__FILE__, line=__LINE__)

if (my_task == master_task) then
write(nu_diag,*) subname,' Reading icefields_nml'
nml_name = 'icefields_nml'
write(nu_diag,*) subname,' Reading ', trim(nml_name)

! open file
call get_fileunit(nu_nml)
open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error)
if (nml_error /= 0) then
call abort_ice(subname//'ERROR: icefields_nml open file '// &
call abort_ice(subname//'ERROR: '//trim(nml_name)//' open file '// &
trim(nml_filename), &
file=__FILE__, line=__LINE__)
endif

! seek to this namelist
call goto_nml(nu_nml,trim(nml_name),nml_error)
if (nml_error /= 0) then
call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
file=__FILE__, line=__LINE__)
endif

! read namelist
nml_error = 1
do while (nml_error > 0)
read(nu_nml, nml=icefields_nml,iostat=nml_error)
! check if error
if (nml_error /= 0) then
! backspace and re-read erroneous line
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
call abort_ice(subname//'ERROR: ' // trim(nml_name) // ' reading ' // &
trim(tmpstr2), file=__FILE__, line=__LINE__)
endif
end do
if (nml_error /= 0) then
call abort_ice(subname//'ERROR: icefields_nml reading ', &
file=__FILE__, line=__LINE__)
endif

close(nu_nml)
call release_fileunit(nu_nml)
endif
Expand Down Expand Up @@ -2164,12 +2182,13 @@ subroutine accum_hist (dt)

real (kind=dbl_kind) :: awtvdr, awtidr, awtvdf, awtidf, puny, secday, rad_to_deg
real (kind=dbl_kind) :: Tffresh, rhoi, rhos, rhow, ice_ref_salinity
real (kind=dbl_kind) :: rho_ice, rho_ocn, Tice, Sbr, phi, rhob, dfresh, dfsalt
real (kind=dbl_kind) :: rho_ice, rho_ocn, Tice, Sbr, phi, rhob, dfresh, dfsalt, sicen
logical (kind=log_kind) :: formdrag, skl_bgc
logical (kind=log_kind) :: tr_pond, tr_aero, tr_brine, tr_snow
integer (kind=int_kind) :: ktherm
integer (kind=int_kind) :: nt_sice, nt_qice, nt_qsno, nt_iage, nt_FY, nt_Tsfc, &
nt_alvl, nt_vlvl
character (len=char_len) :: saltflux_option

type (block) :: &
this_block ! block information for current block
Expand All @@ -2181,6 +2200,7 @@ subroutine accum_hist (dt)
call icepack_query_parameters(Tffresh_out=Tffresh, rhoi_out=rhoi, rhos_out=rhos, &
rhow_out=rhow, ice_ref_salinity_out=ice_ref_salinity)
call icepack_query_parameters(formdrag_out=formdrag, skl_bgc_out=skl_bgc, ktherm_out=ktherm)
call icepack_query_parameters(saltflux_option_out=saltflux_option)
call icepack_query_tracer_flags(tr_pond_out=tr_pond, tr_aero_out=tr_aero, &
tr_brine_out=tr_brine, tr_snow_out=tr_snow)
call icepack_query_tracer_indices(nt_sice_out=nt_sice, nt_qice_out=nt_qice, &
Expand Down Expand Up @@ -2265,7 +2285,7 @@ subroutine accum_hist (dt)
!---------------------------------------------------------------

!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block, &
!$OMP k,n,qn,ns,sn,rho_ocn,rho_ice,Tice,Sbr,phi,rhob,dfresh,dfsalt, &
!$OMP k,n,qn,ns,sn,rho_ocn,rho_ice,Tice,Sbr,phi,rhob,dfresh,dfsalt,sicen, &
!$OMP worka,workb,worka3,Tinz4d,Sinz4d,Tsnz4d)

do iblk = 1, nblocks
Expand Down Expand Up @@ -3224,7 +3244,16 @@ subroutine accum_hist (dt)
dfresh = -rhoi*frazil(i,j,iblk)/dt
endif
endif
dfsalt = ice_ref_salinity*p001*dfresh
if (saltflux_option == 'prognostic') then
sicen = c0
do k = 1, nzilyr
sicen = sicen + trcr(i,j,nt_sice+k-1,iblk)*vice(i,j,iblk) &
/ real(nzilyr,kind=dbl_kind)
enddo
dfsalt = sicen*p001*dfresh
else
dfsalt = ice_ref_salinity*p001*dfresh
endif
worka(i,j) = aice(i,j,iblk)*(fsalt(i,j,iblk)+dfsalt)
endif
enddo
Expand Down
31 changes: 25 additions & 6 deletions cicecore/cicedyn/analysis/ice_history_bgc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ subroutine init_hist_bgc_2D
use ice_communicate, only: my_task, master_task
use ice_history_shared, only: tstr2D, tcstr, define_hist_field, &
f_fsalt, f_fsalt_ai, f_sice
use ice_fileunits, only: goto_nml

integer (kind=int_kind) :: n, ns
integer (kind=int_kind) :: nml_error ! namelist i/o error flag
Expand All @@ -283,6 +284,9 @@ subroutine init_hist_bgc_2D
tr_bgc_DON, tr_bgc_Fe, tr_bgc_hum, &
skl_bgc, solve_zsal, z_tracers

character(len=char_len) :: nml_name ! for namelist check
character(len=char_len_long) :: tmpstr2 ! for namelist check

character(len=*), parameter :: subname = '(init_hist_bgc_2D)'

call icepack_query_parameters(skl_bgc_out=skl_bgc, &
Expand All @@ -305,24 +309,39 @@ subroutine init_hist_bgc_2D
!-----------------------------------------------------------------

if (my_task == master_task) then
write(nu_diag,*) subname,' Reading icefields_bgc_nml'
nml_name = 'icefields_bgc_nml'
write(nu_diag,*) subname,' Reading ', trim(nml_name)

! check if can open file
call get_fileunit(nu_nml)
open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error)
if (nml_error /= 0) then
call abort_ice(subname//'ERROR: icefields_bgc_nml open file '// &
call abort_ice(subname//'ERROR: '//trim(nml_name)//' open file '// &
trim(nml_filename), &
file=__FILE__, line=__LINE__)
endif

! seek to namelist in file
call goto_nml(nu_nml,trim(nml_name),nml_error)
if (nml_error /= 0) then
call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
file=__FILE__, line=__LINE__)
endif

! read namelist
nml_error = 1
do while (nml_error > 0)
read(nu_nml, nml=icefields_bgc_nml,iostat=nml_error)
! check if error
if (nml_error /= 0) then
! backspace and re-read erroneous line
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
call abort_ice(subname//'ERROR: ' // trim(nml_name) // ' reading ' // &
trim(tmpstr2), file=__FILE__, line=__LINE__)
endif
end do
if (nml_error /= 0) then
call abort_ice(subname//'ERROR: icefields_bgc_nml reading ', &
file=__FILE__, line=__LINE__)
endif

close(nu_nml)
call release_fileunit(nu_nml)
endif
Expand Down
30 changes: 24 additions & 6 deletions cicecore/cicedyn/analysis/ice_history_drag.F90
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ subroutine init_hist_drag_2D
use ice_calendar, only: nstreams
use ice_communicate, only: my_task, master_task
use ice_history_shared, only: tstr2D, tcstr, define_hist_field
use ice_fileunits, only: goto_nml

integer (kind=int_kind) :: ns
integer (kind=int_kind) :: nml_error ! namelist i/o error flag
logical (kind=log_kind) :: formdrag
character(len=char_len_long) :: tmpstr2 ! for namelist check
character(len=char_len) :: nml_name ! for namelist check

character(len=*), parameter :: subname = '(init_hist_drag_2D)'

Expand All @@ -81,24 +84,39 @@ subroutine init_hist_drag_2D
!-----------------------------------------------------------------

if (my_task == master_task) then
write(nu_diag,*) subname,' Reading icefields_drag_nml'
nml_name = 'icefields_drag_nml'
write(nu_diag,*) subname,' Reading ', trim(nml_name)

! open namelist file
call get_fileunit(nu_nml)
open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error)
if (nml_error /= 0) then
call abort_ice(subname//'ERROR: icefields_drag_nml open file '// &
call abort_ice(subname//'ERROR: '//trim(nml_name)//' open file '// &
trim(nml_filename), &
file=__FILE__, line=__LINE__)
endif

! go to this namelist
call goto_nml(nu_nml,trim(nml_name),nml_error)
if (nml_error /= 0) then
call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
file=__FILE__, line=__LINE__)
endif

! read namelist
nml_error = 1
do while (nml_error > 0)
read(nu_nml, nml=icefields_drag_nml,iostat=nml_error)
! check if error
if (nml_error /= 0) then
! backspace and re-read erroneous line
backspace(nu_nml)
read(nu_nml,fmt='(A)') tmpstr2
call abort_ice(subname//'ERROR: ' // trim(nml_name) // ' reading ' // &
trim(tmpstr2), file=__FILE__, line=__LINE__)
endif
end do
if (nml_error /= 0) then
call abort_ice(subname//'ERROR: icefields_drag_nml reading ', &
file=__FILE__, line=__LINE__)
endif

close(nu_nml)
call release_fileunit(nu_nml)
endif
Expand Down
Loading

0 comments on commit ce2298e

Please sign in to comment.