[ncl-talk] read namelist file in NCL

Dennis Shea shea at ucar.edu
Wed Sep 20 17:50:21 MDT 2017


Creating a function that reads and evaluate  a f77 or (more complicated)
f90 namelist would require significant effort. For example, there cane be
multiple "groups"; f90 "derived types" (I think), etc

I took a crack at reading the provided namelist using keyword==>value
approach. It is all about book-keeping! For example, the trailing "," must
be addressed.

I have only checked it out with the provided namelist. You can modify to
fit your needs. Use print to check your results.

---
%> ncl tst.read_namelist.ncl

=======

(0)    val_1=5
(0)
(0)    val_2=True
(1)    val_2=True
(2)    val_2=True
(0)
(0)    val_3=wrfout/wrfout_d<domain>_<date>
(0)
(0)    val_4=2015
(1)    val_4=2001
(2)    val_4=2001




On Wed, Sep 20, 2017 at 9:45 AM, Rick Brownrigg <brownrig at ucar.edu> wrote:

> Hi,
>
> I am unaware of an NCL function that directly reads the namelist.
> However, you might look at this example:
>
> http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/
> Examples/EXPERIMENTAL/wrf_show_wps_som_namelist.htm
>
> It uses system calls to "grep" through a namelist file to pull out fields
> that are of interest.
>
> Hope that helps...
> Rick
>
> On Wed, Sep 20, 2017 at 8:54 AM, Zhifeng Yang <yangzf01 at gmail.com> wrote:
>
>> Hi
>>
>> Is there any methods to read a namelist file directly? Similar to
>> FORTRAN. Here is an example of namelist file from WRF
>>
>> &time_control
>>  run_days                            = 5,
>>  run_hours                           = 0,
>>  run_minutes                         = 0,
>>  run_seconds                         = 0,
>>  start_year                          = 2015, 2001, 2001,
>>  start_month                         = 06,   06,   06,
>>  start_day                           = 19,   11,   11,
>>  start_hour                          = 00,   12,   12,
>>  start_minute                        = 00,   00,   00,
>>  start_second                        = 00,   00,   00,
>>  end_year                            = 2015, 2001, 2001,
>>  end_month                           = 06,   06,   06,
>>  end_day                             = 24,   12,   12,
>>  end_hour                            = 00,   12,   12,
>>  end_minute                          = 00,   00,   00,
>>  end_second                          = 00,   00,   00,
>>  interval_seconds                    = 600
>>  input_from_file                     = .true.,.true.,.true.,
>>  history_interval                    = 10,   60,   60,
>>  frames_per_outfile                  = 1,    1,    1,
>>  restart                             = .false.,
>>  restart_interval                    = 5000,
>>  io_form_history                     = 2
>>  io_form_restart                     = 2
>>  io_form_input                       = 2
>>  io_form_boundary                    = 2
>>  auxinput1_inname                    = "../../../WPS/wpsout_cus_4km/m
>> et_em.d<domain>.<date>"
>>  history_outname                     = "wrfout/wrfout_d<domain>_<date>"
>>  debug_level                         = 0
>>
>> I want to read this file with variable names and values from NCL. Thank
>> you
>>
>> Best,
>> Zhifeng
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170920/9ee945c0/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tst.read_namelist.ncl
Type: application/octet-stream
Size: 4963 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170920/9ee945c0/attachment.obj>


More information about the ncl-talk mailing list