<div dir="ltr"><div class="gmail_default" style="font-size:small">If you download the source code from <a href="http://www.earthsystemgrid.org">www.earthsystemgrid.org</a> (ncl_ncarg-6.3.0.tar.gz) and extract it somewhere:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">tar -zxf ncl_ncarg-6.3.0.tar.gz</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">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.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">You have to know where to look, though.  For example, let&#39;s say you want to see the source code for the function &quot;ezfftf&quot;. Here are the steps:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style>Search for &quot;ezfftf_W&quot; and &quot;NhlErrorTypes together in $NCARG/ni/src/lib/nfp<br></div><div class="gmail_default" style><br><font face="monospace, monospace">cd $NCARG/ni/src/lib/nfp<br>grep ezfftf_W *.c | grep NhlErrorTypes</font></div><div class="gmail_default" style><br>This will give you something like:</div><div class="gmail_default" style><br></div><div class="gmail_default" style><div class="gmail_default"><font face="monospace, monospace">ezfftW.c:NhlErrorTypes ezfftf_W( void )</font></div><div class="gmail_default"><font face="monospace, monospace">wrapper.c:extern NhlErrorTypes ezfftf_W(void);</font></div><div class="gmail_default"><font face="monospace, monospace">wrapper.c:    NclRegisterFunc(ezfftf_W,args,&quot;ezfftf&quot;,nargs);</font></div><div class="gmail_default"><br></div><div class="gmail_default">Always ignore the &quot;wrapper.c&quot; file, because this is a giant C code that registers all the built-in functions.  Instead, look at &quot;ezfftfW.c&quot; and search for a line that looks like:</div><div class="gmail_default"><br></div><div class="gmail_default"><div class="gmail_default"><span style="font-family:monospace,monospace">NhlErrorTypes ezfftf_W( void )</span><br></div><div><br></div><div>This is the C wrapper code for &quot;ezfftf&quot; 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:</div><div><br></div><div><div><font face="monospace, monospace">extern void NGCALLF(dezffti,DEZFFTI)(int*,double*);</font></div><div><font face="monospace, monospace">extern void NGCALLF(dezfftf,DEZFFTF)(int*,double*,double*,double*,double*,</font></div><div><font face="monospace, monospace">                                     double*);</font></div></div><div><br></div><div>or look in the &quot;ezfftf_W&quot; subroutine and search for &quot;NGCALLF&quot; which is the call to the Fortran code. You&#39;ll see that it calls two Fortran routines: <font face="monospace, monospace">dezffti</font> and <font face="monospace, monospace">dezfftf</font>.  These are the two functions you can then search for in <font face="monospace, monospace">$NCARG/ni/src/lib/nfpfort</font>:</div><div><br></div><div><div><font face="monospace, monospace">cd $NCARG/ni/src/lib/nfpfort</font></div><div><font face="monospace, monospace">grep -i dezfftf *.f</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">This will give you the following output:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">ezfft_dp.f:      SUBROUTINE DEZFFTF(N,R,AZERO,A,B,WSAVE)</font></div><div><font face="monospace, monospace">finfo.f:      CALL DEZFFTF(NPTS,X,ANOT,A,B,WRK)</font></div><div><font face="monospace, monospace">specx_dp.f:      CALL DEZFFTF(NX,X,AZERO,CR,CI,SAVE)</font></div></div><div><br></div><div>Make sure you use the &quot;-i&quot; when you use &quot;grep&quot;, because the Fortran routine name could be in upper or lower case.</div><div><br></div><div>You can see from the above that the DEZFFTF routine is in ezfft_dp.f  (the &quot;dp&quot; usually means &quot;double precision&quot;, which means it was probably converted from a single precision code.)</div><div><br></div><div>--Mary</div><div><br></div><div><br></div></div><div class="gmail_default"><br></div><div class="gmail_default"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 26, 2015 at 2:33 AM, Fangda Teng <span dir="ltr">&lt;<a href="mailto:tengfangda@gmail.com" target="_blank">tengfangda@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear Everyone<div><br></div><div>Is there any way to see the source code of the built-in functions in NCL?</div><div><br></div><div>Thanks a lot!</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Fangda</div></font></span></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>