[ncl-talk] How to read a specific variable name

Will Hobbs will.hobbs at utas.edu.au
Tue Nov 29 17:30:44 MST 2016


Laura

When both reading and writing to netcdf, you can use ‘$’ to access a variable name from a string e.g.:

 field = “cldfrac”
 diag = f-> $field$

For file output:
 fo->$field$ = (/ diag /)

This is described in NCL reference manual : http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml#FileStringRef


Will


On 30/11/2016, 11:24 AM, "ncl-talk-bounces at ucar.edu on behalf of Laura Fowler" <ncl-talk-bounces at ucar.edu on behalf of laura at ucar.edu> wrote:

    Hello:

    I am trying the following command line:

    ncl 'filename="2621442.cldfrac.mp_thompson_aerosols.2011-01-31_18.00.00.nc"'
    'date="2011-01-31_18.00.00.nc"' 'field="cldfrac"'
    write.rectangular.toNETCDFs.ncl in which the variable cldfrac is the
    actual name of the variable I would liked to read.

    Inside the ncl script write.rectangular.toNETCDFs.ncl, how do I read
    that variable using the generic variable field? I tried something like
    diag = f->"field" and other combinations bu that did not work.

    When I write a new netcdf file out, how do I use
    ncdf->field = ....

    Looks like I always come up with a syntax error and have not been able
    to fix it.

    Thanks,
    Laura



    --
    !-------------------------------------------------------------------------------------------------------------
    Laura D. Fowler
    Mesoscale and Microscale Meteorology Division (MMM)
    National Center for Atmospheric Research
    P.O. Box 3000, Boulder CO 80307-3000

    e-mail: laura at ucar.edu
    phone: 303-497-1628

    !-------------------------------------------------------------------------------------------------------------
    _______________________________________________
    ncl-talk mailing list
    ncl-talk at ucar.edu
    List instructions, subscriber options, unsubscribe:
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk




University of Tasmania Electronic Communications Policy (December, 2014).
This email is confidential, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone outside the intended recipient organisation is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender. The views expressed in this email are not necessarily the views of the University of Tasmania, unless clearly intended otherwise.


More information about the ncl-talk mailing list