# (C) Copyright 2013 ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.

if( HAVE_FCTEST )

  if( NOT HAVE_TRANS )
    set( transi_HAVE_MPI 1 )
  endif()

  add_fctest( TARGET atlas_fctest_functionspace
    MPI             4
    CONDITION       eckit_HAVE_MPI AND transi_HAVE_MPI
    LINKER_LANGUAGE Fortran
    SOURCES         fctest_functionspace.F90
    LIBS            atlas_ecmwf_f
    ENVIRONMENT ${ATLAS_TEST_ENVIRONMENT}
  )

endif()

ecbuild_add_test( TARGET atlas_test_functionspace
  SOURCES  test_functionspace.cc
  LIBS     atlas_ecmwf
  ENVIRONMENT ${ATLAS_TEST_ENVIRONMENT}
)

ecbuild_add_test( TARGET atlas_test_cellcolumns
  SOURCES  test_cellcolumns.cc
  LIBS     atlas_ecmwf
  ENVIRONMENT ${ATLAS_TEST_ENVIRONMENT}
)

ecbuild_add_test( TARGET atlas_test_structuredcolumns
  SOURCES  test_structuredcolumns.cc
  LIBS     atlas_ecmwf
  MPI 5
  ENVIRONMENT ${ATLAS_TEST_ENVIRONMENT}
  CONDITION eckit_HAVE_MPI
)

ecbuild_add_test( TARGET atlas_test_pointcloud
  SOURCES  test_pointcloud.cc
  LIBS     atlas_ecmwf
  ENVIRONMENT ${ATLAS_TEST_ENVIRONMENT}
)

ecbuild_add_test( TARGET atlas_test_reduced_halo
  SOURCES test_reduced_halo.cc
  LIBS    atlas_ecmwf
  ENVIRONMENT ${ATLAS_TEST_ENVIRONMENT}
)

ecbuild_add_test( TARGET atlas_test_stencil
  SOURCES  test_stencil.cc
  LIBS     atlas_ecmwf
  ENVIRONMENT ${ATLAS_TEST_ENVIRONMENT}
)

ecbuild_add_executable( TARGET atlas_test_stencil_parallel
  SOURCES  test_stencil_parallel.cc
  LIBS     atlas_ecmwf
  NOINSTALL
)

ecbuild_add_test( TARGET atlas_test_stencil_parallel_mpi4
  COMMAND atlas_test_stencil_parallel
  MPI 4
  ENVIRONMENT ${ATLAS_TEST_ENVIRONMENT}
  CONDITION eckit_HAVE_MPI
)

ecbuild_add_test( TARGET atlas_test_stencil_parallel_mpi16
  COMMAND atlas_test_stencil_parallel
  MPI 16
  ENVIRONMENT ${ATLAS_TEST_ENVIRONMENT}
  CONDITION eckit_HAVE_MPI
)

