From 94b428d997a4aa283a9e3307af07121f18835f87 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 11 Aug 2023 15:49:28 +0100 Subject: [PATCH] Testing: Fortran julian date conversions --- examples/F90/CMakeLists.txt | 1 + examples/F90/codes_datetime_julian.f90 | 34 ++++++++++++++++++++++++++ examples/F90/codes_datetime_julian.sh | 15 ++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 examples/F90/codes_datetime_julian.f90 create mode 100755 examples/F90/codes_datetime_julian.sh diff --git a/examples/F90/CMakeLists.txt b/examples/F90/CMakeLists.txt index 72f71ec9b..65d127cc9 100644 --- a/examples/F90/CMakeLists.txt +++ b/examples/F90/CMakeLists.txt @@ -9,6 +9,7 @@ configure_file( include.ctest.sh.in include.ctest.sh @ONLY ) if( HAVE_BUILD_TOOLS ) list( APPEND tests_sanity codes_ecc-1392 + codes_datetime_julian grib_set_pv grib_set_data bufr_ecc-1284 diff --git a/examples/F90/codes_datetime_julian.f90 b/examples/F90/codes_datetime_julian.f90 new file mode 100644 index 000000000..fa1e8ffd6 --- /dev/null +++ b/examples/F90/codes_datetime_julian.f90 @@ -0,0 +1,34 @@ +! (C) Copyright 2005- 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. +! +! +program codes_datetime_julian + use eccodes + implicit none + + integer(kind=8) :: year=2012, month=1, day=2, hour=13, min=0, sec=48 + integer(kind=8) :: year2, month2, day2, hour2, min2, sec2 + real(kind=8) :: julian + + CALL codes_datetime_to_julian(year, month, day, hour, min, sec, julian) + PRINT *, 'datetime to julian ', julian + + CALL codes_julian_to_datetime(julian, year2, month2, day2, hour2, min2, sec2) + PRINT *, 'julian to datetime ', year2, month2, day2, hour2, min2, sec2 + + IF (year /= year2) THEN + call codes_check(CODES_INTERNAL_ERROR, 'Error', 'Year is wrong') + END IF + IF (month /= month2) THEN + call codes_check(CODES_INTERNAL_ERROR, 'Error', 'Month is wrong') + END IF + IF (day /= day2) THEN + call codes_check(CODES_INTERNAL_ERROR, 'Error', 'Day is wrong') + END IF + +end program codes_datetime_julian diff --git a/examples/F90/codes_datetime_julian.sh b/examples/F90/codes_datetime_julian.sh new file mode 100755 index 000000000..5d7ba0c8c --- /dev/null +++ b/examples/F90/codes_datetime_julian.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# (C) Copyright 2005- 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. +# + +. ./include.ctest.sh + +label="codes_datetime_julian_test_f" + +${examples_dir}/eccodes_f_codes_datetime_julian