[ncl-talk] write_matrix error

sima sima simasima_64 at yahoo.com
Wed Dec 10 01:13:19 MST 2014


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


More information about the ncl-talk mailing list