c *********************************************************************** subroutine intersp(yy,zz,m,y,z,n,opt) c interpolation soubroutine. input values: y(n) at z(n). c output values: yy(m) at zz(m). options: 1 -> lineal; 2 -> logarithmic c jul 2011 malv+fgg c *********************************************************************** implicit none integer n,m,i,j,opt real zz(m),yy(m),z(n),y(n) real zmin,zzmin,zmax,zzmax ! write(*,*) ' interpolating' call minsp(z,n,zmin) call minsp(zz,m,zzmin) call maxsp(z,n,zmax) call maxsp(zz,m,zzmax) if(zzmin.lt.zmin)then write(*,*) 'from interp: new variable out of limits' write(*,*) zzmin,'must be .ge. ',zmin stop ! elseif(zzmax.gt.zmax)then ! write(*,*)'from interp: new variable out of limits' ! write(*,*)zzmax, 'must be .le. ',zmax ! stop end if do 1,i=1,m do 2,j=1,n-1 if(zz(i).ge.z(j).and.zz(i).lt.z(j+1)) goto 3 2 continue c in this case (zz(m).ge.z(n)) and j leaves the loop with j=n-1+1=n if(opt.eq.1)then yy(i)=y(n-1)+(y(n)-y(n-1))*(zz(i)-z(n-1))/(z(n)-z(n-1)) elseif(opt.eq.2)then if(y(n).eq.0.0.or.y(n-1).eq.0.0)then yy(i)=0.0 else yy(i)=exp(log(y(n-1))+log(y(n)/y(n-1))* @ (zz(i)-z(n-1))/(z(n)-z(n-1))) end if else write(*,*)' from interp error: 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)) elseif(opt.eq.2)then if(y(j+1).eq.0.0.or.y(j).eq.0.0)then yy(i)=0.0 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(*,*)' from interp error: opt must be 1 or 2, opt= ',opt end if 1 continue return end