module load gcc/9.3.0
module load cmake/3.26.4
module load netcdf/gcc.9/4.9.2
export COMPILER=gcc.9.3.0
rm -r build; mkdir build ; cd build
echo `pwd`
parentdir="$(dirname "$(pwd)")"
export PREFIX=$parentdir
echo "builing for "$PREFIX
echo "Press ENTER to run cmake";read aaa
export HDF5=/sw/dataformats/hdf5/$COMPILER/1.12.2/skl
#export HDF5_LIBRARIES=$HDF5/lib
export HDF5_LIBRARIES="$HDF5/lib/libhdf5.a $HDF5/lib/libhdf5_hl.a"
export HDF5_INCLUDE_DIRS=$HDF5/include
export PATH=$HDF5:$PATH
export NETCDF=`nc-config --prefix`
FFLAGS="-O3 -fPIC -march=skylake-avx512 -Wl,-rpath=$LD_RUN_PATH"
CFLAGS="-O3 -fPIC -march=skylake-avx512 -Wl,-rpath=$LD_RUN_PATH"
export CC=gcc
export CXX=g++
export FC=gfortran
cmake \
-DCMAKE_C_COMPILER="$CC" -DCMAKE_Fortran_COMPILER="$FC" \
-DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_Fortran_FLAGS="$FFLAGS" \
-DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_CXX_FLAGS="$CFLAGS" \
-DBUILD_SHARED_LIBS=BOTH \
-DENABLE_MEMFS=ON \
-DENABLE_PNG=ON \
-DENABLE_JPG=ON \
-DENABLE_AEC=ON -DAEC_DIR=/sw/dataformats/aec/1.0.6/skl/intel.19 \
-DENABLE_FORTRAN=ON \
-DENABLE_NETCDF=ON \
-DENABLE_ECCODES_OMP_THREADS=ON \
-DNETCDF_PATH=$NETCDF \
-DENABLE_INSTALL_ECCODES_DEFINITIONS=ON \
-DENABLE_INSTALL_ECCODES_SAMPLES=ON \
-DECCODES_INSTALL_EXTRA_TOOLS=ON \
-DENABLE_ECCODES_OMP_THREADS=ON \
-DCMAKE_INSTALL_PREFIX="$PREFIX" ../src
echo "Press ENTER to run make";read aaa
make -j8
echo "Press ENTER to run ctest";read aaa
ctest
echo "Press ENTER to run make install";read aaa
make install
echo "Do not forget to run make clean!"