diff --git a/src/atlas_f/CMakeLists.txt b/src/atlas_f/CMakeLists.txt index 390c46b29..3c3d396e0 100644 --- a/src/atlas_f/CMakeLists.txt +++ b/src/atlas_f/CMakeLists.txt @@ -136,9 +136,6 @@ generate_fortran_bindings(FORTRAN_BINDINGS ../atlas/functionspace/detail/PointCl generate_fortran_bindings(FORTRAN_BINDINGS ../atlas/redistribution/detail/RedistributionInterface.h MODULE atlas_redistribution_c_binding OUTPUT redistribution_c_binding.f90) -generate_fortran_bindings(FORTRAN_BINDINGS ../atlas/util/function/MDPI_functions.h - MODULE atlas_functions_c_binding - OUTPUT functions_c_binding.f90) if( atlas_HAVE_ATLAS_NUMERICS ) generate_fortran_bindings(FORTRAN_BINDINGS ../atlas/numerics/Nabla.h) diff --git a/src/atlas_f/util/atlas_functions_module.F90 b/src/atlas_f/util/atlas_functions_module.F90 index 9c424bf19..ee94b80e2 100644 --- a/src/atlas_f/util/atlas_functions_module.F90 +++ b/src/atlas_f/util/atlas_functions_module.F90 @@ -11,13 +11,44 @@ module atlas_functions_module use, intrinsic :: iso_c_binding -use atlas_functions_c_binding implicit none +interface + +pure function atlas__functions__MDPI_sinusoid( lon, lat ) bind(C,name="atlas__functi& + &ons__MDPI_sinusoid") + use iso_c_binding, only: c_double + real(c_double) :: atlas__functions__MDPI_sinusoid + real(c_double), intent(in) :: lon, lat +end function + +pure function atlas__functions__MDPI_harmonic( lon, lat ) bind(C,name="atlas__functi& + &ons__MDPI_harmonic") + use iso_c_binding, only: c_double + real(c_double) :: atlas__functions__MDPI_harmonic + real(c_double), intent(in) :: lon, lat +end function + +pure function atlas__functions__MDPI_vortex( lon, lat ) bind(C,name="atlas__function& + &s__MDPI_vortex") + use iso_c_binding, only: c_double + real(c_double) :: atlas__functions__MDPI_vortex + real(c_double), intent(in) :: lon, lat +end function + +pure function atlas__functions__MDPI_gulfstream( lon, lat ) bind(C,name="atlas__func& + &tions__MDPI_gulfstream") + use iso_c_binding, only: c_double + real(c_double) :: atlas__functions__MDPI_gulfstream + real(c_double), intent(in) :: lon, lat +end function + +end interface + contains -function MDPI_sinusoid(lon, lat) result(val) +elemental function MDPI_sinusoid(lon, lat) result(val) real(c_double), intent(in) :: lon, lat real(c_double) :: val val = atlas__functions__MDPI_sinusoid(lon, lat) @@ -25,7 +56,7 @@ end function MDPI_sinusoid ! ----------------------------------------------------------------------------- -function MDPI_harmonic(lon, lat) result(val) +elemental function MDPI_harmonic(lon, lat) result(val) real(c_double), intent(in) :: lon, lat real(c_double) :: val val = atlas__functions__MDPI_harmonic(lon, lat) @@ -33,7 +64,7 @@ end function MDPI_harmonic ! ----------------------------------------------------------------------------- -function MDPI_vortex(lon, lat) result(val) +elemental function MDPI_vortex(lon, lat) result(val) real(c_double), intent(in) :: lon, lat real(c_double) :: val val = atlas__functions__MDPI_vortex(lon, lat) @@ -41,7 +72,7 @@ end function MDPI_vortex ! ----------------------------------------------------------------------------- -function MDPI_gulfstream(lon, lat) result(val) +elemental function MDPI_gulfstream(lon, lat) result(val) real(c_double), intent(in) :: lon, lat real(c_double) :: val val = atlas__functions__MDPI_gulfstream(lon, lat) diff --git a/src/tests/util/fctest_functions.F90 b/src/tests/util/fctest_functions.F90 index fa01a72d9..f631de14f 100644 --- a/src/tests/util/fctest_functions.F90 +++ b/src/tests/util/fctest_functions.F90 @@ -46,6 +46,25 @@ end module fcta_functions_fxt val = MDPI_gulfstream(1._c_double, 1._c_double) END_TEST +TEST( test_atlas_Functions_vector ) + real(c_double), dimension(3) :: val, lon, lat + lon = [ 1._c_double, 1._c_double, 1._c_double ] + lat = [ 1._c_double, 1._c_double, 1._c_double ] + val = MDPI_sinusoid(lon, lat) + val = MDPI_harmonic(lon, lat) + val = MDPI_vortex(lon, lat) + val = MDPI_gulfstream(lon, lat) +END_TEST + +TEST( test_initialise_field ) + type(atlas_Field) :: field + real(c_double), dimension(:,:), pointer :: fieldv + real(c_double), dimension(3) :: val + field = atlas_Field(kind=atlas_real(c_double), shape=[3,3]) + call field%data(fieldv) + val = MDPI_sinusoid(fieldv(1,:), fieldv(2,:)) +END_TEST + ! ----------------------------------------------------------------------------- END_TESTSUITE