Skip to content

Commit

Permalink
Testing script for OpenMPI
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaweiZhuang committed Dec 12, 2018
1 parent 20c164a commit 288f7db
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/build_environment/GCHP/openmpi/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Testing OpenMPI
77 changes: 77 additions & 0 deletions scripts/build_environment/GCHP/openmpi/gchp.ubuntu.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#==============================================================================
# Environment variables
#==============================================================================

# Specify compilers
export CC=gcc
export OMPI_CC=$CC

export CXX=g++
export OMPI_CXX=$CXX

export FC=gfortran
export F77=$FC
export F90=$FC
export OMPI_FC=$FC
export COMPILER=$FC
export ESMF_COMPILER=gfortran

# MPI Communication
export ESMF_COMM=openmpi
export MPI_ROOT=$( dirname $( dirname $( which mpirun ) ) )

# Base paths
export NETCDF_HOME=/usr
export NETCDF_FORTRAN_HOME=/usr

export GC_BIN="$NETCDF_HOME/bin"
export GC_INCLUDE="$NETCDF_HOME/include"
export GC_LIB="$NETCDF_HOME/lib"

# Add to primary path
export PATH=${NETCDF_HOME}/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${NETCDF_HOME}/lib

# If using NetCDF after the C/Fortran split (4.3+), then you will need to
# specify the following additional environment variables
export GC_F_BIN="$NETCDF_FORTRAN_HOME/bin"
export GC_F_INCLUDE="$NETCDF_FORTRAN_HOME/include"
export GC_F_LIB="$NETCDF_FORTRAN_HOME/lib"
export PATH=${NETCDF_FORTRAN_HOME}/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${NETCDF_FORTRAN_HOME}/lib

# Set ESMF optimization (g=debugging, O=optimized (capital o))
export ESMF_BOPT=O

#==============================================================================
# Raise memory limits
#==============================================================================

ulimit -c unlimited # coredumpsize
ulimit -l unlimited # memorylocked
ulimit -u 50000 # maxproc
ulimit -v unlimited # vmemoryuse

#==============================================================================
# additional fixes for MAPL
#==============================================================================
export GC_CODE_DIR=$HOME/tutorial/Code.GCHP

# --- Fixes for Makefile ---
# Dependencies files *.d in MAPL are messed up in that
# 1. It directly specifies library headers like mpi.h as dependency, which should have been handled by MPI wrapper like mpicc.
# 2. It cannot find *.mod files that are in another directory.
# VPATH allows makefile to search additional directories, although is not a good practice.
# This prevents the error "no rule to make target"
export VPATH=/usr/include/x86_64-linux-gnu:$VPATH # sys/resource.h
export VPATH=$GC_CODE_DIR/GCHP/Shared/MAPL_Base:$VPATH # mapl_*.mod
export VPATH=$GC_CODE_DIR/GCHP/ESMF/Linux/mod:$VPATH # esmf.mod

# --- Fixed for header files ("#include <xxx.h>" statement) ---
# This prevents the error "cannot find..."
export CPATH=$GC_CODE_DIR/GCHP/Shared/MAPL_Base:$CPATH # MAPL_Generic.h
export CPATH=$GC_CODE_DIR/GCHP/Shared/GFDL_fms/shared/include:$CPATH # fms_platform.h

# --- Fixes for module files ("USE xxx" statement) ---
# zonal.f is looking for mapl_constantsmod.mod in its own directory. Even /usr/include/ is not included
sudo ln -sf $GC_CODE_DIR/GCHP/Shared/MAPL_Base/mapl_constantsmod.mod $GC_CODE_DIR/GCHP/Shared/GEOS_Util/plots/
30 changes: 30 additions & 0 deletions scripts/build_environment/GCHP/openmpi/install_libraries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Tested on ubuntu 18.04 LTS (ami-0ac019f4fcb7cb7e6)

# =========================
# Additional fixes for GCHP
# =========================
sudo apt-get update

# All libraries need for GCHP. f2py and mpich are new libraries in addition to GC-classic.
sudo apt-get install -y bc gcc gfortran \
libnetcdf-dev libnetcdff-dev netcdf-bin \
python-numpy libopenmpi-dev

# Ubuntu AMI has vim and nano but no emacs
sudo apt-get install -y emacs

# Pull S3 data without installing anaconda Python
sudo apt-get install -y awscli

# clean up cache
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*

# =========================
# Additional fixes for GCHP
# =========================

# GCHP directly uses `gmake` command, which is not available on ubuntu
# https://ubuntuforums.org/showthread.php?t=1811030
sudo ln -s /usr/bin/make /usr/bin/gmake

0 comments on commit 288f7db

Please sign in to comment.