c *********************************************************************** subroutine interdp_limits ( yy,zz,m, i1,i2, y,z,n, j1,j2, opt) c Interpolation soubroutine. c Returns values between indexes i1 & i2, donde 1 =< i1 =< i2 =< m c Solo usan los indices de los inputs entre j1,j2, 1 =< j1 =< j2 =< n c Input values: y(n) , z(n) (solo se usan los valores entre j1,j2) c zz(m) (solo se necesita entre i1,i2) c Output values: yy(m) (solo se calculan entre i1,i2) c Options: opt=1 -> lineal ,, opt=2 -> logarithmic c Difference with interdp: c here interpolation proceeds between indexes i1,i2 only c if i1=1 & i2=m, both subroutines are exactly the same c thus previous calls to interdp or interdp2 could be easily replaced c JAN 98 MALV Version for mz1d c jul 2011 malv+fgg Adapted to LMD-MGCM c *********************************************************************** implicit none ! Arguments integer n,m ! I. Dimensions integer i1, i2, j1, j2, opt ! I real*8 zz(m),yy(m) ! O real*8 z(n),y(n) ! I ! Local variables integer i,j real*8 zmin,zzmin,zmax,zzmax c ******************************* ! type *, ' d interpolating ' call mindp_limits (z,n,zmin, j1,j2) call mindp_limits (zz,m,zzmin, i1,i2) call maxdp_limits (z,n,zmax, j1,j2) call maxdp_limits (zz,m,zzmax, i1,i2) if(zzmin.lt.zmin)then write (*,*) 'from d interp: new variable out of limits' write (*,*) zzmin,'must be .ge. ',zmin stop ! elseif(zzmax.gt.zmax)then ! type *,'from interp: new variable out of limits' ! type *,zzmax, 'must be .le. ',zmax ! stop end if do 1,i=i1,i2 do 2,j=j1,j2-1 if(zz(i).ge.z(j).and.zz(i).lt.z(j+1)) goto 3 2 continue c in this case (zz(i2).eq.z(j2)) and j leaves the loop with j=j2-1+1=j2 if(opt.eq.1)then yy(i)=y(j2-1)+(y(j2)-y(j2-1))*(zz(i)-z(j2-1))/(z(j2)-z(j2-1)) elseif(opt.eq.2)then if(y(j2).eq.0.0d0.or.y(j2-1).eq.0.0d0)then yy(i)=0.0d0 else yy(i)=exp(log(y(j2-1))+log(y(j2)/y(j2-1))* @ (zz(i)-z(j2-1))/(z(j2)-z(j2-1))) end if else write (*,*) ' d interp : opt must be 1 or 2, opt= ',opt end if goto 1 3 continue if(opt.eq.1)then yy(i)=y(j)+(y(j+1)-y(j))*(zz(i)-z(j))/(z(j+1)-z(j)) ! type *, ' ' ! type *, ' z(j),z(j+1) =', z(j),z(j+1) ! type *, ' t(j),t(j+1) =', y(j),y(j+1) ! type *, ' zz, tt = ', zz(i), yy(i) elseif(opt.eq.2)then if(y(j+1).eq.0.0d0.or.y(j).eq.0.0d0)then yy(i)=0.0d0 else yy(i)=exp(log(y(j))+log(y(j+1)/y(j))* @ (zz(i)-z(j))/(z(j+1)-z(j))) end if else write (*,*) ' interp : opt must be 1 or 2, opt= ',opt end if 1 continue return end