[Wrf-users] Manipulating WRF namelists with ruby
Saji Hameed
saji at u-aizu.ac.jp
Wed Apr 4 00:01:31 MDT 2012
Dear All,
Just want to let you know of my simple ruby library to manipulate namelists
for WRF or any fortran namelists at
https://github.com/sajinh/fortran-namelist
Questions/bugs to saji at u-aizu.ac.jp
saji
---
How to use: Commented explanations can be found
in the above website
require './lib/nml'
nml_file = "./namelists/namelist.wps.all_options"
# Read in and manipulate a fortran namelist
nml = NML_Reader.read(nml_file)
share=nml[:share].keep :wrf_core,
:max_dom,
:start_date,
:end_date,
:interval_seconds,
:io_form_geogrid
share[:start_date] = '2012-01-01-00-00'
geogrid=nml[:geogrid]
geogrid.del :s_we, :s_sn, :ref_x, :ref_y
ungrib=nml[:ungrib]
metgrid=nml[:metgrid].del :process_only_bdy,
:constants_name,
:opt_output_from_metgrid_path
# Create namelist groups
nshare = NML_Group.create(:share)
nshare << share << {:a => 1}
ngrid = NML_Group.create(:geogrid)
ngrid << geogrid
ungrb = NML_Group.create(:ungrib)
ungrb << nml[:ungrib]
nmet = NML_Group.create(:metgrid)
nmet << metgrid
outfil = File.new("namelist.wps.asia","w")
# Concat namelist groups to create a new namelist
NML_Writer << nshare << ngrid << ungrb << nmet
# Flush out namelist to outfil
NML_Writer >> outfil
outfil.close
Enjoy!
Copyright Saji Hameed (2012) saji.uaizu at gmail.com
--
Saji N Hameed,
ARC-ENV, Center for Advanced Information Science and Technology,
University of Aizu, Tsuruga, Ikki-machi,
Aizuwakamatsu-shi, Fukushima 965-8580,
Japan
Tel: +81242 37-2736
Fax:+81242 37-2760
email: saji at u-aizu.ac.jp
url: http://www.u-aizu.ac.jp
bib: http://www.researcherid.com/rid/B-9188-2009
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/wrf-users/attachments/20120404/94f76abf/attachment.html
More information about the Wrf-users
mailing list