subroutine bounds_nr(q,u,v,d,h1,h2,hh1,hh2,x1,x2 & ,y1,y2,out,in,n1,n2,nn1,nn2,m,n,mm,nn,grnd) c..... Interpolates values of q,u,v in the vicinity of "in" coordinates c..... onto hh1,hh2 grid. Writes values into x1,x2,y1,y2, vectors with c..... "out" coordinates. All this for "narr" nested grid real*8 d(mm,nn),q(mm,nn),u(mm,nn),v(mm,nn) real*8 uki,vki,qki,uki1,vki1,qki1,xx1,xx2,yy1,yy2,xx & ,h1(n1),h2(n2),hh1(nn1),hh2(nn2),f real*8 x1(n,3,1),x2(n,3,1) & ,y1(m,3,1),y2(m,3,1) real*8 q1,q2,grnd integer in(4,3),out(4,3) f(xx1,xx2,yy1,yy2,xx)=(yy2-yy1)/(xx2-xx1)*(xx-xx1)+yy1 !linear interpolation c..... Getting data INTO the nested grid do 111 i=1,nn2 ! BC for X1 and X2 boundaries do k=in(3,1), in(4,1)+1 if(h2(k).GE.hh2(i).AND.h2(k-1).LT.hh2(i)) then c.......... X1 boundary uki=f(h1(in(1,1)-1),h1(in(1,1)),u(in(1,1)-1,k) & ,u(in(1,1),k),hh1(out(1,1))) vki=f(h1(in(1,1)-1),h1(in(1,1)),v(in(1,1)-1,k) & ,v(in(1,1),k),hh1(out(1,1))) if (q(in(1,1)-1,k).GT.grnd) then q1 = q(in(1,1)-1,k)-d(in(1,1)-1,k) else q1 = 0.0 endif if (q(in(1,1),k).GT.grnd) then q2 = q(in(1,1),k)-d(in(1,1),k) else q2 = 0.0 endif qki=f(h1(in(1,1)-1),h1(in(1,1)) & ,q1 & ,q2,hh1(out(1,1))) uki1=f(h1(in(1,1)-1),h1(in(1,1)) & ,u(in(1,1)-1,k-1),u(in(1,1),k-1) & ,hh1(out(1,1))) vki1=f(h1(in(1,1)-1),h1(in(1,1)) & ,v(in(1,1)-1,k-1),v(in(1,1),k-1) & ,hh1(out(1,1))) if (q(in(1,1)-1,k-1).GT.grnd) then q1 = q(in(1,1)-1,k-1)-d(in(1,1)-1,k-1) else q1 = 0.0 endif if (q(in(1,1),k-1).GT.grnd) then q2 = q(in(1,1),k-1)-d(in(1,1),k-1) else q2 = 0.0 endif qki1=f(h1(in(1,1)-1),h1(in(1,1)) & ,q1 & ,q2 & ,hh1(out(1,1))) x1(i,1,1)=f(h2(k-1),h2(k),uki1,uki,hh2(i)) x1(i,2,1)=f(h2(k-1),h2(k),vki1,vki,hh2(i)) x1(i,3,1)=f(h2(k-1),h2(k),qki1,qki,hh2(i)) c........... X2 boundary uki=f(h1(in(2,1)),h1(in(2,1)+1),u(in(2,1),k) & ,u(in(2,1)+1,k),hh1(out(2,1))) vki=f(h1(in(2,1)),h1(in(2,1)+1),v(in(2,1),k) & ,v(in(2,1)+1,k),hh1(out(2,1))) if (q(in(2,1),k).GT.grnd) then q1 = q(in(2,1),k)-d(in(2,1),k) else q1 = 0.0 endif if (q(in(2,1)+1,k).GT.grnd) then q2 = q(in(2,1)+1,k)-d(in(2,1)+1,k) else q2 = 0.0 endif qki=f(h1(in(2,1)),h1(in(2,1)+1) & ,q1 & ,q2,hh1(out(2,1))) c write(*,*)'i=',i,'k=',k,'qki=',qki,'q=', c & q(in(2,1),k),',',d(in(2,1),k),',', c & q(in(2,1)+1,k),',',d(in(2,1)+1,k) uki1=f(h1(in(2,1)),h1(in(2,1)+1) & ,u(in(2,1),k-1),u(in(2,1)+1,k-1),hh1(out(2,1))) vki1=f(h1(in(2,1)),h1(in(2,1)+1) & ,v(in(2,1),k-1),v(in(2,1)+1,k-1),hh1(out(2,1))) if (q(in(2,1),k-1).GT.grnd) then q1 = q(in(2,1),k-1)-d(in(2,1),k-1) else q1 = 0.0 endif if (q(in(2,1)+1,k-1).GT.grnd) then q2 = q(in(2,1)+1,k-1)-d(in(2,1)+1,k-1) else q2 = 0.0 endif qki1=f(h1(in(2,1)),h1(in(2,1)+1) & ,q1 & ,q2 & ,hh1(out(2,1))) c write(*,*)'i=',i,'k=',k,'qki1=',qki1,'q=', c & q(in(2,1),k-1),',',d(in(2,1),k-1),',', c & q(in(2,1)+1,k-1),',',d(in(2,1)+1,k-1) x2(i,1,1)=f(h2(k-1),h2(k),uki1,uki,hh2(i)) x2(i,2,1)=f(h2(k-1),h2(k),vki1,vki,hh2(i)) x2(i,3,1)=f(h2(k-1),h2(k),qki1,qki,hh2(i)) c write(*,*)'x2=',x2(i,3,1) go to 111 end if end do 111 continue do 222 i=1,nn1 ! BC for Y1 and Y2 boundaries do k=in(1,1), in(2,1)+1 if(h1(k).GE.hh1(i).AND.h1(k-1).LT.hh1(i)) then c........... Y1 boundary uki=f(h2(in(3,1)-1),h2(in(3,1)),u(k,in(3,1)-1) & ,u(k,in(3,1)),hh2(out(3,1))) vki=f(h2(in(3,1)-1),h2(in(3,1)),v(k,in(3,1)-1) & ,v(k,in(3,1)),hh2(out(3,1))) if (q(k,in(3,1)-1).GT.grnd) then q1 = q(k,in(3,1)-1)-d(k,in(3,1)-1) else q1 = 0.0 endif if (q(k,in(3,1)).GT.grnd) then q2 = q(k,in(3,1))-d(k,in(3,1)) else q2 = 0.0 endif qki=f(h2(in(3,1)-1),h2(in(3,1)) & ,q1 & ,q2,hh2(out(3,1))) uki1=f(h2(in(3,1)-1),h2(in(3,1)) & ,u(k-1,in(3,1)-1),u(k-1,in(3,1)),hh2(out(3,1))) vki1=f(h2(in(3,1)-1),h2(in(3,1)) & ,v(k-1,in(3,1)-1),v(k-1,in(3,1)),hh2(out(3,1))) if (q(k-1,in(3,1)-1).GT.grnd) then q1 = q(k-1,in(3,1)-1)-d(k-1,in(3,1)-1) else q1 = 0.0 endif if (q(k-1,in(3,1)).GT.grnd) then q2 = q(k-1,in(3,1))-d(k-1,in(3,1)) else q2 = 0.0 endif qki1=f(h2(in(3,1)-1),h2(in(3,1)) & ,q1 & ,q2,hh2(out(3,1))) y1(i,1,1)=f(h1(k-1),h1(k),uki1,uki,hh1(i)) y1(i,2,1)=f(h1(k-1),h1(k),vki1,vki,hh1(i)) y1(i,3,1)=f(h1(k-1),h1(k),qki1,qki,hh1(i)) c........... Y2 boundary uki=f(h2(in(4,1)),h2(in(4,1)+1),u(k,in(4,1)) & ,u(k,in(4,1)+1),hh2(out(4,1))) vki=f(h2(in(4,1)),h2(in(4,1)+1),v(k,in(4,1)) & ,v(k,in(4,1)+1),hh2(out(4,1))) if (q(k,in(4,1)).GT.grnd) then q1 = q(k,in(4,1))-d(k,in(4,1)) else q1 = 0.0 endif if (q(k,in(4,1)+1).GT.grnd) then q2 = q(k,in(4,1)+1)-d(k,in(4,1)+1) else q2 = 0.0 endif qki=f(h2(in(4,1)),h2(in(4,1)+1) & ,q1 & ,q2,hh2(out(4,1))) uki1=f(h2(in(4,1)),h2(in(4,1)+1) & ,u(k-1,in(4,1)),u(k-1,in(4,1)+1),hh2(out(4,1))) vki1=f(h2(in(4,1)),h2(in(4,1)+1) & ,v(k-1,in(4,1)),v(k-1,in(4,1)+1),hh2(out(4,1))) if (q(k-1,in(4,1)).GT.grnd) then q1 = q(k-1,in(4,1))-d(k-1,in(4,1)) else q1 = 0.0 endif if (q(k-1,in(4,1)+1).GT.grnd) then q2 = q(k-1,in(4,1)+1)-d(k-1,in(4,1)+1) else q2 = 0.0 endif qki1=f(h2(in(4,1)),h2(in(4,1)+1) & ,q1 & ,q2 & ,hh2(out(4,1))) y2(i,1,1)=f(h1(k-1),h1(k),uki1,uki,hh1(i)) y2(i,2,1)=f(h1(k-1),h1(k),vki1,vki,hh1(i)) y2(i,3,1)=f(h1(k-1),h1(k),qki1,qki,hh1(i)) go to 222 end if end do 222 continue return end