- 积分
- 1490
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-11-8
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
各位大神,在用ncl处理站点数据时写了条件语句,但是出了错,请教原因。
脚本如下:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
fname = ".../out.txt"
data = asciiread(fname,-1,"string")
;print(data)
; Count the number of fields, just to show it can be done.
nfields = str_fields_count(data(1)," ")
print("number of fields = " + nfields)
print("step1")
;
; Skip first row of "data" because it's just a header line.
;
; Use a space (" ") as a delimiter in str_get_field. The first
; field is field=1 (unlike str_get_cols, in which the first column
; is column=0).
;
mas= str_get_field(data(2::), 14," ")
fst= str_get_field(data(2::), 9," ")
print("step2")
if(mas.eq."FULL" .and. fst.eq."TMP" ) then
lat = stringtofloat(str_get_field(data(1::), 25," "))
lon = stringtofloat(str_get_field(data(1::), 26," "))
tfct = stringtofloat(str_get_field(data(1::), 29," "))
tobs = stringtofloat(str_get_field(data(1::), 30," "))
tb=tfct-tobs
alist = [/lat, lon, tb/]
write_table("out1.txt", "w", alist, "%16.2f %16.2f %16.2f")
end if
错误信息如下:
Copyright (C) 1995-2014 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.2.1
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
(0) number of fields = 31
(0) step1
(0) step2
fatal:Conditional statements (if and do while) require SCALAR logical values, see all and any functions
fatal:["Execute.c":8578]:Execute: Error occurred at or near line 48 in file minus.ncl
|
|