Skip to content

Commit

Permalink
Yaml Parser (#858)
Browse files Browse the repository at this point in the history
Adds fortran wrappers to libyaml, enabled via the -Duse_yaml macro
Adds unit test to test if the parser is working/crashing as expected
Adds an option, --with-yaml to autotools that checks that the environment is set up correctly and adds the -Duse_yaml macro to your compilation.
Implements the parser to read data_table.yaml and tests this using an ongrid data_override test
  • Loading branch information
uramirez8707 authored Nov 12, 2021
1 parent 474e15a commit 90583ae
Show file tree
Hide file tree
Showing 19 changed files with 1,953 additions and 121 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ SUBDIRS = \
fms2_io \
mosaic2 \
fms \
parser \
affinity \
mosaic \
time_manager \
Expand Down
21 changes: 21 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ AC_ARG_WITH([mpi],
AS_IF([test ${with_mpi:-yes} = yes],
[with_mpi=yes],
[with_mpi=no])
AC_ARG_WITH([yaml],
[AS_HELP_STRING([--with-yaml],
[Build with YAML support. This option will be ignored if --disable-fortran-flag-setting is also given. (Default no)])])
AS_IF([test ${with_yaml:-no} = no],
[with_yaml=no],
[with_yaml=yes])
AC_ARG_ENABLE([setting-flags],
[AS_HELP_STRING([--enable-setting-flags],
[Allow configure to set some compiler flags. Disabling this will also disable any other --with or --enable options that set flags, and will only use user-provided falgs. (Default yes)])])
Expand Down Expand Up @@ -122,6 +128,19 @@ if test $with_mpi = yes; then
AC_CHECK_FUNC([MPI_Init], [], [AC_MSG_ERROR([Can't find the MPI C library. Set CC/LDFLAGS/LIBS])])
fi

# Require yaml
if test $with_yaml = yes; then
AC_CHECK_HEADERS([yaml.h], [], [AC_MSG_ERROR(["Can't find the libYAML C header file. Set CC/CPPFLAGS/CFLAGS"])])
AC_SEARCH_LIBS([yaml_parser_initialize], [yaml], [], [AC_MSG_ERROR(["Can't find the libYAML C library. Set CC/LDFLAGS/LIBS"])])

#If the test pass, define use_yaml macro
AC_DEFINE([use_yaml], [1], [This is required to use yaml parser])

AM_CONDITIONAL([SKIP_PARSER_TESTS], false )
else
AM_CONDITIONAL([SKIP_PARSER_TESTS], true )
fi

# Require netCDF
AC_CHECK_HEADERS([netcdf.h], [], [AC_MSG_ERROR([Can't find the netCDF C header file. Set CPPFLAGS/CFLAGS])])
AC_SEARCH_LIBS([nc_create], [netcdf], [], [AC_MSG_ERROR([Can't find the netCDF C library. Set LDFLAGS/LIBS])])
Expand Down Expand Up @@ -337,6 +356,7 @@ AC_CONFIG_FILES([
random_numbers/Makefile
libFMS/Makefile
docs/Makefile
parser/Makefile
test_fms/test_common.sh
test_fms/Makefile
test_fms/diag_manager/Makefile
Expand All @@ -357,6 +377,7 @@ AC_CONFIG_FILES([
test_fms/mosaic/Makefile
test_fms/affinity/Makefile
test_fms/coupler/Makefile
test_fms/parser/Makefile
FMS.pc
])

Expand Down
304 changes: 187 additions & 117 deletions data_override/data_override.F90

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2033,7 +2033,7 @@ INCLUDE_FILE_PATTERNS = *.inc
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

PREDEFINED =
PREDEFINED = use_yaml

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
Expand Down
4 changes: 4 additions & 0 deletions docs/grouping.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
*
*/

/** @defgroup parser Parser
*
*/

/** @defgroup platform Platform
*
*/
Expand Down
2 changes: 1 addition & 1 deletion fms/fms.F90
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ function fms_c2f_string (cstring) result(fstring)

allocate(character(len=length) :: fstring) !> Set the length of fstring
fstring = string_buffer

deallocate(string_buffer)
end function fms_c2f_string
!#######################################################################
!> @brief Prints to the log file (or a specified unit) the version id string and
Expand Down
1 change: 1 addition & 0 deletions libFMS/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ libFMS_la_LIBADD += $(top_builddir)/tracer_manager/libtracer_manager.la
libFMS_la_LIBADD += $(top_builddir)/random_numbers/librandom_numbers.la
libFMS_la_LIBADD += $(top_builddir)/diag_integral/libdiag_integral.la
libFMS_la_LIBADD += $(top_builddir)/sat_vapor_pres/libsat_vapor_pres.la
libFMS_la_LIBADD += $(top_builddir)/parser/libparser.la
libFMS_la_LIBADD += $(top_builddir)/libFMS_mod.la

# At least one source file must be included to please Automake.
Expand Down
42 changes: 42 additions & 0 deletions parser/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#***********************************************************************
#* GNU Lesser General Public License
#*
#* This file is part of the GFDL Flexible Modeling System (FMS).
#*
#* FMS is free software: you can redistribute it and/or modify it under
#* the terms of the GNU Lesser General Public License as published by
#* the Free Software Foundation, either version 3 of the License, or (at
#* your option) any later version.
#*
#* FMS is distributed in the hope that it will be useful, but WITHOUT
#* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
#* for more details.
#*
#* You should have received a copy of the GNU Lesser General Public
#* License along with FMS. If not, see <http://www.gnu.org/licenses/>.
#***********************************************************************

# This is an automake file for the constants directory of the FMS
# package.

# Ed Hartnett 2/22/19

# Include .h and .mod files.
AM_CPPFLAGS = -I$(top_srcdir)/include
AM_FCFLAGS = $(FC_MODINC). $(FC_MODOUT)$(MODDIR)

# Build this uninstalled convenience library.
noinst_LTLIBRARIES = libparser.la

# The convenience library depends on its source.
libparser_la_SOURCES = \
yaml_parser.F90 \
yaml_parser_binding.c

MODFILES = \
yaml_parser_mod.$(FC_MODEXT)
BUILT_SOURCES = $(MODFILES)
nodist_include_HEADERS = $(MODFILES)

include $(top_srcdir)/mkmods.mk
Loading

0 comments on commit 90583ae

Please sign in to comment.