[ncl-talk] NCL Issue: write_matrix() file output

Rick Brownrigg brownrig at ucar.edu
Mon Oct 23 13:34:58 MDT 2017


Hi,

I got an error when I ran your script as is:

fatal:_NclBuildArray: each element of a literal array must have the same
dimension sizes, at least one item doesn't
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 8 in file
ncl_help_ex.nc

If I change this line:

fmtHD = str_concat((/tostring(hd_dims),"f5.2"/))

which tries to define an array composed of two elements, one which is a 1D
array of two elements, the other a scalar (technically, a 1D array of one
element) to:

fmtHD = str_concat((/tostring(hd_dims(0)),tostring(hd_dims(1)),"f5.2"/))

Then the file gets written as expected

Hope that helps...
Rick

On Mon, Oct 23, 2017 at 11:51 AM, David Ross <rossdl2 at appstate.edu> wrote:

> Hello,
>
> I am a new user to NCL, at Appalachian State University in NC. Our
> research group is interested in exporting formatted tables of WRF output
> data into a standard ascii text file. I will use a simplified example
> matrix, as building the real one requires WRF output files and a
> complicated loop structure. My issue is specifically with the
> write_matrix() command.
>
> hd_array = generate_2d_array(20,20,-1,1,0,(/5,10/))
> hd_dims = dimsizes(hd_array)
>
> The matrix "hd_array" has been successfuly built and yields a nicely
> formatted matrix to the standard output (terminal) with the code below:
>
> fmtHD = str_concat((/tostring(hd_dims),"f5.2"/))
> write_matrix(hd_array,fmtHD,False)
>
> However, when the option is set to write the matrix to a text file, the
> file "example.txt" comes up empty even though the command executes without
> giving errors.
>
> What am I missing here?
>
> -David
>
>
>
>
> _______________________________________________
> 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/20171023/6666238f/attachment.html>


More information about the ncl-talk mailing list