From b4d64ac56ff84112631535eb9353853df1c8a951 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Wed, 16 Jun 2021 15:59:14 -0600 Subject: [PATCH] cdeps streams moved to share_esmf and lilac stream moved to lilac --- cime_config/buildnml | 1 - lilac/bld_templates/lilac_in_template | 1 + lilac/src/lilac_atmaero.F90 | 264 +++++++----------- lilac/src/lilac_mod.F90 | 3 +- python/ctsm/lilac_make_runtime_inputs.py | 1 + src/cpl/lilac/lnd_comp_esmf.F90 | 22 +- src/cpl/lilac/lnd_comp_shr.F90 | 15 + .../FireDataBaseType.F90 | 4 +- .../SoilMoistureStreamMod.F90 | 0 .../UrbanTimeVarType.F90 | 8 +- .../ch4FInundatedStreamType.F90 | 6 +- .../{nuopc => share_esmf}/laiStreamMod.F90 | 10 +- .../{nuopc => share_esmf}/ndepStreamMod.F90 | 2 +- 13 files changed, 146 insertions(+), 191 deletions(-) create mode 100644 src/cpl/lilac/lnd_comp_shr.F90 rename src/cpl/{nuopc => share_esmf}/FireDataBaseType.F90 (99%) rename src/cpl/{nuopc => share_esmf}/SoilMoistureStreamMod.F90 (100%) rename src/cpl/{nuopc => share_esmf}/UrbanTimeVarType.F90 (97%) rename src/cpl/{nuopc => share_esmf}/ch4FInundatedStreamType.F90 (98%) rename src/cpl/{nuopc => share_esmf}/laiStreamMod.F90 (96%) rename src/cpl/{nuopc => share_esmf}/ndepStreamMod.F90 (99%) diff --git a/cime_config/buildnml b/cime_config/buildnml index d47b77fbde..44064b40b8 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -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)) diff --git a/lilac/bld_templates/lilac_in_template b/lilac/bld_templates/lilac_in_template index 78a8ab75cf..1543ed2a0e 100644 --- a/lilac/bld_templates/lilac_in_template +++ b/lilac/bld_templates/lilac_in_template @@ -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 / diff --git a/lilac/src/lilac_atmaero.F90 b/lilac/src/lilac_atmaero.F90 index f9098f4a89..8832c78417 100644 --- a/lilac/src/lilac_atmaero.F90 +++ b/lilac/src/lilac_atmaero.F90 @@ -14,25 +14,16 @@ module lilac_atmaero use shr_nl_mod , only : shr_nl_find_group_name use shr_log_mod , only : shr_log_errMsg use shr_mpi_mod , only : shr_mpi_bcast - use shr_strdata_mod , only : shr_strdata_type, shr_strdata_create - use shr_strdata_mod , only : shr_strdata_print, shr_strdata_advance - use shr_string_mod , only : shr_string_listAppend use shr_cal_mod , only : shr_cal_ymd2date - use shr_pio_mod , only : shr_pio_getiotype - use mct_mod , only : mct_avect_indexra, mct_gsmap, mct_ggrid - use mct_mod , only : mct_gsmap_init, mct_gsmap_orderedpoints - use mct_mod , only : mct_ggrid_init, mct_ggrid_importIAttr, mct_ggrid_importRattr - ! ctsm uses - use ncdio_pio , only : pio_subsystem - use domainMod , only : ldomain - use clm_time_manager , only : get_calendar + ! cdeps uses + use dshr_methods_mod , only : dshr_fldbun_getfldptr + use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_init_from_inline, shr_strdata_advance ! lilac uses - use lilac_atmcap , only : gindex_atm use lilac_methods , only : chkerr use lilac_methods , only : lilac_methods_FB_getFieldN - use lilac_constants , only : field_index_unset + use lilac_constants , only : field_index_unset, logunit use ctsm_LilacCouplingFields, only : a2l_fields, lilac_atm2lnd use ctsm_LilacCouplingFieldIndices @@ -44,8 +35,8 @@ module lilac_atmaero integer :: field_index = field_index_unset end type field_mapping_type - public :: lilac_atmaero_init ! initialize stream data type sdat - public :: lilac_atmaero_interp ! interpolates between two years of ndep file data + public :: lilac_atmaero_init ! initialize stream data type sdat + public :: lilac_atmaero_interp ! interpolates between two years of ndep file data ! module data type(shr_strdata_type) :: sdat ! input data stream @@ -63,7 +54,7 @@ module lilac_atmaero contains !============================================================================== - subroutine lilac_atmaero_init(atm2cpl_state, rc) + subroutine lilac_atmaero_init(atm2cpl_state, lilac_clock, rc) ! ---------------------------------------- ! Initialize data stream information. @@ -71,45 +62,35 @@ subroutine lilac_atmaero_init(atm2cpl_state, rc) ! input/output variables type(ESMF_State) , intent(inout) :: atm2cpl_state + type(ESMF_Clock) , intent(inout) :: lilac_clock integer , intent(out) :: rc ! local variables type(ESMF_VM) :: vm - type(ESMF_Mesh) :: lmesh + type(ESMF_Mesh) :: mesh type(ESMF_FieldBundle) :: lfieldbundle type(ESMF_Field) :: lfield - type(mct_ggrid) :: ggrid_atm ! domain information - type(mct_gsmap) :: gsmap_atm ! decompositoin info + integer :: mytask ! mpi task number + integer :: mpicom ! mpi communicator + integer :: n, nfld ! indices + integer :: field_index ! field index + integer :: nunit ! namelist input unit + integer :: ierr ! namelist i/o error flag + character(len=cl) :: stream_fldfilename ! name of input stream datafile + character(len=cl) :: stream_meshfile ! name of input stream meshfile + character(len=CL) :: mapalgo = 'bilinear' ! type of 2d mapping + character(len=CS) :: taxmode = 'extend' ! time extrapolation + integer :: stream_year_first ! first year in stream to use + integer :: stream_year_last ! last year in stream to use + integer :: model_year_align ! align stream_year_first with model year type(field_mapping_type), allocatable :: all_fields(:) ! all fields that can possibly be read from data - integer :: mytask ! mpi task number - integer :: mpicom ! mpi communicator - integer :: n ! index - integer :: field_index - integer :: lsize ! local size - integer :: gsize ! global size - integer :: nunit ! namelist input unit - integer :: ierr ! namelist i/o error flag - character(len=cl) :: stream_fldfilename ! name of input stream file - character(len=CL) :: mapalgo = 'bilinear' ! type of 2d mapping - character(len=CS) :: taxmode = 'extend' ! time extrapolation - character(len=CL) :: fldlistFile ! name of fields in input stream file - character(len=CL) :: fldlistModel ! name of fields in model - integer :: stream_year_first ! first year in stream to use - integer :: stream_year_last ! last year in stream to use - integer :: model_year_align ! align stream_year_first with model year - integer :: spatialDim - integer :: numOwnedElements - real(r8), pointer :: ownedElemCoords(:) - real(r8), pointer :: mesh_lons(:) - real(r8), pointer :: mesh_lats(:) - real(r8), pointer :: mesh_areas(:) - real(r8), pointer :: rdata(:) - integer , pointer :: idata(:) + character(len=CS), allocatable :: fldlistFile(:) + character(len=CS), allocatable :: fldlistModel(:) !----------------------------------------------------------------------- namelist /atmaero_stream/ & stream_year_first, stream_year_last, model_year_align, & - stream_fldfilename + stream_fldfilename, stream_meshfile rc = ESMF_SUCCESS @@ -129,29 +110,40 @@ subroutine lilac_atmaero_init(atm2cpl_state, rc) field_mapping_type('DSTX04WD', lilac_a2l_Faxa_dstwet4), & field_mapping_type('DSTX04DD', lilac_a2l_Faxa_dstdry4)] - num_fields_to_read = 0 - allocate(fields_to_read(size(all_fields))) - fldlistFile = ' ' - fldlistModel = ' ' + nfld = 0 do n = 1, size(all_fields) field_index = all_fields(n)%field_index if (a2l_fields%is_needed_from_data(field_index)) then - num_fields_to_read = num_fields_to_read + 1 - fields_to_read(num_fields_to_read) = all_fields(n) - call shr_string_listAppend(fldlistFile, fields_to_read(num_fields_to_read)%field_name) - call shr_string_listAppend(fldlistModel, a2l_fields%get_fieldname(field_index)) + nfld = nfld + 1 end if end do + num_fields_to_read = nfld + if (num_fields_to_read == 0) then return end if + allocate(fields_to_read(num_fields_to_read)) + allocate(fldlistFile(num_fields_to_read)) + allocate(fldlistModel(num_fields_to_read)) + nfld = 0 + do n = 1, size(all_fields) + field_index = all_fields(n)%field_index + if (a2l_fields%is_needed_from_data(field_index)) then + nfld = nfld + 1 + fields_to_read(nfld) = all_fields(n) + fldListFile(nfld) = trim(fields_to_read(nfld)%field_name) + fldListModel(nfld) = trim(a2l_fields%get_fieldname(field_index)) + end if + end do + ! default values for namelist stream_year_first = 1 ! first year in stream to use stream_year_last = 1 ! last year in stream to use model_year_align = 1 ! align stream_year_first with this model year stream_fldFileName = ' ' + stream_meshfile = ' ' ! get mytask and mpicom call ESMF_VMGetCurrent(vm, rc=rc) @@ -177,107 +169,57 @@ subroutine lilac_atmaero_init(atm2cpl_state, rc) call shr_mpi_bcast(stream_year_last , mpicom) call shr_mpi_bcast(model_year_align , mpicom) call shr_mpi_bcast(stream_fldfilename, mpicom) + call shr_mpi_bcast(stream_meshfile , mpicom) if (mytask == 0) then print *, ' ' - print *, 'atmaero stream settings:' - print *, ' stream_year_first = ',stream_year_first - print *, ' stream_year_last = ',stream_year_last - print *, ' model_year_align = ',model_year_align - print *, ' stream_fldFileName = ',stream_fldFileName + write(logunit,'(a)') 'atmaero stream settings:' + write(logunit,'(a,i8)')' stream_year_first = ',stream_year_first + write(logunit,'(a,i8)')' stream_year_last = ',stream_year_last + write(logunit,'(a,i8)')' model_year_align = ',model_year_align + write(logunit,'(a)' )' stream_fldFileName = ',trim(stream_fldFileName) + write(logunit,'(a)' )' stream_meshfile = ',trim(stream_meshfile) print *, ' ' endif ! ------------------------------ - ! create the mct gsmap - ! ------------------------------ - lsize = size(gindex_atm) - gsize = ldomain%ni * ldomain%nj - call mct_gsmap_init( gsmap_atm, gindex_atm, mpicom, 1, lsize, gsize ) - - ! ------------------------------ - ! obtain mesh lats, lons and areas + ! obtain atm mesh ! ------------------------------ call ESMF_StateGet(atm2cpl_state, 'a2c_fb', lfieldbundle, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call lilac_methods_FB_getFieldN(lfieldbundle, fieldnum=1, field=lfield, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - - call ESMF_FieldGet(lfield, mesh=lmesh, rc=rc) + call ESMF_FieldGet(lfield, mesh=mesh, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_MeshGet(lmesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - if (numOwnedElements /= lsize) then - call shr_sys_abort('ERROR: numOwnedElements is not equal to lsize') - end if - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - - call ESMF_MeshGet(lmesh, ownedElemCoords=ownedElemCoords, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - - allocate(mesh_lons(numOwnedElements)) - allocate(mesh_lats(numOwnedElements)) - allocate(mesh_areas(numOwnedElements)) - do n = 1,numOwnedElements - mesh_lons(n) = ownedElemCoords(2*n-1) - mesh_lats(n) = ownedElemCoords(2*n) - mesh_areas(n) = 1.e36 ! hard-wire for now for testing - end do - - ! ------------------------------ - ! create the mct ggrid - ! ------------------------------ - call mct_ggrid_init( ggrid=ggrid_atm, CoordChars='lat:lon:hgt', OtherChars='area:aream:mask:frac', lsize=lsize) - call mct_gsmap_orderedpoints(gsmap_atm, mytask, idata) - call mct_gGrid_importIAttr(ggrid_atm,'GlobGridNum', idata, lsize) - call mct_gGrid_importRattr(ggrid_atm,"lon" , mesh_lons , lsize) - call mct_gGrid_importRattr(ggrid_atm,"lat" , mesh_lats , lsize) - call mct_gGrid_importRattr(ggrid_atm,"area", mesh_areas, lsize) - allocate(rdata(lsize)) - rdata(:) = 1._R8 - call mct_gGrid_importRattr(ggrid_atm,"mask", rdata, lsize) - deallocate(mesh_lons, mesh_lats, mesh_areas, rdata) - ! ------------------------------ ! create the stream data sdat ! ------------------------------ - call shr_strdata_create(sdat,& - name = "atmaero", & - pio_subsystem = pio_subsystem, & - pio_iotype = shr_pio_getiotype(compid= 1), & - mpicom = mpicom, & - compid = 1, & - gsmap = gsmap_atm, & - ggrid = ggrid_atm, & - nxg = ldomain%ni, & - nyg = ldomain%nj, & - yearFirst = stream_year_first, & - yearLast = stream_year_last, & - yearAlign = model_year_align, & - offset = 0, & - domFilePath = '', & - domfilename = trim(stream_fldfilename), & - domTvarName = 'time', & - domXvarName = 'lon' , & - domYvarName = 'lat' , & - domAreaName = 'area', & - domMaskName = 'mask', & - filePath = '', & - filename = (/trim(stream_fldfilename)/), & - fldListFile = trim(fldlistFile), & - fldListModel = trim(fldlistModel), & - fillalgo = 'none', & - mapalgo = mapalgo, & - calendar = get_calendar(), & - taxmode = taxmode ) - - if (mytask == 0) then - call shr_strdata_print(sdat,'ATMAERO data') - endif + call shr_strdata_init_from_inline(sdat, & + my_task = mytask, & + logunit = logunit, & + compname = 'LND', & + model_clock = lilac_clock, & + model_mesh = mesh, & + stream_meshfile = trim(stream_meshfile), & + stream_lev_dimname = 'null', & + stream_mapalgo = trim(mapalgo), & + stream_filenames = (/trim(stream_fldfilename)/), & + stream_fldlistFile = fldlistFile, & + stream_fldListModel = fldlistModel, & + stream_yearFirst = stream_year_first, & + stream_yearLast = stream_year_last, & + stream_yearAlign = model_year_align, & + stream_offset = 0, & + stream_taxmode = taxmode, & + stream_dtlimit = 1.5_r8, & + stream_tintalgo = 'linear', & + stream_name = 'ATMAERO data ', & + rc = rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then + call ESMF_Finalize(endflag=ESMF_END_ABORT) + end if end subroutine lilac_atmaero_init @@ -290,13 +232,12 @@ subroutine lilac_atmaero_interp(clock, rc) integer, intent(out) :: rc ! local variables - type(ESMF_VM) :: vm - integer :: mpicom ! mpi communicator - integer :: mytask ! mpi task number - type(ESMF_FieldBundle) :: lfieldbundle - type(ESMF_Time) :: currTime - integer :: yy, mm, dd, sec, curr_ymd - integer :: n + type(ESMF_Time) :: currTime + integer :: yy, mm, dd, sec, curr_ymd + integer :: n + integer :: field_index + character(len=CS) :: stream_varname + real(r8), pointer :: dataptr1d(:) character(len=*), parameter :: subname='lilac_atmaero: [lilac_atmaero_interp]' !----------------------------------------------------------------------- @@ -306,43 +247,32 @@ subroutine lilac_atmaero_interp(clock, rc) return end if - ! get mytask and mpicom - call ESMF_VMGetCurrent(vm, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_VMGet(vm, localPet=mytask, mpiCommunicator=mpicom, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - ! get current time info call ESMF_ClockGet( clock, currTime=currTime, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeGet( currTime, yy=yy, mm=mm, dd=dd, s=sec, rc=rc ) if (ChkErr(rc,__LINE__,u_FILE_u)) return call shr_cal_ymd2date(yy,mm,dd,curr_ymd) ! advance the streams - call shr_strdata_advance(sdat, curr_ymd, sec, mpicom, 'atmaero') + call shr_strdata_advance(sdat, ymd=curr_ymd, tod=sec, logunit=logunit, istr='atmaero', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then + call ESMF_Finalize(endflag=ESMF_END_ABORT) + end if + ! obtain the stream data do n = 1, num_fields_to_read - call set_field(n) + field_index = fields_to_read(n)%field_index + stream_varname = a2l_fields%get_fieldname(field_index) + write(6,*)'DEBUG: stream_varname = ',trim(stream_varname) + call dshr_fldbun_getFldPtr(sdat%pstrm(1)%fldbun_model, trim(stream_varname), fldptr1=dataptr1d, rc=rc) + + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then + call ESMF_Finalize(endflag=ESMF_END_ABORT) + end if + call lilac_atm2lnd(field_index, dataptr1d) end do end subroutine lilac_atmaero_interp - !============================================================================== - - subroutine set_field(fieldnum) - - ! input/output data - integer, intent(in) :: fieldnum ! index into fields_to_read and sdat (which are assumed to have the same ordering) - - ! local data - integer :: field_index ! index in a2l_fields - !----------------------------------------------------------------------- - - field_index = fields_to_read(fieldnum)%field_index - call lilac_atm2lnd(field_index, sdat%avs(1)%rAttr(fieldnum,:)) - - end subroutine set_field - end module lilac_atmaero diff --git a/lilac/src/lilac_mod.F90 b/lilac/src/lilac_mod.F90 index d98e3e080c..6eb17d008c 100644 --- a/lilac/src/lilac_mod.F90 +++ b/lilac/src/lilac_mod.F90 @@ -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 @@ -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") !------------------------------------------------------------------------- diff --git a/python/ctsm/lilac_make_runtime_inputs.py b/python/ctsm/lilac_make_runtime_inputs.py index 2119c0e225..ff292cb660 100644 --- a/python/ctsm/lilac_make_runtime_inputs.py +++ b/python/ctsm/lilac_make_runtime_inputs.py @@ -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, diff --git a/src/cpl/lilac/lnd_comp_esmf.F90 b/src/cpl/lilac/lnd_comp_esmf.F90 index 7d227a4134..c01e454211 100644 --- a/src/cpl/lilac/lnd_comp_esmf.F90 +++ b/src/cpl/lilac/lnd_comp_esmf.F90 @@ -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 @@ -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 @@ -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 !---------------------- @@ -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 !---------------------- @@ -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 @@ -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) @@ -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) @@ -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) @@ -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 diff --git a/src/cpl/lilac/lnd_comp_shr.F90 b/src/cpl/lilac/lnd_comp_shr.F90 new file mode 100644 index 0000000000..dd619c7648 --- /dev/null +++ b/src/cpl/lilac/lnd_comp_shr.F90 @@ -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 diff --git a/src/cpl/nuopc/FireDataBaseType.F90 b/src/cpl/share_esmf/FireDataBaseType.F90 similarity index 99% rename from src/cpl/nuopc/FireDataBaseType.F90 rename to src/cpl/share_esmf/FireDataBaseType.F90 index a0e429e10b..f842fc270b 100644 --- a/src/cpl/nuopc/FireDataBaseType.F90 +++ b/src/cpl/share_esmf/FireDataBaseType.F90 @@ -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 ! @@ -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 diff --git a/src/cpl/nuopc/SoilMoistureStreamMod.F90 b/src/cpl/share_esmf/SoilMoistureStreamMod.F90 similarity index 100% rename from src/cpl/nuopc/SoilMoistureStreamMod.F90 rename to src/cpl/share_esmf/SoilMoistureStreamMod.F90 diff --git a/src/cpl/nuopc/UrbanTimeVarType.F90 b/src/cpl/share_esmf/UrbanTimeVarType.F90 similarity index 97% rename from src/cpl/nuopc/UrbanTimeVarType.F90 rename to src/cpl/share_esmf/UrbanTimeVarType.F90 index 628ac7a4d3..5a479934f0 100644 --- a/src/cpl/nuopc/UrbanTimeVarType.F90 +++ b/src/cpl/share_esmf/UrbanTimeVarType.F90 @@ -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 @@ -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 diff --git a/src/cpl/nuopc/ch4FInundatedStreamType.F90 b/src/cpl/share_esmf/ch4FInundatedStreamType.F90 similarity index 98% rename from src/cpl/nuopc/ch4FInundatedStreamType.F90 rename to src/cpl/share_esmf/ch4FInundatedStreamType.F90 index 7435cbde1e..9a3910a73a 100644 --- a/src/cpl/nuopc/ch4FInundatedStreamType.F90 +++ b/src/cpl/share_esmf/ch4FInundatedStreamType.F90 @@ -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 @@ -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 diff --git a/src/cpl/nuopc/laiStreamMod.F90 b/src/cpl/share_esmf/laiStreamMod.F90 similarity index 96% rename from src/cpl/nuopc/laiStreamMod.F90 rename to src/cpl/share_esmf/laiStreamMod.F90 index 0005819972..a44f0b7198 100644 --- a/src/cpl/nuopc/laiStreamMod.F90 +++ b/src/cpl/share_esmf/laiStreamMod.F90 @@ -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 ! @@ -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(:) @@ -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 diff --git a/src/cpl/nuopc/ndepStreamMod.F90 b/src/cpl/share_esmf/ndepStreamMod.F90 similarity index 99% rename from src/cpl/nuopc/ndepStreamMod.F90 rename to src/cpl/share_esmf/ndepStreamMod.F90 index 4432b0eeea..7aab7c1d5f 100644 --- a/src/cpl/nuopc/ndepStreamMod.F90 +++ b/src/cpl/share_esmf/ndepStreamMod.F90 @@ -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