-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconv2nc.tcl
More file actions
executable file
·39 lines (28 loc) · 971 Bytes
/
conv2nc.tcl
File metadata and controls
executable file
·39 lines (28 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/env convsh
# Convsh script conv2nc.tcl
#
# Convert each file, into a corresponding netCDF file.
# File names are taken from the command arguments.
# For example to convert all PP files in the current directory
# into netCDF files use the following command:
#
# ./conv2nc.tcl *.pp
# Write out netCDF file
set outformat netcdf
# Automatically work out input file type
set filetype 0
# Convert all fields in input files to netCDF
set fieldlist -1
# Read in each of the input files and write output file
foreach infile $argv {
# Replace input file extension with .nc to get output filename
# set outfile [file tail [file rootname $infile].nc]
# Make outfile the same as infile with ".nc" extension
set outfile ${infile}.nc
# Read input file
readfile $filetype $infile
# Write out all input fields to a netCDF file
writefile $outformat $outfile $fieldlist
# Remove input file information from Convsh's memory
clearall
}