Skip to content

Commit

Permalink
Update CICE to latest Consortium master (NOAA-EMC#26)
Browse files Browse the repository at this point in the history
update CICE and Icepack

* changes the criteria for aborting ice for thermo-conservation errors
* updates the time manager
* fixes two bugs in ice_therm_mushy
* updates Icepack to Consortium master w/ flip of abort flag for troublesome IC cases
  • Loading branch information
DeniseWorthen committed Sep 22, 2023
1 parent 0a4a2ac commit d77e6bd
Show file tree
Hide file tree
Showing 85 changed files with 2,569 additions and 333 deletions.
16 changes: 16 additions & 0 deletions cice.setup
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,18 @@ if ((${dosuite} == 1 || ${dotest} == 1) && ${testid} == ${spval}) then
exit -1
endif
# This creates a new sandbox and modifies the source code for "improved" lcov analysis
# Turn this if block off if you don't want coverage to do that
if ($coverage == 1) then
set sandbox_lcov = ${ICE_SANDBOX}/../cice_lcov_${sdate}-${stime}
cp -p -r ${ICE_SANDBOX} ${sandbox_lcov}
echo "shifting to sandbox = ${sandbox_lcov}"
set ICE_SANDBOX = ${sandbox_lcov}
set ICE_SCRIPTS = "${ICE_SANDBOX}/configuration/scripts"
cd ${ICE_SANDBOX}
${ICE_SCRIPTS}/tests/lcov_modify_source.sh
endif
#---------------------------------------------------------------------
# Setup tsfile and test suite support stuff
Expand Down Expand Up @@ -1051,7 +1063,11 @@ cd ${testname_base}
source ./cice.settings
if (\${dobuild} == true) then
if (\${doreuse} == true) then
<<<<<<< HEAD
set ciceexe = "../ciceexe.\${ICE_COMPILER}.\${ICE_COMMDIR}.\${ICE_BLDDEBUG}.\${ICE_THREADED}.\${ICE_IOTYPE}"
=======
set ciceexe = "../ciceexe.\${ICE_TARGET}.\${ICE_ENVNAME}.\${ICE_COMMDIR}.\${ICE_BLDDEBUG}.\${ICE_THREADED}.\${ICE_IOTYPE}"
>>>>>>> 519d3392 (Update CICE to latest Consortium master (#26))
./cice.build --exe \${ciceexe}
if !(-e \${ciceexe}) cp -p \${ICE_RUNDIR}/cice \${ciceexe}
else
Expand Down
76 changes: 44 additions & 32 deletions cicecore/cicedyn/analysis/ice_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@ module ice_diagnostics

implicit none
private
public :: runtime_diags, init_mass_diags, init_diags, &
print_state, print_points_state, diagnostic_abort

public :: runtime_diags, init_mass_diags, init_diags, debug_ice, &
print_state, diagnostic_abort

! diagnostic output file
character (len=char_len), public :: diag_file

! point print data

logical (kind=log_kind), public :: &
debug_model , & ! if true, debug model at high level
print_points , & ! if true, print point data
print_global ! if true, print global data

integer (kind=int_kind), public :: &
debug_model_step = 999999999 ! begin printing at istep1=debug_model_step

integer (kind=int_kind), parameter, public :: &
npnt = 2 ! total number of points to be printed

Expand Down Expand Up @@ -87,16 +90,6 @@ module ice_diagnostics
totaeron , & ! total aerosol mass
totaeros ! total aerosol mass

! printing info for routine print_state
! iblkp, ip, jp, mtask identify the grid cell to print
! character (char_len) :: plabel
integer (kind=int_kind), parameter, public :: &
check_step = 999999999, & ! begin printing at istep1=check_step
iblkp = 1, & ! block number
ip = 72, & ! i index
jp = 11, & ! j index
mtask = 0 ! my_task

!=======================================================================

contains
Expand Down Expand Up @@ -1525,20 +1518,39 @@ end subroutine init_diags

!=======================================================================

! This routine is useful for debugging.
! Calls to it should be inserted in the form (after thermo, for example)
! do iblk = 1, nblocks
! do j=jlo,jhi
! do i=ilo,ihi
! plabel = 'post thermo'
! if (istep1 >= check_step .and. iblk==iblkp .and i==ip &
! .and. j==jp .and. my_task == mtask) &
! call print_state(plabel,i,j,iblk)
! enddo
! enddo
! This routine is useful for debugging
! author Elizabeth C. Hunke, LANL

subroutine debug_ice(iblk, plabeld)

use ice_kinds_mod
use ice_calendar, only: istep1
use ice_communicate, only: my_task
use ice_blocks, only: nx_block, ny_block

character (char_len), intent(in) :: plabeld
integer (kind=int_kind), intent(in) :: iblk

! local
integer (kind=int_kind) :: i, j, m
character(len=*), parameter :: subname='(debug_ice)'

! tcraig, do this only on one point, the first point
! do m = 1, npnt
m = 1
if (istep1 >= debug_model_step .and. &
iblk == pbloc(m) .and. my_task == pmloc(m)) then
i = piloc(m)
j = pjloc(m)
call print_state(plabeld,i,j,iblk)
endif
! enddo
!
! 'use ice_diagnostics' may need to be inserted also

end subroutine debug_ice

!=======================================================================

! This routine is useful for debugging.
! author: Elizabeth C. Hunke, LANL

subroutine print_state(plabel,i,j,iblk)
Expand Down Expand Up @@ -1587,7 +1599,7 @@ subroutine print_state(plabel,i,j,iblk)

this_block = get_block(blocks_ice(iblk),iblk)

write(nu_diag,*) plabel
write(nu_diag,*) subname,plabel
write(nu_diag,*) 'istep1, my_task, i, j, iblk:', &
istep1, my_task, i, j, iblk
write(nu_diag,*) 'Global i and j:', &
Expand Down Expand Up @@ -1692,16 +1704,14 @@ subroutine print_state(plabel,i,j,iblk)
write(nu_diag,*) ' evap = ',evap (i,j,iblk)
write(nu_diag,*) ' flwout = ',flwout(i,j,iblk)
write(nu_diag,*) ' '
call flush_fileunit(nu_diag)

end subroutine print_state

!=======================================================================
#ifdef UNDEPRECATE_print_points_state

! This routine is useful for debugging.
! Calls can be inserted anywhere and it will print info on print_points points
! call print_points_state(plabel)
!
! 'use ice_diagnostics' may need to be inserted also

subroutine print_points_state(plabel,ilabel)

Expand Down Expand Up @@ -1757,6 +1767,7 @@ subroutine print_points_state(plabel,ilabel)
write(llabel,'(a)') 'pps:'//trim(llabel)
endif

write(nu_diag,*) subname
write(nu_diag,*) trim(llabel),'istep1, my_task, i, j, iblk=', &
istep1, my_task, i, j, iblk
write(nu_diag,*) trim(llabel),'Global i and j=', &
Expand Down Expand Up @@ -1835,12 +1846,13 @@ subroutine print_points_state(plabel,ilabel)
write(nu_diag,*) ' evap = ',evap (i,j,iblk)
write(nu_diag,*) ' flwout = ',flwout(i,j,iblk)
write(nu_diag,*) ' '
call flush_fileunit(nu_diag)

endif ! my_task
enddo ! ncnt

end subroutine print_points_state

#endif
!=======================================================================

! prints error information prior to aborting
Expand Down
17 changes: 17 additions & 0 deletions cicecore/cicedyn/analysis/ice_history.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2273,10 +2273,18 @@ subroutine accum_hist (dt)
avgct(ns) = c1
else ! write averages over time histfreq
avgct(ns) = avgct(ns) + c1
<<<<<<< HEAD:cicecore/cicedyn/analysis/ice_history.F90
endif
if (avgct(ns) == c1) then
timedbl = (timesecs-dt)/(secday)
time_beg(ns) = real(timedbl,kind=real_kind)
=======
! if (avgct(ns) == c1) time_beg(ns) = (time-dt)/int(secday)
if (avgct(ns) == c1) then
time_beg(ns) = (timesecs-dt)/int(secday)
time_beg(ns) = real(time_beg(ns),kind=real_kind)
endif
>>>>>>> 519d3392 (Update CICE to latest Consortium master (#26)):cicecore/cicedynB/analysis/ice_history.F90
endif
enddo

Expand Down Expand Up @@ -4550,8 +4558,13 @@ subroutine accum_hist (dt)
enddo ! iblk
!$OMP END PARALLEL DO

<<<<<<< HEAD:cicecore/cicedyn/analysis/ice_history.F90
timedbl = timesecs/secday
time_end(ns) = real(timedbl,kind=real_kind)
=======
time_end(ns) = timesecs/int(secday)
time_end(ns) = real(time_end(ns),kind=real_kind)
>>>>>>> 519d3392 (Update CICE to latest Consortium master (#26)):cicecore/cicedynB/analysis/ice_history.F90

!---------------------------------------------------------------
! write file
Expand Down Expand Up @@ -4643,7 +4656,11 @@ subroutine accum_hist (dt)
enddo
endif ! new_year

<<<<<<< HEAD:cicecore/cicedyn/analysis/ice_history.F90
if ( (mmonth .eq. 7) .and. new_month ) then
=======
if ( (mmonth .eq. 7) .and. new_month ) then
>>>>>>> 519d3392 (Update CICE to latest Consortium master (#26)):cicecore/cicedynB/analysis/ice_history.F90
do j=jlo,jhi
do i=ilo,ihi
! reset SH Jul 1
Expand Down
56 changes: 56 additions & 0 deletions cicecore/cicedyn/analysis/ice_history_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -735,12 +735,18 @@ subroutine construct_filename(ncfile,suffix,ns)
iyear = myear
imonth = mmonth
iday = mday
<<<<<<< HEAD:cicecore/cicedyn/analysis/ice_history_shared.F90
isec = int(msec - dt,int_kind)

<<<<<<< HEAD:cicecore/cicedyn/analysis/ice_history_shared.F90
=======
if (write_ic) isec = sec
>>>>>>> 46fcfbaa (changes for coldstart running):cicecore/cicedynB/analysis/ice_history_shared.F90
=======
isec = msec - dt

if (write_ic) isec = msec
>>>>>>> 519d3392 (Update CICE to latest Consortium master (#26)):cicecore/cicedynB/analysis/ice_history_shared.F90
! construct filename
if (write_ic) then
isec = msec
Expand All @@ -749,6 +755,7 @@ subroutine construct_filename(ncfile,suffix,ns)
imonth,'-',iday,'-',isec,'.',trim(suffix)
else

<<<<<<< HEAD:cicecore/cicedyn/analysis/ice_history_shared.F90
if (hist_avg(ns)) then
if (histfreq(ns) == '1' .or. histfreq(ns) == 'h'.or.histfreq(ns) == 'H') then
! do nothing
Expand All @@ -763,12 +770,29 @@ subroutine construct_filename(ncfile,suffix,ns)
iday = iday - 1
endif
endif
=======
if (hist_avg .and. histfreq(ns) /= '1') then
if (histfreq(ns) == 'h'.or.histfreq(ns) == 'H') then
! do nothing
elseif (new_year) then
iyear = iyear - 1
imonth = 12
iday = daymo(imonth)
elseif (new_month) then
imonth = mmonth - 1
iday = daymo(imonth)
elseif (new_day) then
iday = iday - 1
endif
endif
>>>>>>> 519d3392 (Update CICE to latest Consortium master (#26)):cicecore/cicedynB/analysis/ice_history_shared.F90

cstream = ''
!echmod ! this was implemented for CESM but it breaks post-processing software
!echmod ! of other groups (including RASM which uses CESMCOUPLED)
!echmod if (ns > 1) write(cstream,'(i1.1)') ns-1

<<<<<<< HEAD:cicecore/cicedyn/analysis/ice_history_shared.F90
if (hist_avg(ns)) then ! write averaged data
if (histfreq(ns) == '1' .and. histfreq_n(ns) == 1) then ! timestep
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
Expand All @@ -795,13 +819,45 @@ subroutine construct_filename(ncfile,suffix,ns)
history_file(1:lenstr(history_file))//trim(cstream),'.', &
iyear,'.',trim(suffix)
endif
=======
if (histfreq(ns) == '1') then ! instantaneous, write every dt
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'_inst.', &
iyear,'-',imonth,'-',iday,'-',msec,'.',suffix
>>>>>>> 519d3392 (Update CICE to latest Consortium master (#26)):cicecore/cicedynB/analysis/ice_history_shared.F90

else ! instantaneous
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'_inst.', &
iyear,'-',imonth,'-',iday,'-',msec,'.',trim(suffix)
endif

<<<<<<< HEAD:cicecore/cicedyn/analysis/ice_history_shared.F90
=======
if (histfreq(ns) == 'd'.or.histfreq(ns) == 'D') then ! daily
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream), &
'.',iyear,'-',imonth,'-',iday,'.',suffix
elseif (histfreq(ns) == 'h'.or.histfreq(ns) == 'H') then ! hourly
write(ncfile,'(a,a,i2.2,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'_', &
histfreq_n(ns),'h.',iyear,'-',imonth,'-',iday,'-',msec,'.',suffix
elseif (histfreq(ns) == 'm'.or.histfreq(ns) == 'M') then ! monthly
write(ncfile,'(a,a,i4.4,a,i2.2,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'.', &
iyear,'-',imonth,'.',suffix
elseif (histfreq(ns) == 'y'.or.histfreq(ns) == 'Y') then ! yearly
write(ncfile,'(a,a,i4.4,a,a)') &
history_file(1:lenstr(history_file))//trim(cstream),'.', &
iyear,'.',suffix
endif

else ! instantaneous with histfreq > dt
write(ncfile,'(a,a,i4.4,a,i2.2,a,i2.2,a,i5.5,a,a)') &
history_file(1:lenstr(history_file)),'_inst.', &
iyear,'-',imonth,'-',iday,'-',msec,'.',suffix
endif
>>>>>>> 519d3392 (Update CICE to latest Consortium master (#26)):cicecore/cicedynB/analysis/ice_history_shared.F90
endif

end subroutine construct_filename
Expand Down
Loading

0 comments on commit d77e6bd

Please sign in to comment.