From 66b3301439ce71b1ac1cbb20fd6a81112b78c848 Mon Sep 17 00:00:00 2001 From: Jason Fleming Date: Sun, 19 Jul 2026 09:26:37 -0400 Subject: [PATCH 1/3] Initial fixes for smoke test that looks at all variables to resolve #1731 --- bin/get_nam_data.pl | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/bin/get_nam_data.pl b/bin/get_nam_data.pl index 6612a8b5d..6096679ef 100755 --- a/bin/get_nam_data.pl +++ b/bin/get_nam_data.pl @@ -238,7 +238,7 @@ if ( -e $localDir."/".$f ) { # perform a smoke test on the file we found to check that it is # not corrupted (not a definitive test but better than nothing) - if ( `$scriptdir/bin/wgrib2 $localDir/$f -match PRMSL -inv - -text /dev/null` =~ /PRMSL/ ) { + if ( grib2SmokeTestOK($localDir/$f) ) { ASGSUtil::stderrMessage( "INFO", "'$f' has already been downloaded to '$localDir'."); @@ -267,7 +267,7 @@ #ASGSUtil::stderrMessage("DEBUG","Now have data for $dirDate$hourString."); # perform a smoke test on the file we found to check that it is # not corrupted (not a definitive test but better than nothing) - if ( `$scriptdir/bin/wgrib2 $localDir/$f -match PRMSL -inv - -text /dev/null` =~ /PRMSL/ ) { + if ( grib2SmokeTestOK($localDir/$f) ) { $dl++; push(@files_downloaded,"$localDir/$f"); } else { @@ -351,7 +351,7 @@ if ( -e $localDir."/".$f ) { # perform a smoke test on the file we found to check that it is # not corrupted (not a definitive test but better than nothing) - if ( `$scriptdir/bin/wgrib2 $localDir/$f -match PRMSL -inv - -text /dev/null` =~ /PRMSL/ ) { + if ( grib2SmokeTestOK($localDir/$f) ) { ASGSUtil::stderrMessage( "INFO", "'$f' has already been downloaded to '$localDir'."); @@ -450,7 +450,7 @@ sub partialGribDownload { my $response = $ua->mirror($idx, "$localDir/$idxfile"); my $err = $response->{success} ? 0 : $response->{status}; - + if ($err != 0) { ASGSUtil::stderrMessage( "INFO", @@ -569,3 +569,19 @@ sub partialGribDownload { } return; } +# +# check that grib2 files contain PRMSL, UGRD:10, +# and VGRID:10 datasets. Returns 1 if ok, 0 if data +# are missing. +# +sub grib2SmokeTestOK { + my ( $grib2File ) = @_; + my @grib2Parameters = qw(PRMSL UGRD:10 VGRD:10); + my $smokeTestOK = 1; + foreach my $p (@grib2Parameters) { + unless ( `$scriptdir/bin/wgrib2 $grib2File -match $p -inv - -text /dev/null` =~ /$p/ ) { + $smokeTestOK = 0; + } + } + return $smokeTestOK; +} \ No newline at end of file From 1a0f3c0c1c7fe59bb557cb6be4a84189b40f899f Mon Sep 17 00:00:00 2001 From: Jason Fleming Date: Sun, 19 Jul 2026 09:55:25 -0400 Subject: [PATCH 2/3] Added quotes to file path string; added trailing slash tweak to resolve #1738 --- bin/get_nam_data.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/get_nam_data.pl b/bin/get_nam_data.pl index 6096679ef..9737223ed 100755 --- a/bin/get_nam_data.pl +++ b/bin/get_nam_data.pl @@ -238,7 +238,7 @@ if ( -e $localDir."/".$f ) { # perform a smoke test on the file we found to check that it is # not corrupted (not a definitive test but better than nothing) - if ( grib2SmokeTestOK($localDir/$f) ) { + if ( grib2SmokeTestOK("$localDir/$f") ) { ASGSUtil::stderrMessage( "INFO", "'$f' has already been downloaded to '$localDir'."); @@ -267,7 +267,7 @@ #ASGSUtil::stderrMessage("DEBUG","Now have data for $dirDate$hourString."); # perform a smoke test on the file we found to check that it is # not corrupted (not a definitive test but better than nothing) - if ( grib2SmokeTestOK($localDir/$f) ) { + if ( grib2SmokeTestOK("$localDir/$f") ) { $dl++; push(@files_downloaded,"$localDir/$f"); } else { @@ -351,7 +351,7 @@ if ( -e $localDir."/".$f ) { # perform a smoke test on the file we found to check that it is # not corrupted (not a definitive test but better than nothing) - if ( grib2SmokeTestOK($localDir/$f) ) { + if ( grib2SmokeTestOK("$localDir/$f") ) { ASGSUtil::stderrMessage( "INFO", "'$f' has already been downloaded to '$localDir'."); From 4a0147656f1ff78309159ee2a6e162ddeaa91002 Mon Sep 17 00:00:00 2001 From: Jason Fleming Date: Mon, 20 Jul 2026 13:03:51 -0400 Subject: [PATCH 3/3] Removed trailing slash fix that was already merged to master --- bin/get_nam_status.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/get_nam_status.pl b/bin/get_nam_status.pl index 99e9a5016..23be46fa3 100755 --- a/bin/get_nam_status.pl +++ b/bin/get_nam_status.pl @@ -62,7 +62,7 @@ sub http_dir { my $dir = shift; - my $url = sprintf( qq{https://nomads.ncep.noaa.gov%s/}, $dir ); + my $url = sprintf( qq{https://nomads.ncep.noaa.gov%s}, $dir ); my $res = $ua->get($url); my $raw_listing = $res->{content}; my @dirs = ( $raw_listing =~ m/href="(nam\.\d{8}|\d\d)\/"/g );