<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- P { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<div>Dear Ncl-Team</div>
<div>&nbsp; &nbsp;I'm using NCL - version 6.3.0</div>
<div>&nbsp; &nbsp;I need to write 6 netcdf files for 6 atmospheric variables (u10m,v10m,t2m,q2m,precip,snow) with the same structure.</div>
<div>&nbsp; &nbsp;I would like to define just one procedure for this jobs instead 6 procedure , passing as argument the corrispettive variable.</div>
<div>&nbsp; &nbsp;But to write the variable in the file I need to specify the name of variable (for example fout-&gt;snow = (/atmField/), see code below)</div>
<div>&nbsp; &nbsp;Is there a way to pass a name of variable ad argument in order to define just one procedure for all the variable?</div>
<div><br>
</div>
<div>thanks</div>
<div>Francesco</div>
<div>&nbsp; &nbsp;</div>
<div>procedure write_atm_snow(path_extrapdataAtm,file_extrapdataAtm,glAttDescr, \</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nx,ny,nt,lon1d,lat1d,time,tmask,atmField,maskFieldName,atmFieldName)</div>
<div>begin</div>
<div><br>
</div>
<div>&nbsp; &nbsp;pathfile_extrapdataAtm = path_extrapdataAtm&#43;&quot;/&quot;&#43;file_extrapdataAtm</div>
<div>&nbsp; &nbsp;system(&quot;rm -f &quot;&#43;pathfile_extrapdataAtm)</div>
<div>&nbsp; &nbsp;fout = addfile(pathfile_extrapdataAtm, &quot;c&quot;)</div>
<div>&nbsp; &nbsp;;print(fout)</div>
<div><br>
</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;; Explicitly declare file definition mode. Improve efficiency.</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;setfileoption(fout,&quot;DefineMode&quot;,True)</div>
<div><br>
</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;; Defines global attributes associated with the file.&nbsp;</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;fAtt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= True</div>
<div>&nbsp; &nbsp;fAtt@description &nbsp;= glAttDescr<br>
</div>
<div>&nbsp; &nbsp;fAtt@creation_date= systemfunc (&quot;date&quot;)</div>
<div>&nbsp; &nbsp;fileattdef(fout, fAtt)</div>
<div><br>
</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;; Defines dimension names, dimension sizes, unlimited dimensions on the file.&nbsp;</div>
<div>&nbsp; &nbsp;; (Note: to get an UNLIMITED record dimension, we set the dimensionality</div>
<div>&nbsp; &nbsp;; &nbsp;to -1 (or the actual size) and set the dimension name to True.)</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;dimNames = (/ &quot;lon&quot;, &nbsp;&quot;lat&quot;, &nbsp; &quot;time&quot;/)</div>
<div>&nbsp; &nbsp;dimSizes = (/ nx, &nbsp; &nbsp; ny, &nbsp; &nbsp; &nbsp;nt/)<br>
</div>
<div>&nbsp; &nbsp;dimUnlim = (/ False, False, &nbsp; &nbsp;True /)</div>
<div>&nbsp; &nbsp;filedimdef(fout,dimNames,dimSizes,dimUnlim)</div>
<div><br>
</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;; Defines a list of variable names, variable types, and</div>
<div>&nbsp; &nbsp;; variable dimension names for the file.</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;filevardef(fout, &quot;lon&quot;, &nbsp; &nbsp; &nbsp; &nbsp;typeof(lon1d), &nbsp; &quot;lon&quot;)</div>
<div>&nbsp; &nbsp;filevardef(fout, &quot;lat&quot;, &nbsp; &nbsp; &nbsp; &nbsp;typeof(lat1d), &nbsp; &quot;lat&quot;)</div>
<div>&nbsp; &nbsp;filevardef(fout, &quot;time&quot;, &nbsp; &nbsp; &nbsp; typeof(time), &nbsp; &nbsp;&quot;time&quot;)</div>
<div>&nbsp; &nbsp;filevardef(fout, maskFieldName,typeof(tmask), &nbsp; (/&quot;lat&quot;,&quot;lon&quot;/))</div>
<div>&nbsp; &nbsp;filevardef(fout, atmFieldName, typeof(atmField),(/&quot;time&quot;,&quot;lat&quot;,&quot;lon&quot;/))</div>
<div>&nbsp;<br>
</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;; Copies attributes from an input variable to the variables on the file.&nbsp;</div>
<div>&nbsp; &nbsp;;====================================================================</div>
<div>&nbsp; &nbsp;filevarattdef(fout, &quot;lon&quot;, &nbsp; &nbsp; &nbsp; &nbsp;lon1d)</div>
<div>&nbsp; &nbsp;filevarattdef(fout, &quot;lat&quot;, &nbsp; &nbsp; &nbsp; &nbsp;lat1d)</div>
<div>&nbsp; &nbsp;filevarattdef(fout, &quot;time&quot;, &nbsp; &nbsp; &nbsp; time)</div>
<div>&nbsp; &nbsp;filevarattdef(fout, maskFieldName,tmask)</div>
<div>&nbsp; &nbsp;filevarattdef(fout, atmFieldName, atmField)</div>
<div><br>
</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;; Explicitly exit file definition mode. **NOT REQUIRED**</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;setfileoption(fout,&quot;DefineMode&quot;,False)</div>
<div><br>
</div>
<div>&nbsp; &nbsp;;===================================================================</div>
<div>&nbsp; &nbsp;; output only the data values since the dimensionality and such have</div>
<div>&nbsp; &nbsp;; been predefined. The &quot;(/&quot;, &quot;/)&quot; syntax tells NCL to only output the</div>
<div>&nbsp; &nbsp;; data values to the predefined locations on the file.</div>
<div>&nbsp; &nbsp;;====================================================================</div>
<div>&nbsp; &nbsp;fout-&gt;lat &nbsp;= (/lat1d/)</div>
<div>&nbsp; &nbsp;fout-&gt;lon &nbsp;= (/lon1d/)</div>
<div>&nbsp; &nbsp;fout-&gt;time = (/time/)</div>
<div>&nbsp; &nbsp;fout-&gt;LSM &nbsp;= (/tmask/)</div>
<div>&nbsp; &nbsp;fout-&gt;snow = (/atmField/)</div>
<div><br>
</div>
<div>end</div>
<div><br>
&#8203;<br>
</div>
<p><br>
</p>
</body>
</html>