Skip to content

Changes for constituents, salt, gwflow, and heat#159

Open
RyanTBailey wants to merge 23 commits intoswat-model:mainfrom
RyanTBailey:main
Open

Changes for constituents, salt, gwflow, and heat#159
RyanTBailey wants to merge 23 commits intoswat-model:mainfrom
RyanTBailey:main

Conversation

@RyanTBailey
Copy link

These are changes to many files focused on constituents, salinity, gwflow, and heat. I was doing commits one file at a time, but then I must have pressed the wrong button because the remaining files were committed without being able to enter a description of the changes.

Thank you
Ryan

…imulation years are read in the road salt input file
…ons for cs mass in lateral flow and surface runoff
@celray
Copy link
Member

celray commented Feb 17, 2026

This is a big merge, so I have asked several people including myself to review.

@celray
Copy link
Member

celray commented Feb 17, 2026

so far I found three issues in channel routing that may cause salt and constituent mass to be silently wrong or lost entirely.

ch_rtmusk.f90: cumulative total subtracted each substep instead of per-step increment.
In the subdaily Muskingum routing loop, hcs2%salt(isalt) accumulates across substeps, but the full cumulative sum is subtracted from ch_water each iteration instead of just the current step's portion. On step N, the channel loses the sum of all prior steps' outflow again. Channel salt/cs storage drains far too fast and will go negative. The same pattern applies to hcs2%cs(ics).

!! rtb: add salt and constituent mass to outflow; then subtract from channel mass storage
      if(cs_db%num_salts > 0) then
        do isalt=1,cs_db%num_salts
          hcs2%salt(isalt) = hcs2%salt(isalt) + (rto * ch_water(jrch)%salt(isalt))   ! line 208: accumulates
          ch_water(jrch)%salt(isalt) = ch_water(jrch)%salt(isalt) - hcs2%salt(isalt)  ! line 209: subtracts FULL cumulative
        enddo
      endif
      if(cs_db%num_cs > 0) then
        do ics=1,cs_db%num_cs
          hcs2%cs(ics) = hcs2%cs(ics) + (rto * ch_water(jrch)%cs(ics))               ! line 214: accumulates
          ch_water(jrch)%cs(ics) = ch_water(jrch)%cs(ics) - hcs2%cs(ics)              ! line 215: subtracts FULL cumulative
        enddo
      endif

sd_channel_control3.f90: salt/cs storage-coefficient routing deleted with no replacement.
The seepage mass removal loops and the hcs2 = scoef * hcs3 storage update for salt and constituents were deleted. The PR adds inflow concentration calculations and zeroes hcs2, but no replacement routing or seepage logic exists. Salt and constituent mass will pass through sd_channel_control3-routed channels with zero seepage loss and no storage interaction.

ch_temp.f90 overwrites hyd_sep_array with temperature diagnostics.
ch_temp assigns temperature-related values (LSU flows, tw_final, tw_init) into all 7 columns of hyd_sep_array(ich,...). Since ch_temp is called after sd_channel_control3 populates this array with hydrograph separation data (surface, lateral, groundwater, tile flow components), the output file channel_sd_day_hydsep.txt will contain temperature diagnostics instead of flow separation data.

Set in src/sd_channel_control3.f90:360-366

      hyd_sep_array(ich,1) = hdsep2%flo_surq / 86400.
      hyd_sep_array(ich,2) = hdsep2%flo_latq / 86400.
      hyd_sep_array(ich,3) = hdsep2%flo_gwsw / 86400.
      hyd_sep_array(ich,4) = hdsep2%flo_swgw / 86400.
      hyd_sep_array(ich,5) = hdsep2%flo_satex / 86400.
      hyd_sep_array(ich,6) = hdsep2%flo_satexsw / 86400.
      hyd_sep_array(ich,7) = hdsep2%flo_tile / 86400.

Overwritten by src/ch_temp.f90:436-442 (called at sd_channel_control3.f90:370)

      hyd_sep_array(ich,1) = q_lsu_surf
      hyd_sep_array(ich,2) = q_lsu_lat
      hyd_sep_array(ich,3) = q_gw
      hyd_sep_array(ich,4) = q_lsu_wyld
      hyd_sep_array(ich,5) = q_lsu_sno
      hyd_sep_array(ich,6) = tw_final
      hyd_sep_array(ich,7) = tw_init

@celray
Copy link
Member

celray commented Feb 18, 2026

File: src/ch_read.f90:104-105

       if (ch_dat(ichi)%nut == 0) write (9001,*) ch_dat_c(ichi)%nut, " not found (nutrients.cha)"      ! line 104
       if (ch_dat(ichi)%nut == 0) write (9001,*) ch_dat_c(ichi)%temp, " not found (temperature.cha)"   ! line 105

Line 105 checks %nut instead of %temp. Copy-paste from line 104, condition not updated. Missing temperature data is never flagged; the warning fires when nutrients are missing instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants