Skip to content

Commit

Permalink
Merge pull request #3 from bartnijssen/martynpclark-feature/rootDensity
Browse files Browse the repository at this point in the history
Martynpclark feature/root density
  • Loading branch information
martynpclark committed Dec 7, 2015
2 parents 1d1304d + 6131e3d commit 409f8c1
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 25 deletions.
8 changes: 4 additions & 4 deletions build/source/driver/multi_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ program multi_driver
integer(i4b) :: jStep=0 ! index of model output
! define the re-start file
logical(lgt) :: printRestart ! flag to print a re-start file
integer(i4b),parameter :: ixRestart_iy=1000 ! named variable to print a re-start file once per year
integer(i4b),parameter :: ixRestart_im=1001 ! named variable to print a re-start file once per month
integer(i4b),parameter :: ixRestart_id=1002 ! named variable to print a re-start file once per day
integer(i4b),parameter :: ixRestart_never=1003 ! named variable to print a re-start file never
Expand Down Expand Up @@ -378,8 +379,6 @@ program multi_driver
! read forcing data
call read_force(istep,iHRU,err,message); call handle_err(err,message)
end do ! (end looping through HRUs)
print*, time_data%var


! *****************************************************************************
! (7) create a new NetCDF output file, and write parameters and forcing data
Expand Down Expand Up @@ -500,8 +499,9 @@ program multi_driver
! ****************************************************************************
! define the need to calculate the re-start file
select case(ixRestart)
case(ixRestart_im); printRestart = (time_data%var(iLookTIME%id) == 1 .and. time_data%var(iLookTIME%ih) == 1 .and. time_data%var(iLookTIME%imin) == 0)
case(ixRestart_id); printRestart = (time_data%var(iLookTIME%ih) == 1 .and. time_data%var(iLookTIME%imin) == 0)
case(ixRestart_iy); printRestart = (time_data%var(iLookTIME%im) == 1 .and. time_data%var(iLookTIME%id) == 1 .and. time_data%var(iLookTIME%ih) == 0 .and. time_data%var(iLookTIME%imin) == 0)
case(ixRestart_im); printRestart = (time_data%var(iLookTIME%id) == 1 .and. time_data%var(iLookTIME%ih) == 0 .and. time_data%var(iLookTIME%imin) == 0)
case(ixRestart_id); printRestart = (time_data%var(iLookTIME%ih) == 0 .and. time_data%var(iLookTIME%imin) == 0)
case(ixRestart_never); printRestart = .false.
case default; call handle_err(20,'unable to identify option for the restart file')
end select
Expand Down
3 changes: 2 additions & 1 deletion build/source/dshare/multiconst.f90
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ MODULE multiconst
REAL(DP), PARAMETER :: secprday = 86400._dp ! number of seconds in a day
REAL(DP), PARAMETER :: secprhour = 3600._dp ! number of seconds in an hour
REAL(DP), PARAMETER :: secprmin = 60._dp ! number of seconds in a minute
integer(i4b),parameter :: integerMissing = -9999 ! value for mising integer
REAL(DP), PARAMETER :: minprhour = 60._dp ! number of minutes in an hour
integer(i4b),parameter :: integerMissing = -9999 ! value for missing integer

END MODULE multiconst
2 changes: 1 addition & 1 deletion build/source/engine/coupled_em.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ subroutine printRestartFile(&
write(timeString,'(a,i4,3(a,i2.2))') '_',time_data%var(iLookTIME%iyyy),'-',time_data%var(iLookTIME%im),'-',time_data%var(iLookTIME%id),'-',time_data%var(iLookTIME%ih)

! define the file name
filename = trim(OUTPUT_PATH)//trim(filepref)//trim(timeString)//trim(output_fileSuffix)//'.txt'
filename = trim(OUTPUT_PATH)//trim(OUTPUT_PREFIX)//'_'//trim(filepref)//trim(timeString)//trim(output_fileSuffix)//'.txt'
!print*, trim(filename)
!pause

Expand Down
25 changes: 17 additions & 8 deletions build/source/engine/derivforce.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module derivforce_module
subroutine derivforce(err,message)
USE multiconst,only:Tfreeze ! freezing point of pure water (K)
USE multiconst,only:secprhour ! number of seconds in an hour
USE multiconst,only:minprhour ! number of minutes in an hour
USE data_struc,only:data_step ! length of the data step (s)
USE data_struc,only:time_data,forc_data ! forcing data structures
USE data_struc,only:attr_data,mpar_data,mvar_data ! model data structures
Expand All @@ -49,6 +50,8 @@ subroutine derivforce(err,message)
! variables for cosine of the solar zenith angle
integer(i4b),pointer :: im ! month
integer(i4b),pointer :: id ! day
integer(i4b),pointer :: ih ! hour
integer(i4b),pointer :: imin ! minute
real(dp) :: ahour ! hour at start of time step
real(dp) :: dataStep ! data step (hours)
real(dp),parameter :: slope=0._dp ! terrain slope (assume flat)
Expand Down Expand Up @@ -115,8 +118,8 @@ subroutine derivforce(err,message)
! assign pointers to radiation geometry variables
im => time_data%var(iLookTIME%im) ! month
id => time_data%var(iLookTIME%id) ! day
dataStep = data_step/secprhour ! time step (hours)
ahour = real(time_data%var(iLookTIME%ih),kind(dp)) - dataStep ! hour at start of time step
ih => time_data%var(iLookTIME%ih) ! hour
imin => time_data%var(iLookTIME%imin) ! minute
latitude => attr_data%var(iLookATTR%latitude) ! latitude (degrees north
cosZenith => mvar_data%var(iLookMVAR%scalarCosZenith)%dat(1) ! average cosine of the zenith angle over time step DT
! assign pointers to model forcing data
Expand Down Expand Up @@ -148,18 +151,24 @@ subroutine derivforce(err,message)
scalarCO2air = co2Factor * airpres ! atmospheric co2 concentration (Pa)
scalarO2air = o2Factor * airpres ! atmospheric o2 concentration (Pa)

! compute the decimal hour at the start of the time step
dataStep = data_step/secprhour ! time step (hours)
ahour = real(ih,kind(dp)) + real(imin,kind(dp))/minprhour - data_step/secprhour ! decimal hour (start of the step)

! compute the cosine of the solar zenith angle
call clrsky_rad(im,id,ahour,dataStep, & ! intent(in): time variables
slope,azimuth,latitude, & ! intent(in): location variables
hri,cosZenith) ! intent(out): cosine of the solar zenith angle
!write(*,'(a,1x,4(i2,1x),3(f9.3,1x))') 'im,id,ih,imin,ahour,dataStep,cosZenith = ', &
! im,id,ih,imin,ahour,dataStep,cosZenith
! check that we don't have considerable shortwave when the zenith angle is low
! NOTE: this is likely because the data are not in local time
if(cosZenith < epsilon(cosZenith) .and. SWRadAtm > 100._dp)then
message=trim(message)//'SWRadAtm > 100 W m-2 when cos zenith angle is zero -- check that forcing data are in local time, '//&
'that the time stamp in forcing data is at the end of the data interval, and that the lat-lon '//&
'in the site characteristix file is correct'
err=20; return
endif
!if(cosZenith < epsilon(cosZenith) .and. SWRadAtm > 200._dp)then
! message=trim(message)//'SWRadAtm > 200 W m-2 when cos zenith angle is zero -- check that forcing data are in local time, '//&
! 'that the time stamp in forcing data is at the end of the data interval, and that the lat-lon '//&
! 'in the site characteristix file is correct'
! err=20; return
!endif
! ensure solar radiation is zero between sunset and sunrise
! NOTE: also ensure that sw radiation is positive
if(cosZenith <= 0._dp .or. SWRadAtm < 0._dp) SWRadAtm = 0._dp
Expand Down
7 changes: 7 additions & 0 deletions build/source/engine/read_force.f90
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,12 @@ subroutine read_force(istep,iHRU,err,message)
time_data%var(iLookTIME%ih), & ! input = hour
time_data%var(iLookTIME%imin),dsec, & ! input = minute/second
juldayFirst,err,cmessage) ! output = julian day (fraction of day) + error control
write(*,'(a,i4,1x,4(i2,1x))') 'firstTime: iyyy, im, id, ih, imin = ', time_data%var
! compute the start index
iStart = nint( (dJulianStart - juldayFirst)*secprday/data_step )
print*, 'iStartIndex = ', iStart
if(iStart < 0)then
print*, 'iStart = ', iStart
message=trim(message)//'simulation start time is before the first time index in the datafile ['//trim(infile)//']'
err=20; return
endif
Expand All @@ -160,6 +163,10 @@ subroutine read_force(istep,iHRU,err,message)
read(unt,'(a)',iostat=err)
if(err/=0)then; err=20; message=trim(message)//'problemLineRead[is there any data within the simulation period?]'; return; endif
end do
! iStart=0, then need to back up because of data read in the next block
else
backspace(unit=unt,iostat=err)
if(err/=0)then; err=20; message=trim(message)//'problemRewindingFile: iStart=0'; return; endif
endif
! handle situation where istep>1
if (istep>1) then
Expand Down
1 change: 1 addition & 0 deletions build/source/engine/read_pinit.f90
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ subroutine read_pinit(filenm,isLocal,mpar_meta,parFallback,err,message)
! build filename and update error message
infile = trim(SETNGS_PATH)//trim(filenm)
message=trim(message)//'file='//trim(infile)//' - '
write(*,'(a)') trim(infile)
! open file
call file_open(trim(infile),unt,err,cmessage)
if(err/=0)then; message=trim(message)//trim(cmessage); return; endif
Expand Down
2 changes: 1 addition & 1 deletion build/source/engine/systemSolv.f90
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ subroutine systemSolv(&
real(dp) :: dCanopyEvaporation_dCanLiq ! derivative in canopy evaporation w.r.t. canopy liquid water content (s-1)
! energy fluxes and derivatives for the snow and soil domains
real(dp),dimension(nLayers) :: ssdNetNrgFlux ! net energy flux for each layer (J m-3 s-1)
real(dp),dimension(0:nLayers) :: iLayerNrgFlux ! energy flux at the layer interfaces (W m-2)
real(dp),dimension(0:nLayers) :: dNrgFlux_dTempAbove ! derivatives in the flux w.r.t. temperature in the layer above (J m-2 s-1 K-1)
real(dp),dimension(0:nLayers) :: dNrgFlux_dTempBelow ! derivatives in the flux w.r.t. temperature in the layer below (J m-2 s-1 K-1)
! liquid water fluxes and derivatives for the vegetation domain
Expand Down Expand Up @@ -1716,6 +1715,7 @@ subroutine computFlux(&
mLayerColumnOutflow => mvar_data%var(iLookMVAR%mLayerColumnOutflow)%dat ,& ! intent(out): [dp(:)] column outflow from each soil layer (m3 s-1)

! soil fluxes
iLayerNrgFlux => mvar_data%var(iLookMVAR%iLayerNrgFlux)%dat ,& ! intent(out): [dp(0:)] vertical energy flux at the interface of snow and soil layers
iLayerLiqFluxSnow => mvar_data%var(iLookMVAR%iLayerLiqFluxSnow)%dat ,& ! intent(out): [dp(0:)] vertical liquid water flux at snow layer interfaces (-)
iLayerLiqFluxSoil => mvar_data%var(iLookMVAR%iLayerLiqFluxSoil)%dat ,& ! intent(out): [dp(0:)] vertical liquid water flux at soil layer interfaces (-)
mLayerBaseflow => mvar_data%var(iLookMVAR%mLayerBaseflow)%dat ,& ! intent(out): [dp(:)] baseflow from each soil layer (m s-1)
Expand Down
2 changes: 1 addition & 1 deletion build/source/engine/time_utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ subroutine extractTime(refdate,iyyy,im,id,ih,imin,dsec,err,message)
if (istart+(iend-2)==n) then
ih=0; imin=0; dsec=0._dp; return
endif
print*, 'iyyy, im, id = ', iyyy, im, id

! get the hour (":" at end of hour)
istart = istart+iend
Expand All @@ -92,6 +91,7 @@ subroutine extractTime(refdate,iyyy,im,id,ih,imin,dsec,err,message)
if(istart > len_trim(refdate)) return
iend = index(refdate(istart:n)," ")
read(refdate(istart:n),*) dsec
write(*,'(a,i4,1x,4(i2,1x))') 'refdate: iyyy, im, id, ih, imin = ', iyyy, im, id, ih, imin

contains

Expand Down
6 changes: 3 additions & 3 deletions docs/howto/summa_and_git_howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ In general, if you plan to apply the model rather than work directly on the sour
If you plan on contributing to model development or would like a systematic way to incorporate updates to the SUMMA source code, we encourage you to use Git. The following sections are designed to get you started using Git and working with the SUMMA source code repository.

### Git resources
If you are SUMMA familiar with Git yet, we encourage you to spend a few minutes getting antiquated with the system before you starting working with the SUMMA source code and Git. It's not difficult to use and a few minutes of learning about Git will go along way in helping you manage your code development.
If you are not familiar with Git yet, we encourage you to spend a few minutes getting acquainted with the system before you starting working with the SUMMA source code and Git. It's not difficult to use and a few minutes of learning about Git will go along way in helping you manage your code development.

There are a number of good Git learning resources that will provide a basic introduction to the version control system.
* http://git-scm.com/about
Expand Down Expand Up @@ -84,7 +84,7 @@ then you are not in a Git repository (note that the top level directory in a Git

Assign the truth repo to a remote tracking branch called `upstream`, which will allow you easily pull in changes that are made in the truth repo and keep your clone in-sync with that version. Once you get more familiar with Git, you will be able to control which updates to include:

git remote add --tracking upstream https://github.com/NCAR/summa.git
git remote add upstream https://github.com/NCAR/summa.git

#### Step 4. Sync your clone with the truth repo

Expand Down Expand Up @@ -189,7 +189,7 @@ The SUMMA administrator and other developers will review your pull request and d

### Git workflow

For us to leverage Git to its full potential, we have implemented a Git-oriented workflow. This requires developers to adhere to a few rules regarding branch names and merge requests. A full description of the workflow we use can be found [here](https://github.com/NCAR/summa/docs/summa_git_workflow.md).
For us to leverage Git to its full potential, we have implemented a Git-oriented workflow. This requires developers to adhere to a few rules regarding branch names and merge requests. A full description of the workflow we use can be found [here](https://github.com/NCAR/summa/blob/master/docs/howto/summa_git_workflow.md).



Expand Down
12 changes: 6 additions & 6 deletions docs/howto/summa_git_workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ Although anyone could create these branches, they are designed for the preparati
* Feature branch – feature/{feature_name}
* Hotfix branch – hotfix/{hotfix_name}
* Release branch – release/{release_name}
* Support branch – support/VIC.{base_release_number}.{feature_branch_name}
* Release name – VIC.{major.minor.patch}
* Support release name - VIC.{base_release_number}.{feature_branch_name}.{##}
* Support branch – support/SUMMA.{base_release_number}.{feature_branch_name}
* Release name – SUMMA.{major.minor.patch}
* Support release name - SUMMA.{base_release_number}.{feature_branch_name}.{##}

## User Permissions
Using Github to host the central or truth repository of our models allows us to easily control contributor permissions. Currently we split permission levels into 3 levels, Owners, Model Admins, and Developers.
Expand All @@ -47,7 +47,7 @@ Using Github to host the central or truth repository of our models allows us to

2. Model Admins have full access to specific repositories. They may push, pull, or make administrative changes to those repositories associated with their model. However, they should generally not push to the truth repo directly. Instead, they should fork, clone, edit locally, update their fork and then issue a pull request. This pull request should preferably be reviewed by someone else before it is merged.

3. Developers have read-only access (pull, clone, fork) to any of the publically listed repositories under the UW-hydro name. If a developer would like a feature branch merged into the main repository, a pull request must be submitted and a Model Admin may merge it in.
3. Developers have read-only access (pull, clone, fork) to any of the publicly listed repositories under the UW-hydro name. If a developer would like a feature branch merged into the main repository, a pull request must be submitted and a Model Admin may merge it in.

## Workflow examples

Expand All @@ -67,7 +67,7 @@ The process would be as follows:

* Add the main SUMMA repo as the upstream remote, so you can easily merge changes that are made in the main SUMMA repo into your own local repo

git add remote upstream git@github.com:NCAR/summa.git
git remote add upstream git@github.com:NCAR/summa.git

* Checkout the `develop` branch

Expand All @@ -81,7 +81,7 @@ The process would be as follows:

git push

* Now make as many changes as you need to, commit them to your local repo and push them to your remote on GitHub. This is just like any other work you would do using Git. Once everything is working and eevrything is sufficiently tested, you will be ready to share your code with others.
* Now make as many changes as you need to, commit them to your local repo and push them to your remote on GitHub. This is just like any other work you would do using Git. Once everything is working and everything is sufficiently tested, you will be ready to share your code with others.


* Before you do that, merge any changes that have been made in the develop branch in the main SUMMA repo into the `feature/resistance` branch of your local repo. Assuming you are already on the `feature/resistance` branch:
Expand Down

0 comments on commit 409f8c1

Please sign in to comment.