<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Thanks a lot Dave, that works!</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 was not aware that one can also send arguments from within NCL to the shell, that's why I was writing them out to ASCII files and then reading them again in the shell. But this is more efficient. </div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Still, don't know why it wasn't working that way.</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">Thanks again.</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">best wishes,</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><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><font face="trebuchet ms, sans-serif" color="#666666">-------------------------------<br><span style="background-color:rgb(255,255,255)">Dr Tabish Ansari</span></font></div><div><font face="trebuchet ms, sans-serif" color="#666666">Research Associate </font></div><div><font face="trebuchet ms, sans-serif" color="#666666">Air Quality Modelling Group</font></div><div><span style="background-color:rgb(255,255,255)"><span style="font-weight:normal"><font face="trebuchet ms, sans-serif" color="#666666">IASS-Potsdam </font></span></span></div><div><font face="trebuchet ms, sans-serif" color="#666666">Germany</font></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 8 Oct 2022 at 15:31, Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov">dave.allured@noaa.gov</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>Tabish, I do not know what is wrong with the system() command the way you wrote it.  However, I suggest a simpler approach.  It is easy to directly pass simple string command line arguments to a shell command through system().  Do not use asciiwrite or text files.</div><div><br></div><div>    cd_string = tostring (cd)</div><div>    emis_string = str_join (tostring (emis), " ")<br>    system ("./myscript.sh " + cd_string + " " <a class="gmail_plusreply" id="m_-7499398270281903830plusReplyChip-2">+</a> emis_string)<br></div><div><br></div><div>Take care to include intervening spaces between all arguments to the shell command, as shown here.  You could also write "cd" directly, because NCL automatically converts scalar numbers to strings when doing string concatenation:</div><div><br></div><div>    emis_string = str_join (tostring (emis), " ")</div><div><div>    system ("./myscript.sh "<span> </span>+ cd + " " <a class="gmail_plusreply" id="m_-7499398270281903830gmail-plusReplyChip-2">+</a> emis_string)<br></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 8, 2022 at 6:34 AM Tabish Ansari via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.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 style="font-family:"trebuchet ms",sans-serif">Hello,</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">I have a small shell script <i>myscript.sh</i> which takes 13 arguments: start day, and 12 values of emission levels. For now, it just echoes them back on the screen. </div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">I'm supplying these 13 numbers via an NCL script by writing them out to a text file and reading them again in the shell. NCL is nicely writing these text files out and myscript.sh is able to pick these arguments when I write the command in bash. However, when I try to achieve the same from inside NCL using the system() function, the shell script isn't able to read these arguments.</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">Here's <i>myscript.sh:</i></div><div style="font-family:"trebuchet ms",sans-serif"><font color="#0000ff">#!/bin/bash<br>echo day=$1<br>echo Ai=$2<br>echo Ap=$3<br>echo At=$4<br>echo Ar=$5<br>echo Bi=$6<br>echo Bp=$7<br>echo Bt=$8<br>echo Br=$9<br>echo Ci=${10}<br>echo Cp=${11}<br>echo Ct=${12}<br>echo Cr=${13}<br></font></div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">And here's my NCL script:</div><div style="font-family:"trebuchet ms",sans-serif"><font color="#0000ff">begin<br><br>SD = 02 ; start day<br>baseline = (/100,100,100,100,100,100,100,100,100,100,100,100/)<br><br>emis = baseline<br>print("PREPARING EMISSIONS: "+emis(0)+" "+emis(1)+" "+emis(2)+" "+emis(3)+" "+emis(4)+" "+emis(5)+" "+emis(6)+" "+emis(7)+" "+emis(8)+" "+emis(9)+" "+emis(10)+" "+emis(11))<br><br>asciiwrite("emisstring.txt",emis)<br>asciiwrite("SD.txt",SD)<br><br>system("./myscript.sh $(<SD.txt) $(<emisstring.txt)")<br><br>end</font><br></div><div style="font-family:"trebuchet ms",sans-serif"> </div><div style="font-family:"trebuchet ms",sans-serif">These two scripts are self-sufficient and you can easily copy-paste and test them on your system. Please let me know what's wrong here.</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">Thanks a lot.</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">Tabish</div><div><div dir="ltr"><div dir="ltr"><div><font face="trebuchet ms, sans-serif" color="#666666">-------------------------------<br><span style="background-color:rgb(255,255,255)">Dr Tabish Ansari</span></font></div><div><font face="trebuchet ms, sans-serif" color="#666666">Research Associate </font></div><div><font face="trebuchet ms, sans-serif" color="#666666">Air Quality Modelling Group</font></div><div><span style="background-color:rgb(255,255,255)"><span style="font-weight:normal"><font face="trebuchet ms, sans-serif" color="#666666">IASS-Potsdam </font></span></span></div><div><font face="trebuchet ms, sans-serif" color="#666666">Germany</font></div></div></div></div></div>
</blockquote></div></div>
</blockquote></div>