Install wrf gcc ompi double.sh

From HPC users
Jump to navigationJump to search

Note:

  • The commands in the box below has to be stored in file called install_wrf_gcc_ompi_double.sh.
  • To execute the script please set the execution permissions by chmod 755 install_wrf_gcc_ompi_double.sh.
  • usage is install_wrf_gcc_ompi_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}_gcc_ompi_double and WPS_v${WRF_RELEASE]_gcc_ompi_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 gcc and openmpi with double precision\n\nusage:\n  install_wrf_gcc_ompi.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}_gcc_ompi_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/gcc/64/4.1.1
	module load openmpi/gcc/64/1.4.3
	module load gcc/4.7.1
	module load jasper/1.900.1/gcc/4.7.1

# 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 openMPI compilers
	
	export OMPI_MPICC=gcc
	export OMPI_MPIF90=gfortran
	export OMPI_MPIF77=gfortran
	export OMPI_MPIFC=gfortran

# parallel build on 8 cores

	export J='-j 8'	

# set right netcdf by

	export NETCDF=${NETCDFHOME}
	
# set jasper by

	export JASPERINC=/cm/shared/apps/jasper/1.900.1/gcc/4.7.1/include 
	export JASPERLIB=/cm/shared/apps/jasper/1.900.1/gcc/4.7.1/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 
#   25 (Linux x86_64 i486 i586 i686, ifort compiler with icc (dmpar), then 
#    1 (basic)

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

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

# make settings for intel mpi

	sed configure.wrf  -e 's/^DM_CC.*/DM_CC = mpicc -DMPI2_SUPPORT/' \
                        >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 
#   19 (3.4), 23 (v3.4.1)

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

	  3.4 )
            echo -e "19" | ./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/-convert big_endian/-convert big_endian -fdefault-real-8/g' \
	    -e 's/g95/gfortran/g' -e 's/^DM_FC.*/DM_FC = mpif90/' \
	    -e 's/^DM_CC.*/DM_CC = mpicc/' 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 
#   25 (Linux x86_64 i486 i586 i686, ifort compiler with icc (dmpar), then 
#    1 (basic)

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

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

# make settings for intel mpi

	sed configure.wrf  -e 's/^DM_CC.*/DM_CC = mpicc -DMPI2_SUPPORT/' \
                       -e 's/^RWORDSIZE.*/RWORDSIZE = 8/g' \
	                   -e 's/^PROMOTION.*/PROMOTION = -fdefault-real-8/g' \
                       >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