Re: can a procedure in NCL receive variables from another NCL script?

From: Yi-Chih Huang <dscpln_at_nyahnyahspammersnyahnyah>
Date: Thu Dec 05 2013 - 18:10:13 MST

Dave,

    You are right. It was due to the parentheses I originally used in the
main script. Now I can transport three variables by function or procedure.

    Thank you very much,

           Yi-Chih

On Fri, Dec 6, 2013 at 3:12 AM, Dave Allured - NOAA Affiliate <
dave.allured@noaa.gov> wrote:

> Yi-Chih,
>
> You did not show the whole script this time, so I can not be sure. But I
> think the problem is that you must use square brackets, not parentheses, to
> access the elements of an NCL list. So just change the statements in the
> main program like this:
>
> dv_nmm = out[1]
>
> The syntax rules for both creating an NCL list type, and accessing the
> list elements, are different than ordinary NCL variables. Square brackets
> must be used in both places. Please refer back to the working example that
> I sent yesterday, also the reference manual.
>
> --Dave
>
> On Wed, Dec 4, 2013 at 10:26 PM, Yi-Chih Huang <dscpln@gmail.com> wrote:
>
>> Hello,
>>
>> Thanks much for the replies. I used function vShear_nmm to returns
>> three variables. In the function vShear_nmm the three variables seem to be
>> fine from printVarSummary as follows. But in the main NCL script the error
>> message "Subscript out of range, error in subscript #0" showed up at
>> "script dv_nmm = out(1)" (line 97). Then how can I fix the error?
>>
>> Many thanks,
>>
>> Yi-Chih
>>
>> fatal:["NclMultiDVallistData.c":306]:MultiDVal_list_ReadSection:
>> Subscript out of range, error in subscript #0
>> fatal:An error occurred reading out
>> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 97 in
>> file vShear.ncl
>>
>> ######
>> out = vShear_nmm ()
>> printVarSummary(out)
>> du_nmm = out(0)
>> dv_nmm = out(1)
>> duy_nmm= out(2)
>> printVarSummary(du_nmm)
>> printVarSummary(dv_nmm)
>> printVarSummary(duy_nmm)
>>
>> ######
>> Variable: du_nmm
>> Type: float
>> Total Size: 321152 bytes
>> 80288 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [lat | 193] x [lon | 416]
>> Coordinates:
>> lat: [-30..30]
>> lon: [30.31246..159.9998]
>> Number Of Attributes: 13
>> _FillValue : 1e+20
>> initial_time : 02/05/2006 (00:00)
>> model : Climate Data Assimilation System (CDAS)
>> parameter_number : 33
>> parameter_table_version : 2
>> gds_grid_type : 0
>> level_indicator : 100
>> units : m/s
>> long_name : u-component of wind
>> center : US National Weather Service - NCEP (WMC)
>> lv_ISBL1 : 850
>> average_op_ncl : dim_avg_n over dimension(s): year
>> DataFreq : Monthly
>>
>> Variable: dv_nmm
>> Type: float
>> Total Size: 321152 bytes
>> 80288 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [lat | 193] x [lon | 416]
>> Coordinates:
>> lat: [-30..30]
>> lon: [30.31246..159.9998]
>> Number Of Attributes: 13
>> _FillValue : 1e+20
>> initial_time : 02/05/2006 (00:00)
>> model : Climate Data Assimilation System (CDAS)
>> parameter_number : 34
>> parameter_table_version : 2
>> gds_grid_type : 0
>> level_indicator : 100
>> units : m/s
>> long_name : v-component of wind
>> center : US National Weather Service - NCEP (WMC)
>> lv_ISBL1 : 850
>> average_op_ncl : dim_avg_n over dimension(s): year
>> DataFreq : Monthly
>>
>> Variable: duy_nmm
>> Type: float
>> Total Size: 772 bytes
>> 193 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [lat | 193]
>> Coordinates:
>> lat: [-30..30]
>> Number Of Attributes: 13
>> DataFreq : Monthly
>> average_op_ncl : dim_avg_n over dimension(s): lon
>> lv_ISBL1 : 850
>> center : US National Weather Service - NCEP (WMC)
>> long_name : u-component of wind
>> units : m/s
>> level_indicator : 100
>> gds_grid_type : 0
>> parameter_table_version : 2
>> parameter_number : 33
>> model : Climate Data Assimilation System (CDAS)
>> initial_time : 02/05/2006 (00:00)
>> _FillValue : 1e+20
>>
>> Variable: lat
>> Type: float
>> Total Size: 772 bytes
>> 193 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [lat | 193]
>> Coordinates:
>> lat: [30..-30]
>> Number Of Attributes: 9
>> La1 : 90
>> Lo1 : 0
>> La2 : -90
>> Lo2 : -0.313
>> Di : 0.3124996
>> Dj : 0.3125
>> units : degrees_north
>> GridType : Cylindrical Equidistant Projection Grid
>> long_name : latitude
>> (0) a
>> (0) b
>>
>> Variable: out
>> Type: list <concat | fifo>
>> Total items: 3
>>
>> fatal:["NclMultiDVallistData.c":306]:MultiDVal_list_ReadSection:
>> Subscript out of range, error in subscript #0
>> fatal:An error occurred reading out
>> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 97 in
>> file vShear.ncl
>>
>>
>>
>> On Thu, Dec 5, 2013 at 12:32 PM, Dave Allured - NOAA Affiliate <
>> dave.allured@noaa.gov> wrote:
>>
>>> Rick et al,
>>>
>>> I just ran my demo with disparate data types within the same list. It
>>> works fine.
>>>
>>> --Dave
>>>
>>> On Wed, Dec 4, 2013 at 8:12 PM, <brownrig@ucar.edu> wrote:
>>> >
>>> > ... possibly the use of NCL's list-type in a function to return a
>>>
>>> > 3-element list of what you want. Caveat: I think the list type can
>>> > hold elements of disparate type, but I'm not certain offhand. If not,
>>> > this won't work.
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Dec 5 18:10:29 2013

This archive was generated by hypermail 2.1.8 : Fri Dec 13 2013 - 11:39:30 MST