<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Hi Rick</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">That works - thanks a lot!</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Tabish</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br clear="all"></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div><span style="color:rgb(11,83,148)"><i><span style="font-family:verdana,sans-serif"><font size="1">Tabish U Ansari<br></font></span></i></span></div><span style="color:rgb(11,83,148)"><i><span style="font-family:verdana,sans-serif"><font size="1">Postdoctoral Researcher <br></font></span></i></span></div><div><span style="color:rgb(11,83,148)"><i><span style="font-family:verdana,sans-serif"><font size="1">Centre for Climate and Air Pollution Studies (C-CAPS)<br></font></span></i></span></div><div><span style="color:rgb(11,83,148)"><i><span style="font-family:verdana,sans-serif"><font size="1">School of Physics, NUI-Galway</font></span></i><font size="1"><span style="font-family:tahoma,sans-serif"><i><span style="font-family:verdana,sans-serif">, Ireland</span></i><br></span></font></span></div><div><span style="color:rgb(11,83,148)"><font size="1"><span style="font-family:tahoma,sans-serif"><i><span style="font-family:verdana,sans-serif">ResearchGate: <a href="https://www.researchgate.net/profile/Tabish_Ansari" target="_blank">https://www.researchgate.net/profile/Tabish_Ansari</a></span></i><br></span></font></span></div></div></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 20 Feb 2020 at 14:41, Rick Brownrigg <<a href="mailto:brownrig@ucar.edu">brownrig@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>Hi Tabish,<br></div><div><br></div><div>I *think* the notation for what you want to do is:</div><div><br></div><div><i> var_a1_00z_Oct = a1_00z_Oct -><span style="color:rgb(255,0,0)">$</span>var<span style="color:rgb(255,0,0)">$</span></i></div><div><span style="background-color:rgb(238,238,238)"><i><span style="color:rgb(255,0,0)"><br></span></i></span></div><div><i><span style="color:rgb(255,0,0)"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(238,238,238)">Rick</span></span><br></span></i></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 20, 2020 at 7:24 AM Tabish Ansari via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@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-family:trebuchet ms,sans-serif">Hi <br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I need to repeat a dimension averaging and sum operation over several variables inside netcdf file that I'm reading through addfiles function. I have written a user defined function for the same and want to call it with the names of different variables present in the file. However, NCL isn't accepting string arguments to be used directly as variable names to read off the file.</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Here's my script</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><i>;THIS SCRIPT COMPUTES TOTAL EMISSION FLUX PER SPECIES FOR EACH MODEL DOMAIN<br>begin<br><br>;DOMAIN 1<br>a1_00z_Oct = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_00z_d01_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_00z_d01_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br>a1_12z_Oct = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_12z_d01_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_12z_d01_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br>a1_00z_Nov = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_00z_d01_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_00z_d01_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br>a1_12z_Nov = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_12z_d01_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_12z_d01_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br><br>;DOMAIN 2<br>a2_00z_Oct = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_00z_d02_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_00z_d02_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br>a2_12z_Oct = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_12z_d02_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_12z_d02_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br>a2_00z_Nov = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_00z_d02_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_00z_d02_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br>a2_12z_Nov = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_12z_d02_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_12z_d02_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br><br>;DOMAIN 3<br>a3_00z_Oct = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_00z_d03_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_00z_d03_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br>a3_12z_Oct = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_12z_d03_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_12z_d03_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br>a3_00z_Nov = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_00z_d03_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_00z_d03_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br>a3_12z_Nov = addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_12z_d03_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_12z_d03_total_Nov_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br><br><br>;FUNCTION TO SUM ACROSS 8 VERT LEVELS THEN AVERAGE OVER LAT,LONG,TIME<br>undef("avgsum")<br>function avgsum(var:string)<br>begin<br> var_a1_00z_Oct = a1_00z_Oct ->var<br> var_a1_00z_Oct_vsum = dim_sum_n_Wrap(var_a1_00z_Oct,1)<br> var_a1_00z_Oct_vsum_snavg = dim_avg_n_Wrap(var_a1_00z_Oct_vsum,1)<br> var_a1_00z_Oct_vsum_snweavg = dim_avg_n_Wrap(var_a1_00z_Oct_vsum_snavg,1)<br> var_a1_00z_Oct_vsum_snwetavg = dim_avg_n_Wrap(var_a1_00z_Oct_vsum_snweavg,0)<br><br> var_a1_12z_Oct = a1_12z_Oct ->var<br> var_a1_12z_Oct_vsum = dim_sum_n_Wrap(var_a1_12z_Oct,1)<br> var_a1_12z_Oct_vsum_snavg = dim_avg_n_Wrap(var_a1_12z_Oct_vsum,1)<br> var_a1_12z_Oct_vsum_snweavg = dim_avg_n_Wrap(var_a1_12z_Oct_vsum_snavg,1)<br> var_a1_12z_Oct_vsum_snwetavg = dim_avg_n_Wrap(var_a1_12z_Oct_vsum_snweavg,0)<br><br> result = (var_a1_00z_Oct_vsum_snwetavg + var_a1_12z_Oct_vsum_snwetavg)/2.0<br> return(result)<br>end<br><br><br>print(avgsum("E_CO"))<br><br>end</i></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><i><br></i></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><span style="color:rgb(255,0,0)">I am getting this error:</span></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><span style="color:rgb(255,0,0)">fatal:["Execute.c":6397]:variable (var) is not in file (a1_00z_Oct)<br>fatal:["Execute.c":8640]:Execute: Error occurred at or near line 27 in file emistotals.ncl<br><br>fatal:["Execute.c":8640]:Execute: Error occurred at or near line 44 in file emistotals.ncl<br></span><i><br></i></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Tabish<i><br></i></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><i></i>~                                                                                                                      <br></div><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div><span style="color:rgb(11,83,148)"><i><span style="font-family:verdana,sans-serif"><font size="1">Tabish U Ansari<br></font></span></i></span></div><span style="color:rgb(11,83,148)"><i><span style="font-family:verdana,sans-serif"><font size="1">Postdoctoral Researcher <br></font></span></i></span></div><div><span style="color:rgb(11,83,148)"><i><span style="font-family:verdana,sans-serif"><font size="1">Centre for Climate and Air Pollution Studies (C-CAPS)<br></font></span></i></span></div><div><span style="color:rgb(11,83,148)"><i><span style="font-family:verdana,sans-serif"><font size="1">School of Physics, NUI-Galway</font></span></i><font size="1"><span style="font-family:tahoma,sans-serif"><i><span style="font-family:verdana,sans-serif">, Ireland</span></i><br></span></font></span></div><div><span style="color:rgb(11,83,148)"><font size="1"><span style="font-family:tahoma,sans-serif"><i><span style="font-family:verdana,sans-serif">ResearchGate: <a href="https://www.researchgate.net/profile/Tabish_Ansari" target="_blank">https://www.researchgate.net/profile/Tabish_Ansari</a></span></i><br></span></font></span></div></div></div></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></blockquote></div>
</blockquote></div>