Skip to content

Commit

Permalink
Merge pull request #20 from apcraig/icep230202
Browse files Browse the repository at this point in the history
Merge #03e7e57ce76ea5 from CICE-Consortium main to branch, Feb 2, 2023
  • Loading branch information
apcraig authored Feb 3, 2023
2 parents ef7491f + 47e1791 commit 87db73b
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 26 deletions.
39 changes: 27 additions & 12 deletions columnphysics/icepack_parameters.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1027,47 +1027,62 @@ subroutine icepack_init_parameters( &
endif

if (present(snowage_tau_in) ) then
if (size(snowage_tau_in) /= isnw_T*isnw_Tgrd*isnw_rhos) then
if (size(snowage_tau_in,dim=1) /= isnw_rhos .or. &
size(snowage_tau_in,dim=2) /= isnw_Tgrd .or. &
size(snowage_tau_in,dim=3) /= isnw_T ) then
call icepack_warnings_add(subname//' incorrect size of snowage_tau_in')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
elseif (.not.allocated(snowage_tau)) then
allocate(snowage_tau(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_tau(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_tau = snowage_tau_in
elseif (size(snowage_tau) /= isnw_T*isnw_Tgrd*isnw_rhos) then
elseif &
(size(snowage_tau,dim=1) /= isnw_rhos .or. &
size(snowage_tau,dim=2) /= isnw_Tgrd .or. &
size(snowage_tau,dim=3) /= isnw_T ) then
deallocate(snowage_tau)
allocate(snowage_tau(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_tau(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_tau = snowage_tau_in
else
snowage_tau = snowage_tau_in
endif
endif

if (present(snowage_kappa_in) ) then
if (size(snowage_kappa_in) /= isnw_T*isnw_Tgrd*isnw_rhos) then
if (size(snowage_kappa_in,dim=1) /= isnw_rhos .or. &
size(snowage_kappa_in,dim=2) /= isnw_Tgrd .or. &
size(snowage_kappa_in,dim=3) /= isnw_T ) then
call icepack_warnings_add(subname//' incorrect size of snowage_kappa_in')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
elseif (.not.allocated(snowage_kappa)) then
allocate(snowage_kappa(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_kappa(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_kappa = snowage_kappa_in
elseif (size(snowage_kappa) /= isnw_T*isnw_Tgrd*isnw_rhos) then
elseif &
(size(snowage_kappa,dim=1) /= isnw_rhos .or. &
size(snowage_kappa,dim=2) /= isnw_Tgrd .or. &
size(snowage_kappa,dim=3) /= isnw_T ) then
deallocate(snowage_kappa)
allocate(snowage_kappa(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_kappa(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_kappa = snowage_kappa_in
else
snowage_kappa = snowage_kappa_in
endif
endif

if (present(snowage_drdt0_in) ) then
if (size(snowage_drdt0_in) /= isnw_T*isnw_Tgrd*isnw_rhos) then
if (size(snowage_drdt0_in,dim=1) /= isnw_rhos .or. &
size(snowage_drdt0_in,dim=2) /= isnw_Tgrd .or. &
size(snowage_drdt0_in,dim=3) /= isnw_T ) then
call icepack_warnings_add(subname//' incorrect size of snowage_drdt0_in')
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
elseif (.not.allocated(snowage_drdt0)) then
allocate(snowage_drdt0(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_drdt0(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_drdt0 = snowage_drdt0_in
elseif (size(snowage_drdt0) /= isnw_T*isnw_Tgrd*isnw_rhos) then
elseif &
(size(snowage_drdt0,dim=1) /= isnw_rhos .or. &
size(snowage_drdt0,dim=2) /= isnw_Tgrd .or. &
size(snowage_drdt0,dim=3) /= isnw_T ) then
deallocate(snowage_drdt0)
allocate(snowage_drdt0(isnw_T,isnw_Tgrd,isnw_rhos))
allocate(snowage_drdt0(isnw_rhos,isnw_Tgrd,isnw_T))
snowage_drdt0 = snowage_drdt0_in
else
snowage_drdt0 = snowage_drdt0_in
Expand Down
49 changes: 46 additions & 3 deletions columnphysics/icepack_snow.F90
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,46 @@ subroutine icepack_init_snow
min_T = 223.15_dbl_kind
del_T = 5.0_dbl_kind
lin_T = .true.
allocate (snowage_tau (isnw_rhos,isnw_Tgrd,isnw_T))
allocate (snowage_kappa(isnw_rhos,isnw_Tgrd,isnw_T))
allocate (snowage_drdt0(isnw_rhos,isnw_Tgrd,isnw_T))
! check if these are already allocated/set, if so, make sure size is OK
if (allocated(snowage_tau)) then
if (size(snowage_tau,dim=1) /= isnw_rhos .or. &
size(snowage_tau,dim=2) /= isnw_Tgrd .or. &
size(snowage_tau,dim=3) /= isnw_T ) then
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//'ERROR: snowage_tau size snw_aging_table=snicar')
return
endif
else
allocate (snowage_tau (isnw_rhos,isnw_Tgrd,isnw_T))
endif

if (allocated(snowage_kappa)) then
if (size(snowage_kappa,dim=1) /= isnw_rhos .or. &
size(snowage_kappa,dim=2) /= isnw_Tgrd .or. &
size(snowage_kappa,dim=3) /= isnw_T ) then
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//'ERROR: snowage_kappa size snw_aging_table=snicar')
return
endif
else
allocate (snowage_kappa(isnw_rhos,isnw_Tgrd,isnw_T))
endif

if (allocated(snowage_drdt0)) then
if (size(snowage_drdt0,dim=1) /= isnw_rhos .or. &
size(snowage_drdt0,dim=2) /= isnw_Tgrd .or. &
size(snowage_drdt0,dim=3) /= isnw_T ) then
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//'ERROR: snowage_drdt0 size snw_aging_table=snicar')
return
endif
else
allocate (snowage_drdt0(isnw_rhos,isnw_Tgrd,isnw_T))
endif

if (allocated(snowage_rhos)) deallocate(snowage_rhos)
if (allocated(snowage_Tgrd)) deallocate(snowage_Tgrd)
if (allocated(snowage_T)) deallocate(snowage_T)
allocate (snowage_rhos (isnw_rhos))
allocate (snowage_Tgrd (isnw_Tgrd))
allocate (snowage_T (isnw_T))
Expand Down Expand Up @@ -137,6 +174,12 @@ subroutine icepack_init_snow
min_T = 243.15_dbl_kind
del_T = 5.0_dbl_kind
lin_T = .true.
if (allocated(snowage_tau)) deallocate(snowage_tau)
if (allocated(snowage_kappa)) deallocate(snowage_kappa)
if (allocated(snowage_drdt0)) deallocate(snowage_drdt0)
if (allocated(snowage_rhos)) deallocate(snowage_rhos)
if (allocated(snowage_Tgrd)) deallocate(snowage_Tgrd)
if (allocated(snowage_T)) deallocate(snowage_T)
allocate (snowage_tau (isnw_rhos,isnw_Tgrd,isnw_T))
allocate (snowage_kappa(isnw_rhos,isnw_Tgrd,isnw_T))
allocate (snowage_drdt0(isnw_rhos,isnw_Tgrd,isnw_T))
Expand Down
2 changes: 1 addition & 1 deletion columnphysics/icepack_therm_vertical.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ subroutine thickness_changes (nilyr, nslyr, &
qsub = zqsn(k) - rhos*Lvap ! qsub < 0
dhs = max (-dzs(k), esub/qsub) ! esub > 0, dhs < 0

mass = massice(1) + massliq(1)
mass = massice(k) + massliq(k)
massi = c0
if (dzs(k) > puny) massi = c1 + dhs/dzs(k)
massice(k) = massice(k) * massi
Expand Down
5 changes: 1 addition & 4 deletions configuration/driver/icedrv_calendar.F90
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ module icedrv_calendar
year_init, & ! initial year
nyr , & ! year number
idate , & ! date (yyyymmdd)
idate0 , & ! initial date (yyyymmdd)
sec , & ! elapsed seconds into date
npt , & ! total number of time steps (dt)
ndtd , & ! number of dynamics subcycles: dt_dyn=dt/ndtd
Expand Down Expand Up @@ -166,13 +165,11 @@ subroutine init_calendar
tday = (time-sec)/secday + c1 ! absolute day number

! Convert the current timestep into a calendar date
call sec2time(nyr,month,mday,basis_seconds+sec)
call sec2time(nyr,month,mday,basis_seconds+time)

yday = mday + daycal(month) ! day of the year
nyr = nyr - year_init + 1 ! year number

idate0 = (nyr+year_init-1)*10000 + month*100 + mday ! date (yyyymmdd)

end subroutine init_calendar

!=======================================================================
Expand Down
15 changes: 9 additions & 6 deletions configuration/driver/icedrv_history.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module icedrv_history

subroutine history_write()

use icedrv_calendar, only: idate0, days_per_year, use_leap_years
use icedrv_calendar, only: days_per_year, use_leap_years, year_init
use icedrv_calendar, only: time, time0, secday, istep1, idate, sec
use icedrv_state, only: aice, vice, vsno, uvel, vvel, divu, shear, strength
use icedrv_state, only: trcr, trcrn
Expand Down Expand Up @@ -68,7 +68,11 @@ subroutine history_write()
count1(1), count2(2), count3(3), count4(4), & ! cdf start/count arrays
varid, & ! cdf varid
status, & ! cdf status flag
iflag ! history file attributes
iflag, & ! history file attributes
sec0, & ! number of seconds into the day at istep0
h0, & ! start hour
m0, & ! start minute
s0 ! start second

character (len=8) :: &
cdate ! date string
Expand Down Expand Up @@ -164,9 +168,8 @@ subroutine history_write()
if (status /= nf90_noerr) call icedrv_system_abort(string=subname//' ERROR: def_var time')
status = nf90_put_att(ncid,varid,'long_name','model time')
if (status /= nf90_noerr) call icedrv_system_abort(string=subname//' ERROR: put_att time long_name')
write(cdate,'(i8.8)') idate0
write(tmpstr,'(a,a,a,a,a,a,a,a)') 'days since ', &
cdate(1:4),'-',cdate(5:6),'-',cdate(7:8),' 00:00:00'
write(tmpstr,'(a,i0,a)') 'days since ', &
year_init,'-01-01 00:00:00'
status = nf90_put_att(ncid,varid,'units',trim(tmpstr))
if (status /= nf90_noerr) call icedrv_system_abort(string=subname//' ERROR: put_att time units')
if (days_per_year == 360) then
Expand Down Expand Up @@ -282,7 +285,7 @@ subroutine history_write()

status = nf90_inq_varid(ncid,'time',varid)
if (status /= nf90_noerr) call icedrv_system_abort(string=subname//' ERROR: inq_var '//'time')
value = (time-time0)/secday
value = time/secday
status = nf90_put_var(ncid,varid,value,start=(/timcnt/))
if (status /= nf90_noerr) call icedrv_system_abort(string=subname//' ERROR: put_var '//'time')

Expand Down

0 comments on commit 87db73b

Please sign in to comment.