Skip to content

Commit

Permalink
Enable prescribed ice for UFS (#80)
Browse files Browse the repository at this point in the history
* Remove #ifdef CESMCOUPLED from cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90

* Remove #ifdef CESMCOUPLED from cicecore/drivers/nuopc/cmeps/ice_prescribed_mod.F90

* Testing changing stream_taxmode from cycle to extend

* Change include mpif.h to use mpi in ice_prescribed_mod.F90

* Call dshr_pio_init from ice_prescribed_init

* Call ice_prescribed_run after ice_prescribed_init

* Incorporate ice_prescribed_nml in ice_prescribed_mod.F90

* write stream_taxmode to log. typo in ice_prescribed_mod.F90.

* Remove CESMCOUPLED so models initialize ice_prescribed at end of ice_prescribed_init

* Change indent for #ifndef for gnu debug

* Only call ice_prescribed_run in ice_prescribed_init #ifndef CESMCOUPLED
  • Loading branch information
NickSzapiro-NOAA committed Jun 11, 2024
1 parent 9c0cd8d commit d406c7e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 31 deletions.
2 changes: 0 additions & 2 deletions cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,12 @@ 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, msec)
call t_stopf ('cice_run_presc')
endif
#endif

call step_prep

Expand Down
2 changes: 1 addition & 1 deletion cicecore/drivers/nuopc/cmeps/ice_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
! Prescribed ice initialization
!-----------------------------------------------------------------

call ice_prescribed_init(clock, ice_mesh, rc)
call ice_prescribed_init(gcomp, clock, ice_mesh, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

#ifdef CESMCOUPLED
Expand Down
55 changes: 27 additions & 28 deletions cicecore/drivers/nuopc/cmeps/ice_prescribed_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,15 @@ module ice_prescribed_mod
! Ice/ocean fluxes are set to zero, and ice dynamics are not calculated.
! Regridding and data cycling capabilities are included.

use ESMF, only : ESMF_Clock, ESMF_Mesh, ESMF_SUCCESS, ESMF_FAILURE
use ESMF, only : ESMF_GridComp, ESMF_Clock, ESMF_Mesh, ESMF_SUCCESS, ESMF_FAILURE
use ESMF, only : ESMF_LogFoundError, ESMF_LOGERR_PASSTHRU, ESMF_Finalize, ESMF_END_ABORT

#ifndef CESMCOUPLED

use ice_kinds_mod
implicit none
private ! except
public :: ice_prescribed_init ! initialize input data stream
logical(kind=log_kind), parameter, public :: prescribed_ice = .false. ! true if prescribed ice
contains
! This is a stub routine for now
subroutine ice_prescribed_init(clock, mesh, rc)
type(ESMF_Clock) , intent(in) :: clock
type(ESMF_Mesh) , intent(in) :: mesh
integer , intent(out) :: rc
! do nothing
rc = ESMF_SUCCESS
end subroutine ice_prescribed_init

#else

use ice_kinds_mod
use shr_nl_mod , only : shr_nl_find_group_name
use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_print
use dshr_strdata_mod , only : shr_strdata_init_from_inline, shr_strdata_advance
use dshr_methods_mod , only : dshr_fldbun_getfldptr
use dshr_mod , only : dshr_pio_init
use ice_broadcast
use ice_communicate , only : my_task, master_task, MPI_COMM_ICE
use ice_fileunits
Expand All @@ -43,7 +25,7 @@ end subroutine ice_prescribed_init
use ice_blocks , only : nx_block, ny_block, block, get_block
use ice_domain , only : nblocks, distrb_info, blocks_ice
use ice_grid , only : TLAT, TLON, hm, tmask, tarea, grid_type, ocn_gridcell_frac
use ice_calendar , only : idate, calendar_type
use ice_calendar , only : idate, msec, calendar_type
use ice_arrays_column , only : hin_max
use ice_read_write
use ice_exit , only: abort_ice
Expand Down Expand Up @@ -74,13 +56,17 @@ end subroutine ice_prescribed_init
contains
!===============================================================================

subroutine ice_prescribed_init(clock, mesh, rc)
subroutine ice_prescribed_init(gcomp, clock, mesh, rc)

! Prescribed ice initialization

include 'mpif.h'
#ifndef SERIAL_REMOVE_MPI
!TODO: add 1d character array to cicecore/cicedyn/infrastructure/comm/mpi/ice_broadcast.F90
use mpi ! MPI Fortran module
#endif

! input/output parameters
type(ESMF_GridComp) , intent(in) :: gcomp
type(ESMF_Clock) , intent(in) :: clock
type(ESMF_Mesh) , intent(in) :: mesh
integer , intent(out) :: rc
Expand All @@ -93,6 +79,7 @@ subroutine ice_prescribed_init(clock, mesh, rc)
character(len=char_len_long) :: stream_dataFiles(nFilesMaximum)
character(len=char_len_long) :: stream_varname
character(len=char_len_long) :: stream_mapalgo
character(len=char_len_long) :: stream_taxmode
integer(kind=int_kind) :: stream_yearfirst ! first year in stream to use
integer(kind=int_kind) :: stream_yearlast ! last year in stream to use
integer(kind=int_kind) :: stream_yearalign ! align stream_year_first
Expand All @@ -110,6 +97,7 @@ subroutine ice_prescribed_init(clock, mesh, rc)
stream_varname , &
stream_datafiles, &
stream_mapalgo, &
stream_taxmode, &
stream_yearalign, &
stream_yearfirst , &
stream_yearlast
Expand All @@ -125,6 +113,7 @@ subroutine ice_prescribed_init(clock, mesh, rc)
stream_meshfile = ' '
stream_datafiles(:) = ' '
stream_mapalgo = 'bilinear'
stream_taxmode = 'cycle'

! read namelist on master task
if (my_task == master_task) then
Expand Down Expand Up @@ -155,6 +144,7 @@ subroutine ice_prescribed_init(clock, mesh, rc)
call broadcast_scalar(stream_yearlast , master_task)
call broadcast_scalar(stream_meshfile , master_task)
call broadcast_scalar(stream_mapalgo , master_task)
call broadcast_scalar(stream_taxmode , master_task)
call broadcast_scalar(stream_varname , master_task)
call mpi_bcast(stream_dataFiles, len(stream_datafiles(1))*NFilesMaximum, MPI_CHARACTER, 0, MPI_COMM_ICE, ierr)

Expand All @@ -172,12 +162,18 @@ subroutine ice_prescribed_init(clock, mesh, rc)
write(nu_diag,F00) ' stream_meshfile = ',trim(stream_meshfile)
write(nu_diag,F00) ' stream_varname = ',trim(stream_varname)
write(nu_diag,F00) ' stream_mapalgo = ',trim(stream_mapalgo)
write(nu_diag,F00) ' stream_taxmode = ',trim(stream_taxmode)
do n = 1,nFile
write(nu_diag,F00) ' stream_datafiles = ',trim(stream_dataFiles(n))
end do
write(nu_diag,*) ' '
endif

#ifndef CESMCOUPLED
!CESM does this elsewhere
call dshr_pio_init(gcomp, sdat, nu_diag, rc)
#endif

! initialize sdat
call shr_strdata_init_from_inline(sdat, &
my_task = my_task, &
Expand All @@ -189,13 +185,13 @@ subroutine ice_prescribed_init(clock, mesh, rc)
stream_lev_dimname = 'null', &
stream_mapalgo = trim(stream_mapalgo), &
stream_filenames = stream_datafiles(1:nfile), &
stream_fldlistFile = (/'ice_cov'/), &
stream_fldListModel = (/'ice_cov'/), &
stream_fldlistFile = (/trim(stream_varname)/), &
stream_fldListModel = (/trim(stream_varname)/), &
stream_yearFirst = stream_yearFirst, &
stream_yearLast = stream_yearLast, &
stream_yearAlign = stream_yearAlign , &
stream_offset = 0, &
stream_taxmode = 'cycle', &
stream_taxmode = trim(stream_taxmode), &
stream_dtlimit = 1.5_dbl_kind, &
stream_tintalgo = 'linear', &
rc = rc)
Expand All @@ -211,6 +207,11 @@ subroutine ice_prescribed_init(clock, mesh, rc)
hin_max(1) = 999._dbl_kind
end if

#ifndef CESMCOUPLED
! If need initial cice values for coupling
call ice_prescribed_run(idate, msec)
#endif

end if ! end of if prescribed ice mode

end subroutine ice_prescribed_init
Expand Down Expand Up @@ -489,6 +490,4 @@ subroutine ice_prescribed_phys()

end subroutine ice_prescribed_phys

#endif

end module ice_prescribed_mod

0 comments on commit d406c7e

Please sign in to comment.