Re: Syntax error at end of NCL script

From: Rick Brownrigg <brownrig_at_nyahnyahspammersnyahnyah>
Date: Tue Feb 25 2014 - 11:38:02 MST

Hi,

I believe its because NCL does not have a true if-elseif statement. So what you've written is:

if ( ) then
   …
else
    if (..) then
       …
    else
        if (…) then
           …

which would then need to be closed off with as many "end if"s as there are ifs:

if ( ) then
   …
else
    if (..) then
       …
    else
        if (…) then
           …
        end if
    end if
end if

On Feb 25, 2014, at 11:29 AM, "A.J. Eiserloh" <arthur.eiserloh@gmail.com> wrote:

> Hi,
>
> I am getting a strange syntax error at the end of my NCL script that I have never gotten before. It will not allow me to move forward with the script no matter how many times I try to modify it.
>
> I get the errors:
>
> fatal:syntax error: line 45 in file test1.ncl before or near \n
> end
> ---^
>
> fatal:error in statement
> fatal:syntax error: line -1 before or near
>
> ^
>
> fatal:error in statement
>
>
>
> Here is my script:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> begin
>
> runs = (/"ctrl","sn1","n2","n3","3dvar_t1","3dvar_t2","3dvar_t3"/)
> nr = dimsizes(runs)
>
> ; 0 1 2 3 4 5 6 7 8 9 10 11 12
> sites = (/"czc","hld","lsn","rod","sth","str","ptv","wls"/) ;NORTH COAST
> ;
> ;sites = (/"ata","bbd","blu","cfx","cmn","cnh","fhl","gks","hys","ndn","ocr","ovl","spd"/) ;windward sierra (13)
>
> ns = dimsizes(sites)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ; GET REAL PRECIP
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> pp_real=new((/ns,139/),"float")
> s=0
>
> if (sites(s).eq. "ata".or."cmn".or."cnh".or."ocr") then
> col = 8
> else if (sites(s) .eq. "hld".or."lsn".or."ndn".or."wls") then
> col = 9
> else if (sites(s) .eq. "gks") then
> col = 11
> else if (sites(s) .eq. "sth".or."str") then
> col = 13
> else if (sites(s) .eq. "blu".or."spd") then
> col = 14
> else if (sites(s) .eq. "bbd".or."czc".or."fhl") then
> col = 15
> end if
>
> jd=333
> h=0
> filename = "/home/eiserloh/Research/AR/PSD/metar/"+sites(s)+"/"+sites(s)+"12"+tostring(jd)+"."+sprinti("%0.2i",h)+".m"
> data = readAsciiTable(filename,1,"string",0)
> print(data)
> dims = dimsizes(data)
> print(dims)
> end
>
>
>
> The end of my script looks fine. Would anyone happen know why it is telling me this?
> --
> Arthur J. Eiserloh, Jr.
> San Jose State University
> Graduate Student
> Dept. of Meteorology and Climate Science
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Feb 25 11:38:10 2014

This archive was generated by hypermail 2.1.8 : Mon Mar 03 2014 - 14:26:18 MST