Ticket #1120: extractField0Level0Aust

File extractField0Level0Aust, 2.0 KB (added by cbirch, 7 years ago)
Line 
1#!/usr/bin/convsh
2
3#  Convsh script conv2nc.tcl
4#
5#  Convert input files into single Netcdf file.
6#  All input files must contain the same fields and have
7#  identical dimensions except for the time dimension.
8#  For example to convert UM output files into a Netcdf file
9#  use the following command:
10#
11#      conv2nc.tcl -i xaavaa.pc* -o xaava.nc
12 
13#  Write out Netcdf file
14set outformat netcdf
15
16#  Automatically work out input file type
17set filetype 0
18
19#  Choose limited fields in input files to Netcdf
20set fieldlist "0"
21
22#  Get command line arguments:
23#      -i input files (can be more than one file)
24#      -o output file (single file only)
25
26set i false
27set o false
28foreach arg $argv {
29   switch -glob -- $arg {
30      -i      {set i true ; set o false}
31      -o      {set i false ; set o true}
32      -*      {puts "unknown option $arg" ; set i false; set o false}
33      default {
34         if {$i} {
35            set infile [lappend infile $arg]
36         } elseif {$o} {
37            set outfile [lappend outfile $arg]
38         } else {
39            puts "unknown option $arg"
40         }
41      }
42   }
43}
44
45if {! [info exists infile]} {
46   puts "input file name must be given"
47   exit
48}
49
50if {[info exists outfile]} {
51   if {[llength $outfile] > 1} {
52      set outfile [lindex $outfile 0]
53      puts "Only one output file can be specified, using $outfile"
54   }
55} else {
56   puts "output file name must be given"
57   exit
58}
59
60#  Read in each of the input files
61
62foreach file $infile {
63   readfile $filetype $file
64
65# Choose limited levels
66
67setdim 3 $fieldlist "0"
68
69# setdim 4 $fieldlist "0         1       2       3       4       5       6       7       8       9  10  11  12  13      14      15      16      17"
70
71
72# Choose restricted grid setgrid 1 xnum xstart xinc - xnum=no of gridpoints, xstart=starting in degs, xinc=increment in degs
73# !!!!!!!!!!!!!!!!!!!!!!AVOID INTERPOLATION!!!!!!!!!!!!!!!!!!!!
74 setgrid 1 "820" "70" "0.175781"
75 setgrid 2 "614" "-54.0" "0.117188"
76 interp_grid $fieldlist
77
78}
79
80#  Write out all input fields to a single Netcdf file
81
82writefile $outformat $outfile $fieldlist
83