Re: How to read in different types of input

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Dec 23 2009 - 11:07:01 MST

On the command line:
    'var_type=(/"TS","PS",.../)'

In the script:
     nVar = dimsizes(var_type)

     do nv=0,nVar-1
          rank = dimsizes( getvardimsizes( a, var_type(nv)) )
          if (rank.eq.3)
              x = a->$var_type(nv)$(0,:,:)
          end if

          if (rank.eq.4)
              x = a->$var_type(nv)$(0,:,:,0)
          end if

; ..... code ......

          delete(x) ; rank may change with next variable
     end do

====

On 12/23/2009 12:03 AM, Wee-Beng Tay wrote:
> Hi,
>
> I have a netcdf file with variables like temperature, pressure,
> velocity etc
>
> I want ncl to read in different types of input at different times
> through command line and then plot them out.
>
> It's simple if I only need to plot 1 variables. In that case, I'll use
> at the command line:
>
> e.g. ncl abc.ncl 'var_type="temperature"'
>
> if ((var_type) .eq. "temperature") then
>
> phi = a->TS(0,:,:) ; read temperature
>
> end if
>
> if ((var_type) .eq. "pressure") then
>
> phi = a->PS(0,:,:) ; read pressure
>
> end if
>
> However the problem arises when I need to plot more than 1 variable,
> maybe 3 to 4. Supposed there's 4 variables and there's
> phi1,phi2,phi3,phi4. How should I write the code to read in the
> correct variables?
>
> Thanks again!
>
> Wee-Beng
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate&  Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Dec 23 11:08:16 2009

This archive was generated by hypermail 2.1.8 : Tue Dec 29 2009 - 10:29:16 MST