[ncl-talk] Function return

Marston Johnston shejo284 at gmail.com
Sat Oct 14 01:42:49 MDT 2017


There is an error in your code:        var0 = new((/251/),float,1e+30

As a preference, I always find it best to use the default FillValues when creating arrays. Read up on missing values/fillvalues on the NCL wedpage.

 

There is nothing wrong with returning a list from a function, even if the dimensions are different. Why would the dimensions matter?

This doesn’t seem to be your problem. You have not provided enough information about your code and variable information (printVarSumary) to give a definite answer.

It seems you need to do some more debugging of your code yourself.

 

When defining functions, it is good practice to set the define the intrinsic variables as “local” as well as using the “undef” function. 

Using the same name for the variables inside and outside the function, if you are indeed using a function that is properly designed, can mask a bug in your code. 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Marston S. Ward, PhD

Department of Earth Sciences

University of Gothenburg, Sweden

Email: marston.johnston at gu.se

SkypeID: marston.johnston 

Phone: +46-31-7864901 

Only the fruitful thing is true!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

 

From: ncl-talk <ncl-talk-bounces at ucar.edu> on behalf of Prashanth Bhalachandran <prashanth.bhalachandran at gmail.com>
Date: Saturday, 14 October 2017 at 03:57
To: <ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] Function return

 

Hello, 

I have a quick question regarding returning of arrays from functions. 

 

In my code, I have two arrays var0 and var01 that I want to return from my function. Their dimensionalities are as follows: 



var0      = new((/251/),float,1e+30

var01     = new((/251,73/),float,1e+30)

     

 

At present, I am trying to return this using the command : 

 

return([/var0,var01/]) ; Note that the dimensions of var0 and var1 are different. 



As a result, in my wrapper script, when I receive the variables, it is becoming a confusing task. 



 wnout        = wn01(latvals,lonvals,lat1,lon1,speed)   

 var0         = wnout[0] 

 var1         = wnout[1]  



 The above return procedure is giving out an error since I don’t know how to define the dimensions of wnout. Is there any better way to return two arrays of varying dimensions in NCL? 



Thank you, 

Prashanth  

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171014/2b6b89de/attachment.html>


More information about the ncl-talk mailing list