?? configure
字號:
} } else { die "The name of GNU make on your system can be specified to configure via\n". "the -gmake option or using the interactive mode (-i). Make sure this\n". "name is in your path (add the appropriate directory to your PATH\n". "environment variable) or specify an absolute pathname.\n"; }}# Test for Fortran 90 compatible compilerif ($print) { print "Testing for Fortran 90 compatible compiler... "; }my $fc = check_fc($gmake, $cfgdir);if ($fc) { if ($print) { print "using $fc$eol"; }}# Test NetCDF libraryif ($print) { print "Testing NetCDF library... "; }if (check_netcdf($gmake, $cfgdir)==0) { if ($print) { print "ok$eol"; } }# Test MPI libraryif ($cfg{'spmd'}) { if ($print) { print "Testing MPI library... "; } if (check_mpi($gmake, $cfgdir)==0) { if ($print) { print "ok$eol"; } }}#-----------------------------------------------------------------------------------------------# Done.if ($print) { print "configure done.\n"; }exit;#-----------------------------------------------------------------------------------------------#-----------------------------------------------------------------------------------------------sub read_cfg_file{ my ($file) = @_; my $xml = XML::Lite->new( $file ); my $root = $xml->root_element(); # Check for valid root node my $name = $root->get_name(); $name eq "config_bld" or die "file $file is not a CAM configuration file\n"; # Get source and build directories my $dirs = $xml->elements_by_name( "directories" ); my %dirs = $dirs->get_attributes(); # Get packages my $pkgs = $xml->elements_by_name( "packages" ); my %pkgs = $pkgs->get_attributes(); validate_options($file, \%pkgs); # Get resolution parameters my $resparms = $xml->elements_by_name( "resolution" ); my %resparms = $resparms->get_attributes(); # Get settings for Makefile (parallelism and library locations) my $make = $xml->elements_by_name( "makefile" ); my %make = $make->get_attributes(); return %dirs, %pkgs, %resparms, %make;}#-------------------------------------------------------------------------------sub write_cfg_file{ my ($file, %cfg) = @_; my $fh = new IO::File; $fh->open(">$file") or die "** can't open configuration file: $file\n"; print $fh <<"EOF";<?xml version="1.0"?><config_bld><comment>This is a configuration file for building CAM. It is the file formatproduced by the configure script to store a build configuration. Itmay also be read by the configure script (via setting the -defaultsoption) to provide a default build configuration.This file may be edited by hand to quickly customize a configuration. Ifhand editing is done it should be recognized that XML parser used to readthis file is not able to check the file for valid syntax. Also, thecurrent parser places some restrictions on the normally valid XML syntax:1. Attribute values must be enclosed in DOUBLE QUOTED STRINGS!!!</comment><comment>cam_bld CAM build directory, contains .o and .mod filescam_exedir Directory where CAM executable will be createdcam_root Root directory of CAM distributionesmf_bld Build directory for ESMF, only needed if ESMF lib will be builtesmf_root Root directory of ESMF distribution, only needed if ESMF lib will be builtusr_src User source directories to prepend to the filepath. Multiple directories are specified as a comma separated list with no embedded white space.</comment><directoriescam_bld="$cfg{'cam_bld'}"cam_exedir="$cfg{'cam_exedir'}"cam_root="$cfg{'cam_root'}"esmf_bld="$cfg{'esmf_bld'}"esmf_root="$cfg{'esmf_root'}"usr_src="$cfg{'usr_src'}"/><comment>dyn Dynamics package: eul, sld, or fvphys Physics package: cam1 or ccm366lnd Land model: clm2 or lsm. Currently this value depends on the phys value as follows: cam1 => clm2, ccm366 => lsm.ocn Use SST data or slab ocean model: dom or somsice Sea ice package: csim4 or ccmicepergro Use modifications that allow perturbation growth testing 0 => no, 1 => yes</comment><packagesdyn="$cfg{'dyn'}"phys="$cfg{'phys'}"lnd="$cfg{'lnd'}"ocn="$cfg{'ocn'}"sice="$cfg{'sice'}"pergro="$cfg{'pergro'}"/><comment>res Horizontal grid resolution. Spectral dycores use Gaussian grids are specified by nlat x nlon. The finite volume dycore uses an equally spaced grid that includes pole points and is specified as lat_cell_size x lon_cell_size in degrees.nlon Number of longitude grid pointsnlat Number of latitude grid pointsnlev Number of vertical levelsnadv Number of advected constituentsnnadv Number of non-advected constituentstrm Maximum Fourier wavenumbertrn Highest degree of the Legendre polynomials for m=0trk Highest degree of the associated Legendre polynomials</comment><resolutionres="$cfg{'res'}"nlon="$cfg{'nlon'}"nlat="$cfg{'nlat'}"nlev="$cfg{'nlev'}"nadv="$cfg{'nadv'}"nnadv="$cfg{'nnadv'}"trm="$cfg{'trm'}"trn="$cfg{'trn'}"trk="$cfg{'trk'}"/><comment>cam_exe Name of CAM executablecc User specified C compiler overrides Makefile default.fc User specified Fortran compiler overrides Makefile default.debug Switch to enable debugging options for Fortran compiler.fflags User specified Fortran compiler options to append to Makefile defaults.spmd Switch to enable or disable building SPMD version of CAM.nc_inc Directory containing NetCDF include files.nc_lib Directory containing NetCDF library.mpi_inc Directory containing MPI include files.mpi_lib Directory containing MPI library.</comment><makefilecam_exe="$cfg{'cam_exe'}"cc="$cfg{'cc'}"fc="$cfg{'fc'}"debug="$cfg{'debug'}"fflags="$cfg{'fflags'}"spmd="$cfg{'spmd'}"nc_inc="$cfg{'nc_inc'}"nc_lib="$cfg{'nc_lib'}"mpi_inc="$cfg{'mpi_inc'}"mpi_lib="$cfg{'mpi_lib'}"/></config_bld>EOF $fh->close;}#-------------------------------------------------------------------------------sub write_filepath{ my ($file, %cfg) = @_; my $fh = new IO::File; $fh->open(">$file") or die "** can't open filepath file: $file\n";# User specified source directories. if ($cfg{'usr_src'} =~ /\S+/) { my @dirs = split ',', $cfg{'usr_src'}; while ( my $dir = shift @dirs ) { print $fh "$dir\n"; } } my $srcdir = "$cfg{'cam_root'}/models";# CAM dynamics, physics, control and shared utilities.# Currently the physics directory must be first because of some problem with# the ccm366 physics. print $fh "$srcdir/atm/cam/src/physics/$cfg{'phys'}\n"; print $fh "$srcdir/atm/cam/src/dynamics/$cfg{'dyn'}\n"; print $fh "$srcdir/atm/cam/src/control\n"; print $fh "$srcdir/atmlnd_share\n"; print $fh "$srcdir/csm_share\n"; print $fh "$srcdir/atm/cam/src/utils\n"; print $fh "$srcdir/utils/timing\n";# Parallelization utilies if ($cfg{'dyn'} eq 'fv') { print $fh "$srcdir/utils/pilgrim\n"; }# Advective transport if ($cfg{'dyn'} eq 'eul' or $cfg{'dyn'} eq 'sld') { print $fh "$srcdir/atm/cam/src/advection/slt\n"; }# Ocean package. When using ccm366 physics the ocean package is# included in the physics directory. if ($cfg{'phys'} eq 'cam1') { print $fh "$srcdir/atm/cam/src/ocnsice/$cfg{'ocn'}\n"; }# Land package if ($cfg{'lnd'} eq "lsm") { print $fh "$srcdir/lnd/lsm/src\n"; } else { print $fh "$srcdir/lnd/clm2/src/main\n"; print $fh "$srcdir/lnd/clm2/src/biogeophys\n"; print $fh "$srcdir/lnd/clm2/src/biogeochem\n"; print $fh "$srcdir/lnd/clm2/src/mksrfdata\n"; print $fh "$srcdir/lnd/clm2/src/ecosysdyn\n"; print $fh "$srcdir/lnd/clm2/src/riverroute\n"; }# Sea ice package if ($cfg{'phys'} eq 'cam1') { if ($cfg{'sice'} eq 'csim4') { print $fh "$srcdir/ice/csim4\n"; } else { print $fh "$srcdir/atm/cam/src/ocnsice/dataicemodel\n"; } } $fh->close;}#-------------------------------------------------------------------------------sub write_params_h{ my ($file, %cfg) = @_; my $fh = new IO::File; $fh->open(">$file") or die "** can't open header file: $file\n"; print $fh <<"EOF";#ifndef PARAMS_SET#define PARAMS_SET#define PLON $cfg{'nlon'}#define PLAT $cfg{'nlat'}#define PLEV $cfg{'nlev'}#define PLEVR $cfg{'nlev'}#define PCNST $cfg{'nadv'}#define PNATS $cfg{'nnadv'}#define PTRM $cfg{'trm'}#define PTRN $cfg{'trn'}#define PTRK $cfg{'trk'}EOF my $pcols; if ($cfg{'phys'} eq 'cam1') { $pcols = 16; } else { $pcols = $cfg{'nlon'}; } print $fh "#define PCOLS $pcols\n"; if ($cfg{'dyn'} eq 'fv') { print $fh "#define STAGGERED\n"; } else { print $fh "#undef STAGGERED\n"; } if ($cfg{'ocn'} eq 'som') { print $fh "#define COUP_SOM\n"; } else { print $fh "#undef COUP_SOM\n"; } print $fh "#endif\n"; $fh->close;}#-------------------------------------------------------------------------------sub write_preproc_h{ my ($file, %cfg) = @_; my $fh = new IO::File; $fh->open(">$file") or die "** can't open header file: $file\n"; print $fh <<"EOF";#ifndef PREPROC_SET#define PREPROC_SET#define COUP_CAM#define LSMLON $cfg{'nlon'}#define LSMLAT $cfg{'nlat'}#endifEOF $fh->close;}#-------------------------------------------------------------------------------sub write_misc_h{ my ($file, %cfg) = @_; my $fh = new IO::File; $fh->open(">$file") or die "** can't open header file: $file\n"; print $fh <<"EOF";#ifndef MISC_SET#define MISC_SET#undef COUP_CSMEOF if ($cfg{'spmd'}) { print $fh "#define SPMD\n"; } else { print $fh "#undef SPMD\n"; } if ($cfg{'pergro'}) { print $fh "#define PERGRO\n"; } else { print $fh "#undef PERGRO\n"; } print $fh "#endif\n"; $fh->close;}#-------------------------------------------------------------------------------sub write_makefile{ # Add macro definitions to the beginning of the Makefile # in the CAM configuration script directory my ($file_in, $file_out, %cfg) = @_; my $fh_in = new IO::File; my $fh_out = new IO::File; $fh_out->open(">$file_out") or die "** can't open file: $file_out\n"; my $debug = $cfg{'debug'} ? 'TRUE' : 'FALSE'; my $spmd = $cfg{'spmd'} ? 'TRUE' : 'FALSE'; print $fh_out <<"EOF";# Make macros for CAM.ROOTDIR := $cfg{'cam_root'}EXENAME := $cfg{'cam_exe'}MODEL_EXEDIR := $cfg{'cam_exedir'}INC_NETCDF := $cfg{'nc_inc'}LIB_NETCDF := $cfg{'nc_lib'}INC_MPI := $cfg{'mpi_inc'}LIB_MPI := $cfg{'mpi_lib'}ESMF_ROOT := $cfg{'esmf_root'}ESMF_BLD := $cfg{'esmf_bld'}DEBUG := $debugSPMD := $spmdUSER_FC := $cfg{'fc'}USER_CC := $cfg{'cc'}USER_FFLAGS := $cfg{'fflags'}EOF # Copy the "template" makefile to the new makefile. $fh_in->open("<$file_in") or die "** can't open file: $file_in\n"; while (<$fh_in>) { print $fh_out $_; } $fh_out->close; $fh_in->close;}#-------------------------------------------------------------------------------sub read_res_params{ my ($file) = @_; my $xml = XML::Lite->new( $file ); my $root = $xml->root_element();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -