Skip to content

Commit

Permalink
Merge pull request NOAA-EMC#6 from DeniseWorthen/escomp/nuopc
Browse files Browse the repository at this point in the history
emc nuopc cap changes
  • Loading branch information
dabail10 committed Aug 10, 2020
2 parents aa9ef50 + 1802396 commit 964c860
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 29 deletions.
5 changes: 2 additions & 3 deletions cicecore/drivers/nuopc/cmeps/CICE_FinalMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ subroutine CICE_Finalize
! quit MPI
!-------------------------------------------------------------------

#ifndef coupled
call end_run ! quit MPI
#endif
! standalone
! call end_run ! quit MPI

end subroutine CICE_Finalize

Expand Down
48 changes: 45 additions & 3 deletions cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module ice_comp_nuopc
character(len=*),parameter :: shr_cal_noleap = 'NO_LEAP'
character(len=*),parameter :: shr_cal_gregorian = 'GREGORIAN'

integer , parameter :: dbug = 10
integer :: dbug = 0
integer , parameter :: debug_import = 0 ! internal debug level
integer , parameter :: debug_export = 0 ! internal debug level
character(*), parameter :: modName = "(ice_comp_nuopc)"
Expand Down Expand Up @@ -236,6 +236,14 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
endif

call NUOPC_CompAttributeGet(gcomp, name='dbug_flag', value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) dbug
end if
write(logmsg,'(i6)') dbug
call ESMF_LogWrite('CICE_cap: dbug = '//trim(logmsg), ESMF_LOGMSG_INFO)

call ice_advertise_fields(gcomp, importState, exportState, flds_scalar_name, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down Expand Up @@ -539,6 +547,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
!----------------------------------------------------------------------------

call icepack_query_parameters(ktherm_out=ktherm)
call icepack_query_parameters(tfrz_option_out=tfrz_option)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)
Expand Down Expand Up @@ -602,13 +611,15 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
write(nu_diag,*) trim(subname),' cice calendar_type = ',trim(calendar_type)
endif

#ifdef CESMCOUPLED
if (calendar_type == "GREGORIAN" .or. &
calendar_type == "Gregorian" .or. &
calendar_type == "gregorian") then
call time2sec(iyear-(year_init-1),month,mday,time)
else
call time2sec(iyear-year_init,month,mday,time)
endif
#endif
time = time+start_tod
end if

Expand Down Expand Up @@ -874,8 +885,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
! diagnostics
!--------------------------------

if (dbug > 1) then
call State_diagnose(exportState,subname//':ES',rc=rc)
if (dbug > 0) then
call state_diagnose(exportState,subname//':ES',rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
endif

Expand Down Expand Up @@ -905,8 +916,10 @@ subroutine ModelAdvance(gcomp, rc)
! Local variables
type(ESMF_Clock) :: clock
type(ESMF_Alarm) :: alarm
type(ESMF_Time) :: startTime
type(ESMF_Time) :: currTime
type(ESMF_Time) :: nextTime
type(ESMF_TimeInterval) :: timeStep
type(ESMF_State) :: importState, exportState
character(ESMF_MAXSTR) :: cvalue
real(dbl_kind) :: eccen, obliqr, lambm0, mvelpp
Expand All @@ -928,11 +941,31 @@ subroutine ModelAdvance(gcomp, rc)
logical :: isPresent, isSet
character(*) , parameter :: F00 = "('(ice_comp_nuopc) ',2a,i8,d21.14)"
character(len=*),parameter :: subname=trim(modName)//':(ModelAdvance) '
character(char_len_long) :: msgString
!--------------------------------

rc = ESMF_SUCCESS
if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO)

! query the Component for its clock, importState and exportState
call ESMF_GridCompGet(gcomp, clock=clock, importState=importState, &
exportState=exportState, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call ESMF_ClockPrint(clock, options="currTime", &
preString="------>Advancing ICE from: ", unit=msgString, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_LogWrite(subname//trim(msgString), ESMF_LOGMSG_INFO)

call ESMF_ClockGet(clock, startTime=startTime, currTime=currTime, &
timeStep=timeStep, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call ESMF_TimePrint(currTime + timeStep, &
preString="--------------------------------> to: ", unit=msgString, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO)

!--------------------------------
! Turn on timers
!--------------------------------
Expand Down Expand Up @@ -1050,6 +1083,10 @@ subroutine ModelAdvance(gcomp, rc)
idate, sec, nu_diag, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
if (dbug > 0) then
call state_diagnose(importState,subname//':IS',rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

!--------------------------------
! Advance cice and timestep update
Expand All @@ -1067,11 +1104,16 @@ subroutine ModelAdvance(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call t_stopf ('cice_run_export')

! write Debug output
if (debug_export > 0 .and. my_task==master_task) then
call State_fldDebug(exportState, flds_scalar_name, 'cice_export:', &
idate, sec, nu_diag, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if
if (dbug > 0) then
call state_diagnose(exportState,subname//':ES',rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end if

! reset shr logging to my original values
call shr_file_setLogUnit (shrlogunit)
Expand Down
31 changes: 20 additions & 11 deletions cicecore/drivers/nuopc/cmeps/ice_import_export.F90
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module ice_import_export
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
use icepack_intfc , only : icepack_sea_freezing_temperature
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 @@ -87,7 +88,7 @@ module ice_import_export
type (fld_list_type) :: fldsFrIce(fldsMax)
type(ESMF_GeomType_Flag) :: geomtype

integer , parameter :: dbug = 10 ! i/o debug messages
integer , parameter :: io_dbug = 10 ! i/o debug messages
character(*), parameter :: u_FILE_u = &
__FILE__

Expand Down Expand Up @@ -115,7 +116,7 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam
!-------------------------------------------------------------------------------

rc = ESMF_SUCCESS
if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO)
if (io_dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO)

! Determine if the following attributes are sent by the driver and if so read them in
flds_wiso = .false.
Expand Down Expand Up @@ -253,8 +254,8 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam
if (flds_wiso) then
call fldlist_add(fldsFrIce_num, fldsFrIce, 'mean_fresh_water_to_ocean_rate_wiso', &
ungridded_lbound=1, ungridded_ubound=3)
!call fldlist_add(fldsFrIce_num, fldsFrIce, 'mean_evap_rate_atm_into_ice_wiso', &
! ungridded_lbound=1, ungridded_ubound=3)
call fldlist_add(fldsFrIce_num, fldsFrIce, 'mean_evap_rate_atm_into_ice_wiso', &
ungridded_lbound=1, ungridded_ubound=3)
call fldlist_add(fldsFrIce_num, fldsFrIce, 'Si_qref_wiso', &
ungridded_lbound=1, ungridded_ubound=3)
end if
Expand All @@ -265,7 +266,7 @@ subroutine ice_advertise_fields(gcomp, importState, exportState, flds_scalar_nam
if (ChkErr(rc,__LINE__,u_FILE_u)) return
enddo

if (dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO)
if (io_dbug > 5) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO)

end subroutine ice_advertise_fields

Expand Down Expand Up @@ -361,12 +362,22 @@ subroutine ice_import( importState, rc )
real (kind=dbl_kind),allocatable :: aflds(:,:,:,:)
real (kind=dbl_kind) :: workx, worky
real (kind=dbl_kind) :: MIN_RAIN_TEMP, MAX_SNOW_TEMP
real (kind=dbl_kind) :: tffresh
real (kind=dbl_kind) :: Tffresh
real (kind=dbl_kind) :: inst_pres_height_lowest
character(len=char_len) :: tfrz_option
integer(int_kind) :: ktherm
character(len=*), parameter :: subname = 'ice_import'
character(len=1024) :: msgString
!-----------------------------------------------------

call icepack_query_parameters(Tffresh_out=Tffresh)
call icepack_query_parameters(tfrz_option_out=tfrz_option)
call icepack_query_parameters(ktherm_out=ktherm)
if (io_dbug > 5) then
write(msgString,'(A,i8)')trim(subname)//' tfrz_option = ' &
// trim(tfrz_option)//', ktherm = ',ktherm
call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO)
end if
! call icepack_query_parameters(tfrz_option_out=tfrz_option, &
! modal_aero_out=modal_aero, z_tracers_out=z_tracers, skl_bgc_out=skl_bgc, &
! Tffresh_out=Tffresh)
Expand Down Expand Up @@ -693,8 +704,7 @@ subroutine ice_import( importState, rc )
do iblk = 1, nblocks
do j = 1,ny_block
do i = 1,nx_block
!TODO: tcx should this be icepack_sea_freezing_temperature?
Tf (i,j,iblk) = icepack_liquidus_temperature(sss(i,j,iblk))
Tf(i,j,iblk) = icepack_sea_freezing_temperature(sss(i,j,iblk))
end do
end do
end do
Expand Down Expand Up @@ -769,12 +779,12 @@ subroutine ice_export( exportState, rc )
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), allocatable :: tempfld(:,:,:)
real (kind=dbl_kind) :: tffresh
real (kind=dbl_kind) :: Tffresh
character(len=*),parameter :: subname = 'ice_export'
!-----------------------------------------------------

rc = ESMF_SUCCESS
if (dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO)
if (io_dbug > 5) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO)

call icepack_query_parameters(Tffresh_out=Tffresh)
! call icepack_query_parameters(tfrz_option_out=tfrz_option, &
Expand Down Expand Up @@ -903,7 +913,6 @@ subroutine ice_export( exportState, rc )
! ----

! surface temperature of ice covered portion (degK)
!call state_setexport(exportState, 'sea_ice_temperature', input=Tsrf , lmask=tmask, ifrac=ailohi, rc=rc)
call state_setexport(exportState, 'sea_ice_surface_temperature', input=Tsrf , lmask=tmask, ifrac=ailohi, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
8 changes: 4 additions & 4 deletions configuration/scripts/forapps/ufs/comp_ice.backend.clean
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ setenv OBJDIR $EXEDIR/compile ; if !(-d $OBJDIR) mkdir -p $OBJDIR

if (${SITE} =~ cheyenne*) then
setenv ARCH cheyenne_intel
#else if (${SITE} =~ Orion*) then
# setenv ARCH orion_intel
#else if (${SITE} =~ hera*) then
# setenv ARCH hera_intel
else if (${SITE} =~ orion*) then
setenv ARCH orion_intel
else if (${SITE} =~ hera*) then
setenv ARCH hera_intel
else
echo "CICE6 ${0}: ERROR in ARCH setup, ${hname}"
exit -2
Expand Down
12 changes: 7 additions & 5 deletions configuration/scripts/forapps/ufs/comp_ice.backend.libcice
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ setenv THRD no # set to yes for OpenMP threading

if (${SITE} =~ cheyenne*) then
setenv ARCH cheyenne_intel
else if (${SITE} =~ Orion*) then
else if (${SITE} =~ orion*) then
setenv ARCH orion_intel
else if (${SITE} =~ hera*) then
setenv ARCH hera_intel
Expand Down Expand Up @@ -57,20 +57,22 @@ if !($?IO_TYPE) then
endif
if ($IO_TYPE == 'netcdf3' || $IO_TYPE == 'netcdf4') then
setenv IODIR io_netcdf
setenv ICE_CPPDEFS "${ICE_CPPDEFS} -Dncdf"
setenv ICE_CPPDEFS "${ICE_CPPDEFS} -DUSE_NETCDF"
else if ($IO_TYPE == 'pio') then
setenv IODIR io_pio
setenv ICE_CPPDEFS "${ICE_CPPDEFS} -Dncdf"
setenv ICE_CPPDEFS "${ICE_CPPDEFS} -DUSE_NETCDF"
else
setenv IODIR io_binary
endif

# Build in debug mode. If DEBUG=Y, enable DEBUG compilation. This
# flag is set in ${ROOTDIR}/coupledFV3_MOM6_CICE_debug.appBuilder file.
if (! $?DEBUG) then
setenv ICE_BLDDEBUG true
setenv ICE_BLDDEBUG false
else
if ($DEBUG != "Y") then
if ($DEBUG == "Y") then
setenv ICE_BLDDEBUG true
else
setenv ICE_BLDDEBUG false
endif
endif
Expand Down
2 changes: 1 addition & 1 deletion configuration/scripts/machines/Macros.cheyenne_intel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FFLAGS := -fp-model precise -convert big_endian -assume byterecl -ftz -trace
FFLAGS_NOOPT:= -O0

ifeq ($(ICE_BLDDEBUG), true)
FFLAGS += -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created
FFLAGS += -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created -link_mpi=dbg
else
FFLAGS += -O2
endif
Expand Down
2 changes: 1 addition & 1 deletion configuration/scripts/machines/Macros.hera_intel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FFLAGS := -fp-model precise -convert big_endian -assume byterecl -ftz -trace
FFLAGS_NOOPT:= -O0

ifeq ($(ICE_BLDDEBUG), true)
FFLAGS += -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created
FFLAGS += -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created -link_mpi=dbg
else
FFLAGS += -O2
endif
Expand Down
2 changes: 1 addition & 1 deletion configuration/scripts/machines/Macros.orion_intel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FFLAGS := -fp-model precise -convert big_endian -assume byterecl -ftz -trace
FFLAGS_NOOPT:= -O0

ifeq ($(ICE_BLDDEBUG), true)
FFLAGS += -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created
FFLAGS += -O0 -g -check uninit -check bounds -check pointers -fpe0 -check noarg_temp_created -link_mpi=dbg
else
FFLAGS += -O2
endif
Expand Down

0 comments on commit 964c860

Please sign in to comment.