?? configure
字號:
# the debugging or optimized library version is desired (will choose it # to match CAM option).# $cfg{'esmf_lib'} = absolute_path($cfg);# } else {# die "** ESMF library directory does not exist: $cfg\n";# }# if ($print>=3) { print "Using pre-built ESMF library, top directory is $cfg{'esmf_lib'}$eol"; }#}#-----------------------------------------------------------------------------------------------# ESMF root directory. Only need this if pre-built lib not specified.$cfg{'esmf_root'} = "";unless ($cfg{'esmf_lib'}) { if (defined $esmf_root) { $cfg = $esmf_root; } elsif (defined $usr_defaults{'esmf_root'}) { $cfg = $usr_defaults{'esmf_root'}; } elsif (defined $ENV{ESMF_ROOT}) { $cfg = "$ENV{ESMF_ROOT}"; } else { $cfg = "$cfg{'cam_root'}/models/utils/esmf"; } if ($interactive and $expert) { print "Enter the root ESMF directory [$cfg]: "; $ans = <>; chomp $ans; if ($ans =~ /\S+/) { $cfg = $ans; } } if (-d $cfg and -f "$cfg/makefile") { $cfg{'esmf_root'} = absolute_path($cfg); } else { die <<"EOF";** Invalid ESMF root directory specified: $cfg** ** The ESMF root directory must contain the main makefile for building the** ESMF library. The 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 -esmf_root** * by a default configuration file, specified by -defaults ** * by the environment variable ESMF_ROOT** * by the default value cam_root/models/utils/esmf where cam_root is the** root directory of the CAM distribution.EOF } if ($print>=3) { print "Setting ESMF root directory to $cfg{'esmf_root'}$eol"; }}#-----------------------------------------------------------------------------------------------# ESMF build directory. Only need this if pre-built lib not specified.$cfg{'esmf_bld'} = "";unless ($cfg{'esmf_lib'}) { if (defined $esmf_bld) { $cfg = $esmf_bld; } elsif (defined $usr_defaults{'esmf_bld'}) { $cfg = $usr_defaults{'esmf_bld'}; } else { $cfg = $bld_defaults{'esmf_bld'}; } if ($interactive and $expert) { print "Enter directory where the ESMF library will be built [$cfg]: "; $ans = <>; chomp $ans; if ($ans =~ /\S+/) { $cfg = $ans; } } if (-d $cfg or mkdirp($cfg)) { $cfg{'esmf_bld'} = absolute_path($cfg); } else { die <<"EOF";** Could not create the specified ESMF build directory: $cfgEOF } if ($print>=3) { print "Setting ESMF build directory to $cfg{'esmf_bld'}$eol"; }}#-----------------------------------------------------------------------------------------------# User source directories.if (defined $usr_src) { $cfg = $usr_src;} elsif (defined $usr_defaults{'usr_src'} and $usr_defaults{'usr_src'} ne "") { $cfg = $usr_defaults{'usr_src'};} else { # There is no default for specifying user source directories. $cfg = undef;}if ($interactive and $expert) { $ans = "n"; print "Do you wish to prepend user source directories to the CAM source filepath?\n" . "(The CAM build directory is included in the filepath by default.): y or n [$ans]: "; $ans = <>; chomp $ans; if ($ans =~ /[Yy]/) { print "Enter the directory name, or a comma separated list of 2 or more directories\n". "(no embedded white space) [$cfg]: "; $ans = <>; chomp $ans; if ($ans =~ /\S+/) { $cfg = $ans; } }}$cfg{'usr_src'} = "";if (defined $cfg) { # check that the user specified directories exist my @dirs = split ',', $cfg; my @adirs; while ( my $dir = shift @dirs ) { if (-d "$dir") { push @adirs, absolute_path($dir); } else { die "** User source directory does not exist: $dir\n"; } } $cfg{'usr_src'} = join ',', @adirs;}if ($print>=3) { print "Setting user source directories to $cfg{'usr_src'}$eol"; }#-----------------------------------------------------------------------------------------------# Dynamics packageif (defined $opts{'dyn'}) { $cfg = $opts{'dyn'};} elsif (defined $usr_defaults{'dyn'}) { $cfg = $usr_defaults{'dyn'};} else { $cfg = $bld_defaults{'dyn'};}if ($interactive) { $ans = get_option("Enter dynamics package; eul or sld or fv [$cfg]: ", "eul", "sld", "fv"); if ($ans) { $cfg = $ans; }}$cfg{'dyn'} = $cfg;if ($print>=2) { print "Using $cfg{'dyn'} dynamics.$eol"; }#-----------------------------------------------------------------------------------------------# Physics packageif ($cfg{'dyn'} eq "sld" or $cfg{'dyn'} eq "fv") { $cfg{'phys'} = "cam1"; if (defined $opts{'phys'} and $opts{'phys'} eq "ccm366") { print "Warning: $cfg{'dyn'} and $opts{'phys'} is not a supported model configuration.\n". "Configuring CAM to use physics package $cfg{'phys'}\n"; }} else { if (defined $opts{'phys'}) { $cfg = $opts{'phys'}; } elsif (defined $usr_defaults{'phys'}) { $cfg = $usr_defaults{'phys'}; } else { $cfg = $bld_defaults{'phys'}; } if ($interactive and $expert) { $ans = get_option("Enter physics package; cam1 or ccm366 [$cfg]: ", "cam1", "ccm366"); if ($ans) { $cfg = $ans; } } $cfg{'phys'} = $cfg;}if ($print>=3) { print "Using $cfg{'phys'} physics.$eol"; }#-----------------------------------------------------------------------------------------------# Land modelif ($cfg{'phys'} eq "cam1") { $cfg{'lnd'} = "clm2";} else { $cfg{'lnd'} = "lsm";}if ($print>=3) { print "Using $cfg{'lnd'} land package.$eol"; }#-----------------------------------------------------------------------------------------------# SST data or slab ocean model *** Are there restrictions here? ***if (defined $opts{'ocn'}) { $cfg = $opts{'ocn'};} elsif (defined $usr_defaults{'ocn'}) { $cfg = $usr_defaults{'ocn'};} else { $cfg = $bld_defaults{'ocn'};}if ($interactive and $expert) { $ans = get_option("Enter ocean package; dom or som [$cfg]: ", "dom", "som"); if ($ans) { $cfg = $ans; }}$cfg{'ocn'} = $cfg;if ($print>=3) { print "Using $cfg{'ocn'} ocean package.$eol"; }#-----------------------------------------------------------------------------------------------# Sea ice package (only implemented for cam1 physics)$cfg{'sice'} = '';if ($cfg{'phys'} eq 'cam1') { if (defined $opts{'sice'}) { $cfg = $opts{'sice'}; } elsif (defined $usr_defaults{'sice'}) { $cfg = $usr_defaults{'sice'}; } else { $cfg = $bld_defaults{'sice'}; } if ($interactive and $expert) { $ans = get_option("Enter sea ice package; csim4 or ccmice [$cfg]: ", "csim4", "ccmice"); if ($ans) { $cfg = $ans; } } $cfg{'sice'} = $cfg; if ($print>=3) { print "Using $cfg{'sice'} sea ice package.$eol"; }}#-----------------------------------------------------------------------------------------------# Use modifications for perturbation growth testing?if ($opts{'pergro'}) { $cfg = 'y';} elsif (defined $usr_defaults{'pergro'}) { $cfg = $usr_defaults{'pergro'} ? 'y' : 'n';} else { $cfg = $bld_defaults{'pergro'} ? 'y' : 'n';}if ($interactive) { print "Modify CAM for perturbation growth testing? y or n [$cfg]: "; $ans = <>; chomp $ans; if ($ans =~ /\S+/) { $cfg = $ans; }}$cfg{'pergro'} = ($cfg =~ /[Yy]/) ? 1 : 0;if ($print>=2) { if ($cfg{'pergro'}) { print "Configuring CAM for perturbation growth testing.$eol"; } else { print "NOT configuring CAM for perturbation growth testing.$eol"; }}#-----------------------------------------------------------------------------------------------# Read the resolution parameters data($spec_grid, $fv_grid, $spec_trunc) = read_res_params("$cfgdir/$res_params");#-----------------------------------------------------------------------------------------------# Resolutionmy @grid_keys;unless ($cfg{'dyn'} eq 'fv') { @grid_keys = sort keys %$spec_grid;} else { @grid_keys = sort keys %$fv_grid;}if ($expert) { push @grid_keys, "custom"; }$cfg{'trm'} = '1';$cfg{'trn'} = '1';$cfg{'trk'} = '1';if (defined $opts{'res'} and $opts{'res'} eq 'custom') { $cfg{'res'} = 'custom';} else { if (defined $opts{'res'}) { $cfg = $opts{'res'}; } elsif (defined $usr_defaults{'res'}) { $cfg = $usr_defaults{'res'}; } else { $cfg = $bld_defaults{'res'}; } if ($interactive) { my $mes; unless ($cfg{'dyn'} eq 'fv') { $mes = "Choose the spectral grid resolution. The valid options are expressed\n". "as nlatxnlon where nlat is the number of grid latitudes and nlon is the\n". "number of grid longitudes.\n"; } else { $mes = "Choose the finite-volume grid resolution. The valid options are expressed\n". "as dlatxdlon where dlat is the latitude cell size and dlon is the longitude\n". "cell size, both in degrees.\n"; } $ans = get_option("$mes @grid_keys [$cfg]: ", @grid_keys); if ($ans) { $cfg = $ans; } } # check for valid resolution spec (needed in case the default isn't valid). my $old = $cfg; $cfg = valid_option($old, @grid_keys) or die "** stopping: invalid value of res ($old) specified as a default\n". "** expected one of: @grid_keys\n"; $cfg{'res'} = $cfg; if ($print>=2) { print "Using horizontal resolution: $cfg{'res'}$eol"; } # Set horizontal resolution parameters for valid resolution specifiers except "custom" unless ($cfg{'res'} eq 'custom') { my $res = $cfg{'res'}; my $dyn = $cfg{'dyn'}; if ($dyn eq 'fv') { $cfg{'nlon'} = $fv_grid->{$res}{'nlon'}; $cfg{'nlat'} = $fv_grid->{$res}{'nlat'}; } else { $cfg{'nlon'} = $spec_grid->{$res}{'nlon'}; $cfg{'nlat'} = $spec_grid->{$res}{'nlat'}; # When running perturbation growth tests for sld dynamics use eul truncations if ($cfg{'pergro'}) { $dyn = 'eul'; } $cfg{'trm'} = $spec_trunc->{"$res$dyn"}{'m'}; $cfg{'trn'} = $spec_trunc->{"$res$dyn"}{'n'}; $cfg{'trk'} = $spec_trunc->{"$res$dyn"}{'k'}; } }}if ($cfg{'res'} eq 'custom') { # Get custom resolution # Number of longitudes $cfg = 0; if (defined $opts{'nlon'}) { $cfg = $opts{'nlon'}; } elsif (defined $usr_defaults{'nlon'}) { $cfg = $usr_defaults{'nlon'}; } if ($interactive) { print "Enter number of longitude grid points [$cfg]: "; $ans = <>; chomp $ans; if ($ans =~ /\S+/) { $cfg = $ans; } } die "ERROR: invalid number of longitudes: $cfg\n" unless ($cfg>=1); $cfg{'nlon'} = $cfg; # Number of latitudes $cfg = 0; if (defined $opts{'nlat'}) { $cfg = $opts{'nlat'}; } elsif (defined $usr_defaults{'nlat'}) { $cfg = $usr_defaults{'nlat'}; } if ($interactive) { print "Enter number of latitude grid points [$cfg]: "; $ans = <>; chomp $ans; if ($ans =~ /\S+/) { $cfg = $ans; } } die "ERROR: invalid number of latitudes: $cfg\n" unless ($cfg>=1); $cfg{'nlat'} = $cfg; # Spectral truncation unless ($cfg{'dyn'} eq 'fv') { # M - maximum Fourier wavenumber $cfg = 0; if (defined $opts{'trm'}) { $cfg = $opts{'trm'}; } elsif (defined $usr_defaults{'trm'}) { $cfg = $usr_defaults{'trm'}; } if ($interactive) { print "Enter M, the maximum Fourier wavenumber [$cfg]: "; $ans = <>; chomp $ans; if ($ans =~ /\S+/) { $cfg = $ans; } } die "ERROR: invalid spectral parameter M: $cfg\n" unless ($cfg>=1); $cfg{'trm'} = $cfg; # N - highest degree of the Legendre polynomials for m=0 $cfg = 0; if (defined $opts{'trn'}) { $cfg = $opts{'trn'}; } elsif (defined $usr_defaults{'trn'}) { $cfg = $usr_defaults{'trn'}; } if ($interactive) { print "Enter N, the highest degree of the Legendre polynomials for m=0 [$cfg]: "; $ans = <>; chomp $ans; if ($ans =~ /\S+/) { $cfg = $ans; } } die "ERROR: invalid spectral parameter N: $cfg\n" unless ($cfg>=1); $cfg{'trn'} = $cfg; # K - highest degree of the associated Legendre polynomials $cfg = 0; if (defined $opts{'trk'}) { $cfg = $opts{'trk'}; } elsif (defined $usr_defaults{'trk'}) { $cfg = $usr_defaults{'trk'}; } if ($interactive) { print "Enter K, the highest degree of the associated Legendre polynomials [$cfg]: "; $ans = <>; chomp $ans; if ($ans =~ /\S+/) { $cfg = $ans; } } die "ERROR: invalid spectral parameter K: $cfg\n" unless ($cfg>=1); $cfg{'trk'} = $cfg; }}if ($print>=2) { print "Setting number of longitudes to $cfg{'nlon'}\n"; print "Setting number of latitudes to $cfg{'nlat'}$eol"; unless ($cfg{'dyn'} eq 'fv') { print "Setting spectral truncation parameter M to $cfg{'trm'}\n"; print "Setting spectral truncation parameter N to $cfg{'trn'}\n"; print "Setting spectral truncation parameter K to $cfg{'trk'}$eol"; }}# Number of vertical levelsif (defined $opts{'nlev'}) { $cfg = $opts{'nlev'};} elsif (defined $usr_defaults{'nlev'}) { $cfg = $usr_defaults{'nlev'};} else { $cfg = $bld_defaults{'nlev'};}if ($interactive) { print "Enter number of vertical levels [$cfg]: "; $ans = <>; chomp $ans; if ($ans =~ /\S+/) { $cfg = $ans; }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -