Re: fatal:syntax error: line -1 before or near .

From: Justin Traiteur <jtraite2_at_nyahnyahspammersnyahnyah>
Date: Mon Oct 18 2010 - 14:22:32 MDT

Dave,

That fixed the problem! It is funny how a seemingly innocuous line
makes all the difference.

thanks again,

Justin

Thank you too Mary!

On Oct 18, 2010, at 3:07 PM, Dave Allured wrote:

> This reminds me of a quirk I have seen occasionally when using a
> shell script as a driver for an NCL script. NCL may continue
> reading from "standard in" past the end of the script, and start
> processing an input stream that belongs to the shell script, as if
> that stream was additional NCL statements.
>
> The workaround is to simply add an "exit" statement as the very last
> physical line of the NCL script. This forces NCL to terminate at
> the proper time.
>
> I do not know whether this quirk is active in the current version of
> NCL. HTH.
>
> --Dave A.
> NOAA/PSD/CIRES
>
> On 10/18/2010 9:39 AM, Mary Haley wrote:
>> Justin,
>>
>> I don't see any problems with your NCL script, but I don't
>> understand this command in your shell script:
>>
>> setenv ncl
>>
>> I don't think this will hurt anything, but it shouldn't be needed.
>>
>> The error message says:
>>
>> fatal:syntax error: line -1 before or near .
>> Sounding_200806011400_NN.
>>
>> but I don't see any reference to this name in your NCL script.
>>
>> Try removing the "setenv ncl" line, and running your shell script
>> up to the point where it's about to call "ncl Bayesian.ncl". Then
>> cd to where "Bayesian.ncl" is and type
>>
>> ncl Bayesian.ncl
>>
>> on the UNIX command line. It want to rule out that something is
>> going on with your shell script.
>>
>> --Mary
>>
>>
>> On Oct 18, 2010, at 7:52 AM, Justin Traiteur wrote:
>>
>>>
>>>>
>>>> Hey Everyone,
>>>>
>>>> I apologize for this posting being so long but I believe that I
>>>> must inform you on what this code is actually doing before trying
>>>> to debug. I am currently running the single column WRF model for
>>>> ensembles. The WRF is an idealized version needing only input
>>>> sounding and soil profiles. I have written an NCL script that
>>>> interpolates the 90 m wind speed and writes is to a file named
>>>> 'test.txt'. In order to do all of the ensembles I have written a
>>>> shell script that reads the sounding time and date from another
>>>> directory and injests it into the WRF. Then it calls the NCL
>>>> script to write the wind speed to a file to be concatenated
>>>> together at the end of the ensemble run. This all seems to make
>>>> logical sense but unfortunately I keep getting an error from the
>>>> NCL script. The error is:
>>>>
>>>> [jtraite2@manabe BAYESIAN]$ ./script_ensrun_MN_DY.csh
>>>> Doing Sounding_200806011300_NN.txt
>>>> starting wrf task 0 of 1
>>>> starting wrf task 0 of 1
>>>> Copyright (C) 1995-2010 - All Rights Reserved
>>>> University Corporation for Atmospheric Research
>>>> NCAR Command Language Version 5.2.0
>>>> The use of this software is governed by a License Agreement.
>>>> See http://www.ncl.ucar.edu/ for more details.
>>>> fatal:syntax error: line -1 before or near .
>>>> Sounding_200806011400_NN.
>>>> -------------------------------------^
>>>>
>>>> fatal:error in statement
>>>> fatal:syntax error: line 0 before or near .
>>>> Sounding_200806011500_NN.
>>>> -------------------------------------^
>>>>
>>>> fatal:error in statement
>>>> fatal:syntax error: line 1 before or near .
>>>> Sounding_200806011600_NN.
>>>> -------------------------------------^
>>>>
>>>> fatal:error in statement
>>>> fatal:syntax error: line 2 before or near .
>>>> Sounding_200806011700_NN.
>>>> -------------------------------------^
>>>>
>>>> fatal:error in statement
>>>> fatal:syntax error: line 3 before or near .
>>>> Sounding_200806011800_NN.
>>>> -------------------------------------^
>>>>
>>>> fatal:error in statement
>>>> fatal:syntax error: line 4 before or near .
>>>> Sounding_200806011900_NN.
>>>> -------------------------------------^
>>>>
>>>>
>>>>
>>>> My NCL script is as follows and is named Bayesian.ncl
>>>>
>>>> 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"
>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl" ;
>>>> WRF_Times2Udunits_c
>>>>
>>>> begin
>>>> fili = "wrfout" ;
>>>> Filename
>>>> nc = ".nc"
>>>> f = addfile (fili+nc, "r")
>>>> it = 1
>>>> eta_i = ispan(1,14,1) ;
>>>> First 14 eta levels
>>>> z = wrf_user_getvar(f,"z",it) ;
>>>> Model height
>>>> zn = z(eta_i,0,0) ;
>>>> Only first 14 levs
>>>> u1 = f->U(it,eta_i,0,1) ;
>>>> U wind speed first model quadrant
>>>> u2 = f->U(it,eta_i,1,1) ;
>>>> U wind speed second model quadrant
>>>> v1 = f->V(it,eta_i,1,0) ;
>>>> V wind speed first model quadrant
>>>> v2 = f->V(it,eta_i,1,1) ;
>>>> V wind speed second model quadrant
>>>> u3 = (u1+u2)/2 ;
>>>> Calculate average between U grid points
>>>> v3 = (v1+v2)/2 ;
>>>> Calculate average between V grid points
>>>> spd = sqrt(u3*u3+v3*v3) ;
>>>> Calculate wind speed
>>>> ws90 = wrf_interp_1d(spd,zn,90) ;
>>>> Wind speed interpolation to 90m height
>>>> asciiwrite ("test.txt",ws90)
>>>> end
>>>>
>>>
>>> There is a carriage return after the end in the NCL code.
>>>> The shell script for running the ensembles through different
>>>> times is as follows:
>>>>
>>>> #!/bin/sh
>>>>
>>>> # Read filenames
>>>> #cat StudyTimes_Revised_13_22Z.txt | while read fname
>>>> cat StudyTimes.txt | while read fname
>>>>
>>>> do
>>>> echo "Doing $fname"
>>>>
>>>> # Extract date& time information from filename
>>>> year=`expr substr $fname 1 4`
>>>> mnth=`expr substr $fname 5 2`
>>>> date=`expr substr $fname 7 2`
>>>> strtime=`expr substr $fname 8 2`
>>>> endtime=`expr $strtime + 1`
>>>>
>>>> cat>> namelist_mid<< EOF
>>>> start_year = $year,
>>>> start_month = $mnth,
>>>> start_day = $date,
>>>> start_hour = $strtime,
>>>> start_minute = 00,
>>>> start_second = 00,
>>>> end_year = $year,
>>>> end_month = $mnth,
>>>> end_day = $date,
>>>> end_hour = $endtime,
>>>> end_minute = 00,
>>>> end_second = 00,
>>>> EOF
>>>>
>>>> mv namelist_mid ..
>>>> # Control run
>>>> cd ../../../../../Analysis/Sounding_Soil/Ensemble/
>>>> cp -f Sounding_$year$mnth$date${strtime}00_NN.txt
>>>> input_sounding
>>>> cp -f Soil_$year$mnth$date${strtime}00_NN.txt input_soil
>>>> mv input* ../../../WRF/WRFV3/test/em_scm_xy/
>>>> cd ../../../WRF/WRFV3/test/em_scm_xy/
>>>> cat namelist_start namelist_mid namelist_end>>
>>>> namelist.input
>>>> ./ideal.exe
>>>> ./wrf.exe
>>>> rm rsl*
>>>> cp wrfout* wrfout
>>>> mv wrfout ./BAYESIAN/
>>>> rm wrfout*
>>>> rm wrfinp*
>>>> rm namelist.output
>>>> rm -fr namelist.input
>>>> rm -fr namelist.output
>>>> cd ./BAYESIAN/
>>>> # Write interpolated output to ws90-01.txt
>>>> setenv ncl
>>>> ncl Bayesian.ncl
>>>> cp test.txt ws90-01.txt
>>>> rm test.txt
>>>> # Remove namelist_mid otherwise it will keep on getting appended
>>>> cd ..
>>>> rm -fr namelist_mid
>>>> cd ./BAYESIAN/
>>>> cat ws90*>> Out$year$mnth$date${strtime}.txt
>>>> rm -f ws90-*.txt
>>>> done
>>>>
>>>> The Study_Times.txt file the shell script calls to is as follows.
>>>>
>>>> Sounding_200806011300_NN.txt
>>>> Sounding_200806011400_NN.txt
>>>> Sounding_200806011500_NN.txt
>>>>
>>>> -----------------------------------------------------------------------
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> ~
>>>> 25,0
>>>> -1 All
>>>>
>>>
>>> _______________________________________________
>>> 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
> _______________________________________________
> 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 Mon Oct 18 14:20:06 2010

This archive was generated by hypermail 2.1.8 : Tue Oct 19 2010 - 14:38:00 MDT