Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c489483
Bring Consortium main into CESM
dabail10 Oct 24, 2022
9db5da4
Comment out OMP initialization
dabail10 Oct 24, 2022
490b259
Update wave-ice coupling in NUOPC/CMEPS driver
dabail10 Nov 8, 2022
0d23ccd
Update to Consortium main
dabail10 Nov 30, 2022
675670d
Update saltflux option to be constant and use ice_ref_salinity
dabail10 Nov 30, 2022
758d2ac
Fix a couple inconsistencies with CICE Consortium master
dabail10 Nov 30, 2022
853b6ec
Fix some issues
dabail10 Nov 30, 2022
df51c68
Fix some merge issues
dabail10 Nov 30, 2022
b13b728
Fix some merge issues
dabail10 Nov 30, 2022
9bb0281
Fix ACC directive
dabail10 Nov 30, 2022
33ea462
Bug fixes with eap initialization
dabail10 Nov 30, 2022
842d5c6
Fix evp initialization
dabail10 Nov 30, 2022
fbf9d59
Add warning when ktherm=1 and saltflux_option not constant
dabail10 Dec 1, 2022
d88e71e
Comment out Tair initialization
dabail10 Dec 1, 2022
ba6fe8a
Add CESMCOUPLED around OMP initialization
dabail10 Dec 1, 2022
71cf0fb
CESM File unit handling
dabail10 Dec 1, 2022
df5573f
Change icepack hash for PR
dabail10 Dec 2, 2022
4f8cf7e
Some cleanup things
dabail10 Dec 2, 2022
8b1c232
Move nu_diag_set to CESMCOUPLED region
dabail10 Dec 2, 2022
f19faa7
Put Tair initialization in a CESMCOUPLED
dabail10 Dec 2, 2022
3363e83
New saltflux tests
dabail10 Dec 5, 2022
34dbeed
Update icepack for saltflux option
dabail10 Dec 6, 2022
6201214
Update icepack
dabail10 Dec 6, 2022
38103c5
Merge branch 'main' of https://github.com/ESCOMP/CICE into cesm_updates2
dabail10 Dec 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you could reuse work1 here rather than add new array, work2.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. I thought they needed to be independent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this code, we do not need work2, but in the print_points code we do. The array work2 is used in a number of places, so it is not really saving us memory.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it just looks like work2 was added in init_mass_diags just for the new salt diagnostic. work2 must exist separately in print_points and elsewhere.



if (print_points) then
do n = 1, npnt
if (my_task == pmloc(n)) then
Expand Down
17 changes: 14 additions & 3 deletions cicecore/cicedyn/analysis/ice_history.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2164,12 +2164,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 +2182,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 +2267,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 +3226,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
2 changes: 1 addition & 1 deletion cicecore/cicedyn/analysis/ice_history_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module ice_history_shared
logical (kind=log_kind), public :: &
hist_avg ! if true, write averaged data instead of snapshots

character (len=char_len), public :: &
character (len=char_len_long), public :: &
history_file , & ! output file for history
incond_file ! output file for snapshot initial conditions

Expand Down
2 changes: 1 addition & 1 deletion cicecore/cicedyn/dynamics/ice_dyn_evp_1d.F90
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ subroutine evp1d_halo_update(NAVEL_len, lb, ub, uvel, vvel, &

#ifdef _OPENACC
!$acc parallel &
!$acc present(uvel, vvel) &
!$acc present(uvel, vvel)
!$acc loop
do iw = 1, NAVEL_len
if (halo_parent(iw) == 0) cycle
Expand Down
37 changes: 29 additions & 8 deletions cicecore/cicedyn/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ module ice_init
use ice_constants, only: c0, c1, c2, c3, c5, c12, p2, p3, p5, p75, p166, &
cm_to_m
use ice_exit, only: abort_ice
use ice_fileunits, only: nu_nml, nu_diag, nu_diag_set, nml_filename, diag_type, &
use ice_fileunits, only: nu_nml, nu_diag, nml_filename, diag_type, &
ice_stdout, get_fileunit, release_fileunit, bfbflag, flush_fileunit, &
ice_IOUnitsMinUnit, ice_IOUnitsMaxUnit
#ifdef CESMCOUPLED
use ice_fileunits, only: inst_suffix
use ice_fileunits, only: inst_suffix, nu_diag_set
#endif
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
use icepack_intfc, only: icepack_aggregate
Expand Down Expand Up @@ -151,7 +151,7 @@ subroutine input_data
kitd, kcatbound, ktransport

character (len=char_len) :: shortwave, albedo_type, conduct, fbot_xfer_type, &
tfrz_option, frzpnd, atmbndy, wave_spec_type, snwredist, snw_aging_table, &
tfrz_option, saltflux_option, frzpnd, atmbndy, wave_spec_type, snwredist, snw_aging_table, &
capping_method

logical (kind=log_kind) :: calc_Tsfc, formdrag, highfreq, calc_strair, wave_spec, &
Expand All @@ -163,7 +163,7 @@ subroutine input_data
integer (kind=int_kind) :: numin, numax ! unit number limits

integer (kind=int_kind) :: rplvl, rptopo
real (kind=dbl_kind) :: Cf, ksno, puny
real (kind=dbl_kind) :: Cf, ksno, puny, ice_ref_salinity
character (len=char_len) :: abort_list
character (len=128) :: tmpstr2

Expand Down Expand Up @@ -260,6 +260,7 @@ subroutine input_data
highfreq, natmiter, atmiter_conv, calc_dragio, &
ustar_min, emissivity, iceruf, iceruf_ocn, &
fbot_xfer_type, update_ocn_f, l_mpond_fresh, tfrz_option, &
saltflux_option,ice_ref_salinity, &
oceanmixed_ice, restore_ice, restore_ocn, trestore, &
precip_units, default_season, wave_spec_type,nfreq, &
atm_data_type, ocn_data_type, bgc_data_type, fe_data_type, &
Expand Down Expand Up @@ -497,6 +498,8 @@ subroutine input_data
precip_units = 'mks' ! 'mm_per_month' or
! 'mm_per_sec' = 'mks' = kg/m^2 s
tfrz_option = 'mushy' ! freezing temp formulation
saltflux_option = 'constant' ! saltflux calculation
ice_ref_salinity = 4.0_dbl_kind ! Ice reference salinity for coupling
oceanmixed_ice = .false. ! if true, use internal ocean mixed layer
wave_spec_type = 'none' ! type of wave spectrum forcing
nfreq = 25 ! number of wave frequencies
Expand Down Expand Up @@ -758,8 +761,8 @@ subroutine input_data
! each task gets unique ice log filename when if test is true, for debugging
if (1 == 0) then
call get_fileUnit(nu_diag)
write(tmpstr,'(a,i4.4)') "ice.log.task_",my_task
open(nu_diag,file=tmpstr)
write(tmpstr2,'(a,i4.4)') "ice.log.task_",my_task
open(nu_diag,file=tmpstr2)
endif
end if
if (trim(ice_ic) /= 'default' .and. &
Expand Down Expand Up @@ -979,6 +982,8 @@ subroutine input_data
call broadcast_scalar(wave_spec_file, master_task)
call broadcast_scalar(nfreq, master_task)
call broadcast_scalar(tfrz_option, master_task)
call broadcast_scalar(saltflux_option, master_task)
call broadcast_scalar(ice_ref_salinity, master_task)
call broadcast_scalar(ocn_data_format, master_task)
call broadcast_scalar(bgc_data_type, master_task)
call broadcast_scalar(fe_data_type, master_task)
Expand Down Expand Up @@ -1414,6 +1419,12 @@ subroutine input_data
write(nu_diag,*) subname//' WARNING: For consistency, set tfrz_option = mushy'
endif
endif
if (ktherm == 1 .and. trim(saltflux_option) /= 'constant') then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be an error or just a warning that nobody will see?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm basically going with the example of tfrz_option here. It is not advisable to use ktherm = 1 and saltflux_option /= 'constant', but maybe people could do it if they wanted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine by me, was just asking.

if (my_task == master_task) then
write(nu_diag,*) subname//' WARNING: ktherm = 1 and saltflux_option = ',trim(saltflux_option)
write(nu_diag,*) subname//' WARNING: For consistency, set saltflux_option = constant'
endif
endif
!tcraig
if (ktherm == 1 .and. .not.sw_redist) then
if (my_task == master_task) then
Expand Down Expand Up @@ -1974,6 +1985,10 @@ subroutine input_data
write(nu_diag,*) ' WARNING: will impact ocean forcing interaction'
write(nu_diag,*) ' WARNING: coupled forcing will be modified by mixed layer routine'
endif
write(nu_diag,1030) ' saltflux_option = ', trim(saltflux_option)
if (trim(saltflux_option) == 'constant') then
write(nu_diag,1002) ' ice_ref_salinity = ',ice_ref_salinity
endif
if (trim(tfrz_option) == 'minus1p8') then
tmpstr2 = ' : constant ocean freezing temperature (-1.8C)'
elseif (trim(tfrz_option) == 'linear_salt') then
Expand Down Expand Up @@ -2378,6 +2393,7 @@ subroutine input_data
wave_spec_type_in = wave_spec_type, &
wave_spec_in=wave_spec, nfreq_in=nfreq, &
tfrz_option_in=tfrz_option, kalg_in=kalg, fbot_xfer_type_in=fbot_xfer_type, &
saltflux_option_in=saltflux_option, ice_ref_salinity_in=ice_ref_salinity, &
Pstar_in=Pstar, Cstar_in=Cstar, iceruf_in=iceruf, iceruf_ocn_in=iceruf_ocn, calc_dragio_in=calc_dragio, &
windmin_in=windmin, drhosdwind_in=drhosdwind, &
rsnw_fall_in=rsnw_fall, rsnw_tmax_in=rsnw_tmax, rhosnew_in=rhosnew, &
Expand Down Expand Up @@ -2793,7 +2809,7 @@ subroutine set_state_var (nx_block, ny_block, &
indxi, indxj ! compressed indices for cells with aicen > puny

real (kind=dbl_kind) :: &
Tsfc, sum, hbar, abar, puny, rhos, Lfresh, rad_to_deg, rsnw_fall, dist_ratio
Tsfc, sum, hbar, abar, puny, rhos, Lfresh, rad_to_deg, rsnw_fall, dist_ratio, Tffresh

real (kind=dbl_kind), dimension(ncat) :: &
ainit, hinit ! initial area, thickness
Expand Down Expand Up @@ -2835,7 +2851,7 @@ subroutine set_state_var (nx_block, ny_block, &
nt_smice_out=nt_smice, nt_smliq_out=nt_smliq, &
nt_rhos_out=nt_rhos, nt_rsnw_out=nt_rsnw)
call icepack_query_parameters(rhos_out=rhos, Lfresh_out=Lfresh, puny_out=puny, &
rad_to_deg_out=rad_to_deg, rsnw_fall_out=rsnw_fall)
rad_to_deg_out=rad_to_deg, rsnw_fall_out=rsnw_fall, Tffresh_out=Tffresh)
call icepack_query_parameters(secday_out=secday, pi_out=pi)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
Expand Down Expand Up @@ -3073,7 +3089,12 @@ subroutine set_state_var (nx_block, ny_block, &
do i = ilo, ihi
if (tmask(i,j)) then
! place ice in high latitudes where ocean sfc is cold
#ifdef CESMCOUPLED
! Option to use Tair instead.
if ( (Tair (i,j) <= Tffresh) .and. &
#else
if ( (sst (i,j) <= Tf(i,j)+p2) .and. &
#endif
(TLAT(i,j) < edge_init_sh/rad_to_deg .or. &
TLAT(i,j) > edge_init_nh/rad_to_deg) ) then
icells = icells + 1
Expand Down
35 changes: 19 additions & 16 deletions cicecore/cicedyn/infrastructure/ice_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -507,23 +507,26 @@ subroutine init_grid2
! Diagnose OpenMP thread schedule, force order in output
!-----------------------------------------------------------------

! This code does not work in CESM. Needs to be investigated further.
#ifndef CESMCOUPLED
#if defined (_OPENMP)
!$OMP PARALLEL DO ORDERED PRIVATE(iblk) SCHEDULE(runtime)
do iblk = 1, nblocks
if (my_task == master_task) then
!$OMP ORDERED
if (iblk == 1) then
call omp_get_schedule(ompsk,ompcs)
write(nu_diag,*) ''
write(nu_diag,*) subname,' OpenMP runtime thread schedule:'
write(nu_diag,*) subname,' omp schedule = ',ompsk,ompcs
endif
write(nu_diag,*) subname,' block, thread = ',iblk,OMP_GET_THREAD_NUM()
call flush_fileunit(nu_diag)
!$OMP END ORDERED
endif
enddo
!$OMP END PARALLEL DO
!$OMP PARALLEL DO ORDERED PRIVATE(iblk) SCHEDULE(runtime)
do iblk = 1, nblocks
if (my_task == master_task) then
!$OMP ORDERED
if (iblk == 1) then
call omp_get_schedule(ompsk,ompcs)
! write(nu_diag,*) ''
write(nu_diag,*) subname,' OpenMP runtime thread schedule:'
write(nu_diag,*) subname,' omp schedule = ',ompsk,ompcs
endif
write(nu_diag,*) subname,' block, thread = ',iblk,OMP_GET_THREAD_NUM()
call flush_fileunit(nu_diag)
!$OMP END ORDERED
endif
enddo
!$OMP END PARALLEL DO
#endif
#endif

!-----------------------------------------------------------------
Expand Down
8 changes: 0 additions & 8 deletions cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -749,10 +749,6 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, &
! if (ndim3 == ncat .and. ncat>1) then
if (ndim3 == ncat .and. ndims == 3) then
call pio_read_darray(File, vardesc, iodesc3d_ncat, work, status)
!#ifndef CESM1_PIO
!! This only works for PIO2
! where (work == PIO_FILL_DOUBLE) work = c0
!#endif
if (present(field_loc)) then
do n=1,ndim3
call ice_HaloUpdate (work(:,:,n,:), halo_info, &
Expand All @@ -762,10 +758,6 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, &
! elseif (ndim3 == 1) then
elseif (ndim3 == 1 .and. ndims == 2) then
call pio_read_darray(File, vardesc, iodesc2d, work, status)
!#ifndef CESM1_PIO
!! This only works for PIO2
! where (work == PIO_FILL_DOUBLE) work = c0
!#endif
if (present(field_loc)) then
call ice_HaloUpdate (work(:,:,1,:), halo_info, &
field_loc, field_type)
Expand Down
4 changes: 2 additions & 2 deletions cicecore/drivers/nuopc/cmeps/CICE_InitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ subroutine cice_init2()
call init_hist (dt) ! initialize output history file

if (kdyn == 1) then
call init_evp ! allocate dyn_evp arrays
if (kdyn == 2) then
call init_evp ! define evp dynamics parameters, variables
elseif (kdyn == 2) then
call init_eap ! define eap dynamics parameters, variables
else if (kdyn == 3) then
call init_vp ! define vp dynamics parameters, variables
Expand Down
Loading