[ncl-talk] NCL Built-in functions

Mary Haley haley at ucar.edu
Mon Apr 27 09:01:11 MDT 2015


If you download the source code from www.earthsystemgrid.org
(ncl_ncarg-6.3.0.tar.gz) and extract it somewhere:

tar -zxf ncl_ncarg-6.3.0.tar.gz

then you can see the bulk of the Fortran code used for the functions in
$NCARG/ni/src/lib/nfpfort, where $NCARG represents the top-level directory
of the NCL source tree.

You have to know where to look, though.  For example, let's say you want to
see the source code for the function "ezfftf". Here are the steps:

Search for "ezfftf_W" and "NhlErrorTypes together in $NCARG/ni/src/lib/nfp

cd $NCARG/ni/src/lib/nfp
grep ezfftf_W *.c | grep NhlErrorTypes

This will give you something like:

ezfftW.c:NhlErrorTypes ezfftf_W( void )
wrapper.c:extern NhlErrorTypes ezfftf_W(void);
wrapper.c:    NclRegisterFunc(ezfftf_W,args,"ezfftf",nargs);

Always ignore the "wrapper.c" file, because this is a giant C code that
registers all the built-in functions.  Instead, look at "ezfftfW.c" and
search for a line that looks like:

NhlErrorTypes ezfftf_W( void )

This is the C wrapper code for "ezfftf" that processes the NCL arguments
and calls the Fortran function.  You can find out what the Fortran file is
called either by looking at the top of this file, which has something like:

extern void NGCALLF(dezffti,DEZFFTI)(int*,double*);
extern void NGCALLF(dezfftf,DEZFFTF)(int*,double*,double*,double*,double*,
                                     double*);

or look in the "ezfftf_W" subroutine and search for "NGCALLF" which is the
call to the Fortran code. You'll see that it calls two Fortran routines:
dezffti and dezfftf.  These are the two functions you can then search for
in $NCARG/ni/src/lib/nfpfort:

cd $NCARG/ni/src/lib/nfpfort
grep -i dezfftf *.f

This will give you the following output:

ezfft_dp.f:      SUBROUTINE DEZFFTF(N,R,AZERO,A,B,WSAVE)
finfo.f:      CALL DEZFFTF(NPTS,X,ANOT,A,B,WRK)
specx_dp.f:      CALL DEZFFTF(NX,X,AZERO,CR,CI,SAVE)

Make sure you use the "-i" when you use "grep", because the Fortran routine
name could be in upper or lower case.

You can see from the above that the DEZFFTF routine is in ezfft_dp.f  (the
"dp" usually means "double precision", which means it was probably
converted from a single precision code.)

--Mary





On Sun, Apr 26, 2015 at 2:33 AM, Fangda Teng <tengfangda at gmail.com> wrote:

> Dear Everyone
>
> Is there any way to see the source code of the built-in functions in NCL?
>
> Thanks a lot!
>
> Fangda
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150427/29a73a99/attachment.html 


More information about the ncl-talk mailing list