<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> 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>
</body>
</html>