<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>[1] I doubt it is the size of the ascii file. <br></div><div><br></div><div>[2] I tried the script on an available wrf file that had only one time dimension.</div><div><br></div><div>Variable: rh2<br>Dimensions and sizes: [Time | 1] x [south_north | 108] x [west_east | 114]</div><div><br></div><div>and the script worked fine. It put out 108 latiitudes and 1*114 Time/longitudes<br></div><div>---</div><div>You can add a print to <b>provide more information</b>. It will tell you when it failed. <br></div><div>Did it fail on the 1st iteration or later? Really, just saying it terminated provides little information.<br></div><div><br></div><div> wrftxt = new(nlat, "string")<br> wrftxt = ""<br><br> do nl=0,nlat-1<br></div><div> <br></div><div> do nt=0,ntim-1</div><div> <b>print("nl="+nl+"; nt="+nt)</b><br></div><div> do ml=0,mlon-1<br> wrftxt(nl) = wrftxt(nl) +sprintf("%9.2f", rh2(nt,nl,ml)) ; append to previous value<br> end do<br> end do<br><br> ----</div><div><b>If </b>it failed on the 1st iteration, I speculate that the underlying C-code has some string length limit.</div><div><span class="gmail-im">[Time | 673] x [south_north | 71] x [west_east | 82]</span></div><div><br></div><div>Each single string has 673*82*(nchar) where nchar is the length of each string.</div><div>So: "%9.2f" yields string lengths of 673*82*9= 496674 characters. That is a LONG string length.<br></div><div><br></div><div>Change "%9.2f" to "%6.2f" or "%5.1f" ... see if it works. Still, they are all LONG.<br></div><div><br></div><div> ---</div><div> Play with these</div><div><br></div><div> NTIM = 50 ; whatever</div><div> MLON = ???<br></div><div><div> do nt=0,NTIM <br></div><div> <b>print("nl="+nl+"; nt="+nt)</b><br></div><div> do ml=0,MLON</div></div><div><br></div><div>DO various combinations. That will provides some insight into the issue.</div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 3, 2019 at 4:53 AM Muhammad Omer Mughal <<a href="mailto:m.mughal1@graduate.curtin.edu.au">m.mughal1@graduate.curtin.edu.au</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Dear Dennis and all<br>
<br>
Thank you for reply and sending the code.<br>
<br>
However, the script gets killed by itself without giving an error at the end of do loop. This I suspect might be due the fact that string is getting overflow. <br>
<br>
Is there a way to fix this ?<br>
<br>
<br>
Muhammad Omer Mughal<br>
MSc BSc Mechanical Engineering<br>
PhD Research Scholar<br>
Remote Sensing and Satellite Research Group<br>
Department of Imaging and Applied Physics<br>
Curtin University<br>
<br>
Curtin University<br>
Tel | +61 8 9266 7962<br>
Fax | +61 8 9266 2377<br>
Mobile | 0470 237 525<br>
<br>
Email | <a href="mailto:m.mughal1@postgrad.curtin.edu.au" target="_blank">m.mughal1@postgrad.curtin.edu.au</a><br>
Web | <a href="http://curtin.edu.au" rel="noreferrer" target="_blank">http://curtin.edu.au</a><br>
<br>
Curtin University is a trademark of Curtin University of Technology.<br>
CRICOS Provider Code 00301J (WA), 02637B (NSW)<br>
<br>
<br>
________________________________<br>
From: Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>><br>
Sent: Thursday, 3 January 2019 12:17:16 PM<br>
To: Muhammad Omer Mughal<br>
Cc: Rick Brownrigg; <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
Subject: Re: [ncl-talk] Extracting all values of rh2 from WRF file and writing it to csv file<br>
<br>
This series of questions is a bit frustrating.<br>
<br>
You have used NCL quite a bit and you have sent numerous questions.<br>
As you know, ncl-talk always recommends that users use 'printVarSummary' to look at variables. You should do that.... ALWAYS. I don't have your file but<br>
<br>
rh2 = wrf_user_getvar(a,"rh2",-1) ; [Time | 673] x [south_north | 71] x [west_east | 82]<br>
lat=wrf_user_getvar(a,"XLAT",-1) ; "<br>
lon=wrf_user_getvar(a,"XLONG",-1) ; "<br>
<br>
Your initial question:<br>
<br>
lat and lon are variables with a 'Time' dimension.<br>
You can not use multidimensional variables. The following is not correct syntax.<br>
<br>
allRH = rh2(:, lon, lat) ; ??????????????????<br>
<br>
Please read the User Manual on subscripting and 'do' loops<br>
<a href="http://www.ncl.ucar.edu/Document/Manuals/" rel="noreferrer" target="_blank">http://www.ncl.ucar.edu/Document/Manuals/</a><br>
<br>
also<br>
<br>
<a href="http://www.ncl.ucar.edu/Applications/write_ascii.shtml" rel="noreferrer" target="_blank">http://www.ncl.ucar.edu/Applications/write_ascii.shtml</a><<a href="http://www.ncl.ucar.edu/Applications/write_ascii.shtml" rel="noreferrer" target="_blank">http://www.ncl.ucar.edu/Applications/write_ascii.shtml</a>><br>
<br>
========<br>
rh2 = wrf_user_getvar(a,"rh2",-1)<br>
printVarSummary(rh2)<br>
<br>
lat = wrf_user_getvar(a,"XLAT",-1)<br>
lon = wrf_user_getvar(a,"XLONG",-1)<br>
printVarSummary(lat)<br>
<br>
<br>
dimrh2 = dimsizes(rh2)<br>
ntim = dimrh2(0)<br>
nlat = dimrh2(1)<br>
mlon = dimrh2(2)<br>
<br>
wrftxt = new(nlat, "string")<br>
wrftxt = ""<br>
<br>
do nl=0,nlat-1<br>
<br>
do nt=0,ntim-1<br>
do ml=0,mlon-1<br>
wrftxt(nl) = wrftxt(nl) +sprintf("%9.2f", rh2(nt,nl,ml))<br>
end do<br>
end do<br>
<br>
end do<br>
<br>
<br>
filo = "rh2.csv"<br>
system("/bin/rm -f "+filo)<br>
asciiwrite(filo,wrftxt)<br>
<br>
<br>
On Wed, Jan 2, 2019 at 8:28 PM Muhammad Omer Mughal <<a href="mailto:m.mughal1@graduate.curtin.edu.au" target="_blank">m.mughal1@graduate.curtin.edu.au</a><mailto:<a href="mailto:m.mughal1@graduate.curtin.edu.au" target="_blank">m.mughal1@graduate.curtin.edu.au</a>>> wrote:<br>
Hi Rick<br>
<br>
Thank you for the reply.<br>
<br>
Yes , I want to write rh2 to the ascii format. The size of the rh2 in this particular case is [Time|673]*[south_north|81]*[west_east|72]. I want to save the file in the format so that it would have 72 rows and 54513 columns i.e. (673*81) for a particular code to read it.<br>
<br>
Regards<br>
<br>
Omer<br>
<br>
<br>
Muhammad Omer Mughal<br>
MSc BSc Mechanical Engineering<br>
PhD Research Scholar<br>
Remote Sensing and Satellite Research Group<br>
Department of Imaging and Applied Physics<br>
Curtin University<br>
<br>
Curtin University<br>
Tel | +61 8 9266 7962<br>
Fax | +61 8 9266 2377<br>
Mobile | 0470 237 525<br>
<br>
Email | <a href="mailto:m.mughal1@postgrad.curtin.edu.au" target="_blank">m.mughal1@postgrad.curtin.edu.au</a><mailto:<a href="mailto:m.lynch@curtin.edu.au" target="_blank">m.lynch@curtin.edu.au</a>><br>
Web | <a href="http://curtin.edu.au" rel="noreferrer" target="_blank">http://curtin.edu.au</a><<a href="http://curtin.edu.au/" rel="noreferrer" target="_blank">http://curtin.edu.au/</a>><br>
<br>
Curtin University is a trademark of Curtin University of Technology.<br>
CRICOS Provider Code 00301J (WA), 02637B (NSW)<br>
<br>
<br>
________________________________<br>
From: Rick Brownrigg <<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a><mailto:<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>>><br>
Sent: Thursday, 3 January 2019 10:59:30 AM<br>
To: Muhammad Omer Mughal<br>
Cc: <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><mailto:<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>><br>
Subject: Re: [ncl-talk] Extracting all values of rh2 from WRF file and writing it to csv file<br>
<br>
HI,<br>
<br>
That error message makes sense, since in a WRF file, the variables XLAT and XLONG are 2D (curvilinear).<br>
<br>
I guess I'm confused as to what you are trying to do. If you just simply want the variable "rh2" written to an ascii file, instead of this:<br>
<br>
allRH = rh2(:, lon, lat)<br>
asciiwrite("rh2.csv",allRH)<br>
<br>
what about just:<br>
<br>
asciiwrite("rh2.csv",rh2)<br>
<br>
A simple experiment revealed that this will write the 3D array, 1 value per line, in "row major" format. This means to read such a file later, you must have some way of knowing the shape and dimensionality.<br>
<br>
Hope that helps....<br>
Rick<br>
<br>
<br>
On Wed, Jan 2, 2019 at 7:42 PM Muhammad Omer Mughal <<a href="mailto:m.mughal1@graduate.curtin.edu.au" target="_blank">m.mughal1@graduate.curtin.edu.au</a><mailto:<a href="mailto:m.mughal1@graduate.curtin.edu.au" target="_blank">m.mughal1@graduate.curtin.edu.au</a>>> wrote:<br>
Dear Rick<br>
Thanks for the reply. I changed the script to remove the SEGV error but now I am getting the following error messages<br>
<br>
<br>
Please see the script below<br>
<br>
a=addfile("wrfout_d03_2017-02-01_00:00:<a href="http://00.nc" rel="noreferrer" target="_blank">00.nc</a><<a href="http://00.nc" rel="noreferrer" target="_blank">http://00.nc</a>>","r")<br>
<br>
rh2 = wrf_user_getvar(a,"rh2",-1)<br>
<br>
lat=wrf_user_getvar(a,"XLAT",-1)<br>
lon=wrf_user_getvar(a,"XLONG",-1)<br>
<br>
<br>
allRH = rh2(:, lon, lat)<br>
<br>
asciiwrite("rh2.csv",allRH)<br>
<br>
fatal:Illegal subscript. Subscripts must be scalar or one dimensional vectors<br>
<br>
<br>
<br>
<br>
<br>
Muhammad Omer Mughal<br>
MSc BSc Mechanical Engineering<br>
PhD Research Scholar<br>
Remote Sensing and Satellite Research Group<br>
Department of Imaging and Applied Physics<br>
Curtin University<br>
<br>
Curtin University<br>
Tel | +61 8 9266 7962<br>
Fax | +61 8 9266 2377<br>
Mobile | 0470 237 525<br>
<br>
Email | <a href="mailto:m.mughal1@postgrad.curtin.edu.au" target="_blank">m.mughal1@postgrad.curtin.edu.au</a><mailto:<a href="mailto:m.lynch@curtin.edu.au" target="_blank">m.lynch@curtin.edu.au</a>><br>
Web | <a href="http://curtin.edu.au" rel="noreferrer" target="_blank">http://curtin.edu.au</a><<a href="http://curtin.edu.au/" rel="noreferrer" target="_blank">http://curtin.edu.au/</a>><br>
<br>
Curtin University is a trademark of Curtin University of Technology.<br>
CRICOS Provider Code 00301J (WA), 02637B (NSW)<br>
<br>
<br>
________________________________<br>
From: Rick Brownrigg <<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a><mailto:<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>>><br>
Sent: Wednesday, 2 January 2019 10:18:33 PM<br>
To: Muhammad Omer Mughal<br>
Cc: <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><mailto:<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>><br>
Subject: Re: [ncl-talk] Extracting all values of rh2 from WRF file and writing it to csv file<br>
<br>
Hi,<br>
<br>
Can you share your script and dataset with me? I would like to investigate why there's a SEGV.<br>
<br>
Rick<br>
<br>
<br>
On Wed, Jan 2, 2019 at 4:49 AM Muhammad Omer Mughal <<a href="mailto:m.mughal1@graduate.curtin.edu.au" target="_blank">m.mughal1@graduate.curtin.edu.au</a><mailto:<a href="mailto:m.mughal1@graduate.curtin.edu.au" target="_blank">m.mughal1@graduate.curtin.edu.au</a>>> wrote:<br>
Dear NCL team<br>
<br>
Is there a way to extract all values from WRF output files from all grind points and write to an ascii file.<br>
In my case grid size is 71x82 and the number of times is 673. I tried to write using a table format but I am getting a segmentation fault.<br>
<br>
I will appreciate help. Kindly note that I have used Lambert conformal projection method.<br>
<br>
Regards<br>
<br>
<br>
<br>
Muhammad Omer Mughal<br>
MSc BSc Mechanical Engineering<br>
PhD Research Scholar<br>
Remote Sensing and Satellite Research Group<br>
Department of Imaging and Applied Physics<br>
Curtin University<br>
<br>
Curtin University<br>
Tel | +61 8 9266 7962<br>
Fax | +61 8 9266 2377<br>
Mobile | 0470 237 525<br>
<br>
Email | <a href="mailto:m.mughal1@postgrad.curtin.edu.au" target="_blank">m.mughal1@postgrad.curtin.edu.au</a><mailto:<a href="mailto:m.mughal1@postgrad.curtin.edu.au" target="_blank">m.mughal1@postgrad.curtin.edu.au</a>><br>
Web | <a href="http://curtin.edu.au" rel="noreferrer" target="_blank">http://curtin.edu.au</a><br>
<br>
Curtin University is a trademark of Curtin University of Technology.<br>
CRICOS Provider Code 00301J (WA), 02637B (NSW)<br>
<br>
<br>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><mailto:<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><mailto:<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>