Skip to content

Commit

Permalink
Merge pull request #241 from climbfuji/bugfix_libxml2_info_message_un…
Browse files Browse the repository at this point in the history
…it_conversion

Bugfix libxml2 library location macOS, logging message for unit conversions, bugfix for metadata2html.py
  • Loading branch information
climbfuji committed Nov 20, 2019
2 parents f3cad9e + 5073d98 commit 6da7808
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
14 changes: 9 additions & 5 deletions scripts/metadata2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
help='path to CCPP prebuild configuration file')
method.add_argument('--metafile', '-m', action='store',
help='name of metadata file to convert (requires -o)')
parser.add_argument('--basedir', '-b', action='store',
help='relative path to CCPP directory',
required=False, default='.')
parser.add_argument('--outputdir', '-o', action='store',
help='directory where to write the html files',
required='--metafile' in sys.argv or '-m' in sys.argv)
Expand All @@ -38,10 +41,11 @@ def parse_arguments():
args = parser.parse_args()
config = args.config
filename = args.metafile
basedir = args.basedir
outdir = args.outputdir
return (config, filename, outdir)
return (config, filename, outdir, basedir)

def import_config(configfile, logger):
def import_config(configfile, basedir, logger):
"""Import the configuration from a given configuration file"""

if not os.path.isfile(configfile):
Expand All @@ -61,7 +65,7 @@ def import_config(configfile, logger):
# Add model-independent, CCPP-internal variable definition files
config['variable_definition_files'].append(CCPP_INTERNAL_VARIABLE_DEFINITON_FILE)
# Output directory for converted metadata tables
config['metadata_html_output_dir'] = ccpp_prebuild_config.METADATA_HTML_OUTPUT_DIR
config['metadata_html_output_dir'] = ccpp_prebuild_config.METADATA_HTML_OUTPUT_DIR.format(build_dir=basedir)

return config

Expand Down Expand Up @@ -102,9 +106,9 @@ def main():
logger = init_log('metadata2html')
set_log_level(logger, logging.INFO)
# Convert metadata file
(configfile, filename, outdir) = parse_arguments()
(configfile, filename, outdir, basedir) = parse_arguments()
if configfile:
config = import_config(configfile, logger)
config = import_config(configfile, basedir, logger)
filenames = get_metadata_files_from_config(config, logger)
outdir = get_output_directory_from_config(config, logger)
for filename in filenames:
Expand Down
3 changes: 3 additions & 0 deletions scripts/mkcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from __future__ import print_function
import copy
import logging
import os
import sys
import getopt
Expand Down Expand Up @@ -184,6 +185,7 @@ def convert_to(self, units):
function_name = '{0}__to__{1}'.format(string_to_python_identifier(self.units), string_to_python_identifier(units))
try:
function = getattr(unit_conversion, function_name)
logging.info('Automatic unit conversion from {0} to {1} for {2} before entering {3}'.format(self.units, units, self.standard_name, self.container))
except AttributeError:
raise Exception('Error, automatic unit conversion from {0} to {1} for {2} in {3} not implemented'.format(self.units, units, self.standard_name, self.container))
conversion = function()
Expand All @@ -194,6 +196,7 @@ def convert_from(self, units):
function_name = '{1}__to__{0}'.format(string_to_python_identifier(self.units), string_to_python_identifier(units))
try:
function = getattr(unit_conversion, function_name)
logging.info('Automatic unit conversion from {0} to {1} for {2} after returning from {3}'.format(self.units, units, self.standard_name, self.container))
except AttributeError:
raise Exception('Error, automatic unit conversion from {1} to {0} for {2} in {3} not implemented'.format(self.units, units, self.standard_name, self.container))
conversion = function()
Expand Down
8 changes: 7 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ if(LIBXML2_LIB_DIR AND LIBXML2_INCLUDE_DIR)
if (STATIC)
list(APPEND LIBS "${LIBXML2_LIB_DIR}/libxml2.a")
else (STATIC)
list(APPEND LIBS "${LIBXML2_LIB_DIR}/libxml2.so")
if(APPLE)
list(APPEND LIBS "${LIBXML2_LIB_DIR}/libxml2.dylib")
elseif(UNIX)
list(APPEND LIBS "${LIBXML2_LIB_DIR}/libxml2.so")
else (APPLE)
message (FATAL_ERROR "Unsupported platform, only Linux and MacOSX are supported at this time.")
endif(APPLE)
endif (STATIC)
else(LIBXML2_LIB_DIR AND LIBXML2_INCLUDE_DIR)
find_package(LibXml2 REQUIRED)
Expand Down

0 comments on commit 6da7808

Please sign in to comment.