Skip to content

Commit

Permalink
Merge pull request #1 from ESCOMP/nuopc
Browse files Browse the repository at this point in the history
  • Loading branch information
DeniseWorthen committed May 12, 2020
2 parents 10e7c20 + 8f0b5ee commit 7ac0e3d
Show file tree
Hide file tree
Showing 11 changed files with 479 additions and 122 deletions.
4 changes: 2 additions & 2 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ subroutine input_data
kmt_file = 'unknown_kmt_file'
version_name = 'unknown_version_name'
ncat = 0 ! number of ice thickness categories
nfsd = 0 ! number of floe size categories (1 = default)
nfsd = 1 ! number of floe size categories (1 = default)
nilyr = 0 ! number of vertical ice layers
nslyr = 0 ! number of vertical snow layers
nblyr = 0 ! number of bio layers
Expand Down Expand Up @@ -748,7 +748,7 @@ subroutine input_data
ice_ic /= 'none' .and. ice_ic /= 'default') then
if (my_task == master_task) then
write(nu_diag,*) subname//' ERROR: runtype, restart, ice_ic are inconsistent:'
write(nu_diag,*) subname//' ERROR: runtype=',trim(runtype), 'restart=',restart, 'ice_ic=',trim(ice_ic)
write(nu_diag,*) subname//' ERROR: runtype=',trim(runtype), ' restart=',restart, ' ice_ic=',trim(ice_ic)
write(nu_diag,*) subname//' ERROR: Please review user guide'
endif
abort_flag = 1
Expand Down
2 changes: 1 addition & 1 deletion cicecore/drivers/nuopc/cmeps/CICE_InitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ subroutine cice_init(mpicom_ice)
! coupler communication or forcing data initialization
!--------------------------------------------------------------------

#ifndef coupled
call init_forcing_atmo ! initialize atmospheric forcing (standalone)

#ifndef coupled
#ifndef CESMCOUPLED
if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice
call get_forcing_atmo ! atmospheric forcing from data
Expand Down
4 changes: 4 additions & 0 deletions cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
module CICE_RunMod

use ice_kinds_mod
#ifdef CESMCOUPLED
use perf_mod, only : t_startf, t_stopf, t_barrierf
#endif
use ice_fileunits, only: nu_diag
use ice_arrays_column, only: oceanmixed_ice
use ice_constants, only: c0, c1
Expand Down Expand Up @@ -207,12 +209,14 @@ subroutine ice_step
call init_history_bgc
call ice_timer_stop(timer_diags) ! diagnostics/history

#ifdef CESMCOUPLED
if (prescribed_ice) then ! read prescribed ice
call t_barrierf('cice_run_presc_BARRIER',MPI_COMM_ICE)
call t_startf ('cice_run_presc')
call ice_prescribed_run(idate, sec)
call t_stopf ('cice_run_presc')
endif
#endif

call save_init

Expand Down
206 changes: 145 additions & 61 deletions cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90

Large diffs are not rendered by default.

72 changes: 61 additions & 11 deletions cicecore/drivers/nuopc/cmeps/ice_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module ice_import_export
use ESMF
use NUOPC
use NUOPC_Model
use shr_sys_mod , only : shr_sys_abort, shr_sys_flush
#ifdef CESMCOUPLED
use shr_frz_mod , only : shr_frz_freezetemp
use shr_kind_mod , only : r8 => shr_kind_r8, cl=>shr_kind_cl, cs=>shr_kind_cs
use ice_kinds_mod , only : int_kind, dbl_kind, char_len_long, log_kind
#endif
use ice_kinds_mod , only : int_kind, dbl_kind, char_len, log_kind
use ice_constants , only : c0, c1, spval_dbl
use ice_constants , only : field_loc_center, field_type_scalar, field_type_vector
use ice_blocks , only : block, get_block, nx_block, ny_block
Expand All @@ -23,7 +23,7 @@ module ice_import_export
use ice_flux , only : fresh, fsalt, zlvl, uatm, vatm, potT, Tair, Qa
use ice_flux , only : rhoa, swvdr, swvdf, swidr, swidf, flw, frain
use ice_flux , only : fsnow, uocn, vocn, sst, ss_tltx, ss_tlty, frzmlt
use ice_flux , only : sss, tf, wind, fsw
use ice_flux , only : sss, Tf, wind, fsw
#if (defined NEWCODE)
use ice_flux , only : faero_atm, faero_ocn
use ice_flux , only : fiso_atm, fiso_ocn, fiso_rain, fiso_evap
Expand All @@ -33,13 +33,16 @@ module ice_import_export
use ice_grid , only : tlon, tlat, tarea, tmask, anglet, hm, ocn_gridcell_frac
use ice_grid , only : grid_type, t2ugrid_vector
use ice_boundary , only : ice_HaloUpdate
use ice_fileunits , only : nu_diag
use ice_fileunits , only : nu_diag, flush_fileunit
use ice_communicate , only : my_task, master_task, MPI_COMM_ICE
use ice_prescribed_mod , only : prescribed_ice
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_liquidus_temperature
#ifdef CESMCOUPLED
use perf_mod , only : t_startf, t_stopf, t_barrierf
#endif

implicit none
public
Expand Down Expand Up @@ -107,8 +110,8 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam

! local variables
integer :: n
character(CS) :: stdname
character(CS) :: cvalue
character(char_len) :: stdname
character(char_len) :: cvalue
logical :: flds_wiso ! use case
logical :: flds_i2o_per_cat ! .true. => select per ice thickness category
character(len=*), parameter :: subname='(ice_import_export:ice_advertise_fields)'
Expand All @@ -117,6 +120,9 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam
rc = ESMF_SUCCESS
if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO)

flds_wiso = .false.
flds_i2o_per_cat = .false.
#ifdef CESMCOUPLED
call NUOPC_CompAttributeGet(gcomp, name='flds_wiso', value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) flds_wiso
Expand All @@ -127,6 +133,7 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) send_i2x_per_cat
call ESMF_LogWrite('flds_i2o_per_cat = '// trim(cvalue), ESMF_LOGMSG_INFO)
#endif
#endif

!-----------------
Expand Down Expand Up @@ -154,7 +161,7 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam
call fldlist_add(fldsToIce_num, fldsToIce, 'inst_spec_humid_height_lowest' )
call fldlist_add(fldsToIce_num, fldsToIce, 'inst_temp_height_lowest' )
call fldlist_add(fldsToIce_num, fldsToIce, 'Sa_ptem' )
call fldlist_add(fldsToIce_num, fldsToIce, 'air_density_height_lowest' )
call fldlist_add(fldsToIce_num, fldsToIce, 'air_density_height_lowest' )
call fldlist_add(fldsToIce_num, fldsToIce, 'mean_down_sw_vis_dir_flx' )
call fldlist_add(fldsToIce_num, fldsToIce, 'mean_down_sw_ir_dir_flx' )
call fldlist_add(fldsToIce_num, fldsToIce, 'mean_down_sw_vis_dif_flx' )
Expand All @@ -163,6 +170,7 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam
call fldlist_add(fldsToIce_num, fldsToIce, 'mean_prec_rate' )
call fldlist_add(fldsToIce_num, fldsToIce, 'mean_fprec_rate' )

#ifdef CESMCOUPLED
! from atm - black carbon deposition fluxes (3)
call fldlist_add(fldsToIce_num, fldsToIce, 'Faxa_bcph', ungridded_lbound=1, ungridded_ubound=3)

Expand All @@ -171,6 +179,7 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam

! from - atm dry dust deposition frluxes (4 sizes)
call fldlist_add(fldsToIce_num, fldsToIce, 'Faxa_dstdry', ungridded_lbound=1, ungridded_ubound=4)
#endif

do n = 1,fldsToIce_num
call NUOPC_Advertise(importState, standardName=fldsToIce(n)%stdname, &
Expand Down Expand Up @@ -231,9 +240,11 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam
call fldlist_add(fldsFrIce_num , fldsFrIce, 'mean_salt_rate' )
call fldlist_add(fldsFrIce_num , fldsFrIce, 'stress_on_ocn_ice_zonal' )
call fldlist_add(fldsFrIce_num , fldsFrIce, 'stress_on_ocn_ice_merid' )
#ifdef CESMCOUPLED
call fldlist_add(fldsFrIce_num , fldsFrIce, 'Fioi_bcpho' )
call fldlist_add(fldsFrIce_num , fldsFrIce, 'Fioi_bcphi' )
call fldlist_add(fldsFrIce_num , fldsFrIce, 'Fioi_flxdst' )
#endif
if (flds_wiso) then
call fldlist_add(fldsFrIce_num, fldsFrIce, 'mean_fresh_water_to_ocean_rate_wiso', &
ungridded_lbound=1, ungridded_ubound=3)
Expand Down Expand Up @@ -388,6 +399,7 @@ subroutine ice_import( importState, rc )
call state_getimport(importState, 'inst_height_lowest', output=aflds, index=3, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!tcx errr.... this needs to be fixed in the dictionary!!!
call state_getimport(importState, 'Sa_ptem', output=aflds, index=4, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down Expand Up @@ -431,9 +443,13 @@ subroutine ice_import( importState, rc )
! perform a halo update

if (.not.prescribed_ice) then
#ifdef CESMCOUPLED
call t_startf ('cice_imp_halo')
#endif
call ice_HaloUpdate(aflds, halo_info, field_loc_center, field_type_scalar)
#ifdef CESMCOUPLED
call t_stopf ('cice_imp_halo')
#endif
endif

! now fill in the ice internal data types
Expand Down Expand Up @@ -485,9 +501,13 @@ subroutine ice_import( importState, rc )


if (.not.prescribed_ice) then
#ifdef CESMCOUPLED
call t_startf ('cice_imp_halo')
#endif
call ice_HaloUpdate(aflds, halo_info, field_loc_center, field_type_vector)
#ifdef CESMCOUPLED
call t_stopf ('cice_imp_halo')
#endif
endif

!$OMP PARALLEL DO PRIVATE(iblk,i,j)
Expand Down Expand Up @@ -600,7 +620,9 @@ subroutine ice_import( importState, rc )
! interpolate across the pole)
! use ANGLET which is on the T grid !

#ifdef CESMCOUPLED
call t_startf ('cice_imp_ocn')
#endif
!$OMP PARALLEL DO PRIVATE(iblk,i,j,workx,worky)
do iblk = 1, nblocks

Expand All @@ -624,33 +646,47 @@ subroutine ice_import( importState, rc )
sst(i,j,iblk) = sst(i,j,iblk) - Tffresh ! sea sfc temp (C)

sss(i,j,iblk) = max(sss(i,j,iblk),c0)
#ifndef CESMCOUPLED
!tcx should this be icepack_sea_freezing_temperature?
Tf (i,j,iblk) = icepack_liquidus_temperature(sss(i,j,iblk))
#endif
enddo
enddo

! Use shr_frz_mod for this
#ifdef CESMCOUPLED
! Use shr_frz_mod for this, overwrite Tf computed above
Tf(:,:,iblk) = shr_frz_freezetemp(sss(:,:,iblk))
#endif

enddo
!$OMP END PARALLEL DO
#ifdef CESMCOUPLED
call t_stopf ('cice_imp_ocn')
#endif

! Interpolate ocean dynamics variables from T-cell centers to
! U-cell centers.

if (.not.prescribed_ice) then
#ifdef CESMCOUPLED
call t_startf ('cice_imp_t2u')
#endif
call t2ugrid_vector(uocn)
call t2ugrid_vector(vocn)
call t2ugrid_vector(ss_tltx)
call t2ugrid_vector(ss_tlty)
#ifdef CESMCOUPLED
call t_stopf ('cice_imp_t2u')
#endif
end if

! Atmosphere variables are needed in T cell centers in
! subroutine stability and are interpolated to the U grid
! later as necessary.

#ifdef CESMCOUPLED
call t_startf ('cice_imp_atm')
#endif
!$OMP PARALLEL DO PRIVATE(iblk,i,j,workx,worky)
do iblk = 1, nblocks
do j = 1, ny_block
Expand All @@ -671,7 +707,9 @@ subroutine ice_import( importState, rc )
enddo
enddo
!$OMP END PARALLEL DO
#ifdef CESMCOUPLED
call t_stopf ('cice_imp_atm')
#endif

end subroutine ice_import

Expand Down Expand Up @@ -787,7 +825,7 @@ subroutine ice_export( exportState, rc )
if (tmask(i,j,iblk) .and. ailohi(i,j,iblk) < c0 ) then
write(nu_diag,*) &
' (ice) send: ERROR ailohi < 0.0 ',i,j,ailohi(i,j,iblk)
call shr_sys_flush(nu_diag)
call flush_fileunit(nu_diag)
endif
end do
end do
Expand Down Expand Up @@ -1083,7 +1121,7 @@ subroutine fldlist_add(num, fldlist, stdname, ungridded_lbound, ungridded_ubound

num = num + 1
if (num > fldsMax) then
call shr_sys_abort(trim(subname)//": ERROR num > fldsMax "//trim(stdname))
call abort_ice(trim(subname)//": ERROR num > fldsMax "//trim(stdname))
endif
fldlist(num)%stdname = trim(stdname)

Expand Down Expand Up @@ -1270,6 +1308,9 @@ subroutine state_getimport_4d_output(state, fldname, output, index, do_sum, ungr

rc = ESMF_SUCCESS

! check that fieldname exists
if (.not. State_FldChk(state, trim(fldname))) return

if (geomtype == ESMF_GEOMTYPE_MESH) then

! get field pointer
Expand Down Expand Up @@ -1381,6 +1422,9 @@ subroutine state_getimport_3d_output(state, fldname, output, do_sum, ungridded_i

rc = ESMF_SUCCESS

! check that fieldname exists
if (.not. State_FldChk(state, trim(fldname))) return

if (geomtype == ESMF_GEOMTYPE_MESH) then

! get field pointer
Expand Down Expand Up @@ -1486,6 +1530,9 @@ subroutine state_setexport_4d_input(state, fldname, input, index, lmask, ifrac,

rc = ESMF_SUCCESS

! check that fieldname exists
if (.not. State_FldChk(state, trim(fldname))) return

if (geomtype == ESMF_GEOMTYPE_MESH) then

! get field pointer
Expand Down Expand Up @@ -1600,6 +1647,9 @@ subroutine state_setexport_3d_input(state, fldname, input, lmask, ifrac, ungridd

rc = ESMF_SUCCESS

! check that fieldname exists
if (.not. State_FldChk(state, trim(fldname))) return

if (geomtype == ESMF_GEOMTYPE_MESH) then

! get field pointer
Expand Down
11 changes: 10 additions & 1 deletion cicecore/drivers/nuopc/cmeps/ice_prescribed_mod.F90
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
module ice_prescribed_mod

#ifdef CESMCOUPLED
#ifndef CESMCOUPLED

use ice_kinds_mod

implicit none
private ! except

logical(kind=log_kind), parameter, public :: prescribed_ice = .false. ! true if prescribed ice

#else

! !DESCRIPTION:
! The prescribed ice model reads in ice concentration data from a netCDF
Expand Down
Loading

0 comments on commit 7ac0e3d

Please sign in to comment.