From 0e2490bf2cbbbeab4453e81f7b64afa0f89b2203 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 20 Apr 2020 13:15:08 -0600 Subject: [PATCH] Move section until when sim_yr0 is determined and use it rather than sim_year as sime_year can be a range. Also correct comment about loop over future scenarios --- tools/mksurfdata_map/mksurfdata.pl | 38 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tools/mksurfdata_map/mksurfdata.pl b/tools/mksurfdata_map/mksurfdata.pl index 457cc3146d..74b90963e1 100755 --- a/tools/mksurfdata_map/mksurfdata.pl +++ b/tools/mksurfdata_map/mksurfdata.pl @@ -704,7 +704,7 @@ sub write_namelist_file { # my $double = ".true."; # - # Loop over each sim_year + # Loop over each SSP-RCP scenario # RCP: foreach my $ssp_rcp ( @rcpaths ) { # @@ -719,24 +719,6 @@ sub write_namelist_file { next SIM_YEAR; } # - # Find the file for each of the types - # - foreach my $typ ( @typlist ) { - my $hgrid = $hgrd{$typ}; - my $lmask = $lmsk{$typ}; - my $filnm = $filnm{$typ}; - my $typ_cmd = "$scrdir/../../bld/queryDefaultNamelist.pl $mkopts -options " . - "hgrid=$hgrid,lmask=$lmask,mergeGIS=$merge_gis$mkcrop,sim_year=$sim_year -var $filnm"; - $datfil{$typ} = `$typ_cmd`; - $datfil{$typ} = trim($datfil{$typ}); - if ( $datfil{$typ} !~ /[^ ]+/ ) { - die "ERROR: could NOT find a $filnm data file for this resolution: $hgrid and type: $typ and $lmask.\n$typ_cmd\n\n"; - } - if ( ! defined($opts{'allownofile'}) && ! -f $datfil{$typ} ) { - die "ERROR: data file for this resolution does NOT exist ($datfil{$typ}).\n"; - } - } - # # If year is 1850-2000 actually run 1850-2015 # if ( $sim_year eq "1850-2000" ) { @@ -755,6 +737,24 @@ sub write_namelist_file { $sim_yrn = $2; $transient = 1; } + # + # Find the file for each of the types + # + foreach my $typ ( @typlist ) { + my $hgrid = $hgrd{$typ}; + my $lmask = $lmsk{$typ}; + my $filnm = $filnm{$typ}; + my $typ_cmd = "$scrdir/../../bld/queryDefaultNamelist.pl $mkopts -options " . + "hgrid=$hgrid,lmask=$lmask,mergeGIS=$merge_gis$mkcrop,sim_year=$sim_yr0 -var $filnm"; + $datfil{$typ} = `$typ_cmd`; + $datfil{$typ} = trim($datfil{$typ}); + if ( $datfil{$typ} !~ /[^ ]+/ ) { + die "ERROR: could NOT find a $filnm data file for this resolution: $hgrid and type: $typ and $lmask.\n$typ_cmd\n\n"; + } + if ( ! defined($opts{'allownofile'}) && ! -f $datfil{$typ} ) { + die "ERROR: data file for this resolution does NOT exist ($datfil{$typ}).\n"; + } + } # determine simulation year to use for the surface dataset: my $sim_yr_surfdat = "$sim_yr0";