Skip to content

Commit a1b0386

Browse files
committed
Use a stub rof rather than mosart with lilac
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.
1 parent 4cf744e commit a1b0386

File tree

3 files changed

+83
-43
lines changed

3 files changed

+83
-43
lines changed

cime_config/buildlib

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def _main_func():
123123

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

130130
with open(filepath_file, "w") as filepath:
131131
filepath.write("\n".join(paths))

lilac/src/lilac_mod.F90

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,14 @@ subroutine lilac_init2(mpicom, atm_global_index, atm_lons, atm_lats, &
245245
write(logunit,*) trim(subname) // " ctsm gridded component created"
246246
end if
247247

248-
cname = " MOSART "
249-
rof_gcomp = ESMF_GridCompCreate(name=cname, rc=rc)
250-
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac mosart initialization')
251-
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
252-
if (mytask == 0) then
253-
write(logunit,*) trim(subname) // " mosart gridded component created"
248+
if (couple_to_river) then
249+
cname = " MOSART "
250+
rof_gcomp = ESMF_GridCompCreate(name=cname, rc=rc)
251+
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac mosart initialization')
252+
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
253+
if (mytask == 0) then
254+
write(logunit,*) trim(subname) // " mosart gridded component created"
255+
end if
254256
end if
255257

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

272-
cname = "Coupler from river to land"
273-
cpl_rof2lnd_comp = ESMF_CplCompCreate(name=cname, rc=rc)
274-
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac cpl_r2l initialization')
275-
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
276-
if (mytask == 0) then
277-
write(logunit,*) trim(subname) // " coupler component (atmosphere to land) created"
278-
end if
274+
if (couple_to_river) then
275+
cname = "Coupler from river to land"
276+
cpl_rof2lnd_comp = ESMF_CplCompCreate(name=cname, rc=rc)
277+
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac cpl_r2l initialization')
278+
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
279+
if (mytask == 0) then
280+
write(logunit,*) trim(subname) // " coupler component (river to land) created"
281+
end if
279282

280-
cname = "Coupler from land to river"
281-
cpl_lnd2rof_comp = ESMF_CplCompCreate(name=cname, rc=rc)
282-
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac cpl_l2r initialization')
283-
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
284-
if (mytask == 0) then
285-
write(logunit,*) trim(subname) // " coupler component (land to atmosphere) created"
283+
cname = "Coupler from land to river"
284+
cpl_lnd2rof_comp = ESMF_CplCompCreate(name=cname, rc=rc)
285+
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error lilac cpl_l2r initialization')
286+
call ESMF_LogWrite(subname//"Created "//trim(cname)//" component", ESMF_LOGMSG_INFO)
287+
if (mytask == 0) then
288+
write(logunit,*) trim(subname) // " coupler component (land to river) created"
289+
end if
286290
end if
287291

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

310-
! Register section -- set services -- mosart
311-
call ESMF_GridCompSetServices(rof_gcomp, userRoutine=rof_register, userRc=user_rc, rc=rc)
312-
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('rof_gcomp register failure')
313-
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('rof_gcomp register failure')
314-
call ESMF_LogWrite(subname//"MOSART SetServices finished!", ESMF_LOGMSG_INFO)
315-
if (mytask == 0) then
316-
write(logunit,*) trim(subname) // " CTSM setservices finished"
314+
if (couple_to_river) then
315+
! Register section -- set services -- mosart
316+
call ESMF_GridCompSetServices(rof_gcomp, userRoutine=rof_register, userRc=user_rc, rc=rc)
317+
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('rof_gcomp register failure')
318+
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('rof_gcomp register failure')
319+
call ESMF_LogWrite(subname//"MOSART SetServices finished!", ESMF_LOGMSG_INFO)
320+
if (mytask == 0) then
321+
write(logunit,*) trim(subname) // " CTSM setservices finished"
322+
end if
317323
end if
318324

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

328-
! Register section -- set services -- river to land
329-
call ESMF_CplCompSetServices(cpl_rof2lnd_comp, userRoutine=cpl_rof2lnd_register, userRc=user_rc, rc=rc)
330-
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_rof2lnd_comp register failure')
331-
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_rof2lnd_comp register failure')
332-
call ESMF_LogWrite(subname//"Coupler from river to land SetServices finished!", ESMF_LOGMSG_INFO)
333-
if (mytask == 0) then
334-
write(logunit,*) trim(subname) // " coupler from river to land setservices finished"
334+
if (couple_to_river) then
335+
! Register section -- set services -- river to land
336+
call ESMF_CplCompSetServices(cpl_rof2lnd_comp, userRoutine=cpl_rof2lnd_register, userRc=user_rc, rc=rc)
337+
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_rof2lnd_comp register failure')
338+
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_rof2lnd_comp register failure')
339+
call ESMF_LogWrite(subname//"Coupler from river to land SetServices finished!", ESMF_LOGMSG_INFO)
340+
if (mytask == 0) then
341+
write(logunit,*) trim(subname) // " coupler from river to land setservices finished"
342+
end if
335343
end if
336344

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

346-
! Register section -- set services -- coupler land to river
347-
call ESMF_CplCompSetServices(cpl_lnd2rof_comp, userRoutine=cpl_lnd2rof_register, userRc=user_rc, rc=rc)
348-
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_lnd2rof_comp register failure')
349-
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_lnd2rof_comp register failure')
350-
call ESMF_LogWrite(subname//"Coupler from land to river SetServices finished!", ESMF_LOGMSG_INFO)
351-
if (mytask == 0) then
352-
write(logunit,*) trim(subname) // " coupler from land to river setservices finished"
354+
if (couple_to_river) then
355+
! Register section -- set services -- coupler land to river
356+
call ESMF_CplCompSetServices(cpl_lnd2rof_comp, userRoutine=cpl_lnd2rof_register, userRc=user_rc, rc=rc)
357+
if (chkerr(user_rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_lnd2rof_comp register failure')
358+
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('cpl_lnd2rof_comp register failure')
359+
call ESMF_LogWrite(subname//"Coupler from land to river SetServices finished!", ESMF_LOGMSG_INFO)
360+
if (mytask == 0) then
361+
write(logunit,*) trim(subname) // " coupler from land to river setservices finished"
362+
end if
353363
end if
354364

355365
!-------------------------------------------------------------------------

lilac/stub_rof/rof_comp_esmf.F90

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module rof_comp_esmf
2+
3+
! ------------------------------------------------------------------------
4+
! This is a stub version of rof_comp_esmf that can be used when we don't have a true
5+
! rof component, just to satisfy the necessary interfaces in LILAC.
6+
! ------------------------------------------------------------------------
7+
8+
use ESMF
9+
10+
implicit none
11+
private
12+
13+
public :: rof_register
14+
15+
!===============================================================================
16+
contains
17+
!===============================================================================
18+
19+
subroutine rof_register(comp, rc)
20+
21+
! Stub rof_register routine - shouldn't ever be called!
22+
23+
! input/output argumenents
24+
type(ESMF_GridComp) :: comp ! ROF grid component
25+
integer, intent(out) :: rc ! return status
26+
27+
rc = ESMF_RC_NOT_IMPL
28+
end subroutine rof_register
29+
30+
end module rof_comp_esmf

0 commit comments

Comments
 (0)