Skip to content

Commit

Permalink
Merge pull request #11 from NOAA-EMC/develop
Browse files Browse the repository at this point in the history
Feature/punyswrad (NOAA-EMC#19)
  • Loading branch information
DeniseWorthen authored May 24, 2020
2 parents 5319928 + 990d961 commit dbfc5de
Show file tree
Hide file tree
Showing 7 changed files with 302 additions and 164 deletions.
36 changes: 32 additions & 4 deletions lanl_cice/drivers/cice/CICE_InitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,14 @@ subroutine init_restart
use ice_brine, only: init_hbrine
use ice_calendar, only: time, calendar
use ice_domain, only: nblocks
use ice_domain_size, only: ncat
use ice_domain_size, only: ncat, max_ntrcr
use ice_dyn_eap, only: read_restart_eap
use ice_dyn_shared, only: kdyn
use ice_firstyear, only: init_fy, restart_FY, read_restart_FY
use ice_flux, only: sss
use ice_grid, only: tmask
use ice_init, only: ice_ic
use ice_itd, only: aggregate
use ice_lvl, only: init_lvl, restart_lvl, read_restart_lvl
use ice_meltpond_cesm, only: init_meltponds_cesm, &
restart_pond_cesm, read_restart_pond_cesm
Expand All @@ -187,9 +189,12 @@ subroutine init_restart
restart_pond_topo, read_restart_pond_topo
use ice_restart_shared, only: runtype, restart
use ice_restart_driver, only: restartfile, restartfile_v4
use ice_state, only: tr_iage, tr_FY, tr_lvl, tr_pond_cesm, &
tr_pond_lvl, tr_pond_topo, tr_aero, trcrn, &
nt_iage, nt_FY, nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd, tr_brine
use ice_state, only: aicen, vicen, vsnon, aice, trcr, &
vice, vsno, aice0, tr_iage, trcrn, trcr_depend, &
tr_brine, tr_aero, tr_pond_topo, tr_pond_lvl, tr_pond_cesm, &
tr_lvl, nt_alvl, nt_vlvl, tr_fy, nt_iage, nt_fy, &
nt_hpnd, nt_apnd, nt_ipnd

use ice_zbgc, only: init_bgc
use ice_zbgc_shared, only: skl_bgc

Expand Down Expand Up @@ -289,6 +294,29 @@ subroutine init_restart
if (tr_brine) call init_hbrine ! brine height tracer
if (skl_bgc) call init_bgc ! biogeochemistry

!-----------------------------------------------------------------
! aggregate tracers
!-----------------------------------------------------------------

!$OMP PARALLEL DO PRIVATE(iblk)
do iblk = 1, nblocks

call aggregate (nx_block, ny_block, &
aicen(:,:,:,iblk), &
trcrn(:,:,:,:,iblk),&
vicen(:,:,:,iblk), &
vsnon(:,:,:,iblk), &
aice (:,:, iblk), &
trcr (:,:,:,iblk), &
vice (:,:, iblk), &
vsno (:,:, iblk), &
aice0(:,:, iblk), &
tmask(:,:, iblk), &
max_ntrcr, &
trcr_depend)

enddo
!$OMP END PARALLEL DO
end subroutine init_restart

!=======================================================================
Expand Down
33 changes: 25 additions & 8 deletions lanl_cice/io_netcdf/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ subroutine init_restart_write(filename_spec)

call define_rest_field(ncid,'uvel',dims)
call define_rest_field(ncid,'vvel',dims)
call define_rest_field(ncid,'coszen',dims)

call define_rest_field(ncid,'scale_factor',dims)
call define_rest_field(ncid,'swvdr',dims)
Expand Down Expand Up @@ -395,6 +396,7 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3, &
use ice_domain_size, only: max_blocks, ncat
use ice_fileunits, only: nu_diag
use ice_read_write, only: ice_read, ice_read_nc
use ice_communicate, only: my_task, master_task

integer (kind=int_kind), intent(in) :: &
nu , & ! unit number (not used for netcdf)
Expand Down Expand Up @@ -425,22 +427,37 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3, &
varid, & ! variable id
status ! status variable from netCDF routine

logical (kind=log_kind) :: &
restart_ext2 ! temporary value to allow restart_ext for writing
! but not reading if runtyp = initial

real (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks) :: &
work2 ! input array (real, 8-byte)

! set temporary variable
restart_ext2 = restart_ext
if(runtype .eq. 'initial' .and. restart_ext)restart_ext2 = .false.
if (my_task == master_task)then
if(restart_ext2)then
write(nu_diag,*)'NOTE: will read ghost cells in restart'
else
write(nu_diag,*)'NOTE: will not read ghost cells in restart'
end if
end if

if (restart_format == 'nc') then
if (present(field_loc)) then
if (ndim3 == ncat) then
if (restart_ext) then
if (restart_ext2) then
call ice_read_nc(ncid,1,vname,work,diag, &
field_loc=field_loc,field_type=field_type,restart_ext=restart_ext)
field_loc=field_loc,field_type=field_type,restart_ext=restart_ext2)
else
call ice_read_nc(ncid,1,vname,work,diag,field_loc,field_type)
endif
elseif (ndim3 == 1) then
if (restart_ext) then
if (restart_ext2) then
call ice_read_nc(ncid,1,vname,work2,diag, &
field_loc=field_loc,field_type=field_type,restart_ext=restart_ext)
field_loc=field_loc,field_type=field_type,restart_ext=restart_ext2)
else
call ice_read_nc(ncid,1,vname,work2,diag,field_loc,field_type)
endif
Expand All @@ -450,14 +467,14 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3, &
endif
else
if (ndim3 == ncat) then
if (restart_ext) then
call ice_read_nc(ncid, 1, vname, work, diag, restart_ext=restart_ext)
if (restart_ext2) then
call ice_read_nc(ncid, 1, vname, work, diag, restart_ext=restart_ext2)
else
call ice_read_nc(ncid, 1, vname, work, diag)
endif
elseif (ndim3 == 1) then
if (restart_ext) then
call ice_read_nc(ncid, 1, vname, work2, diag, restart_ext=restart_ext)
if (restart_ext2) then
call ice_read_nc(ncid, 1, vname, work2, diag, restart_ext=restart_ext2)
else
call ice_read_nc(ncid, 1, vname, work2, diag)
endif
Expand Down
6 changes: 5 additions & 1 deletion lanl_cice/source/ice_flux.F90
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ module ice_flux
albice , & ! bare ice albedo
albsno , & ! snow albedo
albpnd , & ! melt pond albedo
apeff_ai ! effective pond area used for radiation calculation
apeff_ai , & ! effective pond area used for radiation calculation
snowfrac ! snow fraction used in radiation

real (kind=dbl_kind), &
dimension(nx_block,ny_block,max_blocks,max_nstrm), target, public :: &
Expand All @@ -210,6 +211,9 @@ module ice_flux
fswthruidr, & ! nir dir shortwave penetrating to ocean (W/m^2)
fswthruidf ! nir dif shortwave penetrating to ocean (W/m^2)

real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: &
fswthrun_ai ! per-category fswthru * ai (W/m^2)

real (kind=dbl_kind), &
dimension (nx_block,ny_block,max_aero,max_blocks), target, public :: &
faero_ocn ! aerosol flux to ocean (kg/m^2/s)
Expand Down
7 changes: 5 additions & 2 deletions lanl_cice/source/ice_restart_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ subroutine dumpfile(filename_spec)
use ice_domain_size, only: nilyr, nslyr, ncat, max_blocks
use ice_fileunits, only: nu_diag, nu_rst_pointer, nu_dump
use ice_flux, only: scale_factor, swvdr, swvdf, swidr, swidf, &
strocnxT, strocnyT, sst, frzmlt, iceumask, &
strocnxT, strocnyT, sst, frzmlt, iceumask, coszen, &
stressp_1, stressp_2, stressp_3, stressp_4, &
stressm_1, stressm_2, stressm_3, stressm_4, &
stress12_1, stress12_2, stress12_3, stress12_4
Expand Down Expand Up @@ -125,6 +125,7 @@ subroutine dumpfile(filename_spec)
!-----------------------------------------------------------------
! radiation fields
!-----------------------------------------------------------------
call write_restart_field(nu_dump,0,coszen,'ruf8','coszen',1,diag)
call write_restart_field(nu_dump,0,scale_factor,'ruf8','scale_factor',1,diag)

call write_restart_field(nu_dump,0,swvdr,'ruf8','swvdr',1,diag)
Expand Down Expand Up @@ -200,7 +201,7 @@ subroutine restartfile (ice_ic)
max_ntrcr, max_blocks
use ice_fileunits, only: nu_diag, nu_rst_pointer, nu_restart
use ice_flux, only: scale_factor, swvdr, swvdf, swidr, swidf, &
strocnxT, strocnyT, sst, frzmlt, iceumask, &
strocnxT, strocnyT, sst, frzmlt, iceumask, coszen, &
stressp_1, stressp_2, stressp_3, stressp_4, &
stressm_1, stressm_2, stressm_3, stressm_4, &
stress12_1, stress12_2, stress12_3, stress12_4
Expand Down Expand Up @@ -327,6 +328,8 @@ subroutine restartfile (ice_ic)
if (my_task == master_task) &
write(nu_diag,*) 'radiation fields'

call read_restart_field(nu_restart,0,coszen,'ruf8', &
'coszen',1,diag, field_loc_center, field_type_scalar)
call read_restart_field(nu_restart,0,scale_factor,'ruf8', &
'scale_factor',1,diag, field_loc_center, field_type_scalar)
call read_restart_field(nu_restart,0,swvdr,'ruf8', &
Expand Down
Loading

0 comments on commit dbfc5de

Please sign in to comment.