From de72b4d8f3b7908a28ca11bc682c4e730eef7e21 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 31 Jan 2018 11:20:57 -0700 Subject: [PATCH 1/8] fix fill value issue --- src/riverroute/RtmIO.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/riverroute/RtmIO.F90 b/src/riverroute/RtmIO.F90 index a9d1196..cc8bb7f 100644 --- a/src/riverroute/RtmIO.F90 +++ b/src/riverroute/RtmIO.F90 @@ -1607,7 +1607,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 From 9effa320d88f9dcddc3b4953a42adaf3fde7f5da Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 31 Jan 2018 16:10:30 -0700 Subject: [PATCH 2/8] more changes for mosart --- src/riverroute/RtmHistFile.F90 | 115 ++++++++++++++++----------------- src/riverroute/RtmIO.F90 | 14 ++-- src/riverroute/RtmRestFile.F90 | 65 +++++++++---------- 3 files changed, 97 insertions(+), 97 deletions(-) diff --git a/src/riverroute/RtmHistFile.F90 b/src/riverroute/RtmHistFile.F90 index d215db9..aa84615 100644 --- a/src/riverroute/RtmHistFile.F90 +++ b/src/riverroute/RtmHistFile.F90 @@ -10,8 +10,8 @@ module RtmHistFile use shr_sys_mod , only : shr_sys_flush, shr_sys_abort use shr_log_mod , only : errMsg => shr_log_errMsg use RunoffMod , only : rtmCTL, Tunit - use RtmVar , only : rtmlon, rtmlat, spval, ispval, secspday, frivinp_rtm, & - iulog, nsrest, caseid, inst_suffix, nsrStartup, nsrBranch, & + use RtmVar , only : rtmlon, rtmlat, spval, ispval, secspday, frivinp_rtm, & + iulog, nsrest, caseid, inst_suffix, nsrStartup, nsrBranch, & ctitle, version, hostname, username, conventions, source use RtmFileUtils , only : get_filename, getfil use RtmTimeManager, only : get_nstep, get_curr_date, get_curr_time, get_ref_date, & @@ -50,7 +50,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) = ' ' ! @@ -59,13 +59,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 ! @@ -113,7 +113,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 @@ -212,7 +212,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 @@ -375,7 +375,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) @@ -464,7 +464,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. @@ -712,9 +712,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 - ! + ! if (rtmhist_nhtfrq(t) < 0) then !hour need to convert to seconds sec_hist_nhtfrq = abs(rtmhist_nhtfrq(t))*3600 else @@ -826,7 +826,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" @@ -861,13 +861,13 @@ subroutine htape_timeconst(t, mode) call ncd_defvar(varname='lat', xtype=tape(t)%ncprec, dim1name='lat', & long_name='runoff coordinate latitude', units='degrees_north', ncid=nfid(t)) call ncd_defvar(varname='mask', xtype=ncd_int, dim1name='lon', dim2name='lat', & - long_name='runoff mask', units='unitless', ncid=nfid(t)) + long_name='runoff mask', units='unitless', ncid=nfid(t), ifill_value=ispval) call ncd_defvar(varname='area', xtype=tape(t)%ncprec, dim1name='lon', dim2name='lat', & - long_name='runoff grid area', units='m2', ncid=nfid(t)) + long_name='runoff grid area', units='m2', ncid=nfid(t), fill_value=spval) call ncd_defvar(varname='areatotal', xtype=tape(t)%ncprec, dim1name='lon', dim2name='lat', & - long_name='basin upstream areatotal', units='m2', ncid=nfid(t)) + long_name='basin upstream areatotal', units='m2', ncid=nfid(t), fill_value=spval) call ncd_defvar(varname='areatotal2', xtype=tape(t)%ncprec, dim1name='lon', dim2name='lat', & - long_name='computed basin upstream areatotal', units='m2', ncid=nfid(t)) + long_name='computed basin upstream areatotal', units='m2', ncid=nfid(t), fill_value=spval) else if (mode == 'write') then @@ -1013,7 +1013,7 @@ subroutine RtmHistHtapesWrapup( rstwr, nlend ) end if end do end do - + ! Increment current time sample counter. tape(t)%ntimes = tape(t)%ntimes + 1 @@ -1042,7 +1042,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' @@ -1057,13 +1057,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)) @@ -1109,11 +1109,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 @@ -1234,7 +1234,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 @@ -1261,7 +1261,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)) @@ -1279,9 +1279,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", & @@ -1317,7 +1317,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' ) @@ -1337,7 +1337,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 @@ -1350,7 +1350,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(:) @@ -1414,11 +1414,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 = rtmCTL%begr endrof = rtmCTL%endr - + start(1)=1 do t = 1,ntapes call getfil( locrest(t), locfnhr(t), 0 ) @@ -1490,7 +1490,7 @@ subroutine RtmHistRestart (ncid, flag, rdate) rtmhist_fexcl1(:) = fexcl(:,1) rtmhist_fexcl2(:) = fexcl(:,2) rtmhist_fexcl3(:) = fexcl(:,3) - + if ( allocated(itemp2d) ) deallocate(itemp2d) end if @@ -1499,8 +1499,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 @@ -1517,9 +1517,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 @@ -1529,7 +1529,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), & @@ -1540,7 +1540,7 @@ subroutine RtmHistRestart (ncid, flag, rdate) end do end if - + end subroutine RtmHistRestart !----------------------------------------------------------------------- @@ -1561,7 +1561,7 @@ integer function max_nFields() do t = 1,ntapes max_nFields = max(max_nFields, tape(t)%nflds) end do - + end function max_nFields !----------------------------------------------------------------------- @@ -1571,29 +1571,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) @@ -1660,13 +1660,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) @@ -1676,7 +1676,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 @@ -1709,7 +1709,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 @@ -1718,7 +1718,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: @@ -1795,11 +1795,10 @@ 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 +end module RtmHistFile diff --git a/src/riverroute/RtmIO.F90 b/src/riverroute/RtmIO.F90 index cc8bb7f..74007d2 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 @@ -632,10 +632,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) @@ -698,6 +698,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 @@ -1825,8 +1826,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 diff --git a/src/riverroute/RtmRestFile.F90 b/src/riverroute/RtmRestFile.F90 index 6db337e..d87c00a 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 : rtmCTL - use RtmIO + use RtmIO use RtmDateTime - use rof_cpl_indices , only : nt_rtm, rtm_tracers + use rof_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 @@ -38,7 +38,7 @@ module RtmRestFile public :: RtmRestart ! ! !PRIVATE MEMBER FUNCTIONS: - private :: restFile_read_pfile + private :: restFile_read_pfile private :: restFile_write_pfile ! Writes restart pointer file private :: restFile_dimset ! @@ -73,7 +73,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,*) @@ -99,14 +99,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 !----------------------------------------------------------------------- @@ -187,29 +187,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)//'.mosart' ftest = 'xx.'//trim(file) @@ -224,11 +224,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 !----------------------------------------------------------------------- @@ -249,12 +249,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 @@ -292,7 +292,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' @@ -306,13 +306,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)//".mosart"//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 !------------------------------------------------------------------------ @@ -337,13 +337,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 @@ -360,7 +360,7 @@ subroutine restFile_dimset( ncid ) 'RTM Restart information, required to continue a simulation' ) end subroutine restFile_dimset - + !----------------------------------------------------------------------- subroutine RtmRestart(ncid, flag) @@ -427,7 +427,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) @@ -471,6 +471,3 @@ subroutine RtmRestart(ncid, flag) end subroutine RtmRestart end module RtmRestFile - - - From 999e26272b8ed26277d4ae4e28582c173ca6e114 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 31 Jan 2018 16:15:02 -0700 Subject: [PATCH 3/8] more changes for mosart --- src/riverroute/RtmIO.F90 | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/riverroute/RtmIO.F90 b/src/riverroute/RtmIO.F90 index 74007d2..6bfae8c 100644 --- a/src/riverroute/RtmIO.F90 +++ b/src/riverroute/RtmIO.F90 @@ -1859,7 +1859,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 @@ -1932,14 +1931,6 @@ subroutine ncd_getiodesc(ncid, ndims, dims, dimids, xtype, iodnum) ! Initialize the decomposition for PIO - if (xtype == pio_double ) then - basetype = PIO_DOUBLE - else if (xtype == pio_real) then - basetype = PIO_DOUBLE - else if (xtype == pio_int) then - basetype = PIO_INT - end if - gsize = rtmCTL%numr lsize = rtmCTL%lnumr allocate(compDOF(lsize)) @@ -1958,7 +1949,7 @@ subroutine ncd_getiodesc(ncid, ndims, dims, dimids, xtype, iodnum) call mpi_barrier(mpicom_rof,status) enddo endif - call pio_initdecomp(pio_subsystem, baseTYPE, dims(1:ndims), compDOF, iodesc_list(iodnum)%iodesc) + call pio_initdecomp(pio_subsystem, xTYPE, dims(1:ndims), compDOF, iodesc_list(iodnum)%iodesc) deallocate(compDOF) iodesc_list(iodnum)%type = xtype From 1cbb07f2af0b19f68cc28217c758dc5110604437 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 1 Oct 2018 12:22:31 -0600 Subject: [PATCH 4/8] py3 pylint compatibility --- cime_config/buildlib | 27 ++++++++++++------------ cime_config/buildnml | 50 ++++++++++++++++++++++---------------------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/cime_config/buildlib b/cime_config/buildlib index 04fe207..1bdc92d 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_mosart(): 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.mosart"), - os.path.join(srcroot,"components","mosart","src","riverroute"), - os.path.join(srcroot,"components","mosart","src","cpl")] + paths = [os.path.join(caseroot, "SourceMods", "src.mosart"), + os.path.join(srcroot, "components", "mosart", "src", "riverroute"), + os.path.join(srcroot, "components", "mosart", "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=mosart COMPLIB=%s -f %s" \ @@ -49,12 +53,9 @@ def _build_mosart(): 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_mosart() - - - diff --git a/cime_config/buildnml b/cime_config/buildnml index b0459f1..7d858c0 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,7 +20,7 @@ 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__) @@ -40,23 +40,23 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen): #---------------------------------------------------- config = {} config['mosart_mode'] = case.get_value("MOSART_MODE") - config['mosart_flood_mode'] = case.get_value("MOSART_FLOOD_MODE") + config['mosart_flood_mode'] = case.get_value("MOSART_FLOOD_MODE") config['clm_accel'] = case.get_value("CLM_ACCELERATED_SPINUP") config['rof_grid'] = case.get_value("ROF_GRID") config['lnd_grid'] = case.get_value("LND_GRID") config['rof_ncpl'] = case.get_value("ROF_NCPL") config['simyr'] = case.get_value("MOSART_SIM_YEAR") - logger.debug ("River Transport Model (MOSART) mode is %s " %(config['mosart_mode'])) - logger.debug (" MOSART lnd grid is %s " %(config['lnd_grid'])) - logger.debug (" MOSART rof grid is %s " %(config['rof_grid'])) + logger.debug("River Transport Model (MOSART) mode is %s ", config['mosart_mode']) + logger.debug(" MOSART lnd grid is %s ", config['lnd_grid']) + logger.debug(" MOSART rof grid is %s ", config['rof_grid']) #---------------------------------------------------- # Check for incompatible options. #---------------------------------------------------- if config["rof_grid"] == "null" and config["mosart_mode"] != "NULL": - expect (False, "ROF_GRID is null MOSART_MODE not NULL") + expect(False, "ROF_GRID is null MOSART_MODE not NULL") #---------------------------------------------------- # Clear out old data. @@ -69,7 +69,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen): # Initialize namelist defaults #---------------------------------------------------- nmlgen.init_defaults(infile, config) - + #---------------------------------------------------- # Set values not obtained in the default settings #---------------------------------------------------- @@ -78,10 +78,10 @@ def _create_namelists(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") - rundir = case.get_value("RUNDIR") + run_tod = case.get_value("RUN_REFTOD") + rundir = case.get_value("RUNDIR") filename = "%s.mosart%s.r.%s-%s.nc" %(run_refcase, inst_string, run_refdate, run_tod) - if not os.path.exists(os.path.join(rundir, filename ) ): + if not os.path.exists(os.path.join(rundir, filename)): filename = "%s.mosart.r.%s-%s.nc" %(run_refcase, run_refdate, run_tod) if run_type == "hybrid": @@ -95,7 +95,7 @@ def _create_namelists(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': @@ -118,7 +118,7 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen): mosart_ncpl = case.get_value("ROF_NCPL") if basedt % mosart_ncpl != 0: - expect(False, "mosart_ncpl %s doesn't divide evenly into basedt \n" + expect(False, "mosart_ncpl %s doesn't divide evenly into basedt %s\n" %(mosart_ncpl, basedt)) else: coupling_period = basedt / mosart_ncpl @@ -135,26 +135,26 @@ def buildnml(case, caseroot, compname): ############################################################################### """Build the mosart namelist """ - # Build the component namelist + # Build the component namelist if compname != "mosart": 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","mosartconf") + confdir = os.path.join(caseroot, "Buildconf", "mosartconf") 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.mosart") - 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", "mosart", "cime_config") @@ -180,9 +180,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)) @@ -203,12 +203,12 @@ def buildnml(case, caseroot, compname): # copy namelist files and stream text files, to rundir if os.path.isdir(rundir): - file_src = os.path.join(confdir, 'mosart_in') + file_src = os.path.join(confdir, 'mosart_in') file_dest = os.path.join(rundir, 'mosart_in') if inst_string: file_dest += inst_string shutil.copy(file_src, file_dest) - + ############################################################################### def _main_func(): From bec343a04b8ed5733c0ee06d779a6f9e08297fb1 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 1 Oct 2018 12:27:54 -0600 Subject: [PATCH 5/8] fix for cime issue 2822 --- cime_config/buildnml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cime_config/buildnml b/cime_config/buildnml index 7d858c0..0db5883 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -26,7 +26,7 @@ logger = logging.getLogger(__name__) # pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements #################################################################################### -def _create_namelists(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. @@ -58,13 +58,6 @@ def _create_namelists(case, confdir, inst_string, infile, nmlgen): if config["rof_grid"] == "null" and config["mosart_mode"] != "NULL": expect(False, "ROF_GRID is null MOSART_MODE not NULL") - #---------------------------------------------------- - # 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) - #---------------------------------------------------- # Initialize namelist defaults #---------------------------------------------------- @@ -168,6 +161,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 #---------------------------------------------------- @@ -199,7 +198,7 @@ def buildnml(case, caseroot, compname): namelist_infile = [infile] # create namelist and stream file(s) data component - _create_namelists(case, confdir, inst_string, namelist_infile, nmlgen) + _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): From fb964bf2f6d94b55e0f5b3e7ff12b78632c4568c Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 8 Oct 2018 23:42:21 -0600 Subject: [PATCH 6/8] Add Mosart r8th degree routing file --- cime_config/namelist_definition_mosart.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/cime_config/namelist_definition_mosart.xml b/cime_config/namelist_definition_mosart.xml index f2b9956..d2f8920 100644 --- a/cime_config/namelist_definition_mosart.xml +++ b/cime_config/namelist_definition_mosart.xml @@ -166,6 +166,7 @@ mosart_inparm $DIN_LOC_ROOT/rof/mosart/MOSART_routing_Global_0.5x0.5_c170601.nc + $DIN_LOC_ROOT/rof/mosart/MOSART_routing_Global_0.5x0.5_c170601.nc - $DIN_LOC_ROOT/rof/mosart/MOSART_routing_Global_0.5x0.5_c170601.nc + $DIN_LOC_ROOT/rof/mosart/MOSART_Global_8th_20160716a.nc Full pathname of input datafile for RTM. From 455c4bf9eb6b17541f70f0a261cc33aa65eaf48c Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 9 Oct 2018 15:59:27 -0600 Subject: [PATCH 8/8] Add notes for release-cesm2.0.00 and release-cesm2.0.01 --- docs/ChangeLog | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/docs/ChangeLog b/docs/ChangeLog index fe87525..4d1dcb4 100644 --- a/docs/ChangeLog +++ b/docs/ChangeLog @@ -1,3 +1,92 @@ +=============================================================== +Tag name: release-cesm2.0.01 +Originator(s): erik/jedwards4b +Date: Oct 09, 2018 +One-line Summary: New r8th routing file, pylint and py3 checking, fill value needed for pio2 + +Add in 8th degree routine file. Run pylint and check for py3 compatability. +There's explict setting of fill type. And also explicit use of shr_kind_r4 for +kind rather than real(4), which is a better mechanism. Also ncd_getiodesc +will read in PIO_DOUBLE for input xtype= PIO_DOUBLE or PIO_REAL. Most of this +is direct from jedwards4b (other than r8th addition). + +MOSART Master Tag This Corresponds To: Identical to mosart1_0_31 + +Science changes since: release-cesm2.0.00 + Added in 8th degree routing file (r8th) +Software changes since: release-cesm2.0.00 + Run pylint on python buildlib and buildnml scripts, check for py3 compatibility. + Corrects the integer fill value. Needed for pio2. + +Pull Requests that document the changes (include PR ids): + + #15 -- Bring in changes for xlf compiler, pio, and python3 update + (#13 and #6 moved to release-cesm2.0) + #14 -- fix type issue with xlf + +Testing: + mosart 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 tag, identical to mosart1_0_31 + +MOSART Master Tag This Corresponds To: Identical to mosart1_0_31 + +Science changes since: mosart1_0_00 + + * Changes from Sean Swenson to add minimum value to rlen + * Update areas on routing file + * Answer changing improvements to channel storage from HongYi Li for faster spinup. + * Bugfix from Tony Craig to use correct delta time for qgwl flux. + * Treat irrigation as a seperate flux + * bugfix for budget diagnostic output + * bugfix: calculation of qgwl_volume must be multiplied by ar + * Update default routing file. + * New method of handeling runoff terms to avoid negative runoff. + * switch to input dataset MOSART_Global_half_20151130a.nc + * update direct sparse matrix to include non basin points in order + * to pass data from any grid cell directly to the ocean. + * modify the direct term and push all direct water to outlet points + * set all tracer 2 water (frozen water) to be a direct term + * add ability to skip some tracers in the euler solver via euler_calc flag + * add a budget accumulator term + * Fix exact restart in atan slope calc + * Swenson bugfix for mosart direction file + * Swenson river volume normalization bugf + +Software changes since: mosart1_0_00 + + * Add config_archive for mosart + * delete rof_comp_esmf + * add model_doi_url, + * change some instances of RTM/CLM in documentation to MOSART + * Update testlist to version 2 format, remove ys tests + * Upgrade config_component to version 3 + * allow output file format to change + * If NINST_ROF > 1, check if instance number in name for REFCASE + * Update testlist and use Clm5 compset names + * Update routing file + * Update to cime5 python namelist infrastructure + * Fix an issue with nag, lower amount of log output + * Add output frequency to history files + * Turn off for CLM_ACCELERATED_SPINUP="on" + * Add new namelist options bypass_routing_option, + * qgwl_runoff_option + * Error checking on max length of history filenames. + * Add testdefs dir, testmods and testlist for integration to cime + * test system. + * remove rofdto from coupler interface fields. + * Changes to get Mosart to build with Nag on Hobart + * merge ACME fixes to decomp and performance + * cime compatible infrastructure + * Add direct to ocean runoff flux + * PIO2 updates + +Changes to User Interface since: mo + =============================================================== Tag name: mosart1_0_31 Originator(s): erik