[ncl-talk] Function in NCL

Md. Jalal Uddin dmjalal90 at gmail.com
Tue Aug 27 02:54:18 MDT 2019


Hi all,

I made a function in NCL that showed an error like *fatal:Undefined
identifier: (a) is undefined, can't continue.  The error line highlighted
in green color. Any suggestions would be appreciated.*

*Code:*

undef ("fftwavenumber")
function fftwavenumber (in,k1,k2)

; K1, k2 are high and low-frequency wave numbers.
; You can determine bandpass, lowpass, highpass filtering,
; and in is the input data time series according to your needs.

local in,p,a,b,f,k1,k2

begin
    N=sizeof(in)

   if mod(N,2).eq.0 then
         p=N/2     ; N even
   else
         p=(N-1)/2 ; N odd
   end if

pi=3.1416

do k=0,p-1
      a(k)=0
      b(k)=0

  do t=0,N-1
      a(k)=a(k)+(2/N)*( in(t)*cos(2*pi*k*t/N) )
      b(k)=b(k)+(2/N)*( in(t)*sin(2*pi*k*t/N) )
  end do
end do

do t=0,N-1
   do k=0,p-1
        f(k,t)=a(k)*cos(2*pi*k*t/N)+b(k)*sin(2*pi*k*t/N)
   end do
   return (sum(f(k1:k2,t)))
end do

end


Jalal
-- 
*Md. Jalal Uddin*
MSc in Applied Meteorology
Nanjing University of Information, Science and Technology, China
B.Sc. in Disaster Management (Hons.)
Patuakhali Science and Technology University, Bangladesh.
Cell: +8613260859092, +8801792052662
Web: www.dmjalal90.weebly.com
Facebook: jalal.hossen.39
LinkedIn: https://bd.linkedin.com/in/md-jalal-uddin-80a026b0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190827/d2ef3c94/attachment.html>


More information about the ncl-talk mailing list