Changeset 23394 for issm/trunk
- Timestamp:
- 10/05/18 10:42:45 (6 years ago)
- Location:
- issm/trunk
- Files:
-
- 2 deleted
- 163 edited
- 28 copied
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
-
issm/trunk/configure.ac
r22822 r23394 2 2 3 3 #AUTOCONF 4 AC_INIT([Ice Sheet System Model (ISSM)],[4.1 4],[issm@jpl.nasa.gov],[issm],[http://issm.jpl.nasa.gov]) #Initializing configure4 AC_INIT([Ice Sheet System Model (ISSM)],[4.15],[issm@jpl.nasa.gov],[issm],[http://issm.jpl.nasa.gov]) #Initializing configure 5 5 AC_CONFIG_AUX_DIR([./aux-config]) #Put config files in aux-config 6 6 AC_CONFIG_MACRO_DIR([m4]) #m4 macros are located in m4 -
issm/trunk/etc/environment.sh
r22758 r23394 75 75 fi 76 76 77 #legacy mpich2 (To be removed)78 MPI_DIR="$ISSM_DIR/externalpackages/mpich2/install"79 if [ -d "$MPI_DIR" ]; then80 export MPI_DIR81 pathprepend "$MPI_DIR/bin"82 libpathappend "$MPI_DIR/lib"83 fi84 85 77 MPI_DIR="$ISSM_DIR/externalpackages/mpich/install" 86 78 if [ -d "$MPI_DIR" ]; then 87 79 export MPI_DIR 88 80 export MPI_INC_DIR="$MPI_DIR/include" 89 pathprepend "$MPI_DIR/bin"90 libpath append "$MPI_DIR/lib"81 pathprepend "$MPI_DIR/bin" 82 libpathprepend "$MPI_DIR/lib" 91 83 fi 92 84 … … 234 226 pathprepend "$GMAKE_DIR/bin" 235 227 236 PYTHON_DIR="$ISSM_DIR/externalpackages/python/install"237 if [ -d "$PYTHON_DIR" ]; then238 export PYTHONPATH="$PYTHONPATH:$ISSM_DIR/lib"239 pathprepend "$PYTHON_DIR/bin"240 libpathprepend "$PYTHON_DIR/lib"241 libpathprepend "$ISSM_DIR/lib"242 fi243 244 228 MODELE_DIR="$ISSM_DIR/externalpackages/modelE/install" 245 229 pathappend "$MODELE_DIR/src/exec" -
issm/trunk/jenkins/jenkins.sh
r23189 r23394 324 324 #concatenate reports 325 325 cd $ISSM_DIR/nightlylog/ 326 echo 'CHECKING NIGHTLYLOG DIRECTORY'327 echo '-----------------------------'328 ls -la329 echo '-----------------------------'326 #echo 'CHECKING NIGHTLYLOG DIRECTORY' 327 #echo '-----------------------------' 328 #ls -la 329 #echo '-----------------------------' 330 330 331 331 if [ -f matlab_log.log ]; then -
issm/trunk/jenkins/linux64_caladan_ad
r22758 r23394 32 32 mpich install-3.2-linux64.sh 33 33 petsc install-3.7-linux64.sh 34 metis install-5.0.1-linux64.sh35 34 triangle install-linux64.sh 36 35 gsl install-linux64.sh -
issm/trunk/jenkins/linux64_caladan_ampi
r22758 r23394 41 41 mpich install-3.2-linux64.sh 42 42 petsc install-3.7-linux64.sh 43 metis install-5.0.1-linux64.sh44 43 triangle install-linux64.sh 45 44 gsl install-linux64.sh -
issm/trunk/jenkins/linux64_ross_ad
r23189 r23394 37 37 mpich install-3.2-linux64.sh 38 38 petsc install-3.7-linux64.sh 39 metis install-5.0.1-linux64.sh40 39 triangle install-linux64.sh 41 40 gsl install-linux64.sh -
issm/trunk/jenkins/linux64_ross_ampi
r23189 r23394 44 44 mpich install-3.2-linux64.sh 45 45 petsc install-3.7-linux64.sh 46 metis install-5.0.1-linux64.sh47 46 triangle install-linux64.sh 48 47 gsl install-linux64.sh -
issm/trunk/jenkins/linux64_ross_dakota
r23189 r23394 11 11 --disable-static \ 12 12 --with-matlab-dir=$MATLAB_PATH \ 13 --with-python-dir=/usr \ 14 --with-python-numpy-dir=/home/jenkins/.local/lib/python2.7/site-packages/numpy \ 13 15 --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \ 14 16 --with-mpi-include=$ISSM_DIR/externalpackages/mpich/install/include \ … … 30 32 #PYTHON and MATLAB testing 31 33 MATLAB_TEST=1 32 PYTHON_TEST= 034 PYTHON_TEST=1 33 35 34 36 #-----------------------------------# … … 63 65 #by Matlab and runme.m 64 66 #ex: "'id',[101 102 103]" 65 PYTHON_NROPTIONS="--exclude 243 701 702 435 "67 PYTHON_NROPTIONS="--exclude 243 701 702 435 --include_name 'Dakota'" 66 68 MATLAB_NROPTIONS="'exclude',[243,701,702,435]" -
issm/trunk/jenkins/linux64_ross_python
r23189 r23394 10 10 ISSM_CONFIG='--prefix=$ISSM_DIR \ 11 11 --disable-static \ 12 --with-matlab-dir=$MATLAB_PATH \ 12 13 --with-python-dir=/usr \ 13 14 --with-python-numpy-dir=/home/jenkins/.local/lib/python2.7/site-packages/numpy \ 14 15 --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \ 15 16 --with-mpi-include=$ISSM_DIR/externalpackages/mpich/install/include \ 16 --with-mpi-libflags="-L$ISSM_DIR/externalpackages/mpich/install/lib -lmpi -lmpi fort" \17 --with-mpi-libflags="-L$ISSM_DIR/externalpackages/mpich/install/lib -lmpi -lmpicxx -lmpifort" \ 17 18 --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \ 18 19 --with-metis-dir=$ISSM_DIR/externalpackages/petsc/install \ … … 21 22 --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \ 22 23 --with-chaco-dir="$ISSM_DIR/externalpackages/chaco/install" \ 23 --with-fortran-lib="-L/usr/lib/gcc/x86_64-linux-gnu/4.9 /-lgfortran" \24 --with-fortran-lib="-L/usr/lib/gcc/x86_64-linux-gnu/4.9 -lgfortran" \ 24 25 --with-m1qn3-dir=$ISSM_DIR/externalpackages/m1qn3/install \ 25 26 --with-numthreads=4 \ … … 50 51 #number of cpus used in ISSM installation and compilation (one is usually 51 52 #safer as some packages are very sensitive to parallel compilation) 52 NUMCPUS_INSTALL= 1053 NUMCPUS_INSTALL=5 53 54 54 55 #number of cpus used in the nightly runs. 55 NUMCPUS_RUN= 556 NUMCPUS_RUN=3 56 57 57 58 #Nightly run options. The matlab routine runme.m will be called -
issm/trunk/jenkins/macosx_pine-island
r23189 r23394 5 5 6 6 #MATLAB path 7 MATLAB_PATH="/Applications/MATLAB_R2015b.app /"7 MATLAB_PATH="/Applications/MATLAB_R2015b.app" 8 8 9 9 #ISSM CONFIGURATION … … 48 48 49 49 #number of cpus used in the nightly runs. 50 NUMCPUS_RUN= 250 NUMCPUS_RUN=4 51 51 52 52 #Nightly run options. The matlab routine runme.m will be called -
issm/trunk/jenkins/macosx_pine-island_dakota
r21729 r23394 5 5 6 6 #MATLAB path 7 MATLAB_PATH="/Applications/MATLAB_R2015b.app /"7 MATLAB_PATH="/Applications/MATLAB_R2015b.app" 8 8 9 #ISSM CONFIGURATION 9 #ISSM CONFIGURATION 10 10 ISSM_CONFIG='--prefix=$ISSM_DIR \ 11 11 --with-matlab-dir=$MATLAB_PATH \ 12 --with-python-dir=/System/Library/Frameworks/Python.framework/Versions/2.7 \ 13 --with-python-numpy-dir=/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy \ 12 14 --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \ 13 15 --with-mpi-include=$ISSM_DIR/externalpackages/mpich/install/include \ … … 27 29 #PYTHON and MATLAB testing 28 30 MATLAB_TEST=1 29 PYTHON_TEST= 031 PYTHON_TEST=1 30 32 31 33 #-----------------------------------# … … 54 56 55 57 #number of cpus used in the nightly runs. 56 NUMCPUS_RUN= 258 NUMCPUS_RUN=4 57 59 58 60 #Nightly run options. The matlab routine runme.m will be called 59 61 #as follows: runme($MATLAB_NROPTIONS). The options must be understandable 60 62 #by Matlab and runme.m 61 #ex: "'id',[101 102 103]" ERRORS ARE LARGE FOR: 418 420 62 PYTHON_NROPTIONS=" "63 #ex: "'id',[101 102 103]" ERRORS ARE LARGE FOR: 418 420 64 PYTHON_NROPTIONS="--exclude 119 243 514 701 702 703 234 235 418 420 --include_name 'Dakota'" 63 65 MATLAB_NROPTIONS="'exclude',[119,243,514,701,702,703,234,235,418,420]" -
issm/trunk/jenkins/macosx_pine-island_dakota_static
r23189 r23394 4 4 5 5 #MATLAB path 6 MATLAB_PATH="/Applications/MATLAB_R2015b.app /"6 MATLAB_PATH="/Applications/MATLAB_R2015b.app" 7 7 8 #ISSM CONFIGURATION 8 #ISSM CONFIGURATION 9 9 ISSM_CONFIG='--prefix=$ISSM_DIR \ 10 10 --disable-static \ … … 56 56 57 57 #number of cpus used in the nightly runs. 58 NUMCPUS_RUN= 258 NUMCPUS_RUN=4 59 59 60 60 #Nightly run options. The matlab routine runme.m will be called … … 62 62 #by Matlab and runme.m 63 63 #ex: "'id',[101 102 103]" 64 ## bamg mesh FS 64 ## bamg mesh FS 65 65 #PYTHON_NROPTIONS="--exclude_name 'Dakota'" 66 66 #MATLAB_NROPTIONS="'exclude',[243,701,702,703,435,IdFromString('Dakota')]" -
issm/trunk/jenkins/macosx_pine-island_examples
r21729 r23394 5 5 6 6 #MATLAB path 7 MATLAB_PATH="/Applications/MATLAB_R2015b.app /"7 MATLAB_PATH="/Applications/MATLAB_R2015b.app" 8 8 9 #ISSM CONFIGURATION 9 #ISSM CONFIGURATION 10 10 ISSM_CONFIG='--prefix=$ISSM_DIR \ 11 11 --with-matlab-dir=$MATLAB_PATH \ -
issm/trunk/m4/issm_options.m4
r23189 r23394 9 9 dnl ISSM's internal options 10 10 dnl Build info{{{ 11 11 12 12 dnl build date 13 13 AC_PATH_PROGS(DATE, date) … … 153 153 AC_MSG_CHECKING(for wrappers compilation) 154 154 AM_CONDITIONAL([WRAPPERS], [test x$WRAPPERS_VALUE = xyes]) 155 AC_MSG_RESULT($WRAPPERS_VALUE) 155 AC_MSG_RESULT($WRAPPERS_VALUE) 156 156 dnl }}} 157 157 dnl Extensions{{{ … … 251 251 fi 252 252 fi 253 AC_SUBST([OSLIBS]) 253 AC_SUBST([OSLIBS]) 254 254 AC_MSG_RESULT(done) 255 255 dnl }}} … … 281 281 282 282 AC_DEFINE([_HAVE_MATLAB_],[1],[with matlab in ISSM src]) 283 283 284 284 dnl 4. get MEXLIB MEXLINK and MEXEXT (experimental) except for windows 285 285 AC_MSG_CHECKING([matlab's mex compilation flags]) 286 286 case "${host_os}" in 287 *cygwin*) 287 *cygwin*) 288 288 if test $VENDOR = intel-win7-32; then 289 MEXLIB="-Wl,libmx.lib -Wl,libmex.lib -Wl,libmat.lib ${OSLIBS} -Wl,libf2cblas.lib -Wl,libf2clapack.lib" 289 MEXLIB="-Wl,libmx.lib -Wl,libmex.lib -Wl,libmat.lib ${OSLIBS} -Wl,libf2cblas.lib -Wl,libf2clapack.lib" 290 290 MEXLINK="-Wl,/LIBPATH:`cygpath -m ${MATLAB_ROOT}/extern/lib/win32/microsoft` -Wl,/link -Wl,/EXPORT:mexFunction -Wl,/DLL" 291 291 MEXEXT=`$MATLAB_ROOT/bin/mexext.bat` 292 292 MEXEXT=".$MEXEXT" 293 293 elif test $VENDOR = intel-win7-64; then 294 MEXLIB="-Wl,libmx.lib -Wl,libmex.lib -Wl,libmat.lib ${OSLIBS} -Wl,libf2cblas.lib -Wl,libf2clapack.lib" 295 MEXLINK="-Wl,/LIBPATH:`cygpath -m ${MATLAB_ROOT}/extern/lib/win64/microsoft` -Wl,/link -Wl,/EXPORT:mexFunction -Wl,/DLL" 294 MEXLIB="-Wl,libmx.lib -Wl,libmex.lib -Wl,libmat.lib ${OSLIBS} -Wl,libf2cblas.lib -Wl,libf2clapack.lib" 295 MEXLINK="-Wl,/LIBPATH:`cygpath -m ${MATLAB_ROOT}/extern/lib/win64/microsoft` -Wl,/link -Wl,/EXPORT:mexFunction -Wl,/DLL" 296 296 MEXEXT=".mexw64" 297 297 elif test $VENDOR = MSVC-Win64 || test $VENDOR = MSVC-Win64-par; then 298 MEXLIB="-Wl,libmx.lib -Wl,libmex.lib -Wl,libmat.lib ${OSLIBS} -Wl,libf2cblas.lib -Wl,libf2clapack.lib" 299 MEXLINK="-Wl,/link -Wl,/LIBPATH:`cygpath -m ${MATLAB_ROOT}/extern/lib/win64/microsoft` -Wl,/link -Wl,/EXPORT:mexFunction -Wl,/DLL" 298 MEXLIB="-Wl,libmx.lib -Wl,libmex.lib -Wl,libmat.lib ${OSLIBS} -Wl,libf2cblas.lib -Wl,libf2clapack.lib" 299 MEXLINK="-Wl,/link -Wl,/LIBPATH:`cygpath -m ${MATLAB_ROOT}/extern/lib/win64/microsoft` -Wl,/link -Wl,/EXPORT:mexFunction -Wl,/DLL" 300 300 MATLABINCL="-I`cygpath -m $MATLAB_ROOT/extern/include/`" 301 301 MEXEXT=".mexw64" … … 311 311 echo "#include <mex.h>" > conftest.cpp 312 312 echo "void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){}" >> conftest.cpp 313 $MATLAB_ROOT/bin/mex -v -lmex conftest.cpp > conftest.tmp 2>&1 313 $MATLAB_ROOT/bin/mex -v -lmex conftest.cpp > conftest.tmp 2>&1 314 314 rm -f conftest.cpp 315 315 MEXLINK=$(cat conftest.tmp | grep LDFLAGS | sed -e "s/LDFLAGS ://g") … … 333 333 MATLABWRAPPEREXT=$MEXEXT 334 334 AC_SUBST([MATLABWRAPPEREXT]) 335 AC_SUBST([MEXLIB]) 335 AC_SUBST([MEXLIB]) 336 336 AC_SUBST([MEXLINK]) 337 337 fi … … 345 345 AC_ARG_WITH([javascript], 346 346 AS_HELP_STRING([--with-javascript], [compile javascript wrappers? default is no.]), 347 [JAVASCRIPT=$withval],[JAVASCRIPT="no"]) 347 [JAVASCRIPT=$withval],[JAVASCRIPT="no"]) 348 348 349 349 dnl Check whether javascript wrappers are desired … … 364 364 AC_ARG_WITH([triangle-dir], 365 365 AS_HELP_STRING([--with-triangle-dir=DIR], [triangle root directory.]), 366 [TRIANGLE_ROOT=$withval],[TRIANGLE_ROOT="no"]) 366 [TRIANGLE_ROOT=$withval],[TRIANGLE_ROOT="no"]) 367 367 368 368 dnl Check whether triangle is enabled … … 394 394 if test "x$HAVE_JAVASCRIPT" = "xyes"; then 395 395 dnl go to the bit code, not the library. 396 TRIANGLELIB=$TRIANGLE_ROOT/triangle.o 396 TRIANGLELIB=$TRIANGLE_ROOT/triangle.o 397 397 else 398 398 TRIANGLELIB=$TRIANGLE_ROOT/triangle.a … … 402 402 if test "x$HAVE_JAVASCRIPT" = "xyes"; then 403 403 dnl go to the bit code, not the library. 404 TRIANGLELIB=$TRIANGLE_ROOT/triangle.o 404 TRIANGLELIB=$TRIANGLE_ROOT/triangle.o 405 405 else 406 406 TRIANGLELIB=$TRIANGLE_ROOT/triangle.a … … 416 416 AC_ARG_WITH([boost-dir], 417 417 AS_HELP_STRING([--with-boost-dir=DIR], [boost root directory.]), 418 [BOOST_ROOT=$withval],[BOOST_ROOT="no"]) 418 [BOOST_ROOT=$withval],[BOOST_ROOT="no"]) 419 419 420 420 dnl Check whether boost is enabled … … 443 443 AC_ARG_WITH([dakota-dir], 444 444 AS_HELP_STRING([--with-dakota-dir=DIR], [dakota root directory.]), 445 [DAKOTA_ROOT=$withval],[DAKOTA_ROOT="no"]) 446 445 [DAKOTA_ROOT=$withval],[DAKOTA_ROOT="no"]) 446 447 447 dnl Check whether dakota is enabled 448 448 AC_MSG_CHECKING([for dakota]) … … 573 573 AC_ARG_WITH([python-dir], 574 574 AS_HELP_STRING([--with-python-dir=DIR], [python root directory.]), 575 [PYTHON_ROOT=$withval],[PYTHON_ROOT="no"]) 575 [PYTHON_ROOT=$withval],[PYTHON_ROOT="no"]) 576 576 577 577 dnl Check whether python is enabled … … 592 592 if test "x$HAVE_PYTHON" = "xyes"; then 593 593 AC_MSG_CHECKING([for python version]) 594 dnl Query Python for its version number. 594 dnl Query Python for its version number. Getting [:3] seems to be the 595 595 dnl best way to do this; it's what "site.py" does in the standard library. 596 596 PYTHON_VERSION=$($PYTHON_ROOT/bin/python -c "import sys; print sys.version[[:3]]") 597 597 AC_MSG_RESULT($PYTHON_VERSION) 598 598 599 dnl recover major 599 dnl recover major 600 600 PYTHON_MAJOR=${PYTHON_VERSION%.*} 601 601 AC_DEFINE_UNQUOTED([_PYTHON_MAJOR_],$PYTHON_MAJOR,[python version major]) … … 643 643 AC_ARG_WITH([python-numpy-dir], 644 644 AS_HELP_STRING([--with-python-numpy-dir=DIR], [python-numpy root directory.]), 645 [PYTHON_NUMPY_ROOT=$withval],[PYTHON_NUMPY_ROOT="no"]) 646 645 [PYTHON_NUMPY_ROOT=$withval],[PYTHON_NUMPY_ROOT="no"]) 646 647 dnl you can find numpy by typing 648 dnl >>> import numpy 649 dnl >>> numpy.__file__ 650 dnl '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/__init__.pyc' 651 647 652 dnl Check whether numpy is enabled 648 653 AC_MSG_CHECKING(for python-numpy) … … 667 672 AC_ARG_WITH([chaco-dir], 668 673 AS_HELP_STRING([--with-chaco-dir=DIR], [chaco root directory.]), 669 [CHACO_ROOT=$withval],[CHACO_ROOT="no"]) 670 674 [CHACO_ROOT=$withval],[CHACO_ROOT="no"]) 675 671 676 dnl Check whether chaco is enabled 672 677 AC_MSG_CHECKING([for chaco]) … … 694 699 AC_ARG_WITH([scotch-dir], 695 700 AS_HELP_STRING([--with-scotch-dir=DIR], [scotch root directory.]), 696 [SCOTCH_ROOT=$withval],[SCOTCH_ROOT="no"]) 701 [SCOTCH_ROOT=$withval],[SCOTCH_ROOT="no"]) 697 702 698 703 dnl Check whether scotch is enabled … … 708 713 AC_MSG_RESULT($HAVE_SCOTCH) 709 714 AM_CONDITIONAL([SCOTCH],[test x$HAVE_SCOTCH = xyes]) 710 715 711 716 dnl scotch libraries 712 717 if test "x$HAVE_SCOTCH" = "xyes"; then … … 721 726 AC_ARG_WITH([esmf-dir], 722 727 AS_HELP_STRING([--with-esmf-dir=DIR], [esmf root directory.]), 723 [ESMF_ROOT=$withval],[ESMF_ROOT="no"]) 728 [ESMF_ROOT=$withval],[ESMF_ROOT="no"]) 724 729 725 730 dnl Check whether esmf is enabled … … 734 739 fi 735 740 AC_MSG_RESULT($HAVE_ESMF) 736 741 737 742 dnl esmf headers and libraries 738 743 if test "x$HAVE_ESMF" == "xyes"; then … … 745 750 AM_CONDITIONAL([ESMF], [test x$HAVE_ESMF = xyes]) 746 751 dnl }}} 752 dnl codipack{{{ 753 AC_ARG_WITH([codipack-dir], 754 AS_HELP_STRING([--with-codipack-dir=DIR], [CoDiPack root directory.]), 755 [CODIPACK_ROOT=$withval],[CODIPACK_ROOT="no"]) 756 757 dnl Check whether codipack is enabled 758 AC_MSG_CHECKING([for CoDiPack]) 759 if test "x$CODIPACK_ROOT" = "xno" ; then 760 HAVE_CODIPACK=no 761 else 762 HAVE_CODIPACK=yes 763 if ! test -d "$CODIPACK_ROOT"; then 764 AC_MSG_ERROR([codipack directory provided ($CODIPACK_ROOT) does not exist]); 765 fi 766 fi 767 AC_MSG_RESULT($HAVE_CODIPACK) 768 769 dnl codipack headers and libraries 770 if test "x$HAVE_CODIPACK" == "xyes"; then 771 CODIPACKINCL="-I$CODIPACK_ROOT/include" 772 AC_DEFINE([_HAVE_CODIPACK_],[1],[with codipack in ISSM src]) 773 AC_DEFINE([_HAVE_AD_],[1],[with AD in ISSM src]) 774 AC_SUBST([CODIPACKINCL]) 775 fi 776 AM_CONDITIONAL([CODIPACK], [test x$HAVE_CODIPACK = xyes]) 777 AM_COND_IF(CODIPACK,[CXXFLAGS+=" -std=c++11"]) 778 dnl }}} 779 dnl tapeallocation {{{ 780 AC_ARG_ENABLE([tape-alloc], dnl feature 781 AS_HELP_STRING([--enable-tape-alloc],[turn tape allocation support on]), 782 [enable_tape_alloc=$enableval], [enable_tape_alloc=no]) 783 784 dnl check whether enabled 785 AC_MSG_CHECKING(for tape memory allocation) 786 if test "x$enable_tape_alloc" = xyes; then 787 AC_DEFINE([_AD_TAPE_ALLOC_],[1],[Macro to enable a priori tape allocation for AD]) 788 fi 789 AC_MSG_RESULT($enable_tape_alloc) 790 dnl }}} 747 791 dnl adolc{{{ 748 792 AC_ARG_WITH([adolc-dir], 749 793 AS_HELP_STRING([--with-adolc-dir=DIR], [adolc root directory.]), 750 [ADOLC_ROOT=$withval],[ADOLC_ROOT="no"]) 794 [ADOLC_ROOT=$withval],[ADOLC_ROOT="no"]) 751 795 752 796 dnl Check whether adolc is enabled … … 761 805 fi 762 806 AC_MSG_RESULT($HAVE_ADOLC) 763 807 764 808 dnl adolc headers and libraries 765 809 if test "x$HAVE_ADOLC" == "xyes"; then … … 773 817 fi 774 818 AM_CONDITIONAL([ADOLC], [test x$HAVE_ADOLC = xyes]) 775 819 AM_COND_IF(ADOLC,[CXXFLAGS+=" -std=c++11"]) 776 820 dnl }}} 777 821 dnl adolc-version{{{ 778 822 AC_ARG_WITH([adolc-version], 779 823 AS_HELP_STRING([--with-adolc-version=number], [adolc version.]), 780 [ADOLC_VERSION=$withval],[ADOLC_VERSION=2]) 781 AC_MSG_CHECKING(for adolc-version) 824 [ADOLC_VERSION=$withval],[ADOLC_VERSION=2]) 825 AC_MSG_CHECKING(for adolc-version) 782 826 783 827 AC_DEFINE_UNQUOTED([_ADOLC_VERSION_],$ADOLC_VERSION,[ADOLC version]) … … 787 831 AC_ARG_WITH([adic2-dir], 788 832 AS_HELP_STRING([--with-adic2-dir=DIR], [adic2 root directory.]), 789 [ADIC2_ROOT=$withval],[ADIC2_ROOT="no"]) 833 [ADIC2_ROOT=$withval],[ADIC2_ROOT="no"]) 790 834 791 835 dnl Check whether adic2 is enabled … … 815 859 AS_HELP_STRING([--with-atlas-dir=DIR],[atlas root directory]), 816 860 [ATLAS_ROOT=$withval],[ATLAS_ROOT="no"]) 817 861 818 862 dnl Check whether atlas is enabled 819 863 AC_MSG_CHECKING(for atlas and cblas libraries) … … 836 880 ;; 837 881 *linux*) 838 ATLASLIB=-L"$ATLAS_ROOT/lib -lcblas -latlas -lm " 882 ATLASLIB=-L"$ATLAS_ROOT/lib -lcblas -latlas -lm " 839 883 ;; 840 884 *darwin*) 841 ATLASLIB=-L"$ATLAS_ROOT/lib -lcblas -latlas -lm" 885 ATLASLIB=-L"$ATLAS_ROOT/lib -lcblas -latlas -lm" 842 886 ;; 843 887 esac … … 849 893 AC_ARG_WITH([gsl-dir], 850 894 AS_HELP_STRING([--with-gsl-dir=DIR], [gsl root directory.]), 851 [GSL_ROOT=$withval],[GSL_ROOT="no"]) 895 [GSL_ROOT=$withval],[GSL_ROOT="no"]) 852 896 853 897 dnl Check whether gsl is enabled … … 862 906 fi 863 907 AC_MSG_RESULT($HAVE_GSL) 864 908 865 909 dnl gsl headers and libraries 866 910 if test "x$HAVE_GSL" == "xyes"; then … … 877 921 AM_CONDITIONAL([GSL], [test x$HAVE_GSL = xyes]) 878 922 dnl }}} 879 dnl a djoinable-mpi{{{923 dnl ampi (ADOLC){{{ 880 924 AC_ARG_WITH([ampi-dir], 881 925 AS_HELP_STRING([--with-ampi-dir=DIR], [adjoinable mpi root directory.]), 882 [AMPI_ROOT=$withval],[AMPI_ROOT="no"]) 926 [AMPI_ROOT=$withval],[AMPI_ROOT="no"]) 883 927 884 928 dnl Check whether ampi is enabled … … 893 937 fi 894 938 AC_MSG_RESULT($HAVE_AMPI) 895 939 896 940 dnl ampi headers and libraries 897 941 if test "x$HAVE_AMPI" == "xyes"; then … … 912 956 AM_CONDITIONAL([AMPI], [test x$HAVE_AMPI = xyes]) 913 957 dnl }}} 958 dnl adjointmpi (CoDiPack){{{ 959 AC_ARG_WITH([adjointmpi-dir], 960 AS_HELP_STRING([--with-adjointmpi-dir=DIR], [adjoinable mpi root directory.]), 961 [ADJOINTMPI_ROOT=$withval],[ADJOINTMPI_ROOT="no"]) 962 963 dnl Check whether adjointmpi is enabled 964 AC_MSG_CHECKING([for adjointmpi]) 965 if test "x$ADJOINTMPI_ROOT" = "xno" ; then 966 HAVE_ADJOINTMPI=no 967 else 968 HAVE_ADJOINTMPI=yes 969 if ! test -d "$ADJOINTMPI_ROOT"; then 970 AC_MSG_ERROR([adjointmpi directory provided ($ADJOINTMPI_ROOT) does not exist]); 971 fi 972 fi 973 AC_MSG_RESULT($HAVE_ADJOINTMPI) 974 975 dnl adjointmpi headers and libraries 976 if test "x$HAVE_ADJOINTMPI" == "xyes"; then 977 if test "x$CODIPACK_ROOT" == "xno"; then 978 AC_MSG_ERROR([cannot run adjoint mpi without CoDiPack]); 979 fi 980 ADJOINTMPIINCL="-I$ADJOINTMPI_ROOT/include" 981 ADJOINTMPILIB="-L$ADJOINTMPI_ROOT/lib -lAMPI" 982 dnl Also set _HAVE_AMPI_, because the interface is (almost) the 983 dnl same as for adjoinable mpi... 984 AC_DEFINE([_HAVE_AMPI_],[1],[with adjoint mpi in ISSM src]) 985 AC_DEFINE([_HAVE_ADJOINTMPI_],[1],[with adjoint mpi in ISSM src]) 986 AC_SUBST([ADJOINTMPIINCL]) 987 AC_SUBST([ADJOINTMPILIB]) 988 fi 989 AM_CONDITIONAL([ADJOINTMPI], [test x$HAVE_ADJOINTMPI = xyes]) 990 dnl }}} 991 dnl medipack (CoDiPack, ADOLC dev){{{ 992 AC_ARG_WITH([medipack-dir], 993 AS_HELP_STRING([--with-medipack-dir=DIR], [MeDiPack root directory.]), 994 [MEDIPACK_ROOT=$withval],[MEDIPACK_ROOT="no"]) 995 996 dnl Check whether medipack is enabled 997 AC_MSG_CHECKING([for medipack]) 998 if test "x$MEDIPACK_ROOT" = "xno" ; then 999 HAVE_MEDIPACK=no 1000 else 1001 HAVE_MEDIPACK=yes 1002 if ! test -d "$MEDIPACK_ROOT"; then 1003 AC_MSG_ERROR([medipack directory provided ($MEDIPACK_ROOT) does not exist]); 1004 fi 1005 fi 1006 AC_MSG_RESULT($HAVE_MEDIPACK) 1007 1008 dnl medipack headers and libraries 1009 if test "x$HAVE_MEDIPACK" == "xyes"; then 1010 if test "x$CODIPACK_ROOT" == "xno"; then 1011 AC_MSG_ERROR([cannot run MeDiPack without CoDiPack]); 1012 fi 1013 MEDIPACKINCL="-I$MEDIPACK_ROOT/include -I$MEDIPACK_ROOT/src" 1014 dnl Also set _HAVE_AMPI_, because the interface is (almost) the 1015 dnl same as for adjoinable mpi... 1016 AC_DEFINE([_HAVE_AMPI_],[1],[with adjoint mpi in ISSM src]) 1017 AC_DEFINE([_HAVE_MEDIPACK_],[1],[with MeDiPack in ISSM src]) 1018 AC_SUBST([MEDIPACKINCL]) 1019 fi 1020 AM_CONDITIONAL([MEDIPACK], [test x$HAVE_MEDIPACK = xyes]) 1021 1022 dnl }}} 914 1023 dnl rose{{{ 915 1024 AC_ARG_WITH([rose-dir], 916 1025 AS_HELP_STRING([--with-rose-dir=DIR], [rose root directory.]), 917 [ROSE_ROOT=$withval],[ROSE_ROOT="no"]) 1026 [ROSE_ROOT=$withval],[ROSE_ROOT="no"]) 918 1027 919 1028 dnl Check whether rose is enabled … … 941 1050 dnl mpi{{{ 942 1051 AC_MSG_CHECKING(for mpi) 943 1052 944 1053 AC_ARG_WITH([mpi-include], 945 1054 AS_HELP_STRING([--with-mpi-include=DIR],[mpi include directory, necessary for parallel build]), … … 954 1063 [MPI_LIBFLAGS=$withval],[MPI_LIBFLAGS=""]) 955 1064 956 1065 957 1066 if test -z "$MPI_INCLUDE" ; then 958 1067 HAVE_MPI=no … … 980 1089 if test x$IS_WINDOWS = xyes; then 981 1090 MPIINCL=/I"$MPI_INCLUDE" 982 else 1091 else 983 1092 MPIINCL=-I"$MPI_INCLUDE" 984 1093 fi … … 996 1105 AS_HELP_STRING([--with-petsc-dir=DIR],[PETSc root directory, necessary for parallel build]), 997 1106 [PETSC_ROOT=$withval],[PETSC_ROOT="no"]) 998 1107 999 1108 dnl Check whether petsc is enabled 1000 1109 AC_MSG_CHECKING([for petsc]) … … 1033 1142 AC_MSG_RESULT(no) 1034 1143 fi 1035 1144 1036 1145 AC_ARG_WITH([petsc-arch], 1037 1146 AS_HELP_STRING([--with-petsc-arch=DIR],[PETSc arch, necessary for PETSc < 3.0]), … … 1050 1159 PETSCINCL+=" $PETSC_ROOT/include/$PETSC_ARCH" 1051 1160 fi 1052 1161 1053 1162 case "${host_os}" in 1054 1163 *cygwin*) … … 1069 1178 if test "x$host_os_version" = "x3.0.101-0.31.1_1.0502.8394-cray_gem_s" ; then 1070 1179 PETSCLIB="-L$PETSC_ROOT/lib -lcraypetsc_gnu_real -lmetis" 1071 fi 1180 fi 1072 1181 ;; 1073 1182 *darwin*) … … 1122 1231 1123 1232 if test "$METIS_VERSION" = "4" ; then 1124 METISINCL=-I"$METIS_ROOT/Lib" 1233 METISINCL=-I"$METIS_ROOT/Lib" 1125 1234 case "${host_os}" in 1126 1235 *cygwin*) 1127 METISINCL="/I`cygpath -m $METIS_ROOT/Lib`" 1236 METISINCL="/I`cygpath -m $METIS_ROOT/Lib`" 1128 1237 METISLIB="-Wl,/link -Wl,/LIBPATH:`cygpath -m $METIS_ROOT` -Wl,libmetis.lib" 1129 1238 ;; … … 1150 1259 ;; 1151 1260 esac 1152 METISINCL=-I"$METIS_ROOT/include" 1261 METISINCL=-I"$METIS_ROOT/include" 1153 1262 AC_DEFINE([_METIS_VERSION_],[5],[ Metis version number]) 1154 1263 fi … … 1164 1273 AC_ARG_WITH([tao-dir], 1165 1274 AS_HELP_STRING([--with-tao-dir=DIR], [tao root directory.]), 1166 [TAO_ROOT=$withval],[TAO_ROOT="no"]) 1275 [TAO_ROOT=$withval],[TAO_ROOT="no"]) 1167 1276 1168 1277 dnl Check whether tao is enabled … … 1199 1308 AC_ARG_WITH([m1qn3-dir], 1200 1309 AS_HELP_STRING([--with-m1qn3-dir=DIR], [m1qn3 root directory.]), 1201 [M1QN3_ROOT=$withval],[M1QN3_ROOT="no"]) 1310 [M1QN3_ROOT=$withval],[M1QN3_ROOT="no"]) 1202 1311 1203 1312 dnl Check whether m1qn3 is enabled … … 1212 1321 fi 1213 1322 AC_MSG_RESULT($HAVE_M1QN3) 1214 1323 1215 1324 dnl m1qn3 headers and libraries 1216 1325 if test "x$HAVE_M1QN3" == "xyes"; then 1217 M1QN3LIB="$M1QN3_ROOT/libm1qn3.a $M1QN3_ROOT/ /libddot.a"1326 M1QN3LIB="$M1QN3_ROOT/libm1qn3.a $M1QN3_ROOT/libddot.a" 1218 1327 AC_DEFINE([_HAVE_M1QN3_],[1],[with M1QN3 in ISSM src]) 1219 1328 AC_SUBST([M1QN3LIB]) … … 1223 1332 AC_ARG_WITH([proj4-dir], 1224 1333 AS_HELP_STRING([--with-proj4-dir=DIR], [proj4 root directory.]), 1225 [PROJ4_ROOT=$withval],[PROJ4_ROOT="no"]) 1334 [PROJ4_ROOT=$withval],[PROJ4_ROOT="no"]) 1226 1335 1227 1336 dnl Check whether proj4 is enabled … … 1236 1345 fi 1237 1346 AC_MSG_RESULT($HAVE_PROJ4) 1238 1347 1239 1348 dnl proj4 headers and libraries 1240 1349 if test "x$HAVE_PROJ4" == "xyes"; then … … 1251 1360 AS_HELP_STRING([--with-slepc-dir=DIR],[slepc root directory]), 1252 1361 [SLEPC_ROOT=$withval],[SLEPC_ROOT="no"]) 1253 1362 1254 1363 dnl Check whether slepc is enabled 1255 1364 AC_MSG_CHECKING([for slepc]) … … 1263 1372 fi 1264 1373 AC_MSG_RESULT($HAVE_SLEPC) 1265 1374 1266 1375 dnl slepc headers and libraries 1267 1376 if test "x$HAVE_SLEPC" == "xyes"; then … … 1277 1386 AS_HELP_STRING([--with-shapelib-dir=DIR], [shapelib root directory]), 1278 1387 [SHAPELIB_ROOT=$withval],[SHAPELIB_ROOT="no"]) 1279 1388 1280 1389 dnl Check whether shapelib is enabled 1281 1390 AC_MSG_CHECKING([for shapelib]) … … 1289 1398 fi 1290 1399 AC_MSG_RESULT($HAVE_SHAPELIB) 1291 1400 1292 1401 dnl shapelib headers and libraries 1293 1402 if test "x$HAVE_SHAPELIB" == "xyes"; then … … 1309 1418 AS_HELP_STRING([--with-scalapack-lib=LIBS],[scalapack libraries to include]), 1310 1419 [SCALAPACKLIB=$withval],[SCALAPACKLIB="no"]) 1311 1420 1312 1421 dnl Check whether scalapack is enabled 1313 1422 AC_MSG_CHECKING([for scalapack]) … … 1329 1438 fi 1330 1439 AC_MSG_RESULT($HAVE_SCALAPACK) 1331 1440 1332 1441 dnl scalapack headers and libraries 1333 1442 if test "x$HAVE_SCALAPACK" = "xyes"; then … … 1340 1449 AS_HELP_STRING([--with-blas-lapack-dir=DIR],[blas-lapack root directory]), 1341 1450 [BLASLAPACK_ROOT=$withval],[BLASLAPACK_ROOT="no"]) 1342 1451 1343 1452 dnl Check whether blas-lapack is enabled 1344 1453 AC_MSG_CHECKING([for blas-lapack]) … … 1352 1461 fi 1353 1462 AC_MSG_RESULT($HAVE_BLASLAPACK) 1354 1463 1355 1464 dnl blas-lapack headers and libraries 1356 1465 if test "x$HAVE_BLASLAPACK" == "xyes"; then … … 1362 1471 ;; 1363 1472 *linux*) 1364 BLASLAPACKLIB=-L"$BLASLAPACK_ROOT/lib -lflapack -lfblas " 1473 BLASLAPACKLIB=-L"$BLASLAPACK_ROOT/lib -lflapack -lfblas " 1365 1474 ;; 1366 1475 *darwin*) 1367 BLASLAPACKLIB=-L"$BLASLAPACK_ROOT/lib -lflapack -lfblas " 1476 BLASLAPACKLIB=-L"$BLASLAPACK_ROOT/lib -lflapack -lfblas " 1368 1477 ;; 1369 1478 esac … … 1393 1502 dnl plapack{{{ 1394 1503 AC_MSG_CHECKING(for plapack) 1395 1504 1396 1505 AC_ARG_WITH([plapack-lib], 1397 1506 AS_HELP_STRING([--with-plapack-lib = lib],[plapack library]), 1398 1507 [PLAPACK_LIB=$withval],[PLAPACK_LIB=""]) 1399 1508 1400 1509 AC_ARG_WITH([plapack-include], 1401 1510 AS_HELP_STRING([--with-plapack-include = include], 1402 1511 [plapack include ]), 1403 1512 [PLAPACK_INCLUDE=$withval],[PLAPACK_INCLUDE=""]) 1404 1513 1405 1514 if test -n "$PLAPACK_LIB"; then 1406 1515 if test -n "$PLAPACK_INCLUDE"; then 1407 1516 1408 1517 HAVE_PLAPACK=yes 1409 1518 PLAPACKINCL="$PLAPACK_INCLUDE" … … 1424 1533 AS_HELP_STRING([--with-mumps-dir=DIR],[mumps root directory]), 1425 1534 [MUMPS_ROOT=$withval],[MUMPS_ROOT="no"]) 1426 1535 1427 1536 dnl Check whether mumps is enabled 1428 1537 AC_MSG_CHECKING([for mumps]) … … 1436 1545 fi 1437 1546 AC_MSG_RESULT($HAVE_MUMPS) 1438 1547 1439 1548 dnl mumps headers and libraries 1440 1549 if test "x$HAVE_MUMPS" == "xyes"; then … … 1455 1564 if test "x$HAVE_MUMPS" != "xyes"; then 1456 1565 AC_MSG_CHECKING(for mumps2 (stand alone)) 1457 1566 1458 1567 AC_ARG_WITH([mumps2-include], 1459 1568 AS_HELP_STRING([--with-mumps2-include=DIR],[mumps2 include directory, necessary for parallel build]), … … 1464 1573 [MUMPS_LIBFLAGS=$withval],[MUMPS_LIBFLAGS=""]) 1465 1574 1466 1575 1467 1576 if test -z "$MUMPS_INCLUDE" ; then 1468 1577 HAVE_MUMPS=no … … 1490 1599 AS_HELP_STRING([--with-blacs-dir=DIR],[blacs root directory]), 1491 1600 [BLACS_ROOT=$withval],[BLACS_ROOT="no"]) 1492 1601 1493 1602 dnl Check whether blacs is enabled 1494 1603 AC_MSG_CHECKING([for blacs]) … … 1502 1611 fi 1503 1612 AC_MSG_RESULT($HAVE_BLACS) 1504 1613 1505 1614 dnl blacs headers and libraries 1506 1615 if test "x$HAVE_BLACS" == "xyes"; then … … 1516 1625 AS_HELP_STRING([--with-hypre-dir=DIR],[hypre root directory]), 1517 1626 [HYPRE_ROOT=$withval],[HYPRE_ROOT="no"]) 1518 1627 1519 1628 dnl Check whether hypre is enabled 1520 1629 AC_MSG_CHECKING([for hypre]) … … 1590 1699 fi 1591 1700 dnl }}} 1592 dnl superlu{{{ 1701 dnl superlu{{{ 1593 1702 AC_ARG_WITH([superlu-dir], 1594 1703 AS_HELP_STRING([--with-superlu-dir=DIR],[superlu root directory]), … … 1606 1715 fi 1607 1716 AC_MSG_RESULT($HAVE_SUPERLU) 1608 1717 1609 1718 dnl superlu headers and libraries 1610 1719 if test "x$HAVE_SUPERLU" == "xyes"; then … … 1616 1725 fi 1617 1726 dnl }}} 1618 dnl spooles{{{ 1727 dnl spooles{{{ 1619 1728 AC_ARG_WITH([spooles-dir], 1620 1729 AS_HELP_STRING([--with-spooles-dir=DIR],[spooles root directory]), … … 1632 1741 fi 1633 1742 AC_MSG_RESULT($HAVE_SPOOLES) 1634 1743 1635 1744 dnl spooles headers and libraries 1636 1745 if test "x$HAVE_SPOOLES" == "xyes"; then … … 1642 1751 fi 1643 1752 dnl }}} 1644 dnl pastix{{{ 1753 dnl pastix{{{ 1645 1754 AC_ARG_WITH([pastix-dir], 1646 1755 AS_HELP_STRING([--with-pastix-dir=DIR],[pastix root directory]), … … 1658 1767 fi 1659 1768 AC_MSG_RESULT($HAVE_PASTIX) 1660 1769 1661 1770 dnl pastix headers and libraries 1662 1771 if test "x$HAVE_PASTIX" == "xyes"; then … … 1672 1781 AS_HELP_STRING([--with-ml-dir=DIR],[ml root directory]), 1673 1782 [ML_ROOT=$withval],[ML_ROOT="no"]) 1674 1783 1675 1784 dnl Check whether ml is enabled 1676 1785 AC_MSG_CHECKING([for ml]) … … 1684 1793 fi 1685 1794 AC_MSG_RESULT($HAVE_ML) 1686 1795 1687 1796 dnl ml headers and libraries 1688 1797 if test "x$HAVE_ML" == "xyes"; then … … 1698 1807 AS_HELP_STRING([--with-umfpack-dir=DIR],[UMFPACK root directory]), 1699 1808 [UMFPACK_ROOT=$withval],[UMFPACK_ROOT="no"]) 1700 1809 1701 1810 dnl Check whether umfpack is enabled 1702 1811 AC_MSG_CHECKING([for umfpack]) … … 1710 1819 fi 1711 1820 AC_MSG_RESULT($HAVE_UMFPACK) 1712 1821 1713 1822 dnl umfpack headers and libraries 1714 1823 if test "x$HAVE_UMFPACK" == "xyes"; then … … 1738 1847 AC_ARG_WITH([math77-dir], 1739 1848 AS_HELP_STRING([--with-math77-dir=DIR], [math77 root directory.]), 1740 [MATH77_ROOT=$withval],[MATH77_ROOT="no"]) 1741 1849 [MATH77_ROOT=$withval],[MATH77_ROOT="no"]) 1850 1742 1851 dnl Check whether math77 is enabled 1743 1852 AC_MSG_CHECKING([for math77]) … … 1751 1860 fi 1752 1861 AC_MSG_RESULT($HAVE_MATH77) 1753 1862 1754 1863 dnl math77 headers and libraries 1755 1864 if test "x$HAVE_MATH77" == "xyes"; then … … 1762 1871 AC_ARG_WITH([fortran], 1763 1872 AS_HELP_STRING([--with-fortran = YES], [do we compile fortran code (default is yes)]), 1764 [FORTRAN=$withval],[FORTRAN=yes]) 1873 [FORTRAN=$withval],[FORTRAN=yes]) 1765 1874 AC_MSG_CHECKING(for fortran compilation) 1766 1875 if test "x$FORTRAN" = "xyes"; then … … 1830 1939 AC_ARG_WITH([meteoio-dir], 1831 1940 AS_HELP_STRING([--with-meteoio-dir=DIR], [use meteoio in conjunction with snowpack model.]), 1832 [METEOIO_ROOT=$withval],[METEOIO_ROOT="no"]) 1941 [METEOIO_ROOT=$withval],[METEOIO_ROOT="no"]) 1833 1942 1834 1943 dnl Check whether meteoio is enabled … … 1843 1952 fi 1844 1953 AC_MSG_RESULT($HAVE_METEOIO) 1845 1954 1846 1955 dnl meteoio headers and libraries 1847 1956 if test "x$HAVE_METEOIO" == "xyes"; then … … 1858 1967 AC_ARG_WITH([snowpack-dir], 1859 1968 AS_HELP_STRING([--with-snowpack-dir=DIR], [use snowpack for surface mass balance model.]), 1860 [SNOWPACK_ROOT=$withval],[SNOWPACK_ROOT="no"]) 1969 [SNOWPACK_ROOT=$withval],[SNOWPACK_ROOT="no"]) 1861 1970 1862 1971 dnl Check whether snowpack is enabled … … 1871 1980 fi 1872 1981 AC_MSG_RESULT($HAVE_SNOWPACK) 1873 1982 1874 1983 dnl snowpack headers and libraries 1875 1984 if test "x$HAVE_SNOWPACK" == "xyes"; then … … 1886 1995 AC_ARG_WITH([neopz-dir], 1887 1996 AS_HELP_STRING([--with-neopz-dir=DIR], [neopz root directory.]), 1888 [NEOPZ_ROOT=$withval],[NEOPZ_ROOT="no"]) 1997 [NEOPZ_ROOT=$withval],[NEOPZ_ROOT="no"]) 1889 1998 1890 1999 dnl Check whether neopz is enabled … … 1899 2008 fi 1900 2009 AC_MSG_RESULT($HAVE_NEOPZ) 1901 2010 1902 2011 dnl neopz headers and libraries 1903 2012 if test "x$HAVE_NEOPZ" == "xyes"; then … … 1938 2047 AC_ARG_WITH([bamg], 1939 2048 AS_HELP_STRING([--with-bamg = YES],[compile with bamg capabilities (default is yes)]), 1940 [BAMG=$withval],[BAMG=yes]) 2049 [BAMG=$withval],[BAMG=yes]) 1941 2050 AC_MSG_CHECKING(for bamg capability compilation) 1942 2051 … … 1952 2061 AC_ARG_WITH([ocean], 1953 2062 AS_HELP_STRING([--with-ocean = YES],[compile with ice/ocean coupling (default is no)]), 1954 [OCEAN=$withval],[OCEAN=no]) 2063 [OCEAN=$withval],[OCEAN=no]) 1955 2064 AC_MSG_CHECKING(for ice/ocean capability compilation) 1956 2065 … … 1966 2075 AC_ARG_WITH([kml], 1967 2076 AS_HELP_STRING([--with-kml = YES],[compile with kml capabilities (default is no)]), 1968 [KML=$withval],[KML=no]) 2077 [KML=$withval],[KML=no]) 1969 2078 AC_MSG_CHECKING(for kml capability compilation) 1970 2079 … … 1980 2089 AC_ARG_WITH([kriging], 1981 2090 AS_HELP_STRING([--with-kriging = YES],[compile with kriging capabilities (default is yes)]), 1982 [KRIGING=$withval],[KRIGING=yes]) 2091 [KRIGING=$withval],[KRIGING=yes]) 1983 2092 AC_MSG_CHECKING(for kriging capability compilation) 1984 2093 … … 1997 2106 AC_ARG_WITH([ios], 1998 2107 AS_HELP_STRING([--with-ios = YES], [compile with iOS capabilities (default is no, alternatives are yes)]), 1999 [IOS=$withval],[IOS=no]) 2108 [IOS=$withval],[IOS=no]) 2000 2109 AC_MSG_CHECKING(for iOS compilation) 2001 2110 … … 2016 2125 AC_ARG_WITH([android], 2017 2126 AS_HELP_STRING([--with-android = EXE], [compile with android capabilities (default is no, alternatives are exe and jni)]), 2018 [ANDROID=$withval],[ANDROID=no]) 2127 [ANDROID=$withval],[ANDROID=no]) 2019 2128 AC_MSG_CHECKING(for android capability compilation) 2020 2129 … … 2043 2152 AC_ARG_WITH([android-ndk], 2044 2153 AS_HELP_STRING([--with-android-ndk=DIR], [android-ndk root directory.]), 2045 [ANDROID_NDK_ROOT=$withval],[ANDROID_NDK_ROOT=""]) 2154 [ANDROID_NDK_ROOT=$withval],[ANDROID_NDK_ROOT=""]) 2046 2155 AC_MSG_CHECKING(with android ndk) 2047 2156 2048 2157 if test -d "$ANDROID_NDK_ROOT"; then 2049 2158 dnl defaults … … 2061 2170 dnl other options 2062 2171 dnl optimization{{{ 2063 dnl bypass standard optimization -g -O2 ? 2172 dnl bypass standard optimization -g -O2 ? 2064 2173 AC_ARG_WITH([cxxoptflags], 2065 2174 AS_HELP_STRING([--with-cxxoptflags = CXXOPTFLAGS], [optimization using CXX flags, ex: --with-cxxoptflags=-march=opteron -O3]), 2066 [CXXOPTFLAGS=$withval],[CXXOPTFLAGS="-g -O2 -fPIC"]) 2175 [CXXOPTFLAGS=$withval],[CXXOPTFLAGS="-g -O2 -fPIC"]) 2067 2176 AC_MSG_CHECKING(for c++ optimization flags) 2068 2177 AC_SUBST([CXXOPTFLAGS]) … … 2079 2188 MULTITHREADINLIB="" 2080 2189 if test "$NUMTHREADS_VALUE" != "1"; then 2081 2190 2082 2191 MULTITHREADINGLIB="-lpthread -lrt" 2083 2192 case "${host_os}" in … … 2094 2203 AC_DEFINE([_MULTITHREADING_],[1],[with numthreads enabled]) 2095 2204 fi 2205 dnl check that it is an integer 2206 if [[ "$NUMTHREADS_VALUE" -eq "$NUMTHREADS_VALUE" 2> /dev/null ]] ; then 2207 dnl cool we have an integer 2208 : 2209 else 2210 AC_MSG_ERROR([Number of threads provided ($NUMTHREADS_VALUE) is not an integer]); 2211 fi 2096 2212 AC_DEFINE_UNQUOTED([_NUMTHREADS_],[$NUMTHREADS_VALUE],[number of threads]) 2097 2213 AC_SUBST([MULTITHREADINGLIB]) 2098 AC_MSG_RESULT($NUMTHREADS_VALUE) 2214 AC_MSG_RESULT($NUMTHREADS_VALUE) 2099 2215 dnl }}} 2100 2216 dnl 64bit {{{ 2101 2217 AC_ARG_WITH([64bit-indices], 2102 2218 AS_HELP_STRING([--with-64bit-indices = bool], [use 64 bit integers, default 0, ex: --with-64bit-indices=1]), 2103 [USE_64BIT_INDICES=$withval],[USE_64BIT_INDICES=0]) 2219 [USE_64BIT_INDICES=$withval],[USE_64BIT_INDICES=0]) 2104 2220 AC_MSG_CHECKING(for 64 bit indices) 2105 2221 … … 2132 2248 AC_MSG_ERROR([need fortran compiler to compile GiaIvins (or use --without-GiaIvins )]); 2133 2249 fi 2134 2250 2135 2251 dnl check that fortran is provided if Love is on 2136 2252 if test "$HAVE_LOVE" = "yes" && test "$HAVE_FORTRAN" = "no" ; then … … 2142 2258 AC_MSG_ERROR([need mpi if using the metis partitioner!]); 2143 2259 fi 2144 2260 2145 2261 dnl check that if we run adolc, we don't compile krigging.exe 2146 2262 if test "$HAVE_ADOLC" = "yes" && test "$HAVE_KRIGING" = "yes" ; then … … 2151 2267 AC_MSG_ERROR([cannot compile ISSM with both PETSc and adolc]); 2152 2268 fi 2269 if test "$HAVE_ADOLC" = "yes" && test "$HAVE_CODIPACK" = "yes" ; then 2270 AC_MSG_ERROR([cannot compile ISSM with both ADOLC and CoDiPack]); 2271 fi 2272 if test "$HAVE_ADJOINTMPI" = "yes" && test "$HAVE_MEDIPACK" = "yes" ; then 2273 AC_MSG_ERROR([cannot compile ISSM with both MeDiPack and AdjointMPI]); 2274 fi 2153 2275 dnl check that if we run meteoio, we have snowpack also 2154 2276 if test "$HAVE_METEOIO" = "yes" && test "$HAVE_SNOWPACK" = "no" ; then -
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/c/Makefile.am
r23189 r23394 1 AM_CPPFLAGS = @NEOPZINCL@ @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @AMPIINCL@ @ MPIINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ @ANDROID_NDKINCL@ @METEOIOINCL@ @SNOWPACKINCL@ @PROJ4INCL@1 AM_CPPFLAGS = @NEOPZINCL@ @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @AMPIINCL@ @ADJOINTMPIINCL@ @MEDIPACKINCL@ @MPIINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @CODIPACKINCL@ @GSLINCL@ @BOOSTINCL@ @ANDROID_NDKINCL@ @METEOIOINCL@ @SNOWPACKINCL@ @PROJ4INCL@ 2 2 3 3 AUTOMAKE_OPTIONS = subdir-objects … … 51 51 ./modules/BamgTriangulatex/BamgTriangulatex.cpp 52 52 53 #do not include AmrBamg with AD OLC53 #do not include AmrBamg with AD 54 54 if ADOLC 55 55 else 56 if CODIPACK 57 else 56 58 issm_sources += ./classes/AmrBamg.cpp 59 endif 57 60 endif 58 61 endif … … 172 175 ./shared/Elements/PrintArrays.cpp\ 173 176 ./shared/Elements/PddSurfaceMassBalance.cpp\ 177 ./shared/Elements/PddSurfaceMassBalanceSicopolis.cpp\ 174 178 ./shared/Elements/ComputeDelta18oTemperaturePrecipitation.cpp\ 175 179 ./shared/Elements/ComputeMungsmTemperaturePrecipitation.cpp\ … … 320 324 ./classes/Inputs/TetraInput.cpp 321 325 #}}} 326 #ADJOINTMPI/MeDiPack sources {{{ 327 if ADJOINTMPI 328 issm_sources += ./toolkits/codipack/ampi_interface.cpp 329 endif 330 if MEDIPACK 331 issm_sources += ./toolkits/codipack/ampi_interface.cpp 332 endif 333 # }}} 322 334 #DAKOTA sources {{{ 323 335 if DAKOTA … … 632 644 if !WINDOWS 633 645 if !STANDALONE_LIBRARIES 634 libISSMCore_la_LIBADD = $(PETSCLIB) $(TAOLIB) $(M1QN3LIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) $(ADOLCLIB) $(AMPILIB) $( METEOIOLIB) $(SNOWPACKLIB)646 libISSMCore_la_LIBADD = $(PETSCLIB) $(TAOLIB) $(M1QN3LIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(SCALAPACKLIB) $(BLACSLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) $(ADOLCLIB) $(AMPILIB) $(ADJOINTMPILIB) $(METEOIOLIB) $(SNOWPACKLIB) 635 647 if FORTRAN 636 648 libISSMCore_la_LIBADD += $(FLIBS) $(FORTRANLIB) … … 714 726 715 727 #External packages 716 LDADD += $(NEOPZLIB) $(TAOLIB) $(M1QN3LIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(SCALAPACKLIB) $(BLACSLIB) $(PETSCLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) $(AMPILIB) $(AD OLCLIB) $(MPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(PROJ4LIB)728 LDADD += $(NEOPZLIB) $(TAOLIB) $(M1QN3LIB) $(PLAPACKLIB) $(MUMPSLIB) $(SUPERLULIB) $(SPOOLESLIB) $(SCALAPACKLIB) $(BLACSLIB) $(PETSCLIB) $(HYPRELIB) $(SPAILIB) $(PROMETHEUSLIB) $(PASTIXLIB) $(MLLIB) $(DAKOTALIB) $(METISLIB) $(CHACOLIB) $(SCOTCHLIB) $(BLASLAPACKLIB) $(MKLLIB) $(MPILIB) $(MATHLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB) $(OSLIBS) $(GSLLIB) $(AMPILIB) $(ADJOINTMPILIB) $(ADOLCLIB) $(MPILIB) $(METEOIOLIB) $(SNOWPACKLIB) $(PROJ4LIB) 717 729 718 730 if FORTRAN -
issm/trunk/src/c/analyses/EnthalpyAnalysis.cpp
r23189 r23394 43 43 int smb_model; 44 44 iomodel->FindConstant(&smb_model,"md.smb.model"); 45 if(smb_model==SMBpddEnum) isdynamic=true; 46 if(smb_model==SMBd18opddEnum) isdynamic=true; 45 if(smb_model==SMBpddEnum) isdynamic=true; 46 if(smb_model==SMBd18opddEnum) isdynamic=true; 47 if(smb_model==SMBpddSicopolisEnum) isdynamic=true; 47 48 } 48 49 … … 1200 1201 _assert_((Hc+Ht)>0.); 1201 1202 lambda = Hc/(Hc+Ht); 1203 _assert_(lambda>=0.); 1204 _assert_(lambda<=1.); 1202 1205 kappa = kappa_c*kappa_t/(lambda*kappa_t+(1.-lambda)*kappa_c); // ==(lambda/kappa_c + (1.-lambda)/kappa_t)^-1 1203 1206 } -
issm/trunk/src/c/analyses/ExtrapolationAnalysis.cpp
r23189 r23394 65 65 femmodel->SetCurrentConfiguration(ExtrapolationAnalysisEnum); 66 66 67 if(VerboseSolution()) _printf0_(" extrapolation of " << EnumToStringx(extvar_enum) << ": call computational core:\n");67 if(VerboseSolution()) _printf0_(" extrapolation of " << EnumToStringx(extvar_enum) << ":\n"); 68 68 solutionsequence_linear(femmodel); 69 69 -
issm/trunk/src/c/analyses/FreeSurfaceBaseAnalysis.cpp
r22758 r23394 80 80 iomodel->FetchDataToInput(elements,"md.mask.ice_levelset",MaskIceLevelsetEnum); 81 81 iomodel->FetchDataToInput(elements,"md.basalforcings.groundedice_melting_rate",BasalforcingsGroundediceMeltingRateEnum,0.); 82 iomodel->FetchDataToInput(elements,"md.basalforcings.floatingice_melting_rate",BasalforcingsFloatingiceMeltingRateEnum);83 82 iomodel->FetchDataToInput(elements,"md.initialization.vx",VxEnum); 84 83 iomodel->FetchDataToInput(elements,"md.initialization.vy",VyEnum); … … 89 88 iomodel->FetchDataToInput(elements,"md.mesh.vertexonbase",MeshVertexonbaseEnum); 90 89 iomodel->FetchDataToInput(elements,"md.mesh.vertexonsurface",MeshVertexonsurfaceEnum); 90 } 91 92 /*Get what we need for ocean-induced basal melting*/ 93 int basalforcing_model; 94 iomodel->FindConstant(&basalforcing_model,"md.basalforcings.model"); 95 switch(basalforcing_model){ 96 case FloatingMeltRateEnum: 97 iomodel->FetchDataToInput(elements,"md.basalforcings.floatingice_melting_rate",BasalforcingsFloatingiceMeltingRateEnum); 98 break; 99 case LinearFloatingMeltRateEnum: 100 break; 101 case MismipFloatingMeltRateEnum: 102 break; 103 case MantlePlumeGeothermalFluxEnum: 104 break; 105 case SpatialLinearFloatingMeltRateEnum: 106 iomodel->FetchDataToInput(elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsDeepwaterMeltingRateEnum); 107 iomodel->FetchDataToInput(elements,"md.basalforcings.deepwater_elevation",BasalforcingsDeepwaterElevationEnum); 108 iomodel->FetchDataToInput(elements,"md.basalforcings.upperwater_elevation",BasalforcingsUpperwaterElevationEnum); 109 break; 110 case BasalforcingsPicoEnum: 111 iomodel->FetchDataToInput(elements,"md.basalforcings.basin_id",BasalforcingsPicoBasinIdEnum); 112 break; 113 default: 114 _error_("Basal forcing model "<<EnumToStringx(basalforcing_model)<<" not supported yet"); 91 115 } 92 116 }/*}}}*/ -
issm/trunk/src/c/analyses/HydrologyDCEfficientAnalysis.cpp
r23189 r23394 313 313 } 314 314 /*Intermediaries */ 315 int smb_model; 315 316 IssmDouble dt,scalar,water_head; 316 IssmDouble water_load,transfer ;317 IssmDouble water_load,transfer,runoff_value; 317 318 IssmDouble epl_storing,epl_transmitivity; 318 319 IssmDouble Jdet; 319 320 IssmDouble residual,connectivity; 320 321 321 IssmDouble *xyz_list = NULL; 322 Input* old_wh_input = NULL; 322 IssmDouble *xyz_list = NULL; 323 Input* old_wh_input = NULL; 324 Input* surface_runoff_input = NULL; 323 325 324 326 /*Fetch number of nodes and dof for this finite element*/ … … 334 336 //basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 335 337 basalelement ->FindParam(&dt,HydrologydtEnum); 336 337 Input* epl_thick_input = basalelement->GetInput(HydrologydcEplThicknessHydrostepEnum); _assert_(epl_thick_input); 338 Input* sed_head_input = basalelement->GetInput(SedimentHeadHydrostepEnum); _assert_(sed_head_input); 339 Input* epl_head_input = basalelement->GetInput(EplHeadHydrostepEnum); _assert_(epl_head_input); 340 Input* water_input = basalelement->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(water_input); 341 Input* residual_input = basalelement->GetInput(SedimentHeadResidualEnum); _assert_(residual_input); 342 Input* base_input = basalelement->GetInput(BaseEnum); _assert_(base_input); 338 basalelement ->FindParam(&smb_model,SmbEnum); 339 340 Input* epl_thick_input = basalelement->GetInput(HydrologydcEplThicknessHydrostepEnum); _assert_(epl_thick_input); 341 Input* sed_head_input = basalelement->GetInput(SedimentHeadHydrostepEnum); _assert_(sed_head_input); 342 Input* epl_head_input = basalelement->GetInput(EplHeadHydrostepEnum); _assert_(epl_head_input); 343 Input* basal_melt_input = basalelement->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(basal_melt_input); 344 Input* residual_input = basalelement->GetInput(SedimentHeadResidualEnum); _assert_(residual_input); 345 Input* base_input = basalelement->GetInput(BaseEnum); _assert_(base_input); 343 346 344 347 if(dt!= 0.){ 345 348 old_wh_input = basalelement->GetInput(EplHeadOldEnum); _assert_(old_wh_input); 346 349 } 350 if(smb_model==SMBgradientscomponentsEnum){ 351 surface_runoff_input = basalelement->GetInput(SmbRunoffEnum); _assert_(surface_runoff_input); 352 } 353 347 354 /* Start looping on the number of gaussian points: */ 348 355 Gauss* gauss = basalelement->NewGauss(2); … … 355 362 356 363 /*Loading term*/ 357 water_input->GetInputValue(&water_load,gauss); 358 scalar = Jdet*gauss->weight*(water_load); 364 basal_melt_input->GetInputValue(&water_load,gauss); 365 if(surface_runoff_input) surface_runoff_input->GetInputValue(&runoff_value,gauss); 366 else runoff_value = 0.; 367 scalar = Jdet*gauss->weight*(water_load+runoff_value); 359 368 //scalar = Jdet*gauss->weight*(water_load)/epl_transmitivity; 360 369 if(dt!=0.) scalar = scalar*dt; … … 524 533 IssmDouble EPLgrad2; 525 534 IssmDouble EPL_N; 535 IssmDouble opening,closing; 526 536 527 537 femmodel->parameters->FindParam(&domaintype,DomainTypeEnum); … … 589 599 EPLgrad2 = (epl_slopeX[i]*epl_slopeX[i])+(epl_slopeY[i]*epl_slopeY[i]); 590 600 /*And proceed to the real thing*/ 591 thickness[i] = old_thickness[i]/(1.0 592 -((rho_water*gravity*epl_conductivity*EPLgrad2*dt)/(rho_ice*latentheat)) 593 +((2.0*A*dt*pow(EPL_N,n))/(pow(n,n)))); 601 opening=(rho_water*gravity*epl_conductivity*EPLgrad2*dt)/(rho_ice*latentheat); 602 closing=(2.0*A*dt*pow(EPL_N,n))/(pow(n,n)); 603 /*implicit*/ 604 thickness[i] = old_thickness[i]/(1.0-opening+closing); 605 /*explicit*/ 606 //thickness[i] = old_thickness[i]*(1.0+opening-closing); 607 /*centered*/ 608 //thickness[i] = old_thickness[i]*(1.0+opening-closing)/(1.0-opening+closing); 594 609 /*Take care of otherthikening*/ 595 610 if(thickness[i]>max_thick){ … … 688 703 if(old_active[i]>0.){ 689 704 vec_mask->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 690 /* If epl thickness gets under colapse thickness, close the layer */691 if(epl_thickness[i]<colapse_thick ){705 /* If epl thickness gets under colapse thickness, close the layer if there is no residual*/ 706 if(epl_thickness[i]<colapse_thick && residual[i]<=0.){ 692 707 vec_mask->SetValue(basalelement->nodes[i]->Sid(),0.,INS_VAL); 693 708 recurence->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 694 709 } 695 /* //If epl head gets under base elevation, close the layer */ 696 /* else if(eplhead[i]<(base[i]-1.0e-8)){ */ 697 /* vec_mask->SetValue(basalelement->nodes[i]->Sid(),0.,INS_VAL); */ 698 /* recurence->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); */ 699 /* } */ 700 } 701 /*If node is now closed bring its thickness back to initial*/ 710 } 702 711 if (old_active[i]==0.){ 703 epl_thickness[i]=init_thick;704 712 /*Activate if we have a residual from sediment*/ 705 713 if(residual[i]>0.){ 706 714 vec_mask->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 707 if(old_active[i]==0.){ 708 recurence->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 709 } 715 recurence->SetValue(basalelement->nodes[i]->Sid(),1.,INS_VAL); 716 } 717 else{ 718 /*If node is now closed bring its thickness back to initial*/ 719 epl_thickness[i]=init_thick; 720 vec_mask->SetValue(basalelement->nodes[i]->Sid(),0.,INS_VAL); 710 721 } 711 722 } -
issm/trunk/src/c/analyses/HydrologyDCInefficientAnalysis.cpp
r23189 r23394 10 10 return 1; 11 11 }/*}}}*/ 12 13 12 void HydrologyDCInefficientAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 14 13 … … 29 28 30 29 /*retrieve some parameters: */ 30 bool issmb; 31 iomodel->FindConstant(&issmb,"md.transient.issmb"); 31 32 iomodel->FindConstant(&hydrology_model,"md.hydrology.model"); 32 33 … … 63 64 parameters->AddObject(new DoubleParam(HydrologydcSedimentlimitEnum,sedimentlimit)); 64 65 } 66 if(!issmb){ 67 parameters->AddObject(iomodel->CopyConstantObject("md.smb.model",SmbEnum)); 68 } 69 65 70 /*Requested outputs*/ 66 71 iomodel->FindConstant(&requestedoutputs,&numoutputs,"md.hydrology.requested_outputs"); … … 69 74 iomodel->DeleteData(&requestedoutputs,numoutputs,"md.hydrology.requested_outputs"); 70 75 }/*}}}*/ 71 72 76 void HydrologyDCInefficientAnalysis::UpdateElements(Elements* elements,IoModel* iomodel,int analysis_counter,int analysis_type){/*{{{*/ 73 77 … … 105 109 iomodel->FetchDataToInput(elements,"md.mesh.vertexonsurface",MeshVertexonsurfaceEnum); 106 110 } 107 108 111 if(isefficientlayer){ 109 112 iomodel->FetchDataToInput(elements,"md.hydrology.mask_eplactive_node",HydrologydcMaskEplactiveNodeEnum); 110 113 iomodel->FetchDataToInput(elements,"md.initialization.epl_head",EplHeadHydrostepEnum); 111 114 } 112 }/*}}}*/ 113 115 116 }/*}}}*/ 114 117 void HydrologyDCInefficientAnalysis::CreateNodes(Nodes* nodes,IoModel* iomodel){/*{{{*/ 115 118 … … 127 130 iomodel->DeleteData(2,"md.mesh.vertexonbase","md.mesh.vertexonsurface"); 128 131 }/*}}}*/ 129 130 132 void HydrologyDCInefficientAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ 131 133 … … 137 139 IoModelToConstraintsx(constraints,iomodel,"md.hydrology.spcsediment_head",HydrologyDCInefficientAnalysisEnum,P1Enum); 138 140 }/*}}}*/ 139 140 141 void HydrologyDCInefficientAnalysis::CreateLoads(Loads* loads, IoModel* iomodel){/*{{{*/ 141 142 … … 172 173 _error_("not implemented"); 173 174 }/*}}}*/ 174 175 175 ElementVector* HydrologyDCInefficientAnalysis::CreateDVector(Element* element){/*{{{*/ 176 176 /*Default, return NULL*/ 177 177 return NULL; 178 178 }/*}}}*/ 179 180 179 ElementMatrix* HydrologyDCInefficientAnalysis::CreateJacobianMatrix(Element* element){/*{{{*/ 181 180 _error_("Not implemented"); 182 181 }/*}}}*/ 183 184 182 ElementMatrix* HydrologyDCInefficientAnalysis::CreateKMatrix(Element* element){/*{{{*/ 185 183 … … 307 305 return Ke; 308 306 }/*}}}*/ 309 310 307 ElementVector* HydrologyDCInefficientAnalysis::CreatePVector(Element* element){/*{{{*/ 311 308 … … 342 339 /*Intermediaries */ 343 340 bool active_element,isefficientlayer; 341 int smb_model; 344 342 IssmDouble dt,scalar,sediment_storing; 345 343 IssmDouble water_head,sediment_transmitivity; 346 IssmDouble water_load, transfer;344 IssmDouble water_load,runoff_value,transfer; 347 345 IssmDouble Jdet; 348 346 349 347 IssmDouble *xyz_list = NULL; 350 348 Input* active_element_input = NULL; 351 Input* old_wh_input = NULL; 349 Input* old_wh_input = NULL; 350 Input* surface_runoff_input = NULL; 352 351 353 352 /*Fetch number of nodes and dof for this finite element*/ … … 361 360 basalelement->GetVerticesCoordinates(&xyz_list); 362 361 //basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 363 basalelement 362 basalelement->FindParam(&dt,HydrologydtEnum); 364 363 basalelement->FindParam(&isefficientlayer,HydrologydcIsefficientlayerEnum); 365 366 Input* sed_head_input = basalelement->GetInput(SedimentHeadHydrostepEnum); 367 Input* epl_head_input = basalelement->GetInput(EplHeadHydrostepEnum); 368 Input* base_input = basalelement->GetInput(BaseEnum); 369 Input* water_input = basalelement->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(water_input); 370 Input* SedTrans_input = basalelement->GetInput(HydrologydcSedimentTransmitivityEnum); _assert_(SedTrans_input); 364 basalelement->FindParam(&smb_model,SmbEnum); 365 366 Input* sed_head_input = basalelement->GetInput(SedimentHeadHydrostepEnum); 367 Input* epl_head_input = basalelement->GetInput(EplHeadHydrostepEnum); 368 Input* base_input = basalelement->GetInput(BaseEnum); 369 Input* basal_melt_input = basalelement->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(basal_melt_input); 370 Input* SedTrans_input = basalelement->GetInput(HydrologydcSedimentTransmitivityEnum); _assert_(SedTrans_input); 371 371 372 372 if(dt!= 0.){ 373 373 old_wh_input = basalelement->GetInput(SedimentHeadOldEnum); _assert_(old_wh_input); 374 374 } 375 if(smb_model==SMBgradientscomponentsEnum){ 376 surface_runoff_input = basalelement->GetInput(SmbRunoffEnum); _assert_(surface_runoff_input); 377 } 378 375 379 /*Transfer related Inputs*/ 376 380 if(isefficientlayer){ … … 388 392 /*Loading term*/ 389 393 if(!isefficientlayer){ 390 water_input->GetInputValue(&water_load,gauss); 391 scalar = Jdet*gauss->weight*(water_load); 394 basal_melt_input->GetInputValue(&water_load,gauss); 395 if(surface_runoff_input) surface_runoff_input->GetInputValue(&runoff_value,gauss); 396 else runoff_value = 0.; 397 scalar = Jdet*gauss->weight*(water_load+runoff_value); 392 398 //scalar = Jdet*gauss->weight*(water_load)/sediment_transmitivity; 393 399 if(dt!=0.) scalar = scalar*dt; … … 400 406 active_element_input->GetInputValue(&active_element); 401 407 if(!active_element){ 402 water_input->GetInputValue(&water_load,gauss); 403 scalar = Jdet*gauss->weight*(water_load); 408 basal_melt_input->GetInputValue(&water_load,gauss); 409 if(surface_runoff_input) surface_runoff_input->GetInputValue(&runoff_value,gauss); 410 else runoff_value = 0.; 411 scalar = Jdet*gauss->weight*(water_load+runoff_value); 404 412 //scalar = Jdet*gauss->weight*(water_load)/sediment_transmitivity; 405 413 if(dt!=0.) scalar = scalar*dt; … … 444 452 return pe; 445 453 }/*}}}*/ 446 447 454 void HydrologyDCInefficientAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 448 455 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. … … 472 479 xDelete<IssmDouble>(dbasis); 473 480 }/*}}}*/ 474 475 481 void HydrologyDCInefficientAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 476 482 element->GetSolutionFromInputsOneDof(solution,SedimentHeadHydrostepEnum); 477 483 }/*}}}*/ 478 479 484 void HydrologyDCInefficientAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ 480 485 _error_("Not implemented yet"); 481 486 }/*}}}*/ 482 483 487 void HydrologyDCInefficientAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 484 488 … … 514 518 /*Use the dof list to index into the solution vector: */ 515 519 516 /*need to introduce thawed test herre*/517 520 for(int i=0;i<numnodes;i++){ 518 521 values[i] =solution[doflist[i]]; … … 542 545 kappa=kmax*pow(10.,penalty_factor); 543 546 547 548 Input* thawed_element_input = basalelement->GetInput(HydrologydcMaskThawedEltEnum); _assert_(thawed_element_input); 549 thawed_element_input->GetInputValue(&thawed_element); 550 544 551 for(int i=0;i<numnodes;i++){ 552 /*frozen elements heads are set to base elevation*/ 553 if(!thawed_element){ 554 values[i]=base[i]; 555 } 545 556 GetHydrologyDCInefficientHmax(&h_max,basalelement,basalelement->GetNode(i)); 546 557 if(values[i]>h_max) { … … 551 562 residual[i] = 0.; 552 563 } 553 //adding base in min to take into account heads under bed wich don't change N554 //pressure[i]=(rho_ice*g*thickness[i])-(rho_freshwater*g*(max((min(h_max,values[i])-base[i]),0.0)));555 564 pressure[i]=(rho_ice*g*thickness[i])-(rho_freshwater*g*(values[i]-base[i])); 565 556 566 } 557 567 xDelete<IssmDouble>(thickness); … … 575 585 } 576 586 }/*}}}*/ 577 578 587 void HydrologyDCInefficientAnalysis::UpdateConstraints(FemModel* femmodel){/*{{{*/ 579 588 /*Default, do nothing*/ 580 589 return; 581 590 }/*}}}*/ 582 583 591 IssmDouble HydrologyDCInefficientAnalysis::SedimentStoring(Element* element,Gauss* gauss,Input* sed_head_input, Input* base_input){/*{{{*/ 584 592 int unconf_scheme; … … 620 628 return sediment_storing; 621 629 }/*}}}*/ 622 623 630 IssmDouble HydrologyDCInefficientAnalysis::SedimentTransmitivity(Element* element,Gauss* gauss,Input* sed_head_input, Input* base_input,Input* SedTrans_input){/*{{{*/ 624 631 int unconf_scheme; … … 630 637 IssmDouble base_elev,prestep_head,water_sheet; 631 638 IssmDouble sediment_thickness = element->GetMaterialParameter(HydrologydcSedimentThicknessEnum); 632 bool isthermal; 633 634 element->FindParam(&isthermal,TransientIsthermalEnum); 639 635 640 element->FindParam(&unconf_scheme,HydrologydcUnconfinedFlagEnum); 636 641 SedTrans_input->GetInputValue(&FullLayer_transmitivity,gauss); … … 657 662 return sediment_transmitivity; 658 663 }/*}}}*/ 659 660 664 void HydrologyDCInefficientAnalysis::GetHydrologyDCInefficientHmax(IssmDouble* ph_max,Element* element, Node* innode){/*{{{*/ 661 665 … … 693 697 } 694 698 /*}}}*/ 695 696 699 IssmDouble HydrologyDCInefficientAnalysis::GetHydrologyKMatrixTransfer(Element* element){/*{{{*/ 697 700 … … 715 718 return transfer; 716 719 }/*}}}*/ 717 718 720 IssmDouble HydrologyDCInefficientAnalysis::GetHydrologyPVectorTransfer(Element* element, Gauss* gauss, Input* epl_head_input){/*{{{*/ 719 721 … … 740 742 return transfer; 741 743 }/*}}}*/ 742 743 744 void HydrologyDCInefficientAnalysis::ElementizeEplMask(FemModel* femmodel){/*{{{*/ 744 745 … … 759 760 } 760 761 }/*}}}*/ 761 762 void HydrologyDCInefficientAnalysis::HydrologyIDSGetMask(Vector<IssmDouble>* vec_mask, Element* element){ 762 void HydrologyDCInefficientAnalysis::HydrologyIDSGetMask(Vector<IssmDouble>* vec_mask, Element* element){/*{{{*/ 763 763 bool active_element; 764 764 int domaintype; … … 801 801 xDelete<IssmDouble>(meltingrate); 802 802 xDelete<IssmDouble>(groundedice); 803 } 803 }/*}}}*/ 804 804 void HydrologyDCInefficientAnalysis::ElementizeIdsMask(FemModel* femmodel){/*{{{*/ 805 805 … … 820 820 } 821 821 }/*}}}*/ 822 823 822 void HydrologyDCInefficientAnalysis::HydrologyIdsGetActive(Vector<IssmDouble>* active_vec, Element* element){/*{{{*/ 824 823 /*Constants*/ -
issm/trunk/src/c/analyses/LevelsetAnalysis.cpp
r23189 r23394 131 131 femmodel->SetCurrentConfiguration(LevelsetAnalysisEnum); 132 132 133 if(VerboseSolution()) _printf0_(" call computational core:\n");133 if(VerboseSolution()) _printf0_(" call computational core:\n"); 134 134 if(stabilization==4){ 135 135 solutionsequence_fct(femmodel); -
issm/trunk/src/c/analyses/MasstransportAnalysis.cpp
r23189 r23394 124 124 bool isoceancoupling; 125 125 bool issmb; 126 int basalforcingsmodel;127 126 128 127 /*Fetch data needed: */ … … 133 132 iomodel->FindConstant(&isoceancoupling,"md.transient.isoceancoupling"); 134 133 iomodel->FindConstant(&issmb,"md.transient.issmb"); 135 iomodel->FindConstant(&basalforcingsmodel,"md.basalforcings.model");136 134 137 135 /*Finite element type*/ … … 158 156 iomodel->FetchDataToInput(elements,"md.mask.groundedice_levelset",MaskGroundediceLevelsetEnum); 159 157 iomodel->FetchDataToInput(elements,"md.basalforcings.groundedice_melting_rate",BasalforcingsGroundediceMeltingRateEnum); 160 if (basalforcingsmodel==SpatialLinearFloatingMeltRateEnum){161 iomodel->FetchDataToInput(elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsDeepwaterMeltingRateEnum);162 iomodel->FetchDataToInput(elements,"md.basalforcings.deepwater_elevation",BasalforcingsDeepwaterElevationEnum);163 iomodel->FetchDataToInput(elements,"md.basalforcings.upperwater_elevation",BasalforcingsUpperwaterElevationEnum);164 }165 158 iomodel->FetchDataToInput(elements,"md.initialization.vx",VxEnum); 166 159 iomodel->FetchDataToInput(elements,"md.initialization.vy",VyEnum); … … 181 174 break; 182 175 case MantlePlumeGeothermalFluxEnum: 176 break; 177 case SpatialLinearFloatingMeltRateEnum: 178 iomodel->FetchDataToInput(elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsDeepwaterMeltingRateEnum); 179 iomodel->FetchDataToInput(elements,"md.basalforcings.deepwater_elevation",BasalforcingsDeepwaterElevationEnum); 180 iomodel->FetchDataToInput(elements,"md.basalforcings.upperwater_elevation",BasalforcingsUpperwaterElevationEnum); 183 181 break; 184 182 case BasalforcingsPicoEnum: … … 631 629 }/*}}}*/ 632 630 void MasstransportAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 633 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 631 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 634 632 * For node i, Bi can be expressed in the actual coordinate system 635 * by: 633 * by: 636 634 * Bi=[ N ] 637 635 * [ N ] … … 659 657 }/*}}}*/ 660 658 void MasstransportAnalysis::GetBprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 661 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 659 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 662 660 * For node i, Bi' can be expressed in the actual coordinate system 663 * by: 661 * by: 664 662 * Bi_prime=[ dN/dx ] 665 663 * [ dN/dy ] -
issm/trunk/src/c/analyses/SmbAnalysis.cpp
r23189 r23394 5 5 #include "../modules/modules.h" 6 6 7 // FIX 8 #include "./shared/io/Print/Print.h" 9 7 10 /*Model processing*/ 8 11 void SmbAnalysis::CreateConstraints(Constraints* constraints,IoModel* iomodel){/*{{{*/ … … 21 24 22 25 int smb_model; 23 bool isdelta18o,ismungsm,isd18opd,issetpddfac,isprecipscaled,istemperaturescaled ;26 bool isdelta18o,ismungsm,isd18opd,issetpddfac,isprecipscaled,istemperaturescaled,isfirnwarming; 24 27 25 28 /*Update elements: */ … … 35 38 /*Figure out smb model: */ 36 39 iomodel->FindConstant(&smb_model,"md.smb.model"); 37 38 40 switch(smb_model){ 39 41 case SMBforcingEnum: … … 88 90 } 89 91 break; 92 case SMBpddSicopolisEnum: 93 iomodel->FetchDataToInput(elements,"md.smb.s0p",SmbS0pEnum); 94 iomodel->FetchDataToInput(elements,"md.smb.s0t",SmbS0tEnum); 95 iomodel->FindConstant(&isfirnwarming,"md.smb.isfirnwarming"); 96 iomodel->FetchDataToInput(elements,"md.smb.smb_corr",SmbSmbCorrEnum); 97 iomodel->FetchDataToInput(elements,"md.smb.precipitation",SmbPrecipitationEnum); 98 iomodel->FetchDataToInput(elements,"md.smb.monthlytemperatures",SmbMonthlytemperaturesEnum); 99 iomodel->FetchDataToInput(elements,"md.smb.precipitation_anomaly",SmbPrecipitationsAnomalyEnum); 100 iomodel->FetchDataToInput(elements,"md.smb.temperature_anomaly",SmbTemperaturesAnomalyEnum); 101 break; 90 102 case SMBd18opddEnum: 91 103 iomodel->FindConstant(&istemperaturescaled,"md.smb.istemperaturescaled"); … … 139 151 iomodel->FetchDataToInput(elements,"md.smb.refreeze",SmbRefreezeEnum,0.); 140 152 break; 153 case SMBgradientscomponentsEnum: 154 iomodel->FetchDataToInput(elements,"md.smb.accualti",SmbAccualtiEnum); 155 iomodel->FetchDataToInput(elements,"md.smb.accugrad",SmbAccugradEnum); 156 iomodel->FetchDataToInput(elements,"md.smb.runoffalti",SmbRunoffaltiEnum); 157 iomodel->FetchDataToInput(elements,"md.smb.runoffgrad",SmbRunoffgradEnum); 158 break; 141 159 default: 142 160 _error_("Surface mass balance model "<<EnumToStringx(smb_model)<<" not supported yet"); … … 148 166 int numoutputs; 149 167 char** requestedoutputs = NULL; 150 bool isdelta18o,ismungsm,isd18opd,issetpddfac,interp ;168 bool isdelta18o,ismungsm,isd18opd,issetpddfac,interp,isfirnwarming; 151 169 int smb_model; 152 170 IssmDouble *temp = NULL; … … 215 233 } 216 234 break; 235 case SMBpddSicopolisEnum: 236 parameters->AddObject(iomodel->CopyConstantObject("md.smb.isfirnwarming",SmbIsfirnwarmingEnum)); 237 break; 217 238 case SMBd18opddEnum: 218 239 parameters->AddObject(iomodel->CopyConstantObject("md.smb.ismungsm",SmbIsmungsmEnum)); … … 246 267 /*Nothing to add to parameters*/ 247 268 break; 269 case SMBgradientscomponentsEnum: 270 parameters->AddObject(iomodel->CopyConstantObject("md.smb.accualti",SmbAccualtiEnum)); 271 parameters->AddObject(iomodel->CopyConstantObject("md.smb.accugrad",SmbAccugradEnum)); 272 parameters->AddObject(iomodel->CopyConstantObject("md.smb.runoffalti",SmbRunoffaltiEnum)); 273 parameters->AddObject(iomodel->CopyConstantObject("md.smb.runoffgrad",SmbRunoffgradEnum)); 274 275 iomodel->FetchData(&temp,&N,&M,"md.smb.accuref"); _assert_(N==2); 276 parameters->AddObject(new TransientParam(SmbAccurefEnum,&temp[0],&temp[M],interp,M)); 277 iomodel->DeleteData(temp,"md.smb.accuref"); 278 279 iomodel->FetchData(&temp,&N,&M,"md.smb.runoffref"); _assert_(N==2); 280 parameters->AddObject(new TransientParam(SmbRunoffrefEnum,&temp[0],&temp[M],interp,M)); 281 iomodel->DeleteData(temp,"md.smb.runoffref"); 282 break; 248 283 default: 249 284 _error_("Surface mass balance model "<<EnumToStringx(smb_model)<<" not supported yet"); … … 280 315 if(VerboseSolution()) _printf0_(" call Delta18oParameterization module\n"); 281 316 Delta18oParameterizationx(femmodel); 282 } 317 } 283 318 if(ismungsm){ 284 319 if(VerboseSolution()) _printf0_(" call MungsmtpParameterization module\n"); 285 320 MungsmtpParameterizationx(femmodel); 286 } 321 } 287 322 if(VerboseSolution()) _printf0_(" call positive degree day module\n"); 288 323 PositiveDegreeDayx(femmodel); 324 break; 325 case SMBpddSicopolisEnum: 326 if(VerboseSolution()) _printf0_(" call SICOPOLIS positive degree day module\n"); 327 PositiveDegreeDaySicopolisx(femmodel); 289 328 break; 290 329 case SMBd18opddEnum: … … 296 335 if(VerboseSolution()) _printf0_(" call positive degree day module\n"); 297 336 PositiveDegreeDayx(femmodel); 298 } 337 } 299 338 break; 300 339 case SMBgradientsEnum: … … 321 360 /*Nothing to be done*/ 322 361 break; 362 case SMBgradientscomponentsEnum: 363 if(VerboseSolution())_printf0_(" call smb gradients components module\n"); 364 SmbGradientsComponentsx(femmodel); 365 break; 323 366 default: 324 367 _error_("Surface mass balance model "<<EnumToStringx(smb_model)<<" not supported yet"); -
issm/trunk/src/c/analyses/StressbalanceAnalysis.cpp
r23189 r23394 766 766 if(isFS){ 767 767 iomodel->FetchDataToInput(elements,"md.initialization.pressure",PressureEnum,0.); 768 iomodel->FetchDataToInput(elements,"md.basalforcings.floatingice_melting_rate",BasalforcingsFloatingiceMeltingRateEnum,0.); 768 769 /*Add basal forcings to compute melt rate*/ 770 int basalforcing_model; 771 iomodel->FindConstant(&basalforcing_model,"md.basalforcings.model"); 772 switch(basalforcing_model){ 773 case FloatingMeltRateEnum: 774 iomodel->FetchDataToInput(elements,"md.basalforcings.floatingice_melting_rate",BasalforcingsFloatingiceMeltingRateEnum); 775 break; 776 case LinearFloatingMeltRateEnum: 777 break; 778 case MismipFloatingMeltRateEnum: 779 break; 780 case MantlePlumeGeothermalFluxEnum: 781 break; 782 case SpatialLinearFloatingMeltRateEnum: 783 iomodel->FetchDataToInput(elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsDeepwaterMeltingRateEnum); 784 iomodel->FetchDataToInput(elements,"md.basalforcings.deepwater_elevation",BasalforcingsDeepwaterElevationEnum); 785 iomodel->FetchDataToInput(elements,"md.basalforcings.upperwater_elevation",BasalforcingsUpperwaterElevationEnum); 786 break; 787 case BasalforcingsPicoEnum: 788 iomodel->FetchDataToInput(elements,"md.basalforcings.basin_id",BasalforcingsPicoBasinIdEnum); 789 break; 790 default: 791 _error_("Basal forcing model "<<EnumToStringx(basalforcing_model)<<" not supported yet"); 792 } 769 793 } 770 794 /*LATH parameters*/ … … 844 868 iomodel->FetchDataToInput(elements,"md.friction.till_friction_angle",FrictionTillFrictionAngleEnum); 845 869 iomodel->FetchDataToInput(elements,"md.friction.sediment_compressibility_coefficient",FrictionSedimentCompressibilityCoefficientEnum); 870 iomodel->FetchDataToInput(elements,"md.hydrology.watercolumn_max",HydrologyWatercolumnMaxEnum); 871 iomodel->FetchDataToInput(elements,"md.initialization.watercolumn",WatercolumnEnum,0.); 846 872 break; 847 873 default: … … 945 971 int solver_type; 946 972 PetscOptionsDetermineSolverType(&solver_type); 973 947 974 if(solver_type==FSSolverEnum) is_schur_cg_solver = true; 948 975 #endif 949 976 977 950 978 if(is_schur_cg_solver) 951 979 solutionsequence_schurcg(femmodel); … … 3270 3298 element->NodalFunctionsPressure(pbasis,gauss); 3271 3299 3272 if(dim==3 ){3300 if(dim==3 || dim==2){ 3273 3301 /*Pressure mass matrix*/ 3274 3302 for(int k=0;k<pnumnodes;k++){ 3275 3303 for(int j=0;j<pnumnodes;j++){ 3276 Ke->values[( 3*vnumnodes+k)*numdof+3*vnumnodes+j] += gauss->weight*Jdet*(pbasis[j]*pbasis[k]);3304 Ke->values[(dim*vnumnodes+k)*numdof+dim*vnumnodes+j] += gauss->weight*Jdet*(pbasis[j]*pbasis[k]); 3277 3305 } 3278 3306 } 3279 } 3280 else{ 3307 }else{ 3281 3308 _error_("STOP"); 3282 3309 } … … 3289 3316 return Ke; 3290 3317 }/*}}}*/ 3318 ElementMatrix* StressbalanceAnalysis::CreateSchurPrecondMatrix(Element* element){/*{{{*/ 3319 3320 /*Intermediaries*/ 3321 int i,dim; 3322 IssmDouble viscosity,FSreconditioning,Jdet; 3323 IssmDouble *xyz_list = NULL; 3324 3325 /*Get problem dimension*/ 3326 element->FindParam(&dim,DomainDimensionEnum); 3327 3328 /*Fetch number of nodes and dof for this finite element*/ 3329 int vnumnodes = element->NumberofNodesVelocity(); 3330 int pnumnodes = element->NumberofNodesPressure(); 3331 int numdof = vnumnodes*dim + pnumnodes; 3332 3333 /*Initialize Element matrix and vectors*/ 3334 ElementMatrix* Ke = element->NewElementMatrix(FSvelocityEnum); 3335 IssmDouble* pbasis = xNew<IssmDouble>(pnumnodes); 3336 3337 /*Retrieve all inputs and parameters*/ 3338 element->GetVerticesCoordinates(&xyz_list); 3339 //element->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum); 3340 Input* vx_input=element->GetInput(VxEnum); _assert_(vx_input); 3341 Input* vy_input=element->GetInput(VyEnum); _assert_(vy_input); 3342 Input* vz_input = NULL; 3343 if(dim==3){vz_input=element->GetInput(VzEnum); _assert_(vz_input);} 3344 3345 3346 /* Start looping on the number of gaussian points: */ 3347 Gauss* gauss = element->NewGauss(5); 3348 for(int ig=gauss->begin();ig<gauss->end();ig++){ 3349 gauss->GaussPoint(ig); 3350 3351 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 3352 element->NodalFunctionsPressure(pbasis,gauss); 3353 element->material->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input); 3354 3355 3356 if(dim==3 || dim==2){ 3357 /*Pressure mass matrix*/ 3358 for(int k=0;k<pnumnodes;k++){ 3359 for(int j=0;j<pnumnodes;j++){ 3360 Ke->values[(dim*vnumnodes+k)*numdof+dim*vnumnodes+j] += gauss->weight*1./viscosity*Jdet*(pbasis[j]*pbasis[k]); 3361 } 3362 } 3363 }else{ 3364 _error_("STOP"); 3365 } 3366 } 3367 3368 /*Clean up and return*/ 3369 delete gauss; 3370 xDelete<IssmDouble>(xyz_list); 3371 xDelete<IssmDouble>(pbasis); 3372 return Ke; 3373 }/*}}}*/ 3374 3291 3375 ElementMatrix* StressbalanceAnalysis::CreateKMatrixFSViscousLA(Element* element){/*{{{*/ 3292 3376 -
issm/trunk/src/c/analyses/StressbalanceAnalysis.h
r23189 r23394 75 75 ElementMatrix* CreateKMatrixFSViscousXTH(Element* element); 76 76 ElementMatrix* CreatePressureMassMatrix(Element* element); 77 ElementMatrix* CreateSchurPrecondMatrix(Element* element); 77 78 ElementVector* CreatePVectorFS(Element* element); 78 79 ElementVector* CreatePVectorFSFriction(Element* element); -
issm/trunk/src/c/analyses/StressbalanceVerticalAnalysis.cpp
r23189 r23394 111 111 } 112 112 iomodel->FetchDataToInput(elements,"md.basalforcings.groundedice_melting_rate",BasalforcingsGroundediceMeltingRateEnum); 113 iomodel->FetchDataToInput(elements,"md.basalforcings.floatingice_melting_rate",BasalforcingsFloatingiceMeltingRateEnum,0.);114 113 //iomodel->FetchDataToInput(elements,"md.smb.mass_balance",SmbMassBalanceEnum); 114 115 116 /*Add basal forcings to compute melt rate*/ 117 int basalforcing_model; 118 iomodel->FindConstant(&basalforcing_model,"md.basalforcings.model"); 119 switch(basalforcing_model){ 120 case FloatingMeltRateEnum: 121 iomodel->FetchDataToInput(elements,"md.basalforcings.floatingice_melting_rate",BasalforcingsFloatingiceMeltingRateEnum); 122 break; 123 case LinearFloatingMeltRateEnum: 124 break; 125 case MismipFloatingMeltRateEnum: 126 break; 127 case MantlePlumeGeothermalFluxEnum: 128 break; 129 case SpatialLinearFloatingMeltRateEnum: 130 iomodel->FetchDataToInput(elements,"md.basalforcings.deepwater_melting_rate",BasalforcingsDeepwaterMeltingRateEnum); 131 iomodel->FetchDataToInput(elements,"md.basalforcings.deepwater_elevation",BasalforcingsDeepwaterElevationEnum); 132 iomodel->FetchDataToInput(elements,"md.basalforcings.upperwater_elevation",BasalforcingsUpperwaterElevationEnum); 133 break; 134 case BasalforcingsPicoEnum: 135 iomodel->FetchDataToInput(elements,"md.basalforcings.basin_id",BasalforcingsPicoBasinIdEnum); 136 break; 137 default: 138 _error_("Basal forcing model "<<EnumToStringx(basalforcing_model)<<" not supported yet"); 139 } 115 140 iomodel->FetchDataToInput(elements,"md.initialization.vx",VxEnum,0.); 116 141 iomodel->FetchDataToInput(elements,"md.initialization.vy",VyEnum,0.); -
issm/trunk/src/c/analyses/ThermalAnalysis.cpp
r23189 r23394 33 33 int smb_model; 34 34 iomodel->FindConstant(&smb_model,"md.smb.model"); 35 if(smb_model==SMBpddEnum) isdynamic=true; 36 if(smb_model==SMBd18opddEnum) isdynamic=true; 35 if(smb_model==SMBpddEnum) isdynamic=true; 36 if(smb_model==SMBd18opddEnum) isdynamic=true; 37 if(smb_model==SMBpddSicopolisEnum) isdynamic=true; 37 38 } 38 39 else{ -
issm/trunk/src/c/classes/Elements/Element.cpp
r23189 r23394 653 653 xDelete<IssmDouble>(tmp); 654 654 655 } 656 /*}}}*/ 657 void Element::SmbGradCompParameterization(void){/*{{{*/ 658 659 /*Are we on the base? If not, return*/ 660 if(!IsOnBase()) return; 661 int numvertices = this->GetNumberOfVertices(); 662 663 int i; 664 IssmDouble accuref, runoffref; //reference values at given altitude 665 IssmDouble accualti, runoffalti; //reference altitudes 666 IssmDouble accugrad, runoffgrad; //gradients from reference altitude 667 IssmDouble rho_water, rho_ice; 668 IssmDouble time; 669 670 IssmDouble* smb = xNew<IssmDouble>(numvertices); 671 IssmDouble* surf = xNew<IssmDouble>(numvertices); 672 IssmDouble* accu = xNew<IssmDouble>(numvertices); 673 IssmDouble* runoff = xNew<IssmDouble>(numvertices); 674 675 /*Get material parameters :*/ 676 rho_water=this->matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 677 rho_ice=this->matpar->GetMaterialParameter(MaterialsRhoIceEnum); 678 679 /*Recover parameters*/ 680 parameters->FindParam(&time,TimeEnum); 681 parameters->FindParam(&accualti,SmbAccualtiEnum); 682 parameters->FindParam(&accugrad,SmbAccugradEnum); 683 parameters->FindParam(&runoffalti,SmbRunoffaltiEnum); 684 parameters->FindParam(&runoffgrad,SmbRunoffgradEnum); 685 686 /*Recover reference values at current time*/ 687 parameters->FindParam(&accuref,SmbAccurefEnum,time); 688 parameters->FindParam(&runoffref,SmbRunoffrefEnum,time); 689 690 /*Recover surface elevation*/ 691 GetInputListOnVertices(&surf[0],SurfaceEnum); 692 693 /*Compute the temperature and precipitation*/ 694 for(int iv=0;iv<numvertices;iv++){ 695 accu[iv]=max(0.,(accuref+(surf[iv]-accualti)*accugrad)); 696 runoff[iv]=max(0.,(runoffref+(surf[iv]-runoffalti)*runoffgrad)); 697 smb[iv]=(accu[iv]-runoff[iv])*rho_ice/rho_water; 698 } 699 switch(this->ObjectEnum()){ 700 case TriaEnum: 701 this->inputs->AddInput(new TriaInput(SmbMassBalanceEnum,&smb[0],P1Enum)); 702 this->inputs->AddInput(new TriaInput(SmbRunoffEnum,&runoff[0],P1Enum)); 703 break; 704 case PentaEnum: 705 this->inputs->AddInput(new PentaInput(SmbMassBalanceEnum,&smb[0],P1Enum)); 706 this->inputs->AddInput(new PentaInput(SmbRunoffEnum,&runoff[0],P1Enum)); 707 this->InputExtrude(SmbMassBalanceEnum,-1); 708 this->InputExtrude(SmbRunoffEnum,-1); 709 break; 710 case TetraEnum: 711 this->inputs->AddInput(new TetraInput(SmbMassBalanceEnum,&smb[0],P1Enum)); 712 this->inputs->AddInput(new TetraInput(SmbRunoffEnum,&runoff[0],P1Enum)); 713 this->InputExtrude(SmbMassBalanceEnum,-1); 714 this->InputExtrude(SmbRunoffEnum,-1); 715 break; 716 default: _error_("Not implemented yet"); 717 } 718 /* this->AddInput(SmbMassBalanceEnum,smb,P1Enum); */ 719 /* this->AddInput(SmbRunoffEnum,runoff,P1Enum); */ 720 /*clean-up*/ 721 xDelete<IssmDouble>(surf); 722 xDelete<IssmDouble>(accu); 723 xDelete<IssmDouble>(runoff); 724 xDelete<IssmDouble>(smb); 655 725 } 656 726 /*}}}*/ … … 2561 2631 } 2562 2632 /*}}}*/ 2633 void Element::PositiveDegreeDaySicopolis(bool isfirnwarming){/*{{{*/ 2634 2635 /* General FIXMEs: get Tmelting point, pddicefactor, pddsnowfactor, sigma from parameters/user input */ 2636 2637 int numvertices = this->GetNumberOfVertices(); 2638 2639 int i; 2640 IssmDouble* smb=xNew<IssmDouble>(numvertices); // surface mass balance 2641 IssmDouble* melt=xNew<IssmDouble>(numvertices); // melting comp. of surface mass balance 2642 IssmDouble* accu=xNew<IssmDouble>(numvertices); // accuumulation comp. of surface mass balance 2643 IssmDouble* melt_star=xNew<IssmDouble>(numvertices); 2644 IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices); 2645 IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices); 2646 IssmDouble* yearlytemperatures=xNew<IssmDouble>(numvertices); memset(yearlytemperatures, 0., numvertices*sizeof(IssmDouble)); 2647 IssmDouble* s=xNew<IssmDouble>(numvertices); // actual surface height 2648 IssmDouble* s0p=xNew<IssmDouble>(numvertices); // reference elevation for precip. 2649 IssmDouble* s0t=xNew<IssmDouble>(numvertices); // reference elevation for temperature 2650 IssmDouble* smbcorr=xNew<IssmDouble>(numvertices); // surface mass balance correction; will be added after pdd call 2651 IssmDouble* p_ampl=xNew<IssmDouble>(numvertices); // precip anomaly 2652 IssmDouble* t_ampl=xNew<IssmDouble>(numvertices); // remperature anomaly 2653 IssmDouble rho_water,rho_ice,desfac,rlaps; 2654 IssmDouble inv_twelve=1./12.; //factor for monthly average 2655 IssmDouble time,yts,time_yr; 2656 2657 /*Get material parameters :*/ 2658 rho_water=this->matpar->GetMaterialParameter(MaterialsRhoSeawaterEnum); 2659 rho_ice=this->matpar->GetMaterialParameter(MaterialsRhoIceEnum); 2660 2661 /*Get parameters for height corrections*/ 2662 desfac=this->matpar->GetMaterialParameter(SmbDesfacEnum); 2663 rlaps=this->matpar->GetMaterialParameter(SmbRlapsEnum); 2664 2665 /*Recover monthly temperatures and precipitation*/ 2666 Input* input=this->inputs->GetInput(SmbMonthlytemperaturesEnum); _assert_(input); 2667 Input* input2=this->inputs->GetInput(SmbPrecipitationEnum); _assert_(input2); 2668 /*Recover smb correction term */ 2669 Input* input3=this->inputs->GetInput(SmbSmbCorrEnum); _assert_(input3); 2670 2671 /* Get time */ 2672 this->parameters->FindParam(&time,TimeEnum); 2673 this->parameters->FindParam(&yts,ConstantsYtsEnum); 2674 time_yr=floor(time/yts)*yts; 2675 2676 /* Set parameters for finrnwarming */ 2677 IssmDouble MU_0 = 9.7155; //Firn-warming correction, in (d*deg C)/(mm WE) 2678 IssmDouble mu = MU_0*(1000.0*86400.0)*(rho_ice/rho_water); // (d*deg C)/(mm WE) --> (s*deg C)/(m IE) 2679 2680 /*loop over vertices: */ 2681 Gauss* gauss=this->NewGauss(); 2682 for(int month=0;month<12;month++){ 2683 for(int iv=0;iv<numvertices;iv++){ 2684 gauss->GaussVertex(iv); 2685 input->GetInputValue(&monthlytemperatures[iv*12+month],gauss,(month+1)/12.*yts); 2686 monthlytemperatures[iv*12+month]=monthlytemperatures[iv*12+month]-273.15; // conversion from Kelvin to celcius for PDD module 2687 input2->GetInputValue(&monthlyprec[iv*12+month],gauss,(month+1)/12.*yts); 2688 monthlyprec[iv*12+month]=monthlyprec[iv*12+month]*yts; 2689 } 2690 } 2691 2692 /*Recover info at the vertices: */ 2693 GetInputListOnVertices(&s[0],SurfaceEnum); 2694 GetInputListOnVertices(&s0p[0],SmbS0pEnum); 2695 GetInputListOnVertices(&s0t[0],SmbS0tEnum); 2696 GetInputListOnVertices(&smbcorr[0],SmbSmbCorrEnum); 2697 GetInputListOnVertices(&t_ampl[0],SmbTemperaturesAnomalyEnum); 2698 GetInputListOnVertices(&p_ampl[0],SmbPrecipitationsAnomalyEnum); 2699 2700 /*measure the surface mass balance*/ 2701 for (int iv = 0; iv<numvertices; iv++){ 2702 smb[iv]=PddSurfaceMassBalanceSicopolis(&monthlytemperatures[iv*12], &monthlyprec[iv*12], 2703 &melt[iv], &accu[iv], &melt_star[iv], &t_ampl[iv], &p_ampl[iv], yts, s[iv], 2704 desfac, s0t[iv], s0p[iv],rlaps,rho_water,rho_ice); 2705 2706 /* make correction */ 2707 smb[iv] = smb[iv]+smbcorr[iv]; 2708 /*Get yearlytemperatures */ 2709 for(int month=0;month<12;month++) yearlytemperatures[iv]=yearlytemperatures[iv]+((monthlytemperatures[iv*12+month]+273.15)+t_ampl[iv])*inv_twelve; // Has to be in Kelvin 2710 2711 if(isfirnwarming){ 2712 if(melt_star[iv]>=melt[iv]){ 2713 yearlytemperatures[iv]= yearlytemperatures[iv]+mu*(melt_star[iv]-melt[iv]); 2714 } 2715 else{ 2716 yearlytemperatures[iv]= yearlytemperatures[iv]; 2717 } 2718 } 2719 if (yearlytemperatures[iv]>273.15) yearlytemperatures[iv]=273.15; 2720 } 2721 2722 switch(this->ObjectEnum()){ 2723 case TriaEnum: 2724 // this->inputs->AddInput(new TriaInput(TemperatureEnum,&yearlytemperatures[0],P1Enum)); 2725 this->inputs->AddInput(new TriaInput(TemperaturePDDEnum,&yearlytemperatures[0],P1Enum)); 2726 this->inputs->AddInput(new TriaInput(SmbMassBalanceEnum,&smb[0],P1Enum)); 2727 this->inputs->AddInput(new TriaInput(SmbAccumulationEnum,&accu[0],P1Enum)); 2728 this->inputs->AddInput(new TriaInput(SmbMeltEnum,&melt[0],P1Enum)); 2729 break; 2730 case PentaEnum: 2731 bool isthermal; 2732 this->parameters->FindParam(&isthermal,TransientIsthermalEnum); 2733 if(isthermal){ 2734 bool isenthalpy; 2735 this->parameters->FindParam(&isenthalpy,ThermalIsenthalpyEnum); 2736 if(IsOnSurface()){ 2737 /*Here, we want to change the BC of the thermal model, keep 2738 * the temperatures as they are for the base of the penta and 2739 * use yearlytemperatures for the top*/ 2740 GetInputListOnVertices(&s[0],TemperatureEnum); 2741 yearlytemperatures[0] = s[0]; 2742 yearlytemperatures[1] = s[1]; 2743 yearlytemperatures[2] = s[2]; 2744 this->inputs->AddInput(new PentaInput(TemperatureEnum,&yearlytemperatures[0],P1Enum)); 2745 if(isenthalpy){ 2746 /*Convert that to enthalpy for the enthalpy model*/ 2747 IssmDouble enthalpy[6]; 2748 GetInputListOnVertices(&enthalpy[0],EnthalpyEnum); 2749 ThermalToEnthalpy(&enthalpy[3],yearlytemperatures[3],0.,0.); 2750 ThermalToEnthalpy(&enthalpy[4],yearlytemperatures[4],0.,0.); 2751 ThermalToEnthalpy(&enthalpy[5],yearlytemperatures[5],0.,0.); 2752 this->inputs->AddInput(new PentaInput(EnthalpyEnum,&enthalpy[0],P1Enum)); 2753 } 2754 } 2755 } 2756 this->inputs->AddInput(new PentaInput(SmbMassBalanceEnum,&smb[0],P1Enum)); 2757 this->inputs->AddInput(new PentaInput(TemperaturePDDEnum,&yearlytemperatures[0],P1Enum)); 2758 this->inputs->AddInput(new PentaInput(SmbAccumulationEnum,&accu[0],P1Enum)); 2759 this->inputs->AddInput(new PentaInput(SmbMeltEnum,&melt[0],P1Enum)); 2760 this->InputExtrude(TemperaturePDDEnum,-1); 2761 this->InputExtrude(SmbMassBalanceEnum,-1); 2762 this->InputExtrude(SmbAccumulationEnum,-1); 2763 this->InputExtrude(SmbMeltEnum,-1); 2764 break; 2765 case TetraEnum: 2766 if(IsOnSurface()){ 2767 GetInputListOnVertices(&s[0],TemperatureEnum); 2768 yearlytemperatures[0] = s[0]; 2769 yearlytemperatures[1] = s[1]; 2770 yearlytemperatures[2] = s[2]; 2771 this->inputs->AddInput(new TetraInput(TemperatureEnum,&yearlytemperatures[0],P1Enum)); 2772 } 2773 this->inputs->AddInput(new TetraInput(SmbMassBalanceEnum,&smb[0],P1Enum)); 2774 this->inputs->AddInput(new TetraInput(TemperaturePDDEnum,&yearlytemperatures[0],P1Enum)); 2775 this->InputExtrude(TemperaturePDDEnum,-1); 2776 this->InputExtrude(SmbMassBalanceEnum,-1); 2777 break; 2778 default: _error_("Not implemented yet"); 2779 } 2780 2781 /*clean-up*/ 2782 delete gauss; 2783 xDelete<IssmDouble>(monthlytemperatures); 2784 xDelete<IssmDouble>(monthlyprec); 2785 xDelete<IssmDouble>(smb); 2786 xDelete<IssmDouble>(melt); 2787 xDelete<IssmDouble>(accu); 2788 xDelete<IssmDouble>(yearlytemperatures); 2789 xDelete<IssmDouble>(s); 2790 xDelete<IssmDouble>(s0t); 2791 xDelete<IssmDouble>(s0p); 2792 xDelete<IssmDouble>(t_ampl); 2793 xDelete<IssmDouble>(p_ampl); 2794 xDelete<IssmDouble>(smbcorr); 2795 xDelete<IssmDouble>(melt_star); 2796 } 2797 /*}}}*/ 2563 2798 IssmDouble Element::PureIceEnthalpy(IssmDouble pressure){/*{{{*/ 2564 2799 return this->matpar->PureIceEnthalpy(pressure); … … 2568 2803 /*Some intputs need to be computed, even if they are already in inputs, they might not be up to date!*/ 2569 2804 switch(output_enum){ 2570 2571 2805 case ViscousHeatingEnum: this->ViscousHeatingCreateInput(); break; 2806 case StressMaxPrincipalEnum: this->StressMaxPrincipalCreateInput(); break; 2572 2807 case StressTensorxxEnum: 2573 2808 case StressTensorxyEnum: … … 2582 2817 case StrainRateyzEnum: 2583 2818 case StrainRatezzEnum: 2584 2819 case StrainRateeffectiveEnum: this->ComputeStrainRate(); break; 2585 2820 case DeviatoricStressxxEnum: 2586 2821 case DeviatoricStressxyEnum: … … 3133 3368 } 3134 3369 3135 #ifndef _HAVE_ADOLC_ //we want to avoid the round operation at all cost. Not differentiable. 3370 #if defined(_HAVE_AD_) 3371 /*we want to avoid the round operation at all cost. Not differentiable.*/ 3372 _error_("not implemented yet"); 3373 #else 3136 3374 dMass = sumMass + sumR + sumW - sumP - sumEC - initMass - sumMassAdd; 3137 3375 dMass = round(dMass * 100.0)/100.0; -
issm/trunk/src/c/classes/Elements/Element.h
r23189 r23394 1 1 /*!\file: Element.h 2 2 * \brief abstract class for Element object 3 * This class is a place holder for the Tria and the Penta elements. 3 * This class is a place holder for the Tria and the Penta elements. 4 4 * It is derived from Element, so DataSets can contain them. 5 */ 5 */ 6 6 7 7 #ifndef _ELEMENT_H_ … … 50 50 int element_type; 51 51 52 public: 52 public: 53 53 /*Constructors/Destructores*/ 54 54 Element(); … … 68 68 void Delta18oParameterization(void); 69 69 void Delta18opdParameterization(void); 70 void SmbGradCompParameterization(void); 70 71 IssmDouble Divergence(void); 71 72 void dViscositydBFS(IssmDouble* pdmudB,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input); … … 130 131 void InputUpdateFromConstant(int constant, int name); 131 132 void InputUpdateFromConstant(bool constant, int name); 132 bool IsFloating(); 133 bool IsFloating(); 133 134 bool IsIceInElement(); 134 135 bool IsLandInElement(); 135 136 bool IsWaterInElement(); 136 void LinearFloatingiceMeltingRate(); 137 void SpatialLinearFloatingiceMeltingRate(); 138 void MantlePlumeGeothermalFlux(); 137 void LinearFloatingiceMeltingRate(); 138 void SpatialLinearFloatingiceMeltingRate(); 139 void MantlePlumeGeothermalFlux(); 139 140 void MarshallElement(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction,int numanalyses); 140 141 void MigrateGroundingLine(IssmDouble* sheet_ungrounding); 141 void MismipFloatingiceMeltingRate(); 142 void MismipFloatingiceMeltingRate(); 142 143 void MungsmtpParameterization(void); 143 144 ElementMatrix* NewElementMatrix(int approximation_enum=NoneApproximationEnum); … … 145 146 ElementVector* NewElementVector(int approximation_enum=NoneApproximationEnum); 146 147 void PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm,bool ismungsm,bool issetpddfac); 148 void PositiveDegreeDaySicopolis(bool isfirnwarming); 147 149 IssmDouble PureIceEnthalpy(IssmDouble pressure); 148 150 void ResultInterpolation(int* pinterpolation,int*nodesperelement,int* parray_size, int output_enum); … … 240 242 virtual bool IsFaceOnBoundary(void)=0; 241 243 virtual bool IsIcefront(void)=0; 242 virtual bool IsNodeOnShelfFromFlags(IssmDouble* flags)=0; 244 virtual bool IsNodeOnShelfFromFlags(IssmDouble* flags)=0; 243 245 virtual bool IsOnBase()=0; 244 246 virtual bool IsOnSurface()=0; … … 330 332 virtual IssmDouble OceanAverage(IssmDouble* Sg)=0; 331 333 virtual IssmDouble OceanArea(void)=0; 332 virtual void SealevelriseMomentOfInertia(IssmDouble* dI_list,IssmDouble* Sg_old,IssmDouble eartharea)=0; 334 virtual void SealevelriseMomentOfInertia(IssmDouble* dI_list,IssmDouble* Sg_old,IssmDouble eartharea)=0; 333 335 virtual void SealevelriseEustatic(Vector<IssmDouble>* pSgi,IssmDouble* peustatic,IssmDouble* latitude,IssmDouble* longitude,IssmDouble* radius,IssmDouble oceanarea,IssmDouble eartharea)=0; 334 336 virtual void SealevelriseNonEustatic(Vector<IssmDouble>* pSgo,IssmDouble* Sg_old,IssmDouble* latitude,IssmDouble* longitude,IssmDouble* radius,IssmDouble eartharea)=0; -
issm/trunk/src/c/classes/ExternalResults/GenericExternalResult.h
r23189 r23394 622 622 623 623 /*Specific instantiations for IssmDouble*: */ 624 #if defined(_HAVE_AD OLC_) && !defined(_WRAPPERS_) //We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization.624 #if defined(_HAVE_AD_) && !defined(_WRAPPERS_) //We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization. 625 625 template <> inline GenericExternalResult<IssmDouble*>::~GenericExternalResult(){ /*{{{*/ 626 626 xDelete<char>(result_name); … … 709 709 return new GenericExternalResult<Vector<IssmPDouble>*>(this->id,StringToEnumx(this->result_name),this->value,this->step,this->time); 710 710 } /*}}}*/ 711 #if defined(_HAVE_AD OLC_) && !defined(_WRAPPERS_) //We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization.711 #if defined(_HAVE_AD_) && !defined(_WRAPPERS_) //We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization. 712 712 template <> inline void GenericExternalResult<Vector<IssmPDouble>*>::WriteData(FILE* fid,bool io_gather){ /*{{{*/ 713 713 -
issm/trunk/src/c/classes/FemModel.cpp
r23189 r23394 17 17 #include "../shared/Enum/Enum.h" 18 18 #include "../analyses/analyses.h" 19 20 #if _HAVE_CODIPACK_ 21 #include <sstream> // for output of the CoDiPack tape 22 extern CoDi_global codi_global; 23 #endif 19 24 20 25 /*module includes: {{{*/ … … 84 89 this->parameters->FindParam(&amr_frequency,TransientAmrFrequencyEnum); 85 90 this->parameters->FindParam(&amr_frequency,TransientAmrFrequencyEnum); 86 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD OLC_)91 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_) 87 92 this->amr = NULL; 88 93 #endif 89 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD OLC_)94 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_) 90 95 this->amrbamg = NULL; 91 96 #endif 92 #if !defined(_HAVE_AD OLC_)97 #if !defined(_HAVE_AD_) 93 98 if(amr_frequency && solution_type==TransientSolutionEnum){ 94 99 /*Verifications. AMR supports SSA, P1 and horizontal 2D domain*/ … … 147 152 profiler->Stop(MPROCESSOR); 148 153 149 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD OLC_)154 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_) 150 155 this->amr = NULL; 151 156 #endif 152 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD OLC_)157 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_) 153 158 this->amrbamg = NULL; 154 159 #endif … … 184 189 if(results)delete results; 185 190 186 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD OLC_)191 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_) 187 192 if(amr)delete amr; 188 193 #endif 189 194 190 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD OLC_)195 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_) 191 196 if(amrbamg)delete amrbamg; 192 197 #endif … … 254 259 /*Before we delete the profiler, report statistics for this run: */ 255 260 profiler->Stop(TOTAL); //final tagging 261 256 262 _printf0_("\n"); 257 _printf0_(" "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<profiler->TotalTime(MPROCESSOR) << "\n"); 258 _printf0_(" "<<setw(40)<<left<<"Core solution elapsed time:"<<profiler->TotalTime(CORE) << "\n"); 259 _printf0_(" "<<setw(40)<<left<<"Solver elapsed time:"<<profiler->TotalTime(SOLVER) << "\n"); 263 _printf0_(" "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<setw(7)<<profiler->TotalTime(MPROCESSOR) << "\n"); 264 /*Total times*/ 265 _printf0_(" "<<setw(40)<<left<<"Total Core solution elapsed time:"<<setw(7)<<profiler->TotalTime(CORE) << "\n"); 266 267 /*Linear solver only*/ 268 _printf0_(" "<<setw(40)<<left<<"Linear solver elapsed time:"<<setw(7)<<profiler->TotalTime(SOLVER) << " ("<<setprecision(2)<<profiler->TotalTime(SOLVER)/profiler->TotalTime(CORE)*100.<<"%)\n"); 260 269 _printf0_("\n"); 261 270 _printf0_(" Total elapsed time: " … … 319 328 320 329 /*AMR, no copy for now*/ 321 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD OLC_)330 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_) 322 331 this->amr = NULL; 323 332 #endif 324 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD OLC_)333 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_) 325 334 this->amrbamg = NULL; 326 335 #endif … … 853 862 solution_memory=profiler->Memory(CORE); 854 863 855 _printf0_("Core solution elapsed time : " << solution_time << " Seconds\n"); 856 _printf0_("Core solution number of flops : " << solution_flops << " Flops\n"); 857 _printf0_("Core solution memory used : " << solution_memory << " Bytes\n"); 858 864 _printf0_("\nCore solution profiling\n"); 865 _printf0_(" elapsed time : " << solution_time << " Seconds\n"); 866 _printf0_(" number of flops : " << solution_flops << " Flops\n"); 867 _printf0_(" memory used : " << solution_memory << " Bytes\n"); 868 869 /*Individual cores*/ 870 _printf0_("Individual core profiling\n"); 871 if(profiler->Used(THERMALCORE)) _printf0_(" "<<setw(40)<<left<<"Thermal core elapsed time:"<<setw(7)<<setprecision(6)<<profiler->TotalTime(THERMALCORE) << " sec\n"); 872 if(profiler->Used(HYDROLOGYCORE)) _printf0_(" "<<setw(40)<<left<<"Hydrology core elapsed time:"<<setw(7)<<setprecision(6)<<profiler->TotalTime(HYDROLOGYCORE) << " sec\n"); 873 if(profiler->Used(STRESSBALANCECORE)) _printf0_(" "<<setw(40)<<left<<"Stress balance core elapsed time:"<<setw(7)<<setprecision(6)<<profiler->TotalTime(STRESSBALANCECORE) << " sec\n"); 874 if(profiler->Used(DAMAGECORE)) _printf0_(" "<<setw(40)<<left<<"Damage core elapsed time:"<<setw(7)<<setprecision(6)<<profiler->TotalTime(DAMAGECORE) << " sec\n"); 875 if(profiler->Used(MOVINGFRONTCORE)) _printf0_(" "<<setw(40)<<left<<"Moving front core elapsed time:"<<setw(7)<<setprecision(6)<<profiler->TotalTime(MOVINGFRONTCORE) << " sec\n"); 876 if(profiler->Used(MASSTRANSPORTCORE)) _printf0_(" "<<setw(40)<<left<<"Mass transport core elapsed time:"<<setw(7)<<setprecision(6)<<profiler->TotalTime(MASSTRANSPORTCORE) << " sec\n"); 877 if(profiler->Used(SMBCORE)) _printf0_(" "<<setw(40)<<left<<"SMB core elapsed time:"<<setw(7)<<setprecision(6)<<profiler->TotalTime(SMBCORE) << " sec\n"); 878 if(profiler->Used(GROUNDINGLINECORE)) _printf0_(" "<<setw(40)<<left<<"Groundingline migration core elapsed time:"<<setw(7)<<setprecision(6)<<profiler->TotalTime(GROUNDINGLINECORE) << " sec\n"); 879 if(profiler->Used(GIACORE)) _printf0_(" "<<setw(40)<<left<<"GIA core elapsed time:"<<setw(7)<<setprecision(6)<<profiler->TotalTime(GIACORE) << " sec\n"); 880 if(profiler->Used(ESACORE)) _printf0_(" "<<setw(40)<<left<<"ESA core elapsed time:"<<setw(7)<<setprecision(6)<<profiler->TotalTime(ESACORE) << " sec\n"); 881 if(profiler->Used(SLRCORE)) _printf0_(" "<<setw(40)<<left<<"SLR core elapsed time:"<<setw(7)<<setprecision(6)<<profiler->TotalTime(SLRCORE) << " sec\n"); 882 859 883 /*Add to results: */ 860 884 results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingSolutionTimeEnum, solution_time)); … … 862 886 results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentFlopsEnum, solution_flops)); 863 887 864 #ifdef _HAVE_ADOLC_ 865 solution_time=profiler->TotalTime(ADCORE); 866 solution_flops=profiler->TotalFlops(ADCORE); 867 solution_memory=profiler->Memory(ADCORE); 868 869 _printf0_("AD Solution elapsed time : " << solution_time << " Seconds\n"); 870 _printf0_("AD Solution number of flops : " << solution_flops << " Flops\n"); 871 _printf0_("AD Solution memory used : " << solution_memory << " Bytes\n"); 888 #ifdef _HAVE_AD_ 889 solution_time = profiler->TotalTime(ADCORE); 890 solution_flops = profiler->TotalFlops(ADCORE); 891 solution_memory = profiler->Memory(ADCORE); 892 893 _printf0_("AD profiling\n"); 894 _printf0_(" elapsed time : " << solution_time << " Seconds\n"); 895 _printf0_(" number of flops : " << solution_flops << " Flops\n"); 896 _printf0_(" memory used : " << solution_memory << " Bytes\n"); 872 897 #endif 898 _printf0_("\n"); 873 899 874 900 } … … 1824 1850 1825 1851 if(isautodiff){ 1826 #ifdef _HAVE_AD OLC_1852 #ifdef _HAVE_AD_ 1827 1853 parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 1828 1854 parameters->FindParam(&dependent_objects,AutodiffDependentObjectsEnum); 1829 1855 if(num_dependents){ 1830 1856 dependents=xNew<IssmPDouble>(num_dependents); 1857 1858 #if defined(_HAVE_CODIPACK_) 1859 auto& tape_codi = IssmDouble::getGlobalTape(); 1860 #endif 1831 1861 1832 1862 /*Go through our dependent variables, and compute the response:*/ … … 1835 1865 dep->Responsex(&output_value,this); 1836 1866 if (my_rank==0) { 1837 output_value>>=dependents[i]; 1867 #if defined(_HAVE_CODIPACK_) 1868 tape_codi.registerOutput(output_value); 1869 dependents[i] = output_value.getValue(); 1870 codi_global.output_indices.push_back(output_value.getGradientData()); 1871 #else 1872 output_value>>=dependents[i]; 1873 #endif 1838 1874 } 1839 1875 } … … 2509 2545 2510 2546 /*AMR*/ 2511 #if !defined(_HAVE_ADOLC_)2547 #ifndef _HAVE_AD_ 2512 2548 void FemModel::ReMesh(void){/*{{{*/ 2513 2549 … … 2528 2564 this->parameters->FindParam(&amrtype,AmrTypeEnum); 2529 2565 switch(amrtype){ 2530 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD OLC_)2566 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_) 2531 2567 case AmrNeopzEnum: this->ReMeshNeopz(&newnumberofvertices,&newnumberofelements,&newx,&newy,&newz,&newelementslist); break; 2532 2568 #endif 2533 2569 2534 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD OLC_)2570 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_) 2535 2571 case AmrBamgEnum: this->ReMeshBamg(&newnumberofvertices,&newnumberofelements,&newx,&newy,&newz,&newelementslist); break; 2536 2572 #endif … … 4884 4920 #endif 4885 4921 4886 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD OLC_)4922 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_) 4887 4923 void FemModel::ReMeshBamg(int* pnewnumberofvertices,int* pnewnumberofelements,IssmDouble** pnewx,IssmDouble** pnewy,IssmDouble** pnewz,int** pnewelementslist){/*{{{*/ 4888 4924 … … 5210 5246 #endif 5211 5247 5212 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD OLC_)5248 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_) 5213 5249 void FemModel::ReMeshNeopz(int* pnewnumberofvertices,int* pnewnumberofelements,IssmDouble** pnewx,IssmDouble** pnewy,IssmDouble** pnewz,int** pnewelementslist){/*{{{*/ 5214 5250 -
issm/trunk/src/c/classes/FemModel.h
r23189 r23394 20 20 class Profiler; 21 21 class Elements; 22 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD OLC_)22 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_) 23 23 #include "./AdaptiveMeshRefinement.h" 24 24 #endif 25 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD OLC_)25 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_) 26 26 #include "./AmrBamg.h" 27 27 #endif … … 51 51 52 52 //FIXME: do we want only one class and have virtual functions? or keep 2 classes, at least rename AdaptiveMeshRefinement -> AmrNeopz 53 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD OLC_)53 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_) 54 54 AdaptiveMeshRefinement *amr; //adaptive mesh refinement object. It keeps coarse mesh and execute refinement process 55 55 #endif 56 56 57 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD OLC_)57 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_) 58 58 AmrBamg *amrbamg; //adaptive mesh refinement object. It keeps coarse mesh and execute refinement process 59 59 #endif … … 164 164 165 165 /*AMR*/ 166 #if !defined(_HAVE_AD OLC_)166 #if !defined(_HAVE_AD_) 167 167 void ReMesh(void); 168 168 void BedrockFromMismipPlus(void); … … 191 191 #endif 192 192 193 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD OLC_)193 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_) 194 194 void ReMeshBamg(int* pnewnumberofvertices,int* pnewnumberofelements,IssmDouble** pnewx,IssmDouble** pnewy,IssmDouble** pnewz,int** pnewelementslist); 195 195 void InitializeAdaptiveRefinementBamg(void); … … 199 199 #endif 200 200 201 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD OLC_)201 #if defined(_HAVE_NEOPZ_) && !defined(_HAVE_AD_) 202 202 void ReMeshNeopz(int* pnewnumberofvertices,int* pnewnumberofelements,IssmDouble** pnewx,IssmDouble** pnewy,IssmDouble** pnewz,int** pnewelementslist); 203 203 void InitializeAdaptiveRefinementNeopz(void); -
issm/trunk/src/c/classes/IoModel.cpp
r23189 r23394 27 27 #include "../shared/io/io.h" 28 28 #include "../shared/shared.h" 29 30 #ifdef _HAVE_CODIPACK_ 31 extern CoDi_global codi_global; 32 #include <sstream> // for output of the CoDiPack tape 33 #endif 29 34 30 35 /*IoConstant class and methods*/ … … 431 436 if(trace || (autodiff && !iscontrol)){ 432 437 433 #ifdef _HAVE_ADOLC_ 438 #ifdef _HAVE_AD_ 439 // FIXME codi here we should be able to execute codi version as normal 434 440 this->FetchData(&num_independent_objects,"md.autodiff.num_independent_objects"); 435 441 if(num_independent_objects){ … … 460 466 #else 461 467 /*if we asked for AD computations, we have a problem!: */ 462 _error_("Cannot carry out AD mode computations without support of ADOLC compiled in!");468 _error_("Cannot carry out AD mode computations without support of ADOLC or CoDiPack compiled in!"); 463 469 #endif 464 470 } … … 1702 1708 if(X) Xcount=*pXcount; 1703 1709 1704 #ifdef _HAVE_AD OLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents:1710 #ifdef _HAVE_AD_ //cannot come here unless you are running AD mode, from DeclaredIndependents: 1705 1711 1706 1712 /*output: */ … … 1719 1725 /*Now, before we even broadcast this to other nodes, declare the scalar as an independent variable!. If we 1720 1726 *have been supplied an X vector, use it instead of what we just read: */ 1721 if(X){ 1722 scalar<<=X[Xcount]; 1723 } 1724 else{ 1725 scalar<<=pscalar; 1726 } 1727 #if defined(_HAVE_CODIPACK_) 1728 // FIXME codi here we just assign instead of using "operator <<=" 1729 if(X){ 1730 scalar=X[Xcount]; 1731 } else { 1732 scalar=pscalar; 1733 } 1734 auto& tape_codi = IssmDouble::getGlobalTape(); 1735 tape_codi.registerInput(scalar); 1736 codi_global.input_indices.push_back(scalar.getGradientData()); 1737 #else 1738 if(X){ 1739 scalar<<=X[Xcount]; 1740 } 1741 else{ 1742 scalar<<=pscalar; 1743 } 1744 #endif 1727 1745 } 1728 1746 … … 1744 1762 if(X) Xcount=*pXcount; 1745 1763 1746 #ifdef _HAVE_AD OLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents:1764 #ifdef _HAVE_AD_ //cannot come here unless you are running AD mode, from DeclaredIndependents: 1747 1765 1748 1766 /*Intermediaries*/ … … 1785 1803 /*Now, before we even broadcast this to other nodes, declare the whole matrix as a independent variable! 1786 1804 If we have been supplied an X vector, use it instead of what we just read: */ 1787 if(X){ 1788 for(int i=0;i<M*N;i++) matrix[i]<<=X[Xcount+i]; /*<<= ADOLC overloaded operator to declare independent*/ 1789 } 1790 else{ 1791 for(int i=0;i<M*N;i++) matrix[i]<<=buffer[i]; 1792 } 1805 #if defined(_HAVE_CODIPACK_) 1806 // FIXME codi here we just assign instead of using "operator <<=" 1807 auto& tape_codi = IssmDouble::getGlobalTape(); 1808 if(X){ 1809 for (int i=0;i<M*N;i++) { 1810 matrix[i]=X[Xcount+i]; 1811 tape_codi.registerInput(matrix[i]); 1812 codi_global.input_indices.push_back(matrix[i].getGradientData()); 1813 } 1814 } 1815 else{ 1816 for (int i=0;i<M*N;i++) { 1817 matrix[i]=buffer[i]; 1818 tape_codi.registerInput(matrix[i]); 1819 codi_global.input_indices.push_back(matrix[i].getGradientData()); 1820 } 1821 } 1822 #else /*ADOLC*/ 1823 if(X){ 1824 for(int i=0;i<M*N;i++) matrix[i]<<=X[Xcount+i]; /*<<= ADOLC overloaded operator to declare independent*/ 1825 } 1826 else{ 1827 for(int i=0;i<M*N;i++) matrix[i]<<=buffer[i]; 1828 } 1829 #endif 1793 1830 } 1794 1831 ISSM_MPI_Bcast(matrix,M*N,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); … … 1798 1835 else _error_("cannot declare the independent variable \"" << data_name << "\" if it's empty!"); 1799 1836 1837 // FIXME codi is that at all relevant to CoDiPack or can we simply assume the same? 1838 1800 1839 /*Add to data as independent*/ 1801 1840 this->AddDataIndependent(new IoData(matrix,code,layout,M,N,data_name)); … … 2472 2511 /*recover my_rank:*/ 2473 2512 my_rank=IssmComm::GetRank(); 2474 _assert_(strncmp(data_name,mddot,3)==0); 2513 if(strncmp(data_name,mddot,3)!=0){ 2514 _error_("Cannot fetch \""<<data_name<<"\" does not start with \""<<mddot<<"\""); 2515 } 2475 2516 2476 2517 /*Go find in the binary file, the position of the data we want to fetch: */ … … 2562 2603 2563 2604 if(trace || (autodiff && !iscontrol)){ 2564 #ifdef _HAVE_ADOLC_ 2605 2606 #if defined(_HAVE_ADOLC_) 2565 2607 /*Retrieve parameters: */ 2566 2608 this->FetchData(&keep,"md.autodiff.keep"); … … 2579 2621 int skipFileDeletion=1; 2580 2622 trace_on(my_rank,keepTaylors,reCast<size_t>(obufsize),reCast<size_t>(lbufsize),reCast<size_t>(cbufsize),reCast<size_t>(tbufsize),skipFileDeletion); 2623 2624 #elif defined(_HAVE_CODIPACK_) 2625 //fprintf(stderr, "*** Codipack IoModel::StartTrace\n"); 2626 /* 2627 * FIXME codi 2628 * - ADOL-C variant uses fine grained tracing with various arguments 2629 * - ADOL-C variant sets a garbage collection parameter for its tape 2630 * -> These parameters are not read for the CoDiPack ISSM version! 2631 */ 2632 auto& tape_codi = IssmDouble::getGlobalTape(); 2633 tape_codi.setActive(); 2634 #if _AD_TAPE_ALLOC_ 2635 //alloc_profiler.Tag(StartInit, true); 2636 IssmDouble x_t(1.0), y_t(1.0); 2637 tape_codi.registerInput(y_t); 2638 int codi_allocn = 0; 2639 this->FetchData(&codi_allocn,"md.autodiff.tapeAlloc"); 2640 for(int i = 0;i < codi_allocn;++i) { 2641 x_t = y_t * y_t; 2642 } 2643 /* 2644 std::stringstream out_s; 2645 IssmDouble::getGlobalTape().printStatistics(out_s); 2646 _printf0_("StartTrace::Tape Statistics : TapeAlloc count=[" << codi_allocn << "]\n" << out_s.str()); 2647 */ 2648 tape_codi.reset(); 2649 //alloc_profiler.Tag(FinishInit, true); 2581 2650 #endif 2582 } 2583 2584 } 2585 /*}}}*/ 2651 #endif 2652 } 2653 2654 } 2655 /*}}}*/ -
issm/trunk/src/c/classes/Materials/Matpar.cpp
r23189 r23394 107 107 iomodel->FindConstant(&this->rlapslgm,"md.smb.rlapslgm"); 108 108 break; 109 case SMBpddSicopolisEnum: 110 iomodel->FindConstant(&this->desfac,"md.smb.desfac"); 111 iomodel->FindConstant(&this->rlaps,"md.smb.rlaps"); 112 break; 109 113 case SMBd18opddEnum: 110 114 iomodel->FindConstant(&this->desfac,"md.smb.desfac"); 111 115 iomodel->FindConstant(&this->rlaps,"md.smb.rlaps"); 112 116 iomodel->FindConstant(&this->rlapslgm,"md.smb.rlapslgm"); 113 iomodel->FindConstant(&this->dpermil,"md.smb.dpermil"); 117 iomodel->FindConstant(&this->dpermil,"md.smb.dpermil"); 114 118 case SMBgradientsEnum: 115 119 /*Nothing to add*/ … … 125 129 break; 126 130 case SMBmeltcomponentsEnum: 131 /*Nothing to add*/ 132 break; 133 case SMBgradientscomponentsEnum: 127 134 /*Nothing to add*/ 128 135 break; … … 170 177 break; 171 178 case MaterialsEnum: 172 //we have several types of materials. Retrieve this info first: 179 //we have several types of materials. Retrieve this info first: 173 180 iomodel->FetchData(&nature,&nnat,&dummy,"md.materials.nature"); 174 181 175 //go through list of materials, and create constant parameters accordingly: 176 for(int i=0;i<nnat;i++){ 182 //go through list of materials, and create constant parameters accordingly: 183 for(int i=0;i<nnat;i++){ 177 184 switch(IoCodeToEnumMaterials(nature[i])){ //{{{ 178 185 case MatlithoEnum: … … 211 218 iomodel->FindConstant(&this->rlapslgm,"md.smb.rlapslgm"); 212 219 break; 220 case SMBpddSicopolisEnum: 221 iomodel->FindConstant(&this->desfac,"md.smb.desfac"); 222 iomodel->FindConstant(&this->rlaps,"md.smb.rlaps"); 223 break; 213 224 case SMBd18opddEnum: 214 225 iomodel->FindConstant(&this->desfac,"md.smb.desfac"); 215 226 iomodel->FindConstant(&this->rlaps,"md.smb.rlaps"); 216 227 iomodel->FindConstant(&this->rlapslgm,"md.smb.rlapslgm"); 217 iomodel->FindConstant(&this->dpermil,"md.smb.dpermil"); 228 iomodel->FindConstant(&this->dpermil,"md.smb.dpermil"); 218 229 case SMBgradientsEnum: 219 230 /*Nothing to add*/ … … 233 244 default: 234 245 _error_("Surface mass balance model "<<EnumToStringx(smb_model)<<" not supported yet"); 235 } 246 } 236 247 if(hydrology_model==HydrologydcEnum){ 237 248 iomodel->FindConstant(&this->sediment_compressibility,"md.hydrology.sediment_compressibility"); … … 350 361 351 362 this->Echo(); 352 } 363 } 353 364 /*}}}*/ 354 365 void Matpar::Echo(void){/*{{{*/ … … 381 392 _printf_(" sediment_porosity: " << sediment_porosity << "\n"); 382 393 _printf_(" sediment_thickness: " << sediment_thickness << "\n"); 383 _printf_(" water_compressibility: " << water_compressibility << "\n"); 384 _printf_(" epl_compressibility: " << epl_compressibility << "\n"); 385 _printf_(" epl_porosity: " << epl_porosity << "\n"); 386 _printf_(" epl_init_thickness: " << epl_init_thickness << "\n"); 387 _printf_(" epl_colapse_thickness: " << epl_colapse_thickness << "\n"); 388 _printf_(" epl_max_thickness: " << epl_max_thickness << "\n"); 389 _printf_(" epl_conductivity: " << epl_conductivity << "\n"); 390 _printf_(" lithosphere_shear_modulus: " << lithosphere_shear_modulus << "\n"); 391 _printf_(" lithosphere_density: " << lithosphere_density << "\n"); 392 _printf_(" mantle_shear_modulus: " << mantle_shear_modulus << "\n"); 393 _printf_(" mantle_density: " << mantle_density << "\n"); 394 _printf_(" earth_density: " << earth_density << "\n"); 394 _printf_(" water_compressibility: " << water_compressibility << "\n"); 395 _printf_(" epl_compressibility: " << epl_compressibility << "\n"); 396 _printf_(" epl_porosity: " << epl_porosity << "\n"); 397 _printf_(" epl_init_thickness: " << epl_init_thickness << "\n"); 398 _printf_(" epl_colapse_thickness: " << epl_colapse_thickness << "\n"); 399 _printf_(" epl_max_thickness: " << epl_max_thickness << "\n"); 400 _printf_(" epl_conductivity: " << epl_conductivity << "\n"); 401 _printf_(" lithosphere_shear_modulus: " << lithosphere_shear_modulus << "\n"); 402 _printf_(" lithosphere_density: " << lithosphere_density << "\n"); 403 _printf_(" mantle_shear_modulus: " << mantle_shear_modulus << "\n"); 404 _printf_(" mantle_density: " << mantle_density << "\n"); 405 _printf_(" earth_density: " << earth_density << "\n"); 395 406 return; 396 407 } … … 512 523 this->dpermil=constant; 513 524 break; 514 default: 525 default: 515 526 break; 516 527 } -
issm/trunk/src/c/classes/Numberedcostfunction.cpp
r23189 r23394 149 149 _error_("not supported"); 150 150 } 151 _printf0_("#"<<i+1<<": "<<value<<" "); 151 152 value_sum += value; 152 153 } 154 _printf0_("\n"); 153 155 154 156 /*done:*/ -
issm/trunk/src/c/classes/Options/GenericOption.h
r22758 r23394 102 102 }; 103 103 104 #if defined(_HAVE_AD OLC_) && !defined(_WRAPPERS_)104 #if defined(_HAVE_AD_) && !defined(_WRAPPERS_) 105 105 /*We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization*/ 106 106 template <> inline void GenericOption<IssmPDouble*>::Get(IssmPDouble** pvalue){ /*{{{*/ -
issm/trunk/src/c/classes/Params/Parameters.cpp
r22758 r23394 92 92 } 93 93 /*}}}*/ 94 void Parameters::DeepEcho(void){/*{{{*/ 94 void Parameters::DeepEcho(void){/*{{{*/ 95 95 for(int i=0;i<NUMPARAMS;i++) { 96 96 if(this->params[i]) this->params[i]->DeepEcho(); … … 99 99 } 100 100 /*}}}*/ 101 void Parameters::Echo(void){/*{{{*/ 101 void Parameters::Echo(void){/*{{{*/ 102 102 for(int i=0;i<NUMPARAMS;i++) { 103 103 if(this->params[i]) this->params[i]->Echo(); … … 139 139 140 140 /*Recover enum of object first: */ 141 MARSHALLING(obj_enum); 141 MARSHALLING(obj_enum); 142 142 143 143 if(obj_enum==DoubleParamEnum){ … … 200 200 fileparam->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 201 201 delete fileparam; 202 /* No need to add this object, the pointer is not valid 202 /* No need to add this object, the pointer is not valid 203 203 The FemModel should reset all FileParams in the restart function */ 204 204 } … … 426 426 } 427 427 /*}}}*/ 428 void Parameters::FindParamAndMakePassive(IssmPDouble* pscalar,int param_enum){ _assert_(this);/*{{{*/ 429 _assert_(param_enum>ParametersSTARTEnum); 430 _assert_(param_enum<ParametersENDEnum); 431 432 /*Get "active" parameter*/ 433 IssmDouble intermediary; 434 int index = param_enum - ParametersSTARTEnum -1; 435 if(!this->params[index]) _error_("Parameter " << EnumToStringx(param_enum) <<" not set"); 436 this->params[index]->GetParameterValue(&intermediary); 437 438 /*cast to "passive"*/ 439 *pscalar=reCast<IssmPDouble>(intermediary); 440 } 441 /*}}}*/ 442 void Parameters::FindParamAndMakePassive(IssmPDouble** pvec,int* pM, int param_enum){ _assert_(this);/*{{{*/ 443 444 _assert_(param_enum>ParametersSTARTEnum); 445 _assert_(param_enum<ParametersENDEnum); 446 447 int index = param_enum - ParametersSTARTEnum -1; 448 449 /*Output*/ 450 int n; 451 IssmDouble* vector = NULL; 452 453 if(!this->params[index]) _error_("Parameter " << EnumToStringx(param_enum) <<" not set"); 454 this->params[index]->GetParameterValue(&vector,&n); 455 456 /*Make output passive*/ 457 IssmPDouble* output = xNew<IssmPDouble>(n); 458 for(int i=0;i<n;i++) output[i] = reCast<IssmPDouble>(vector[i]); 459 460 /*assign output pointers*/ 461 if(pvec) *pvec = output; 462 if(pM) *pM = n; 463 }/*}}}*/ 428 464 void Parameters::FindParamInDataset(IssmDouble** pIssmDoublearray,int* pM,int* pN,int dataset_type,int enum_type){/*{{{*/ 429 465 _assert_(this); … … 613 649 char* OptionsFromAnalysis(char** pouttoolkit,Parameters* parameters,int analysis_type){ /*{{{*/ 614 650 615 /* figure out ISSM options for current analysis, return a string. */ 651 /* figure out ISSM options for current analysis, return a string. */ 616 652 617 653 /*output: */ … … 631 667 632 668 parameters->FindParam(&strings,&numanalyses,ToolkitsOptionsStringsEnum); 633 parameters->FindParam(&toolkits,&dummy,ToolkitsTypesEnum); _assert_(dummy==numanalyses); 634 parameters->FindParam(&analyses,&dummy,ToolkitsOptionsAnalysesEnum); _assert_(dummy==numanalyses); 669 parameters->FindParam(&toolkits,&dummy,ToolkitsTypesEnum); _assert_(dummy==numanalyses); 670 parameters->FindParam(&analyses,&dummy,ToolkitsOptionsAnalysesEnum); _assert_(dummy==numanalyses); 635 671 636 672 if(numanalyses==0)return NULL; //we did not find petsc options, don't bother. … … 674 710 xDelete<int>(analyses); 675 711 return outstring; 676 } 712 } 677 713 /*}}}*/ 678 714 void ToolkitsOptionsFromAnalysis(Parameters* parameters,int analysis_type){ /*{{{*/ 679 715 680 716 /*!\file: ToolkitsOptionsFromAnalysis.cpp 681 * \brief: for each analysis, setup the issmoptions string. 682 * This is mainly for the case where we run our toolkits using petsc. In this case, we need to 683 * plug our toolkits options directly into the petsc options database. This is the case for each analysis type 717 * \brief: for each analysis, setup the issmoptions string. 718 * This is mainly for the case where we run our toolkits using petsc. In this case, we need to 719 * plug our toolkits options directly into the petsc options database. This is the case for each analysis type 684 720 * and parameters 685 */ 721 */ 686 722 687 723 char* options = NULL; … … 695 731 696 732 #ifdef _HAVE_PETSC_ 697 /*In case we are using PETSC, we do not rely on issmoptions. Instead, we dump issmoptions into the Petsc 733 /*In case we are using PETSC, we do not rely on issmoptions. Instead, we dump issmoptions into the Petsc 698 734 * options database: */ 699 735 #if (_PETSC_MINOR_>=7) … … 717 753 } 718 754 /*}}}*/ 719 720 /*Specific case with ADOL-C, we might need to get double params for m1qn3*/721 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_)722 void Parameters::FindParamAndMakePassive(double* pscalar,int param_enum){ _assert_(this);/*{{{*/723 _assert_(param_enum>ParametersSTARTEnum);724 _assert_(param_enum<ParametersENDEnum);725 726 /*Get "active" parameter*/727 IssmDouble intermediary;728 int index = param_enum - ParametersSTARTEnum -1;729 if(!this->params[index]) _error_("Parameter " << EnumToStringx(param_enum) <<" not set");730 this->params[index]->GetParameterValue(&intermediary);731 732 /*cast to "passive"*/733 *pscalar=reCast<double>(intermediary);734 }735 /*}}}*/736 #endif -
issm/trunk/src/c/classes/Params/Parameters.h
r22758 r23394 52 52 void FindParam(FILE** pfid,int enum_type); 53 53 void FindParam(DataSet** pdataset, int enum_type); 54 void FindParamAndMakePassive(IssmPDouble* pscalar, int enum_type); 55 void FindParamAndMakePassive(IssmPDouble** pvec,int* pM,int enum_type); 54 56 void FindParamInDataset(IssmDouble** pIssmDoublearray,int* pM,int* pN,int dataset_type,int enum_type); 55 57 … … 70 72 Param* FindParamObject(int enum_type); 71 73 72 /*Specific instantiations for IssmDouble*: */73 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_)74 void FindParamAndMakePassive(double* pscalar, int enum_type);75 #endif76 77 74 }; 78 75 -
issm/trunk/src/c/classes/Profiler.cpp
r23189 r23394 15 15 /*Profiler constructors and destructors:*/ 16 16 Profiler::Profiler(){/*{{{*/ 17 for(int i=0;i<MAX IMUMSIZE;i++){17 for(int i=0;i<MAXPROFSIZE;i++){ 18 18 this->time[i] = 0.; 19 19 this->time_start[i] = 0.; … … 23 23 this->memory_start[i] = 0.; 24 24 this->running[i] = false; 25 this->used[i] = false; 25 26 } 26 27 } /*}}}*/ … … 32 33 Profiler* output=new Profiler(); 33 34 34 for(int i=0;i<MAX IMUMSIZE;i++){35 for(int i=0;i<MAXPROFSIZE;i++){ 35 36 output->time[i] =this->time[i]; 36 37 output->flops[i] =this->flops[i]; … … 49 50 50 51 _printf_("Profiler:\n"); 51 for(int i=0;i<MAX IMUMSIZE;i++){52 for(int i=0;i<MAXPROFSIZE;i++){ 52 53 _printf_(" Tag "<<i<<":\n"); 53 54 _printf_(" flops: "<<this->flops[i]<<"\n"); … … 70 71 MARSHALLING_ENUM(ProfilerEnum); 71 72 pointer = &this->time[0]; 72 MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAX IMUMSIZE);73 MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAXPROFSIZE); 73 74 pointer = &this->flops[0]; 74 MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAX IMUMSIZE);75 MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAXPROFSIZE); 75 76 pointer = &this->memory[0]; 76 MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAX IMUMSIZE);77 MARSHALLING_DYNAMIC(pointer,IssmPDouble,MAXPROFSIZE); 77 78 bpointer = &this->running[0]; 78 MARSHALLING_DYNAMIC(bpointer,bool,MAX IMUMSIZE);79 MARSHALLING_DYNAMIC(bpointer,bool,MAXPROFSIZE); 79 80 80 81 } /*}}}*/ … … 88 89 /*Get tag*/ 89 90 _assert_(tag>=0); 90 _assert_(tag<MAX IMUMSIZE);91 _assert_(tag<MAXPROFSIZE); 91 92 if(this->running[tag]) _error_("Tag "<<tag<<" has not been stopped"); 92 93 … … 97 98 /*Get tag*/ 98 99 _assert_(tag>=0); 99 _assert_(tag<MAX IMUMSIZE);100 _assert_(tag<MAXPROFSIZE); 100 101 if(this->running[tag]) _error_("Tag "<<tag<<" has not been stopped"); 101 102 … … 130 131 /*Get initial flops*/ 131 132 _assert_(tag>=0); 132 _assert_(tag<MAX IMUMSIZE);133 _assert_(tag<MAXPROFSIZE); 133 134 if(this->running[tag]) _error_("Tag "<<tag<<" has not been stopped"); 134 135 … … 140 141 /*Check tag*/ 141 142 _assert_(tag>=0); 142 _assert_(tag<MAX IMUMSIZE);143 _assert_(tag<MAXPROFSIZE); 143 144 if(this->running[tag]) _error_("Tag "<<tag<<" is already running"); 144 145 … … 167 168 /*Plug into this->time: */ 168 169 _assert_(tag>=0); 169 _assert_(tag<MAX IMUMSIZE);170 _assert_(tag<MAXPROFSIZE); 170 171 this->time_start[tag] = t; 171 172 this->flops_start[tag] = f; … … 174 175 /*turn on running*/ 175 176 this->running[tag] = true; 177 this->used[tag] = true; 176 178 }/*}}}*/ 177 179 void Profiler::Stop(int tag,bool dontmpisync){/*{{{*/ … … 179 181 /*Check tag*/ 180 182 _assert_(tag>=0); 181 _assert_(tag<MAX IMUMSIZE);183 _assert_(tag<MAXPROFSIZE); 182 184 if(!this->running[tag]) _error_("Tag "<<tag<<" is not running"); 183 185 … … 206 208 /*Plug into this->time: */ 207 209 _assert_(tag>=0); 208 _assert_(tag<MAX IMUMSIZE);210 _assert_(tag<MAXPROFSIZE); 209 211 this->time[tag] += t - this->time_start[tag]; 210 212 this->flops[tag] += f - this->flops_start[tag]; … … 214 216 this->running[tag] = false; 215 217 }/*}}}*/ 218 bool Profiler::Used(int tag){/*{{{*/ 219 220 /*Check tag*/ 221 _assert_(tag>=0); 222 _assert_(tag<MAXPROFSIZE); 223 return this->used[tag]; 224 }/*}}}*/ -
issm/trunk/src/c/classes/Profiler.h
r22758 r23394 11 11 12 12 /*Macros*/ 13 #define TOTAL 0 /*Profiling Total time */ 14 #define MPROCESSOR 1 /*Profiling Model processor*/ 15 #define CORE 2 /*Profiling solution */ 16 #define SOLVER 3 /*Profiling solution */ 17 #define ADCORE 4 /*Profiling AD */ 18 #define MAXIMUMSIZE 5 13 #define TOTAL 0 /*Profiling Total time */ 14 #define MPROCESSOR 1 /*Profiling Model processor*/ 15 #define CORE 2 /*Profiling solution */ 16 #define SOLVER 3 /*Profiling solution */ 17 #define ADCORE 4 /*Profiling AD */ 18 #define THERMALCORE 5 /*Profiling THERMAL */ 19 #define HYDROLOGYCORE 6 /*Profiling HYDROLOGY */ 20 #define STRESSBALANCECORE 7 /*Profiling STRESSBALANCE */ 21 #define DAMAGECORE 8 /*Profiling DAMAGE */ 22 #define MOVINGFRONTCORE 9 /*Profiling MOVINGFRONT */ 23 #define MASSTRANSPORTCORE 10 /*Profiling MASSTRANSPORT */ 24 #define SMBCORE 11 /*Profiling SMB */ 25 #define GROUNDINGLINECORE 12 /*Profiling GROUDINGLINE MIGRATION */ 26 #define GIACORE 13 /*Profiling GIA */ 27 #define ESACORE 14 /*Profiling ESA */ 28 #define SLRCORE 15 /*Profiling SLR */ 29 #define MAXPROFSIZE 16 /*Used to initialize static arrays*/ 19 30 20 31 class Profiler: public Object{ 21 32 22 33 public: 23 IssmPDouble flops[MAXIMUMSIZE]; 24 IssmPDouble flops_start[MAXIMUMSIZE]; 25 IssmPDouble memory[MAXIMUMSIZE]; 26 IssmPDouble memory_start[MAXIMUMSIZE]; 27 IssmPDouble time[MAXIMUMSIZE]; 28 IssmPDouble time_start[MAXIMUMSIZE]; 29 bool running[MAXIMUMSIZE]; 34 IssmPDouble flops[MAXPROFSIZE]; 35 IssmPDouble flops_start[MAXPROFSIZE]; 36 IssmPDouble memory[MAXPROFSIZE]; 37 IssmPDouble memory_start[MAXPROFSIZE]; 38 IssmPDouble time[MAXPROFSIZE]; 39 IssmPDouble time_start[MAXPROFSIZE]; 40 bool running[MAXPROFSIZE]; 41 bool used[MAXPROFSIZE]; 30 42 31 43 /*Profiler constructors, destructors */ … … 48 60 int TotalTimeModSec(int tag); 49 61 IssmPDouble Memory(int tag); 50 void Start(int tagenum,bool dontmpisync=false); 51 void Stop(int tagenum,bool dontmpisync=false); 62 void Start(int tagenum,bool dontmpisync=true); /*Do not call MPI barrier by default to save some ms*/ 63 void Stop(int tagenum, bool dontmpisync=true); /*Do not call MPI barrier by default to save some ms*/ 64 bool Used(int tagenum); 52 65 }; 53 66 -
issm/trunk/src/c/cores/ad_core.cpp
r23189 r23394 19 19 /*}}}*/ 20 20 21 #ifdef _HAVE_CODIPACK_ 22 CoDi_global codi_global = {}; 23 #endif 21 24 void ad_core(FemModel* femmodel){ 22 25 … … 41 44 if(isautodiff && !iscontrol){ 42 45 43 #if def _HAVE_ADOLC_46 #if defined(_HAVE_ADOLC_) 44 47 if(VerboseAutodiff())_printf0_(" start ad core\n"); 45 48 … … 318 321 xDelete(axp); 319 322 xDelete(driver); 323 324 #elif defined(_HAVE_CODIPACK_) 325 if(VerboseAutodiff())_printf0_(" start CoDiPack ad core\n"); 326 327 /*First, stop tracing: */ 328 auto& tape_codi = IssmDouble::getGlobalTape(); 329 tape_codi.setPassive(); 330 331 if(VerboseAutodiff()){ /*{{{*/ 332 if(my_rank == 0) { 333 // FIXME codi "just because" for now 334 tape_codi.printStatistics(std::cout); 335 codi_global.print(std::cout); 336 } 337 } 338 339 /*retrieve parameters: */ 340 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 341 femmodel->parameters->FindParam(&num_independents,AutodiffNumIndependentsEnum); 342 343 /*if no dependents, no point in running a driver: */ 344 if(!(num_dependents*num_independents)) return; 345 346 /*Branch according to AD driver: */ 347 femmodel->parameters->FindParam(&driver,AutodiffDriverEnum); 348 if(VerboseAutodiff())_printf0_(" driver: " << driver << "\n"); 349 350 if (strcmp(driver,"fos_reverse")==0) { /*{{{*/ 351 if(VerboseAutodiff())_printf0_(" CoDiPack fos_reverse\n"); 352 int aDepIndex=0; 353 double *weightVectorTimesJac=NULL; 354 355 /*retrieve direction index: */ 356 femmodel->parameters->FindParam(&aDepIndex,AutodiffFosReverseIndexEnum); 357 if (my_rank==0) { 358 if (aDepIndex<0 || aDepIndex>=num_dependents 359 || codi_global.output_indices.size() <= aDepIndex){ 360 _error_("index value for AutodiffFosReverseIndexEnum should be in [0,num_dependents-1]"); 361 } 362 tape_codi.setGradient(codi_global.output_indices[aDepIndex], 1.0); 363 } 364 365 tape_codi.evaluate(); 366 367 weightVectorTimesJac=xNew<double>(num_independents); 368 /*call driver: */ 369 auto in_size = codi_global.input_indices.size(); 370 for(size_t i = 0; i < in_size; ++i) { 371 weightVectorTimesJac[i] = tape_codi.getGradient(codi_global.input_indices[i]); 372 } 373 374 /*add to results*/ 375 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,AutodiffJacobianEnum,weightVectorTimesJac,num_independents,1,0,0.0)); 376 377 /*free resources :*/ 378 xDelete(weightVectorTimesJac); 379 } /*}}}*/ 380 else _error_("driver: " << driver << " not yet supported!"); 381 382 if(VerboseAutodiff())_printf0_(" end CoDiPack ad core\n"); 383 xDelete(driver); 320 384 #else 321 385 _error_("Should not be requesting AD drivers when an AD library is not available!"); -
issm/trunk/src/c/cores/adgradient_core.cpp
r23189 r23394 48 48 if(isautodiff){ 49 49 50 #if def _HAVE_ADOLC_50 #if defined(_HAVE_ADOLC_) 51 51 if(VerboseAutodiff())_printf0_(" start ad core\n"); 52 52 … … 182 182 xDelete(totalgradient); 183 183 xDelete(axp); /*}}}*/ 184 185 #elif defined(_HAVE_CODIPACK_) 186 fprintf(stderr, "*** Codipack adgradient_core()\n"); 184 187 #else 185 188 _error_("Should not be requesting AD drivers when an AD library is not available!"); -
issm/trunk/src/c/cores/adjointstressbalance_core.cpp
r23189 r23394 31 31 if(VerboseSolution()) _printf0_(" computing velocities\n"); 32 32 femmodel->SetCurrentConfiguration(StressbalanceAnalysisEnum); 33 34 bool is_schur_cg_solver = false; 35 #ifdef _HAVE_PETSC_ 36 int solver_type; 37 PetscOptionsDetermineSolverType(&solver_type); 38 39 if(solver_type==FSSolverEnum) is_schur_cg_solver = true; 40 #endif 41 33 42 if(isFS){ 34 43 if (fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum) 35 44 solutionsequence_la(femmodel); 45 else if(is_schur_cg_solver) 46 solutionsequence_schurcg(femmodel); 36 47 else 37 48 solutionsequence_nonlinear(femmodel,conserve_loads); -
issm/trunk/src/c/cores/balancethickness_core.cpp
r16518 r23394 21 21 femmodel->parameters->FindParam(&save_results,SaveResultsEnum); 22 22 23 if(VerboseSolution()) _printf0_(" call computational core:\n");23 if(VerboseSolution()) _printf0_(" call computational core:\n"); 24 24 solutionsequence_linear(femmodel); 25 25 -
issm/trunk/src/c/cores/balancevelocity_core.cpp
r19105 r23394 27 27 solutionsequence_linear(femmodel); 28 28 29 if(VerboseSolution()) _printf0_(" call computational core:\n");29 if(VerboseSolution()) _printf0_(" call computational core:\n"); 30 30 femmodel->SetCurrentConfiguration(BalancevelocityAnalysisEnum); 31 31 solutionsequence_linear(femmodel); -
issm/trunk/src/c/cores/control_core.cpp
r22758 r23394 81 81 IssmDouble *XL = NULL; 82 82 IssmDouble *XU = NULL; 83 GetVectorFromControlInputsx(&XL, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");84 GetVectorFromControlInputsx(&XU, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");83 GetVectorFromControlInputsx(&XL,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound"); 84 GetVectorFromControlInputsx(&XU,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound"); 85 85 for(long i=0;i<nsize;i++){ 86 86 if(X0[i]>XU[i]) X0[i]=XU[i]; … … 97 97 femmodel->OutputControlsx(&femmodel->results); 98 98 99 #ifdef _HAVE_AD OLC_99 #ifdef _HAVE_AD_ 100 100 IssmPDouble* J_passive=xNew<IssmPDouble>(nsteps); 101 101 for(int i=0;i<nsteps;i++) J_passive[i]=reCast<IssmPDouble>(J[i]); … … 134 134 IssmDouble *XL = NULL; 135 135 IssmDouble *XU = NULL; 136 GetVectorFromControlInputsx(&XL, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");137 GetVectorFromControlInputsx(&XU, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");136 GetVectorFromControlInputsx(&XL,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound"); 137 GetVectorFromControlInputsx(&XU,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound"); 138 138 for(long i=0;i<nsize;i++){ 139 139 if(X[i]>XU[i]) X[i]=XU[i]; … … 143 143 /*Update control input*/ 144 144 SetControlInputsFromVectorx(femmodel,X); 145 145 146 146 147 /*solve forward: */ 147 148 switch(solution_type){ … … 150 151 stressbalance_core(femmodel); //We need a 3D velocity!! (vz is required for the next thermal run) 151 152 break; 152 case StressbalanceSolutionEnum: 153 case StressbalanceSolutionEnum:{ 153 154 femmodel->SetCurrentConfiguration(StressbalanceAnalysisEnum); 154 solutionsequence_nonlinear(femmodel,conserve_loads); 155 break; 155 156 bool is_schur_cg_solver = false; 157 #ifdef _HAVE_PETSC_ 158 int solver_type; 159 PetscOptionsDetermineSolverType(&solver_type); 160 if(solver_type==FSSolverEnum) is_schur_cg_solver = true; 161 #endif 162 163 if(is_schur_cg_solver){ 164 solutionsequence_schurcg(femmodel); 165 }else{ 166 solutionsequence_nonlinear(femmodel,conserve_loads); 167 } 168 } 169 break; 156 170 case BalancethicknessSolutionEnum: 157 171 femmodel->SetCurrentConfiguration(BalancethicknessAnalysisEnum); … … 211 225 IssmDouble *XL = NULL; 212 226 IssmDouble *XU = NULL; 213 GetVectorFromControlInputsx(&XL, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");214 GetVectorFromControlInputsx(&XU, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");227 GetVectorFromControlInputsx(&XL,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound"); 228 GetVectorFromControlInputsx(&XU,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound"); 215 229 for(long i=0;i<nsize;i++){ 216 230 if(X[i]>XU[i]) X[i]=XU[i]; -
issm/trunk/src/c/cores/controlad_core.cpp
r23189 r23394 11 11 #include "../solutionsequences/solutionsequences.h" 12 12 13 /*This file is probably never used!*/ 13 14 #if defined (_HAVE_M1QN3_) & defined (_HAVE_ADOLC_) 14 15 /*m1qn3 prototypes {{{*/ -
issm/trunk/src/c/cores/controladm1qn3_core.cpp
r23189 r23394 11 11 #include "../solutionsequences/solutionsequences.h" 12 12 13 #if defined (_HAVE_M1QN3_) && defined(_HAVE_ADOLC_) 14 /*m1qn3 prototypes*/ 13 #ifdef _HAVE_CODIPACK_ 14 extern CoDi_global codi_global; 15 #include <sstream> // for output of the CoDiPack tape 16 #endif 17 18 #if defined (_HAVE_M1QN3_) && defined(_HAVE_AD_) 19 /*m1qn3 prototypes {{{*/ 15 20 extern "C" void *ctonbe_; // DIS mode : Conversion 16 21 extern "C" void *ctcabe_; // DIS mode : Conversion … … 31 36 int* i; 32 37 } m1qn3_struct; 38 /*}}}*/ 33 39 34 40 /*m1qm3 functions*/ 35 41 void simul_starttrace(FemModel* femmodel){/*{{{*/ 36 42 43 #if defined(_HAVE_ADOLC_) 37 44 /*Retrive ADOLC parameters*/ 38 45 IssmDouble gcTriggerRatio; … … 57 64 int my_rank=IssmComm::GetRank(); 58 65 trace_on(my_rank,keepTaylors,reCast<size_t>(obufsize),reCast<size_t>(lbufsize),reCast<size_t>(cbufsize),reCast<size_t>(tbufsize),skipFileDeletion); 66 67 #elif defined(_HAVE_CODIPACK_) 68 69 //fprintf(stderr, "*** Codipack IoModel::StartTrace\n"); 70 /* 71 * FIXME codi 72 * - ADOL-C variant uses fine grained tracing with various arguments 73 * - ADOL-C variant sets a garbage collection parameter for its tape 74 * -> These parameters are not read for the CoDiPack ISSM version! 75 */ 76 auto& tape_codi = IssmDouble::getGlobalTape(); 77 tape_codi.setActive(); 78 #if _AD_TAPE_ALLOC_ 79 //alloc_profiler.Tag(StartInit, true); 80 IssmDouble x_t(1.0), y_t(1.0); 81 tape_codi.registerInput(y_t); 82 int codi_allocn = 0; 83 femmodel->parameters->FindParam(&codi_allocn,AutodiffTapeAllocEnum); 84 for(int i = 0;i < codi_allocn;++i) { 85 x_t = y_t * y_t; 86 } 87 /* 88 std::stringstream out_s; 89 IssmDouble::getGlobalTape().printStatistics(out_s); 90 _printf0_("StartTrace::Tape Statistics : TapeAlloc count=[" << codi_allocn << "]\n" << out_s.str()); 91 */ 92 tape_codi.reset(); 93 //alloc_profiler.Tag(FinishInit, true); 94 #else 95 tape_codi.reset(); 96 #endif 97 98 #else 99 _error_("not implemented"); 100 #endif 59 101 }/*}}}*/ 60 void simul_ad(long* indic,long* n,double* X,double* pf,double* G,long izs[1],float rzs[1],void* dzs){/*{{{*/ 61 62 /*Get rank*/ 63 int my_rank=IssmComm::GetRank(); 64 65 /*Recover Arguments*/ 66 m1qn3_struct *input_struct = (m1qn3_struct*)dzs; 67 68 FemModel* femmodel = input_struct->femmodel; 69 int num_responses,num_controls,numberofvertices,solution_type; 70 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); 71 int* N = NULL; 72 int N_add = 0; 73 int* control_enum = NULL; 74 75 if (solution_type == TransientSolutionEnum){ 76 femmodel = input_struct->femmodel->copy(); 77 } 78 79 IssmPDouble* Jlist = input_struct->Jlist; 80 int JlistM = input_struct->M; 81 int JlistN = input_struct->N; 82 int* Jlisti = input_struct->i; 83 int intn = (int)*n; 84 85 /*Recover some parameters*/ 86 IssmDouble* scaling_factors = NULL; 87 femmodel->parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum); 88 femmodel->parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 89 femmodel->parameters->FindParam(&scaling_factors,NULL,InversionControlScalingFactorsEnum); 90 femmodel->parameters->FindParam(&N,NULL,ControlInputSizeNEnum); 91 femmodel->parameters->FindParam(&control_enum,NULL,InversionControlParametersEnum); 92 numberofvertices=femmodel->vertices->NumberOfVertices(); 93 94 /*Constrain input vector and update controls*/ 95 double *XL = NULL; 96 double *XU = NULL; 97 GetPassiveVectorFromControlInputsx(&XL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound"); 98 GetPassiveVectorFromControlInputsx(&XU,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound"); 99 100 N_add = 0; 101 for (int c=0;c<num_controls;c++){ 102 for(int i=0;i<numberofvertices*N[c];i++){ 103 int index = N_add*numberofvertices+i; 104 X[index] = X[index]*reCast<double>(scaling_factors[c]); 105 if(X[index]>XU[index]) X[index]=XU[index]; 106 if(X[index]<XL[index]) X[index]=XL[index]; 107 } 108 N_add+=N[c]; 109 } 110 111 /*Start Tracing*/ 112 simul_starttrace(femmodel); 113 /*Set X as our new control input and as INDEPENDENT*/ 114 #ifdef _HAVE_AD_ 115 IssmDouble* aX=xNew<IssmDouble>(intn,"t"); 116 #else 117 IssmDouble* aX=xNew<IssmDouble>(intn); 118 #endif 119 if(my_rank==0){ 120 for(int i=0;i<intn;i++){ 121 aX[i]<<=X[i]; 122 } 123 } 124 125 ISSM_MPI_Bcast(aX,intn,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 126 SetControlInputsFromVectorx(femmodel,aX); 127 xDelete<IssmDouble>(aX); 128 129 /*Compute solution (forward)*/ 130 void (*solutioncore)(FemModel*)=NULL; 131 CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type); 132 solutioncore(femmodel); 133 134 /*Reset the time to zero for next optimization*/ 135 if(solution_type==TransientSolutionEnum){ 136 IssmDouble restart_time; 137 femmodel->parameters->FindParam(&restart_time,TimesteppingStartTimeEnum); 138 femmodel->parameters->SetParam(restart_time,TimeEnum); 139 140 } 141 142 /*Get Dependents*/ 143 IssmDouble output_value; 144 int num_dependents; 145 IssmPDouble *dependents; 146 DataSet* dependent_objects=NULL; 147 IssmDouble J=0.; 148 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 149 femmodel->parameters->FindParam(&dependent_objects,AutodiffDependentObjectsEnum); 150 151 /*Go through our dependent variables, and compute the response:*/ 152 dependents=xNew<IssmPDouble>(num_dependents); 153 for(int i=0;i<dependent_objects->Size();i++){ 154 DependentObject* dep=(DependentObject*)dependent_objects->GetObjectByOffset(i); 155 if(solution_type==TransientSolutionEnum) output_value = dep->GetValue(); 156 if(solution_type!=TransientSolutionEnum) dep->Responsex(&output_value,femmodel); 157 if (my_rank==0) { 158 output_value>>=dependents[i]; 159 J+=output_value; 160 } 161 } 162 163 /*Turning off trace tape*/ 102 void simul_stoptrace(){/*{{{*/ 103 104 #if defined(_HAVE_ADOLC_) 164 105 trace_off(); 165 time_t now = time(NULL);166 if(my_rank==0) _printf_("\nTIME: "<<now<<"\n");167 /*Print tape statistics so that user can kill this run if something is off already:*/168 106 if(VerboseAutodiff()){ /*{{{*/ 107 108 #ifdef _HAVE_ADOLC_ 109 int my_rank=IssmComm::GetRank(); 169 110 size_t tape_stats[15]; 170 111 tapestats(my_rank,tape_stats); //reading of tape statistics … … 207 148 } 208 149 delete [] sstats; 150 #endif 151 152 #ifdef _HAVE_CODIPACK_ 153 #ifdef _AD_TAPE_ALLOC_ 154 //_printf_("Allocation time P(" << my_rank << "): " << alloc_profiler.DeltaTime(StartInit, FinishInit) << "\n"); 155 #endif 156 std::stringstream out_s; 157 IssmDouble::getGlobalTape().printStatistics(out_s); 158 _printf0_("CoDiPack Profiling::Tape Statistics :\n" << out_s.str()); 159 #endif 209 160 } /*}}}*/ 210 161 211 /*diverse: */ 212 int dummy; 213 int num_independents=0; 162 #elif defined(_HAVE_CODIPACK_) 163 auto& tape_codi = IssmDouble::getGlobalTape(); 164 tape_codi.setPassive(); 165 if(VerboseAutodiff()){ 166 int my_rank=IssmComm::GetRank(); 167 if(my_rank == 0) { 168 // FIXME codi "just because" for now 169 tape_codi.printStatistics(std::cout); 170 codi_global.print(std::cout); 171 } 172 } 173 #else 174 _error_("not implemented"); 175 #endif 176 }/*}}}*/ 177 void simul_ad(long* indic,long* n,double* X,double* pf,double* G,long izs[1],float rzs[1],void* dzs){/*{{{*/ 178 179 /*Get rank*/ 180 int my_rank=IssmComm::GetRank(); 181 182 /*Recover Arguments*/ 183 m1qn3_struct *input_struct = (m1qn3_struct*)dzs; 184 185 FemModel* femmodel = input_struct->femmodel; 186 int num_responses,num_controls,solution_type; 187 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); 188 189 /*In transient, we need to make sure we do not modify femmodel at each iteration, make a copy*/ 190 if(solution_type == TransientSolutionEnum) femmodel = input_struct->femmodel->copy(); 191 192 IssmPDouble* Jlist = input_struct->Jlist; 193 int JlistM = input_struct->M; 194 int JlistN = input_struct->N; 195 int* Jlisti = input_struct->i; 196 int intn = (int)*n; 197 198 /*Recover some parameters*/ 199 IssmDouble *scaling_factors = NULL; 200 int *N = NULL; 201 int *control_enum = NULL; 202 femmodel->parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum); 203 femmodel->parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 204 femmodel->parameters->FindParam(&scaling_factors,NULL,InversionControlScalingFactorsEnum); 205 femmodel->parameters->FindParam(&N,NULL,ControlInputSizeNEnum); 206 femmodel->parameters->FindParam(&control_enum,NULL,InversionControlParametersEnum); 207 int numberofvertices=femmodel->vertices->NumberOfVertices(); 208 209 /*Constrain input vector and update controls*/ 210 double *XL = NULL; 211 double *XU = NULL; 212 GetPassiveVectorFromControlInputsx(&XL,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound"); 213 GetPassiveVectorFromControlInputsx(&XU,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound"); 214 215 int N_add = 0; 216 for (int c=0;c<num_controls;c++){ 217 for(int i=0;i<numberofvertices*N[c];i++){ 218 int index = N_add*numberofvertices+i; 219 X[index] = X[index]*reCast<double>(scaling_factors[c]); 220 if(X[index]>XU[index]) X[index]=XU[index]; 221 if(X[index]<XL[index]) X[index]=XL[index]; 222 } 223 N_add+=N[c]; 224 } 225 226 /*Start Tracing*/ 227 simul_starttrace(femmodel); 228 /*Set X as our new control input and as INDEPENDENT*/ 229 #ifdef _HAVE_AD_ 230 IssmDouble* aX=xNew<IssmDouble>(intn,"t"); 231 #else 232 IssmDouble* aX=xNew<IssmDouble>(intn); 233 #endif 234 235 #if defined(_HAVE_ADOLC_) 236 if(my_rank==0){ 237 for(int i=0;i<intn;i++){ 238 aX[i]<<=X[i]; 239 } 240 } 241 #elif defined(_HAVE_CODIPACK_) 242 auto& tape_codi = IssmDouble::getGlobalTape(); 243 codi_global.input_indices.clear(); 244 if(my_rank==0){ 245 for (int i=0;i<intn;i++) { 246 aX[i]=X[i]; 247 tape_codi.registerInput(aX[i]); 248 codi_global.input_indices.push_back(aX[i].getGradientData()); 249 } 250 } 251 #else 252 _error_("not suppoted"); 253 #endif 254 255 ISSM_MPI_Bcast(aX,intn,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 256 SetControlInputsFromVectorx(femmodel,aX); 257 xDelete<IssmDouble>(aX); 258 259 /*Compute solution (forward)*/ 260 void (*solutioncore)(FemModel*)=NULL; 261 CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type); 262 solutioncore(femmodel); 263 264 /*Reset the time to zero for next optimization*/ 265 if(solution_type==TransientSolutionEnum){ 266 IssmDouble restart_time; 267 femmodel->parameters->FindParam(&restart_time,TimesteppingStartTimeEnum); 268 femmodel->parameters->SetParam(restart_time,TimeEnum); 269 270 } 271 272 /*Get Dependents*/ 273 IssmDouble output_value; 274 int num_dependents; 275 IssmPDouble *dependents; 276 DataSet* dependent_objects=NULL; 277 IssmDouble J=0.; 278 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 279 femmodel->parameters->FindParam(&dependent_objects,AutodiffDependentObjectsEnum); 280 281 /*Go through our dependent variables, and compute the response:*/ 282 dependents=xNew<IssmPDouble>(num_dependents); 283 #if defined(_HAVE_CODIPACK_) 284 codi_global.output_indices.clear(); 285 #endif 286 for(int i=0;i<dependent_objects->Size();i++){ 287 DependentObject* dep=(DependentObject*)dependent_objects->GetObjectByOffset(i); 288 if(solution_type==TransientSolutionEnum) output_value = dep->GetValue(); 289 if(solution_type!=TransientSolutionEnum) dep->Responsex(&output_value,femmodel); 290 if(my_rank==0) { 291 292 #if defined(_HAVE_CODIPACK_) 293 tape_codi.registerOutput(output_value); 294 dependents[i] = output_value.getValue(); 295 codi_global.output_indices.push_back(output_value.getGradientData()); 296 297 #elif defined(_HAVE_ADOLC_) 298 output_value>>=dependents[i]; 299 300 #else 301 _error_("not suppoted"); 302 #endif 303 J+=output_value; 304 } 305 } 306 307 /*Turning off trace tape*/ 308 simul_stoptrace(); 309 //time_t now = time(NULL); 310 //if(my_rank==0) _printf_("\nTIME: "<<now<<"\n"); 214 311 215 312 /*intermediary: */ 313 int num_independents=intn; 216 314 IssmPDouble *aWeightVector=NULL; 217 315 IssmPDouble *weightVectorTimesJac=NULL; 218 219 /*output: */ 220 IssmPDouble *totalgradient=NULL; 221 222 /*retrieve parameters: */ 223 num_independents = intn; 316 IssmPDouble *totalgradient=xNewZeroInit<IssmPDouble>(num_independents); 224 317 225 318 /*if no dependents, no point in running a driver: */ … … 229 322 int num_dependents_old = num_dependents; 230 323 int num_independents_old = num_independents; 324 325 #if defined(_HAVE_ADOLC_) 326 /*Get gradient for ADOLC {{{*/ 231 327 if(my_rank!=0){ 232 328 num_dependents = 0; … … 243 339 /* Ok, now we are going to call the fos_reverse in a loop on the index, from 0 to num_dependents, so 244 340 * as to generate num_dependents gradients: */ 245 totalgradient=xNewZeroInit<IssmPDouble>(num_independents_old);246 247 341 for(int aDepIndex=0;aDepIndex<num_dependents_old;aDepIndex++){ 248 342 … … 277 371 xDelete(aWeightVector); 278 372 } 373 /*}}}*/ 374 #elif defined(_HAVE_CODIPACK_) 375 /*Get gradient for CoDiPack{{{*/ 376 if(VerboseAutodiff())_printf0_(" CoDiPack fos_reverse\n"); 377 378 /* call the fos_reverse in a loop on the index, from 0 to num_dependents, so 379 * as to generate num_dependents gradients: */ 380 for(int aDepIndex=0;aDepIndex<num_dependents_old;aDepIndex++){ 381 382 /*initialize direction index in the weights vector: */ 383 aWeightVector=xNewZeroInit<IssmPDouble>(num_dependents); 384 if(my_rank==0){ 385 if(aDepIndex<0 || aDepIndex>=num_dependents || codi_global.output_indices.size() <= aDepIndex){ 386 _error_("index value for AutodiffFosReverseIndexEnum should be in [0,num_dependents-1]"); 387 } 388 tape_codi.setGradient(codi_global.output_indices[aDepIndex],1.0); 389 } 390 tape_codi.evaluate(); 391 392 /*Get gradient for this dependent */ 393 weightVectorTimesJac=xNew<IssmPDouble>(num_independents); 394 auto in_size = codi_global.input_indices.size(); 395 for(size_t i = 0; i < in_size; ++i) { 396 _assert_(i<num_independents); 397 weightVectorTimesJac[i] = tape_codi.getGradient(codi_global.input_indices[i]); 398 } 399 if(my_rank==0) for(int i=0;i<num_independents;i++) { 400 totalgradient[i]+=weightVectorTimesJac[i]; 401 } 402 /*free resources :*/ 403 xDelete(weightVectorTimesJac); 404 xDelete(aWeightVector); 405 } 406 /*}}}*/ 407 #else 408 _error_("not suppoted"); 409 #endif 279 410 280 411 /*Broadcast gradient to other ranks*/ … … 293 424 Jlist[(*Jlisti)*JlistN+num_responses] = reCast<IssmPDouble>(J); 294 425 295 /*296 IssmDouble* test = xNew<IssmDouble>(intn);297 femmodel->parameters->FindParam(&test,NULL,InversionXBestEnum);298 for(int i=0;i<10;i++)_printf_("X "<<test[i]<<"\n");299 xDelete<IssmDouble>(intn);300 */301 426 if(*indic==0){ 302 427 /*dry run, no gradient required*/ … … 341 466 xDelete<double>(XU); 342 467 xDelete<double>(XL); 468 xDelete<int>(control_enum); 469 xDelete<int>(N); 343 470 xDelete<IssmDouble>(scaling_factors); 344 471 xDelete<IssmPDouble>(totalgradient); … … 394 521 395 522 /*Get initial guess*/ 396 Vector<double> *Xpetsc = NULL; 397 398 GetPassiveVectorFromControlInputsx(&Xpetsc,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value"); 399 X = Xpetsc->ToMPISerial(); 400 Xpetsc->GetSize(&intn); 401 delete Xpetsc; 523 GetPassiveVectorFromControlInputsx(&X,&intn,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value"); 402 524 //_assert_(intn==numberofvertices*num_controls); 403 525 … … 458 580 double *XL = NULL; 459 581 double *XU = NULL; 460 GetPassiveVectorFromControlInputsx(&XL, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");461 GetPassiveVectorFromControlInputsx(&XU, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");582 GetPassiveVectorFromControlInputsx(&XL,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound"); 583 GetPassiveVectorFromControlInputsx(&XU,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound"); 462 584 463 585 N_add = 0; … … 479 601 aX[i] = reCast<IssmDouble>(X[i]); 480 602 aG[i] = reCast<IssmDouble>(G[i]); 481 603 } 482 604 483 605 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,aG); … … 538 660 539 661 #else 540 void controladm1qn3_core(FemModel* femmodel){_error_("M1QN3 or ADOLC not installed");}662 void controladm1qn3_core(FemModel* femmodel){_error_("M1QN3 or ADOLC/CoDiPack not installed");} 541 663 #endif //_HAVE_M1QN3_ -
issm/trunk/src/c/cores/controlm1qn3_core.cpp
r23189 r23394 11 11 #include "../solutionsequences/solutionsequences.h" 12 12 13 #if defined (_HAVE_M1QN3_) && !defined(_HAVE_ADOLC_)14 /*m1qn3 prototypes */13 #if defined (_HAVE_M1QN3_) 14 /*m1qn3 prototypes {{{*/ 15 15 extern "C" void *ctonbe_; // DIS mode : Conversion 16 16 extern "C" void *ctcabe_; // DIS mode : Conversion … … 28 28 /*Use struct to provide arguments*/ 29 29 typedef struct{ 30 FemModel * femmodel;31 Issm Double* Jlist;30 FemModel * femmodel; 31 IssmPDouble* Jlist; 32 32 int M; 33 33 int N; 34 34 int* i; 35 35 } m1qn3_struct; 36 37 void controlm1qn3_core(FemModel* femmodel){ 36 /*}}}*/ 37 38 void controlm1qn3_core(FemModel* femmodel){/*{{{*/ 38 39 39 40 /*Intermediaries*/ 40 long 41 double 42 int 43 int 44 IssmDouble*scaling_factors = NULL;45 IssmDouble*X = NULL;46 IssmDouble*G = NULL;41 long omode; 42 double f,dxmin,gttol; 43 int maxsteps,maxiter; 44 int intn,numberofvertices,num_controls,num_cost_functions,solution_type; 45 double *scaling_factors = NULL; 46 double *X = NULL; 47 double *G = NULL; 47 48 48 49 /*Recover some parameters*/ … … 52 53 femmodel->parameters->FindParam(&maxsteps,InversionMaxstepsEnum); 53 54 femmodel->parameters->FindParam(&maxiter,InversionMaxiterEnum); 54 femmodel->parameters->FindParam (&dxmin,InversionDxminEnum);55 femmodel->parameters->FindParam (>tol,InversionGttolEnum);56 femmodel->parameters->FindParam (&scaling_factors,NULL,InversionControlScalingFactorsEnum);55 femmodel->parameters->FindParamAndMakePassive(&dxmin,InversionDxminEnum); 56 femmodel->parameters->FindParamAndMakePassive(>tol,InversionGttolEnum); 57 femmodel->parameters->FindParamAndMakePassive(&scaling_factors,NULL,InversionControlScalingFactorsEnum); 57 58 femmodel->parameters->SetParam(false,SaveResultsEnum); 58 59 numberofvertices=femmodel->vertices->NumberOfVertices(); … … 77 78 78 79 /*Get initial guess*/ 79 Vector<IssmDouble> *Xpetsc = NULL; 80 GetVectorFromControlInputsx(&Xpetsc,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value"); 81 X = Xpetsc->ToMPISerial(); 82 Xpetsc->GetSize(&intn); 83 delete Xpetsc; 80 GetPassiveVectorFromControlInputsx(&X,&intn,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value"); 84 81 _assert_(intn==numberofvertices*num_controls); 85 82 … … 111 108 mystruct.M = maxiter; 112 109 mystruct.N = num_cost_functions+1; 113 mystruct.Jlist = xNewZeroInit<Issm Double>(mystruct.M*mystruct.N);110 mystruct.Jlist = xNewZeroInit<IssmPDouble>(mystruct.M*mystruct.N); 114 111 mystruct.i = xNewZeroInit<int>(1); 115 112 … … 127 124 &reverse,&indic,izs,rzs,(void*)&mystruct); 128 125 126 /*Print exit flag*/ 129 127 switch(int(omode)){ 130 128 case 0: _printf0_(" Stop requested (indic = 0)\n"); break; … … 140 138 141 139 /*Constrain solution vector*/ 142 IssmDouble *XL = NULL;143 IssmDouble *XU = NULL;144 Get VectorFromControlInputsx(&XL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");145 Get VectorFromControlInputsx(&XU,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");140 double *XL = NULL; 141 double *XU = NULL; 142 GetPassiveVectorFromControlInputsx(&XL,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound"); 143 GetPassiveVectorFromControlInputsx(&XU,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound"); 146 144 for(int c=0;c<num_controls;c++){ 147 145 for(int i=0;i<numberofvertices;i++){ … … 152 150 } 153 151 } 152 153 /*Set X as our new control (need to recast)*/ 154 #ifdef _HAVE_AD_ 155 IssmDouble* aX=xNew<IssmDouble>(intn); 156 IssmDouble* aG=xNew<IssmDouble>(intn); 157 for(int i=0;i<intn;i++) { 158 aX[i] = reCast<IssmDouble>(X[i]); 159 aG[i] = reCast<IssmDouble>(G[i]); 160 } 161 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,aG); 162 SetControlInputsFromVectorx(femmodel,aX); 163 xDelete(aX); 164 xDelete(aG); 165 #else 154 166 SetControlInputsFromVectorx(femmodel,X); 155 167 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,G); 168 #endif 169 156 170 femmodel->OutputControlsx(&femmodel->results); 157 171 femmodel->results->AddObject(new GenericExternalResult<double*>(femmodel->results->Size()+1,JEnum,mystruct.Jlist,(*mystruct.i),mystruct.N,0,0)); … … 173 187 xDelete<double>(mystruct.Jlist); 174 188 xDelete<int>(mystruct.i); 175 } 176 177 /*Cost function definition*/ 178 void simul(long* indic,long* n,double* X,double* pf,double* G,long izs[1],float rzs[1],void* dzs){ 189 }/*}}}*/ 190 void simul(long* indic,long* n,double* X,double* pf,double* G,long izs[1],float rzs[1],void* dzs){/*{{{*/ 179 191 180 192 /*Recover Arguments*/ 181 193 m1qn3_struct *input_struct = (m1qn3_struct*)dzs; 182 194 FemModel *femmodel = input_struct->femmodel; 183 Issm Double*Jlist = input_struct->Jlist;195 IssmPDouble *Jlist = input_struct->Jlist; 184 196 int JlistM = input_struct->M; 185 197 int JlistN = input_struct->N; … … 188 200 /*Recover some parameters*/ 189 201 int num_responses,num_controls,numberofvertices,solution_type; 190 IssmDouble* scaling_factors = NULL;202 double* scaling_factors = NULL; 191 203 femmodel->parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum); 192 204 femmodel->parameters->FindParam(&num_controls,InversionNumControlParametersEnum); 193 femmodel->parameters->FindParam (&scaling_factors,NULL,InversionControlScalingFactorsEnum);205 femmodel->parameters->FindParamAndMakePassive(&scaling_factors,NULL,InversionControlScalingFactorsEnum); 194 206 femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum); 195 207 numberofvertices=femmodel->vertices->NumberOfVertices(); 196 208 197 209 /*Constrain input vector and update controls*/ 198 IssmDouble*XL = NULL;199 IssmDouble*XU = NULL;200 Get VectorFromControlInputsx(&XL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");201 Get VectorFromControlInputsx(&XU,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");210 double *XL = NULL; 211 double *XU = NULL; 212 GetPassiveVectorFromControlInputsx(&XL,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound"); 213 GetPassiveVectorFromControlInputsx(&XU,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound"); 202 214 for(int c=0;c<num_controls;c++){ 203 215 for(int i=0;i<numberofvertices;i++){ … … 208 220 } 209 221 } 222 #ifdef _HAVE_AD_ 223 IssmDouble* aX=xNew<IssmDouble>(*n); 224 for(int i=0;i<*n;i++) aX[i] = reCast<IssmDouble>(X[i]); 225 SetControlInputsFromVectorx(femmodel,aX); 226 xDelete(aX); 227 #else 210 228 SetControlInputsFromVectorx(femmodel,X); 229 #endif 211 230 212 231 /*Compute solution and adjoint*/ … … 222 241 /*Compute objective function*/ 223 242 IssmDouble* Jtemp = NULL; 224 femmodel->CostFunctionx(pf,&Jtemp,NULL); 243 IssmDouble J; 244 femmodel->CostFunctionx(&J,&Jtemp,NULL); 245 *pf = reCast<double>(J); 225 246 _printf0_("f(x) = "<<setw(12)<<setprecision(7)<<*pf<<" | "); 226 247 227 248 /*Record cost function values and delete Jtemp*/ 228 for(int i=0;i<num_responses;i++) Jlist[(*Jlisti)*JlistN+i] = Jtemp[i];249 for(int i=0;i<num_responses;i++) Jlist[(*Jlisti)*JlistN+i] = reCast<double>(Jtemp[i]); 229 250 Jlist[(*Jlisti)*JlistN+num_responses] = *pf; 230 251 xDelete<IssmDouble>(Jtemp); … … 239 260 240 261 *Jlisti = (*Jlisti) +1; 241 xDelete< IssmDouble>(XU);242 xDelete< IssmDouble>(XL);262 xDelete<double>(XU); 263 xDelete<double>(XL); 243 264 return; 244 265 } … … 251 272 IssmDouble* G2 = NULL; 252 273 Gradjx(&G2,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 253 for(long i=0;i<*n;i++) G[i] = - G2[i];274 for(long i=0;i<*n;i++) G[i] = -reCast<double>(G2[i]); 254 275 xDelete<IssmDouble>(G2); 255 276 … … 275 296 /*Clean-up and return*/ 276 297 *Jlisti = (*Jlisti) +1; 277 xDelete< IssmDouble>(XU);278 xDelete< IssmDouble>(XL);279 xDelete< IssmDouble>(scaling_factors);280 } 298 xDelete<double>(XU); 299 xDelete<double>(XL); 300 xDelete<double>(scaling_factors); 301 }/*}}}*/ 281 302 282 303 #else 283 void controlm1qn3_core(FemModel* femmodel){ 284 _error_("M1QN3 not installed"); 285 } 304 void controlm1qn3_core(FemModel* femmodel){_error_("M1QN3 not installed");} 286 305 #endif //_HAVE_M1QN3_ -
issm/trunk/src/c/cores/controlvalidation_core.cpp
r22758 r23394 9 9 #include "../modules/modules.h" 10 10 11 #ifdef _HAVE_CODIPACK_ 12 extern CoDi_global codi_global; 13 #include <sstream> // for output of the CoDiPack tape 14 #endif 15 16 #ifdef _HAVE_AD_ 17 void simul_starttrace2(FemModel* femmodel){/*{{{*/ 18 19 #if defined(_HAVE_ADOLC_) 20 /*Retrive ADOLC parameters*/ 21 IssmDouble gcTriggerRatio; 22 IssmDouble gcTriggerMaxSize; 23 IssmDouble obufsize; 24 IssmDouble lbufsize; 25 IssmDouble cbufsize; 26 IssmDouble tbufsize; 27 femmodel->parameters->FindParam(&gcTriggerRatio,AutodiffGcTriggerRatioEnum); 28 femmodel->parameters->FindParam(&gcTriggerMaxSize,AutodiffGcTriggerMaxSizeEnum); 29 femmodel->parameters->FindParam(&obufsize,AutodiffObufsizeEnum); 30 femmodel->parameters->FindParam(&lbufsize,AutodiffLbufsizeEnum); 31 femmodel->parameters->FindParam(&cbufsize,AutodiffCbufsizeEnum); 32 femmodel->parameters->FindParam(&tbufsize,AutodiffTbufsizeEnum); 33 34 /*Set garbage collection parameters: */ 35 setStoreManagerControl(reCast<IssmPDouble>(gcTriggerRatio),reCast<size_t>(gcTriggerMaxSize)); 36 37 /*Start trace: */ 38 int skipFileDeletion=1; 39 int keepTaylors=1; 40 int my_rank=IssmComm::GetRank(); 41 trace_on(my_rank,keepTaylors,reCast<size_t>(obufsize),reCast<size_t>(lbufsize),reCast<size_t>(cbufsize),reCast<size_t>(tbufsize),skipFileDeletion); 42 43 #elif defined(_HAVE_CODIPACK_) 44 45 //fprintf(stderr, "*** Codipack IoModel::StartTrace\n"); 46 /* 47 * FIXME codi 48 * - ADOL-C variant uses fine grained tracing with various arguments 49 * - ADOL-C variant sets a garbage collection parameter for its tape 50 * -> These parameters are not read for the CoDiPack ISSM version! 51 */ 52 auto& tape_codi = IssmDouble::getGlobalTape(); 53 tape_codi.setActive(); 54 #if _AD_TAPE_ALLOC_ 55 //alloc_profiler.Tag(StartInit, true); 56 IssmDouble x_t(1.0), y_t(1.0); 57 tape_codi.registerInput(y_t); 58 int codi_allocn = 0; 59 femmodel->parameters->FindParam(&codi_allocn,AutodiffTapeAllocEnum); 60 for(int i = 0;i < codi_allocn;++i) { 61 x_t = y_t * y_t; 62 } 63 /* 64 std::stringstream out_s; 65 IssmDouble::getGlobalTape().printStatistics(out_s); 66 _printf0_("StartTrace::Tape Statistics : TapeAlloc count=[" << codi_allocn << "]\n" << out_s.str()); 67 */ 68 tape_codi.reset(); 69 //alloc_profiler.Tag(FinishInit, true); 70 #else 71 tape_codi.reset(); 72 #endif 73 74 #else 75 _error_("not implemented"); 76 #endif 77 }/*}}}*/ 78 void simul_stoptrace2(){/*{{{*/ 79 80 #if defined(_HAVE_ADOLC_) 81 trace_off(); 82 if(VerboseAutodiff()){ /*{{{*/ 83 84 #ifdef _HAVE_ADOLC_ 85 int my_rank=IssmComm::GetRank(); 86 size_t tape_stats[15]; 87 tapestats(my_rank,tape_stats); //reading of tape statistics 88 int commSize=IssmComm::GetSize(); 89 int *sstats=new int[7]; 90 sstats[0]=tape_stats[NUM_OPERATIONS]; 91 sstats[1]=tape_stats[OP_FILE_ACCESS]; 92 sstats[2]=tape_stats[NUM_LOCATIONS]; 93 sstats[3]=tape_stats[LOC_FILE_ACCESS]; 94 sstats[4]=tape_stats[NUM_VALUES]; 95 sstats[5]=tape_stats[VAL_FILE_ACCESS]; 96 sstats[6]=tape_stats[TAY_STACK_SIZE]; 97 int *rstats=NULL; 98 if (my_rank==0) rstats=new int[commSize*7]; 99 ISSM_MPI_Gather(sstats,7,ISSM_MPI_INT,rstats,7,ISSM_MPI_INT,0,IssmComm::GetComm()); 100 if (my_rank==0) { 101 int offset=50; 102 int rOffset=(commSize/10)+1; 103 _printf_(" ADOLC statistics: \n"); 104 _printf_(" "<<setw(offset)<<left<<"#independents: " <<setw(12)<<right<<tape_stats[NUM_INDEPENDENTS] << "\n"); 105 _printf_(" "<<setw(offset)<<left<<"#dependents: " <<setw(12)<<right<<tape_stats[NUM_DEPENDENTS] << "\n"); 106 _printf_(" "<<setw(offset)<<left<<"max #live active variables: " <<setw(12)<<right<<tape_stats[NUM_MAX_LIVES] << "\n"); 107 _printf_(" operations: entry size "<< sizeof(unsigned char) << " Bytes \n"); 108 _printf_(" "<<setw(offset)<<left<<" #entries in buffer (AutodiffObufsizeEnum) " <<setw(12)<<right<<tape_stats[OP_BUFFER_SIZE] << "\n"); 109 for (int r=0;r<commSize;++r) 110 _printf_(" ["<<setw(rOffset)<<right<<r<<"]"<<setw(offset-rOffset-4)<<left<<" #entries total" <<setw(12)<<right<<rstats[r*7+0] << (rstats[r*7+1]?" ->file":"") << "\n"); 111 _printf_(" locations: entry size " << sizeof(locint) << " Bytes\n"); 112 _printf_(" "<<setw(offset)<<left<<" #entries in buffer (AutodiffLbufsizeEnum) " <<setw(12)<<right<<tape_stats[LOC_BUFFER_SIZE] << "\n"); 113 for (int r=0;r<commSize;++r) 114 _printf_(" ["<<setw(rOffset)<<right<<r<<"]"<<setw(offset-rOffset-4)<<left<<" #entries total" <<setw(12)<<right<<rstats[r*7+2] << (rstats[r*7+3]?" ->file":"") << "\n"); 115 _printf_(" constant values: entry size " << sizeof(double) << " Bytes\n"); 116 _printf_(" "<<setw(offset)<<left<<" #entries in buffer (AutodiffCbufsizeEnum) " <<setw(12)<<right<<tape_stats[VAL_BUFFER_SIZE] << "\n"); 117 for (int r=0;r<commSize;++r) 118 _printf_(" ["<<setw(rOffset)<<right<<r<<"]"<<setw(offset-rOffset-4)<<left<<" #entries total" <<setw(12)<<right<<rstats[r*7+4] << (rstats[r*7+5]?" ->file":"") << "\n"); 119 _printf_(" Taylor stack: entry size " << sizeof(revreal) << " Bytes\n"); 120 _printf_(" "<<setw(offset)<<left<<" #entries in buffer (AutodiffTbufsizeEnum) " <<setw(12)<<right<<tape_stats[TAY_BUFFER_SIZE] << "\n"); 121 for (int r=0;r<commSize;++r) 122 _printf_(" ["<<setw(rOffset)<<right<<r<<"]"<<setw(offset-rOffset-4)<<left<<" #entries total" <<setw(12)<<right<<rstats[r*7+6] << (rstats[r*7+6]>tape_stats[TAY_BUFFER_SIZE]?" ->file":"") << "\n"); 123 delete []rstats; 124 } 125 delete [] sstats; 126 #endif 127 128 #ifdef _HAVE_CODIPACK_ 129 #ifdef _AD_TAPE_ALLOC_ 130 //_printf_("Allocation time P(" << my_rank << "): " << alloc_profiler.DeltaTime(StartInit, FinishInit) << "\n"); 131 #endif 132 std::stringstream out_s; 133 IssmDouble::getGlobalTape().printStatistics(out_s); 134 _printf0_("CoDiPack Profiling::Tape Statistics :\n" << out_s.str()); 135 #endif 136 } /*}}}*/ 137 138 #elif defined(_HAVE_CODIPACK_) 139 auto& tape_codi = IssmDouble::getGlobalTape(); 140 tape_codi.setPassive(); 141 if(VerboseAutodiff()){ 142 int my_rank=IssmComm::GetRank(); 143 if(my_rank == 0) { 144 // FIXME codi "just because" for now 145 tape_codi.printStatistics(std::cout); 146 codi_global.print(std::cout); 147 } 148 } 149 #else 150 _error_("not implemented"); 151 #endif 152 }/*}}}*/ 153 #endif 154 11 155 void controlvalidation_core(FemModel* femmodel){ 12 156 13 157 int solution_type,n; 14 158 int num_responses; 15 IssmDouble j0,j ,yts;159 IssmDouble j0,j; 16 160 IssmDouble Ialpha,exponent,alpha; 17 161 IssmDouble* scaling_factors = NULL; 18 162 IssmDouble* jlist = NULL; 19 IssmDouble *G = NULL; 20 IssmDouble *X = NULL; 21 IssmDouble *X0= NULL; 22 23 /*Solution and Adjoint core pointer*/ 24 void (*solutioncore)(FemModel*) = NULL; 25 void (*adjointcore)(FemModel*) = NULL; 163 int my_rank=IssmComm::GetRank(); 26 164 27 165 /*Recover parameters used throughout the solution*/ … … 29 167 femmodel->parameters->SetParam(false,SaveResultsEnum); 30 168 femmodel->parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum); 31 femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);32 169 femmodel->parameters->FindParam(&scaling_factors,NULL,InversionControlScalingFactorsEnum); 33 170 34 171 /*Get initial guess*/ 35 Vector<IssmDouble> *Xpetsc = NULL; 36 GetVectorFromControlInputsx(&Xpetsc,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value"); 37 Xpetsc->GetSize(&n); 38 X0 = Xpetsc->ToMPISerial(); 39 delete Xpetsc; 40 41 /*Allocate current vector*/ 42 X = xNew<IssmDouble>(n); 172 IssmPDouble* X0 = NULL; 173 GetPassiveVectorFromControlInputsx(&X0,&n,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"value"); 174 175 /*Allocate vectors*/ 176 IssmDouble* X = xNew<IssmDouble>(n); 177 IssmPDouble* G = xNew<IssmPDouble>(n); 43 178 44 179 /*out of solution_type, figure out solution core and adjoint function pointer*/ 180 void (*solutioncore)(FemModel*)=NULL; 45 181 CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type); 182 183 #if defined(_HAVE_ADOLC_) 184 /*{{{*/ 185 IssmDouble* aX=xNew<IssmDouble>(n); 186 if(my_rank==0){ 187 for(int i=0;i<n;i++){ 188 aX[i]<<=X0[i]; 189 } 190 } 191 _error_("not implemented yet..."); 192 /*}}}*/ 193 #elif defined(_HAVE_CODIPACK_) 194 simul_starttrace2(femmodel); 195 IssmDouble* aX=xNew<IssmDouble>(n); 196 auto& tape_codi = IssmDouble::getGlobalTape(); 197 codi_global.input_indices.clear(); 198 if(my_rank==0){ 199 for (int i=0;i<n;i++) { 200 aX[i]=X0[i]; 201 tape_codi.registerInput(aX[i]); 202 codi_global.input_indices.push_back(aX[i].getGradientData()); 203 } 204 } 205 SetControlInputsFromVectorx(femmodel,aX); 206 xDelete(aX); 207 208 if(VerboseControl()) _printf0_(" Compute Initial cost function\n"); 209 solutioncore(femmodel); 210 211 /*Get Dependents*/ 212 IssmDouble output_value; 213 int num_dependents; 214 IssmPDouble *dependents; 215 DataSet* dependent_objects=NULL; 216 IssmDouble J=0.; 217 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 218 femmodel->parameters->FindParam(&dependent_objects,AutodiffDependentObjectsEnum); 219 220 /*Go through our dependent variables, and compute the response:*/ 221 dependents=xNew<IssmPDouble>(num_dependents); 222 codi_global.output_indices.clear(); 223 for(int i=0;i<dependent_objects->Size();i++){ 224 DependentObject* dep=(DependentObject*)dependent_objects->GetObjectByOffset(i); 225 if(solution_type==TransientSolutionEnum){ 226 output_value = dep->GetValue(); 227 } 228 else{ 229 dep->Responsex(&output_value,femmodel); 230 } 231 _printf0_("=== output ="<<output_value<<" \n"); 232 if(my_rank==0) { 233 tape_codi.registerOutput(output_value); 234 dependents[i] = output_value.getValue(); 235 codi_global.output_indices.push_back(output_value.getGradientData()); 236 J+=output_value; 237 } 238 } 239 j0 = J; 240 _printf0_("Initial cost function J(x) = "<<setw(12)<<setprecision(7)<<j0<<"\n"); 241 _assert_(j0>0.); 242 simul_stoptrace2(); 243 /*initialize direction index in the weights vector: */ 244 if(my_rank==0){ 245 tape_codi.setGradient(codi_global.output_indices[0],1.0); 246 } 247 tape_codi.evaluate(); 248 249 /*Get gradient for this dependent */ 250 auto in_size = codi_global.input_indices.size(); 251 for(size_t i = 0; i < in_size; ++i) { 252 G[i] = tape_codi.getGradient(codi_global.input_indices[i]); 253 } 254 #else 255 /*{{{*/ 256 void (*adjointcore)(FemModel*) = NULL; 46 257 AdjointCorePointerFromSolutionEnum(&adjointcore,solution_type); 47 258 … … 59 270 Gradjx(&G,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 60 271 for(int i=0;i<n;i++) G[i] = -G[i]; 272 /*}}}*/ 273 #endif 61 274 62 275 /*Allocate output*/ … … 76 289 SetControlInputsFromVectorx(femmodel,X); 77 290 solutioncore(femmodel); 291 292 #if defined(_HAVE_CODIPACK_) 293 j=0.; 294 for(int i=0;i<dependent_objects->Size();i++){ 295 DependentObject* dep=(DependentObject*)dependent_objects->GetObjectByOffset(i); 296 if(solution_type==TransientSolutionEnum){ 297 output_value = dep->GetValue(); 298 } 299 else{ 300 dep->Responsex(&output_value,femmodel); 301 } 302 j+=output_value; 303 } 304 #else 78 305 femmodel->CostFunctionx(&j,NULL,NULL); 306 #endif 79 307 80 308 IssmDouble Den = 0.; 81 309 for(int i=0;i<n;i++) Den += alpha* G[i] * scaling_factors[0]; 82 310 Ialpha = fabs((j - j0)/Den - 1.); 311 _assert_(fabs(Den)>0.); 83 312 84 313 _printf0_(" " << setw(11) << setprecision (5)<<alpha<<" " << setw(11) << setprecision (5)<<Ialpha<<"\n"); … … 88 317 89 318 /*output*/ 90 #ifdef _HAVE_AD OLC_319 #ifdef _HAVE_AD_ 91 320 IssmPDouble* J_passive=xNew<IssmPDouble>(2*num); 92 321 for(int i=0;i<2*num;i++) J_passive[i]=reCast<IssmPDouble>(output[i]); 93 322 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,JEnum,J_passive,num,2,0,0)); 94 323 xDelete<IssmPDouble>(J_passive); 324 IssmDouble* aG=xNew<IssmDouble>(n); 325 for(int i=0;i<n;i++) aG[i] = G[i]; 326 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,aG); 327 xDelete<IssmDouble>(aG); 95 328 #else 96 329 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,JEnum,output,num,2,0,0)); 330 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,G); 97 331 #endif 98 ControlInputSetGradientx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,G);99 332 femmodel->OutputControlsx(&femmodel->results); 100 333 101 334 /*Clean up and return*/ 102 335 xDelete<IssmDouble>(output); 103 xDelete<Issm Double>(G);336 xDelete<IssmPDouble>(G); 104 337 xDelete<IssmDouble>(X); 105 xDelete< IssmDouble>(X0);338 xDelete<double>(X0); 106 339 xDelete<IssmDouble>(scaling_factors); 107 340 } -
issm/trunk/src/c/cores/damage_core.cpp
r23189 r23394 11 11 12 12 void damage_core(FemModel* femmodel){ 13 13 14 /*Start profiler*/ 15 femmodel->profiler->Start(DAMAGECORE); 16 14 17 /*intermediary*/ 15 18 bool save_results; … … 48 51 xDelete<char*>(requested_outputs); 49 52 } 53 54 /*End profiler*/ 55 femmodel->profiler->Stop(DAMAGECORE); 50 56 } -
issm/trunk/src/c/cores/esa_core.cpp
r23189 r23394 11 11 12 12 void esa_core(FemModel* femmodel){ /*{{{*/ 13 14 /*Start profiler*/ 15 femmodel->profiler->Start(ESACORE); 13 16 14 17 Vector<IssmDouble> *U_radial = NULL; … … 112 115 if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);} 113 116 } 117 118 /*End profiler*/ 119 femmodel->profiler->Stop(ESACORE); 114 120 115 121 } -
issm/trunk/src/c/cores/gia_core.cpp
r23189 r23394 10 10 #include "../solutionsequences/solutionsequences.h" 11 11 void gia_core(FemModel* femmodel){ 12 13 /*Start profiler*/ 14 femmodel->profiler->Start(GIACORE); 12 15 13 16 Vector<IssmDouble> *wg = NULL; … … 56 59 xDelete<IssmDouble>(x); 57 60 xDelete<IssmDouble>(y); 61 62 /*End profiler*/ 63 femmodel->profiler->Stop(GIACORE); 58 64 } -
issm/trunk/src/c/cores/hydrology_core.cpp
r23189 r23394 11 11 12 12 void hydrology_core(FemModel* femmodel){ 13 14 /*Start profiler*/ 15 femmodel->profiler->Start(HYDROLOGYCORE); 13 16 14 17 /*intermediary*/ … … 47 50 /*intermediary: */ 48 51 bool isefficientlayer; 49 bool isthermal;50 52 int step,hydroslices; 51 53 IssmDouble time,init_time,hydrotime,yts; … … 59 61 femmodel->parameters->FindParam(&yts,ConstantsYtsEnum); 60 62 61 femmodel->parameters->FindParam(&isthermal,TransientIsthermalEnum);62 63 /*first we exclude frozen nodes of the solved nodes*/ 63 64 femmodel->SetCurrentConfiguration(HydrologyDCInefficientAnalysisEnum); … … 150 151 xDelete<char*>(requested_outputs); 151 152 } 153 154 /*End profiler*/ 155 femmodel->profiler->Stop(HYDROLOGYCORE); 152 156 } -
issm/trunk/src/c/cores/masstransport_core.cpp
r23189 r23394 11 11 12 12 void masstransport_core(FemModel* femmodel){ 13 14 /*Start profiler*/ 15 femmodel->profiler->Start(MASSTRANSPORTCORE); 13 16 14 17 /*parameters: */ … … 81 84 /*Free ressources:*/ 82 85 if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);} 86 87 /*profiler*/ 88 femmodel->profiler->Stop(MASSTRANSPORTCORE); 83 89 } -
issm/trunk/src/c/cores/movingfront_core.cpp
r22758 r23394 11 11 12 12 void movingfront_core(FemModel* femmodel){ 13 14 /*Start profiler*/ 15 femmodel->profiler->Start(MOVINGFRONTCORE); 13 16 14 17 /* intermediaries */ … … 98 101 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],1); 99 102 } 103 104 /*End profiler*/ 105 femmodel->profiler->Stop(MOVINGFRONTCORE); 100 106 } -
issm/trunk/src/c/cores/sealevelrise_core.cpp
r23189 r23394 13 13 void sealevelrise_core(FemModel* femmodel){ /*{{{*/ 14 14 15 /*Start profiler*/ 16 femmodel->profiler->Start(SLRCORE); 17 15 18 /*Parameters, variables:*/ 16 19 bool save_results; … … 54 57 /*requested dependents: */ 55 58 if(solution_type==SealevelriseSolutionEnum)femmodel->RequestedDependentsx(); 59 60 /*End profiler*/ 61 femmodel->profiler->Stop(SLRCORE); 56 62 } 57 63 /*}}}*/ -
issm/trunk/src/c/cores/smb_core.cpp
r23189 r23394 11 11 12 12 void smb_core(FemModel* femmodel){ 13 13 14 /*Start profiler*/ 15 femmodel->profiler->Start(SMBCORE); 16 14 17 /*parameters: */ 15 18 Analysis* analysis=NULL; … … 45 48 /*Free ressources:*/ 46 49 if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);} 50 51 /*End profiler*/ 52 femmodel->profiler->Stop(SMBCORE); 47 53 } -
issm/trunk/src/c/cores/stressbalance_core.cpp
r23189 r23394 12 12 13 13 void stressbalance_core(FemModel* femmodel){ 14 15 /*Start profiler*/ 16 femmodel->profiler->Start(STRESSBALANCECORE); 14 17 15 18 /*parameters: */ … … 37 40 38 41 if(VerboseSolution()) _printf0_(" computing new velocity\n"); 39 40 42 /*Compute slopes if necessary */ 41 43 if(isSIA || (isFS && domaintype==Domain2DverticalEnum)) surfaceslope_core(femmodel); … … 73 75 /*Compute vertical velocities*/ 74 76 if (domaintype==Domain3DEnum && (isSIA || isSSA || isL1L2 || isHO)){ 77 78 /*We need basal melt rates for vertical velocity*/ 79 bmb_core(femmodel); 80 75 81 analysis = new StressbalanceVerticalAnalysis(); 76 82 analysis->Core(femmodel); … … 87 93 /*Free ressources:*/ 88 94 if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);} 95 96 /*End profiler*/ 97 femmodel->profiler->Stop(STRESSBALANCECORE); 89 98 } -
issm/trunk/src/c/cores/thermal_core.cpp
r20500 r23394 12 12 13 13 void thermal_core(FemModel* femmodel){ 14 14 15 /*Start profiler*/ 16 femmodel->profiler->Start(THERMALCORE); 17 15 18 /*intermediary*/ 16 19 bool save_results,isenthalpy; … … 52 55 /*Free ressources:*/ 53 56 if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);} 54 57 58 /*End profiler*/ 59 femmodel->profiler->Stop(THERMALCORE); 55 60 } -
issm/trunk/src/c/cores/transient_core.cpp
r23189 r23394 70 70 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,TransientRequestedOutputsEnum); 71 71 72 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD OLC_)72 #if defined(_HAVE_BAMG_) && !defined(_HAVE_AD_) 73 73 if(amr_frequency){ 74 74 femmodel->parameters->FindParam(&amr_restart,AmrRestartEnum); … … 78 78 79 79 if(isoceancoupling){ /*{{{*/ 80 #ifndef _HAVE_AD OLC_80 #ifndef _HAVE_AD_ 81 81 if(VerboseSolution()) _printf0_(" ocean coupling: initialization \n"); 82 82 int my_rank; … … 180 180 for(int i=0;i<ngrids_ocean;i++) if(icemask_oceangrid[i]>0.) icebase_oceangrid[i]=+9999.; 181 181 xDelete<IssmDouble>(icemask_oceangrid); 182 182 183 183 if(my_rank==0){ 184 184 ISSM_MPI_Send(icebase_oceangrid,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001008,tomitgcmcomm); … … 247 247 if(isoceancoupling){ /*{{{*/ 248 248 249 #ifndef _HAVE_AD OLC_249 #ifndef _HAVE_AD_ 250 250 if(VerboseSolution()) _printf0_(" ocean coupling: exchanging information\n"); 251 251 int my_rank; … … 371 371 femmodel->parameters->FindParam(&smb_model,SmbEnum); 372 372 if(isenthalpy){ 373 if(smb_model==SMBpddEnum) ResetBoundaryConditions(femmodel,EnthalpyAnalysisEnum); 374 if(smb_model==SMBd18opddEnum) ResetBoundaryConditions(femmodel,EnthalpyAnalysisEnum); 373 if(smb_model==SMBpddEnum) ResetBoundaryConditions(femmodel,EnthalpyAnalysisEnum); 374 if(smb_model==SMBd18opddEnum) ResetBoundaryConditions(femmodel,EnthalpyAnalysisEnum); 375 if(smb_model==SMBpddSicopolisEnum) ResetBoundaryConditions(femmodel,EnthalpyAnalysisEnum); 375 376 } 376 377 else{ 377 if(smb_model==SMBpddEnum) ResetBoundaryConditions(femmodel,ThermalAnalysisEnum); 378 if(smb_model==SMBd18opddEnum) ResetBoundaryConditions(femmodel,ThermalAnalysisEnum); 378 if(smb_model==SMBpddEnum) ResetBoundaryConditions(femmodel,ThermalAnalysisEnum); 379 if(smb_model==SMBd18opddEnum) ResetBoundaryConditions(femmodel,ThermalAnalysisEnum); 380 if(smb_model==SMBpddSicopolisEnum) ResetBoundaryConditions(femmodel,ThermalAnalysisEnum); 379 381 } 380 382 } … … 382 384 } 383 385 386 /*shifting smb position to have runoff value*/ 387 if(issmb) smb_core(femmodel); 388 384 389 if(ishydrology) hydrology_core(femmodel); 385 390 … … 391 396 392 397 /* from here on, prepare geometry for next time step*/ 393 394 if(issmb) smb_core(femmodel); 398 //if(issmb) smb_core(femmodel); 395 399 396 400 if(ismasstransport){ … … 401 405 402 406 if(isgroundingline){ 407 408 /*Start profiler*/ 409 femmodel->profiler->Start(GROUNDINGLINECORE); 410 403 411 if(VerboseSolution()) _printf0_(" computing new grounding line position\n"); 404 412 GroundinglineMigrationx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); … … 410 418 femmodel->parameters->SetParam(SurfaceEnum,InputToExtrudeEnum); 411 419 extrudefrombase_core(femmodel); 420 421 /*Stop profiler*/ 422 femmodel->profiler->Stop(GROUNDINGLINECORE); 412 423 413 424 if(save_results){ … … 453 464 if(amr_frequency){ 454 465 455 #if !defined(_HAVE_AD OLC_)466 #if !defined(_HAVE_AD_) 456 467 if(save_results) femmodel->WriteMeshInResults(); 457 468 if(step%amr_frequency==0 && time<finaltime){ … … 461 472 462 473 #else 463 _error_("AMR not suppored with AD OLC");474 _error_("AMR not suppored with AD"); 464 475 #endif 465 476 } -
issm/trunk/src/c/modules/CoordinateSystemTransformx/CoordinateSystemTransformx.cpp
r22758 r23394 9 9 #include <proj_api.h> 10 10 11 void CoordinateSystemTransformx( IssmDouble** px_dest,IssmDouble** py_dest,IssmDouble* x_src,IssmDouble* y_src,int size,const char* str_src,const char* str_dst){11 void CoordinateSystemTransformx(double** px_dest,double** py_dest,double* x_src,double* y_src,int size,const char* str_src,const char* str_dst){ 12 12 13 13 #if !defined(_HAVE_PROJ4_) … … 17 17 /*Allocate output and initialize values as src*/ 18 18 _assert_(size>0); 19 IssmDouble* x_dest = xNew<IssmDouble>(size);20 IssmDouble* y_dest = xNew<IssmDouble>(size);19 double* x_dest = xNew<double>(size); 20 double* y_dest = xNew<double>(size); 21 21 for(int i=0;i<size;i++){ 22 22 x_dest[i] = x_src[i]; -
issm/trunk/src/c/modules/CoordinateSystemTransformx/CoordinateSystemTransformx.h
r18801 r23394 8 8 9 9 /* local prototypes: */ 10 void CoordinateSystemTransformx( IssmDouble** px_dest,IssmDouble** py_dest,IssmDouble* x_src,IssmDouble* y_src,int size,const char* str_src,const char* str_dst);10 void CoordinateSystemTransformx(double** px_dest,double** py_dest,double* x_src,double* y_src,int size,const char* str_src,const char* str_dst); 11 11 #endif -
issm/trunk/src/c/modules/FloatingiceMeltingRatePicox/FloatingiceMeltingRatePicox.cpp
r23189 r23394 78 78 IssmDouble val=sqrt(dmax_basin[i]/dist_max)*(maxbox-1); 79 79 80 #ifdef _HAVE_ADOLC_ 80 #ifdef _HAVE_AD_ 81 _error_("Check the implementation of floor below"); 81 82 /*Do not use floor when AD is on*/ 82 83 int k=0; while(k<val+.5){k++;} -
issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp
r23189 r23394 78 78 79 79 }/*}}}*/ 80 void GetVectorFromControlInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, const char* data){/*{{{*/80 void GetVectorFromControlInputsx( IssmDouble** pvector,int *pN, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, const char* data){/*{{{*/ 81 81 82 82 /*intermediary: */ 83 int N; 83 84 Vector<IssmDouble>* vec_vector=NULL; 84 85 86 /*Get PETSc vector*/ 85 87 GetVectorFromControlInputsx( &vec_vector, elements,nodes, vertices, loads, materials, parameters,data); 88 89 /*Serialize*/ 90 vec_vector->GetSize(&N); 86 91 IssmDouble* vector=vec_vector->ToMPISerial(); 87 88 /*Free ressources:*/89 92 delete vec_vector; 90 93 91 94 /*Assign output pointers:*/ 92 95 *pvector=vector; 96 if(pN) *pN=N; 93 97 }/*}}}*/ 94 98 95 99 /*For autodiff, we sometimes need to cast our vectors to passive*/ 96 #ifdef _HAVE_ADOLC_ 97 void GetPassiveVectorFromControlInputsx(Vector<IssmPDouble>** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,const char* data){/*{{{*/ 98 99 /*Get active vector first*/ 100 Vector<IssmDouble>* activevector=NULL; 101 Vector<IssmPDouble>* vector=NULL; 102 int size; 103 104 /*Retrieve some parameters*/ 105 GetVectorFromControlInputsx(&activevector, elements,nodes, vertices, loads, materials, parameters,data); 106 107 /*Serialize vector*/ 108 activevector->GetSize(&size); 109 IssmDouble* dactivevector=activevector->ToMPISerial(); 110 111 /*Cast to passive*/ 112 vector=new Vector<IssmPDouble>(size); 113 for(int i=0;i<size;i++){ 114 vector->SetValue(i,reCast<IssmPDouble>(dactivevector[i]),INS_VAL); 115 } 116 vector->Assemble(); 117 118 /*Assign output pointers:*/ 119 delete activevector; 120 xDelete<IssmDouble>(dactivevector); 121 *pvector=vector; 122 123 }/*}}}*/ 124 void GetPassiveVectorFromControlInputsx(IssmPDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, const char* data){/*{{{*/ 100 #ifdef _HAVE_AD_ 101 void GetPassiveVectorFromControlInputsx(IssmPDouble** pvector,int* pN, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, const char* data){/*{{{*/ 125 102 126 103 /*Get active vector first*/ … … 144 121 xDelete<IssmDouble>(dactivevector); 145 122 *pvector=vector; 123 if(pN) *pN=size; 146 124 147 125 }/*}}}*/ 148 126 #else 149 void GetPassiveVectorFromControlInputsx( Vector<IssmPDouble>** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,const char* data){/*{{{*/127 void GetPassiveVectorFromControlInputsx(IssmPDouble** pvector,int* pN, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, const char* data){/*{{{*/ 150 128 151 GetVectorFromControlInputsx(pvector, elements,nodes, vertices, loads, materials, parameters,data); 152 153 }/*}}}*/ 154 void GetPassiveVectorFromControlInputsx(IssmPDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, const char* data){/*{{{*/ 155 156 GetVectorFromControlInputsx(pvector, elements,nodes, vertices, loads, materials, parameters,data); 129 GetVectorFromControlInputsx(pvector,pN,elements,nodes, vertices, loads, materials, parameters,data); 157 130 }/*}}}*/ 158 131 #endif -
issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h
r23189 r23394 9 9 /* local prototypes: */ 10 10 void GetVectorFromControlInputsx( Vector<IssmDouble>** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,const char* data="value"); 11 void GetVectorFromControlInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,const char* data="value");11 void GetVectorFromControlInputsx( IssmDouble** pvector,int* pN, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,const char* data="value"); 12 12 13 void GetPassiveVectorFromControlInputsx(Vector<double>** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,const char* data="value"); 14 void GetPassiveVectorFromControlInputsx(double** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,const char* data="value"); 13 void GetPassiveVectorFromControlInputsx(double** pvector,int* pN, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,const char* data="value"); 15 14 16 15 #endif /* _GETVECTORFROMCONTROLINPUTSXX_H */ -
issm/trunk/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp
r23189 r23394 73 73 xDelete<char>(options); 74 74 /*}}}*/ 75 #elif _HAVE_CODIPACK_ 76 //fprintf(stderr, "*** Codipack CreateParametersAutodiff()\n"); 77 /*initialize a placeholder to store solver pointers: {{{*/ 78 /*Solver pointers depend on what type of solver we are implementing: */ 79 options=OptionsFromAnalysis(&toolkit,parameters,DefaultAnalysisEnum); 80 ToolkitOptions::Init(toolkit,options); 81 xDelete<char>(toolkit); 82 83 switch(IssmSolverTypeFromToolkitOptions()){ 84 case MumpsEnum:{ 85 #ifndef _HAVE_MUMPS_ 86 _error_("CoDiPack: requesting mumps solver without MUMPS being compiled in!"); 87 #endif 88 break; 89 } 90 case GslEnum: { 91 #ifndef _HAVE_GSL_ 92 _error_("CoDiPack: requesting GSL solver without GSL being compiled in!"); 93 #endif 94 break; 95 } 96 default: 97 _error_("solver type not supported yet!"); 98 } 99 /*Free ressources: */ 100 xDelete<char>(options); 101 #endif 102 #if defined(_HAVE_AD_) 75 103 76 104 if(isautodiff){ 77 /*Copy some parameters from IoModel to parameters dataset: {{{*/ 105 #if defined(_HAVE_ADOLC_) 106 /*Copy some parameters from IoModel to parameters dataset*/ 78 107 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.obufsize",AutodiffObufsizeEnum)); 79 108 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.cbufsize",AutodiffCbufsizeEnum)); … … 82 111 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.gcTriggerRatio",AutodiffGcTriggerRatioEnum)); 83 112 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.gcTriggerMaxSize",AutodiffGcTriggerMaxSizeEnum)); 84 /*}}}*/ 113 114 #elif defined(_HAVE_CODIPACK_) 115 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.tapeAlloc",AutodiffTapeAllocEnum)); 116 117 #else 118 _error_("not supported yet"); 119 #endif 120 85 121 /*retrieve driver: {{{*/ 86 122 iomodel->FindConstant(&autodiff_driver,"md.autodiff.driver"); … … 88 124 89 125 if(strcmp(autodiff_driver,"fos_forward")==0){ 126 #if _HAVE_CODIPACK_ 127 // FIXME codi support Foward Mode (scalar) 128 _error_("Foward Mode (scalar) not supported yet!"); 129 #endif 90 130 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.fos_forward_index",AutodiffFosForwardIndexEnum)); 91 131 } … … 94 134 } 95 135 else if(strcmp(autodiff_driver,"fov_forward")==0){ 136 #if _HAVE_CODIPACK_ 137 // FIXME codi support Foward Mode (vector) 138 _error_("Foward Mode (vector) not supported yet!"); 139 #endif 96 140 /*Retrieve list of indices: */ 97 141 iomodel->FetchData(&indices,&num_indices,&dummy,"md.autodiff.fov_forward_indices"); -
issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
r23189 r23394 9 9 #include "../ModelProcessorx.h" 10 10 11 #if !defined(_HAVE_ADOLC_)12 11 void UpdateElementsAndMaterialsControl(Elements* elements,Parameters* parameters,Materials* materials, IoModel* iomodel){ 13 12 /*Intermediary*/ … … 20 19 char **controls = NULL; 21 20 char **cost_functions = NULL; 21 22 /*Fetch parameters: */ 23 bool isautodiff; 24 iomodel->FindConstant(&isautodiff,"md.autodiff.isautodiff"); 25 if(isautodiff){ 26 UpdateElementsAndMaterialsControlAD(elements,parameters,materials,iomodel); 27 return; 28 } 22 29 23 30 /*Fetch parameters: */ … … 126 133 xDelete<char*>(controls); 127 134 } 128 #else 129 void UpdateElementsAndMaterialsControl(Elements* elements,Parameters* parameters,Materials* materials, IoModel* iomodel){ 130 135 void UpdateElementsAndMaterialsControlAD(Elements* elements,Parameters* parameters,Materials* materials, IoModel* iomodel){ 136 137 #if defined(_HAVE_AD_) 131 138 /*Intermediaries*/ 132 139 int num_independent_objects,M,N,M_par,N_par; … … 222 229 xDelete<IssmDouble>(independents_fullmax); 223 230 xDelete<int>(start_point); 231 xDelete<int>(control_sizes); 224 232 /*Step2: create cost functions (dependents)*/ 225 233 226 234 return; 235 #else 236 _error_("AD not compiled"); 237 #endif 227 238 } 228 #endif -
issm/trunk/src/c/modules/ModelProcessorx/CreateNodes.cpp
r23189 r23394 32 32 for(j=0;j<3;j++){ 33 33 if(my_nodes[3*i+j]){ 34 nodes->AddObject(new Node(id0+3*i+j+1,id0+3*i+j,lid++,iomodel->elements[ +3*i+j]-1,iomodel,analysis,approximation));34 nodes->AddObject(new Node(id0+3*i+j+1,id0+3*i+j,lid++,iomodel->elements[3*i+j]-1,iomodel,analysis,approximation)); 35 35 36 36 } -
issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp
r23189 r23394 374 374 ParseToolkitsOptionsx(parameters,toolkitsoptionsfid); 375 375 376 #ifdef _HAVE_AD OLC_376 #ifdef _HAVE_AD_ 377 377 if(VerboseMProcessor()) _printf0_(" starting autodiff parameters \n"); 378 378 CreateParametersAutodiff(parameters,iomodel); -
issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h
r23189 r23394 19 19 void CreateOutputDefinitions(Elements* elements, Parameters* parameters,IoModel* iomodel); 20 20 void UpdateElementsAndMaterialsControl(Elements* elements,Parameters* parameters,Materials* materials, IoModel* iomodel); 21 void UpdateElementsAndMaterialsControlAD(Elements* elements,Parameters* parameters,Materials* materials, IoModel* iomodel); 21 22 void UpdateElementsAndMaterialsDakota(Elements* elements,Materials* materials, IoModel* iomodel); 22 23 void UpdateElementsTransient(Elements* elements,Parameters* parameters,IoModel* iomodel,int analysis_type); -
issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp
r23189 r23394 33 33 34 34 xDelete<int>(control_type); 35 xDelete<int>(M); 36 xDelete<int>(N); 35 37 } 36 38 else{ -
issm/trunk/src/c/modules/SurfaceMassBalancex/Gembx.cpp
r23189 r23394 62 62 //into specified top structure depth (zTop). Also make sure top grid cell 63 63 //structure length (dzTop) is greater than 5 cm 64 #ifndef _HAVE_AD OLC_ //avoid the round operation check!64 #ifndef _HAVE_AD_ //avoid the round operation check! 65 65 if (dgpTop != round(dgpTop)){ 66 66 _error_("top grid cell structure length does not go evenly into specified top structure depth, adjust dzTop or zTop"); … … 425 425 // spectral range: 426 426 // 0.3 - 0.8um 427 IssmDouble a0 = fmin(0.98, 1 - 1.58 *pow(gsz,0.5));427 IssmDouble a0 = min(0.98, 1 - 1.58 *pow(gsz,0.5)); 428 428 // 0.8 - 1.5um 429 IssmDouble a1 = fmax(0, 0.95 - 15.4 *pow(gsz,0.5));429 IssmDouble a1 = max(0., 0.95 - 15.4 *pow(gsz,0.5)); 430 430 // 1.5 - 2.8um 431 IssmDouble a2 = fmax(0.127, 0.88 + 346.3*gsz - 32.31*pow(gsz,0.5));431 IssmDouble a2 = max(0.127, 0.88 + 346.3*gsz - 32.31*pow(gsz,0.5)); 432 432 433 433 // broadband surface albedo … … 667 667 // NS: 2.16.18 divided dt by scaling factor, default set to 1/11 for stability 668 668 dt=1e12; 669 for(int i=0;i<m;i++)dt = fmin(dt,CI * pow(dz[i],2) * d[i] / (3 * K[i]) * thermo_scaling);669 for(int i=0;i<m;i++)dt = min(dt,CI * pow(dz[i],2) * d[i] / (3 * K[i]) * thermo_scaling); 670 670 671 671 // smallest possible even integer of 60 min where diffusion number > 1/2 … … 752 752 // less when Ts is taken as the mean of the x top grid cells. 753 753 Ts = (T[0] + T[1])/2.0; 754 Ts = fmin(CtoK,Ts); // don't allow Ts to exceed 273.15 K (0 degC)754 Ts = min(CtoK,Ts); // don't allow Ts to exceed 273.15 K (0 degC) 755 755 756 756 //TURBULENT HEAT FLUX … … 767 767 768 768 // do not allow Ri to exceed 0.19 769 Ri = fmin(Ri, 0.19);769 Ri = min(Ri, 0.19); 770 770 771 771 // calculate momentum 'coefM' stability factor … … 947 947 // spectral albedos: 948 948 // 0.3 - 0.8um 949 IssmDouble a0 = fmin(0.98, 1.0 - 1.58 *pow(gsz[0],0.5));949 IssmDouble a0 = min(0.98, 1.0 - 1.58 *pow(gsz[0],0.5)); 950 950 // 0.8 - 1.5um 951 IssmDouble a1 = fmax(0.0, 0.95 - 15.4 *pow(gsz[0],0.5));951 IssmDouble a1 = max(0.0, 0.95 - 15.4 *pow(gsz[0],0.5)); 952 952 // 1.5 - 2.8um 953 IssmDouble a2 = fmax(0.127, 0.88 + 346.3*gsz[0] - 32.31*pow(gsz[0],0.5));953 IssmDouble a2 = max(0.127, 0.88 + 346.3*gsz[0] - 32.31*pow(gsz[0],0.5)); 954 954 955 955 // separate net shortwave radiative flux into spectral ranges … … 1204 1204 mass_diff = mass - massinit - P; 1205 1205 1206 #ifndef _HAVE_AD OLC_ //avoid round operation. only check in forward mode.1206 #ifndef _HAVE_AD_ //avoid round operation. only check in forward mode. 1207 1207 mass_diff = round(mass_diff * 100.0)/100.0; 1208 1208 if (mass_diff > 0) _error_("mass not conserved in accumulation function"); … … 1323 1323 // calculate temperature excess above 0 deg C 1324 1324 exsT=xNewZeroInit<IssmDouble>(n); 1325 for(int i=0;i<n;i++) exsT[i]= fmax(0.0, T[i] - CtoK); // [K] to [degC]1325 for(int i=0;i<n;i++) exsT[i]= max(0.0, T[i] - CtoK); // [K] to [degC] 1326 1326 1327 1327 // new grid point center temperature, T [K] 1328 1328 // for(int i=0;i<n;i++) T[i]-=exsT[i]; 1329 for(int i=0;i<n;i++) T[i]= fmin(T[i],CtoK);1329 for(int i=0;i<n;i++) T[i]=min(T[i],CtoK); 1330 1330 1331 1331 // specify irreducible water content saturation [fraction] … … 1337 1337 if(VerboseSmb() && sid==0 && IssmComm::GetRank()==0)_printf0_(" pore water refreeze\n"); 1338 1338 // calculate maximum freeze amount, maxF [kg] 1339 for(int i=0;i<n;i++) maxF[i] = fmax(0.0, -((T[i] - CtoK) * m[i] * CI) / LF);1339 for(int i=0;i<n;i++) maxF[i] = max(0.0, -((T[i] - CtoK) * m[i] * CI) / LF); 1340 1340 1341 1341 // freeze pore water and change snow/ice properties 1342 for(int i=0;i<n;i++) dW[i] = fmin(maxF[i], W[i]); // freeze mass [kg]1342 for(int i=0;i<n;i++) dW[i] = min(maxF[i], W[i]); // freeze mass [kg] 1343 1343 for(int i=0;i<n;i++) W[i] -= dW[i]; // pore water mass [kg] 1344 1344 for(int i=0;i<n;i++) m[i] += dW[i]; // new mass [kg] … … 1356 1356 for(int i=0;i<n;i++){ 1357 1357 Wi= (dIce - d[i]) * Swi * (m[i] / d[i]); // irreducible water content [kg] 1358 exsW[i] = fmax(0.0, W[i] - Wi); // water "squeezed" from snow [kg]1358 exsW[i] = max(0.0, W[i] - Wi); // water "squeezed" from snow [kg] 1359 1359 } 1360 1360 … … 1368 1368 // (maximum T of snow before entire grid cell melts is a constant 1369 1369 // LF/CI = 159.1342) 1370 surpT=xNew<IssmDouble>(n); for(int i=0;i<n;i++)surpT[i] = fmax(0.0, exsT[i]- LF/CI);1370 surpT=xNew<IssmDouble>(n); for(int i=0;i<n;i++)surpT[i] = max(0.0, exsT[i]- LF/CI); 1371 1371 1372 1372 if (cellsum(surpT,n) > 0.0 + Ttol ){ … … 1380 1380 T[i+1] = surpE[i]/m[i+1]/CI + T[i+1]; 1381 1381 1382 exsT[i+1] = fmax(0.0, T[i+1] - CtoK) + exsT[i+1];1383 T[i+1] = fmin(CtoK, T[i+1]);1384 1385 surpT[i+1] = fmax(0.0, exsT[i+1] - LF/CI);1382 exsT[i+1] = max(0.0, T[i+1] - CtoK) + exsT[i+1]; 1383 T[i+1] = min(CtoK, T[i+1]); 1384 1385 surpT[i+1] = max(0.0, exsT[i+1] - LF/CI); 1386 1386 surpE[i+1] = surpT[i+1] * CI * m[i+1]; 1387 1387 … … 1394 1394 1395 1395 // convert temperature excess to melt [kg] 1396 for(int i=0;i<n;i++) M[i] = fmin(exsT[i] * d[i] * dz[i] * CI / LF, m[i]); // melt1396 for(int i=0;i<n;i++) M[i] = min(exsT[i] * d[i] * dz[i] * CI / LF, m[i]); // melt 1397 1397 sumM = cellsum(M,n); // total melt [kg] 1398 1398 1399 1399 // calculate maximum refreeze amount, maxF [kg] 1400 for(int i=0;i<n;i++)maxF[i] = fmax(0.0, -((T[i] - CtoK) * d[i] * dz[i] * CI)/ LF);1400 for(int i=0;i<n;i++)maxF[i] = max(0.0, -((T[i] - CtoK) * d[i] * dz[i] * CI)/ LF); 1401 1401 1402 1402 // initialize refreeze, runoff, flxDn and dW vectors [kg] … … 1435 1435 m[i] = m[i] - M[i]; // mass after melt 1436 1436 Wi = (dIce-d[i]) * Swi * (m[i]/d[i]); // irreducible water 1437 dW[i] = fmax(fmin(inM, Wi - W[i]),-1*W[i]); // change in pore water1438 R[i] = fmax(0.0, inM - dW[i]); // runoff1437 dW[i] = max(min(inM, Wi - W[i]),-1*W[i]); // change in pore water 1438 R[i] = max(0.0, inM - dW[i]); // runoff 1439 1439 F[i] = 0.0; 1440 1440 } … … 1447 1447 m[i] = m[i] - M[i]; // mass after melt 1448 1448 Wi = (dIce-d[i]) * Swi * (m[i]/d[i]); // irreducible water 1449 dW[i] = fmax(fmin(inM, Wi - W[i]),-1*W[i]); // change in pore water1450 flxDn[i+1] = fmax(0.0, inM - dW[i]); // meltwater out1449 dW[i] = max(min(inM, Wi - W[i]),-1*W[i]); // change in pore water 1450 flxDn[i+1] = max(0.0, inM - dW[i]); // meltwater out 1451 1451 R[i] = 0.0; 1452 1452 F[i] = 0.0; // no freeze … … 1460 1460 IssmDouble dz_0 = m[i]/d[i]; 1461 1461 IssmDouble dMax = (dIce - d[i])*dz_0; // d max = dIce 1462 IssmDouble F1 = fmin(fmin(inM,dMax),maxF[i]); // maximum refreeze1462 IssmDouble F1 = min(min(inM,dMax),maxF[i]); // maximum refreeze 1463 1463 m[i] = m[i] + F1; // mass after refreeze 1464 1464 d[i] = m[i]/dz_0; … … 1466 1466 //-----------------------pore water----------------------------- 1467 1467 Wi = (dIce-d[i])* Swi * dz_0; // irreducible water 1468 dW[i] = fmin(inM - F1, Wi-W[i]); // change in pore water1468 dW[i] = min(inM - F1, Wi-W[i]); // change in pore water 1469 1469 if (dW[i] < 0.0-Wtol && -1*dW[i]>W[i]-Wtol ){ 1470 1470 dW[i]= -1*W[i]; … … 1474 1474 if (dW[i] < 0.0-Wtol){ // excess pore water 1475 1475 dMax = (dIce - d[i])*dz_0; // maximum refreeze 1476 IssmDouble maxF2 = fmin(dMax, maxF[i]-F1); // maximum refreeze1477 F2 = fmin(-1*dW[i], maxF2); // pore water refreeze1476 IssmDouble maxF2 = min(dMax, maxF[i]-F1); // maximum refreeze 1477 F2 = min(-1*dW[i], maxF2); // pore water refreeze 1478 1478 m[i] = m[i] + F2; // mass after refreeze 1479 1479 d[i] = m[i]/dz_0; … … 1753 1753 1754 1754 /*only in forward mode! avoid round in AD mode as it is not differentiable: */ 1755 #ifndef _HAVE_AD OLC_1755 #ifndef _HAVE_AD_ 1756 1756 dm = round((mSum0 - mSum1 + mAdd)*100.0)/100.0; 1757 1757 dE = round(sumE0 - sumE1 - sumER + addE); … … 1915 1915 c0arth = 0.07 * H; 1916 1916 c1arth = 0.03 * H; 1917 M0 = fmax(1.435 - (0.151 * log(C)),0.25);1918 M1 = fmax(2.366 - (0.293 * log(C)),0.25);1917 M0 = max(1.435 - (0.151 * log(C)),0.25); 1918 M1 = max(2.366 - (0.293 * log(C)),0.25); 1919 1919 c0 = M0*c0arth; 1920 1920 c1 = M1*c1arth; … … 1926 1926 c0arth = 0.07 * H; 1927 1927 c1arth = 0.03 * H; 1928 M0 = fmax(1.042 - (0.0916 * log(C)),0.25);1929 M1 = fmax(1.734 - (0.2039 * log(C)),0.25);1928 M0 = max(1.042 - (0.0916 * log(C)),0.25); 1929 M1 = max(1.734 - (0.2039 * log(C)),0.25); 1930 1930 c0 = M0*c0arth; 1931 1931 c1 = M1*c1arth; … … 2021 2021 2022 2022 // do not allow Ri to exceed 0.19 2023 Ri = fmin(Ri, 0.19);2023 Ri = min(Ri, 0.19); 2024 2024 2025 2025 // calculate momentum 'coefM' stability factor -
issm/trunk/src/c/modules/SurfaceMassBalancex/SurfaceMassBalancex.cpp
r23189 r23394 1 1 /*!\file SurfaceMassBalancex 2 * \brief: calculates SMB 2 * \brief: calculates SMB 3 3 */ 4 4 … … 105 105 for(v=0;v<numvertices;v++){ 106 106 // if surface is above the ELA 107 if(s[v]>ela[v]){ 107 if(s[v]>ela[v]){ 108 108 smb[v]=b_pos[v]*(s[v]-ela[v]); 109 109 } … … 167 167 // INPUT: surface elevation (m): hd(NA) 168 168 // monthly mean surface sealevel temperature (degrees C): vTempsea(NA 169 // ,NTIME) 169 // ,NTIME) 170 170 // monthly mean precip rate (m/yr water equivalent): vPrec(NA,NTIME) 171 171 // OUTPUT: mass-balance (m/yr ice): agd(NA) … … 174 174 int i, it, jj, itm; 175 175 IssmDouble DT = 0.02, sigfac, snormfac; 176 IssmDouble signorm = 5.5; // signorm : sigma of the temperature distribution for a normal day 176 IssmDouble signorm = 5.5; // signorm : sigma of the temperature distribution for a normal day 177 177 IssmDouble siglim; // sigma limit for the integration which is equal to 2.5 sigmanorm 178 178 IssmDouble signormc = signorm - 0.5; // sigma of the temperature distribution for cloudy day … … 180 180 IssmDouble tstep, tsint, tint, tstepc; 181 181 int NPDMAX = 1504, NPDCMAX = 1454; 182 //IssmDouble pdds[NPDMAX]={0}; 182 //IssmDouble pdds[NPDMAX]={0}; 183 183 //IssmDouble pds[NPDCMAX]={0}; 184 184 IssmDouble pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow … … 193 193 Element *element = NULL; 194 194 195 pdds=xNew<IssmDouble>(NPDMAX+1); 196 pds=xNew<IssmDouble>(NPDCMAX+1); 195 pdds=xNew<IssmDouble>(NPDMAX+1); 196 pds=xNew<IssmDouble>(NPDCMAX+1); 197 197 198 198 // Get ismungsm parameter … … 216 216 217 217 if(itm >= NPDMAX) _error_("increase NPDMAX in massBalance.cpp"); 218 for(it = 0; it < itm; it++){ 218 for(it = 0; it < itm; it++){ 219 219 // tstar = REAL(it)*DT-siglim; 220 220 tstar = it*DT-siglim; … … 262 262 xDelete<IssmDouble>(pds); 263 263 }/*}}}*/ 264 void PositiveDegreeDaySicopolisx(FemModel* femmodel){/*{{{*/ 265 266 bool isfirnwarming; 267 femmodel->parameters->FindParam(&isfirnwarming,SmbIsfirnwarmingEnum); 268 269 for(int i=0;i<femmodel->elements->Size();i++){ 270 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 271 element->PositiveDegreeDaySicopolis(isfirnwarming); 272 } 273 274 }/*}}}*/ 264 275 void SmbHenningx(FemModel* femmodel){/*{{{*/ 265 276 … … 346 357 /*Allocate all arrays*/ 347 358 int numvertices = element->GetNumberOfVertices(); 348 IssmDouble* acc = xNew<IssmDouble>(numvertices); 359 IssmDouble* acc = xNew<IssmDouble>(numvertices); 349 360 IssmDouble* evap = xNew<IssmDouble>(numvertices); 350 IssmDouble* runoff = xNew<IssmDouble>(numvertices); 361 IssmDouble* runoff = xNew<IssmDouble>(numvertices); 351 362 IssmDouble* smb = xNew<IssmDouble>(numvertices); 352 363 … … 388 399 int numvertices = element->GetNumberOfVertices(); 389 400 IssmDouble* acc = xNew<IssmDouble>(numvertices); 390 IssmDouble* evap = xNew<IssmDouble>(numvertices); 401 IssmDouble* evap = xNew<IssmDouble>(numvertices); 391 402 IssmDouble* melt = xNew<IssmDouble>(numvertices); 392 403 IssmDouble* refreeze = xNew<IssmDouble>(numvertices); … … 414 425 415 426 }/*}}}*/ 427 void SmbGradientsComponentsx(FemModel* femmodel){/*{{{*/ 428 429 // void SurfaceMassBalancex(hd,agd,ni){ 430 // INPUT parameters: ni: working size of arrays 431 // INPUT: surface elevation (m): hd(NA) 432 // OUTPUT: mass-balance (m/yr ice): agd(NA) 433 434 for(int i=0;i<femmodel->elements->Size();i++){ 435 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 436 element->SmbGradCompParameterization(); 437 } 438 439 }/*}}}*/ -
issm/trunk/src/c/modules/SurfaceMassBalancex/SurfaceMassBalancex.h
r22758 r23394 1 1 /*!\file: SurfaceMassBalancex.h 2 2 * \brief header file for SMB 3 */ 3 */ 4 4 5 5 #ifndef _SurfaceMassBalancex_H … … 16 16 void Delta18opdParameterizationx(FemModel* femmodel); 17 17 void PositiveDegreeDayx(FemModel* femmodel); 18 void PositiveDegreeDaySicopolisx(FemModel* femmodel); 18 19 void SmbHenningx(FemModel* femmodel); 19 20 void SmbComponentsx(FemModel* femmodel); 20 void SmbMeltComponentsx(FemModel* femmodel); 21 21 void SmbMeltComponentsx(FemModel* femmodel); 22 void SmbGradientsComponentsx(FemModel* femmodel); 22 23 /*GEMB: */ 23 24 void Gembx(FemModel* femmodel); 24 void GembgridInitialize(IssmDouble** pdz, int* psize, IssmDouble zTop, IssmDouble dzTop, IssmDouble zMax, IssmDouble zY); 25 void GembgridInitialize(IssmDouble** pdz, int* psize, IssmDouble zTop, IssmDouble dzTop, IssmDouble zMax, IssmDouble zY); 25 26 IssmDouble Marbouty(IssmDouble T, IssmDouble d, IssmDouble dT); 26 27 void grainGrowth(IssmDouble** pre, IssmDouble** pgdn, IssmDouble** pgsp, IssmDouble* T,IssmDouble* dz,IssmDouble* d, IssmDouble* W,IssmDouble smb_dt,int m,int aIdx, int sid); … … 28 29 void shortwave(IssmDouble** pswf, int swIdx, int aIdx, IssmDouble dsw, IssmDouble as, IssmDouble* d, IssmDouble* dz, IssmDouble* re, IssmDouble dIce, int m, int sid); 29 30 void thermo(IssmDouble* pEC, IssmDouble** T, IssmDouble* dz, IssmDouble* d, IssmDouble* swf, IssmDouble dlw, IssmDouble Ta, IssmDouble V, IssmDouble eAir, IssmDouble pAir, IssmDouble teValue, IssmDouble Ws, IssmDouble dt0, int m, IssmDouble Vz, IssmDouble Tz, IssmDouble thermo_scaling, IssmDouble dIce, int sid); 30 void accumulation(IssmDouble** pT, IssmDouble** pdz, IssmDouble** pd, IssmDouble** pW, IssmDouble** pa, IssmDouble** pre, IssmDouble** pgdn, IssmDouble** pgsp, int* pm, int aIdx,IssmDouble Ta, IssmDouble P, IssmDouble dzMin, IssmDouble aSnow, IssmDouble dIce, int sid); 31 void accumulation(IssmDouble** pT, IssmDouble** pdz, IssmDouble** pd, IssmDouble** pW, IssmDouble** pa, IssmDouble** pre, IssmDouble** pgdn, IssmDouble** pgsp, int* pm, int aIdx,IssmDouble Ta, IssmDouble P, IssmDouble dzMin, IssmDouble aSnow, IssmDouble dIce, int sid); 31 32 void melt(IssmDouble* pM, IssmDouble* pR, IssmDouble* pmAdd, IssmDouble* pdz_add, IssmDouble** pT, IssmDouble** pd, IssmDouble** pdz, IssmDouble** pW, IssmDouble** pa, IssmDouble** pre, IssmDouble** pgdn, IssmDouble** pgsp, int* pn, IssmDouble dzMin, IssmDouble zMax, IssmDouble zMin, IssmDouble zTop, IssmDouble dIce, int sid); 32 33 void densification(IssmDouble** pd,IssmDouble** pdz, IssmDouble* T, IssmDouble* re, int denIdx, IssmDouble C, IssmDouble dt, IssmDouble Tmean, IssmDouble dIce, int m, int sid); -
issm/trunk/src/c/shared/Elements/PrintArrays.cpp
r23189 r23394 12 12 _printf_("\n"); 13 13 } 14 #ifdef _HAVE_AD OLC_14 #ifdef _HAVE_AD_ 15 15 void printarray(IssmDouble* array,int lines,int cols){ 16 16 _printf_("\n"); -
issm/trunk/src/c/shared/Elements/elements.h
r23189 r23394 24 24 IssmDouble TdiffTime,IssmDouble sealevTime,IssmDouble pddsnowfac,IssmDouble pddicefac, 25 25 IssmDouble rho_water, IssmDouble rho_ice); 26 IssmDouble PddSurfaceMassBalanceSicopolis(IssmDouble* monthlytemperatures, IssmDouble* monthlyprec, 27 IssmDouble* melt, IssmDouble* accu, IssmDouble* melt_star, IssmDouble* t_ampl, IssmDouble* p_ampl, 28 IssmDouble yts, IssmDouble s, IssmDouble desfac,IssmDouble s0t, 29 IssmDouble s0p, IssmDouble rlaps, IssmDouble rho_water, IssmDouble rho_ice); 26 30 void ComputeDelta18oTemperaturePrecipitation(IssmDouble Delta18oSurfacePresent, IssmDouble Delta18oSurfaceLgm, IssmDouble Delta18oSurfaceTime, 27 31 IssmDouble Delta18oPresent, IssmDouble Delta18oLgm, IssmDouble Delta18oTime, … … 42 46 /*Print arrays*/ 43 47 void printarray(IssmPDouble* array,int lines,int cols=1); 44 #if _HAVE_AD OLC_ && !defined(_WRAPPERS_)48 #if _HAVE_AD_ && !defined(_WRAPPERS_) 45 49 void printarray(IssmDouble* array,int lines,int cols=1); 46 50 #endif -
issm/trunk/src/c/shared/Enum/EnumDefinitions.h
r23189 r23394 53 53 AutodiffNumIndependentsEnum, 54 54 AutodiffObufsizeEnum, 55 AutodiffTapeAllocEnum, 55 56 AutodiffTbufsizeEnum, 56 57 AutodiffXpEnum, … … 272 273 SettingsSolverResidueThresholdEnum, 273 274 SettingsWaitonlockEnum, 275 SmbAccualtiEnum, 276 SmbAccugradEnum, 277 SmbAccurefEnum, 274 278 SmbAdThreshEnum, 275 279 SmbAIceEnum, … … 290 294 SmbIsdensificationEnum, 291 295 SmbIsgraingrowthEnum, 296 SmbIsfirnwarmingEnum, 292 297 SmbIsmeltEnum, 293 298 SmbIsmungsmEnum, … … 302 307 SmbPfacEnum, 303 308 SmbRequestedOutputsEnum, 309 SmbRunoffaltiEnum, 310 SmbRunoffgradEnum, 311 SmbRunoffrefEnum, 304 312 SmbSealevEnum, 305 313 SmbSwIdxEnum, … … 526 534 SealevelNEsaRateEnum, 527 535 SealevelRSLRateEnum, 528 SealevelUEsaEnum, 536 SealevelUEsaEnum, 529 537 SealevelRSLEustaticRateEnum, 530 SealevelNEsaEnum, 538 SealevelNEsaEnum, 531 539 SealevelUGiaEnum, 532 540 SealevelNGiaEnum, … … 577 585 SmbPEnum, 578 586 SmbPrecipitationEnum, 587 SmbPrecipitationsAnomalyEnum, 579 588 SmbPrecipitationsLgmEnum, 580 589 SmbPrecipitationsPresentdayEnum, … … 588 597 SmbSizeiniEnum, 589 598 SmbSmbrefEnum, 599 SmbSmbCorrEnum, 590 600 SmbTaEnum, 601 SmbTemperaturesAnomalyEnum, 591 602 SmbTemperaturesLgmEnum, 592 603 SmbTemperaturesPresentdayEnum, … … 1095 1106 SMBmeltcomponentsEnum, 1096 1107 SMBpddEnum, 1108 SMBpddSicopolisEnum, 1109 SMBgradientscomponentsEnum, 1097 1110 SmbRlapsEnum, 1098 1111 SmbRlapslgmEnum, -
issm/trunk/src/c/shared/Enum/EnumToStringx.cpp
r23189 r23394 61 61 case AutodiffNumIndependentsEnum : return "AutodiffNumIndependents"; 62 62 case AutodiffObufsizeEnum : return "AutodiffObufsize"; 63 case AutodiffTapeAllocEnum : return "AutodiffTapeAlloc"; 63 64 case AutodiffTbufsizeEnum : return "AutodiffTbufsize"; 64 65 case AutodiffXpEnum : return "AutodiffXp"; … … 280 281 case SettingsSolverResidueThresholdEnum : return "SettingsSolverResidueThreshold"; 281 282 case SettingsWaitonlockEnum : return "SettingsWaitonlock"; 283 case SmbAccualtiEnum : return "SmbAccualti"; 284 case SmbAccugradEnum : return "SmbAccugrad"; 285 case SmbAccurefEnum : return "SmbAccuref"; 282 286 case SmbAdThreshEnum : return "SmbAdThresh"; 283 287 case SmbAIceEnum : return "SmbAIce"; … … 298 302 case SmbIsdensificationEnum : return "SmbIsdensification"; 299 303 case SmbIsgraingrowthEnum : return "SmbIsgraingrowth"; 304 case SmbIsfirnwarmingEnum : return "SmbIsfirnwarming"; 300 305 case SmbIsmeltEnum : return "SmbIsmelt"; 301 306 case SmbIsmungsmEnum : return "SmbIsmungsm"; … … 310 315 case SmbPfacEnum : return "SmbPfac"; 311 316 case SmbRequestedOutputsEnum : return "SmbRequestedOutputs"; 317 case SmbRunoffaltiEnum : return "SmbRunoffalti"; 318 case SmbRunoffgradEnum : return "SmbRunoffgrad"; 319 case SmbRunoffrefEnum : return "SmbRunoffref"; 312 320 case SmbSealevEnum : return "SmbSealev"; 313 321 case SmbSwIdxEnum : return "SmbSwIdx"; … … 583 591 case SmbPEnum : return "SmbP"; 584 592 case SmbPrecipitationEnum : return "SmbPrecipitation"; 593 case SmbPrecipitationsAnomalyEnum : return "SmbPrecipitationsAnomaly"; 585 594 case SmbPrecipitationsLgmEnum : return "SmbPrecipitationsLgm"; 586 595 case SmbPrecipitationsPresentdayEnum : return "SmbPrecipitationsPresentday"; … … 594 603 case SmbSizeiniEnum : return "SmbSizeini"; 595 604 case SmbSmbrefEnum : return "SmbSmbref"; 605 case SmbSmbCorrEnum : return "SmbSmbCorr"; 596 606 case SmbTaEnum : return "SmbTa"; 607 case SmbTemperaturesAnomalyEnum : return "SmbTemperaturesAnomaly"; 597 608 case SmbTemperaturesLgmEnum : return "SmbTemperaturesLgm"; 598 609 case SmbTemperaturesPresentdayEnum : return "SmbTemperaturesPresentday"; … … 1099 1110 case SMBmeltcomponentsEnum : return "SMBmeltcomponents"; 1100 1111 case SMBpddEnum : return "SMBpdd"; 1112 case SMBpddSicopolisEnum : return "SMBpddSicopolis"; 1113 case SMBgradientscomponentsEnum : return "SMBgradientscomponents"; 1101 1114 case SmbRlapsEnum : return "SmbRlaps"; 1102 1115 case SmbRlapslgmEnum : return "SmbRlapslgm"; -
issm/trunk/src/c/shared/Enum/StringToEnumx.cpp
r23189 r23394 61 61 else if (strcmp(name,"AutodiffNumIndependents")==0) return AutodiffNumIndependentsEnum; 62 62 else if (strcmp(name,"AutodiffObufsize")==0) return AutodiffObufsizeEnum; 63 else if (strcmp(name,"AutodiffTapeAlloc")==0) return AutodiffTapeAllocEnum; 63 64 else if (strcmp(name,"AutodiffTbufsize")==0) return AutodiffTbufsizeEnum; 64 65 else if (strcmp(name,"AutodiffXp")==0) return AutodiffXpEnum; … … 136 137 else if (strcmp(name,"FrictionLaw")==0) return FrictionLawEnum; 137 138 else if (strcmp(name,"FrictionPseudoplasticityExponent")==0) return FrictionPseudoplasticityExponentEnum; 138 else if (strcmp(name,"FrictionThresholdSpeed")==0) return FrictionThresholdSpeedEnum;139 139 else stage=2; 140 140 } 141 141 if(stage==2){ 142 if (strcmp(name,"FrictionDelta")==0) return FrictionDeltaEnum; 142 if (strcmp(name,"FrictionThresholdSpeed")==0) return FrictionThresholdSpeedEnum; 143 else if (strcmp(name,"FrictionDelta")==0) return FrictionDeltaEnum; 143 144 else if (strcmp(name,"FrictionVoidRatio")==0) return FrictionVoidRatioEnum; 144 145 else if (strcmp(name,"GiaCrossSectionShape")==0) return GiaCrossSectionShapeEnum; … … 259 260 else if (strcmp(name,"SealevelriseFluidLove")==0) return SealevelriseFluidLoveEnum; 260 261 else if (strcmp(name,"SealevelriseGElastic")==0) return SealevelriseGElasticEnum; 261 else if (strcmp(name,"SealevelriseGeodetic")==0) return SealevelriseGeodeticEnum;262 262 else stage=3; 263 263 } 264 264 if(stage==3){ 265 if (strcmp(name,"SealevelriseGeodeticRunFrequency")==0) return SealevelriseGeodeticRunFrequencyEnum; 265 if (strcmp(name,"SealevelriseGeodetic")==0) return SealevelriseGeodeticEnum; 266 else if (strcmp(name,"SealevelriseGeodeticRunFrequency")==0) return SealevelriseGeodeticRunFrequencyEnum; 266 267 else if (strcmp(name,"SealevelriseHElastic")==0) return SealevelriseHElasticEnum; 267 268 else if (strcmp(name,"SealevelriseHoriz")==0) return SealevelriseHorizEnum; … … 286 287 else if (strcmp(name,"SettingsSolverResidueThreshold")==0) return SettingsSolverResidueThresholdEnum; 287 288 else if (strcmp(name,"SettingsWaitonlock")==0) return SettingsWaitonlockEnum; 289 else if (strcmp(name,"SmbAccualti")==0) return SmbAccualtiEnum; 290 else if (strcmp(name,"SmbAccugrad")==0) return SmbAccugradEnum; 291 else if (strcmp(name,"SmbAccuref")==0) return SmbAccurefEnum; 288 292 else if (strcmp(name,"SmbAdThresh")==0) return SmbAdThreshEnum; 289 293 else if (strcmp(name,"SmbAIce")==0) return SmbAIceEnum; … … 304 308 else if (strcmp(name,"SmbIsdensification")==0) return SmbIsdensificationEnum; 305 309 else if (strcmp(name,"SmbIsgraingrowth")==0) return SmbIsgraingrowthEnum; 310 else if (strcmp(name,"SmbIsfirnwarming")==0) return SmbIsfirnwarmingEnum; 306 311 else if (strcmp(name,"SmbIsmelt")==0) return SmbIsmeltEnum; 307 312 else if (strcmp(name,"SmbIsmungsm")==0) return SmbIsmungsmEnum; … … 316 321 else if (strcmp(name,"SmbPfac")==0) return SmbPfacEnum; 317 322 else if (strcmp(name,"SmbRequestedOutputs")==0) return SmbRequestedOutputsEnum; 323 else if (strcmp(name,"SmbRunoffalti")==0) return SmbRunoffaltiEnum; 324 else if (strcmp(name,"SmbRunoffgrad")==0) return SmbRunoffgradEnum; 325 else if (strcmp(name,"SmbRunoffref")==0) return SmbRunoffrefEnum; 318 326 else if (strcmp(name,"SmbSealev")==0) return SmbSealevEnum; 319 327 else if (strcmp(name,"SmbSwIdx")==0) return SmbSwIdxEnum; … … 375 383 else if (strcmp(name,"TransientIsmovingfront")==0) return TransientIsmovingfrontEnum; 376 384 else if (strcmp(name,"TransientIsoceancoupling")==0) return TransientIsoceancouplingEnum; 377 else if (strcmp(name,"TransientIsslr")==0) return TransientIsslrEnum; 385 else stage=4; 386 } 387 if(stage==4){ 388 if (strcmp(name,"TransientIsslr")==0) return TransientIsslrEnum; 378 389 else if (strcmp(name,"TransientIssmb")==0) return TransientIssmbEnum; 379 390 else if (strcmp(name,"TransientIsstressbalance")==0) return TransientIsstressbalanceEnum; … … 383 394 else if (strcmp(name,"Velocity")==0) return VelocityEnum; 384 395 else if (strcmp(name,"WorldComm")==0) return WorldCommEnum; 385 else stage=4; 386 } 387 if(stage==4){ 388 if (strcmp(name,"ParametersEND")==0) return ParametersENDEnum; 396 else if (strcmp(name,"ParametersEND")==0) return ParametersENDEnum; 389 397 else if (strcmp(name,"InputsSTART")==0) return InputsSTARTEnum; 390 398 else if (strcmp(name,"Adjoint")==0) return AdjointEnum; … … 498 506 else if (strcmp(name,"Ice")==0) return IceEnum; 499 507 else if (strcmp(name,"IceMaskNodeActivation")==0) return IceMaskNodeActivationEnum; 500 else if (strcmp(name,"Input")==0) return InputEnum; 508 else stage=5; 509 } 510 if(stage==5){ 511 if (strcmp(name,"Input")==0) return InputEnum; 501 512 else if (strcmp(name,"InversionCostFunctionsCoefficients")==0) return InversionCostFunctionsCoefficientsEnum; 502 513 else if (strcmp(name,"InversionSurfaceObs")==0) return InversionSurfaceObsEnum; … … 506 517 else if (strcmp(name,"InversionVyObs")==0) return InversionVyObsEnum; 507 518 else if (strcmp(name,"LevelsetfunctionSlopeX")==0) return LevelsetfunctionSlopeXEnum; 508 else stage=5; 509 } 510 if(stage==5){ 511 if (strcmp(name,"LevelsetfunctionSlopeY")==0) return LevelsetfunctionSlopeYEnum; 519 else if (strcmp(name,"LevelsetfunctionSlopeY")==0) return LevelsetfunctionSlopeYEnum; 512 520 else if (strcmp(name,"LoadingforceX")==0) return LoadingforceXEnum; 513 521 else if (strcmp(name,"LoadingforceY")==0) return LoadingforceYEnum; … … 595 603 else if (strcmp(name,"SmbP")==0) return SmbPEnum; 596 604 else if (strcmp(name,"SmbPrecipitation")==0) return SmbPrecipitationEnum; 605 else if (strcmp(name,"SmbPrecipitationsAnomaly")==0) return SmbPrecipitationsAnomalyEnum; 597 606 else if (strcmp(name,"SmbPrecipitationsLgm")==0) return SmbPrecipitationsLgmEnum; 598 607 else if (strcmp(name,"SmbPrecipitationsPresentday")==0) return SmbPrecipitationsPresentdayEnum; … … 606 615 else if (strcmp(name,"SmbSizeini")==0) return SmbSizeiniEnum; 607 616 else if (strcmp(name,"SmbSmbref")==0) return SmbSmbrefEnum; 617 else if (strcmp(name,"SmbSmbCorr")==0) return SmbSmbCorrEnum; 608 618 else if (strcmp(name,"SmbTa")==0) return SmbTaEnum; 619 else if (strcmp(name,"SmbTemperaturesAnomaly")==0) return SmbTemperaturesAnomalyEnum; 609 620 else if (strcmp(name,"SmbTemperaturesLgm")==0) return SmbTemperaturesLgmEnum; 610 621 else if (strcmp(name,"SmbTemperaturesPresentday")==0) return SmbTemperaturesPresentdayEnum; … … 618 629 else if (strcmp(name,"SmbVz")==0) return SmbVzEnum; 619 630 else if (strcmp(name,"SmbW")==0) return SmbWEnum; 620 else if (strcmp(name,"SmbWini")==0) return SmbWiniEnum; 631 else stage=6; 632 } 633 if(stage==6){ 634 if (strcmp(name,"SmbWini")==0) return SmbWiniEnum; 621 635 else if (strcmp(name,"SmbZMax")==0) return SmbZMaxEnum; 622 636 else if (strcmp(name,"SmbZMin")==0) return SmbZMinEnum; … … 629 643 else if (strcmp(name,"StrainRatexy")==0) return StrainRatexyEnum; 630 644 else if (strcmp(name,"StrainRatexz")==0) return StrainRatexzEnum; 631 else stage=6; 632 } 633 if(stage==6){ 634 if (strcmp(name,"StrainRateyy")==0) return StrainRateyyEnum; 645 else if (strcmp(name,"StrainRateyy")==0) return StrainRateyyEnum; 635 646 else if (strcmp(name,"StrainRateyz")==0) return StrainRateyzEnum; 636 647 else if (strcmp(name,"StrainRatezz")==0) return StrainRatezzEnum; … … 741 752 else if (strcmp(name,"DatasetInput")==0) return DatasetInputEnum; 742 753 else if (strcmp(name,"DataSetParam")==0) return DataSetParamEnum; 743 else if (strcmp(name,"DefaultAnalysis")==0) return DefaultAnalysisEnum; 754 else stage=7; 755 } 756 if(stage==7){ 757 if (strcmp(name,"DefaultAnalysis")==0) return DefaultAnalysisEnum; 744 758 else if (strcmp(name,"DefaultCalving")==0) return DefaultCalvingEnum; 745 759 else if (strcmp(name,"DegreeOfChannelization")==0) return DegreeOfChannelizationEnum; … … 752 766 else if (strcmp(name,"Domain3Dsurface")==0) return Domain3DsurfaceEnum; 753 767 else if (strcmp(name,"DoubleArrayInput")==0) return DoubleArrayInputEnum; 754 else stage=7; 755 } 756 if(stage==7){ 757 if (strcmp(name,"DoubleExternalResult")==0) return DoubleExternalResultEnum; 768 else if (strcmp(name,"DoubleExternalResult")==0) return DoubleExternalResultEnum; 758 769 else if (strcmp(name,"DoubleInput")==0) return DoubleInputEnum; 759 770 else if (strcmp(name,"DoubleMatArrayParam")==0) return DoubleMatArrayParamEnum; … … 864 875 else if (strcmp(name,"LambdaS")==0) return LambdaSEnum; 865 876 else if (strcmp(name,"LATaylorHood")==0) return LATaylorHoodEnum; 866 else if (strcmp(name,"LevelsetAnalysis")==0) return LevelsetAnalysisEnum; 877 else stage=8; 878 } 879 if(stage==8){ 880 if (strcmp(name,"LevelsetAnalysis")==0) return LevelsetAnalysisEnum; 867 881 else if (strcmp(name,"LevelsetfunctionPicard")==0) return LevelsetfunctionPicardEnum; 868 882 else if (strcmp(name,"LinearFloatingMeltRate")==0) return LinearFloatingMeltRateEnum; … … 875 889 else if (strcmp(name,"LoveKernelsImag")==0) return LoveKernelsImagEnum; 876 890 else if (strcmp(name,"LoveKernelsReal")==0) return LoveKernelsRealEnum; 877 else stage=8; 878 } 879 if(stage==8){ 880 if (strcmp(name,"LoveKi")==0) return LoveKiEnum; 891 else if (strcmp(name,"LoveKi")==0) return LoveKiEnum; 881 892 else if (strcmp(name,"LoveKr")==0) return LoveKrEnum; 882 893 else if (strcmp(name,"LoveLi")==0) return LoveLiEnum; … … 987 998 else if (strcmp(name,"Outputdefinition37")==0) return Outputdefinition37Enum; 988 999 else if (strcmp(name,"Outputdefinition38")==0) return Outputdefinition38Enum; 989 else if (strcmp(name,"Outputdefinition39")==0) return Outputdefinition39Enum; 1000 else stage=9; 1001 } 1002 if(stage==9){ 1003 if (strcmp(name,"Outputdefinition39")==0) return Outputdefinition39Enum; 990 1004 else if (strcmp(name,"Outputdefinition3")==0) return Outputdefinition3Enum; 991 1005 else if (strcmp(name,"Outputdefinition40")==0) return Outputdefinition40Enum; … … 998 1012 else if (strcmp(name,"Outputdefinition47")==0) return Outputdefinition47Enum; 999 1013 else if (strcmp(name,"Outputdefinition48")==0) return Outputdefinition48Enum; 1000 else stage=9; 1001 } 1002 if(stage==9){ 1003 if (strcmp(name,"Outputdefinition49")==0) return Outputdefinition49Enum; 1014 else if (strcmp(name,"Outputdefinition49")==0) return Outputdefinition49Enum; 1004 1015 else if (strcmp(name,"Outputdefinition4")==0) return Outputdefinition4Enum; 1005 1016 else if (strcmp(name,"Outputdefinition50")==0) return Outputdefinition50Enum; … … 1110 1121 else if (strcmp(name,"SMBcomponents")==0) return SMBcomponentsEnum; 1111 1122 else if (strcmp(name,"SMBd18opdd")==0) return SMBd18opddEnum; 1112 else if (strcmp(name,"SmbDesfac")==0) return SmbDesfacEnum; 1123 else stage=10; 1124 } 1125 if(stage==10){ 1126 if (strcmp(name,"SmbDesfac")==0) return SmbDesfacEnum; 1113 1127 else if (strcmp(name,"SmbDpermil")==0) return SmbDpermilEnum; 1114 1128 else if (strcmp(name,"SmbDzAdd")==0) return SmbDzAddEnum; … … 1121 1135 else if (strcmp(name,"SMBhenning")==0) return SMBhenningEnum; 1122 1136 else if (strcmp(name,"SmbMAdd")==0) return SmbMAddEnum; 1123 else stage=10; 1124 } 1125 if(stage==10){ 1126 if (strcmp(name,"SMBmeltcomponents")==0) return SMBmeltcomponentsEnum; 1137 else if (strcmp(name,"SMBmeltcomponents")==0) return SMBmeltcomponentsEnum; 1127 1138 else if (strcmp(name,"SMBpdd")==0) return SMBpddEnum; 1139 else if (strcmp(name,"SMBpddSicopolis")==0) return SMBpddSicopolisEnum; 1140 else if (strcmp(name,"SMBgradientscomponents")==0) return SMBgradientscomponentsEnum; 1128 1141 else if (strcmp(name,"SmbRlaps")==0) return SmbRlapsEnum; 1129 1142 else if (strcmp(name,"SmbRlapslgm")==0) return SmbRlapslgmEnum; -
issm/trunk/src/c/shared/MemOps/MemOps.cpp
r21729 r23394 16 16 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_) 17 17 template <> adouble* xNew(unsigned int size, const char* const contig) { 18 if ( *contig == 't')18 if (contig[0] == 't' || contig[0] == 'c') 19 19 ensureContiguousLocations(size); 20 20 -
issm/trunk/src/c/shared/Numerics/extrema.cpp
r15396 r23394 11 11 #include "./types.h" 12 12 13 #ifndef _HAVE_CODIPACK_// already defined in codipack headers 13 14 IssmDouble min(IssmDouble a,IssmDouble b){ 14 15 if (a<b)return a; 15 16 else return b; 16 17 } 18 #endif 17 19 int min(int a,int b){ 18 20 if (a<b)return a; 19 21 else return b; 20 22 } 23 #ifndef _HAVE_CODIPACK_// already defined in codipack headers 21 24 IssmDouble max(IssmDouble a,IssmDouble b){ 22 25 if (a>b)return a; 23 26 else return b; 24 27 } 28 #endif 25 29 int max(int a,int b){ 26 30 if (a>b)return a; … … 28 32 } 29 33 30 #ifdef _HAVE_AD OLC_34 #ifdef _HAVE_AD_ 31 35 IssmPDouble min(IssmPDouble a,IssmPDouble b){ 32 36 if (a<b)return a; -
issm/trunk/src/c/shared/Numerics/isnan.cpp
r21341 r23394 13 13 return std::isnan(X.getValue()); 14 14 } 15 #endif16 17 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_)18 15 template <> int xIsInf<adouble> (const adouble& X){ 19 16 return std::isinf(X.getValue()); 20 17 } 21 18 #endif 19 20 #if defined(_HAVE_CODIPACK_) && !defined(_WRAPPERS_) 21 template <> int xIsNan<IssmDouble> (const IssmDouble& X){ 22 return std::isnan(X.getValue()); 23 } 24 template <> int xIsInf<IssmDouble> (const IssmDouble& X){ 25 return std::isinf(X.getValue()); 26 } 27 #endif -
issm/trunk/src/c/shared/Numerics/isnan.h
r21341 r23394 33 33 #endif 34 34 35 #if defined(_HAVE_CODIPACK_) && !defined(_WRAPPERS_) 36 #include "./types.h" 37 template <> int xIsNan<IssmDouble> (const IssmDouble& X); 38 template <> int xIsInf<IssmDouble> (const IssmDouble& X); 35 39 #endif 40 41 #endif -
issm/trunk/src/c/shared/Numerics/numerics.h
r20500 r23394 20 20 #include "./OptPars.h" 21 21 22 #if !defined(_HAVE_CODIPACK_) 23 // already defined in codipack headers 22 24 IssmDouble min(IssmDouble a,IssmDouble b); 23 25 IssmDouble max(IssmDouble a,IssmDouble b); 26 #endif 24 27 25 #ifdef _HAVE_AD OLC_28 #ifdef _HAVE_AD_ 26 29 IssmPDouble min(IssmPDouble a,IssmPDouble b); 27 30 IssmPDouble max(IssmPDouble a,IssmPDouble b); -
issm/trunk/src/c/shared/Numerics/recast.h
r19105 r23394 15 15 #endif 16 16 17 #if !defined(_HAVE_AD OLC_) || defined(_WRAPPERS_)17 #if !defined(_HAVE_AD_) || defined(_WRAPPERS_) 18 18 19 19 template<class To, class From> To reCast(const From& from) { … … 34 34 * partial specialization 35 35 */ 36 #ifdef _HAVE_ADOLC_ 36 37 template<class To> struct ForPartialSpecialization<To,adouble> { 37 38 static To reCast(const adouble& from ) { return (To) (from.getValue());} 38 39 }; 40 #endif 41 #ifdef _HAVE_CODIPACK_ 42 template<class To> struct ForPartialSpecialization<To,IssmDouble> { 43 static To reCast(const IssmDouble& from ) { return (To) (from.getValue());} 44 }; 45 #endif 39 46 40 47 #endif -
issm/trunk/src/c/shared/Numerics/types.h
r16137 r23394 22 22 23 23 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_) 24 /*ADOLC typedefs*/ 24 25 #include "adolc/adolc.h" 25 // for active variables 26 typedef adouble IssmDouble; 27 // for passive variables 28 typedef double IssmPDouble; 26 typedef adouble IssmDouble; /*for active variables*/ 27 typedef double IssmPDouble; /*for passive variables*/ 28 29 #elif defined(_HAVE_CODIPACK_) && !defined(_WRAPPERS_) 30 /*CoDiPack typedefs*/ 31 #include <codi.hpp> 32 typedef codi::RealReverse IssmDouble; 33 typedef double IssmPDouble; 34 35 /*Non-AD typedefs*/ 29 36 #else 30 // see above 31 typedef double IssmDouble; 32 // see above 37 typedef double IssmDouble; 33 38 typedef IssmDouble IssmPDouble; 34 39 #endif -
issm/trunk/src/c/shared/io/Marshalling/IoCodeConversions.cpp
r23189 r23394 173 173 case 8: return SMBgembEnum; 174 174 case 9: return SMBgradientselaEnum; 175 case 10: return SMBpddSicopolisEnum; 176 case 11: return SMBgradientscomponentsEnum; 175 177 default: _error_("Marshalled SMB code \""<<enum_in<<"\" not supported yet"); 176 178 } … … 205 207 case 3: return HydrologyshaktiEnum; 206 208 case 4: return HydrologypismEnum; 207 default: _error_("Marshalled hydrology code \""<<enum_in<<"\" not supported yet"); 209 default: _error_("Marshalled hydrology code \""<<enum_in<<"\" not supported yet"); 208 210 } 209 211 }/*}}}*/ … … 211 213 switch(enum_in){ 212 214 case 1: return MatdamageiceEnum; 213 case 2: return MatestarEnum; 215 case 2: return MatestarEnum; 214 216 case 3: return MaticeEnum; 215 217 case 4: return MatenhancediceEnum; 216 218 case 5: return MatlithoEnum; 217 219 case 6: return MaterialsEnum; 218 default: _error_("Marshalled materials code \""<<enum_in<<"\" not supported yet"); 220 default: _error_("Marshalled materials code \""<<enum_in<<"\" not supported yet"); 219 221 } 220 222 }/*}}}*/ … … 222 224 switch(enum_in){ 223 225 case 1: return FixedTimesteppingEnum; 224 case 2: return AdaptiveTimesteppingEnum; 225 default: _error_("Marshalled materials code \""<<enum_in<<"\" not supported yet"); 226 case 2: return AdaptiveTimesteppingEnum; 227 default: _error_("Marshalled materials code \""<<enum_in<<"\" not supported yet"); 226 228 } 227 229 }/*}}}*/ … … 229 231 switch(enum_in){ 230 232 case 1: return AmrBamgEnum; 231 case 2: return AmrNeopzEnum; 232 default: _error_("Marshalled AMR code \""<<enum_in<<"\" not supported yet"); 233 case 2: return AmrNeopzEnum; 234 default: _error_("Marshalled AMR code \""<<enum_in<<"\" not supported yet"); 233 235 } 234 236 }/*}}}*/ -
issm/trunk/src/c/solutionsequences/convergence.cpp
r23189 r23394 7 7 #include "../shared/shared.h" 8 8 9 void convergence(bool* pconverged, Matrix<IssmDouble>* Kff,Vector<IssmDouble>* pf,Vector<IssmDouble>* uf,Vector<IssmDouble>* old_uf,IssmDouble eps_res,IssmDouble eps_rel,IssmDouble eps_abs){ 9 void convergence(bool* pconverged, Matrix<IssmDouble>* Kff,Vector<IssmDouble>* pf,Vector<IssmDouble>* uf,Vector<IssmDouble>* old_uf,IssmDouble eps_res,IssmDouble eps_rel,IssmDouble eps_abs){/*{{{*/ 10 10 11 11 /*output*/ … … 34 34 } 35 35 36 36 37 /*Display solver caracteristics*/ 37 38 if (VerboseConvergence()){ 39 40 38 41 39 42 /*compute KUF = KU - F = K*U - F*/ … … 136 139 /*assign output*/ 137 140 *pconverged=converged; 138 } 141 }/*}}}*/ 142 143 -
issm/trunk/src/c/solutionsequences/solutionsequence_hydro_nonlinear.cpp
r23189 r23394 190 190 Reduceloadx(pf,Kfs,ys); delete Kfs; 191 191 delete uf_epl; 192 192 193 femmodel->profiler->Start(SOLVER); 193 194 Solverx(&uf_epl,Kff,pf,uf_epl_sub_iter,df,femmodel->parameters); 194 195 femmodel->profiler->Stop(SOLVER); 196 195 197 delete Kff; delete pf; delete df; 196 198 delete uf_epl_sub_iter; 197 uf_epl_sub_iter=uf_epl->Duplicate(); 199 uf_epl_sub_iter=uf_epl->Duplicate();_assert_(uf_epl_sub_iter); 198 200 uf_epl->Copy(uf_epl_sub_iter); 199 201 delete ug_epl; … … 215 217 _error_(" maximum number of EPL iterations (" << hydro_maxiter << ") exceeded"); 216 218 } 217 //If there is some colapse go through sediment again218 /* if(ThickCount<L2Count)eplconverged=true; */219 219 eplcount++; 220 220 -
issm/trunk/src/c/solutionsequences/solutionsequence_nonlinear.cpp
r22758 r23394 70 70 Solverx(&uf, Kff, pf, old_uf, df, femmodel->parameters); 71 71 femmodel->profiler->Stop(SOLVER); 72 72 73 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);delete ys; 73 74 … … 86 87 } 87 88 } 88 89 89 90 /*Increase count: */ 90 91 count++; -
issm/trunk/src/c/solutionsequences/solutionsequence_schurcg.cpp
r23189 r23394 10 10 #include "../analyses/analyses.h" 11 11 12 12 13 #ifdef _HAVE_PETSC_ 13 void SchurCGSolver(Vector<IssmDouble>** puf,Mat Kff,Mat Mff,Vec pf, Vec uf0,Vec df,Parameters* parameters){/*{{{*/ 14 15 16 void SchurCGSolver(Vector<IssmDouble>** puf,Mat Kff,Vec pf, Vec uf0,IS isv,IS isp,Parameters* parameters){/*{{{*/ 17 18 Mat A, B, BT; /* Saddle point block matrices */ 19 Mat IP; /* Preconditioner matrix */ 20 Mat IP2; 21 int nu, np; /* No of. free nodes in velocity / pressure space */ 22 Vec p,uold,unew; /* Solution vectors for pressure / vel. */ 23 Vec tmpu, tmpp, rhsu,rhsp; /* temp. vectors, arbitrary RHS in vel. / pressure space */ 24 Vec gold,gnew,wold,wnew,chi,thetaold,thetanew,eta; /* CG intermediaries */ 25 Vec f1,f2; /* RHS of the global system */ 26 double rho,gamma,tmpScalar; /* Step sizes, arbitrary double */ 27 KSP kspu,kspp; /* KSP contexts for vel. / pressure systems*/ 28 KSPConvergedReason reason; /* Convergence reason for troubleshooting */ 29 int its; /* No. of iterations for troubleshooting */ 30 double initRnorm, rnorm, TOL; /* residual norms, STOP tolerance */ 31 PC pcu,pcp; /* Preconditioner contexts pertaining the KSP contexts*/ 32 PetscViewer viewer; /* Viewer for troubleshooting */ 33 IssmPDouble t1,t2; /* Time measurement for bottleneck analysis */ 34 35 /*STOP tolerance for the rel. residual*/ 36 TOL = 0.4; 14 37 15 38 /*Initialize output*/ 16 Vec uf = NULL; 17 18 _error_("not implemented yet"); 39 Vector<IssmDouble>* out_uf=new Vector<IssmDouble>(uf0); 40 41 /* Extract block matrices from the saddle point matrix */ 42 /* [ A B ] = Kff 43 * [ B^T 0 ] 44 * */ 45 #if (_PETSC_MAJOR_==3) && (_PETSC_MINOR_>=8) 46 MatCreateSubMatrix(Kff,isv,isv,MAT_INITIAL_MATRIX,&A); 47 MatCreateSubMatrix(Kff,isv,isp,MAT_INITIAL_MATRIX,&B); 48 MatCreateSubMatrix(Kff,isp,isv,MAT_INITIAL_MATRIX,&BT); 49 #else 50 MatGetSubMatrix(Kff,isv,isv,MAT_INITIAL_MATRIX,&A); 51 MatGetSubMatrix(Kff,isv,isp,MAT_INITIAL_MATRIX,&B); 52 MatGetSubMatrix(Kff,isp,isv,MAT_INITIAL_MATRIX,&BT); 53 #endif 54 55 /* Extract preconditioner matrix on the pressure space*/ 56 #if (_PETSC_MAJOR_==3) && (_PETSC_MINOR_>=8) 57 MatCreateSubMatrix(Kff,isp,isp,MAT_INITIAL_MATRIX,&IP); 58 #else 59 MatGetSubMatrix(Kff,isp,isp,MAT_INITIAL_MATRIX,&IP); 60 #endif 61 62 /* Get number of velocity / pressure nodes */ 63 MatGetSize(B,&nu,&np); 64 65 /* Extract initial guesses for uold and pold */ 66 VecCreate(IssmComm::GetComm(),&p);VecSetSizes(p,PETSC_DECIDE,np);VecSetFromOptions(p); 67 VecAssemblyBegin(p);VecAssemblyEnd(p); 68 VecCreate(IssmComm::GetComm(),&uold);VecSetSizes(uold,PETSC_DECIDE,nu);VecSetFromOptions(uold); 69 VecAssemblyBegin(uold);VecAssemblyEnd(uold); 70 71 VecGetSubVector(out_uf->pvector->vector,isv,&uold); 72 VecGetSubVector(out_uf->pvector->vector,isp,&p); 73 74 75 /* Set up intermediaries */ 76 VecDuplicate(uold,&f1);VecSet(f1,0.0); 77 VecDuplicate(p,&f2);VecSet(f2,0.0); 78 VecDuplicate(uold,&tmpu);VecSet(tmpu,0.0); 79 VecDuplicate(p,&tmpp);VecSet(tmpp,0.0); 80 VecDuplicate(p,&rhsp);VecSet(rhsp,0.0); 81 VecDuplicate(uold,&rhsu);VecSet(rhsu,0.0); 82 VecDuplicate(p,&gold);VecSet(gold,0.0); 83 VecDuplicate(p,&wnew);VecSet(wnew,0.0); 84 VecDuplicate(uold,&chi);VecSet(chi,0.0); 85 VecDuplicate(p,&thetanew);VecSet(thetanew,0.0); 86 VecDuplicate(p,&thetaold);VecSet(thetaold,0.0); 87 VecDuplicate(p,&eta);VecSet(eta,0.0); 88 89 /* Get global RHS (for each block sub-problem respectively)*/ 90 VecGetSubVector(pf,isv,&f1); 91 VecGetSubVector(pf,isp,&f2); 92 93 /* ------------------------------------------------------------ */ 94 95 /* Generate initial value for the velocity from the pressure */ 96 /* a(u0,v) = f1(v)-b(p0,v) i.e. Au0 = F1-Bp0 */ 97 /* u0 = u_DIR on \Gamma_DIR */ 98 99 /* Create KSP context */ 100 KSPCreate(IssmComm::GetComm(),&kspu); 101 #if (_PETSC_MAJOR_==3) && (_PETSC_MINOR_>=5) 102 KSPSetOperators(kspu,A,A); 103 #else 104 KSPSetOperators(kspu,A,A,DIFFERENT_NONZERO_PATTERN); 105 #endif 106 KSPSetType(kspu,KSPCG); 107 KSPSetInitialGuessNonzero(kspu,PETSC_TRUE); 108 //KSPSetTolerances(kspu,1e-12,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT); 109 //KSPMonitorSet(kspu,KSPMonitorDefault,NULL,NULL); 110 KSPGetPC(kspu,&pcu); 111 PCSetType(pcu,PCSOR); 112 KSPSetUp(kspu); 113 114 115 /* Create RHS */ 116 /* RHS = F1-B * pold */ 117 VecScale(p,-1.);MatMultAdd(B,p,f1,rhsu);VecScale(p,-1.); 118 119 /* Go solve Au0 = F1-Bp0*/ 120 KSPSolve(kspu,rhsu,uold); 121 122 123 /* Set up u_new */ 124 VecDuplicate(uold,&unew);VecCopy(uold,unew); 125 VecAssemblyBegin(unew);VecAssemblyEnd(unew); 126 127 128 129 /* ------------------------------------------------------------- */ 130 131 /*Get initial residual*/ 132 /*(1/mu(x) * g0, q) = b(q,u0) - (f2,q) i.e. IP * g0 = BT * u0 - F2*/ 133 134 /* Create KSP context */ 135 KSPCreate(IssmComm::GetComm(),&kspp); 136 #if (_PETSC_MAJOR_==3) && (_PETSC_MINOR_>=5) 137 KSPSetOperators(kspp,IP,IP); 138 #else 139 KSPSetOperators(kspp,IP,IP,DIFFERENT_NONZERO_PATTERN); 140 #endif 141 142 /* Create RHS */ 143 /* RHS = BT * uold - F2 */ 144 VecScale(f2,-1.);MatMultAdd(BT,uold,f2,rhsp);VecScale(f2,-1.); 145 146 /* Set KSP & PC options */ 147 KSPSetType(kspp,KSPCG); 148 KSPSetInitialGuessNonzero(kspp,PETSC_TRUE); 149 KSPGetPC(kspp,&pcp); 150 PCSetType(pcp,PCJACOBI); 151 /* Note: Systems in the pressure space are cheap, so we can afford a better tolerance */ 152 KSPSetTolerances(kspp,1e-10,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT); 153 KSPSetUp(kspp); 154 155 /* Go solve */ 156 KSPSolve(kspp,rhsp,gold); 157 158 /*Initial residual*/ 159 VecNorm(gold,NORM_INFINITY,&initRnorm); 160 161 /* Further setup */ 162 VecDuplicate(gold,&gnew);VecCopy(gold,gnew); 163 VecAssemblyBegin(gnew);VecAssemblyEnd(gnew); 164 165 166 /* ------------------------------------------------------------ */ 167 168 /*Set initial search direction*/ 169 /*w0 = g0*/ 170 VecDuplicate(gold,&wold);VecCopy(gold,wold); 171 VecAssemblyBegin(wold);VecAssemblyEnd(wold); 172 173 /*Realizing the step size part 1: thetam */ 174 /*IP * theta = BT * uold - F2*/ 175 VecScale(f2,-1.);MatMultAdd(BT,uold,f2,rhsp);VecScale(f2,-1.); 176 KSPSolve(kspp,rhsp,thetaold); 177 178 179 /* Count number of iterations */ 180 int count = 0; 181 182 /* CG iteration*/ 183 for(;;){ 184 185 /*Realizing the step size part 2: chim */ 186 /*a(chim,v) = -b(wm,v) i.e. A * chim = -B * wm */ 187 /*chim_DIR = 0*/ 188 VecScale(wold,-1.);MatMult(B,wold,rhsu);VecScale(wold,-1.); 189 KSPSolve(kspu,rhsu,chi); 190 191 /*Realizing the step size part 3: etam */ 192 MatMult(BT,chi,rhsp); 193 KSPSolve(kspp,rhsp,eta); 194 195 /* ---------------------------------------------------------- */ 196 197 198 /*Set step size*/ 199 /*rhom = [(wm)^T * IP^-1 * (BT * um - F2)]/[(wm)^T * IP^-1 * BT * chim]*/ 200 VecDot(wold,thetaold,&rho); 201 VecDot(wold,eta,&tmpScalar); 202 rho = rho/tmpScalar; 203 204 205 /* ---------------------------------------------------------- */ 206 207 208 /*Pressure update*/ 209 /*p(m+1) = pm - rhom * wm*/ 210 VecAXPY(p,-1.*rho,wold); 211 212 213 /*Velocity update*/ 214 /*u(m+1) = um - rhom * chim*/ 215 VecWAXPY(unew,-1.*rho,chi,uold); 216 217 218 /* ---------------------------------------------------------- */ 219 220 /*Theta update*/ 221 /*IP * theta = BT * uold - F2*/ 222 VecScale(f2,-1.);MatMultAdd(BT,unew,f2,rhsp);VecScale(f2,-1.); 223 KSPSolve(kspp,rhsp,thetanew); 224 225 226 /* ---------------------------------------------------------- */ 227 228 /*Residual update*/ 229 /*g(m+1) = gm - rhom * BT * chim*/ 230 VecWAXPY(gnew,-1.*rho,eta,gold); 231 232 /* ---------------------------------------------------------- */ 233 234 235 /*BREAK if norm(g(m+0),2) < TOL or pressure space has been full searched*/ 236 VecNorm(gnew,NORM_INFINITY,&rnorm); 237 if(rnorm < TOL*initRnorm) 238 break; 239 else if(rnorm > 100*initRnorm) 240 _error_("Solver diverged. This shouldn't happen\n"); 241 //else 242 // PetscPrintf(PETSC_COMM_WORLD,"rel. residual at step %d: %g, at TOL = %g\n",count,rnorm/initRnorm,TOL); 243 244 245 246 247 if(count > np-1) break; 248 249 250 /* ---------------------------------------------------------- */ 251 252 253 /*Directional update*/ 254 /*gamma = [g(m+1)^T * theta(m+1)]/[g(m)^T * thetam]*/ 255 VecDot(gnew,thetanew,&gamma); 256 VecDot(gold,thetaold,&tmpScalar); 257 gamma = gamma/tmpScalar; 258 259 /*w(m+1) = g(m+1) + gamma * w(m)*/ 260 VecWAXPY(wnew,gamma,wold,gnew); 261 262 /* Assign new to old iterates */ 263 VecCopy(wnew,wold);VecCopy(gnew,gold);VecCopy(unew,uold);VecCopy(thetanew,thetaold); 264 265 count++; 266 } 267 268 269 /* Restore pressure and velocity sol. vectors to its global form */ 270 VecRestoreSubVector(out_uf->pvector->vector,isv,&unew); 271 VecRestoreSubVector(out_uf->pvector->vector,isp,&p); 19 272 20 273 /*return output pointer*/ 21 Vector<IssmDouble>* out_uf=new Vector<IssmDouble>(uf);22 VecFree(&uf);23 274 *puf=out_uf; 275 276 277 /* Cleanup */ 278 KSPDestroy(&kspu);KSPDestroy(&kspp); 279 280 MatDestroy(&A);MatDestroy(&B);MatDestroy(&BT);MatDestroy(&IP); 281 282 VecDestroy(&p);VecDestroy(&uold);VecDestroy(&unew);VecDestroy(&rhsu);VecDestroy(&rhsp); 283 VecDestroy(&gold);VecDestroy(&gnew);VecDestroy(&wold);VecDestroy(&wnew);VecDestroy(&chi); 284 VecDestroy(&tmpp);VecDestroy(&tmpu);VecDestroy(&f1);VecDestroy(&f2);VecDestroy(&eta); 285 VecDestroy(&thetanew);VecDestroy(&thetaold); 286 287 }/*}}}*/ 288 void convergence_schurcg(bool* pconverged, Matrix<IssmDouble>* Kff,Vector<IssmDouble>* pf,Vector<IssmDouble>* uf,Vector<IssmDouble>* old_uf,IssmDouble eps_res,IssmDouble eps_rel,IssmDouble eps_abs,IS isv,IS isp){/*{{{*/ 289 290 /*output*/ 291 bool converged=false; 292 293 /*intermediary*/ 294 //Vector<IssmDouble>* KU=NULL; 295 //Vector<IssmDouble>* KUF=NULL; 296 //Vector<IssmDouble>* KUold=NULL; 297 //Vector<IssmDouble>* KUoldF=NULL; 298 Vector<IssmDouble>* duf=NULL; 299 IssmDouble ndu,nduinf,nu; 300 IssmDouble nKUF; 301 IssmDouble nKUoldF; 302 IssmDouble nF; 303 IssmDouble solver_residue,res; 304 int analysis_type; 305 306 Mat A, B, BT; 307 Vec u,p,uold,pold,f1,f2,tmp,res1,res2; 308 int n_u,n_p; 309 double rnorm1, rnorm2; 310 311 312 if(VerboseModule()) _printf0_(" checking convergence\n"); 313 314 /*If uf is NULL in input, f-set is nil, model is fully constrained, therefore converged from 315 * the get go: */ 316 if(uf->IsEmpty()){ 317 *pconverged=true; 318 return; 319 } 320 321 /* Note: SchurCG also constructs the Schur preconditioner and stores it in the free block of Kff */ 322 /* [A B] 323 * Kff = | | 324 * [B^T IP] 325 * To calculate the residual, only the necessary blocks need to be extracted */ 326 327 /*Extract A, B, B^T */ 328 #if (_PETSC_MAJOR_==3) && (_PETSC_MINOR_>=8) 329 MatCreateSubMatrix(Kff->pmatrix->matrix,isv,isv,MAT_INITIAL_MATRIX,&A); 330 MatCreateSubMatrix(Kff->pmatrix->matrix,isv,isp,MAT_INITIAL_MATRIX,&B); 331 MatCreateSubMatrix(Kff->pmatrix->matrix,isp,isv,MAT_INITIAL_MATRIX,&BT); 332 #else 333 MatGetSubMatrix(Kff->pmatrix->matrix,isv,isv,MAT_INITIAL_MATRIX,&A); 334 MatGetSubMatrix(Kff->pmatrix->matrix,isv,isp,MAT_INITIAL_MATRIX,&B); 335 MatGetSubMatrix(Kff->pmatrix->matrix,isp,isv,MAT_INITIAL_MATRIX,&BT); 336 #endif 337 338 /*no. of free nodes in velocity/pressure space*/ 339 MatGetSize(B,&n_u,&n_p); 340 341 /*Extract values corresponding to the free velocity/pressure nodes*/ 342 VecCreate(IssmComm::GetComm(),&p);VecSetSizes(p,PETSC_DECIDE,n_p);VecSetFromOptions(p); 343 VecAssemblyBegin(p);VecAssemblyEnd(p); 344 VecCreate(IssmComm::GetComm(),&u);VecSetSizes(u,PETSC_DECIDE,n_u);VecSetFromOptions(u); 345 VecAssemblyBegin(u);VecAssemblyEnd(u); 346 347 VecGetSubVector(uf->pvector->vector,isv,&u); 348 VecGetSubVector(uf->pvector->vector,isp,&p); 349 350 351 /*Extract values of the RHS corresponding to the first/second block*/ 352 VecDuplicate(u,&f1);VecSet(f1,1.0); 353 VecDuplicate(p,&f2);VecSet(f2,1.0); 354 VecGetSubVector(pf->pvector->vector,isv,&f1); 355 VecGetSubVector(pf->pvector->vector,isp,&f2); 356 357 /*Allocate intermediaries*/ 358 VecDuplicate(u,&res1);VecSet(res1,1.0); 359 VecDuplicate(u,&tmp);VecSet(tmp,1.0); 360 VecDuplicate(p,&res2);VecSet(res2,1.0); 361 362 363 /*Display solver caracteristics*/ 364 if (VerboseConvergence()){ 365 366 /*Calculate res1 = A*u + B*p - f1*/ 367 VecScale(f1,-1.);MatMultAdd(A,u,f1,tmp);MatMultAdd(B,p,tmp,res1);VecScale(f1,-1.); 368 /*Calculate res2 = B^T * u - f2*/ 369 VecScale(f2,-1.);MatMultAdd(BT,u,f2,res2);VecScale(f2,-1.); 370 371 372 /*compute norm(res1), norm(res2), norm(F) and residue*/ 373 VecNorm(res1,NORM_2,&rnorm1);VecNorm(res2,NORM_2,&rnorm2); 374 nKUF=sqrt(rnorm1*rnorm1 + rnorm2*rnorm2); 375 nF=pf->Norm(NORM_TWO); 376 solver_residue=nKUF/nF; 377 _printf0_("\n" << " solver residue: norm(KU-F)/norm(F)=" << solver_residue << "\n"); 378 if(xIsNan<IssmDouble>(solver_residue)){ 379 //Kff->Echo(); 380 } 381 382 } 383 /*clean up*/ 384 VecRestoreSubVector(uf->pvector->vector,isv,&u); 385 VecRestoreSubVector(uf->pvector->vector,isp,&p); 386 387 /*Extract values corresponding to velocity/pressure on the old solution*/ 388 VecGetSubVector(old_uf->pvector->vector,isv,&uold); 389 VecGetSubVector(old_uf->pvector->vector,isp,&pold); 390 391 392 /*Force equilibrium (Mandatory)*/ 393 394 /*Calculate res1 = A*uold + B*pold - f1*/ 395 VecScale(f1,-1.);MatMultAdd(A,uold,f1,tmp);MatMultAdd(B,pold,tmp,res1);VecScale(f1,-1.); 396 /*Calculate res2 = B^T * uold - f2*/ 397 VecScale(f2,-1.);MatMultAdd(BT,uold,f2,res2);VecScale(f2,-1.); 398 399 /*compute norm(res1), norm(res2), norm(F) and residue*/ 400 VecNorm(res1,NORM_2,&rnorm1);VecNorm(res2,NORM_2,&rnorm2); 401 nKUoldF=sqrt(rnorm1*rnorm1 + rnorm2*rnorm2); 402 nF=pf->Norm(NORM_TWO); 403 res=nKUoldF/nF; 404 if (xIsNan<IssmDouble>(res)){ 405 _printf0_("norm nf = " << nF << "f and norm kuold = " << nKUoldF << "f\n"); 406 _error_("mechanical equilibrium convergence criterion is NaN!"); 407 } 408 409 MatDestroy(&A);MatDestroy(&B);MatDestroy(&BT); 410 VecRestoreSubVector(pf->pvector->vector,isv,&f1); 411 VecRestoreSubVector(pf->pvector->vector,isp,&f2); 412 VecDestroy(&res1);VecDestroy(&res2);VecDestroy(&tmp); 413 VecRestoreSubVector(old_uf->pvector->vector,isv,&uold); 414 VecRestoreSubVector(old_uf->pvector->vector,isp,&pold); 415 416 417 418 //print 419 if(res<eps_res){ 420 if(VerboseConvergence()) _printf0_(setw(50)<<left<<" mechanical equilibrium convergence criterion"<<res*100<< " < "<<eps_res*100<<" %\n"); 421 converged=true; 422 } 423 else{ 424 if(VerboseConvergence()) _printf0_(setw(50)<<left<<" mechanical equilibrium convergence criterion"<<res*100<<" > "<<eps_res*100<<" %\n"); 425 converged=false; 426 } 427 428 /*Relative criterion (optional)*/ 429 if (!xIsNan<IssmDouble>(eps_rel) || (VerboseConvergence())){ 430 431 //compute norm(du)/norm(u) 432 duf=old_uf->Duplicate(); old_uf->Copy(duf); duf->AYPX(uf,-1.0); 433 ndu=duf->Norm(NORM_TWO); nu=old_uf->Norm(NORM_TWO); 434 435 if (xIsNan<IssmDouble>(ndu) || xIsNan<IssmDouble>(nu)) _error_("convergence criterion is NaN!"); 436 437 //clean up 438 delete duf; 439 440 //print 441 if (!xIsNan<IssmDouble>(eps_rel)){ 442 if((ndu/nu)<eps_rel){ 443 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " < " << eps_rel*100 << " %\n"); 444 } 445 else{ 446 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " > " << eps_rel*100 << " %\n"); 447 converged=false; 448 } 449 } 450 else _printf0_(setw(50) << left << " Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " %\n"); 451 452 } 453 454 /*Absolute criterion (Optional) = max(du)*/ 455 if (!xIsNan<IssmDouble>(eps_abs) || (VerboseConvergence())){ 456 457 //compute max(du) 458 duf=old_uf->Duplicate(); old_uf->Copy(duf); duf->AYPX(uf,-1.0); 459 ndu=duf->Norm(NORM_TWO); nduinf=duf->Norm(NORM_INF); 460 if (xIsNan<IssmDouble>(ndu) || xIsNan<IssmDouble>(nu)) _error_("convergence criterion is NaN!"); 461 462 //clean up 463 delete duf; 464 465 //print 466 if (!xIsNan<IssmDouble>(eps_abs)){ 467 if ((nduinf)<eps_abs){ 468 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: max(du)" << nduinf << " < " << eps_abs << "\n"); 469 } 470 else{ 471 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: max(du)" << nduinf << " > " << eps_abs << "\n"); 472 converged=false; 473 } 474 } 475 else _printf0_(setw(50) << left << " Convergence criterion: max(du)" << nduinf << "\n"); 476 477 } 478 479 /*assign output*/ 480 *pconverged=converged; 24 481 }/*}}}*/ 25 482 void solutionsequence_schurcg(FemModel* femmodel){/*{{{*/ … … 32 489 Vector<IssmDouble>* old_uf = NULL; 33 490 Vector<IssmDouble>* pf = NULL; 34 Vector<IssmDouble>* pf0 = NULL;35 491 Vector<IssmDouble>* df = NULL; 36 492 Vector<IssmDouble>* ys = NULL; 37 Matrix<IssmDouble>* Mff = NULL; 493 38 494 39 495 /*parameters:*/ … … 49 505 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 50 506 femmodel->UpdateConstraintsx(); 51 507 int size; 52 508 int count=0; 53 509 bool converged=false; … … 69 525 /*Get stiffness matrix and Load vector*/ 70 526 SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel); 71 pf0=pf->Duplicate(); pf->Copy(pf0);72 527 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 73 528 Reduceloadx(pf, Kfs, ys); delete Kfs; 74 529 75 530 /*Create mass matrix*/ 76 int fsize; Kff->GetSize(&fsize,&fsize);77 Mff=new Matrix<IssmDouble>(fsize,fsize,100,4);78 531 StressbalanceAnalysis* analysis = new StressbalanceAnalysis(); 79 532 /*Get complete stiffness matrix without penalties*/ 80 533 for(int i=0;i<femmodel->elements->Size();i++){ 81 534 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 82 ElementMatrix* Me = analysis->CreatePressureMassMatrix(element);83 if( Me) Me->AddToGlobal(Mff,NULL);84 delete Me;535 ElementMatrix* Ie = analysis->CreateSchurPrecondMatrix(element); 536 if(Ie) Ie->AddToGlobal(Kff,NULL); 537 delete Ie; 85 538 } 86 Mff->Assemble();539 Kff->Assemble(); 87 540 delete analysis; 541 542 /*Obtain index sets for velocity and pressure components */ 543 IS isv = NULL; 544 IS isp = NULL; 545 #if _PETSC_MAJOR_==3 546 /*Make indices out of doftypes: */ 547 if(!(df->pvector->vector))_error_("need doftypes for FS solver!\n"); 548 DofTypesToIndexSet(&isv,&isp,df->pvector->vector,FSSolverEnum); 549 #else 550 _error_("Petsc 3.X required"); 551 #endif 552 88 553 89 554 /*Solve*/ 90 555 femmodel->profiler->Start(SOLVER); 91 556 _assert_(Kff->type==PetscMatType); 557 92 558 SchurCGSolver(&uf, 93 559 Kff->pmatrix->matrix, 94 Mff->pmatrix->matrix,95 560 pf->pvector->vector, 96 561 old_uf->pvector->vector, 97 df->pvector->vector, 562 isv, 563 isp, 98 564 femmodel->parameters); 99 565 femmodel->profiler->Stop(SOLVER); 100 delete pf0; delete Mff;566 101 567 102 568 /*Merge solution from f set to g set*/ … … 104 570 105 571 /*Check for convergence and update inputs accordingly*/ 106 convergence (&converged,Kff,pf,uf,old_uf,eps_res,eps_rel,eps_abs); delete Kff; delete pf; delete df;572 convergence_schurcg(&converged,Kff,pf,uf,old_uf,eps_res,eps_rel,eps_abs,isv,isp); delete Kff; delete pf; delete df; 107 573 count++; 574 108 575 if(count>=max_nonlinear_iterations){ 109 576 _printf0_(" maximum number of nonlinear iterations (" << max_nonlinear_iterations << ") exceeded\n"); … … 128 595 129 596 }/*}}}*/ 597 130 598 #else 131 599 void solutionsequence_schurcg(FemModel* femmodel){_error_("PETSc needs to be installed");} -
issm/trunk/src/c/toolkits/gsl/DenseGslSolve.cpp
r21729 r23394 14 14 #include "../../classes/Params/Parameters.h" 15 15 #include "../adolc/adolcincludes.h" 16 #include "../codipack/codipackincludes.h" 16 17 #include "./gslincludes.h" 17 18 … … 251 252 /*}}}*/ 252 253 #endif 254 255 #ifdef _HAVE_CODIPACK_ 256 void SolverxSeq_codi_b(void* tape_in,void* data_in,void* ra) {/*{{{*/ 257 258 /*recast data_in and tape*/ 259 codi::DataStore* data = (codi::DataStore*)data_in; 260 //IssmDouble::TapeType& tape = (IssmDouble::TapeType&)tape_in; 261 IssmDouble::TapeType& tape = IssmDouble::getGlobalTape(); 262 263 IssmDouble::Real* valueATrans; 264 IssmDouble::GradientData* indexATrans; 265 IssmDouble::GradientData* indexB; 266 IssmDouble::Real* valueX; 267 IssmDouble::GradientData* indexX; 268 int n; 269 270 data->getData(valueATrans); 271 data->getData(indexATrans); 272 data->getData(indexB); 273 data->getData(valueX); 274 data->getData(indexX); 275 data->getData(n); 276 277 278 // create the adjoint vector for x and reset the adjoint values on the tape 279 IssmDouble::GradientValue* adjX = xNew<IssmDouble::GradientValue>(n); 280 getVectorAdjoint(tape, indexX, adjX, n); 281 282 IssmDouble::GradientValue* sol = xNew<IssmDouble::GradientValue>(n); 283 SolverxSeq(sol, valueATrans, adjX, n); 284 285 updateVectorAdjoint(tape, indexB, sol, n); 286 for(int i=0; i<n; ++i) { 287 for (int j=0; j<n; ++j) { 288 // we access the transposed matrix here because we stored the indices in a transposed way 289 updateAdjoint(tape, indexATrans[i*n+j], -sol[j]*valueX[i]); 290 } 291 } 292 293 xDelete(sol); 294 xDelete(adjX); 295 } 296 /*}}}*/ 297 void SolverxSeq_codi_delete(void* tape_in,void* data_in) {/*{{{*/ 298 299 /*recast data_in*/ 300 codi::DataStore* data = (codi::DataStore*)data_in; 301 302 IssmDouble::Real* valueATrans; 303 IssmDouble::GradientData* indexATrans; 304 IssmDouble::GradientData* indexB; 305 IssmDouble::Real* valueX; 306 IssmDouble::GradientData* indexX; 307 int n; 308 309 data->getData(valueATrans); 310 data->getData(indexATrans); 311 data->getData(indexB); 312 data->getData(valueX); 313 data->getData(indexX); 314 data->getData(n); 315 316 xDelete(valueATrans); 317 xDelete(indexATrans); 318 xDelete(indexB); 319 xDelete(valueX); 320 xDelete(indexX); 321 } 322 /*}}}*/ 323 void SolverxSeq(IssmDouble *X,IssmDouble *A,IssmDouble *B,int n, Parameters* parameters){/*{{{*/ 324 IssmDouble::TapeType& tape = IssmDouble::getGlobalTape(); 325 codi::DataStore* dataHandler = NULL; 326 327 if(tape.isActive()) { 328 dataHandler = new codi::DataStore(); 329 330 // create the index vector and the double data for A and B 331 IssmDouble::Real* valueATrans = xNew<IssmDouble::Real>(n*n); 332 IssmDouble::GradientData* indexATrans = xNew<IssmDouble::GradientData>(n*n); 333 334 // read the data for matrix in a transposed fashion 335 for (int i=0; i<n; ++i) { 336 for (int j=0; j<n; ++j) { 337 getPrimalAndGradData(A[i*n+j], valueATrans[j*n+i], indexATrans[j*n+i]); 338 } 339 } 340 341 // read the data from B (primal values are not required vor B 342 IssmDouble::GradientData* indexB = xNew<IssmDouble::GradientData>(n); 343 getVectorGradData(B, indexB, n); 344 345 dataHandler->addData(valueATrans); 346 dataHandler->addData(indexATrans); 347 dataHandler->addData(indexB); 348 } 349 350 // unpack the primal values from the matrix and the vector 351 IssmDouble::Real* valueA = xNew<IssmDouble::Real>(n*n); 352 IssmDouble::Real* valueB = xNew<IssmDouble::Real>(n); 353 // read the data from A and B 354 getVectorPrimal(A, valueA, n*n); 355 getVectorPrimal(B, valueB, n); 356 357 // create the placeholder for X and solve the system 358 IssmDouble::Real* valueX = xNew<IssmDouble::Real>(n); 359 SolverxSeq(valueX, valueA, valueB, n); 360 361 // pack the values into x 362 setVectorPrimal(X, valueX, n); 363 364 if(tape.isActive()) { 365 // create the index vector X and register x as active variables 366 IssmDouble::GradientData* indexX = xNew<IssmDouble::GradientData>(n); 367 registerVector(X, indexX, n); 368 369 dataHandler->addData(valueX); 370 dataHandler->addData(indexX); 371 372 // store other arguments 373 dataHandler->addData(n); 374 375 tape.pushExternalFunctionHandle(&SolverxSeq_codi_b, dataHandler, &SolverxSeq_codi_delete); 376 } else { 377 // if the tape is active valueX is stored in the dataHandler and deleted in the reverse sweep 378 xDelete(valueX); 379 } 380 381 xDelete(valueB); 382 xDelete(valueA); 383 } 384 /*}}}*/ 385 void DenseGslSolve(/*output*/ IssmDouble** px,/*stiffness matrix:*/ IssmDouble* Kff, int Kff_M, int Kff_N, /*right hand side load vector: */ IssmDouble* pf, int pf_M, Parameters* parameters){ /*{{{*/ 386 387 /*Intermediary: */ 388 389 if(Kff_N!=pf_M)_error_("Right hand side vector of size " << pf_M << ", when matrix is of size " << Kff_M << "-" << Kff_N << " !"); 390 if(Kff_M!=Kff_N)_error_("Stiffness matrix should be square!"); 391 392 IssmDouble *x = xNew<IssmDouble>(Kff_N,"t"); 393 394 SolverxSeq(x,Kff,pf,Kff_N,parameters); 395 396 /*allocate output pointers: */ 397 *px=x; 398 } 399 /*}}}*/ 400 #endif -
issm/trunk/src/c/toolkits/issm/IssmToolkitUtils.cpp
r16560 r23394 86 86 int IssmSolverTypeFromToolkitOptions(void){ /*{{{*/ 87 87 88 char* solver_type=NULL;89 88 int solver_type_enum; 90 int num_procs=0;91 89 bool isparallel=false; 92 90 93 91 /*first, figure out if we are running in parallel: */ 94 num_procs=IssmComm::GetSize();92 int num_procs=IssmComm::GetSize(); 95 93 if(num_procs>1)isparallel=true; 96 94 97 95 /*retrieve solver type as a string, from the Toolkits Options database, similar to what Petsc does. Actually, 98 96 *we try and stick with the Petsc vector types: */ 99 solver_type=ToolkitOptions::GetToolkitOptionValue("solver_type"); 97 char* solver_type=ToolkitOptions::GetToolkitOptionValue("solver_type"); 98 if(!solver_type) _error_("Solver not set"); 100 99 101 100 if (strcmp(solver_type,"mumps")==0){ -
issm/trunk/src/c/toolkits/mpi/issmmpi.cpp
r20500 r23394 42 42 assert(sendcount==recvcount || sendtype==recvtype); // we handle only identical representations 43 43 #ifdef _HAVE_MPI_ 44 # ifdef _HAVE_AMPI_44 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 45 45 rc=AMPI_Allgather(sendbuf, 46 46 sendcount, … … 60 60 # endif 61 61 #else 62 # ifdef _HAVE_AD OLC_62 # ifdef _HAVE_AD_ 63 63 if (sendtype==ISSM_MPI_DOUBLE) { 64 64 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; … … 76 76 assert(sendtype==recvtype); // we handle only identical representations 77 77 #ifdef _HAVE_MPI_ 78 # ifdef _HAVE_AMPI_78 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 79 79 rc=AMPI_Allgatherv(sendbuf, 80 80 sendcount, … … 97 97 #else 98 98 assert(sendcount==recvcounts[0]); // we handle only identical representations 99 # ifdef _HAVE_AD OLC_99 # ifdef _HAVE_AD_ 100 100 if (sendtype==ISSM_MPI_DOUBLE) { 101 101 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; … … 113 113 int rc=0; 114 114 #ifdef _HAVE_MPI_ 115 # ifdef _HAVE_AMPI_115 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 116 116 rc=AMPI_Allreduce(sendbuf, 117 117 recvbuf, … … 129 129 # endif 130 130 #else 131 # ifdef _HAVE_ADOLC_131 #ifdef _HAVE_AD_ 132 132 if (datatype==ISSM_MPI_DOUBLE) { 133 133 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; … … 145 145 int rc=0; 146 146 #ifdef _HAVE_MPI_ 147 # ifdef _HAVE_AMPI_147 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 148 148 rc=AMPI_Barrier(comm); 149 149 # else … … 159 159 int rc=0; 160 160 #ifdef _HAVE_MPI_ 161 # ifdef _HAVE_AMPI_161 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 162 162 rc=AMPI_Bcast(buffer, 163 163 count, … … 181 181 int rc=0; 182 182 #ifdef _HAVE_MPI_ 183 # ifdef _HAVE_AMPI_183 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 184 184 assert(0); // to be implemented 185 185 # else … … 215 215 int ISSM_MPI_Finalize(void){ /*{{{*/ 216 216 217 int rc=0; 218 #ifdef _HAVE_MPI_ 219 # ifdef _HAVE_AMPI_ 220 rc=AMPI_Finalize_NT(); 221 # else 222 rc=MPI_Finalize(); 223 # endif 224 #endif 217 int rc=0; 218 #ifdef _HAVE_MPI_ 219 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 220 #if defined(_HAVE_ADJOINTMPI_) 221 rc=AMPI_Finalize(); 222 #elif defined(_HAVE_MEDIPACK_) 223 TOOL::finalize(); 224 rc=AMPI_Finalize(); 225 #else 226 rc=AMPI_Finalize_NT(); 227 #endif 228 #else 229 rc=MPI_Finalize(); 230 #endif 231 #endif 225 232 return rc; 226 233 }/*}}}*/ … … 230 237 assert(sendtype==recvtype && sendcnt==recvcnt); // we handle only identical representations 231 238 #ifdef _HAVE_MPI_ 232 # ifdef _HAVE_AMPI_239 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 233 240 rc=AMPI_Gather(sendbuf, 234 241 sendcnt, … … 250 257 # endif 251 258 #else 252 # ifdef _HAVE_AD OLC_259 # ifdef _HAVE_AD_ 253 260 if (sendtype==ISSM_MPI_DOUBLE) { 254 261 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; … … 267 274 assert(sendtype==recvtype); // we handle only identical representations 268 275 #ifdef _HAVE_MPI_ 269 # ifdef _HAVE_AMPI_276 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 270 277 rc=AMPI_Gatherv(sendbuf, 271 278 sendcnt, … … 290 297 #else 291 298 assert(sendcnt==recvcnts[0]); // we handle only identical representations 292 # ifdef _HAVE_ADOLC_299 #ifdef _HAVE_AD_ 293 300 if (sendtype==ISSM_MPI_DOUBLE) { 294 301 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; … … 304 311 int ISSM_MPI_Init(int *argc, char ***argv){ /*{{{*/ 305 312 306 int rc=0; 307 #ifdef _HAVE_MPI_ 308 # ifdef _HAVE_AMPI_ 309 rc=AMPI_Init_NT(argc,argv); 310 # else 311 rc=MPI_Init(argc,argv); 312 # endif 313 #endif 313 int rc=0; 314 #ifdef _HAVE_MPI_ 315 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 316 #if defined(_HAVE_ADJOINTMPI_) 317 rc=AMPI_Init(argc,argv); 318 #elif defined(_HAVE_MEDIPACK_) 319 rc=AMPI_Init(argc,argv); 320 TOOL::init(); 321 #else 322 rc=AMPI_Init_NT(argc,argv); 323 #endif 324 #else 325 rc=MPI_Init(argc,argv); 326 #endif 327 #endif 314 328 return rc; 315 329 }/*}}}*/ … … 318 332 int rc=0; 319 333 #ifdef _HAVE_MPI_ 320 # ifdef _HAVE_AMPI_334 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 321 335 rc=AMPI_Recv(buf, 322 336 count, … … 324 338 source, 325 339 tag, 340 #if !defined(_HAVE_ADJOINTMPI_) && !defined(_HAVE_MEDIPACK_) 326 341 AMPI_FROM_SEND, // as long as there are no other variants 342 #endif 327 343 comm, 328 344 status); … … 347 363 int rc=0; 348 364 #ifdef _HAVE_MPI_ 349 # ifdef _HAVE_AMPI_365 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 350 366 rc=AMPI_Reduce(sendbuf, 351 367 recvbuf, … … 365 381 # endif 366 382 #else 367 # ifdef _HAVE_AD OLC_383 # ifdef _HAVE_AD_ 368 384 if (datatype==ISSM_MPI_DOUBLE) { 369 385 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; … … 382 398 assert(sendtype==recvtype && sendcnt==recvcnt); // we handle only identical representations 383 399 #ifdef _HAVE_MPI_ 384 # ifdef _HAVE_AMPI_400 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 385 401 rc=AMPI_Scatter(sendbuf, 386 402 sendcnt, … … 402 418 # endif 403 419 #else 404 # ifdef _HAVE_AD OLC_420 # ifdef _HAVE_AD_ 405 421 if (sendtype==ISSM_MPI_DOUBLE) { 406 422 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; … … 419 435 assert(sendtype==recvtype); // we handle only identical representations 420 436 #ifdef _HAVE_MPI_ 421 # ifdef _HAVE_AMPI_437 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 422 438 rc=AMPI_Scatterv(sendbuf, 423 439 sendcnts, … … 442 458 #else 443 459 assert(sendcnts[0]==recvcnt); // we handle only identical representations 444 # ifdef _HAVE_AD OLC_460 # ifdef _HAVE_AD_ 445 461 if (sendtype==ISSM_MPI_DOUBLE) { 446 462 IssmDouble* activeSendBuf=(IssmDouble*)(sendbuf)+displs[0]; … … 458 474 int rc=0; 459 475 #ifdef _HAVE_MPI_ 460 # ifdef _HAVE_AMPI_476 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 461 477 rc=AMPI_Send(buf, 462 478 count, … … 464 480 dest, 465 481 tag, 482 #if !defined(_HAVE_ADJOINTMPI_) && !defined(_HAVE_MEDIPACK_) 466 483 AMPI_TO_RECV, // as long as there are no other variants 484 #endif 467 485 comm); 468 486 # else … … 492 510 #ifdef _HAVE_ADOLC_ 493 511 ensureContiguousLocations(aSize); 512 #else 513 fprintf(stderr, "*** Codipack ISSM_MPI_ContiguousInAdolc()\n"); 494 514 #endif 495 515 }/*}}}*/ … … 498 518 int rc=0; 499 519 #ifdef _HAVE_MPI_ 500 #if def _HAVE_AMPI_520 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 501 521 rc=MPI_Comm_split(comm, color, key, newcomm); 502 522 #else … … 512 532 int rc=0; 513 533 #ifdef _HAVE_MPI_ 514 #if def _HAVE_AMPI_534 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 515 535 rc=MPI_Intercomm_create(comm,local_leader,peer_comm,remote_leader,tag,newintercomm); 516 536 #else -
issm/trunk/src/c/toolkits/mpi/issmmpi.h
r22758 r23394 16 16 #include "../../shared/Numerics/types.h" 17 17 18 #if def _HAVE_MPI_18 #if defined(_HAVE_MPI_) 19 19 /*Include header files: {{{*/ 20 #ifdef _HAVE_AMPI_ 21 #include <ampi/ampi.h> 20 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 21 #if defined(_HAVE_ADJOINTMPI_) 22 #include <ampi_tape.hpp> 23 24 #elif defined(_HAVE_MEDIPACK_) 25 #include "medi/medi.hpp" 26 using namespace medi; 27 #include "medi/codiMediPackTypes.hpp" 28 #if defined(_HAVE_CODIPACK_) 29 #define TOOL CoDiPackTool<IssmDouble> 30 #define AMPI_ADOUBLE TOOL::MPI_TYPE 31 #elif defined(_HAVE_ADOLC_) 32 #include "adolc/medipacksupport.h" 33 #define TOOL AdolcTool 34 #else 35 #error "don't know about AD tool" 36 #endif 37 38 #else 39 #include <ampi/ampi.h> 40 #endif 22 41 #elif _HAVE_PETSC_MPI_ // Petsc now hides there MPI header. It can be reached through Petsc. 23 42 #include <petsc.h> … … 27 46 /*}}}*/ 28 47 /*MPI defines: *{{{*/ 48 29 49 // types 50 #if defined(_HAVE_MEDIPACK_) && !defined(_WRAPPERS_) 51 typedef AMPI_Comm ISSM_MPI_Comm; 52 typedef AMPI_Datatype ISSM_MPI_Datatype; 53 typedef AMPI_Op ISSM_MPI_Op; 54 typedef AMPI_Status ISSM_MPI_Status; 55 #else 30 56 typedef MPI_Comm ISSM_MPI_Comm; 31 57 typedef MPI_Datatype ISSM_MPI_Datatype; 32 58 typedef MPI_Op ISSM_MPI_Op; 33 59 typedef MPI_Status ISSM_MPI_Status; 60 #endif 34 61 35 // data types 36 #define ISSM_MPI_CHAR MPI_CHAR 37 #ifdef _HAVE_AMPI_ 38 #define ISSM_MPI_DOUBLE AMPI_ADOUBLE // corresponds to IssmDouble 39 #else 40 #define ISSM_MPI_DOUBLE MPI_DOUBLE // corresponds to IssmDouble 62 #if defined(_HAVE_MEDIPACK_) && !defined(_WRAPPERS_) 63 #define ISSM_MPI_CHAR AMPI_CHAR 64 #define ISSM_MPI_DOUBLE AMPI_ADOUBLE // corresponds to IssmDouble 65 #define ISSM_MPI_PDOUBLE AMPI_DOUBLE // corresponds to IssmPDouble 66 #define ISSM_MPI_INT AMPI_INT 67 68 // operations 69 #define ISSM_MPI_MAX AMPI_MAX 70 #define ISSM_MPI_MIN AMPI_MIN 71 #define ISSM_MPI_PROD AMPI_PROD 72 #define ISSM_MPI_SUM AMPI_SUM 73 74 // others 75 #define ISSM_MPI_COMM_WORLD AMPI_COMM_WORLD 76 #define ISSM_MPI_STATUS_IGNORE AMPI_STATUS_IGNORE 77 #define ISSM_MPI_ANY_TAG AMPI_ANY_TAG 78 #define ISSM_MPI_ANY_SOURCE AMPI_ANY_SOURCE 79 80 #else 81 #if defined(_HAVE_AMPI_) && !defined(_WRAPPERS_) 82 #define ISSM_MPI_DOUBLE AMPI_ADOUBLE 83 #else 84 #define ISSM_MPI_DOUBLE MPI_DOUBLE 85 #endif 86 #define ISSM_MPI_PDOUBLE MPI_DOUBLE 87 #define ISSM_MPI_INT MPI_INT 88 #define ISSM_MPI_CHAR MPI_CHAR 89 90 // operations 91 #define ISSM_MPI_MAX MPI_MAX 92 #define ISSM_MPI_MIN MPI_MIN 93 #define ISSM_MPI_PROD MPI_PROD 94 #define ISSM_MPI_SUM MPI_SUM 95 96 // others 97 #define ISSM_MPI_COMM_WORLD MPI_COMM_WORLD 98 #define ISSM_MPI_STATUS_IGNORE MPI_STATUS_IGNORE 99 #define ISSM_MPI_ANY_TAG MPI_ANY_TAG 100 #define ISSM_MPI_ANY_SOURCE MPI_ANY_SOURCE 41 101 #endif 42 #define ISSM_MPI_PDOUBLE MPI_DOUBLE // corresponds to IssmPDouble43 #define ISSM_MPI_INT MPI_INT44 45 // operations46 #define ISSM_MPI_MAX MPI_MAX47 #define ISSM_MPI_MIN MPI_MIN48 #define ISSM_MPI_PROD MPI_PROD49 #define ISSM_MPI_SUM MPI_SUM50 51 // others52 #define ISSM_MPI_COMM_WORLD MPI_COMM_WORLD53 #define ISSM_MPI_STATUS_IGNORE MPI_STATUS_IGNORE54 #define ISSM_MPI_ANY_TAG MPI_ANY_TAG55 #define ISSM_MPI_ANY_SOURCE MPI_ANY_SOURCE56 102 57 103 /*other include files: */ … … 90 136 template <class T> ISSM_MPI_Datatype TypeToMPIType(){assert(false);}; 91 137 template <> inline ISSM_MPI_Datatype TypeToMPIType<IssmDouble>(){return ISSM_MPI_DOUBLE;}; 92 #if defined(_HAVE_AD OLC_) && !defined(_WRAPPERS_)138 #if defined(_HAVE_AD_) && !defined(_WRAPPERS_) 93 139 template <> inline ISSM_MPI_Datatype TypeToMPIType<IssmPDouble>(){return ISSM_MPI_PDOUBLE;}; 94 140 #endif -
issm/trunk/src/c/toolkits/mumps/MumpsSolve.cpp
r23189 r23394 18 18 #include "../mpi/issmmpi.h" 19 19 #include "../adolc/adolcincludes.h" 20 #include "../codipack/codipackincludes.h" 20 21 #include "../issm/SparseRow.h" 21 22 #include "./mumpsincludes.h" … … 25 26 26 27 void MumpsInit(DMUMPS_STRUC_C &theMumpsStruc){ 28 theMumpsStruc.n = 0; 29 theMumpsStruc.nz = 0; 30 theMumpsStruc.a = NULL; 31 theMumpsStruc.jcn = NULL; 32 theMumpsStruc.irn = NULL; 27 33 theMumpsStruc.par = 1; 28 34 theMumpsStruc.sym = 0; … … 98 104 } 99 105 100 #ifdef _HAVE_AD OLC_106 #ifdef _HAVE_AD_ 101 107 // prototype for active variant 102 108 void MumpsSolve(int n, … … 354 360 355 361 #ifdef _HAVE_ADOLC_ 356 357 int mumpsSolveEDF(int iArrLength, int* iArr, int /* ignored */, IssmPDouble* dp_x, int /* ignored */, IssmPDouble* dp_y) { 362 int mumpsSolveEDF(int iArrLength, int* iArr, int /* ignored */, IssmPDouble* dp_x, int /* ignored */, IssmPDouble* dp_y){/*{{{*/ 358 363 // unpack parameters 359 364 int n=iArr[0]; … … 381 386 xDelete(local_irn); 382 387 return 0; 383 } 384 385 void MumpsSolve(int n,int nnz,int local_nnz,int* irn_loc,int* jcn_loc,IssmDouble *a_loc,IssmDouble *rhs,Parameters* parameters){ 388 }/*}}}*/ 389 void MumpsSolve(int n,int nnz,int local_nnz,int* irn_loc,int* jcn_loc,IssmDouble *a_loc,IssmDouble *rhs,Parameters* parameters){/*{{{*/ 386 390 int packedDimsSparseArrLength=1+1+1+local_nnz+local_nnz; 387 391 int *packedDimsSparseArr=xNew<int>(packedDimsSparseArrLength); … … 425 429 xDelete(pack_A_rhs); 426 430 xDelete(packedDimsSparseArr); 427 } 428 429 int fos_reverse_mumpsSolveEDF(int iArrLength, int* iArr, 430 int m, IssmPDouble *dp_U, 431 int nPlusNz, IssmPDouble *dp_Z, 432 IssmPDouble *dp_x, IssmPDouble *dp_y) { 431 }/*}}}*/ 432 int fos_reverse_mumpsSolveEDF(int iArrLength, int* iArr, int m, IssmPDouble *dp_U, int nPlusNz, IssmPDouble *dp_Z, IssmPDouble *dp_x, IssmPDouble *dp_y) {/*{{{*/ 433 433 // unpack parameters 434 434 int n=iArr[0]; … … 481 481 xDelete(local_irn); 482 482 return 3; 483 } 484 485 #endif 483 }/*}}}*/ 484 #endif 485 486 #ifdef _HAVE_CODIPACK_ 487 void MumpsSolve_codi_b(void* tape_in,void* data_in,void* ra) {/*{{{*/ 488 489 /*recast data_in and tape*/ 490 codi::DataStore* data = (codi::DataStore*)data_in; 491 //IssmDouble::TapeType& tape = (IssmDouble::TapeType&)tape_in; 492 IssmDouble::TapeType& tape = IssmDouble::getGlobalTape(); 493 494 495 IssmDouble::Real* valueATrans; 496 IssmDouble::GradientData* indexATrans; 497 int* irnATrans; 498 int* jcnATrans; 499 IssmDouble::GradientData* indexB; 500 IssmDouble::Real* valueX; 501 IssmDouble::GradientData* indexX; 502 int n; 503 int nnz; 504 int local_nnz; 505 Parameters* parameters; 506 507 data->getData(valueATrans); 508 data->getData(indexATrans); 509 data->getData(irnATrans); 510 data->getData(jcnATrans); 511 data->getData(indexB); 512 data->getData(valueX); 513 data->getData(indexX); 514 data->getData(n); 515 data->getData(nnz); 516 data->getData(local_nnz); 517 data->getData(parameters); 518 519 // create the adjoint vector for x and reset the adjoint values on the tape 520 IssmDouble::GradientValue* adjX = xNew<IssmDouble::GradientValue>(n); 521 getVectorAdjoint(tape, indexX, adjX, n); 522 523 MumpsSolve(n, nnz, local_nnz, irnATrans, jcnATrans, valueATrans, adjX, parameters); 524 // adjX contains now the solution 525 526 updateVectorAdjoint(tape, indexB, adjX, n); 527 528 // bcast dp_y (the solution of the forward system) 529 ISSM_MPI_Bcast(valueX,n,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 530 // bcast the adjoint of the right-hand-side, i.e. this solution 531 ISSM_MPI_Bcast(adjX,n,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm()); 532 533 for(int i=0; i<local_nnz; ++i) { 534 // we access the transposed matrix here because we stored the indices in a transposed way 535 // -1 is substracted because jcn and irn are stored with fortran indexing 536 updateAdjoint(tape, indexATrans[i], -adjX[jcnATrans[i]-1]*valueX[irnATrans[i]-1]); 537 } 538 539 xDelete(adjX); 540 } 541 /*}}}*/ 542 void MumpsSolve_codi_delete(void* tape_in,void* data_in) {/*{{{*/ 543 544 /*recast data_in*/ 545 codi::DataStore* data = (codi::DataStore*)data_in; 546 547 IssmDouble::Real* valueATrans; 548 IssmDouble::GradientData* indexATrans; 549 int* irnATrans; 550 int* jcnATrans; 551 IssmDouble::GradientData* indexB; 552 IssmDouble::Real* valueX; 553 IssmDouble::GradientData* indexX; 554 int n; 555 int nnz; 556 int local_nnz; 557 Parameters* parameters; 558 559 data->getData(valueATrans); 560 data->getData(indexATrans); 561 data->getData(irnATrans); 562 data->getData(jcnATrans); 563 data->getData(indexB); 564 data->getData(valueX); 565 data->getData(indexX); 566 data->getData(n); 567 data->getData(nnz); 568 data->getData(local_nnz); 569 data->getData(parameters); 570 571 xDelete(valueATrans); 572 xDelete(indexATrans); 573 xDelete(irnATrans); 574 xDelete(jcnATrans); 575 xDelete(indexB); 576 xDelete(valueX); 577 xDelete(indexX); 578 } 579 /*}}}*/ 580 void MumpsSolve(int n,int nnz,int local_nnz,int* irn_loc,int* jcn_loc,IssmDouble *a_loc,IssmDouble *rhs,Parameters* parameters){/*{{{*/ 581 IssmDouble::TapeType& tape = IssmDouble::getGlobalTape(); 582 codi::DataStore* dataHandler = NULL; 583 584 if(tape.isActive()) { 585 dataHandler = new codi::DataStore(); 586 587 // create the index and double vector for the matrix 588 IssmDouble::Real* valueATrans = xNew<IssmDouble::Real>(local_nnz); 589 IssmDouble::GradientData* indexATrans = xNew<IssmDouble::GradientData>(local_nnz); 590 int* irnATrans = xNew<int>(local_nnz); 591 int* jcnATrans = xNew<int>(local_nnz); 592 593 // read the data for the matrix A in a transposed fashion 594 for (int i=0; i<local_nnz; ++i) { 595 getPrimalAndGradData(a_loc[i], valueATrans[i], indexATrans[i]); 596 irnATrans[i]=jcn_loc[i]; // transposed store 597 jcnATrans[i]=irn_loc[i]; // transposed store 598 } 599 600 // create the index vector for a (primal values are not needed for a) 601 IssmDouble::GradientData* indexB = xNew<IssmDouble::GradientData>(n); 602 getVectorGradData(rhs, indexB, n); 603 604 dataHandler->addData(valueATrans); 605 dataHandler->addData(indexATrans); 606 dataHandler->addData(irnATrans); 607 dataHandler->addData(jcnATrans); 608 dataHandler->addData(indexB); 609 } 610 611 // unpack the primal values from the matrix and the vector 612 IssmDouble::Real* valueA = xNew<IssmDouble::Real>(local_nnz); 613 IssmDouble::Real* valueB = xNew<IssmDouble::Real>(n); 614 // read the data from A and B 615 getVectorPrimal(a_loc, valueA, local_nnz); 616 getVectorPrimal(rhs, valueB, n); 617 618 MumpsSolve(n, nnz, local_nnz, irn_loc, jcn_loc, valueA, valueB, parameters); 619 // valueB contains now the solution 620 621 // pack the values into rhs 622 setVectorPrimal(rhs, valueB, n); 623 624 if(tape.isActive()) { 625 // create the index vector X and register x as active variables 626 IssmDouble::GradientData* indexX = xNew<IssmDouble::GradientData>(n); 627 registerVector(rhs, indexX, n); 628 629 dataHandler->addData(valueB); // contains the values from x 630 dataHandler->addData(indexX); 631 632 // store other arguments 633 dataHandler->addData(n); 634 dataHandler->addData(nnz); 635 dataHandler->addData(local_nnz); 636 dataHandler->addData(parameters); // we assume here that parameters is still intact when the reverse run is called 637 638 //tape.pushExternalFunction(&MumpsSolve_codi_b, dataHandler, &MumpsSolve_codi_delete); 639 tape.pushExternalFunctionHandle(&MumpsSolve_codi_b,(void*)dataHandler, &MumpsSolve_codi_delete); 640 } else { 641 // if the tape is active valueB is stored in the dataHandler and deleted in the reverse sweep 642 xDelete(valueB); 643 } 644 645 xDelete(valueA); 646 } 647 /*}}}*/ 648 #endif -
issm/trunk/src/c/toolkits/petsc/objects/PetscMat.cpp
r20500 r23394 21 21 PetscMat::PetscMat(){/*{{{*/ 22 22 this->matrix=NULL; 23 #ifdef _HAVE_AD OLC_23 #ifdef _HAVE_AD_ 24 24 this->amatrix=NULL; 25 25 #endif -
issm/trunk/src/c/toolkits/petsc/objects/PetscMat.h
r15396 r23394 27 27 Mat matrix; 28 28 29 #ifdef _HAVE_AD OLC_29 #ifdef _HAVE_AD_ 30 30 IssmDouble* amatrix; 31 31 #endif -
issm/trunk/src/c/toolkits/petsc/objects/PetscSolver.cpp
r23189 r23394 15 15 #include "../../../shared/io/Comm/IssmComm.h" 16 16 #include "../../../shared/Enum/Enum.h" 17 #include "../../../shared/io/Print/Print.h" 17 18 18 19 void PetscSolve(PetscVec** puf, PetscMat* Kff, PetscVec* pf, PetscVec* uf0,PetscVec* df, Parameters* parameters){ /*{{{*/ … … 156 157 KSPGetIterationNumber(ksp,&iteration_number); 157 158 if (iteration_number<0) _error_("Solver diverged at iteration number: " << -iteration_number); 159 if (VerboseSolver()) _printf0_("Petsc: "<< iteration_number << " KSP iterations\n"); 158 160 159 161 /*Free resources:*/ -
issm/trunk/src/c/toolkits/petsc/objects/PetscVec.cpp
r20500 r23394 21 21 PetscVec::PetscVec(){/*{{{*/ 22 22 this->vector=NULL; 23 #ifdef _HAVE_AD OLC_23 #ifdef _HAVE_AD_ 24 24 this->avector=NULL; 25 25 #endif -
issm/trunk/src/c/toolkits/petsc/objects/PetscVec.h
r20500 r23394 25 25 Vec vector; 26 26 27 #ifdef _HAVE_AD OLC_27 #ifdef _HAVE_AD_ 28 28 IssmDouble* avector; 29 29 #endif -
issm/trunk/src/c/toolkits/toolkits.h
r16137 r23394 30 30 #endif 31 31 32 #ifdef _HAVE_CODIPACK_ 33 #include "./codipack/codipackincludes.h" 34 #endif 35 32 36 #ifdef _HAVE_TRIANGLE_ 33 37 #include "./triangle/triangleincludes.h" -
issm/trunk/src/m/classes/autodiff.js
r21341 r23394 14 14 this.gcTriggerRatio=2.0; 15 15 this.gcTriggerMaxSize=65536; 16 this.tapeAlloc = 15000000; 16 17 17 18 }// }}} … … 29 30 fielddisplay(this,'gcTriggerRatio','free location block sorting/consolidation triggered if the ratio between allocated and used locations exceeds gcTriggerRatio'); 30 31 fielddisplay(this,'gcTriggerMaxSize','free location block sorting/consolidation triggered if the allocated locations exceed gcTriggerMaxSize'); 32 fielddisplay(this,'tapeAlloc','Iteration count of a priori memory allocation of the AD tape'); 31 33 32 34 }// }}} … … 49 51 checkfield(md,'fieldname','autodiff.gcTriggerRatio','>=',0); 50 52 checkfield(md,'fieldname','autodiff.gcTriggerMaxSize','>=',65536); 53 checkfield(md,'fieldname','autodiff.tapeAlloc','>=',0); 51 54 52 55 //go through our dependents and independents and check consistency: … … 79 82 WriteData(fid,prefix,'object',this,'fieldname','gcTriggerRatio','format','Double'); 80 83 WriteData(fid,prefix,'object',this,'fieldname','gcTriggerMaxSize','format','Double'); 84 WriteData(fid,prefix,'object',this,'fieldname','tapeAlloc','format','Integer'); 81 85 //}}} 82 86 //process dependent variables {{{ … … 216 220 this.gcTriggerRatio=NullFix(this.gcTriggerRatio,NaN); 217 221 this.gcTriggerMaxSize=NullFix(this.gcTriggerMaxSize,NaN); 222 this.tapeAlloc=NullFix(this.tapeAlloc,NaN); 218 223 }//}}} 219 224 //properties … … 229 234 this.gcTriggerRatio = NaN; 230 235 this.gcTriggerMaxSize = NaN; 236 this.tapeAlloc = NaN; 231 237 232 238 this.setdefaultparameters(); -
issm/trunk/src/m/classes/autodiff.m
r23189 r23394 17 17 gcTriggerRatio = NaN; 18 18 gcTriggerMaxSize = NaN; 19 tapeAlloc = NaN; 19 20 end 20 21 %}}} … … 35 36 self.gcTriggerRatio=2.0; 36 37 self.gcTriggerMaxSize=65536; 38 self.tapeAlloc = 15000000; 37 39 end % }}} 38 40 function md = checkconsistency(self,md,solution,analyses) % {{{ … … 51 53 md = checkfield(md,'fieldname','autodiff.gcTriggerRatio','>=',0); 52 54 md = checkfield(md,'fieldname','autodiff.gcTriggerMaxSize','>=',65536); 55 md = checkfield(md,'fieldname','autodiff.tapeAlloc','>=',0); 53 56 54 57 %go through our dependents and independents and check consistency: … … 75 78 fielddisplay(self,'gcTriggerRatio','free location block sorting/consolidation triggered if the ratio between allocated and used locations exceeds gcTriggerRatio'); 76 79 fielddisplay(self,'gcTriggerMaxSize','free location block sorting/consolidation triggered if the allocated locations exceed gcTriggerMaxSize'); 80 fielddisplay(self,'tapeAlloc','Iteration count of a priori memory allocation of the AD tape'); 77 81 end % }}} 78 82 function marshall(self,prefix,md,fid) % {{{ … … 95 99 WriteData(fid,prefix,'object',self,'fieldname','gcTriggerRatio','format','Double'); 96 100 WriteData(fid,prefix,'object',self,'fieldname','gcTriggerMaxSize','format','Double'); 101 WriteData(fid,prefix,'object',self,'fieldname','tapeAlloc','format','Integer'); 97 102 %}}} 98 103 %process dependent variables {{{ -
issm/trunk/src/m/classes/autodiff.py
r21341 r23394 25 25 self.gcTriggerMaxSize = float('NaN') 26 26 self.gcTriggerRatio = float('NaN') 27 self.tapeAlloc = float('NaN') 27 28 if not len(args): 28 29 self.setdefaultparameters() … … 43 44 s+="%s\n" % fielddisplay(self,'gcTriggerRatio',"free location block sorting/consolidation triggered if the ratio between allocated and used locations exceeds gcTriggerRatio") 44 45 s+="%s\n" % fielddisplay(self,'gcTriggerMaxSize',"free location block sorting/consolidation triggered if the allocated locations exceed gcTriggerMaxSize)") 46 s+="%s\n" % fielddisplay(self,'tapeAlloc','Iteration count of a priori memory allocation of the AD tape'); 45 47 46 48 return s … … 54 56 self.gcTriggerRatio=2.0 55 57 self.gcTriggerMaxSize=65536 58 self.tapeAlloc = 15000000; 56 59 return self 57 60 # }}} … … 68 71 md = checkfield(md,'fieldname','autodiff.gcTriggerRatio','>=',2.0) 69 72 md = checkfield(md,'fieldname','autodiff.gcTriggerMaxSize','>=',65536) 73 md = checkfield(md,'fieldname','autodiff.tapeAlloc','>=',0); 70 74 71 75 #Driver value: … … 97 101 WriteData(fid,prefix,'object',self,'fieldname','gcTriggerRatio','format','Double'); 98 102 WriteData(fid,prefix,'object',self,'fieldname','gcTriggerMaxSize','format','Double'); 99 #}}} 103 WriteData(fid,prefix,'object',self,'fieldname','tapeAlloc','format','Integer'); 104 #}}} 100 105 #process dependent variables {{{ 101 106 num_dependent_objects=len(self.dependents) -
issm/trunk/src/m/classes/clusters/stallo.py
r22758 r23394 12 12 except ImportError: 13 13 print 'You need stallo_settings.py to proceed, check presence and sys.path' 14 14 15 15 class stallo(object): 16 16 """ 17 17 Stallo cluster class definition 18 18 This is a SLURM queue 19 The priorities are given to: 19 The priorities are given to: 20 20 - Large jobs 21 21 - Short jobs … … 23 23 24 24 There are some 20cpu nodes and 16cpu nodes, with 32GB (a few with 128GB) mem per node, you can ask for part of a node if you need more memory.(1 node, 2 CPUS and 10GB per cpu for example) 25 25 26 26 27 27 Usage: … … 51 51 #OK get other fields 52 52 self=options.AssignObjectFields(self) 53 self.np=self.numnodes*self.cpuspernode 53 self.np=self.numnodes*self.cpuspernode 54 54 # }}} 55 55 56 56 def __repr__(self): 57 57 # {{{ … … 61 61 s = "%s\n%s"%(s,fielddisplay(self,'login','login')) 62 62 s = "%s\n%s"%(s,fielddisplay(self,'numnodes','number of nodes')) 63 s = "%s\n%s"%(s,fielddisplay(self,'cpuspernode','number of nodes per CPUs'))63 s = "%s\n%s"%(s,fielddisplay(self,'cpuspernode','number of CPUs per nodes')) 64 64 s = "%s\n%s"%(s,fielddisplay(self,'mem','memory per CPU')) 65 65 s = "%s\n%s"%(s,fielddisplay(self,'queue','name of the queue (normal (D), short,singlenode,multinode,devel)')) … … 104 104 if isoceancoupling: 105 105 executable='issm_ocean.exe' 106 #write queuing script 106 #write queuing script 107 107 shortname=modelname[0:min(12,len(modelname))] 108 timeobj=datetime.timedelta(minutes=self.time) 109 m,s=divmod(timeobj.total_seconds(), 60) 110 h,m=divmod(m, 60) 111 d,h=divmod(h, 60) 112 timestring="%02d-%02d:%02d:%02d" % (d, h, m, s) 113 108 114 fid=open(modelname+'.queue','w') 109 110 115 fid.write('#!/bin/bash -l\n') 111 116 fid.write('#SBATCH --job-name=%s \n' % shortname) 112 fid.write('#SBATCH -- partition%s \n' % self.queue)113 fid.write('#SBATCH --nodes=%i ' % self.numnodes)114 fid.write('#SBATCH --ntasks-per-node s==%i \n' % self.cpuspernode)115 fid.write('#SBATCH --time= %s\n' % self.time) #walltime is minutes116 fid.write('#SBATCH --mem-per-cpu= %iGB\n' % self.mem)# mem is in GB117 fid.write('#SBATCH --qos=%s \n' % self.queue) 118 fid.write('#SBATCH --nodes=%i \n' % self.numnodes) 119 fid.write('#SBATCH --ntasks-per-node=%i \n' % self.cpuspernode) 120 fid.write('#SBATCH --time={}\n'.format(timestring)) #walltime is minutes 121 fid.write('#SBATCH --mem-per-cpu={}MB\n'.format(int(1000*self.mem)))# mem is in MB 117 122 if (np.mod(self.np,16)+np.mod(self.np,20))==0: 118 123 fid.write('#SBATCH --ntask=%i\n' % self.np) 119 fid.write('#SBATCH --account=%s\n' % self.accountname) 124 fid.write('#SBATCH --account=%s\n' % self.accountname) 120 125 fid.write('#SBATCH --output %s/%s/%s.outlog \n' % (self.executionpath,dirname,modelname)) 121 126 fid.write('#SBATCH --error %s/%s/%s.errlog \n\n' % (self.executionpath,dirname,modelname)) -
issm/trunk/src/m/classes/geometry.py
r22758 r23394 13 13 14 14 def __init__(self): # {{{ 15 self.surface 16 self.thickness 15 self.surface = float('NaN') 16 self.thickness = float('NaN') 17 17 self.base = float('NaN') 18 self.bed 19 self.hydrostatic_ratio 18 self.bed = float('NaN') 19 self.hydrostatic_ratio = float('NaN') 20 20 21 21 #set defaults -
issm/trunk/src/m/classes/groundingline.js
r23189 r23394 29 29 checkfield(md,'fieldname','groundingline.melt_interpolation','values',['NoMeltOnPartiallyFloating', 'SubelementMelt1', 'SubelementMelt2', 'FullMeltOnPartiallyFloating']); 30 30 31 if (this.migration !='None'){31 if(this.migration !='None' & md.trans.isgroundingline==1 & solution == 'TransientSolution'){ 32 32 if (isNaN(md.geometry.bed)){ 33 33 md.checkmessage('requesting grounding line migration, but bathymetry is absent!'); -
issm/trunk/src/m/classes/groundingline.m
r23189 r23394 33 33 md = checkfield(md,'fieldname','groundingline.melt_interpolation','values',{'NoMeltOnPartiallyFloating' 'SubelementMelt1' 'SubelementMelt2' 'FullMeltOnPartiallyFloating'}); 34 34 35 if ~strcmp(self.migration,'None') ,35 if ~strcmp(self.migration,'None') & strcmp(solution,'TransientSolution') & md.transient.isgroundingline==1, 36 36 if isnan(md.geometry.bed), 37 37 md = checkmessage(md,['requesting grounding line migration, but bathymetry is absent!']); -
issm/trunk/src/m/classes/groundingline.py
r23189 r23394 45 45 md = checkfield(md,'fieldname','groundingline.melt_interpolation','values',['SubelementMelt1','SubelementMelt2','NoMeltOnPartiallyFloating','FullMeltOnPartiallyFloating']) 46 46 47 if not m.strcmp(self.migration,'None'):47 if(not m.strcmp(self.migration,'None') and md.transient.isgroundingline and solution=='TransientSolution'): 48 48 if np.any(np.isnan(md.geometry.bed)): 49 49 md.checkmessage("requesting grounding line migration, but bathymetry is absent!") -
issm/trunk/src/m/classes/numberedcostfunction.m
r22758 r23394 1 % M1QN3INVERSION class definition1 %NUMBEREDCOSTFUNCTION class definition 2 2 % 3 3 % Usage: … … 44 44 function md = checkconsistency(self,md,solution,analyses) % {{{ 45 45 46 num_costfunc=size( md.inversion.cost_functions,2);46 num_costfunc=size(self.cost_functions,2); 47 47 48 md = checkfield(md,'fieldname',' inversion.cost_functions','size',[1 num_costfunc],'values',supportedcostfunctions());49 md = checkfield(md,'fieldname',' inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices num_costfunc],'>=',0);50 48 md = checkfield(md,'fieldname','md.outputdefinition.definition{X}.dependent{X}.cost_functions','field',self.cost_functions,'size',[1 num_costfunc],'values',supportedcostfunctions()); 49 md = checkfield(md,'fieldname','md.outputdefinition.definition{X}.cost_functions_coefficients','field',self.cost_functions_coefficients,'size',[md.mesh.numberofvertices numel(self.cost_functions)],'>=',0); 50 51 51 if strcmp(solution,'BalancethicknessSolution') 52 md = checkfield(md,'fieldname',' inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1);53 md = checkfield(md,'fieldname',' inversion.surface_obs','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1);52 md = checkfield(md,'fieldname','md.outputdefinition.definition{X}.thickness_obs','field',self.thickness_obs,'size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 53 md = checkfield(md,'fieldname','md.outputdefinition.definition{X}.surface_obs','field',self.surface_obs,'size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 54 54 elseif strcmp(solution,'BalancethicknessSoftSolution') 55 md = checkfield(md,'fieldname',' inversion.thickness_obs','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1);55 md = checkfield(md,'fieldname','md.outputdefinition.definition{X}.thickness_obs','field',self.thickness_obs,'size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 56 56 else 57 md = checkfield(md,'fieldname',' inversion.vx_obs','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1);57 md = checkfield(md,'fieldname','md.outputdefinition.definition{X}.vx_obs','field',self.vx_obs,'size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 58 58 if ~strcmp(domaintype(md.mesh),'2Dvertical'), 59 md = checkfield(md,'fieldname',' inversion.vy_obs','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1);59 md = checkfield(md,'fieldname','md.outputdefinition.definition{X}.vy_obs','field',self.vy_obs,'size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 60 60 end 61 61 end -
issm/trunk/src/m/classes/taoinversion.py
r22758 r23394 97 97 else: 98 98 self.algorithm = 'tao_blmvm'; 99 99 100 100 #several responses can be used: 101 101 self.cost_functions=101; … … 110 110 if numel(self.cost_functions_coefficients) > 1: 111 111 self.cost_functions_coefficients=project3d(md,'vector',self.cost_functions_coefficients,'type','node') 112 112 113 113 if numel(self.min_parameters) > 1: 114 114 self.min_parameters=project3d(md,'vector',self.min_parameters,'type','node') 115 115 116 116 if numel(self.max_parameters)>1: 117 117 self.max_parameters=project3d(md,'vector',self.max_parameters,'type','node') … … 123 123 return md 124 124 if not IssmConfig('_HAVE_TAO_')[0]: 125 md = checkmessage(md,['TAO has not been installed, ISSM needs to be reconfigured and recompiled with TAO'])125 md = md.checkmessage('TAO has not been installed, ISSM needs to be reconfigured and recompiled with TAO') 126 126 127 127 -
issm/trunk/src/m/contrib/defleurian/netCDF/export_netCDF.py
r21729 r23394 18 18 print ('New file name is {}'.format(newname)) 19 19 filename=newname 20 20 21 21 NCData=Dataset(filename, 'w', format='NETCDF4') 22 22 NCData.description = 'Results for run' + md.miscellaneous.name … … 100 100 Subgroup.__setattr__('classtype',md.__dict__[group].__class__.__name__) 101 101 subfields=dict.keys(md.__dict__[group].__dict__[field].__dict__) 102 102 103 103 for subfield in subfields: 104 104 if str(subfield)!='outlog': 105 105 Var=md.__dict__[group].__dict__[field].__dict__[subfield] 106 106 DimDict=CreateVar(NCData,Var,subfield,Subgroup,DimDict) 107 107 108 108 NCData.close() 109 109 … … 130 130 str:str, 131 131 dict:str} 132 132 133 133 val_dim=np.shape(val_shape)[0] 134 134 135 #Now define and fill up variable 135 136 #treating scalar string or bool as atribute 136 if val_type ==str or val_type==unicode or val_type==bool:137 if val_type in [str,unicode,bool]: 137 138 Group.__setattr__(str(field).swapcase(), str(var)) 138 139 #treating list as string table … … 147 148 if val_shape==0: 148 149 ncvar= [] 149 else: 150 else: 150 151 for elt in range(0,val_shape[0]): 151 152 ncvar[elt] = var[elt] … … 164 165 ncvar[elt,1]=str(dict.values(var)[elt]) #converting to str to avoid potential problems 165 166 #Now dealing with numeric variables 166 el se:167 elif val_type in [float,'float64',np.float64,int,'int64']: 167 168 dimensions,DimDict=GetDim(NCData,var,val_shape,DimDict,val_dim) 168 169 ncvar = Group.createVariable(str(field),TypeDict[val_type],dimensions,zlib=True) … … 175 176 except TypeError: #type does not accept nan, get vallue of the variable 176 177 ncvar[:] = var 178 else: 179 print('WARNING type "{}" is unknown for "{}.{}"'.format(val_type,Group.name,field)) 177 180 return DimDict 178 181 -
issm/trunk/src/m/contrib/defleurian/paraview/enveloppeVTK.py
r21341 r23394 9 9 creates a directory with the vtk files for displays in paraview 10 10 (only work for triangle and wedges based on their number of nodes) 11 12 Give only the results for nw but could be extended to geometry, mask... 13 14 input: filename destination 11 12 Give only the results for nw but could be extended to geometry, mask... 13 14 input: filename destination 15 15 (string) 16 16 ------------------------------------------------------------------ 17 model this is md 17 model this is md 18 18 ------------------------------------------------------------------ 19 19 By default only the results are exported, you can add whichever … … 40 40 os.mkdir(filename) 41 41 42 IsEnveloppe=np.where(model.mesh.vertexonbase | model.mesh.vertexonsurface) 43 #get the element related variables 42 # {{{get the element related variables 44 43 if 'z' in dict.keys(model.mesh.__dict__): 45 points=np.column_stack((model.mesh.x,model.mesh.y,model.mesh.z)) 46 num_of_elt=np.size(np.isnan(model.mesh.lowerelements))+np.size(np.isnan(model.mesh.upperelements)) 47 low_elt_num=np.size(np.isnan(model.mesh.lowerelements)) 48 top_elt_num=np.size(np.isnan(model.mesh.upperelements)) 44 is_enveloppe=np.logical_or(model.mesh.vertexonbase,model.mesh.vertexonsurface) 45 enveloppe_index=np.where(is_enveloppe)[0] 46 convert_index=np.nan*np.ones(np.shape(model.mesh.x)) 47 convert_index=np.asarray([[i,np.where(enveloppe_index==i)[0][0]] for i,val in enumerate(convert_index) if any(enveloppe_index==i)]) 48 points=np.column_stack((model.mesh.x[enveloppe_index], 49 model.mesh.y[enveloppe_index], 50 model.mesh.z[enveloppe_index])) 51 low_elt_num=np.size(np.where(np.isnan(model.mesh.lowerelements))) 52 top_elt_num=np.size(np.where(np.isnan(model.mesh.upperelements))) 53 num_of_elt=low_elt_num+top_elt_num 54 connect=model.mesh.elements[np.where(is_enveloppe[model.mesh.elements-1])].reshape(int(num_of_elt),3)-1 55 for elt in range(0, num_of_elt): 56 connect[elt,0]=convert_index[np.where(convert_index==connect[elt,0])[0],1][0] 57 connect[elt,1]=convert_index[np.where(convert_index==connect[elt,1])[0],1][0] 58 connect[elt,2]=convert_index[np.where(convert_index==connect[elt,2])[0],1][0] 59 49 60 else: 50 points=np.column_stack((model.mesh.x,model.mesh.y,np.zeros(np.shape(model.mesh.x)))) 61 points=np.column_stack((model.mesh.x, 62 model.mesh.y, 63 np.zeros(np.shape(model.mesh.x)))) 51 64 num_of_elt=np.shape(model.mesh.elements)[0] 52 53 num_of_points=np.size(points)[0] 54 dim=np.size(points)[1] 55 point_per_elt=np.shape(model.mesh.elements)[1] 56 65 connect=model.mesh.elements-1 66 enveloppe_index=np.arange(0,np.size(model.mesh.x)) 67 68 every_nodes=np.size(model.mesh.x) 69 num_of_points=np.size(enveloppe_index) 70 dim=3 71 point_per_elt=3 57 72 celltype=5 #triangles 58 59 #this is the result structure 73 74 # }}} 75 # {{{this is the result structure 60 76 res_struct=model.results 61 77 if (len(res_struct.__dict__)>0): … … 64 80 num_of_sols=len(solnames) 65 81 num_of_timesteps=1 66 #%building solutionstructure 82 #%building solutionstructure 67 83 for solution in solnames: 68 84 #looking for multiple time steps 69 85 if (np.size(res_struct.__dict__[solution])>num_of_timesteps): 70 86 num_of_timesteps=np.size(res_struct.__dict__[solution]) 71 num_of_timesteps=int(num_of_timesteps) +187 num_of_timesteps=int(num_of_timesteps) 72 88 else: 73 89 num_of_timesteps=1 74 90 # }}} 91 # {{{write header and mesh 75 92 for step in range(0,num_of_timesteps): 76 93 timestep=step … … 83 100 for point in points: 84 101 fid.write('%f %f %f \n'%(point[0], point[1], point[2])) 85 102 86 103 fid.write('CELLS %d %d\n' %(num_of_elt, num_of_elt*(point_per_elt+1))) 87 104 88 # if exist('low_elt_num')89 # triaconnect=zeros(num_of_elt,3);90 # triaconnect(1:low_elt_num,:)=model.mesh.elements(find(isnan(model.mesh.lowerelements)),1:3);91 # upshift=-min(min(model.mesh.elements(find(isnan(model.mesh.upperelements)),4:6)))+1+max(max(model.mesh.elements(find(isnan(model.mesh.lowerelements)),1:3)));92 # triaconnect(1+low_elt_num:num_of_elt,:)=model.mesh.elements(find(isnan(model.mesh.upperelements)),4:6)+upshift;93 # fprintf(fid,s,[(3)*ones(num_of_elt,1) triaconnect-1]');94 105 for elt in range(0, num_of_elt): 95 96 fid.write('3 %d %d %d\n' %(model.mesh.elements[elt,0]-1,model.mesh.elements[elt,1]-1,model.mesh.elements[elt,2]-1)) 97 106 fid.write('3 %d %d %d\n' %(connect[elt,0], 107 connect[elt,1], 108 connect[elt,2])) 109 98 110 fid.write('CELL_TYPES %d\n' %num_of_elt) 99 111 for elt in range(0, num_of_elt): … … 101 113 102 114 fid.write('POINT_DATA %s \n' %str(num_of_points)) 103 104 # loop over the different solution structures115 # }}} 116 # {{{loop over the different solution structures 105 117 if 'solnames' in locals(): 106 118 for sol in solnames: … … 110 122 else: 111 123 timestep = np.size(res_struct.__dict__[sol]) 112 124 113 125 #getting the fields in the solution 114 126 if(np.size(res_struct.__dict__[sol])>1): 115 fieldnames=dict.keys(res_struct.__dict__[sol].__getitem__(timestep -1).__dict__)127 fieldnames=dict.keys(res_struct.__dict__[sol].__getitem__(timestep).__dict__) 116 128 else: 117 129 fieldnames=dict.keys(res_struct.__dict__[sol].__dict__) … … 119 131 for field in fieldnames: 120 132 if(np.size(res_struct.__dict__[sol])>1): 121 fieldstruct=res_struct.__dict__[sol].__getitem__(timestep -1).__dict__[field]133 fieldstruct=res_struct.__dict__[sol].__getitem__(timestep).__dict__[field] 122 134 else: 123 135 fieldstruct=res_struct.__dict__[sol].__dict__[field] 124 136 125 if ((np.size(fieldstruct))== num_of_points):137 if ((np.size(fieldstruct))==every_nodes): 126 138 fid.write('SCALARS %s float 1 \n' % field) 127 139 fid.write('LOOKUP_TABLE default\n') 128 140 for node in range(0,num_of_points): 129 141 #paraview does not like NaN, replacing 130 if np.isnan(fieldstruct[ node]):142 if np.isnan(fieldstruct[enveloppe_index[node]]): 131 143 fid.write('%e\n' % -9999.9999) 132 144 #also checking for verry small value that mess up 133 elif (abs(fieldstruct[ node])<1.0e-20):145 elif (abs(fieldstruct[enveloppe_index[node]])<1.0e-20): 134 146 fid.write('%e\n' % 0.0) 135 147 else: 136 fid.write('%e\n' % fieldstruct[ node])137 138 # loop on arguments, if something other than result is asked, do139 #it now 148 fid.write('%e\n' % fieldstruct[enveloppe_index[node]]) 149 # }}} 150 # {{{loop on arguments, if something other than result is asked, do it now 151 140 152 for other in args: 141 153 other_struct=model.__dict__[other] 142 154 othernames=(dict.keys(other_struct.__dict__)) 143 155 for field in othernames: 144 # fprintf(fid,s,res_struct.(fieldnames{k})(IsEnveloppe)); 145 if ((np.size(other_struct.__dict__[field]))==num_of_points): 156 if ((np.size(other_struct.__dict__[field]))==every_nodes): 146 157 fid.write('SCALARS %s float 1 \n' % field) 147 158 fid.write('LOOKUP_TABLE default\n') 148 159 for node in range(0,num_of_points): 149 160 #paraview does not like NaN, replacing 150 if np.isnan(other_struct.__dict__[field][ node]):161 if np.isnan(other_struct.__dict__[field][enveloppe_index[node]]): 151 162 fid.write('%e\n' % -9999.9999) 152 163 #also checking for verry small value that mess up 153 elif (abs(other_struct.__dict__[field][ node])<1.0e-20):164 elif (abs(other_struct.__dict__[field][enveloppe_index[node]])<1.0e-20): 154 165 fid.write('%e\n' % 0.0) 155 166 else: 156 fid.write('%e\n' % other_struct.__dict__[field][node]) 167 fid.write('%e\n' % other_struct.__dict__[field][enveloppe_index[node]]) 168 169 # }}} 157 170 fid.close(); -
issm/trunk/src/m/contrib/defleurian/paraview/exportVTK.py
r21729 r23394 9 9 creates a directory with the vtk files for displays in paraview 10 10 (only work for triangle and wedges based on their number of nodes) 11 12 Give only the results for nw but could be extended to geometry, mask... 13 14 input: filename destination 11 12 Give only the results for nw but could be extended to geometry, mask... 13 14 input: filename destination 15 15 (string) 16 16 ------------------------------------------------------------------ 17 model this is md 17 model this is md 18 18 ------------------------------------------------------------------ 19 19 By default only the results are exported, you can add whichever … … 67 67 num_of_sols=len(solnames) 68 68 num_of_timesteps=1 69 #%building solutionstructure 69 #%building solutionstructure 70 70 for solution in solnames: 71 71 #looking for multiple time steps … … 91 91 for point in points: 92 92 fid.write('%f %f %f \n'%(point[0], point[1], point[2])) 93 93 94 94 fid.write('CELLS %d %d\n' %(num_of_elt, num_of_elt*(point_per_elt+1))) 95 95 96 96 if point_per_elt==3: 97 97 for elt in range(0, num_of_elt): … … 117 117 else: 118 118 timestep = np.size(res_struct.__dict__[sol]) 119 119 120 120 #getting the fields in the solution 121 121 if(np.size(res_struct.__dict__[sol])>1): … … 187 187 # reloaded variable are generally of dim 2 188 188 elif np.shape(other_struct.__dict__[field])[0]==num_of_points: 189 # we want only vector 190 if np.shape(other_struct.__dict__[field])[1]==1: 189 191 fid.write('SCALARS %s float 1 \n' % field) 190 192 fid.write('LOOKUP_TABLE default\n') 191 193 for node in range(0,num_of_points): 192 194 #paraview does not like NaN, replacing 195 print other_struct.__dict__[field][node] 193 196 if np.isnan(other_struct.__dict__[field][node]): 194 197 fid.write('%e\n' % -9999.9999) 195 #also checking for verry small value that mess up198 #also checking for verry small value that mess up 196 199 elif (abs(other_struct.__dict__[field][node])<1.0e-20): 197 200 fid.write('%e\n' % 0.0) -
issm/trunk/src/m/mesh/planet/gmsh/gmshplanet.m
r22822 r23394 23 23 resolution=getfieldvalue(options,'resolution')*1000; 24 24 25 %initialize mesh: 25 %initialize mesh: 26 26 mesh=mesh3dsurface; 27 27 … … 97 97 end 98 98 fprintf(fid,'};\n'); 99 99 100 100 fclose(fid); 101 101 % }}} … … 111 111 end 112 112 if isempty(gmshpath), 113 error('gm tnot found, make sure it is properly installed');113 error('gmsh not found, make sure it is properly installed'); 114 114 end 115 115 … … 160 160 mesh.numberofelements=fscanf(fid,'%i',1); 161 161 A=fscanf(fid,'%i %i %i %i %i %i %i %i',[8 mesh.numberofelements]); 162 mesh.elements=A(6:8,:)'; 162 mesh.elements=A(6:8,:)'; 163 163 A=fscanf(fid,'%s',1); 164 164 if ~strcmp(A,'$EndElements'), 165 165 error(['Expecting $EndElements (' A ')']); 166 166 end 167 fclose(fid); 167 fclose(fid); 168 168 %}}} 169 169 170 %figure out other fields in mesh3dsurface: 170 %figure out other fields in mesh3dsurface: 171 171 mesh.r=sqrt(mesh.x.^2+mesh.y.^2+mesh.z.^2); 172 172 mesh.lat = asin(mesh.z./mesh.r)/pi*180; 173 173 mesh.long = atan2(mesh.y,mesh.x)/pi*180; 174 174 175 %erase files: 175 %erase files: 176 176 system('rm -rf sphere.geo sphere.msh sphere.pos'); 177 177 178 %return mesh: 178 %return mesh: 179 179 return; -
issm/trunk/src/m/mesh/triangle.py
r22758 r23394 2 2 import numpy as np 3 3 from mesh2d import mesh2d 4 from Triangle import Triangle5 4 from NodeConnectivity import NodeConnectivity 6 5 from ElementConnectivity import ElementConnectivity 6 from Triangle_python import Triangle_python 7 7 import MatlabFuncs as m 8 8 … … 50 50 #Mesh using Triangle 51 51 md.mesh=mesh2d() 52 md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers=Triangle (domainname,riftname,area)52 md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers=Triangle_python(domainname,riftname,area) 53 53 md.mesh.elements=md.mesh.elements.astype(int) 54 54 md.mesh.segments=md.mesh.segments.astype(int) -
issm/trunk/src/m/mesh/triangle2dvertical.m
r22758 r23394 25 25 26 26 %Mesh using Triangle 27 [elements,x,z,segments,segmentmarkers]=Triangle (domainname,'',area);27 [elements,x,z,segments,segmentmarkers]=Triangle_matlab(domainname,'',area); 28 28 29 29 %check that all the created nodes belong to at least one element -
issm/trunk/src/m/modules/Chaco.py
r23189 r23394 5 5 6 6 Usage: 7 [assgn]= Chaco(A,vwgts,ewgts,x,y,z,options,nparts,goal);7 assgn = Chaco(A,vwgts,ewgts,x,y,z,options,nparts,goal); 8 8 9 9 A: Input adjacency matrix -
issm/trunk/src/m/modules/MeshPartition.m
r22758 r23394 3 3 % 4 4 % Usage: 5 % [element_partitioning,node_partitioning]=MeshPartition(md,numpartitions) ");5 % [element_partitioning,node_partitioning]=MeshPartition(md,numpartitions); 6 6 % 7 7 % element_partitioning: Vector of partitioning area numbers, for every element. … … 35 35 36 36 % Call mex module 37 [element_partitioning, node_partitioning] = MeshPartition_matlab(numberofvertices,elements,numberofvertices2d,elements2d,numberoflayers, meshelementtype,numpartitions);37 [element_partitioning, node_partitioning] = MeshPartition_matlab(numberofvertices,elements,numberofvertices2d,elements2d,numberoflayers,elementtype,numpartitions); -
issm/trunk/src/m/modules/MeshPartition.py
r23189 r23394 9 9 10 10 Usage: 11 [element_partitioning,node_partitioning]=MeshPartition(md.mesh,numpartitions) ")11 [element_partitioning,node_partitioning]=MeshPartition(md.mesh,numpartitions) 12 12 13 13 element_partitioning: Vector of partitioning area numbers, for every element. … … 38 38 39 39 #Call module 40 [element_partitioning, node_partitioning] = MeshPartition_python(numberofvertices, elements, numberofvertices2d, elements2d, numberoflayers, meshelementtype, numpartitions)40 [element_partitioning, node_partitioning] = MeshPartition_python(numberofvertices, elements, numberofvertices2d, elements2d, numberoflayers,elementtype, numpartitions) 41 41 42 42 return [element_partitioning, node_partitioning] -
issm/trunk/src/m/modules/Scotch.py
r23189 r23394 2 2 3 3 def Scotch(*varargin): 4 '''SCOTCH - Scotch partitioner4 '''SCOTCH - Scotch partitioner 5 5 6 6 Usage: -
issm/trunk/src/m/partition/partitioner.py
r23189 r23394 3 3 import MatlabFuncs as m 4 4 from adjacency import * 5 #from Chaco import *5 from Chaco import * 6 6 #from Scotch import * 7 #from MeshPartition import *7 from MeshPartition import * 8 8 from project3d import * 9 from mesh2d import * 9 10 10 11 def partitioner(md,*varargin): … … 60 61 61 62 if m.strcmpi(package,'chaco'): 62 raise RuntimeError('Chaco is not currently supported for this function')63 #raise RuntimeError('Chaco is not currently supported for this function') 63 64 64 65 # default method (from chaco.m) 65 #method=np.array([1,1,0,0,1,1,50,0,.001,7654321]).reshape(-1,1)66 #method[0]=3 # global method (3=inertial (geometric))67 #method[2]=0 # vertex weights (0=off, 1=on)66 method=np.array([1,1,0,0,1,1,50,0,.001,7654321]) 67 method[0]=3 # global method (3=inertial (geometric)) 68 method[2]=0 # vertex weights (0=off, 1=on) 68 69 69 70 #specify bisection 70 #method[5]=options.getfieldvalue('section')# ndims (1=bisection, 2=quadrisection, 3=octasection)71 method[5]=options.getfieldvalue('section')# ndims (1=bisection, 2=quadrisection, 3=octasection) 71 72 72 73 #are we using weights? 73 #if m.strcmpi(options.getfieldvalue('weighting'),'on'):74 #weights=np.floor(md.qmu.vertex_weight/min(md.qmu.vertex_weight))75 #method[2]=176 #else:77 #weights=[]74 if m.strcmpi(options.getfieldvalue('weighting'),'on'): 75 weights=np.floor(md.qmu.vertex_weight/min(md.qmu.vertex_weight)) 76 method[2]=1 77 else: 78 weights=[] 78 79 80 method = method.reshape(-1,1) # transpose to 1x10 instead of 10 81 79 82 # partition into nparts 80 #if isinstance(md.mesh,mesh2d): 81 #part=Chaco(md.qmu.adjacency,weights,[],md.mesh.x, md.mesh.y,np.zeros((md.mesh.numberofvertices,)),method,npart,[]).T+1 #index partitions from 1 up. like metis. 82 #else: 83 #part=Chaco(md.qmu.adjacency,weights,[],md.mesh.x, md.mesh.y,md.mesh.z,method,npart,[]).T+1 #index partitions from 1 up. like metis. 84 83 if isinstance(md.mesh,mesh2d): 84 part=np.array(Chaco(md.qmu.adjacency,weights,np.array([]),md.mesh.x, md.mesh.y,np.zeros((md.mesh.numberofvertices,)),method,npart,np.array([]))).T+1 #index partitions from 1 up. like metis. 85 else: 86 part=np.array(Chaco(md.qmu.adjacency,weights,np.array([]),md.mesh.x, md.mesh.y,md.mesh.z,method,npart,np.array([]))).T+1 #index partitions from 1 up. like metis. 85 87 86 88 elif m.strcmpi(package,'scotch'): -
issm/trunk/src/m/plot/applyoptions.m
r23189 r23394 142 142 if exist(options,'colorbarcornerposition'), 143 143 c=colorbar(getfieldvalue(options,'colorbarcornerposition'),'peer',gca); 144 elseif exist(options,'colorbarpos') & ischar(getfieldvalue(options,'colorbarpos')), 145 c=colorbar(getfieldvalue(options,'colorbarpos')); 144 146 else 145 147 c=colorbar('peer',gca); … … 151 153 set(c,'Ylim',lim); 152 154 end 153 if exist(options,'colorbarpos') ,155 if exist(options,'colorbarpos') & isnumeric(getfieldvalue(options,'colorbarpos')), 154 156 set(c,'Position',getfieldvalue(options,'colorbarpos')); 155 157 end -
issm/trunk/src/m/plot/googlemaps.m
r22758 r23394 123 123 '&scale=' num2str(scale)]; 124 124 url = ['http://maps.google.com/maps/api/staticmap?' params]; 125 [X, map]=imread(url,'png'); 125 count = 0; 126 countmax = 10; 127 while(true) 128 try, 129 [X, map]=imread(url,'png'); 130 break; 131 catch me, 132 count = count+1; 133 disp(['Failed, trying again... (' num2str(countmax-count) ' more attempts)']); 134 pause(.3); 135 if count>countmax, 136 disp('Giving up...'); 137 rethrow(me); 138 end 139 end 140 end 126 141 X=ind2rgb(X,map); 127 142 indx1 = floor(x*width)+1; -
issm/trunk/src/m/qmu/dakota_in_write.py
r23189 r23394 62 62 filei2=fullfile(pathstr,name+ext) 63 63 64 print 'Opening Dakota input file \''+filei2 + '\' '64 print 'Opening Dakota input file \''+filei2 + '\'.' 65 65 try: 66 66 with open(filei2,'w+') as fidi: -
issm/trunk/src/m/qmu/dakota_out_parse.py
r23189 r23394 241 241 dmax95 =prctile_issm(data,95,0) 242 242 243 # Note: the following line may cause the following warning 244 # (should not crash or invalidate results) when one of 245 # the inputs does not change with respect to the 246 # other/s causing an internal divide-by-zero error 247 248 #/usr/local/lib/python2.7/dist-packages/numpy/lib/function_base.py:3163: 249 # RuntimeWarning: invalid value encountered in true_divide 250 # c /= stddev[:,None] 251 252 # (and/or the same but with "c /= stddev[None, :]") 253 243 254 dcorrel=np.corrcoef(data.T) 244 255 -
issm/trunk/src/m/qmu/helpers.py
r23189 r23394 250 250 pass 251 251 252 # if all of that fails, then i fis not empty252 # if all of that fails, then it is not empty 253 253 return False 254 254 -
issm/trunk/src/m/qmu/preqmu.py
r23189 r23394 45 45 raise RuntimeError('Existing '+str(options.qmudir)+' directory, cannot overwrite. Specify "overwrite","y" option in solve arguments.') 46 46 47 48 os.makedirs(qmudir) 47 # os.makedirs() raises error when dir exists, matlab's mkdir() does not 48 if not os.path.isdir(qmudir): 49 os.makedirs(qmudir) 49 50 os.chdir(qmudir) 50 51 -
issm/trunk/src/m/qmu/process_qmu_response_data.m
r23189 r23394 43 43 %ok, process the domains named in qmu_mass_flux_profiles, to build a list of segments (MatArray) 44 44 md.qmu.mass_flux_segments=cell(num_mass_flux,1); 45 md.qmu.mass_flux_segments46 45 for i=1:num_mass_flux, 47 46 md.qmu.mass_flux_segments{i}=MeshProfileIntersection(md.mesh.elements,md.mesh.x,md.mesh.y,[md.qmu.mass_flux_profile_directory '/' md.qmu.mass_flux_profiles{i}]); 48 47 end 49 md.qmu.mass_flux_segments50 48 end -
issm/trunk/src/m/solve/WriteData.py
r23189 r23394 7 7 """ 8 8 WRITEDATA - write model field in binary file 9 9 10 10 Usage: 11 11 WriteData(fid,varargin) … … 57 57 #Step 1: write the enum to identify this record uniquely 58 58 fid.write(struct.pack('i',len(name))) 59 fid.write(struct.pack('%ds' % len(name),name)) 59 fid.write(struct.pack('%ds' % len(name),name)) 60 60 61 61 #Step 2: write the data itself. … … 67 67 fid.write(struct.pack('i',4+4)) #1 bool (disguised as an int)+code 68 68 69 #write data code: 70 fid.write(struct.pack('i',FormatToCode(format))) 69 #write data code: 70 fid.write(struct.pack('i',FormatToCode(format))) 71 71 72 72 #now write integer … … 81 81 fid.write(struct.pack('i',4+4)) #1 integer + code 82 82 83 #write data code: 84 fid.write(struct.pack('i',FormatToCode(format))) 83 #write data code: 84 fid.write(struct.pack('i',FormatToCode(format))) 85 85 86 86 #now write integer 87 fid.write(struct.pack('i',data)) 87 fid.write(struct.pack('i',data)) 88 88 # }}} 89 89 … … 95 95 fid.write(struct.pack('i',8+4)) #1 double+code 96 96 97 #write data code: 98 fid.write(struct.pack('i',FormatToCode(format))) 97 #write data code: 98 fid.write(struct.pack('i',FormatToCode(format))) 99 99 100 100 #now write double 101 fid.write(struct.pack('d',data)) 101 fid.write(struct.pack('d',data)) 102 102 # }}} 103 103 … … 106 106 fid.write(struct.pack('i',len(data)+4+4)) #string + string size + code 107 107 108 #write data code: 109 fid.write(struct.pack('i',FormatToCode(format))) 108 #write data code: 109 fid.write(struct.pack('i',FormatToCode(format))) 110 110 111 111 #now write string 112 fid.write(struct.pack('i',len(data))) 113 fid.write(struct.pack('%ds' % len(data),data)) 112 fid.write(struct.pack('i',len(data))) 113 fid.write(struct.pack('%ds' % len(data),data)) 114 114 # }}} 115 115 … … 135 135 fid.write(struct.pack('i',4+4+8*np.product(s)+4+4)) #2 integers (32 bits) + the double matrix + code + matrix type 136 136 137 #write data code and matrix type: 138 fid.write(struct.pack('i',FormatToCode(format))) 137 #write data code and matrix type: 138 fid.write(struct.pack('i',FormatToCode(format))) 139 139 fid.write(struct.pack('i',mattype)) 140 140 141 141 #now write matrix 142 142 if np.ndim(data)==1: 143 fid.write(struct.pack('i',s[0])) 144 fid.write(struct.pack('i',1)) 143 fid.write(struct.pack('i',s[0])) 144 fid.write(struct.pack('i',1)) 145 145 for i in xrange(s[0]): 146 146 fid.write(struct.pack('d',float(data[i]))) #get to the "c" convention, hence the transpose 147 147 else: 148 fid.write(struct.pack('i',s[0])) 149 fid.write(struct.pack('i',s[1])) 148 fid.write(struct.pack('i',s[0])) 149 fid.write(struct.pack('i',s[1])) 150 150 for i in xrange(s[0]): 151 151 for j in xrange(s[1]): … … 174 174 fid.write(struct.pack('i',4+4+8*np.product(s)+4+4)) #2 integers (32 bits) + the double matrix + code + matrix type 175 175 176 #write data code and matrix type: 177 fid.write(struct.pack('i',FormatToCode(format))) 176 #write data code and matrix type: 177 fid.write(struct.pack('i',FormatToCode(format))) 178 178 fid.write(struct.pack('i',mattype)) 179 179 180 180 #now write matrix 181 181 if np.ndim(data) == 1: 182 fid.write(struct.pack('i',s[0])) 183 fid.write(struct.pack('i',1)) 182 fid.write(struct.pack('i',s[0])) 183 fid.write(struct.pack('i',1)) 184 184 for i in xrange(s[0]): 185 185 fid.write(struct.pack('d',float(data[i]))) #get to the "c" convention, hence the transpose 186 186 else: 187 fid.write(struct.pack('i',s[0])) 188 fid.write(struct.pack('i',s[1])) 187 fid.write(struct.pack('i',s[0])) 188 fid.write(struct.pack('i',s[1])) 189 189 for i in xrange(s[0]): 190 190 for j in xrange(s[1]): … … 217 217 fid.write(struct.pack('i',recordlength)) #2 integers (32 bits) + the double matrix + code + matrix type 218 218 219 #write data code and matrix type: 220 fid.write(struct.pack('i',FormatToCode(format))) 219 #write data code and matrix type: 220 fid.write(struct.pack('i',FormatToCode(format))) 221 221 fid.write(struct.pack('i',mattype)) 222 222 223 223 #now write matrix 224 224 if np.ndim(data) == 1: 225 fid.write(struct.pack('i',s[0])) 226 fid.write(struct.pack('i',1)) 225 fid.write(struct.pack('i',s[0])) 226 fid.write(struct.pack('i',1)) 227 227 for i in xrange(s[0]): 228 228 fid.write(struct.pack('d',float(data[i]))) #get to the "c" convention, hence the transpose 229 229 else: 230 fid.write(struct.pack('i',s[0])) 231 fid.write(struct.pack('i',s[1])) 230 fid.write(struct.pack('i',s[0])) 231 fid.write(struct.pack('i',s[1])) 232 232 for i in xrange(s[0]): 233 233 for j in xrange(s[1]): … … 266 266 fid.write(struct.pack('i',recordlength)) #2 integers (32 bits) + the matrix + code + matrix type 267 267 268 #write data code and matrix type: 269 fid.write(struct.pack('i',FormatToCode(format))) 268 #write data code and matrix type: 269 fid.write(struct.pack('i',FormatToCode(format))) 270 270 fid.write(struct.pack('i',mattype)) 271 271 … … 276 276 277 277 if rangeA == 0: 278 A = A*0 279 else: 280 A = (A-offsetA)/rangeA*255. 281 278 A = A*0 279 else: 280 A = (A-offsetA)/rangeA*255. 281 282 282 #now write matrix 283 283 if np.ndim(data) == 1: 284 fid.write(struct.pack('i',s[0])) 285 fid.write(struct.pack('i',1)) 284 fid.write(struct.pack('i',s[0])) 285 fid.write(struct.pack('i',1)) 286 286 fid.write(struct.pack('d',float(offsetA))) 287 287 fid.write(struct.pack('d',float(rangeA))) … … 292 292 293 293 elif np.product(s) > 0: 294 fid.write(struct.pack('i',s[0])) 295 fid.write(struct.pack('i',s[1])) 294 fid.write(struct.pack('i',s[0])) 295 fid.write(struct.pack('i',s[1])) 296 296 fid.write(struct.pack('d',float(offsetA))) 297 297 fid.write(struct.pack('d',float(rangeA))) … … 324 324 325 325 #write length of record 326 fid.write(struct.pack('i',recordlength)) 327 328 #write data code: 329 fid.write(struct.pack('i',FormatToCode(format))) 326 fid.write(struct.pack('i',recordlength)) 327 328 #write data code: 329 fid.write(struct.pack('i',FormatToCode(format))) 330 330 331 331 #write data, first number of records 332 fid.write(struct.pack('i',len(data))) 332 fid.write(struct.pack('i',len(data))) 333 333 334 334 for matrix in data: … … 343 343 344 344 if np.ndim(matrix) == 1: 345 fid.write(struct.pack('i',s[0])) 346 fid.write(struct.pack('i',1)) 345 fid.write(struct.pack('i',s[0])) 346 fid.write(struct.pack('i',1)) 347 347 for i in xrange(s[0]): 348 348 fid.write(struct.pack('d',float(matrix[i]))) #get to the "c" convention, hence the transpose 349 349 else: 350 fid.write(struct.pack('i',s[0])) 351 fid.write(struct.pack('i',s[1])) 350 fid.write(struct.pack('i',s[0])) 351 fid.write(struct.pack('i',s[1])) 352 352 for i in xrange(s[0]): 353 353 for j in xrange(s[1]): … … 363 363 364 364 #write length of record 365 fid.write(struct.pack('i',recordlength)) 366 367 #write data code: 368 fid.write(struct.pack('i',FormatToCode(format))) 365 fid.write(struct.pack('i',recordlength)) 366 367 #write data code: 368 fid.write(struct.pack('i',FormatToCode(format))) 369 369 370 370 #now write length of string array 371 fid.write(struct.pack('i',len(data))) 371 fid.write(struct.pack('i',len(data))) 372 372 373 373 #now write the strings 374 374 for string in data: 375 fid.write(struct.pack('i',len(string))) 376 fid.write(struct.pack('%ds' % len(string),string)) 375 fid.write(struct.pack('i',len(string))) 376 fid.write(struct.pack('%ds' % len(string),string)) 377 377 # }}} 378 378 … … 383 383 def FormatToCode(format): # {{{ 384 384 """ 385 This routine takes the format string, and hardcodes it into an integer, which 386 is passed along the record, in order to identify the nature of the dataset being 385 This routine takes the format string, and hardcodes it into an integer, which 386 is passed along the record, in order to identify the nature of the dataset being 387 387 sent. 388 388 """ -
issm/trunk/src/wrappers/Chaco/Chaco.cpp
r22758 r23394 47 47 /*Fetch Data*/ 48 48 FetchChacoData(&nvtxs,&adjacency,&start,&ewgts,A_IN,EWGTS_IN); 49 FetchData(&vwgts,&nterms,VWGTS_IN); 50 FetchData(&x,&nterms,X_IN); 51 FetchData(&y,&nterms,Y_IN); 52 FetchData(&z,&nterms,Z_IN); 53 FetchData(&in_options,&nterms,OPTNS_IN); 49 FetchData(&vwgts,&nterms,VWGTS_IN); 50 FetchData(&x,&nterms,X_IN); 51 FetchData(&y,&nterms,Y_IN); 52 FetchData(&z,&nterms,Z_IN); 53 FetchData(&in_options,&nterms,OPTNS_IN); 54 54 for (i=0;i<(nterms<10?nterms:10);i++) options[i]=in_options[i]; //copy in_options into default options 55 FetchData(&npart,NPARTS_IN); 55 FetchData(&npart,NPARTS_IN); 56 56 //int * nparts=xNew<int>(1); nparts[0]=npart; //weird Chacox interface ain't it? 57 FetchData(&goal,&nterms,GOAL_IN); 57 FetchData(&goal,&nterms,GOAL_IN); 58 58 59 59 /*Allocate output: */ -
issm/trunk/src/wrappers/DistanceToMaskBoundary/DistanceToMaskBoundary.cpp
r21341 r23394 43 43 44 44 /*Call core of computation: */ 45 DistanceToMaskBoundaryx(&distance,x,y,mask,nods); 45 _error_("messing up with AD, is this fonction really used??"); 46 //DistanceToMaskBoundaryx(&distance,x,y,mask,nods); 46 47 47 48 /*Write results: */ -
issm/trunk/src/wrappers/IssmConfig/IssmConfig.cpp
r21341 r23394 66 66 else if(strcmp(name,"_HAVE_M1QN3_")==0){ 67 67 #ifdef _HAVE_M1QN3_ 68 value = 1.; 69 #endif 70 } 71 else if(strcmp(name,"_HAVE_ADOLC_")==0){ 72 #ifdef _HAVE_ADOLC_ 73 value = 1.; 74 #endif 75 } 76 else if(strcmp(name,"_HAVE_CODIPACK_")==0){ 77 #ifdef _HAVE_CODIPACK_ 68 78 value = 1.; 69 79 #endif -
issm/trunk/src/wrappers/javascript/Makefile.am
r23189 r23394 1 AM_CPPFLAGS = @DAKOTAINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @AMPIINCL@ 1 AM_CPPFLAGS = @DAKOTAINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @AMPIINCL@ @ADJOINTMPIINCL@ @CODIPACKINCL@ 2 2 AUTOMAKE_OPTIONS = subdir-objects 3 3 -
issm/trunk/src/wrappers/matlab/Makefile.am
r22758 r23394 1 AM_CPPFLAGS = @NEOPZINCL@ @DAKOTAINCL@ @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @AMPIINCL@ 1 AM_CPPFLAGS = @NEOPZINCL@ @DAKOTAINCL@ @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @AMPIINCL@ @ADJOINTMPIINCL@ @MEDIPACKINCL@ @CODIPACKINCL@ 2 2 AUTOMAKE_OPTIONS = subdir-objects 3 3 -
issm/trunk/src/wrappers/python/Makefile.am
r22758 r23394 1 AM_CPPFLAGS = @DAKOTAINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@ @AMPIINCL@ 1 AM_CPPFLAGS = @DAKOTAINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@ @AMPIINCL@ @ADJOINTMPIINCL@ @MEDIPACKINCL@ @CODIPACKINCL@ 2 2 AUTOMAKE_OPTIONS = subdir-objects 3 3 -
issm/trunk/src/wrappers/python/io/FetchPythonData.cpp
r22758 r23394 32 32 } 33 33 else if (PyInt_Check(py_float)) 34 34 dscalar=(double)PyInt_AsLong(py_float); 35 35 else if (PyBool_Check(py_float)) 36 36 dscalar=(double)PyLong_AsLong(py_float); … … 132 132 double* dmatrix=NULL; 133 133 double* matrix=NULL; 134 int M,N; 134 int M=0; 135 int N=0; 135 136 int ndim; 136 137 npy_intp* dims=NULL; … … 236 237 /*output: */ 237 238 int* matrix=NULL; 238 int M,N; 239 int M=0; 240 int N=0; 239 241 int ndim; 240 242 npy_intp* dims=NULL; … … 325 327 bool* bmatrix=NULL; 326 328 bool* matrix=NULL; 327 int M,N; 329 int M=0; 330 int N=0; 328 331 int ndim; 329 332 npy_intp* dims=NULL; … … 411 414 double* dvector=NULL; 412 415 double* vector=NULL; 413 int M ;416 int M=0; 414 417 int ndim; 415 418 npy_intp* dims=NULL; … … 499 502 /*output: */ 500 503 float* vector=NULL; 501 int M ;504 int M=0; 502 505 int ndim; 503 506 npy_intp* dims=NULL; … … 539 542 /*transform into int vector: */ 540 543 vector=xNew<float>(M); 541 for(i=0;i<M;i++)vector[i]=(float) lvector[i];544 for(i=0;i<M;i++)vector[i]=(float)dvector[i]; 542 545 } 543 546 … … 566 569 } 567 570 else 568 571 vector=NULL; 569 572 } 570 573 else{ … … 584 587 /*output: */ 585 588 int* vector=NULL; 586 int M ;589 int M=0; 587 590 int ndim; 588 591 npy_intp* dims=NULL; … … 624 627 /*transform into int vector: */ 625 628 vector=xNew<int>(M); 626 for(i=0;i<M;i++)vector[i]=(int) lvector[i];629 for(i=0;i<M;i++)vector[i]=(int)dvector[i]; 627 630 } 628 631 … … 672 675 bool* bvector=NULL; 673 676 bool* vector=NULL; 674 int M ;677 int M=0; 675 678 int ndim; 676 679 npy_intp* dims=NULL; … … 923 926 *pcontours=contours; 924 927 } 925 /*}}}*/ 926 void FetchChacoData(int* pnvtxs,int** padjacency,int** pstart,float** pewgts,PyObject* A_IN,PyObject* EWGTS_IN){ 927 _error_("Nathan... I need your help here"); 928 } 928 929 void FetchChacoData(int* pnvtxs,int** padjacency,int** pstart,float** pewgts,PyObject* A_IN, PyObject* EWGTS_IN){/*{{{*/ 930 931 double* a = ((double*)PyArray_DATA((PyArrayObject*)A_IN)); 932 int ndim = PyArray_NDIM((PyArrayObject*)A_IN); 933 int nzmax = PyArray_CountNonzero((PyArrayObject*)A_IN); 934 935 /*Fetch adjacency matrix:*/ 936 int nvtxs = PyArray_DIMS((PyArrayObject*)A_IN)[1]; 937 938 int* mwstart = xNewZeroInit<int>(nvtxs+1); 939 pyGetJc(a,nvtxs,mwstart); 940 941 int* mwadjacency = xNewZeroInit<int>(nzmax); 942 pyGetIr(a,nvtxs,nzmax,mwadjacency); 943 944 int* start = xNew<int>(nvtxs+1); 945 for(int i=0;i<nvtxs+1;i++) start[i]=(int)mwstart[i]; 946 int* adjacency = xNew<int>(nzmax); 947 for(int i=0; i<nzmax; i++) adjacency[i]=(int)mwadjacency[i]; 948 949 /*Get edges weights*/ 950 int nedges = start[nvtxs]; 951 float* ewgts = NULL; 952 int size = PyArray_SIZE((PyArrayObject*)EWGTS_IN); 953 //size may be 1 and still be empty; 954 //presumably size of edge_weights input will never be exactly 1 955 if(size != 1 && size != 0){ 956 ewgts = xNewZeroInit<float>(nedges); 957 for(int i = 0; i<nedges;i++){ 958 ewgts[i] = (float)a[i]; 959 } 960 } 961 962 /*Assign output pointers*/ 963 *pnvtxs = nvtxs; 964 *padjacency = adjacency; 965 *pstart = start; 966 *pewgts = ewgts; 967 } 968 /*}}}*/ 969 970 void pyGetJc(double* a, int nvtxs, int* Jc){ 971 /*{{{*/ 972 //get the number of non-zero elements in each row, adding to the prior number; 973 //always starts with 0 and has length: number_of_rows_in(a)+1 == nvtxs+1 974 // eg: 0, 1, 3, 6, 8, 13, ... 975 // for: 1 in the first row, 2 in the second, 3 in the third, etc. 976 int c = 0; 977 Jc[c++] = 0; 978 979 for(int i=0;i<nvtxs;i++){ 980 for(int j=0;j<nvtxs;j++){ 981 if ((int)a[i+(j*nvtxs)] != 0){ 982 Jc[c] += 1; 983 } 984 } 985 c++; 986 Jc[c] = Jc[c-1]; 987 } 988 return; 989 } 990 /*}}}*/ 991 992 void pyGetIr(double* a, int nvtxs, int nzmax, int* Ir){ 993 /*{{{*/ 994 //get the row-wise position of each non-zero element; 995 //has length: number_of_non_zero_elements_in(a) == nzmax 996 // eg: 10, 24, 25, 4, ... 997 // the 10th, 24th, and 25th elements in the first row, the 4th in the second row 998 // using pyGetJc to determine which indices correspond to which row 999 int r = 0; 1000 1001 for(int i=0;i<nvtxs;i++){ 1002 for(int j=0;j<nvtxs;j++){ 1003 if ((int)a[i+(j*nvtxs)] != 0){ 1004 Ir[r] = j; 1005 r++; 1006 } 1007 } 1008 } 1009 return; 1010 } 1011 /*}}}*/ 929 1012 930 1013 /*Python version dependent: */ -
issm/trunk/src/wrappers/python/io/pythonio.h
r22758 r23394 51 51 void FetchChacoData(int* pnvtxs,int** padjacency,int** pstart,float** pewgts,PyObject* A_IN,PyObject* EWGTS_IN); 52 52 53 void pyGetJc(double* a, int nvtxs, int* Jc); 54 void pyGetIr(double* a, int nvtxs, int nzmax, int* Ir); 55 53 56 int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void )); 54 57 -
issm/trunk/test
-
issm/trunk/test/NightlyRun/runme.py
r23189 r23394 11 11 """ 12 12 RUNME - test deck for ISSM nightly runs 13 13 14 14 In a test deck directory (tests/Vertification/NightlyRun for example) 15 15 The following command will launch all the existing tests: … … 18 18 >> runme(id=[101,102]) 19 19 etc... 20 20 21 21 Available options: 22 22 'id' followed by the list of ids or (parts of) test names requested … … 37 37 'procedure' 'check' : run the test (default) 38 38 'update': update the archive 39 39 40 40 Usage: 41 41 runme(varargin) 42 42 43 43 Examples: 44 44 runme() … … 49 49 runme(id=[[101,102],['Dakota','Slr']]) 50 50 """ 51 52 51 from parallelrange import parallelrange 53 52 from IdToName import IdToName … … 82 81 flist=glob('test*.py') #File name must start with 'test' and must end by '.py' and must be different than 'test.py' 83 82 list_ids=[int(file[4:-3]) for file in flist if not file == 'test.py'] #Keep test id only (skip 'test' and '.py') 84 #print 'list_ids =',list_ids85 83 86 84 i1,i2=parallelrange(rank,numprocs,len(list_ids)) #Get tests for this cpu only 87 85 list_ids=list_ids[i1:i2+1] 88 #print 'list_ids after parallelrange =',list_ids 89 90 if id: 86 87 if np.size(id) > 0 and not id==None: 91 88 test_ids = set(GetIds(id)).intersection(set(list_ids)) 92 89 else: 93 90 # if no tests are specifically provided, do them all 94 91 test_ids = set(list_ids) 95 96 #print 'test_ids after list =',test_ids 92 97 93 # }}} 98 94 #GET exclude {{{ … … 100 96 101 97 test_ids=test_ids.difference(exclude_ids) 102 #print 'test_ids after exclude =',sorted(test_ids)103 #return104 98 # }}} 105 99 #Process Ids according to benchmarks {{{ … … 124 118 elif benchmark=='adolc': 125 119 test_ids=test_ids.intersection(set(range(3001,3200))) 126 #print 'test_ids after benchmark =',test_ids127 120 test_ids=list(test_ids) 128 121 test_ids.sort() 129 #print 'test_ids after sort =',test_ids130 122 # }}} 131 123 … … 190 182 if np.shape(field) != np.shape(archive): 191 183 raise RuntimeError("Field '"+archive_name+"' from test is malformed; shape is "+str(np.shape(field.T))+", should be "+str(np.shape(archive))+" (or "+str(np.shape(archive.T))+").") 192 184 193 185 error_diff=np.amax(np.abs(archive-field),axis=0)/(np.amax(np.abs(archive),axis=0)+float_info.epsilon) 194 186 -
issm/trunk/test/NightlyRun/test2084.m
r23189 r23394 1 2 %Test Name: GiaCaron. 1 %Test Name: GiaCaron 3 2 %Forward Love number solution for a viscoelastic earth, model M3-L70-V01 from 4 3 %Spada, G., Barletta, V. R., Klemann, V., Riva, R. E. M., Martinec, Z., … … 39 38 %loading love numbers 40 39 field_names ={'LoveH_loading_elastic','LoveK_loading_elastic','LoveL_loading_elastic'}; 41 field_tolerances={ 7.0e-10,7.0e-10,7.0e-10};40 field_tolerances={4.3e-9,4.3e-9,4.3e-9}; 42 41 field_values={... 43 42 (md.results.LoveSolution.LoveHr(:,1)),... … … 57 56 %Fields and tolerances to track changes 58 57 field_names ={field_names{:},'LoveH_loading_realpart','LoveK_loading_realpart','LoveL_loading_realpart','LoveH_loading_imagpart','LoveK_loading_imagpart','LoveL_loading_imagpart'}; 59 field_tolerances={field_tolerances{:}, 7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10};58 field_tolerances={field_tolerances{:},5e-7,5e-7,5e-7,5e-7,5e-7,5e-7}; 60 59 field_values={field_values{:},... 61 60 (md.results.LoveSolution.LoveHr(:,:)),... … … 75 74 %tidal love numbers 76 75 field_names ={field_names{:},'LoveH_tidal_elastic','LoveK_tidal_elastic','LoveL_tidal_elastic','LoveH_tidal_realpart','LoveK_tidal_realpart','LoveL_tidal_realpart','LoveH_tidal_imagpart','LoveK_tidal_imagpart','LoveL_tidal_imagpart'}; 77 field_tolerances={field_tolerances{:}, 7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10};76 field_tolerances={field_tolerances{:},8e-6,8e-6,8e-6,8e-6,8e-6,8e-6,8e-6,8e-6,8e-6}; 78 77 field_values={field_values{:},... 79 78 (md.results.LoveSolution.LoveHr(:,1)),... … … 115 114 % 116 115 %field_names ={field_names{:},'LoveH_loadingVSS96_elastic','LoveK_loadingVSS96_elastic','LoveL_loadingVSS96_elastic','LoveH_loadingVSS96_realpart','LoveK_loadingVSS96_realpart','LoveL_loadingVSS96_realpart','LoveH_loadingVSS96_imagpart','LoveK_loadingVSS96_imagpart','LoveL_loadingVSS96_imagpart'}; 117 %field_tolerances={field_tolerances{:}, 7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10};116 %field_tolerances={field_tolerances{:},2e-6,2e-6,2e-6,2e-6,2e-6,2e-6,2e-6,2e-6,2e-6}; 118 117 %field_values={field_values{:},... 119 118 % (md.results.LoveSolution.LoveHr(:,1)),... … … 147 146 148 147 field_names ={field_names{:},'LoveH_loadingVSS96_elastic','LoveK_loadingVSS96_elastic','LoveL_loadingVSS96_elastic','LoveH_loadingVSS96_realpart','LoveK_loadingVSS96_realpart','LoveL_loadingVSS96_realpart','LoveH_loadingVSS96_imagpart','LoveK_loadingVSS96_imagpart','LoveL_loadingVSS96_imagpart'}; 149 field_tolerances={field_tolerances{:}, 7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10,7.0e-10};148 field_tolerances={field_tolerances{:},2e-6,2e-6,2e-6,2e-6,2e-6,2e-6,2e-6,2e-6,2e-6}; 150 149 field_values={field_values{:},... 151 150 (md.results.LoveSolution.LoveHr(:,1)),... -
issm/trunk/test/NightlyRun/test2084.py
r23189 r23394 1 #Test Name: GiaCaron. Forward Love number solution for a viscoelastic earth, 2 # model M3-L70-V01 from Spada, G., Barletta, V. R., Klemann, V., Riva, R. E. M., 3 # Martinec, Z., Gasperini, P., Lund, B., Wolf, D., Vermeersen, L. L. A. 4 # and King, M. A. (2011), A benchmark study for glacial isostatic 5 # adjustment codes. Geophysical Journal International, 6 # 185: 106-132. doi:10.1111/j.1365-246X.2011.04952.x 1 #Test Name: GiaCaron 2 #Forward Love number solution for a viscoelastic earth, 3 #model M3-L70-V01 from Spada, G., Barletta, V. R., Klemann, V., Riva, R. E. M., 4 #Martinec, Z., Gasperini, P., Lund, B., Wolf, D., Vermeersen, L. L. A. 5 #and King, M. A. (2011), A benchmark study for glacial isostatic 6 #adjustment codes. Geophysical Journal International, 7 #185: 106-132. doi:10.1111/j.1365-246X.2011.04952.x 7 8 8 9 from model import * … … 48 49 #Fields and tolerances to track changes 49 50 #loading love numbers 50 field_names=['LoveH e','LoveKe','LoveLe']51 field_tolerances=[ 3.7e-9,3.7e-9,3.7e-9]51 field_names=['LoveH_loading_elastic','LoveK_loading_elastic','LoveL_loading_elastic'] 52 field_tolerances=[4.3e-9,4.3e-9,4.3e-9] 52 53 field_values=[ 53 54 np.array(md.results.LoveSolution.LoveHr)[:,0], … … 67 68 #Fields and tolerances to track changes 68 69 #loading love numbers 69 field_names+=['LoveH lr','LoveKlr','LoveLlr','LoveHli','LoveKli','LoveLli']70 field_tolerances+=[ 3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9]70 field_names+=['LoveH_loading_realpart','LoveK_loading_realpart','LoveL_loading_realpart','LoveH_loading_imagpart','LoveK_loading_imagpart','LoveL_loading_imagpart'] 71 field_tolerances+=[5e-7,5e-7,5e-7,5e-7,5e-7,5e-7] 71 72 field_values+=[ 72 73 np.array(md.results.LoveSolution.LoveHr), … … 87 88 88 89 #tidal love numbers, check 89 field_names+=['LoveH tr','LoveKtr','LoveLtr','LoveHti','LoveKti','LoveLti']90 field_tolerances+=[ 3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9]90 field_names+=['LoveH_tidal_elastic','LoveK_tidal_elastic','LoveL_tidal_elastic','LoveH_tidal_realpart','LoveK_tidal_realpart','LoveL_tidal_realpart','LoveH_tidal_imagpart','LoveK_tidal_imagpart','LoveL_tidal_imagpart'] 91 field_tolerances+=[8e-6,8e-6,8e-6,8e-6,8e-6,8e-6,8e-6,8e-6,8e-6] 91 92 field_values+=[ 92 93 np.array(md.results.LoveSolution.LoveHr)[:,0], … … 127 128 #md=solve(md,'lv') 128 129 # 129 #field_names=[field_names,'LoveH mr','LoveKmr','LoveLmr','LoveHmi','LoveKmi','LoveLmi']130 #field_tolerances=[field_tolerances, 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13]130 #field_names=[field_names,'LoveH_loadingVSS96_elastic','LoveK_loadingVSS96_elastic','LoveL_loadingVSS96_elastic','LoveH_loadingVSS96_realpart','LoveK_loadingVSS96_realpart','LoveL_loadingVSS96_realpart','LoveH_loadingVSS96_imagpart','LoveK_loadingVSS96_imagpart','LoveL_loadingVSS96_imagpart'] 131 #field_tolerances=[field_tolerances,4.3e-9,4.3e-9,4.3e-9,4.3e-9,4.3e-9,4.3e-9,4.3e-9,4.3e-9,4.3e-9] 131 132 #field_values=[field_values,\ 132 133 # (md.results.LoveSolution.LoveHr[:][0]),\ … … 186 187 md.love.nfreq=len(md.love.frequencies) 187 188 188 field_names+=['LoveH mr','LoveKmr','LoveLmr','LoveHmi','LoveKmi','LoveLmi']189 field_tolerances+=[ 3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9,3.7e-9]189 field_names+=['LoveH_loadingVSS96_elastic','LoveK_loadingVSS96_elastic','LoveL_loadingVSS96_elastic','LoveH_loadingVSS96_realpart','LoveK_loadingVSS96_realpart','LoveL_loadingVSS96_realpart','LoveH_loadingVSS96_imagpart','LoveK_loadingVSS96_imagpart','LoveL_loadingVSS96_imagpart'] 190 field_tolerances+=[2e-6,2e-6,2e-6,2e-6,2e-6,2e-6,2e-6,2e-6,2e-6] 190 191 field_values+=[ 191 192 np.array(md.results.LoveSolution.LoveHr)[:,0], -
issm/trunk/test/NightlyRun/test211.js
r21341 r23394 12 12 //Fields and tolerances to track changes 13 13 field_names=[ 14 'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsGroundediceMeltingRate1', 15 'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsGroundediceMeltingRate2', 14 'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsGroundediceMeltingRate1', 15 'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsGroundediceMeltingRate2', 16 16 'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsGroundediceMeltingRate3']; 17 17 field_tolerances=[ 18 18 2e-08,2e-08,5e-05,2e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08, 19 5e-06,5e-06,8e-05,5e-06, 1e-07,5e-07,5e-07,5e-07,3e-06,5e-05,19 5e-06,5e-06,8e-05,5e-06,5e-07,5e-07,5e-07,5e-07,3e-06,5e-05, 20 20 8e-06,8e-06,8e-05,8e-06,5e-07,8e-07,8e-07,8e-07,5e-06,8e-05]; 21 21 field_values=[ -
issm/trunk/test/NightlyRun/test211.m
r21341 r23394 16 16 field_tolerances={... 17 17 2e-08,2e-08,5e-05,2e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,... 18 5e-06,5e-06,8e-05,5e-06, 1e-07,5e-07,5e-07,5e-07,3e-06,5e-05,...18 5e-06,5e-06,8e-05,5e-06,5e-07,5e-07,5e-07,5e-07,3e-06,5e-05,... 19 19 8e-06,8e-06,8e-05,8e-06,5e-07,8e-07,8e-07,8e-07,5e-06,8e-05}; 20 20 field_values={... -
issm/trunk/test/NightlyRun/test211.py
r21729 r23394 26 26 'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsGroundediceMeltingRate3'] 27 27 field_tolerances=[2e-08,2e-08,5e-05,2e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08, 28 5e-06,5e-06,8e-05,5e-06,1e-07,5e-07,5e-07,5e-07,3e-06,5e-05,29 28 5e-06,5e-06,8e-05,5e-06,5e-07,5e-07,5e-07,5e-07,3e-06,5e-05, 29 8e-06,8e-06,8e-05,8e-06,5e-07,8e-07,8e-07,8e-07,5e-06,8e-05] 30 30 field_values=[md.results.TransientSolution[0].Vx, 31 31 md.results.TransientSolution[0].Vy, -
issm/trunk/test/NightlyRun/test215.m
r23189 r23394 24 24 %Fields and tolerances to track changes 25 25 field_names ={'Gradient','Misfits','MaterialsRheologyBbar','Pressure','Vel','Vx','Vy'}; 26 field_tolerances={4.6e-08,1e-08,2e-08, 1e-09,2e-09,2e-08,2e-08};26 field_tolerances={4.6e-08,1e-08,2e-08,2e-09,3e-09,2e-08,2e-08}; 27 27 field_values={... 28 28 (md.results.StressbalanceSolution.Gradient1),... -
issm/trunk/test/NightlyRun/test215.py
r23189 r23394 37 37 # Fields and tolerances to track changes 38 38 field_names =['Gradient','Misfits','MaterialsRheologyBbar','Pressure','Vel','Vx','Vy'] 39 field_tolerances=[4.6e-08,1e-08,2e-0 9,1e-08,2e-09,2e-08,2e-08]39 field_tolerances=[4.6e-08,1e-08,2e-08,2e-09,3e-09,2e-08,2e-08] 40 40 field_values=[md.results.StressbalanceSolution.Gradient1, 41 41 md.results.StressbalanceSolution.J, -
issm/trunk/test/NightlyRun/test290.m
r21341 r23394 11 11 %Fields and tolerances to track changes 12 12 field_names ={'Vx','Vy','Vz','Vel','Pressure'}; 13 field_tolerances={5e-5,5e-5,8e- 5,5e-5,1e-7};13 field_tolerances={5e-5,5e-5,8e-4,5e-4,2e-7}; 14 14 field_values={... 15 15 (md.results.StressbalanceSolution.Vx),... -
issm/trunk/test/NightlyRun/test290.py
r21729 r23394 21 21 #Fields and tolerances to track changes 22 22 field_names =['Vx', 'Vy', 'Vz', 'Vel','Pressure'] 23 field_tolerances=[5e-5,5e-5,8e- 5,5e-5,1e-7]23 field_tolerances=[5e-5,5e-5,8e-4,5e-4,2e-7] 24 24 field_values=[\ 25 25 md.results.StressbalanceSolution.Vx,\ -
issm/trunk/test/NightlyRun/test3015.m
r22758 r23394 15 15 %setup autodiff parameters 16 16 index=1; %this is the scalar component we are checking against 17 md.autodiff.independents={... 18 independent('name','md.geometry.thickness','type','vertex','nods',md.mesh.numberofvertices,'fos_forward_index',index) 17 18 if IssmConfig('_HAVE_CODIPACK_') 19 md.autodiff.independents={... 20 independent('name','md.geometry.thickness','type','vertex','nods',md.mesh.numberofvertices) 21 }; 22 md.autodiff.dependents={... 23 dependent('name','IceVolume','type','scalar','fos_reverse_index',index)... 24 }; 25 md.autodiff.driver='fos_reverse'; 26 else 27 md.autodiff.independents={... 28 independent('name','md.geometry.thickness','type','vertex','nods',md.mesh.numberofvertices,'fos_forward_index',index) 19 29 }; 20 30 21 md.autodiff.dependents={... 22 dependent('name','IceVolume','type','scalar')... 23 }; 24 md.autodiff.driver='fos_forward'; 31 md.autodiff.dependents={... 32 dependent('name','IceVolume','type','scalar')... 33 }; 34 md.autodiff.driver='fos_forward'; 35 end 25 36 26 37 %parameters for the step-wise derivative … … 70 81 md=solve(md,'Masstransport'); 71 82 %retrieve directly 72 dVdh_ad=md.results.MasstransportSolution.AutodiffJacobian; 83 if IssmConfig('_HAVE_CODIPACK_') 84 dVdh_ad=md.results.MasstransportSolution.AutodiffJacobian(index); 85 else 86 dVdh_ad=md.results.MasstransportSolution.AutodiffJacobian; 87 end 73 88 74 disp(sprintf('dV/dh: analytical: %16.16g\n using ad olc:%16.16g\n',dVdh_an,dVdh_ad));89 disp(sprintf('dV/dh: analytical: %16.16g\n using ad: %16.16g\n',dVdh_an,dVdh_ad)); 75 90 76 91 %Fields and tolerances to track changes -
issm/trunk/test/NightlyRun/test3480.m
r22758 r23394 18 18 md.inversion.iscontrol=1; 19 19 md.autodiff.isautodiff=1; 20 md.autodiff.driver='fos_reverse'; 20 21 21 22 md.friction.coefficient(1:md.mesh.numberofvertices,1)=50; -
issm/trunk/test/NightlyRun/test3481.m
r22758 r23394 18 18 md.inversion.iscontrol=1; 19 19 md.autodiff.isautodiff=1; 20 md.autodiff.driver='fos_reverse'; 20 21 21 22 md.friction.coefficient(1:md.mesh.numberofvertices,1)=50; -
issm/trunk/test/NightlyRun/test421.m
r23189 r23394 10 10 %Fields and tolerances to track changes 11 11 field_names ={'Vx','Vy','Vz','Vel','Pressure'}; 12 field_tolerances={ 1e-06,9e-07,2e-05,2e-06,2e-06};12 field_tolerances={2e-06,9e-07,2e-05,2e-06,2e-06}; 13 13 field_values={... 14 14 (md.results.StressbalanceSolution.Vx),... -
issm/trunk/test/NightlyRun/test421.py
r23189 r23394 20 20 #Fields and tolerances to track changes 21 21 field_names =['Vx','Vy','Vz','Vel','Pressure'] 22 field_tolerances=[ 1e-06,9e-07,2e-05,2e-06,2e-06]22 field_tolerances=[2e-06,9e-07,2e-05,2e-06,2e-06] 23 23 field_values=[\ 24 24 md.results.StressbalanceSolution.Vx,\ -
issm/trunk/test/NightlyRun/test455.m
r21341 r23394 14 14 md=solve(md,'Stressbalance'); 15 15 field_names ={field_names{:},['Vx' i{1}],['Vy' i{1}],['Vz' i{1}],['Vel' i{1}],['Pressure' i{1}]}; 16 field_tolerances={field_tolerances{:}, 6e-08,6e-08,6e-08,6e-08,3e-13};16 field_tolerances={field_tolerances{:},7e-08,6e-08,6e-08,6e-08,3e-13}; 17 17 field_values={field_values{:},... 18 18 (md.results.StressbalanceSolution.Vx),... -
issm/trunk/test/NightlyRun/test455.py
r21729 r23394 24 24 md=solve(md,'Stressbalance') 25 25 field_names =field_names+['Vx'+i,'Vy'+i,'Vz'+i,'Vel'+i,'Pressure'+i] 26 field_tolerances=field_tolerances+[ 6e-08,6e-08,6e-08,6e-08,3e-13]26 field_tolerances=field_tolerances+[7e-08,6e-08,6e-08,6e-08,3e-13] 27 27 field_values=field_values+[\ 28 28 md.results.StressbalanceSolution.Vx,\ -
issm/trunk/test/NightlyRun/test701.m
r23189 r23394 35 35 md.stressbalance.spcvx(find(vertexflags(md.mesh,4)))=0; 36 36 md.stressbalance.spcvy(find(vertexflags(md.mesh,4)))=0; 37 md.basalforcings.floatingice_melting_rate=zeros(md.mesh.numberofvertices,1); 37 38 38 39 %Misc -
issm/trunk/test/NightlyRun/test701.py
r23189 r23394 42 42 md.stressbalance.spcvx[np.where(md.mesh.vertexflags(4))] = 0. 43 43 md.stressbalance.spcvy[np.where(md.mesh.vertexflags(4))] = 0. 44 md.basalforcings.floatingice_melting_rate=np.zeros((md.mesh.numberofvertices,)) 44 45 45 46 #Misc -
issm/trunk/test/NightlyRun/test702.m
r23189 r23394 34 34 md.stressbalance.spcvx(find(vertexflags(md.mesh,4)))=800; 35 35 md.stressbalance.spcvy(find(vertexflags(md.mesh,4)))=0; 36 md.basalforcings.floatingice_melting_rate=zeros(md.mesh.numberofvertices,1); 36 37 37 38 %Misc
Note:
See TracChangeset
for help on using the changeset viewer.