From 5f9a6557a6f04430c243336f195a4825dd76ce7a Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Wed, 29 Jul 2020 19:47:52 -0600 Subject: [PATCH 1/3] bug fixes --- datm/cime_config/namelist_definition_datm.xml | 11 ++++- dshr/dshr_dfield_mod.F90 | 9 ----- streams/dshr_strdata_mod.F90 | 26 +++++++----- streams/dshr_stream_mod.F90 | 40 +++++++++++-------- 4 files changed, 48 insertions(+), 38 deletions(-) diff --git a/datm/cime_config/namelist_definition_datm.xml b/datm/cime_config/namelist_definition_datm.xml index 479c5587b5..9167c72a29 100644 --- a/datm/cime_config/namelist_definition_datm.xml +++ b/datm/cime_config/namelist_definition_datm.xml @@ -342,7 +342,7 @@ - $DATM_DOMAIN_MESH + $ATM_DOMAIN_MESH $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc @@ -351,7 +351,7 @@ - $DATM_DOMAIN_MESH + $ATM_DOMAIN_MESH $DIN_LOC_ROOT/atm/datm7/topo_forcing/topodata_0.9x1.SCRIP.210520_ESMFmesh.nc @@ -2409,6 +2409,10 @@ linear nearest nearest + coszen + nearest + coszen + nearest coszen nearest coszen @@ -2503,6 +2507,9 @@ 3.0 3.0 3.0 + 1.e30 + 1.e30 + 1.e30 diff --git a/dshr/dshr_dfield_mod.F90 b/dshr/dshr_dfield_mod.F90 index 8f4a774e8b..6abcc1c36f 100644 --- a/dshr/dshr_dfield_mod.F90 +++ b/dshr/dshr_dfield_mod.F90 @@ -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 !=============================================================================== diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index 7821351f03..6e2cf2a954 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -6,7 +6,7 @@ module dshr_strdata_mod use ESMF use shr_kind_mod , only : r8=>shr_kind_r8, r4=>shr_kind_r4, i2=>shr_kind_I2 - use shr_kind_mod , only : cs=>shr_kind_cs, cl=>shr_kind_cl, cxx=>shr_kind_cxx + use shr_kind_mod , only : cs=>shr_kind_cs, cl=>shr_kind_cl, cxx=>shr_kind_cxx use shr_sys_mod , only : shr_sys_abort use shr_const_mod , only : shr_const_pi, shr_const_cDay, shr_const_spval use shr_cal_mod , only : shr_cal_calendarname, shr_cal_timeSet @@ -213,7 +213,7 @@ subroutine shr_strdata_init_from_inline(sdat, my_task, logunit, compname, model_ type(shr_strdata_type) , intent(inout) :: sdat ! stream data type integer , intent(in) :: my_task ! my mpi task integer , intent(in) :: logunit ! stdout logunit - character(len=*) , intent(in) :: compname ! component name (e.g. ATM, OCN, ...) + character(len=*) , intent(in) :: compname ! component name (e.g. ATM, OCN, ...) type(ESMF_Clock) , intent(in) :: model_clock ! model clock type(ESMF_Mesh) , intent(in) :: model_mesh ! model mesh character(*) , intent(in) :: stream_meshFile ! full pathname to stream mesh file @@ -699,15 +699,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 @@ -809,21 +807,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 diff --git a/streams/dshr_stream_mod.F90 b/streams/dshr_stream_mod.F90 index 5f1975eb1f..776c14343c 100644 --- a/streams/dshr_stream_mod.F90 +++ b/streams/dshr_stream_mod.F90 @@ -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__ @@ -129,19 +129,23 @@ subroutine shr_stream_init_from_xml(xmlfilename, streamdat, mastertask, logunit, ! ! ! - ! - ! mesh_filename - ! - ! - ! /glade/p/cesmdata/cseg/inputdata/atm/datm7/NYF/nyf.ncep.T62.050923.nc - ! ..... - ! - ! - ! u_10 u - ! - ! - ! 0 - ! + ! + ! + ! + ! + ! + ! + ! + ! + ! + ! + ! + ! + ! + ! + ! + ! + ! ! ! ! --------------------------------------------------------------------- @@ -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 @@ -332,8 +337,12 @@ 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 @@ -341,7 +350,6 @@ subroutine shr_stream_init_from_xml(xmlfilename, streamdat, mastertask, logunit, ! initialize flag that stream has been set streamdat(:)%init = .true. - end subroutine shr_stream_init_from_xml !=============================================================================== From 4f5499d3d86a9572dd0faebd0968e5585525c209 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Thu, 6 Aug 2020 13:45:59 -0600 Subject: [PATCH 2/3] cleanup --- streams/dshr_strdata_mod.F90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index 6e2cf2a954..21441bf0a6 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -1264,8 +1264,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) @@ -1371,6 +1369,9 @@ subroutine shr_strdata_readstrm(sdat, ns, stream, stream_mesh, & elseif(associated(dataptr2d_src) .and. trim(fldlist_model(nf)) .eq. vname) then dataptr2d_src(2,:) = dataptr(:) else if (pio_iodesc_set) then + 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 From bfa92e3f742d30189e17516398ccb7fe745e33e4 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Sat, 8 Aug 2020 15:14:31 -0600 Subject: [PATCH 3/3] more bug fixes --- dice/cime_config/namelist_definition_dice.xml | 2 +- streams/dshr_strdata_mod.F90 | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/dice/cime_config/namelist_definition_dice.xml b/dice/cime_config/namelist_definition_dice.xml index 86e4b24d2c..9401e295cc 100644 --- a/dice/cime_config/namelist_definition_dice.xml +++ b/dice/cime_config/namelist_definition_dice.xml @@ -76,7 +76,7 @@ $DIN_LOC_ROOT/ice/dice7/SSMI/ssmi.ifrac.0.5x0.5_ESMFmesh_120520.nc - + $DIN_LOC_ROOT/ocn/iaf/ssmi.ifrac.0.5x0.5_ESMFmesh_120520.nc diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index 21441bf0a6..a250f7143d 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -396,7 +396,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 @@ -1363,19 +1363,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