<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Francesco,<br>
<br>
I think you are looking for something like the attached script.<br>
<br>
Bye,<br>
Karin<br>
<br>
<br>
<div class="moz-cite-prefix">Am 26.01.17 um 11:09 schrieb Francesco
Trotta:<br>
</div>
<blockquote cite="mid:1485425374600.48855@unibo.it" type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css" style="display:none"><!-- P { margin-top: 0px; margin-bottom: 0px; }--></style>
<div>Dear Ncl-Team</div>
<div> I'm using NCL - version 6.3.0</div>
<div> I need to write 6 netcdf files for 6 atmospheric variables
(u10m,v10m,t2m,q2m,precip,snow) with the same structure.</div>
<div> I would like to define just one procedure for this jobs
instead 6 procedure , passing as argument the corrispettive
variable.</div>
<div> But to write the variable in the file I need to specify
the name of variable (for example fout->snow = (/atmField/),
see code below)</div>
<div> 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> </div>
<div>procedure
write_atm_snow(path_extrapdataAtm,file_extrapdataAtm,glAttDescr,
\</div>
<div>
nx,ny,nt,lon1d,lat1d,time,tmask,atmField,maskFieldName,atmFieldName)</div>
<div>begin</div>
<div><br>
</div>
<div> pathfile_extrapdataAtm =
path_extrapdataAtm+"/"+file_extrapdataAtm</div>
<div> system("rm -f "+pathfile_extrapdataAtm)</div>
<div> fout = addfile(pathfile_extrapdataAtm, "c")</div>
<div> ;print(fout)</div>
<div><br>
</div>
<div>
;===================================================================</div>
<div> ; Explicitly declare file definition mode. Improve
efficiency.</div>
<div>
;===================================================================</div>
<div> setfileoption(fout,"DefineMode",True)</div>
<div><br>
</div>
<div>
;===================================================================</div>
<div> ; Defines global attributes associated with the file. </div>
<div>
;===================================================================</div>
<div> fAtt = True</div>
<div> fAtt@description = glAttDescr<br>
</div>
<div> fAtt@creation_date= systemfunc ("date")</div>
<div> fileattdef(fout, fAtt)</div>
<div><br>
</div>
<div>
;===================================================================</div>
<div> ; Defines dimension names, dimension sizes, unlimited
dimensions on the file. </div>
<div> ; (Note: to get an UNLIMITED record dimension, we set the
dimensionality</div>
<div> ; to -1 (or the actual size) and set the dimension name
to True.)</div>
<div>
;===================================================================</div>
<div> dimNames = (/ "lon", "lat", "time"/)</div>
<div> dimSizes = (/ nx, ny, nt/)<br>
</div>
<div> dimUnlim = (/ False, False, True /)</div>
<div> filedimdef(fout,dimNames,dimSizes,dimUnlim)</div>
<div><br>
</div>
<div>
;===================================================================</div>
<div> ; Defines a list of variable names, variable types, and</div>
<div> ; variable dimension names for the file.</div>
<div>
;===================================================================</div>
<div> filevardef(fout, "lon", typeof(lon1d), "lon")</div>
<div> filevardef(fout, "lat", typeof(lat1d), "lat")</div>
<div> filevardef(fout, "time", typeof(time), "time")</div>
<div> filevardef(fout, maskFieldName,typeof(tmask),
(/"lat","lon"/))</div>
<div> filevardef(fout, atmFieldName,
typeof(atmField),(/"time","lat","lon"/))</div>
<div> <br>
</div>
<div>
;===================================================================</div>
<div> ; Copies attributes from an input variable to the
variables on the file. </div>
<div>
;====================================================================</div>
<div> filevarattdef(fout, "lon", lon1d)</div>
<div> filevarattdef(fout, "lat", lat1d)</div>
<div> filevarattdef(fout, "time", time)</div>
<div> filevarattdef(fout, maskFieldName,tmask)</div>
<div> filevarattdef(fout, atmFieldName, atmField)</div>
<div><br>
</div>
<div>
;===================================================================</div>
<div> ; Explicitly exit file definition mode. **NOT REQUIRED**</div>
<div>
;===================================================================</div>
<div> setfileoption(fout,"DefineMode",False)</div>
<div><br>
</div>
<div>
;===================================================================</div>
<div> ; output only the data values since the dimensionality and
such have</div>
<div> ; been predefined. The "(/", "/)" syntax tells NCL to only
output the</div>
<div> ; data values to the predefined locations on the file.</div>
<div>
;====================================================================</div>
<div> fout->lat = (/lat1d/)</div>
<div> fout->lon = (/lon1d/)</div>
<div> fout->time = (/time/)</div>
<div> fout->LSM = (/tmask/)</div>
<div> fout->snow = (/atmField/)</div>
<div><br>
</div>
<div>end</div>
<div><br>
<br>
</div>
<p><br>
</p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
ncl-talk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Dipl. Geophys. Karin Meier-Fleischer
Visualization, NCL
Application Support
Deutsches Klimarechenzentrum GmbH (DKRZ)
Bundesstrasse 45a - D20146 Hamburg - Germany
Phone: +49 (0)40 460094 126
Fax: +49 (0)40 460094 270
E-Mail: <a class="moz-txt-link-abbreviated" href="mailto:meier-fleischer@dkrz.de">meier-fleischer@dkrz.de</a>
URL: <a class="moz-txt-link-abbreviated" href="http://www.dkrz.de">www.dkrz.de</a>
Geschäftsführer: Prof. Dr. Thomas Ludwig
Sitz der Gesellschaft: Hamburg
Amtsgericht Hamburg HRB 39784
</pre>
</body>
</html>