ESCOMP / CAM

Community Atmosphere Model
77 stars 140 forks source link

Perl ~~ (Smartmatch) function depricated #1123

Open jedwards4b opened 2 months ago

jedwards4b commented 2 months ago

Issue Type

Infrastructure Update

Issue Description

err=Smartmatch is deprecated at /glade/u/home/fischer/code/cesm3_0_alpha03a/components/cam/bld/perl5lib/Build/ChemNamelist.pm line 300. Smartmatch is deprecated at /glade/u/home/fischer/code/cesm3_0_alpha03a/components/cam/bld/build-namelist line 2271.

Will this change answers?

No

Will you be implementing this yourself?

Yes

jedwards4b commented 2 months ago

The build-namelist issue is trivial - just need to replace ~~ with =~. The ChemNamelist.pm change is more complicated and will take some thought.

jedwards4b commented 2 months ago

@fvitt Here is the line in ChemNamelist.pm that needs to be replaced: https://github.com/ESCOMP/CAM/blob/cam_development/bld/perl5lib/Build/ChemNamelist.pm#L300

fvitt commented 2 months ago

@fvitt Here is the line in ChemNamelist.pm that needs to be replaced: https://github.com/ESCOMP/CAM/blob/cam_development/bld/perl5lib/Build/ChemNamelist.pm#L300

@jedwards4b I will try alternative implementations.

fvitt commented 2 months ago

@jedwards4b I would like to test the follwing chenages. Do you see any problems with this?

diff --git a/bld/perl5lib/Build/ChemNamelist.pm b/bld/perl5lib/Build/ChemNamelist.pm
index 7d4f5a61..b74e45a9 100644
--- a/bld/perl5lib/Build/ChemNamelist.pm
+++ b/bld/perl5lib/Build/ChemNamelist.pm
@@ -16,6 +16,7 @@ use Exporter;
 use FindBin qw($Bin);
 use lib "$Bin/perl5lib";
 use Build::ChemPreprocess qw(get_species_list get_species_nottransported_list);
+use List::Util 'any';

 our @ISA = qw(Exporter);
 our @EXPORT = qw(set_dep_lists set_aero_modes_info chem_has_species);
@@ -295,9 +296,10 @@ sub get_dep_list

     my $list = '';
     my $first = 1; my $pre = "";
+
     foreach my $name (sort @species_list) {
        foreach my $item (@master_list) {
-           if (!($item ~~ @nottransported_list)) {
+           if (!(any { $item eq $_ } @nottransported_list)) {
                if ($name eq $item) {
                    $list .= $pre .  quote_string($name) ;
                    if ($first) { $pre = ","; $first = 0; }
jedwards4b commented 2 months ago

It's worth a try - you can compare the dry_dep_list in Buildconf/camconf in the case directory after running preview_namelist

fvitt commented 2 months ago

It's worth a try - you can compare the dry_dep_list in Buildconf/camconf in the case directory after running preview_namelist

There are several differnt waccm and cam-chem configurations where I need to compare namelists...

fvitt commented 2 months ago

@jedwards4b My use of the any util in ChemNamelist.pm seems to be working well for me. My mods are in branch: https://github.com/fvitt/CAM/tree/chem_bldnml