<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Amal,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The error message is telling you what the problem is:</div><div class="gmail_default" style="font-size:small"><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default" style="font-size:small"> fatal:Assignment type mismatch, right hand side can't be coerced to type of left hand side</div><div class="gmail_default" style="font-size:small"><br></div></blockquote><div class="gmail_default" style="font-size:small">This is telling you that the variable you have on the left side of the "=" sign is not of the correct type of the calculation being done on the right side. Here's what you have:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"> data(n,0) = (/"y_a"+n/)</div><div class="gmail_default"> data(n,1) = (/"y_b","+n"/)</div><div class="gmail_default" style="font-size:small"> data(n,2) = (/"y_c","+n"/)</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">On the right side of this equation, you are appending an integer to a string, which is going to result in a string. The type of "data" however, was defined as a float a few lines above:</div><div class="gmail_default" style="font-size:small"><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div> data = new((/28,3/),"float")</div></blockquote><div><br></div><div class="gmail_default" style="font-size:small">I think I see what you are trying to do, however. You have variables called y_a1, y_a2, etc defined earlier in the code, and you want to put these into "data". The way you are doing is not going to work, however. You would have to list out the variables by hand:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">data(0,0) = y_a1</div><div class="gmail_default" style="font-size:small">data(0,1) = y_b1</div><div class="gmail_default" style="font-size:small">data(0,2) = y_c1</div><div class="gmail_default" style="font-size:small"><div class="gmail_default">data(010) = y_a2</div><div class="gmail_default">data(1,1) = y_b2</div><div class="gmail_default">data(1,2) = y_c2</div><div class="gmail_default"><br></div></div><div class="gmail_default" style="font-size:small">I don't have time to look at your code in detail to understand the full scope of it, but the best thing to do is figure out how to put all of these calculations inside a do loop, instead of calculating all 28 quantities individually.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">For example: (THIS IS UNTESTED AND IS MEANT AS AN EXAMPLE ONLY):</div><div class="gmail_default" style="font-size:small"><br></div><font face="monospace, monospace">dir = /home/netapp-clima/scratch/asalhi/mask/GSA01/"<br>files1 = systemfunc("ls " + dir + "dox*_<a href="http://med_0-52_timemean.nc">med_0-52_timemean.nc</a>")<span class="gmail_default" style=""></span></font><div><font face="monospace, monospace"><span class="gmail_default" style="">f</span>iles2 = systemfunc("ls " + dir + "dox*_med_<span class="gmail_default" style="">5</span><a href="http://2-101_timemean.nc">2-101_timemean.nc</a>")</font><div class="gmail_default" style=""><font face="monospace, monospace"><span class="gmail_default">f</span>iles3 = systemfunc("ls " + dir + "dox*_med_<span class="gmail_default">101-209</span>_<a href="http://timemean.nc">timemean.nc</a>")<br class="gmail-Apple-interchange-newline"></font></div><div class="gmail_default" style=""><font face="monospace, monospace">nfiles = dimsizes(files1)</font></div><font face="monospace, monospace">data = new((/<span class="gmail_default" style="">nfiles,3</span>/),"float")</font></div><div><font face="monospace, monospace"><br></font><div class="gmail_default" style=""><font face="monospace, monospace">do nf = 0,nfiles-1</font></div><div class="gmail_default" style=""><font face="monospace, monospace"> a = addfile(files1(nf),"r")</font></div><div class="gmail_default" style=""><font face="monospace, monospace"> b = addfile(files2(nf),"r")</font></div><div class="gmail_default" style=""><font face="monospace, monospace"> c = addfile(files3(nf),"r")<br></font></div><div class="gmail_default" style="">
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><font face="monospace, monospace" style=""><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space" style=""> </span>dox_a<span class="gmail-Apple-converted-space" style=""> </span>= a</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(208,59,255)">-></span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">dox</span></font></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><font face="monospace, monospace"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>dox_b = b</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(208,59,255)">-></span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">dox</span></font></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><font face="monospace, monospace"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>dox_c = c</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(208,59,255)">-></span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">dox</span></font></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><br></p></div><div dir="ltr"> dox_ave_a = dim_avg_wgt_n_Wrap(dox_a, <span class="gmail_default" style="font-size:small">(/</span><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-variant-ligatures:no-common-ligatures">dox_a&lev<span class="gmail_default" style="font-size:small">/)</span></span>, 0, 1 ) <br> dox_ave_<span class="gmail_default" style="font-size:small">b</span> = dim_avg_wgt_n_Wrap(dox_<span class="gmail_default" style="font-size:small">b</span>, <span class="gmail_default">(/</span><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-variant-ligatures:no-common-ligatures">dox_<span class="gmail_default" style="font-size:small">b</span>&lev<span class="gmail_default">/)</span></span>, 0, 1 ) </div><div dir="ltr"> dox_ave_<span class="gmail_default">c</span> = dim_avg_wgt_n_Wrap(dox_<span class="gmail_default">c</span>, <span class="gmail_default">(/</span><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-variant-ligatures:no-common-ligatures">dox_<span class="gmail_default">c</span>&lev<span class="gmail_default">/)</span></span>, 0, 1 ) </div><div dir="ltr"><br> <span class="gmail_default" style="font-size:small">data(nf,0)</span> = dim_avg_n_Wrap(dox_ave_a,(/1,2/))</div><div dir="ltr"><div dir="ltr"> <span class="gmail_default">data(nf,1)</span> = dim_avg_n_Wrap(dox_ave_<span class="gmail_default" style="font-size:small">b</span>,(/1,2/))</div><div dir="ltr"> <span class="gmail_default">data(nf,2)</span> = dim_avg_n_Wrap(dox_ave_<span class="gmail_default" style="font-size:small">c</span>,(/1,2/))<span class="gmail_default" style="font-size:small"></span></div><div dir="ltr"><span class="gmail_default" style="font-size:small">. . .</span></div><div dir="ltr"><div class="gmail_default" style="font-size:small">end do</div></div><br><div class="gmail_default" style="font-size:small">Hopefully this helps you get started...</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"></div><br><div class="gmail_default" style="font-size:small"><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 24, 2018 at 2:58 AM Amal Inge <<a href="mailto:amalingenieur89@gmail.com">amalingenieur89@gmail.com</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"><div dir="ltr"><div dir="ltr"><div dir="ltr">Dear NCL experts,<div><br></div><div>i'm trying to plot bar charts for a variable 4 dimension for 28 subareas, and for each subarea i have 3 depths (3 ncfiles).</div><div>i had this error:</div><div> fatal:Assignment type mismatch, right hand side can't be coerced to type of left hand side</div><div>fatal:["Execute.c":8575]:Execute: Error occurred at or near line 587 in file dox_gsa.ncl</div><div>i'm not sure if i did well the loop, Could you help me to correct it please?</div><div><div>here is the variable and the script in attachement</div><div><br></div><div>many thanks</div><div>amal</div><div>netcdf dox01_med_0-52_timemean {</div><div>dimensions:</div><div><span style="white-space:pre-wrap"> </span>lon = 670 ;</div><div><span style="white-space:pre-wrap"> </span>lat = 253 ;</div><div><span style="white-space:pre-wrap"> </span>lev = 13 ;</div><div><span style="white-space:pre-wrap"> </span>time = UNLIMITED ; // (1 currently)</div><div><span style="white-space:pre-wrap"> </span>bnds = 2 ;</div><div>variables:</div><div><span style="white-space:pre-wrap"> </span>float lon(lon) ;</div><div><span style="white-space:pre-wrap"> </span>lon:standard_name = "longitude" ;</div><div><span style="white-space:pre-wrap"> </span>lon:long_name = "longitude" ;</div><div><span style="white-space:pre-wrap"> </span>lon:units = "degrees_east" ;</div><div><span style="white-space:pre-wrap"> </span>lon:axis = "X" ;</div><div><span style="white-space:pre-wrap"> </span>float lat(lat) ;</div><div><span style="white-space:pre-wrap"> </span>lat:standard_name = "latitude" ;</div><div><span style="white-space:pre-wrap"> </span>lat:long_name = "latitude" ;</div><div><span style="white-space:pre-wrap"> </span>lat:units = "degrees_north" ;</div><div><span style="white-space:pre-wrap"> </span>lat:axis = "Y" ;</div><div><span style="white-space:pre-wrap"> </span>float lev(lev) ;</div><div><span style="white-space:pre-wrap"> </span>lev:standard_name = "depth" ;</div><div><span style="white-space:pre-wrap"> </span>lev:long_name = "depth" ;</div><div><span style="white-space:pre-wrap"> </span>lev:units = "m" ;</div><div><span style="white-space:pre-wrap"> </span>lev:positive = "down" ;</div><div><span style="white-space:pre-wrap"> </span>lev:axis = "Z" ;</div><div><span style="white-space:pre-wrap"> </span>lev:_CoordinateZisPositive = "down" ;</div><div><span style="white-space:pre-wrap"> </span>lev:_CoordinateAxisType = "Height" ;</div><div><span style="white-space:pre-wrap"> </span>double time(time) ;</div><div><span style="white-space:pre-wrap"> </span>time:standard_name = "time" ;</div><div><span style="white-space:pre-wrap"> </span>time:long_name = "time" ;</div><div><span style="white-space:pre-wrap"> </span>time:bounds = "time_bnds" ;</div><div><span style="white-space:pre-wrap"> </span>time:units = "seconds since 1970-01-01 00:00:00" ;</div><div><span style="white-space:pre-wrap"> </span>time:calendar = "standard" ;</div><div><span style="white-space:pre-wrap"> </span>time:axis = "T" ;</div><div><span style="white-space:pre-wrap"> </span>double time_bnds(time, bnds) ;</div><div><span style="white-space:pre-wrap"> </span>float dox(time, lev, lat, lon) ;</div><div><span style="white-space:pre-wrap"> </span>dox:standard_name = "mole_concentration_of_dissolved_molecular_oxygen_in_sea_water" ;</div><div><span style="white-space:pre-wrap"> </span>dox:long_name = "Mole concentration of Dissolved Molecular Oxygen in sea water" ;</div><div><span style="white-space:pre-wrap"> </span>dox:units = "millimol m-3" ;</div><div><span style="white-space:pre-wrap"> </span>dox:_FillValue = 1.e+20f ;</div><div><span style="white-space:pre-wrap"> </span>dox:missing_value = 1.e+20f ;</div><div><span style="white-space:pre-wrap"> </span>dox:_ChunkSizes = 1, 22, 84, 161 ;</div><div><br></div><div>// global attributes:</div><div><span style="white-space:pre-wrap"> </span>:CDI = "Climate Data Interface version 1.9.0 (<a href="http://mpimet.mpg.de/cdi" target="_blank">http://mpimet.mpg.de/cdi</a>)" ;</div><div><span style="white-space:pre-wrap"> </span>:Conventions = "None" ;</div><div><span style="white-space:pre-wrap"> </span>:history = "Thu Dec 20 13:29:55 2018: cdo timmean <a href="http://dox01_med_0-52.nc" target="_blank">dox01_med_0-52.nc</a> <a href="http://dox01_med_0-52_timemean.nc" target="_blank">dox01_med_0-52_timemean.nc</a>" ;</div><div><span style="white-space:pre-wrap"> </span>:creation_date = "Tue Dec 4 23:27:50 CET 2018" ;</div><div><span style="white-space:pre-wrap"> </span>:source_file = "<a href="http://dox_med_0-52.nc" target="_blank">dox_med_0-52.nc</a>" ;</div><div><span style="white-space:pre-wrap"> </span>:title = "NCL Efficient Approach to netCDF Creation" ;</div><div><span style="white-space:pre-wrap"> </span>:CDO = "Climate Data Operators version 1.9.0 (<a href="http://mpimet.mpg.de/cdo" target="_blank">http://mpimet.mpg.de/cdo</a>)" ;</div></div><div><br></div></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<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>