[ncl-talk] About how to use a variable in str_get_filed

Tao Lu hakufu.asano at gmail.com
Wed Dec 7 18:14:09 MST 2016


Hello Shea

Thank you for your reminding.
I have solved this problem.

Here is my code:
begin
;file = (/"bst_kilo_2015", "bst_etau_2015"/)
; read ascii data------------------------------------------------------
lines = asciiread("./bst_etau_2015",-1,"string")

; read  data
delimiter = " "
international_no = str_get_field(lines(0),2, delimiter)
number_of_dataline_str = str_get_field(lines(0),3, delimiter)
number_of_dataline = toint(number_of_dataline_str)
name = str_get_field(lines(0),8, delimiter)
date = str_get_field(lines(1:number_of_dataline+1), 1, delimiter)

Here is my data form:
66666 1517  046 0017 1517 1 0                 KILO              20151013
15090118 002 7 237 1801  945     090     20060 0040 20150 0100
15090200 002 5 240 1798  950     080     90060 0060 10150 0120
15090206 002 5 244 1794  950     080     90060 0060 80150 0120
15090212 002 5 246 1791  965     070     90060 0060 80150 0120
15090218 002 5 246 1785  965     070     80070 0050 70150 0120
15090300 002 5 247 1782  965     070     80070 0050 90150 0150
15090306 002 5 246 1781  965     070     80070 0050 90150 0150
15090312 002 5 244 1777  965     070     80070 0050 90150 0150
15090318 002 5 241 1775  965     070     80070 0050 90150 0150
15090400 002 5 238 1771  970     065     70100 0060 70180 0120
15090406 002 5 236 1766  970     065     70100 0060 70200 0120

When I run the script, such error appeared:
fatal:Subscript out of range, error in subscript #0
fatal:An error occurred reading lines
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 19 in file
best_track_plot.ncl

The problem is at "number_of_dataline+1".

Thank you.

Tao



On Wed, Dec 7, 2016 at 11:25 PM, Dennis Shea <shea at ucar.edu> wrote:

> Not enough information:  What was the error message?
>
> Also, including the, say, first 5 lines of the field being read would be
> useful.
>
> Regards
>
>
>
>
> On Wed, Dec 7, 2016 at 3:56 AM, Tao Lu <hakufu.asano at gmail.com> wrote:
>
>> Dear ncl-talk
>>
>> I wrote some codes to use str_get_field()
>> ------------------------------------------------------------
>> ----------------------------------------------------------
>> number_of_dataline = toint(number_of_dataline_str)
>> print (number_of_dataline)
>> name = str_get_field(lines(0),8, delimiter)
>> date = str_get_field(lines(1:number_of_dataline+1), 1, delimiter)
>> ------------------------------------------------------------
>> -----------------------------------------------------------
>> Error occurred at "date".
>>
>> Could you give me some advice?
>>
>> Yours sincerely,
>> Tao
>>
>> --
>> ******************************************************
>> 盧 涛 (ル タオ) 修士課程2年
>>
>> 〒112-8551 東京都文京区春日1-13-27
>>
>> 中央大学理工学研究科都市環境学専攻
>>
>> 河川・水文研究室(山田正教授)
>>
>>
>> TEL: 03-3817-3406;   Phone: 070-2188-7509
>> Email1: hakufu.asano at gmail.com <mail%3Amet.yamos at gmail.com>
>> Email2: lutao at civil.chuo-u.ac.jp <mail%3Ayamoto at civil.chuo-u.ac.jp>
>> *******************************************************
>> ******************************************************
>> Tao Lu    (M. Eng)
>> Laboratory of River Engineering and Hydrology,
>> Dept. of Civil and Environmental Engineering,
>> Graduate School of Science and Engineering,
>> Chuo University
>>
>> 1-13-27,Kasuga,Bunkyo-ku,Tokyo
>> 112-8551, Japan
>> TEL: 03-3817-1805;   Phone: 070-2188-7509
>> Email1: hakufu.asano at gmail.com <mail%3Amet.yamos at gmail.com>
>> Email2: lutao at civil.chuo-u.ac.jp <mail%3Ayamoto at civil.chuo-u.ac.jp>
>> *****************************************************
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>


-- 
******************************************************
盧 涛 (ル タオ) 修士課程2年

〒112-8551 東京都文京区春日1-13-27

中央大学理工学研究科都市環境学専攻

河川・水文研究室(山田正教授)


TEL: 03-3817-3406;   Phone: 070-2188-7509
Email1: hakufu.asano at gmail.com <mail%3Amet.yamos at gmail.com>
Email2: lutao at civil.chuo-u.ac.jp <mail%3Ayamoto at civil.chuo-u.ac.jp>
*******************************************************
******************************************************
Tao Lu    (M. Eng)
Laboratory of River Engineering and Hydrology,
Dept. of Civil and Environmental Engineering,
Graduate School of Science and Engineering,
Chuo University

1-13-27,Kasuga,Bunkyo-ku,Tokyo
112-8551, Japan
TEL: 03-3817-1805;   Phone: 070-2188-7509
Email1: hakufu.asano at gmail.com <mail%3Amet.yamos at gmail.com>
Email2: lutao at civil.chuo-u.ac.jp <mail%3Ayamoto at civil.chuo-u.ac.jp>
*****************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161208/1e41f8cd/attachment.html 


More information about the ncl-talk mailing list