⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configure

📁 CCSM Research Tools: Community Atmosphere Model (CAM)
💻
📖 第 1 页 / 共 5 页
字号:
#!/usr/bin/env perl#-----------------------------------------------------------------------------------------------## configure## Produce the configuration files required to build CAM, i.e., Filepath,# misc.h, params.h, preproc.h, and Makefile.  A complete build# specification is written to the file config_cache.xml which may be used# in a subsequent invokation of configure to exactly reproduce the# configuration files.  All files produced by running configure are# written to the CAM build directory, which defaults to the current# directory.## Optionally test that the Fortran90 compiler works (for "hello world") and# can resolve external references to the netCDF and MPI libraries.## Date        Contributor         Modification# ---------------------------------------------------------------------------# 2002-05-03  Brian Eaton         Original version#-----------------------------------------------------------------------------------------------use strict;#use warnings;#use diagnostics;use Cwd;use English;use Getopt::Long;use IO::File;use FileHandle;#-----------------------------------------------------------------------------------------------my $version = '$Name: cam2_0_brnchT_release3 $';                #' CVS tag used to check out CAM distributionautoflush STDOUT, 1;                   # Helps in debugging to have the test description                                       # echoed before the error messages startmy $ProgName;($ProgName = $0) =~ s!(.*)/!!;         # name of programmy $ProgDir = $1;                      # name of directory where program lives# default filenamesmy $bld_defaults = 'config_cache_defaults.xml';# name of input configure defaults filemy $res_params = 'resolution_parameters.xml';  # name of input resolution parameters filemy $sys_defaults = 'system_defaults.xml';      # name of input system defaults filemy $fp_filename = 'Filepath';                  # name of output filepath filemy $params_filename = 'params.h';              # name of output resolution cpp tokens filemy $misc_filename = 'misc.h';                  # name of output atmlnd_share cpp tokens filemy $preproc_filename = 'preproc.h';            # name of output land model cpp tokens filemy $cfg_filename = 'config_cache.xml';         # name of output configuration file#-----------------------------------------------------------------------------------------------sub usage {    die <<EOF;SYNOPSIS     $ProgName [options]OPTIONS     User supplied values are denoted in angle brackets (<>).  Any value that contains     white-space must be quoted.  Single letter options may NOT be bundled.     -cache <file>      Name of output configuration file (default: $cfg_filename).     -cam_bld <dir>     Directory where CAM will be built.     -cam_cfg <dir>     Directory containing CAM configuration scripts.     -cam_exe <name>    Name of the CAM executable.     -cam_exedir <dir>  Directory where CAM executable will be created.     -cam_root <dir>    Top level directory of CAM distribution.     -cc <name>         User specified C compiler (linux only).  Overrides Makefile default.     -debug             Switch to turn on building CAM with debugging compiler options.     -defaults <file>   Use a configuration cache file to provide defaults.     -dyn <name>        Build CAM with specified dynamical core [eul | sld | fv].     -fc <name>         User specified Fortran compiler.  Overrides Makefile default.     -fflags <string>   A string of user specified Fortran compiler options.  Appended to                        Makefile defaults.     -esmf_bld <dir>    Top level directory where ESMF library will be built.     -esmf_root <dir>   Top level directory of ESMF distribution.     -gmake <name>      Name of the GNU make program on your system.  Supply the absolute                        pathname if the program is not in your path (or fix your path).     -h                 Print usage to STDOUT.     -i                 Turns on interactive prompting.     -mpi_inc <dir>     Directory containing MPI include files.     -mpi_lib <dir>     Directory containing MPI library.     -nadv <n>          Set number of advected species to <n>.     -nc_inc <dir>      Directory containing netCDF include files.     -nc_lib <dir>      Directory containing netCDF library.     -nlat <n>          Set number of latitudes to <n>.  Must also set "-res custom".     -nlev <n>          Set number of levels to <n>.     -nlon <n>          Set number of longitudes to <n>.  Must also set "-res custom".     -nnadv <n>         Set number of non-advected species to <n>.     -ocn <name>        Build CAM with data SSTs or slab ocean model [dom | som].     -pergro            Switch enables building CAM for perturbation growth tests.     -phys <name>       Build CAM with specified physics package [cam1 | ccm366]     -res <name>        Specify horizontal grid resolution.  Use nlatxnlon for spectral grids                        and dlatxdlon for fv grids (dlat and dlon are the grid cell size                        in degrees for latitude and longitude respectively).     -s                 Turns on silent mode - only fatal messages issued.     -sice <name>       Build CAM with specified sea ice package [csim4 | ccmice]     -[no]spmd          Switch on [off] SPMD parallelism.     -[no]test          Switch on [off] testing of Fortran compiler and external libraries.     -trk <k>           <k> is the highest degree of the associated Legendre polynomials.                        Must also set "-res custom".     -trm <m>           <m> is the maximum Fourier wavenumber.  Must also set "-res custom".     -trn <n>           <n> is the highest degree of the Legendre polynomials for m=0.                        Must also set "-res custom".     -usr_src <dir1>[,<dir2>[,<dir3>[...]]]                        Directories containing user source code.     -v <n>             Set verbosity to level <n>.  1 (default), 2 or 3.     -version           Echo the CVS tag name used to check out this CAM distribution.     -x                 Enables expert interactive prompting mode.  (Must also specify -i.)EOF}#-----------------------------------------------------------------------------------------------my $cwd = getcwd();  # current working directory# Parse command-line options.my $help = 0;my $interactive = 0;my $silent = 0;my $expert = 0;my($defaults, $cam_bld, $cam_cfg, $cam_exe, $cam_exedir, $cam_root, $esmf_bld, $esmf_lib, $esmf_root,   $usr_src);my %opts = ( v    => 0,             test => undef, );GetOptions(    "cache=s"                   => \$cfg_filename,    "cam_bld=s"                 => \$cam_bld,    "cam_cfg=s"                 => \$cam_cfg,    "cam_exe=s"                 => \$cam_exe,    "cam_exedir=s"              => \$cam_exedir,    "cam_root=s"                => \$cam_root,    "cc=s"                      => \$opts{'cc'},    "debug"                     => \$opts{'debug'},    "defaults=s"                => \$defaults,    "dyn=s"                     => \$opts{'dyn'},    "fc=s"                      => \$opts{'fc'},    "fflags=s"                  => \$opts{'fflags'},    "esmf_bld=s"                => \$esmf_bld,#    "esmf_lib=s"                => \$esmf_lib,    "esmf_root=s"               => \$esmf_root,    "gmake=s"                   => \$opts{'gmake'},    "h|help"                    => \$help,    "i|interactive"             => \$interactive,    "mpi_inc=s"                 => \$opts{'mpi_inc'},    "mpi_lib=s"                 => \$opts{'mpi_lib'},    "nadv=s"                    => \$opts{'nadv'},    "nc_inc=s"                  => \$opts{'nc_inc'},    "nc_lib=s"                  => \$opts{'nc_lib'},    "nlat=s"                    => \$opts{'nlat'},    "nlev=s"                    => \$opts{'nlev'},    "nlon=s"                    => \$opts{'nlon'},    "nnadv=s"                   => \$opts{'nnadv'},    "ocn=s"                     => \$opts{'ocn'},#    "omp"                       => \$opts{'omp'},    "pergro"                    => \$opts{'pergro'},    "phys=s"                    => \$opts{'phys'},    "res=s"                     => \$opts{'res'},    "s|silent"                  => \$silent,    "sice=s"                    => \$opts{'sice'},    "spmd!"                     => \$opts{'spmd'},    "test!"                     => \$opts{'test'},    "trk=s"                     => \$opts{'trk'},    "trm=s"                     => \$opts{'trm'},    "trn=s"                     => \$opts{'trn'},    "usr_src=s"                 => \$usr_src,    "v|verbose=s"               => \$opts{'verbose'},    "version"                   => \$opts{'version'},    "x"                         => \$expert,)  or usage();# Give usage message.usage() if $help;# Check for unparsed argumentsif (@ARGV) {    print "ERROR: unrecognized arguments: @ARGV\n";    usage();}# Echo version info (CVS tag name for checked out model version).(print "$version\n" and exit) if $opts{'version'};# Validate specified option values.validate_options("command line", \%opts);# Define 4 print levels:# 0 - only issue fatal error messages# 1 - only informs what files are created (default)# 2 - echo results of basic interactive queries (-i)# 3 - echo results of expert interactive queries (-i -x) my $print = 1;if ($silent) { $print = 0; }if ($interactive or $opts{'verbose'}==2) { $print = 2; }if (($interactive and $expert) or $opts{'verbose'}>=3) { $print = 3; }my $eol = "\n";if ($interactive) { $eol = "\n\n"; }# Set default for testing.  If user has set a command-line option use it.# Otherwise, if interactive prompting will ask user with default on, and if# not interactive then testing turned off.unless (defined $opts{'test'}) {    $opts{'test'} = $interactive ? 1 : 0;}# Print instructions for interactive use.if ($interactive) {    print <<"EOF";Entering interactive mode.  To accept the default values given inbrackets [] just enter return.EOF}# Configuration.my $cfgdir;             # directory containing CAM configuration scriptsmy %cfg = ();           # build configurationmy %usr_defaults = ();  # user defaults for the build configurationmy %bld_defaults = ();  # defaults to produce the CCSM production version of CAMmy %sys_defaults = ();  # system defaults for parallelism and library locationsmy $cfg;                # scratch scalar for optionsmy $ans;                # scratch scalar for interactive answersmy @expect;             # valid values for an optionmy $spec_grid;          # reference to hash of hashes containing spectral grid resolutionsmy $fv_grid;            # reference to hash of hashes containing finite volume grid resolutionsmy $spec_trunc;         # reference to hash of hashes containing spectral truncations#-----------------------------------------------------------------------------------------------# Make sure we can find required perl modules and configuration files.if (defined $cam_cfg) {    $cfgdir = $cam_cfg;} elsif (defined $ENV{CAM_CFGDIR}) {    $cfgdir = "$ENV{CAM_CFGDIR}";} elsif (defined $ENV{CAM_ROOT}) {    $cfgdir = "$ENV{CAM_ROOT}/models/atm/cam/bld";} else {    if ($ProgDir) { $cfgdir = $ProgDir; }    else { $cfgdir = $cwd; }}if ($interactive and $expert) {    print "Enter directory that contains CAM configuration scripts [$cfgdir]: ";    $ans = <>; chomp $ans;    if ($ans =~ /\S+/) { $cfgdir = $ans; }}my $die_message ="** This file is supplied with the CAM source distribution in the\n"          ."** directory containing the CAM configuration scripts.  This directory can\n" ."** be specified as follows (highest to lowest precedence):\n"                 ."** - interactively (use -i and -x command-line options)\n"                    ."** - by the command-line option -cam_cfg\n"                                   ."** - by the environment variable CAM_CFGDIR\n"                                ."** - by the environment variable CAM_ROOT (the configuration\n"               ."**   script directory is CAM_ROOT/models/atm/cam/bld)\n"                      ."** The default value is the directory the contains the $ProgName script. \n";(-f "$cfgdir/$bld_defaults")  or  die <<"EOF";** Cannot find configure defaults file \"$bld_defaults\" in directory \"$cfgdir\" **$die_messageEOF(-f "$cfgdir/$res_params")  or  die <<"EOF";** Cannot find resolution parameters file \"$res_params\" in directory \"$cfgdir\" **$die_messageEOF(-f "$cfgdir/XML/Lite.pm")  or  die <<"EOF";** Cannot find perl module \"XML/Lite.pm\" in directory \"$cfgdir\" **$die_messageEOF$cfgdir = absolute_path($cfgdir);if ($print>=3) { print "Setting CAM configuration script directory to $cfgdir$eol"; }#-----------------------------------------------------------------------------------------------# Add $cfgdir to the list of paths that Perl searches for modulesunshift @INC, $cfgdir;require XML::Lite;# Can read defaults files now that we know where to find XML::Lite%bld_defaults = read_cfg_file( "$cfgdir/$bld_defaults" );if (defined $defaults && -s $defaults) {     %usr_defaults = read_cfg_file( $defaults );}#-----------------------------------------------------------------------------------------------# CAM root directory.if (defined $cam_root) {    $cfg = $cam_root;} elsif (defined $usr_defaults{'cam_root'}) {    $cfg = $usr_defaults{'cam_root'};} elsif (defined $ENV{CAM_ROOT}) {    $cfg = "$ENV{CAM_ROOT}";} else {    $cfg = absolute_path("$cfgdir/../../../..");}if ($interactive and $expert) {    print "Enter CAM root directory [$cfg]: ";    $ans = <>; chomp $ans;    if ($ans =~ /\S+/) { $cfg = $ans; }}if (-d "$cfg/models/atm/cam/src" and -d "$cfg/models/atmlnd_share" and    -d "$cfg/models/csm_share" and -d "$cfg/models/utils" and    -d "$cfg/models/lnd") {    $cfg{'cam_root'} = absolute_path($cfg);} else {    die <<"EOF";** Invalid CAM root directory specified: $cfg** ** The CAM root directory must contain the subdirectory models/ which contains** the subdirectories atm/cam/src/, atmlnd_share/, csm_share/, lnd/, and utils/.** The CAM root directory is determined from the following set of options listed** from highest to lowest precedence:** * interactively, enabled by command-line option -i** * by the command-line option -cam_root** * by a default configuration file, specified by -defaults ** * by the environment variable CAM_ROOT** * by the default value config_dir/../../../.. where config_dir is the**   directory in the CAM distribution that contains the configuration**   scripts.EOF}if ($print>=3) { print "Setting CAM root directory to $cfg{'cam_root'}$eol"; }#-----------------------------------------------------------------------------------------------# CAM build directory.if (defined $cam_bld) {    $cfg = $cam_bld;} elsif (defined $usr_defaults{'cam_bld'}) {    $cfg = $usr_defaults{'cam_bld'};} else {    $cfg = $bld_defaults{'cam_bld'};}if ($interactive) {    print "Enter directory where CAM will be built [$cfg]: ";    $ans = <>; chomp $ans;    if ($ans =~ /\S+/) { $cfg = $ans; }}if (-d $cfg or mkdirp($cfg)) {    $cfg{'cam_bld'} = absolute_path($cfg);} else {    die <<"EOF";** Could not create the specified CAM build directory: $cfgEOF}# Make sure that build and CAM configuration script directories are different.# Otherwise, the standard Makefile will be overwritten.if ($cfgdir eq $cfg{'cam_bld'}) {    die <<"EOF";** Invalid build directory: $cfg{'cam_bld'}** The specified build directory is the same as the configuration script** directory.  This is not allowed because the Makefile produced by configure** would overwrite the standard Makefile.  Use a different build directory.EOF}if ($print>=2) { print "Setting CAM build directory to $cfg{'cam_bld'}$eol"; }#-----------------------------------------------------------------------------------------------# CAM install directory.if (defined $cam_exedir) {    $cfg = $cam_exedir;} elsif (defined $usr_defaults{'cam_exedir'}) {    $cfg = $usr_defaults{'cam_exedir'};} else {    $cfg = $bld_defaults{'cam_exedir'};}if ($interactive) {    print "Enter directory where CAM executable will be created [$cfg]: ";    $ans = <>; chomp $ans;    if ($ans =~ /\S+/) { $cfg = $ans; }}if (-d $cfg or mkdirp($cfg)) {    $cfg{'cam_exedir'} = absolute_path($cfg);} else {    die <<"EOF";** Could not create the specified CAM installation directory: $cfgEOF}if ($print>=2) { print "The CAM executable will be created in $cfg{'cam_exedir'}$eol"; }#-----------------------------------------------------------------------------------------------# ESMF lib directory.  Makefile doesn't currently support using pre-built ESMF lib.#if (defined $esmf_lib) {#    $cfg = $esmf_lib;#} elsif (defined $usr_defaults{'esmf_lib'} and $usr_defaults{'esmf_lib'} ne "") {#    $cfg = $usr_defaults{'esmf_lib'};#} elsif (defined $ENV{ESMF_LIB} and $ENV{ESMF_LIB} ne "") {#    $cfg = "$ENV{ESMF_LIB}";#} else {#    # There is no default for specifying a pre-built ESMF lib.#    $cfg = undef;#}#if ($interactive and $expert) {#    $ans = "n";#    print "Do you wish to use a pre-built ESMF library?  y or n [$ans]: ";#    $ans = <>; chomp $ans;#    if ($ans =~ /[Yy]/) {#	print "Enter name of the directory which contains the lib/ and mod/\n" .#	    "subdirectories [$cfg]: ";#	$ans = <>; chomp $ans;#	if ($ans =~ /\S+/) { $cfg = $ans; }#    }#}$cfg{'esmf_lib'} = '';#if (defined $cfg) {#    if (-d "$cfg") {	# Can only do this weak check for now since we don't know yet whether

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -