From 654c6f488eb714ecacbae6391e4cd58070adc322 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 9 Oct 2018 18:16:34 -0600 Subject: [PATCH 1/3] Same changes on mosart fill-value and pylint cleanup on rtm Move the mosart changes to rtm. Did this with patch and then resolved rejected diffs by hand. Also did pylint on my mac. --- cime_config/buildlib | 28 ++++----- cime_config/buildnml | 54 +++++++++-------- src/riverroute/RtmHistFile.F90 | 102 ++++++++++++++++----------------- src/riverroute/RtmIO.F90 | 17 +++--- src/riverroute/RtmRestFile.F90 | 65 ++++++++++----------- 5 files changed, 136 insertions(+), 130 deletions(-) diff --git a/cime_config/buildlib b/cime_config/buildlib index 07447bea8b..a8bdc72ba1 100755 --- a/cime_config/buildlib +++ b/cime_config/buildlib @@ -1,6 +1,10 @@ #!/usr/bin/env python - -import os, shutil, sys, glob +""" +Build the mosart component library +""" +#pylint: disable=unused-wildcard-import, wildcard-import, multiple-imports +#pylint: disable=wrong-import-position, invalid-name, too-many-locals +import os, sys CIMEROOT = os.environ.get("CIMEROOT") if CIMEROOT is None: @@ -22,25 +26,25 @@ def _build_rtm(): with Case(caseroot) as case: casetools = case.get_value("CASETOOLS") - gmake_j = case.get_value("GMAKE_J") - gmake = case.get_value("GMAKE") + gmake_j = case.get_value("GMAKE_J") + gmake = case.get_value("GMAKE") # create Filepath file objroot = case.get_value("OBJROOT") - filepath_file = os.path.join(objroot,"rof","obj","Filepath") + filepath_file = os.path.join(objroot, "rof", "obj", "Filepath") if not os.path.isfile(filepath_file): srcroot = case.get_value("SRCROOT") caseroot = case.get_value("CASEROOT") - paths = [ os.path.join(caseroot,"SourceMods","src.rtm"), - os.path.join(srcroot,"components","rtm","src","riverroute"), - os.path.join(srcroot,"components","rtm","src","cpl")] + paths = [os.path.join(caseroot, "SourceMods", "src.rtm"), + os.path.join(srcroot, "components", "rtm", "src", "riverroute"), + os.path.join(srcroot, "components", "rtm", "src", "cpl")] with open(filepath_file, "w") as filepath: filepath.write("\n".join(paths)) filepath.write("\n") # build the library - complib = os.path.join(libroot,"librof.a") + complib = os.path.join(libroot, "librof.a") makefile = os.path.join(casetools, "Makefile") cmd = "%s complib -j %d MODEL=rtm COMPLIB=%s -f %s" \ @@ -49,13 +53,9 @@ def _build_rtm(): rc, out, err = run_cmd(cmd, from_dir=bldroot) expect(rc == 0, "Command %s failed rc=%d\nout=%s\nerr=%s" % (cmd, rc, out, err)) - logger.info("Command %s completed with output %s\nerr %s" ,cmd, out, err) + logger.info("Command %s completed with output %s\nerr %s", cmd, out, err) ############################################################################### if __name__ == "__main__": _build_rtm() - - - - diff --git a/cime_config/buildnml b/cime_config/buildnml index 1a851fc89c..98e6fdd6cf 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -8,8 +8,8 @@ # Disable these because this is our standard setup # pylint: disable=wildcard-import,unused-wildcard-import,wrong-import-position - -import os, shutil, sys, glob +# pylint: disable=multiple-imports +import os, shutil, sys CIMEROOT = os.environ.get("CIMEROOT") if CIMEROOT is None: @@ -20,13 +20,13 @@ from standard_script_setup import * from CIME.case import Case from CIME.nmlgen import NamelistGenerator from CIME.utils import expect -from CIME.buildnml import create_namelist_infile +from CIME.buildnml import create_namelist_infile, parse_input logger = logging.getLogger(__name__) # pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements #################################################################################### -def _create_namelist(case, confdir, inst_string, infile, nmlgen): +def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path): #################################################################################### """Write out the namelist for this component. @@ -40,7 +40,7 @@ def _create_namelist(case, confdir, inst_string, infile, nmlgen): #---------------------------------------------------- config = {} config['rtm_mode'] = case.get_value("RTM_MODE") - config['rtm_flood_mode'] = case.get_value("RTM_FLOOD_MODE") + config['rtm_flood_mode'] = case.get_value("RTM_FLOOD_MODE") config['clm_accelerated_spinup'] = case.get_value("CLM_ACCELERATED_SPINUP") config['rof_grid'] = case.get_value("ROF_GRID") config['lnd_grid'] = case.get_value("LND_GRID") @@ -52,7 +52,7 @@ def _create_namelist(case, confdir, inst_string, infile, nmlgen): # Check for incompatible options. #---------------------------------------------------- if config["rof_grid"] == "null" and config["rtm_mode"] != "NULL": - expect (False, "ROF_GRID is null RTM_MODE not NULL") + expect(False, "ROF_GRID is null RTM_MODE not NULL") #---------------------------------------------------- # Clear out old data. @@ -74,10 +74,10 @@ def _create_namelist(case, confdir, inst_string, infile, nmlgen): if run_type == 'branch' or run_type == 'hybrid': run_refcase = case.get_value("RUN_REFCASE") run_refdate = case.get_value("RUN_REFDATE") - run_tod = case.get_value("RUN_REFTOD") + run_tod = case.get_value("RUN_REFTOD") filename = "%s.rtm%s.r.%s-%s.nc" %(run_refcase, inst_string, run_refdate, run_tod) rundir = case.get_value("RUNDIR") - if not os.path.exists(os.path.join(rundir, filename ) ): + if not os.path.exists(os.path.join(rundir, filename)): filename = "%s.rtm.r.%s-%s.nc" %(run_refcase, run_refdate, run_tod) if run_type == "hybrid": @@ -90,7 +90,7 @@ def _create_namelist(case, confdir, inst_string, infile, nmlgen): else: nmlgen.add_default("finidat_rtm") - ncpl_base_period = case.get_value('NCPL_BASE_PERIOD') + ncpl_base_period = case.get_value('NCPL_BASE_PERIOD') if ncpl_base_period == 'hour': basedt = 3600 elif ncpl_base_period == 'day': @@ -113,7 +113,7 @@ def _create_namelist(case, confdir, inst_string, infile, nmlgen): rof_ncpl = case.get_value("ROF_NCPL") if basedt % rof_ncpl != 0: - expect(False, "rof_ncpl %s doesn't divide evenly into basedt \n" + expect(False, "rof_ncpl %s doesn't divide evenly into basedt %s\n" %(rof_ncpl, basedt)) else: rtm_tstep = basedt / rof_ncpl @@ -130,26 +130,26 @@ def buildnml(case, caseroot, compname): ############################################################################### """Build the namelist """ - # Build the component namelist + # Build the component namelist if compname != "rtm": raise AttributeError - srcroot = case.get_value("SRCROOT") + srcroot = case.get_value("SRCROOT") rundir = case.get_value("RUNDIR") ninst = case.get_value("NINST_ROF") # Determine configuration directory - confdir = os.path.join(caseroot,"Buildconf","rtmconf") + confdir = os.path.join(caseroot, "Buildconf", "rtmconf") if not os.path.isdir(confdir): os.makedirs(confdir) #---------------------------------------------------- - # Construct the namelist generator + # Construct the namelist generator #---------------------------------------------------- # determine directory for user modified namelist_definitions.xml and namelist_defaults.xml user_xml_dir = os.path.join(caseroot, "SourceMods", "src.rtm") - expect (os.path.isdir(user_xml_dir), - "user_xml_dir %s does not exist " %user_xml_dir) + expect(os.path.isdir(user_xml_dir), + "user_xml_dir %s does not exist "%user_xml_dir) # NOTE: User definition *replaces* existing definition. namelist_xml_dir = os.path.join(srcroot, "components", "rtm", "cime_config") @@ -163,6 +163,12 @@ def buildnml(case, caseroot, compname): # Create the namelist generator object - independent of instance nmlgen = NamelistGenerator(case, definition_file) + #---------------------------------------------------- + # Clear out old data. + #---------------------------------------------------- + data_list_path = os.path.join(case.get_case_root(), "Buildconf", "mosart.input_data_list") + if os.path.exists(data_list_path): + os.remove(data_list_path) #---------------------------------------------------- # Loop over instances #---------------------------------------------------- @@ -175,9 +181,9 @@ def buildnml(case, caseroot, compname): # If multi-instance case does not have restart file, use # single-case restart for each instance - rpointer = "rpointer.rof" - if (os.path.isfile(os.path.join(rundir,rpointer)) and - (not os.path.isfile(os.path.join(rundir,rpointer + inst_string)))): + rpointer = "rpointer.rof" + if (os.path.isfile(os.path.join(rundir, rpointer)) and + (not os.path.isfile(os.path.join(rundir, rpointer + inst_string)))): shutil.copy(os.path.join(rundir, rpointer), os.path.join(rundir, rpointer + inst_string)) @@ -193,20 +199,20 @@ def buildnml(case, caseroot, compname): create_namelist_infile(case, user_nl_file, infile) namelist_infile = [infile] - # create namelist - _create_namelist(case, confdir, inst_string, namelist_infile, nmlgen) + # create namelist + _create_namelists(case, confdir, inst_string, namelist_infile, nmlgen, data_list_path) # copy namelist files and stream text files, to rundir if os.path.isdir(rundir): - file_src = os.path.join(confdir, 'rof_in') + file_src = os.path.join(confdir, 'rof_in') file_dest = os.path.join(rundir, 'rof_in') if inst_string: file_dest += inst_string shutil.copy(file_src, file_dest) - + for txtfile in glob.glob(os.path.join(confdir, "*txt*")): shutil.copy(txtfile, rundir) - + ############################################################################### def _main_func(): diff --git a/src/riverroute/RtmHistFile.F90 b/src/riverroute/RtmHistFile.F90 index c18ac98d3f..b2387f05bf 100644 --- a/src/riverroute/RtmHistFile.F90 +++ b/src/riverroute/RtmHistFile.F90 @@ -51,7 +51,7 @@ module RtmHistFile rtmhist_avgflag_pertape(max_tapes) = (/(' ',ni=1,max_tapes)/) ! namelist: per tape averaging flag ! list of fields to add - character(len=max_namlen+2), public :: rtmhist_fincl1(max_flds) = ' ' + character(len=max_namlen+2), public :: rtmhist_fincl1(max_flds) = ' ' character(len=max_namlen+2), public :: rtmhist_fincl2(max_flds) = ' ' character(len=max_namlen+2), public :: rtmhist_fincl3(max_flds) = ' ' ! @@ -60,13 +60,13 @@ module RtmHistFile character(len=max_namlen+2), public :: time_period_freq = ' ' ! list of fields to remove - character(len=max_namlen+2), public :: rtmhist_fexcl1(max_flds) = ' ' - character(len=max_namlen+2), public :: rtmhist_fexcl2(max_flds) = ' ' - character(len=max_namlen+2), public :: rtmhist_fexcl3(max_flds) = ' ' + character(len=max_namlen+2), public :: rtmhist_fexcl1(max_flds) = ' ' + character(len=max_namlen+2), public :: rtmhist_fexcl2(max_flds) = ' ' + character(len=max_namlen+2), public :: rtmhist_fexcl3(max_flds) = ' ' ! equivalence list of fields to add/remove - character(len=max_namlen+2), public :: fexcl(max_flds,max_tapes) - character(len=max_namlen+2), public :: fincl(max_flds,max_tapes) + character(len=max_namlen+2), public :: fexcl(max_flds,max_tapes) + character(len=max_namlen+2), public :: fincl(max_flds,max_tapes) !! Restart ! @@ -115,7 +115,7 @@ module RtmHistFile character(len=max_namlen) :: name ! field name character(len=max_chars) :: long_name ! long name character(len=max_chars) :: units ! units - integer :: hpindex ! history pointer index + integer :: hpindex ! history pointer index end type field_info type master_entry @@ -237,7 +237,7 @@ end subroutine RtmHistPrintflds subroutine RtmHistHtapesBuild () ! !DESCRIPTION: - ! Initialize ntapes history file for initial or branch run. + ! Initialize ntapes history file for initial or branch run. ! !ARGUMENTS: implicit none @@ -400,7 +400,7 @@ subroutine htapes_fieldlist() ! will not be called for field avgflag = getflag (fincl(ff,t)) call htape_addfld (t, f, avgflag) - else + else ! find index of field in exclude list call list_index (fexcl(1,t), mastername, ff) @@ -489,7 +489,7 @@ subroutine htapes_fieldlist() call shr_sys_flush(iulog) end if - ! Set flag indicating h-tape contents are now defined + ! Set flag indicating h-tape contents are now defined htapes_defined = .true. @@ -740,9 +740,9 @@ subroutine htape_create (t, histrest) str = get_filename(frivinp_rtm) call ncd_putatt(lnfid, ncd_global, 'RTM_input_dataset', trim(str)) - ! + ! ! add global attribute time_period_freq - ! + ! sec_hist_nhtfrq = rtmhist_nhtfrq(t) if (rtmhist_nhtfrq(t) < 0) then !hour need to convert to seconds sec_hist_nhtfrq = abs(rtmhist_nhtfrq(t))*3600 @@ -858,7 +858,7 @@ subroutine htape_timeconst(t, mode) dim1id(1) = time_dimid str = 'days since ' // basedate // " " // basesec call ncd_defvar(nfid(t), 'time', tape(t)%ncprec, 1, dim1id, varid, & - long_name='time',units=str) + long_name='time',units=str) cal = get_calendar() if ( trim(cal) == NO_LEAP_C )then caldesc = "noleap" @@ -1039,7 +1039,7 @@ subroutine RtmHistHtapesWrapup( rstwr, nlend ) end if end do end do - + ! Increment current time sample counter. tape(t)%ntimes = tape(t)%ntimes + 1 @@ -1068,7 +1068,7 @@ subroutine RtmHistHtapesWrapup( rstwr, nlend ) long_name = tape(t)%hlist(f)%field%long_name units = tape(t)%hlist(f)%field%units avgflag = tape(t)%hlist(f)%avgflag - + select case (avgflag) case ('A') avgstr = 'mean' @@ -1083,13 +1083,13 @@ subroutine RtmHistHtapesWrapup( rstwr, nlend ) ' ERROR: unknown time averaging flag (avgflag)=',avgflag call shr_sys_abort() end select - + call ncd_defvar(ncid=nfid(t), varname=varname, xtype=tape(t)%ncprec, & dim1name='lon', dim2name='lat', dim3name='time', & long_name=long_name, units=units, cell_method=avgstr, & missing_value=spval, fill_value=spval) end do - + ! Exit define model call ncd_enddef(nfid(t)) @@ -1135,11 +1135,11 @@ subroutine RtmHistHtapesWrapup( rstwr, nlend ) ! must reopen the files do t = 1, ntapes - if (nlend) then + if (nlend) then if_close(t) = .true. - else if (rstwr) then + else if (rstwr) then if_close(t) = .true. - else + else if (tape(t)%ntimes == tape(t)%mfilt) then if_close(t) = .true. else @@ -1260,7 +1260,7 @@ subroutine RtmHistRestart (ncid, flag, rdate) dim1name='max_chars', dim2name="ntapes" ) ! max_nflds is the maximum number of fields on any tape - ! max_flds is the maximum number possible number of fields + ! max_flds is the maximum number possible number of fields max_nflds = max_nFields() ! Loop over tapes - write out namelist information to each restart-history tape @@ -1287,7 +1287,7 @@ subroutine RtmHistRestart (ncid, flag, rdate) long_name_acc = trim(long_name) // " accumulator number of samples" nacs => tape(t)%hlist(f)%nacs hbuf => tape(t)%hlist(f)%hbuf - + call ncd_defvar(ncid=ncid_hist(t), varname=trim(name), xtype=ncd_double, & dim1name='lon', dim2name='lat', & long_name=trim(long_name), units=trim(units)) @@ -1305,9 +1305,9 @@ subroutine RtmHistRestart (ncid, flag, rdate) call ncd_defdim( ncid_hist(t), 'len1' , 1 , dimid) call ncd_defdim( ncid_hist(t), 'scalar' , 1 , dimid) call ncd_defdim( ncid_hist(t), 'max_chars' , max_chars , dimid) - call ncd_defdim( ncid_hist(t), 'max_nflds' , max_nflds , dimid) - call ncd_defdim( ncid_hist(t), 'max_flds' , max_flds , dimid) - + call ncd_defdim( ncid_hist(t), 'max_nflds' , max_nflds , dimid) + call ncd_defdim( ncid_hist(t), 'max_flds' , max_flds , dimid) + call ncd_defvar(ncid=ncid_hist(t), varname='nhtfrq', xtype=ncd_int, & long_name="Frequency of history writes", & comment="Namelist item", & @@ -1343,7 +1343,7 @@ subroutine RtmHistRestart (ncid, flag, rdate) call ncd_defvar(ncid=ncid_hist(t), varname='begtime', xtype=ncd_double, & long_name="Beginning time", units="time units", & dim1name='scalar') - + call ncd_defvar(ncid=ncid_hist(t), varname='hpindex', xtype=ncd_int, & long_name="History pointer index", units="unitless", & dim1name='max_nflds' ) @@ -1363,7 +1363,7 @@ subroutine RtmHistRestart (ncid, flag, rdate) dim1name='max_chars', dim2name='max_nflds' ) call ncd_enddef(ncid_hist(t)) - end do ! end of ntapes loop + end do ! end of ntapes loop RETURN @@ -1376,7 +1376,7 @@ subroutine RtmHistRestart (ncid, flag, rdate) call ncd_io('locfnh', locfnh(t), 'write', ncid, nt=t) call ncd_io('locfnhr', locfnhr(t), 'write', ncid, nt=t) end do - + fincl(:,1) = rtmhist_fincl1(:) fincl(:,2) = rtmhist_fincl2(:) fincl(:,3) = rtmhist_fincl3(:) @@ -1440,11 +1440,11 @@ subroutine RtmHistRestart (ncid, flag, rdate) call strip_null(locfnh(t)) end do - ! Determine necessary indices - the following is needed if model decomposition + ! Determine necessary indices - the following is needed if model decomposition ! is different on restart begrof = runoff%begr endrof = runoff%endr - + start(1)=1 do t = 1,ntapes call getfil( locrest(t), locfnhr(t), 0 ) @@ -1516,7 +1516,7 @@ subroutine RtmHistRestart (ncid, flag, rdate) rtmhist_fexcl1(:) = fexcl(:,1) rtmhist_fexcl2(:) = fexcl(:,2) rtmhist_fexcl3(:) = fexcl(:,3) - + if ( allocated(itemp) ) deallocate(itemp) end if @@ -1525,8 +1525,8 @@ subroutine RtmHistRestart (ncid, flag, rdate) ! If the current history file(s) are not full, file(s) are opened ! so that subsequent time samples are added until the file is full. ! A new history file is used on a branch run. - - if (flag == 'write') then + + if (flag == 'write') then do t = 1,ntapes if (.not. tape(t)%is_endhist) then @@ -1543,9 +1543,9 @@ subroutine RtmHistRestart (ncid, flag, rdate) end do end if ! end of is_endhist block call ncd_pio_closefile(ncid_hist(t)) - end do ! end of ntapes loop + end do ! end of ntapes loop - else if (flag == 'read') then + else if (flag == 'read') then ! Read history restart information if history files are not full do t = 1,ntapes @@ -1555,7 +1555,7 @@ subroutine RtmHistRestart (ncid, flag, rdate) name_acc = trim(name) // "_acc" nacs => tape(t)%hlist(f)%nacs hbuf => tape(t)%hlist(f)%hbuf - + call ncd_io(ncid=ncid_hist(t), flag='read', varname=trim(name), & dim1name='allrof', data=hbuf) call ncd_io(ncid=ncid_hist(t), flag='read', varname=trim(name_acc), & @@ -1566,7 +1566,7 @@ subroutine RtmHistRestart (ncid, flag, rdate) end do end if - + end subroutine RtmHistRestart !----------------------------------------------------------------------- @@ -1587,7 +1587,7 @@ integer function max_nFields() do t = 1,ntapes max_nFields = max(max_nFields, tape(t)%nflds) end do - + end function max_nFields !----------------------------------------------------------------------- @@ -1597,29 +1597,29 @@ character(len=max_namlen) function getname (inname) ! DESCRIPTION: ! Retrieve name portion of inname. If an averaging flag separater character ! is present (:) in inname, lop it off. - + ! ARGUMENTS: implicit none character(len=*), intent(in) :: inname - + integer :: length integer :: i character(len=*),parameter :: subname = 'getname' - + length = len (inname) if (length < max_namlen .or. length > max_namlen+2) then write(iulog,*) trim(subname),' ERROR: bad length=',length call shr_sys_abort() end if - + getname = ' ' do i = 1,max_namlen if (inname(i:i) == ':') exit getname(i:i) = inname(i:i) end do - + end function getname - + !----------------------------------------------------------------------- character(len=1) function getflag (inname) @@ -1686,13 +1686,13 @@ end subroutine list_index character(len=max_length_filename) function set_hist_filename (hist_freq, rtmhist_mfilt, hist_file) ! Determine history dataset filenames. - + ! !ARGUMENTS: implicit none integer, intent(in) :: hist_freq !history file frequency integer, intent(in) :: rtmhist_mfilt !history file number of time-samples integer, intent(in) :: hist_file !history file index - + ! !LOCAL VARIABLES: character(len=256) :: cdate !date char string character(len= 1) :: hist_index !p,1 or 2 (currently) @@ -1702,7 +1702,7 @@ character(len=max_length_filename) function set_hist_filename (hist_freq, rtmhis integer :: sec !seconds into current day integer :: filename_length character(len=*),parameter :: subname = 'set_hist_filename' - + if (hist_freq == 0 .and. rtmhist_mfilt == 1) then !monthly call get_prev_date (yr, mon, day, sec) write(cdate,'(i4.4,"-",i2.2)') yr,mon @@ -1735,7 +1735,7 @@ end function set_hist_filename subroutine RtmHistAddfld (fname, units, avgflag, long_name, ptr_rof, default) - ! Initialize a single level history field. + ! Initialize a single level history field. ! !ARGUMENTS: implicit none @@ -1744,7 +1744,7 @@ subroutine RtmHistAddfld (fname, units, avgflag, long_name, ptr_rof, default) character(len=1), intent(in) :: avgflag ! time averaging flag character(len=*), intent(in) :: long_name ! long name of field real(r8) , pointer :: ptr_rof(:) ! pointer to channel runoff - character(len=*), optional, intent(in) :: default ! if set to 'inactive, + character(len=*), optional, intent(in) :: default ! if set to 'inactive, ! field will not appear on primary tape ! !LOCAL VARIABLES: @@ -1821,11 +1821,11 @@ end subroutine RtmHistAddfld subroutine strip_null(str) character(len=*), intent(inout) :: str - integer :: i + integer :: i do i=1,len(str) if(ichar(str(i:i))==0) str(i:i)=' ' end do end subroutine strip_null - + end module RtmHistFile diff --git a/src/riverroute/RtmIO.F90 b/src/riverroute/RtmIO.F90 index c41261bf24..59d7ca50c2 100644 --- a/src/riverroute/RtmIO.F90 +++ b/src/riverroute/RtmIO.F90 @@ -9,7 +9,7 @@ module RtmIO ! Generic interfaces to write fields to netcdf files for RTM ! ! !USES: - use shr_kind_mod , only : r8 => shr_kind_r8, i8=>shr_kind_i8, shr_kind_cl + use shr_kind_mod , only : r8 => shr_kind_r8, i8=>shr_kind_i8, shr_kind_cl, r4=>shr_kind_r4 use shr_sys_mod , only : shr_sys_flush, shr_sys_abort use shr_file_mod , only : shr_file_getunit, shr_file_freeunit use RtmFileUtils , only : getavu, relavu @@ -633,10 +633,10 @@ subroutine ncd_putatt_real(ncid,varid,attrib,value,xtype) ! ! !LOCAL VARIABLES: integer :: status - real*4 :: value4 + real(r4) :: value4 !----------------------------------------------------------------------- - value4 = value + value4 = real(value, kind=r4) if (xtype == pio_double) then status = PIO_put_att(ncid,varid,trim(attrib),value) @@ -699,6 +699,7 @@ subroutine ncd_defvar_bynf(ncid, varname, xtype, ndims, dimid, varid, & integer , intent(in), optional :: ifill_value ! attribute for int integer , intent(in), optional :: flag_values(:) ! attribute for int integer , intent(in), optional :: nvalid_range(2) ! attribute for int + ! ! !LOCAL VARIABLES: integer :: n ! indices @@ -1600,7 +1601,7 @@ subroutine ncd_io_int_var1(varname, data, dim1name, flag, ncid, nt, readvar) if (present(nt)) then call pio_setframe(ncid, vardesc, int(nt,kind=pio_offset_kind)) end if - call pio_write_darray(ncid, vardesc, iodesc_plus%iodesc, data, status, fillval=0) + call pio_write_darray(ncid, vardesc, iodesc_plus%iodesc, data, status, fillval=ispval) else @@ -1818,8 +1819,11 @@ subroutine ncd_io_real_var1(varname, data, dim1name, & if (present(nt)) then call pio_setframe(ncid, vardesc, int(nt,kind=pio_offset_kind)) end if - call pio_write_darray(ncid, vardesc, iodesc_plus%iodesc, data, status, fillval=spval) - + if(xtype == ncd_float) then + call pio_write_darray(ncid, vardesc, iodesc_plus%iodesc, real(data, kind=r4), status, fillval=real(spval,kind=r4)) + else + call pio_write_darray(ncid, vardesc, iodesc_plus%iodesc, data, status, fillval=spval) + endif else if (masterproc) then @@ -1848,7 +1852,6 @@ subroutine ncd_getiodesc(ncid, ndims, dims, dimids, xtype, iodnum) integer , intent(out) :: iodnum ! iodesc num in list ! !LOCAL VARIABLES: integer :: k,m,n,cnt ! indices - integer :: basetype ! pio basetype integer :: lsize ! local size integer :: gsize ! global size integer :: status ! error status diff --git a/src/riverroute/RtmRestFile.F90 b/src/riverroute/RtmRestFile.F90 index d5be897f52..1ca523c7a1 100644 --- a/src/riverroute/RtmRestFile.F90 +++ b/src/riverroute/RtmRestFile.F90 @@ -11,26 +11,26 @@ module RtmRestFile ! !USES: use shr_kind_mod , only : r8 => shr_kind_r8 use shr_sys_mod , only : shr_sys_abort - use RtmSpmd , only : masterproc + use RtmSpmd , only : masterproc use RtmVar , only : rtmlon, rtmlat, iulog, inst_suffix, rpntfil, & caseid, nsrest, brnch_retain_casename, & - finidat_rtm, nrevsn_rtm, & + finidat_rtm, nrevsn_rtm, spval, & nsrContinue, nsrBranch, nsrStartup, & ctitle, version, username, hostname, conventions, source use RtmHistFile , only : RtmHistRestart use RtmFileUtils , only : relavu, getavu, opnfil, getfil use RtmTimeManager, only : timemgr_restart, get_nstep, get_curr_date, is_last_step use RunoffMod , only : runoff - use RtmIO + use RtmIO use RtmDateTime - use rtm_cpl_indices , only : nt_rtm, rtm_tracers + use rtm_cpl_indices , only : nt_rtm, rtm_tracers ! ! !PUBLIC TYPES: implicit none save ! ! !PUBLIC MEMBER FUNCTIONS: - public :: RtmRestFileName + public :: RtmRestFileName public :: RtmRestFileRead public :: RtmRestFileWrite public :: RtmRestGetfile @@ -39,7 +39,7 @@ module RtmRestFile public :: RtmRestFinalize ! ! !PRIVATE MEMBER FUNCTIONS: - private :: restFile_read_pfile + private :: restFile_read_pfile private :: restFile_write_pfile ! Writes restart pointer file private :: restFile_dimset ! @@ -74,7 +74,7 @@ subroutine RtmRestFileWrite( file, rdate ) ! Define dimensions and variables - if (masterproc) then + if (masterproc) then write(iulog,*) write(iulog,*)'restFile_open: writing RTM restart dataset ' write(iulog,*) @@ -100,14 +100,14 @@ subroutine RtmRestFileWrite( file, rdate ) ! Write restart pointer file call restFile_write_pfile( file ) - + ! Write out diagnostic info if (masterproc) then write(iulog,*) 'Successfully wrote out restart data at nstep = ',get_nstep() write(iulog,'(72a1)') ("-",i=1,60) end if - + end subroutine RtmRestFileWrite !----------------------------------------------------------------------- @@ -188,29 +188,29 @@ subroutine RtmRestGetfile( file, path ) ! LOCAL VARIABLES: integer :: status ! return status - integer :: length ! temporary + integer :: length ! temporary character(len=256) :: ftest,ctest ! temporaries !--------------------------------------------------- ! Continue run: - ! Restart file pathname is read restart pointer file + ! Restart file pathname is read restart pointer file if (nsrest==nsrContinue) then call restFile_read_pfile( path ) call getfil( path, file, 0 ) end if - - ! Branch run: + + ! Branch run: ! Restart file pathname is obtained from namelist "nrevsn_rtm" if (nsrest==nsrBranch) then length = len_trim(nrevsn_rtm) if (nrevsn_rtm(length-2:length) == '.nc') then - path = trim(nrevsn_rtm) + path = trim(nrevsn_rtm) else path = trim(nrevsn_rtm) // '.nc' end if call getfil( path, file, 0 ) - - ! Check case name consistency (case name must be different + + ! Check case name consistency (case name must be different ! for branch run, unless brnch_retain_casename is set) ctest = 'xx.'//trim(caseid)//'.rtm' ftest = 'xx.'//trim(file) @@ -225,11 +225,11 @@ subroutine RtmRestGetfile( file, path ) end if end if - ! Initial run + ! Initial run if (nsrest==nsrStartup) then call getfil( finidat_rtm, file, 0 ) end if - + end subroutine RtmRestGetfile !----------------------------------------------------------------------- @@ -250,12 +250,12 @@ subroutine restFile_read_pfile( pnamer ) character(len=256) :: locfn ! Restart pointer file name !-------------------------------------------------------- - ! Obtain the restart file from the restart pointer file. - ! For restart runs, the restart pointer file contains the full pathname - ! of the restart file. For branch runs, the namelist variable - ! [nrevsn_rtm] contains the full pathname of the restart file. + ! Obtain the restart file from the restart pointer file. + ! For restart runs, the restart pointer file contains the full pathname + ! of the restart file. For branch runs, the namelist variable + ! [nrevsn_rtm] contains the full pathname of the restart file. ! New history files are always created for branch runs. - + if (masterproc) then write(iulog,*) 'Reading restart pointer file....' endif @@ -293,7 +293,7 @@ subroutine restFile_write_pfile( fnamer ) nio = getavu() filename= './'// trim(rpntfil)//trim(inst_suffix) call opnfil( filename, nio, 'f' ) - + write(nio,'(a)') fnamer call relavu( nio ) write(iulog,*)'Successfully wrote local restart pointer file' @@ -307,13 +307,13 @@ end subroutine restFile_write_pfile character(len=256) function RtmRestFileName( rdate ) implicit none - character(len=*), intent(in) :: rdate ! input date for restart file name + character(len=*), intent(in) :: rdate ! input date for restart file name RtmRestFileName = "./"//trim(caseid)//".rtm"//trim(inst_suffix)//".r."//trim(rdate)//".nc" if (masterproc) then write(iulog,*)'writing restart file ',trim(RtmRestFileName),' for model date = ',rdate end if - + end function RtmRestFileName !------------------------------------------------------------------------ @@ -338,13 +338,13 @@ subroutine restFile_dimset( ncid ) !---------------------------------------------------------------- ! Define dimensions - + call ncd_defdim(ncid, 'rtmlon' , rtmlon , dimid) call ncd_defdim(ncid, 'rtmlat' , rtmlat , dimid) call ncd_defdim(ncid, 'string_length', 64 , dimid) - + ! Define global attributes - + call ncd_putatt(ncid, NCD_GLOBAL, 'Conventions', trim(conventions)) call getdatetime(curdate, curtime) str = 'created on ' // curdate // ' ' // curtime @@ -359,7 +359,7 @@ subroutine restFile_dimset( ncid ) 'RTM Restart information, required to continue a simulation' ) end subroutine restFile_dimset - + !----------------------------------------------------------------------- subroutine RtmRestart(ncid, flag) @@ -411,7 +411,7 @@ subroutine RtmRestart(ncid, flag) if (flag == 'define') then call ncd_defvar(ncid=ncid, varname=trim(vname), & xtype=ncd_double, dim1name='rtmlon', dim2name='rtmlat', & - long_name=trim(lname), units=trim(uname)) + long_name=trim(lname), units=trim(uname), fill_value=spval) else if (flag == 'read' .or. flag == 'write') then call ncd_io(varname=trim(vname), data=dfld, dim1name='allrof', & ncid=ncid, flag=flag, readvar=readvar) @@ -467,6 +467,3 @@ subroutine RtmRestFinalize( ) end subroutine RtmRestFinalize end module RtmRestFile - - - From 22f22ef25e92be401ce4c80a86849a8ab8e8fff4 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 12 Oct 2018 15:15:44 -0600 Subject: [PATCH 2/3] Use the floor operator rather than divide as python3 turns the divide into reals, but the floor does whats desired --- cime_config/buildnml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/buildnml b/cime_config/buildnml index 98e6fdd6cf..68f9d2b01c 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -116,7 +116,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen, data_list_path expect(False, "rof_ncpl %s doesn't divide evenly into basedt %s\n" %(rof_ncpl, basedt)) else: - rtm_tstep = basedt / rof_ncpl + rtm_tstep = basedt // rof_ncpl nmlgen.set_value("rtm_tstep", value=rtm_tstep) #---------------------------------------------------- From 81815e9b6cbd87bb57a593eefbb6aa5d3241c50b Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 12 Oct 2018 15:18:07 -0600 Subject: [PATCH 3/3] Update changelog --- docs/ChangeLog | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/docs/ChangeLog b/docs/ChangeLog index fb8b4ac5ae..cff611e702 100644 --- a/docs/ChangeLog +++ b/docs/ChangeLog @@ -1,3 +1,75 @@ +=============================================================== +Tag name: release-cesm2.0.01 +Originator(s): erik +Date: Oct 10, 2018 +One-line Summary: pylint cleanup, and fill value changes for pio2 + +Changes ported from mosart/#15 to rtm. Run pylint through buildlib/buildnml, +changes for fill value needed for pio2. Also use the floor operator +for a specific integer divide as python3 turns it into reals. + +Purpose: + +Software Changes since last release: release-cesm2.0.00 + * pylint on buildlib/buildnml + * fill value changes needed for pio2 from the mosart changes + * Use floor operator in buildnml for an integer division + +Science Changes since last release: release-cesm2.0.00 + * None + +Changes to User Interface since: release-cesm2.0.00 + * None + +Pull Requests that document the changes (include PR ids): + #9 -- Same changes on mosart fill-value and pylint cleanup on rtm enhancement + +Testing: + rtm testlist on hobart and cheyenne (PASS) + +=============================================================== +Tag name: release-cesm2.0.00 +Originator(s): erik +Date: May 21, 2018 +One-line Summary: First CESM2.0 release version, identical to rtm1_0_66 + +Purpose: + +First RTM version for the CESM2.0 release. This tag is identical to rtm1_0_66 + +Software Changes since last release: rtm1_0_30 + + * Add in model_doi_url read in from infodata from coupler. + * RTM own's version of config_archive.xml + * Remove old rof_comp_esmf + * Remove revision_id from output files + * Convert testlist format to version 2, and use new Clm5 compset names. + * Remove yellowstone tests. + * Update config_component.xml to version 3 format. + * if NINST_RTM > 1, will check if REFCASE has instance name and use it, otherwise without it. + * I/O fixes from Jim Edwards + * Update buildnamelist to cime5 python namelist infrastructure + * Add time period frequency to output history file + * Remove ESMF top level coupler interface and tests + * Have RTM react to CLM_ACCELERATED_SPINUP setting from CLM and turn itself off + * Update to newer cime versions + * Move tests from goldbach to hobart + * Don't assume that direction files are global + * NAG6.0 requires additional pointers to be nullified + * readnamelist on mastertask only + * PIO2 Compatibility changes + * address valgrind errors + * add SHR_ASSERT macros + * migration of cpl_share/, cpl_esmf/ and cpl_mct code into new cpl/ and introduction of rof_import_export.F90 + +Science Changes since last release: rtm1_0_30 + + * Treat irrigation as a seperate flux + * Remove directo to ocean runnoff + * fix fthresh bug and refactor RtmFloodInit + * convert volr coupling field from state to flux + * RTM Master Tag this corresponds to: rtm1_0_66 + =============================================================== Tag name: rtm1_0_66 Originator(s): erik