From 699175061fbcbc250b25b866b640a8b17d6b959f Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 2 Aug 2018 11:27:39 +0100 Subject: [PATCH] Perl script for generating mars class, type and stream --- definitions/marsattrib_db2def.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/definitions/marsattrib_db2def.pl b/definitions/marsattrib_db2def.pl index d6ea666fb..10c52f525 100755 --- a/definitions/marsattrib_db2def.pl +++ b/definitions/marsattrib_db2def.pl @@ -1,4 +1,6 @@ -#!/usr/local/bin/perl56 -I/usr/local/lib/metaps/perl +#! /usr/local/apps/perl/current/bin/perl + +# old #!/usr/local/bin/perl56 -I/usr/local/lib/metaps/perl use strict; use warnings; @@ -19,19 +21,19 @@ use DBI; my $db="param"; my $host="grib-param-db-prod.ecmwf.int"; -my $user="ecmwf_ro"; -my $pass="ecmwf_ro"; +my $user="ecmwf_ro"; # Read-only access to Param DB +my $pass="ecmwf_ro"; # Read-only access to Param DB my $dbh = DBI->connect("dbi:mysql(RaiseError=>1):database=$db;host=$host","$user","$pass") or die $DBI::errstr; my $mars_dir = "mars"; -foreach my $att qw(class type stream) { +foreach my $att ('class', 'type', 'stream') { my $sth = $dbh->prepare("select grib_code,mars_abbreviation,long_name from grib_$att order by grib_code"); $sth->execute(); my $mars_file = "${mars_dir}/${att}.table"; - open OUT,">${mars_file}" or die $!; + open OUT,">${mars_file}" or die "Failed to write \"$mars_file\": $!"; print OUT "0 0 Unknown\n"; while (my @row = $sth->fetchrow_array) {