Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Ok I got your point, so bellow is the file I think it has the issue :
#!/usr/bin/perl -w use Class::Date qw(date now); use File::Path; use File::Copy; use List::Util qw(min max); chomp( $region = $ARGV[0] ); chomp( $lrun = $ARGV[1] ); chomp( $flag = $ARGV[2] ); if ( $flag =~ m/^(00|06|12|18)$/ ) { $hh = $flag; chomp( $yyyymmdd = `date +%Y%m%d` ); $yymmdd = substr( $yyyymmdd, 2, 6 ); $real_time = 1; } elsif ( $flag =~ m!^(19|20)\d\d(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])(00|06|12|18) +$! ) { $yyyymmdd = substr( $flag, 0, 8 ); $yymmdd = substr( $yyyymmdd, 2, 6 ); $hh = substr( $flag, 8, 2 ); $real_time = 1; } $yyyymmddhh = $yyyymmdd . $hh; $Class::Date::DATE_FORMAT = "%Y-%m-%d_%H:%M:%S"; $data_inici = date $yyyymmddhh. "0000"; $copyright = $data_inici->year; $data_final = $data_inici + "$lrun h"; $root = '/home/meteo/Build_WRF'; $regdir = "$root/SCRIPTS$region"; $wpsdir = "$root/WPS"; $wrfdir = "$root/WRFV3"; $wrfdmdir = "$root/WRFV3"; $postdir = "$root/ARWpost"; $rundir = "$root/DATA/WRF/$region/$yyyymmddhh"; $gfsdir = '/home/meteo/Build_WRF/DATA/GFS'; $mapsdir = "/home/meteo/Build_WRF/DATA/MAPS/$region/$ +yyyymmddhh"; $grads = '/home/meteo/Build_WRF/LIBRARIES/grads/bin/grads'; if ( !-d $mapsdir ) { mkpath($mapsdir) or die $!; } else { rmtree($mapsdir) or die $!; mkpath($mapsdir) or die $!; } chdir("$rundir/arwpost") or die $!; %var_list = ( 'prec' => 'Total precipitation (mm)', 't2m' => 'Temperature at 2m (Celsius)', 't850' => 'Temperature at 850hPa (Celsius)', 't500' => 'Temperature at 500hPa (Celsius)', 't700' => 'Temperature at 700hPa (Celsius)', 'slp' => 'Sea level pressure (hPa)', 'clfr' => 'Total cloud clover (%)', 'prec_slp' => 'Precipitation (mm) and SLP (hPa)', 'prec_type' => 'Precipitation type', 'frozen_lvl' => 'Frozen level (m)', 'wind10_slp' => 'Wind 10m (m/s) and SLP (hPa)', 'prec24' => '24h Precipitation (mm)', 'acsnow' => 'Accumulated snow and ice (mm) + snow cover', # 'cape' => 'CAPE (J/kg)' ); @doms = ( 'd01', 'd02' ); foreach (@doms) { $domain = $_; if ( $domain eq 'd01' ) { $xsize = '850'; $ysize = '650'; $img_size = '850x650'; $latmin = '34.0'; $latmax = '72.5'; $lonmin = '-12.3333'; $lonmax = '39.0'; $logo_size = '+130+540'; $region_plot = 'europe-27km'; $gradsdir = "$root/Build_WRF/SCRIPTS/grads_europe"; } elsif ( $domain eq 'd02' ) { $xsize = '850'; $ysize = '650'; $img_size = '850x650'; $latmin = '34.6875'; $latmax = '41.8125'; $lonmin = '19.0'; $lonmax = '28.5'; $logo_size = '+130+540'; $region_plot = 'greece-9km'; $gradsdir = "$root/Build_WRF/SCRIPTS/grads_greece"; } elsif ( $domain eq 'd03' ) { $xsize = '850'; $ysize = '650'; $img_size = '850x650'; $latmin = '37.3875'; $latmax = '39.1125'; $lonmin = '23.0'; $lonmax = '25.3'; $logo_size = '+130+540'; $region_plot = 'attica-3km'; $gradsdir = "$root/Build_WRF/SCRIPTS/grads_attica"; } $mapsdir = "/home/meteo/Build_WRF/DATA/MAPS/$region_plot/$yyyymmdd +hh"; if ( !-d $mapsdir ) { mkpath($mapsdir) or die $!; } else { rmtree($mapsdir) or die $!; mkpath($mapsdir) or die $!; } chdir("$rundir/arwpost") or die $!; while ( ( $var, $name ) = each(%var_list) ) { print("$var, $fname\n"); if ( $var eq 'prec' || $var eq 'prec_type' || $var eq 'prec_sl +p' ) { $data = $data_inici; while ( $data <= $data_final ) { print "$region_plot $gradsdir $var \"$name\" $data\n"; $Class::Date::DATE_FORMAT = "%Y-%m-%d %H"; $title = "$name $data UTC"; $Class::Date::DATE_FORMAT = "%Y%m%d%H"; $pngfile = "$data\_$var.png"; $Class::Date::DATE_FORMAT = "%Y-%m-%d_%H:%M:%S"; $ctlfile = "wrfout_$domain\_$data.ctl +"; $data2 = $data - '1h'; $ctlfile2 = "wrfout_$domain\_$data2.ct +l"; if ( $data != $data_inici ) { open( GS1, ">$rundir/arwpost/commands.gs" ) or die + $!; print GS1 "'open $ctlfile'\n"; print GS1 "'open $ctlfile2'\n"; print GS1 "'clear'\n"; print GS1 "'set lat $latmin $latmax'\n"; print GS1 "'set lon $lonmin $lonmax'\n"; print GS1 "'run $gradsdir/$var\_in.gs'\n"; print GS1 "'run $gradsdir/xcbar.gs -fs 3 -edge cir +cle'\n"; print GS1 "'set font 0'\n"; print GS1 "'set rgb 100 100 0 100'\n"; print GS1 "'set map 1 1 6'\n"; print GS1 "'set string 1 tc 5'\n"; print GS1 "'draw string 5.5 0.4 kairos.gr copyrigh +t $copyright'\n"; print GS1 "'set strsiz 0.18'\n"; print GS1 "'set string 1 tc 9'\n"; print GS1 "'draw string 5.5 8.2 $title'\n"; print GS1 "'set mpdraw off'\n"; print GS1 "'printim $mapsdir/$pngfile png white x$ +xsize y$ysize -b /home/meteo/Build_WRF/SCRIPTS/background.png'\n"; print GS1 "'quit'\n"; close(GS1); } else { open( GS2, ">$rundir/arwpost/commands.gs" ) or die + $!; print GS2 "'open $ctlfile'\n"; print GS2 "'clear'\n"; print GS2 "'set lat $latmin $latmax'\n"; print GS2 "'set lon $lonmin $lonmax'\n"; print GS2 "'run $gradsdir/$var.gs'\n"; print GS2 "'run $gradsdir/xcbar.gs -fs 3 -edge cir +cle'\n"; print GS2 "'set font 0'\n"; print GS2 "'set rgb 100 100 0 100'\n"; print GS2 "'set map 1 1 6'\n"; print GS2 "'set string 1 tc 5'\n"; print GS2 "'draw string 5.5 0.4 kairos.gr copyrigh +t $copyright'\n"; print GS2 "'set strsiz 0.18'\n"; print GS2 "'set string 1 tc 9'\n"; print GS2 "'draw string 5.5 8.2 $title'\n"; print GS2 "'set mpdraw off'\n"; print GS2 "'printim $mapsdir/$pngfile png white x$ +xsize y$ysize'\n"; print GS2 "'quit'\n"; close(GS2); } @args = ("$grads -blc $rundir/arwpost/commands.gs > /d +ev/null 2>&1"); print("@args\n"); system(@args) == 0 or die $!; open( LG, ">$rundir/arwpost/composite.sh" ) or die $!; print LG "#!/bin/bash\n"; print LG "convert -size $img_size xc:white $mapsdir/co +mposite.png\n"; print LG "composite -geometry +0+0 $mapsdir/$pngfile $ +mapsdir/composite.png $mapsdir/composite.png\n"; print LG "mv $mapsdir/composite.png $mapsdir/$pngfile" +; close(LG); my $file = "$rundir/arwpost/composite.sh"; chmod 0755, $file or die "Couldn't chmod $file: $!"; @args = ("$file > /dev/null 2>&1"); print("@args\n"); system(@args) == 0 or die $!; $data = $data + '1h'; } } elsif ($var eq 't2m' || $var eq 't850' || $var eq 't500' || $v +ar eq 'slp' || $var eq 'clfr' || $var eq 'frozen_lvl' || $var eq 'wind1 +0_slp' || $var eq 'acsnow' || $var eq 'cape' ) { $data = $data_inici; while ( $data <= $data_final ) { print "$region_plot $gradsdir $var \"$name\" $data\n"; $Class::Date::DATE_FORMAT = "%Y-%m-%d %H"; $title = "$name $data UTC"; $Class::Date::DATE_FORMAT = "%Y%m%d%H"; $pngfile = "$data\_$var.png"; $Class::Date::DATE_FORMAT = "%Y-%m-%d_%H:%M:%S"; $ctlfile = "wrfout_$domain\_$data.ctl +"; open( GS3, ">$rundir/arwpost/commands.gs" ) or die $!; print GS3 "'open $ctlfile'\n"; print GS3 "'clear'\n"; print GS3 "'set lat $latmin $latmax'\n"; print GS3 "'set lon $lonmin $lonmax'\n"; print GS3 "'run $gradsdir/$var.gs'\n"; print GS3 "'run $gradsdir/xcbar.gs -fs 3 -edge circle' +\n"; print GS3 "'set font 0'\n"; print GS3 "'set rgb 100 100 0 100'\n"; print GS3 "'set map 1 1 6'\n"; print GS3 "'set string 1 tc 5'\n"; print GS3 "'draw string 5.5 0.4 kairos.gr copyright $c +opyright'\n"; print GS3 "'set strsiz 0.18'\n"; print GS3 "'set string 1 tc 9'\n"; print GS3 "'draw string 5.5 8.2 $title'\n"; print GS3 "'set mpdraw off'\n"; print GS3 "'printim $mapsdir/$pngfile png white x$xsiz +e y$ysize'\n"; print GS3 "'quit'\n"; close(GS3); @args = ("$grads -blc $rundir/arwpost/commands.gs > /d +ev/null 2>&1"); print("@args\n"); system(@args) == 0 or die $!; open( LG, ">$rundir/arwpost/composite.sh" ) or die $!; print LG "#!/bin/bash\n"; print LG "convert -size $img_size xc:white $mapsdir/co +mposite.png\n"; print LG "composite -geometry +0+0 $mapsdir/$pngfile $ +mapsdir/composite.png $mapsdir/composite.png\n"; print LG "mv $mapsdir/composite.png $mapsdir/$pngfile" +; close(LG); my $file = "$rundir/arwpost/composite.sh"; chmod 0755, $file or die "Couldn't chmod $file: $!"; @args = ("$file > /dev/null 2>&1"); print("@args\n"); system(@args) == 0 or die $!; $data = $data + '1h'; } } elsif ( $var eq 'prec24' ) { $data = $data_inici; while ( $data < $data_final ) { print "$region_plot $gradsdir $var \"$name\" $data\n"; $Class::Date::DATE_FORMAT = "%Y-%m-%d %H"; $title = "$name $data UTC"; $Class::Date::DATE_FORMAT = "%Y%m%d%H"; $pngfile = "$data\_$var.png"; $data = $data + '24h'; $Class::Date::DATE_FORMAT = "%Y-%m-%d_%H:%M:%S"; $ctlfile = "wrfout_$domain\_$data.ctl +"; $data2 = $data - '24h'; $ctlfile2 = "wrfout_$domain\_$data2.ct +l"; open( GS4, ">$rundir/arwpost/commands.gs" ) or die $!; print GS4 "'open $ctlfile'\n"; print GS4 "'open $ctlfile2'\n"; print GS4 "'clear'\n"; print GS4 "'set lat $latmin $latmax'\n"; print GS4 "'set lon $lonmin $lonmax'\n"; print GS4 "'run $gradsdir/$var\_in.gs'\n"; print GS4 "'run $gradsdir/xcbar.gs -fs 3 -edge circle' +\n"; print GS4 "'set font 0'\n"; print GS4 "'set rgb 100 100 0 100'\n"; print GS4 "'set map 1 1 6'\n"; print GS4 "'set strsiz 0.18'\n"; print GS4 "'set string 1 tc 5'\n"; print GS4 "'draw string 5.5 0.4 kairos.gr copyright $c +opyright'\n"; print GS4 "'set string 1 tc 9'\n"; print GS4 "'draw string 5.5 8.2 $title'\n"; print GS4 "'set mpdraw off'\n"; print GS4 "'printim $mapsdir/$pngfile png white x$xsiz +e y$ysize -b /home/meteo/Build_WRF/SCRIPTS/background.png'\n"; print GS4 "'quit'\n"; close(GS4); @args = ("$grads -blc $rundir/arwpost/commands.gs > /d +ev/null 2>&1"); print("@args\n"); system(@args) == 0 or die $!; open( LG, ">$rundir/arwpost/composite.sh" ) or die $!; print LG "#!/bin/bash\n"; print LG "convert -size $img_size xc:white $mapsdir/co +mposite.png\n"; print LG "composite -geometry +0+0 $mapsdir/$pngfile $ +mapsdir/composite.png $mapsdir/composite.png\n"; print LG "mv $mapsdir/composite.png $mapsdir/$pngfile" +; close(LG); my $file = "$rundir/arwpost/composite.sh"; chmod 0755, $file or die "Couldn't chmod $file: $!"; @args = ("$file > /dev/null 2>&1"); print("@args\n"); system(@args) == 0 or die $!; } } } } exit;

In reply to Re^4: Perl script error by sellinios
in thread Perl script error by sellinios

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-24 13:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found