[ncl-talk] iteration over files

Steeven Paul Yerraguntla steevenpaul at gmail.com
Mon Feb 23 21:56:16 MST 2015


Dear NCL users,
          I wanted to convert number of OLR hdf(.h5) files to netcdf files
and to get it done i used the following script and facing error at the line
marked in the following script. I could not make out how to solve it.
Please help me in solving out it.  Thanks in advance.

=================================================================
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
  diri = "./"
  diro = "./"

  fili = systemfunc("cd "+diri+" ; ls *.h5")
  nfil = dimsizes(fili)
  print("nfil="+nfil)

  do nf=0,nfil-1
     print("===========================")
    f    = addfile(diri+fili(nf), "r")

     print("---")
     fbase = str_get_field(fili(nf),1,".")
     print("fbase="+fbase)

     diro = "./"
     filo = fbase+".nc"
     ptho = diro+filo

     system("/bin/rm -f "+ptho) ; remove any pre-existing file
     ncdf = addfile(ptho ,"c")  ; open output netCDF file

                                          ; create global attributes of the
file
     fAtt               = True            ; assign file attributes
     fAtt at title         = "NCL: H5 to netCDF"
     fAtt at source        = "MOSDAC: Meteorological & Oceanographic Satellite
Data Archival Center (India)"
     fAtt at source_file   =  fili(nf)
     fAtt at Conventions   = "None"
     fAtt at creation_date = systemfunc ("date")
     fileattdef( ncdf, fAtt )            ; copy file attributes

    *ncdf->OLR = OLR1     <==============  This is where error is occuring*
  end do
 end
=====================================
*Error message as follows:*

(0) nfil=31
(0) ===========================
(0) ---
(0) fbase=K1VHR_05OCT2013_DAILY_L03_OLR
fatal:Variable (OLR1) is undefined
fatal:["Execute.c":7743]:Execute: Error occurred at or near line 41 in file
nfiles_conversion_h5_to_nc.ncl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150224/17271670/attachment.html 


More information about the ncl-talk mailing list