Skip to content

Commit

Permalink
Use a stub rof rather than mosart with lilac
Browse files Browse the repository at this point in the history
This change is important in the short-term, at least, because I'm not
ready to bring the mosart lilac_cap branch to master, so we're pointing
to a version of mosart that doesn't have the necessary changes - see
ESCOMP/MOSART#32.

Once those MOSART changes are on MOSART's master branch, then we should
change buildlib back to using the MOSART source code rather than stub
rof. We may want to do this conditionally, depending on whether rof
coupling is actually wanted in the given run.

(I at first thought that we could let the cime build build mosart for
us, but then realized that the current mechanism is needed because lilac
depends on the mosart code; also, mosart is not built during the
--sharedlib build phase.)

Note: I have NOT given careful thought to the changes in lilac_mod.F90:
It seems right to put this rof-related code inside a conditional, but I
haven't done a careful analysis to determine if that's correct.
  • Loading branch information
billsacks committed Jul 2, 2020
1 parent 4cf744e commit a1b0386
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 43 deletions.
6 changes: 3 additions & 3 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ def _main_func():

if lilac_mode == 'on':
paths.append(os.path.join(lnd_root,"lilac","src"))
mosart_src = os.path.join(lnd_root,"components","mosart","src")
paths.append(os.path.join(mosart_src,"riverroute"))
paths.append(os.path.join(mosart_src,"cpl","lilac"))
# If we want to build with a real river model (e.g., MOSART), we'll need
# to use its directories in place of stub_rof
paths.append(os.path.join(lnd_root,"lilac","stub_rof"))

with open(filepath_file, "w") as filepath:
filepath.write("\n".join(paths))
Expand Down
90 changes: 50 additions & 40 deletions lilac/src/lilac_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,14 @@ subroutine lilac_init2(mpicom, atm_global_index, atm_lons, atm_lats, &
write(logunit,*) trim(subname) // " ctsm gridded component created"
end if

cname = " MOSART "
rof_gcomp = ESMF_GridCompCreate(name=cname, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac mosart initialization')
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " mosart gridded component created"
if (couple_to_river) then
cname = " MOSART "
rof_gcomp = ESMF_GridCompCreate(name=cname, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac mosart initialization')
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " mosart gridded component created"
end if
end if

cname = "Coupler from atmosphere to land"
Expand All @@ -269,20 +271,22 @@ subroutine lilac_init2(mpicom, atm_global_index, atm_lons, atm_lats, &
write(logunit,*) trim(subname) // " coupler component (land to atmosphere) created"
end if

cname = "Coupler from river to land"
cpl_rof2lnd_comp = ESMF_CplCompCreate(name=cname, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac cpl_r2l initialization')
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " coupler component (atmosphere to land) created"
end if
if (couple_to_river) then
cname = "Coupler from river to land"
cpl_rof2lnd_comp = ESMF_CplCompCreate(name=cname, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac cpl_r2l initialization')
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " coupler component (river to land) created"
end if

cname = "Coupler from land to river"
cpl_lnd2rof_comp = ESMF_CplCompCreate(name=cname, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac cpl_l2r initialization')
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " coupler component (land to atmosphere) created"
cname = "Coupler from land to river"
cpl_lnd2rof_comp = ESMF_CplCompCreate(name=cname, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac cpl_l2r initialization')
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " coupler component (land to river) created"
end if
end if

!-------------------------------------------------------------------------
Expand All @@ -307,13 +311,15 @@ subroutine lilac_init2(mpicom, atm_global_index, atm_lons, atm_lats, &
write(logunit,*) trim(subname) // " CTSM setservices finished"
end if

! Register section -- set services -- mosart
call ESMF_GridCompSetServices(rof_gcomp, userRoutine=rof_register, userRc=user_rc, rc=rc)
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('rof_gcomp register failure')
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('rof_gcomp register failure')
call ESMF_LogWrite(subname//"MOSART SetServices finished!", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " CTSM setservices finished"
if (couple_to_river) then
! Register section -- set services -- mosart
call ESMF_GridCompSetServices(rof_gcomp, userRoutine=rof_register, userRc=user_rc, rc=rc)
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('rof_gcomp register failure')
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('rof_gcomp register failure')
call ESMF_LogWrite(subname//"MOSART SetServices finished!", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " CTSM setservices finished"
end if
end if

! Register section -- set services -- coupler atmosphere to land
Expand All @@ -325,13 +331,15 @@ subroutine lilac_init2(mpicom, atm_global_index, atm_lons, atm_lats, &
write(logunit,*) trim(subname) // " coupler from atmosphere to land setservices finished"
end if

! Register section -- set services -- river to land
call ESMF_CplCompSetServices(cpl_rof2lnd_comp, userRoutine=cpl_rof2lnd_register, userRc=user_rc, rc=rc)
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_rof2lnd_comp register failure')
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_rof2lnd_comp register failure')
call ESMF_LogWrite(subname//"Coupler from river to land SetServices finished!", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " coupler from river to land setservices finished"
if (couple_to_river) then
! Register section -- set services -- river to land
call ESMF_CplCompSetServices(cpl_rof2lnd_comp, userRoutine=cpl_rof2lnd_register, userRc=user_rc, rc=rc)
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_rof2lnd_comp register failure')
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_rof2lnd_comp register failure')
call ESMF_LogWrite(subname//"Coupler from river to land SetServices finished!", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " coupler from river to land setservices finished"
end if
end if

! Register section -- set services -- coupler land to atmosphere
Expand All @@ -343,13 +351,15 @@ subroutine lilac_init2(mpicom, atm_global_index, atm_lons, atm_lats, &
write(logunit,*) trim(subname) // " coupler from land to atmosphere setservices finished"
end if

! Register section -- set services -- coupler land to river
call ESMF_CplCompSetServices(cpl_lnd2rof_comp, userRoutine=cpl_lnd2rof_register, userRc=user_rc, rc=rc)
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_lnd2rof_comp register failure')
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_lnd2rof_comp register failure')
call ESMF_LogWrite(subname//"Coupler from land to river SetServices finished!", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " coupler from land to river setservices finished"
if (couple_to_river) then
! Register section -- set services -- coupler land to river
call ESMF_CplCompSetServices(cpl_lnd2rof_comp, userRoutine=cpl_lnd2rof_register, userRc=user_rc, rc=rc)
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_lnd2rof_comp register failure')
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_lnd2rof_comp register failure')
call ESMF_LogWrite(subname//"Coupler from land to river SetServices finished!", ESMF_LOGMSG_INFO)
if (mytask == 0) then
write(logunit,*) trim(subname) // " coupler from land to river setservices finished"
end if
end if

!-------------------------------------------------------------------------
Expand Down
30 changes: 30 additions & 0 deletions lilac/stub_rof/rof_comp_esmf.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module rof_comp_esmf

! ------------------------------------------------------------------------
! This is a stub version of rof_comp_esmf that can be used when we don't have a true
! rof component, just to satisfy the necessary interfaces in LILAC.
! ------------------------------------------------------------------------

use ESMF

implicit none
private

public :: rof_register

!===============================================================================
contains
!===============================================================================

subroutine rof_register(comp, rc)

! Stub rof_register routine - shouldn't ever be called!

! input/output argumenents
type(ESMF_GridComp) :: comp ! ROF grid component
integer, intent(out) :: rc ! return status

rc = ESMF_RC_NOT_IMPL
end subroutine rof_register

end module rof_comp_esmf

0 comments on commit a1b0386

Please sign in to comment.