# Travis doesn't have a fortran build config, so we'll use c as a base and
# create our own environment
language: c
sudo: required

dist: xenial

addons:
  apt:
    update: true
    packages:
      - pkg-config csh cmake 
      - gfortran 
      - openmpi-bin libopenmpi-dev libopenmpi1.10 
      - netcdf-bin libnetcdf-dev libnetcdff-dev libnetcdf11

git:
    depth: 3
    quiet: true

addons:
  apt:
    update: true
    packages:
      - pkg-config csh cmake
      - gcc gfortran 
      - libgomp1 openmpi-bin libopenmpi-dev 
      - libnetcdf-dev libnetcdff-dev  netcdf-bin

env:
    matrix:
        - TYPE=MOM_solo
        - TYPE=MOM_SIS
        - TYPE=CM2M
        - TYPE=ESM2M
        - TYPE=ICCM
        - TYPE=EBM
        - TYPE=ACCESS-OM
        - TYPE=ACCESS-CM
        - TYPE=ACCESS-OM-BGC
        - TYPE=ACCESS-ESM
    global:
        - FC=gfortran
        - OMPI_FC=${FC}
    
before_script:
    - echo $(nf-config --flibs)
    - echo $(nf-config --fflags)
    - |
      if [[ "$TYPE" == "ACCESS-"* ]]; then
        export OASIS_ROOT=$TRAVIS_BUILD_DIR/oasis3-mct/Linux
        git clone --depth=1 https://github.com/COSIMA/oasis3-mct.git
        (cd oasis3-mct && make ubuntu)
      fi
    - |
      if [[ "$TYPE" == "ACCESS-OM" || "$TYPE" == "ACCESS-OM-BGC" ]]; then
        export LIBACCESSOM2_ROOT=$TRAVIS_BUILD_DIR/libaccessom2
        wget https://github.com/COSIMA/libaccessom2/releases/latest/download/binary_release.tar.gz
        tar -zxf binary_release.tar.gz
      fi

script: 
    - env
    - cd exp && ./MOM_compile.csh --type $TYPE --platform travis --use_netcdf4

# after_success:
#     - find .
#     - codecov --gcov-exec=gcov

