@@ -2616,3 +2616,50 @@ AC_DEFUN([ISSM_OPTIONS],[
26162616 AC_SUBST ( [ CXXFLAGS] )
26172617 AC_SUBST ( [ OSLIBS] )
26182618] )
2619+
2620+ dnl =====================================================================
2621+ dnl ISSM_ENABLE_AD – Automatic-Differentiation (CoDiPack + MediPack)
2622+ dnl =====================================================================
2623+ AC_DEFUN ( [ ISSM_ENABLE_AD] , [
2624+ # --- command-line switches ------------------------------------------
2625+ AC_ARG_ENABLE ( [ ad] ,
2626+ AS_HELP_STRING ( [ --enable-ad] ,
2627+ [ Build ISSM with CoDiPack+MediPack automatic differentiation (disables PETSc)] ) ,
2628+ [ enable_ad=$enableval] ,
2629+ [ enable_ad=no] )
2630+
2631+ AC_ARG_WITH ( [ codipack-dir] ,
2632+ AS_HELP_STRING ( [ --with-codipack-dir=DIR] ,
2633+ [ Prefix of CoDiPack install] ) ,
2634+ [ CODIPACK_ROOT=$withval] , [ CODIPACK_ROOT=] )
2635+
2636+ AC_ARG_WITH ( [ medipack-dir] ,
2637+ AS_HELP_STRING ( [ --with-medipack-dir=DIR] ,
2638+ [ Prefix of MediPack install] ) ,
2639+ [ MEDIPACK_ROOT=$withval] , [ MEDIPACK_ROOT=] )
2640+
2641+ # --- validation & flag injection ------------------------------------
2642+ if test "x$enable_ad" = "xyes"; then
2643+ if test -z "$CODIPACK_ROOT" || test -z "$MEDIPACK_ROOT"; then
2644+ AC_MSG_ERROR ( [ --enable-ad needs BOTH --with-codipack-dir and --with-medipack-dir] )
2645+ fi
2646+
2647+ AC_DEFINE ( [ ISSM_USE_AD] , [ 1] ,
2648+ [ Define to 1 if building with automatic differentiation] )
2649+
2650+ ENABLE_PETSC=no
2651+ AM_CONDITIONAL([ USE_AD] , [ true] )
2652+
2653+ AM_CPPFLAGS="$AM_CPPFLAGS -I$CODIPACK_ROOT/include -I$MEDIPACK_ROOT/include -DCODI_ForcedInlines"
2654+ AM_LDFLAGS="$AM_LDFLAGS -L$CODIPACK_ROOT/lib -L$MEDIPACK_ROOT/lib"
2655+ LIBS="$LIBS -lcodi -lmedi"
2656+ else
2657+ ENABLE_PETSC=yes
2658+ AM_CONDITIONAL([ USE_AD] , [ false] )
2659+ fi
2660+
2661+ dnl Export augmented vars once
2662+ AC_SUBST ( [ AM_CPPFLAGS] )
2663+ AC_SUBST ( [ AM_LDFLAGS] )
2664+ AC_SUBST ( [ LIBS] )
2665+ ] )
0 commit comments