Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)

scol_valid = (scol_mask == 1)
if (.not. scol_valid) then
write(6,*)'DEBUG: i am here'
! Advertise fields
call ice_advertise_fields(gcomp, importState, exportState, flds_scalar_name, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down
118 changes: 20 additions & 98 deletions cicecore/drivers/nuopc/cmeps/ice_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module ice_import_export
use ice_blocks , only : block, get_block, nx_block, ny_block
use ice_domain , only : nblocks, blocks_ice, halo_info, distrb_info
use ice_domain_size , only : nx_global, ny_global, block_size_x, block_size_y, max_blocks, ncat
use ice_domain_size , only : nfreq, nfsd
use ice_exit , only : abort_ice
use ice_flux , only : strairxt, strairyt, strocnxt, strocnyt
use ice_flux , only : alvdr, alidr, alvdf, alidf, Tref, Qref, Uref
Expand All @@ -24,8 +23,7 @@ module ice_import_export
use ice_flux , only : fsnow, uocn, vocn, sst, ss_tltx, ss_tlty, frzmlt
use ice_flux , only : send_i2x_per_cat
use ice_flux , only : sss, Tf, wind, fsw
use ice_arrays_column , only : floe_rad_c, wave_spectrum
use ice_state , only : vice, vsno, aice, aicen_init, trcr, trcrn
use ice_state , only : vice, vsno, aice, aicen_init, trcr
use ice_grid , only : tlon, tlat, tarea, tmask, anglet, hm
use ice_grid , only : grid_type, t2ugrid_vector
use ice_mesh_mod , only : ocn_gridcell_frac
Expand All @@ -36,10 +34,8 @@ module ice_import_export
use ice_shr_methods , only : chkerr, state_reset
use icepack_intfc , only : icepack_warnings_flush, icepack_warnings_aborted
use icepack_intfc , only : icepack_query_parameters, icepack_query_tracer_flags
use icepack_intfc , only : icepack_query_tracer_indices
use icepack_intfc , only : icepack_liquidus_temperature
use icepack_intfc , only : icepack_sea_freezing_temperature
use icepack_parameters , only : puny, c2
use cice_wrapper_mod , only : t_startf, t_stopf, t_barrierf
#ifdef CESMCOUPLED
use shr_frz_mod , only : shr_frz_freezetemp
Expand Down Expand Up @@ -191,16 +187,11 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam
! in the cmeps esmFldsExchange_xxx_mod.F90 that is model specific
! from atm - black carbon deposition fluxes (3)
call fldlist_add(fldsToIce_num, fldsToIce, 'Faxa_bcph', ungridded_lbound=1, ungridded_ubound=3)
! from atm - wet dust deposition fluxes (4 sizes)
! from atm - wet dust deposition frluxes (4 sizes)
call fldlist_add(fldsToIce_num, fldsToIce, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4)
! from atm - dry dust deposition fluxes (4 sizes)
! from - atm dry dust deposition frluxes (4 sizes)
call fldlist_add(fldsToIce_num, fldsToIce, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4)

! the following are advertised but might not be connected if they are not advertised in the
! in the cmeps esmFldsExchange_xxx_mod.F90 that is model specific
! from wave
call fldlist_add(fldsToIce_num, fldsToIce, 'Sw_elevation_spectrum', ungridded_lbound=1, ungridded_ubound=25)

do n = 1,fldsToIce_num
call NUOPC_Advertise(importState, standardName=fldsToIce(n)%stdname, &
TransferOfferGeomObject='will provide', rc=rc)
Expand All @@ -223,8 +214,6 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam
call fldlist_add(fldsFrIce_num, fldsFrIce, 'Si_qref' )
call fldlist_add(fldsFrIce_num, fldsFrIce, 'Si_snowh' )
call fldlist_add(fldsFrIce_num, fldsFrIce, 'Si_u10' )
call fldlist_add(fldsFrIce_num, fldsFrIce, 'Si_thick' )
call fldlist_add(fldsFrIce_num, fldsFrIce, 'Si_floediam' )
call fldlist_add(fldsFrIce_num, fldsFrIce, 'inst_ice_vis_dir_albedo' )
call fldlist_add(fldsFrIce_num, fldsFrIce, 'inst_ice_ir_dir_albedo' )
call fldlist_add(fldsFrIce_num, fldsFrIce, 'inst_ice_vis_dif_albedo' )
Expand Down Expand Up @@ -303,7 +292,7 @@ subroutine ice_realize_fields(gcomp, mesh, flds_scalar_name, flds_scalar_num, rc
type(ESMF_State) :: exportState
type(ESMF_Field) :: lfield
integer :: numOwnedElements
integer :: i, j, iblk, n, k
integer :: i, j, iblk, n
integer :: ilo, ihi, jlo, jhi ! beginning and end of physical domain
type(block) :: this_block ! block information for current block
real(dbl_kind), allocatable :: mesh_areas(:)
Expand Down Expand Up @@ -360,38 +349,28 @@ subroutine ice_realize_fields(gcomp, mesh, flds_scalar_name, flds_scalar_num, rc
allocate(mesh_areas(numOwnedElements))
mesh_areas(:) = dataptr(:)

call NUOPC_CompAttributeGet(gcomp, name='mesh_atm', value=mesh_atm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompAttributeGet(gcomp, name='mesh_ice', value=mesh_ice, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Determine flux correction factors (module variables)
allocate(model_areas(numOwnedElements))
allocate(mod2med_areacor(numOwnedElements))
allocate(med2mod_areacor(numOwnedElements))
mod2med_areacor(:) = 1._dbl_kind
med2mod_areacor(:) = 1._dbl_kind

! flux correction factors are only set if the atm and ice meshes are different
! this is needed in order for single column mode to work correctly
if (trim(mesh_atm) /= trim(mesh_ice)) then
n = 0
do iblk = 1, nblocks
this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi
do j = jlo, jhi
do i = ilo, ihi
n = n+1
model_areas(n) = tarea(i,j,iblk)/(radius*radius)
mod2med_areacor(n) = model_areas(n) / mesh_areas(n)
med2mod_areacor(n) = mesh_areas(n) / model_areas(n)
enddo
n = 0
do iblk = 1, nblocks
this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo
ihi = this_block%ihi
jlo = this_block%jlo
jhi = this_block%jhi
do j = jlo, jhi
do i = ilo, ihi
n = n+1
model_areas(n) = tarea(i,j,iblk)/(radius*radius)
mod2med_areacor(n) = model_areas(n) / mesh_areas(n)
med2mod_areacor(n) = mesh_areas(n) / model_areas(n)
enddo
enddo
end if
enddo
deallocate(model_areas)
deallocate(mesh_areas)

Expand Down Expand Up @@ -424,7 +403,7 @@ subroutine ice_import( importState, rc )
! local variables
integer,parameter :: nflds=16
integer,parameter :: nfldv=6
integer :: i, j, iblk, n, k
integer :: i, j, iblk, n
integer :: ilo, ihi, jlo, jhi !beginning and end of physical domain
type(block) :: this_block ! block information for current block
real (kind=dbl_kind),allocatable :: aflds(:,:,:,:)
Expand Down Expand Up @@ -579,30 +558,6 @@ subroutine ice_import( importState, rc )
end do
!$OMP END PARALLEL DO

! import wave elevation spectrum from wave (frequencies 1-25, assume that nfreq is 25)
if (State_FldChk(importState, 'Sw_elevation_spectrum')) then
if (nfreq /= 25) then
call abort_ice(trim(subname)//": ERROR nfreq not equal to 25 ")
end if
call state_getfldptr(importState, 'Sw_elevation_spectrum', fldptr=dataPtr2d, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
do k = 1,nfreq
n = 0
do iblk = 1, nblocks
this_block = get_block(blocks_ice(iblk),iblk)
ilo = this_block%ilo; ihi = this_block%ihi
jlo = this_block%jlo; jhi = this_block%jhi
do j = jlo, jhi
do i = ilo, ihi
n = n+1
wave_spectrum(i,j,k,iblk) = dataPtr2d(k,n)
end do
end do
end do
end do
end if


if ( State_fldChk(importState, 'Sa_ptem') .and. State_fldchk(importState,'air_density_height_lowest')) then
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
Expand Down Expand Up @@ -889,7 +844,7 @@ subroutine ice_export( exportState, rc )

! local variables
type(block) :: this_block ! block information for current block
integer :: i, j, iblk, n, k ! incides
integer :: i, j, iblk, n ! incides
integer :: n2 ! thickness category index
integer :: ilo, ihi, jlo, jhi ! beginning and end of physical domain
real (kind=dbl_kind) :: workx, worky ! tmps for converting grid
Expand All @@ -903,10 +858,7 @@ subroutine ice_export( exportState, rc )
real (kind=dbl_kind) :: tauxo (nx_block,ny_block,max_blocks) ! ice/ocean stress
real (kind=dbl_kind) :: tauyo (nx_block,ny_block,max_blocks) ! ice/ocean stress
real (kind=dbl_kind) :: ailohi(nx_block,ny_block,max_blocks) ! fractional ice area
real (kind=dbl_kind) :: floediam(nx_block,ny_block,max_blocks)
real (kind=dbl_kind) :: floethick(nx_block,ny_block,max_blocks) ! ice thickness
real (kind=dbl_kind) :: Tffresh
integer (kind=int_kind) :: nt_fsd
real (kind=dbl_kind), allocatable :: tempfld(:,:,:)
real (kind=dbl_kind), pointer :: dataptr_ifrac_n(:,:)
real (kind=dbl_kind), pointer :: dataptr_swpen_n(:,:)
Expand All @@ -924,8 +876,6 @@ subroutine ice_export( exportState, rc )
! tr_FY_out=tr_FY, tr_pond_out=tr_pond, tr_lvl_out=tr_lvl, &
! tr_zaero_out=tr_zaero, tr_bgc_Nit_out=tr_bgc_Nit)

call icepack_query_tracer_indices(nt_fsd_out=nt_fsd)

call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=u_FILE_u, line=__LINE__)
Expand Down Expand Up @@ -953,26 +903,6 @@ subroutine ice_export( exportState, rc )
! ice fraction
ailohi(i,j,iblk) = min(aice(i,j,iblk), c1)

! ice thickness (m)
if (aice(i,j,iblk) > puny) then
floethick(i,j,iblk) = vice(i,j,iblk) / aice(i,j,iblk)
else
floethick(i,j,iblk) = c0
end if

! floe diameter (m)
floediam(i,j,iblk) = c0
workx = c0
worky = c0
do n = 1, ncat
do k = 1, nfsd
workx = workx + floe_rad_c(k) * aicen_init(i,j,n,iblk) * trcrn(i,j,nt_fsd+k-1,n,iblk)
worky = worky + aicen_init(i,j,n,iblk) * trcrn(i,j,nt_fsd+k-1,n,iblk)
end do
end do
if (worky > c0) workx = c2*workx / worky
floediam(i,j,iblk) = MAX(c2*floe_rad_c(1),workx)

! surface temperature
Tsrf(i,j,iblk) = Tffresh + trcr(i,j,1,iblk) !Kelvin (original ???)

Expand Down Expand Up @@ -1097,14 +1027,6 @@ subroutine ice_export( exportState, rc )
call state_setexport(exportState, 'Si_qref' , input=Qref , lmask=tmask, ifrac=ailohi, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Sea ice thickness (m)
call state_setexport(exportState, 'Si_thick' , input=floethick , lmask=tmask, ifrac=ailohi, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Sea ice floe diameter (m)
call state_setexport(exportState, 'Si_floediam' , input=floediam , lmask=tmask, ifrac=ailohi, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Snow volume
call state_setexport(exportState, 'mean_snow_volume' , input=vsno , lmask=tmask, ifrac=ailohi, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down