Unfortunately, this option is buggy, and in a case when river flow is strong, it can lead to temperatures quickly going out of range. Looking at the code together with John Wilkin and Chuning Wang, we discovered the source of the problem and came up with the modifications to the code. Below we discuss the modifications. We also attach the files with the modifications.
There are several routines that are responsible for implementation of LwSrc. First, volume flux is added directly to the water column by increasing surface height in Nonlinear/step2d_LF_AM3.h.
Then, since this operation influences flow divergence, vertical velocity needs to be adjusted. This is done in omega.F, where velocity divergence is integrated from the bottom up, but the mass source is not integrated from the bottom up, it just added on each sigma level, as follows:
Code: Select all
IF (LwSrc(ng)) THEN
DO is=1,Nsrc(ng)
ii=SOURCES(ng)%Isrc(is)
jj=SOURCES(ng)%Jsrc(is)
IF (((IstrR.le.ii).and.(ii.le.IendR)).and. &
& ((JstrR.le.jj).and.(jj.le.JendR)).and. &
& (j.eq.jj)) THEN
DO k=1,N(ng)
W(ii,jj,k)=W(ii,jj,k)+SOURCES(ng)%Qsrc(is,k)
END DO
END IF
END DO
Code: Select all
IF (LwSrc(ng)) THEN
DO is=1,Nsrc(ng)
ii=SOURCES(ng)%Isrc(is)
jj=SOURCES(ng)%Jsrc(is)
IF (((IstrR.le.ii).and.(ii.le.IendR)).and. &
& (j.eq.jj)) THEN
DO k=1,N(ng)
W(ii,jj,k)=W(ii,jj,k-1)- &
& (Huon(ii+1,jj,k)-Huon(ii,jj,k)+ &
& Hvom(ii,jj+1,k)-Hvom(ii,jj,k))+ &
& SOURCES(ng)%Qsrc(is,k)
Heat and fresh water fluxes from LwSrc are done in pre_step3d.F and stepd3d_t.F. They are currently done through vertical advection, like this:
Code: Select all
IF (LwSrc(ng).and.ANY(LtracerSrc(:,ng))) THEN
DO is=1,Nsrc(ng)
Isrc=SOURCES(ng)%Isrc(is)
Jsrc=SOURCES(ng)%Jsrc(is)
IF (LtracerSrc(itrc,ng).and. &
& ((IstrR.le.Isrc).and.(Isrc.le.IendR)).and. &
& (j.eq.Jsrc)) THEN
DO k=1,N(ng)-1
FC(Isrc,k)=FC(Isrc,k)+0.5_r8* &
& (SOURCES(ng)%Qsrc(is,k )* &
& SOURCES(ng)%Tsrc(is,k ,itrc)+ &
& SOURCES(ng)%Qsrc(is,k+1)* &
& SOURCES(ng)%Tsrc(is,k+1,itrc))
Code: Select all
IF (LwSrc(ng)) THEN
DO is=1,Nsrc(ng)
Isrc=SOURCES(ng)%Isrc(is)
Jsrc=SOURCES(ng)%Jsrc(is)
IF ( &
& ((IstrR.le.Isrc).and.(Isrc.le.IendR)).and. &
& ((JstrR.le.Jsrc).and.(Jsrc.le.JendR))) THEN
cff=dt(ng)*pm(Isrc,Jsrc)*pn(Isrc,Jsrc)
IF (LtracerSrc(itrc,ng)) THEN
t(Isrc,Jsrc,k,nnew,itrc)=t(Isrc,Jsrc,k,nnew,itrc)+ &
& cff*SOURCES(ng)%Qsrc(is,k)* &
& SOURCES(ng)%Tsrc(is,k,itrc)
ELSE
t(Isrc,Jsrc,k,nnew,itrc)=t(Isrc,Jsrc,k,nnew,itrc)+ &
& cff*SOURCES(ng)%Qsrc(is,k)* &
& t(Isrc,Jsrc,k,3,itrc)
This seems to have made the difference in my runs with LwSrc=T. The temperature stopped going out of range, and all the fluxes add up correctly to agree with the LuvSrc=T results.
Acknowledgement: Jupiter Intelligence INC has paid for my work on discovering and correcting this issue. Jupiter agrees to release this code to the ROMS community.