Install wrf intel double.sh

From HPC users
Revision as of 15:47, 25 January 2013 by Albensoeder (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Note:

  • The commands in the box below has to be stored in file called install_wrf_intel_double.sh.
  • To execute the script please set the execution permissions by chmod 755 install_wrf_intel_double.sh.
  • usage is install_wrf_intel_double.sh WRF_RELEASE DIR_TO_TAR_GZ_FILES
  • The final installation of WRF and WPS will be in the directories WRFV3_v${WRF_RELEASE}_intel_double and WPS_v${WRF_RELEASE]_intel_double, respectively
  • The orginal folders WRFV3 and WPS will be removed during the installation process!
#!/bin/bash

# Web site: http://www.mmm.ucar.edu/wrf/OnLineTutorial/index.htm

	HELP_MSG="Installation program for WRF on flow with intel compilers and intel mpi with double precision\n\nusage:\n  install_wrf_intel.sh WRF_VERSION WRF_TAR_DIR\n"

# check number od cmdline args

	if [ $# != 2 ]; then
	  echo -e $HELP_MSG
	  exit 1
	fi
	
        WRF_VERSION=$1
	WPS_SRC_DIR=$2
	
  	BUILD_SUFFIX=v${WRF_VERSION}_intel_double
	export WRF_INST_DIR=WRFV3_$BUILD_SUFFIX
	export WPS_INST_DIR=WPS_$BUILD_SUFFIX
	echo "build $WRF_INST_DIR..."
	
# load modules

    if [ "$LOADEDMODULES" != "" ]; then
      echo 'clean and load module'
      echo "Please answer following quesion with 'y' to enable a clean setup!"
      module clear 
    fi
	
	module load shared
	module load netcdf/4.2.1.1/intel/64/2011.0.013 
	module load netcdf-fortran/4.2/intel/64/2011.0.013
	module load intel/impi/64/4.1.0.024
	module load intel/ics/64/2013.0.028
	module load jasper/1.900.1/intel/64/2011.0.013

# check compiler version
    ICC_VERSION=`icc --version|head -1|awk '{print $3}'`
    echo -e "icc version $ICC_VERSION"
    if [ $ICC_VERSION != "13.0.1" ]; then
      echo -e "ERROR: icc version $ICC_VERSION is not correct!"
	  exit 1
    fi
    
# check untar files

	echo "untar files..."
	if [ ! -e $WPS_SRC_DIR/WRFV${WRF_VERSION}.TAR.gz ]; then
	  echo -e "Source tar-ball\n $WPS_SRC_DIR/WRFV${WRF_VERSION}.TAR.gz\n does not exist!"
	  exit 1
	fi
	
	if [ ! -e $WPS_SRC_DIR/WPSV${WRF_VERSION}.TAR.gz ]; then
	  echo -e "Source tar-ball\n $WPS_SRC_DIR/WRFV${WRF_VERSION}.TAR.gz\n does not exist!"
	  exit 1
	fi
	
	rm -rf WRFV3 WPS $WRF_INST_DIR $WPS_INST_DIR
	tar -xzf $WPS_SRC_DIR/WRFV${WRF_VERSION}.TAR.gz
	tar -xzf $WPS_SRC_DIR/WPSV${WRF_VERSION}.TAR.gz

# mv build

	mv WRFV3 $WRF_INST_DIR
	mv WPS $WPS_INST_DIR

##################################################################
# go into directory WRF to make WRF with single precision 
# for wps
##################################################################

	cd $WRF_INST_DIR

# set intel compilers

	export I_MPI_CC=icc
	export I_MPI_CXX=icpc
	export I_MPI_FC=ifort
	export I_MPI_F77=ifort
	export I_MPI_F90=ifort

# parallel build on 8 cores

	export J='-j 8'	

# set right netcdf by

	export NETCDF=${NETCDFF_HOME}
	
# set jasper by

	export JASPERINC=/cm/shared/apps/jasper/1.900.1/intel/64/2011.0.013/include
	export JASPERLIB=/cm/shared/apps/jasper/1.900.1/intel/64/2011.0.013/lib

	sed -e 's/I_really_want_to_output_grib2_from_WRF = "FALSE"/I_really_want_to_output_grib2_from_WRF = "TRUE"/' arch/Config_new.pl > arch/Config_new.pl_new
	mv arch/Config_new.pl_new arch/Config_new.pl
	
# enable large file support

	export WRFIO_NCD_LARGE_FILE_SUPPORT=1

# linux intel cluster

	export WRF_EM_CORE=1

# run configure and select 
#   15 
#    1 (basic)

	./clean -a >& /dev/null 
	case $WRF_VERSION in
	
	  3.4.1 )
            echo -e "15\n1\n" | ./configure &> configure.log
	    ;;

	  3.4 )
            echo -e "15\n1\n" | ./configure &> configure.log
	    ;;
	  * )
	    echo "WRV3 release not supported yet. Please configure!"
	    exit 1
	    ;;
	esac

# make settings for intel mpi
	sed -e 's/-lnetcdff -lnetcdf/-lnetcdff -L$(NETCDF_DIR) -lnetcdf/' \
	    -e 's/-fno-ip/-no-ip/g' \
	    -e 's/-O3/-O3 -heap-arrays -fp-model precise/g' \
	    -e 's/^DM_CC.*/DM_CC\  \=\ mpicc -DMPI2_SUPPORT/' \
	    -e 's/^DM_FC.*/DM_FC\  \=\ mpif90/' configure.wrf >configure.wrf.impi
	mv configure.wrf.impi configure.wrf
	
# compile and log compilation

	echo 'compile WRF for WPS in single precision...'
	./compile em_real >& compile.log
	if [ $? != "0" ]; then
	  echo "Error in building WRF"
	  exit 1
	fi

# check existance of binaries
	BIN_NAMES="main/real.exe main/ndown.exe main/nup.exe main/wrf.exe main/tc.exe"
	for name in $BIN_NAMES; do
	  if [ ! -x $name ]; then
	    echo "Binary $name not exist! WRF was not build correctly!"
	    exit 1
	  fi
	done

##################################################################
# go into directory WPS to make WPS
##################################################################
# make now WPS
# so change directory and clean it for safity

	cd ../$WPS_INST_DIR
	echo "build $WPS_INST_DIR..."
	./clean -a >& /dev/null 

#
# patch files
	sed  -e 's/BIG_ENDIAN/MY_BIG_ENDIAN/g' \
	     -e 's/LITTLE_ENDIAN/MY_LITTLE_ENDIAN/g' geogrid/src/read_geogrid.c > geogrid/src/read_geogrid.c_patched
	mv geogrid/src/read_geogrid.c_patched geogrid/src/read_geogrid.c

# run configure and select 
#   15 (3.4), 19 (v3.4.1)

	case $WRF_VERSION in
	
	  3.4.1 )
            echo -e "19" | ./configure &> configure.log
	    ;;

	  3.4 )
            echo -e "15" | ./configure &> configure.log
	    ;;
	  * )
	    echo "WPS release not supported yet. Please configure!"
	    exit 1
	    ;;
	esac

# make settings for intel mpi

	sed  -e 's/^WRF_DIR.*/WRF_DIR = ..\/$(WRF_INST_DIR)/' \
	     -e 's/-lnetcdff -lnetcdf/-lnetcdff -L$(NETCDF_DIR) -lnetcdf/' \
	     -e 's/^DM_CC.*/DM_CC\  \=\ mpicc/' \
	     -e 's/^DM_FC.*/DM_FC\  \=\ mpif90/'  \
	     -e 's/^SCC.*/SCC\  \=\ icc/' configure.wps > configure.wps.tmp
	mv configure.wps.tmp configure.wps
	
# compile and log compilation

	echo 'compile WPS...'
	./compile >& compile.log
	if [ $? != "0" ]; then
          echo "Error in building WPS"
          exit 1
	fi

# check existance of binaries
	BIN_NAMES="geogrid/src/geogrid.exe metgrid/src/metgrid.exe ungrib/src/ungrib.exe util/rd_intermediate.exe"
	for name in $BIN_NAMES; do
	  if [ ! -x $name ]; then
	    echo "Binary $name not exist! WPS was not build correctly!"
	    exit 1
	  fi
	done

# and go back to root install dir

    cd ..

##################################################################
# Now build the final version of WRF again with double precision
##################################################################

	rm -rf $WRF_INST_DIR
	tar -xzf $WPS_SRC_DIR/WRFV${WRF_VERSION}.TAR.gz

# mv build

	mv WRFV3 $WRF_INST_DIR

##################################################################
# go into directory WRF to make WRF with double precision 
##################################################################

	cd $WRF_INST_DIR

# set jasper by
	sed -e 's/I_really_want_to_output_grib2_from_WRF = "FALSE"/I_really_want_to_output_grib2_from_WRF = "TRUE"/' arch/Config_new.pl > arch/Config_new.pl_new
	mv arch/Config_new.pl_new arch/Config_new.pl

# run configure and select 
#   15 
#    1 (basic)

	./clean -a >& /dev/null 
	case $WRF_VERSION in
	
	  3.4.1 )
            echo -e "15\n1\n" | ./configure &> configure.log
	    ;;

	  3.4 )
            echo -e "15\n1\n" | ./configure &> configure.log
	    ;;
	  * )
	    echo "WRV3 release not supported yet. Please configure!"
	    exit 1
	    ;;
	esac

# make settings for intel mpi

	sed -e 's/-lnetcdff -lnetcdf/-lnetcdff -L$(NETCDF_DIR) -lnetcdf/' \
	    -e 's/-fno-ip/-no-ip/g' \
	    -e 's/-O3/-O3 -heap-arrays -fp-model precise/g' \
	    -e 's/^RWORDSIZE.*/RWORDSIZE = 8/g' \
	    -e 's/^PROMOTION.*/PROMOTION = -i4 -r8/g' \
	    -e 's/^DM_CC.*/DM_CC\  \=\ mpicc -DMPI2_SUPPORT/' \
	    -e 's/^DM_FC.*/DM_FC\  \=\ mpif90/' configure.wrf >configure.wrf.impi
	mv configure.wrf.impi configure.wrf
	
# compile and log compilation

	echo 'compile final WRF with double precision...'
	./compile em_real >& compile.log
	if [ $? != "0" ]; then
	  echo "Error in building WRF"
	  exit 1
	fi

# check existance of binaries
	BIN_NAMES="main/real.exe main/ndown.exe main/nup.exe main/wrf.exe main/tc.exe"
	for name in $BIN_NAMES; do
	  if [ ! -x $name ]; then
	    echo "Binary $name not exist! WRF was not build correctly!"
	    exit 1
	  fi
	done

#################################################################################
# go back to root directory
################################################################################	
	cd ..

back to WRF/WPS main page