<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 13, 2014, at 6:12 AM, pankaj kumar wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div>Hi,</div><div><br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;">It's my deepest request to whosoever working to write 4-dimensional netcdf data using grads since sdfwrite is unable to generate 4-D netcdf data. My global netcdf data is in 4-D format with each yearly file has 12 time and 15 vertical points. I am trying to save errenous data from these files into netcdf format in 4-dimensions. I have tried many methods of looping in z and t scales. Although loops in z and t scales are running properly as grads displays sorted data for each time and each layer, the output file only saves data in netcdf format for final time and final layer which is 2-dimensional data. It is clear that
the sdfwrite command does not allow one to write out more than one variable to a file (source: grads documentation on sdfwrite) so the sdfwrite generates output for one time and one layer only.<br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;">However, can someone tell me how to write a loop in grads to generate multiple netcdf files using sdfwrite command for each single time and each layer from my 4-D netcdf data? Once number of netcdf files are generated with data for different time and layers, I hope sdfwrite allows to <span id="misspell-15" class="">concatenate</span> all files for multiple layers
first and then for long time series.</div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;">Here, I have tried a looping to produce multiple files for each layer and each time but it hasn't worked.</div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;">_____________________________________________________________________________________<br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new
york,times,serif; background-color: transparent; font-style: normal;">'set lon 0 360'<br>'set lat -90 90'<br></div></div></div></blockquote>'set z 1 15'</div><div>'set t 1 12'</div><div>'var = var'</div><div><blockquote type="cite"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;">'set sdfwrite -4d -flt -nc4 data.nc'<br>'sdfwrite var'<br><br></div></div></div></blockquote><div><br></div><div>You must define your variable with X,Y,Z, and T varying BEFORE you invoke sdfwrite. The code above will write out a 4D file for all levels and all time steps in one file. However, you will likely have an extra column so it would be better to remove 'set lon 0 360' and set the x dimension to vary by the grid size -- 'set x 1 'xsize -- where xsize is the size of your X axis. </div><div><br></div><div>If you want one time step per file:</div><div>'set x 1 'xsize</div><div>'set lat -90 90'</div><div>'set z 1 15'</div><div>t=1</div><div>while (t<=12)</div><div> 'set t 't</div><div> 'var = var'</div><div> 'set sdfwrite -4d -flt -nc4 data't'.nc'</div><div> 'sdfwrite var'</div><div> t=t+1</div><div>endwhile</div><div><br></div><div>In this case, your variable has 3 dimensions (X, Y, and Z) but since you use the -4d flag the variable in the netcdf file will have 4 dimensions, with the 4th being time having a size of 1. But it will provide correct metadata for the time associated with that grid. If you want your netcdf variable to have only the 3 varyding dimensions , remove the -4d from the 'set sdfwrite' statement. </div><div>--Jennifer</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><br><blockquote type="cite"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: garamond, 'new york', times, serif; font-size: 14pt; position: static; z-index: auto; "><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;">t=1<br> while(t<=12)<br> 'set t 't<br><br> z=1</div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;"> while(z<=15)<br> 'set z 'z</div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-style: italic;"># rec=read(filename.nc)</span></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-style: italic;"><span># IO = sublin(rec,1)</span></span><i><br></i></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: italic;"><i># if (IO = 0)
</i><br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: italic;">#<i> a = subwrd(rec,2) </i><br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: italic;"># <i>endif </i><i><br></i></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: italic;"><i># 'sdfopen 'a'' <br></i></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: italic;"># <i>say '' <br></i></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: italic;"># <i>say ' Filename: 'a'' <br></i></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: italic;"># <i>say ' File no: 'z'_'t''</i></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: italic;"><i><br></i></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;"><br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new
york,times,serif; background-color: transparent; font-style: normal;"> 'define var = var'</div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;"> 'd var'</div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;"> #'set sdfwrite -4d flt -nc4 data-sort_'z'_'t'.nc'<br> #'sdfwrite var'</div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color:
transparent; font-style: normal;"><br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;"> z=z+1<br> endwhile<br> t=t+1<br>endwhile<br><br></div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;">Thank you for your help and support here.</div><div class="yui_3_13_0_ym1_6_1392287372419_29" style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;">Regards</div><div style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: garamond,new york,times,serif; background-color: transparent; font-style: normal;">Pankaj<br></div></div></div>_______________________________________________<br>gradsusr mailing list<br><a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>http://gradsusr.org/mailman/listinfo/gradsusr<br></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>--</div><div>Jennifer M. Adams<br>Center for Ocean-Land-Atmosphere Studies (COLA)<br>111 Research Hall, Mail Stop 2B3<br>George Mason University<br>4400 University Drive<br>Fairfax, VA 22030 <br><br></div><div><br class="khtml-block-placeholder"></div><br class="Apple-interchange-newline"></span></span></div></span></span><br class="Apple-interchange-newline">
</div>
<br></body></html>