CAM icon indicating copy to clipboard operation
CAM copied to clipboard

Perl ~~ (Smartmatch) function depricated

Open jedwards4b opened this issue 1 year ago • 7 comments

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 avatar Aug 12 '24 16:08 jedwards4b

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

jedwards4b avatar Aug 12 '24 17:08 jedwards4b

@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 avatar Aug 13 '24 13:08 jedwards4b

@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 avatar Aug 13 '24 14:08 fvitt

@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; }

fvitt avatar Aug 13 '24 19:08 fvitt

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

jedwards4b avatar Aug 13 '24 19:08 jedwards4b

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 avatar Aug 13 '24 19:08 fvitt

@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

fvitt avatar Aug 14 '24 18:08 fvitt