[ncl-talk] write_matrix error

Rick Brownrigg brownrig at ucar.edu
Wed Dec 10 06:22:13 MST 2014


Hi,

I took a look at the fortran code in writematrix. I'm not sure exactly the
problem, but that section of code is handed a 16-bit integer array to
write, whereas you've provided it a formatting string for reals.  Are you
certain your "u" and "v" variables are of type float?


Rick

On Wed, Dec 10, 2014 at 1:13 AM, sima sima <simasima_64 at yahoo.com> wrote:

> Dear NCL talk
>
> I need to convert a netcdf file to text format.
> the netcdf file include 3d variebls in (time,latitude, longitude),
> here is my ncl script
>
> begin
>
> f=addfile("/home/sima/data/ECMWF_0.125_nc/
> netcdf-web224-20141210070054-17182-4152.nc","r")
>
> ;print("ino mikhoone" + lst(i))
>
> u=f->u10(:,:,:)
> v=f->v10(:,:,:)
> msl=f->msl(:,:,:)
> times =f->time ; get all times in the file
> ntimes = dimsizes(times)                 ; number of times in the file
>
> do it=0,  ntimes-1
>
>  print("Time " + times(it))
>   opt = True
>     opt at fout = "U.txt"
>     write_matrix (u(it,:,:), "1000f9.3", opt)
>
>     opt = True
>     opt at fout = "V.txt"
>     write_matrix (v(it,:,:), "1000f9.3", opt)
>
>  opt = True
>     opt at fout = "MSL.txt"
>     write_matrix (msl(it,:,:), "1000f9.3", opt)
>
> ;system("echo 'tstep  item layer'>> uv.txt")
>     system("cat U.txt >> uv.txt")
>     system("echo >> uv.txt")
> ;system("echo 'tstep  item layer'>> uv.txt")
>     system("cat V.txt >> uv.txt")
>     system("echo >> uv.txt")
>
>    system("cat MSL.txt >> uv.txt")
>     system("echo >> uv.txt")
>
> end do
> end
>
>
> but when I run he script I got:
>
> Copyright (C) 1995-2012 - All Rights Reserved
>  University Corporation for Atmospheric Research
>  NCAR Command Language Version 6.1.0-beta
>  The use of this software is governed by a License Agreement.
>  See http://www.ncl.ucar.edu/ for more details.
> (0)     Time 999312
> At line 333 of file writematrix.f (unit = 31, file = 'U.txt')
> Fortran runtime error: Expected REAL for item 2 in formatted transfer, got
> INTEGER
> (1000f9.3)
>      ^
>
> I always use this formating way to convert my grib. what's wrong??
> please help me to solve this?
>
> many thanks
>
> Sima
> _______________________________________________
> ncl-talk mailing list
> 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/20141210/e420b487/attachment.html 


More information about the ncl-talk mailing list