make the script faster

From: Debasish <debasish_at_nyahnyahspammersnyahnyah>
Date: Tue Oct 12 2010 - 15:46:57 MDT

Hello!

I am trying to convert netcdf to ascii file. I would like to know is there anyway to make my attached NCL program faster.

Thanks

Debasish

The dimension of the file and NCL program are attached below:
==============================================
dimensions:
       cell_index = 451 ;
       date_length = 16 ;
       time = UNLIMITED ; // (10988 currently)
variables:
       float T(time, cell_index) ;
               T:units = "K" ;
       int x-index(cell_index) ;
       int y-index(cell_index) ;
       char time(time, date_length) ;

;===============================================
;NCL PROGRAM
;===============================================
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"
begin
 ;************************************
 ; create pointer to several types of
 ; files. Note the syntax is the same
 ;************************************
 f = addfile("Temp_1970_01_01_00_00.nc","r")
x = f->T
iindex = f->$"x-index"$
jindex= f->$"y-index"$

printVarSummary(x)

  dimx = dimsizes(x)
  ntim = dimx(0)
  niindex = dimx(1)

  npts = 451 ; total number of grid points

  fName = "foo.txt"
  data = new( npts, "string")

  npt = -1
  do nl=0,niindex-1

       print(npt)
       npt = npt + 1
       data(npt) = sprinti("%0.5i", (npt+1) )
       data(npt) = data(npt) + sprintf("%7.1i ",iindex(nl))
       data(npt) = data(npt) + sprintf("%7.1i ",jindex(nl))

      do nt=0,ntim-1
         data(npt) = data(npt) + sprintf("%10.3f ", x(nt,nl))
      end do
  end do

  asciiwrite (fName , data)

end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Oct 12 15:49:11 2010

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