Skip to content

Commit

Permalink
cdeps streams moved to share_esmf and lilac stream moved to lilac
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariana Vertenstein committed Jun 16, 2021
1 parent 8c8718a commit b4d64ac
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 191 deletions.
1 change: 0 additions & 1 deletion cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ def buildnml(case, caseroot, compname):
configuration, structure,
lndfrac_file, glc_nec, glc_use_antarctica_flag, ccsm_co2_ppmv, clm_co2_type, config_cache_file, driver,
clm_bldnml_opts, spinup, tuning, gridmask))
print "DEBUG: command is ",command

rc, out, err = run_cmd(command, from_dir=ctsmconf)
expect(rc==0,"Command %s failed rc=%d\nout=%s\nerr=%s"%(cmd,rc,out,err))
Expand Down
1 change: 1 addition & 0 deletions lilac/bld_templates/lilac_in_template
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/
&atmaero_stream
stream_fldfilename='$INPUTDATA/atm/cam/chem/trop_mozart_aero/aero/aerosoldep_WACCM.ensmean_monthly_hist_1849-2015_0.9x1.25_CMIP6_c180926.nc'
stream_meshfile = '$INPUTDATA/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc'
stream_year_first = 2000
stream_year_last = 2000
/
Expand Down
264 changes: 97 additions & 167 deletions lilac/src/lilac_atmaero.F90

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions lilac/src/lilac_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ subroutine lilac_init2(mpicom, atm_global_index, atm_lons, atm_lats, &
integer, pointer :: mycomms(:) ! for mct
integer, pointer :: myids(:) ! for mct
integer :: compids(1) = (/1/) ! for pio_init2 - array with component ids
integer :: comms(1) ! for both mct and pio_init2 - array with mpicoms
character(len=32) :: compLabels(1) = (/'LND'/) ! for pio_init2
character(len=64) :: comp_name(1) = (/'LND'/) ! for pio_init2
logical :: comp_iamin(1) = (/.true./) ! for pio init2
Expand Down Expand Up @@ -485,7 +484,7 @@ subroutine lilac_init2(mpicom, atm_global_index, atm_lons, atm_lats, &
! Initialize atmaero stream data (using share strearm capability from CIME)
!-------------------------------------------------------------------------

call lilac_atmaero_init(atm2cpl_state, rc)
call lilac_atmaero_init(atm2cpl_state, lilac_clock, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) call shr_sys_abort("lilac error in initializing lilac_atmaero_init")

!-------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions python/ctsm/lilac_make_runtime_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def buildnml(cime_path, rundir):
# call build-namelist
cmd = os.path.abspath(os.path.join(path_to_ctsm_root(), "bld", "build-namelist"))
command = [cmd,
'-driver', 'nuopc',
'-cimeroot', cime_path,
'-infile', infile,
'-csmdata', inputdata_path,
Expand Down
22 changes: 14 additions & 8 deletions src/cpl/lilac/lnd_comp_esmf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module lnd_comp_esmf
use clm_driver , only : clm_drv
use lnd_import_export , only : import_fields, export_fields
use lnd_shr_methods , only : chkerr, state_diagnose
use lnd_comp_shr , only : mesh, model_meshfile, model_clock
use lnd_set_decomp_and_domain, only :lnd_set_decomp_and_domain_from_readmesh

implicit none
Expand Down Expand Up @@ -127,7 +128,6 @@ subroutine lnd_init(comp, import_state, export_state, clock, rc)
type(ESMF_Field) :: lfield

! mesh generation
type(ESMF_Mesh) :: lnd_mesh
character(ESMF_MAXSTR) :: lnd_mesh_filename ! full filepath of land mesh file
integer, pointer :: gindex(:) ! global index space for land and ocean points
type(ESMF_DistGrid) :: distgrid
Expand Down Expand Up @@ -251,6 +251,9 @@ subroutine lnd_init(comp, import_state, export_state, clock, rc)
end if
call shr_mpi_bcast(lnd_mesh_filename, mpicom)

! Fill in the value for model_meshfile in lnd_comp_shr used by the stream routines in share_esmf/
model_meshfile = trim(lnd_mesh_filename)

!----------------------
! Obtain caseid and start type from attributes in import state
!----------------------
Expand Down Expand Up @@ -320,6 +323,9 @@ subroutine lnd_init(comp, import_state, export_state, clock, rc)
ref_ymd_in=ref_ymd, ref_tod_in=ref_tod, dtime_in=dtime_lilac)
call ESMF_LogWrite(subname//"ctsm time manager initialized....", ESMF_LOGMSG_INFO)

! Set model clock in lnd_comp_shr
model_clock = clock

!----------------------
! Read namelist, grid and surface data
!----------------------
Expand All @@ -342,7 +348,7 @@ subroutine lnd_init(comp, import_state, export_state, clock, rc)
! For now set the meshfile_mask equal to the model_meshfile
call lnd_set_decomp_and_domain_from_readmesh(driver='lilac', vm=vm, &
meshfile_lnd=lnd_mesh_filename, meshfile_mask=lnd_mesh_filename, &
mesh_ctsm=lnd_mesh, ni=ni, nj=nj, rc=rc)
mesh_ctsm=mesh, ni=ni, nj=nj, rc=rc)

!--------------------------------
! Finish initializing ctsm
Expand All @@ -357,9 +363,9 @@ subroutine lnd_init(comp, import_state, export_state, clock, rc)
c2l_fb_atm = ESMF_FieldBundleCreate (name='c2l_fb_atm', rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! now add atm import fields on lnd_mesh to this field bundle
! now add atm import fields on mesh to this field bundle
do n = 1, a2l_fields%num_fields()
lfield = ESMF_FieldCreate(lnd_mesh, ESMF_TYPEKIND_R8 , meshloc=ESMF_MESHLOC_ELEMENT, &
lfield = ESMF_FieldCreate(mesh, ESMF_TYPEKIND_R8 , meshloc=ESMF_MESHLOC_ELEMENT, &
name=a2l_fields%get_fieldname(n), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleAdd(c2l_fb_atm, (/lfield/), rc=rc)
Expand Down Expand Up @@ -393,9 +399,9 @@ subroutine lnd_init(comp, import_state, export_state, clock, rc)
l2c_fb_atm = ESMF_FieldBundleCreate(name='l2c_fb_atm', rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! now add atm export fields on lnd_mesh to this field bundle
! now add atm export fields on mesh to this field bundle
do n = 1, l2a_fields%num_fields()
lfield = ESMF_FieldCreate(lnd_mesh, ESMF_TYPEKIND_R8 , meshloc=ESMF_MESHLOC_ELEMENT, &
lfield = ESMF_FieldCreate(mesh, ESMF_TYPEKIND_R8 , meshloc=ESMF_MESHLOC_ELEMENT, &
name=l2a_fields%get_fieldname(n), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleAdd(l2c_fb_atm, (/lfield/), rc=rc)
Expand All @@ -410,7 +416,7 @@ subroutine lnd_init(comp, import_state, export_state, clock, rc)
l2c_fb_rof = ESMF_FieldBundleCreate(name='l2c_fb_rof', rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! now add rof export fields on lnd_mesh to this field bundle
! now add rof export fields on mesh to this field bundle
call fldbundle_add('Flrl_rofsur', l2c_fb_rof, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call fldbundle_add('Flrl_rofgwl', l2c_fb_rof, rc=rc)
Expand Down Expand Up @@ -488,7 +494,7 @@ subroutine fldbundle_add(stdname, fieldbundle, rc)
type(ESMF_Field) :: field
!-------------------------------------------------------------------------------
rc = ESMF_SUCCESS
field = ESMF_FieldCreate(lnd_mesh, ESMF_TYPEKIND_R8 , meshloc=ESMF_MESHLOC_ELEMENT , name=trim(stdname), rc=rc)
field = ESMF_FieldCreate(mesh, ESMF_TYPEKIND_R8 , meshloc=ESMF_MESHLOC_ELEMENT , name=trim(stdname), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldBundleAdd(fieldbundle, (/field/), rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down
15 changes: 15 additions & 0 deletions src/cpl/lilac/lnd_comp_shr.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module lnd_comp_shr

! Model mesh info is here in order to be leveraged by CDEPS in line calls

use ESMF
use shr_kind_mod, only : r8 => shr_kind_r8, cl=>shr_kind_cl

implicit none
public

type(ESMF_Clock) :: model_clock ! model clock
type(ESMF_Mesh) :: mesh ! model_mesh
character(len=cl) :: model_meshfile ! model mesh file

end module lnd_comp_shr
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ subroutine hdm_init( this, bounds, NLFilename )
! !USES:
use clm_nlUtilsMod , only : find_nlgroup_name
use histFileMod , only : hist_addfld1d
use lnd_comp_shr , only : mesh, model_meshfile, model_clock
use lnd_comp_shr , only : mesh, model_clock
use dshr_strdata_mod , only : shr_strdata_init_from_inline
use shr_mpi_mod , only : shr_mpi_bcast
!
Expand Down Expand Up @@ -307,7 +307,7 @@ subroutine lnfm_init( this, bounds, NLFilename )
!
! !USES:
use clm_nlUtilsMod , only : find_nlgroup_name
use lnd_comp_shr , only : mesh, model_meshfile, model_clock
use lnd_comp_shr , only : mesh, model_clock
use dshr_strdata_mod , only : shr_strdata_init_from_inline
use histFileMod , only : hist_addfld1d
use shr_mpi_mod , only : shr_mpi_bcast
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ subroutine urbantv_init(this, bounds, NLFilename)
use shr_mpi_mod , only : shr_mpi_bcast
use landunit_varcon , only : isturb_tbd, isturb_hd, isturb_md
use dshr_strdata_mod , only : shr_strdata_init_from_inline
use lnd_comp_shr , only : mesh, model_meshfile, model_clock
use lnd_comp_shr , only : mesh, model_clock
!
! !ARGUMENTS:
implicit none
Expand Down Expand Up @@ -242,7 +242,11 @@ subroutine urbantv_interp(this, bounds)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then
call ESMF_Finalize(endflag=ESMF_END_ABORT)
end if
dataptr2d(:,n) = dataptr1d(:)
! Note that the size of dataptr1d includes ocean points so it will be around 3x larger than lsize
! So an explicit loop is required here
do g = 1,lsize
dataptr2d(g,n) = dataptr1d(g)
end do
end do

! Determine this%tbuilding_max for all landunits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ subroutine Init(this, bounds, NLFilename)
use spmdMod , only : iam
use ch4varcon , only : finundation_mtd_h2osfc
use ch4varcon , only : finundation_mtd_ZWT_inversion, finundation_mtd_TWS_inversion
use lnd_comp_shr , only : mesh, model_meshfile, model_clock
use lnd_comp_shr , only : mesh, model_clock
use dshr_strdata_mod , only : shr_strdata_init_from_inline, shr_strdata_print
use dshr_strdata_mod , only : shr_strdata_advance
use dshr_methods_mod , only : dshr_fldbun_getfldptr
Expand Down Expand Up @@ -136,10 +136,6 @@ subroutine Init(this, bounds, NLFilename)
call ESMF_Finalize(endflag=ESMF_END_ABORT)
end if

if (masterproc) then
call shr_strdata_print(sdat_ch4, trim(stream_name)//' data')
endif

! Explicitly set current date to a hardcoded constant value. Otherwise
! using the real date can cause roundoff differences that are
! detrected as issues with exact restart. EBK M05/20/2017
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ subroutine lai_init(bounds)
! !USES:
use shr_mpi_mod , only : shr_mpi_bcast
use clm_nlUtilsMod , only : find_nlgroup_name
use lnd_comp_shr , only : mesh, model_meshfile, model_clock
use lnd_comp_shr , only : mesh, model_clock
use dshr_strdata_mod , only : shr_strdata_init_from_inline
use controlMod , only : NLFilename
!
Expand Down Expand Up @@ -210,7 +210,7 @@ subroutine lai_interp(bounds, canopystate_inst)
type(canopystate_type) , intent(inout) :: canopystate_inst
!
! !LOCAL VARIABLES:
integer :: ivt, p, ip, ig, n
integer :: ivt, p, ip, ig, n, g
integer :: lsize
integer :: rc
real(r8), pointer :: dataptr1d(:)
Expand All @@ -230,7 +230,11 @@ subroutine lai_interp(bounds, canopystate_inst)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then
call ESMF_Finalize(endflag=ESMF_END_ABORT)
end if
dataptr2d(:,n) = dataptr1d(:)
! Note that the size of dataptr1d includes ocean points so it will be around 3x larger than lsize
! So an explicit loop is required here
do g = 1,lsize
dataptr2d(g,n) = dataptr1d(g)
end do
end do

do p = bounds%begp, bounds%endp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ subroutine ndep_init(bounds, NLFilename)
use shr_string_mod , only : shr_string_listGetName, shr_string_listGetNum
use shr_log_mod , only : errMsg => shr_log_errMsg
use shr_mpi_mod , only : shr_mpi_bcast
use lnd_comp_shr , only : mesh, model_meshfile, model_clock
use lnd_comp_shr , only : mesh, model_clock
use dshr_strdata_mod , only : shr_strdata_init_from_inline
!
! arguments
Expand Down

0 comments on commit b4d64ac

Please sign in to comment.