#!/bin/bash

# exit on error
set -e
# turn on command echoing
set -v
# make the output directory if it doesn't exist
mkdir -p out
# run from NAMELIST folder, like in MONARCH
cd ..

if [[ $1 == "MPI" ]]; then
  exec_str="mpirun -v -np 2 ../SRC_LIBS/partmc/build/mock_monarch phlex-chem/current_config.json phlex-chem/current_interface.json phlex-chem/out/current"
else
  exec_str="../SRC_LIBS/partmc/build/mock_monarch phlex-chem/current_config.json phlex-chem/current_interface.json phlex-chem/out/current"
fi

if ! $exec_str; then
  echo FAIL
  exit 1
else
  echo PASS
  exit 1
fi
