Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,42 @@ target_link_libraries(cml_static
PRIVATE
$<$<BOOL:${CML_CODE_COVERAGE}>:--coverage>
)
target_link_libraries(cml_shared
PUBLIC
LibXml2::LibXml2
$<$<BOOL:${CML_USE_SANITIZERS}>:-fsanitize=address,undefined>
PRIVATE
$<$<BOOL:${CML_CODE_COVERAGE}>:--coverage>
)

if(APPLE)
message(STATUS "Configuring macOS-specific linking for cml_shared")

target_link_libraries(cml_shared
PUBLIC
LibXml2::LibXml2
${JEOD_LIBRARY}
${Trick_LIBRARY}
${Trick_liber7_utils}
${Trick_libtrick_mm}
${Trick_libtrick_math}
${Trick_libtrick_comm}
${Trick_libtrick_connection_handlers}
${Trick_libtrick_units}
${Trick_libtrick_pyip}
/opt/homebrew/lib/libudunits2.dylib
${Trick_libtrick_var_binary_parser}
${Trick_libconversions}
PRIVATE
$<$<BOOL:${CML_CODE_COVERAGE}>:--coverage>
)

else()
message(STATUS "Configuring Linux-specific linking for cml_shared")

# Linux does NOT require explicit Trick/JEOD linking for shared libraries
target_link_libraries(cml_shared
PUBLIC
LibXml2::LibXml2
$<$<BOOL:${CML_USE_SANITIZERS}>:-fsanitize=address,undefined>
PRIVATE
$<$<BOOL:${CML_CODE_COVERAGE}>:--coverage>
)

endif()

# Set include directories for libcml. This is mostly for unit test executables
# that rely on libcml.
Expand Down
21 changes: 2 additions & 19 deletions bin/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,13 @@ def _parse_args():

def _verify_args(args):
'''
Ensure Trick and JEOD areas exist and libs are built. If they aren't, all tests will fail
Ensure JEOD areas exist and libs are built. If they aren't, all tests will fail
'''
if not args.trick or not os.path.exists(args.trick):
msg = ("Unable to locate trick directory. Define TRICK_HOME in your environment"
" or use --trick=/path/to/trick/ to specify a path to a pre-built Trick"
" directory (Requires version 19.5.1 or later)")
raise RuntimeError(msg)
if (not os.path.exists(os.path.join(args.trick, 'lib64')) or
not os.listdir(os.path.join(args.trick,'lib64'))):
msg = (f"Specified trick directory {args.trick} is missing built libraries. "
"Build trick for this platform to resolve this error.")
raise RuntimeError(msg)
if not args.jeod or not os.path.exists(args.jeod):
msg = ("Unable to locate JEOD directory. Define JEOD_HOME in your environment"
" or use --jeod=/path/to/jeod/ to specify a path to a JEOD"
" directory (Requires version 3.4 or later)")
raise RuntimeError(msg)
# We need to know what TRICK_HOST_CPU is to find the libraries, so get that first
cmd = ( os.path.join(args.trick, 'bin/trick-gte') + " TRICK_HOST_CPU")
sys.path.append(os.path.abspath(os.path.join(args.trick, 'share/trick/trickops/')))
from WorkflowCommon import run_subprocess
trick_host_cpu = run_subprocess(command=cmd,m_shell=True).stdout.strip().split("\n")[-1]
if not os.path.isfile(os.path.join(args.trick, 'lib64/libtrick.a')):
raise RuntimeError(f"Trick hasn't been built. Build {args.trick} and try again.")
if not os.path.isfile(os.path.join(args.jeod, 'lib_jeod_' + trick_host_cpu + '/libjeod.a' )):
raise RuntimeError(f"JEOD library under {args.jeod} hasn't been built. See README.md for instructions and try again.")
if not os.path.isfile(os.path.join(args.jeod, f'trickified/trickified_jeod_{trick_host_cpu}.o')):
Expand All @@ -74,7 +57,7 @@ def _verify_args(args):
if len(ephem_files) < 1:
raise RuntimeError(f"JEOD ephemeris files under {args.jeod} haven't been built. See README.md for instructions and try again.")

return args
return args

# Argparsing must happen at global scope since we can't import TrickOps without
# figuring out the location of Trick, which can be passed in to this script.
Expand Down
5 changes: 5 additions & 0 deletions cmake/SetCMLCompileWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
include_guard()

function(set_cml_compile_warnings TARGET)
# If the compiler is GCC, continue. Otherwise, return immediately.
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
return()
endif()

set(CML_SHARED_WARNING_FLAGS
# Keep these first since we may override some of the levels set for
# certain warnings below.
Expand Down
2 changes: 1 addition & 1 deletion mkspecs/cml.mk
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ endif
TRICK_CXXFLAGS += -I${CML_HOME}/.. -D_USE_MATH_DEFINES
TRICK_CFLAGS += -I${CML_HOME}/.. -D_USE_MATH_DEFINES

# Include paths and libraries for libxml2
# Include paths and libraries for libxml2 for linux
ifeq ($(shell pkg-config --exists libxml-2.0 && echo $$?),0)
TRICK_CXXFLAGS += $(shell pkg-config libxml-2.0 --cflags)
TRICK_LDFLAGS += $(shell pkg-config libxml-2.0 --libs)
Expand Down
2 changes: 2 additions & 0 deletions mkspecs/internal/cml_lib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ TRICK_EXT_LIB_DIRS += :${CML_SOURCE_DIRS}
TRICK_LDFLAGS += -L${CML_LIBRARY_DIR}
ifeq (1, $(CML_USE_STATIC_LIB))
TRICK_LDFLAGS += -l:libcml.a
else ifeq ($(shell trick-gte TRICK_HOST_CPU), Darwin_25)
TRICK_LDFLAGS += -Wl,-rpath,${CML_LIBRARY_DIR} -lcml
else
TRICK_LDFLAGS += -Wl,-rpath=${CML_LIBRARY_DIR} -lcml
endif
45 changes: 45 additions & 0 deletions mkspecs/internal/cml_unit_sim.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ CML_BUILD_DEBUG := 1
include ${CML_HOME}/mkspecs/cml.mk
include ${CML_HOME}/mkspecs/internal/jeod.mk

# temporary fix for Mac as -Wno-nonnull-compare is not recognized by clang
TRICK_CFLAGS += -g -I. -Wall -Wextra -Werror -Wno-implicit-fallthrough -Wno-format-truncation -Wno-int-in-bool-context -Wno-address
TRICK_CXXFLAGS += -g -I. -Wall -Wextra -Werror -Wno-implicit-fallthrough -Wno-format-truncation -Wno-int-in-bool-context -Wno-address
Comment thread
jman025 marked this conversation as resolved.
TRICK_SFLAGS += -I${JEOD_HOME}/lib/jeod/JEOD_S_modules -I.

# Try adding -Wno-nonnull-compare only if the compiler supports it
CHECK_CXXFLAG = $(shell \
$(CXX) -Werror=unknown-warning-option -Wno-nonnull-compare -E - < /dev/null \
>/dev/null 2>&1 && echo yes || echo no)

ifeq ($(CHECK_CXXFLAG),yes)
TRICK_CFLAGS += -Wno-nonnull-compare
TRICK_CXXFLAGS += -Wno-nonnull-compare
endif

# Remove after JEOD 5:
TRICK_CXXFLAGS += -I${JEOD_HOME}/models -I${JEOD_HOME}/..

# Strip unneeded -lint from TRICK_EXEC_LINK_LIBS. This originates from python3-config
# and appears to be part of the FSL spack-installed version of python3.X only
# If we can understand/resolve the core issue, this can be removed.
# See: https://gitlab-fsl.jsc.nasa.gov/FSL/Documentation/-/issues/1111 -Jordan 4/2024
TRICK_EXEC_LINK_LIBS := $(filter-out -lintl,$(TRICK_EXEC_LINK_LIBS))
TRICK_CFLAGS += -g -I. -Wall -Wextra -Werror
TRICK_CXXFLAGS += -g -I. -std=c++17 -Wall -Wextra -Werror
TRICK_SFLAGS += -I${JEOD_HOME}/lib/jeod/JEOD_S_modules -I.
Expand All @@ -21,3 +44,25 @@ TRICK_CXXFLAGS += -fsanitize=address,undefined
TRICK_LDFLAGS += -fsanitize=address,undefined

TRICK_CXXFLAGS += -I${JEOD_HOME}/..

# ============================================================
# macOS (Darwin) specific fixes
# ============================================================
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)

# ------------------------------------------------------------
# 1. Strip Trick's auto-added -std=c++11 and -std=c++14
# 2. Add -Wno-overloaded-virtual to Apple builds
# ------------------------------------------------------------
TRICK_IO_CXXFLAGS := $(filter-out -std=c++11 -std=c++14,$(TRICK_IO_CXXFLAGS))
TRICK_IO_CXXFLAGS += -std=c++17

TRICK_CXXFLAGS := $(filter-out -std=c++11 -std=c++14,$(TRICK_CXXFLAGS))
TRICK_CXXFLAGS += -std=c++17

TRICK_CXXFLAGS += -Wno-overloaded-virtual
TRICK_CFLAGS += -Wno-overloaded-virtual
TRICK_IO_CXXFLAGS += -Wno-overloaded-virtual

endif
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ PROGRAMMERS:
(New implementation of ball_impact for Antares))
((Bingquan Wang) (OSR) (May 2014)
(cleaned up the code per its IV&V code review))
)
)
******************************************************************************/

#ifndef CML_IMPACT_POINT_HH
Expand All @@ -34,12 +34,12 @@ PROGRAMMERS:
// Forward declaration
class RefFrameTrans;

class ImpactPoint : public jeod::PlanetFixedPosition,
public SubscriptionBase
class ImpactPoint : public jeod::PlanetFixedPosition,
public SubscriptionBase
{
protected:
const double & dyn_time; /* (s) Reference to the simulation's dynamic time.*/
const jeod::Planet & planet_ref; /* (--)
const jeod::Planet & planet_ref; /* (--)
Reference to the central planet. Note - planet_ref is the reference;
"planet" is a pointer to the same place that is inherited from
PlanetFixedPosition but is not used in this model. */
Expand All @@ -60,7 +60,7 @@ class ImpactPoint : public jeod::PlanetFixedPosition,

//INPUT
bool auto_off; /* (--) Turns off automatically when vehicle hits the ground */
double iteration_threshold; /* (m)
double iteration_threshold; /* (m)
The threshold distance between the orbital position and the planet
surface at which the iteration is considered to have converged. */
unsigned int iteration_count_max; /* (--) max number of iterations */
Expand All @@ -70,7 +70,7 @@ class ImpactPoint : public jeod::PlanetFixedPosition,
double time_to_impact; /* (s) Time until impact */
double time_of_impact; /* (s) Simulation dynamic time of predicted impact. */
ImpactType impact_type; /* (--) Identifies type of impact. */
RangeFromPfixReference launch_range; /* (--)
RangeFromPfixReference launch_range; /* (--)
The range from the reference point, typically the launch site. */

protected:
Expand All @@ -86,7 +86,7 @@ class ImpactPoint : public jeod::PlanetFixedPosition,
const jeod::Planet & planet,
const double & grav_mu);
~ImpactPoint() override = default;

void initialize() override;
void initialize( double ref_pos[3]);
void update();
Expand All @@ -103,5 +103,5 @@ class ImpactPoint : public jeod::PlanetFixedPosition,
ImpactPoint(const ImpactPoint&);
ImpactPoint & operator = (const ImpactPoint&);
};

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public:
// NOTE - initialize(jeod::DynManager) is called from Dynamics Manager as a
// consequence of adding this body action with the add_body_action method
// call.
using jeod::BodyDetach::initialize;
void initialize( const jeod::DynBody & parent,
SeparationState & sep_state)
{
Expand Down Expand Up @@ -97,7 +98,7 @@ public:
};

void apply( jeod::DynManager & dyn_manager) override
{
{
springs.action_body_is_child = child_is_action_body;
springs.activate();
jeod::BodyDetach::apply(dyn_manager);
Expand Down
1 change: 1 addition & 0 deletions models/interactions/aero/include/aero_executive_table.hh
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public:
void update() override;
protected:
void activate() override;

void configure_new_table(AeroTableSetBase *);
void trig_functions();
void post_process_table_data();
Expand Down
1 change: 1 addition & 0 deletions models/interactions/aero/include/aero_interface_table.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public:

void initialize() override;
void update() override;

protected:
void activate() override;
void deactivate() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ struct TestStruc
double x;
int i;
TestStruc() : x(1.1), i(1){};
TestStruc( const TestStruc & rhs) = default;
TestStruc( const TestStruc & rhs) : x(rhs.x), i(rhs.i){};
TestStruc& operator=(const TestStruc& rhs)
{
if (this != &rhs)
{
x = rhs.x;
i = rhs.i;
}
return *this;
}
};

struct SampleModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ class ThresholdTimedConstraintSpecData : public Constraint
(num_specs-1) and fraction 0 by definition.
- The first and last test values have already been assigned.
- The highest value of any other mapped-index is num_specs-2.*/
size_t mapped_ix[num_tests-1];
std::vector<size_t> mapped_ix(num_tests-1);
mapped_ix[0] = 0; // unused spacer, we already have values for test-0.
size_t spec_ix=0;
for (size_t test_ix = 1; test_ix <= num_tests-2; ++test_ix) {
Expand Down Expand Up @@ -577,7 +577,7 @@ class ThresholdTimedConstraintSpecData : public Constraint
* redundant repetition (typically, we are adding more tests than
* specified, so the same spec-ix will be used multiple times).
* lg_ratio[i] = lg (threshold[i+1] / threshold[i]) */
double log_threshold_ratios[num_specs-1];
std::vector<double> log_threshold_ratios(num_specs-1);
for (spec_ix = 0; spec_ix <= num_specs-2; ++spec_ix) {
log_threshold_ratios[spec_ix] = std::log10( threshold_spec[spec_ix+1] /
threshold_spec[spec_ix]);
Expand Down
12 changes: 6 additions & 6 deletions models/utilities/math_utils/include/math_utils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public:
return false;
}
return ((val2 > val1) ?
val1 + tol >= val2 :
val1 + tol >= val2 :
val2 + tol >= val1);
}
template <typename T>
Expand Down Expand Up @@ -310,19 +310,19 @@ public:
{
return MathUtilsPrivate::asin_fp<double>(val);
}

/* TODO Hirad Mirhashemi 2025/10.
* DEPRECATED CONTENT. Remove after reasonable timeframe.*/
static float sqrt( float val)
{
static float sqrt( float val)
{
CMLMessage::inform(__FILE__,__LINE__,
"Deprecated method used: sqrt.\n"
"This method name was not sufficiently descriptive.\n"
"Use sqrt_protected instead.");
return sqrt_protected(val);
}
static double sqrt( double val)
{
{
CMLMessage::inform(__FILE__,__LINE__,
"Deprecated method used: sqrt.\n"
"This method name was not sufficiently descriptive.\n"
Expand Down Expand Up @@ -975,7 +975,7 @@ Purpose:
// [in] = [C_decomp] * [C_decomp]' => [inv(in)] = [inv(C)]' * [inv(C)]
// and the inverse of the decomposed matrix is arithmetically simple to
// compute.
double C_inv[dimension][dimension] = {0};
double C_inv[dimension][dimension] = {};
for ( size_t ii = 0; ii < dimension; ii++) {
// Note -- division by zero already checked above and method has
// returned if any diagonal elements are zero.
Expand Down
Loading
Loading