Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge/netcdf restart #166

Merged
merged 18 commits into from
Aug 20, 2016
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8d46c90
Rough draft of netcdf restart capabilities -> before code review(s).
May 23, 2016
bffe83a
Updates after Martyn's informal code review.
May 27, 2016
73026d0
Finished adding comments after Martyn's informal code review
May 28, 2016
d55039f
1. Fixed output descriptions and units as per Michael's suggestions.
Jun 17, 2016
b92f1b5
Merge remote-tracking branch 'ncar/develop' into feature/netcdfRestart
Jun 20, 2016
56013f9
Merge remote-tracking branch 'ncar/develop' into feature/netcdfRestart
Jun 20, 2016
1917935
Fixed bug related to not running proper # of GRUs in partial run.
Jun 21, 2016
13cf7f9
Removed some unused variables and fixed some iFort compiler warnings.
Jun 24, 2016
d193260
Fixed some error messages in read_attributes.f90 re: Michael's PR rev…
grey-nearing Jun 24, 2016
608f9a6
More changes due to PR code review.
Jun 29, 2016
e1e357d
Added Michael's bug fix from his PR #167. This passes the global HRU …
Jun 29, 2016
e458503
Fixed a problem where read_icond.f90 did not read nSnow and nSoil for…
Jun 29, 2016
8684dc0
Fixed another indexing error in the read initial conditions file.
grey-nearing Jun 29, 2016
92dc578
Fixed the following issues:
grey-nearing Jul 6, 2016
2fd934e
Fixed an error in an error message in ffile_info.f90
grey-nearing Jul 6, 2016
1927ed4
Fixed some small bugs in the I/O that were discovered while porting t…
grey-nearing Jul 16, 2016
d58d3c2
Merge remote-tracking branch 'ncar/develop' into merge/netcdfRestart
grey-nearing Aug 19, 2016
7e03a0b
Changed the name of the global variable that points to the model outp…
grey-nearing Aug 19, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ summa.exe.dSYM*
# makefile
make.out
Makefile-*
# backup files
*.backup
570 changes: 288 additions & 282 deletions build/source/driver/multi_driver.f90

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions build/source/dshare/ascii_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ subroutine file_open(infile,unt,err,message)
if(.not.xist)then
message=trim(message)//"FileNotFound[file='"//trim(infile)//"']"
err=10; return
endif
end if
! check if the file is already open
inquire(file=trim(infile),opened=xopn) ! Check if the file is open
if(xopn)then
message=trim(message)//"FileAlreadyOpen['"//trim(infile)//"']"
err=20; return
endif
end if
! open file
open(newunit=unt,file=trim(infile),status="old",action="read",iostat=err)
if(err/=0)then
message=trim(message)//"OpenError['"//trim(infile)//"']"
err=20; return
endif
end if
end subroutine file_open


Expand Down Expand Up @@ -109,14 +109,14 @@ subroutine split_line(inline,words,err,message)
else
allocate(current%next); current%next=node(cword,iword,null())
current=>current%next
endif
end if
! check that the line has fewer words than maxWords
if (iword==maxWords)then; err=20; message=trim(message)//"exceedMaxWords [line = "//trim(inline)//"]"; return; endif
if (iword==maxWords)then; err=20; message=trim(message)//"exceedMaxWords [line = "//trim(inline)//"]"; return; end if
end do
! ***** allocate space for the list of words
nWords = current%ix
allocate(words(nWords),stat=err)
if(err/=0)then; err=30; message=trim(message)//"problemAllocateWords"; return; endif
if(err/=0)then; err=30; message=trim(message)//"problemAllocateWords"; return; end if
! ***** save the list in a vector, and deallocate space as we go...
current=>list
do while(associated(current))
Expand Down Expand Up @@ -169,12 +169,12 @@ subroutine get_vlines(unt,vlines,err,message)
allocate(current%next)
current%next=node(temp,icount,null())
current=>current%next
endif
if (iline==maxLines)then; err=20; message=trim(message)//"exceedMaxLines"; return; endif
end if
if (iline==maxLines)then; err=20; message=trim(message)//"exceedMaxLines"; return; end if
end do ! looping through the lines in the file (exit clause above will kick in)
! ***** allocate space for the valid lines *****
allocate(vlines(icount),stat=err)
if(err/=0)then; err=30; message=trim(message)//"problemAllocateVlines"; return; endif
if(err/=0)then; err=30; message=trim(message)//"problemAllocateVlines"; return; end if
! ***** save the list in a vector, and deallocate space as we go... *****
current=>list
do while(associated(current))
Expand Down
4 changes: 2 additions & 2 deletions build/source/dshare/data_types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ MODULE data_types
! hru info data structure
type, public :: hru_info
integer(i4b) :: hru_nc ! index of the hru in the netcdf file
integer(i4b) :: hru_ix ! index of the hru in the entire domain
integer(i4b) :: hru_ix ! index of the hru in the run domain
integer(i4b) :: hru_id ! id (non-sequential number) of the hru
integer(i4b) :: nSnow ! number of snow layers
integer(i4b) :: nSoil ! number of soil layers
endtype hru_info

! define mapping from HRUs to the HRUs
! define mapping from GRUs to the HRUs
type, public :: gru2hru_map
integer(i4b) :: gruId ! id of the gru
integer(i4b) :: hruCount ! total number of hrus in the gru
Expand Down
38 changes: 19 additions & 19 deletions build/source/dshare/get_ixname.f90
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function get_ixdecisions(varName)
! get to here if cannot find the variable
case default
get_ixdecisions = integerMissing
endselect
end select
end function get_ixdecisions


Expand All @@ -119,7 +119,7 @@ function get_ixtime(varName)
! get to here if cannot find the variable
case default
get_ixtime = integerMissing
endselect
end select
end function get_ixtime


Expand All @@ -145,7 +145,7 @@ function get_ixforce(varName)
! get to here if cannot find the variable
case default
get_ixforce = integerMissing
endselect
end select
end function get_ixforce


Expand All @@ -170,7 +170,7 @@ function get_ixAttr(varName)
! get to here if cannot find the variable
case default
get_ixAttr = integerMissing
endselect
end select
end function get_ixAttr


Expand All @@ -193,7 +193,7 @@ function get_ixType(varName)
! get to here if cannot find the variable
case default
get_ixType = integerMissing
endselect
end select
end function get_ixType


Expand Down Expand Up @@ -377,7 +377,7 @@ function get_ixparam(varName)
! get to here if cannot find the variable
case default
get_ixparam = integerMissing
endselect
end select
end function get_ixparam


Expand Down Expand Up @@ -422,7 +422,7 @@ function get_ixprog(varName)
! get to here if cannot find the variable
case default
get_ixprog = integerMissing
endselect
end select
end function get_ixprog


Expand Down Expand Up @@ -528,7 +528,7 @@ function get_ixdiag(varName)
! get to here if cannot find the variable
case default
get_ixdiag = integerMissing
endselect
end select
end function get_ixdiag


Expand Down Expand Up @@ -640,7 +640,7 @@ function get_ixflux(varName)
case('scalarAquiferBaseflow' ); get_ixflux = iLookFLUX%scalarAquiferBaseflow ! baseflow from the aquifer (m s-1)
case default
get_ixflux = integerMissing
endselect
end select
end function get_ixflux


Expand Down Expand Up @@ -702,7 +702,7 @@ function get_ixderiv(varName)
case('dPsiLiq_dTemp' ); get_ixderiv = iLookDERIV%dPsiLiq_dTemp ! derivative in the liquid water matric potential w.r.t. temperature (m K-1)
case default
get_ixderiv = integerMissing
endselect
end select
end function get_ixderiv


Expand Down Expand Up @@ -762,7 +762,7 @@ function get_ixindex(varName)
case('ifcTotoStartIndex'); get_ixindex = iLookINDEX%ifcTotoStartIndex ! start index of the ifcToto vector for a given timestep
case default
get_ixindex = integerMissing
endselect
end select
end function get_ixindex


Expand All @@ -787,7 +787,7 @@ function get_ixbpar(varName)
! get to here if cannot find the variable
case default
get_ixbpar = integerMissing
endselect
end select
end function get_ixbpar


Expand Down Expand Up @@ -819,7 +819,7 @@ function get_ixbvar(varName)
! get to here if cannot find the variable
case default
get_ixbvar = integerMissing
endselect
end select
end function get_ixbvar

! *********************************************************************************************************
Expand All @@ -846,7 +846,7 @@ function get_ixVarType(varType)
! get to here if cannot find the variable
case default
get_ixVarType = integerMissing
endselect
end select
end function get_ixVarType

! ****************************************************************************************************************
Expand All @@ -873,7 +873,7 @@ function get_varTypeName(varType)
! get to here if cannot find the variable
case default
get_VarTypeName = 'missing'
endselect
end select
end function get_VarTypeName

! *******************************************************************************************************************
Expand Down Expand Up @@ -916,9 +916,9 @@ subroutine get_ixUnknown(varName,typeName,vDex,err,message)
case ('bpar' ); vDex = get_ixBpar(trim(varName))
case ('bvar' ); vDex = get_ixBvar(trim(varName))
case ('deriv'); vDex = get_ixDeriv(trim(varName))
endselect
if (vDex>0) then; typeName=trim(structInfo(iStruc)%structName); return; endif;
enddo
end select
if (vDex>0) then; typeName=trim(structInfo(iStruc)%structName); return; end if;
end do

! 404
err=20;message=trim(message)//'variable not found in any structure:'//trim(varName); return;
Expand Down Expand Up @@ -946,7 +946,7 @@ function get_statName(istat)
! get to here if cannot find the variable
case default
get_statName = 'unknown'
endselect
end select
end function get_statName

end module get_ixname_module
24 changes: 14 additions & 10 deletions build/source/dshare/outpt_stat.f90
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ subroutine calcStats(stat,dat,meta,iStep,err,message)
stat(iVar)%dat(iLookStat%inst) = tdata
else
call calc_stats(meta(iVar),stat(iVar),tdata,iStep,err,cmessage)
endif
end if

if(err/=0)then; message=trim(message)//trim(cmessage);return; endif
endif
enddo ! model variables
if(err/=0)then; message=trim(message)//trim(cmessage);return; end if
end if
end do ! model variables

return
end subroutine calcStats
Expand All @@ -103,6 +103,8 @@ subroutine calc_stats(meta,stat,tdata,iStep,err,message)
USE data_types,only:var_info,ilength,dlength ! type dec for meta data structures
USE var_lookup,only:maxVarStat ! # of output statistics
USE globalData,only:outFreq ! output frequencies
! global variables
USE globalData,only:data_step ! forcing timestep
! structures of named variables
USE var_lookup,only:iLookVarType ! named variables for variable types
USE var_lookup,only:iLookStat ! named variables for output statistics types
Expand All @@ -124,7 +126,7 @@ subroutine calc_stats(meta,stat,tdata,iStep,err,message)

! pull current frequency for normalization
iFreq = meta%outFreq
if (iFreq<0) then; err=-20; message=trim(message)//'bad output file id# (outfreq)'; return; endif
if (iFreq<0) then; err=-20; message=trim(message)//'bad output file id# (outfreq)'; return; end if

! pack back into struc
select type (stat)
Expand Down Expand Up @@ -155,8 +157,8 @@ subroutine calc_stats(meta,stat,tdata,iStep,err,message)
case (iLookStat%mode) ! mode over period (does not work)
tstat(iStat) = -9999.
end select
enddo ! iStat
endif
end do ! iStat
end if

! ---------------------------------------------
! Calculate each statistic that is requested by user
Expand All @@ -181,7 +183,7 @@ subroutine calc_stats(meta,stat,tdata,iStep,err,message)
case (iLookStat%mode) ! (does not work)
tstat(iStat) = -9999.
end select
enddo ! iStat
end do ! iStat

! ---------------------------------------------
! finalize statistics at end of frequenncy period
Expand All @@ -191,14 +193,16 @@ subroutine calc_stats(meta,stat,tdata,iStep,err,message)
if (.not.meta%statFlag(iStat)) cycle ! do not bother if output flag is off
if (meta%vartype.ne.iLookVarType%outstat) cycle ! only calculate stats for scalars
select case(iStat) ! act depending on the statistic
case (iLookStat%totl) ! summation over period
tstat(iStat) = tstat(iStat)*data_step ! scale by seconds per timestep
case (iLookStat%mean) ! mean over period
tstat(iStat) = tstat(iStat)/outFreq(iFreq) ! normalize sum into mean
case (iLookStat%vari) ! variance over period
tstat(maxVarStat+1) = tstat(maxVarStat+1)/outFreq(iFreq) ! E[X] term
tstat(iStat) = tstat(iStat)/outFreq(iFreq) - tstat(maxVarStat+1)**2 ! full variance
end select
enddo ! iStat
endif
end do ! iStat
end if

! pack back into struc
select type (stat)
Expand Down
Loading