Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newer versions of perl may not have 'switch' -- relevant for config #213

Open
bsu-wrudisill opened this issue Sep 18, 2024 · 0 comments
Open

Comments

@bsu-wrudisill
Copy link

bsu-wrudisill commented Sep 18, 2024

** EDITED 9/23 for clarity **
It appears that not all versions of perl have the 'switch' module installed as a default, and I found it somewhat difficult to install the switch module on my system. 'Switch' is used in the .config script, located here:

use Switch;

Based on my reading it sounds like the 'given/when' syntax is preferred with new versions of perl.
With the aid of a ChatGPT, I was able to replace the switch statements with given/when which appears to work:



#!/usr/bin/perl
use feature 'switch';

if ($#ARGV == 0) {
    $response = shift(@ARGV);
    print("Configure HRLDAS: $response \n");
} else {
    print "Please select from the following supported architectures: \n\n";

    print "   1. Linux PGI compiler serial \n";
    print "   2. Linux PGI compiler MPI \n";
    print "   3. Linux intel compiler serial \n";
    print "   4. Linux intel compiler MPI \n";
    print "   5. Linux intel compiler MPI (NCAR/Derecho) \n";
    print "   6. Linux gfortran/gcc compiler serial \n";
    print "   7. Linux gfortran/gcc compiler MPI \n";
    print "   8. Linux gfortran/gcc compiler MPI (NCAR/Derecho) \n";
    print "   9. Linux gfortran/gcc compiler MPI (Docker container) \n";
    print "   0. exit only \n";

    printf "\nEnter selection [%d-%d] : ", 0, 9;

    $response = <STDIN>;
    chomp($response);
}

given ($response) {
    when (1) {
        # serial PGI
        system "cp arch/user_build_options.pgi.serial user_build_options";
    }
    when (2) {
        # MPI PGI
        system "cp arch/user_build_options.pgi.mpi user_build_options";
    }
    when (3) {
        # serial intel
        system "cp arch/user_build_options.ifort.serial user_build_options";
    }
    when (4) {
        # MPI intel
        system "cp arch/user_build_options.ifort.mpi user_build_options";
    }
    when (5) {
        # MPI intel (NCAR/Derecho)
        system "cp arch/user_build_options.ifort.mpi.derecho user_build_options";
    }
    when (6) {
        # serial GFORTRAN
        system "cp arch/user_build_options.gfortran.serial user_build_options";
    }
    when (7) {
        # MPI GFORTRAN
        system "cp arch/user_build_options.gfortran.mpi user_build_options";
    }
    when (8) {
        # MPI GFORTRAN (NCAR/Derecho)
        system "cp arch/user_build_options.gfortran.mpi.derecho user_build_options";
    }
    when (9) {
        # MPI GFORTRAN for Docker container
        system "cp arch/user_build_options.gfortran.mpi.container user_build_options";
    }
    default {
        print "no selection $response\n";
        last;
    }
}

print "The user_build_options file used for compiling source code has been successfully generated. \n";
print "Please check and change the software package path in the generated user_build_options file before compiling! \n";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant