Skip to content

Commit

Permalink
Merge pull request ESCOMP#15 from ESCOMP/feature/bug_fixes
Browse files Browse the repository at this point in the history
Several bug fixes
  • Loading branch information
jedwards4b authored Aug 8, 2020
2 parents 2fa1125 + bb79a7f commit 339112c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 42 deletions.
11 changes: 9 additions & 2 deletions datm/cime_config/namelist_definition_datm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
<!-- optional stream prescribed aero -->
<!-- ==================================== -->
<value stream="presaero.cplhist">
$DATM_DOMAIN_MESH
$ATM_DOMAIN_MESH
</value>
<value stream="presaero\.">
$DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc
Expand All @@ -351,7 +351,7 @@
<!-- optional topo -->
<!-- ==================================== -->
<value stream="topo.cplhist">
$DATM_DOMAIN_MESH
$ATM_DOMAIN_MESH
</value>
<value stream="topo.observed">
$DIN_LOC_ROOT/atm/datm7/topo_forcing/topodata_0.9x1.SCRIP.210520_ESMFmesh.nc
Expand Down Expand Up @@ -2412,6 +2412,10 @@
<value stream="CPLHISTForcing.State1hr">linear</value>
<value stream="presaero.cplhist">nearest</value>
<value stream="topo.cplhist">nearest</value>
<value stream="CLM_QIAN.Solar">coszen</value>
<value stream="CLM_QIAN.Precip">nearest</value>
<value stream="CLM_QIAN_WISO.Solar">coszen</value>
<value stream="CLM_QIAN_WISO.Precip">nearest</value>
<value stream="CLMCRUNCEP.Solar">coszen</value>
<value stream="CLMCRUNCEP.Precip">nearest</value>
<value stream="CLMCRUNCEPv7.Solar">coszen</value>
Expand Down Expand Up @@ -2506,6 +2510,9 @@
<value stream="CPLHISTForcing.State1hr">3.0</value>
<value stream="presaero.cplhist">3.0</value>
<value stream="topo.cplhist">3.0</value>
<value stream="co2tseries.20tr">1.e30</value>
<value stream="co2tseries.SSP">1.e30</value>
<value datm_mode="1PT">1.e30</value>
</values>
</entry>

Expand Down
2 changes: 1 addition & 1 deletion dice/cime_config/namelist_definition_dice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<value stream="ssmi$">
$DIN_LOC_ROOT/ice/dice7/SSMI/ssmi.ifrac.0.5x0.5_ESMFmesh_120520.nc
</value>
<value stream="ssmi_IAF">
<value stream="ssmi_iaf">
$DIN_LOC_ROOT/ocn/iaf/ssmi.ifrac.0.5x0.5_ESMFmesh_120520.nc
</value>
</values>
Expand Down
9 changes: 0 additions & 9 deletions dshr/dshr_dfield_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,6 @@ subroutine dshr_dfield_add_1d(dfields, sdat, state_fld, strm_fld, state, logunit
110 format(a)
end if

! write output
if (masterproc) then
if (found) then
write(logunit,100)'(dshr_addfield_add) set pointer to stream field strm_'//trim(strm_fld)//&
' stream index = ',ns,' field bundle index= ',nf
100 format(a,i6,2x,a,i6)
end if
end if

end subroutine dshr_dfield_add_1d

!===============================================================================
Expand Down
37 changes: 23 additions & 14 deletions streams/dshr_strdata_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ subroutine shr_strdata_init(sdat, model_clock, rc)
call shr_sys_abort(subName//"ERROR: file does not exist: "//trim(fileName))
end if
endif
if(filename /= 'none') then
if (filename /= 'none') then
sdat%pstrm(ns)%stream_mesh = ESMF_MeshCreate(trim(filename), fileformat=ESMF_FILEFORMAT_ESMFMESH, rc=rc)
endif
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down Expand Up @@ -698,15 +698,13 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc)
logical :: checkflag = .false.
integer :: npes
integer :: my_task
integer :: nstreams
real(r8) ,parameter :: solZenMin = 0.001_r8 ! minimum solar zenith angle
integer ,parameter :: tadj = 2
character(len=*) ,parameter :: timname = "_strd_adv"
character(*) ,parameter :: subname = "(shr_strdata_advance) "
character(*) ,parameter :: F00 = "('(shr_strdata_advance) ',a)"
character(*) ,parameter :: F01 = "('(shr_strdata_advance) ',a,a,i4,2(f10.5,2x))"
real(r8), pointer :: dataptr_temp1(:)
real(r8), pointer :: dataptr_temp2(:)
integer :: nstreams
!-------------------------------------------------------------------------------

rc = ESMF_SUCCESS
Expand Down Expand Up @@ -806,21 +804,27 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc)
call shr_cal_timeSet(timeUB,sdat%pstrm(ns)%ymdUB,0,sdat%stream(ns)%calendar,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
timeint = timeUB-timeLB
call ESMF_TimeIntervalGet(timeint,StartTimeIn=timeLB,d=dday)
call ESMF_TimeIntervalGet(timeint, StartTimeIn=timeLB, d=dday)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
dtime = abs(real(dday,r8) + real(sdat%pstrm(ns)%todUB-sdat%pstrm(ns)%todLB,r8)/shr_const_cDay)

sdat%pstrm(ns)%dtmin = min(sdat%pstrm(ns)%dtmin,dtime)
sdat%pstrm(ns)%dtmax = max(sdat%pstrm(ns)%dtmax,dtime)

if ((sdat%pstrm(ns)%dtmax/sdat%pstrm(ns)%dtmin) > sdat%stream(ns)%dtlimit) then
if (sdat%masterproc) then
write(sdat%logunit,*) trim(subname),' ERROR: for stream ',n
write(sdat%logunit,*) trim(subName),' ERROR: dt limit1 ',&
sdat%pstrm(ns)%dtmax, sdat%pstrm(ns)%dtmin, sdat%stream(ns)%dtlimit
write(sdat%logunit,*) trim(subName),' ERROR: dt limit2 ',&
write(sdat%logunit,*) trim(subname),' ERROR: for stream ',ns
write(sdat%logunit,*) trim(subName),' ERROR: dtime, dtmax, dtmin, dtlimit = ',&
dtime, sdat%pstrm(ns)%dtmax, sdat%pstrm(ns)%dtmin, sdat%stream(ns)%dtlimit
write(sdat%logunit,*) trim(subName),' ERROR: ymdLB, todLB, ymdUB, todUB = ', &
sdat%pstrm(ns)%ymdLB, sdat%pstrm(ns)%todLB, sdat%pstrm(ns)%ymdUB, sdat%pstrm(ns)%todUB
end if
call shr_sys_abort(trim(subName)//' ERROR dt limit for stream')
write(6,*) trim(subname),' ERROR: for stream ',ns
write(6,*) trim(subName),' ERROR: dtime, dtmax, dtmin, dtlimit = ',&
dtime, sdat%pstrm(ns)%dtmax, sdat%pstrm(ns)%dtmin, sdat%stream(ns)%dtlimit
write(6,*) trim(subName),' ERROR: ymdLB, todLB, ymdUB, todUB = ', &
sdat%pstrm(ns)%ymdLB, sdat%pstrm(ns)%todLB, sdat%pstrm(ns)%ymdUB, sdat%pstrm(ns)%todUB
call shr_sys_abort(trim(subName)//' ERROR dt limit for stream, see atm.log output')
endif
endif

Expand Down Expand Up @@ -1256,8 +1260,6 @@ subroutine shr_strdata_readstrm(sdat, ns, stream, stream_mesh, &

lsize = size(dataptr)
do nf = 1,size(fldlist_stream)
call dshr_fldbun_getfieldN(fldbun_model, nf, field_dst, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
rcode = pio_inq_varid(pioid, trim(fldlist_stream(nf)), varid)
! determine type of the variable
rcode = pio_inq_vartype(pioid, varid, pio_iovartype)
Expand Down Expand Up @@ -1357,16 +1359,23 @@ subroutine shr_strdata_readstrm(sdat, ns, stream, stream_mesh, &
call shr_sys_abort(subName//"ERROR: only double, real and short types are supported for stream read")
end if

if(associated(dataptr2d_src) .and. trim(fldlist_model(nf)) .eq. uname) then
if (associated(dataptr2d_src) .and. trim(fldlist_model(nf)) .eq. uname) then
! save in dataptr2d_src
dataptr2d_src(1,:) = dataptr(:)
elseif(associated(dataptr2d_src) .and. trim(fldlist_model(nf)) .eq. vname) then
else if (associated(dataptr2d_src) .and. trim(fldlist_model(nf)) .eq. vname) then
! save in dataptr2d_src
dataptr2d_src(2,:) = dataptr(:)
else if (pio_iodesc_set) then
! regrid the data
call dshr_fldbun_getfieldN(fldbun_model, nf, field_dst, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldRegrid(sdat%pstrm(ns)%field_stream, field_dst, routehandle=sdat%pstrm(ns)%routehandle, &
termorderflag=ESMF_TERMORDER_SRCSEQ, checkflag=.false., zeroregion=ESMF_REGION_TOTAL, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
else
! fill the data
call dshr_fldbun_getfieldN(fldbun_model, nf, field_dst, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldFill(field_dst, dataFillScheme="const", const1=dataptr(1), rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
endif
Expand Down
40 changes: 24 additions & 16 deletions streams/dshr_stream_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module dshr_stream_mod
end type shr_stream_streamType

!----- parameters -----
integer , save :: debug = 0 ! edit/turn-on for debug write statements
integer :: debug = 0 ! edit/turn-on for debug write statements
real(R8) , parameter :: spd = shr_const_cday ! seconds per day
character(*) , parameter :: u_FILE_u = &
__FILE__
Expand All @@ -129,19 +129,23 @@ subroutine shr_stream_init_from_xml(xmlfilename, streamdat, mastertask, logunit,
! <?xml version="1.0"?>
! <file id="stream" version="1.0">
! <stream_info>
! <meshfile>
! mesh_filename
! </meshfile>
! <data_files>
! /glade/p/cesmdata/cseg/inputdata/atm/datm7/NYF/nyf.ncep.T62.050923.nc
! .....
! <data_files>
! <data_variables>
! u_10 u
! </data_variables>
! <stream_offset>
! 0
! </stream_offset>
! <taxmode></taxmode>
! <tInterpAlgo></tInterpAlgo>
! <readMode></readMode>
! <mapalgo></mapalgo>
! <dtlimit></dtlimit>
! <yearFirst></yearFirst>
! <yearLast></yearLast>
! <yearAlign></yearAlign>
! <stream_vectors></stream_vectors>
! <stream_mesh_file></stream_mesh_file>
! <stream_data_files>
! <file></file>
! </stream_data_files>
! <stream_data_variables>
! <var></var>
! </stream_data_variables>
! <stream_offset></stream_offset>
! </stream_info>
! </file>
! ---------------------------------------------------------------------
Expand All @@ -163,6 +167,7 @@ subroutine shr_stream_init_from_xml(xmlfilename, streamdat, mastertask, logunit,
integer :: status
integer :: tmp(6)
real(r8) :: rtmp(1)
character(*),parameter :: subName = '(shr_stream_init_from_xml) '
! --------------------------------------------------------

rc = ESMF_SUCCESS
Expand Down Expand Up @@ -332,16 +337,19 @@ subroutine shr_stream_init_from_xml(xmlfilename, streamdat, mastertask, logunit,
streamdat(i)%pio_iotype = shr_pio_getiotype(trim(compname))
streamdat(i)%pio_ioformat = shr_pio_getioformat(trim(compname))
call shr_stream_getCalendar(streamdat(i), 1, streamdat(i)%calendar)
enddo

! Error check
if (trim(streamdat(i)%taxmode) == shr_stream_taxis_extend .and. streamdat(i)%dtlimit < 1.e10) then
call shr_sys_abort(trim(subName)//" ERROR: if taxmode value is extend set dtlimit to 1.e30")
end if
enddo

! Set logunit
streamdat(:)%logunit = logunit

! initialize flag that stream has been set
streamdat(:)%init = .true.


end subroutine shr_stream_init_from_xml

!===============================================================================
Expand Down

0 comments on commit 339112c

Please sign in to comment.