Running NCL through Bash script

From: John Overton <jd3_at_nyahnyahspammersnyahnyah>
Date: Wed, 30 Jan 2008 15:47:29 -0500

I am trying to run an ncl script from a bash script and am getting some
strange results, so I thought I would ask the community for some help.
Here is the command as I would run it from the command line:
-bash-3.00$ ncl 'domain="d01"' 'resDate="2008012912"'
'wrfFile="wrfout_d01_2008-01-29_13_00_00"' 'postFile="WRFPRS_d01.01"'
'shour="H01"' 200GL60Labels.ncl

Here is the section of my bash script that calls ncl:

for file in *.ncl ; do
      ncl domain=\"$4\" resDate=\"$1\" wrfFile=\"$2\" postFile=\"$3\"
shour=\"H$5\" $file
      echo After Running NCL
      exit 0
      #$WRF_VIS_HOME/bin/createOne7Layer $1 $4 $5
      #exit 0
      # run swfcombine
done

When I first started using NCL from bash I realized I had to leave off
the single quotes surrounding the <parameter name>=<parameter value>
term, as the shell stripped them off. Previously I was running a
command similar to the above only with 2 command-line arguments instead
of 5. I had no problems in execution.

When I run this command from the command-line there are no errors. When
I run it from my bash script, however, here is the resulting output:
 Copyright (C) 1995-2007 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 4.3.1
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.
warning:NclGRIB: Unknown grib parameter number detected (154, center 7,
table ve
rsion 130 grib record 387), using default variable name (VAR_154)
warning:NclGRIB: Unknown grib parameter number detected (171, center 7,
table ve
rsion 130 grib record 405), using default variable name (VAR_171)
warning:NclGRIB: Unknown grib parameter number detected (168, center 7,
table ve
rsion 129 grib record 416), using default variable name (VAR_168)
warning:NclGRIB: Unknown grib parameter number detected (169, center 7,
table ve
rsion 129 grib record 417), using default variable name (VAR_169)
(0) Added File
(0) Before Res
(0) Before Domain Equals
(0) After Plot
(0) After Delete
fatal:syntax error: line -1 before or near 01
01
-^

fatal:error in statement
fatal:syntax error: line 0 before or near 02
02
-^

fatal:error in statement
fatal:syntax error: line 1 before or near 03
03
-^

fatal:error in statement
fatal:syntax error: line 2 before or near 04
04
-^

fatal:error in statement
fatal:syntax error: line 3 before or near 05
05
-^

fatal:error in statement
fatal:syntax error: line 4 before or near 06
06
-^

fatal:error in statement
fatal:syntax error: line 5 before or near 07
07
-^

fatal:error in statement
fatal:syntax error: line 6 before or near 08
08
-^

fatal:error in statement
fatal:syntax error: line 7 before or near 09
09
-^

fatal:error in statement
fatal:syntax error: line 8 before or near 10
10
-^

fatal:error in statement
fatal:syntax error: line 9 before or near 11
11
-^

fatal:error in statement
fatal:syntax error: line 10 before or near 12
12
-^

fatal:error in statement
fatal:syntax error: line 11 before or near 13
13
-^

fatal:error in statement
fatal:syntax error: line 12 before or near 14
14
-^

fatal:error in statement
fatal:syntax error: line 13 before or near 15
15
-^

fatal:error in statement
fatal:syntax error: line 14 before or near 16
16
-^

fatal:error in statement
fatal:syntax error: line 15 before or near 17
17
-^

fatal:error in statement
fatal:syntax error: line 16 before or near 18
18
-^

fatal:error in statement
fatal:syntax error: line 17 before or near 19
19
-^

fatal:error in statement
fatal:syntax error: line 18 before or near 20
20
-^

fatal:error in statement
fatal:syntax error: line 19 before or near 21
21
-^

fatal:error in statement
fatal:syntax error: line 20 before or near 22
22
-^

fatal:error in statement
fatal:syntax error: line 21 before or near 23
23
-^

fatal:error in statement
fatal:syntax error: line 22 before or near 24
24
-^

fatal:error in statement
fatal:syntax error: line 23 before or near 25
25
-^

fatal:error in statement
fatal:syntax error: line 24 before or near 26
26
-^

fatal:error in statement
fatal:syntax error: line 25 before or near 27
27
-^

fatal:error in statement
fatal:syntax error: line 26 before or near 28
28
-^

fatal:error in statement
fatal:syntax error: line 27 before or near 29
29
-^

fatal:error in statement
fatal:syntax error: line 28 before or near 30
30
-^

fatal:error in statement
fatal:syntax error: line 29 before or near 31
31
-^

fatal:error in statement
fatal:syntax error: line 30 before or near 32
32
-^

fatal:error in statement
fatal:syntax error: line 31 before or near 33
33
-^

fatal:error in statement
fatal:syntax error: line 32 before or near 34
34
-^

fatal:error in statement
fatal:syntax error: line 33 before or near 35
35
-^

fatal:error in statement
fatal:syntax error: line 34 before or near 36
36
-^

fatal:error in statement
fatal:syntax error: line 35 before or near 37
37
-^

fatal:error in statement
fatal:syntax error: line 36 before or near 38
38
-^

fatal:error in statement
fatal:syntax error: line 37 before or near 39
39
-^

fatal:error in statement
fatal:syntax error: line 38 before or near 40
40
-^

fatal:error in statement
fatal:syntax error: line 39 before or near 41
41
-^

fatal:error in statement
fatal:syntax error: line 40 before or near 42
42
-^

fatal:error in statement
fatal:syntax error: line 41 before or near 43
43
-^

fatal:error in statement
fatal:syntax error: line 42 before or near 44
44
-^

fatal:error in statement
fatal:syntax error: line 43 before or near 45
45
-^

fatal:error in statement
fatal:syntax error: line 44 before or near 46
46
-^

fatal:error in statement
fatal:syntax error: line 45 before or near 47
47
-^

fatal:error in statement
fatal:syntax error: line 46 before or near 48
48
-^

fatal:error in statement
After Running NCL

The warnings about unknown grib parameter numbers are harmless.
The printouts:
0) Added File
(0) Before Res
(0) Before Domain Equals
(0) After Plot
(0) After Delete
are coming from inside the ncl script. "After Delete" is output at the
very end of the script.
The strange part are the 48 statements like this one:
fatal:syntax error: line -1 before or near 01
01
-^
They are being output AFTER all the work in the script is done, and
BEFORE the next line in the calling bash script is performed. The
"After Running NCL" comes from the calling bash script.

Below is a copy of the ncl script in question. Does anyone know where
these script lines are coming from? I've noticed in the past that ncl
creates tmp files. Am I doing something that creates a error filled
temp script? Any other ideas?

Thanks,
John Overton

;*************************************************
; WRF: near surface winds and total precipitation
;************************************************
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/wrf/WRF_contributed.ncl"
begin

          
           wks = gsn_open_wks("pdf"
,"../../layer/"+resDate+"/"+domain+"/"+shour+"/200GL60Labels")
          
        ;************************************************
        ; open file
        ; Read U10 and V10, Cumulus (rinc) and Non-cumulus (rainnc) prc
        ;************************************************
     
          
        f =
addfile("/data/hydromet/wrf/output/2.2/OPERATIONAL/"+resDate+"/"+postFile+".grb",
"r")
        print("Added File");
        geo = f->HGT_GDS3_ISBL(13,:,:) ; (Time,
south_north, west_east)

        lat2d = f->g3_lat_0(:,:)
        lon2d = f->g3_lon_1(:,:)
       
        geo_at_lat2d = lat2d
        geo_at_lon2d = lon2d

        geo_at_long_name = ""
        geo_at_units = ""
        geo_at_center = ""
        ;************************************************
        ; create plots: create colormap using named colors
        ;************************************************
                    ; ps,pdf,x11,ncgm,eps
    
          gsn_define_colormap(wks,"gsdtol") ; select color map

        ;************************************************
        ; create plots
        ;************************************************
        print("Before Res");
         
         
          res = True ; plot mods desired
        res_at_tiMainOn = False
        res_at_gsnBoxMargin = 0.0
       
          res_at_gsnSpreadColors = True ; use full range
of colormap
          res_at_cnFillOn = False ; color plot desired
          res_at_cnLinesOn = True ; turn off contour
lines
          res_at_cnLineLabelsOn = True ; turn off contour
labels
          res_at_cnMonoLineColor = True ;
          res_at_cnMonoLineThickness = True ;
          res_at_cnLevelSelectionMode = "AutomaticLevels"
          res_at_cnLineColor = "transparent"
       ;res_at_cnLineColors =
(/16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31/)

        res_at_tmXBBorderOn = False
        res_at_tmXBOn = False
        res_at_tmXTBorderOn = False
        res_at_tmXTOn = False
        res_at_tmYLBorderOn = False
        res_at_tmYLOn = False
        res_at_tmYRBorderOn = False
        res_at_tmYROn = False
       
        res_at_cnLineLabelPlacementMode = "Randomized"
        ;res_at_cnLineDashSegLenF
        res_at_cnLineLabelDensityF = .5
          res_at_cnLineThicknessF = 1.0
          res_at_cnLineDashSegLenF = .1
          res_at_cnLineLabelsOn = True
          res_at_cnLineLabelBackgroundColor = "black"
          res_at_cnLineLabelFontColor = "snow"
          res_at_cnLineLabelFontHeightF = 0.006
          res_at_cnLevelSpacingF = 60.0
        res_at_lgLineLabelsOn = False
          res_at_lbLabelBarOn = False
          res_at_lbLabelOn = False
          res_at_pmLabelBarDisplayMode = "NoCreate"
          res_at_pmLegendDisplayMode = "NoCreate"
          res_at_cnInfoLabelOn = False
          res_at_vpXF = 0.0
           res_at_vpYF = 1.0
           res_at_vpWidthF = 1.0
           res_at_vpHeightF = 1.0

     
        res_at_mpOutlineBoundarySets = "NoBoundaries"
        res_at_mpFillBoundarySets = "NoBoundaries"
        ;res_at_mpDataBaseVersion = "Ncarg4_1"
          ;res_at_mpDataSetName = "Earth..2"
   
    print("Before Domain Equals");
        if ( domain .eq. "d01" ) then
            print("Domain is D01")
            res_at_mpMaxLatF = 45.67379 ; zoom
in on map
              res_at_mpMinLatF = 24.76594
              res_at_mpMinLonF = -92.40985
              res_at_mpMaxLonF = -65.52133
          else
            res_at_mpMaxLatF = 40.2727 ; zoom
in on map
              res_at_mpMinLatF = 30.77704
              res_at_mpMinLonF = -85.83099
              res_at_mpMaxLonF = -74.1015
           end if
          
          plotu = gsn_csm_contour_map(wks,geo(:,:),res)
         
     print("After Plot");
        delete(res)
     
     print("After Delete");
end

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jan 30 2008 - 13:47:29 MST

This archive was generated by hypermail 2.2.0 : Tue Feb 05 2008 - 21:51:45 MST