@@ -604,7 +604,7 @@ sub write_namelist_file {
604604 my $mkcrop_on = " ,crop='on'" ;
605605
606606 #
607- # Loop over all resolutions listed
607+ # Loop over all resolutions and sim-years listed
608608 #
609609 foreach my $res ( @hresols ) {
610610 #
@@ -628,7 +628,7 @@ sub write_namelist_file {
628628 #
629629 # Mapping files
630630 #
631- my %map ; my %hgrd ; my %lmsk ; my %datfil ;
631+ my %map ; my %hgrd ; my %lmsk ; my %datfil ; my %filnm ;
632632 my $hirespft = " off" ;
633633 if ( defined ($opts {' hirespft' }) ) {
634634 $hirespft = " on" ;
@@ -659,8 +659,9 @@ sub write_namelist_file {
659659 $hgrid = trim($hgrid );
660660 my $filnm = ` $scrdir /../../bld/queryDefaultNamelist.pl $mopts -options type=$typ -var mksrf_filename` ;
661661 $filnm = trim($filnm );
662- $hgrd {$typ } = $hgrid ;
663- $lmsk {$typ } = $lmask ;
662+ $filnm {$typ } = $filnm ;
663+ $hgrd {$typ } = $hgrid ;
664+ $lmsk {$typ } = $lmask ;
664665 if ( $opts {' hgrid' } eq " usrspec" ) {
665666 $map {$typ } = $opts {' usr_mapdir' }." /map_${hgrid} _${lmask} _to_${res} _nomask_aave_da_c${mapdate} \. nc" ;
666667 } else {
@@ -672,15 +673,6 @@ sub write_namelist_file {
672673 }
673674 if ( ! defined ($opts {' allownofile' }) && ! -f $map {$typ } ) {
674675 die " ERROR: mapping file for this resolution does NOT exist ($map {$typ }).\n " ;
675- }
676- my $typ_cmd = " $scrdir /../../bld/queryDefaultNamelist.pl $mkopts -options hgrid=$hgrid ,lmask=$lmask ,mergeGIS=$merge_gis$mkcrop -var $filnm " ;
677- $datfil {$typ } = ` $typ_cmd ` ;
678- $datfil {$typ } = trim($datfil {$typ });
679- if ( $datfil {$typ } !~ / [^ ]+/ ) {
680- die " ERROR: could NOT find a $filnm data file for this resolution: $hgrid and type: $typ and $lmask .\n $typ_cmd \n\n " ;
681- }
682- if ( ! defined ($opts {' allownofile' }) && ! -f $datfil {$typ } ) {
683- die " ERROR: data file for this resolution does NOT exist ($datfil {$typ }).\n " ;
684676 }
685677 }
686678 #
@@ -712,7 +704,7 @@ sub write_namelist_file {
712704 #
713705 my $double = " .true." ;
714706 #
715- # Loop over each sim_year
707+ # Loop over each SSP-RCP scenario
716708 #
717709 RCP: foreach my $ssp_rcp ( @rcpaths ) {
718710 #
@@ -745,6 +737,24 @@ sub write_namelist_file {
745737 $sim_yrn = $2 ;
746738 $transient = 1;
747739 }
740+ #
741+ # Find the file for each of the types
742+ #
743+ foreach my $typ ( @typlist ) {
744+ my $hgrid = $hgrd {$typ };
745+ my $lmask = $lmsk {$typ };
746+ my $filnm = $filnm {$typ };
747+ my $typ_cmd = " $scrdir /../../bld/queryDefaultNamelist.pl $mkopts -options " .
748+ " hgrid=$hgrid ,lmask=$lmask ,mergeGIS=$merge_gis$mkcrop ,sim_year=$sim_yr0 -var $filnm " ;
749+ $datfil {$typ } = ` $typ_cmd ` ;
750+ $datfil {$typ } = trim($datfil {$typ });
751+ if ( $datfil {$typ } !~ / [^ ]+/ ) {
752+ die " ERROR: could NOT find a $filnm data file for this resolution: $hgrid and type: $typ and $lmask .\n $typ_cmd \n\n " ;
753+ }
754+ if ( ! defined ($opts {' allownofile' }) && ! -f $datfil {$typ } ) {
755+ die " ERROR: data file for this resolution does NOT exist ($datfil {$typ }).\n " ;
756+ }
757+ }
748758 # determine simulation year to use for the surface dataset:
749759 my $sim_yr_surfdat = " $sim_yr0 " ;
750760
0 commit comments