<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>General programming comment: I 'really' like the reassignment operator <b><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,255)">:=</span></span> :-) :-) :-)</b><b><br></b></div><div><b><br></b></div><div>Some languages allow existing variables on the left-hand-side of the assignment operator <span style="color:rgb(0,0,255)"><b>=</b><span style="color:rgb(0,0,0)"> to be replaced [over-written] by a variable on the right handle side regardless of shape or type. My historical use of a language that did allow this type of operation occasionally led to some subtle errors. [ Of course, it could have been bad programming on my part! ]</span> </span><br></div><div><b><br></b></div>Within NCL, a person could always use <span style="color:rgb(0,0,255)"><b>:=</b></span> rather than the 'regular' assignment operator <span style="color:rgb(0,0,255)"><b>=</b></span></div><div><span style="color:rgb(0,0,0)">There would only be a very small timing penalty.</span> However, <b>I think this would be bad coding style</b>. Kinda like hard-wiring numbers [123.987] into a code rather than using a named constant ( con_name = 123.987). <br></div><div dir="ltr"><div><br></div><div>To me, judicious use of <span style="color:rgb(0,0,255)"><b>:=</b></span> indicates to someone looking at the code that a variable 'may' change shape and/or type. <br></div><div>A common case would be calculating a monthly mean from observations. Each month has a different number of days. <br></div><div>So if there were (say) 6-hrly values, months with 28, 29, 30, 31 days [*4] would have a different number of observations.</div><br><div> x(ntim) ===> ntim=> all 6=hrly values</div><div><br></div><div> nyrs = yrLast-yrStrt+1</div><div> NTIM = nyrs*12 ; total number of monthly values to be calculated<br></div><div> xAvg = new ( (/NTIM/), typeof(x), getVarFillValue(x)) <br></div><div><br></div><div> do yyyy=yrStrt,yrLast<br> do mm=1,12 <br></div><div> it <span style="color:rgb(0,0,255)"><b>:=</b></span> ind(yyyy.eq.year .and. mm.eq.month) ; temporal indices [*] of observations in current month & year<br> if (<b>.not.all</b>(<b>ismissing</b>(it))) then<br> nit <b>=</b> <b>dimsizes</b>(it) ; # of 6-hrly values [scalar]<br> nt <b>=</b> nt+1 ; index of current monthly value [scalar]<br></div><div> xAvg(nt) <b>=</b> <b>dim_avg_n</b>( x(it), nDim) ; average all values for the current month/year<br></div><div> end if</div><div> end do ; end 'mm'<br></div><div> end do ; end 'yyyy'<br></div><div> <br><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 23, 2019 at 10:09 AM Laura Fowler <<a href="mailto:laura@ucar.edu" target="_blank">laura@ucar.edu</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 class="gmail_default" style="font-size:small">Hi Adriana:</div><div class="gmail_default" style="font-size:small">You may want to add "delete(file1)" below "print(file1)" since as you wrote file1 contains 30 files for June and 31 files for July?</div><div class="gmail_default" style="font-size:small">Laura</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 23, 2019 at 7:39 AM <<a href="mailto:adriana.bossolasco@cnrs-orleans.fr" target="_blank">adriana.bossolasco@cnrs-orleans.fr</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">Hi Everyone<br>
<br>
I have a problem for read monthly files with systemfunc<br>
I know that the problem is because the first month that I read is JUN <br>
which have 30 days and the when I try to read JUL with 31 days my code <br>
says:<br>
<br>
fatal:Dimension sizes of left hand side and right hand side of <br>
assignment do not match<br>
<br>
How can I fix this? Maybe is very basic but I don't realize<br>
<br>
I copy my code here<br>
<br>
begin<br>
;************************************************<br>
; variable and file handling<br>
;************************************************<br>
<br>
<br>
year1=2001<br>
year2=2002<br>
nyear=year2-year1<br>
print(nyear)<br>
month1=6<br>
month2=8<br>
nmonths=month2-month1<br>
<br>
do i = 1,nyear<br>
do j = 1,nmonths<br>
print(nmonths)<br>
print(nyear)<br>
if (month1+j-1 .ge. 10) then<br>
mois=10<br>
else<br>
mois="0"+(j-1+month1) ;<br>
end if<br>
print(mois)<br>
<br>
file1 = systemfunc(" ls <br>
/PROJETS/MOUSSON-NEW/MAM_GEOS_8y_rest/MAM_GEOS_8y_rest.cam.h0.200"+i+"-"+mois+"*-<a href="http://43200.nc" rel="noreferrer" target="_blank">43200.nc</a>")<br>
print(file1)<br>
<br>
end do<br>
end do<br>
<br>
end<br>
<br>
<br>
-- <br>
Adriana Bossolasco<br>
LPC2E UMR 7328 (CNRS, Université d'Orléans)<br>
3A avenue de la Recherche Scientifique<br>
45071 Orléans Cedex 2 - FRANCE<br>
Tel +33 (0)2 38 25 52 85<br>
e-mail: <a href="mailto:adriana.bossolasco@cnrs-orleans.fr" target="_blank">adriana.bossolasco@cnrs-orleans.fr</a><br>
_______________________________________________<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><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-3574266224473999734gmail-m_5392926586020028800gmail-m_6998962886651760086gmail_signature"><div dir="ltr"><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#0000ff">!-------------------------------------------------------------------------------------------------------------</font><div><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#0000ff">Laura D. Fowler </font></div><div><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#0000ff">Mesoscale and Microscale Meteorology Division (MMM) </font></div><div><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#0000ff">National Center for Atmospheric Research<br></font></div><div><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#0000ff">P.O. Box 3000, Boulder CO 80307-3000</font></div><div><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#0000ff"><br></font></div><div><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#0000ff">e-mail: <a href="mailto:laura@ucar.edu" target="_blank">laura@ucar.edu</a></font></div><div><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#0000ff">phone: 303-497-1628</font></div><div><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#0000ff"><br></font></div><div><font style="background-color:rgb(255,255,255)" face="arial, helvetica, sans-serif" color="#0000ff">!-------------------------------------------------------------------------------------------------------------</font><br></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>