#!/bin/bash
#Usage: make target CORE=[core] [options]
#Example targets:
#    ifort
#    gfortran
#    xlf
#    pgi
#Availabe Cores:
#    atmosphere
#    init_atmosphere
#    landice
#    ocean
#    seaice
#    sw
#    test
#Available Options:
#    DEBUG=true    - builds debug version. Default is optimized version.
#    USE_PAPI=true - builds version using PAPI for timers. Default is off.
#    TAU=true      - builds version using TAU hooks for profiling. Default is off.
#    AUTOCLEAN=true    - forces a clean of infrastructure prior to build new core.
#    GEN_F90=true  - Generates intermediate .f90 files through CPP, and builds with them.
#    TIMER_LIB=opt - Selects the timer library interface to be used for profiling the model. Options are:
#                    TIMER_LIB=native - Uses native built-in timers in MPAS
#                    TIMER_LIB=gptl - Uses gptl for the timer interface instead of the native interface
#                    TIMER_LIB=tau - Uses TAU for the timer interface instead of the native interface
#    OPENMP=true   - builds and links with OpenMP flags. Default is to not use OpenMP.
#    OPENACC=true  - builds and links with OpenACC flags. Default is to not use OpenACC.
#    USE_PIO2=true - links with the PIO 2 library. Default is to use the PIO 1.x library.
#    PRECISION=single - builds with default single-precision real kind. Default is to use double-precision.
#    SHAREDLIB=true - generate position-independent code suitable for use in a shared library. Default is false.

export LC_ALL="en_US.UTF-8"

# BE CAREFUL WITH THE LIB SUFFIX NAME !!! CHECK IT EVERY INSTALLATION WITH: spack find -p
# ***************************************************************************************
# ***************************************************************************************

DIR_MPAS_LIBS=/mnt/beegfs/denis.eiras/spack/spack_ufs/opt/spack/linux-rhel8-zen2/intel-2021.4.0
export NETCDF=${DIR_MPAS_LIBS}/netcdf-c-4.8.1-i4a34atday6jesyhfxq7wj4vkllyqshf
export PNETCDF=${DIR_MPAS_LIBS}/parallel-netcdf-1.12.2-6rmjpdchj5wna4mfyyj2vj3n7kypyqz3
export PIO=${DIR_MPAS_LIBS}/parallelio-2_5_4-daursxrgf2dd2auuzpzeztso7zt76bzv

make -j 8 ifort DEBUG=true CORE=atmosphere OPENMP=true USE_PIO2=true PRECISION=single 2>&1 | tee make.output
