<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EL link=blue vlink=purple style='word-wrap: break-word;-webkit-nbsp-mode: space;
-webkit-line-break: after-white-space'>
<div class=Section1>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Dear Jack,<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>It is exactly what I want….<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I modified properly your revised script according to my needs
and it works perfectly….<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Thanks for your time and your patience….<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Best regards<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Ioannis<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
ncl-talk-bounces@ucar.edu [mailto:ncl-talk-bounces@ucar.edu] <b>On Behalf Of </b>Jack
Ogaja<br>
<b>Sent:</b> Tuesday, November 24, 2015 5:36 PM<br>
<b>To:</b> Ioannis Koletsis<br>
<b>Cc:</b> ncl-talk [ncl-talk]<br>
<b>Subject:</b> Re: [ncl-talk] Calculate Average value for a number of files<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<div>
<p class=MsoNormal>Dear Ioannis,<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal>You can still use “dim_avg_n” function, you just need to
reorganise your code, and I don’t think another loop is necessary.<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal>My suggestions:<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal>[1] Retrieve the variables from all the files at once(hoping
you won’t experience any memory problem).<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>;****<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> it = -1 ;<== this retrieves the time
dimension as well<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> dust1 =
wrf_user_getvar(fS,"DUST_1",it) <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> dust2 = wrf_user_getvar(fS,"DUST_2",it)
<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> dust3 =
wrf_user_getvar(fS,"DUST_3",it) <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> dust4 =
wrf_user_getvar(fS,"DUST_4",it) <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> dust5 =
wrf_user_getvar(fS,"DUST_5",it) <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>;****<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal>[2] Do most data manipulations outside the loops.<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>;****<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> dust_J = dim_sum_n((/dust1,dust2,dust3,dust4,dust5/),0)*density<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> dust_tot = dust_J(:,level,:,:)<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>;****<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal>[3] Calculate the files averages(hoping I understood what
you want to do)<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>;****<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> n1=0 ;<=== Set to suit your needs<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> n2=2<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> do ifil = 0,numFILES-1<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal> if (ifil.eq.n2) then<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> dust_avg =
dim_avg_n(dust_J(n1:n2,level,:,:),0)<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> print(" average of file|" + n1
+ "| and file|" + n2 + "| calculated...")<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> n1=n1+2<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> n2=n2+2<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> end if<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> ;****<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> ;….and then write to the output file(whichever way
you wish)<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal> ;****<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> data(npt) = data(npt) +
sprintf("%7.3f ", dust_tot(ifil,ml,nl))<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> if (ifil.eq.n2-2) then ;<==
write the averages after every other column<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> data(npt) = data(npt) + sprintf("%7.3f
", dust_avg(ml,nl))<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> end if<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal> end do<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> ;****<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal>See the attached script. Test it with your data files. If it
doesn’t solve the problem as always write again to ncl-talk.<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal>Jack<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</div>
<br /><br />
<hr style='border:none; color:#909090; background-color:#B0B0B0; height: 1px; width: 99%;' />
<table style='border-collapse:collapse;border:none;'>
        <tr>
                <td style='border:none;padding:0px 15px 0px 8px'>
                        <a href="https://www.avast.com/antivirus">
                                <img border=0 src="http://static.avast.com/emails/avast-mail-stamp.png" alt="Avast logo" />
                        </a>
                </td>
                <td>
                        <p style='color:#3d4d5a; font-family:"Calibri","Verdana","Arial","Helvetica"; font-size:12pt;'>
                                Αυτό το e-mail ελέγχθηκε για ιούς από το πρόγραμμα Avast antivirus.
                                <br><a href="https://www.avast.com/antivirus">www.avast.com</a>
                        </p>
                </td>
        </tr>
</table>
<br />
</body>
</html>