Dear All,<br><br>Just want to let you know of my simple ruby library to manipulate namelists<br>for WRF or any fortran namelists at<br><br> <a href="https://github.com/sajinh/fortran-namelist">https://github.com/sajinh/fortran-namelist</a><br>
<br>Questions/bugs to <a href="mailto:saji@u-aizu.ac.jp">saji@u-aizu.ac.jp</a><br><br>saji<br>---<br>How to use: Commented explanations can be found<br> in the above website<br><br> <span style="font-family:courier new,monospace">require './lib/nml'</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">nml_file = "./namelists/namelist.wps.all_options"</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"># Read in and manipulate a fortran namelist<br>
nml = NML_Reader.read(nml_file)</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">share=nml[:share].keep :wrf_core,</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> :max_dom,</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> :start_date,</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> :end_date,</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> :interval_seconds,</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> :io_form_geogrid</span><br style="font-family:courier new,monospace"><br>share[:start_date] = '2012-01-01-00-00'<br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">geogrid=nml[:geogrid]</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">geogrid.del :s_we, :s_sn, :ref_x, :ref_y</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">ungrib=nml[:ungrib]</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">metgrid=nml[:metgrid].del :process_only_bdy,<br>
:constants_name,</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> :opt_output_from_metgrid_path</span><br style="font-family:courier new,monospace">
<br># Create namelist groups<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">nshare = NML_Group.create(:share)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">nshare << share << {:a => 1}</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">ngrid = NML_Group.create(:geogrid)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">ngrid << geogrid</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">ungrb = NML_Group.create(:ungrib)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">ungrb << nml[:ungrib]</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">nmet = NML_Group.create(:metgrid)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">nmet << metgrid</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">outfil = File.new("<a href="http://namelist.wps.asia">namelist.wps.asia</a>","w")</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"><br># Concat namelist groups to create a new namelist<br>NML_Writer << nshare << ngrid << ungrb << nmet<br><br># Flush out namelist to outfil<br style="font-family:courier new,monospace">
</span><span style="font-family:courier new,monospace">NML_Writer >> outfil</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">outfil.close</span><br><br>Enjoy!<br><br>
Copyright Saji Hameed (2012) <a href="mailto:saji.uaizu@gmail.com">saji.uaizu@gmail.com</a><br>-- <br><br>Saji N Hameed,<br>ARC-ENV, Center for Advanced Information Science and Technology,<br>University of Aizu, Tsuruga, Ikki-machi,<br>
Aizuwakamatsu-shi, Fukushima 965-8580,<br>Japan<br> <br>Tel: +81242 37-2736<br>Fax:+81242 37-2760<br> email: <a href="mailto:saji@u-aizu.ac.jp">saji@u-aizu.ac.jp</a><br> url: <a href="http://www.u-aizu.ac.jp">http://www.u-aizu.ac.jp</a><br>
bib: <a href="http://www.researcherid.com/rid/B-9188-2009">http://www.researcherid.com/rid/B-9188-2009</a><br><br>