Coordinate variable undefined (reading ERA-40 grib file)

From: Arlene Laing <laing_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 17 2010 - 10:18:52 MST

Hi folks,

I am getting the following error:

fatal:Variable (lat) is undefined

I am reading from era-40 grib files as shown in the script (excerpt
below). The dimensions are printed correctly and I assign names to
the dimensions (time, lat, lon). However when I assign the coordinate
variable (the "&"), the fatal error occurs.

The script excerpt and output are below.

Thanks in advance for your help.

Arlene

*************start script excerpt***********************

;--------------------------------------------------------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.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/shea_util.ncl"

;--------------------------------------------------------------
begin

dirin ="/project/amp/andrew/conflict/era40/"
dirout ="/project/amp/laing/conflict/era40/"

yyyymm = yyyymm_time(1970, 1970, "integer")
;print (yyyymm)
nmonths = dimsizes(yyyymm)

;--------------------------------------------------------------
; loop through specified years

do iyr = 0,nmonths-1,12
   yyyy= yyyymm(iyr)/100

; print (yyyy)
   yr = sprinti ("%4.0i",yyyy)

fieldin1="CP"
fieldin2="LSP"
fieldout="TOT_PRCP"

field1 =fieldin1+"_GDS4_SFC"
field2 =fieldin2+"_GDS4_SFC"

;--------------------------------------------------------------
; READ AN ORDERED LIST OF FILES....

files=systemfunc("ls "+dirin+"e4oper.an.sfc.othr."+yr+"*")

;print(files)
f = addfiles(files+".gr","r")

print(f)

bigvarcp = f[:]->$field1$
bigvarlsp = f[:]->$field2$
bigvar = bigvarcp + bigvarlsp

printVarSummary(bigvar)
ndims = dimsizes(bigvar)
print(ndims)
;--------------------------------------------------------------
;rename coordinate arrays

bigvar!0="time"
bigvar!1="lat"
bigvar!2="lon"

  print("before latitude flip")
  printVarSummary(bigvar)

;-------------------------------------------------------------
; flip latitude to S to N (initially, N to S)
bigvar = bigvar(:,::-1,:)

  print("after latitude flip")
  printVarSummary(bigvar)

bigvar!0="time"
bigvar!1="lat"
bigvar!2="lon"

bigvar&lat = lat ;*******fatal error here****************
bigvar&lon = lon
bigvar@time = time

*************end script excerpt***********************

*************start output ***********************

Variable: f
Type: list
Total Size: 4 bytes
             1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:

Variable: bigvar
Type: float
Total Size: 299008000 bytes
             74752000 values
Number of Dimensions: 3
Dimensions and sizes: [1460] x [160] x [320]
Coordinates:
Number Of Attributes: 1
   _FillValue : 1e+20

Variable: ndims
Type: integer
Total Size: 12 bytes
             3 values
Number of Dimensions: 1
Dimensions and sizes: [3]
Coordinates:
(0) 1460
(1) 160
(2) 320
(0) before latitude flip

Variable: bigvar
Type: float
Total Size: 299008000 bytes
             74752000 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1460] x [lat | 160] x [lon | 320]
Coordinates:
Number Of Attributes: 1
   _FillValue : 1e+20
(0) after latitude flip

Variable: bigvar
Type: float
Total Size: 299008000 bytes
             74752000 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1460] x [lat | 160] x [lon | 320]
Coordinates:
Number Of Attributes: 1
   _FillValue : 1e+20
fatal:Variable (lat) is undefined
fatal:Execute: Error occurred at or near line 123 in file
rera40_grib2cdf_daily_rain.ncl
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 17 10:19:22 2010

This archive was generated by hypermail 2.1.8 : Wed Nov 17 2010 - 13:14:26 MST