[issm-svn] r13975 - issm/trunk

morlighe at issm.ess.uci.edu morlighe at issm.ess.uci.edu
Fri Nov 16 08:10:16 PST 2012


Author: morlighe
Date: 2012-11-16 08:10:16 -0800 (Fri, 16 Nov 2012)
New Revision: 13975

Added:
   issm/trunk/configs/config-linux64-cloud.sh
   issm/trunk/configs/config-macosx64-mlion-mathieu.sh
   issm/trunk/configs/config-pleiades-petsc3.3.sh
   issm/trunk/externalpackages/adolc/install-2.2.0.sh
   issm/trunk/externalpackages/adolc/install-update-dev.sh
   issm/trunk/externalpackages/adolc/update.sh
   issm/trunk/externalpackages/dakota/install-linux64-cloud.sh
   issm/trunk/externalpackages/dakota/install-pleiades-petsc3.3.sh
   issm/trunk/externalpackages/ec2ami/
   issm/trunk/externalpackages/ec2api/
   issm/trunk/externalpackages/gdal/GDALmake.opt.patch.astrid
   issm/trunk/externalpackages/gdal/install-linux64-astrid.sh
   issm/trunk/externalpackages/gdal/install-linux64-murdo.sh
   issm/trunk/externalpackages/gdal/install-macosx64.sh
   issm/trunk/externalpackages/gmp/
   issm/trunk/externalpackages/mpich2/install-1.5-linux64.sh
   issm/trunk/externalpackages/mpich2/install-1.5-macosx64.sh
   issm/trunk/externalpackages/mpich2/install-1.5-walgreen.sh
   issm/trunk/externalpackages/netcdf/install.sh
   issm/trunk/externalpackages/numpy/install-macosx-mlion.sh
   issm/trunk/externalpackages/openssl/
   issm/trunk/externalpackages/petsc/install-3.3-pleiades.sh
   issm/trunk/externalpackages/petsc/install-3.3-walgreen.sh
   issm/trunk/externalpackages/python/install-2.7.3-macosx-mlion.sh
   issm/trunk/externalpackages/scipy/install-macosx-mlion.sh
   issm/trunk/externalpackages/starcluster/
   issm/trunk/scripts/BinRead.py
   issm/trunk/scripts/mToPy.py
   issm/trunk/scripts/translateToPy.py
   issm/trunk/src/android/ISSM/
   issm/trunk/src/android/ISSM_Visual/
   issm/trunk/src/android/Makefile.am
   issm/trunk/src/android/helloworld/
   issm/trunk/src/android/issm-android-inputfiles/
   issm/trunk/src/c/android/
   issm/trunk/src/c/classes/AdolcEdf.h
   issm/trunk/src/c/classes/IssmComm.cpp
   issm/trunk/src/c/classes/IssmComm.h
   issm/trunk/src/c/classes/RiftStruct.cpp
   issm/trunk/src/c/classes/RiftStruct.h
   issm/trunk/src/c/classes/objects/DependentObject.cpp
   issm/trunk/src/c/classes/objects/DependentObject.h
   issm/trunk/src/c/classes/objects/IndependentObject.cpp
   issm/trunk/src/c/classes/objects/IndependentObject.h
   issm/trunk/src/c/classes/objects/Params/DataSetParam.cpp
   issm/trunk/src/c/classes/objects/Params/DataSetParam.h
   issm/trunk/src/c/classes/objects/Profiler.cpp
   issm/trunk/src/c/classes/objects/Profiler.h
   issm/trunk/src/c/io/Disk/WriteLockFile.cpp
   issm/trunk/src/c/modules/TriMeshProcessRiftsx/
   issm/trunk/src/c/shared/Numerics/isnan.cpp
   issm/trunk/src/c/solutions/DakotaSpawnCore.cpp
   issm/trunk/src/c/solutions/EnvironmentFinalize.cpp
   issm/trunk/src/c/solutions/EnvironmentInit.cpp
   issm/trunk/src/c/solutions/WrapperCorePointerFromSolutionEnum.cpp
   issm/trunk/src/c/solutions/ad_core.cpp
   issm/trunk/src/c/solutions/dakota_core.cpp
   issm/trunk/src/m/boundaryconditions/SetIceSheetBC.py
   issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.py
   issm/trunk/src/m/classes/clusters/cloud.m
   issm/trunk/src/m/classes/dependent.m
   issm/trunk/src/m/classes/dependent.py
   issm/trunk/src/m/classes/independent.m
   issm/trunk/src/m/classes/independent.py
   issm/trunk/src/m/classes/matdamageice.py
   issm/trunk/src/m/classes/organizer.py
   issm/trunk/src/m/classes/plotoptions.py
   issm/trunk/src/m/classes/results.py
   issm/trunk/src/m/enum/AutodiffDependentObjectIndicesEnum.m
   issm/trunk/src/m/enum/AutodiffDependentObjectNamesEnum.m
   issm/trunk/src/m/enum/AutodiffDependentObjectTypesEnum.m
   issm/trunk/src/m/enum/AutodiffDependentObjectsEnum.m
   issm/trunk/src/m/enum/AutodiffDriverEnum.m
   issm/trunk/src/m/enum/AutodiffFosForwardIndexEnum.m
   issm/trunk/src/m/enum/AutodiffFosReverseIndexEnum.m
   issm/trunk/src/m/enum/AutodiffFovForwardIndicesEnum.m
   issm/trunk/src/m/enum/AutodiffIndependentObjectNamesEnum.m
   issm/trunk/src/m/enum/AutodiffIndependentObjectTypesEnum.m
   issm/trunk/src/m/enum/AutodiffIndependentObjectsEnum.m
   issm/trunk/src/m/enum/AutodiffKeepEnum.m
   issm/trunk/src/m/enum/AutodiffMassFluxSegmentsPresentEnum.m
   issm/trunk/src/m/enum/AutodiffNumDependentObjectsEnum.m
   issm/trunk/src/m/enum/AutodiffNumIndependentObjectsEnum.m
   issm/trunk/src/m/enum/DataSetParamEnum.m
   issm/trunk/src/m/enum/DependentObjectEnum.m
   issm/trunk/src/m/enum/IndependentObjectEnum.m
   issm/trunk/src/m/enum/LockFileNameEnum.m
   issm/trunk/src/m/enum/MassFluxSegmentsEnum.m
   issm/trunk/src/m/enum/MassFluxSegmentsPresentEnum.m
   issm/trunk/src/m/enum/ProfilerEnum.m
   issm/trunk/src/m/enum/PrognosticNumRequestedOutputsEnum.m
   issm/trunk/src/m/enum/PrognosticRequestedOutputsEnum.m
   issm/trunk/src/m/enum/QmuMassFluxSegmentsPresentEnum.m
   issm/trunk/src/m/enum/SurfaceforcingsHrefEnum.m
   issm/trunk/src/m/enum/SurfaceforcingsSmbrefEnum.m
   issm/trunk/src/m/geometry/GetAreas.py
   issm/trunk/src/m/geometry/isconnected.m
   issm/trunk/src/m/io/loadmodel.py
   issm/trunk/src/m/io/loadvars.py
   issm/trunk/src/m/io/savevars.py
   issm/trunk/src/m/mesh/ComputeHessian.py
   issm/trunk/src/m/mesh/ComputeMetric.py
   issm/trunk/src/m/mesh/ElementsFromEdge.py
   issm/trunk/src/m/mesh/GetNodalFunctionsCoeff.py
   issm/trunk/src/m/mesh/bamg.py
   issm/trunk/src/m/mesh/rifts/meshprocessoutsiderifts.py
   issm/trunk/src/m/mesh/rifts/meshprocessrifts.py
   issm/trunk/src/m/mesh/roundmesh.py
   issm/trunk/src/m/os/issmstscpin.m
   issm/trunk/src/m/os/issmstscpout.m
   issm/trunk/src/m/os/issmstssh.m
   issm/trunk/src/m/os/starcluster.m
   issm/trunk/src/m/parameterization/contourenvelope.py
   issm/trunk/src/m/plot/applyoptions.py
   issm/trunk/src/m/plot/checkplotoptions.py
   issm/trunk/src/m/plot/curvedarrow.m
   issm/trunk/src/m/plot/plot_manager.py
   issm/trunk/src/m/plot/plot_mesh.py
   issm/trunk/src/m/plot/plot_unit.py
   issm/trunk/src/m/plot/plotmodel.py
   issm/trunk/src/m/plot/processdata.py
   issm/trunk/src/m/plot/processmesh.py
   issm/trunk/src/wrappers/
   issm/trunk/test/Archives/Archive3015.nc
   issm/trunk/test/Archives/Archive3019.nc
   issm/trunk/test/Archives/Archive3020.nc
   issm/trunk/test/NightlyRun/InNeedOfDebugging/
   issm/trunk/test/NightlyRun/ad_maxalloc.m
   issm/trunk/test/NightlyRun/python_skipped_tests.txt
   issm/trunk/test/NightlyRun/python_test_guidelines.txt
   issm/trunk/test/NightlyRun/test119.py
   issm/trunk/test/NightlyRun/test1601.py
   issm/trunk/test/NightlyRun/test1602.py
   issm/trunk/test/NightlyRun/test201.py
   issm/trunk/test/NightlyRun/test202.py
   issm/trunk/test/NightlyRun/test203.py
   issm/trunk/test/NightlyRun/test204.py
   issm/trunk/test/NightlyRun/test205.py
   issm/trunk/test/NightlyRun/test206.py
   issm/trunk/test/NightlyRun/test207.py
   issm/trunk/test/NightlyRun/test208.py
   issm/trunk/test/NightlyRun/test209.py
   issm/trunk/test/NightlyRun/test210.py
   issm/trunk/test/NightlyRun/test211.py
   issm/trunk/test/NightlyRun/test212.py
   issm/trunk/test/NightlyRun/test213.py
   issm/trunk/test/NightlyRun/test214.py
   issm/trunk/test/NightlyRun/test215.py
   issm/trunk/test/NightlyRun/test216.py
   issm/trunk/test/NightlyRun/test217.py
   issm/trunk/test/NightlyRun/test219.py
   issm/trunk/test/NightlyRun/test220.py
   issm/trunk/test/NightlyRun/test221.py
   issm/trunk/test/NightlyRun/test222.py
   issm/trunk/test/NightlyRun/test223.py
   issm/trunk/test/NightlyRun/test224.py
   issm/trunk/test/NightlyRun/test225.py
   issm/trunk/test/NightlyRun/test226.py
   issm/trunk/test/NightlyRun/test227.py
   issm/trunk/test/NightlyRun/test228.py
   issm/trunk/test/NightlyRun/test229.py
   issm/trunk/test/NightlyRun/test230.py
   issm/trunk/test/NightlyRun/test231.py
   issm/trunk/test/NightlyRun/test232.py
   issm/trunk/test/NightlyRun/test233.py
   issm/trunk/test/NightlyRun/test236.py
   issm/trunk/test/NightlyRun/test237.py
   issm/trunk/test/NightlyRun/test270.py
   issm/trunk/test/NightlyRun/test272.py
   issm/trunk/test/NightlyRun/test274.py
   issm/trunk/test/NightlyRun/test3001.py
   issm/trunk/test/NightlyRun/test3002.py
   issm/trunk/test/NightlyRun/test3003.py
   issm/trunk/test/NightlyRun/test3004.py
   issm/trunk/test/NightlyRun/test3005.py
   issm/trunk/test/NightlyRun/test3006.py
   issm/trunk/test/NightlyRun/test3007.py
   issm/trunk/test/NightlyRun/test3008.py
   issm/trunk/test/NightlyRun/test3009.py
   issm/trunk/test/NightlyRun/test301.py
   issm/trunk/test/NightlyRun/test3010.py
   issm/trunk/test/NightlyRun/test3015.m
   issm/trunk/test/NightlyRun/test3015.py
   issm/trunk/test/NightlyRun/test3019.m
   issm/trunk/test/NightlyRun/test3019.py
   issm/trunk/test/NightlyRun/test302.py
   issm/trunk/test/NightlyRun/test3020.m
   issm/trunk/test/NightlyRun/test3020.py
   issm/trunk/test/NightlyRun/test303.py
   issm/trunk/test/NightlyRun/test304.py
   issm/trunk/test/NightlyRun/test305.py
   issm/trunk/test/NightlyRun/test306.py
   issm/trunk/test/NightlyRun/test307.py
   issm/trunk/test/NightlyRun/test308.py
   issm/trunk/test/NightlyRun/test309.py
   issm/trunk/test/NightlyRun/test310.py
   issm/trunk/test/NightlyRun/test311.py
   issm/trunk/test/NightlyRun/test312.py
   issm/trunk/test/NightlyRun/test313.py
   issm/trunk/test/NightlyRun/test314.py
   issm/trunk/test/NightlyRun/test315.py
   issm/trunk/test/NightlyRun/test316.py
   issm/trunk/test/NightlyRun/test317.py
   issm/trunk/test/NightlyRun/test318.py
   issm/trunk/test/NightlyRun/test319.py
   issm/trunk/test/NightlyRun/test320.py
   issm/trunk/test/NightlyRun/test321.py
   issm/trunk/test/NightlyRun/test322.py
   issm/trunk/test/NightlyRun/test323.py
   issm/trunk/test/NightlyRun/test324.py
   issm/trunk/test/NightlyRun/test325.py
   issm/trunk/test/NightlyRun/test326.py
   issm/trunk/test/NightlyRun/test327.py
   issm/trunk/test/NightlyRun/test328.py
   issm/trunk/test/NightlyRun/test329.py
   issm/trunk/test/NightlyRun/test401.py
   issm/trunk/test/NightlyRun/test402.py
   issm/trunk/test/NightlyRun/test403.py
   issm/trunk/test/NightlyRun/test404.py
   issm/trunk/test/NightlyRun/test405.py
   issm/trunk/test/NightlyRun/test406.py
   issm/trunk/test/NightlyRun/test407.py
   issm/trunk/test/NightlyRun/test408.py
   issm/trunk/test/NightlyRun/test409.py
   issm/trunk/test/NightlyRun/test410.py
   issm/trunk/test/NightlyRun/test411.py
   issm/trunk/test/NightlyRun/test415.py
   issm/trunk/test/NightlyRun/test416.py
   issm/trunk/test/NightlyRun/test419.py
   issm/trunk/test/NightlyRun/test421.py
   issm/trunk/test/NightlyRun/test422.py
   issm/trunk/test/NightlyRun/test423.py
   issm/trunk/test/NightlyRun/test424.py
   issm/trunk/test/NightlyRun/test425.py
   issm/trunk/test/NightlyRun/test426.py
   issm/trunk/test/NightlyRun/test427.py
   issm/trunk/test/NightlyRun/test428.py
   issm/trunk/test/NightlyRun/test429.py
   issm/trunk/test/NightlyRun/test430.py
   issm/trunk/test/NightlyRun/test431.py
   issm/trunk/test/NightlyRun/test432.py
   issm/trunk/test/NightlyRun/test501.py
   issm/trunk/test/NightlyRun/test502.py
   issm/trunk/test/NightlyRun/test503.py
   issm/trunk/test/NightlyRun/test504.py
   issm/trunk/test/NightlyRun/test505.py
   issm/trunk/test/NightlyRun/test506.py
   issm/trunk/test/NightlyRun/test507.py
   issm/trunk/test/NightlyRun/test508.py
   issm/trunk/test/NightlyRun/test509.py
   issm/trunk/test/NightlyRun/test510.py
   issm/trunk/test/NightlyRun/test511.py
   issm/trunk/test/NightlyRun/test512.py
   issm/trunk/test/NightlyRun/test513.py
   issm/trunk/test/NightlyRun/test514.py
   issm/trunk/test/NightlyRun/test515.py
   issm/trunk/test/NightlyRun/test516.py
   issm/trunk/test/NightlyRun/test601.py
   issm/trunk/test/NightlyRun/test602.py
   issm/trunk/test/NightlyRun/test603.py
   issm/trunk/test/NightlyRun/test604.py
   issm/trunk/test/NightlyRun/test605.py
   issm/trunk/test/NightlyRun/test606.py
   issm/trunk/test/NightlyRun/test607.py
   issm/trunk/test/NightlyRun/test608.py
   issm/trunk/test/NightlyRun/test609.py
   issm/trunk/test/NightlyRun/test610.py
   issm/trunk/test/NightlyRun/test611.py
   issm/trunk/test/NightlyRun/test612.py
   issm/trunk/test/NightlyRun/test613.py
   issm/trunk/test/Par/79North.py
   issm/trunk/test/Par/Pig.py
   issm/trunk/test/Par/RoundSheetShelf.py
   issm/trunk/test/Par/SquareSheetConstrained.py
   issm/trunk/test/Par/SquareSheetShelf.py
   issm/trunk/test/Par/SquareShelf.py
Removed:
   issm/trunk/configs/config-linux64-astrid-python.sh
   issm/trunk/configs/config-macosx64-larour-bothapis.sh
   issm/trunk/externalpackages/adolc/install.sh
   issm/trunk/externalpackages/chaco/chaco_guide.pdf
   issm/trunk/externalpackages/chaco/chaco_guide.ps
   issm/trunk/externalpackages/esmf/doc/
   issm/trunk/externalpackages/gdal/install-murdo.sh
   issm/trunk/externalpackages/gdal/install.sh
   issm/trunk/externalpackages/git/install-nopython.sh
   issm/trunk/externalpackages/netcdf/install-4.0.sh
   issm/trunk/externalpackages/netcdf/install-4.2.sh
   issm/trunk/externalpackages/scotch/ptscotch_user5.1.pdf
   issm/trunk/externalpackages/scotch/scotch_user5.1.pdf
   issm/trunk/externalpackages/shapelib/shapefile.pdf
   issm/trunk/src/android/ISSM_App/
   issm/trunk/src/android/test102/
   issm/trunk/src/c/classes/objects.h
   issm/trunk/src/c/issm-binding.h
   issm/trunk/src/c/matlab/
   issm/trunk/src/c/modules/AddExternalResultx/
   issm/trunk/src/c/modules/AutodiffDriversx/
   issm/trunk/src/c/modules/CostFunctionx/
   issm/trunk/src/c/modules/CreateJacobianMatrixx/
   issm/trunk/src/c/modules/DakotaResponsesx/
   issm/trunk/src/c/modules/Dakotax/
   issm/trunk/src/c/modules/ElementResponsex/
   issm/trunk/src/c/modules/IceVolumex/
   issm/trunk/src/c/modules/MassFluxx/
   issm/trunk/src/c/modules/MaxAbsVxx/
   issm/trunk/src/c/modules/MaxAbsVyx/
   issm/trunk/src/c/modules/MaxAbsVzx/
   issm/trunk/src/c/modules/MaxVelx/
   issm/trunk/src/c/modules/MaxVxx/
   issm/trunk/src/c/modules/MaxVyx/
   issm/trunk/src/c/modules/MaxVzx/
   issm/trunk/src/c/modules/MinVelx/
   issm/trunk/src/c/modules/MinVxx/
   issm/trunk/src/c/modules/MinVyx/
   issm/trunk/src/c/modules/MinVzx/
   issm/trunk/src/c/modules/RequestedDependentsx/
   issm/trunk/src/c/modules/RequestedOutputsx/
   issm/trunk/src/c/modules/Responsex/
   issm/trunk/src/c/modules/SmearFunctionx/
   issm/trunk/src/c/modules/SystemMatricesx/
   issm/trunk/src/c/modules/ThicknessAbsGradientx/
   issm/trunk/src/c/modules/TimeAdaptx/
   issm/trunk/src/c/modules/TotalSmbx/
   issm/trunk/src/c/modules/UpdateConstraintsx/
   issm/trunk/src/c/modules/UpdateVertexPositionsx/
   issm/trunk/src/c/python/
   issm/trunk/src/c/shared/Numerics/adolc_edf.h
   issm/trunk/src/c/shared/Numerics/isnan.cpp
   issm/trunk/src/c/shared/Sys/
   issm/trunk/src/c/shared/Wrapper/
   issm/trunk/src/c/solutions/WriteLockFile.cpp
   issm/trunk/src/c/toolkits/mpi/patches/MPI_Boundariesfromrange.cpp
   issm/trunk/src/c/toolkits/mpi/patches/MPI_Lowerrow.cpp
   issm/trunk/src/c/toolkits/mpi/patches/MPI_Upperrow.cpp
   issm/trunk/src/c/toolkits/petsc/patches/ISFree.cpp
   issm/trunk/src/c/toolkits/petsc/patches/MatInvert.cpp
   issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp
   issm/trunk/src/c/toolkits/petsc/patches/SerialToVec.cpp
   issm/trunk/src/c/toolkits/petsc/patches/VecPartition.cpp
   issm/trunk/src/c/toolkits/petsc/patches/VecTranspose.cpp
   issm/trunk/src/c/toolkits/python/pythonincludes.h
   issm/trunk/src/m/enum/AutodiffDependentsEnum.m
   issm/trunk/src/m/enum/AutodiffFosForwardOutputEnum.m
   issm/trunk/src/m/enum/AutodiffIndependentsEnum.m
   issm/trunk/src/m/enum/QmuMassFluxSegmentsEnum.m
   issm/trunk/src/m/miscellaneous/BinRead.py
   issm/trunk/src/modules/
   issm/trunk/src/py/
Modified:
   issm/trunk/
   issm/trunk/configs/config-arm-linux.sh
   issm/trunk/configs/config-discover.sh
   issm/trunk/configs/config-greenplanet.sh
   issm/trunk/configs/config-linux64-ad.sh
   issm/trunk/configs/config-linux64-astrid.sh
   issm/trunk/configs/config-linux64-murdo-ad.sh
   issm/trunk/configs/config-linux64-murdo.sh
   issm/trunk/configs/config-macosx-snowleopard-bothapis.sh
   issm/trunk/configs/config-macosx-snowleopard-python.sh
   issm/trunk/configs/config-macosx64-ad.sh
   issm/trunk/configs/config-macosx64-chris-bothapis.sh
   issm/trunk/configs/config-macosx64-chris-python.sh
   issm/trunk/configs/config-macosx64-gsl.sh
   issm/trunk/configs/config-macosx64-larour-ad.sh
   issm/trunk/configs/config-macosx64-larour-nopetsc.sh
   issm/trunk/configs/config-macosx64-larour-python.sh
   issm/trunk/configs/config-macosx64-larour.sh
   issm/trunk/configs/config-macosx64-lion-helene.sh
   issm/trunk/configs/config-pleiades-petsc2.sh
   issm/trunk/configs/config-pleiades-petscdev.sh
   issm/trunk/configs/config-pleiades.sh
   issm/trunk/configure.ac
   issm/trunk/etc/environment.csh
   issm/trunk/etc/environment.sh
   issm/trunk/execution/
   issm/trunk/externalpackages/adolc/
   issm/trunk/externalpackages/adolc/install-dev.sh
   issm/trunk/externalpackages/android/android-ndk/
   issm/trunk/externalpackages/android/android-ndk/install.sh
   issm/trunk/externalpackages/android/android-sdk/
   issm/trunk/externalpackages/android/android-sdk/install.sh
   issm/trunk/externalpackages/android/android_aux.sh
   issm/trunk/externalpackages/chaco/install.sh
   issm/trunk/externalpackages/cmake/
   issm/trunk/externalpackages/esmf/
   issm/trunk/externalpackages/esmf/install.sh
   issm/trunk/externalpackages/export_fig/
   issm/trunk/externalpackages/git/install.sh
   issm/trunk/externalpackages/gmake/
   issm/trunk/externalpackages/gsl/
   issm/trunk/externalpackages/gsl/install-android.sh
   issm/trunk/externalpackages/hdf5/install.sh
   issm/trunk/externalpackages/mpich2/install-1.0.2-altix64.sh
   issm/trunk/externalpackages/mpich2/install-1.0.2-linux64.sh
   issm/trunk/externalpackages/mpich2/install-1.0.2-macosx32.sh
   issm/trunk/externalpackages/mpich2/install-1.0.2-win32.sh
   issm/trunk/externalpackages/mpich2/install-1.3.1-linux64-berg.sh
   issm/trunk/externalpackages/mpich2/install-1.4-linux64.sh
   issm/trunk/externalpackages/mpich2/install-1.4-macosx32.sh
   issm/trunk/externalpackages/mpich2/install-1.4-macosx64.sh
   issm/trunk/externalpackages/numpy/install-linux64.sh
   issm/trunk/externalpackages/numpy/install-macosx-lion.sh
   issm/trunk/externalpackages/petsc/
   issm/trunk/externalpackages/petsc/install-3.2-greenplanet.sh
   issm/trunk/externalpackages/petsc/install-dev-linux64.sh
   issm/trunk/externalpackages/petsc/install-dev-pleiades.sh
   issm/trunk/externalpackages/readline/install.sh
   issm/trunk/externalpackages/scotch/install.sh
   issm/trunk/externalpackages/shapelib/install.sh
   issm/trunk/externalpackages/vim/addons/vim/colors/issm_black.vim
   issm/trunk/externalpackages/vim/addons/vim/colors/issm_white.vim
   issm/trunk/externalpackages/vim/addons/vim/syntax/c.vim
   issm/trunk/externalpackages/vim/addons/vimrc
   issm/trunk/m4/issm_options.m4
   issm/trunk/scripts/report.sh
   issm/trunk/src/
   issm/trunk/src/Makefile.am
   issm/trunk/src/ad/todo
   issm/trunk/src/android/
   issm/trunk/src/android/ISSM/bin/
   issm/trunk/src/android/ISSM/libs/
   issm/trunk/src/android/helloworld/ISSM/bin/
   issm/trunk/src/android/helloworld/ISSM/gen/com/example/issm/
   issm/trunk/src/android/helloworld/My First App/
   issm/trunk/src/android/helloworld/My First App/bin/
   issm/trunk/src/android/helloworld/My First App/bin/classes/
   issm/trunk/src/android/helloworld/My First App/bin/res/
   issm/trunk/src/android/helloworld/My First App/gen/com/example/my/first/app/
   issm/trunk/src/android/helloworld/OpenGLES20/bin/
   issm/trunk/src/android/helloworld/OpenGLES20/bin/classes/
   issm/trunk/src/c/Container/Constraints.cpp
   issm/trunk/src/c/Container/Constraints.h
   issm/trunk/src/c/Container/DataSet.cpp
   issm/trunk/src/c/Container/DataSet.h
   issm/trunk/src/c/Container/Elements.cpp
   issm/trunk/src/c/Container/Elements.h
   issm/trunk/src/c/Container/Inputs.cpp
   issm/trunk/src/c/Container/Inputs.h
   issm/trunk/src/c/Container/Loads.cpp
   issm/trunk/src/c/Container/Loads.h
   issm/trunk/src/c/Container/Materials.cpp
   issm/trunk/src/c/Container/Materials.h
   issm/trunk/src/c/Container/Nodes.cpp
   issm/trunk/src/c/Container/Nodes.h
   issm/trunk/src/c/Container/Observations.cpp
   issm/trunk/src/c/Container/Observations.h
   issm/trunk/src/c/Container/Options.cpp
   issm/trunk/src/c/Container/Options.h
   issm/trunk/src/c/Container/Parameters.cpp
   issm/trunk/src/c/Container/Parameters.h
   issm/trunk/src/c/Container/Results.cpp
   issm/trunk/src/c/Container/Results.h
   issm/trunk/src/c/Container/Vertices.cpp
   issm/trunk/src/c/Container/Vertices.h
   issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
   issm/trunk/src/c/Makefile.am
   issm/trunk/src/c/classes/DofIndexing.cpp
   issm/trunk/src/c/classes/DofIndexing.h
   issm/trunk/src/c/classes/FemModel.cpp
   issm/trunk/src/c/classes/FemModel.h
   issm/trunk/src/c/classes/Hook.cpp
   issm/trunk/src/c/classes/Hook.h
   issm/trunk/src/c/classes/IoModel.cpp
   issm/trunk/src/c/classes/IoModel.h
   issm/trunk/src/c/classes/Patch.cpp
   issm/trunk/src/c/classes/Patch.h
   issm/trunk/src/c/classes/Update.h
   issm/trunk/src/c/classes/bamg/AdjacentTriangle.cpp
   issm/trunk/src/c/classes/bamg/AdjacentTriangle.h
   issm/trunk/src/c/classes/bamg/BamgGeom.cpp
   issm/trunk/src/c/classes/bamg/BamgMesh.cpp
   issm/trunk/src/c/classes/bamg/BamgOpts.cpp
   issm/trunk/src/c/classes/bamg/BamgQuadtree.cpp
   issm/trunk/src/c/classes/bamg/BamgQuadtree.h
   issm/trunk/src/c/classes/bamg/BamgVertex.cpp
   issm/trunk/src/c/classes/bamg/Direction.h
   issm/trunk/src/c/classes/bamg/Edge.h
   issm/trunk/src/c/classes/bamg/EigenMetric.cpp
   issm/trunk/src/c/classes/bamg/Geometry.cpp
   issm/trunk/src/c/classes/bamg/Geometry.h
   issm/trunk/src/c/classes/bamg/ListofIntersectionTriangles.cpp
   issm/trunk/src/c/classes/bamg/Mesh.cpp
   issm/trunk/src/c/classes/bamg/Metric.cpp
   issm/trunk/src/c/classes/bamg/R2.h
   issm/trunk/src/c/classes/bamg/SetOfE4.cpp
   issm/trunk/src/c/classes/bamg/Triangle.cpp
   issm/trunk/src/c/classes/bamg/VertexOnVertex.cpp
   issm/trunk/src/c/classes/classes.h
   issm/trunk/src/c/classes/dakota/DakotaPlugin.cpp
   issm/trunk/src/c/classes/dakota/DakotaPlugin.h
   issm/trunk/src/c/classes/gauss/GaussPenta.h
   issm/trunk/src/c/classes/gauss/GaussTria.h
   issm/trunk/src/c/classes/kriging/ExponentialVariogram.cpp
   issm/trunk/src/c/classes/kriging/ExponentialVariogram.h
   issm/trunk/src/c/classes/kriging/GaussianVariogram.cpp
   issm/trunk/src/c/classes/kriging/GaussianVariogram.h
   issm/trunk/src/c/classes/kriging/Observation.cpp
   issm/trunk/src/c/classes/kriging/Observation.h
   issm/trunk/src/c/classes/kriging/PowerVariogram.cpp
   issm/trunk/src/c/classes/kriging/PowerVariogram.h
   issm/trunk/src/c/classes/kriging/Quadtree.cpp
   issm/trunk/src/c/classes/kriging/Quadtree.h
   issm/trunk/src/c/classes/kriging/SphericalVariogram.cpp
   issm/trunk/src/c/classes/kriging/SphericalVariogram.h
   issm/trunk/src/c/classes/matrix/ElementMatrix.cpp
   issm/trunk/src/c/classes/matrix/ElementMatrix.h
   issm/trunk/src/c/classes/matrix/ElementVector.cpp
   issm/trunk/src/c/classes/matrix/ElementVector.h
   issm/trunk/src/c/classes/matrix/Matrix.h
   issm/trunk/src/c/classes/matrix/Vector.h
   issm/trunk/src/c/classes/matrix/matrixobjects.h
   issm/trunk/src/c/classes/objects/Constraints/Constraint.h
   issm/trunk/src/c/classes/objects/Constraints/SpcDynamic.cpp
   issm/trunk/src/c/classes/objects/Constraints/SpcDynamic.h
   issm/trunk/src/c/classes/objects/Constraints/SpcStatic.cpp
   issm/trunk/src/c/classes/objects/Constraints/SpcStatic.h
   issm/trunk/src/c/classes/objects/Constraints/SpcTransient.cpp
   issm/trunk/src/c/classes/objects/Constraints/SpcTransient.h
   issm/trunk/src/c/classes/objects/Contour.h
   issm/trunk/src/c/classes/objects/ElementResults/BoolElementResult.cpp
   issm/trunk/src/c/classes/objects/ElementResults/BoolElementResult.h
   issm/trunk/src/c/classes/objects/ElementResults/DoubleElementResult.cpp
   issm/trunk/src/c/classes/objects/ElementResults/DoubleElementResult.h
   issm/trunk/src/c/classes/objects/ElementResults/ElementResult.h
   issm/trunk/src/c/classes/objects/ElementResults/ElementResultLocal.h
   issm/trunk/src/c/classes/objects/ElementResults/PentaP1ElementResult.cpp
   issm/trunk/src/c/classes/objects/ElementResults/PentaP1ElementResult.h
   issm/trunk/src/c/classes/objects/ElementResults/TriaP1ElementResult.cpp
   issm/trunk/src/c/classes/objects/ElementResults/TriaP1ElementResult.h
   issm/trunk/src/c/classes/objects/Elements/Element.h
   issm/trunk/src/c/classes/objects/Elements/Penta.cpp
   issm/trunk/src/c/classes/objects/Elements/Penta.h
   issm/trunk/src/c/classes/objects/Elements/PentaHook.cpp
   issm/trunk/src/c/classes/objects/Elements/PentaHook.h
   issm/trunk/src/c/classes/objects/Elements/PentaRef.cpp
   issm/trunk/src/c/classes/objects/Elements/PentaRef.h
   issm/trunk/src/c/classes/objects/Elements/Tria.cpp
   issm/trunk/src/c/classes/objects/Elements/Tria.h
   issm/trunk/src/c/classes/objects/Elements/TriaHook.cpp
   issm/trunk/src/c/classes/objects/Elements/TriaHook.h
   issm/trunk/src/c/classes/objects/Elements/TriaRef.cpp
   issm/trunk/src/c/classes/objects/Elements/TriaRef.h
   issm/trunk/src/c/classes/objects/ExternalResults/ExternalResult.h
   issm/trunk/src/c/classes/objects/ExternalResults/GenericExternalResult.h
   issm/trunk/src/c/classes/objects/Inputs/BoolInput.cpp
   issm/trunk/src/c/classes/objects/Inputs/BoolInput.h
   issm/trunk/src/c/classes/objects/Inputs/ControlInput.cpp
   issm/trunk/src/c/classes/objects/Inputs/ControlInput.h
   issm/trunk/src/c/classes/objects/Inputs/DatasetInput.cpp
   issm/trunk/src/c/classes/objects/Inputs/DatasetInput.h
   issm/trunk/src/c/classes/objects/Inputs/DoubleInput.cpp
   issm/trunk/src/c/classes/objects/Inputs/DoubleInput.h
   issm/trunk/src/c/classes/objects/Inputs/Input.h
   issm/trunk/src/c/classes/objects/Inputs/IntInput.cpp
   issm/trunk/src/c/classes/objects/Inputs/IntInput.h
   issm/trunk/src/c/classes/objects/Inputs/PentaP1Input.cpp
   issm/trunk/src/c/classes/objects/Inputs/PentaP1Input.h
   issm/trunk/src/c/classes/objects/Inputs/TransientInput.cpp
   issm/trunk/src/c/classes/objects/Inputs/TransientInput.h
   issm/trunk/src/c/classes/objects/Inputs/TriaP1Input.cpp
   issm/trunk/src/c/classes/objects/Inputs/TriaP1Input.h
   issm/trunk/src/c/classes/objects/KML/KMLFileReadUtils.cpp
   issm/trunk/src/c/classes/objects/KML/KMLFileReadUtils.h
   issm/trunk/src/c/classes/objects/KML/KML_Attribute.h
   issm/trunk/src/c/classes/objects/KML/KML_ColorStyle.h
   issm/trunk/src/c/classes/objects/KML/KML_Comment.h
   issm/trunk/src/c/classes/objects/KML/KML_Container.h
   issm/trunk/src/c/classes/objects/KML/KML_Document.cpp
   issm/trunk/src/c/classes/objects/KML/KML_Document.h
   issm/trunk/src/c/classes/objects/KML/KML_Feature.h
   issm/trunk/src/c/classes/objects/KML/KML_File.cpp
   issm/trunk/src/c/classes/objects/KML/KML_File.h
   issm/trunk/src/c/classes/objects/KML/KML_Folder.h
   issm/trunk/src/c/classes/objects/KML/KML_Geometry.h
   issm/trunk/src/c/classes/objects/KML/KML_GroundOverlay.h
   issm/trunk/src/c/classes/objects/KML/KML_Icon.h
   issm/trunk/src/c/classes/objects/KML/KML_LatLonBox.cpp
   issm/trunk/src/c/classes/objects/KML/KML_LatLonBox.h
   issm/trunk/src/c/classes/objects/KML/KML_LineString.h
   issm/trunk/src/c/classes/objects/KML/KML_LineStyle.cpp
   issm/trunk/src/c/classes/objects/KML/KML_LineStyle.h
   issm/trunk/src/c/classes/objects/KML/KML_LinearRing.h
   issm/trunk/src/c/classes/objects/KML/KML_MultiGeometry.h
   issm/trunk/src/c/classes/objects/KML/KML_Object.h
   issm/trunk/src/c/classes/objects/KML/KML_Overlay.h
   issm/trunk/src/c/classes/objects/KML/KML_Placemark.h
   issm/trunk/src/c/classes/objects/KML/KML_Point.h
   issm/trunk/src/c/classes/objects/KML/KML_PolyStyle.cpp
   issm/trunk/src/c/classes/objects/KML/KML_PolyStyle.h
   issm/trunk/src/c/classes/objects/KML/KML_Polygon.cpp
   issm/trunk/src/c/classes/objects/KML/KML_Polygon.h
   issm/trunk/src/c/classes/objects/KML/KML_Style.h
   issm/trunk/src/c/classes/objects/KML/KML_StyleSelector.cpp
   issm/trunk/src/c/classes/objects/KML/KML_StyleSelector.h
   issm/trunk/src/c/classes/objects/KML/KML_SubStyle.cpp
   issm/trunk/src/c/classes/objects/KML/KML_SubStyle.h
   issm/trunk/src/c/classes/objects/KML/KML_Unknown.cpp
   issm/trunk/src/c/classes/objects/KML/KML_Unknown.h
   issm/trunk/src/c/classes/objects/Loads/Friction.cpp
   issm/trunk/src/c/classes/objects/Loads/Friction.h
   issm/trunk/src/c/classes/objects/Loads/Icefront.cpp
   issm/trunk/src/c/classes/objects/Loads/Icefront.h
   issm/trunk/src/c/classes/objects/Loads/Load.h
   issm/trunk/src/c/classes/objects/Loads/Numericalflux.cpp
   issm/trunk/src/c/classes/objects/Loads/Numericalflux.h
   issm/trunk/src/c/classes/objects/Loads/Pengrid.cpp
   issm/trunk/src/c/classes/objects/Loads/Pengrid.h
   issm/trunk/src/c/classes/objects/Loads/Penpair.cpp
   issm/trunk/src/c/classes/objects/Loads/Penpair.h
   issm/trunk/src/c/classes/objects/Loads/Riftfront.cpp
   issm/trunk/src/c/classes/objects/Loads/Riftfront.h
   issm/trunk/src/c/classes/objects/Materials/Matdamageice.cpp
   issm/trunk/src/c/classes/objects/Materials/Matdamageice.h
   issm/trunk/src/c/classes/objects/Materials/Material.h
   issm/trunk/src/c/classes/objects/Materials/Matice.cpp
   issm/trunk/src/c/classes/objects/Materials/Matice.h
   issm/trunk/src/c/classes/objects/Materials/Matpar.cpp
   issm/trunk/src/c/classes/objects/Materials/Matpar.h
   issm/trunk/src/c/classes/objects/Node.cpp
   issm/trunk/src/c/classes/objects/Node.h
   issm/trunk/src/c/classes/objects/Object.h
   issm/trunk/src/c/classes/objects/Options/GenericOption.h
   issm/trunk/src/c/classes/objects/Options/Option.h
   issm/trunk/src/c/classes/objects/Options/OptionUtilities.h
   issm/trunk/src/c/classes/objects/Params/BoolParam.cpp
   issm/trunk/src/c/classes/objects/Params/BoolParam.h
   issm/trunk/src/c/classes/objects/Params/DoubleMatArrayParam.cpp
   issm/trunk/src/c/classes/objects/Params/DoubleMatArrayParam.h
   issm/trunk/src/c/classes/objects/Params/DoubleMatParam.cpp
   issm/trunk/src/c/classes/objects/Params/DoubleMatParam.h
   issm/trunk/src/c/classes/objects/Params/DoubleParam.cpp
   issm/trunk/src/c/classes/objects/Params/DoubleParam.h
   issm/trunk/src/c/classes/objects/Params/DoubleTransientMatParam.h
   issm/trunk/src/c/classes/objects/Params/DoubleVecParam.cpp
   issm/trunk/src/c/classes/objects/Params/DoubleVecParam.h
   issm/trunk/src/c/classes/objects/Params/FileParam.cpp
   issm/trunk/src/c/classes/objects/Params/FileParam.h
   issm/trunk/src/c/classes/objects/Params/GenericParam.h
   issm/trunk/src/c/classes/objects/Params/IntMatParam.cpp
   issm/trunk/src/c/classes/objects/Params/IntMatParam.h
   issm/trunk/src/c/classes/objects/Params/IntParam.cpp
   issm/trunk/src/c/classes/objects/Params/IntParam.h
   issm/trunk/src/c/classes/objects/Params/IntVecParam.cpp
   issm/trunk/src/c/classes/objects/Params/IntVecParam.h
   issm/trunk/src/c/classes/objects/Params/MatrixParam.cpp
   issm/trunk/src/c/classes/objects/Params/MatrixParam.h
   issm/trunk/src/c/classes/objects/Params/Param.h
   issm/trunk/src/c/classes/objects/Params/StringArrayParam.cpp
   issm/trunk/src/c/classes/objects/Params/StringArrayParam.h
   issm/trunk/src/c/classes/objects/Params/StringParam.cpp
   issm/trunk/src/c/classes/objects/Params/StringParam.h
   issm/trunk/src/c/classes/objects/Params/TransientParam.cpp
   issm/trunk/src/c/classes/objects/Params/TransientParam.h
   issm/trunk/src/c/classes/objects/Params/VectorParam.cpp
   issm/trunk/src/c/classes/objects/Params/VectorParam.h
   issm/trunk/src/c/classes/objects/Segment.h
   issm/trunk/src/c/classes/objects/Vertex.cpp
   issm/trunk/src/c/classes/objects/Vertex.h
   issm/trunk/src/c/classes/objects/objects.h
   issm/trunk/src/c/include/globals.h
   issm/trunk/src/c/include/macros.h
   issm/trunk/src/c/include/typedefs.h
   issm/trunk/src/c/include/types.h
   issm/trunk/src/c/io/Disk/diskio.h
   issm/trunk/src/c/io/Disk/pfclose.cpp
   issm/trunk/src/c/io/Disk/pfopen.cpp
   issm/trunk/src/c/io/PrintfFunction.cpp
   issm/trunk/src/c/issm.h
   issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.cpp
   issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.h
   issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp
   issm/trunk/src/c/modules/Bamgx/Bamgx.cpp
   issm/trunk/src/c/modules/Chacox/Chacox.cpp
   issm/trunk/src/c/modules/Chacox/Chacox.h
   issm/trunk/src/c/modules/Chacox/chaco_seconds.cpp
   issm/trunk/src/c/modules/Chacox/input_parse.cpp
   issm/trunk/src/c/modules/Chacox/user_params.cpp
   issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp
   issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.h
   issm/trunk/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.cpp
   issm/trunk/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.h
   issm/trunk/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp
   issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStateLocal.h
   issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp
   issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.h
   issm/trunk/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp
   issm/trunk/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp
   issm/trunk/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp
   issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.cpp
   issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.h
   issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp
   issm/trunk/src/c/modules/ContourToNodesx/ContourToNodesx.cpp
   issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp
   issm/trunk/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp
   issm/trunk/src/c/modules/Delta18oParameterizationx/Delta18oParameterizationx.cpp
   issm/trunk/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp
   issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp
   issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.h
   issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp
   issm/trunk/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp
   issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp
   issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h
   issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp
   issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h
   issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp
   issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h
   issm/trunk/src/c/modules/Gradjx/Gradjx.cpp
   issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
   issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.cpp
   issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.h
   issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.cpp
   issm/trunk/src/c/modules/InputControlUpdatex/InputControlUpdatex.cpp
   issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.cpp
   issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.h
   issm/trunk/src/c/modules/InputDuplicatex/InputDuplicatex.cpp
   issm/trunk/src/c/modules/InputDuplicatex/InputDuplicatex.h
   issm/trunk/src/c/modules/InputScalex/InputScalex.cpp
   issm/trunk/src/c/modules/InputScalex/InputScalex.h
   issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp
   issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp
   issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h
   issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp
   issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h
   issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp
   issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.h
   issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp
   issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h
   issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp
   issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h
   issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp
   issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h
   issm/trunk/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp
   issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp
   issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h
   issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp
   issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp
   issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
   issm/trunk/src/c/modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp
   issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp
   issm/trunk/src/c/modules/KMLOverlayx/KMLOverlayx.cpp
   issm/trunk/src/c/modules/Kml2Expx/Kml2Expx.cpp
   issm/trunk/src/c/modules/Krigingx/pKrigingx.cpp
   issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp
   issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h
   issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.h
   issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp
   issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegmentsIntersection.cpp
   issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp
   issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h
   issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp
   issm/trunk/src/c/modules/MeshProfileIntersectionx/NodeInElement.cpp
   issm/trunk/src/c/modules/MeshProfileIntersectionx/SegmentIntersect.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateConstraintsBalancethickness.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp
   issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateConstraintsBedSlope.cpp
   issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateLoadsBedSlope.cpp
   issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateNodesBedSlope.cpp
   issm/trunk/src/c/modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
   issm/trunk/src/c/modules/ModelProcessorx/CreateDataSets.cpp
   issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
   issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateLoadsDiagnosticHutter.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateNodesDiagnosticHutter.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/UpdateElementsDiagnosticHutter.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateLoadsDiagnosticVert.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateNodesDiagnosticVert.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/UpdateElementsDiagnosticVert.cpp
   issm/trunk/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp
   issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateLoadsEnthalpy.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateNodesEnthalpy.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/UpdateElementsEnthalpy.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateConstraintsHydrology.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateLoadsHydrology.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateNodesHydrology.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Hydrology/UpdateElementsHydrology.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateConstraintsMelting.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateLoadsMelting.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateNodesMelting.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Melting/UpdateElementsMelting.cpp
   issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
   issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h
   issm/trunk/src/c/modules/ModelProcessorx/NodesPartitioning.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp
   issm/trunk/src/c/modules/ModelProcessorx/SortDataSets.cpp
   issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateConstraintsSurfaceSlope.cpp
   issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp
   issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateNodesSurfaceSlope.cpp
   issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/UpdateElementsSurfaceSlope.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateConstraintsThermal.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateLoadsThermal.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateNodesThermal.cpp
   issm/trunk/src/c/modules/ModelProcessorx/Thermal/UpdateElementsThermal.cpp
   issm/trunk/src/c/modules/ModelProcessorx/UpdateCounters.cpp
   issm/trunk/src/c/modules/NodalValuex/NodalValuex.cpp
   issm/trunk/src/c/modules/NodalValuex/NodalValuex.h
   issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp
   issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.h
   issm/trunk/src/c/modules/NodesDofx/NodesDofx.cpp
   issm/trunk/src/c/modules/Orthx/Orthx.cpp
   issm/trunk/src/c/modules/Orthx/Orthx.h
   issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp
   issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.h
   issm/trunk/src/c/modules/OutputRiftsx/OutputRiftsx.cpp
   issm/trunk/src/c/modules/OutputRiftsx/OutputRiftsx.h
   issm/trunk/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp
   issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h
   issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp
   issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp
   issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.cpp
   issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h
   issm/trunk/src/c/modules/Reduceloadx/Reduceloadx.cpp
   issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp
   issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.h
   issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp
   issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.h
   issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.cpp
   issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.h
   issm/trunk/src/c/modules/ResetCoordinateSystemx/ResetCoordinateSystemx.cpp
   issm/trunk/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp
   issm/trunk/src/c/modules/Scotchx/Scotchx.h
   issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp
   issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp
   issm/trunk/src/c/modules/SmbGradientsx/SmbGradientsx.cpp
   issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp
   issm/trunk/src/c/modules/Solverx/Solverx.cpp
   issm/trunk/src/c/modules/Solverx/Solverx.h
   issm/trunk/src/c/modules/Solverx/SolverxPetsc.cpp
   issm/trunk/src/c/modules/Solverx/SolverxSeq.cpp
   issm/trunk/src/c/modules/SpcNodesx/SpcNodesx.cpp
   issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp
   issm/trunk/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp
   issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.cpp
   issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.h
   issm/trunk/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp
   issm/trunk/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp
   issm/trunk/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp
   issm/trunk/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp
   issm/trunk/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp
   issm/trunk/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp
   issm/trunk/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp
   issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp
   issm/trunk/src/c/modules/TriMeshx/TriMeshx.h
   issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.cpp
   issm/trunk/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp
   issm/trunk/src/c/modules/VecMergex/VecMergex.cpp
   issm/trunk/src/c/modules/VerticesDofx/VerticesDofx.cpp
   issm/trunk/src/c/modules/VerticesDofx/VerticesDofx.h
   issm/trunk/src/c/modules/modules.h
   issm/trunk/src/c/shared/Alloc/alloc.cpp
   issm/trunk/src/c/shared/Alloc/xNewDelete.h
   issm/trunk/src/c/shared/Bamg/shared.h
   issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp
   issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp
   issm/trunk/src/c/shared/Elements/Paterson.cpp
   issm/trunk/src/c/shared/Elements/PddSurfaceMassBalance.cpp
   issm/trunk/src/c/shared/Elements/PrintArrays.cpp
   issm/trunk/src/c/shared/Elements/TransformLoadVectorCoord.cpp
   issm/trunk/src/c/shared/Elements/TransformSolutionCoord.cpp
   issm/trunk/src/c/shared/Elements/elements.h
   issm/trunk/src/c/shared/Exceptions/Exceptions.cpp
   issm/trunk/src/c/shared/Exceptions/exceptions.h
   issm/trunk/src/c/shared/Exceptions/exprintf.cpp
   issm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp
   issm/trunk/src/c/shared/Exp/IsInPoly.cpp
   issm/trunk/src/c/shared/Exp/IsInPolySerial.cpp
   issm/trunk/src/c/shared/Exp/exp.h
   issm/trunk/src/c/shared/MemOps/xMemCpy.h
   issm/trunk/src/c/shared/Numerics/BrentSearch.cpp
   issm/trunk/src/c/shared/Numerics/IsInputConverged.cpp
   issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp
   issm/trunk/src/c/shared/Numerics/OptionsFromAnalysis.cpp
   issm/trunk/src/c/shared/Numerics/Synchronize.sh
   issm/trunk/src/c/shared/Numerics/UnitConversion.cpp
   issm/trunk/src/c/shared/Numerics/Verbosity.cpp
   issm/trunk/src/c/shared/Numerics/Verbosity.h
   issm/trunk/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp
   issm/trunk/src/c/shared/Numerics/cross.cpp
   issm/trunk/src/c/shared/Numerics/isnan.h
   issm/trunk/src/c/shared/Numerics/recast.h
   issm/trunk/src/c/shared/Sorting/binary_search.cpp
   issm/trunk/src/c/shared/Sorting/sorting.h
   issm/trunk/src/c/shared/String/DescriptorIndex.cpp
   issm/trunk/src/c/shared/String/sharedstring.h
   issm/trunk/src/c/shared/Threads/LaunchThread.cpp
   issm/trunk/src/c/shared/Threads/PartitionRange.cpp
   issm/trunk/src/c/shared/Threads/issm_threads.h
   issm/trunk/src/c/shared/TriMesh/AssociateSegmentToElement.cpp
   issm/trunk/src/c/shared/TriMesh/OrderSegments.cpp
   issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp
   issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp
   issm/trunk/src/c/shared/TriMesh/trimesh.h
   issm/trunk/src/c/shared/shared.h
   issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp
   issm/trunk/src/c/solutions/AnalysisConfiguration.cpp
   issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp
   issm/trunk/src/c/solutions/ProcessArguments.cpp
   issm/trunk/src/c/solutions/ResetBoundaryConditions.cpp
   issm/trunk/src/c/solutions/adjointbalancethickness_core.cpp
   issm/trunk/src/c/solutions/adjointdiagnostic_core.cpp
   issm/trunk/src/c/solutions/balancethickness_core.cpp
   issm/trunk/src/c/solutions/bedslope_core.cpp
   issm/trunk/src/c/solutions/control_core.cpp
   issm/trunk/src/c/solutions/controlconvergence.cpp
   issm/trunk/src/c/solutions/controltao_core.cpp
   issm/trunk/src/c/solutions/diagnostic_core.cpp
   issm/trunk/src/c/solutions/hydrology_core.cpp
   issm/trunk/src/c/solutions/hydrology_core_step.cpp
   issm/trunk/src/c/solutions/issm.cpp
   issm/trunk/src/c/solutions/kriging.cpp
   issm/trunk/src/c/solutions/objectivefunction.cpp
   issm/trunk/src/c/solutions/prognostic_core.cpp
   issm/trunk/src/c/solutions/solutions.h
   issm/trunk/src/c/solutions/steadystate_core.cpp
   issm/trunk/src/c/solutions/steadystateconvergence.cpp
   issm/trunk/src/c/solutions/surfaceslope_core.cpp
   issm/trunk/src/c/solutions/thermal_core.cpp
   issm/trunk/src/c/solutions/transient_core.cpp
   issm/trunk/src/c/solvers/solver_adjoint_linear.cpp
   issm/trunk/src/c/solvers/solver_linear.cpp
   issm/trunk/src/c/solvers/solver_newton.cpp
   issm/trunk/src/c/solvers/solver_nonlinear.cpp
   issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp
   issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp
   issm/trunk/src/c/toolkits/issm/SeqMat.h
   issm/trunk/src/c/toolkits/issm/SeqVec.h
   issm/trunk/src/c/toolkits/mpi/mpiincludes.h
   issm/trunk/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp
   issm/trunk/src/c/toolkits/mpi/patches/mpipatches.h
   issm/trunk/src/c/toolkits/petsc/objects/PetscMat.cpp
   issm/trunk/src/c/toolkits/petsc/objects/PetscMat.h
   issm/trunk/src/c/toolkits/petsc/objects/PetscVec.cpp
   issm/trunk/src/c/toolkits/petsc/objects/PetscVec.h
   issm/trunk/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp
   issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp
   issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscMatrixType.cpp
   issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp
   issm/trunk/src/c/toolkits/petsc/patches/KSPFree.cpp
   issm/trunk/src/c/toolkits/petsc/patches/MatFree.cpp
   issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp
   issm/trunk/src/c/toolkits/petsc/patches/MatToSerial.cpp
   issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp
   issm/trunk/src/c/toolkits/petsc/patches/NewVec.cpp
   issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp
   issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp
   issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp
   issm/trunk/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp
   issm/trunk/src/c/toolkits/petsc/patches/SolverEnum.h
   issm/trunk/src/c/toolkits/petsc/patches/VecDuplicatePatch.cpp
   issm/trunk/src/c/toolkits/petsc/patches/VecFree.cpp
   issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp
   issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp
   issm/trunk/src/c/toolkits/petsc/patches/petscpatches.h
   issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp
   issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp
   issm/trunk/src/c/toolkits/plapack/patches/PlapackToPetsc.cpp
   issm/trunk/src/c/toolkits/plapack/patches/plapackpatches.h
   issm/trunk/src/c/toolkits/plapack/plapackincludes.h
   issm/trunk/src/c/toolkits/scalapack/FortranMapping.h
   issm/trunk/src/c/toolkits/toolkits.h
   issm/trunk/src/c/toolkits/triangle/triangleincludes.h
   issm/trunk/src/dox/issm.dox
   issm/trunk/src/m/Makefile.am
   issm/trunk/src/m/array/array_numel.m
   issm/trunk/src/m/array/array_size.m
   issm/trunk/src/m/array/str2int.m
   issm/trunk/src/m/array/struc_desc.m
   issm/trunk/src/m/boundaryconditions/SetIceSheetBC.m
   issm/trunk/src/m/boundaryconditions/SetIceShelfBC.py
   issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.m
   issm/trunk/src/m/classes/autodiff.m
   issm/trunk/src/m/classes/autodiff.py
   issm/trunk/src/m/classes/bamggeom.py
   issm/trunk/src/m/classes/bamgmesh.py
   issm/trunk/src/m/classes/clusters/discover.m
   issm/trunk/src/m/classes/clusters/generic.m
   issm/trunk/src/m/classes/diagnostic.m
   issm/trunk/src/m/classes/diagnostic.py
   issm/trunk/src/m/classes/flaim.m
   issm/trunk/src/m/classes/flowequation.py
   issm/trunk/src/m/classes/groundingline.m
   issm/trunk/src/m/classes/initialization.py
   issm/trunk/src/m/classes/inversion.py
   issm/trunk/src/m/classes/matice.py
   issm/trunk/src/m/classes/mesh.m
   issm/trunk/src/m/classes/mesh.py
   issm/trunk/src/m/classes/model/model.m
   issm/trunk/src/m/classes/model/model.py
   issm/trunk/src/m/classes/modellist.m
   issm/trunk/src/m/classes/organizer.m
   issm/trunk/src/m/classes/pairoptions.m
   issm/trunk/src/m/classes/pairoptions.py
   issm/trunk/src/m/classes/planetmesh.m
   issm/trunk/src/m/classes/prognostic.m
   issm/trunk/src/m/classes/prognostic.py
   issm/trunk/src/m/classes/qmu.m
   issm/trunk/src/m/classes/qmu.py
   issm/trunk/src/m/classes/qmu/@dakota_method/dakota_method.m
   issm/trunk/src/m/classes/qmu/@dakota_method/dmeth_params_write.m
   issm/trunk/src/m/classes/qmu/continuous_design.m
   issm/trunk/src/m/classes/qmu/continuous_state.m
   issm/trunk/src/m/classes/qmu/least_squares_term.m
   issm/trunk/src/m/classes/qmu/linear_equality_constraint.m
   issm/trunk/src/m/classes/qmu/linear_inequality_constraint.m
   issm/trunk/src/m/classes/qmu/nonlinear_equality_constraint.m
   issm/trunk/src/m/classes/qmu/nonlinear_inequality_constraint.m
   issm/trunk/src/m/classes/qmu/normal_uncertain.m
   issm/trunk/src/m/classes/qmu/objective_function.m
   issm/trunk/src/m/classes/qmu/response_function.m
   issm/trunk/src/m/classes/qmu/uniform_uncertain.m
   issm/trunk/src/m/classes/rifts.m
   issm/trunk/src/m/classes/rifts.py
   issm/trunk/src/m/classes/solver.m
   issm/trunk/src/m/classes/surfaceforcings.m
   issm/trunk/src/m/classes/surfaceforcings.py
   issm/trunk/src/m/classes/thermal.m
   issm/trunk/src/m/classes/thermal.py
   issm/trunk/src/m/classes/verbose.m
   issm/trunk/src/m/classes/verbose.py
   issm/trunk/src/m/consistency/ismodelselfconsistent.m
   issm/trunk/src/m/contrib/bamg/YamsCall.m
   issm/trunk/src/m/contrib/bamg/meshread.m
   issm/trunk/src/m/contrib/bamg/yams.m
   issm/trunk/src/m/contrib/gslib/gamv.m
   issm/trunk/src/m/contrib/gslib/gslib.m
   issm/trunk/src/m/contrib/gslib/pkriging.m
   issm/trunk/src/m/contrib/gslib/varmap.m
   issm/trunk/src/m/contrib/hack/tres.m
   issm/trunk/src/m/contrib/massbalance/outflow.m
   issm/trunk/src/m/contrib/uci/expremovestraightsegments.m
   issm/trunk/src/m/enum/EnumDefinitions.py
   issm/trunk/src/m/enum/MaximumNumberOfEnums.m
   issm/trunk/src/m/enum/OutputfilenameEnum.m
   issm/trunk/src/m/exp/expcoarsen.m
   issm/trunk/src/m/exp/expcontract.m
   issm/trunk/src/m/exp/expcreatecontour.m
   issm/trunk/src/m/exp/expcreateprofile.m
   issm/trunk/src/m/exp/expexcludeoutliers.m
   issm/trunk/src/m/exp/expflip.m
   issm/trunk/src/m/exp/expll2xy.m
   issm/trunk/src/m/exp/expread.m
   issm/trunk/src/m/exp/expswapxy.m
   issm/trunk/src/m/exp/exptool.m
   issm/trunk/src/m/exp/expwrite.m
   issm/trunk/src/m/exp/expxy2ll.m
   issm/trunk/src/m/exp/manipulation/addcontour.m
   issm/trunk/src/m/exp/manipulation/addendprofile.m
   issm/trunk/src/m/exp/manipulation/addinsideprofile.m
   issm/trunk/src/m/exp/manipulation/addprofile.m
   issm/trunk/src/m/exp/manipulation/closeprofile.m
   issm/trunk/src/m/exp/manipulation/cutarea.m
   issm/trunk/src/m/exp/manipulation/cutprofile.m
   issm/trunk/src/m/exp/manipulation/mergeprofiles.m
   issm/trunk/src/m/exp/manipulation/modifyposition.m
   issm/trunk/src/m/exp/manipulation/orientprofile.m
   issm/trunk/src/m/exp/manipulation/removepoints.m
   issm/trunk/src/m/exp/manipulation/removeprofile.m
   issm/trunk/src/m/exp/manipulation/removeseveralpoints.m
   issm/trunk/src/m/extrusion/DepthAverage.m
   issm/trunk/src/m/extrusion/project3d.m
   issm/trunk/src/m/geometry/FlagElements.py
   issm/trunk/src/m/geometry/SegIntersect.m
   issm/trunk/src/m/geometry/SegIntersect.py
   issm/trunk/src/m/interp/PatchToVec.m
   issm/trunk/src/m/interp/SectionValues.m
   issm/trunk/src/m/interp/plugvelocities.m
   issm/trunk/src/m/inversions/parametercontrolB.m
   issm/trunk/src/m/kml/edgeadjacency.m
   issm/trunk/src/m/kml/exp2kml.m
   issm/trunk/src/m/kml/kml2exp.m
   issm/trunk/src/m/kml/kml_colorstyle.m
   issm/trunk/src/m/kml/kml_container.m
   issm/trunk/src/m/kml/kml_document.m
   issm/trunk/src/m/kml/kml_feature.m
   issm/trunk/src/m/kml/kml_file_swrite.m
   issm/trunk/src/m/kml/kml_file_write.m
   issm/trunk/src/m/kml/kml_folder.m
   issm/trunk/src/m/kml/kml_geometry.m
   issm/trunk/src/m/kml/kml_linearring.m
   issm/trunk/src/m/kml/kml_linestring.m
   issm/trunk/src/m/kml/kml_linestyle.m
   issm/trunk/src/m/kml/kml_mesh_elem.m
   issm/trunk/src/m/kml/kml_mesh_write.m
   issm/trunk/src/m/kml/kml_multigeometry.m
   issm/trunk/src/m/kml/kml_object.m
   issm/trunk/src/m/kml/kml_part_edges.m
   issm/trunk/src/m/kml/kml_part_elems.m
   issm/trunk/src/m/kml/kml_part_flagedges.m
   issm/trunk/src/m/kml/kml_partitions.m
   issm/trunk/src/m/kml/kml_placemark.m
   issm/trunk/src/m/kml/kml_polygon.m
   issm/trunk/src/m/kml/kml_polystyle.m
   issm/trunk/src/m/kml/kml_style.m
   issm/trunk/src/m/kml/kml_styleselector.m
   issm/trunk/src/m/kml/kml_substyle.m
   issm/trunk/src/m/kml/kml_unsh_edges.m
   issm/trunk/src/m/kml/string_buf.m
   issm/trunk/src/m/materials/paterson.m
   issm/trunk/src/m/materials/paterson.py
   issm/trunk/src/m/mech/basalstress.m
   issm/trunk/src/m/mech/cfl_step.m
   issm/trunk/src/m/mech/mechanicalproperties.m
   issm/trunk/src/m/mesh/ComputeHessian.m
   issm/trunk/src/m/mesh/ComputeMetric.m
   issm/trunk/src/m/mesh/ElementsFromEdge.m
   issm/trunk/src/m/mesh/FixMesh.m
   issm/trunk/src/m/mesh/MeshQuality.m
   issm/trunk/src/m/mesh/NodeInElement.m
   issm/trunk/src/m/mesh/bamg.m
   issm/trunk/src/m/mesh/meshconvert.py
   issm/trunk/src/m/mesh/planet/mesh_refine_tri4.m
   issm/trunk/src/m/mesh/planet/planetmixedmesh.m
   issm/trunk/src/m/mesh/planet/sphere_project.m
   issm/trunk/src/m/mesh/planet/sphere_tri.m
   issm/trunk/src/m/mesh/rifts/meshaddrifts.m
   issm/trunk/src/m/mesh/rifts/meshplug.m
   issm/trunk/src/m/mesh/rifts/meshprocessoutsiderifts.m
   issm/trunk/src/m/mesh/rifts/rifttipsonmesh.m
   issm/trunk/src/m/mesh/rifts/rifttipsrefine.m
   issm/trunk/src/m/mesh/roundmesh.m
   issm/trunk/src/m/mesh/triangle.py
   issm/trunk/src/m/miscellaneous/MatlabFuncs.py
   issm/trunk/src/m/miscellaneous/fielddisplay.m
   issm/trunk/src/m/miscellaneous/fielddisplay.py
   issm/trunk/src/m/miscellaneous/isnans.m
   issm/trunk/src/m/miscellaneous/issmdoc.m
   issm/trunk/src/m/miscellaneous/parallelrange.m
   issm/trunk/src/m/os/ismpi.m
   issm/trunk/src/m/os/ismumps.m
   issm/trunk/src/m/os/ispetsc.m
   issm/trunk/src/m/os/issmbbftpin.m
   issm/trunk/src/m/os/issmbbftpout.m
   issm/trunk/src/m/os/issmscpin.m
   issm/trunk/src/m/os/issmscpout.m
   issm/trunk/src/m/os/issmssh.m
   issm/trunk/src/m/os/issmssh.py
   issm/trunk/src/m/os/oshostname.m
   issm/trunk/src/m/parameterization/contourenvelope.m
   issm/trunk/src/m/parameterization/parameterize.m
   issm/trunk/src/m/parameterization/setflowequation.py
   issm/trunk/src/m/parameterization/setmask.py
   issm/trunk/src/m/partition/AreaAverageOntoPartition.m
   issm/trunk/src/m/partition/adjacency.m
   issm/trunk/src/m/partition/flagedges.m
   issm/trunk/src/m/partition/partitioner.m
   issm/trunk/src/m/plot/applyoptions.m
   issm/trunk/src/m/plot/arrow.m
   issm/trunk/src/m/plot/checkplotoptions.m
   issm/trunk/src/m/plot/colormaps/getcolormap.m
   issm/trunk/src/m/plot/colormaps/haxby.m
   issm/trunk/src/m/plot/kmlgroundoverlay.m
   issm/trunk/src/m/plot/latlonoverlay.m
   issm/trunk/src/m/plot/plot_BC.m
   issm/trunk/src/m/plot/plot_basaldrag.m
   issm/trunk/src/m/plot/plot_boundaries.m
   issm/trunk/src/m/plot/plot_contour.m
   issm/trunk/src/m/plot/plot_drivingstress.m
   issm/trunk/src/m/plot/plot_edges.m
   issm/trunk/src/m/plot/plot_elementnumbering.m
   issm/trunk/src/m/plot/plot_elementstype.m
   issm/trunk/src/m/plot/plot_highlightelements.m
   issm/trunk/src/m/plot/plot_highlightvertices.m
   issm/trunk/src/m/plot/plot_icefront.m
   issm/trunk/src/m/plot/plot_importancefactors.m
   issm/trunk/src/m/plot/plot_manager.m
   issm/trunk/src/m/plot/plot_mesh.m
   issm/trunk/src/m/plot/plot_none.m
   issm/trunk/src/m/plot/plot_overlay.m
   issm/trunk/src/m/plot/plot_parthist.m
   issm/trunk/src/m/plot/plot_parthistn.m
   issm/trunk/src/m/plot/plot_parthistw.m
   issm/trunk/src/m/plot/plot_penalties.m
   issm/trunk/src/m/plot/plot_qmu_mass_flux_segments.m
   issm/trunk/src/m/plot/plot_qmuhistnorm.m
   issm/trunk/src/m/plot/plot_qmumean.m
   issm/trunk/src/m/plot/plot_qmustddev.m
   issm/trunk/src/m/plot/plot_referential.m
   issm/trunk/src/m/plot/plot_riftfraction.m
   issm/trunk/src/m/plot/plot_riftnumbering.m
   issm/trunk/src/m/plot/plot_riftpenetration.m
   issm/trunk/src/m/plot/plot_riftrelvel.m
   issm/trunk/src/m/plot/plot_rifts.m
   issm/trunk/src/m/plot/plot_riftvel.m
   issm/trunk/src/m/plot/plot_sarpwr.m
   issm/trunk/src/m/plot/plot_scatter.m
   issm/trunk/src/m/plot/plot_section.m
   issm/trunk/src/m/plot/plot_segments.m
   issm/trunk/src/m/plot/plot_tensor.m
   issm/trunk/src/m/plot/plot_tensor_components.m
   issm/trunk/src/m/plot/plot_tensor_principal.m
   issm/trunk/src/m/plot/plot_tensor_principalaxis.m
   issm/trunk/src/m/plot/plot_thermaltransient_results.m
   issm/trunk/src/m/plot/plot_transient_movie.m
   issm/trunk/src/m/plot/plot_vertexnumbering.m
   issm/trunk/src/m/plot/plotmodel.m
   issm/trunk/src/m/plot/processdata.m
   issm/trunk/src/m/plot/processmesh.m
   issm/trunk/src/m/plot/quiver_colorbar.m
   issm/trunk/src/m/plot/radarpower.m
   issm/trunk/src/m/plot/subplotmodel.m
   issm/trunk/src/m/print/printmodel.m
   issm/trunk/src/m/qmu/MassFluxProcessProfile.m
   issm/trunk/src/m/qmu/dakota_cdfs.m
   issm/trunk/src/m/qmu/dakota_in_data.m
   issm/trunk/src/m/qmu/dakota_in_params.m
   issm/trunk/src/m/qmu/dakota_in_parse.m
   issm/trunk/src/m/qmu/dakota_moments.m
   issm/trunk/src/m/qmu/dakota_out_parse.m
   issm/trunk/src/m/qmu/examples/direct.m
   issm/trunk/src/m/qmu/examples/lrel_mmf.m
   issm/trunk/src/m/qmu/expandvariables.m
   issm/trunk/src/m/qmu/importancefactors.m
   issm/trunk/src/m/qmu/lclist_write.m
   issm/trunk/src/m/qmu/plot/plot_boxplot.m
   issm/trunk/src/m/qmu/plot/plot_cdf.m
   issm/trunk/src/m/qmu/plot/plot_hist_norm.m
   issm/trunk/src/m/qmu/plot/plot_hist_norm_ci.m
   issm/trunk/src/m/qmu/plot/plot_if_bars.m
   issm/trunk/src/m/qmu/plot/plot_if_spec.m
   issm/trunk/src/m/qmu/plot/plot_normdist_bars.m
   issm/trunk/src/m/qmu/plot/plot_normplot.m
   issm/trunk/src/m/qmu/plot/plot_prob_bars.m
   issm/trunk/src/m/qmu/plot/plot_rlev_bars.m
   issm/trunk/src/m/qmu/plot/plot_rlev_bars_ci.m
   issm/trunk/src/m/qmu/plot/plot_rvsv_line.m
   issm/trunk/src/m/qmu/plot/plot_rvsv_scat3.m
   issm/trunk/src/m/qmu/plot/plot_rvsv_surf.m
   issm/trunk/src/m/qmu/plot/plot_sampdist_bars.m
   issm/trunk/src/m/qmu/process_qmu_options.m
   issm/trunk/src/m/qmu/process_qmu_response_data.m
   issm/trunk/src/m/qmu/qmu_correlation.m
   issm/trunk/src/m/qmu/qmuisdistributed.m
   issm/trunk/src/m/qmu/qmumarshall.m
   issm/trunk/src/m/qmu/qmuresponse.m
   issm/trunk/src/m/qmu/qmuroot.m
   issm/trunk/src/m/qmu/rlist_write.m
   issm/trunk/src/m/qmu/sensitivities.m
   issm/trunk/src/m/qmu/setupdesign/IsScaled.m
   issm/trunk/src/m/qmu/setupdesign/QmuSetupVariables.m
   issm/trunk/src/m/qmu/vector_write.m
   issm/trunk/src/m/regional/BasinConstrain.m
   issm/trunk/src/m/regional/BasinConstrainShelf.m
   issm/trunk/src/m/regional/basinzoom.m
   issm/trunk/src/m/regional/regionaltransient2d.m
   issm/trunk/src/m/regional/showbasins.m
   issm/trunk/src/m/solve/MatlabProcessPatch.m
   issm/trunk/src/m/solve/MatlabProcessPatch.py
   issm/trunk/src/m/solve/WriteData.m
   issm/trunk/src/m/solve/WriteData.py
   issm/trunk/src/m/solve/loadresultsfromdisk.m
   issm/trunk/src/m/solve/loadresultsfromdisk.py
   issm/trunk/src/m/solve/marshall.m
   issm/trunk/src/m/solve/parseresultsfromdisk.m
   issm/trunk/src/m/solve/parseresultsfromdisk.py
   issm/trunk/src/m/solve/solve.m
   issm/trunk/src/m/solve/waitonlock.m
   issm/trunk/src/m/solvers/asmoptions.m
   issm/trunk/src/m/solvers/iluasmoptions.m
   issm/trunk/src/m/solvers/jacobiasmoptions.m
   issm/trunk/src/m/solvers/jacobicgoptions.m
   issm/trunk/src/m/solvers/matlaboptions.m
   issm/trunk/src/m/solvers/soroptions.m
   issm/trunk/src/m/string/issmprintf.m
   issm/trunk/src/m/string/strsplit.m
   issm/trunk/src/m/string/strsplit_strict.m
   issm/trunk/src/wrappers/matlab/
   issm/trunk/src/wrappers/python/
   issm/trunk/startup.py
   issm/trunk/test/
   issm/trunk/test/Archives/Archive237.nc
   issm/trunk/test/Archives/Archive423.nc
   issm/trunk/test/NightlyRun/ad.m
   issm/trunk/test/NightlyRun/runme.m
   issm/trunk/test/NightlyRun/runme.py
   issm/trunk/test/NightlyRun/test101.m
   issm/trunk/test/NightlyRun/test101.py
   issm/trunk/test/NightlyRun/test102.m
   issm/trunk/test/NightlyRun/test102.py
   issm/trunk/test/NightlyRun/test103.m
   issm/trunk/test/NightlyRun/test103.py
   issm/trunk/test/NightlyRun/test104.m
   issm/trunk/test/NightlyRun/test104.py
   issm/trunk/test/NightlyRun/test105.m
   issm/trunk/test/NightlyRun/test105.py
   issm/trunk/test/NightlyRun/test106.m
   issm/trunk/test/NightlyRun/test106.py
   issm/trunk/test/NightlyRun/test107.m
   issm/trunk/test/NightlyRun/test107.py
   issm/trunk/test/NightlyRun/test108.m
   issm/trunk/test/NightlyRun/test108.py
   issm/trunk/test/NightlyRun/test109.m
   issm/trunk/test/NightlyRun/test109.py
   issm/trunk/test/NightlyRun/test110.m
   issm/trunk/test/NightlyRun/test110.py
   issm/trunk/test/NightlyRun/test1101.m
   issm/trunk/test/NightlyRun/test1102.m
   issm/trunk/test/NightlyRun/test1103.m
   issm/trunk/test/NightlyRun/test1104.m
   issm/trunk/test/NightlyRun/test1105.m
   issm/trunk/test/NightlyRun/test1106.m
   issm/trunk/test/NightlyRun/test1107.m
   issm/trunk/test/NightlyRun/test1108.m
   issm/trunk/test/NightlyRun/test1109.m
   issm/trunk/test/NightlyRun/test111.m
   issm/trunk/test/NightlyRun/test111.py
   issm/trunk/test/NightlyRun/test1110.m
   issm/trunk/test/NightlyRun/test112.m
   issm/trunk/test/NightlyRun/test112.py
   issm/trunk/test/NightlyRun/test113.m
   issm/trunk/test/NightlyRun/test113.py
   issm/trunk/test/NightlyRun/test114.m
   issm/trunk/test/NightlyRun/test114.py
   issm/trunk/test/NightlyRun/test115.m
   issm/trunk/test/NightlyRun/test115.py
   issm/trunk/test/NightlyRun/test116.m
   issm/trunk/test/NightlyRun/test116.py
   issm/trunk/test/NightlyRun/test117.m
   issm/trunk/test/NightlyRun/test117.py
   issm/trunk/test/NightlyRun/test118.m
   issm/trunk/test/NightlyRun/test118.py
   issm/trunk/test/NightlyRun/test119.m
   issm/trunk/test/NightlyRun/test120.m
   issm/trunk/test/NightlyRun/test120.py
   issm/trunk/test/NightlyRun/test1201.m
   issm/trunk/test/NightlyRun/test1202.m
   issm/trunk/test/NightlyRun/test1203.m
   issm/trunk/test/NightlyRun/test1204.m
   issm/trunk/test/NightlyRun/test1205.m
   issm/trunk/test/NightlyRun/test1206.m
   issm/trunk/test/NightlyRun/test1207.m
   issm/trunk/test/NightlyRun/test1208.m
   issm/trunk/test/NightlyRun/test121.m
   issm/trunk/test/NightlyRun/test121.py
   issm/trunk/test/NightlyRun/test122.m
   issm/trunk/test/NightlyRun/test122.py
   issm/trunk/test/NightlyRun/test1301.m
   issm/trunk/test/NightlyRun/test1302.m
   issm/trunk/test/NightlyRun/test1303.m
   issm/trunk/test/NightlyRun/test1304.m
   issm/trunk/test/NightlyRun/test1401.m
   issm/trunk/test/NightlyRun/test1402.m
   issm/trunk/test/NightlyRun/test1501.m
   issm/trunk/test/NightlyRun/test1502.m
   issm/trunk/test/NightlyRun/test1601.m
   issm/trunk/test/NightlyRun/test1602.m
   issm/trunk/test/NightlyRun/test201.m
   issm/trunk/test/NightlyRun/test202.m
   issm/trunk/test/NightlyRun/test203.m
   issm/trunk/test/NightlyRun/test204.m
   issm/trunk/test/NightlyRun/test205.m
   issm/trunk/test/NightlyRun/test206.m
   issm/trunk/test/NightlyRun/test207.m
   issm/trunk/test/NightlyRun/test208.m
   issm/trunk/test/NightlyRun/test209.m
   issm/trunk/test/NightlyRun/test210.m
   issm/trunk/test/NightlyRun/test211.m
   issm/trunk/test/NightlyRun/test212.m
   issm/trunk/test/NightlyRun/test213.m
   issm/trunk/test/NightlyRun/test214.m
   issm/trunk/test/NightlyRun/test215.m
   issm/trunk/test/NightlyRun/test216.m
   issm/trunk/test/NightlyRun/test217.m
   issm/trunk/test/NightlyRun/test218.m
   issm/trunk/test/NightlyRun/test219.m
   issm/trunk/test/NightlyRun/test220.m
   issm/trunk/test/NightlyRun/test221.m
   issm/trunk/test/NightlyRun/test222.m
   issm/trunk/test/NightlyRun/test223.m
   issm/trunk/test/NightlyRun/test224.m
   issm/trunk/test/NightlyRun/test225.m
   issm/trunk/test/NightlyRun/test226.m
   issm/trunk/test/NightlyRun/test227.m
   issm/trunk/test/NightlyRun/test228.m
   issm/trunk/test/NightlyRun/test229.m
   issm/trunk/test/NightlyRun/test230.m
   issm/trunk/test/NightlyRun/test231.m
   issm/trunk/test/NightlyRun/test232.m
   issm/trunk/test/NightlyRun/test233.m
   issm/trunk/test/NightlyRun/test234.m
   issm/trunk/test/NightlyRun/test235.m
   issm/trunk/test/NightlyRun/test236.m
   issm/trunk/test/NightlyRun/test237.m
   issm/trunk/test/NightlyRun/test270.m
   issm/trunk/test/NightlyRun/test272.m
   issm/trunk/test/NightlyRun/test274.m
   issm/trunk/test/NightlyRun/test3001.m
   issm/trunk/test/NightlyRun/test3002.m
   issm/trunk/test/NightlyRun/test3003.m
   issm/trunk/test/NightlyRun/test3004.m
   issm/trunk/test/NightlyRun/test3005.m
   issm/trunk/test/NightlyRun/test3006.m
   issm/trunk/test/NightlyRun/test3007.m
   issm/trunk/test/NightlyRun/test3008.m
   issm/trunk/test/NightlyRun/test3009.m
   issm/trunk/test/NightlyRun/test301.m
   issm/trunk/test/NightlyRun/test3010.m
   issm/trunk/test/NightlyRun/test302.m
   issm/trunk/test/NightlyRun/test303.m
   issm/trunk/test/NightlyRun/test304.m
   issm/trunk/test/NightlyRun/test305.m
   issm/trunk/test/NightlyRun/test306.m
   issm/trunk/test/NightlyRun/test307.m
   issm/trunk/test/NightlyRun/test308.m
   issm/trunk/test/NightlyRun/test309.m
   issm/trunk/test/NightlyRun/test310.m
   issm/trunk/test/NightlyRun/test311.m
   issm/trunk/test/NightlyRun/test312.m
   issm/trunk/test/NightlyRun/test313.m
   issm/trunk/test/NightlyRun/test314.m
   issm/trunk/test/NightlyRun/test315.m
   issm/trunk/test/NightlyRun/test316.m
   issm/trunk/test/NightlyRun/test317.m
   issm/trunk/test/NightlyRun/test318.m
   issm/trunk/test/NightlyRun/test319.m
   issm/trunk/test/NightlyRun/test320.m
   issm/trunk/test/NightlyRun/test321.m
   issm/trunk/test/NightlyRun/test322.m
   issm/trunk/test/NightlyRun/test323.m
   issm/trunk/test/NightlyRun/test324.m
   issm/trunk/test/NightlyRun/test325.m
   issm/trunk/test/NightlyRun/test326.m
   issm/trunk/test/NightlyRun/test327.m
   issm/trunk/test/NightlyRun/test328.m
   issm/trunk/test/NightlyRun/test329.m
   issm/trunk/test/NightlyRun/test401.m
   issm/trunk/test/NightlyRun/test402.m
   issm/trunk/test/NightlyRun/test403.m
   issm/trunk/test/NightlyRun/test404.m
   issm/trunk/test/NightlyRun/test405.m
   issm/trunk/test/NightlyRun/test406.m
   issm/trunk/test/NightlyRun/test407.m
   issm/trunk/test/NightlyRun/test408.m
   issm/trunk/test/NightlyRun/test409.m
   issm/trunk/test/NightlyRun/test410.m
   issm/trunk/test/NightlyRun/test411.m
   issm/trunk/test/NightlyRun/test412.m
   issm/trunk/test/NightlyRun/test413.m
   issm/trunk/test/NightlyRun/test414.m
   issm/trunk/test/NightlyRun/test415.m
   issm/trunk/test/NightlyRun/test416.m
   issm/trunk/test/NightlyRun/test417.m
   issm/trunk/test/NightlyRun/test418.m
   issm/trunk/test/NightlyRun/test419.m
   issm/trunk/test/NightlyRun/test420.m
   issm/trunk/test/NightlyRun/test421.m
   issm/trunk/test/NightlyRun/test422.m
   issm/trunk/test/NightlyRun/test423.m
   issm/trunk/test/NightlyRun/test424.m
   issm/trunk/test/NightlyRun/test425.m
   issm/trunk/test/NightlyRun/test426.m
   issm/trunk/test/NightlyRun/test427.m
   issm/trunk/test/NightlyRun/test428.m
   issm/trunk/test/NightlyRun/test429.m
   issm/trunk/test/NightlyRun/test430.m
   issm/trunk/test/NightlyRun/test431.m
   issm/trunk/test/NightlyRun/test432.m
   issm/trunk/test/NightlyRun/test501.m
   issm/trunk/test/NightlyRun/test502.m
   issm/trunk/test/NightlyRun/test503.m
   issm/trunk/test/NightlyRun/test504.m
   issm/trunk/test/NightlyRun/test505.m
   issm/trunk/test/NightlyRun/test506.m
   issm/trunk/test/NightlyRun/test507.m
   issm/trunk/test/NightlyRun/test508.m
   issm/trunk/test/NightlyRun/test509.m
   issm/trunk/test/NightlyRun/test510.m
   issm/trunk/test/NightlyRun/test511.m
   issm/trunk/test/NightlyRun/test512.m
   issm/trunk/test/NightlyRun/test513.m
   issm/trunk/test/NightlyRun/test514.m
   issm/trunk/test/NightlyRun/test515.m
   issm/trunk/test/NightlyRun/test516.m
   issm/trunk/test/NightlyRun/test601.m
   issm/trunk/test/NightlyRun/test602.m
   issm/trunk/test/NightlyRun/test603.m
   issm/trunk/test/NightlyRun/test604.m
   issm/trunk/test/NightlyRun/test605.m
   issm/trunk/test/NightlyRun/test606.m
   issm/trunk/test/NightlyRun/test607.m
   issm/trunk/test/NightlyRun/test608.m
   issm/trunk/test/NightlyRun/test609.m
   issm/trunk/test/NightlyRun/test610.m
   issm/trunk/test/NightlyRun/test611.m
   issm/trunk/test/NightlyRun/test612.m
   issm/trunk/test/NightlyRun/test613.m
   issm/trunk/test/Par/79North.par
   issm/trunk/test/Par/RoundSheetShelf.par
   issm/trunk/test/Par/SquareSheetConstrained.par
   issm/trunk/test/Par/SquareSheetShelf.par
   issm/trunk/test/Par/SquareShelfConstrained.py
Log:
merged trunk-jpl and trunk for revision 13974


Property changes on: issm/trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /issm/trunk-jpl:10936-11994,11996-12326,12333-12336,12338-12703,12705-12707,12710-13393
   + /issm/trunk-jpl:10936-11994,11996-12326,12333-12336,12338-12703,12705-12707,12710-13393,13396-13974

Modified: issm/trunk/configs/config-arm-linux.sh
===================================================================
--- issm/trunk/configs/config-arm-linux.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-arm-linux.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,8 +5,10 @@
     --build="i386-apple-darwin10.8.0" \
     --host="arm-linux-androideabi" \
     --enable-shared \
+    --with-android=jni\
     --without-fortran \
-	--without-modules \
+	--without-wrappers \
+	--without-kriging \
 	--with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install \
 	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
     --disable-static

Modified: issm/trunk/configs/config-discover.sh
===================================================================
--- issm/trunk/configs/config-discover.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-discover.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,6 +21,6 @@
  --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install \
  --with-tao-dir=$ISSM_DIR/externalpackages/tao/install \
  --with-graphics-lib=/usr/lib64/libX11.so \
- --with-cxxoptflags="-O3 -xS" \
+ --with-cxxoptflags="-O3 -xS -DMPICH_IGNORE_CXX_SEEK" \
  --with-vendor=intel-discover
 

Modified: issm/trunk/configs/config-greenplanet.sh
===================================================================
--- issm/trunk/configs/config-greenplanet.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-greenplanet.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,7 @@
 
 ./configure \
  --prefix=$ISSM_DIR \
- --with-modules=no \
+ --with-wrappers=no \
  --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
  --with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
  --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \

Modified: issm/trunk/configs/config-linux64-ad.sh
===================================================================
--- issm/trunk/configs/config-linux64-ad.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-linux64-ad.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,7 @@
 
 ./configure \
 	--prefix=$ISSM_DIR \
-	--without-modules\
+	--without-wrappers\
 	--with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install\
 	--without-thermal \
 	--without-control \

Modified: issm/trunk/configs/config-linux64-astrid.sh
===================================================================
--- issm/trunk/configs/config-linux64-astrid.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-linux64-astrid.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,7 +12,6 @@
  --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \
  --with-python-dir=$ISSM_DIR/externalpackages/python/install\
  --with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/lib/python2.7/site-packages/numpy/core/include/numpy\
- --with-python-version=2.7\
  --with-tao-dir=$ISSM_DIR/externalpackages/tao/install \
  --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
  --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \

Modified: issm/trunk/configs/config-linux64-murdo-ad.sh
===================================================================
--- issm/trunk/configs/config-linux64-murdo-ad.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-linux64-murdo-ad.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,37 +1,10 @@
 #!/bin/sh
 
 ./configure \
- --prefix=$ISSM_DIR \
- --with-serial=no\
- --with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
- --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \
- --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
- --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich" \
- --with-petsc-arch=$ISSM_ARCH \
- --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
- --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
- --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
- --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
- --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
- --with-hypre-dir=$ISSM_DIR/externalpackages/petsc/install/ \
- --with-ml-dir=$ISSM_DIR/externalpackages/petsc/install/ \
- --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
- --with-graphics-lib=/usr/lib64/libX11.so \
- --with-cxxoptflags="-mtune=barcelona -ffast-math -O3 -msse4.2 -Wno-write-strings "\
- --with-fortran-lib="-L/usr/lib/gcc/x86_64-redhat-linux/3.4.6/ -lg2c  /usr/lib/gcc/x86_64-redhat-linux/4.1.1/libgfortran.a" \
- --with-adic2-dir=$ISSM_DIR/externalpackages/adic/install/ \
---with-numthreads=24 \
- --without-thermal \
- --without-control \
- --without-hydrology \
- --without-diagnostic \
- --without-balanced \
- --without-responses \
- --without-slope \
- --without-rifts \
- --without-steadystate \
- --without-transient \
- --without-3d \
- --without-groundingline
- 
-#--without-prognostic \
+	 --prefix=$ISSM_DIR \
+	 --without-kriging \
+	 --without-kml \
+	--with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install \
+	--with-adolc-dir=$ISSM_DIR/externalpackages/adolc/install \
+	--with-matlab-dir=$MATLAB_DIR \
+	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install

Modified: issm/trunk/configs/config-linux64-murdo.sh
===================================================================
--- issm/trunk/configs/config-linux64-murdo.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-linux64-murdo.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,26 +1,27 @@
 #!/bin/sh
 
+#petsc 3.2
+#mpich 1.4
+
 ./configure \
- --prefix=$ISSM_DIR \
- --with-matlab-dir=$MATLAB_DIR \
- --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
- --with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
- --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \
- --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
- --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich" \
- --with-petsc-arch=$ISSM_ARCH \
- --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
- --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
- --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/INCLUDE" \
- --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
- --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
- --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
- --with-scotch-dir="$ISSM_DIR/externalpackages/scotch/install" \
- --with-chaco-dir="$ISSM_DIR/externalpackages/chaco/install" \
- --with-graphics-lib=/usr/lib64/libX11.so \
- --with-cxxoptflags="-mtune=barcelona -ffast-math -O3 -msse4.2 -Wno-write-strings "\
- --with-numthreads=18 \
- --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
- --enable-debugging
- 
- 
+	--prefix=$ISSM_DIR \
+	--with-matlab-dir=$MATLAB_DIR \
+	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
+	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
+	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
+	--with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich" \
+	--with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/lib/python2.7/site-packages/numpy/core/include/numpy\
+	--with-tao-dir=$ISSM_DIR/externalpackages/tao/install \
+	--with-petsc-arch=$ISSM_ARCH \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
+	--with-chaco-dir="$ISSM_DIR/externalpackages/chaco/install" \
+	--with-scotch-dir="$ISSM_DIR/externalpackages/scotch/install" \
+	--with-graphics-lib=/usr/lib64/libX11.so \
+	--with-cxxoptflags="-mtune=barcelona -ffast-math -O3 -msse4.2 -Wno-write-strings "\
+	--with-numthreads=18 \
+	--enable-debugging 

Modified: issm/trunk/configs/config-macosx-snowleopard-bothapis.sh
===================================================================
--- issm/trunk/configs/config-macosx-snowleopard-bothapis.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-macosx-snowleopard-bothapis.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,20 +3,12 @@
 #petsc 3.2
 #mpich 1.4
 
-#export FCFLAGS=" -m32"
-#export FFLAGS=" -m32"
-#export CFLAGS=" -arch i386"
-#export CXXFLAGS=" -arch i386"
-
-pythonversion=2.7
-
 ./configure \
 	--prefix=$ISSM_DIR \
 	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
 	--with-matlab-dir=$MATLAB_DIR \
 	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
-	--with-python-version=$pythonversion \
-	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Python.framework/Versions/$pythonversion/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy\
 	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
 	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
 	--with-mpi-lib=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \

Modified: issm/trunk/configs/config-macosx-snowleopard-python.sh
===================================================================
--- issm/trunk/configs/config-macosx-snowleopard-python.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-macosx-snowleopard-python.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,14 +3,11 @@
 #petsc 3.2
 #mpich 1.4
 
-pythonversion=2.7
-
 ./configure \
 	--prefix=$ISSM_DIR \
 	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
 	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
-	--with-python-version=$pythonversion \
-	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Library/Frameworks/Python.framework/Versions/$pythonversion/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy\
 	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
 	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
 	--with-mpi-lib=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \

Modified: issm/trunk/configs/config-macosx64-ad.sh
===================================================================
--- issm/trunk/configs/config-macosx64-ad.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-macosx64-ad.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,7 @@
 
 ./configure \
 	--prefix=$ISSM_DIR \
-	--without-modules\
+	--without-wrappers\
 	--with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install\
 	--without-thermal \
 	--without-control \

Modified: issm/trunk/configs/config-macosx64-chris-bothapis.sh
===================================================================
--- issm/trunk/configs/config-macosx64-chris-bothapis.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-macosx64-chris-bothapis.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,20 +3,17 @@
 #petsc 3.2
 #mpich 1.4
 
-pythonversion=2.7
-
 ./configure \
 	--prefix=$ISSM_DIR \
-	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
 	--with-matlab-dir=$MATLAB_DIR \
-	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
-	--with-python-version=$pythonversion \
+	--with-python-dir=$ISSM_DIR/externalpackages/python/install \
 	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy\
+	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
 	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
 	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
 	--with-mpi-lib=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
 	--with-chaco-dir=$ISSM_DIR/externalpackages/chaco/install \
-	--with-fortran-lib="/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10/4.6.2/libgfortran.a" \
+	--with-fortran-lib="/usr/local/gfortran/lib/libgfortran.a" \
 	--with-math-lib="/usr/lib/libm.dylib" \
 	--with-graphics-lib="/usr/X11/lib/libX11.dylib" \
 	--with-cxxoptflags=" -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -mmacosx-version-min=10.5  -O3 -DNDEBUG -w "\
@@ -27,7 +24,4 @@
 	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
-	--with-numthreads=8
-	#--with-fortran-lib="/usr/local/gfortran/lib/libgfortran.a" \
-	#--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
-	#--with-boost-dir=$ISSM_DIR/externalpackages/boost/install/ \
+	#--with-fortran-lib="/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10/4.6.2/libgfortran.a" \

Modified: issm/trunk/configs/config-macosx64-chris-python.sh
===================================================================
--- issm/trunk/configs/config-macosx64-chris-python.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-macosx64-chris-python.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,14 +3,11 @@
 #petsc 3.2
 #mpich 1.4
 
-pythonversion=2.7
-
 ./configure \
 	--prefix=$ISSM_DIR \
 	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
 	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
-	--with-python-version=$pythonversion \
-	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/lib/python2.7/site-packages/numpy/core/include/numpy\
 	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
 	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
 	--with-mpi-lib=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \
@@ -23,12 +20,7 @@
 	--with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install  \
 	--with-petsc-arch=$ISSM_ARCH \
 	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
-	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
 	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-numthreads=8
-	#--with-fortran-lib="/usr/local/gfortran/lib/libgfortran.a" \
-	#--with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
-	#--with-boost-dir=$ISSM_DIR/externalpackages/boost/install/ \

Modified: issm/trunk/configs/config-macosx64-gsl.sh
===================================================================
--- issm/trunk/configs/config-macosx64-gsl.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-macosx64-gsl.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,7 @@
 
 ./configure \
 	--prefix=$ISSM_DIR \
-	--without-modules\
+	--without-wrappers\
 	--with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install
 	#--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install 
     #--without-fortran-lib

Modified: issm/trunk/configs/config-macosx64-larour-ad.sh
===================================================================
--- issm/trunk/configs/config-macosx64-larour-ad.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-macosx64-larour-ad.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+pythonversion=2.7
+
 ./configure \
 	--prefix=$ISSM_DIR \
 	--without-kriging  \
@@ -7,5 +9,7 @@
 	--with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install \
 	--with-adolc-dir=$ISSM_DIR/externalpackages/adolc/install \
 	--with-matlab-dir=$MATLAB_DIR \
+	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Library/Frameworks/Python.framework/Versions/$pythonversion/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
 	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
 

Modified: issm/trunk/configs/config-macosx64-larour-nopetsc.sh
===================================================================
--- issm/trunk/configs/config-macosx64-larour-nopetsc.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-macosx64-larour-nopetsc.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,13 +1,10 @@
 #!/bin/sh
 
-pythonversion=3.2
-
 ./configure \
 	--prefix=$ISSM_DIR \
 	--with-matlab-dir=$MATLAB_DIR \
 	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
-	--with-python-version=$pythonversion \
-	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Python.framework/Versions/$pythonversion/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/numpy\
 	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
 	--with-math-lib="/usr/lib/libm.dylib" \
 	--with-graphics-lib="/usr/X11/lib/libX11.dylib" \

Modified: issm/trunk/configs/config-macosx64-larour-python.sh
===================================================================
--- issm/trunk/configs/config-macosx64-larour-python.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-macosx64-larour-python.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,14 +3,11 @@
 #petsc 3.2
 #mpich 1.4
 
-pythonversion=2.7
-
 ./configure \
 	--prefix=$ISSM_DIR \
 	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
 	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
-	--with-python-version=$pythonversion \
-	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/lib/python2.7/site-packages/numpy/core/include/numpy\
 	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
 	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
 	--with-mpi-lib=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \

Modified: issm/trunk/configs/config-macosx64-larour.sh
===================================================================
--- issm/trunk/configs/config-macosx64-larour.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-macosx64-larour.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,9 +3,13 @@
 #petsc 3.2
 #mpich 1.4
 
+pythonversion=2.7
+
 ./configure \
 	--prefix=$ISSM_DIR \
 	--with-matlab-dir=$MATLAB_DIR \
+	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/Library/Frameworks/Python.framework/Versions/$pythonversion/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
 	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
 	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
 	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
@@ -19,8 +23,6 @@
 	--with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install  \
 	--with-petsc-arch=$ISSM_ARCH \
 	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
-	--with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
-	--with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/include/ " \
 	--with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
 	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \

Modified: issm/trunk/configs/config-macosx64-lion-helene.sh
===================================================================
--- issm/trunk/configs/config-macosx64-lion-helene.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-macosx64-lion-helene.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,15 +3,12 @@
 #petsc 3.2
 #mpich 1.4
 
-pythonversion=2.7
-
 ./configure \
 	--prefix=$ISSM_DIR \
 	--with-matlab-dir=$MATLAB_DIR \
 	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
 	--with-python-dir=$ISSM_DIR/externalpackages/python/install\
-	--with-python-version=$pythonversion \
-	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/lib/python$pythonversion/site-packages/numpy/core/include/numpy\
+	--with-python-numpy-dir=$ISSM_DIR/externalpackages/python/install/lib/python2.7/site-packages/numpy/core/include/numpy\
 	--with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
 	--with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  \
 	--with-mpi-lib=" $ISSM_DIR/externalpackages/mpich2/install/lib/libpmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpich.a $ISSM_DIR/externalpackages/mpich2/install/lib/libmpl.a " \

Modified: issm/trunk/configs/config-pleiades-petsc2.sh
===================================================================
--- issm/trunk/configs/config-pleiades-petsc2.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-pleiades-petsc2.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,7 @@
 
 ./configure \
  --prefix=$ISSM_DIR \
- --with-modules=no \
+ --with-wrappers=no \
  --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
  --with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
  --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \

Modified: issm/trunk/configs/config-pleiades-petscdev.sh
===================================================================
--- issm/trunk/configs/config-pleiades-petscdev.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-pleiades-petscdev.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,7 @@
 
 ./configure \
  --prefix=$ISSM_DIR \
- --with-modules=no \
+ --with-wrappers=no \
  --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
  --with-metis-dir=$ISSM_DIR/externalpackages/petsc/src/externalpackages/metis-5.0.2-p3 \
  --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \
@@ -12,17 +12,14 @@
  --with-petsc-arch=$ISSM_ARCH \
  --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install \
  --with-mkl-dir=/nasa/intel/mkl/10.0.011/lib/64/ \
- --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/ -lPLAPACK" \
- --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/src/externalpackages/PLAPACKR32-hg/INCLUDE" \
  --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-spai-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-hypre-dir=$ISSM_DIR/externalpackages/petsc/install/ \
- --with-prometheus-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-superlu-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-spooles-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-pastix-dir=$ISSM_DIR/externalpackages/petsc/install/ \
  --with-graphics-lib=/usr/lib64/libX11.so \
- --with-cxxoptflags="-O3 -xS" \
+ --with-cxxoptflags="-O3" \
  --with-vendor=intel-pleiades

Modified: issm/trunk/configs/config-pleiades.sh
===================================================================
--- issm/trunk/configs/config-pleiades.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configs/config-pleiades.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,7 @@
 
 ./configure \
  --prefix=$ISSM_DIR \
- --with-modules=no \
+ --with-wrappers=no \
  --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
  --with-metis-dir=$ISSM_DIR/externalpackages/metis/install \
  --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install \

Modified: issm/trunk/configure.ac
===================================================================
--- issm/trunk/configure.ac	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/configure.ac	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
 # Process this file with autoconf to produce a configure script.
 
 #AUTOCONF
-AC_INIT([ISSM],[4.2.2],[issm at jpl.nasa.gov],[issm],[http://issm.jpl.nasa.gov]) #Initializing configure
+AC_INIT([ISSM],[4.2.3],[issm at jpl.nasa.gov],[issm],[http://issm.jpl.nasa.gov]) #Initializing configure
 AC_CONFIG_AUX_DIR([./aux-config])         #Put config files in aux-config
 AC_CONFIG_MACRO_DIR([m4])                 #m4 macros are located in m4
 m4_include([m4/issm_options.m4])
@@ -35,9 +35,11 @@
 AC_CONFIG_FILES([Makefile
 			src/Makefile
 			src/c/Makefile 
-			src/modules/Makefile
-			src/modules/python/Makefile
-			src/modules/matlab/Makefile
+			src/wrappers/Makefile
+			src/wrappers/python/Makefile
+			src/wrappers/matlab/Makefile
+			src/android/Makefile
+			src/android/ISSM/Makefile
 			src/m/Makefile])
 
 #End of configure.ac

Modified: issm/trunk/etc/environment.csh
===================================================================
--- issm/trunk/etc/environment.csh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/etc/environment.csh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -87,7 +87,7 @@
 #CMAKE
 set CMAKE_DIR="$ISSM_DIR/externalpackages/cmake/install"
 if (-d $CMAKE_DIR) then
-	setenv PATH {$PATH}:{$CMAKE_DIR}/bin
+	setenv PATH {$CMAKE_DIR}/bin:{$PATH}
 endif
 
 #YAMS

Modified: issm/trunk/etc/environment.sh
===================================================================
--- issm/trunk/etc/environment.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/etc/environment.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,7 @@
 
 pathprepend(){ #{{{
 	if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
-		PATH="$1:$PATH"
+		export PATH="$1:$PATH"
 	fi
 } #}}}
 pathappend(){ #{{{
@@ -65,9 +65,11 @@
 libpathappend "$MATLAB_DIR/lib"
 
 MPI_DIR="$ISSM_DIR/externalpackages/mpich2/install"
-export MPI_DIR
-pathprepend   "$MPI_DIR/bin"
-libpathappend "$MPI_DIR/lib"
+if [ -d "$MPI_DIR" ]; then
+	export MPI_DIR
+	pathprepend   "$MPI_DIR/bin"
+	libpathappend "$MPI_DIR/lib"
+fi
 
 PETSC_DIR="$ISSM_DIR/externalpackages/petsc/install"
 export PETSC_DIR
@@ -101,7 +103,7 @@
 pathappend "$CPPCHECK_DIR/bin"
 
 GDAL_DIR="$ISSM_DIR/externalpackages/gdal/install"
-pathprepend "$GDAL_DIR/bin:$PATH"
+pathprepend "$GDAL_DIR/bin"
 libpathappend "$GDAL_DIR/lib"
 
 MERCURIAL_DIR="$ISSM_DIR/externalpackages/mercurial/install"
@@ -186,10 +188,13 @@
 PACKAGEMAKER_DIR="$ISSM_DIR/externalpackages/packagemaker/install"
 pathappend "$PACKAGEMAKER_DIR"
 
-ANDROID_NDK_DIR="$ISSM_DIR/externalpackages/android-ndk/install"
-pathappend "$ANDROID_NDK_DIR/"
+#android-dev-dir
+export ANDROID_DIR="$ISSM_DIR/externalpackages/android"
 
-ANDROID_SDK_DIR="$ANDROID_DIR/android-sdk/install-sdk"
+export ANDROID_NDK_DIR="$ANDROID_DIR/android-ndk/install"
+pathappend "$ANDROID_NDK_DIR/arm-linux-android-install/bin"
+
+export ANDROID_SDK_DIR="$ANDROID_DIR/android-sdk/install"
 pathappend "$ANDROID_SDK_DIR/"
 
 GSL_DIR="$ISSM_DIR/externalpackages/gsl/install"
@@ -211,7 +216,7 @@
 pathappend "$MODELE_DIR/src/exec"
 
 GIT_DIR="$ISSM_DIR/externalpackages/git/install"
-pathappend "$GIT_DIR/bin"
+pathprepend "$GIT_DIR/bin"
 
 NCVIEW_DIR="$ISSM_DIR/externalpackages/ncview/install"
 pathappend "$NCVIEW_DIR"


Property changes on: issm/trunk/execution
___________________________________________________________________
Modified: svn:ignore
   - test*
ad*

   + *-*-*-*
Pig-*
test*
pig*
ad*



Property changes on: issm/trunk/externalpackages/adolc
___________________________________________________________________
Modified: svn:ignore
   - adolc_v220_issm
trunk
*.gz
install*
src
src-*
configure.sh
.ignore.txt

   + adolc_issm
adolc_v220_issm
trunk
*.gz
install*
src
src-*
configure.sh
.ignore.txt


Modified: issm/trunk/externalpackages/adolc/install-dev.sh
===================================================================
--- issm/trunk/externalpackages/adolc/install-dev.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/adolc/install-dev.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,12 +2,12 @@
 set -eu
 
 #Some cleanup
-rm -rf install adolc_v220_issm
+rm -rf install adolc*issm
 
-git clone -b 2.3.x_ISSM  git://gitorious.org/~utke/adol-c/adolc_v220_issm.git 
+git clone -b 2.3.x_ISSM  git://git.mcs.anl.gov/adol-c.git adolc_issm
 
 #Compile ADOL-C
-cd adolc_v220_issm
+cd adolc_issm
 
 autoreconf -f -i 
 ./configure --prefix=$ISSM_DIR/externalpackages/adolc/install 


Property changes on: issm/trunk/externalpackages/android/android-ndk
___________________________________________________________________
Modified: svn:ignore
   - install

   + android-ndk-r*
*.bz2
install


Modified: issm/trunk/externalpackages/android/android-ndk/install.sh
===================================================================
--- issm/trunk/externalpackages/android/android-ndk/install.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/android/android-ndk/install.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,4 @@
 #!/bin/bash
-set -eu
 
 # This installs the Android NDK (Native Development Kit)
 # which is needed for the compilation of C/C++ code into the 
@@ -28,5 +27,5 @@
 # Create Standalone Development Directory
 # Note: API-14 corresponds to Android 4.0.
 if [[ $step == "2" || $step == "0" ]]; then
-    $ANDROID_NDK_DIR/build/tools/make-standalone-toolchain.sh --platform=android-14 --install-dir=$ANDROID_DIR/arm-linux-android-4.0
+    $ANDROID_DIR/android-ndk/install/build/tools/make-standalone-toolchain.sh --platform=android-14 --install-dir=$ANDROID_DIR/android-ndk/install/arm-linux-android-install
 fi


Property changes on: issm/trunk/externalpackages/android/android-sdk
___________________________________________________________________
Modified: svn:ignore
   - install-sdk
install-ant

   + *.zip
install-sdk
install-ant


Modified: issm/trunk/externalpackages/android/android-sdk/install.sh
===================================================================
--- issm/trunk/externalpackages/android/android-sdk/install.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/android/android-sdk/install.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,4 @@
 #!/bin/bash
-set -eu 
 
 # This installs the Android SDK (Software Development Kit)
 # which is needed for the compilation of the Java project. 

Modified: issm/trunk/externalpackages/android/android_aux.sh
===================================================================
--- issm/trunk/externalpackages/android/android_aux.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/android/android_aux.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,16 +15,29 @@
 step=0;
 j=1;
 
+echo ""
+echo "This install script utilizes 'android_aux.sh' to allow for options."
+echo "For usage information enter: '--help'"
 echo Number of arguments is: $#
+
 for arg in $* 
 do 
     if [[ "$arg" =~ --step=([0-9])* ]]; then
         step=${BASH_REMATCH[1]}; 
         echo "Setting step to: " $step
-    elif [[ "$arg" =~ -j=([1-9]+[0-9]*) || "$arg" =~ ([1-9]+[0-9]*) ]]; then
+    elif [[ "$arg" == "--help" ]]; then
+        echo ""
+        echo "USAGE: $ install.sh [--step=#] [-j#]"
+        echo ""
+        echo "Where '#' is some integer."
+        echo "To check the number of steps check the install script."
+        echo ""
+        exit 1;
+    elif [[ "$arg" =~ -j=([1-9]+[0-9]*) ]]; then
         j=${BASH_REMATCH[1]}; 
         echo "Number of jobs set to: " $j
     else
         echo "Option not recognized"
+        exit 1;
     fi
 done

Modified: issm/trunk/externalpackages/chaco/install.sh
===================================================================
--- issm/trunk/externalpackages/chaco/install.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/chaco/install.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,6 +9,7 @@
 
 #Download from ISSM server
 $ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/Chaco-2.2.tar.gz' 'Chaco-2.2.tar.gz'
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/docs/chaco_guide.pdf' 'chaco_guide.pdf'
 
 # Untar 
 tar -xvzf Chaco-2.2.tar.gz


Property changes on: issm/trunk/externalpackages/cmake
___________________________________________________________________
Modified: svn:ignore
   - install
src

   + *.gz
install
src



Property changes on: issm/trunk/externalpackages/ec2ami
___________________________________________________________________
Added: svn:ignore
   + ec2-ami-tools-*
*.zip




Property changes on: issm/trunk/externalpackages/ec2api
___________________________________________________________________
Added: svn:ignore
   + ec2-api-tools.zip
ec2-api-tools-*




Property changes on: issm/trunk/externalpackages/esmf
___________________________________________________________________
Modified: svn:ignore
   - esmf
*.gz

   + esmf-gfortran*
esmf
*.gz


Modified: issm/trunk/externalpackages/esmf/install.sh
===================================================================
--- issm/trunk/externalpackages/esmf/install.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/esmf/install.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,51 +1,38 @@
 #!/bin/bash
 set -eu
 
-#0: cleanup
-#1: install
-#2: test
-
-install=2
-
 export ESMF_DIR=$ISSM_DIR/externalpackages/esmf/esmf
 export ESMF_COMPILER=gfortran
 export ESMF_COMM=mpich2
 
-if [[ $install == "0" ]]; then
-	#Some cleanup
-	rm -rf esmf_5_2_0rp2
-	rm -rf esmf
-fi
+#Some cleanup
+rm -rf esmf_5_2_0rp2
+rm -rf esmf
 
-if [[ $install == "1" ]]; then
+#Download from ISSM server
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/esmf_5_2_0rp2_src.tar.gz' 'esmf_5_2_0rp2_src.tar.gz'
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/docs/ESMF_refdoc.pdf' 'ESMF_refdoc.pdf'
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/docs/ESMF_usrdoc.pdf' 'ESMF_usrdoc.pdf'
 
-	#Download from ISSM server
-	$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/esmf_5_2_0rp2_src.tar.gz' 'esmf_5_2_0rp2_src.tar.gz'
+#Untar 
+tar -zxvf  esmf_5_2_0rp2_src.tar.gz
 
-	#Untar 
-	tar -zxvf  esmf_5_2_0rp2_src.tar.gz
 
+#Configure esmf
+cd esmf
 
-	#Configure esmf
-	cd esmf
-
-
-
-	#Compile and install esmf
-	if [ $# -eq 0 ]; then
-		make
-		make install
-	else
-		make -j $1
-		make -j $1 install
-	fi
+#Compile and install esmf
+if [ $# -eq 0 ]; then
+	make
+	make install
+else
+	make -j $1
+	make -j $1 install
 fi
 
-if [[ $install == "2" ]]; then
-	cd esmf
-	if [ $# -eq 0 ]; then
-		make all_tests
-	else
-		make -j $1 all_tests
-	fi
+cd esmf
+if [ $# -eq 0 ]; then
+	make all_tests
+else
+	make -j $1 all_tests
 fi


Property changes on: issm/trunk/externalpackages/export_fig
___________________________________________________________________
Added: svn:ignore
   + .ignore


Modified: issm/trunk/externalpackages/git/install.sh
===================================================================
--- issm/trunk/externalpackages/git/install.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/git/install.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,7 +17,8 @@
 
 #install
 cd src 
-./configure  --prefix="$ISSM_DIR/externalpackages/git/install" --with-python="$ISSM_DIR/externalpackages/python/install/bin/python"
+./configure  --prefix="$ISSM_DIR/externalpackages/git/install"
+#--with-python="$ISSM_DIR/externalpackages/python/install/bin/python" #Do we really need this line?
 	
 #Compile
 make install


Property changes on: issm/trunk/externalpackages/gmake
___________________________________________________________________
Modified: svn:ignore
   - install
src

   + *.gz
install
src



Property changes on: issm/trunk/externalpackages/gmp
___________________________________________________________________
Added: svn:ignore
   + install
src
*.bz2
*.tar



Property changes on: issm/trunk/externalpackages/gsl
___________________________________________________________________
Modified: svn:ignore
   - *.gz
install
src

   + install-macosx*
*.gz
install
src


Modified: issm/trunk/externalpackages/gsl/install-android.sh
===================================================================
--- issm/trunk/externalpackages/gsl/install-android.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/gsl/install-android.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -23,8 +23,10 @@
 #Configure gsl
 if [[ $step == "2" || $step == "0" ]]; then
     cd src
+
+    patch Makefile.am < Makefile.am.patch
     
-    autoreconf -iv --force -I $LIBTOOL_DIR/share/aclocal/ 
+    autoreconf -iv --force -I $ISSM_DIR/externalpackages/autotools/install/share/aclocal
 
     ./configure \
         --build="i386-apple-darwin10.8.0" \
@@ -35,6 +37,7 @@
 
 #Compile gsl
 if [[ $step == "3" || $step == "0" ]]; then
+	cd src
     if [ $# -eq 0 ]; then
 	    make $j 
     else
@@ -43,3 +46,4 @@
 
     make install
 fi
+

Modified: issm/trunk/externalpackages/hdf5/install.sh
===================================================================
--- issm/trunk/externalpackages/hdf5/install.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/hdf5/install.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,7 +21,8 @@
 ./configure  --prefix="$ISSM_DIR/externalpackages/hdf5/install" 
 if [ $# -eq 0 ]; then
 	make
+	make install
 else
 	make -j $1
+	make -j $1 install
 fi
-make install

Modified: issm/trunk/externalpackages/mpich2/install-1.0.2-altix64.sh
===================================================================
--- issm/trunk/externalpackages/mpich2/install-1.0.2-altix64.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/mpich2/install-1.0.2-altix64.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -29,12 +29,8 @@
 patch -R ./src/binding/cxx/mpicxx.h ../configs/1.0.2/altix64/mpicxx.h.patch
 patch -R ./src/include/mpicxx.h ../configs/1.0.2/altix64/mpicxx.h.patch
 
-#Compile mpich2
-if [ $# -eq 0 ]; then
-	make
-else
-	make -j $1
-fi
+#Compile mpich2 (parallel make not supported)
+make
 make install 
 
 #remove so files

Modified: issm/trunk/externalpackages/mpich2/install-1.0.2-linux64.sh
===================================================================
--- issm/trunk/externalpackages/mpich2/install-1.0.2-linux64.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/mpich2/install-1.0.2-linux64.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -29,10 +29,6 @@
 patch -R ./src/binding/cxx/mpicxx.h ../configs/1.0.2/linux64/mpicxx.h.patch
 patch -R ./src/include/mpicxx.h ../configs/1.0.2/linux64/mpicxx.h.patch
 
-#Compile mpich2
-if [ $# -eq 0 ]; then
-	make
-else
-	make -j $1
-fi
+#Compile mpich2 (parallel make not supported)
+make
 make install 

Modified: issm/trunk/externalpackages/mpich2/install-1.0.2-macosx32.sh
===================================================================
--- issm/trunk/externalpackages/mpich2/install-1.0.2-macosx32.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/mpich2/install-1.0.2-macosx32.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,12 +28,8 @@
 patch -R ./src/binding/cxx/mpicxx.h ../configs/1.0.2/macosx32/mpicxx.h.patch
 patch -R ./src/include/mpicxx.h ../configs/1.0.2/macosx32/mpicxx.h.patch
 
-#Compile mpich2
-if [ $# -eq 0 ]; then
-	make
-else
-	make -j $1
-fi
+#Compile mpich2 (parallel make not supported)
+make
 make install 
 
 #remove so files

Modified: issm/trunk/externalpackages/mpich2/install-1.0.2-win32.sh
===================================================================
--- issm/trunk/externalpackages/mpich2/install-1.0.2-win32.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/mpich2/install-1.0.2-win32.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -26,12 +26,8 @@
 patch -R ./src/binding/cxx/mpicxx.h ../configs/1.0.2/win32/mpicxx.h.patch
 patch -R ./src/include/mpicxx.h ../configs/1.0.2/win32/mpicxx.h.patch
 
-#Compile mpich2
-if [ $# -eq 0 ]; then
-	make
-else
-	make -j $1
-fi
+#Compile mpich2 (parallel make not supported)
+make
 make install 
 
 #remove so files

Modified: issm/trunk/externalpackages/mpich2/install-1.3.1-linux64-berg.sh
===================================================================
--- issm/trunk/externalpackages/mpich2/install-1.3.1-linux64-berg.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/mpich2/install-1.3.1-linux64-berg.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -35,14 +35,6 @@
 	patch -R ./src/include/mpicxx.h ../mpicxx.h.patch
 fi
 
-#Compile mpich2
-if [ $# -eq 0 ];
-then
-	make
-else
-	make -j $1
-fi
+#Compile mpich2 (parallel make not supported)
+make
 make install 
-
-cd ../install/lib
-rm -rf *.so

Modified: issm/trunk/externalpackages/mpich2/install-1.4-linux64.sh
===================================================================
--- issm/trunk/externalpackages/mpich2/install-1.4-linux64.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/mpich2/install-1.4-linux64.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,10 +25,6 @@
 	--enable-sharedlibs=gcc \
 	--enable-f91=gfortran 
 
-#Compile mpich2
-if [ $# -eq 0 ]; then
-	make
-else
-	make -j $1
-fi
+#Compile mpich2 (parallel make not supported)
+make
 make install 

Modified: issm/trunk/externalpackages/mpich2/install-1.4-macosx32.sh
===================================================================
--- issm/trunk/externalpackages/mpich2/install-1.4-macosx32.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/mpich2/install-1.4-macosx32.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -27,10 +27,6 @@
 	--enable-shared \
 	--enable-fc
 
-#Compile mpich2
-if [ $# -eq 0 ]; then
-	make
-else
-	make -j $1
-fi
+#Compile mpich2 (parallel make not supported)
+make
 make install 

Modified: issm/trunk/externalpackages/mpich2/install-1.4-macosx64.sh
===================================================================
--- issm/trunk/externalpackages/mpich2/install-1.4-macosx64.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/mpich2/install-1.4-macosx64.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -27,10 +27,6 @@
 	--enable-shared \
 	--enable-fc
 
-#Compile mpich2
-if [ $# -eq 0 ]; then
-	make
-else
-	make -j $1
-fi
+#Compile mpich2 (parallel make not supported)
+make
 make install 

Modified: issm/trunk/externalpackages/numpy/install-linux64.sh
===================================================================
--- issm/trunk/externalpackages/numpy/install-linux64.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/numpy/install-linux64.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,13 +9,16 @@
 
 #clean up
 rm -rf numpy
+rm -rf numpy-1.7.0b2
 
 #download numpy first
-export GIT_SSL_NO_VERIFY=true 
-git clone https://github.com/numpy/numpy.git
+#export GIT_SSL_NO_VERIFY=true 
+#git clone https://github.com/numpy/numpy.git
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/numpy-1.7.0b2.tar.gz' 'numpy-1.7.0b2.tar.gz'
 
 #install numpy
-cd numpy
+tar -zxvf numpy-1.7.0b2.tar.gz
+cd numpy-1.7.0b2
 python setup.py build
 python setup.py install
 cd ..

Modified: issm/trunk/externalpackages/numpy/install-macosx-lion.sh
===================================================================
--- issm/trunk/externalpackages/numpy/install-macosx-lion.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/numpy/install-macosx-lion.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,10 +5,20 @@
 export CXX=g++
 export FFLAGS=-ff2c
 
+#clean up
+rm -rf numpy
+rm -rf numpy-1.7.0b2
+
 #download numpy first
-git clone https://github.com/numpy/numpy.git
+#export GIT_SSL_NO_VERIFY=true 
+#git clone https://github.com/numpy/numpy.git
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/numpy-1.7.0b2.tar.gz' 'numpy-1.7.0b2.tar.gz'
 
 #install numpy
-cd numpy
+tar -zxvf numpy-1.7.0b2.tar.gz
+cd numpy-1.7.0b2
 python setup.py build
 python setup.py install
+cd ..
+python -c "import numpy; print 'Installed NumPy', numpy.__version__"
+python -c "import numpy; numpy.test()"


Property changes on: issm/trunk/externalpackages/petsc
___________________________________________________________________
Modified: svn:ignore
   - *.tgz
*.gz
install
install-3.1
src

   + install-3.2
install-dev
*.tgz
*.gz
install
install-3.1
src


Modified: issm/trunk/externalpackages/petsc/install-3.2-greenplanet.sh
===================================================================
--- issm/trunk/externalpackages/petsc/install-3.2-greenplanet.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/petsc/install-3.2-greenplanet.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,7 +21,7 @@
 	--PETSC_ARCH="$ISSM_ARCH" \
 	--with-batch=1 \
 	--with-debugging=0 \
-	--with-shared-libraries=0 \
+	--with-shared-libraries=1 \
 	--known-mpi-shared-libraries=1 \
 	--with-mpi-dir=/sopt/mpi/openmpi-1.5.4_psm/intel/ \
 	--with-blas-lapack-dir=/opt/intel/mkl/10.2.4.032/ \

Modified: issm/trunk/externalpackages/petsc/install-dev-linux64.sh
===================================================================
--- issm/trunk/externalpackages/petsc/install-dev-linux64.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/petsc/install-dev-linux64.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,4 @@
 #!/bin/bash
-set -eu
 
 STEP=2
 
@@ -18,11 +17,14 @@
 #      cd config/BuildSystem
 #      hg pull -u
 
-
 # configure script
-# Note: using metis from externalpackages did not work...
-#       -for now download new metis
-#       -rename metis in externalpackages to metis2
+# Note: 
+#  Metis: -using metis from externalpackages did not work...
+#         -for now download new metis
+#         -rename metis in externalpackages to metis2
+#
+# SuperLU: -If download-..-=yes does not work try downloading from
+#    --download-superlu=http://crd.lbl.gov/~xiaoye/SuperLU/superlu_4.3.tar.gz \
 
 
 if [ $STEP -eq 2 ]; then
@@ -37,7 +39,6 @@
 	--with-debugging=0 \
 	--with-shared-libraries=1 \
 	--download-mumps=yes \
-	--download-plapack=yes \
 	--download-scalapack=yes \
 	--download-blacs=yes  \
 	--download-blas=yes \
@@ -46,14 +47,12 @@
 	--download-metis=yes \
 	--download-trilinos=yes \
 	--download-euclid=yes \
-	--download-pastix=yes \
-	--download-ptscotch=yes \
 	--download-spooles=yes \
 	--download-spai=yes \
-	--download-superlu=yes \
+	--download-superlu=http://crd.lbl.gov/~xiaoye/SuperLU/superlu_4.3.tar.gz \
 	--download-hypre=yes \
-	--download-prometheus=yes \
-	--with-pic=1
+	--download-c2html=yes
+#	--with-pic=1
 
 	#Compile petsc and install it
 	make

Modified: issm/trunk/externalpackages/petsc/install-dev-pleiades.sh
===================================================================
--- issm/trunk/externalpackages/petsc/install-dev-pleiades.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/petsc/install-dev-pleiades.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,8 +1,7 @@
 #!/bin/bash
-set -eu
 #Step 0: download
 #Step 1: install and write script
-STEP=0
+STEP=1
 
 if [ $STEP -eq 0 ]; then
 	# Adapted from petsc 3.2. 
@@ -23,10 +22,13 @@
 # Note: using metis from externalpackages did not work...
 # for now downloading new metis
 #   -then rename metis in externalpackages to metis2
+#
+#		--download-prometheus=yes \
+#--download-superlu=http://crd.lbl.gov/~xiaoye/SuperLU/superlu_4.3.tar.gz \
+#		--download-plapack=yes \
+
 if [ $STEP -eq 1 ]; then
 
-	mkdir install
-
 	#configure
 	cd src
 	./config/configure.py \
@@ -35,13 +37,11 @@
 		--PETSC_ARCH="$ISSM_ARCH" \
 		--PETSC_DIR="$ISSM_DIR/externalpackages/petsc/src" \
 		--with-debugging=0 \
-		--with-shared-libraries=0 \
+		--with-shared-libraries=1 \
 		--with-blas-lapack-dir=/nasa/intel/mkl/10.0.011/ \
 		--known-mpi-shared-libraries=1 \
-		--with-mpi-lib=/nasa/sgi/mpt/2.04/lib/libmpi.so \
-		--with-mpi-include=/nasa/sgi/mpt/2.04/include  \
+		--with-mpi=1 \
 		--download-mumps=yes \
-		--download-plapack=yes \
 		--download-scalapack=yes \
 		--download-blacs=yes  \
 		--download-blas=yes \
@@ -50,35 +50,29 @@
 		--download-metis=yes \
 		--download-trilinos=yes \
 		--download-euclid=yes \
-		--download-pastix=yes \
-		--download-ptscotch=yes \
-		--download-spooles=yes \
 		--download-spai=yes \
-		--download-superlu=yes \
+		--download-superlu=http://crd.lbl.gov/~xiaoye/SuperLU/superlu_4.3.tar.gz \
 		--download-hypre=yes \
-		--download-prometheus=yes \
-		--FFLAGS=-I/usr/include \
-		--with-cxx=icpc \
-		--with-cc=icc \
-		--with-fc=ifort \
-		--COPTFLAGS=" -O3 -xS" \
-		--FOPTFLAGS=" -O3 -xS" \
-		--CXXOPTFLAGS=" -O3 -xS" \
-		--with-pic=1
+		--with-cxx=/nasa/sgi/mpt/2.06a67/bin/mpicxx \
+		--with-fc=/nasa/sgi/mpt/2.06a67/bin/mpif90 \
+		--COPTFLAGS="-lmpi -O3" \
+		--FOPTFLAGS="-lmpi -O3" \
+		--CXXOPTFLAGS="-lmpi -O3" 
 		cat > script.queue << EOF
 #PBS -S /bin/bash
-#PBS -q debug 
-#PBS -l select=1:ncpus=1:model=har 
+#PBS -l select=1:ncpus=1:model=wes 
 #PBS -l walltime=200 
 #PBS -W group_list=s1010 
 #PBS -m e 
 . /usr/share/modules/init/bash 
-module load comp-intel/11.1.046 
-module load mpi-sgi/mpt.2.04  #DEFINES MPI_Type_create_indexed_block
+module load comp-intel/2012.0.032 
+module load mpi-sgi/mpt.2.06a67  
 module load math/intel_mkl_64_10.0.011 
 export PATH="$PATH:." 
 export MPI_GROUP_MAX=64 
 mpiexec -np 1 ./conftest-linux-gnu-ia64-intel.py
 EOF
-	echo "== Follow PETSc's instructions"
+	echo "== Now: cd src/ "
+	echo "== qsub -q devel script.queue "
+	echo "== Then run reconfigure script generated by PETSc and follow instructions"
 fi

Modified: issm/trunk/externalpackages/readline/install.sh
===================================================================
--- issm/trunk/externalpackages/readline/install.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/readline/install.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,6 +16,6 @@
 mv readline-6.2.2/* src
 rm -rf readline-6.2.2
 
-$install
+#install
 cd src
 python setup.py install

Modified: issm/trunk/externalpackages/scotch/install.sh
===================================================================
--- issm/trunk/externalpackages/scotch/install.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/scotch/install.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,6 +11,8 @@
 
 #Download from ISSM server
 $ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/scotch_5.1.6.tar.gz' 'scotch_5.1.6.tar.gz'
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/docs/ptscotch_user5.1.pdf' 'ptscotch_user5.1.pdf'
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/docs/scotch_user5.1.pdf' 'scotch_user5.1.pdf'
 
 # Untar 
 tar -xvzf scotch_5.1.6.tar.gz

Modified: issm/trunk/externalpackages/shapelib/install.sh
===================================================================
--- issm/trunk/externalpackages/shapelib/install.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/shapelib/install.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,7 +9,8 @@
 
 #Download from ISSM server
 $ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/shapelib-1.2.10.tar.gz' 'shapelib-1.2.10.tar.gz'
-$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/shape_eg_data.zip' 'shape_eg_data.zip'
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/shape_eg_data.zip'  'shape_eg_data.zip'
+$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/docs/shapefile.pdf' 'shapefile.pdf'
 
 # Untar 
 tar -xvzf shapelib-1.2.10.tar.gz


Property changes on: issm/trunk/externalpackages/starcluster
___________________________________________________________________
Added: svn:ignore
   + StarCluster


Modified: issm/trunk/externalpackages/vim/addons/vim/colors/issm_black.vim
===================================================================
--- issm/trunk/externalpackages/vim/addons/vim/colors/issm_black.vim	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/vim/addons/vim/colors/issm_black.vim	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,227 +1,86 @@
-" ir_black color scheme
-" More at: http://blog.infinitered.com/entries/show/8
+" issm_black color scheme
+" table http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html
 
-
-" ********************************************************************************
-" Standard colors used in all ir_black themes:
-" Note, x:x:x are RGB values
-"
-"  normal: #f6f3e8
-" 
-"  string: #A8FF60  168:255:96                   
-"    string inner (punc, code, etc): #00A0A0  0:160:160
-"  number: #FF73FD  255:115:253                 
-"  comments: #7C7C7C  124:124:124
-"  keywords: #96CBFE  150:203:254             
-"  operators: white
-"  class: #FFFFB6  255:255:182
-"  method declaration name: #FFD2A7  255:210:167
-"  regular expression: #E9C062  233:192:98
-"    regexp alternate: #FF8000  255:128:0
-"    regexp alternate 2: #B18A3D  177:138:61
-"  variable: #C6C5FE  198:197:254
-"  
-" Misc colors:
-"  red color (used for whatever): #FF6C60   255:108:96 
-"     light red: #FFB6B0   255:182:176
-"
-"  brown: #E18964  good for special
-"
-"  lightpurpleish: #FFCCFF
-" 
-" Interface colors:
-"  background color: black
-"  cursor (where underscore is used): #FFA560  255:165:96
-"  cursor (where block is used): white
-"  visual selection: #1D1E2C  
-"  current line: #151515  21:21:21
-"  search selection: #07281C  7:40:28
-"  line number: #3D3D3D  61:61:61
-
-
-" ********************************************************************************
-" The following are the preferred 16 colors for your terminal
-"           Colors      Bright Colors
-" Black     #4E4E4E     #7C7C7C
-" Red       #FF6C60     #FFB6B0
-" Green     #A8FF60     #CEFFAB
-" Yellow    #FFFFB6     #FFFFCB
-" Blue      #96CBFE     #FFFFCB
-" Magenta   #FF73FD     #FF9CFE
-" Cyan      #C6C5FE     #DFDFFE
-" White     #EEEEEE     #FFFFFF
-
-
-" ********************************************************************************
+"Set up coloring
 hi clear
-
 if exists("syntax_on")
   syntax reset
 endif
 syntax on
-
 let colors_name = "issm_black"
 
-"                   GUI not used in terminal mode                     forground           background          style (reverse,bold,..)
-"hi Example         guifg=NONE        guibg=NONE        gui=NONE      ctermfg=NONE        ctermbg=NONE        cterm=NONE
+"preferred colors:
+"  0  : black
+"  9  : red
+" 15  : white
+" 69  : blue
+" 87  : cyan
+" 129 : dark purple
+" 202 : orange
+" 214 : light orange
+" 227 : yellow
+" 234 : very dark gray
+" 241 : dark gray
+" 244 : gray
+" 255 : light gray
 
+"                forground    background   style (reverse,bold,..)
 " General colors
-hi Normal           guifg=#f6f3e8     guibg=black       gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=NONE
-hi NonText          guifg=#070707     guibg=black       gui=NONE      ctermfg=129        ctermbg=NONE        cterm=NONE         "214 =orange
+hi Normal        ctermfg=NONE ctermbg=NONE cterm=NONE
+hi NonText       ctermfg=129  ctermbg=NONE cterm=NONE
+hi Cursor        ctermfg=NONE ctermbg=NONE cterm=reverse
+hi LineNr        ctermfg=15   ctermbg=241  cterm=NONE
+hi VertSplit     ctermfg=241  ctermbg=241  cterm=NONE
+hi StatusLine    ctermfg=241  ctermbg=87   cterm=NONE
+hi StatusLineNC  ctermfg=87   ctermbg=241  cterm=NONE
+hi Folded        ctermfg=141  ctermbg=236  cterm=NONE
+hi Title         ctermfg=NONE ctermbg=NONE cterm=NONE
+hi Visual        ctermfg=NONE ctermbg=NONE cterm=reverse
+hi SpecialKey    ctermfg=NONE ctermbg=NONE cterm=NONE
+hi WildMenu      ctermfg=0    ctermbg=227  cterm=NONE
+hi PmenuSbar     ctermfg=0    ctermbg=129  cterm=NONE
+hi Error         ctermfg=15   ctermbg=129  cterm=NONE
+hi ErrorMsg      ctermfg=15   ctermbg=129  cterm=NONE
+hi WarningMsg    ctermfg=15   ctermbg=129  cterm=NONE
 
-hi Cursor           guifg=black       guibg=white       gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=reverse      "cursor (mouse)
-hi LineNr           guifg=#3D3D3D     guibg=black       gui=NONE      ctermfg=249        ctermbg=232         cterm=NONE         "line numbering gray/blak 
-
-hi VertSplit        guifg=#202020     guibg=#202020     gui=NONE      ctermfg=241        ctermbg=241         cterm=NONE         "vertical split
-hi StatusLine       guifg=#CCCCCC     guibg=#202020     gui=italic    ctermfg=241        ctermbg=87          cterm=NONE         "87 = cyan
-hi StatusLineNC     guifg=black       guibg=#202020     gui=NONE      ctermfg=87         ctermbg=241         cterm=NONE         "241 = dark gray
-
-hi Folded           guifg=#a0a8b0     guibg=#384048     gui=NONE      ctermfg=135        ctermbg=234         cterm=NONE         "folded 129 = violet ,234 Gray
-hi Title            guifg=#f6f3e8     guibg=NONE        gui=bold      ctermfg=NONE       ctermbg=NONE        cterm=NONE
-hi Visual           guifg=NONE        guibg=#262D51     gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=reverse "visual 255 = white
-
-hi SpecialKey       guifg=#808080     guibg=#343434     gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=NONE
-
-hi WildMenu         guifg=green       guibg=yellow      gui=NONE      ctermfg=black      ctermbg=yellow      cterm=NONE          "?????
-hi PmenuSbar        guifg=black       guibg=white       gui=NONE      ctermfg=black      ctermbg=magenta     cterm=NONE          "????
-"hi Ignore           guifg=gray        guibg=black       gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=NONE
-
-hi Error            guifg=white        guibg=NONE        gui=none ctermfg=255      ctermbg=129         cterm=NONE
-hi ErrorMsg         guifg=white       guibg=#FF6C60     gui=BOLD      ctermfg=255      ctermbg=129         cterm=NONE                   " 196 = red
-hi WarningMsg       guifg=white       guibg=#FF6C60     gui=BOLD      ctermfg=255      ctermbg=201         cterm=NONE                   "201 = magenta
-
 " Message displayed in lower left, such as --INSERT--
-hi ModeMsg          guifg=black       guibg=#C6C5FE     gui=BOLD      ctermfg=241      ctermbg=87        cterm=BOLD
-
+hi ModeMsg       ctermfg=0  ctermbg=87   cterm=BOLD
 if version >= 700 " Vim 7.x specific colors
-  hi CursorLine     guifg=NONE        guibg=#121212     gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=BOLD
-  hi CursorColumn   guifg=NONE        guibg=#121212     gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=BOLD
-  hi MatchParen     guifg=#f6f3e8     guibg=#857b6f     gui=BOLD      ctermfg=87         ctermbg=241         cterm=BOLD,reverse  "matching parenthesis
-  hi Pmenu          guifg=#f6f3e8     guibg=#444444     gui=NONE      ctermfg=black      ctermbg=white         cterm=NONE "auto completion panel
-  hi PmenuSel       guifg=#000000     guibg=#cae682     gui=NONE      ctermfg=255        ctermbg=darkgray    cterm=NONE
-  hi Search         guifg=NONE        guibg=NONE        gui=underline ctermfg=black      ctermbg=220         cterm=NONE  "227 = yellow
+  hi CursorLine   ctermfg=NONE ctermbg=NONE cterm=BOLD
+  hi CursorColumn ctermfg=NONE ctermbg=NONE cterm=BOLD
+  hi MatchParen   ctermfg=87   ctermbg=241  cterm=reverse "matching parenthesis
+  hi Pmenu        ctermfg=0    ctermbg=15   cterm=NONE    "auto completion panel
+  hi PmenuSel     ctermfg=255  ctermbg=241  cterm=NONE
+  hi Search       ctermfg=0    ctermbg=220  cterm=NONE
 endif
 
 " Syntax highlighting
-hi Comment          guifg=#7C7C7C     guibg=NONE        gui=NONE      ctermfg=243         ctermbg=NONE        cterm=NONE
-hi String           guifg=#A8FF60     guibg=NONE        gui=NONE      ctermfg=120         ctermbg=NONE        cterm=NONE
-hi Number           guifg=#FF73FD     guibg=NONE        gui=NONE      ctermfg=201         ctermbg=NONE        cterm=NONE
+hi Comment      ctermfg=244  ctermbg=NONE cterm=NONE
+hi String       ctermfg=120  ctermbg=NONE cterm=NONE
+hi Number       ctermfg=201  ctermbg=NONE cterm=NONE
+hi Keyword      ctermfg=9    ctermbg=NONE cterm=NONE  " matlab function
+hi PreProc      ctermfg=9    ctermbg=NONE cterm=NONE  " def undef include
+hi Conditional  ctermfg=220  ctermbg=NONE cterm=NONE  " if else end
+hi Todo         ctermfg=214  ctermbg=NONE cterm=NONE
+hi Constant     ctermfg=196  ctermbg=NONE cterm=NONE
+hi Identifier   ctermfg=9    ctermbg=NONE cterm=NONE
+hi Function     ctermfg=69   ctermbg=NONE cterm=NONE "functions 69 = pastel blue
+hi Type         ctermfg=87   ctermbg=NONE cterm=NONE "cterm matlab global
+hi Statement    ctermfg=69   ctermbg=NONE cterm=NONE "cd ls sed mv
+hi Special      ctermfg=202  ctermbg=NONE cterm=NONE " matlab '...'
+hi Delimiter    ctermfg=NONE ctermbg=NONE cterm=NONE " [ ]
+hi Operator     ctermfg=202  ctermbg=NONE cterm=NONE " == &
+hi Directory    ctermfg=87   ctermbg=NONE cterm=NONE " == & 
 
-hi Keyword          guifg=#96CBFE     guibg=NONE        gui=NONE      ctermfg=red         ctermbg=NONE        cterm=NONE  " matlab function
-hi PreProc          guifg=#96CBFE     guibg=NONE        gui=NONE      ctermfg=red         ctermbg=NONE        cterm=NONE   " def undef include
-hi Conditional      guifg=#6699CC     guibg=NONE        gui=NONE      ctermfg=220         ctermbg=NONE        cterm=NONE  " if else end
-
-hi Todo             guifg=#8f8f8f     guibg=NONE        gui=NONE      ctermfg=214          ctermbg=NONE        cterm=NONE
-hi Constant         guifg=#99CC99     guibg=NONE        gui=NONE      ctermfg=196         ctermbg=NONE        cterm=NONE
-
-hi Identifier       guifg=#C6C5FE     guibg=NONE        gui=NONE      ctermfg=red         ctermbg=NONE        cterm=NONE
-hi Function         guifg=#FFD2A7     guibg=NONE        gui=NONE      ctermfg=69          ctermbg=NONE        cterm=NONE "functions 69 = pastel blue
-hi Type             guifg=#FFFFB6     guibg=NONE        gui=NONE      ctermfg=87         ctermbg=NONE        cterm=NONE "cterm matlab global
-hi Statement        guifg=#6699CC     guibg=NONE        gui=NONE      ctermfg=69          ctermbg=NONE        cterm=NONE " cd ls sed mv
-
-hi Special          guifg=#E18964     guibg=NONE        gui=NONE      ctermfg=202         ctermbg=NONE        cterm=NONE  " ; 202  = orange 
-hi Delimiter        guifg=#00A0A0     guibg=NONE        gui=NONE      ctermfg=NONE        ctermbg=NONE        cterm=NONE  " [ ]
-hi Operator         guifg=white       guibg=NONE        gui=NONE      ctermfg=202         ctermbg=NONE        cterm=NONE  " == &  178 = darkyellow
-
-hi Directory        guifg=white       guibg=NONE        gui=NONE      ctermfg=87          ctermbg=NONE        cterm=NONE  " == &  178 = darkyellow
-
- "Specific for diff
- hi DiffAdd      guifg=#ffff33 guibg=#404010 gui=bold term=none cterm=none ctermfg=black ctermbg=119
- hi DiffChange                 guibg=#202020 gui=bold term=none cterm=none ctermfg=black ctermbg=228
- hi DiffText     guifg=#3333ff guibg=#100040 gui=bold term=none cterm=none ctermfg=black ctermbg=178
- hi DiffDelete   guifg=#ff0000 guibg=#401010 gui=bold term=none cterm=none ctermfg=black ctermbg=197
- hi diffLine     guifg=#444444 guibg=bg gui=bold term=none cterm=bold ctermfg=darkgrey
- hi diffOldLine  guifg=#444444 guibg=bg gui=none term=none cterm=none ctermfg=darkgrey
- hi diffOldFile  guifg=#444444 guibg=bg gui=none term=none cterm=none ctermfg=darkgrey
- hi diffNewFile  guifg=#444444 guibg=bg gui=none term=none cterm=none ctermfg=darkgrey
- hi diffAdded    guifg=#80ff80 guibg=bg gui=none term=none cterm=none
- hi diffRemoved  guifg=#ff0000 guibg=bg gui=none term=none cterm=none ctermfg=red
- hi diffChanged  guifg=#0000ff guibg=bg gui=none term=none cterm=none ctermfg=blue
-
-hi link Character       Constant
-hi link Boolean         Constant
-hi link Float           Number
-hi link Repeat          Statement
-hi link Label           Statement
-hi link Exception       Statement
-hi link Include         PreProc
-hi link Define          PreProc
-hi link Macro           PreProc
-hi link PreCondit       PreProc
-hi link StorageClass    Type
-hi link Structure       Type
-hi link Typedef         Type
-hi link Tag             Special
-hi link SpecialChar     Special
-hi link SpecialComment  Special
-hi link Debug           Special
-
-
-" Special for Ruby
-hi rubyRegexp                  guifg=#B18A3D      guibg=NONE      gui=NONE      ctermfg=brown          ctermbg=NONE      cterm=NONE
-hi rubyRegexpDelimiter         guifg=#FF8000      guibg=NONE      gui=NONE      ctermfg=brown          ctermbg=NONE      cterm=NONE
-hi rubyEscape                  guifg=white        guibg=NONE      gui=NONE      ctermfg=cyan           ctermbg=NONE      cterm=NONE
-hi rubyInterpolationDelimiter  guifg=#00A0A0      guibg=NONE      gui=NONE      ctermfg=blue           ctermbg=NONE      cterm=NONE
-hi rubyControl                 guifg=#6699CC      guibg=NONE      gui=NONE      ctermfg=blue           ctermbg=NONE      cterm=NONE  "and break, etc
-"hi rubyGlobalVariable          guifg=#FFCCFF      guibg=NONE      gui=NONE      ctermfg=lightblue      ctermbg=NONE      cterm=NONE  "yield
-hi rubyStringDelimiter         guifg=#336633      guibg=NONE      gui=NONE      ctermfg=lightgreen     ctermbg=NONE      cterm=NONE
-"rubyInclude
-"rubySharpBang
-"rubyAccess
-"rubyPredefinedVariable
-"rubyBoolean
-"rubyClassVariable
-"rubyBeginEnd
-"rubyRepeatModifier
-"hi link rubyArrayDelimiter    Special  " [ , , ]
-"rubyCurlyBlock  { , , }
-
-hi link rubyClass             Keyword 
-hi link rubyModule            Keyword 
-hi link rubyKeyword           Keyword 
-hi link rubyOperator          Operator
-hi link rubyIdentifier        Identifier
-hi link rubyInstanceVariable  Identifier
-hi link rubyGlobalVariable    Identifier
-hi link rubyClassVariable     Identifier
-hi link rubyConstant          Type  
-
-
-" Special for Java
-" hi link javaClassDecl    Type
-hi link javaScopeDecl         Identifier 
-hi link javaCommentTitle      javaDocSeeTag 
-hi link javaDocTags           javaDocSeeTag 
-hi link javaDocParam          javaDocSeeTag 
-hi link javaDocSeeTagParam    javaDocSeeTag 
-
-hi javaDocSeeTag              guifg=#CCCCCC     guibg=NONE        gui=NONE      ctermfg=darkgray    ctermbg=NONE        cterm=NONE
-hi javaDocSeeTag              guifg=#CCCCCC     guibg=NONE        gui=NONE      ctermfg=darkgray    ctermbg=NONE        cterm=NONE
-"hi javaClassDecl              guifg=#CCFFCC     guibg=NONE        gui=NONE      ctermfg=white       ctermbg=NONE        cterm=NONE
-
-
-" Special for XML
-hi link xmlTag          Keyword 
-hi link xmlTagName      Conditional 
-hi link xmlEndTag       Identifier 
-
-
-" Special for HTML
-hi link htmlTag         Keyword 
-hi link htmlTagName     Conditional 
-hi link htmlEndTag      Identifier 
-
-
-" Special for Javascript
-hi link javaScriptNumber      Number 
-
-
-" Special for Python
-"hi  link pythonEscape         Keyword      
-
-
-" Special for CSharp
-hi  link csXmlTag             Keyword      
-
-
-" Special for PHP
+"Specific for diff
+hi DiffAdd      cterm=none ctermfg=0 ctermbg=119
+hi DiffChange   cterm=none ctermfg=0 ctermbg=228
+hi DiffText     cterm=none ctermfg=0 ctermbg=178
+hi DiffDelete   cterm=none ctermfg=0 ctermbg=197
+hi diffLine     cterm=bold ctermfg=241
+hi diffOldLine  cterm=none ctermfg=241
+hi diffOldFile  cterm=none ctermfg=241
+hi diffNewFile  cterm=none ctermfg=241
+hi diffAdded    cterm=none
+hi diffRemoved  cterm=none ctermfg=9
+hi diffChanged  cterm=none ctermfg=69

Modified: issm/trunk/externalpackages/vim/addons/vim/colors/issm_white.vim
===================================================================
--- issm/trunk/externalpackages/vim/addons/vim/colors/issm_white.vim	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/vim/addons/vim/colors/issm_white.vim	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,212 +1,86 @@
-" ir_black color scheme
-" More at: http://blog.infinitered.com/entries/show/8
+" issm_white scheme
+" table http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html
 
-
-" ********************************************************************************
-" Standard colors used in all ir_black themes:
-" Note, x:x:x are RGB values
-"
-"  normal: #f6f3e8
-" 
-"  string: #A8FF60  168:255:96                   
-"    string inner (punc, code, etc): #00A0A0  0:160:160
-"  number: #FF73FD  255:115:253                 
-"  comments: #7C7C7C  124:124:124
-"  keywords: #96CBFE  150:203:254             
-"  operators: white
-"  class: #FFFFB6  255:255:182
-"  method declaration name: #FFD2A7  255:210:167
-"  regular expression: #E9C062  233:192:98
-"    regexp alternate: #FF8000  255:128:0
-"    regexp alternate 2: #B18A3D  177:138:61
-"  variable: #C6C5FE  198:197:254
-"  
-" Misc colors:
-"  red color (used for whatever): #FF6C60   255:108:96 
-"     light red: #FFB6B0   255:182:176
-"
-"  brown: #E18964  good for special
-"
-"  lightpurpleish: #FFCCFF
-" 
-" Interface colors:
-"  background color: black
-"  cursor (where underscore is used): #FFA560  255:165:96
-"  cursor (where block is used): white
-"  visual selection: #1D1E2C  
-"  current line: #151515  21:21:21
-"  search selection: #07281C  7:40:28
-"  line number: #3D3D3D  61:61:61
-
-
-" ********************************************************************************
-" The following are the preferred 16 colors for your terminal
-"           Colors      Bright Colors
-" Black     #4E4E4E     #7C7C7C
-" Red       #FF6C60     #FFB6B0
-" Green     #A8FF60     #CEFFAB
-" Yellow    #FFFFB6     #FFFFCB
-" Blue      #96CBFE     #FFFFCB
-" Magenta   #FF73FD     #FF9CFE
-" Cyan      #C6C5FE     #DFDFFE
-" White     #EEEEEE     #FFFFFF
-
-
-" ********************************************************************************
+"Set up coloring
 hi clear
-
 if exists("syntax_on")
   syntax reset
 endif
 syntax on
+let colors_name = "issm_black"
 
-let colors_name = "issm_white"
+"preferred colors:
+"  0  : black
+"  9  : red
+" 15  : white
+" 20  : blue
+" 33  : cyan
+" 129 : dark purple
+" 202 : orange
+" 204 : light orange
+" 227 : yellow
+" 234 : very dark gray
+" 241 : dark gray
+" 244 : gray
+" 255 : light gray
 
-"                   GUI not used in terminal mode                     forground           background          style (reverse,bold,..)
-"hi Example         guifg=NONE        guibg=NONE        gui=NONE      ctermfg=NONE        ctermbg=NONE        cterm=NONE
-
+"                forground    background   style (reverse,bold,..)
 " General colors
-hi Normal           guifg=#f6f3e8     guibg=black       gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=NONE
-hi NonText          guifg=#070707     guibg=black       gui=NONE      ctermfg=129        ctermbg=NONE        cterm=NONE         "214 =orange
+hi Normal        ctermfg=NONE ctermbg=NONE cterm=NONE
+hi NonText       ctermfg=129  ctermbg=NONE cterm=NONE
+hi Cursor        ctermfg=NONE ctermbg=NONE cterm=reverse
+hi LineNr        ctermfg=15   ctermbg=241  cterm=NONE
+hi VertSplit     ctermfg=241  ctermbg=241  cterm=NONE
+hi StatusLine    ctermfg=241  ctermbg=33   cterm=NONE
+hi StatusLineNC  ctermfg=33   ctermbg=241  cterm=NONE
+hi Folded        ctermfg=93   ctermbg=254  cterm=NONE
+hi Title         ctermfg=NONE ctermbg=NONE cterm=NONE
+hi Visual        ctermfg=NONE ctermbg=NONE cterm=reverse
+hi SpecialKey    ctermfg=NONE ctermbg=NONE cterm=NONE
+hi WildMenu      ctermfg=0    ctermbg=227  cterm=NONE
+hi PmenuSbar     ctermfg=0    ctermbg=129  cterm=NONE
+hi Error         ctermfg=15   ctermbg=129  cterm=NONE
+hi ErrorMsg      ctermfg=15   ctermbg=129  cterm=NONE
+hi WarningMsg    ctermfg=15   ctermbg=129  cterm=NONE
 
-hi Cursor           guifg=black       guibg=white       gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=reverse      "cursor (mouse)
-hi LineNr           guifg=#3D3D3D     guibg=black       gui=NONE      ctermfg=249        ctermbg=232         cterm=NONE         "line numbering gray/blak 
-
-hi VertSplit        guifg=#202020     guibg=#202020     gui=NONE      ctermfg=241        ctermbg=241         cterm=NONE         "vertical split
-hi StatusLine       guifg=#CCCCCC     guibg=#202020     gui=italic    ctermfg=241        ctermbg=87          cterm=NONE         "87 = cyan
-hi StatusLineNC     guifg=black       guibg=#202020     gui=NONE      ctermfg=87         ctermbg=241         cterm=NONE         "241 = dark gray
-
-hi Folded           guifg=#a0a8b0     guibg=#384048     gui=NONE      ctermfg=NONE       ctermbg=129         cterm=NONE         "folded 129 = violet
-hi Title            guifg=#f6f3e8     guibg=NONE        gui=bold      ctermfg=NONE       ctermbg=NONE        cterm=NONE
-hi Visual           guifg=NONE        guibg=#262D51     gui=NONE                         ctermbg=255         cterm=bold,reverse "visual 255 = white
-
-hi SpecialKey       guifg=#808080     guibg=#343434     gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=NONE
-
-hi WildMenu         guifg=green       guibg=yellow      gui=NONE      ctermfg=black      ctermbg=yellow      cterm=NONE          "?????
-hi PmenuSbar        guifg=black       guibg=white       gui=NONE      ctermfg=black      ctermbg=magenta     cterm=NONE          "????
-"hi Ignore           guifg=gray        guibg=black       gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=NONE
-
-hi Error            guifg=NONE        guibg=black       gui=NONE ctermfg=255      ctermbg=129         cterm=NONE
-hi ErrorMsg         guifg=white       guibg=#FF6C60     gui=BOLD      ctermfg=255      ctermbg=129         cterm=NONE                   " 196 = red
-hi WarningMsg       guifg=white       guibg=#FF6C60     gui=BOLD      ctermfg=255      ctermbg=201         cterm=NONE                   "201 = magenta
-
 " Message displayed in lower left, such as --INSERT--
-hi ModeMsg          guifg=black       guibg=#C6C5FE     gui=BOLD      ctermfg=241      ctermbg=87        cterm=BOLD
-
+hi ModeMsg       ctermfg=0  ctermbg=33   cterm=BOLD
 if version >= 700 " Vim 7.x specific colors
-  hi CursorLine     guifg=NONE        guibg=#121212     gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=BOLD
-  hi CursorColumn   guifg=NONE        guibg=#121212     gui=NONE      ctermfg=NONE       ctermbg=NONE        cterm=BOLD
-  hi MatchParen     guifg=#f6f3e8     guibg=#857b6f     gui=BOLD      ctermfg=87         ctermbg=241         cterm=BOLD,reverse  "matching parenthesis
-  hi Pmenu          guifg=#f6f3e8     guibg=#444444     gui=NONE      ctermfg=232        ctermbg=254         cterm=NONE "auto completion panel
-  hi PmenuSel       guifg=#000000     guibg=#cae682     gui=NONE      ctermfg=255        ctermbg=201        cterm=NONE
-  hi Search         guifg=NONE        guibg=NONE        gui=underline ctermfg=NONE       ctermbg=227         cterm=NONE  "227 = yellow
+  hi CursorLine   ctermfg=NONE ctermbg=NONE cterm=BOLD
+  hi CursorColumn ctermfg=NONE ctermbg=NONE cterm=BOLD
+  hi MatchParen   ctermfg=33   ctermbg=241  cterm=reverse "matching parenthesis
+  hi Pmenu        ctermfg=0    ctermbg=15   cterm=NONE    "auto completion panel
+  hi PmenuSel     ctermfg=255  ctermbg=241  cterm=NONE
+  hi Search       ctermfg=0    ctermbg=220  cterm=NONE
 endif
 
 " Syntax highlighting
-hi Comment          guifg=#7C7C7C     guibg=NONE        gui=NONE      ctermfg=243         ctermbg=NONE        cterm=NONE
-hi String           guifg=#A8FF60     guibg=NONE        gui=NONE      ctermfg=40          ctermbg=NONE        cterm=NONE
-hi Number           guifg=#FF73FD     guibg=NONE        gui=NONE      ctermfg=201         ctermbg=NONE        cterm=NONE
+hi Comment      ctermfg=241  ctermbg=NONE cterm=NONE
+hi String       ctermfg=28   ctermbg=NONE cterm=NONE
+hi Number       ctermfg=201  ctermbg=NONE cterm=NONE
+hi Keyword      ctermfg=9    ctermbg=NONE cterm=NONE  " matlab function
+hi PreProc      ctermfg=9    ctermbg=NONE cterm=NONE  " def undef include
+hi Conditional  ctermfg=220  ctermbg=NONE cterm=NONE  " if else end
+hi Todo         ctermfg=204  ctermbg=NONE cterm=NONE
+hi Constant     ctermfg=196  ctermbg=NONE cterm=NONE
+hi Identifier   ctermfg=9    ctermbg=NONE cterm=NONE
+hi Function     ctermfg=20   ctermbg=NONE cterm=NONE "functions 20 = pastel blue
+hi Type         ctermfg=33   ctermbg=NONE cterm=NONE "cterm matlab global
+hi Statement    ctermfg=20   ctermbg=NONE cterm=NONE "cd ls sed mv
+hi Special      ctermfg=202  ctermbg=NONE cterm=NONE " matlab '...'
+hi Delimiter    ctermfg=NONE ctermbg=NONE cterm=NONE " [ ]
+hi Operator     ctermfg=202  ctermbg=NONE cterm=NONE " == &
+hi Directory    ctermfg=33   ctermbg=NONE cterm=NONE " == & 
 
-hi Keyword          guifg=#96CBFE     guibg=NONE        gui=NONE      ctermfg=196          ctermbg=NONE        cterm=NONE  " matlab function
-hi PreProc          guifg=#96CBFE     guibg=NONE        gui=NONE      ctermfg=196         ctermbg=NONE        cterm=NONE   " def undef include
-hi Conditional      guifg=#6699CC     guibg=NONE        gui=NONE      ctermfg=93         ctermbg=NONE        cterm=NONE  " if else end
-
-hi Todo             guifg=#8f8f8f     guibg=NONE        gui=NONE      ctermfg=18         ctermbg=NONE        cterm=NONE
-hi Constant         guifg=#99CC99     guibg=NONE        gui=NONE      ctermfg=21         ctermbg=NONE        cterm=NONE
-
-hi Identifier       guifg=#C6C5FE     guibg=NONE        gui=NONE      ctermfg=21          ctermbg=NONE        cterm=NONE
-hi Function         guifg=#FFD2A7     guibg=NONE        gui=NONE      ctermfg=69          ctermbg=NONE        cterm=NONE "functions 69 = pastel blue
-hi Type             guifg=#FFFFB6     guibg=NONE        gui=NONE      ctermfg=165         ctermbg=NONE        cterm=NONE
-hi Statement        guifg=#6699CC     guibg=NONE        gui=NONE      ctermfg=69         ctermbg=NONE        cterm=NONE " cd ls sed mv
-
-hi Special          guifg=#E18964     guibg=NONE        gui=NONE      ctermfg=43          ctermbg=NONE        cterm=NONE  " ; 202  = orange 
-hi Delimiter        guifg=#00A0A0     guibg=NONE        gui=NONE      ctermfg=NONE        ctermbg=NONE        cterm=NONE  " [ ]
-hi Operator         guifg=white       guibg=NONE        gui=NONE      ctermfg=43          ctermbg=NONE        cterm=NONE  " == &  178 = darkyellow
-
-hi link Character       Constant
-hi link Boolean         Constant
-hi link Float           Number
-hi link Repeat          Statement
-hi link Label           Statement
-hi link Exception       Statement
-hi link Include         PreProc
-hi link Define          PreProc
-hi link Macro           PreProc
-hi link PreCondit       PreProc
-hi link StorageClass    Type
-hi link Structure       Type
-hi link Typedef         Type
-hi link Tag             Special
-hi link SpecialChar     Special
-hi link SpecialComment  Special
-hi link Debug           Special
-
-
-" Special for Ruby
-hi rubyRegexp                  guifg=#B18A3D      guibg=NONE      gui=NONE      ctermfg=brown          ctermbg=NONE      cterm=NONE
-hi rubyRegexpDelimiter         guifg=#FF8000      guibg=NONE      gui=NONE      ctermfg=brown          ctermbg=NONE      cterm=NONE
-hi rubyEscape                  guifg=white        guibg=NONE      gui=NONE      ctermfg=cyan           ctermbg=NONE      cterm=NONE
-hi rubyInterpolationDelimiter  guifg=#00A0A0      guibg=NONE      gui=NONE      ctermfg=blue           ctermbg=NONE      cterm=NONE
-hi rubyControl                 guifg=#6699CC      guibg=NONE      gui=NONE      ctermfg=blue           ctermbg=NONE      cterm=NONE  "and break, etc
-"hi rubyGlobalVariable          guifg=#FFCCFF      guibg=NONE      gui=NONE      ctermfg=lightblue      ctermbg=NONE      cterm=NONE  "yield
-hi rubyStringDelimiter         guifg=#336633      guibg=NONE      gui=NONE      ctermfg=lightgreen     ctermbg=NONE      cterm=NONE
-"rubyInclude
-"rubySharpBang
-"rubyAccess
-"rubyPredefinedVariable
-"rubyBoolean
-"rubyClassVariable
-"rubyBeginEnd
-"rubyRepeatModifier
-"hi link rubyArrayDelimiter    Special  " [ , , ]
-"rubyCurlyBlock  { , , }
-
-hi link rubyClass             Keyword 
-hi link rubyModule            Keyword 
-hi link rubyKeyword           Keyword 
-hi link rubyOperator          Operator
-hi link rubyIdentifier        Identifier
-hi link rubyInstanceVariable  Identifier
-hi link rubyGlobalVariable    Identifier
-hi link rubyClassVariable     Identifier
-hi link rubyConstant          Type  
-
-
-" Special for Java
-" hi link javaClassDecl    Type
-hi link javaScopeDecl         Identifier 
-hi link javaCommentTitle      javaDocSeeTag 
-hi link javaDocTags           javaDocSeeTag 
-hi link javaDocParam          javaDocSeeTag 
-hi link javaDocSeeTagParam    javaDocSeeTag 
-
-hi javaDocSeeTag              guifg=#CCCCCC     guibg=NONE        gui=NONE      ctermfg=darkgray    ctermbg=NONE        cterm=NONE
-hi javaDocSeeTag              guifg=#CCCCCC     guibg=NONE        gui=NONE      ctermfg=darkgray    ctermbg=NONE        cterm=NONE
-"hi javaClassDecl              guifg=#CCFFCC     guibg=NONE        gui=NONE      ctermfg=white       ctermbg=NONE        cterm=NONE
-
-
-" Special for XML
-hi link xmlTag          Keyword 
-hi link xmlTagName      Conditional 
-hi link xmlEndTag       Identifier 
-
-
-" Special for HTML
-hi link htmlTag         Keyword 
-hi link htmlTagName     Conditional 
-hi link htmlEndTag      Identifier 
-
-
-" Special for Javascript
-hi link javaScriptNumber      Number 
-
-
-" Special for Python
-"hi  link pythonEscape         Keyword      
-
-
-" Special for CSharp
-hi  link csXmlTag             Keyword      
-
-
-" Special for PHP
+"Specific for diff
+hi DiffAdd      cterm=none ctermfg=0 ctermbg=119
+hi DiffChange   cterm=none ctermfg=0 ctermbg=228
+hi DiffText     cterm=none ctermfg=0 ctermbg=178
+hi DiffDelete   cterm=none ctermfg=0 ctermbg=197
+hi diffLine     cterm=bold ctermfg=241
+hi diffOldLine  cterm=none ctermfg=241
+hi diffOldFile  cterm=none ctermfg=241
+hi diffNewFile  cterm=none ctermfg=241
+hi diffAdded    cterm=none
+hi diffRemoved  cterm=none ctermfg=9
+hi diffChanged  cterm=none ctermfg=20

Modified: issm/trunk/externalpackages/vim/addons/vim/syntax/c.vim
===================================================================
--- issm/trunk/externalpackages/vim/addons/vim/syntax/c.vim	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/vim/addons/vim/syntax/c.vim	2012-11-16 16:10:16 UTC (rev 13975)
@@ -568,9 +568,26 @@
 syn keyword cType FemModel
 "ISSM's objects end
 "ISSM's Enums begin
-syn keyword cConstant AutodiffForwardEnum
 syn keyword cConstant AutodiffIsautodiffEnum
-syn keyword cConstant AutodiffReverseEnum
+syn keyword cConstant AutodiffNumDependentsEnum
+syn keyword cConstant AutodiffNumDependentObjectsEnum
+syn keyword cConstant AutodiffDependentObjectNamesEnum
+syn keyword cConstant AutodiffDependentObjectTypesEnum
+syn keyword cConstant AutodiffDependentObjectIndicesEnum
+syn keyword cConstant AutodiffDependentObjectsEnum
+syn keyword cConstant AutodiffNumIndependentsEnum
+syn keyword cConstant AutodiffNumIndependentObjectsEnum
+syn keyword cConstant AutodiffIndependentObjectNamesEnum
+syn keyword cConstant AutodiffIndependentObjectTypesEnum
+syn keyword cConstant AutodiffIndependentObjectsEnum
+syn keyword cConstant AutodiffJacobianEnum
+syn keyword cConstant AutodiffXpEnum
+syn keyword cConstant AutodiffDriverEnum
+syn keyword cConstant AutodiffFosForwardIndexEnum
+syn keyword cConstant AutodiffFovForwardIndicesEnum
+syn keyword cConstant AutodiffFosReverseIndexEnum
+syn keyword cConstant AutodiffMassFluxSegmentsPresentEnum
+syn keyword cConstant AutodiffKeepEnum
 syn keyword cConstant BalancethicknessSpcthicknessEnum
 syn keyword cConstant BalancethicknessStabilizationEnum
 syn keyword cConstant BalancethicknessThickeningRateEnum
@@ -582,6 +599,7 @@
 syn keyword cConstant ConstantsGEnum
 syn keyword cConstant ConstantsReferencetemperatureEnum
 syn keyword cConstant ConstantsYtsEnum
+syn keyword cConstant DependentObjectEnum
 syn keyword cConstant DiagnosticAbstolEnum
 syn keyword cConstant DiagnosticIcefrontEnum
 syn keyword cConstant DiagnosticIsnewtonEnum
@@ -606,6 +624,7 @@
 syn keyword cConstant FlowequationBorderstokesEnum
 syn keyword cConstant FlowequationElementEquationEnum
 syn keyword cConstant FlowequationIshutterEnum
+syn keyword cConstant FlowequationIsl1l2Enum
 syn keyword cConstant FlowequationIsmacayealpattynEnum
 syn keyword cConstant FlowequationIsstokesEnum
 syn keyword cConstant FlowequationVertexEquationEnum
@@ -620,6 +639,7 @@
 syn keyword cConstant HydrologyQEnum
 syn keyword cConstant HydrologySpcwatercolumnEnum
 syn keyword cConstant HydrologyStabilizationEnum
+syn keyword cConstant IndependentObjectEnum
 syn keyword cConstant InversionControlParametersEnum
 syn keyword cConstant InversionCostFunctionEnum
 syn keyword cConstant InversionCostFunctionThresholdEnum
@@ -657,6 +677,8 @@
 syn keyword cConstant MaterialsRheologyBbarEnum
 syn keyword cConstant MaterialsRheologyLawEnum
 syn keyword cConstant MaterialsRheologyNEnum
+syn keyword cConstant MaterialsRheologyZEnum
+syn keyword cConstant MaterialsRheologyZbarEnum
 syn keyword cConstant MaterialsRhoIceEnum
 syn keyword cConstant MaterialsRhoWaterEnum
 syn keyword cConstant MaterialsRhoFreshwaterEnum
@@ -691,8 +713,12 @@
 syn keyword cConstant PrognosticSpcthicknessEnum
 syn keyword cConstant PrognosticStabilizationEnum
 syn keyword cConstant PrognosticVertexPairingEnum
+syn keyword cConstant PrognosticNumRequestedOutputsEnum
+syn keyword cConstant PrognosticRequestedOutputsEnum
 syn keyword cConstant QmuIsdakotaEnum
-syn keyword cConstant QmuMassFluxSegmentsEnum
+syn keyword cConstant MassFluxSegmentsEnum
+syn keyword cConstant MassFluxSegmentsPresentEnum
+syn keyword cConstant QmuMassFluxSegmentsPresentEnum
 syn keyword cConstant QmuNumberofpartitionsEnum
 syn keyword cConstant QmuNumberofresponsesEnum
 syn keyword cConstant QmuPartitionEnum
@@ -727,6 +753,8 @@
 syn keyword cConstant SurfaceforcingsIssmbgradientsEnum
 syn keyword cConstant SurfaceforcingsMonthlytemperaturesEnum
 syn keyword cConstant SurfaceforcingsHcEnum
+syn keyword cConstant SurfaceforcingsHrefEnum
+syn keyword cConstant SurfaceforcingsSmbrefEnum
 syn keyword cConstant SurfaceforcingsSmbPosMaxEnum
 syn keyword cConstant SurfaceforcingsSmbPosMinEnum
 syn keyword cConstant SurfaceforcingsAPosEnum
@@ -788,11 +816,12 @@
 syn keyword cConstant ThermalSolutionEnum
 syn keyword cConstant TransientSolutionEnum
 syn keyword cConstant ApproximationEnum
+syn keyword cConstant NoneApproximationEnum
 syn keyword cConstant HutterApproximationEnum
 syn keyword cConstant MacAyealApproximationEnum
 syn keyword cConstant MacAyealPattynApproximationEnum
 syn keyword cConstant MacAyealStokesApproximationEnum
-syn keyword cConstant NoneApproximationEnum
+syn keyword cConstant L1L2ApproximationEnum
 syn keyword cConstant PattynApproximationEnum
 syn keyword cConstant PattynStokesApproximationEnum
 syn keyword cConstant StokesApproximationEnum
@@ -803,6 +832,8 @@
 syn keyword cConstant ParametersEnum
 syn keyword cConstant VerticesEnum
 syn keyword cConstant ResultsEnum
+syn keyword cConstant GenericParamEnum
+syn keyword cConstant AdolcParamEnum
 syn keyword cConstant BoolInputEnum
 syn keyword cConstant BoolParamEnum
 syn keyword cConstant ContourEnum
@@ -810,6 +841,7 @@
 syn keyword cConstant DatasetInputEnum
 syn keyword cConstant DofIndexingEnum
 syn keyword cConstant DoubleInputEnum
+syn keyword cConstant DataSetParamEnum
 syn keyword cConstant DoubleMatArrayParamEnum
 syn keyword cConstant DoubleMatParamEnum
 syn keyword cConstant DoubleParamEnum
@@ -828,15 +860,18 @@
 syn keyword cConstant MacAyeal2dIceFrontEnum
 syn keyword cConstant MacAyeal3dIceFrontEnum
 syn keyword cConstant MaticeEnum
+syn keyword cConstant MatdamageiceEnum
 syn keyword cConstant MatparEnum
 syn keyword cConstant NodeEnum
 syn keyword cConstant NumericalfluxEnum
 syn keyword cConstant ParamEnum
+syn keyword cConstant L1L2IceFrontEnum
 syn keyword cConstant PattynIceFrontEnum
 syn keyword cConstant PengridEnum
 syn keyword cConstant PenpairEnum
 syn keyword cConstant PentaEnum
 syn keyword cConstant PentaP1InputEnum
+syn keyword cConstant ProfilerEnum
 syn keyword cConstant MatrixParamEnum
 syn keyword cConstant VectorParamEnum
 syn keyword cConstant RiftfrontEnum
@@ -902,6 +937,8 @@
 syn keyword cConstant TemperatureEnum
 syn keyword cConstant TemperatureOldEnum
 syn keyword cConstant TemperaturePicardEnum
+syn keyword cConstant TemperatureSurfaceEnum
+syn keyword cConstant TemperatureBasalEnum
 syn keyword cConstant ThicknessAbsMisfitEnum
 syn keyword cConstant TypeEnum
 syn keyword cConstant VelEnum
@@ -923,6 +960,8 @@
 syn keyword cConstant EnthalpyEnum
 syn keyword cConstant EnthalpyPicardEnum
 syn keyword cConstant ThicknessAbsGradientEnum
+syn keyword cConstant ThicknessAlongGradientEnum
+syn keyword cConstant ThicknessAcrossGradientEnum
 syn keyword cConstant StepResponsesEnum
 syn keyword cConstant IntMatParamEnum
 syn keyword cConstant RheologyBbarAbsGradientEnum
@@ -943,10 +982,6 @@
 syn keyword cConstant StressTensoryyEnum
 syn keyword cConstant StressTensoryzEnum
 syn keyword cConstant StressTensorzzEnum
-syn keyword cConstant IceVolumeEnum
-syn keyword cConstant TotalSmbEnum
-syn keyword cConstant ThicknessAlongGradientEnum
-syn keyword cConstant ThicknessAcrossGradientEnum
 syn keyword cConstant P0Enum
 syn keyword cConstant P1Enum
 syn keyword cConstant P1DGEnum
@@ -980,6 +1015,8 @@
 syn keyword cConstant MinVzEnum
 syn keyword cConstant MaxVzEnum
 syn keyword cConstant MaxAbsVzEnum
+syn keyword cConstant IceVolumeEnum
+syn keyword cConstant TotalSmbEnum
 syn keyword cConstant RelativeEnum
 syn keyword cConstant AbsoluteEnum
 syn keyword cConstant IncrementalEnum
@@ -1003,6 +1040,8 @@
 syn keyword cConstant NodalEnum
 syn keyword cConstant OldGradientEnum
 syn keyword cConstant OutputFilePointerEnum
+syn keyword cConstant OutputFileNameEnum
+syn keyword cConstant LockFileNameEnum
 syn keyword cConstant PetscOptionsAnalysesEnum
 syn keyword cConstant PetscOptionsStringsEnum
 syn keyword cConstant QmuErrNameEnum
@@ -1019,6 +1058,7 @@
 syn keyword cConstant XYEnum
 syn keyword cConstant XYZPEnum
 syn keyword cConstant OptionEnum
+syn keyword cConstant GenericOptionEnum
 syn keyword cConstant OptionCellEnum
 syn keyword cConstant OptionCharEnum
 syn keyword cConstant OptionStructEnum

Modified: issm/trunk/externalpackages/vim/addons/vimrc
===================================================================
--- issm/trunk/externalpackages/vim/addons/vimrc	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/externalpackages/vim/addons/vimrc	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,5 @@
 
-" General setup{{{1
+" General setup{{{
 " ----------------------------------------------------------------------
 " Use Vim settings, rather then Vi settings (much better!).
 " This must be first, because it changes other options as a side effect.
@@ -17,7 +17,7 @@
 " display curent mode
 set showmode
 "----------------------------------------------------------------------}}}
-" Text-Formatting, Identing, Tabbing{{{1
+" Text-Formatting, Identing, Tabbing{{{
 " ----------------------------------------------------------------------
 " allow backspacing (to delete) over everything in insert mode
 set backspace=indent,eol,start
@@ -38,14 +38,14 @@
 set foldmethod=marker
 set foldtext=IssmFoldText()
 " -----------------------------------------------------------}}}
-" Backups {{{1
+" Backups {{{
 " -----------------------------------------------------------
 " updatecount   number of characters typed to cause a swap file update (0->disable)
 set uc=0
 " make no backups
 set nobackup
 " -----------------------------------------------------------}}}
-" Searching, Substituting {{{1
+" Searching, Substituting {{{
 " -----------------------------------------------------------
 " select case-insenitive search
 "set ignorecase 
@@ -74,7 +74,7 @@
 " some filetypes got lower priority
 set su=.h,.bak,~,.o,.info,.swp,.obj
 " ----------------------------------------------------------------------}}}
-" Colors and theme {{{1
+" Colors and theme {{{
 " ----------------------------------------------------------------------
 " use 256 colors
 "set t_Co=8
@@ -87,7 +87,7 @@
 colorscheme issm_black
 " ----------------------------------------------------------------------}}}
 
-" Mappings{{{1
+" Mappings{{{
 " ----------------------------------------------------------------------
 "stop highlightings when spce is pressed
 nnoremap <silent> <Space> :silent noh<Bar>echo<CR> 
@@ -110,7 +110,7 @@
 " Don't use Ex mode, use Q for formatting
 map Q gq
 " ----------------------------------------------------------------------}}}
-" Autocommands {{{1
+" Autocommands {{{
 " ----------------------------------------------------------------------
 " Only do this part when compiled with support for autocommands.
 if has("autocmd")
@@ -139,20 +139,20 @@
 
 endif " has("autocmd")
 " ----------------------------------------------------------------------}}}
-" Matlab special {{{1
+" Matlab special {{{
 " ----------------------------------------------------------------------
 "" associate *.par with matlab filetype
 au BufRead,BufNewFile *.par setfiletype matlab
 au BufRead,BufNewFile *.tpl setfiletype html
 " ----------------------------------------------------------------------}}}
-" C special{{{1
+" C special{{{
 " ----------------------------------------------------------------------
 "indenting for C-code
 set cindent
 " and here some nice options for cindenting
 set cinoptions={.5s,+.5s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s 
 " ----------------------------------------------------------------------}}}
-" TEX special{{{1
+" TEX special{{{
 " ----------------------------------------------------------------------
 au BufRead,BufNewFile *.tex,*.html set textwidth=100     "100 caracters max (See gq command)
 au BufRead,BufNewFile *.tex,*.html set formatoptions=cqt "automatic wraping
@@ -164,11 +164,11 @@
 " The following changes the default filetype back to 'tex':
 let g:tex_flavor='latex'
 " ----------------------------------------------------------------------}}}
-" FORTRAN special{{{1
+" FORTRAN special{{{
 " ----------------------------------------------------------------------
 au BufRead,BufNewFile *.src setfiletype fortran
 " ----------------------------------------------------------------------}}}
-" InsertTabWrapper{{{1
+" InsertTabWrapper{{{
 " ----------------------------------------------------------------------
 function! InsertTabWrapper(direction) 
 let col = col('.') - 1 
@@ -191,7 +191,7 @@
 autocmd BufEnter * lcd %:p:h
 " ----------------------------------------------------------------------}}}
 
-" Abbreviations {{{1
+" Abbreviations {{{
 " ----------------------------------------------------------------------
 "func Eatchar(pat)
 "	let c = nr2char(getchar())
@@ -224,7 +224,7 @@
 "			\<CR>\end{enumerate}<up><C-R>=Eatchar('\s')<CR>
 "au BufRead,BufNewFile *.tex ab (()) \left( \right)
 "}}}
-" Skeletons {{{1
+" Skeletons {{{
 au BufNewFile letter.tex   0r ~/.vim/xtr/skeleton/letter.tex
 "}}}
 " Copy and Paste{{{

Modified: issm/trunk/m4/issm_options.m4
===================================================================
--- issm/trunk/m4/issm_options.m4	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/m4/issm_options.m4	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,29 +13,27 @@
 	fi
 
 	dnl }}}
-    dnl shared build {{{
+    dnl Shared build {{{
     AC_ARG_ENABLE([sharedlibs],                                                dnl feature
         AS_HELP_STRING([--enable-sharedlibs], [produce libISSM.so.0]),         dnl help string
         [enable_sharedlibs=$enableval],                                        dnl action if given
         [enable_sharedlibs=no])                                                dnl action if not given
     AM_CONDITIONAL([SHAREDLIBS], [test x$enable_sharedlibs = xyes])
     dnl }}}
-
-    dnl shared build {{{
+    dnl Version{{{
     AC_ARG_ENABLE([version],                                                dnl feature
         AS_HELP_STRING([--enable-version], [produce libISSM.so.0]),         dnl help string
         [enable_version=$enableval],                                        dnl action if given
         [enable_version=no])                                                dnl action if not given
     AM_CONDITIONAL([VERSION], [test x$enable_VERSION = xyes])
     dnl }}}
-
-	dnl Modules build {{{
-	AC_ARG_WITH([modules],
-		AS_HELP_STRING([--with-modules = value],[modules compilation. ]),
-		[MODULES_VALUE=$withval],[MODULES_VALUE="yes"])
-	AC_MSG_CHECKING(for modules compilation)
-	AM_CONDITIONAL([MODULES], [test $MODULES_VALUE = yes])
-	AC_MSG_RESULT($MODULES_VALUE) 
+	dnl Wrappers build {{{
+	AC_ARG_WITH([wrappers],
+		AS_HELP_STRING([--with-wrappers = value],[wrappers compilation. ]),
+		[WRAPPERS_VALUE=$withval],[WRAPPERS_VALUE="yes"])
+	AC_MSG_CHECKING(for wrappers compilation)
+	AM_CONDITIONAL([WRAPPERS], [test x$WRAPPERS_VALUE = xyes])
+	AC_MSG_RESULT($WRAPPERS_VALUE) 
 	dnl }}}
 	dnl Extensions{{{
 	ISSMEXT=".exe"
@@ -79,8 +77,8 @@
 		elif test $VENDOR = intel-discover; then
 			export CC=icc
 			export CXX=icpc
-			export CXXFLAGS=" -O3 -D_INTEL_LINUX_ "
-			export CFLAGS=" -O3 -D_INTEL_LINUX_ "
+			export CXXFLAGS=" -O3 -D_INTEL_LINUX_ -DMPICH_IGNORE_CXX_SEEK"
+			export CFLAGS=" -O3 -D_INTEL_LINUX_ -DMPICH_IGNORE_CXX_SEEK"
 		elif test $VENDOR = intel-pleiades; then
 			export CC=icc
 			export CXX=icpc
@@ -93,7 +91,7 @@
 	AC_SUBST([OSLIBS]) 
 	AC_MSG_RESULT(done)
 	dnl }}}
-	dnl Matlab{{{
+	dnl matlab{{{
 
 	dnl 1. See if matlab has been provided
 	AC_ARG_WITH([matlab-dir],
@@ -112,71 +110,9 @@
 	AC_MSG_RESULT($HAVE_MATLAB)
 	AM_CONDITIONAL([MATLAB], [test x$HAVE_MATLAB = xyes])
 
-	dnl 2. if matlab is provided, get version number
+	dnl 2. Get Matlab libraries
 	if test x$HAVE_MATLAB = xyes; then
-		AC_MSG_CHECKING([for matlab version])
-		MATLAB_VERSION=""
 
-		dnl For Matlab R2008a and more, the version number is stored in .VERSION
-		if test -f "$MATLAB_ROOT/.VERSION" ; then
-			MATLAB_VERSION=$(cat $MATLAB_ROOT/.VERSION)
-		fi
-		dnl Otherwise find version in file stored in bin/util/mex/version.txt
-		if test -f "$MATLAB_ROOT/bin/util/mex/version.txt" ; then
-			MATLAB_VERSION=$(cat $MATLAB_ROOT/bin/util/mex/version.txt)
-		fi
-
-		dnl check that we found the version
-		if test -z "$MATLAB_VERSION" ; then
-			AC_MSG_ERROR([Matlab version not found])
-		fi
-
-		case $MATLAB_VERSION in
-			@<:@1-9@:>@.@<:@0-9@:>@ | @<:@1-9@:>@@<:@0-9@:>@.@<:@0-9@:>@ | @<:@1-9@:>@.@<:@1-9@:>@@<:@0-9@:>@)
-				MATLAB_MAJOR=$(echo $MATLAB_VERSION | sed -e "s/^\(@<:@0-9@:>@*\)\.@<:@0-9@:>@*.*/\1/")
-				MATLAB_MINOR=$(echo $MATLAB_VERSION | sed -e "s/^@<:@0-9@:>@*\.\(@<:@0-9@:>@*\).*/\1/")
-				;;
-			R2007a)
-			  MATLAB_MAJOR=7
-			  MATLAB_MINOR=4
-			  ;;
-			R2008a)
-			  MATLAB_MAJOR=7
-			  MATLAB_MINOR=6
-			  ;;
-			R2009a)
-			  MATLAB_MAJOR=7
-			  MATLAB_MINOR=8
-			  ;;
-			R2010a)
-			  MATLAB_MAJOR=7
-			  MATLAB_MINOR=10
-			  ;;
-			R2010b)
-			  MATLAB_MAJOR=7
-			  MATLAB_MINOR=11
-			  ;;
-			R2011a)
-			  MATLAB_MAJOR=7
-			  MATLAB_MINOR=12
-			  ;;
-			R2011b)
-			  MATLAB_MAJOR=7
-			  MATLAB_MINOR=13
-			  ;;
-			R2012a)
-			  MATLAB_MAJOR=7
-			  MATLAB_MINOR=14
-			  ;;
-			*)
-			  AC_MSG_ERROR([can not determine Matlab version number])
-			esac
-		AC_SUBST([MATLAB_VERSION])
-		AC_SUBST([MATLAB_MAJOR])
-		AC_SUBST([MATLAB_MINOR])
-		AC_MSG_RESULT($MATLAB_VERSION ($MATLAB_MAJOR.$MATLAB_MINOR))
-
-		dnl 3. Get Matlab libraries
 		AC_MSG_CHECKING(for matlab headers and libraries in $MATLAB_ROOT)
 		MATLABINCL=-I"$MATLAB_ROOT/extern/include";
 		
@@ -184,44 +120,6 @@
 		MEXLINK=$(mex -v 2>&1 < /dev/null | grep LDFLAGS     | sed -e "s/         LDFLAGS            = //g")
 		MEXLIB=$( mex -v 2>&1 < /dev/null | grep CXXLIBS     | sed -e "s/         CXXLIBS            = //g")
 		MEXEXT=$( mex -v 2>&1 < /dev/null | grep LDEXTENSION | sed -e "s/         LDEXTENSION        = //g")
-		dnl dnl OS-dependent variables and checks (old stuff)
-		dnl case "${host_os}" in
-		dnl 	*linux*)
-		dnl 		if test "${host_cpu}" = "x86_64";
-		dnl 		then
-		dnl 			MEXLIB="-Wl,-rpath-link,$MATLAB_ROOT/bin/glnxa64 -L$MATLAB_ROOT/bin/glnxa64/ -lmx -lmex -lmat -lm"
-		dnl 			MEXLINK="-pthread -shared -W2,--version-script,${MATLAB_ROOT}/extern/lib/glnxa64/mexFunction.map";
-		dnl 		else
-		dnl 			MEXLIB=-L"$MATLAB_ROOT/bin/glnx86/ -lmex"
-		dnl 			MEXLINK="-pthread -shared -W2,--version-script,${MATLAB_ROOT}/extern/lib/glnx86/mexFunction.map";
-		dnl 		fi
-		dnl 		MEXEXT=`$MATLAB_ROOT/bin/mexext`
-		dnl 		MEXEXT=".$MEXEXT"
-		dnl 	;;
-		dnl 	*darwin*)
-		dnl 		dnl mex -v gives all the flags for compilation of mex files
-		dnl 		dnl if matlab version is 7.9 or more, we must use mexmaci64 (64 bits)
-		dnl 		MEXLINK="-O -Wl,-flat_namespace -undefined suppress -arch i386 -bundle -Wl,-exported_symbols_list,$MATLAB_ROOT/extern/lib/maci/mexFunction.map"
-		dnl 		MEXLIB=" -L$MATLAB_ROOT/bin/maci/ -lmx -lmex -lmat -lstdc++ -largeArrayDims"
-		dnl 		if test $MATLAB_MAJOR -ge 7; then 
-		dnl 			 if test $MATLAB_MINOR -ge 9; then 
-		dnl 				  MEXLINK="-O -Wl,-flat_namespace -undefined suppress -bundle -Wl,-exported_symbols_list,$MATLAB_ROOT/extern/lib/maci64/mexFunction.map"
-		dnl 					 MEXLIB=" -L$MATLAB_ROOT/bin/maci64/ -lmx -lmex -lmat -lstdc++"
-		dnl 			 fi
-		dnl 		fi
-		dnl 		MEXEXT=`$MATLAB_ROOT/bin/mexext`
-		dnl 		MEXEXT=".$MEXEXT"
-		dnl 	;;
-		dnl 	*cygwin*) 
-		dnl 		if  test $VENDOR = intel-win7-32; then
-		dnl 			MEXLIB="-dll -export:mexFunction -LIBPATH:\"$MATLAB_ROOT\extern\lib\win32\microsoft\" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  -NOLOGO -INCREMENTAL:NO -manifest" 
-		dnl 		elif  test $VENDOR = intel-win7-64; then
-		dnl 			MEXLIB="-dll -export:mexFunction -LIBPATH:\"$MATLAB_ROOT\extern\lib\win64\microsoft\" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  -NOLOGO -INCREMENTAL:NO -manifest" 
-		dnl 		fi
-		dnl 		MEXEXT=`$MATLAB_ROOT/bin/mexext.bat`
-		dnl 		MEXEXT=".$MEXEXT"
-		dnl 	;;
-		dnl esac
 	   AC_MSG_RESULT(done)
 
 		AC_SUBST([MATLABINCL])
@@ -331,30 +229,37 @@
 	AC_ARG_WITH([python-dir],
 	  AS_HELP_STRING([--with-python-dir=DIR], [python root directory.]),
 	  [PYTHON_ROOT=$withval],[PYTHON_ROOT=""]) 
+
 	AC_MSG_CHECKING(for python)
-	
 	if test -d "$PYTHON_ROOT"; then
-		dnl defaults
-		HAVE_PYTHON3="no"
-		HAVE_PYTHON=yes
-		
-		AC_ARG_WITH([python-version],
-		  AS_HELP_STRING([--with-python-version = PYTHONVERSION],[python version.]),
-		  [PYTHONVERSION=$withval],[PYTHONVERSION=""])
+		HAVE_PYTHON="yes"
+		AC_DEFINE([_HAVE_PYTHON_],[1],[with Python in ISSM src])
+	else
+		HAVE_PYTHON=no
+	fi
+	AC_MSG_RESULT($HAVE_PYTHON)
+
+	dnl get python version
+	if test x$HAVE_PYTHON = xyes; then
 		AC_MSG_CHECKING(for python version)
+		dnl Query Python for its version number.  Getting [:3] seems to be
+		dnl the best way to do this; it's what "site.py" does in the standard
+		dnl library.
+		PYTHON_VERSION=$($PYTHON_ROOT/bin/python -c "import sys; print sys.version[[:3]]")
+		AC_MSG_RESULT($PYTHON_VERSION)
 
 		dnl recover major: 
-		PYTHON_MAJOR=${PYTHONVERSION%.*}
-
+		PYTHON_MAJOR=${PYTHON_VERSION%.*}
 		if test x$PYTHON_MAJOR = x3; then
 			dnl are we running python 3?
 			HAVE_PYTHON3="yes"
+		else
+			HAVE_PYTHON3="no"
 		fi
 		AC_DEFINE_UNQUOTED([_PYTHON_MAJOR_],$PYTHON_MAJOR,[python version major])
-		AC_MSG_RESULT($PYTHON_MAJOR)
 
 		PYTHONINCL=-I$PYTHON_ROOT/include
-		PYTHONLIB="-L$PYTHON_ROOT/lib -lpython$PYTHONVERSION"
+		PYTHONLIB="-L$PYTHON_ROOT/lib -lpython$PYTHON_VERSION"
 		PYTHONEXT=.so
 
 		case "${host_os}" in
@@ -369,19 +274,14 @@
 			;;
 		esac
 
-		AC_DEFINE([_HAVE_PYTHON_],[1],[with Python in ISSM src])
 		AC_SUBST([PYTHONINCL])
 		AC_SUBST([PYTHONLIB])
 		PYTHONWRAPPEREXT=$PYTHONEXT
 		AC_SUBST([PYTHONWRAPPEREXT])
 		AC_SUBST([PYTHONLINK])
-	else
-		HAVE_PYTHON=no
 	fi
 	AM_CONDITIONAL([PYTHON], [test x$HAVE_PYTHON = xyes])
 	AM_CONDITIONAL([PYTHON3], [test x$HAVE_PYTHON3 = xyes])
-	AC_MSG_RESULT($HAVE_PYTHON)
-
 	dnl }}}
 	dnl python-numpy{{{
 	AC_ARG_WITH([python-numpy-dir],
@@ -556,69 +456,6 @@
 	AM_CONDITIONAL([ROSE], [test x$HAVE_ROSE = xyes])
 	AC_MSG_RESULT($HAVE_ROSE)
 	dnl }}}
-	dnl metis{{{
-	AC_ARG_WITH([metis-dir],
-	  AS_HELP_STRING([--with-metis-dir=DIR],[metis root directory. necessary for serial build]),
-	  [METIS_ROOT=$withval],[METIS_ROOT=""])
-
-   AC_MSG_CHECKING(for metis headers and libraries in $METIS_ROOT)
-
-	if test -d "$METIS_ROOT"; then
-
-		dnl first figure out version of metis: does the VERSION file exist?
-		if test -e "$METIS_ROOT/VERSION"; then
-			METIS_VERSION=4
-		else
-			METIS_VERSION=5
-		fi
-
-		dnl defaults
-		HAVE_METIS=yes
-
-		if test "$METIS_VERSION" = "4" ; then
-   			
-			METISINCL=-I"$METIS_ROOT/Lib" 
-			case "${host_os}" in
-				*cygwin*)
-				METISLIB="-LIBPATH:\"$METIS_ROOT\" libmetis.lib"
-				;;
-				*linux*)
-				METISLIB=-L"$METIS_ROOT/ -lmetis"
-				;;
-				*darwin*)
-				METISLIB=-L"$METIS_ROOT/ -lmetis"
-				;;
-			esac
-
-   			AC_DEFINE([_METIS_VERSION_],[4],[ Metis version number])
-		fi
-		if test "$METIS_VERSION" = "5" ; then
-	
-			case "${host_os}" in
-				*cygwin*)
-				METISLIB="-LIBPATH:\"$METIS_ROOT\" libmetis.lib"
-				;;
-				*linux*)
-				METISLIB=-L"$METIS_ROOT/lib -lmetis"
-				;;
-				*darwin*)
-				METISLIB=-L"$METIS_ROOT/lib -lmetis"
-				;;
-			esac
-
-			METISINCL=-I"$METIS_ROOT/include" 
-			AC_DEFINE([_METIS_VERSION_],[5],[ Metis version number])
-		fi
-
-		AC_DEFINE([_HAVE_METIS_],[1],[with Metis in ISSM src])
-		AC_SUBST([METISINCL])
-		AC_SUBST([METISLIB])
-	else
-		HAVE_METIS=no
-	fi
-	AM_CONDITIONAL([METIS], [test x$HAVE_METIS = xyes])
-	AC_MSG_RESULT($HAVE_METIS)
-	dnl }}}
 	dnl mpi{{{
 	AC_MSG_CHECKING(for mpi)
 	AC_ARG_WITH([mpi-lib],
@@ -680,36 +517,44 @@
 	dnl make getlinklibs
 	if test -d "$PETSC_ROOT"; then
 
-		PETSCINCL="-I$PETSC_ROOT/$PETSC_ARCH/include -I$PETSC_ROOT/include/$PETSC_ARCH/ -I$PETSC_ROOT/include -I$PETSC_ROOT/ -I$PETSC_ROOT/bmake/$PETSC_ARCH -I$PETSC_ROOT/src/mat/impls/dense/mpi/plapack/"
+	 PETSCINCL=" -I$PETSC_ROOT/include"
+	 dnl Add other location (maybe not needed anymore)
+	 if test -d "$PETSC_ROOT/$PETSC_ARCH/include"; then
+	  PETSCINCL+=" $PETSC_ROOT/$PETSC_ARCH/include"
+	 fi
+	 if test -d "$PETSC_ROOT/include/$PETSC_ARCH"; then
+	  PETSCINCL+=" $PETSC_ROOT/include/$PETSC_ARCH"
+	 fi
 	
-		case "${host_os}" in
+	 case "${host_os}" in
 			*cygwin*)
-			if test "$PETSC_MAJOR" = "2" ; then
-				PETSCLIB="-link -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libpetscksp.lib  libpetscdm.lib  libpetscmat.lib  libpetscvec.lib libpetscsnes.lib libpetscts.lib libmpiuni.lib libpetsc.lib"
+			if test $PETSC_MAJOR -lt 3 ; then
+				PETSCLIB="-link -LIBPATH:\"$PETSC_ROOT/lib\" libpetscksp.lib libpetscdm.lib libpetscmat.lib libpetscvec.lib libpetscsnes.lib libpetscts.lib libmpiuni.lib libpetsc.lib"
 			else
-				PETSCLIB="-link -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib\" -LIBPATH:\"$PETSC_ROOT/lib/$PETSC_ARCH\" libpetsc.lib"
+				PETSCLIB="-link -LIBPATH:\"$PETSC_ROOT/lib\" libpetsc.lib"
+				if test $PETSC_MAJOR -gt 3 || test $PETSC_MINOR -ge 3; then PETSCLIB+=" libmetis.lib"; fi
 			fi
 			;;
 			*linux*)
-			if test "$PETSC_MAJOR" = "2" ; then
-			PETSCLIB="-L$PETSC_ROOT/lib -L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetsc  -lpetscsnes -lpetscts"
+			if test $PETSC_MAJOR -lt 3 ; then
+				PETSCLIB="-L$PETSC_ROOT/lib -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetsc  -lpetscsnes -lpetscts"
 			else
-			PETSCLIB="-L$PETSC_ROOT/lib -L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH -lpetsc -ldl"
+				PETSCLIB="-L$PETSC_ROOT/lib -lpetsc -ldl"
+				if test $PETSC_MAJOR -gt 3 || test $PETSC_MINOR -ge 3; then PETSCLIB+=" -lmetis"; fi
 			fi
 			;;
 			*darwin*)
-			if test "$PETSC_MAJOR" = "2" ; then
-			PETSCLIB="-L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH/ -L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetscsnes -lpetscts -lpetsc"
+			if test $PETSC_MAJOR -lt 3 ; then
+				PETSCLIB="-L$PETSC_ROOT/lib -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetscsnes -lpetscts -lpetsc"
 			else
-			PETSCLIB="-L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH/ -L$PETSC_ROOT/lib -L$PETSC_ROOT/lib/$PETSC_ARCH -lpetsc"
+				PETSCLIB="-L$PETSC_ROOT/lib -lpetsc"
+				if test $PETSC_MAJOR -gt 3 || test $PETSC_MINOR -ge 3; then PETSCLIB+=" -lmetis"; fi
 			fi
 			;;
 		esac
-
 		AC_DEFINE([_HAVE_PETSC_],[1],[with PETSc in ISSM src])
 		AC_SUBST([PETSCINCL])
 		AC_SUBST([PETSCLIB])
-
 		HAVE_PETSC=yes
 	else
 		HAVE_PETSC=no
@@ -718,6 +563,77 @@
 	AM_CONDITIONAL([PETSC], [test x$HAVE_PETSC = xyes])
 	AC_MSG_RESULT($HAVE_PETSC)
 	dnl }}}
+	dnl metis{{{
+	if test "$HAVE_PETSC" = "yes" && test "x$PETSC_MAJOR" = "x3" && test $PETSC_MINOR -ge 3; then
+
+		dnl in petsc >=3.3, metis is provided
+		HAVE_METIS="yes"
+		AC_DEFINE([_METIS_VERSION_],[5],[ Metis version number])
+		AC_DEFINE([_HAVE_METIS_],[1],[with Metis in ISSM src])
+	else
+		AC_ARG_WITH([metis-dir],
+		  AS_HELP_STRING([--with-metis-dir=DIR],[metis root directory. necessary for serial build]),
+		  [METIS_ROOT=$withval],[METIS_ROOT=""])
+
+		AC_MSG_CHECKING(for metis headers and libraries in $METIS_ROOT)
+
+		if test -d "$METIS_ROOT"; then
+
+			dnl first figure out version of metis: does the VERSION file exist?
+			if test -e "$METIS_ROOT/VERSION"; then
+				METIS_VERSION=4
+			else
+				METIS_VERSION=5
+			fi
+
+			dnl defaults
+			HAVE_METIS=yes
+
+			if test "$METIS_VERSION" = "4" ; then
+					
+				METISINCL=-I"$METIS_ROOT/Lib" 
+				case "${host_os}" in
+					*cygwin*)
+					METISLIB="-LIBPATH:\"$METIS_ROOT\" libmetis.lib"
+					;;
+					*linux*)
+					METISLIB=-L"$METIS_ROOT/ -lmetis"
+					;;
+					*darwin*)
+					METISLIB=-L"$METIS_ROOT/ -lmetis"
+					;;
+				esac
+
+					AC_DEFINE([_METIS_VERSION_],[4],[ Metis version number])
+			fi
+			if test "$METIS_VERSION" = "5" ; then
+		
+				case "${host_os}" in
+					*cygwin*)
+					METISLIB="-LIBPATH:\"$METIS_ROOT\" libmetis.lib"
+					;;
+					*linux*)
+					METISLIB=-L"$METIS_ROOT/lib -lmetis"
+					;;
+					*darwin*)
+					METISLIB=-L"$METIS_ROOT/lib -lmetis"
+					;;
+				esac
+
+				METISINCL=-I"$METIS_ROOT/include" 
+				AC_DEFINE([_METIS_VERSION_],[5],[ Metis version number])
+			fi
+
+			AC_DEFINE([_HAVE_METIS_],[1],[with Metis in ISSM src])
+			AC_SUBST([METISINCL])
+			AC_SUBST([METISLIB])
+		else
+			HAVE_METIS=no
+		fi
+		AC_MSG_RESULT($HAVE_METIS)
+	fi
+	AM_CONDITIONAL([METIS], [test x$HAVE_METIS = xyes])
+	dnl }}}
 	dnl tao{{{
 	AC_ARG_WITH([tao-dir],
 		AS_HELP_STRING([--with-tao-dir=DIR], [tao root directory.]),
@@ -1399,6 +1315,33 @@
 	AM_CONDITIONAL([RIFTS], [test x$HAVE_RIFTS = xyes])
 	AC_MSG_RESULT($HAVE_RIFTS)
 	dnl }}}
+	dnl with-android{{{
+	AC_ARG_WITH([android],
+		AS_HELP_STRING([--with-android = EXE], [compile with android capabilities (default is no, alternatives are exe and jni)]),
+		[ANDROID=$withval],[ANDROID=no]) 
+	AC_MSG_CHECKING(for android capability compilation)
+
+	if test "x$ANDROID" = "xjni"; then
+
+		dnl defaults
+		HAVE_ANDROID=jni
+
+		AC_DEFINE([_HAVE_ANDROID_],[1],[with android capability])
+	elif test "x$ANDROID" = "xexe"; then
+		dnl defaults
+		HAVE_ANDROID=exe
+
+		AC_DEFINE([_HAVE_ANDROID_],[1],[with android capability])
+	elif test "x$ANDROID" = "xno"; then
+		HAVE_ANDROID=no
+	else
+	  AC_MSG_ERROR([--with-android should be either no, exe or jni])
+	fi
+	AM_CONDITIONAL([ANDROID], [test x$HAVE_ANDROID != xno])
+	AM_CONDITIONAL([ANDROIDJNI], [test x$HAVE_ANDROID = xjni])
+	AM_CONDITIONAL([ANDROIDEXE], [test x$HAVE_ANDROID = xexe])
+	AC_MSG_RESULT($HAVE_ANDROID)
+	dnl }}}
 	dnl with-3d{{{
 	AC_ARG_WITH([3d],
 		AS_HELP_STRING([--with-3d = YES], [compile with 3d capabilities (default is yes)]),
@@ -1432,20 +1375,11 @@
 		AC_MSG_ERROR([need at least python or matlab support to compile modules (or use --with-modules=no)]);
 	fi
 
-	dnl check that we have python version if python compile is specified
-	if test "$HAVE_PYTHON" = "yes"  && test "$PYTHONVERSION" = "" ; then
-	AC_MSG_ERROR([need python-version if python compile is required!]);
-	fi
-
 	dnl check that if we have MPI, we have metis
 	if test "$HAVE_METIS" = "yes"  && test "$HAVE_MPI" = "no" ; then
 	AC_MSG_ERROR([need mpi if using the metis partitioner!]);
 	fi
 
-
-
-
-
 	AC_MSG_RESULT(done)
 	dnl }}}
 
@@ -1502,13 +1436,4 @@
 	fi
 	AC_MSG_RESULT($USE_64BIT_INDICES)
 	dnl }}}
-	dnl circular-dependency{{{
-	AC_ARG_WITH([circular-dependency],
-	  AS_HELP_STRING([--with-circular-dependency = bool],[do we look for circular dependencies, default "yes", ex: --with-circular-dependency="no"]),
-	  [CIRCULAR_DEPENDENCIES=$withval],[CIRCULAR_DEPENDENCIES=yes]) 
-	AC_MSG_CHECKING(for circular dependencies)
-	AM_CONDITIONAL([CIRCULAR_DEPENDENCIES], [test x$CIRCULAR_DEPENDENCIES = xyes])
-	AC_MSG_RESULT($CIRCULAR_DEPENDENCIES) 
-
-	dnl }}}
 ])

Modified: issm/trunk/scripts/report.sh
===================================================================
--- issm/trunk/scripts/report.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/scripts/report.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,8 +9,8 @@
 SECTION_FONT='style="color:#6495ed; font-family:Arial, Verdana, Tahoma; font-size:20px; font-weight: bold;" align="left"'
 TABLE_STYLE='width="680px" rules=none bgcolor="#ffffdd" border=1 bordercolor="#000000" cellpadding="3"'
 TABLE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px; font-weight: normal;" align="left"'
-MATLAB_STYLE='width="700px" rules=none'
-MATLAB_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="left"'
+CODE_STYLE='width="700px" rules=none'
+CODE_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:12px; font-weight: normal;" align="left"'
 BODY_STYLE='width="700px"'
 BODY_FONT='style="color:#404040; font-family:Arial, Verdana, Tahoma; font-size:14px;"'
 BODY_FONTC=$(echo $BODY_FONT | sed -e "s/style=\"/style=\"text-align:center; /g")
@@ -103,7 +103,7 @@
 <table $SECTION_STYLE><tr><td $SECTION_FONT>Matlab tests</td></tr></table>
 <table $(echo $BODY_STYLE) style="border-collapse:collapse;">
 $(if [ $CRASH_MATLAB -eq 0 ]; then
-echo "<tr><td $BODY_FONTL>Status: <span style=\"color:#008000\">all test desks have been run</span></td></tr>"
+echo "<tr><td $BODY_FONTL>Status: <span style=\"color:#008000\">all tests have been run</span></td></tr>"
 else
 	echo "<tr><td $BODY_FONTL>Status: <span style=\"color:#ff0000\">Matlab crashed</span></td></tr>"
 fi)
@@ -132,7 +132,7 @@
 <table $SECTION_STYLE><tr><td $SECTION_FONT>Python tests</td></tr></table>
 <table $(echo $BODY_STYLE) style="border-collapse:collapse;">
 $(if [ $CRASH_PYTHON -eq 0 ]; then
-	echo "<tr><td $BODY_FONTL>Status: <span style=\"color:#008000\">all test desks have been run</span></td></tr>"
+	echo "<tr><td $BODY_FONTL>Status: <span style=\"color:#008000\">all tests have been run</span></td></tr>"
 else
 	echo "<tr><td $BODY_FONTL>Status: <span style=\"color:#ff0000\">Python crashed</span></td></tr>"
 fi)
@@ -214,7 +214,7 @@
 	<th $BODY_FONT>Test name</th> 
 	<th $BODY_FONT>Field checked</th>
 	</tr>
-	$(cat matlab_short.log | while read line
+	$(cat python_short.log | while read line
 do
 	echo "<tr>"
 	STATUS=`echo $line | awk '{print $1}'`
@@ -262,7 +262,7 @@
 #Matlab {{{
 cat << END >> report.html
 <table $SECTION_STYLE><tr><td $SECTION_FONT>Matlab errors</td></tr></table>
-<table $MATLAB_STYLE><tr><td $MATLAB_FONT>
+<table $CODE_STYLE><tr><td $CODE_FONT>
 <pre style="
 white-space: -moz-pre-wrap;
 white-space: -pre-wrap;
@@ -274,11 +274,27 @@
 END
 #}}}
 fi
+if [ $IS_PYTHON -eq 1 ] && [ -s pythonerror.log ]; then
+	#Python {{{
+	cat << END >> report.html
+<table $SECTION_STYLE><tr><td $SECTION_FONT>Python errors</td></tr></table>
+<table $CODE_STYLE><tr><td $CODE_FONT>
+<pre style="
+white-space: -moz-pre-wrap;
+white-space: -pre-wrap;
+white-space: -o-pre-wrap;
+white-space: pre-wrap;
+word-wrap: break-word;
+">$(cat pythonerror.log)</pre>
+</td></tr></table>
+END
+	#}}}
+fi
 if [ -s petscerror.log ]; then
 	#PETSc{{{
 cat << END >> report.html
 <table $SECTION_STYLE><tr><td $SECTION_FONT>PETSc errors</td></tr></table>
-<table $MATLAB_STYLE><tr><td $MATLAB_FONT>
+<table $CODE_STYLE><tr><td $CODE_FONT>
 <pre style="
 white-space: -moz-pre-wrap;
 white-space: -pre-wrap;


Property changes on: issm/trunk/src
___________________________________________________________________
Modified: svn:mergeinfo
   - /issm/branches/trunk-jpl-damage/src:11427-13118
/issm/trunk-jpl/src:10936-11994,11996-12326,12333-12336,12338-12703,12705-12707,12710-13393
   + /issm/branches/trunk-jpl-damage/src:11427-13118
/issm/trunk-jpl/src:10936-11994,11996-12326,12333-12336,12338-12703,12705-12707,12710-13393,13396-13974

Modified: issm/trunk/src/Makefile.am
===================================================================
--- issm/trunk/src/Makefile.am	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/Makefile.am	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,2 +1,5 @@
-EXTRA_DIST =  perl pro py
-SUBDIRS = c modules m
+EXTRA_DIST =  perl pro
+SUBDIRS = c m wrappers 
+if ANDROID
+SUBDIRS += android
+endif

Modified: issm/trunk/src/ad/todo
===================================================================
--- issm/trunk/src/ad/todo	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/ad/todo	2012-11-16 16:10:16 UTC (rev 13975)
@@ -56,3 +56,10 @@
 - run valgrind on new adolc or old adolc. send a text on how to run it. 
 - make gdb wrapper.
 - think about ModelProcessor setup. need to keep track, before we partition, on cpu 0, of the independent declarations. 
+
+
+MPI: what's missing that equivalent of MPI.h -> no well defined api.  
+What's exposed is the internals of it.
+
+Wanted to look at changing the way for the matrices and vertices would be implemented.
+


Property changes on: issm/trunk/src/android
___________________________________________________________________
Added: svn:ignore
   + Makefile.in
Makefile



Property changes on: issm/trunk/src/android/ISSM
___________________________________________________________________
Added: svn:ignore
   + Makefile.in
Makefile
libs
obj


Modified: issm/trunk/src/c/Container/Constraints.cpp
===================================================================
--- issm/trunk/src/c/Container/Constraints.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Constraints.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -48,12 +48,11 @@
 
 	/*figure out total number of constraints combining all the cpus (no clones here)*/
 	#ifdef _HAVE_MPI_
-		MPI_Reduce(&localconstraints,&numberofconstraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-		MPI_Bcast(&numberofconstraints,1,MPI_INT,0,MPI_COMM_WORLD);
+		MPI_Reduce(&localconstraints,&numberofconstraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+		MPI_Bcast(&numberofconstraints,1,MPI_INT,0,IssmComm::GetComm());
 	#else
 		numberofconstraints=localconstraints;
 	#endif
-	
 
 	return numberofconstraints;
 }

Modified: issm/trunk/src/c/Container/Constraints.h
===================================================================
--- issm/trunk/src/c/Container/Constraints.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Constraints.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,21 +15,17 @@
 class DataSet;
 class Inputs;
 
-
 class Constraints: public DataSet{
 
 	public:
 
-		/*constructors, destructors: {{{*/
+		/*constructors, destructors*/
 		Constraints();
 		~Constraints();
-		/*}}}*/
-		/*numerics: {{{*/
+
+		/*numerics*/
 		int   NumberOfConstraints(void);
-		/*}}}*/
 
 };
 
-
 #endif //ifndef _CONSTRAINTS_H_
-

Modified: issm/trunk/src/c/Container/DataSet.cpp
===================================================================
--- issm/trunk/src/c/Container/DataSet.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/DataSet.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -29,7 +29,7 @@
 /*Constructors/Destructors*/
 /*FUNCTION DataSet::DataSet(){{{*/
 DataSet::DataSet(){
-	
+
 	sorted=0;
 	sorted_ids=NULL;
 	id_offsets=NULL;
@@ -39,7 +39,7 @@
 /*FUNCTION DataSet::DataSet(int dataset_enum){{{*/
 DataSet::DataSet(int dataset_enum){
 	enum_type=dataset_enum;
-	
+
 	sorted=0;
 	sorted_ids=NULL;
 	id_offsets=NULL;
@@ -49,11 +49,10 @@
 /*FUNCTION DataSet::Copy{{{*/
 DataSet*   DataSet::Copy(void){
 
-	DataSet* copy=NULL;
 	vector<Object*>::iterator object;
 	Object* object_copy=NULL;
 
-	copy=new DataSet(enum_type);
+	DataSet* copy=new DataSet(enum_type);
 
 	copy->sorted=sorted;
 	copy->presorted=presorted;
@@ -129,7 +128,6 @@
 /*FUNCTION DataSet::DeepEcho{{{*/
 void DataSet::DeepEcho(){
 
-
 	vector<Object*>::iterator object;
 
 	if(this==NULL)_error_("trying to echo a NULL dataset");
@@ -190,7 +188,6 @@
 
 	int id_offset;
 	int offset;
-	int i;
 
 	_assert_(this);
 	if(!sorted)_error_("trying to binary search on a non-sorted dataset!");
@@ -215,8 +212,6 @@
 
 	/*vector of objects is already sorted, just allocate the sorted ids and their
 	 * offsets:*/
-	int i;
-
 	if(objects.size()){
 
 		/*Delete existing ids*/
@@ -228,7 +223,7 @@
 		id_offsets=xNew<int>(objects.size());
 
 		/*Build id_offsets and sorted_ids*/
-		for(i=0;i<objects.size();i++){
+		for(int i=0;i<objects.size();i++){
 			id_offsets[i]=i;
 			sorted_ids[i]=objects[i]->Id();
 		}

Modified: issm/trunk/src/c/Container/DataSet.h
===================================================================
--- issm/trunk/src/c/Container/DataSet.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/DataSet.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,45 +22,44 @@
 class Patch;
 
 class DataSet{
-	
+
 	public: 
-		
+
 		/*internals: */
 		std::vector<Object*> objects;
-		
+
 		/*type of dataset: */
 		int             enum_type;
-		
+
 		/*sorting: */
 		int             sorted;
 		int             presorted;
 		int*            sorted_ids;
 		int*            id_offsets;
 
-		/*constructors, destructors: {{{*/
+		/*constructors, destructors*/
 		DataSet();
 		DataSet(int enum_type);
 		~DataSet();
-		/*}}}*/
-		/*management: {{{*/
-		int   GetEnum();
-		int   GetEnum(int offset);
-		void  Echo();
-		void  DeepEcho();
-		int   AddObject(Object* object);
-		int   DeleteObject(int id);
-		int   Size();
-		void  clear();
-		Object* GetObjectByOffset(int offset);
-		Object* GetObjectById(int* poffset,int eid);
-		void  Presort();
-		void  SetSorting(int* in_sorted_ids,int* in_id_offsets);
-		void  Sort();
-		DataSet* Copy(void);
-		int   DeleteObject(Object* object);
-		Results* SpawnTriaResults(int* indices);
-		/*}}}*/
 
+		/*management*/
+		int      GetEnum();
+		int      GetEnum(int offset);
+		void     Echo();
+		void     DeepEcho();
+		int      AddObject(Object *object);
+		int      DeleteObject(int id);
+		int      Size();
+		void     clear();
+		Object  *GetObjectByOffset(int  offset);
+		Object  *GetObjectById(int *poffset,int eid);
+		void     Presort();
+		void     SetSorting(int *in_sorted_ids,int*in_id_offsets);
+		void     Sort();
+		DataSet *Copy(void);
+		int      DeleteObject(Object *object);
+		Results *SpawnTriaResults(int *indices);
+
 };
 
 #endif

Modified: issm/trunk/src/c/Container/Elements.cpp
===================================================================
--- issm/trunk/src/c/Container/Elements.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Elements.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -45,7 +45,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		element=(Element*)(*object);
+		element=dynamic_cast<Element*>((*object));
 		element->Configure(elements,loads,nodes,materials,parameters);
 
 	}
@@ -57,16 +57,16 @@
 
 	//Process results to be output in the correct units
 	for(int i=0;i<this->Size();i++){
-		Element* element=(Element*)this->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
 		element->ProcessResultsUnits();
 	}
 }
 /*}}}*/
 /*FUNCTION Elements::DeleteResults{{{*/
 void Elements::DeleteResults(void){
-	
+
 	for (int i=0;i<this->Size();i++){
-		Element* element=(Element*)this->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
 		element->DeleteResults();
 	}
 }
@@ -107,7 +107,7 @@
 	 *
 	 * We will use the Patch object, which will store all of the information needed, and will be able 
 	 * to output itself to disk on its own. See object/Patch.h for format of this object.*/
-	
+
 	/*First, determine maximum number of vertices, nodes, and number of results: */
 	numrows=0;
 	numvertices=0;
@@ -115,7 +115,7 @@
 
 	for(i=0;i<this->Size();i++){
 
-		Element* element=(Element*)this->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
 		element->PatchSize(&element_numrows,&element_numvertices,&element_numnodes);
 
 		numrows+=element_numrows;
@@ -125,12 +125,12 @@
 
 	/*Synchronize across cluster, so as to not end up with different sizes for each patch on each cpu: */
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&numvertices,&max_numvertices,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
-	MPI_Bcast(&max_numvertices,1,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Reduce (&numvertices,&max_numvertices,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&max_numvertices,1,MPI_INT,0,IssmComm::GetComm());
 	numvertices=max_numvertices;
 
-	MPI_Reduce (&numnodes,&max_numnodes,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
-	MPI_Bcast(&max_numnodes,1,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Reduce (&numnodes,&max_numnodes,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&max_numnodes,1,MPI_INT,0,IssmComm::GetComm());
 	numnodes=max_numnodes;
 	#endif
 
@@ -140,7 +140,7 @@
 	/*Now, go through elements, and fill the Patch object: */
 	count=0;
 	for(i=0;i<this->Size();i++){
-		Element* element=(Element*)this->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
 		element->PatchFill(&count,patch);
 	}
 
@@ -155,7 +155,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		element=(Element*)(*object);
+		element=dynamic_cast<Element*>((*object));
 		element->SetCurrentConfiguration(elements,loads,nodes,materials,parameters);
 
 	}
@@ -165,25 +165,27 @@
 /*FUNCTION Elements::ToResults{{{*/
 void Elements::ToResults(Results* results,Parameters* parameters){
 
-	int i;
-	
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank;
+	int num_procs;
 
-	Patch  *patch        = NULL;
-	int    *resultsenums = NULL;
-	int    *resultssizes  = NULL;
-	int    *resultssteps  = NULL;
-	IssmDouble *resultstimes = NULL;
-	IssmDouble *vector_serial= NULL;
-	Vector<IssmDouble>*     vector       = NULL;
-	bool   io_gather;
-	bool   results_as_patches;
-	int    numberofvertices,numberofelements;
-	int    numberofresults,vectorsize;
-	int    rank;
-	int    minrank;
+	Patch               *patch              = NULL;
+	int                 *resultsenums       = NULL;
+	int                 *resultssizes       = NULL;
+	int                 *resultssteps       = NULL;
+	IssmDouble          *resultstimes       = NULL;
+	IssmDouble          *vector_serial      = NULL;
+	Vector<IssmDouble> *vector = NULL;
+	bool                io_gather;
+	bool                results_as_patches;
+	int                 numberofvertices     ,numberofelements;
+	int                 numberofresults      ,vectorsize;
+	int                 rank;
+	int                 minrank;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+	num_procs=IssmComm::GetSize();
+
 	/*Recover parameters: */
 	parameters->FindParam(&io_gather,SettingsIoGatherEnum);
 	parameters->FindParam(&results_as_patches,SettingsResultsAsPatchesEnum);
@@ -197,7 +199,7 @@
 		#ifdef _HAVE_MPI_
 		if(this->Size()) rank=my_rank;
 		else rank=num_procs;
-		MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
+		MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,IssmComm::GetComm());
 		#else
 		minrank=my_rank;
 		#endif
@@ -205,11 +207,11 @@
 		/*see what the first element of this partition has in stock (this is common to all partitions)*/
 		if(my_rank==minrank){
 			if(this->Size()==0) _error_("Cannot write results because there is no element??");
-			Element* element=(Element*)this->GetObjectByOffset(0);
+			Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(0));
 			element->ListResultsInfo(&resultsenums,&resultssizes,&resultstimes,&resultssteps,&numberofresults);
 		}
 		#ifdef _HAVE_MPI_
-		MPI_Bcast(&numberofresults,1,MPI_DOUBLE,minrank,MPI_COMM_WORLD);
+		MPI_Bcast(&numberofresults,1,MPI_DOUBLE,minrank,IssmComm::GetComm());
 		#endif
 
 		/*Get out if there is no results. Otherwise broadcast info*/
@@ -221,10 +223,10 @@
 			resultstimes=xNew<IssmDouble>(numberofresults);
 			resultssteps=xNew<int>(numberofresults);
 		}
-		MPI_Bcast(resultsenums,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD);
-		MPI_Bcast(resultssizes,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD);
-		MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE,minrank,MPI_COMM_WORLD);
-		MPI_Bcast(resultssteps,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD);
+		MPI_Bcast(resultsenums,numberofresults,MPI_INT,minrank,IssmComm::GetComm());
+		MPI_Bcast(resultssizes,numberofresults,MPI_INT,minrank,IssmComm::GetComm());
+		MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE,minrank,IssmComm::GetComm());
+		MPI_Bcast(resultssteps,numberofresults,MPI_INT,minrank,IssmComm::GetComm());
 		#endif
 
 		/*Loop over all results and get nodal vector*/
@@ -237,7 +239,7 @@
 			vector=new Vector<IssmDouble>(vectorsize);
 
 			for(int j=0;j<this->Size();j++){
-				Element* element=(Element*)this->GetObjectByOffset(j);
+				Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(j));
 				element->GetVectorFromResults(vector,i,resultsenums[i],resultssizes[i]);
 			}
 			vector->Assemble();
@@ -291,15 +293,39 @@
 	delete patch;
 }
 /*}}}*/
+/*FUNCTION Elements::MaxNumNodes{{{*/
+int Elements::MaxNumNodes(void){
+
+	int max=0;
+	int allmax;
+	int numnodes=0;
+
+	/*Now go through all elements, and get how many nodes they own, unless they are clone nodes: */
+	for(int i=0;i<this->Size();i++){
+
+		Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
+		numnodes=element->GetNumberOfNodes();
+		if(numnodes>max)max=numnodes;
+	}
+
+	/*Grab max of all cpus: */
+	#ifdef _HAVE_MPI_
+	MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
+	max=allmax;
+	#endif
+
+	return max;
+}
+/*}}}*/
 /*FUNCTION Elements::NumberOfElements{{{*/
 int Elements::NumberOfElements(void){
 
-	int local_nelem=0;
+	int local_nelem;
 	int numberofelements;
 
 	local_nelem=this->Size();
 	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)&local_nelem,(void*)&numberofelements,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+	MPI_Allreduce ( (void*)&local_nelem,(void*)&numberofelements,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
 	#else
 	numberofelements=local_nelem;
 	#endif
@@ -311,7 +337,7 @@
 void Elements::InputDuplicate(int input_enum,int output_enum){
 
 	for(int i=0;i<this->Size();i++){
-		Element* element=(Element*)this->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
 		element->InputDuplicate(input_enum,output_enum);
 	}
 }

Modified: issm/trunk/src/c/Container/Elements.h
===================================================================
--- issm/trunk/src/c/Container/Elements.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Elements.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,20 +19,20 @@
 
 	public:
 
-		/*constructors, destructors: {{{*/
+		/*constructors, destructors*/
 		Elements();
 		~Elements();
-		/*}}}*/
-		/*numerics: {{{*/
-		void Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
-		void DeleteResults(void);
-		void ProcessResultsUnits(void);
-		void SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
-		void ToResults(Results* results,Parameters* parameters);
+
+		/*numerics*/
+		void   Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
+		void   DeleteResults(void);
+		int    MaxNumNodes(void);
+		void   ProcessResultsUnits(void);
+		void   SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
+		void   ToResults(Results* results,Parameters* parameters);
 		Patch* ResultsToPatch(void);
-		int   NumberOfElements(void);
-		void InputDuplicate(int input_enum,int output_enum);
-		/*}}}*/
+		int    NumberOfElements(void);
+		void   InputDuplicate(int input_enum,int output_enum);
 
 };
 

Modified: issm/trunk/src/c/Container/Inputs.cpp
===================================================================
--- issm/trunk/src/c/Container/Inputs.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Inputs.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -46,7 +46,7 @@
 	/*Go through inputs and check whether any input with the same name is already in: */
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=(Input*)(*object); 
+		input=dynamic_cast<Input*>(*object);
 		if (input->InstanceEnum()==enum_type){
 			found=true;
 			break;
@@ -74,7 +74,7 @@
 	/*Go through inputs and check whether any input with the same name is already in: */
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=(Input*)(*object); 
+		input=dynamic_cast<Input*>(*object);
 		if (input->InstanceEnum()==enum_type){
 			found=true;
 			break;
@@ -102,7 +102,7 @@
 	/*Go through inputs and check whether any input with the same name is already in: */
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=(Input*)(*object); 
+		input=dynamic_cast<Input*>(*object); 
 		if (input->InstanceEnum()==enum_type){
 			found=true;
 			break;
@@ -130,7 +130,7 @@
 	/*Go through inputs and check whether any input with the same name is already in: */
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=(Input*)(*object); 
+		input=dynamic_cast<Input*>(*object);
 		if (input->InstanceEnum()==enum_type){
 			found=true;
 			break;
@@ -162,7 +162,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=(Input*)(*object); 
+		input=dynamic_cast<Input*>(*object);
 
 		if (input->InstanceEnum()==in_input->InstanceEnum()){
 			this->DeleteObject(input);
@@ -184,7 +184,7 @@
 
 	/*Delete existing input of newenumtype if it exists*/
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		input=(Input*)(*object); 
+		input=dynamic_cast<Input*>(*object);
 
 		if (input->InstanceEnum()==newenumtype){
 			this->DeleteObject(input);
@@ -195,7 +195,7 @@
 	/*Change enum_type of input of oldenumtype*/
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=(Input*)(*object); 
+		input=dynamic_cast<Input*>(*object);
 
 		if (input->InstanceEnum()==oldenumtype){
 			input->ChangeEnum(newenumtype);
@@ -206,10 +206,9 @@
 /*}}}*/
 /*FUNCTION Inputs::ConstrainMin{{{*/
 void  Inputs::ConstrainMin(int constrain_enum, IssmDouble minimum){
-	   
-	Input* constrain_input=NULL; 
+
 	/*Find x and y inputs: */
-	constrain_input=(Input*)this->GetInput(constrain_enum);
+	Input* constrain_input=dynamic_cast<Input*>(this->GetInput(constrain_enum));
 
 	/*some checks: */
 	if(!constrain_input) _error_("input " << EnumToStringx(constrain_enum) << " could not be found!");
@@ -225,7 +224,7 @@
 	IssmDouble norm;
 
 	/*Get input*/
-	Input* input=(Input*)this->GetInput(enumtype);
+	Input* input=dynamic_cast<Input*>(this->GetInput(enumtype));
 
 	/*Apply ContrainMin: */
 	if (input){
@@ -246,7 +245,7 @@
 	IssmDouble max;
 
 	/*Get input*/
-	Input* input=(Input*)this->GetInput(enumtype);
+	Input* input=dynamic_cast<Input*>(this->GetInput(enumtype));
 
 	/*Apply ContrainMin: */
 	if (input){
@@ -267,7 +266,7 @@
 	IssmDouble max;
 
 	/*Get input*/
-	Input* input=(Input*)this->GetInput(enumtype);
+	Input* input=dynamic_cast<Input*>(this->GetInput(enumtype));
 
 	/*Apply ContrainMin: */
 	if (input){
@@ -288,7 +287,7 @@
 	IssmDouble min;
 
 	/*Get input*/
-	Input* input=(Input*)this->GetInput(enumtype);
+	Input* input=dynamic_cast<Input*>(this->GetInput(enumtype));
 
 	/*Apply ContrainMin: */
 	if (input){
@@ -309,7 +308,7 @@
 	IssmDouble min;
 
 	/*Get input*/
-	Input* input=(Input*)this->GetInput(enumtype);
+	Input* input=dynamic_cast<Input*>(this->GetInput(enumtype));
 
 	/*Apply ContrainMin: */
 	if (input){
@@ -331,7 +330,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=(Input*)(*object); 
+		input=dynamic_cast<Input*>(*object);
 
 		if (input->InstanceEnum()==enum_name){
 			return input;
@@ -348,7 +347,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=(Input*)(*object); 
+		input=dynamic_cast<Input*>(*object);
 
 		if (input->InstanceEnum()==enum_type){
 			this->DeleteObject(input);
@@ -363,19 +362,16 @@
 /*FUNCTION Inputs::DuplicateInput{{{*/
 void  Inputs::DuplicateInput(int original_enum,int new_enum){
 
-	Input* original=NULL;
-	Input* copy=NULL;
-
 	/*Make a copy of the original input: */
-	original=(Input*)this->GetInput(original_enum);
+	Input* original=dynamic_cast<Input*>(this->GetInput(original_enum));
 	if(!original)_error_("could not find input with enum: " << EnumToStringx(original_enum)); 
-	copy=(Input*)original->copy();
+	Input* copy=dynamic_cast<Input*>(original->copy());
 
 	/*Change copy enum to reinitialized_enum: */
 	copy->ChangeEnum(new_enum);
 
 	/*Add copy into inputs, it will wipe off the one already there: */
-	this->AddInput((Input*)copy);
+	this->AddInput(dynamic_cast<Input*>(copy));
 }
 /*}}}*/
 /*FUNCTION Inputs::SpawnTriaInputs{{{*/
@@ -393,7 +389,7 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
 		/*Create new input*/
-		inputin=(Input*)(*object); 
+		inputin=dynamic_cast<Input*>(*object);
 		inputout=inputin->SpawnTriaInput(indices);
 
 		/*Add input to new inputs*/
@@ -406,13 +402,10 @@
 /*}}}*/
 /*FUNCTION Inputs::AXPY{{{*/
 void  Inputs::AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum){
-	   
-	Input* xinput=NULL;
-	Input* yinput=NULL;
 
 	/*Find x and y inputs: */
-	xinput=(Input*)this->GetInput(MeshXEnum);
-	yinput=(Input*)this->GetInput(MeshYEnum);
+	Input* xinput=dynamic_cast<Input*>(this->GetInput(MeshXEnum));
+	Input* yinput=dynamic_cast<Input*>(this->GetInput(MeshYEnum));
 
 	/*some checks: */
 	if(!xinput) _error_("input " << EnumToStringx(MeshXEnum) << " could not be found!");
@@ -430,7 +423,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=(Input*)(*object);
+		input=dynamic_cast<Input*>(*object);
 		input->Configure(parameters);
 
 	}

Modified: issm/trunk/src/c/Container/Inputs.h
===================================================================
--- issm/trunk/src/c/Container/Inputs.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Inputs.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,33 +22,29 @@
 
 	public:
 
-		/*constructors, destructors: {{{*/
+		/*constructors, destructors*/
 		Inputs();
 		~Inputs();
 
-		/*}}}*/
-		/*numerics: {{{*/
-		int     AddInput(Input* in_input);
-		void    ChangeEnum(int enumtype,int new_enumtype);
-		void    ConstrainMin(int constrain_enum, IssmDouble minimum);
-		int     DeleteInput(int enum_type);
-		void    DuplicateInput(int original_enum,int new_enum);
-		Input*  GetInput(int enum_name);
-		Inputs* SpawnTriaInputs(int* indices);
-		void    AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum);
+		/*numerics*/
+		int        AddInput(Input* in_input);
+		void       ChangeEnum(int enumtype,int new_enumtype);
+		void       ConstrainMin(int constrain_enum, IssmDouble minimum);
+		int        DeleteInput(int enum_type);
+		void       DuplicateInput(int original_enum,int new_enum);
+		Input*     GetInput(int enum_name);
+		Inputs*    SpawnTriaInputs(int* indices);
+		void       AXPY(int MeshYEnum, IssmDouble scalar, int MeshXEnum);
 		IssmDouble  InfinityNorm(int enumtype);
 		IssmDouble  Max(int enumtype);
 		IssmDouble  MaxAbs(int enumtype);
 		IssmDouble  Min(int enumtype);
 		IssmDouble  MinAbs(int enumtype);
-		
 		void GetInputAverage(IssmDouble* pvalue, int enum_type);
 		void GetInputValue(bool* pvalue,int enum_type);
 		void GetInputValue(int* pvalue,int enum_type);
 		void GetInputValue(IssmDouble* pvalue,int enum_type);
-
 		void Configure(Parameters* parameters);
-		/*}}}*/
 
 };
 

Modified: issm/trunk/src/c/Container/Loads.cpp
===================================================================
--- issm/trunk/src/c/Container/Loads.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Loads.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -45,34 +45,135 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		load=(Load*)(*object);
+		load=dynamic_cast<Load*>(*object);
 		load->Configure(elements,loads,nodes,vertices,materials,parameters);
 
 	}
 
 }
 /*}}}*/
-/*FUNCTION Loads::NumberOfLoads{{{*/
+/*FUNCTION Loads::IsPenalty{{{*/
+bool Loads::IsPenalty(int analysis_type){
+
+	int ispenalty=0;
+	int allispenalty=0;
+
+	/*Now go through all loads, and get how many nodes they own, unless they are clone nodes: */
+	for(int i=0;i<this->Size();i++){
+
+		Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));
+		if (load->InAnalysis(analysis_type)){
+			if(load->IsPenalty()) ispenalty++;
+		}
+	}
+
+	/*Grab sum of all cpus: */
+#ifdef _HAVE_MPI_
+	MPI_Allreduce((void*)&ispenalty,(void*)&allispenalty,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
+	ispenalty=allispenalty;
+#endif
+
+	if(ispenalty)
+	 return true;
+	else
+	 return false;
+}
+/*}}}*/
+/*FUNCTION Loads::MaxNumNodes{{{*/
+int Loads::MaxNumNodes(int analysis_type){
+
+	int max=0;
+	int allmax;
+	int numnodes=0;
+
+	/*Now go through all loads, and get how many nodes they own, unless they are clone nodes: */
+	for(int i=0;i<this->Size();i++){
+
+		Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));
+		if (load->InAnalysis(analysis_type)){
+			numnodes=load->GetNumberOfNodes();
+			if(numnodes>max)max=numnodes;
+		}
+	}
+
+	/*Grab max of all cpus: */
+#ifdef _HAVE_MPI_
+	MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
+	max=allmax;
+#endif
+
+	return max;
+}
+/*}}}*/
+/*FUNCTION Loads::NumberOfLoads(){{{*/
 int Loads::NumberOfLoads(void){
 
-	int localloads=0;
-	int numberofloads=0;
+	int localloads;
+	int numberofloads;
 
 	/*Get number of local loads*/
 	localloads=this->Size();
 
 	/*figure out total number of loads combining all the cpus (no clones here)*/
 	#ifdef _HAVE_MPI_
-	MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&numberofloads,1,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&numberofloads,1,MPI_INT,0,IssmComm::GetComm());
 	#else
 	numberofloads=localloads;
 	#endif
 
+	return numberofloads;
+}
+/*}}}*/
+/*FUNCTION Loads::NumberOfLoads(int analysis){{{*/
+int Loads::NumberOfLoads(int analysis_type){
 
+	int localloads = 0;
+	int numberofloads;
+
+	/*Get number of local loads*/
+	for(int i=0;i<this->Size();i++){
+
+		Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));
+
+		/*Check that this load corresponds to our analysis currently being carried out: */
+		if (load->InAnalysis(analysis_type)) localloads++;
+	}
+
+	/*figure out total number of loads combining all the cpus (no clones here)*/
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&numberofloads,1,MPI_INT,0,IssmComm::GetComm());
+#else
+	numberofloads=localloads;
+#endif
+
 	return numberofloads;
 }
 /*}}}*/
+/*FUNCTION Loads::Size(){{{*/
+int Loads::Size(void){
+
+	return this->DataSet::Size();
+}
+/*}}}*/
+/*FUNCTION Loads::Size(int analysis){{{*/
+int Loads::Size(int analysis_type){
+
+	int localloads = 0;
+
+	/*Get number of local loads*/
+	for(int i=0;i<this->Size();i++){
+
+		Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));
+
+		/*Check that this load corresponds to our analysis currently being carried out: */
+		if (load->InAnalysis(analysis_type)) localloads++;
+	}
+
+	return localloads;
+}
+/*}}}*/
 /*FUNCTION Loads::SetCurrentConfiguration{{{*/
 void Loads::SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
 
@@ -81,7 +182,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		load=(Load*)(*object);
+		load=dynamic_cast<Load*>(*object);
 		load->SetCurrentConfiguration(elements,loads,nodes,vertices,materials,parameters);
 
 	}

Modified: issm/trunk/src/c/Container/Loads.h
===================================================================
--- issm/trunk/src/c/Container/Loads.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Loads.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,15 +19,19 @@
 
 	public:
 
-		/*constructors, destructors: {{{*/
+		/*constructors, destructors*/
 		Loads();
 		~Loads();
-		/*}}}*/
-		/*numerics: {{{*/
+
+		/*numerics*/
 		void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
+		bool  IsPenalty(int analysis);
+		int   MaxNumNodes(int analysis);
 		int   NumberOfLoads(void);
+		int   NumberOfLoads(int analysis);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
-		/*}}}*/
+		int   Size(int analysis);
+		int   Size(void);
 
 };
 

Modified: issm/trunk/src/c/Container/Materials.cpp
===================================================================
--- issm/trunk/src/c/Container/Materials.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Materials.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -45,7 +45,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		material=(Material*)(*object);
+		material=dynamic_cast<Material*>(*object);
 		material->Configure(elements);
 
 	}

Modified: issm/trunk/src/c/Container/Materials.h
===================================================================
--- issm/trunk/src/c/Container/Materials.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Materials.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,13 +18,12 @@
 
 	public:
 
-		/*constructors, destructors: {{{*/
+		/*constructors, destructors*/
 		Materials();
 		~Materials();
-		/*}}}*/
-		/*numerics: {{{*/
+
+		/*numerics*/
 		void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
-		/*}}}*/
 
 };
 

Modified: issm/trunk/src/c/Container/Nodes.cpp
===================================================================
--- issm/trunk/src/c/Container/Nodes.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Nodes.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -45,7 +45,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		node=(Node*)(*object);
+		node=dynamic_cast<Node*>(*object);
 		node->Configure(nodes,vertices);
 
 	}
@@ -55,9 +55,6 @@
 /*FUNCTION Nodes::DistributeDofs{{{*/
 void  Nodes::DistributeDofs(int analysis_type,int setenum){
 
-	extern int num_procs;
-	extern int my_rank;
-
 	int  i;
 	int  dofcount=0;
 	int  maxdofspernode=0;
@@ -66,12 +63,16 @@
 	int* alltruedofs=NULL;
 	int  numnodes=0;
 
+	/*recover my_rank:*/
+	int my_rank   = IssmComm::GetRank();
+	int num_procs = IssmComm::GetSize();
+
 	/*some check: */
 	_assert_(setenum==GsetEnum || setenum==FsetEnum || setenum==SsetEnum);
 
 	/*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/
 	for (i=0;i<this->Size();i++){
-		Node* node=(Node*)this->GetObjectByOffset(i);
+		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
 		if (node->InAnalysis(analysis_type)){
@@ -85,22 +86,20 @@
 	 * First: get number of dofs for each cpu*/
 	alldofcount=xNew<int>(num_procs);
 	#ifdef _HAVE_MPI_
-	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
-	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,IssmComm::GetComm());
+	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,IssmComm::GetComm());
 	#else
 	alldofcount[0]=dofcount;
 	#endif
 
 	/* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
 	dofcount=0;
-	if(my_rank!=0){
-		for(i=0;i<my_rank;i++){
-			dofcount+=alldofcount[i];
-		}
+	for(i=0;i<my_rank;i++){
+		dofcount+=alldofcount[i];
 	}
 	for (i=0;i<this->Size();i++){
 		/*Check that this node corresponds to our analysis currently being carried out: */
-		Node* node=(Node*)this->GetObjectByOffset(i);
+		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
 		if (node->InAnalysis(analysis_type)){
 			node->OffsetDofs(dofcount,setenum);
 		}
@@ -117,21 +116,21 @@
 	}
 
 	for (i=0;i<this->Size();i++){
-		Node* node=(Node*)this->GetObjectByOffset(i);
+		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
 		if (node->InAnalysis(analysis_type)){
 			node->ShowTrueDofs(truedofs,maxdofspernode,setenum);//give maxdofspernode, column size, so that nodes can index into truedofs
 		}
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
+	MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,IssmComm::GetComm());
 	#else
 	for(i=0;i<numnodes*maxdofspernode;i++)alltruedofs[i]=truedofs[i];
 	#endif
 
 	/* Now every cpu knows the true dofs of everyone else that is not a clone*/
 	for (i=0;i<this->Size();i++){
-		Node* node=(Node*)this->GetObjectByOffset(i);
+		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
 		if (node->InAnalysis(analysis_type)){
 			node->UpdateCloneDofs(alltruedofs,maxdofspernode,setenum);
 		}
@@ -147,19 +146,18 @@
 void  Nodes::FlagClones(int analysis_type){
 
 	int i;
-	extern int num_procs;
+	int num_procs;
+	int numnodes;
 
-	int* ranks=NULL;
-	int* minranks=NULL;
-	int  numnodes;
+	/*recover num_procs: */
+	num_procs=IssmComm::GetSize();
 
 	/*Figure out number of nodes for this analysis: */
 	numnodes=this->NumberOfNodes(analysis_type);
 
 	/*Allocate ranks: */
-	ranks=xNew<int>(numnodes);
-	minranks=xNew<int>(numnodes);
-
+	int* ranks    = xNew<int>(numnodes);
+	int* minranks = xNew<int>(numnodes);
 	for(i=0;i<numnodes;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit.
 
 	/*Now go through all our objects and ask them to report to who they belong (which rank): */
@@ -170,7 +168,7 @@
 	 * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing 
 	 * order of cpu rank. This is also why we initialized this array to num_procs.*/
 	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)ranks,(void*)minranks,numnodes,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
+	MPI_Allreduce((void*)ranks,(void*)minranks,numnodes,MPI_INT,MPI_MIN,IssmComm::GetComm());
 	#else
 	for(i=0;i<numnodes;i++)minranks[i]=ranks[i];
 	#endif
@@ -178,7 +176,7 @@
 	/*Now go through all objects, and use minranks to flag which objects are cloned: */
 	for(i=0;i<this->Size();i++){
 
-		Node* node=(Node*)this->GetObjectByOffset(i);
+		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
 		if (node->InAnalysis(analysis_type)){
@@ -198,26 +196,26 @@
 int   Nodes::MaxNumDofs(int analysis_type,int setenum){
 
 	int i;
-	int   max=0;
-	int   allmax;
-	int   numdofs=0;
+	int max=0;
+	int allmax;
+	int numdofs=0;
 
 	/*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */
 	for(i=0;i<this->Size();i++){
 
-		Node* node=(Node*)this->GetObjectByOffset(i);
+		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
 		if (node->InAnalysis(analysis_type)){
 
 			numdofs=node->GetNumberOfDofs(NoneApproximationEnum,setenum);
-			if (numdofs>max)max=numdofs;
+			if(numdofs>max)max=numdofs;
 		}
 	}
 
 	/*Grab max of all cpus: */
 	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
+	MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
 	max=allmax;
 	#endif
 
@@ -227,35 +225,41 @@
 /*FUNCTION Nodes::NumberOfDofs{{{*/
 int   Nodes::NumberOfDofs(int analysis_type,int setenum){
 
-	int i;
-	
-	int   numdofs=0;
 	int   allnumdofs;
 
+	/*Get number of dofs on current cpu (excluding clones)*/
+	int numdofs=this->NumberOfDofsLocal(analysis_type,setenum);
+
+	/*Gather from all cpus: */
+	#ifdef _HAVE_MPI_
+	MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
+	#else
+	allnumdofs=numdofs;
+	#endif
+	return allnumdofs;
+}
+/*}}}*/
+/*FUNCTION Nodes::NumberOfDofsLocal{{{*/
+int   Nodes::NumberOfDofsLocal(int analysis_type,int setenum){
+
+	int   numdofs=0;
+
 	/*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */
-	for(i=0;i<this->Size();i++){
+	for(int i=0;i<this->Size();i++){
 
-		Node* node=(Node*)this->GetObjectByOffset(i);
+		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
 		if (node->InAnalysis(analysis_type)){
 
 			/*Ok, this object is a node, ask it to plug values into partition: */
 			if (!node->IsClone()){
-
 				numdofs+=node->GetNumberOfDofs(NoneApproximationEnum,setenum);
-
 			}
 		}
 	}
 
-	/*Gather from all cpus: */
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
-	#else
-	allnumdofs=numdofs;
-	#endif
-	return allnumdofs;
+	return numdofs;
 }
 /*}}}*/
 /*FUNCTION Nodes::NumberOfNodes(){{{*/
@@ -263,14 +267,12 @@
 
 	/*Careful! only use once all clones have been setup for all nodes!: */
 
-	int i;
-	
-	int   numnodes=0;
-	int   allnumnodes=0;
+	int numnodes=0;
+	int allnumnodes=0;
 
 	/*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */
-	for(i=0;i<this->Size();i++){
-		Node* node=(Node*)this->GetObjectByOffset(i);
+	for(int i=0;i<this->Size();i++){
+		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
 
 		/*Ok, this object is a node, ask it to plug values into partition: */
 		if (!node->IsClone()) numnodes++;
@@ -278,7 +280,7 @@
 
 	/*Gather from all cpus: */
 	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)&numnodes,(void*)&allnumnodes,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+	MPI_Allreduce ( (void*)&numnodes,(void*)&allnumnodes,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
 	#else
 	allnumnodes=numnodes;
 	#endif
@@ -297,7 +299,7 @@
 
 	for(i=0;i<this->Size();i++){
 
-		Node* node=(Node*)this->GetObjectByOffset(i);
+		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
 		if (node->InAnalysis(analysis_type)){
@@ -308,47 +310,39 @@
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&max_sid,&node_max_sid,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
-	MPI_Bcast(&node_max_sid,1,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Reduce (&max_sid,&node_max_sid,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_max_sid,1,MPI_INT,0,IssmComm::GetComm());
 	max_sid=node_max_sid;
 	#endif
 
-	if(max_sid==1){
-		return 0;
-	}
-	else{
-		/*sid starts at 0*/
-		max_sid++;
-	
-		/*return*/
-		return max_sid;
-	}
+	/*sid starts at 0*/
+	max_sid++;
+
+	/*return*/
+	return max_sid;
 }
 /*}}}*/
 /*FUNCTION Nodes::Ranks{{{*/
 void   Nodes::Ranks(int* ranks,int analysis_type){
 
-	/*Go through nodes, and for each object, report it cpu: */
-
-	int i;
-	int rank;
+	int my_rank;
 	int sid;
-	
-	for(i=0;i<this->Size();i++){
 
-		Node* node=(Node*)this->GetObjectByOffset(i);
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
 
+	/*Go through nodes, and for each object, report it cpu: */
+	for(int i=0;i<this->Size();i++){
+
+		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+
 		/*Check that this node corresponds to our analysis currently being carried out: */
 		if (node->InAnalysis(analysis_type)){
-
-			rank=node->MyRank();
+			/*Plug rank into ranks, according to sid: */
 			sid=node->Sid();
-
-			/*Plug rank into ranks, according to id: */
-			ranks[sid]=rank; 
+			ranks[sid]=my_rank; 
 		}
 	}
-	return;
 }
 /*}}}*/
 /*FUNCTION Nodes::SetCurrentConfiguration{{{*/
@@ -357,12 +351,11 @@
 	vector<Object*>::iterator object;
 	Node* node=NULL;
 
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
+	for (object=objects.begin() ; object < objects.end(); object++ ){
 
-		node=(Node*)(*object);
+		node=dynamic_cast<Node*>(*object);
 		node->SetCurrentConfiguration(nodes,vertices);
 
 	}
-
 }
 /*}}}*/

Modified: issm/trunk/src/c/Container/Nodes.h
===================================================================
--- issm/trunk/src/c/Container/Nodes.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Nodes.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,21 +12,21 @@
 
 	public:
 
-		/*constructors, destructors: {{{*/
+		/*constructors, destructors*/
 		Nodes();
 		~Nodes();
-		/*}}}*/
-		/*numerics: {{{*/
+
+		/*numerics*/
 		void  Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
 		void  DistributeDofs(int analysis_type,int SETENUM);
 		void  FlagClones(int analysis_type);
 		int   MaxNumDofs(int analysis_type,int setenum);
 		int   NumberOfDofs(int analysis_type,int setenum);
+		int   NumberOfDofsLocal(int analysis_type,int setenum);
 		int   NumberOfNodes(int analysis_type);
 		int   NumberOfNodes(void);
 		void  Ranks(int* ranks,int analysis_type);
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters);
-		/*}}}*/
 
 };
 

Modified: issm/trunk/src/c/Container/Observations.cpp
===================================================================
--- issm/trunk/src/c/Container/Observations.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Observations.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -39,7 +39,7 @@
 Observations::Observations(IssmPDouble* observations_list,IssmPDouble* x,IssmPDouble* y,int n,Options* options){
 
 	/*Intermediaries*/
-	int          i,j,maxdepth,level,counter,index;
+	int          i,maxdepth,level,counter,index;
 	int          xi,yi;
 	IssmPDouble  xmin,xmax,ymin,ymax;
 	IssmPDouble  offset,minlength,minspacing,mintrimming,maxtrimming;
@@ -87,7 +87,7 @@
 		/*First check that this observation is not too close from another one*/
 		this->quadtree->ClosestObs(&index,x[i],y[i]);
 		if(index>=0){
-			observation=(Observation*)this->GetObjectByOffset(index);
+			observation=dynamic_cast<Observation*>(this->GetObjectByOffset(index));
 			if(pow(observation->x-x[i],2)+pow(observation->y-y[i],2) < minspacing) continue;
 		}
 
@@ -120,7 +120,6 @@
 void Observations::ClosestObservation(IssmPDouble *px,IssmPDouble *py,IssmPDouble *pobs,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius){
 
 	/*Output and Intermediaries*/
-	bool         stop;
 	int          nobs,i,index;
 	IssmPDouble  h2,hmin2,radius2;
 	int         *indices      = NULL;
@@ -135,7 +134,7 @@
 	/*Find all observations that are in radius*/
 	this->quadtree->RangeSearch(&indices,&nobs,x_interp,y_interp,radius);
 	for (i=0;i<nobs;i++){
-		observation=(Observation*)this->GetObjectByOffset(indices[i]);
+		observation=dynamic_cast<Observation*>(this->GetObjectByOffset(indices[i]));
 		h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp);
 
 		if(i==0){
@@ -157,7 +156,7 @@
 		*pobs=UNDEF;
 	}
 	else{
-		observation=(Observation*)this->GetObjectByOffset(indices[index]);
+		observation=dynamic_cast<Observation*>(this->GetObjectByOffset(indices[index]));
 		*px=observation->x;
 		*py=observation->y;
 		*pobs=observation->value;
@@ -194,7 +193,7 @@
 	}
 	nobs = 0;
 	for (i=0;i<tempnobs;i++){
-		observation=(Observation*)this->GetObjectByOffset(tempindices[i]);
+		observation=dynamic_cast<Observation*>(this->GetObjectByOffset(tempindices[i]));
 		h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp);
 
 		if(nobs==maxdata && h2>radius2) continue;
@@ -236,7 +235,7 @@
 
 		/*Loop over all observations and fill in x, y and obs*/
 		for (i=0;i<nobs;i++){
-			observation=(Observation*)this->GetObjectByOffset(indices[i]);
+			observation=dynamic_cast<Observation*>(this->GetObjectByOffset(indices[i]));
 			observation->WriteXYObs(&x[i],&y[i],&obs[i]);
 		}
 	}
@@ -265,7 +264,7 @@
 		y   = xNew<IssmPDouble>(nobs);
 		obs = xNew<IssmPDouble>(nobs);
 		for(int i=0;i<this->Size();i++){
-			observation=(Observation*)this->GetObjectByOffset(i);
+			observation=dynamic_cast<Observation*>(this->GetObjectByOffset(i));
 			observation->WriteXYObs(&x[i],&y[i],&obs[i]);
 		}
 	}
@@ -450,10 +449,10 @@
 	for(j=0;j<n;j++) gamma[j]   = 0.0;
 
 	for(i=0;i<this->Size();i++){
-		observation1=(Observation*)this->GetObjectByOffset(i);
+		observation1=dynamic_cast<Observation*>(this->GetObjectByOffset(i));
 
 		for(j=i+1;j<this->Size();j++){
-			observation2=(Observation*)this->GetObjectByOffset(j);
+			observation2=dynamic_cast<Observation*>(this->GetObjectByOffset(j));
 
 			distance=sqrt(pow(observation1->x - observation2->x,2.) + pow(observation1->y - observation2->y,2.));
 			if(distance>x[n-1]) continue;

Modified: issm/trunk/src/c/Container/Observations.h
===================================================================
--- issm/trunk/src/c/Container/Observations.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Observations.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -36,4 +36,3 @@
 
 };
 #endif //ifndef _OBSERVATIONS_H_
-

Modified: issm/trunk/src/c/Container/Options.cpp
===================================================================
--- issm/trunk/src/c/Container/Options.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Options.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -41,7 +41,7 @@
 int  Options::AddOption(Option* in_option){
 
 	char* name=NULL;
-	
+
 	vector<Object*>::iterator object;
 	Option* option=NULL;
 
@@ -59,7 +59,7 @@
 	/*Finally, check that no option of the same name already exists in the dataset*/
 	for(object=objects.begin();object<objects.end();object++){
 
-		option=(Option*)(*object); 
+		option=dynamic_cast<Option*>(*object);
 		if (!strcmp(option->Name(),name)){
 			_error_("Options \"" << name << "\" found multiple times");
 			break;
@@ -81,7 +81,7 @@
 	/*Go through options and find option: */
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		option=(Option*)(*object); 
+		option=dynamic_cast<Option*>(*object);
 		if (!strncmp(name,option->Name(),strlen(option->Name()))){
 
 			/*OK, now do we have a complete name? If not, it is a cell or a structure, we need to go further*/

Modified: issm/trunk/src/c/Container/Options.h
===================================================================
--- issm/trunk/src/c/Container/Options.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Options.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,15 +21,11 @@
 		/*numerics*/
 		int  AddOption(Option* in_oobject);
 		Option* GetOption(const char* name);
-		
-		
+
 		template <class OptionType> void Get(OptionType* pvalue,const char* name){ /*{{{*/
 
-			vector<Object*>::iterator object;
-			GenericOption<OptionType>* genericoption=NULL;
-
 			/*Get option*/
-			genericoption=(GenericOption<OptionType>*)GetOption(name);
+			GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name));
 
 			/*If the pointer is not NULL, the option has been found*/
 			if(genericoption){
@@ -43,11 +39,8 @@
 		/*}}}*/
 		template <class OptionType> void Get(OptionType* pvalue,int* pnumel, const char* name){ /*{{{*/
 
-			vector<Object*>::iterator object;
-			GenericOption<OptionType>* genericoption=NULL;
-
 			/*Get option*/
-			genericoption=(GenericOption<OptionType>*)GetOption(name);
+			GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name));
 
 			/*If the pointer is not NULL, the option has been found*/
 			if(genericoption){
@@ -62,11 +55,8 @@
 		/*}}}*/
 		template <class OptionType> void Get(OptionType* pvalue,const char* name,OptionType default_value){ /*{{{*/
 
-			vector<Object*>::iterator object;
-			GenericOption<OptionType>* genericoption=NULL;
-
 			/*Get option*/
-			genericoption=(GenericOption<OptionType>*)GetOption(name);
+			GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name));
 
 			/*If the pointer is not NULL, the option has been found*/
 			if(genericoption){
@@ -79,11 +69,8 @@
 		/*}}}*/
 		template <class OptionType> void Get(OptionType* pvalue,int* pnumel, const char* name,OptionType default_value){ /*{{{*/
 
-			vector<Object*>::iterator object;
-			GenericOption<OptionType>* genericoption=NULL;
-
 			/*Get option*/
-			genericoption=(GenericOption<OptionType>*)GetOption(name);
+			GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name));
 
 			/*If the pointer is not NULL, the option has been found*/
 			if(genericoption){
@@ -102,11 +89,8 @@
 
 template <> inline void Options::Get(char** pvalue,const char* name,char* default_value){ /*{{{*/
 
-	vector<Object*>::iterator object;
-	GenericOption<char*>* genericoption=NULL;
-
 	/*Get option*/
-	genericoption=(GenericOption<char*>*)GetOption(name);
+	GenericOption<char*>* genericoption=dynamic_cast<GenericOption<char*>*>(GetOption(name));
 
 	/*If the pointer is not NULL, the option has been found*/
 	if(genericoption){
@@ -114,11 +98,8 @@
 	}
 	else{
 		/*Make a copy*/
-		char* outstring=NULL;
-		int   stringsize;
-
-		stringsize=strlen(default_value)+1;
-		outstring=xNew<char>(stringsize);
+		int   stringsize=strlen(default_value)+1;
+		char* outstring=xNew<char>(stringsize);
 		xMemCpy<char>(outstring,default_value,stringsize);
 		*pvalue=outstring;
 	}

Modified: issm/trunk/src/c/Container/Parameters.cpp
===================================================================
--- issm/trunk/src/c/Container/Parameters.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Parameters.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -44,7 +44,7 @@
 	Param* param=NULL;
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type) return true;
 	}
 	return false;
@@ -52,13 +52,13 @@
 /*}}}*/
 /*FUNCTION Parameters::FindParam(bool* pbool,int enum_type){{{*/
 void Parameters::FindParam(bool* pbool,int enum_type){ _assert_(this);
-	
+
 	vector<Object*>::iterator object;
 	Param* param=NULL;
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pbool);
 			return;
@@ -69,13 +69,13 @@
 /*}}}*/
 /*FUNCTION Parameters::FindParam(int* pinteger,int enum_type){{{*/
 void Parameters::FindParam(int* pinteger,int enum_type){ _assert_(this);
-	
+
 	vector<Object*>::iterator object;
 	Param* param=NULL;
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pinteger);
 			return;
@@ -86,13 +86,13 @@
 /*}}}*/
 /*FUNCTION Parameters::FindParam(IssmDouble* pscalar, int enum_type){{{*/
 void Parameters::FindParam(IssmDouble* pscalar, int enum_type){ _assert_(this);
-	
+
 	vector<Object*>::iterator object;
 	Param* param=NULL;
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pscalar);
 			return;
@@ -109,7 +109,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pscalar,time);
 			return;
@@ -120,13 +120,13 @@
 /*}}}*/
 /*FUNCTION Parameters::FindParam(char** pstring,int enum_type){{{*/
 void Parameters::FindParam(char** pstring,int enum_type){ _assert_(this);
-	
+
 	vector<Object*>::iterator object;
 	Param* param=NULL;
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pstring);
 			return;
@@ -138,13 +138,13 @@
 /*}}}*/
 /*FUNCTION Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){{{*/
 void Parameters::FindParam(char*** pstringarray,int* pM,int enum_type){ _assert_(this);
-	
+
 	vector<Object*>::iterator object;
 	Param* param=NULL;
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pstringarray,pM);
 			return;
@@ -162,7 +162,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pintarray,pM);
 			return;
@@ -180,7 +180,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pintarray,pM,pN);
 			return;
@@ -198,7 +198,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pIssmDoublearray,pM);
 			return;
@@ -216,7 +216,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pIssmDoublearray,pM,pN);
 			return;
@@ -228,13 +228,13 @@
 /*}}}*/
 /*FUNCTION Parameters::FindParam(IssmDouble*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){{{*/
 void Parameters::FindParam(IssmDouble*** parray,int* pM,int** pmdims_array,int** pndims_array,int enum_type){ _assert_(this);
-	
+
 	vector<Object*>::iterator object;
 	Param* param=NULL;
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(parray,pM,pmdims_array,pndims_array);
 			return;
@@ -245,13 +245,13 @@
 /*}}}*/
 /*FUNCTION Parameters::FindParam(Vector<IssmDouble>** pvec,int enum_type){{{*/
 void Parameters::FindParam(Vector<IssmDouble>** pvec,int enum_type){ _assert_(this);
-	
+
 	vector<Object*>::iterator object;
 	Param* param=NULL;
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pvec);
 			return;
@@ -263,13 +263,13 @@
 /*}}}*/
 /*FUNCTION Parameters::FindParam(Matrix<IssmDouble>** pmat,int enum_type){{{*/
 void Parameters::FindParam(Matrix<IssmDouble>** pmat,int enum_type){ _assert_(this);
-	
+
 	vector<Object*>::iterator object;
 	Param* param=NULL;
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pmat);
 			return;
@@ -287,7 +287,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pfid);
 			return;
@@ -296,14 +296,32 @@
 	_error_("could not find parameter " << EnumToStringx(enum_type));
 }
 /*}}}*/
+/*FUNCTION Parameters::FindParam(DataSet** pdataset,int enum_type){{{*/
+void Parameters::FindParam(DataSet** pdataset,int enum_type){ 
+	_assert_(this);
 
+	vector<Object*>::iterator object;
+	Param* param=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		param=dynamic_cast<Param*>(*object);
+		if(param->InstanceEnum()==enum_type){
+			param->GetParameterValue(pdataset);
+			return;
+		}
+	}
+	_error_("could not find parameter " << EnumToStringx(enum_type));
+}
+/*}}}*/
+
 /*FUNCTION Parameters::SetParam(bool boolean,int enum_type);{{{*/
 void   Parameters::SetParam(bool boolean,int enum_type){
 
 	Param* param=NULL;
-	
+
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(boolean); //already exists, just set it.
 	else this->AddObject(new BoolParam(enum_type,boolean)); //just add the new parameter.
@@ -313,9 +331,9 @@
 void   Parameters::SetParam(int integer,int enum_type){
 
 	Param* param=NULL;
-	
+
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(integer); //already exists, just set it.
 	else this->AddObject(new IntParam(enum_type,integer)); //just add the new parameter.
@@ -325,9 +343,9 @@
 void   Parameters::SetParam(IssmDouble scalar,int enum_type){
 
 	Param* param=NULL;
-	
+
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(scalar); //already exists, just set it.
 	else this->AddObject(new DoubleParam(enum_type,scalar)); //just add the new parameter.
@@ -337,9 +355,9 @@
 void   Parameters::SetParam(char* string,int enum_type){
 
 	Param* param=NULL;
-	
+
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(string); //already exists, just set it.
 	else this->AddObject(new StringParam(enum_type,string)); //just add the new parameter.
@@ -349,9 +367,9 @@
 void   Parameters::SetParam(char** stringarray,int M, int enum_type){
 
 	Param* param=NULL;
-	
+
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(stringarray,M); //already exists, just set it.
 	else this->AddObject(new StringArrayParam(enum_type,stringarray,M)); //just add the new parameter.
@@ -361,9 +379,9 @@
 void   Parameters::SetParam(IssmDouble* IssmDoublearray,int M, int enum_type){
 
 	Param* param=NULL;
-	
+
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(IssmDoublearray,M); //already exists, just set it.
 	else this->AddObject(new DoubleVecParam(enum_type,IssmDoublearray,M)); //just add the new parameter.
@@ -373,9 +391,9 @@
 void   Parameters::SetParam(IssmDouble* IssmDoublearray,int M, int N, int enum_type){
 
 	Param* param=NULL;
-	
+
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(IssmDoublearray,M,N); //already exists, just set it.
 	else this->AddObject(new DoubleMatParam(enum_type,IssmDoublearray,M,N)); //just add the new parameter.
@@ -387,7 +405,7 @@
 	Param* param=NULL;
 
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(intarray,M); //already exists, just set it.
 	else this->AddObject(new IntVecParam(enum_type,intarray,M)); //just add the new parameter.
@@ -399,7 +417,7 @@
 	Param* param=NULL;
 
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(intarray,M,N); //already exists, just set it.
 	else this->AddObject(new IntMatParam(enum_type,intarray,M,N)); //just add the new parameter.
@@ -409,9 +427,9 @@
 void   Parameters::SetParam(Vector<IssmDouble>* vector,int enum_type){
 
 	Param* param=NULL;
-	
+
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(vector); //already exists, just set it.
 	else this->AddObject(new VectorParam(enum_type,vector)); //just add the new parameter.
@@ -421,9 +439,9 @@
 void   Parameters::SetParam(Matrix<IssmDouble>* matrix,int enum_type){
 
 	Param* param=NULL;
-	
+
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(matrix); //already exists, just set it.
 	else this->AddObject(new MatrixParam(enum_type,matrix)); //just add the new parameter.
@@ -435,7 +453,7 @@
 	Param* param=NULL;
 
 	/*first, figure out if the param has already been created: */
-	param=(Param*)this->FindParamObject(enum_type);
+	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(fid); //already exists, just set it.
 	else this->AddObject(new FileParam(enum_type,fid)); //just add the new parameter.
@@ -448,7 +466,7 @@
 	Param* param=NULL;
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		param->UnitConversion(direction_enum);
 	}
 
@@ -463,7 +481,7 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=(Param*)(*object);
+		param=dynamic_cast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			return (*object);
 		}

Modified: issm/trunk/src/c/Container/Parameters.h
===================================================================
--- issm/trunk/src/c/Container/Parameters.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Parameters.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -43,7 +43,8 @@
 		void  FindParam(Vector<IssmDouble>** pvec,int enum_type);
 		void  FindParam(Matrix<IssmDouble>** pmat,int enum_type);
 		void  FindParam(FILE** pfid,int enum_type);
-		
+		void  FindParam(DataSet** pdataset, int enum_type);
+
 		void  SetParam(bool boolean,int enum_type);
 		void  SetParam(int integer,int enum_type);
 		void  SetParam(IssmDouble scalar, int enum_type);

Modified: issm/trunk/src/c/Container/Results.cpp
===================================================================
--- issm/trunk/src/c/Container/Results.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Results.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -65,7 +65,7 @@
 /*}}}*/
 /*FUNCTION Results::Write{{{*/
 void Results::Write(Parameters* parameters){
-	
+
 	int         i;
 	FILE       *fid          = NULL;
 	bool        io_gather=true;
@@ -75,7 +75,7 @@
 	parameters->FindParam(&io_gather,SettingsIoGatherEnum);
 
 	for(i=0;i<this->Size();i++){
-		ExternalResult* result=(ExternalResult*)this->GetObjectByOffset(i);
+		ExternalResult* result=dynamic_cast<ExternalResult*>(this->GetObjectByOffset(i));
 
 		/*write result to disk: */
 		result->WriteData(fid,io_gather);

Modified: issm/trunk/src/c/Container/Results.h
===================================================================
--- issm/trunk/src/c/Container/Results.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Results.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,14 +19,12 @@
 
 	public:
 
-		/*constructors, destructors: {{{*/
+		/*constructors, destructors*/
 		Results();
 		~Results();
-		/*}}}*/
-		/*numerics: {{{*/
+
+		/*numerics*/
 		Results* SpawnTriaResults(int* indices);
-		void Write(Parameters* parameters);
-		/*}}}*/
+		void     Write(Parameters* parameters);
 };
 #endif //ifndef _RESULTS_H_
-

Modified: issm/trunk/src/c/Container/Vertices.cpp
===================================================================
--- issm/trunk/src/c/Container/Vertices.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Vertices.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -37,84 +37,91 @@
 /*}}}*/
 
 /*Numerics management*/
-/*FUNCTION Vertices::DistributeDofs{{{*/
-void  Vertices::DistributeDofs(int numberofobjects,int numberofdofsperobject){
+/*FUNCTION Vertices::DistributePids{{{*/
+void  Vertices::DistributePids(int numberofobjects){
 
-	extern int num_procs;
-	extern int my_rank;
+	int num_procs;
+	int my_rank;
 
 	int  i;
-	int  dofcount=0;
-	int* alldofcount=NULL;
-	int* truedofs=NULL;
-	int* alltruedofs=NULL;
+	int  pidcount    = 0;
+	int *allpidcount = NULL;
+	int *truepids    = NULL;
+	int *alltruepids = NULL;
 
-	/*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+	num_procs=IssmComm::GetSize();
+
+	/*Go through objects, and distribute pids locally, from 0 to numberofpidsperobject*/
 	for (i=0;i<this->Size();i++){
-		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
-		vertex->DistributeDofs(&dofcount);
+		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		vertex->DistributePids(&pidcount);
 	}
 
-	/* Now every object has distributed dofs, but locally, and with a dof count starting from 
-	 * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache
-	 * cpus by the total last dofs of the previus cpu, starting from 0.
-	 * First: bet number of dofs for each cpu*/
-	alldofcount=xNew<int>(num_procs);
+	/* Now every object has distributed pids, but locally, and with a pid count starting from 
+	 * 0. This means the pids between all the cpus are not unique. We now offset the pids of each
+	 * cpus by the total last pids of the previus cpu, starting from 0.
+	 * First: get number of pids for each cpu*/
+	allpidcount=xNew<int>(num_procs);
 	#ifdef _HAVE_MPI_
-	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
-	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Gather(&pidcount,1,MPI_INT,allpidcount,1,MPI_INT,0,IssmComm::GetComm());
+	MPI_Bcast(allpidcount,num_procs,MPI_INT,0,IssmComm::GetComm());
 	#else
-	alldofcount[0]=dofcount;
+	allpidcount[0]=pidcount;
 	#endif
 
-	/* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
-	dofcount=0;
+	/* Every cpu should start its own pid count at the end of the pidcount from cpu-1*/
+	pidcount=0;
 	if(my_rank!=0){
 		for(i=0;i<my_rank;i++){
-			dofcount+=alldofcount[i];
+			pidcount+=allpidcount[i];
 		}
 	}
 	for (i=0;i<this->Size();i++){
-		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
-		vertex->OffsetDofs(dofcount);
+		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		vertex->OffsetPids(pidcount);
 	}
 
 	/* Finally, remember that cpus may have skipped some objects, because they were clones. For every 
-	 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 
+	 * object that is not a clone, tell them to show their pids, so that later on, they can get picked 
 	 * up by their clones: */
-	truedofs   =xNewZeroInit<int>(numberofobjects*numberofdofsperobject);
-	alltruedofs=xNewZeroInit<int>(numberofobjects*numberofdofsperobject);
+	truepids   =xNewZeroInit<int>(numberofobjects);
+	alltruepids=xNewZeroInit<int>(numberofobjects);
 	for (i=0;i<this->Size();i++){
-		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
-		vertex->ShowTrueDofs(truedofs);
+		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		vertex->ShowTruePids(truepids);
 	}
 	#ifdef _HAVE_MPI_
-	MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
+	MPI_Allreduce((void*)truepids,(void*)alltruepids,numberofobjects,MPI_INT,MPI_MAX,IssmComm::GetComm());
 	#else
-	for(i=0;i<numberofobjects*numberofdofsperobject;i++)alltruedofs[i]=truedofs[i];
+	for(i=0;i<numberofobjects;i++)alltruepids[i]=truepids[i];
 	#endif
 
-	/* Now every cpu knows the true dofs of everyone else that is not a clone*/
-	for (i=0;i<this->Size();i++){
-		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
-		vertex->UpdateCloneDofs(alltruedofs);
+	/* Now every cpu knows the true pids of everyone else that is not a clone*/
+	for(i=0;i<this->Size();i++){
+		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		vertex->UpdateClonePids(alltruepids);
 	}
 
 	/* Free ressources: */
-	xDelete<int>(alldofcount);
-	xDelete<int>(truedofs);
-	xDelete<int>(alltruedofs);
+	xDelete<int>(allpidcount);
+	xDelete<int>(truepids);
+	xDelete<int>(alltruepids);
 }
 /*}}}*/
 /*FUNCTION Vertices::FlagClones{{{*/
 void  Vertices::FlagClones(int numberofobjects){
 
 	int i;
-	extern int num_procs;
+	int num_procs;
 
 	int* ranks=NULL;
 	int* minranks=NULL;
 
+	/*recover num_procs:*/
+	num_procs=IssmComm::GetSize();
+
 	/*Allocate ranks: */
 	ranks=xNew<int>(numberofobjects);
 	minranks=xNew<int>(numberofobjects);
@@ -129,7 +136,7 @@
 	 * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing 
 	 * order of cpu rank. This is also why we initialized this array to num_procs.*/
 	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)ranks,(void*)minranks,numberofobjects,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
+	MPI_Allreduce ( (void*)ranks,(void*)minranks,numberofobjects,MPI_INT,MPI_MIN,IssmComm::GetComm());
 	#else
 	for(i=0;i<numberofobjects;i++)minranks[i]=ranks[i];
 	#endif
@@ -137,7 +144,7 @@
 	/*Now go through all objects, and use minranks to flag which objects are cloned: */
 	for(i=0;i<this->Size();i++){
 		/*For this object, decide whether it is a clone: */
-		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
+		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
 		vertex->SetClone(minranks);
 	}
 
@@ -155,14 +162,14 @@
 	int vertex_max_sid;
 
 	for(i=0;i<this->Size();i++){
-		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
+		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
 		sid=vertex->Sid();
 		if (sid>max_sid)max_sid=sid;
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&max_sid,&vertex_max_sid,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
-	MPI_Bcast(&vertex_max_sid,1,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Reduce (&max_sid,&vertex_max_sid,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&vertex_max_sid,1,MPI_INT,0,IssmComm::GetComm());
 	max_sid=vertex_max_sid;
 	#endif
 
@@ -176,20 +183,18 @@
 /*FUNCTION Vertices::Ranks{{{*/
 void   Vertices::Ranks(int* ranks){
 
+	int my_rank;
+	int        sid;
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Go through a dataset, and for each object, report it cpu: */
-
-	int i;
-	int rank;
-	int sid;
-	
-	for(i=0;i<this->Size();i++){
-		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
-		rank=vertex->MyRank();
+	for(int i=0;i<this->Size();i++){
+		/*Plug rank into ranks, according to id: */
+		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
 		sid=vertex->Sid();
-		
-		/*Plug rank into ranks, according to id: */
-		ranks[sid]=rank; 
+		ranks[sid]=my_rank; 
 	}
-	return;
 }
 /*}}}*/

Modified: issm/trunk/src/c/Container/Vertices.h
===================================================================
--- issm/trunk/src/c/Container/Vertices.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Container/Vertices.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,17 +18,15 @@
 
 	public:
 
-		/*constructors, destructors: {{{*/
+		/*constructors, destructors:*/ 
 		Vertices();
 		~Vertices();
-		/*}}}*/
-		/*numerics: {{{*/
-		void  DistributeDofs(int numberofnodes,int numdofspernode);
+
+		/*numerics:*/
+		void  DistributePids(int numberofnodes);
 		void  FlagClones(int numberofnodes);
 		int   NumberOfVertices(void);
 		void  Ranks(int* ranks);
-		/*}}}*/
-
 };
 
 #endif //ifndef _VERTICES_H_

Modified: issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,13 +12,25 @@
 enum definitions{
 	/*Model fields {{{1*/
 	AutodiffIsautodiffEnum, 
-	AutodiffDependentsEnum,
 	AutodiffNumDependentsEnum,
-	AutodiffIndependentsEnum,
+	AutodiffNumDependentObjectsEnum,
+	AutodiffDependentObjectNamesEnum,
+	AutodiffDependentObjectTypesEnum,
+	AutodiffDependentObjectIndicesEnum,
+	AutodiffDependentObjectsEnum,
 	AutodiffNumIndependentsEnum,
+	AutodiffNumIndependentObjectsEnum,
+	AutodiffIndependentObjectNamesEnum,
+	AutodiffIndependentObjectTypesEnum,
+	AutodiffIndependentObjectsEnum,
 	AutodiffJacobianEnum,
 	AutodiffXpEnum,
-	AutodiffFosForwardOutputEnum,
+	AutodiffDriverEnum,
+	AutodiffFosForwardIndexEnum,
+	AutodiffFovForwardIndicesEnum,
+	AutodiffFosReverseIndexEnum,
+	AutodiffMassFluxSegmentsPresentEnum,
+	AutodiffKeepEnum,
 	BalancethicknessSpcthicknessEnum,
 	BalancethicknessStabilizationEnum,
 	BalancethicknessThickeningRateEnum,
@@ -30,6 +42,7 @@
 	ConstantsGEnum,
 	ConstantsReferencetemperatureEnum,
 	ConstantsYtsEnum,
+	DependentObjectEnum,
 	DiagnosticAbstolEnum,
 	DiagnosticIcefrontEnum,
 	DiagnosticIsnewtonEnum,
@@ -69,6 +82,7 @@
 	HydrologyQEnum,
 	HydrologySpcwatercolumnEnum,
 	HydrologyStabilizationEnum,
+	IndependentObjectEnum,
 	InversionControlParametersEnum,
 	InversionCostFunctionEnum,
 	InversionCostFunctionThresholdEnum,
@@ -142,8 +156,12 @@
 	PrognosticSpcthicknessEnum,
 	PrognosticStabilizationEnum,
 	PrognosticVertexPairingEnum,
+	PrognosticNumRequestedOutputsEnum,
+	PrognosticRequestedOutputsEnum,
 	QmuIsdakotaEnum,
-	QmuMassFluxSegmentsEnum,
+	MassFluxSegmentsEnum,
+	MassFluxSegmentsPresentEnum,
+	QmuMassFluxSegmentsPresentEnum,
 	QmuNumberofpartitionsEnum,
 	QmuNumberofresponsesEnum,
 	QmuPartitionEnum,
@@ -178,6 +196,8 @@
 	SurfaceforcingsIssmbgradientsEnum,
 	SurfaceforcingsMonthlytemperaturesEnum,
 	SurfaceforcingsHcEnum,
+	SurfaceforcingsHrefEnum,
+	SurfaceforcingsSmbrefEnum,
 	SurfaceforcingsSmbPosMaxEnum,
 	SurfaceforcingsSmbPosMinEnum,
 	SurfaceforcingsAPosEnum,
@@ -272,6 +292,7 @@
 	DatasetInputEnum,
 	DofIndexingEnum,
 	DoubleInputEnum,
+	DataSetParamEnum,
 	DoubleMatArrayParamEnum,
 	DoubleMatParamEnum,
 	DoubleParamEnum,
@@ -301,6 +322,7 @@
 	PenpairEnum,
 	PentaEnum,
 	PentaP1InputEnum,
+	ProfilerEnum,
 	MatrixParamEnum,
 	VectorParamEnum,
 	RiftfrontEnum,
@@ -489,6 +511,8 @@
 	NodalEnum,
 	OldGradientEnum,
 	OutputFilePointerEnum,
+	OutputFileNameEnum,
+	LockFileNameEnum,
 	PetscOptionsAnalysesEnum,
 	PetscOptionsStringsEnum,
 	QmuErrNameEnum,

Modified: issm/trunk/src/c/Makefile.am
===================================================================
--- issm/trunk/src/c/Makefile.am	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/Makefile.am	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
+AM_CPPFLAGS = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@
 
 EXEEXT=$(ISSMEXT)
 
@@ -8,17 +8,8 @@
 if SHAREDLIBS
 lib_LTLIBRARIES = libISSMCore.la libISSMOverload.la libISSM.la
 endif
-if PYTHON
-lib_LIBRARIES += libISSMPython.a 
-endif
-if MATLAB
+if WRAPPERS
 if SHAREDLIBS
-lib_LTLIBRARIES += libISSMMatlab.la
-endif
-lib_LIBRARIES += libISSMMatlab.a 
-endif
-if MODULES
-if SHAREDLIBS
 lib_LTLIBRARIES += libISSMModules.la
 endif
 lib_LIBRARIES += libISSMModules.a 
@@ -53,6 +44,10 @@
 					./classes/objects/Inputs/TransientInput.cpp\
 					./classes/objects/Constraints/SpcTransient.cpp\
 					./classes/objects/Constraints/SpcTransient.h\
+					./classes/objects/IndependentObject.h\
+					./classes/objects/IndependentObject.cpp\
+					./classes/objects/DependentObject.h\
+					./classes/objects/DependentObject.cpp\
 					./classes/DofIndexing.h\
 					./classes/DofIndexing.cpp\
 					./classes/IoModel.h\
@@ -62,6 +57,9 @@
 					./classes/objects/Segment.h\
 					./classes/objects/Vertex.h\
 					./classes/objects/Vertex.cpp\
+					./classes/objects/AdolcEdf.h\
+					./classes/IssmComm.h\
+					./classes/IssmComm.cpp\
 					./classes/Hook.h\
 					./classes/Hook.cpp\
 					./classes/Patch.h\
@@ -151,6 +149,10 @@
 					./classes/objects/Params/VectorParam.cpp\
 					./classes/objects/Params/TransientParam.h\
 					./classes/objects/Params/TransientParam.cpp\
+					./classes/objects/Params/DataSetParam.h\
+					./classes/objects/Params/DataSetParam.cpp\
+					./classes/objects/Profiler.h\
+					./classes/objects/Profiler.cpp\
 					./Container/Container.h\
 					./Container/Constraints.h\
 					./Container/Constraints.cpp\
@@ -181,7 +183,6 @@
 					./shared/MemOps/xMemCpy.h\
 					./shared/Matrix/matrix.h\
 					./shared/Matrix/MatrixUtils.cpp\
-					./shared/Numerics/adolc_edf.h\
 					./shared/Numerics/numerics.h\
 					./shared/Numerics/Verbosity.h\
 					./shared/Numerics/Verbosity.cpp\
@@ -212,12 +213,7 @@
 					./shared/Elements/PddSurfaceMassBalance.cpp\
 					./shared/Elements/ComputeDelta18oTemperaturePrecipitation.cpp\
 					./shared/String/sharedstring.h\
-					./shared/Wrapper/wrappershared.h\
-					./shared/Wrapper/ModuleBoot.cpp\
-					./shared/Wrapper/ModuleEnd.cpp\
-					./shared/Sys/sys.h\
-					./shared/Sys/ProfilingStart.cpp\
-					./shared/Sys/ProfilingEnd.cpp\
+					./shared/String/DescriptorIndex.cpp\
 					./toolkits/metis/metisincludes.h\
 					./toolkits/issm/issmtoolkit.h\
 					./toolkits/issm/SeqVec.h\
@@ -229,6 +225,7 @@
 					./io/Disk/diskio.h\
 					./io/Disk/pfopen.cpp\
 					./io/Disk/pfclose.cpp\
+					./io/Disk/WriteLockFile.cpp\
 					./io/PrintfFunction.cpp\
 					./EnumDefinitions/EnumDefinitions.h\
 					./modules/ModelProcessorx/ModelProcessorx.h\
@@ -278,10 +275,6 @@
 					./modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp\
 					./modules/InputArtificialNoisex/InputArtificialNoisex.h\
 					./modules/InputArtificialNoisex/InputArtificialNoisex.cpp\
-					./modules/TimeAdaptx/TimeAdaptx.h\
-					./modules/TimeAdaptx/TimeAdaptx.cpp\
-					./modules/UpdateVertexPositionsx/UpdateVertexPositionsx.h\
-					./modules/UpdateVertexPositionsx/UpdateVertexPositionsx.cpp\
 					./modules/ConfigureObjectsx/ConfigureObjectsx.h\
 					./modules/ConfigureObjectsx/ConfigureObjectsx.cpp\
 					./modules/ComputeBasalStressx/ComputeBasalStressx.h\
@@ -296,8 +289,6 @@
 					./modules/Delta18oParameterizationx/Delta18oParameterizationx.cpp\
 					./modules/SmbGradientsx/SmbGradientsx.h\
 					./modules/SmbGradientsx/SmbGradientsx.cpp\
-					./modules/UpdateConstraintsx/UpdateConstraintsx.h\
-					./modules/UpdateConstraintsx/UpdateConstraintsx.cpp\
 					./modules/MeshPartitionx/MeshPartitionx.h\
 					./modules/Reducevectorgtofx/Reducevectorgtofx.cpp\
 					./modules/Reducevectorgtofx/Reducevectorgtofx.h\
@@ -307,21 +298,9 @@
 					./modules/EnumToStringx/EnumToStringx.h\
 					./modules/StringToEnumx/StringToEnumx.cpp\
 					./modules/StringToEnumx/StringToEnumx.h\
-					./modules/SystemMatricesx/SystemMatricesx.cpp\
-					./modules/SystemMatricesx/SystemMatricesx.h\
-					./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp\
-					./modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h\
 					./modules/ConstraintsStatex/ConstraintsStatex.cpp\
 					./modules/ConstraintsStatex/ConstraintsStatex.h\
 					./modules/ConstraintsStatex/ConstraintsStateLocal.h\
-					./modules/Responsex/Responsex.h\
-					./modules/Responsex/Responsex.cpp\
-					./modules/RequestedOutputsx/RequestedOutputsx.h\
-					./modules/RequestedOutputsx/RequestedOutputsx.cpp\
-					./modules/RequestedDependentsx/RequestedDependentsx.h\
-					./modules/RequestedDependentsx/RequestedDependentsx.cpp\
-					./modules/AutodiffDriversx/AutodiffDriversx.h\
-					./modules/AutodiffDriversx/AutodiffDriversx.cpp\
 					./modules/ResetConstraintsx/ResetConstraintsx.h\
 					./modules/ResetConstraintsx/ResetConstraintsx.cpp\
 					./modules/ResetCoordinateSystemx/ResetCoordinateSystemx.h\
@@ -339,40 +318,37 @@
 					./modules/InputConvergencex/InputConvergencex.h\
 					./solutions/convergence.cpp\
 					./solutions/ProcessArguments.cpp\
-					./solutions/WriteLockFile.cpp\
 					./solutions/ResetBoundaryConditions.cpp\
 					./solutions/AnalysisConfiguration.cpp\
+					./solutions/WrapperCorePointerFromSolutionEnum.cpp\
 					./solutions/CorePointerFromSolutionEnum.cpp\
+					./solutions/EnvironmentInit.cpp\
+					./solutions/EnvironmentFinalize.cpp\
+					./solutions/ad_core.cpp\
 					./solvers/solver_linear.cpp\
 					./solvers/solver_nonlinear.cpp\
 					./solvers/solver_newton.cpp\
 					./classes/objects/Options/Option.h\
 					./classes/objects/Options/GenericOption.h\
 					./classes/objects/Options/OptionUtilities.cpp\
-					./classes/objects/Options/OptionUtilities.h
-
+					./classes/objects/Options/OptionUtilities.h\
+					./classes/RiftStruct.cpp\
+					./classes/RiftStruct.h
 #}}}
 #DAKOTA sources  {{{
 dakota_sources = ./classes/dakota/DakotaPlugin.h\
 					  ./classes/dakota/DakotaPlugin.cpp\
 					  ./modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h\
 					  ./modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp\
-					  ./modules/DakotaResponsesx/DakotaResponsesx.h\
-					  ./modules/DakotaResponsesx/DakotaResponsesx.cpp\
 					  ./modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h\
 					  ./modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp\
 					  ./modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.h\
 					  ./modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp\
 					  ./modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp\
 					  ./modules/AverageOntoPartitionx/AverageOntoPartitionx.h\
-					  ./modules/Dakotax/Dakotax.h\
-					  ./modules/Dakotax/Dakotax.cpp\
-					  ./modules/Dakotax/DakotaMPI_Bcast.cpp\
-					  ./modules/Dakotax/DakotaFree.cpp\
-					  ./modules/Dakotax/SpawnCore.cpp\
-					  ./modules/Dakotax/DescriptorIndex.cpp\
 					  ./modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp\
-					  ./modules/Dakotax/SpawnCoreParallel.cpp
+					  ./solutions/dakota_core.cpp\
+					  ./solutions/DakotaSpawnCore.cpp
 #}}}
 #Transient sources  {{{
 transient_sources  = ./modules/ModelProcessorx/Transient/UpdateElementsTransient.cpp \
@@ -436,16 +412,12 @@
 					  ./modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp\
 					  ./modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.h\
 					  ./modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp\
-					  ./modules/CostFunctionx/CostFunctionx.h\
-					  ./modules/CostFunctionx/CostFunctionx.cpp\
 					  ./modules/Orthx/Orthx.h\
 					  ./modules/Orthx/Orthx.cpp\
 					  ./modules/Gradjx/Gradjx.h\
 					  ./modules/Gradjx/Gradjx.cpp\
 					  ./modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp\
 					  ./modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.h\
-					  ./modules/ThicknessAbsGradientx/ThicknessAbsGradientx.cpp\
-					  ./modules/ThicknessAbsGradientx/ThicknessAbsGradientx.h\
 					  ./modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp\
 					  ./modules/ThicknessAlongGradientx/ThicknessAlongGradientx.h\
 					  ./modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp\
@@ -504,38 +476,6 @@
 						./modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp\
 						./solutions/balancethickness_core.cpp
 #}}}
-#Responses sources  {{{
-responses_sources = ./modules/MinVelx/MinVelx.h\
-					     ./modules/MinVelx/MinVelx.cpp\
-					     ./modules/MaxVelx/MaxVelx.h\
-					     ./modules/MaxVelx/MaxVelx.cpp\
-					     ./modules/MaxAbsVxx/MaxAbsVxx.h\
-					     ./modules/MaxAbsVxx/MaxAbsVxx.cpp\
-					     ./modules/MaxAbsVyx/MaxAbsVyx.h\
-					     ./modules/MaxAbsVyx/MaxAbsVyx.cpp\
-					     ./modules/MaxAbsVzx/MaxAbsVzx.h\
-					     ./modules/MaxAbsVzx/MaxAbsVzx.cpp\
-					     ./modules/MaxVxx/MaxVxx.h\
-					     ./modules/MaxVxx/MaxVxx.cpp\
-					     ./modules/MaxVyx/MaxVyx.h\
-					     ./modules/MaxVyx/MaxVyx.cpp\
-					     ./modules/MaxVzx/MaxVzx.h\
-					     ./modules/MaxVzx/MaxVzx.cpp\
-					     ./modules/MinVxx/MinVxx.h\
-					     ./modules/MinVxx/MinVxx.cpp\
-					     ./modules/MinVyx/MinVyx.h\
-					     ./modules/MinVyx/MinVyx.cpp\
-					     ./modules/MinVzx/MinVzx.h\
-					     ./modules/MinVzx/MinVzx.cpp\
-					     ./modules/TotalSmbx/TotalSmbx.h\
-					     ./modules/TotalSmbx/TotalSmbx.cpp\
-					     ./modules/IceVolumex/IceVolumex.h\
-					     ./modules/IceVolumex/IceVolumex.cpp\
-					     ./modules/ElementResponsex/ElementResponsex.h\
-					     ./modules/ElementResponsex/ElementResponsex.cpp\
-					     ./modules/MassFluxx/MassFluxx.cpp\
-					     ./modules/MassFluxx/MassFluxx.h
-#}}}
 #Slope sources  {{{
 slope_sources =  ./modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp\
 					  ./modules/ModelProcessorx/BedSlope/CreateNodesBedSlope.cpp \
@@ -557,6 +497,10 @@
 				    ./classes/objects/Loads/Riftfront.h\
 				    ./modules/ConstraintsStatex/RiftConstraintsState.cpp
 #}}}
+#Android sources  {{{
+android_sources = ./android/fac.h\
+				  ./android/fac.cpp
+#}}}
 #3D sources  {{{
 threed_sources = ./classes/gauss/GaussPenta.h\
 				     ./classes/gauss/GaussPenta.cpp\
@@ -750,7 +694,6 @@
 					./toolkits/petsc/patches\
 					./toolkits/petsc/patches/SolverEnum.h\
 					./toolkits/petsc/patches/petscpatches.h\
-					./toolkits/petsc/patches/VecTranspose.cpp\
 					./toolkits/petsc/patches/VecToMPISerial.cpp\
 					./toolkits/petsc/patches/MatToSerial.cpp\
 					./toolkits/petsc/patches/VecMerge.cpp\
@@ -758,18 +701,12 @@
 					./toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp\
 					./toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp\
 					./toolkits/petsc/patches/NewMat.cpp\
-					./toolkits/petsc/patches/SerialToVec.cpp\
 					./toolkits/petsc/patches/VecFree.cpp\
 					./toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp\
 					./toolkits/petsc/patches/PetscVectorToDoubleVector.cpp\
 					./toolkits/petsc/patches/VecDuplicatePatch.cpp\
 					./toolkits/petsc/patches/KSPFree.cpp\
-					./toolkits/petsc/patches/ISFree.cpp\
 					./toolkits/petsc/patches/MatFree.cpp\
-					./toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp\
-					./toolkits/petsc/patches/VecPartition.cpp\
-					./toolkits/petsc/patches/MatPartition.cpp\
-					./toolkits/petsc/patches/MatInvert.cpp\
 					./toolkits/petsc/patches/MatMultPatch.cpp\
 					./toolkits/petsc/patches/ISSMToPetscMatrixType.cpp\
 					./toolkits/petsc/patches/ISSMToPetscInsertMode.cpp\
@@ -788,47 +725,14 @@
 #Mpi sources  {{{
 mpi_sources= ./toolkits/mpi/mpiincludes.h\
 				./toolkits/mpi/patches/mpipatches.h\
-				./toolkits/mpi/patches/DetermineLocalSize.cpp\
-				./toolkits/mpi/patches/MPI_Upperrow.cpp\
-				./toolkits/mpi/patches/MPI_Lowerrow.cpp\
-				./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp
+				./toolkits/mpi/patches/DetermineLocalSize.cpp
 #}}}
 #Metis sources  {{{
 metis_sources= ./toolkits/metis/patches/metispatches.h\
 					./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp
 #}}}
-#Python sources  {{{
-python_sources=     ./python/io/pythonio.h\
-					./python/python-binding.h\
-				    ./python/io/WritePythonData.cpp\
-				    ./python/io/CheckNumPythonArguments.cpp\
-				    ./python/io/FetchPythonData.cpp
-
-#}}}
-#Matlab sources  {{{
-matlab_sources= ./toolkits/matlab/matlabincludes.h\
-				    ./matlab/matlab-binding.h\
-				    ./matlab/io/matlabio.h\
-				    ./matlab/io/MatlabNArrayToNArray.cpp\
-				    ./matlab/io/CheckNumMatlabArguments.cpp\
-				    ./matlab/io/mxGetAssignedField.cpp\
-				    ./matlab/io/WriteMatlabData.cpp\
-				    ./matlab/io/FetchMatlabData.cpp\
-				    ./matlab/io/OptionParse.cpp\
-				    ./matlab/io/MatlabMatrixToMatrix.cpp\
-				    ./matlab/io/MatlabVectorToVector.cpp\
-					 ./matlab/io/MatlabVectorToDoubleVector.cpp\
-					 ./matlab/io/MatlabMatrixToDoubleMatrix.cpp\
-					 ./matlab/io/MatlabMatrixToSeqMat.cpp\
-					 ./matlab/io/MatlabVectorToSeqVec.cpp
-#}}}
-#Matlab and Petsc sources  {{{
-matlabpetsc_sources= ./matlab/io/MatlabMatrixToPetscMat.cpp\
-					 ./matlab/io/MatlabVectorToPetscVec.cpp
-
-#}}}
 #Modules sources{{{
-module_sources= ./shared/Threads/issm_threads.h\
+modules_sources= ./shared/Threads/issm_threads.h\
 			./shared/Threads/LaunchThread.cpp\
 			./shared/Threads/PartitionRange.cpp\
 			./shared/Exp/exp.h\
@@ -841,8 +745,6 @@
 			./shared/TriMesh/OrderSegments.cpp\
 			./shared/TriMesh/SplitMeshForRifts.cpp\
 			./shared/TriMesh/TriMeshUtils.cpp\
-			./modules/AddExternalResultx/AddExternalResultx.h\
-			./modules/AddExternalResultx/AddExternalResultx.cpp\
 			./modules/Chacox/Chacox.h\
 			./modules/Chacox/Chacox.cpp\
 			./modules/Chacox/input_parse.cpp\
@@ -852,6 +754,8 @@
 			./modules/TriaSearchx/TriaSearchx.cpp\
 			./modules/TriMeshx/TriMeshx.h\
 			./modules/TriMeshx/TriMeshx.cpp\
+			./modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.h\
+			./modules/TriMeshProcessRiftsx/TriMeshProcessRiftsx.cpp\
 			./modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h\
 			./modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.cpp\
 			./modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp\
@@ -946,10 +850,6 @@
 issm_sources  +=  $(balanced_sources)
 endif
 
-if RESPONSES
-issm_sources +=  $(responses_sources)
-endif
-
 if SLOPE
 issm_sources  +=  $(slope_sources)
 endif
@@ -962,6 +862,10 @@
 issm_sources +=  $(rifts_sources)
 endif
 
+if ANDROID
+issm_sources +=  $(android_sources)
+endif
+
 if THREED
 issm_sources +=  $(threed_sources)
 endif
@@ -974,12 +878,6 @@
 issm_sources +=  $(metis_sources)
 endif
 
-if PETSC
-if MATLAB
-issm_sources +=  $(matlabpetsc_sources)
-endif
-endif
-
 if KRIGING
 issm_sources +=  $(pkriging_sources)
 endif
@@ -1000,8 +898,8 @@
 libISSMOverload_la_SOURCES = ./shared/String/stricmp.c
 endif
 
-if MODULES
-libISSMModules_a_SOURCES = $(module_sources)
+if WRAPPERS
+libISSMModules_a_SOURCES = $(modules_sources)
 libISSMModules_a_SOURCES += $(bamg_sources)
 if KRIGING
 libISSMModules_a_SOURCES += $(kriging_sources)
@@ -1016,19 +914,6 @@
 endif
 endif
 
-if PYTHON
-libISSMPython_a_SOURCES = $(python_sources)
-libISSMPython_a_CXXFLAGS= $(ALLCXXFLAGS)
-endif
-
-if MATLAB
-libISSMMatlab_a_SOURCES = $(matlab_sources)
-libISSMMatlab_a_CXXFLAGS= $(ALLCXXFLAGS)
-if SHAREDLIBS
-libISSMMatlab_la_SOURCES = $(libISSMMatlab_a_SOURCES)
-endif
-endif
-
 if VERSION
 AM_LDFLAGS =
 else
@@ -1041,7 +926,15 @@
 #}}}
 
 #Executable {{{
+if ANDROID
+if ANDROIDEXE
 bin_PROGRAMS = issm 
+else
+bin_PROGRAMS = 
+endif
+else
+bin_PROGRAMS = issm 
+endif
 
 #Standard libraries
 LDADD = ./libISSMCore.a ./libISSMOverload.a

Modified: issm/trunk/src/c/classes/DofIndexing.cpp
===================================================================
--- issm/trunk/src/c/classes/DofIndexing.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/DofIndexing.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,8 +9,8 @@
 #endif
 
 #include <stdio.h>
-#include "./classes.h"
 #include <string.h>
+#include "./classes.h"
 #include "../EnumDefinitions/EnumDefinitions.h"
 #include "../shared/shared.h"
 #include "../Container/Container.h"
@@ -20,17 +20,17 @@
 /*FUNCTION DofIndexing::DofIndexing(){{{*/
 DofIndexing::DofIndexing(){
 
-	this->gsize=UNDEF;
-	this->fsize=UNDEF;
-	this->ssize=UNDEF;
-	this->clone=0;
-	this->f_set=NULL;
-	this->s_set=NULL;
-	this->svalues=NULL;
-	this->doftype=NULL;
-	this->gdoflist=NULL;
-	this->fdoflist=NULL;
-	this->sdoflist=NULL;
+	this->gsize    = UNDEF;
+	this->fsize    = UNDEF;
+	this->ssize    = UNDEF;
+	this->clone    = false;
+	this->f_set    = NULL;
+	this->s_set    = NULL;
+	this->svalues  = NULL;
+	this->doftype  = NULL;
+	this->gdoflist = NULL;
+	this->fdoflist = NULL;
+	this->sdoflist = NULL;
 
 }
 /*}}}*/
@@ -42,12 +42,10 @@
 /*FUNCTION DofIndexing::DofIndexing(DofIndexing* in)  -> copy{{{*/
 DofIndexing::DofIndexing(DofIndexing* in){ //copy constructor
 
-	int i;
-	this->gsize=in->gsize;
-	this->fsize=in->fsize;
-	this->ssize=in->ssize;
-	
-	this->clone=in->clone;
+	this->gsize = in->gsize;
+	this->fsize = in->fsize;
+	this->ssize = in->ssize;
+	this->clone = in->clone;
 
 	if(this->gsize>0){
 		this->f_set=xNew<bool>(this->gsize);
@@ -57,11 +55,11 @@
 		this->gdoflist=xNew<int>(this->gsize); 
 	}
 	else{
-		this->f_set=NULL;
-		this->s_set=NULL;
-		this->svalues=NULL;
-		this->doftype=NULL;
-		this->gdoflist=NULL;
+		this->f_set    = NULL;
+		this->s_set    = NULL;
+		this->svalues  = NULL;
+		this->doftype  = NULL;
+		this->gdoflist = NULL;
 	}
 	if(this->fsize>0 && this->fsize!=UNDEF)this->fdoflist=xNew<int>(this->fsize); else this->fdoflist=NULL;
 	if(this->ssize>0 && this->ssize!=UNDEF)this->sdoflist=xNew<int>(this->ssize); else this->sdoflist=NULL;
@@ -94,10 +92,8 @@
 /*FUNCTION DofIndexing::Init{{{*/
 void DofIndexing::Init(int in_gsize,int* in_doftype){
 
-	int i;
 	this->gsize=in_gsize;
-	
-	this->clone=0;
+	this->clone=false;
 
 	/*allocate: */
 	if(this->gsize>0){
@@ -108,7 +104,7 @@
 		this->gdoflist=xNew<int>(this->gsize);
 	}
 
-	for (i=0;i<this->gsize;i++){
+	for(int i=0;i<this->gsize;i++){
 		/*assume dof is free, no constraints, no rigid body constraint: */
 		this->f_set[i]=true;
 		this->s_set[i]=false;
@@ -150,8 +146,6 @@
 /*FUNCTION DofIndexing::Echo{{{*/
 void DofIndexing::Echo(void){
 
-	int i;
-
 	_printLine_("DofIndexing:");
 	_printLine_("   gsize: " << gsize);
 	_printLine_("   clone: " << clone);
@@ -167,7 +161,7 @@
 	_printLine_("   fsize: " << fsize);
 	_printLine_("   ssize: " << ssize);
 	_printLine_("   clone: " << clone);
-	
+
 	_printLine_("   set membership: f,s sets ");
 	for(i=0;i<gsize;i++){
 		_printLine_("      dof " << i << ": " <<(f_set[i]?"true":"false")<< " " <<(s_set[i]?"true":"false"));
@@ -207,4 +201,3 @@
 	_printLine_("");
 }		
 /*}}}*/
-

Modified: issm/trunk/src/c/classes/DofIndexing.h
===================================================================
--- issm/trunk/src/c/classes/DofIndexing.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/DofIndexing.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,31 +8,30 @@
 #include "../include/include.h"
 
 class DofIndexing{
-	
+
 	public:
 
 		/*sizes: */
-		int gsize; //number of dofs for a node
-		int fsize; //number of dofs solver for
-		int ssize; //number of constrained dofs
+		int gsize;   //number of dofs for a node
+		int fsize;   //number of dofs solver for
+		int ssize;   //number of constrained dofs
 
 		/*partitioning: */
-		int     clone;   //this node is replicated from another one 
+		bool clone;   //this node is replicated from another one
 
 		/*boundary conditions sets: */
-		bool*     f_set; //is dof on f-set (on which we solve)
-		bool*     s_set; //is dof on s-set (on which boundary conditions -dirichlet- are applied)
-		IssmDouble*   svalues; //list of constraint values. size g_size, for ease of use.
+		bool       *f_set;     //is dof on f-set (on which we solve)
+		bool       *s_set;     //is dof on s-set (on which boundary conditions -dirichlet- are applied)
+		IssmDouble *svalues;   //list of constraint values. size g_size, for ease of use.
 
 		/*types of dofs: */
-		int*     doftype; //approximation type of the dofs (used only for coupling), size g_size
-		
+		int        *doftype;   //approximation type of the dofs (used only for coupling), size g_size
+
 		/*list of degrees of freedom: */
-		int*     gdoflist; //dof list in g_set
-		int*     fdoflist; //dof list in f_set
-		int*     sdoflist; //dof list in s_set
+		int *gdoflist;   //dof list in g_set
+		int *fdoflist;   //dof list in f_set
+		int *sdoflist;   //dof list in s_set
 
-
 		/*DofIndexing constructors, destructors {{{*/
 		DofIndexing();
 		DofIndexing(int g_size);

Modified: issm/trunk/src/c/classes/FemModel.cpp
===================================================================
--- issm/trunk/src/c/classes/FemModel.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/FemModel.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief: implementation of the FemModel object
  */
 
-
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -12,6 +11,7 @@
 #include <stdio.h>
 #include "../Container/Container.h"
 #include "../modules/ModelProcessorx/ModelProcessorx.h"
+#include "../solutions/solutions.h"
 #include "../io/io.h"
 #include "./classes.h"
 #include "../include/include.h"
@@ -19,24 +19,161 @@
 #include "../modules/modules.h"
 
 /*Object constructors and destructor*/
-/*FUNCTION FemModel::constructor {{{*/
-FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, const int in_solution_type,const int* analyses,const int nummodels){
+/*FUNCTION FemModel::FemModel(int argc,char** argv){{{*/
+FemModel::FemModel(int argc,char** argv,COMM incomm){
 
+	/*configuration: */
+	int* analyses=NULL;
+	int  numanalyses;
+	int  solution_type;
+	int  ierr;
+
+	/*File names*/
+	char *lockfilename   = NULL;
+	char *binfilename    = NULL;
+	char *outbinfilename = NULL;
+	char *petscfilename  = NULL;
+	char *rootpath       = NULL;
+
+	/*First things first, store the communicator, and set it as a global variable: */
+	this->comm=incomm;
+	this->SetStaticComm();
+	
+	/*Now, initialize PETSC: */
+	#ifdef _HAVE_PETSC_
+	PETSC_COMM_WORLD=this->comm;
+	ierr=PetscInitialize(&argc,&argv,(char*)0,"");  if(ierr) _error_("Could not initialize Petsc");
+	#endif
+
+	/*Start profiler: */
+	this->profiler=new Profiler();
+	profiler->Tag(Start);
+
+	/*From command line arguments, retrieve different filenames needed to create the FemModel: */
+	ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,&rootpath,argc,argv);
+
+	/*out of solution_type, figure out types of analyses needed in the femmodel: */
+	AnalysisConfiguration(&analyses,&numanalyses,solution_type);
+
+	/*Create femmodel from input files: */
+	profiler->Tag(StartInit);
+	this->InitFromFiles(rootpath,binfilename,outbinfilename,petscfilename,lockfilename,solution_type,analyses,numanalyses);
+	profiler->Tag(FinishInit);
+
+	/*Free resources */
+	xDelete<int>(analyses);
+	xDelete<char>(lockfilename);
+	xDelete<char>(binfilename);
+	xDelete<char>(outbinfilename);
+	xDelete<char>(petscfilename);
+	xDelete<char>(rootpath);
+
+}
+/*}}}*/
+/*FUNCTION FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){{{*/
+FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){
+
+	/*Call InitFromFiles. This constructor is just a wrapper: */
+	this->InitFromFiles(rootpath, inputfilename, outputfilename, petscfilename, lockfilename, in_solution_type,analyses,nummodels);
+
+}
+/*}}}*/
+/*FUNCTION FemModel::~FemModel{{{*/
+FemModel::~FemModel(){
+
+	/*Intermediary*/
+	FILE *output_fid;
+	char *outbinfilename = NULL;
+	char *lockfilename   = NULL;
+	bool  waitonlock     = false;
+
+	/*Close output file: */
+	this->parameters->FindParam(&output_fid,OutputFilePointerEnum); 
+	this->parameters->FindParam(&outbinfilename,OutputFileNameEnum); 
+	pfclose(output_fid,outbinfilename);
+
+	/*Write lock file if requested: */
+	this->parameters->FindParam(&waitonlock,SettingsWaitonlockEnum);
+	this->parameters->FindParam(&lockfilename,LockFileNameEnum);
+	if (waitonlock>0){
+		_pprintLine_("write lock file:");
+		WriteLockFile(lockfilename);
+	}
+
+	/*Delete all the datasets: */
+	xDelete<int>(analysis_type_list);
+	xDelete<char>(outbinfilename);
+	xDelete<char>(lockfilename);
+	delete elements;
+	delete nodes;
+	delete vertices;
+	delete constraints;
+	delete loads;
+	delete materials;
+	delete parameters;
+	delete results;
+
+	/*Before we delete the profiler, report statistics for this run: */
+	profiler->Tag(Finish);  //final tagging
+	_pprintLine_("");
+	_pprintLine_("   "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<profiler->DeltaTime(StartInit,FinishInit));
+	_pprintLine_("   "<<setw(40)<<left<<"Core solution elapsed time:"<<profiler->DeltaTime(StartCore,FinishCore));
+	_pprintLine_("");
+	_pprintLine_("   Total elapsed time:"
+			<<profiler->DeltaTimeModHour(Start,Finish)<<" hrs "
+			<<profiler->DeltaTimeModMin(Start,Finish)<<" min "
+			<<profiler->DeltaTimeModSec(Start,Finish)<<" sec"
+			);
+	_pprintLine_("");
+
+	/*Now delete: */
+	delete profiler;
+	
+	/*Finalize PETSC for this model: */
+	#ifdef _HAVE_PETSC_
+	_pprintLine_("closing Petsc");
+	PetscFinalize(); 
+	#endif
+
+}
+/*}}}*/
+
+/*Object management*/
+/*FUNCTION FemModel::Echo {{{*/
+void FemModel::Echo(void){
+
+	_printLine_("FemModel echo: ");
+	_printLine_("   number of fem models: " << nummodels);
+	_printLine_("   analysis_type_list: ");
+	for(int i=0;i<nummodels;i++)_printLine_("     " << i << ": " << EnumToStringx(analysis_type_list[i]));
+	_printLine_("   current analysis_type: ");
+	_printLine_("     " << analysis_counter << ": " << EnumToStringx(analysis_type_list[analysis_counter]));
+
+}
+/*}}}*/
+/*FUNCTION FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){{{*/
+void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){
+
 	/*intermediary*/
 	int         i;
 	int         analysis_type;
 	FILE       *IOMODEL = NULL;
-	extern int  my_rank;
+	FILE       *petscoptionsfid = NULL;
+	FILE       *output_fid = NULL;
+	int         my_rank;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Open input file on cpu 0: */
 	if(my_rank==0) IOMODEL = pfopen(inputfilename ,"rb");
 
 	/*Initialize internal data: */
-	this->nummodels=nummodels;
-	this->solution_type=in_solution_type;
-	this->analysis_counter=nummodels-1; //point to last analysis_type carried out.
-	this->results=new Results(); //not initialized by CreateDataSets
-	
+	this->nummodels        = nummodels;
+	this->solution_type    = in_solution_type;
+	this->analysis_counter = nummodels-1;   //point to last analysis_type carried out.
+	this->results          = new Results(); //not initialized by CreateDataSets
+
 	/*Dynamically allocate whatever is a list of length nummodels: */
 	analysis_type_list=xNew<int>(nummodels);
 
@@ -52,7 +189,7 @@
 		if(VerboseMProcessor()) _pprintLine_("   Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":");
 		analysis_type=analysis_type_list[i];
 		this->SetCurrentConfiguration(analysis_type);
-	
+
 		if(i==0){
 			if(VerboseMProcessor()) _pprintLine_("      creating vertex degrees of freedom");
 			VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
@@ -63,55 +200,47 @@
 
 		if(VerboseMProcessor()) _pprintLine_("      creating nodal degrees of freedom");
 		NodesDofx(nodes,parameters,analysis_type);
-	
+
 		if(VerboseMProcessor()) _pprintLine_("      configuring element and loads");
 		ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
 	}
-	
+
 	/*Close input file descriptors: */
 	if(my_rank==0) pfclose(IOMODEL,inputfilename);
 
-	/*Add output file name to parameters: */
-	this->parameters->AddObject(new StringParam(OutputfilenameEnum,outputfilename));
+	/*Open output file once for all and add output file name and file descriptor to parameters*/
+	output_fid=pfopen(outputfilename,"wb");
+	this->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename));
+	this->parameters->SetParam(output_fid,OutputFilePointerEnum);
 
+	/*Save lock file name for later: */
+	this->parameters->AddObject(new StringParam(LockFileNameEnum,lockfilename));
+
+	/*Now, deal with petsc options, which need to be put into the parameters dataset: */
+	petscoptionsfid=pfopen(petscfilename,"r");
+	ParsePetscOptionsx(this->parameters,petscoptionsfid);
+	pfclose(petscoptionsfid,petscfilename);
 }
-
 /*}}}*/
-/*FUNCTION FemModel::destructor {{{*/
-FemModel::~FemModel(){
+/*FUNCTION FemModel::OutputResults {{{*/
+void FemModel::OutputResults(void){
 
-	/*Intermediary*/
-	int i;
+	_pprintLine_("write results to disk:");
 
-	/*Delete all the datasets: */
-	xDelete<int>(analysis_type_list);
-	delete elements;
-	delete nodes;
-	delete vertices;
-	delete constraints;
-	delete loads;
-	delete materials;
-	delete parameters;
-	delete results;
+	/*Just call the OutputResultsx module: */
+	OutputResultsx(this->elements, this->nodes, this->vertices, this->loads, this->materials, this->parameters,this->results);
 
 }
 /*}}}*/
+/*FUNCTION FemModel::SetStaticComm {{{*/
+void FemModel::SetStaticComm(void){
 
-/*Object management*/
-/*FUNCTION FemModel::Echo {{{*/
-void FemModel::Echo(void){
+	/*This routine sets the global communicator variable hidden inside the IssmComm 
+	 *class: */
+	IssmComm::SetComm(this->comm);
 
-	_printLine_("FemModel echo: ");
-	_printLine_("   number of fem models: " << nummodels);
-	_printLine_("   analysis_type_list: ");
-	for(int i=0;i<nummodels;i++)_printLine_("     " << i << ": " << EnumToStringx(analysis_type_list[i]));
-	_printLine_("   current analysis_type: ");
-	_printLine_("     " << analysis_counter << ": " << EnumToStringx(analysis_type_list[analysis_counter]));
-
 }
 /*}}}*/
-
-/*Numerics: */
 /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){{{*/
 void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){
 
@@ -152,8 +281,1236 @@
 /*}}}*/
 /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{*/
 void FemModel::SetCurrentConfiguration(int configuration_type){
-
-	/*overload: analysis_type = configuration_type: */
 	this->SetCurrentConfiguration(configuration_type,configuration_type);
 }
 /*}}}*/
+/*FUNCTION FemModel::Solve {{{*/
+void FemModel::Solve(void){
+
+	/*profiling: */
+	bool profiling = false;
+	IssmDouble solution_time;
+	IssmDouble solution_flops;
+	IssmDouble solution_memory;
+
+	/*solution: */
+	int solution_type;
+	void (*solutioncore)(FemModel*)=NULL; //core solution function pointer
+
+	_pprintLine_("call computational core:");
+
+	/*Retrieve solution_type from parameters: */
+	parameters->FindParam(&solution_type,SolutionTypeEnum);
+
+	/*Figure out which solution core we are going to run with the current solution type: */
+	WrapperCorePointerFromSolutionEnum(&solutioncore,this->parameters,solution_type);
+
+	/*run solutoin core: */
+	profiler->Tag(StartCore);   
+	solutioncore(this); 
+	profiler->Tag(FinishCore);
+
+	/*run AD core if needed: */
+	profiler->Tag(StartAdCore); 
+	ad_core(this);      
+	profiler->Tag(FinishAdCore);
+
+	/*some profiling results for the core: */
+	parameters->FindParam(&profiling,DebugProfilingEnum);
+	if(profiling){
+
+		solution_time=profiler->DeltaTime(StartCore,FinishCore);
+		solution_flops=profiler->DeltaFlops(StartCore,FinishCore);
+		solution_memory=profiler->Memory(FinishCore);
+
+		_pprintLine_("Solution elapsed time  : " << solution_time << "  Seconds");
+		_pprintLine_("Solution elapsed flops : " << solution_flops << "  Flops");
+		_pprintLine_("Solution memory used   : " << solution_memory << "  Bytes");
+
+		/*Add to results: */
+		results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingSolutionTimeEnum, solution_time, 1, 0));
+		results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentMemEnum, solution_memory, 1, 0));
+		results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentFlopsEnum, solution_flops, 1, 0));
+	}
+}
+/*}}}*/
+
+/*Modules:*/
+void FemModel::AllocateSystemMatrices(Matrix<IssmDouble>** pKff,Matrix<IssmDouble>** pKfs,Vector<IssmDouble>** pdf,Vector<IssmDouble>** ppf){ /*{{{*/
+
+	/*Intermediary*/
+	int  fsize,ssize,flocalsize,slocalsize;
+	int  connectivity, numberofdofspernode;
+	int  configuration_type;
+	int  m,n,M,N;
+	int *d_nnz = NULL;
+	int *o_nnz = NULL;
+
+	/*output*/
+	Matrix<IssmDouble> *Kff  = NULL;
+	Matrix<IssmDouble> *Kfs  = NULL;
+	Vector<IssmDouble> *pf   = NULL;
+	Vector<IssmDouble> *df   = NULL;
+
+	bool oldalloc=false;
+
+	/*retrieve parameters: */
+	this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
+	this->parameters->FindParam(&connectivity,MeshAverageVertexConnectivityEnum);
+
+	/*retrieve node info*/
+	fsize      = this->nodes->NumberOfDofs(configuration_type,FsetEnum);
+	ssize      = this->nodes->NumberOfDofs(configuration_type,SsetEnum);
+	flocalsize = this->nodes->NumberOfDofsLocal(configuration_type,FsetEnum);
+	slocalsize = this->nodes->NumberOfDofsLocal(configuration_type,SsetEnum);
+
+	numberofdofspernode=this->nodes->MaxNumDofs(configuration_type,GsetEnum);
+
+	if(oldalloc){
+		if(pKff) Kff=new Matrix<IssmDouble>(fsize,fsize,connectivity,numberofdofspernode);
+		if(pKfs) Kfs=new Matrix<IssmDouble>(fsize,ssize,connectivity,numberofdofspernode);
+		if(pdf)  df =new Vector<IssmDouble>(fsize);
+		if(ppf)  pf =new Vector<IssmDouble>(fsize);
+	}
+	else{
+		if(pKff){
+			m=flocalsize; n=flocalsize; /*local  sizes*/
+			M=fsize;      N=fsize;      /*global sizes*/
+			this->MatrixNonzeros(&d_nnz,&o_nnz,FsetEnum,FsetEnum);
+			Kff=new Matrix<IssmDouble>(m,n,M,N,d_nnz,o_nnz);
+			xDelete<int>(d_nnz);
+			xDelete<int>(o_nnz);
+		}
+		if(pKfs){
+			m=flocalsize; n=slocalsize; /*local  sizes*/
+			M=fsize;      N=ssize;      /*global sizes*/
+			this->MatrixNonzeros(&d_nnz,&o_nnz,FsetEnum,SsetEnum);
+			Kfs=new Matrix<IssmDouble>(m,n,M,N,d_nnz,o_nnz);
+			xDelete<int>(d_nnz);
+			xDelete<int>(o_nnz);
+		}
+		if(pdf) df =new Vector<IssmDouble>(flocalsize,fsize);
+		if(ppf) pf =new Vector<IssmDouble>(flocalsize,fsize);
+	}
+
+	/*Allocate output pointers*/
+	if(pKff) *pKff = Kff;
+	if(pKfs) *pKfs = Kfs;
+	if(pdf)  *pdf  = df;
+	if(ppf)  *ppf  = pf;
+}
+/*}}}*/
+void FemModel::MatrixNonzeros(int** pd_nnz,int** po_nnz,int set1enum,int set2enum){/*{{{*/
+
+	/*Intermediary*/
+	int      i,j,k,index,offset,count;
+	int      configuration_type;
+	int      d_nz,o_nz;
+	Element *element            = NULL;
+	Load    *load               = NULL;
+	int     *head_e             = NULL;
+	int     *next_e             = NULL;
+	int     *count2offset_e     = NULL;
+	int     *head_l             = NULL;
+	int     *next_l             = NULL;
+	int     *count2offset_l     = NULL;
+	int     *sidlist            = NULL;
+
+	/*output*/
+	int *d_nnz = NULL;
+	int *o_nnz = NULL;
+
+	/*retrive parameters: */
+	this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
+
+	/*Get vector size and number of nodes*/
+	int numnodes            = nodes->NumberOfNodes(configuration_type);
+	int numberofdofspernode = nodes->MaxNumDofs(configuration_type,GsetEnum);
+	int M                   = nodes->NumberOfDofs(configuration_type,set1enum);
+	int N                   = nodes->NumberOfDofs(configuration_type,set2enum);
+	int m                   = nodes->NumberOfDofsLocal(configuration_type,set1enum);
+	int n                   = nodes->NumberOfDofsLocal(configuration_type,set2enum);
+	int numnodesperelement  = elements->MaxNumNodes();
+	int numnodesperload     = loads->MaxNumNodes(configuration_type);
+
+	/*First, we are building chaining vectors so that we know what nodes are
+	 * connected to what elements. These vectors are such that:
+	 *   for(int i=head[id];i!=-1;i=next[i])
+	 * will loop over all the elements that are connected to the node number
+	 * id*/
+	head_e         = xNew<int>(numnodes); for(i=0;i<numnodes;i++) head_e[i]=-1;
+	next_e         = xNew<int>(elements->Size()*numnodesperelement);
+	count2offset_e = xNew<int>(elements->Size()*numnodesperelement);
+
+	k=0;
+	for(i=0;i<elements->Size();i++){
+		element = dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		sidlist = xNew<int>(element->GetNumberOfNodes());
+		element->GetNodesSidList(sidlist);
+
+		for(j=0;j<element->GetNumberOfNodes();j++){
+			index = sidlist[j];
+			_assert_(index>=0 && index<numnodes);
+
+			count2offset_e[k]=i;
+			next_e[k]=head_e[index];
+			head_e[index]=k++;
+		}
+		for(j=0;j<numnodesperelement-element->GetNumberOfNodes();j++) k++;
+
+		xDelete<int>(sidlist);
+	}
+
+	/*Chain for loads*/
+	head_l         = xNew<int>(numnodes); for(i=0;i<numnodes;i++) head_l[i]=-1;
+	next_l         = xNew<int>(loads->Size(configuration_type)*numnodesperload);
+	count2offset_l = xNew<int>(loads->Size(configuration_type)*numnodesperload);
+	k=0;
+	for(i=0;i<loads->Size();i++){
+		load = dynamic_cast<Load*>(loads->GetObjectByOffset(i));
+		if(!load->InAnalysis(configuration_type)) continue;
+		sidlist = xNew<int>(load->GetNumberOfNodes());
+		load->GetNodesSidList(sidlist);
+
+		for(j=0;j<load->GetNumberOfNodes();j++){
+			index = sidlist[j];
+			_assert_(index>=0 && index<numnodes);
+
+			count2offset_l[k]=i;
+			next_l[k]=head_l[index];
+			head_l[index]=k++;
+		}
+		for(j=0;j<numnodesperload-load->GetNumberOfNodes();j++) k++;
+
+		xDelete<int>(sidlist);
+	}
+
+	/*OK now count number of dofs and flag each nodes for each node i*/
+	bool *flags                  = xNew<bool>(numnodes);
+	int  *d_connectivity         = xNewZeroInit<int>(numnodes);
+	int  *o_connectivity         = xNewZeroInit<int>(numnodes);
+	int  *connectivity_clone     = xNewZeroInit<int>(numnodes);
+	int  *all_connectivity_clone = xNewZeroInit<int>(numnodes);
+
+	/*Create connectivity vector*/
+	for(i=0;i<nodes->Size();i++){
+		Node* node=dynamic_cast<Node*>(nodes->GetObjectByOffset(i));
+		if(node->InAnalysis(configuration_type)){
+
+			/*Reinitialize flags to 0*/
+			for(j=0;j<numnodes;j++) flags[j]=false;
+
+			/*Loop over elements that hold node number i*/
+			_assert_(head_e[node->Sid()]!=-1 || head_l[node->Sid()]!=-1);
+			for(j=head_e[node->Sid()];j!=-1;j=next_e[j]){
+				offset=count2offset_e[j];
+				element=dynamic_cast<Element*>(elements->GetObjectByOffset(offset));
+				element->SetwiseNodeConnectivity(&d_nz,&o_nz,node,flags,set1enum,set2enum);
+				if(node->IsClone()){
+					connectivity_clone[node->Sid()]+=d_nz+o_nz;
+				}
+				else{
+					d_connectivity[node->Sid()]+=d_nz;
+					o_connectivity[node->Sid()]+=o_nz;
+				}
+			}
+			for(j=head_l[node->Sid()];j!=-1;j=next_l[j]){
+				offset=count2offset_l[j];
+				load=dynamic_cast<Load*>(loads->GetObjectByOffset(offset));
+				load->SetwiseNodeConnectivity(&d_nz,&o_nz,node,flags,set1enum,set2enum);
+				if(node->IsClone()){
+					connectivity_clone[node->Sid()]+=d_nz+o_nz;
+				}
+				else{
+					d_connectivity[node->Sid()]+=d_nz;
+					o_connectivity[node->Sid()]+=o_nz;
+				}
+			}
+		}
+	}
+	xDelete<bool>(flags);
+	xDelete<int>(count2offset_e);
+	xDelete<int>(head_e);
+	xDelete<int>(next_e);
+	xDelete<int>(count2offset_l);
+	xDelete<int>(head_l);
+	xDelete<int>(next_l);
+
+	/*sum over all cpus*/
+#ifdef _HAVE_MPI_
+	MPI_Allreduce((void*)connectivity_clone,(void*)all_connectivity_clone,numnodes,MPI_INT,MPI_SUM,IssmComm::GetComm());
+#endif
+	xDelete<int>(connectivity_clone);
+
+	if(set1enum==FsetEnum){
+		count=0;
+		d_nnz=xNew<int>(m);
+		o_nnz=xNew<int>(m);
+		for(i=0;i<nodes->Size();i++){
+			Node* node=dynamic_cast<Node*>(nodes->GetObjectByOffset(i));
+			if(node->InAnalysis(configuration_type) && !node->IsClone()){
+				for(j=0;j<node->indexing.fsize;j++){
+					_assert_(count<m);
+					d_nnz[count]=numberofdofspernode*(d_connectivity[node->Sid()] + all_connectivity_clone[node->Sid()]);
+					o_nnz[count]=numberofdofspernode*(o_connectivity[node->Sid()] + all_connectivity_clone[node->Sid()]);
+					if(d_nnz[count]>n)   d_nnz[count]=n;
+					if(o_nnz[count]>N-n) o_nnz[count]=N-n;
+					count++;
+				}
+			}
+		}
+		_assert_(m==count);
+	}
+	else{
+		_error_("STOP not implemented");
+	}
+	xDelete<int>(d_connectivity);
+	xDelete<int>(o_connectivity);
+	xDelete<int>(all_connectivity_clone);
+
+	/*Allocate ouptput pointer*/
+	*pd_nnz=d_nnz;
+	*po_nnz=o_nnz;
+
+}/*}}}*/
+void FemModel::CreateJacobianMatrixx(Matrix<IssmDouble>** pJff,IssmDouble kmax){/*{{{*/
+
+	int      i,connectivity;
+	int      numberofdofspernode;
+	int      fsize,configuration_type;
+	Element *element = NULL;
+	Load    *load    = NULL;
+	Matrix<IssmDouble>* Jff = NULL;
+
+	/*Checks*/
+	_assert_(nodes && elements);
+
+	/*Recover some parameters*/
+	parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
+	parameters->FindParam(&connectivity,MeshAverageVertexConnectivityEnum);
+	fsize=nodes->NumberOfDofs(configuration_type,FsetEnum);
+	numberofdofspernode=nodes->MaxNumDofs(configuration_type,GsetEnum);
+
+	/*Initialize Jacobian Matrix*/
+	this->AllocateSystemMatrices(&Jff,NULL,NULL,NULL);
+
+	/*Create and assemble matrix*/
+	for(i=0;i<elements->Size();i++){
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		element->CreateJacobianMatrix(Jff);
+	}
+	for (i=0;i<loads->Size();i++){
+		load=(Load*)loads->GetObjectByOffset(i);
+		if(load->InAnalysis(configuration_type)) load->CreateJacobianMatrix(Jff);
+		if(load->InAnalysis(configuration_type)) load->PenaltyCreateJacobianMatrix(Jff,kmax);
+	}
+	Jff->Assemble();
+
+	/*Assign output pointer*/
+	*pJff=Jff;
+
+}/*}}}*/
+int  FemModel::UpdateVertexPositionsx(void){ /*{{{*/
+
+	int     i;
+	Vector<IssmDouble>*     vz        = NULL;
+	Vertex *vertex    = NULL;
+	IssmDouble *thickness = NULL;
+	IssmDouble *bed       = NULL;
+
+	/*get vertex vectors for bed and thickness: */
+	GetVectorFromInputsx(&thickness,elements,nodes, vertices, loads, materials, parameters, ThicknessEnum,VertexEnum);
+	GetVectorFromInputsx(&bed      ,elements,nodes, vertices, loads, materials, parameters, BedEnum,      VertexEnum);
+
+	/*Allocate vector*/
+	vz=new Vector<IssmDouble>(vertices->NumberOfVertices());
+
+	/*Update verices new geometry: */
+	for (i=0;i<vertices->Size();i++){
+		vertex=(Vertex*)vertices->GetObjectByOffset(i);
+		vertex->UpdatePosition(vz,parameters,thickness,bed);
+	}
+
+	/*Assemble mesh velocity*/
+	vz->Assemble();
+
+	/*Update element inputs*/
+	InputUpdateFromVectorx(elements,nodes,vertices,loads,materials,parameters,vz,VzMeshEnum,VertexEnum);
+
+	/*Free ressources:*/
+	xDelete<IssmDouble>(thickness);
+	xDelete<IssmDouble>(bed);
+	xdelete(&vz);
+	return 1;
+}
+/*}}}*/
+void FemModel::UpdateConstraintsx(void){ /*{{{*/
+
+	IssmDouble time;
+	int    analysis_type;
+
+	/*retrieve parameters: */
+	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
+	parameters->FindParam(&time,TimeEnum);
+
+	/*start module: */
+	if(VerboseModule()) _pprintLine_("   Updating constraints for time: " << time);
+
+	/*First, update dof constraints in nodes, using constraints: */
+	SpcNodesx(nodes,constraints,parameters,analysis_type); 
+
+	/*Now, update degrees of freedoms: */
+	NodesDofx(nodes,parameters,analysis_type);
+
+}
+/*}}}*/
+void FemModel::Responsex(IssmDouble* responses,const char* response_descriptor,bool process_units,int weight_index){/*{{{*/
+
+	int response_descriptor_enum=StringToEnumx(response_descriptor);
+	this->Responsex(responses, response_descriptor_enum, process_units, weight_index);
+
+}
+/*}}}*/
+void FemModel::Responsex(IssmDouble* responses,int response_descriptor_enum,bool process_units,int weight_index){/*{{{*/
+
+
+	switch (response_descriptor_enum){
+
+		#ifdef _HAVE_RESPONSES_
+		case IceVolumeEnum:              this->IceVolumex(responses,process_units); break;
+		case MinVelEnum:                 this->MinVelx(responses,process_units); break;
+		case MaxVelEnum:                 this->MaxVelx(                  responses,process_units); break;
+		case MinVxEnum:                  this->MinVxx(responses,process_units); break;
+		case MaxVxEnum:                  this->MaxVxx(                   responses,process_units); break;
+		case MaxAbsVxEnum:               this->MaxAbsVxx(                responses,process_units); break;
+		case MinVyEnum:                  this->MinVyx(responses,process_units); break;
+		case MaxVyEnum:                  this->MaxVyx(                   responses,process_units); break;
+		case MaxAbsVyEnum:               this->MaxAbsVyx(                responses,process_units); break;
+		case MinVzEnum:                  this->MinVzx(responses,process_units); break;
+		case MaxVzEnum:                  this->MaxVzx(                   responses,process_units); break;
+		case MaxAbsVzEnum:               this->MaxAbsVzx(                responses,process_units); break;
+		case MassFluxEnum:               this->MassFluxx(         responses,process_units); break;
+		case SurfaceAbsVelMisfitEnum:    SurfaceAbsVelMisfitx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case SurfaceRelVelMisfitEnum:    SurfaceRelVelMisfitx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case SurfaceLogVelMisfitEnum:    SurfaceLogVelMisfitx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case SurfaceLogVxVyMisfitEnum:   SurfaceLogVxVyMisfitx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case SurfaceAverageVelMisfitEnum:SurfaceAverageVelMisfitx( responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case ThicknessAbsMisfitEnum:     ThicknessAbsMisfitx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case ThicknessAbsGradientEnum:   this->ThicknessAbsGradientx(responses, process_units,weight_index); break;
+		case ThicknessAlongGradientEnum: ThicknessAlongGradientx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case ThicknessAcrossGradientEnum:ThicknessAcrossGradientx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case TotalSmbEnum:					this->TotalSmbx(responses,process_units); break;
+		case RheologyBbarAbsGradientEnum:RheologyBbarAbsGradientx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case DragCoefficientAbsGradientEnum:DragCoefficientAbsGradientx(responses, elements,nodes, vertices, loads, materials, parameters,process_units,weight_index); break;
+		case MaterialsRheologyBbarEnum: this->ElementResponsex(responses,MaterialsRheologyBbarEnum,process_units); break;
+		case VelEnum:                   this->ElementResponsex(responses,VelEnum,process_units); break;
+		case FrictionCoefficientEnum:NodalValuex(responses, FrictionCoefficientEnum,elements,nodes, vertices, loads, materials, parameters,process_units); break;
+		default: _error_("response descriptor \"" << EnumToStringx(response_descriptor_enum) << "\" not supported yet!"); break;
+		#else
+		default: _error_("ISSM was not compiled with responses capabilities, exiting!");
+		#endif
+	}
+
+}
+/*}}}*/
+void FemModel::RequestedOutputsx(int* requested_outputs, int numoutputs){/*{{{*/
+
+
+	int      output_enum;
+	int      step;
+	IssmDouble   time;
+	IssmDouble   output_value;
+	Element *element      = NULL;
+
+	/*Get time and step*/
+	parameters->FindParam(&step,StepEnum);
+	parameters->FindParam(&time,TimeEnum);
+
+	/*retrieve Inputs*/
+	if(numoutputs){
+		for(int i=0;i<numoutputs;i++){
+			output_enum=requested_outputs[i];
+
+			switch(output_enum){
+
+				case IceVolumeEnum:
+					Responsex(&output_value,"IceVolume",false,0);
+					results->AddObject(new GenericExternalResult<double>(results->Size()+1,IceVolumeEnum,reCast<IssmPDouble>(output_value),step,time));
+					break;
+				case TotalSmbEnum:
+					Responsex(&output_value,"TotalSmb",false,0);
+					results->AddObject(new GenericExternalResult<double>(results->Size()+1,TotalSmbEnum,reCast<IssmPDouble>(output_value),step,time));
+					break;
+				case MaxVelEnum:
+					Responsex(&output_value,"MaxVel",false,0);
+					results->AddObject(new GenericExternalResult<double>(results->Size()+1,MaxVelEnum,reCast<IssmPDouble>(output_value),step,time));
+					break;
+				default:
+					/*create this output in the element inputs, and then transfer to results:*/
+					for(int j=0;j<elements->Size();j++){
+						element=(Element*)elements->GetObjectByOffset(j);
+						element->RequestedOutput(output_enum,step,time);
+					}
+					break;
+			}
+		}
+	}
+}
+/*}}}*/
+void FemModel::RequestedDependentsx(void){/*{{{*/
+
+
+	bool        isautodiff      = false;
+	IssmDouble  output_value;
+
+	int         num_dependents;
+	IssmPDouble *dependents;
+	DataSet*    dependent_objects=NULL;
+
+	/*AD mode on?: */
+	parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum);
+
+	if(isautodiff){
+		#ifdef _HAVE_ADOLC_
+		parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum);
+		parameters->FindParam(&dependent_objects,AutodiffDependentObjectsEnum);
+		if(num_dependents){
+			dependents=xNew<IssmPDouble>(num_dependents);
+
+			/*Go through our dependent variables, and compute the response:*/
+			for(int i=0;i<dependent_objects->Size();i++){
+				DependentObject* dep=(DependentObject*)dependent_objects->GetObjectByOffset(i);
+				dep->Responsex(&output_value,this);
+				output_value>>=dependents[i];
+			}
+		}
+		delete dependent_objects;
+		#else
+		_error_("Should not be requesting dependents when an AD library is not available!");
+		#endif
+	}
+}
+/*}}}*/
+void FemModel::SystemMatricesx(Matrix<IssmDouble>** pKff, Matrix<IssmDouble>** pKfs, Vector<IssmDouble>** ppf, Vector<IssmDouble>** pdf, IssmDouble* pkmax){/*{{{*/
+
+	/*intermediary: */
+	int      i;
+	int      configuration_type;
+	Element *element = NULL;
+	Load    *load    = NULL;
+
+	/*output: */
+	Matrix<IssmDouble> *Kff  = NULL;
+	Matrix<IssmDouble> *Kfs  = NULL;
+	Vector<IssmDouble> *pf   = NULL;
+	Vector<IssmDouble> *df   = NULL;
+	IssmDouble          kmax = 0;
+
+	/*Display message*/
+	if(VerboseModule()) _pprintLine_("   Generating matrices");
+
+	/*retrive parameters: */
+	this->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
+
+	/*First, we might need to do a dry run to get kmax if penalties are employed*/
+	if(loads->IsPenalty(configuration_type)){
+
+		/*Allocate Kff_temp*/
+		Matrix<IssmDouble> *Kff_temp = NULL;
+		this->AllocateSystemMatrices(&Kff_temp,NULL,NULL,NULL);
+
+		/*Get complete stiffness matrix without penalties*/
+		for (i=0;i<this->elements->Size();i++){
+			element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+			element->CreateKMatrix(Kff_temp,NULL,NULL);
+		}
+		for (i=0;i<this->loads->Size();i++){
+			load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i));
+			if(load->InAnalysis(configuration_type)) load->CreateKMatrix(Kff_temp,NULL);
+		}
+		Kff_temp->Assemble();
+
+		/*Now, figure out maximum value of stiffness matrix, so that we can penalize it correctly: */
+		kmax=Kff_temp->Norm(NORM_INF);
+		delete Kff_temp;
+	}
+
+	/*Allocate stiffness matrices and load vector*/
+	this->AllocateSystemMatrices(&Kff,&Kfs,&df,&pf);
+
+	/*Fill stiffness matrix from elements and loads */
+	for (i=0;i<this->elements->Size();i++){
+		element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		element->CreateKMatrix(Kff,Kfs,df);
+	}
+	for (i=0;i<this->loads->Size();i++){
+		load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i));
+		if(load->InAnalysis(configuration_type)) load->CreateKMatrix(Kff,Kfs);
+	}
+
+	/*Fill right hand side vector, from elements and loads */
+	for (i=0;i<this->elements->Size();i++){
+		element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		element->CreatePVector(pf);
+	}
+	for (i=0;i<this->loads->Size();i++){
+		load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i));
+		if(load->InAnalysis(configuration_type)) load->CreatePVector(pf);
+	}
+
+	/*Now deal with penalties (only in loads)*/
+	if(loads->IsPenalty(configuration_type)){
+		for (i=0;i<this->loads->Size();i++){
+			load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i));
+			if(load->InAnalysis(configuration_type)) load->PenaltyCreateKMatrix(Kff,Kfs,kmax);
+		}
+		for (i=0;i<this->loads->Size();i++){
+			load=dynamic_cast<Load*>(this->loads->GetObjectByOffset(i));
+			if(load->InAnalysis(configuration_type)) load->PenaltyCreatePVector(pf,kmax);
+		}
+	}
+
+	/*Assemble matrices and vector*/
+	Kff->Assemble();
+	Kfs->Assemble();
+	pf->Assemble();
+	df->Assemble();
+	//Kff->AllocationInfo();
+	//Kfs->AllocationInfo();
+
+	/*Assign output pointers: */
+	if(pKff) *pKff=Kff;
+	else      xdelete(&Kff);
+	if(pKfs) *pKfs=Kfs;
+	else      xdelete(&Kfs);
+	if(ppf)  *ppf=pf;
+	else      xdelete(&pf);
+	if(pdf)  *pdf=df;
+	else      xdelete(&df);
+	if(pkmax) *pkmax=kmax;
+}
+/*}}}*/
+void FemModel::TimeAdaptx(IssmDouble* pdt){/*{{{*/
+
+	int      i;
+
+	/*output: */
+	IssmDouble   dt;
+
+	/*intermediary: */
+	Element *element     = NULL;
+	IssmDouble   min_dt      = 0;
+	IssmDouble   node_min_dt = 0;
+
+	/*Go through elements, and figure out the minimum of the time steps for each element (using CFL criterion): */
+	element=(Element*)elements->GetObjectByOffset(0); min_dt=element->TimeAdapt();
+
+	for (i=1;i<elements->Size();i++){
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		dt=element->TimeAdapt();
+		if(dt<min_dt)min_dt=dt;
+	}
+
+	/*Figure out minimum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce (&min_dt,&node_min_dt,1,MPI_DOUBLE,MPI_MIN,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_min_dt,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	min_dt=node_min_dt;
+#endif
+
+	/*Assign output pointers:*/
+	*pdt=min_dt;
+}
+/*}}}*/
+#ifdef _HAVE_RESPONSES_
+void FemModel::MassFluxx(IssmDouble* pmass_flux,bool process_units){/*{{{*/
+
+	int          i,j;
+	Element     *element       = NULL;
+	int          element_id;
+	bool         ispresent     = false;
+	IssmDouble   mass_flux     = 0;
+	IssmDouble   all_mass_flux = 0;
+	int          counter;
+	IssmDouble **array         = NULL;
+	int          M;
+	int         *mdims_array   = NULL;
+	int         *ndims_array   = NULL;
+	IssmDouble  *segments      = NULL;
+	int          num_segments;
+
+	/*First, figure out which segment to compute our mass flux on. Start with retrieving qmu_mass_flux_segments: */
+	this->parameters->FindParam(&ispresent,MassFluxSegmentsPresentEnum);
+	if(!ispresent)_error_("no mass flux segments available!");
+	this->parameters->FindParam(&array,&M,&mdims_array,&ndims_array,MassFluxSegmentsEnum);
+
+	/*Retrieve index of segments being used for MassFlux computation: */
+	parameters->FindParam(&counter,IndexEnum);
+
+	/*retrieve segments from array: */
+	segments     = array[counter-1]; //matlab to "C" indexing
+	num_segments = mdims_array[counter-1];
+
+	/*Go through segments, and then elements, and figure out which elements belong to a segment. 
+	 * When we find one, use the element to compute the mass flux on the segment: */
+	for(i=0;i<num_segments;i++){
+		element_id=reCast<int,IssmDouble>(*(segments+5*i+4));
+		for(j=0;j<elements->Size();j++){
+			element=(Element*)this->elements->GetObjectByOffset(j);
+			if (element->Id()==element_id){
+				/*We found the element which owns this segment, use it to compute the mass flux: */
+				mass_flux+=element->MassFlux(segments+5*i+0,process_units);
+				break;
+			}
+		}
+	}
+
+#ifdef _HAVE_MPI_
+	MPI_Allreduce ( (void*)&mass_flux,(void*)&all_mass_flux,1,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm());
+	mass_flux=all_mass_flux;
+#endif
+
+	/*Free ressources:*/
+	for(i=0;i<M;i++){
+		IssmDouble* matrix=array[i];
+		xDelete<IssmDouble>(matrix);
+	}
+	xDelete<int>(mdims_array);
+	xDelete<int>(ndims_array);
+	xDelete<IssmDouble*>(array);
+
+	/*Assign output pointers: */
+	*pmass_flux=mass_flux;
+
+}/*}}}*/
+void FemModel::MaxAbsVxx(IssmDouble* pmaxabsvx,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxabsvx;
+	IssmDouble node_maxabsvx;
+	IssmDouble element_maxabsvx;
+
+	/*Go through elements, and request velocity: */
+	maxabsvx=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxAbsVx(&element_maxabsvx,process_units);
+		if(element_maxabsvx>maxabsvx) maxabsvx=element_maxabsvx;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxabsvx,&node_maxabsvx,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxabsvx,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxabsvx=node_maxabsvx;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxabsvx=maxabsvx;
+
+}/*}}}*/
+void FemModel::MaxAbsVyx(IssmDouble* pmaxabsvy,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxabsvy;
+	IssmDouble node_maxabsvy;
+	IssmDouble element_maxabsvy;
+
+	/*Go through elements, and request velocity: */
+	maxabsvy=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxAbsVy(&element_maxabsvy,process_units);
+		if(element_maxabsvy>maxabsvy) maxabsvy=element_maxabsvy;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxabsvy,&node_maxabsvy,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxabsvy,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxabsvy=node_maxabsvy;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxabsvy=maxabsvy;
+
+}/*}}}*/
+void FemModel::MaxAbsVzx(IssmDouble* pmaxabsvz,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxabsvz;
+	IssmDouble node_maxabsvz;
+	IssmDouble element_maxabsvz;
+
+	/*Go through elements, and request velocity: */
+	maxabsvz=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxAbsVz(&element_maxabsvz,process_units);
+		if(element_maxabsvz>maxabsvz) maxabsvz=element_maxabsvz;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxabsvz,&node_maxabsvz,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxabsvz,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxabsvz=node_maxabsvz;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxabsvz=maxabsvz;
+
+}/*}}}*/
+void FemModel::MaxVelx(IssmDouble* pmaxvel,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxvel;
+	IssmDouble node_maxvel;
+	IssmDouble element_maxvel;
+
+	/*Go through elements, and request velocity: */
+	maxvel=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxVel(&element_maxvel,process_units);
+		if(element_maxvel>maxvel) maxvel=element_maxvel;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxvel,&node_maxvel,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxvel,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxvel=node_maxvel;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxvel=maxvel;
+
+}/*}}}*/
+void FemModel::MaxVxx(IssmDouble* pmaxvx,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxvx;
+	IssmDouble node_maxvx;
+	IssmDouble element_maxvx;
+
+	/*Go through elements, and request velocity: */
+	maxvx=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxVx(&element_maxvx,process_units);
+		if(element_maxvx>maxvx) maxvx=element_maxvx;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxvx,&node_maxvx,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxvx,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxvx=node_maxvx;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxvx=maxvx;
+
+}/*}}}*/
+void FemModel::MaxVyx(IssmDouble* pmaxvy,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxvy;
+	IssmDouble node_maxvy;
+	IssmDouble element_maxvy;
+
+	/*Go through elements, and request velocity: */
+	maxvy=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxVy(&element_maxvy,process_units);
+		if(element_maxvy>maxvy) maxvy=element_maxvy;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxvy,&node_maxvy,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxvy,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxvy=node_maxvy;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxvy=maxvy;
+
+}/*}}}*/
+void FemModel::MaxVzx(IssmDouble* pmaxvz,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble maxvz;
+	IssmDouble node_maxvz;
+	IssmDouble element_maxvz;
+
+	/*Go through elements, and request velocity: */
+	maxvz=-INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MaxVz(&element_maxvz,process_units);
+		if(element_maxvz>maxvz) maxvz=element_maxvz;
+	}
+
+	/*Figure out maximum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&maxvz,&node_maxvz,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_maxvz,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	maxvz=node_maxvz;
+#endif
+
+	/*Assign output pointers:*/
+	*pmaxvz=maxvz;
+
+}/*}}}*/
+void FemModel::MinVelx(IssmDouble* pminvel,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble minvel;
+	IssmDouble node_minvel;
+	IssmDouble element_minvel;
+
+	/*Go through elements, and request velocity: */
+	minvel=INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MinVel(&element_minvel,process_units);
+		if(element_minvel<minvel) minvel=element_minvel;
+	}
+
+	/*Figure out minimum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&minvel,&node_minvel,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_minvel,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	minvel=node_minvel;
+#endif
+
+	/*Assign output pointers:*/
+	*pminvel=minvel;
+
+}/*}}}*/
+void FemModel::MinVxx(IssmDouble* pminvx,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble minvx;
+	IssmDouble node_minvx;
+	IssmDouble element_minvx;
+
+	/*Go through elements, and request velocity: */
+	minvx=INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MinVx(&element_minvx,process_units);
+		if(element_minvx<minvx) minvx=element_minvx;
+	}
+
+	/*Figure out minimum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&minvx,&node_minvx,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_minvx,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	minvx=node_minvx;
+#endif
+
+	/*Assign output pointers:*/
+	*pminvx=minvx;
+
+}/*}}}*/
+void FemModel::MinVyx(IssmDouble* pminvy,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble minvy;
+	IssmDouble node_minvy;
+	IssmDouble element_minvy;
+
+	/*Go through elements, and request velocity: */
+	minvy=INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MinVy(&element_minvy,process_units);
+		if(element_minvy<minvy) minvy=element_minvy;
+	}
+
+	/*Figure out minimum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&minvy,&node_minvy,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_minvy,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	minvy=node_minvy;
+#endif
+
+	/*Assign output pointers:*/
+	*pminvy=minvy;
+
+}/*}}}*/
+void FemModel::MinVzx(IssmDouble* pminvz,bool process_units){/*{{{*/
+
+	int i;
+	IssmDouble minvz;
+	IssmDouble node_minvz;
+	IssmDouble element_minvz;
+
+	/*Go through elements, and request velocity: */
+	minvz=INFINITY;
+	for(i=0;i<this->elements->Size();i++){
+		Element* element=(Element*)this->elements->GetObjectByOffset(i);
+		element->MinVz(&element_minvz,process_units);
+		if(element_minvz<minvz) minvz=element_minvz;
+	}
+
+	/*Figure out minimum across the cluster: */
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&minvz,&node_minvz,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&node_minvz,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	minvz=node_minvz;
+#endif
+
+	/*Assign output pointers:*/
+	*pminvz=minvz;
+
+}/*}}}*/
+void FemModel::TotalSmbx(IssmDouble* pSmb,bool process_units){/*{{{*/
+
+	IssmDouble local_smb = 0;
+	IssmDouble total_smb;
+
+	for(int i=0;i<this->elements->Size();i++){
+		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		local_smb+=element->TotalSmb();
+	}
+#ifdef _HAVE_MPI_
+	MPI_Reduce(&local_smb,&total_smb,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&total_smb,1,MPI_DOUBLE,0,IssmComm::GetComm());
+#else
+	total_smb=local_smb;
+#endif
+
+	/*Assign output pointers: */
+	*pSmb=total_smb;
+
+}/*}}}*/
+void FemModel::IceVolumex(IssmDouble* pV,bool process_units){/*{{{*/
+
+	IssmDouble local_ice_volume = 0;
+	IssmDouble total_ice_volume;
+
+	for(int i=0;i<this->elements->Size();i++){
+		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		local_ice_volume+=element->IceVolume();
+	}
+	#ifdef _HAVE_MPI_
+	MPI_Reduce(&local_ice_volume,&total_ice_volume,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&total_ice_volume,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	#else
+	total_ice_volume=local_ice_volume;
+	#endif
+
+	/*Assign output pointers: */
+	*pV=total_ice_volume;
+
+}/*}}}*/
+void FemModel::ElementResponsex(IssmDouble* presponse,int response_enum,bool process_units){/*{{{*/
+
+	int found=0;
+	int sumfound=0;
+	int cpu_found=-1;
+	int index;
+	IssmDouble response;
+	Element* element=NULL;
+
+	/*retrieve element we are interested in: */
+	this->parameters->FindParam(&index,IndexEnum);
+	int my_rank=IssmComm::GetRank();
+
+	/*now, go through our elements, and retrieve the one with this id: index: */
+	for(int i=0;i<this->elements->Size();i++){
+		element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		if (element->Id()==index){
+			found=1;
+			cpu_found=my_rank;
+			break;
+		}
+	}
+
+	/*Broadcast whether we found the element: */
+#ifdef _HAVE_MPI_
+	MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
+	if(!sumfound)_error_("could not find material with id" << index << " to compute ElementResponse");
+#endif
+
+	/*Ok, we found the element, compute responseocity: */
+	if(my_rank==cpu_found){
+		element->ElementResponse(&response,response_enum,IuToExtEnum);
+	}
+
+	/*Broadcast and plug into response: */
+#ifdef _HAVE_MPI_
+	MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
+	MPI_Bcast(&response,1,MPI_DOUBLE,cpu_found,IssmComm::GetComm()); 
+#endif
+
+	/*Assign output pointers: */
+	*presponse=response;
+
+}/*}}}*/
+#endif
+#ifdef _HAVE_CONTROL_
+void FemModel::ThicknessAbsGradientx( IssmDouble* pJ, bool process_units, int weight_index){/*{{{*/
+
+
+	/*Intermediary*/
+	int i;
+	Element* element=NULL;
+
+	/*output: */
+	IssmDouble J=0;
+	IssmDouble J_sum;
+
+	/*Compute Misfit: */
+	for (i=0;i<elements->Size();i++){
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		J+=element->ThicknessAbsGradient(process_units,weight_index);
+	}
+
+	/*Sum all J from all cpus of the cluster:*/
+	#ifdef _HAVE_MPI_
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	J=J_sum;
+	#endif
+
+	/*Assign output pointers: */
+	*pJ=J;
+}
+/*}}}*/
+void FemModel::CostFunctionx(IssmDouble* pJ){/*{{{*/
+
+
+	/*Intermediary*/
+	int      num_responses;
+	Element *element       = NULL;
+	int     *responses     = NULL;
+
+	/*output: */
+	IssmDouble J,Jplus;
+
+	/*Recover parameters*/
+	parameters->FindParam(&num_responses,InversionNumCostFunctionsEnum);
+	parameters->FindParam(&responses,NULL,NULL,StepResponsesEnum);
+
+	/*Get response*/
+	J=0;
+	for(int i=0;i<num_responses;i++){
+		this->Responsex(&Jplus,EnumToStringx(responses[i]),false,i); //False means DO NOT process units
+		J+=Jplus;
+	}
+
+	/*Assign output pointers: */
+	xDelete<int>(responses);
+	*pJ=J;
+}
+/*}}}*/
+#endif
+#ifdef  _HAVE_DAKOTA_
+void FemModel::DakotaResponsesx(double* d_responses,char** responses_descriptors,int numresponsedescriptors,int d_numresponses){/*{{{*/
+
+
+	int        i,j;
+	int        my_rank;
+	bool       process_units = true;
+
+	/*intermediary: */
+	char   root[50];
+	int    index;
+	int    npart;
+	double femmodel_response;
+	int    flag;
+	double *vertex_response   = NULL;
+	double *qmu_response      = NULL;
+	double *responses_pointer = NULL;
+
+	/*retrieve npart: */
+	parameters->FindParam(&npart,QmuNumberofpartitionsEnum);
+	my_rank=IssmComm::GetRank();
+
+	/*save the d_responses pointer: */
+	responses_pointer=d_responses;
+
+	//watch out, we have more d_numresponses than numresponsedescriptors, because the responses have been expanded if they were scaled. 
+	//because we don't know the d_responses descriptors (the scaled ones) we can't key off them, so we will key off the responses_descriptors: */
+
+	for(i=0;i<numresponsedescriptors;i++){
+
+		flag=DescriptorIndex(root,&index,responses_descriptors[i]);
+
+		if(flag==ScaledEnum){
+
+			/*this response was scaled. pick up the response from the inputs: */
+			GetVectorFromInputsx(&vertex_response,elements,nodes, vertices, loads, materials, parameters, StringToEnumx(root),VertexEnum);
+
+			/*Now, average it onto the partition nodes: */
+			AverageOntoPartitionx(&qmu_response,elements,nodes,vertices,loads,materials,parameters,vertex_response);
+
+			/*Copy onto our dakota responses: */
+			if(my_rank==0){
+				/*plug response: */
+				for(j=0;j<npart;j++)responses_pointer[j]=qmu_response[j];
+
+				/*increment response_pointer :*/
+				responses_pointer+=npart;
+			}
+
+			/*Free ressources:*/
+			xDelete<double>(vertex_response);
+			xDelete<double>(qmu_response);
+
+		}
+		else if (flag==IndexedEnum){
+
+			/*indexed response: plug index into parameters and call response module: */
+			parameters->SetParam(index,IndexEnum);
+
+			this->Responsex(&femmodel_response,root,process_units,0);//0 is the index for weights
+
+			if(my_rank==0){
+				/*plug response: */
+				responses_pointer[0]=femmodel_response;
+
+				/*increment response_pointer :*/
+				responses_pointer++;
+			}
+		}
+		else if (flag==NodalEnum){
+			_error_("nodal response functions not supported yet!");
+
+			/*increment response_pointer :*/
+			responses_pointer++;
+		}
+		else if (flag==RegularEnum){
+
+			/*perfectly normal response function: */
+			this->Responsex(&femmodel_response,root,process_units,0);//0 is the weight index
+
+			if(my_rank==0){
+				/*plug response: */
+				responses_pointer[0]=femmodel_response;
+
+				/*increment response_pointer :*/
+				responses_pointer++;
+			}
+		}
+		else _error_("flag type " << flag << " not supported yet for response analysis");
+	}
+
+	/*Synthesize echo: {{{*/
+	if(my_rank==0){
+		_printString_("   responses: " << d_numresponses << ": ");
+		for(i=0;i<d_numresponses-1;i++)_printString_(d_responses[i] << "|");
+		_printString_(d_responses[d_numresponses-1]);
+		_printLine_("");
+	}
+	/*}}}*/
+
+}
+/*}}}*/
+#endif

Modified: issm/trunk/src/c/classes/FemModel.h
===================================================================
--- issm/trunk/src/c/classes/FemModel.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/FemModel.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,40 +18,83 @@
 class Constraints;
 class Loads;
 class Materials;
+class Profiler;
+class Elements;
 /*}}}*/
 
-
 class FemModel {
 
 	/*no private members, as we need access to these datasets quite often!:*/
 
 	public:
 
-		int                 nummodels;
-		int                 solution_type;
-		int*                analysis_type_list; //list of analyses this femmodel is going to carry out
-		int                 analysis_counter; //counter into analysis_type_list
-		
-		Elements*           elements; //elements (one set for all analyses)
-		Nodes*              nodes; //one set of nodes
-		Vertices*           vertices; //one set of vertices
-		Constraints*        constraints; //one set of constraints. each constraint knows which analysis_type it handles
-		Loads*              loads;  //one set of constraints. each constraint knows which analysis_type it handles
-		Materials*          materials;  //one set of materials, for each element
-		Parameters*         parameters; //one set of parameters, independent of the analysis_type
-		Results*            results; //results that cannot be fit into the elements (such as one time constants, arrays, strings, etc ...)
+		int          nummodels;
+		int          solution_type;
+		int         *analysis_type_list;   //list of analyses this femmodel is going to carry out
+		int          analysis_counter;     //counter into analysis_type_list
 
+		Profiler*    profiler;             //keep time, cpu and mem statistics while we are running.
+
+		Elements    *elements;             //elements (one set for all analyses)
+		Nodes       *nodes;                //one set of nodes
+		Vertices    *vertices;             //one set of vertices
+		Constraints *constraints;          //one set of constraints. each constraint knows which analysis_type it handles
+		Loads       *loads;                //one set of constraints. each constraint knows which analysis_type it handles
+		Materials   *materials;            //one set of materials, for each element
+		Parameters  *parameters;           //one set of parameters, independent of the analysis_type
+		Results     *results;              //results that cannot be fit into the elements 
+		COMM        comm;                  //communicator for this particular model
+
 		/*constructors, destructors: */
-		FemModel(char* rootpath, char* inputfilename, char* outputfilename, const int solution_type,const int* analyses,const int nummodels);
+		FemModel(int argc,char** argv,COMM comm_init);
+		FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
 		~FemModel();
 
-		/*Methods: */
+		/*Methods:*/
+		void AllocateSystemMatrices(Matrix<IssmDouble>** pKff,Matrix<IssmDouble>** pKfs,Vector<IssmDouble>** pdf,Vector<IssmDouble>** ppf);
+		void CreateJacobianMatrixx(Matrix<IssmDouble>** pJff,IssmDouble kmax);
 		void Echo();
+		void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
+		void MatrixNonzeros(int** pd_nnz,int** po_nnz,int set1enum,int set2enum);
+		void Solve(void);
+		void OutputResults(void);
+		void SetStaticComm();
+		void SetCurrentConfiguration(int configuration_type);
+		void SetCurrentConfiguration(int configuration_type,int analysis_type);
 
-		/*Fem: */
-		void  SetCurrentConfiguration(int configuration_type);
-		void  SetCurrentConfiguration(int configuration_type,int analysis_type);
-
+		/*Modules*/ 
+		#ifdef _HAVE_RESPONSES_
+		void MassFluxx(IssmDouble* presponse,bool process_units);
+		void MaxAbsVxx(IssmDouble* presponse,bool process_units);
+		void MaxAbsVyx(IssmDouble* presponse,bool process_units);
+		void MaxAbsVzx(IssmDouble* presponse,bool process_units);
+		void MaxVelx(IssmDouble* presponse,bool process_units);
+		void MaxVxx(IssmDouble* presponse,bool process_units);
+		void MaxVyx(IssmDouble* presponse,bool process_units);
+		void MaxVzx(IssmDouble* presponse,bool process_units);
+		void MinVelx(IssmDouble* presponse,bool process_units);
+		void MinVxx(IssmDouble* presponse,bool process_units);
+		void MinVyx(IssmDouble* presponse,bool process_units);
+		void MinVzx(IssmDouble* presponse,bool process_units);
+		void TotalSmbx(IssmDouble* pSmb,bool process_units);
+		void IceVolumex(IssmDouble* pV,bool process_units);
+		void ElementResponsex(IssmDouble* presponse,int response_enum,bool process_units);
+		#endif
+		#ifdef  _HAVE_DAKOTA_
+		void DakotaResponsesx(double* d_responses,char** responses_descriptors,int numresponsedescriptors,int d_numresponses);
+		#endif
+		void RequestedOutputsx(int* requested_outputs, int numoutputs);
+		void RequestedDependentsx(void);
+		void Responsex(IssmDouble* presponse,int response_descriptor_enum,bool process_units,int weight_index);
+		void Responsex(IssmDouble* presponse,const char* response_descriptor,bool process_units,int weight_index);
+		#ifdef _HAVE_CONTROL_
+		void CostFunctionx( IssmDouble* pJ);
+		void ThicknessAbsGradientx( IssmDouble* pJ, bool process_units,int weight_index);
+		#endif
+		void SystemMatricesx(Matrix<IssmDouble>** pKff, Matrix<IssmDouble>** pKfs, Vector<IssmDouble>** ppf, Vector<IssmDouble>** pdf, IssmDouble* pkmax);
+		void TimeAdaptx(IssmDouble* pdt);
+		void UpdateConstraintsx(void);
+		int  UpdateVertexPositionsx(void);
 };
 
 #endif

Modified: issm/trunk/src/c/classes/Hook.cpp
===================================================================
--- issm/trunk/src/c/classes/Hook.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/Hook.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief: implementation of the Hook object: see Hook.h for more explanations.
  */
 
-
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -17,32 +16,27 @@
 #include "../shared/shared.h"
 #include "../include/include.h"
 
-
 /*Constructor/Destructors*/
 /*FUNCTION Hook::Hook(){{{*/
 Hook::Hook(){
-	this->num=0;
-	this->objects=NULL;
-	this->ids=NULL;
-	this->offsets=NULL;
-	return;
+	this->num     = 0;
+	this->objects = NULL;
+	this->ids     = NULL;
+	this->offsets = NULL;
 }
 /*}}}*/
 /*FUNCTION Hook::Hook(int* ids, int num){{{*/
 Hook::Hook(int* in_ids, int in_num){
 
-	/*Intermediaries*/
-	int i;
-
 	/*Get number of objects to hook*/
 	this->num=in_num;
 
 	/*Get out if num=0*/
 	if (num==0){
 		/*Empty hook*/
-		this->ids=NULL;
-		this->objects=NULL;
-		this->offsets=NULL;
+		this->ids     = NULL;
+		this->objects = NULL;
+		this->offsets = NULL;
 	}
 	else{
 		/*Allocate: */
@@ -51,21 +45,19 @@
 		this->offsets=xNew<int>(this->num);
 
 		/*Copy ids: */
-		for (i=0;i<this->num;i++){
-			this->ids[i]=in_ids[i];
-			this->objects[i]=NULL;
-			this->offsets[i]=0;
+		for(int i=0;i<this->num;i++){
+			this->ids[i]     = in_ids[i];
+			this->objects[i] = NULL;
+			this->offsets[i] = 0;
 		}
 	}
 }
 /*}}}*/
 /*FUNCTION Hook::~Hook(){{{*/
 Hook::~Hook(){
-	/*deallocate: */
 	xDelete<Object*>(this->objects);
 	xDelete<int>(this->ids);
 	xDelete<int>(this->offsets);
-	return;
 }
 /*}}}*/
 
@@ -120,8 +112,6 @@
 /*FUNCTION Hook::copy {{{*/
 Object* Hook::copy(void){
 
-	int i;
-
 	/*output: */
 	Hook* output=NULL;
 
@@ -131,15 +121,15 @@
 	/*copy in the fields: */
 	output->num=this->num;
 	if(output->num){
-		output->objects=xNew<Object*>(output->num);
-		output->ids=xNew<int>(output->num);
-		output->offsets=xNew<int>(output->num);
+		output->objects = xNew<Object*>(output->num);
+		output->ids     = xNew<int>(output->num);
+		output->offsets = xNew<int>(output->num);
 	}
-	
-	for(i=0;i<output->num;i++){
-		output->objects[i]=this->objects[i];
-		output->offsets[i]=this->offsets[i];
-		output->ids[i]=this->ids[i];
+
+	for(int i=0;i<output->num;i++){
+		output->objects[i] = this->objects[i];
+		output->offsets[i] = this->offsets[i];
+		output->ids[i]     = this->ids[i];
 	}
 
 	return (Object*)output;
@@ -182,7 +172,7 @@
 
 		/*Now, for this->objects that did not get resolved, and for which we have no offset, chase them in the dataset, by id: */
 		if(this->objects[i]==NULL){
-			this->objects[i]=(Object*)dataset->GetObjectById(this->offsets+i,this->ids[i]); //remember the offset for later on.
+			this->objects[i]=dynamic_cast<Object*>(dataset->GetObjectById(this->offsets+i,this->ids[i])); //remember the offset for later on.
 			/*check the id is correct!: */
 			if (this->objects[i]->Id()!=this->ids[i]) _error_("wrong id: " << this->objects[i]->Id() << " vs " << this->ids[i] << "  in resolved pointer!");
 		}
@@ -191,7 +181,7 @@
 /*}}}*/
 /*FUNCTION Hook::delivers{{{*/
 Object* Hook::delivers(void){
-	
+
 	/*first, check that we only have one T object in our object list: */
 	if (this->num!=1) _error_("trying to delivery a single hook object when hook holds " << this->num << " objects" << "\n");
 
@@ -230,8 +220,6 @@
 /*FUNCTION Hook::Spawn{{{*/
 Hook* Hook::Spawn(int* indices, int numindices){
 
-	int i;
-
 	/*output: */
 	Hook* output=NULL;
 
@@ -245,20 +233,20 @@
 	}
 
 	/*Else, check that we are requesting a half of num*/
-	if (numindices>this->num) _error_("Cannot spawn hook with " << numindices << " objects from a Hook of " << this->num << " objects");
+	if(numindices>this->num) _error_("Cannot spawn hook with " << numindices << " objects from a Hook of " << this->num << " objects");
 
 	/*go pickup the correct objects, ids and offsets :*/
 	output->num=numindices;
 	if(output->num<1) _error_("Trying to spawn an empty ElementProperties!");
 
-	output->objects=xNew<Object*>(output->num);
-	output->ids=xNew<int>(output->num);
-	output->offsets=xNew<int>(output->num);
+	output->objects = xNew<Object*>(output->num);
+	output->ids     = xNew<int>(output->num);
+	output->offsets = xNew<int>(output->num);
 
-	for(i=0;i<output->num;i++){
-		output->objects[i]=this->objects[indices[i]];
-		output->ids[i]=this->ids[indices[i]];
-		output->offsets[i]=this->offsets[indices[i]];
+	for(int i=0;i<output->num;i++){
+		output->objects[i] = this->objects[indices[i]];
+		output->ids[i]     = this->ids[indices[i]];
+		output->offsets[i] = this->offsets[indices[i]];
 	}
 
 	return output;

Modified: issm/trunk/src/c/classes/Hook.h
===================================================================
--- issm/trunk/src/c/classes/Hook.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/Hook.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,10 +18,10 @@
 
 	private: 
 
-		int	   num; //number of objects being hooked onto
-		Object**	   objects; //list of object pointers. we do not allocate objects, just a list a pointers, that will get to point to the real objects from a dataset.
-		int*   ids;     //list of object ids, to go look for them in datasets.
-		int*   offsets;  //list of object offsets into datasets, to speed up lookup.
+		int      num;       //number of objects being hooked onto
+		Object **objects;   //list of object pointers
+		int     *ids;       //list of object ids, to go look for them in datasets.
+		int     *offsets;   //list of object offsets into datasets, to speed up lookup.
 
 	public:
 

Modified: issm/trunk/src/c/classes/IoModel.cpp
===================================================================
--- issm/trunk/src/c/classes/IoModel.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/IoModel.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,9 +16,8 @@
 
 #include "./classes.h"
 #include "../io/io.h"
-#include "./Container/Parameters.h"
+#include "../Container/Parameters.h"
 #include "../shared/shared.h"
-#include "../io/io.h"
 #include "../include/include.h"
 
 /*FUNCTION IoModel::IoModel(){{{*/
@@ -27,13 +26,13 @@
 	this->data=NULL;
 	this->independents=NULL;
 	this->constants=NULL;
-	
+
 	this->my_elements=NULL;
 	this->my_nodes=NULL;
 	this->my_vertices=NULL;
 	this->singlenodetoelementconnectivity=NULL;
 	this->numbernodetoelementconnectivity=NULL;
-	
+
 	this->nodecounter=0;
 	this->loadcounter=0;
 	this->constraintcounter=0;
@@ -41,32 +40,33 @@
 /*}}}*/
 /*FUNCTION IoModel::IoModel(FILE*  iomodel_handle){{{*/
 IoModel::IoModel(FILE* iomodel_handle){
-	
+
 	/*First, keep track of the file handle: */
 	this->fid=iomodel_handle;
 
 	/*Check that Enums are Synchronized*/
 	this->CheckEnumSync();
 
-	/*Initialize and read constants:*/
-	this->constants=new Parameters();
-	this->FetchConstants(); /*this routine goes through the input file, and fetches bools, ints, IssmDoubles and strings only, nothing memory intensive*/
-
 	/*Initialize data: */
 	this->data=xNew<IssmDouble*>(MaximumNumberOfEnums);
 	for(int i=0;i<MaximumNumberOfEnums;i++) this->data[i]=NULL;
 
-	/*Initialize array detecting whether data[i] is an independent AD mode variable: */
-	this->independents=xNew<bool>(MaximumNumberOfEnums);
-	for(int i=0;i<MaximumNumberOfEnums;i++) this->independents[i]=false;
-	
+	/*If we are running in AD mode, we need to start the trace and declare our independent variables now, 
+	 *and prevent them from being erased during successive calls to iomodel->FetchConstants, iomodel->FetchData and 
+	 iomodel->DeleteData:*/
+	this->DeclareIndependents();
+
+	/*Initialize and read constants:*/
+	this->constants=new Parameters();
+	this->FetchConstants(); /*this routine goes through the input file, and fetches bools, ints, IssmDoubles and strings only, nothing memory intensive*/
+
 	/*Initialize permanent data: */
 	this->my_elements=NULL;
 	this->my_nodes=NULL;
 	this->my_vertices=NULL;
 	this->singlenodetoelementconnectivity=NULL;
 	this->numbernodetoelementconnectivity=NULL;
-	
+
 	this->nodecounter=0;
 	this->loadcounter=0;
 	this->constraintcounter=0;
@@ -90,6 +90,7 @@
 
 	xDelete<IssmDouble*>(this->data);
 	xDelete<bool>(this->independents);
+	if(this->independent_objects)delete this->independent_objects;
 	xDelete<bool>(this->my_elements);
 	xDelete<bool>(this->my_nodes);
 	xDelete<int>(this->my_vertices);
@@ -101,9 +102,12 @@
 /*FUNCTION IoModel::CheckEnumSync{{{*/
 void  IoModel::CheckEnumSync(void){
 
-	extern int my_rank;
+	int my_rank;
 	int record_enum = 0;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Check that some fields have been allocated*/
 	_assert_(this->fid || my_rank);
 
@@ -181,10 +185,10 @@
 	_assert_(this->constants);
 
 	/*Find constant*/
-	Param* param=(Param*)this->constants->FindParamObject(constant_enum);
+	Param* param=dynamic_cast<Param*>(this->constants->FindParamObject(constant_enum));
 	if(!param) _error_("Constant " << EnumToStringx(constant_enum) << " not found in iomodel");
 
-	return (Param*)param->copy();
+	return dynamic_cast<Param*>(param->copy());
 }
 /*}}}*/
 /*FUNCTION IoModel::Data{{{*/
@@ -196,6 +200,70 @@
 	return this->data[data_enum];
 }
 /*}}}*/
+/*FUNCTION IoModel::DeclareIndependents{{{*/
+void IoModel::DeclareIndependents(void){
+
+	int         i;
+	bool        autodiff                = false;
+	int         num_independent_objects;
+
+	int *names = NULL;
+	int *types = NULL;
+
+	int         numberofvertices;
+	int         dummy;
+	bool        keep=false;
+
+	/*Initialize array detecting whether data[i] is an independent AD mode variable: */
+	this->independents=xNew<bool>(MaximumNumberOfEnums);
+	for(i=0;i<MaximumNumberOfEnums;i++) this->independents[i]=false;
+
+	this->FetchData(&autodiff,AutodiffIsautodiffEnum);
+	if(autodiff){
+
+		this->FetchData(&numberofvertices,MeshNumberofverticesEnum);
+
+		#ifdef _HAVE_ADOLC_
+
+		/*Start trace: {{{*/
+		this->FetchData(&keep,AutodiffKeepEnum);
+		if(keep)trace_on(1,1);
+		else    trace_on(1);
+
+		/*}}}*/
+		/*build dataset made of independent objects: {{{*/
+		this->independent_objects=new DataSet();
+		this->FetchData(&num_independent_objects,AutodiffNumIndependentObjectsEnum);
+		if(num_independent_objects){
+			this->FetchData(&names,&dummy,&dummy,AutodiffIndependentObjectNamesEnum);
+			this->FetchData(&types,&dummy,&dummy,AutodiffIndependentObjectTypesEnum);
+
+			/*create independent objects, and at the same time, fetch the corresponding independent variables, 
+			 *and declare them as such in ADOLC: */
+			for(i=0;i<num_independent_objects;i++){
+
+				IndependentObject* independent_object=NULL;
+				independent_object=new IndependentObject(names[i],types[i],numberofvertices);
+
+				/*add to independent_objects dataset:*/
+				this->independent_objects->AddObject(independent_object);
+
+				/*now go fetch the independent variable: */
+				independent_object->FetchIndependent(this); //supply the pointer to iomodel.
+			}
+			xDelete<int>(names);
+			xDelete<int>(types);
+		} /*}}}*/
+
+		#else
+		/*if we asked for AD computations, we have a problem!: */
+		_error_("Cannot carry out AD mode computations without support of ADOLC compiled in!");
+		#endif
+	}
+	else this->independent_objects=NULL;
+
+}
+/*}}}*/
 /*FUNCTION IoModel::DeleteData(int num,...){{{*/
 void  IoModel::DeleteData(int num,...){
 
@@ -210,7 +278,7 @@
 	for(i = 0; i <num; i++){
 		dataenum=va_arg(ap, int);
 		_assert_(dataenum<MaximumNumberOfEnums);
-		
+
 		/*do not erase independent variables for the AD mode computations!: */
 		if (!this->independents[dataenum]) xDelete<IssmDouble>(this->data[dataenum]);
 	}
@@ -226,9 +294,8 @@
 /*FUNCTION IoModel::FetchConstants{{{*/
 void  IoModel::FetchConstants(void){
 
-	extern int my_rank;
-	extern int num_procs;
-	
+	int my_rank;
+
 	/*record descriptions; */
 	int record_enum;
 	int record_length;
@@ -237,17 +304,21 @@
 	/*records: */
 	int  booleanint=0;
 	int  integer=0;
-	IssmPDouble scalar=0;
+	IssmPDouble pscalar=0;
+	IssmDouble scalar=0;
 	char* string=NULL;
 	int   string_size;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Check that some fields have been allocated*/
 	_assert_(this->fid || my_rank);
 	_assert_(this->constants);
 
 	/*Go find in the binary file, the position of the data we want to fetch: */
 	if(my_rank==0){ //cpu 0{{{
-	
+
 		/*First set FILE* position to the beginning of the file: */
 		fseek(this->fid,0,SEEK_SET);
 
@@ -258,31 +329,31 @@
 				/*Ok, we have reached the end of the file. break: */
 				record_code=0; //0 means bailout
 				#ifdef _HAVE_MPI_
-				MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD);  /*tell others cpus we are bailing: */
+				MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm());  /*tell others cpus we are bailing: */
 				#endif
 				break;
 			}
 			else{
-			
+
 				/* Read the record length and the data type code: */
 				fread(&record_length,sizeof(int),1,this->fid);
 				fread(&record_code,sizeof(int),1,this->fid);
-					
+
 				#ifdef _HAVE_MPI_
 				/*Tell other cpus what we are doing: */
-				MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD);  /*tell other cpus what we are going to do: */
+				MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm());  /*tell other cpus what we are going to do: */
 
 				/*Tell other cpus the name of the data, then branch according to the data type: */
-				MPI_Bcast(&record_enum,1,MPI_INT,0,MPI_COMM_WORLD);  
-				MPI_Bcast(&record_length,1,MPI_INT,0,MPI_COMM_WORLD);  
+				MPI_Bcast(&record_enum,1,MPI_INT,0,IssmComm::GetComm());  
+				MPI_Bcast(&record_length,1,MPI_INT,0,IssmComm::GetComm());  
 				#endif
-				
+
 				switch(record_code){
 					case 1: 
 						/*Read the boolean and broadcast it to other cpus:*/
 						if(fread(&booleanint,sizeof(int),1,this->fid)!=1) _error_("could not read boolean ");
 						#ifdef _HAVE_MPI_
-						MPI_Bcast(&booleanint,1,MPI_INT,0,MPI_COMM_WORLD); 
+						MPI_Bcast(&booleanint,1,MPI_INT,0,IssmComm::GetComm()); 
 						#endif
 
 						/*create BoolParam: */
@@ -293,7 +364,7 @@
 						/*Read the integer and broadcast it to other cpus:*/
 						if(fread(&integer,sizeof(int),1,this->fid)!=1) _error_("could not read integer ");
 						#ifdef _HAVE_MPI_
-						MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 
+						MPI_Bcast(&integer,1,MPI_INT,0,IssmComm::GetComm()); 
 						#endif
 
 						/*create IntParam: */
@@ -301,11 +372,19 @@
 
 						break;
 					case 3:
-						/*Read the scalar and broadcast it to other cpus:*/
-						if(fread(&scalar,sizeof(IssmPDouble),1,this->fid)!=1) _error_("could not read scalar ");
-						#ifdef _HAVE_MPI_
-						MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
-						#endif
+						/*Read the scalar and broadcast it to other cpus. However, if this record has already 
+						 * been read in DeclareIndependents, we should not re-read it, but grab it from the iomodel->data 
+						 * slots: */
+						if(this->independents[record_enum]){
+							scalar=*(this->data[record_enum]);
+						}
+						else{
+							if(fread(&pscalar,sizeof(IssmPDouble),1,this->fid)!=1) _error_("could not read scalar ");
+							#ifdef _HAVE_MPI_
+							MPI_Bcast(&pscalar,1,MPI_DOUBLE,0,IssmComm::GetComm()); 
+							#endif
+							scalar=reCast<IssmDouble>(pscalar);
+						}
 
 						/*create DoubleParam: */
 						this->constants->AddObject(new DoubleParam(record_enum,scalar));
@@ -315,7 +394,7 @@
 						/*We have to read a string from disk. First read the dimensions of the string, then the string: */
 						if(fread(&string_size,sizeof(int),1,this->fid)!=1) _error_("could not read length of string ");
 						#ifdef _HAVE_MPI_
-						MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
+						MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 
 						#endif
 
 						if(string_size){
@@ -325,14 +404,14 @@
 							/*Read string, then broadcast: */
 							if(fread(string,string_size*sizeof(char),1,this->fid)!=1)_error_(" could not read string ");
 							#ifdef _HAVE_MPI_
-							MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
+							MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 
 							#endif
 						}
 						else{
 							string=xNew<char>(1);
 							string[0]='\0';
 						}
-						
+
 						/*Add string to parameters: */
 						this->constants->AddObject(new StringParam(record_enum,string));
 
@@ -383,46 +462,46 @@
 	#ifdef _HAVE_MPI_
 	else{ //cpu ~0 {{{
 		for(;;){ //wait on cpu 0
-			MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD);  /*get from cpu 0 what we are going to do: */
+			MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm());  /*get from cpu 0 what we are going to do: */
 			if(record_code==0){
 				break; //we are done, break from the loop
 			}
 			else{
-				MPI_Bcast(&record_enum,1,MPI_INT,0,MPI_COMM_WORLD);   //get from cpu 0 name of the data
-				MPI_Bcast(&record_length,1,MPI_INT,0,MPI_COMM_WORLD);  
+				MPI_Bcast(&record_enum,1,MPI_INT,0,IssmComm::GetComm());   //get from cpu 0 name of the data
+				MPI_Bcast(&record_length,1,MPI_INT,0,IssmComm::GetComm());  
 				switch(record_code){
 				case 1: 
 					/*boolean. get it from cpu 0 */
-					MPI_Bcast(&booleanint,1,MPI_INT,0,MPI_COMM_WORLD); 
-						
+					MPI_Bcast(&booleanint,1,MPI_INT,0,IssmComm::GetComm()); 
+
 					/*create BoolParam: */
 					this->constants->AddObject(new BoolParam(record_enum,(bool)booleanint)); //cast to a boolean
 					break;
 
 				case 2:
 					/*integer. get it from cpu 0 */
-					MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 
-						
+					MPI_Bcast(&integer,1,MPI_INT,0,IssmComm::GetComm()); 
+
 					/*create IntParam: */
 					this->constants->AddObject(new IntParam(record_enum,integer));
 
 					break;
 				case 3:
 					/*scalar. get it from cpu 0 */
-					MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
-						
+					MPI_Bcast(&scalar,1,MPI_DOUBLE,0,IssmComm::GetComm()); 
+
 					/*create DoubleParam: */
 					this->constants->AddObject(new DoubleParam(record_enum,scalar));
 
 					break;
 				case 4: 
-					MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
+					MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 
 					if(string_size){
 						string=xNew<char>((string_size+1));
 						string[string_size]='\0';
 
 						/*Read string from cpu 0: */
-						MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
+						MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 
 					}
 					else{
 						string=xNew<char>(1);
@@ -446,7 +525,6 @@
 					break;;
 				}
 
-
 			}
 		}
 	} //}}}
@@ -456,25 +534,26 @@
 /*FUNCTION IoModel::FetchData(bool*     pbool,int data_enum){{{*/
 void  IoModel::FetchData(bool* pboolean,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
-	
+	int my_rank;
 
 	/*output: */
 	int   booleanint;
 	int   code;
-	
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 
 	if(code!=1)_error_("expecting a boolean for enum " << EnumToStringx(data_enum));
-	
+
 	/*We have to read a boolean from disk. */
 	if(my_rank==0){  
 		if(fread(&booleanint,sizeof(int),1,fid)!=1) _error_("could not read boolean ");
 	}
 	#ifdef _HAVE_MPI_
-	MPI_Bcast(&booleanint,1,MPI_INT,0,MPI_COMM_WORLD); 
+	MPI_Bcast(&booleanint,1,MPI_INT,0,IssmComm::GetComm()); 
 	#endif
 
 	/*cast to bool: */
@@ -486,25 +565,27 @@
 /*FUNCTION IoModel::FetchData(int*      pinteger,int data_enum){{{*/
 void  IoModel::FetchData(int* pinteger,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank;
 
 	/*output: */
 	int   integer;
 	int   code;
-	
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
-	
+
 	if(code!=2)_error_("expecting an integer for enum " << EnumToStringx(data_enum));
-	
+
 	/*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */
 	if(my_rank==0){  
 		if(fread(&integer,sizeof(int),1,fid)!=1) _error_("could not read integer ");
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Bcast(&integer,1,MPI_INT,0,MPI_COMM_WORLD); 
+	MPI_Bcast(&integer,1,MPI_INT,0,IssmComm::GetComm()); 
 	#endif
 
 	/*Assign output pointers: */
@@ -514,59 +595,60 @@
 /*FUNCTION IoModel::FetchData(IssmDouble*   pscalar,int data_enum){{{*/
 void  IoModel::FetchData(IssmDouble* pscalar,int data_enum){
 
+	int my_rank;
 
-	extern int my_rank;
-	extern int num_procs;
-	
-
 	/*output: */
 	IssmPDouble   scalar;
 	int      code;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
-	
+
 	if(code!=3)_error_("expecting a IssmDouble for enum " << EnumToStringx(data_enum));
-	
+
 	/*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */
 	if(my_rank==0){
 		if(fread(&scalar,sizeof(IssmPDouble),1,fid)!=1)_error_("could not read scalar ");
 	}
 	#ifdef _HAVE_MPI_
-	MPI_Bcast(&scalar,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+	MPI_Bcast(&scalar,1,MPI_DOUBLE,0,IssmComm::GetComm()); 
 	#endif
 
 	/*Assign output pointers: */
 	*pscalar=scalar;
-		 
+
 }
 /*}}}*/
 /*FUNCTION IoModel::FetchData(char**    pstring,int data_enum){{{*/
 void  IoModel::FetchData(char** pstring,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
-	
+	int my_rank;
 
 	/*output: */
 	char* string=NULL;
 	int   string_size;
 	int code=0;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
-	
+
 	if(code!=4)_error_("expecting a string for enum " << EnumToStringx(data_enum));
-	
+
 	/*Now fetch: */
-	
+
 	/*We have to read a string from disk. First read the dimensions of the string, then the string: */
 	if(my_rank==0){  
 		if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string ");
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
+	MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 
 	#endif
 
 	/*Now allocate string: */
@@ -579,7 +661,7 @@
 			if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string ");
 		}
 		#ifdef _HAVE_MPI_
-		MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
+		MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 
 		#endif
 	}
 	else{
@@ -587,7 +669,6 @@
 		string[0]='\0';
 	}
 
-
 	/*Assign output pointers: */
 	*pstring=string;
 }
@@ -595,8 +676,7 @@
 /*FUNCTION IoModel::FetchData(int**     pintegerematrix,int* pM,int* pN,int data_enum){{{*/
 void  IoModel::FetchData(int** pmatrix,int* pM,int* pN,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank;
 	int i,j;
 
 	/*output: */
@@ -606,12 +686,14 @@
 	int code=0;
 	int vector_type=0;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
 
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,&vector_type,data_enum);
 
 	if((code!=5) && (code!=6) && (code!=7))_error_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(data_enum));
-	
+
 	/*Now fetch: */
 
 	/*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
@@ -621,14 +703,14 @@
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
+	MPI_Bcast(&M,1,MPI_INT,0,IssmComm::GetComm()); 
 	#endif
 
 	if(my_rank==0){  
 		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
 	}
 	#ifdef _HAVE_MPI_
-	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Bcast(&N,1,MPI_INT,0,IssmComm::GetComm());
 	#endif
 
 	/*Now allocate matrix: */
@@ -639,9 +721,9 @@
 		if(my_rank==0){  
 			if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix ");
 		}
-		
+
 		#ifdef _HAVE_MPI_
-		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,IssmComm::GetComm()); 
 		#endif
 	}
 
@@ -670,8 +752,7 @@
 /*FUNCTION IoModel::FetchData(IssmDouble**  pIssmDoublematrix,int* pM,int* pN,int data_enum){{{*/
 void  IoModel::FetchData(IssmDouble** pmatrix,int* pM,int* pN,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank;
 
 	/*output: */
 	int M,N;
@@ -679,10 +760,13 @@
 	int code=0;
 	int vector_type=0;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,&vector_type,data_enum);
 	if((code!=5) && (code!=6) && (code!=7))_error_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(data_enum));
-	
+
 	/*Now fetch: */
 
 	/*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
@@ -691,14 +775,14 @@
 		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
 	}
 	#ifdef _HAVE_MPI_
-	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
+	MPI_Bcast(&M,1,MPI_INT,0,IssmComm::GetComm()); 
 	#endif
 
 	if(my_rank==0){  
 		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
 	}
 	#ifdef _HAVE_MPI_
-	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
+	MPI_Bcast(&N,1,MPI_INT,0,IssmComm::GetComm()); 
 	#endif
 
 	/*Now allocate matrix: */
@@ -710,7 +794,7 @@
 			if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix ");
 		}
 		#ifdef _HAVE_MPI_
-		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,IssmComm::GetComm()); 
 		#endif
 
 		_assert_(this->independents);
@@ -735,31 +819,33 @@
 /*FUNCTION IoModel::FetchData(char***   pstrings,int* pnumstrings,int data_enum){{{*/
 void  IoModel::FetchData(char*** pstrings,int* pnumstrings,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
-	
+	int my_rank;
+
 	int i;
 
 	/*output: */
 	int   numstrings=0;
 	char** strings=NULL;
-	
+
 	/*intermediary: */
 	char* string=NULL;
 	int   string_size;
 	int   code;
-	
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
-	
+
 	if(code!=9)_error_("expecting a string array for enum " << EnumToStringx(data_enum));
-	
+
 	/*We have to read a bunch of strings from disk. First read the number of strings, and allocate: */
 	if(my_rank==0){  
 		if(fread(&numstrings,sizeof(int),1,fid)!=1) _error_("could not read length of string array");
 	}
 	#ifdef _HAVE_MPI_
-	MPI_Bcast(&numstrings,1,MPI_INT,0,MPI_COMM_WORLD); 
+	MPI_Bcast(&numstrings,1,MPI_INT,0,IssmComm::GetComm()); 
 	#endif
 
 	/*Now allocate string array: */
@@ -769,12 +855,12 @@
 
 		/*Go through strings, and read: */
 		for(i=0;i<numstrings;i++){
-			
+
 			if(my_rank==0){  
 				if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string ");
 			}
 			#ifdef _HAVE_MPI_
-			MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
+			MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 
 			#endif
 			if(string_size){
 				string=xNew<char>((string_size+1));
@@ -785,7 +871,7 @@
 					if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string ");
 				}
 				#ifdef _HAVE_MPI_
-				MPI_Bcast(string,string_size,MPI_CHAR,0,MPI_COMM_WORLD); 
+				MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 
 				#endif
 			}
 			else{
@@ -807,8 +893,7 @@
 
 	int i;
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank;
 
 	/*output: */
 	IssmDouble** matrices=NULL;
@@ -820,17 +905,20 @@
 	int     M, N;
 	IssmPDouble *matrix = NULL;
 	int     code;
-	
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 	if(code!=8)_error_("expecting a IssmDouble mat array for enum " << EnumToStringx(data_enum));
-	
+
 	/*Now fetch: */
 	if(my_rank==0){  
 		if(fread(&numrecords,sizeof(int),1,fid)!=1) _error_("could not read number of records in matrix array ");
 	}
 	#ifdef _HAVE_MPI_
-	MPI_Bcast(&numrecords,1,MPI_INT,0,MPI_COMM_WORLD); 
+	MPI_Bcast(&numrecords,1,MPI_INT,0,IssmComm::GetComm()); 
 	#endif
 
 	if(numrecords){
@@ -853,14 +941,14 @@
 				if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows in " << i << "th matrix of matrix array");
 			}
 			#ifdef _HAVE_MPI_
-			MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
+			MPI_Bcast(&M,1,MPI_INT,0,IssmComm::GetComm()); 
 			#endif
 
 			if(my_rank==0){  
 				if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns in " << i << "th matrix of matrix array");
 			}
 			#ifdef _HAVE_MPI_
-			MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
+			MPI_Bcast(&N,1,MPI_INT,0,IssmComm::GetComm()); 
 			#endif
 
 			/*Now allocate matrix: */
@@ -873,7 +961,7 @@
 				}
 
 				#ifdef _HAVE_MPI_
-				MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+				MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,IssmComm::GetComm()); 
 				#endif
 				matrices[i]=xNew<IssmDouble>(M*N);
 				for (int j=0;j<M*N;++j) {matrices[i][j]=matrix[j];}
@@ -897,9 +985,6 @@
 /*FUNCTION IoModel::FetchData(Option**  poption,int data_enum){{{*/
 void  IoModel::FetchData(Option** poption,int index){
 
-	extern int my_rank;
-	extern int num_procs;
-
 	/*output: */
 	int     code;
 	char   *name        = NULL;
@@ -954,12 +1039,12 @@
 
 	/*Go through the entire list of enums and fetch the corresponding data. Add it to the iomodel->data dataset. Everything
 	 *we fetch is a IssmDouble* : */
-	
+
 	va_start(ap,num);
 	for(i=0; i<num; i++){
-		
+
 		dataenum=va_arg(ap, int);
-		
+
 		if (this->independents[dataenum]){
 			/*this data has already been checked out! Continue: */
 			continue;
@@ -995,11 +1080,8 @@
 	int     code          = 0;
 	int     vector_layout = 0;
 	int     counter;
-	int     nods;
-	int     nel;
 	int     numberofelements;
 
-
 	/*variables being fetched: */
 	bool    boolean;
 	int     integer;
@@ -1022,7 +1104,7 @@
 			counter=0;
 			for (i=0;i<numberofelements;i++){
 				if(this->my_elements[i]){
-					Element* element=(Element*)elements->GetObjectByOffset(counter);
+					Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter));
 					element->InputCreate((IssmDouble)boolean,vector_enum,code);
 					counter++;
 				}
@@ -1035,7 +1117,7 @@
 			counter=0;
 			for (i=0;i<numberofelements;i++){
 				if(this->my_elements[i]){
-					Element* element=(Element*)elements->GetObjectByOffset(counter);
+					Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter));
 					element->InputCreate((IssmDouble)integer,vector_enum,code);
 					counter++;
 				}
@@ -1048,7 +1130,7 @@
 			counter=0;
 			for (i=0;i<numberofelements;i++){
 				if(this->my_elements[i]){
-					Element* element=(Element*)elements->GetObjectByOffset(counter);
+					Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter));
 					element->InputCreate(scalar,vector_enum,code); 
 					counter++;
 				}
@@ -1085,7 +1167,7 @@
 			counter=0;
 			for (i=0;i<numberofelements;i++){
 				if(this->my_elements[i]){
-					Element* element=(Element*)elements->GetObjectByOffset(counter);
+					Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter));
 					if(defaulting) element->InputCreate(default_value,vector_enum,code); 
 					else           element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
 					counter++;
@@ -1123,7 +1205,7 @@
 			counter=0;
 			for (i=0;i<numberofelements;i++){
 				if(this->my_elements[i]){
-					Element* element=(Element*)elements->GetObjectByOffset(counter);
+					Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter));
 					if(defaulting) element->InputCreate(default_value,vector_enum,code); 
 					else           element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
 					counter++;
@@ -1161,7 +1243,7 @@
 			counter=0;
 			for (i=0;i<numberofelements;i++){
 				if(this->my_elements[i]){
-					Element* element=(Element*)elements->GetObjectByOffset(counter);
+					Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(counter));
 					if(defaulting) element->InputCreate(default_value,vector_enum,code); 
 					else           element->InputCreate(IssmDoublevector,i,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
 					counter++;
@@ -1182,10 +1264,13 @@
 /*FUNCTION IoModel::LastIndex{{{*/
 void IoModel::LastIndex(int *pindex){
 
-	extern int my_rank;
+	int my_rank;
 	int        lastindex,index;
 	int        record_length;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Go find in the binary file, the position of the data we want to fetch: */
 	if(my_rank==0){
 
@@ -1208,7 +1293,7 @@
 	}
 	/*Broadcast code and vector type: */
 #ifdef _HAVE_MPI_
-	MPI_Bcast(&lastindex,1,MPI_INT,0,MPI_COMM_WORLD); 
+	MPI_Bcast(&lastindex,1,MPI_INT,0,IssmComm::GetComm()); 
 #endif
 
 	/*Assign output pointers:*/
@@ -1218,15 +1303,17 @@
 /*FUNCTION IoModel::SetFilePointerToData{{{*/
 FILE* IoModel::SetFilePointerToData(int* pcode,int* pvector_type, int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank;
 
-	int found=0;
+	int found         = 0;
 	int record_enum;
 	int record_length;
-	int record_code; //1 to 7 number
-	int vector_type; //nodal or elementary
+	int record_code;       //1 to 7 number
+	int vector_type   = 0; //nodal or elementary
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*Go find in the binary file, the position of the data we want to fetch: */
 	if(my_rank==0){
 
@@ -1261,17 +1348,17 @@
 			}
 		}
 	}
-#ifdef _HAVE_MPI_
-	MPI_Bcast(&found,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(!found)_error_("could not find data with name" << " " << EnumToStringx(data_enum) << " ");
-#endif
+	#ifdef _HAVE_MPI_
+	MPI_Bcast(&found,1,MPI_INT,0,IssmComm::GetComm()); 
+	if(!found)_error_("could not find data with name " << EnumToStringx(data_enum) << " in binary file");
+	#endif
 
 	/*Broadcast code and vector type: */
-#ifdef _HAVE_MPI_
-	MPI_Bcast(&record_code,1,MPI_INT,0,MPI_COMM_WORLD); 
-	MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 
-	if(record_code==5) MPI_Bcast(&vector_type,1,MPI_INT,0,MPI_COMM_WORLD); 
-#endif
+	#ifdef _HAVE_MPI_
+	MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm()); 
+	MPI_Bcast(&vector_type,1,MPI_INT,0,IssmComm::GetComm()); 
+	if(record_code==5) MPI_Bcast(&vector_type,1,MPI_INT,0,IssmComm::GetComm()); 
+	#endif
 
 	/*Assign output pointers:*/
 	*pcode=record_code;
@@ -1280,96 +1367,3 @@
 	return fid;
 }
 /*}}}*/
-/*FUNCTION IoModel::DeclareIndependents{{{*/
-void IoModel::DeclareIndependents(void){
-
-	bool autodiff=false;
-	int  dummy;
-	int i;
-	int  num_independents;
-	int* independents=NULL;
-
-	#ifdef _HAVE_ADOLC_
-	/*recover independent enums: */
-	this->Constant(&num_independents,AutodiffNumIndependentsEnum);
-	if(num_independents){
-		this->FetchData(&independents,&dummy,&dummy,AutodiffIndependentsEnum);
-
-		/*now go fetch the independent variables for each independent enum: */
-		for(i=0;i<num_independents;i++){
-			this->FetchIndependent(independents[i]);
-		}
-		xDelete<int>(independents);
-	}
-	#else
-	/*if we asked for AD computations, we have a problem!: */
-	this->Constant(&autodiff,AutodiffIsautodiffEnum);
-	if(autodiff)_error_("Cannot carry out AD mode computations without support of ADOLC compiled in!");
-	#endif
-
-}
-/*}}}*/
-/*FUNCTION IoModel::FetchIndependent{{{*/
-void IoModel::FetchIndependent(int independent_enum){
-
-	#ifdef _HAVE_ADOLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents:
-	extern int my_rank;
-	extern int num_procs;
-
-	/*output: */
-	int M,N;
-	IssmPDouble* buffer=NULL; //a buffer to read the data from disk
-	IssmDouble* matrix=NULL; //our independent variable
-	int code=0;
-	int vector_type=0;
-	
-	/*Set file pointer to beginning of the data: */
-	fid=this->SetFilePointerToData(&code,&vector_type,independent_enum);
-	if((code!=5) && (code!=6) && (code!=7))_error_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(independent_enum));
-	
-	/*Now fetch: */
-
-	/*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
-	/*numberofelements: */
-	if(my_rank==0){  
-		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
-	}
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
-	#endif
-
-	if(my_rank==0){  
-		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
-	}
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 
-	#endif
-
-	/*Now allocate matrix: */
-	if(M*N){
-		buffer=xNew<IssmPDouble>(M*N);
-		matrix=xNew<IssmDouble>(M*N);
-
-		/*Read matrix on node 0, then broadcast: */
-		if(my_rank==0){  
-			if(fread(buffer,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix ");
-			
-			/*Now, before we even broadcast this to other nodes, declare the whole matrix as a independent variable!: */
-			for (int i=0;i<M*N;++i) matrix[i]<<=buffer[i];  /*we use the <<= ADOLC overloaded operator to declare the independency*/
-		}
-		#ifdef _HAVE_MPI_
-		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
-		#endif
-		
-		xDelete<IssmPDouble>(buffer);
-	}
-	else _error_("cannot declare the independent variable " << EnumToStringx(independent_enum) <<  "if it's empty!");
-
-	/*Ok, we are almost done. Matrix is now a independent matrix. We don't want this matrix to be fetched again in the 
-	 *future, which would effectively write over the independency in the ADOLC tape! So we are going to keep track of this 
-	 independent matrix inthe iomodel->data[independent_enum] data slot: */
-	this->data[independent_enum]=matrix;
-	this->independents[independent_enum]=true;
- 	#endif
-}
-/*}}}*/

Modified: issm/trunk/src/c/classes/IoModel.h
===================================================================
--- issm/trunk/src/c/classes/IoModel.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/IoModel.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,13 +18,13 @@
 class IoModel {
 
 	private: 
-		Parameters  *constants;   //this dataset holds all IssmDouble, int, bool and char *parameters read in from the input file.*
-	
+		Parameters *constants;   //this dataset holds all IssmDouble, int, bool and char from input
+
 	public:
-		IssmDouble **data;        //this dataset holds temporary data, memory intensive.
-		
+		IssmDouble **data;   //this dataset holds temporary data, memory intensive.
+
 		/*This data needs to stay memory resident at all time, even if it's memory intensive: */
-		FILE *fid;         //pointer to input file
+		FILE *fid;                               //pointer to input file
 		bool *my_elements;
 		bool *my_nodes;
 		int  *my_vertices;
@@ -35,9 +35,10 @@
 		int nodecounter;         //keep track of how many nodes are being created in each analysis type
 		int loadcounter;         //keep track of how many loads are being created in each analysis type
 		int constraintcounter;   //keep track of how many constraints are being created in each analysis type
-		
+
 		/*for AD mode: to keep track of our independent variables we fetch:*/
 		bool* independents;
+		DataSet* independent_objects;
 
 		/*Methods*/
 		~IoModel();

Modified: issm/trunk/src/c/classes/Patch.cpp
===================================================================
--- issm/trunk/src/c/classes/Patch.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/Patch.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,7 @@
  * \brief: implementation of the Patch object
  */
 
-/*Include files: {{{*/
+/*Include files */
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -18,26 +18,23 @@
 #include "../EnumDefinitions/EnumDefinitions.h"
 #include "../shared/shared.h"
 #include "../include/include.h"
-/*}}}*/
 
 /*Object constructors and destructors:*/
 /*FUNCTION Patch::Patch() default constructor {{{*/
 Patch::Patch(){
-	this->numrows=0;
-	this->numcols=0;
-	this->maxvertices=0;
-	this->maxnodes=0;
-	this->values=NULL;
+	this->numrows     = 0;
+	this->numcols     = 0;
+	this->maxvertices = 0;
+	this->maxnodes    = 0;
+	this->values      = NULL;
 }
 /*}}}*/
 /*FUNCTION Patch::Patch(int numrows, int maxvertices, int maxnodes){{{*/
 Patch::Patch(int in_numrows, int in_maxvertices, int in_maxnodes){
 
-	int i,j;
 	this->numrows=in_numrows;
 	this->maxvertices=in_maxvertices;
 	this->maxnodes=in_maxnodes;
-    
 	this->numcols=1  //enum_type
 		+1           //step
 		+1           //time 
@@ -51,9 +48,9 @@
 		this->values=NULL;
 	}
 	else{
-	        this->values=xNew<IssmDouble>(this->numcols*this->numrows);
-		for(i=0;i<this->numrows;i++){
-			for(j=0;j<this->numcols;j++){
+		this->values=xNew<IssmDouble>(this->numcols*this->numrows);
+		for(int i=0;i<this->numrows;i++){
+			for(int j=0;j<this->numcols;j++){
 				this->values[i*this->numcols+j]=NAN;
 			}
 		}
@@ -97,8 +94,7 @@
 	row=this->values+count*this->numcols;
 
 	/*Let's remember what is on a row: 
-	 enum_type step time element_id interpolation vertices_ids nodal_values
-	 */
+	 enum_type step time element_id interpolation vertices_ids nodal_values */
 	row[0]=enum_type;
 	row[1]=(IssmDouble)step;
 	row[2]=time;
@@ -112,10 +108,9 @@
 /*FUNCTION Patch::Gather{{{*/
 void Patch::Gather(void){
 
-	int         i;
 	int         count;
-	extern int  my_rank;
-	extern int  num_procs;
+	int         my_rank;
+	int         num_procs;
 	int         total_numrows;
 	int         node_numrows;
 	IssmDouble     *total_values  = NULL;
@@ -123,10 +118,14 @@
 	MPI_Status  status;
 	#endif
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+	num_procs=IssmComm::GetSize();
+
 	/*First, figure out total number of rows combining all the cpus: */
 	#ifdef _HAVE_MPI_
-	MPI_Reduce(&this->numrows,&total_numrows,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&total_numrows,1,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Reduce(&this->numrows,&total_numrows,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&total_numrows,1,MPI_INT,0,IssmComm::GetComm());
 	#else
 	total_numrows=this->numrows;
 	#endif
@@ -146,14 +145,14 @@
 
 	/*Now, ask other nodes to send their values: */
 	#ifdef _HAVE_MPI_
-	for (i=1;i<num_procs;i++){
+	for(int i=1;i<num_procs;i++){
 		if (my_rank==i){ 
-			MPI_Send(&this->numrows,1,MPI_INT,0,1,MPI_COMM_WORLD);   
-			if (this->numrows)MPI_Send(this->values,this->numrows*this->numcols,MPI_DOUBLE,0,1,MPI_COMM_WORLD); 
+			MPI_Send(&this->numrows,1,MPI_INT,0,1,IssmComm::GetComm());   
+			if (this->numrows)MPI_Send(this->values,this->numrows*this->numcols,MPI_DOUBLE,0,1,IssmComm::GetComm()); 
 		}
 		if (my_rank==0){
-			MPI_Recv(&node_numrows,1,MPI_INT,i,1,MPI_COMM_WORLD,&status); 
-			if (node_numrows)MPI_Recv(total_values+count,node_numrows*this->numcols,MPI_DOUBLE,i,1,MPI_COMM_WORLD,&status);
+			MPI_Recv(&node_numrows,1,MPI_INT,i,1,IssmComm::GetComm(),&status); 
+			if (node_numrows)MPI_Recv(total_values+count,node_numrows*this->numcols,MPI_DOUBLE,i,1,IssmComm::GetComm(),&status);
 			count+=node_numrows*this->numcols;
 		}
 	}	

Modified: issm/trunk/src/c/classes/Patch.h
===================================================================
--- issm/trunk/src/c/classes/Patch.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/Patch.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
  */ 
 
 /*A Patch object is used to store all results held in elements, in a serial way, and to dump them to disk. 
-	
+
 	Each row of the Patch object is made of the following information: 
 	- the result enum_type, 
 	- the step and time, 
@@ -11,7 +11,7 @@
 	- the interpolation type, 
 	- the vertices ids, 
 	- and the values at the nodes (could be different from the vertices).
-	
+
 	For ex: 
 	1. on a Beam element, Vx, at step 1, time .5, element id 1, interpolation type P0 (constant), vertices ids 1 and 2, one constant value 4.5
 	   VxEnum 1  .5  1 P0  1 2       4.5 NaN  NaN
@@ -19,7 +19,6 @@
 	   VzEnum 2  .8  2 P1  1 3 4     4.5 3.2  2.5
 */
 
-
 #ifndef _PATCH_H_
 #define  _PATCH_H_
 
@@ -28,12 +27,11 @@
 
 	public:
 
-		int     numrows; //number of results held in Patch object
-		int     numcols; //number of columns
-		int     maxvertices; //maxvertices corresponds to largest amount of vertices on a given element, determined by the geometry.
-		int     maxnodes;    // maxnodes corresponds to the largest amout of nodes on a given element, determined by the interpolation type.
-		
-		IssmDouble* values;  //result values
+		int         numrows;       //number of results held in Patch object
+		int         numcols;       //number of columns
+		int         maxvertices;   //largest amount of vertices on a given element, determined by geometry
+		int         maxnodes;      //the largest amout of nodes on a given element, determined by interpolation
+		IssmDouble *values;        //result values
 
 		Patch();
 		Patch(int numrows, int maxvertices, int maxnodes);

Modified: issm/trunk/src/c/classes/Update.h
===================================================================
--- issm/trunk/src/c/classes/Update.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/Update.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,9 +6,8 @@
 #define  _UPDATE_H_
 
 /*Headers:*/
-/*{{{*/
 #include "../shared/shared.h"
-/*}}}*/
+class IoModel;
 
 class Update{
 
@@ -32,4 +31,3 @@
 };
 
 #endif //ifndef _UPDATE_H_
-

Modified: issm/trunk/src/c/classes/bamg/AdjacentTriangle.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/AdjacentTriangle.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/AdjacentTriangle.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,7 +8,6 @@
 
 namespace bamg {
 
-
 	/*Constructors/Destructors*/
 	//See header file
 

Modified: issm/trunk/src/c/classes/bamg/AdjacentTriangle.h
===================================================================
--- issm/trunk/src/c/classes/bamg/AdjacentTriangle.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/AdjacentTriangle.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -43,4 +43,3 @@
 	};
 }
 #endif
-

Modified: issm/trunk/src/c/classes/bamg/BamgGeom.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/BamgGeom.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/BamgGeom.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include "../objects.h"
+#include "../objects/objects.h"
 #include "../../io/io.h"
 #include "../../shared/shared.h"
 

Modified: issm/trunk/src/c/classes/bamg/BamgMesh.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/BamgMesh.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/BamgMesh.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include "../objects.h"
+#include "../objects/objects.h"
 #include "../../io/io.h"
 #include "../../shared/shared.h"
 

Modified: issm/trunk/src/c/classes/bamg/BamgOpts.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/BamgOpts.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/BamgOpts.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include "../../shared/shared.h"
 #include "../../include/include.h"
-#include "../objects.h"
+#include "../objects/objects.h"
 #include "../../io/io.h"
 
 /*Constructors/Destructors*/

Modified: issm/trunk/src/c/classes/bamg/BamgQuadtree.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/BamgQuadtree.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/BamgQuadtree.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "../objects.h"
+#include "../objects/objects.h"
 
 namespace bamg {
 
@@ -427,7 +427,6 @@
 			hb = hb2; 
 		  }
 
-
 		if ( n0 > 0) 
 		  {  
 			for(register int k=0;k<n0;k++)

Modified: issm/trunk/src/c/classes/bamg/BamgQuadtree.h
===================================================================
--- issm/trunk/src/c/classes/bamg/BamgQuadtree.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/BamgQuadtree.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -33,7 +33,6 @@
 					void    Echo()       {_error_("not implemented yet"); };
 					void    DeepEcho()   {_error_("not implemented yet"); };
 					int     Id()         {_error_("not implemented yet"); };
-					int     MyRank()     {_error_("not implemented yet"); };
 					int     ObjectEnum() {_error_("not implemented yet"); };
 					Object *copy()       {_error_("not implemented yet"); };
 			};

Modified: issm/trunk/src/c/classes/bamg/BamgVertex.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/BamgVertex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/BamgVertex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 #include <cmath>
 #include <ctime>
 
-#include "../objects.h"
+#include "../objects/objects.h"
 
 namespace bamg {
 

Modified: issm/trunk/src/c/classes/bamg/Direction.h
===================================================================
--- issm/trunk/src/c/classes/bamg/Direction.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/Direction.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,4 +18,3 @@
 	};
 }
 #endif
-

Modified: issm/trunk/src/c/classes/bamg/Edge.h
===================================================================
--- issm/trunk/src/c/classes/bamg/Edge.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/Edge.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 
 	//classes
 	class Mesh;
-	
+
 	class Edge {
 
 		public:
@@ -35,4 +35,3 @@
 	};
 }
 #endif
-

Modified: issm/trunk/src/c/classes/bamg/EigenMetric.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/EigenMetric.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/EigenMetric.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -29,7 +29,6 @@
 		b=-a11-a22;
 		delta=b*b - 4*(a11*a22-a21*a21);
 
-
 		/*Compute norm of M to avoid round off errors*/
 		normM=a11*a11 + a22*a22 + a21*a21;
 

Modified: issm/trunk/src/c/classes/bamg/Geometry.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/Geometry.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/Geometry.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 #include <cmath>
 #include <ctime>
 
-#include "../objects.h"
+#include "../objects/objects.h"
 #include "../../include/include.h"
 #include "../../shared/Exceptions/exceptions.h"
 
@@ -67,7 +67,7 @@
 		nbcurves=0;
 
 		double Hmin = HUGE_VAL;// the infinie value 
-		int i,j,k,n,i0,i1,i2,i3;
+		int i,j,n,i0,i1,i2,i3;
 
 		/*initialize some variables*/
 		verbose= bamgopts->verbose;
@@ -172,7 +172,7 @@
 				 vertices[i].m=Metric(Hmin);
 			}
 			delete [] verticeslength;
-			
+
 		}
 		else{
 			_error_("No edges provided");
@@ -498,15 +498,13 @@
 	void Geometry::PostRead(){
 		/*Original code from Frederic Hecht <hecht at ann.jussieu.fr> (BAMG v1.01, MeshGeom.cpp/AfterRead)*/
 
-		long               i,j,k;
-		int                jj;
-		long              *head_v   = new long[nbv];
-		long              *next_p   = new long[2*nbe];
-		float             *eangle   = new float[nbe];
-		double             eps      = 1e-20;
-		BamgQuadtree           quadtree; // build quadtree to find duplicates
-		BamgVertex        *v0       = vertices;
-		GeomVertex *v0g      = (GeomVertex*) (void*)v0;
+		long          i          ,j,k;
+		long         *head_v   = new long[nbv];
+		long         *next_p   = new long[2 *nbe];
+		float        *eangle   = new float[nbe];
+		double        eps      = 1e-20;
+		BamgQuadtree  quadtree;                            // build quadtree to find duplicates
+		BamgVertex   *v0       = vertices;
 
 		k=0;
 
@@ -868,7 +866,7 @@
 		ge[bge] = e.GeomEdgeHook;
 		directionge[bge]=1;
 
-		while (eg0!=(GeomEdge*)vg0 && (*eg0)(direction0)!=(GeomVertex*)vg0){ 
+		while(eg0!=(GeomEdge*)vg0 && (*eg0)(direction0)!=(GeomVertex*)vg0){ 
 			if (bge<=0) {
 				if(NbTry) {
 					_printLine_("Fatal Error: on the class Mesh before call Geometry::ProjectOnCurve");
@@ -904,7 +902,6 @@
 			_assert_(tge>=0 && tge<=mxe);
 		}
 
-
 		if ((*eg0)(direction0)==(GeomVertex*)vg0)
 		 vg0=VertexOnGeom(*(BamgVertex*) vg0,*eg0,direction0); //vg0 = absisce
 

Modified: issm/trunk/src/c/classes/bamg/Geometry.h
===================================================================
--- issm/trunk/src/c/classes/bamg/Geometry.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/Geometry.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -63,6 +63,6 @@
 			GeomEdge *Containing(const R2 P, GeomEdge *start) const;
 			void             WriteGeometry(BamgGeom *bamggeom, BamgOpts*bamgopts);
 	};
-	
+
 }
 #endif

Modified: issm/trunk/src/c/classes/bamg/ListofIntersectionTriangles.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/ListofIntersectionTriangles.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/ListofIntersectionTriangles.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 #include <cmath>
 #include <ctime>
 
-#include "../objects.h"
+#include "../objects/objects.h"
 
 namespace bamg {
 
@@ -319,8 +319,6 @@
 				ilast=NewItem(t,ba[0],ba[1],ba[2]); }
 		}  //  outside departure
 
-
-
 		// recherche the intersection of [a,b] with Bh Mesh.
 		// we know  a triangle ta contening the vertex a
 		// we have 2 case for intersection [a,b] with a edge [A,B] of Bh
@@ -391,7 +389,6 @@
 
 				Icoor2 detbij = bamg::det((*t)[i],(*t)[j],b);
 
-
 				if (detbij >= 0) { //we find the triangle contening b
 					dt[0]=bamg::det((*t)[1],(*t)[2],b);
 					dt[1]=bamg::det((*t)[2],(*t)[0],b);

Modified: issm/trunk/src/c/classes/bamg/Mesh.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/Mesh.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/Mesh.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 #include <cmath>
 #include <ctime>
 
-#include "../objects.h"
+#include "../objects/objects.h"
 
 namespace bamg {
 
@@ -200,7 +200,6 @@
 			  VertexOnBThEdge=0;
 			 }
 
-
 		  if(nbe)
 			edges = new Edge[nbe];
 		  if(nbsubdomains)
@@ -269,7 +268,7 @@
 
 		double Hmin = HUGE_VAL;// the infinie value 
 		long i1,i2,i3;
-		long i,j;
+		long i;
 		Metric M1(1);
 		int verbose=0;
 		bool* nodeflags=NULL;
@@ -385,7 +384,7 @@
 		//Quadrilaterals
 		if(bamgmesh->Quadrilaterals){
 			if(verbose>5) _printLine_("      processing Quadrilaterals");
-			long i1,i2,i3,i4,iref;
+			long i1,i2,i3,i4;
 			triangles =new Triangle[nbt];
 			for (i=0;i<bamgmesh->QuadrilateralsSize[0];i++){
 				//divide the quad into two triangles
@@ -1008,11 +1007,11 @@
 	void Mesh::WriteIndex(int** pindex,int* pnels){
 
 		/*Intermediary*/
-		int i,k,num;
-		int verbose=0;
+		int i,k;
 
 		/*output*/
 		int* index=NULL;
+		int  num=0;
 
 		/*Get number of triangles*/
 		k=0;
@@ -1023,7 +1022,6 @@
 
 		if (k){
 			index=xNew<int>(3*k);
-			num=0;
 			for (i=0;i<nbt;i++){
 				Triangle &t=triangles[i];
 				if (t.det>0 && !(t.Hidden(0)||t.Hidden(1) || t.Hidden(2) )){
@@ -1244,7 +1242,6 @@
 		tt[1]->SetSingleVertexToTriangleConnectivity();
 		tt[2]->SetSingleVertexToTriangleConnectivity();
 
-
 		// swap if the point s is on a edge
 		if(izerodet>=0) {
 			int rswap=tt[izerodet]->swap(iedge);
@@ -1573,7 +1570,7 @@
 
 		//initialize subdomains[isd].head as 0
 		for (isd=0;isd<nbsubdomains;isd++) subdomains[isd].head =0;
-		  
+
 		k=0;
 		for (it=0;it<nbt;it++){
 			for (int j=0;j<3;j++){
@@ -2539,7 +2536,6 @@
 			delete [] HeapArete;
 			delete [] HeapTriangle;
 
-
 			if (OutSide|| !Gh.subdomains || !Gh.nbsubdomains ) 
 			  { // No geom sub domain
 				long i;
@@ -2694,7 +2690,6 @@
 					if (verbose>5) _printLine_("WARNING: " << nbsubdomains-inew << " SubDomains are being removed");
 					nbsubdomains=inew;}
 
-
 					for (it=0;it<nbt;it++)
 					 if ( mark[it] ==-1 ) 
 					  nbtout++,triangles[it].link =0;
@@ -3075,7 +3070,6 @@
 			if (verbose>5) _printLine_("   do nothing: costheta > 1");
 		}
 
-
 			long nbqq = (nbt*3)/2;
 			DoubleAndInt *qq = new DoubleAndInt[nbqq];
 
@@ -4273,7 +4267,6 @@
 			newedges[ie].adj[1]=newedges + ie +1;
 			R2 A = edges[i][0],B = edges[i][1];
 
-
 			kk += (i == edge4->SortAndAdd(GetId(edges[i][0]),GetId(edges[i][1])));
 			if (ong) // a geometrical edges 
 			  { 
@@ -4342,7 +4335,6 @@
 
 		nbv = k;
 
-
 		kedge = new long[3*nbt+1];
 		ksplitarray = new long[nbt+1];
 		ksplit = ksplitarray +1; // because ksplit[-1] == ksplitarray[0]
@@ -4411,7 +4403,6 @@
 				const AdjacentTriangle ta = t.Adj(j);
 				const Triangle & tt = ta;
 
-
 				const BamgVertex & v0 = t[VerticesOfTriangularEdge[j][0]];
 				const BamgVertex & v1 = t[VerticesOfTriangularEdge[j][1]];
 				if ( kedge[3*i+j] < 0) 
@@ -4647,7 +4638,6 @@
 		 for (i=0;i<BTh.nbv;i++)
 		  BTh.vertices[i].m =  BTh.vertices[i].m*2.;
 
-
 		ret = 2;
 		if (nbt>= maxnbt) goto Error; // bug 
 		if (nbv>= maxnbv) goto Error; // bug 
@@ -4962,7 +4952,7 @@
 		/*Generate mesh from geometry*/
 
 		/*Intermediaries*/
-		int                i,j,k;
+		int                i,k;
 		int                nbcurves    = 0;
 		int                NbNewPoints,NbEdgeCurve;
 		double             lcurve,lstep,s;
@@ -5000,7 +4990,7 @@
 				//Add the vertex
 				_assert_(nbv<maxnbv);
 				vertices[nbv]=Gh[i];
-				
+
 				//Add pointer from geometry (Gh) to vertex from mesh (Th)
 				Gh[i].MeshVertexHook=vertices+nbv;
 
@@ -5195,7 +5185,7 @@
 										nbe++;
 										va = vb;
 									}
-									
+
 									/*We just added one edge to the curve: Go to the next one*/
 									lcurve = lcurveb;
 									e->SetMark();
@@ -5370,7 +5360,7 @@
 
 					/*Get curve number*/
 					int nc=ei.GeomEdgeHook->CurveNumber;
-					
+
 					//_printLine_("Dealing with curve number " << nc);
 					//_printLine_("edge on geometry is same as GhCurve? " << (ei.GeomEdgeHook==Gh.curves[nc].FirstEdge || ei.GeomEdgeHook==Gh.curves[nc].LastEdge)?"yes":"no");
 					//if(ei.GeomEdgeHook==Gh.curves[nc].FirstEdge || ei.GeomEdgeHook==Gh.curves[nc].LastEdge){
@@ -5418,7 +5408,7 @@
 
 				/*Get edge of Bth with index iedge*/
 				Edge &ei = BTh.edges[iedge];
-			
+
 				/*Initialize variables*/
 				double Lstep=0,Lcurve=0;    // step between two points   (phase==1) 
 				long NbCreatePointOnCurve=0;// Nb of new points on curve (phase==1) 
@@ -5536,7 +5526,6 @@
 						}// for(;;) end of the curve
 					}
 
-
 					if (phase){ // construction of the last edge
 						Edge* e=edges + nbe++;
 						e->GeomEdgeHook  = ongequi;
@@ -5786,7 +5775,6 @@
 		BamgVertex & s1= (*t1)[OppositeVertex[a1]];
 		BamgVertex & s2= (*t2)[OppositeVertex[a2]];
 
-
 		Icoor2 dets2 = det(*pva,*pvb,s2);
 		Icoor2 det1=t1->det , det2=t2->det ;
 		Icoor2 detT = det1+det2;

Modified: issm/trunk/src/c/classes/bamg/Metric.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/Metric.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/Metric.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,11 +15,11 @@
 	/*Constructor/Destructor*/
 	/*FUNCTION Metric::Metric(double a){{{*/
 	Metric::Metric(double a): a11(1/(a*a)),a21(0),a22(1/(a*a)){
-	
+
 	}/*}}}*/
 	/*FUNCTION Metric::Metric(double a,double b,double c){{{*/
 	Metric::Metric(double a,double b,double c) :a11(a),a21(b),a22(c){
-	
+
 	}/*}}}*/
 	/*FUNCTION Metric::Metric(const double  a[3],const  Metric& m0, const  Metric& m1,const  Metric&  m2 ){{{*/ 
 	Metric::Metric(const double  a[3],const  Metric& m0, const  Metric& m1,const  Metric& m2 ){

Modified: issm/trunk/src/c/classes/bamg/R2.h
===================================================================
--- issm/trunk/src/c/classes/bamg/R2.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/R2.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -38,11 +38,6 @@
 
 	template <class R,class RR> class P2xP2{
 
-		  private:
-
-			  friend P2<R,RR> operator*(P2<R,RR> c,P2xP2<R,RR> cc){
-				  return P2<R,RR>(c.x*cc.x.x + c.y*cc.y.x, c.x*cc.x.y + c.y*cc.y.y);
-			  } 
 		  public:
 
 			  //fields

Modified: issm/trunk/src/c/classes/bamg/SetOfE4.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/SetOfE4.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/SetOfE4.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-#include "../objects.h"
+#include "../objects/objects.h"
 
 using namespace std;
 namespace bamg {

Modified: issm/trunk/src/c/classes/bamg/Triangle.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/Triangle.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/Triangle.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 #include <cmath>
 #include <ctime>
 
-#include "../objects.h"
+#include "../objects/objects.h"
 
 namespace bamg {
 
@@ -424,7 +424,6 @@
 									 sinb12 = double(det2),
 									 sinba2 = double(t2->det);
 
-
 						 // angle b12 > angle ba2 => cotg(angle b12) < cotg(angle ba2)
 						 OnSwap =  ((double) cosb12 * (double)  sinba2) <  ((double) cosba2 * (double) sinb12);
 						 break;

Modified: issm/trunk/src/c/classes/bamg/VertexOnVertex.cpp
===================================================================
--- issm/trunk/src/c/classes/bamg/VertexOnVertex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/bamg/VertexOnVertex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,7 +16,7 @@
 	};/*}}}*/
 	/*FUNCTION VertexOnVertex::VertexOnVertex(BamgVertex * w,BamgVertex *bw){{{*/
 	VertexOnVertex::VertexOnVertex(BamgVertex * w,BamgVertex *bw) :v(w),bv(bw){
-	
+
 	}/*}}}*/
 
 	/*Methods*/

Modified: issm/trunk/src/c/classes/classes.h
===================================================================
--- issm/trunk/src/c/classes/classes.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/classes.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -29,5 +29,8 @@
 #include "./FemModel.h"
 #include "./OptArgs.h"
 #include "./OptPars.h"
+#include "./AdolcEdf.h"
+#include "./IssmComm.h"
+#include "./RiftStruct.h"
 
 #endif

Modified: issm/trunk/src/c/classes/dakota/DakotaPlugin.cpp
===================================================================
--- issm/trunk/src/c/classes/dakota/DakotaPlugin.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/dakota/DakotaPlugin.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,6 @@
  * the entire computations. 
  */ 
 
-
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -24,8 +23,8 @@
 /*Standard ISSM includes: */
 #include "../../shared/shared.h"
 #include "../../include/include.h"
+#include "../../solutions/solutions.h"
 #include "../classes.h"
-#include "../../modules/Dakotax/Dakotax.h"
 
 /*Standard includes: */
 #include <string>
@@ -33,28 +32,25 @@
 #ifdef _HAVE_DAKOTA_ //only works if dakota library has been compiled in.
 
 //Dakota headers
-#include "DakotaResponse.H"
-#include "ParamResponsePair.H"
-#include "DakotaPlugin.h"
-#include "system_defs.h"
-#include "ProblemDescDB.H"
-#include "ParallelLibrary.H"
+#include <DakotaResponse.H>
+#include <ParamResponsePair.H>
+#include <system_defs.h>
+#include <ProblemDescDB.H>
+#include <ParallelLibrary.H>
+#include "./DakotaPlugin.h"
 
 namespace SIM {
 
-//constructor
-DakotaPlugin::DakotaPlugin(const Dakota::ProblemDescDB& problem_db,void* in_femmodel):Dakota::DirectApplicInterface(problem_db){
+DakotaPlugin::DakotaPlugin(const Dakota::ProblemDescDB& problem_db,void* in_femmodel):Dakota::DirectApplicInterface(problem_db){/*{{{*/
 
-
 	femmodel=in_femmodel;
 	counter=0;
-}
+}/*}}}*/
+DakotaPlugin::~DakotaPlugin(){/*{{{*/
+	/* Virtual destructor handles referenceCount at Interface level. */ 
+}/*}}}*/
+int DakotaPlugin::derived_map_ac(const Dakota::String& driver){/*{{{*/
 
-//destructor
-DakotaPlugin::~DakotaPlugin(){ /* Virtual destructor handles referenceCount at Interface level. */ }
-
-int DakotaPlugin::derived_map_ac(const Dakota::String& driver) {
-
 	int i;
 	IssmDouble* variables=NULL;
 	char** variable_descriptors=NULL;
@@ -79,7 +75,6 @@
 		variable_descriptor=xNew<char>(strlen(label.c_str())+1);
 		memcpy(variable_descriptor,label.c_str(),(strlen(label.c_str())+1)*sizeof(char));
 
-		
 		variable_descriptors[i]=variable_descriptor;
 	}
 
@@ -87,14 +82,13 @@
 	responses=xNewZeroInit<IssmDouble>(numFns);
 
 	/*run core solution: */
-	SpawnCore(responses,numFns, variables,variable_descriptors,numACV,femmodel,counter);
+	DakotaSpawnCore(responses,numFns, variables,variable_descriptors,numACV,femmodel,counter);
 
 	/*populate responses: */
 	for(i=0;i<numFns;i++){
 		fnVals[i]=responses[i];
 	}
 
-
 	/*Free ressources:*/
 	xDelete<IssmDouble>(variables);
 	for(i=0;i<numACV;i++){
@@ -105,14 +99,11 @@
 	xDelete<IssmDouble>(responses);
 
 	return 0;
-}
-  
-
-int DakotaPlugin::GetCounter(){
+}/*}}}*/
+int DakotaPlugin::GetCounter(){/*{{{*/
 	return counter;
-}
+}/*}}}*/
 
 } // namespace SIM
 
-
 #endif //only works if dakota library has been compiled in.

Modified: issm/trunk/src/c/classes/dakota/DakotaPlugin.h
===================================================================
--- issm/trunk/src/c/classes/dakota/DakotaPlugin.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/dakota/DakotaPlugin.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,15 +4,12 @@
 #ifndef _DAKOTAPLUGIN_H
 #define _DAKOTAPLUGIN_H
 
-
 #ifdef _HAVE_DAKOTA_ //only works if dakota library has been compiled in.
 
 /*Headers:*/
-/*{{{*/
-#include "DirectApplicInterface.H"
+#include <DirectApplicInterface.H>
 #include "../../toolkits/toolkits.h"
 #include "../../classes/classes.h"
-/*}}}*/
 
 namespace SIM {
 
@@ -48,5 +45,4 @@
 
 #endif //only works if dakota library has been compiled in.
 
-
 #endif

Modified: issm/trunk/src/c/classes/gauss/GaussPenta.h
===================================================================
--- issm/trunk/src/c/classes/gauss/GaussPenta.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/gauss/GaussPenta.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -27,7 +27,7 @@
 		double coord2;
 		double coord3;
 		double coord4;
-		
+
 	public:
 
 		/*GaussPenta constructors, destructors*/

Modified: issm/trunk/src/c/classes/gauss/GaussTria.h
===================================================================
--- issm/trunk/src/c/classes/gauss/GaussTria.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/gauss/GaussTria.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -24,7 +24,7 @@
 		IssmDouble coord1;
 		IssmDouble coord2;
 		IssmDouble coord3;
-		
+
 	public:
 
 		/*GaussTria constructors, destructors*/

Modified: issm/trunk/src/c/classes/kriging/ExponentialVariogram.cpp
===================================================================
--- issm/trunk/src/c/classes/kriging/ExponentialVariogram.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/ExponentialVariogram.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "../objects.h"
+#include "../objects/objects.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
 #include "../../shared/shared.h"
 #include "../../include/include.h"

Modified: issm/trunk/src/c/classes/kriging/ExponentialVariogram.h
===================================================================
--- issm/trunk/src/c/classes/kriging/ExponentialVariogram.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/ExponentialVariogram.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -24,7 +24,6 @@
 		void  Echo();
 		void  DeepEcho(){_error_("Not implemented yet");};
 		int   Id(){_error_("Not implemented yet");}; 
-		int   MyRank(){_error_("Not implemented yet");};
 		int   ObjectEnum(){_error_("Not implemented yet");};
 		Object* copy(){_error_("Not implemented yet");};
 

Modified: issm/trunk/src/c/classes/kriging/GaussianVariogram.cpp
===================================================================
--- issm/trunk/src/c/classes/kriging/GaussianVariogram.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/GaussianVariogram.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "../objects.h"
+#include "../objects/objects.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
 #include "../../shared/shared.h"
 #include "../../include/include.h"

Modified: issm/trunk/src/c/classes/kriging/GaussianVariogram.h
===================================================================
--- issm/trunk/src/c/classes/kriging/GaussianVariogram.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/GaussianVariogram.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,7 +25,6 @@
 		void  Echo();
 		void  DeepEcho(){_error_("Not implemented yet");};
 		int   Id(){_error_("Not implemented yet");}; 
-		int   MyRank(){_error_("Not implemented yet");};
 		int   ObjectEnum(){_error_("Not implemented yet");};
 		Object* copy(){_error_("Not implemented yet");};
 

Modified: issm/trunk/src/c/classes/kriging/Observation.cpp
===================================================================
--- issm/trunk/src/c/classes/kriging/Observation.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/Observation.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
  */
 
 #include <stdlib.h>
-#include "../objects.h"
+#include "../objects/objects.h"
 
 /*Observation constructors and destructor*/
 /*FUNCTION Observation::Observation(){{{*/
@@ -34,8 +34,6 @@
 /*FUNCTION Observation::Echo {{{*/
 void Observation::Echo(void){
 
-	int  bit;
-
 	_printLine_("Observation");
 	_printLine_("   index : " << this->index);
 	_printLine_("   x     : " << this->x);

Modified: issm/trunk/src/c/classes/kriging/Observation.h
===================================================================
--- issm/trunk/src/c/classes/kriging/Observation.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/Observation.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,7 +25,6 @@
 		void    Echo();
 		void    DeepEcho()  {_error_("Not implemented yet"); };
 		int     Id()        {_error_("Not implemented yet"); };
-		int     MyRank()    {_error_("Not implemented yet"); };
 		int     ObjectEnum(){_error_("Not implemented yet"); };
 		Object *copy()      {_error_("Not implemented yet"); };
 

Modified: issm/trunk/src/c/classes/kriging/PowerVariogram.cpp
===================================================================
--- issm/trunk/src/c/classes/kriging/PowerVariogram.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/PowerVariogram.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "../objects.h"
+#include "../objects/objects.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
 #include "../../shared/shared.h"
 #include "../../include/include.h"

Modified: issm/trunk/src/c/classes/kriging/PowerVariogram.h
===================================================================
--- issm/trunk/src/c/classes/kriging/PowerVariogram.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/PowerVariogram.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -24,7 +24,6 @@
 		void  Echo();
 		void  DeepEcho(){_error_("Not implemented yet");};
 		int   Id(){_error_("Not implemented yet");}; 
-		int   MyRank(){_error_("Not implemented yet");};
 		int   ObjectEnum(){_error_("Not implemented yet");};
 		Object* copy(){_error_("Not implemented yet");};
 

Modified: issm/trunk/src/c/classes/kriging/Quadtree.cpp
===================================================================
--- issm/trunk/src/c/classes/kriging/Quadtree.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/Quadtree.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-#include "../objects.h"
+#include "../objects/objects.h"
 
 /*DOCUMENTATION What is a Quadtree? {{{
  * A Quadtree is a very simple way to group vertices according

Modified: issm/trunk/src/c/classes/kriging/Quadtree.h
===================================================================
--- issm/trunk/src/c/classes/kriging/Quadtree.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/Quadtree.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,7 +28,6 @@
 				void    Echo();
 				void    DeepEcho()  {_error_("not implemented yet"); };
 				int     Id()        {_error_("not implemented yet"); };
-				int     MyRank()    {_error_("not implemented yet"); };
 				int     ObjectEnum(){_error_("not implemented yet"); };
 				Object *copy()      {_error_("not implemented yet"); };
 

Modified: issm/trunk/src/c/classes/kriging/SphericalVariogram.cpp
===================================================================
--- issm/trunk/src/c/classes/kriging/SphericalVariogram.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/SphericalVariogram.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "../objects.h"
+#include "../objects/objects.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
 #include "../../shared/shared.h"
 #include "../../include/include.h"

Modified: issm/trunk/src/c/classes/kriging/SphericalVariogram.h
===================================================================
--- issm/trunk/src/c/classes/kriging/SphericalVariogram.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/kriging/SphericalVariogram.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -24,7 +24,6 @@
 		void  Echo();
 		void  DeepEcho(){_error_("Not implemented yet");};
 		int   Id(){_error_("Not implemented yet");}; 
-		int   MyRank(){_error_("Not implemented yet");};
 		int   ObjectEnum(){_error_("Not implemented yet");};
 		Object* copy(){_error_("Not implemented yet");};
 

Modified: issm/trunk/src/c/classes/matrix/ElementMatrix.cpp
===================================================================
--- issm/trunk/src/c/classes/matrix/ElementMatrix.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/matrix/ElementMatrix.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -229,7 +229,7 @@
 /*}}}*/
 /*FUNCTION ElementMatrix::~ElementMatrix(){{{*/
 ElementMatrix::~ElementMatrix(){
-	
+
 	xDelete<IssmDouble>(this->values);
 	xDelete<int>(this->gglobaldoflist);
 	xDelete<int>(this->row_flocaldoflist);
@@ -277,7 +277,6 @@
 			xDelete<IssmDouble>(localvalues);
 		}
 
-
 		if((this->row_ssize!=0) && (this->row_fsize!=0)){
 			/*first, retrieve values that are in the f and s-set from the g-set values matrix: */
 			localvalues=xNew<IssmDouble>(this->row_fsize*this->row_ssize);

Modified: issm/trunk/src/c/classes/matrix/ElementMatrix.h
===================================================================
--- issm/trunk/src/c/classes/matrix/ElementMatrix.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/matrix/ElementMatrix.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,7 +21,7 @@
 class ElementMatrix{
 
 	public:
-	
+
 		int      nrows;
 		int      ncols;
 		bool     dofsymmetrical;

Modified: issm/trunk/src/c/classes/matrix/ElementVector.cpp
===================================================================
--- issm/trunk/src/c/classes/matrix/ElementVector.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/matrix/ElementVector.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -35,7 +35,7 @@
 
 	/*intermediaries*/
 	int i,j,counter;
-	int gsize,fsize,ssize;
+	int gsize,fsize;
 	int* P=NULL;
 	bool found;
 
@@ -138,7 +138,7 @@
 
 	/*fill values with 0: */
 	this->values=xNewZeroInit<IssmDouble>(this->nrows);
-	
+
 	/*g list*/
 	this->gglobaldoflist=GetGlobalDofList(nodes,numnodes,GsetEnum,approximation);
 
@@ -150,7 +150,7 @@
 /*}}}*/
 /*FUNCTION ElementVector::~ElementVector(){{{*/
 ElementVector::~ElementVector(){
-	
+
 	xDelete<IssmDouble>(this->values);
 	xDelete<int>(this->gglobaldoflist);
 	xDelete<int>(this->flocaldoflist);
@@ -180,7 +180,7 @@
 		/*Free ressources:*/
 		xDelete<IssmDouble>(localvalues);
 	}
-	
+
 }
 /*}}}*/
 /*FUNCTION ElementVector::InsertIntoGlobal(Vector<IssmDouble>* pf){{{*/
@@ -218,7 +218,8 @@
 /*FUNCTION ElementVector::Echo{{{*/
 void ElementVector::Echo(void){
 
-	int i,j;
+	int i;
+
 	_printLine_("Element Vector echo:");
 	_printLine_("   nrows: " << nrows);
 	_printLine_("   values:");

Modified: issm/trunk/src/c/classes/matrix/ElementVector.h
===================================================================
--- issm/trunk/src/c/classes/matrix/ElementVector.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/matrix/ElementVector.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,10 +21,10 @@
 class ElementVector{
 
 	public:
-	
+
 		int      nrows;
 		IssmDouble*  values;
-		
+
 		//gset
 		int*     gglobaldoflist;
 
@@ -32,7 +32,7 @@
 		int      fsize;
 		int*     flocaldoflist;
 		int*     fglobaldoflist;
-		
+
 		/*ElementVector constructors, destructors {{{*/
 		ElementVector();
 		ElementVector(ElementVector* pe1,ElementVector* pe2);
@@ -50,4 +50,3 @@
 		/*}}}*/
 };
 #endif //#ifndef _ELEMENT_VECTOR_H_
-

Modified: issm/trunk/src/c/classes/matrix/Matrix.h
===================================================================
--- issm/trunk/src/c/classes/matrix/Matrix.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/matrix/Matrix.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -75,6 +75,33 @@
 
 		}
 		/*}}}*/
+		/*FUNCTION Matrix(int m,int n,int M,int N,int* d_nnz,int* o_nnz,int type){{{*/
+		#ifdef _HAVE_PETSC_
+		Matrix(int m,int n,int M,int N,int* d_nnz,int* o_nnz,int in_type=PetscMatType){
+		#else
+		Matrix(int m,int n,int M,int N,int* d_nnz,int* o_nnz,int in_type=SeqMatType){
+		#endif
+
+			#ifdef _HAVE_PETSC_
+			pmatrix=NULL;
+			#endif
+			smatrix=NULL;
+			type=in_type;
+
+			if(type==PetscMatType){
+				#ifdef _HAVE_PETSC_
+				this->pmatrix=new PetscMat(m,n,M,N,d_nnz,o_nnz);
+				#else
+				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
+				#endif
+			}
+			else if(type==SeqMatType){
+				this->smatrix=new SeqMat<doubletype>(m,n,M,N,d_nnz,o_nnz);
+			}
+			else _error_("Matrix type: " << type << " not supported yet!");
+
+		}
+		/*}}}*/
 		/*FUNCTION Matrix(int M,int N,IssmDouble sparsity,int in_type){{{*/
 		#ifdef _HAVE_PETSC_
 		Matrix(int M,int N,double sparsity,int in_type=PetscMatType){
@@ -162,14 +189,11 @@
 			if(type==PetscMatType){
 				#ifdef _HAVE_PETSC_
 				delete this->pmatrix;
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
 				#endif
 			}
 			else if(type==SeqMatType){
 				delete this->smatrix;
 			}
-			else _error_("Matrix type: " << type << " not supported yet!");
 
 		}
 		/*}}}*/
@@ -191,6 +215,19 @@
 
 		}
 		/*}}}*/
+		/*FUNCTION AllocationInfo{{{*/
+		void AllocationInfo(void){
+			_assert_(this);
+			if(type==PetscMatType){
+				#ifdef _HAVE_PETSC_
+				this->pmatrix->AllocationInfo();
+				#endif
+			}
+			else if(type==SeqMatType){
+				//this->smatrix->AllocationInfo();
+			}
+			else _error_("Matrix type: " << type << " not supported yet!");
+		}/*}}}*/
 		/*FUNCTION Assemble{{{*/
 		void Assemble(void){
 
@@ -273,10 +310,8 @@
 		/*FUNCTION Duplicate{{{*/
 		Matrix* Duplicate(void){
 
-			Matrix* output=NULL;
+			Matrix* output=new Matrix();
 
-			output=new Matrix();
-
 			if(type==PetscMatType){
 				#ifdef _HAVE_PETSC_
 				output->pmatrix=this->pmatrix->Duplicate();
@@ -305,7 +340,6 @@
 			}
 			else _error_("Matrix type: " << type << " not supported yet!");
 
-
 			return output;
 		}
 		/*}}}*/

Modified: issm/trunk/src/c/classes/matrix/Vector.h
===================================================================
--- issm/trunk/src/c/classes/matrix/Vector.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/matrix/Vector.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -60,7 +60,6 @@
 			svector=NULL;
 			type=in_type;
 
-
 			if(type==PetscVecType){
 			#ifdef _HAVE_PETSC_
 				this->pvector=new PetscVec(M,fromlocalsize);
@@ -75,6 +74,33 @@
 
 		}
 		/*}}}*/
+		/*FUNCTION Vector(int m,int M,int in_type){{{*/
+		#ifdef _HAVE_PETSC_
+		Vector(int m,int M,int in_type=PetscVecType){
+		#else
+		Vector(int m,int M,int in_type=SeqVecType){
+		#endif
+
+			#ifdef _HAVE_PETSC_
+			pvector=NULL;
+			#endif
+			svector=NULL;
+			type=in_type;
+
+			if(type==PetscVecType){
+			#ifdef _HAVE_PETSC_
+				this->pvector=new PetscVec(m,M);
+			 #else
+				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
+			 #endif
+			}
+			else if(type==SeqVecType){
+				this->svector=new SeqVec<doubletype>(m,M);
+			}
+			else _error_("Vector type: " << type << " not supported yet!");
+
+		}
+		/*}}}*/
 		/*FUNCTION Vector(doubletype* serial_vec,int M,int in_type){{{*/
 		#ifdef _HAVE_PETSC_
 		Vector(doubletype* serial_vec,int M,int in_type=PetscVecType){
@@ -110,14 +136,11 @@
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				delete this->pvector;
-				#else
-				_error_("Petsc matrix format not usable, as Petsc has not been compiled!");
 				#endif
 			}
 			else if(type==SeqVecType){
 				delete this->svector;
 			}
-			else _error_("Vector type: " << type << " not supported yet!");
 		}
 		/*}}}*/
 		#ifdef _HAVE_PETSC_
@@ -170,7 +193,6 @@
 		/*FUNCTION SetValues{{{*/
 		void SetValues(int ssize, int* list, doubletype* values, InsMode mode){
 
-
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				this->pvector->SetValues(ssize,list,values,mode);
@@ -183,8 +205,6 @@
 			}
 			else _error_("Vector type: " << type << " not supported yet!");
 
-
-
 		}
 		/*}}}*/
 		/*FUNCTION SetValue{{{*/
@@ -207,7 +227,6 @@
 		/*FUNCTION GetValue{{{*/
 		void GetValue(doubletype* pvalue,int dof){
 
-
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				this->pvector->GetValue(pvalue,dof);
@@ -255,7 +274,6 @@
 		/*FUNCTION GetLocalSize{{{*/
 		void GetLocalSize(int* pM){
 
-
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				this->pvector->GetLocalSize(pM);
@@ -275,7 +293,6 @@
 
 			Vector* output=NULL;
 
-
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				output=new Vector();
@@ -297,7 +314,6 @@
 		/*FUNCTION Set{{{*/
 		void Set(doubletype value){
 
-
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				this->pvector->Set(value);
@@ -315,7 +331,6 @@
 		/*FUNCTION AXPY{{{*/
 		void AXPY(Vector* X, doubletype a){
 
-
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				this->pvector->AXPY(X->pvector,a);
@@ -333,7 +348,6 @@
 		/*FUNCTION AYPX{{{*/
 		void AYPX(Vector* X, doubletype a){
 
-
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				this->pvector->AYPX(X->pvector,a);
@@ -346,7 +360,6 @@
 			}
 			else _error_("Vector type: " << type << " not supported yet!");
 
-
 		}
 		/*}}}*/
 		/*FUNCTION ToMPISerial{{{*/
@@ -373,7 +386,6 @@
 		/*FUNCTION Copy{{{*/
 		void Copy(Vector* to){
 
-
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				this->pvector->Copy(to->pvector);
@@ -386,7 +398,6 @@
 			}
 			else _error_("Vector type: " << type << " not supported yet!");
 
-
 		}
 		/*}}}*/
 		/*FUNCTION Norm{{{*/
@@ -412,7 +423,6 @@
 		/*FUNCTION Scale{{{*/
 		void Scale(doubletype scale_factor){
 
-
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				this->pvector->Scale(scale_factor);
@@ -450,7 +460,6 @@
 		/*FUNCTION PointwiseDivide{{{*/
 		void PointwiseDivide(Vector* x,Vector* y){
 
-
 			if(type==PetscVecType){
 				#ifdef _HAVE_PETSC_
 				this->pvector->PointwiseDivide(x->pvector,y->pvector);

Modified: issm/trunk/src/c/classes/matrix/matrixobjects.h
===================================================================
--- issm/trunk/src/c/classes/matrix/matrixobjects.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/matrix/matrixobjects.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,12 +5,10 @@
 #ifndef ALL_MATRIX_OBJECTS_H_
 #define ALL_MATRIX_OBJECTS_H_
 
-
 /*Numerics:*/
 #include "./ElementMatrix.h"
 #include "./ElementVector.h"
 #include "./Vector.h"
 #include "./Matrix.h"
 
-
 #endif

Modified: issm/trunk/src/c/classes/objects/Constraints/Constraint.h
===================================================================
--- issm/trunk/src/c/classes/objects/Constraints/Constraint.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Constraints/Constraint.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,7 +4,6 @@
  * It is derived from Object, so DataSets can contain them.
  */ 
 
-
 #ifndef _CONSTRAINT_H_
 #define _CONSTRAINT_H_
 
@@ -18,11 +17,10 @@
 class Constraint: public Object{
 
 	public: 
-		
+
 		virtual      ~Constraint(){};
 		virtual void ConstrainNode(Nodes* nodes,Parameters* parameters)=0;
 		virtual bool InAnalysis(int analysis_type)=0;
 
-
 };
 #endif

Modified: issm/trunk/src/c/classes/objects/Constraints/SpcDynamic.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Constraints/SpcDynamic.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Constraints/SpcDynamic.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -40,7 +40,7 @@
 	return;
 }
 /*}}}*/
-		
+
 /*Object virtual functions definitions:*/
 /*FUNCTION SpcDynamic::Echo {{{*/
 void SpcDynamic::Echo(void){
@@ -65,12 +65,6 @@
 /*FUNCTION SpcDynamic::Id {{{*/
 int    SpcDynamic::Id(void){ return sid; }
 /*}}}*/
-/*FUNCTION SpcDynamic::MyRank {{{*/
-int    SpcDynamic::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION SpcDynamic::ObjectEnum{{{*/
 int SpcDynamic::ObjectEnum(void){
 
@@ -116,7 +110,7 @@
 /*}}}*/
 /*FUNCTION SpcDynamic::GetNodeId {{{*/
 int   SpcDynamic::GetNodeId(){
-	
+
 	return nodeid;
 }
 /*}}}*/

Modified: issm/trunk/src/c/classes/objects/Constraints/SpcDynamic.h
===================================================================
--- issm/trunk/src/c/classes/objects/Constraints/SpcDynamic.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Constraints/SpcDynamic.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -32,7 +32,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Constraints/SpcStatic.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Constraints/SpcStatic.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Constraints/SpcStatic.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -39,7 +39,7 @@
 	return;
 }
 /*}}}*/
-		
+
 /*Object virtual functions definitions:*/
 /*FUNCTION SpcStatic::Echo {{{*/
 void SpcStatic::Echo(void){
@@ -68,12 +68,6 @@
 /*FUNCTION SpcStatic::Id {{{*/
 int    SpcStatic::Id(void){ return sid; }
 /*}}}*/
-/*FUNCTION SpcStatic::MyRank {{{*/
-int    SpcStatic::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION SpcStatic::ObjectEnum{{{*/
 int SpcStatic::ObjectEnum(void){
 
@@ -117,7 +111,7 @@
 /*}}}*/
 /*FUNCTION SpcStatic::GetNodeId {{{*/
 int   SpcStatic::GetNodeId(){
-	
+
 	return nodeid;
 }
 /*}}}*/

Modified: issm/trunk/src/c/classes/objects/Constraints/SpcStatic.h
===================================================================
--- issm/trunk/src/c/classes/objects/Constraints/SpcStatic.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Constraints/SpcStatic.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -31,7 +31,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Constraints/SpcTransient.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Constraints/SpcTransient.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Constraints/SpcTransient.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -53,7 +53,7 @@
 	return;
 }
 /*}}}*/
-		
+
 /*Object virtual functions definitions:*/
 /*FUNCTION SpcTransient::Echo {{{*/
 void SpcTransient::Echo(void){
@@ -80,12 +80,6 @@
 /*FUNCTION SpcTransient::Id {{{*/
 int    SpcTransient::Id(void){ return sid; }
 /*}}}*/
-/*FUNCTION SpcTransient::MyRank {{{*/
-int    SpcTransient::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION SpcTransient::ObjectEnum{{{*/
 int SpcTransient::ObjectEnum(void){
 
@@ -102,7 +96,7 @@
 /*Constraint virtual functions definitions:*/
 /*FUNCTION SpcTransient::InAnalysis{{{*/
 bool SpcTransient::InAnalysis(int in_analysis_type){
-	
+
 	if (in_analysis_type==this->analysis_type) return true;
 	else return false;
 }
@@ -119,7 +113,7 @@
 
 	/*Chase through nodes and find the node to which this SpcTransient applys: */
 	node=(Node*)nodes->GetObjectById(NULL,nodeid);
-	
+
 	if(node){ //in case the spc is dealing with a node on another cpu
 
 		/*Retrieve time in parameters: */
@@ -164,7 +158,7 @@
 /*}}}*/
 /*FUNCTION SpcTransient::GetNodeId {{{*/
 int   SpcTransient::GetNodeId(){
-	
+
 	return nodeid;
 }
 /*}}}*/
@@ -173,4 +167,3 @@
 	return values[0];
 }
 /*}}}*/
-

Modified: issm/trunk/src/c/classes/objects/Constraints/SpcTransient.h
===================================================================
--- issm/trunk/src/c/classes/objects/Constraints/SpcTransient.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Constraints/SpcTransient.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -33,7 +33,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Contour.h
===================================================================
--- issm/trunk/src/c/classes/objects/Contour.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Contour.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,28 +21,28 @@
 
 	public: 
 
-		int     id;
-		int	  nods;  //number of vertices in the contour
-		doubletype* x;
-		doubletype* y;
-		bool    closed; //is this contour closed?
+		int         id;
+		int         nods;     //number of vertices in the contour
+		doubletype *x;
+		doubletype *y;
+		bool        closed;   //is this contour closed?
 
 		/*Contour constructors, destructors :*/
-		/*FUNCTION Contour() default constructor {{{*/
+		/*FUNCTION Contour() {{{*/
 		Contour(){
-			this->id=0;
-			this->nods=0;
-			this->x=NULL;
-			this->y=NULL;
-			this->closed=false;
+			this->id     = 0;
+			this->nods   = 0;
+			this->x      = NULL;
+			this->y      = NULL;
+			this->closed = false;
 		}
 		/*}}}*/
 		/*FUNCTION Contour(int pid, int nods, doubletype* x, doubletype* y,bool closed) {{{*/
 		Contour(int pid,int pnods, doubletype* px, doubletype* py,bool pclosed){
 
-			this->id=pid;
-			this->nods=pnods;
-			this->closed=pclosed;
+			this->id     = pid;
+			this->nods   = pnods;
+			this->closed = pclosed;
 			if(nods){
 				this->x=xNew<doubletype>(nods);
 				xMemCpy<doubletype>(this->x,px,nods);
@@ -51,27 +51,23 @@
 			}
 		}
 		/*}}}*/
-		/*FUNCTION Contour() default constructor {{{*/
+		/*FUNCTION ~Contour() {{{*/
 		~Contour(){
 			xDelete<doubletype>(this->x);
 			xDelete<doubletype>(this->y);
 		}
 		/*}}}*/
 
-
 		/*Object virtual function resolutoin: */
 		/*FUNCTION Echo(){{{*/
 		void Echo(void){
-
-			int i;
-
-			_printLine_("Contour: " << id);
-			_printLine_("   nods: " << nods);
-			_printLine_("   closed: " << (closed?"true":"false"));
+			_printLine_(" Contour: " << id);
+			_printLine_("    nods: " << nods);
+			_printLine_("  closed: " << (closed?"true":"false"));
 			if(nods){
-				_printLine_("   x,y:");
-				for(i=0;i<nods;i++){
-					_printLine_(i << ": " << x[i] << "|" << y[i]);
+				_printLine_("   x , y:");
+				for(int i=0;i<nods;i++){
+					_printLine_(i << ": " << x[i] << " | " << y[i]);
 				}
 			}
 		}
@@ -86,25 +82,14 @@
 			return id;
 		}
 		/*}}}*/
-		/*FUNCTION MyRank{{{*/
-		int    MyRank(void){ 
-			extern int my_rank;
-
-			return my_rank; 
-		}
-		/*}}}*/
 		/*FUNCTION ObjectEnum{{{*/
 		int ObjectEnum(void){
-
 			return ContourEnum;
-
 		}
 		/*}}}*/
 		/*FUNCTION copy {{{*/
 		Object* copy() {
-
 			return new Contour(*this); 
-
 		}
 		/*}}}*/
 };

Modified: issm/trunk/src/c/classes/objects/ElementResults/BoolElementResult.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/ElementResults/BoolElementResult.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ElementResults/BoolElementResult.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -57,12 +57,6 @@
 /*FUNCTION BoolElementResult::Id{{{*/
 int    BoolElementResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION BoolElementResult::MyRank{{{*/
-int    BoolElementResult::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION BoolElementResult::ObjectEnum{{{*/
 int BoolElementResult::ObjectEnum(void){
 
@@ -115,7 +109,7 @@
 /*}}}*/
 /*FUNCTION BoolElementResult::PatchFill{{{*/
 void BoolElementResult::PatchFill(int row, Patch* patch){
-	
+
 	 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 
 	  * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
 	  * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */

Modified: issm/trunk/src/c/classes/objects/ElementResults/BoolElementResult.h
===================================================================
--- issm/trunk/src/c/classes/objects/ElementResults/BoolElementResult.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ElementResults/BoolElementResult.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,6 @@
  *  A boll result object is just derived from a BoolInput object, with additional time and step information.
  */
 
-
 #ifndef _BOOLELEMENTRESULT_H_
 #define _BOOLELEMENTRESULT_H_
 
@@ -33,7 +32,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/ElementResults/DoubleElementResult.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/ElementResults/DoubleElementResult.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ElementResults/DoubleElementResult.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -57,12 +57,6 @@
 /*FUNCTION DoubleElementResult::Id{{{*/
 int    DoubleElementResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleElementResult::MyRank{{{*/
-int    DoubleElementResult::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION DoubleElementResult::ObjectEnum{{{*/
 int DoubleElementResult::ObjectEnum(void){
 
@@ -105,7 +99,7 @@
 /*}}}*/
 /*FUNCTION DoubleElementResult::ProcessUnits{{{*/
 void DoubleElementResult::ProcessUnits(Parameters* parameters){
-	
+
 	this->value=UnitConversion(this->value,IuToExtEnum,this->enum_type);
 
 }
@@ -117,7 +111,7 @@
 /*}}}*/
 /*FUNCTION DoubleElementResult::PatchFill{{{*/
 void DoubleElementResult::PatchFill(int row, Patch* patch){
-	
+
 	 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 
 	  * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
 	  * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */

Modified: issm/trunk/src/c/classes/objects/ElementResults/DoubleElementResult.h
===================================================================
--- issm/trunk/src/c/classes/objects/ElementResults/DoubleElementResult.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ElementResults/DoubleElementResult.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,6 @@
  *  A IssmDouble result object is just derived from a DoubleInput object, with additional time and step information.
  */
 
-
 #ifndef _DOUBLEELEMENTRESULT_H_
 #define _DOUBLEELEMENTRESULT_H_
 
@@ -33,7 +32,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/ElementResults/ElementResult.h
===================================================================
--- issm/trunk/src/c/classes/objects/ElementResults/ElementResult.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ElementResults/ElementResult.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief abstract class for ElementResult object
  */ 
 
-
 #ifndef _ELEMENTRESULT_H_
 #define _ELEMENTRESULT_H_
 
@@ -14,9 +13,8 @@
 class ElementResult:public Object{
 
 	public: 
-		
+
 		virtual        ~ElementResult(){};
-		
 		virtual         ElementResult* SpawnTriaElementResult(int* indices)=0;
 		virtual IssmDouble  GetTime(void)=0;
 		virtual int     GetStep(void)=0;

Modified: issm/trunk/src/c/classes/objects/ElementResults/ElementResultLocal.h
===================================================================
--- issm/trunk/src/c/classes/objects/ElementResults/ElementResultLocal.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ElementResults/ElementResultLocal.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,4 +8,3 @@
 class Parameters;
 
 #endif //ifndef _ELEMENTRESULTLOCAL_H_
-

Modified: issm/trunk/src/c/classes/objects/ElementResults/PentaP1ElementResult.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/ElementResults/PentaP1ElementResult.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ElementResults/PentaP1ElementResult.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -60,12 +60,6 @@
 /*FUNCTION PentaP1ElementResult::Id{{{*/
 int    PentaP1ElementResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION PentaP1ElementResult::MyRank{{{*/
-int    PentaP1ElementResult::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION PentaP1ElementResult::ObjectEnum{{{*/
 int PentaP1ElementResult::ObjectEnum(void){
 
@@ -75,7 +69,7 @@
 /*}}}*/
 /*FUNCTION PentaP1ElementResult::copy{{{*/
 Object* PentaP1ElementResult::copy() {
-	
+
 	return new PentaP1ElementResult(this->enum_type,this->values,this->step,this->time);
 
 }
@@ -116,7 +110,7 @@
 /*}}}*/
 /*FUNCTION PentaP1ElementResult::ProcessUnits{{{*/
 void PentaP1ElementResult::ProcessUnits(Parameters* parameters){
-	
+
 	UnitConversion(this->values,6,IuToExtEnum,this->enum_type);
 
 }
@@ -128,7 +122,7 @@
 /*}}}*/
 /*FUNCTION PentaP1ElementResult::PatchFill{{{*/
 void PentaP1ElementResult::PatchFill(int row, Patch* patch){
-	
+
 	 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 
 	  * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
 	  * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */

Modified: issm/trunk/src/c/classes/objects/ElementResults/PentaP1ElementResult.h
===================================================================
--- issm/trunk/src/c/classes/objects/ElementResults/PentaP1ElementResult.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ElementResults/PentaP1ElementResult.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,6 @@
  *  this object is just a PentaP1Input with additional time and step info.
  */
 
-
 #ifndef _PENTAP1ELEMENTRESULT_H_
 #define _PENTAP1ELEMENTRESULT_H_
 
@@ -32,7 +31,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/ElementResults/TriaP1ElementResult.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/ElementResults/TriaP1ElementResult.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ElementResults/TriaP1ElementResult.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -48,7 +48,7 @@
 /*}}}*/
 /*FUNCTION TriaP1ElementResult::DeepEcho{{{*/
 void TriaP1ElementResult::DeepEcho(void){
-		
+
 	_printLine_("TriaP1ElementResult:");
 	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	_printLine_("   values: [" << this->values[0] << " " << this->values[1] << " " << this->values[2] << "]");
@@ -59,12 +59,6 @@
 /*FUNCTION TriaP1ElementResult::Id{{{*/
 int    TriaP1ElementResult::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION TriaP1ElementResult::MyRank{{{*/
-int    TriaP1ElementResult::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION TriaP1ElementResult::ObjectEnum{{{*/
 int TriaP1ElementResult::ObjectEnum(void){
 
@@ -74,7 +68,7 @@
 /*}}}*/
 /*FUNCTION TriaP1ElementResult::copy{{{*/
 Object* TriaP1ElementResult::copy() {
-	
+
 	return new TriaP1ElementResult(this->enum_type,this->values,this->step,this->time);
 
 }
@@ -104,7 +98,7 @@
 /*}}}*/
 /*FUNCTION TriaP1ElementResult::ProcessUnits{{{*/
 void TriaP1ElementResult::ProcessUnits(Parameters* parameters){
-	
+
 	UnitConversion(this->values,3,IuToExtEnum,this->enum_type);
 
 }
@@ -116,7 +110,7 @@
 /*}}}*/
 /*FUNCTION TriaP1ElementResult::PatchFill{{{*/
 void TriaP1ElementResult::PatchFill(int row, Patch* patch){
-	
+
 	 /*Here, we fill the result information into the patch object. First, let's remember what is in a row 
 	  * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
 	  * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */

Modified: issm/trunk/src/c/classes/objects/ElementResults/TriaP1ElementResult.h
===================================================================
--- issm/trunk/src/c/classes/objects/ElementResults/TriaP1ElementResult.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ElementResults/TriaP1ElementResult.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for TriaP1ElementResult object
  */
 
-
 #ifndef _TRIAP1ELEMENTRESULT_H_
 #define _TRIAP1ELEMENTRESULT_H_
 
@@ -31,7 +30,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Elements/Element.h
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/Element.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/Element.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,7 +4,6 @@
  * It is derived from Element, so DataSets can contain them.
  */ 
 
-
 #ifndef _ELEMENT_H_
 #define _ELEMENT_H_
 
@@ -24,16 +23,20 @@
 class Element: public Object,public Update{
 
 	public: 
-		
+
 		virtual        ~Element(){};
-	
+
 		virtual void   Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters)=0;
 		virtual void   SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters)=0;
+		virtual void   SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum)=0;
 		virtual void   CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>*  Kfs,Vector<IssmDouble>* df)=0;
 		virtual void   CreatePVector(Vector<IssmDouble>* pf)=0;
 		virtual void   CreateJacobianMatrix(Matrix<IssmDouble>* Jff)=0;
 		virtual void   GetSolutionFromInputs(Vector<IssmDouble>* solution)=0;
 		virtual int    GetNodeIndex(Node* node)=0;
+		virtual int    GetNumberOfNodes(void)=0;
+		virtual void   GetNodesSidList(int* sidlist)=0;
+
 		virtual int    Sid()=0;
 		virtual bool   IsFloating()=0; 
 		virtual bool   IsNodeOnShelf()=0; 
@@ -42,7 +45,7 @@
 		virtual void   GetInputListOnVertices(IssmDouble* pvalue,int enumtype)=0;
 		virtual void   GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue)=0;
 		virtual void   GetInputValue(IssmDouble* pvalue,Node* node,int enumtype)=0;
-		
+
 		virtual IssmDouble SurfaceArea(void)=0;
 		virtual void   InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum)=0;
 		virtual void   ComputeBasalStress(Vector<IssmDouble>* sigma_b)=0;
@@ -58,7 +61,7 @@
 		virtual void   InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code)=0;
 		virtual void   ProcessResultsUnits(void)=0;
 		virtual void   RequestedOutput(int output_enum,int step,IssmDouble time)=0;
-		
+
 		virtual int    NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units)=0;
 		virtual void   InputScale(int enum_type,IssmDouble scale_factor)=0;
 		virtual void   GetVectorFromInputs(Vector<IssmDouble>* vector, int name_enum)=0;

Modified: issm/trunk/src/c/classes/objects/Elements/Penta.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/Penta.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/Penta.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -81,7 +81,7 @@
 	/*intialize inputs and results: */
 	this->inputs=new Inputs();
 	this->results=new Results();
-	
+
 	/*initialize pointers:*/
 	this->nodes=NULL;
 	this->material=NULL;
@@ -179,13 +179,12 @@
 	const int  numdof=NUMVERTICES*NDOF1;
 
 	/*Intermediaries */
-	int    count,ig;
+	int    count;
 	IssmDouble basalfriction[NUMVERTICES]={0,0,0,0,0,0};
 	IssmDouble alpha2,vx,vy;
 	Friction*  friction=NULL;
 	GaussPenta* gauss=NULL;
 
-
 	/* Basal friction can only be found at the base of an ice sheet: */
 	if (!IsOnBed() || IsFloating()){
 		//empty friction: 
@@ -198,14 +197,13 @@
 	Input* vy_input=inputs->GetInput(VyEnum);                         _assert_(vy_input);
 	Input* vz_input=inputs->GetInput(VzEnum);                         _assert_(vz_input);
 
-
 	/*Build friction element, needed later: */
 	friction=new Friction("3d",inputs,matpar,DiagnosticHorizAnalysisEnum);
 
 	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
 	gauss=new GaussPenta(0,1,2,2);
 	count=0;
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -215,7 +213,7 @@
 		basalfriction[count]=alpha2*(pow(vx,2.0)+pow(vy,2.0));
 		count++;
 	}
-	
+
 	/*Create PentaVertex input, which will hold the basal friction:*/
 	this->inputs->AddInput(new PentaP1Input(BasalFrictionEnum,&basalfriction[0]));
 
@@ -227,23 +225,21 @@
 /*FUNCTION Penta::ComputeBasalStress {{{*/
 void  Penta::ComputeBasalStress(Vector<IssmDouble>* sigma_b){
 
-	int         i,j,ig;
+	int         i,j;
 	int         dofv[3]={0,1,2};
 	int         dofp[1]={3};
 	int         analysis_type,approximation;
-	int         doflist[NUMVERTICES];
-	IssmDouble      xyz_list[NUMVERTICES][3];
-	IssmDouble      xyz_list_tria[3][3];
-	IssmDouble      rho_ice,gravity,stokesreconditioning;
-	IssmDouble      pressure,viscosity,bed,Jdet2d;
-	IssmDouble      bed_normal[3];
-	IssmDouble      basalforce[3];
-	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	IssmDouble      devstresstensor[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	IssmDouble      stresstensor[6]={0.0};
-	IssmDouble      sigma_xx,sigma_yy,sigma_zz;
-	IssmDouble      sigma_xy,sigma_xz,sigma_yz;
-	IssmDouble      surface=0,value=0;
+	IssmDouble  xyz_list[NUMVERTICES][3];
+	IssmDouble  xyz_list_tria[3][3];
+	IssmDouble  rho_ice,gravity,stokesreconditioning;
+	IssmDouble  pressure,viscosity,Jdet2d;
+	IssmDouble  bed_normal[3];
+	IssmDouble  basalforce[3];
+	IssmDouble  epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble  stresstensor[6]={0.0};
+	IssmDouble  sigma_xx,sigma_yy,sigma_zz;
+	IssmDouble  sigma_xy,sigma_xz,sigma_yz;
+	IssmDouble  surface=0,value=0;
 	GaussPenta* gauss;
 
 	/*retrive parameters: */
@@ -256,7 +252,7 @@
 
 	/*retrieve some parameters: */
 	this->parameters->FindParam(&stokesreconditioning,DiagnosticStokesreconditioningEnum);
-	
+
 	if(!IsOnBed()){
 		//put zero
 		sigma_b->SetValue(id-1,0.0,INS_VAL);
@@ -279,7 +275,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(0,1,2,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -324,7 +320,6 @@
 /*FUNCTION Penta::ComputeStressTensor {{{*/
 void  Penta::ComputeStressTensor(){
 
-	int         iv;
 	IssmDouble      xyz_list[NUMVERTICES][3];
 	IssmDouble      pressure,viscosity;
 	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,exy];*/
@@ -363,7 +358,7 @@
 		sigma_xz[iv]=2*viscosity*epsilon[4];
 		sigma_yz[iv]=2*viscosity*epsilon[5];
 	}
-	
+
 	/*Add Stress tensor components into inputs*/
 	this->inputs->AddInput(new PentaP1Input(StressTensorxxEnum,&sigma_xx[0]));
 	this->inputs->AddInput(new PentaP1Input(StressTensorxyEnum,&sigma_xy[0]));
@@ -380,7 +375,7 @@
 void  Penta::Configure(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
 
 	int analysis_counter;
-	
+
 	/*go into parameters and get the analysis_counter: */
 	parametersin->FindParam(&analysis_counter,AnalysisCounterEnum);
 
@@ -420,7 +415,7 @@
 	/*Checks in debugging {{{*/
 	_assert_(this->nodes && this->material && this->matpar && this->verticalneighbors && this->parameters && this->inputs);
 	/*}}}*/
-	
+
 	/*Skip if water element*/
 	if(IsOnWater()) return;
 
@@ -650,8 +645,6 @@
 /*FUNCTION Penta::DeepEcho{{{*/
 void Penta::DeepEcho(void){
 
-	int i;
-	
 	_printLine_("Penta:");
 	_printLine_("   id: " << id);
 	nodes[0]->DeepEcho();
@@ -671,8 +664,6 @@
 	results->DeepEcho();
 	_printLine_("neighboor sids: ");
 	_printLine_(" " << horizontalneighborsids[0] << " " << horizontalneighborsids[1] << " " << horizontalneighborsids[2]);
-
-	return;
 }
 /*}}}*/
 /*FUNCTION Penta::DeleteResults {{{*/
@@ -793,7 +784,7 @@
 /*FUNCTION Penta::GetDofList {{{*/
 void  Penta::GetDofList(int** pdoflist,int approximation_enum,int setenum){
 
-	int  i,j,count=0;
+	int  i,count=0;
 	int  numberofdofs=0;
 	int* doflist=NULL;
 
@@ -814,14 +805,22 @@
 	*pdoflist=doflist;
 }
 /*}}}*/
-/*FUNCTION Penta::GetDofList1 {{{*/
-void  Penta::GetDofList1(int* doflist){
+/*FUNCTION Penta::GetVertexPidList {{{*/
+void  Penta::GetVertexPidList(int* doflist){
 
 	int i;
-	for(i=0;i<6;i++) doflist[i]=nodes[i]->GetDofList1();
+	for(i=0;i<6;i++) doflist[i]=nodes[i]->GetVertexPid();
 
 }
 /*}}}*/
+/*FUNCTION Penta::GetVertexSidList{{{*/
+void  Penta::GetVertexSidList(int* sidlist){
+
+	int i;
+	for(i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetVertexSid();
+
+}
+/*}}}*/
 /*FUNCTION Penta::GetConnectivityList {{{*/
 void  Penta::GetConnectivityList(int* connectivity){
 	for(int i=0;i<NUMVERTICES;i++) connectivity[i]=nodes[i]->GetConnectivity();
@@ -891,13 +890,35 @@
 
 }
 /*}}}*/
+/*FUNCTION Penta::GetNodesSidList{{{*/
+void Penta::GetNodesSidList(int* sidlist){
+
+	_assert_(sidlist);
+	_assert_(nodes);
+
+	for(int i=0;i<NUMVERTICES;i++){
+		sidlist[i]=nodes[i]->Sid();
+	}
+}
+/*}}}*/
+/*FUNCTION Penta::GetNumberOfNodes{{{*/
+int Penta::GetNumberOfNodes(void){
+
+	if(this->nodes==NULL) return 0;
+
+	switch(this->element_type){
+		case P1Enum:
+			return 6;
+		case P1DGEnum:
+			return 6;
+		default:
+			_error_("Element type "<<EnumToStringx(this->element_type)<<" not supported yet");
+	}
+}
+/*}}}*/
 /*FUNCTION Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype) {{{*/
 void Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype){
 
-	/*Intermediaries*/
-	IssmDouble     value[NUMVERTICES];
-	GaussPenta *gauss              = NULL;
-
 	/*Recover input*/
 	Input* input=inputs->GetInput(enumtype);
 	if (!input) _error_("Input " << EnumToStringx(enumtype) << " not found in element");
@@ -906,7 +927,7 @@
 	_assert_(pvalue);
 
 	/* Start looping on the number of vertices: */
-	gauss=new GaussPenta();
+	GaussPenta *gauss=new GaussPenta();
 	for (int iv=0;iv<NUMVERTICES;iv++){
 		gauss->GaussVertex(iv);
 		input->GetInputValue(&pvalue[iv],gauss);
@@ -919,10 +940,6 @@
 /*FUNCTION Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue) {{{*/
 void Penta::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){
 
-	/*Intermediaries*/
-	IssmDouble     value[NUMVERTICES];
-	GaussPenta *gauss              = NULL;
-
 	/*Recover input*/
 	Input* input=inputs->GetInput(enumtype);
 
@@ -931,18 +948,16 @@
 
 	/* Start looping on the number of vertices: */
 	if (input){
-		gauss=new GaussPenta();
+		GaussPenta *gauss=new GaussPenta();
 		for (int iv=0;iv<NUMVERTICES;iv++){
 			gauss->GaussVertex(iv);
 			input->GetInputValue(&pvalue[iv],gauss);
 		}
+		delete gauss;
 	}
 	else{
 		for (int iv=0;iv<NUMVERTICES;iv++) pvalue[iv]=defaultvalue;
 	}
-
-	/*clean-up*/
-	delete gauss;
 }
 /*}}}*/
 /*FUNCTION Penta::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype) {{{*/
@@ -996,14 +1011,6 @@
 	*phi=4*pow(epsilon_eff,2.0)*viscosity;
 }
 /*}}}*/
-/*FUNCTION Penta::GetSidList{{{*/
-void  Penta::GetSidList(int* sidlist){
-
-	int i;
-	for(i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetSidList();
-
-}
-/*}}}*/
 /*FUNCTION Penta::GetSolutionFromInputs{{{*/
 void  Penta::GetSolutionFromInputs(Vector<IssmDouble>* solution){
 
@@ -1134,20 +1141,20 @@
 /*FUNCTION Penta::GetVectorFromInputs{{{*/
 void  Penta::GetVectorFromInputs(Vector<IssmDouble>* vector,int input_enum){
 
-	int doflist1[NUMVERTICES];
+	int vertexpidlist[NUMVERTICES];
 
 	/*Get out if this is not an element input*/
 	if (!IsInput(input_enum)) return;
 
 	/*Prepare index list*/
-	this->GetDofList1(&doflist1[0]);
+	this->GetVertexPidList(&vertexpidlist[0]);
 
 	/*Get input (either in element or material)*/
 	Input* input=inputs->GetInput(input_enum);
 	if(!input) _error_("Input " << EnumToStringx(input_enum) << " not found in element");
 
 	/*We found the enum.  Use its values to fill into the vector, using the vertices ids: */
-	input->GetVectorFromInputs(vector,&doflist1[0]);
+	input->GetVectorFromInputs(vector,&vertexpidlist[0]);
 }
 /*}}}*/
 /*FUNCTION Penta::GetVectorFromResults{{{*/
@@ -1159,11 +1166,11 @@
 		_error_("Results of offset "<<offset<<" is "<<EnumToStringx(elementresult->InstanceEnum())<<" when "<<EnumToStringx(enum_in)<<" was expected");
 	}  
 	if(interp==P1Enum){
-		int doflist1[NUMVERTICES];
+		int vertexpidlist[NUMVERTICES];
 		int connectivity[NUMVERTICES];
-		this->GetSidList(&doflist1[0]);
+		this->GetVertexSidList(&vertexpidlist[0]);
 		this->GetConnectivityList(&connectivity[0]);
-		elementresult->GetVectorFromResults(vector,&doflist1[0],&connectivity[0],NUMVERTICES);
+		elementresult->GetVectorFromResults(vector,&vertexpidlist[0],&connectivity[0],NUMVERTICES);
 	}
 	else if(interp==P0Enum){
 		elementresult->GetElementVectorFromResults(vector,sid);
@@ -1190,7 +1197,7 @@
 /*}}}*/
 /*FUNCTION Penta::Sid {{{*/
 int    Penta::Sid(){
-	
+
 	return sid;
 
 }
@@ -1250,7 +1257,7 @@
 
 	/*Check that name is an element input*/
 	if (!IsInput(name)) return;
-	
+
 	if ((code==5) || (code==1)){ //boolean
 		this->inputs->AddInput(new BoolInput(name,reCast<bool,IssmDouble>(scalar)));
 	}
@@ -1268,7 +1275,7 @@
 void Penta::InputCreate(IssmDouble* vector, int index,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){//index into elements
 
 	/*Intermediaries*/
-	int    i,j,t;
+	int    i,t;
 	int    penta_vertex_ids[6];
 	int    row;
 	IssmDouble nodeinputs[6];
@@ -1872,7 +1879,7 @@
 		/* get upper Penta*/
 		penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id);
 	}
-	
+
 	/*Free ressources:*/
 	xDelete<int>(doflist);
 }
@@ -1896,7 +1903,7 @@
 
 	/*Add input to the element: */
 	this->inputs->AddInput(new PentaP1Input(enum_type,values));
-	
+
 	/*Free ressources:*/
 	xDelete<int>(doflist);
 }
@@ -1936,7 +1943,7 @@
 		/* get upper Penta*/
 		penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id);
 	}
-	
+
 	/*Free ressources:*/
 	xDelete<int>(doflist);
 }
@@ -1959,7 +1966,7 @@
 
 				/*Get values on the 6 vertices*/
 				for (int i=0;i<6;i++){
-					values[i]=vector[this->nodes[i]->GetVertexDof()];
+					values[i]=vector[this->nodes[i]->GetVertexPid()];
 				}
 
 				/*update input*/
@@ -2161,6 +2168,7 @@
 
 	/*Recover info at the vertices: */
 	parameters->FindParam(&migration_style,GroundinglineMigrationEnum);
+	parameters->FindParam(&gl_melting_rate,GroundinglineMeltingRateEnum);
 	parameters->FindParam(&yts,ConstantsYtsEnum);
 	GetInputListOnVertices(&h[0],ThicknessEnum);
 	GetInputListOnVertices(&s[0],SurfaceEnum);
@@ -2169,7 +2177,7 @@
 	rho_water=matpar->GetRhoWater();
 	rho_ice=matpar->GetRhoIce();
 	density=rho_ice/rho_water;
-	
+
 	/*go through vertices, and update inputs, considering them to be PentaVertex type: */
 	for(i=0;i<NUMVERTICES;i++){
 		/*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */
@@ -2210,7 +2218,7 @@
 			break;
 		}
 	}
-	
+
    /*Add basal melting rate if element just ungrounded*/
 	if(!this->IsFloating() && elementonshelf==true){
 		for(i=0;i<NUMVERTICES;i++)melting[i]=gl_melting_rate/yts;
@@ -2252,12 +2260,6 @@
 	return minlength;
 }
 /*}}}*/
-/*FUNCTION Penta::MyRank {{{*/
-int    Penta::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Penta::NodalValue {{{*/
 int    Penta::NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units){
 
@@ -2298,7 +2300,7 @@
 
 	/*recover pointer: */
 	count=*pcount;
-		
+
 	/*will be needed later: */
 	for(i=0;i<6;i++) vertices_ids[i]=nodes[i]->GetVertexId(); //vertices id start at column 3 of the patch.
 
@@ -2507,7 +2509,7 @@
 /*}}}*/
 /*FUNCTION Penta::RequestedOutput{{{*/
 void Penta::RequestedOutput(int output_enum,int step,IssmDouble time){
-			
+
 	if(IsInput(output_enum)){
 		/*just transfer this input to results, and we are done: */
 		InputToResult(output_enum,step,time);
@@ -2606,6 +2608,57 @@
 	else this->nodes=NULL;
 }
 /*}}}*/
+/*FUNCTION Penta::SetwiseNodeConnectivity{{{*/
+void Penta::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
+
+	/*Output */
+	int d_nz = 0;
+	int o_nz = 0;
+
+	/*Loop over all nodes*/
+	for(int i=0;i<6;i++){
+
+		if(!flags[this->nodes[i]->Sid()]){
+
+			/*flag current node so that no other element processes it*/
+			flags[this->nodes[i]->Sid()]=true;
+
+			/*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
+			switch(set2_enum){
+				case FsetEnum:
+					if(nodes[i]->indexing.fsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case GsetEnum:
+					if(nodes[i]->indexing.gsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case SsetEnum:
+					if(nodes[i]->indexing.ssize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				default: _error_("not supported");
+			}
+		}
+	}
+
+	/*Assign output pointers: */
+	*pd_nz=d_nz;
+	*po_nz=o_nz;
+}
+/*}}}*/
 /*FUNCTION Penta::SpawnTria {{{*/
 Tria*  Penta::SpawnTria(int g0, int g1, int g2){
 
@@ -2662,6 +2715,8 @@
 	IssmDouble a_neg[NUMVERTICES];				// Hs-SMB relation parameter
 	IssmDouble b_neg[NUMVERTICES];				// Hs-SMB relation paremeter
 	IssmDouble Hc[NUMVERTICES];					// elevation of transition between accumulation regime and ablation regime
+	IssmDouble Href[NUMVERTICES];					// reference elevation from which deviations are used to calculate the SMB adjustment
+	IssmDouble Smbref[NUMVERTICES];				// reference SMB to which deviations are added
 	IssmDouble smb_pos_max[NUMVERTICES];		// maximum SMB value in the accumulation regime
 	IssmDouble smb_pos_min[NUMVERTICES];		// minimum SMB value in the accumulation regime
    IssmDouble rho_water;                   // density of fresh water
@@ -2672,13 +2727,15 @@
 
 	/*Recover SmbGradients*/
 	GetInputListOnVertices(&Hc[0],SurfaceforcingsHcEnum);
+	GetInputListOnVertices(&Href[0],SurfaceforcingsHrefEnum);
+	GetInputListOnVertices(&Smbref[0],SurfaceforcingsSmbrefEnum);
 	GetInputListOnVertices(&smb_pos_max[0],SurfaceforcingsSmbPosMaxEnum);
 	GetInputListOnVertices(&smb_pos_min[0],SurfaceforcingsSmbPosMinEnum);
 	GetInputListOnVertices(&a_pos[0],SurfaceforcingsAPosEnum);
 	GetInputListOnVertices(&b_pos[0],SurfaceforcingsBPosEnum);
 	GetInputListOnVertices(&a_neg[0],SurfaceforcingsANegEnum);
 	GetInputListOnVertices(&b_neg[0],SurfaceforcingsBNegEnum);
-	
+
    /*Recover surface elevatio at vertices: */
 	GetInputListOnVertices(&h[0],ThicknessEnum);
 	GetInputListOnVertices(&s[0],SurfaceEnum);
@@ -2686,19 +2743,20 @@
    /*Get material parameters :*/
    rho_ice=matpar->GetRhoIce();
    rho_water=matpar->GetRhoFreshwater();
-			
+
    // loop over all vertices
-   for(i=0;i<NUMVERTICES;i++){
+ for(i=0;i<NUMVERTICES;i++){
      if(s[i]>Hc[i]){
-	    smb[i]=a_pos[i]+b_pos[i]*s[i];
-		 if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];}
-		 if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];}
+		  if(Href[i]>Hc[i]){smb[i]=Smbref[i]+b_pos[i]*(s[i]-Href[i]);}
+		  if(Href[i]<=Hc[i]){smb[i]=a_pos[i]+b_pos[i]*s[i];}
+		  if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];}
+		  if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];}
 	  }
 	  else{
-	    smb[i]=a_neg[i]+b_neg[i]*s[i];
+		  if(Href[i]>Hc[i]){smb[i]=a_neg[i]+b_neg[i]*s[i];}
+		  if(Href[i]<=Hc[i]){smb[i]=Smbref[i]+b_neg[i]*(s[i]-Href[i]);}
 	  }
 	  smb[i]=smb[i]/rho_ice;      // SMB in m/y ice		
-	  
 	}  //end of the loop over the vertices
 	  /*Update inputs*/
 	  this->inputs->AddInput(new PentaP1Input(SurfaceforcingsMassBalanceEnum,&smb[0]));
@@ -2791,7 +2849,7 @@
 	maxy=xyz_list[0][1];
 	minz=xyz_list[0][2];
 	maxz=xyz_list[0][2];
-	
+
 	for(i=1;i<NUMVERTICES;i++){
 		if (xyz_list[i][0]<minx)minx=xyz_list[i][0];
 		if (xyz_list[i][0]>maxx)maxx=xyz_list[i][0];
@@ -2973,7 +3031,7 @@
 	for(i=0;i<NUMVERTICES;i++){
 		if (reCast<bool,IssmDouble>(vertices_potentially_ungrounding[nodes[i]->Sid()])){
 			vec_nodes_on_iceshelf->SetValue(nodes[i]->Sid(),1,INS_VAL);
-		
+
 			/*If node was not on ice shelf, we flipped*/
 			if(nodes_on_iceshelf[nodes[i]->Sid()]==0){
 				nflipped++;
@@ -2990,13 +3048,12 @@
 	const int  numdof=NUMVERTICES*NDOF1;
 
 	/*Intermediaries*/
-	int    iv;
 	IssmDouble phi;
 	IssmDouble viscosity;
 	IssmDouble xyz_list[NUMVERTICES][3];
 	IssmDouble epsilon[6];
-	IssmDouble     viscousheating[NUMVERTICES]={0,0,0,0,0,0};
-	IssmDouble     thickness;
+	IssmDouble viscousheating[NUMVERTICES]={0,0,0,0,0,0};
+	IssmDouble thickness;
 	GaussPenta *gauss=NULL;
 
 	/*Initialize Element vector*/
@@ -3013,13 +3070,12 @@
 	gauss=new GaussPenta();
 	for (int iv=0;iv<NUMVERTICES;iv++){
 		gauss->GaussVertex(iv);
-		
+
 		thickness_input->GetInputValue(&thickness,gauss);
 
 		this->GetStrainRate3d(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input,vz_input);
 		material->GetViscosity3dStokes(&viscosity,&epsilon[0]);
 		GetPhi(&phi, &epsilon[0], viscosity);
-		
 
 		viscousheating[iv]=phi*thickness;
 	}
@@ -3274,7 +3330,7 @@
 	rho_ice=matpar->GetRhoIce();
 
 	if(IsOnWater() || !IsOnSurface()) return 0.;
-	
+
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
 
 	/*First calculate the area of the base (cross section triangle)
@@ -3286,10 +3342,10 @@
 	Input* smb_input = inputs->GetInput(SurfaceforcingsMassBalanceEnum); _assert_(smb_input);
 	smb_input->GetInputAverage(&smb);
 	Total_Smb=rho_ice*base*smb;// smb on element in kg s-1
-	
+
 	/*Process units: */
 	Total_Smb=UnitConversion(Total_Smb,IuToExtEnum,TotalSmbEnum);// smb on element in GigaTon yr-1
-	
+
 	/*Return: */
 	return Total_Smb;
 }
@@ -3299,12 +3355,12 @@
 #ifdef _HAVE_THERMAL_
 /*FUNCTION Penta::CreateKMatrixEnthalpy {{{*/
 ElementMatrix* Penta::CreateKMatrixEnthalpy(void){
-	
+
 	/*compute all stiffness matrices for this element*/
 	ElementMatrix* Ke1=CreateKMatrixEnthalpyVolume();
 	ElementMatrix* Ke2=CreateKMatrixEnthalpyShelf();
 	ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2);
-	
+
 	/*clean-up and return*/
 	delete Ke1;
 	delete Ke2;
@@ -3319,25 +3375,25 @@
 
 	/*Intermediaries */
 	int        stabilization;
-	int        i,j,ig,found=0;
-	IssmDouble     Jdet,u,v,w,um,vm,wm;
-	IssmDouble     h,hx,hy,hz,vx,vy,vz,vel;
-	IssmDouble     gravity,rho_ice,rho_water;
-	IssmDouble     epsvel=2.220446049250313e-16;
-	IssmDouble     heatcapacity,thermalconductivity,dt;
-	IssmDouble     pressure,enthalpy;
-	IssmDouble     latentheat,kappa;
-	IssmDouble     tau_parameter,diameter;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     B_conduct[3][numdof];
-	IssmDouble     B_advec[3][numdof];
-	IssmDouble     Bprime_advec[3][numdof];
-	IssmDouble     L[numdof];
-	IssmDouble     dbasis[3][6];
-	IssmDouble     D_scalar_conduct,D_scalar_advec;
-	IssmDouble     D_scalar_trans,D_scalar_stab;
-	IssmDouble     D[3][3];
-	IssmDouble     K[3][3]={0.0};
+	int        i,j,found=0;
+	IssmDouble Jdet,u,v,w,um,vm,wm;
+	IssmDouble h,hx,hy,hz,vx,vy,vz,vel;
+	IssmDouble gravity,rho_ice,rho_water;
+	IssmDouble epsvel=2.220446049250313e-16;
+	IssmDouble heatcapacity,thermalconductivity,dt;
+	IssmDouble pressure,enthalpy;
+	IssmDouble latentheat,kappa;
+	IssmDouble tau_parameter,diameter;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble B_conduct[3][numdof];
+	IssmDouble B_advec[3][numdof];
+	IssmDouble Bprime_advec[3][numdof];
+	IssmDouble L[numdof];
+	IssmDouble dbasis[3][6];
+	IssmDouble D_scalar_conduct,D_scalar_advec;
+	IssmDouble D_scalar_trans,D_scalar_stab;
+	IssmDouble D[3][3];
+	IssmDouble K[3][3]={0.0};
 	Tria*      tria=NULL;
 	GaussPenta *gauss=NULL;
 
@@ -3366,7 +3422,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(2,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3475,14 +3531,14 @@
 	const int    numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries */
-	int       i,j,ig;
-	IssmDouble    mixed_layer_capacity,thermal_exchange_velocity;
-	IssmDouble    rho_ice,rho_water,heatcapacity;
-	IssmDouble    Jdet2d,dt;
-	IssmDouble    xyz_list[NUMVERTICES][3];
-	IssmDouble	 xyz_list_tria[NUMVERTICES2D][3];
-	IssmDouble    basis[NUMVERTICES];
-	IssmDouble    D_scalar;
+	int        i,j;
+	IssmDouble mixed_layer_capacity,thermal_exchange_velocity;
+	IssmDouble rho_ice,rho_water,heatcapacity;
+	IssmDouble Jdet2d,dt;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble basis[NUMVERTICES];
+	IssmDouble D_scalar;
 	GaussPenta *gauss=NULL;
 
 	/*Initialize Element matrix and return if necessary*/
@@ -3501,13 +3557,13 @@
 
 	/* Start looping on the number of gauss (nodes on the bedrock) */
 	gauss=new GaussPenta(0,1,2,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
-		
+
 		GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss);
 		GetNodalFunctionsP1(&basis[0], gauss);
-				
+
 		D_scalar=gauss->weight*Jdet2d*rho_water*mixed_layer_capacity*thermal_exchange_velocity/(rho_ice*heatcapacity);
 		if(reCast<bool,IssmDouble>(dt)) D_scalar=dt*D_scalar;
 
@@ -3516,7 +3572,7 @@
 					&basis[0],1,numdof,0,
 					&Ke->values[0],1);
 	}
-	
+
 	/*Clean up and return*/
 	delete gauss;
 	return Ke;
@@ -3536,12 +3592,12 @@
 /*}}}*/
 /*FUNCTION Penta::CreateKMatrixThermal {{{*/
 ElementMatrix* Penta::CreateKMatrixThermal(void){
-	
+
 	/*compute all stiffness matrices for this element*/
 	ElementMatrix* Ke1=CreateKMatrixThermalVolume();
 	ElementMatrix* Ke2=CreateKMatrixThermalShelf();
 	ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2);
-	
+
 	/*clean-up and return*/
 	delete Ke1;
 	delete Ke2;
@@ -3556,22 +3612,22 @@
 
 	/*Intermediaries */
 	int        stabilization;
-	int        i,j,ig,found=0;
-	IssmDouble     Jdet,u,v,w,um,vm,wm,vel;
-	IssmDouble     h,hx,hy,hz,vx,vy,vz;
-	IssmDouble     gravity,rho_ice,rho_water,kappa;
-	IssmDouble     heatcapacity,thermalconductivity,dt;
-	IssmDouble     tau_parameter,diameter;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     B_conduct[3][numdof];
-	IssmDouble     B_advec[3][numdof];
-	IssmDouble     Bprime_advec[3][numdof];
-	IssmDouble     L[numdof];
-	IssmDouble     dbasis[3][6];
-	IssmDouble     D_scalar_conduct,D_scalar_advec;
-	IssmDouble     D_scalar_trans,D_scalar_stab;
-	IssmDouble     D[3][3];
-	IssmDouble     K[3][3]={0.0};
+	int        i,j,found=0;
+	IssmDouble Jdet,u,v,w,um,vm,wm,vel;
+	IssmDouble h,hx,hy,hz,vx,vy,vz;
+	IssmDouble gravity,rho_ice,rho_water,kappa;
+	IssmDouble heatcapacity,thermalconductivity,dt;
+	IssmDouble tau_parameter,diameter;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble B_conduct[3][numdof];
+	IssmDouble B_advec[3][numdof];
+	IssmDouble Bprime_advec[3][numdof];
+	IssmDouble L[numdof];
+	IssmDouble dbasis[3][6];
+	IssmDouble D_scalar_conduct,D_scalar_advec;
+	IssmDouble D_scalar_trans,D_scalar_stab;
+	IssmDouble D[3][3];
+	IssmDouble K[3][3]={0.0};
 	Tria*      tria=NULL;
 	GaussPenta *gauss=NULL;
 
@@ -3598,7 +3654,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(2,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3703,19 +3759,18 @@
 /*FUNCTION Penta::CreateKMatrixThermalShelf {{{*/
 ElementMatrix* Penta::CreateKMatrixThermalShelf(void){
 
-
 	/*Constants*/
 	const int    numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries */
-	int       i,j,ig;
-	IssmDouble    mixed_layer_capacity,thermal_exchange_velocity;
-	IssmDouble    rho_ice,rho_water,heatcapacity;
-	IssmDouble    Jdet2d,dt;
-	IssmDouble    xyz_list[NUMVERTICES][3];
-	IssmDouble	 xyz_list_tria[NUMVERTICES2D][3];
-	IssmDouble    basis[NUMVERTICES];
-	IssmDouble    D_scalar;
+	int       i,j;
+	IssmDouble mixed_layer_capacity,thermal_exchange_velocity;
+	IssmDouble rho_ice,rho_water,heatcapacity;
+	IssmDouble Jdet2d,dt;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble basis[NUMVERTICES];
+	IssmDouble D_scalar;
 	GaussPenta *gauss=NULL;
 
 	/*Initialize Element matrix and return if necessary*/
@@ -3734,13 +3789,13 @@
 
 	/* Start looping on the number of gauss (nodes on the bedrock) */
 	gauss=new GaussPenta(0,1,2,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
-		
+
 		GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss);
 		GetNodalFunctionsP1(&basis[0], gauss);
-				
+
 		D_scalar=gauss->weight*Jdet2d*rho_water*mixed_layer_capacity*thermal_exchange_velocity/(heatcapacity*rho_ice);
 		if(reCast<bool,IssmDouble>(dt)) D_scalar=dt*D_scalar;
 
@@ -3749,7 +3804,7 @@
 					&basis[0],1,numdof,0,
 					&Ke->values[0],1);
 	}
-	
+
 	/*Clean up and return*/
 	delete gauss;
 	return Ke;
@@ -3778,7 +3833,7 @@
 	const int  numdof=NUMVERTICES*NDOF1;
 
 	/*Intermediaries*/
-	int    i,j,ig,found=0;
+	int    i,j,found=0;
 	int    friction_type,stabilization;
 	IssmDouble Jdet,phi,dt;
 	IssmDouble rho_ice,heatcapacity;
@@ -3821,7 +3876,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(2,3);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3874,14 +3929,14 @@
 	const int  numdof=NUMVERTICES*NDOF1;
 
 	/*Intermediaries */
-	int        i,j,ig;
-	IssmDouble     Jdet2d;
-	IssmDouble     heatcapacity,h_pmp;
-	IssmDouble     mixed_layer_capacity,thermal_exchange_velocity;
-	IssmDouble     rho_ice,rho_water,pressure,dt,scalar_ocean;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     xyz_list_tria[NUMVERTICES2D][3];
-	IssmDouble     basis[NUMVERTICES];
+	int        i,j;
+	IssmDouble Jdet2d;
+	IssmDouble heatcapacity,h_pmp;
+	IssmDouble mixed_layer_capacity,thermal_exchange_velocity;
+	IssmDouble rho_ice,rho_water,pressure,dt,scalar_ocean;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble basis[NUMVERTICES];
 	GaussPenta* gauss=NULL;
 
 	/* Ice/ocean heat exchange flux on ice shelf base */
@@ -3903,7 +3958,7 @@
 
 	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
 	gauss=new GaussPenta(0,1,2,2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3931,16 +3986,16 @@
 	const int  numdof=NUMVERTICES*NDOF1;
 
 	/*Intermediaries */
-	int        i,j,ig;
+	int        i,j;
 	int        analysis_type;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	IssmDouble     Jdet2d,dt;
-	IssmDouble     rho_ice,heatcapacity,geothermalflux_value;
-	IssmDouble     basalfriction,alpha2,vx,vy;
-	IssmDouble     scalar,enthalpy,enthalpyup;
-	IssmDouble     pressure,pressureup;
-	IssmDouble     basis[NUMVERTICES];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble Jdet2d,dt;
+	IssmDouble rho_ice,heatcapacity,geothermalflux_value;
+	IssmDouble basalfriction,alpha2,vx,vy;
+	IssmDouble scalar,enthalpy,enthalpyup;
+	IssmDouble pressure,pressureup;
+	IssmDouble basis[NUMVERTICES];
 	Friction*  friction=NULL;
 	GaussPenta* gauss=NULL;
 	GaussPenta* gaussup=NULL;
@@ -3971,7 +4026,7 @@
 	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
 	gauss=new GaussPenta(0,1,2,2);
 	gaussup=new GaussPenta(3,4,5,2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 		gaussup->GaussPoint(ig);
@@ -4041,7 +4096,7 @@
 	const int  numdof=NUMVERTICES*NDOF1;
 
 	/*Intermediaries*/
-	int    i,j,ig,found=0;
+	int    i,j,found=0;
 	int    friction_type,stabilization;
 	IssmDouble Jdet,phi,dt;
 	IssmDouble rho_ice,heatcapacity;
@@ -4077,7 +4132,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(2,3);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4128,14 +4183,14 @@
 	const int  numdof=NUMVERTICES*NDOF1;
 
 	/*Intermediaries */
-	int        i,j,ig;
-	IssmDouble     Jdet2d;
-	IssmDouble     mixed_layer_capacity,thermal_exchange_velocity;
-	IssmDouble     rho_ice,rho_water,pressure,dt,scalar_ocean;
-	IssmDouble     heatcapacity,t_pmp;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     xyz_list_tria[NUMVERTICES2D][3];
-	IssmDouble     basis[NUMVERTICES];
+	int        i,j;
+	IssmDouble Jdet2d;
+	IssmDouble mixed_layer_capacity,thermal_exchange_velocity;
+	IssmDouble rho_ice,rho_water,pressure,dt,scalar_ocean;
+	IssmDouble heatcapacity,t_pmp;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble basis[NUMVERTICES];
 	GaussPenta* gauss=NULL;
 
 	/* Ice/ocean heat exchange flux on ice shelf base */
@@ -4157,7 +4212,7 @@
 
 	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
 	gauss=new GaussPenta(0,1,2,2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4185,15 +4240,15 @@
 	const int  numdof=NUMVERTICES*NDOF1;
 
 	/*Intermediaries */
-	int        i,j,ig;
+	int        i,j;
 	int        analysis_type;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	IssmDouble     Jdet2d,dt;
-	IssmDouble     rho_ice,heatcapacity,geothermalflux_value;
-	IssmDouble     basalfriction,alpha2,vx,vy;
-	IssmDouble     basis[NUMVERTICES];
-	IssmDouble     scalar;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble Jdet2d,dt;
+	IssmDouble rho_ice,heatcapacity,geothermalflux_value;
+	IssmDouble basalfriction,alpha2,vx,vy;
+	IssmDouble basis[NUMVERTICES];
+	IssmDouble scalar;
 	Friction*  friction=NULL;
 	GaussPenta* gauss=NULL;
 
@@ -4220,7 +4275,7 @@
 
 	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
 	gauss=new GaussPenta(0,1,2,2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4409,7 +4464,7 @@
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
 	GetInputListOnVertices(&pressure[0],PressureEnum);
 	Input* surface_input=inputs->GetInput(SurfaceEnum); _assert_(surface_input);
-	
+
 	this->inputs->GetInputValue(&converged,ConvergedEnum);
 	if(converged){
 		/*Convert enthalpy into temperature and water fraction*/
@@ -4418,7 +4473,7 @@
 			if(waterfraction[i]<0) _error_("Negative water fraction found in solution vector");
 			//if(waterfraction[i]>1) _error_("Water fraction >1 found in solution vector");
 		}
-			
+
 		this->inputs->AddInput(new PentaP1Input(EnthalpyEnum,values));
 		this->inputs->AddInput(new PentaP1Input(WaterfractionEnum,waterfraction));
 		this->inputs->AddInput(new PentaP1Input(TemperatureEnum,temperatures));
@@ -4462,7 +4517,7 @@
 /*FUNCTION Penta::ControlInputGetGradient{{{*/
 void Penta::ControlInputGetGradient(Vector<IssmDouble>* gradient,int enum_type,int control_index){
 
-	int doflist1[NUMVERTICES];
+	int vertexpidlist[NUMVERTICES];
 	Input* input=NULL;
 
 	if(enum_type==MaterialsRheologyBbarEnum){
@@ -4473,15 +4528,15 @@
 		if(!IsOnBed()) return;
 		input=(Input*)material->inputs->GetInput(MaterialsRheologyZEnum);
 	}
-		
+
 	else{
 		input=inputs->GetInput(enum_type);
 	}
 	if (!input) _error_("Input " << EnumToStringx(enum_type) << " not found");
 	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
 
-	GradientIndexing(&doflist1[0],control_index);
-	((ControlInput*)input)->GetGradient(gradient,&doflist1[0]);
+	GradientIndexing(&vertexpidlist[0],control_index);
+	((ControlInput*)input)->GetGradient(gradient,&vertexpidlist[0]);
 
 }/*}}}*/
 /*FUNCTION Penta::ControlInputScaleGradient{{{*/
@@ -4506,7 +4561,7 @@
 /*FUNCTION Penta::ControlInputSetGradient{{{*/
 void Penta::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){
 
-	int    doflist1[NUMVERTICES];
+	int    vertexpidlist[NUMVERTICES];
 	IssmDouble grad_list[NUMVERTICES];
 	Input* grad_input=NULL;
 	Input* input=NULL;
@@ -4523,8 +4578,8 @@
 	if (!input) _error_("Input " << EnumToStringx(enum_type) << " not found");
 	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
 
-	GradientIndexing(&doflist1[0],control_index);
-	for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[doflist1[i]];
+	GradientIndexing(&vertexpidlist[0],control_index);
+	for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[vertexpidlist[i]];
 	grad_input=new PentaP1Input(GradientEnum,grad_list);
 	((ControlInput*)input)->SetGradient(grad_input);
 
@@ -4586,21 +4641,18 @@
 /*FUNCTION Penta::CreateKMatrixAdjointPattyn{{{*/
 ElementMatrix* Penta::CreateKMatrixAdjointPattyn(void){
 
-	/*Constants*/
-	const int    numdof=NDOF2*NUMVERTICES;
-
 	/*Intermediaries */
-	int        i,j,ig;
+	int        i,j;
 	bool       incomplete_adjoint;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     Jdet;
-	IssmDouble     eps1dotdphii,eps1dotdphij;
-	IssmDouble     eps2dotdphii,eps2dotdphij;
-	IssmDouble     mu_prime;
-	IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	IssmDouble     eps1[3],eps2[3];
-	IssmDouble     phi[NUMVERTICES];
-	IssmDouble     dphi[3][NUMVERTICES];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble Jdet;
+	IssmDouble eps1dotdphii,eps1dotdphij;
+	IssmDouble eps2dotdphii,eps2dotdphij;
+	IssmDouble mu_prime;
+	IssmDouble epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble eps1[3],eps2[3];
+	IssmDouble phi[NUMVERTICES];
+	IssmDouble dphi[3][NUMVERTICES];
 	GaussPenta *gauss=NULL;
 
 	/*Initialize Jacobian with regular Pattyn (first part of the Gateau derivative)*/
@@ -4615,7 +4667,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4658,18 +4710,17 @@
 	const int    numdof=NDOF4*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig;
+	int        i,j;
 	bool       incomplete_adjoint;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     Jdet;
-	IssmDouble     eps1dotdphii,eps1dotdphij;
-	IssmDouble     eps2dotdphii,eps2dotdphij;
-	IssmDouble     eps3dotdphii,eps3dotdphij;
-	IssmDouble     mu_prime;
-	IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	IssmDouble     eps1[3],eps2[3],eps3[3];
-	IssmDouble     phi[NUMVERTICES];
-	IssmDouble     dphi[3][NUMVERTICES];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble Jdet;
+	IssmDouble eps1dotdphii,eps1dotdphij;
+	IssmDouble eps2dotdphii,eps2dotdphij;
+	IssmDouble eps3dotdphii,eps3dotdphij;
+	IssmDouble mu_prime;
+	IssmDouble epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble eps1[3],eps2[3],eps3[3];
+	IssmDouble dphi[3][NUMVERTICES];
 	GaussPenta *gauss=NULL;
 
 	/*Initialize Jacobian with regular Stokes (first part of the Gateau derivative)*/
@@ -4685,7 +4736,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4801,7 +4852,7 @@
 
 	/*get gradient indices*/
 	for(int i=0;i<NUMVERTICES;i++){
-		indexing[i]=num_controls*this->nodes[i]->GetVertexDof() + control_index;
+		indexing[i]=num_controls*this->nodes[i]->GetVertexPid() + control_index;
 	}
 
 }
@@ -4912,26 +4963,26 @@
 /*FUNCTION Penta::GradjDragPattyn {{{*/
 void  Penta::GradjDragPattyn(Vector<IssmDouble>* gradient,int control_index){
 
-	int        i,j,ig;
+	int        i,j;
 	int        analysis_type;
-	int        doflist1[NUMVERTICES];
-	IssmDouble     vx,vy,lambda,mu,alpha_complement,Jdet;
-	IssmDouble     bed,thickness,Neff,drag;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	IssmDouble     dk[NDOF3]; 
-	IssmDouble     grade_g[NUMVERTICES]={0.0};
-	IssmDouble     grade_g_gaussian[NUMVERTICES];
-	IssmDouble     basis[6];
+	int        vertexpidlist[NUMVERTICES];
+	IssmDouble vx,vy,lambda,mu,alpha_complement,Jdet;
+	IssmDouble bed,thickness,Neff,drag;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble dk[NDOF3]; 
+	IssmDouble grade_g[NUMVERTICES]={0.0};
+	IssmDouble grade_g_gaussian[NUMVERTICES];
+	IssmDouble basis[6];
 	Friction*  friction=NULL;
-	GaussPenta  *gauss=NULL;
+	GaussPenta *gauss=NULL;
 
 	/*Gradient is 0 if on shelf or not on bed*/
 	if(IsFloating() || !IsOnBed()) return;
 
 	/*Retrieve all inputs and parameters*/
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
 	for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<2;j++) xyz_list_tria[i][j]=xyz_list[i][j];
 	Input* adjointx_input=inputs->GetInput(AdjointxEnum);               _assert_(adjointx_input);
@@ -4945,7 +4996,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(0,1,2,4);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4973,7 +5024,7 @@
 			grade_g[i]+=grade_g_gaussian[i];
 		}
 	}
-	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
+	gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
 	delete gauss;
@@ -4983,19 +5034,19 @@
 /*FUNCTION Penta::GradjDragStokes {{{*/
 void  Penta::GradjDragStokes(Vector<IssmDouble>* gradient,int control_index){
 
-	int        i,j,ig;
+	int        i,j;
 	int        analysis_type;
-	int        doflist1[NUMVERTICES];
-	IssmDouble     bed,thickness,Neff;
-	IssmDouble     lambda,mu,xi,Jdet,vx,vy,vz;
-	IssmDouble     alpha_complement,drag;
-	IssmDouble     surface_normal[3],bed_normal[3];
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	IssmDouble     dk[NDOF3]; 
-	IssmDouble     basis[6];
-	IssmDouble     grade_g[NUMVERTICES]={0.0};
-	IssmDouble     grade_g_gaussian[NUMVERTICES];
+	int        vertexpidlist[NUMVERTICES];
+	IssmDouble bed,thickness,Neff;
+	IssmDouble lambda,mu,xi,Jdet,vx,vy,vz;
+	IssmDouble alpha_complement,drag;
+	IssmDouble surface_normal[3],bed_normal[3];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble dk[NDOF3]; 
+	IssmDouble basis[6];
+	IssmDouble grade_g[NUMVERTICES]={0.0};
+	IssmDouble grade_g_gaussian[NUMVERTICES];
 	Friction*  friction=NULL;
 	GaussPenta* gauss=NULL;
 
@@ -5006,7 +5057,7 @@
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
 	for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<2;j++) xyz_list_tria[i][j]=xyz_list[i][j];
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 	Input* drag_input    =inputs->GetInput(FrictionCoefficientEnum); _assert_(drag_input);
 	Input* vx_input      =inputs->GetInput(VxEnum);                  _assert_(vx_input);
 	Input* vy_input      =inputs->GetInput(VyEnum);                  _assert_(vy_input);
@@ -5020,7 +5071,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(0,1,2,4);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -5066,7 +5117,7 @@
 		for( i=0; i<NUMVERTICES; i++)grade_g[i]+=grade_g_gaussian[i];
 	}
 
-	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
+	gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL);
 
 	delete friction;
 	delete gauss;
@@ -5493,13 +5544,13 @@
 /*FUNCTION Penta::GetVectorFromControlInputs{{{*/
 void  Penta::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data){
 
-	int doflist1[NUMVERTICES];
+	int vertexpidlist[NUMVERTICES];
 
 	/*Get out if this is not an element input*/
 	if(!IsInput(control_enum)) return;
 
 	/*Prepare index list*/
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 
 	/*Get input (either in element or material)*/
 	Input* input=inputs->GetInput(control_enum);
@@ -5510,14 +5561,14 @@
 		_error_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
 	}
 
-	((ControlInput*)input)->GetVectorFromInputs(vector,&doflist1[0],data);
+	((ControlInput*)input)->GetVectorFromInputs(vector,&vertexpidlist[0],data);
 }
 /*}}}*/
 /*FUNCTION Penta::SetControlInputsFromVector{{{*/
 void  Penta::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){
 
 	IssmDouble  values[NUMVERTICES];
-	int     doflist1[NUMVERTICES];
+	int     vertexpidlist[NUMVERTICES];
 	Input  *input     = NULL;
 	Input  *new_input = NULL;
 
@@ -5525,15 +5576,14 @@
 	if(!IsInput(control_enum)) return;
 
 	/*Prepare index list*/
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 
 	/*Get values on vertices*/
 	for (int i=0;i<NUMVERTICES;i++){
-		values[i]=vector[doflist1[i]];
+		values[i]=vector[vertexpidlist[i]];
 	}
 	new_input = new PentaP1Input(control_enum,values);
 
-
 	if(control_enum==MaterialsRheologyBbarEnum){
 		input=(Input*)material->inputs->GetInput(control_enum); _assert_(input);
 	}
@@ -5553,7 +5603,7 @@
 #ifdef _HAVE_DAKOTA_
 /*FUNCTION Penta::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);{{{*/
 void  Penta::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
-	
+
 	int i,j;
 
 	/*Check that name is an element input*/
@@ -5568,7 +5618,7 @@
 
 			/*Get values on the 6 vertices*/
 			for (i=0;i<6;i++){
-				values[i]=vector[this->nodes[i]->GetSidList()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!)
+				values[i]=vector[this->nodes[i]->GetVertexSid()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!)
 			}
 
 			/*Branch on the specified type of update: */
@@ -5580,7 +5630,7 @@
 					IssmDouble  hydrostatic_ratio[6];
 					IssmDouble  surface[6];
 					IssmDouble  bed[6];
-					
+
 					/*retrieve inputs: */
 					GetInputListOnVertices(&thickness_init[0],ThicknessEnum);
 					GetInputListOnVertices(&hydrostatic_ratio[0],GeometryHydrostaticRatioEnum);
@@ -5665,7 +5715,7 @@
 /*}}}*/
 /*FUNCTION Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type);{{{*/
 void  Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
-	
+
 	int i,j,t;
 	TransientInput* transientinput=NULL;
 	IssmDouble values[6];
@@ -5679,16 +5729,16 @@
 	switch(type){
 
 		case VertexEnum:
-			
+
 			/*Create transient input: */
-						
+
 			parameters->FindParam(&yts,ConstantsYtsEnum);
 
 			for(t=0;t<ncols;t++){ //ncols is the number of times
 
 				/*create input values: */
 				for(i=0;i<6;i++){
-					row=this->nodes[i]->GetSidList();
+					row=this->nodes[i]->GetVertexSid();
 					values[i]=(IssmDouble)matrix[ncols*row+t];
 				}
 
@@ -5752,12 +5802,12 @@
 /*}}}*/
 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattyn{{{*/
 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattyn(void){
-	
+
 	/*compute all stiffness matrices for this element*/
 	ElementMatrix* Ke1=CreateKMatrixCouplingMacAyealPattynViscous();
 	ElementMatrix* Ke2=CreateKMatrixCouplingMacAyealPattynFriction();
 	ElementMatrix* Ke=new ElementMatrix(Ke1,Ke2);
-	
+
 	/*clean-up and return*/
 	delete Ke1;
 	delete Ke2;
@@ -5774,17 +5824,17 @@
 	const int numdoftotal = 2 *NDOF2*NUMVERTICES;
 
 	/*Intermediaries */
-	int         i,j,ig;
-	IssmDouble      Jdet;
-	IssmDouble      viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
-	IssmDouble      epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	IssmDouble      xyz_list[NUMVERTICES][3];
-	IssmDouble      B[3][numdofp];
-	IssmDouble      Bprime[3][numdofm];
-	IssmDouble      D[3][3]={0.0};            // material matrix, simple scalar matrix.
-	IssmDouble      D_scalar;
-	IssmDouble      Ke_gg[numdofp][numdofm]={0.0}; //local element stiffness matrix 
-	IssmDouble      Ke_gg_gaussian[numdofp][numdofm]; //stiffness matrix evaluated at the gaussian point.
+	int         i,j;
+	IssmDouble  Jdet;
+	IssmDouble  viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
+	IssmDouble  epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble  xyz_list[NUMVERTICES][3];
+	IssmDouble  B[3][numdofp];
+	IssmDouble  Bprime[3][numdofm];
+	IssmDouble  D[3][3]={0.0};            // material matrix, simple scalar matrix.
+	IssmDouble  D_scalar;
+	IssmDouble  Ke_gg[numdofp][numdofm]={0.0}; //local element stiffness matrix 
+	IssmDouble  Ke_gg_gaussian[numdofp][numdofm]; //stiffness matrix evaluated at the gaussian point.
 	GaussPenta *gauss=NULL;
 	GaussTria  *gauss_tria=NULL;
 	Node       *node_list[numnodes];
@@ -5819,7 +5869,7 @@
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
 	gauss_tria=new GaussTria();
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 		gauss->SynchronizeGaussTria(gauss_tria);
@@ -5864,20 +5914,20 @@
 	const int numnodes    = 2 *NUMVERTICES;
 	const int numdof      = NDOF2 *NUMVERTICES;
 	const int numdoftotal = NDOF4 *NUMVERTICES;
-	
+
 	/*Intermediaries */
-	int       i,j,ig,analysis_type;
-	IssmDouble    Jdet2d,slope_magnitude,alpha2;
-	IssmDouble    xyz_list[NUMVERTICES][3];
-	IssmDouble    xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	IssmDouble    slope[3]={0.0,0.0,0.0};
-	IssmDouble    MAXSLOPE=.06; // 6 %
-	IssmDouble    MOUNTAINKEXPONENT=10;
-	IssmDouble    L[2][numdof];
-	IssmDouble    DL[2][2]                  ={{ 0,0 },{0,0}}; //for basal drag
-	IssmDouble    DL_scalar;
-	IssmDouble    Ke_gg[numdof][numdof]     ={0.0};
-	IssmDouble    Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag
+	int       i,j,analysis_type;
+	IssmDouble Jdet2d,slope_magnitude,alpha2;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble slope[3]={0.0,0.0,0.0};
+	IssmDouble MAXSLOPE=.06; // 6 %
+	IssmDouble MOUNTAINKEXPONENT=10;
+	IssmDouble L[2][numdof];
+	IssmDouble DL[2][2]                  ={{ 0,0 },{0,0}}; //for basal drag
+	IssmDouble DL_scalar;
+	IssmDouble Ke_gg[numdof][numdof]     ={0.0};
+	IssmDouble Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag
 	Friction  *friction = NULL;
 	GaussPenta *gauss=NULL;
 	Node       *node_list[numnodes];
@@ -5912,7 +5962,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(0,1,2,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -5933,7 +5983,7 @@
 
 		DL_scalar=alpha2*gauss->weight*Jdet2d;
 		for (i=0;i<2;i++) DL[i][i]=DL_scalar; 
-		
+
 		/*  Do the triple producte tL*D*L: */
 		TripleMultiply( &L[0][0],2,numdof,1,
 					&DL[0][0],2,2,0,
@@ -5979,22 +6029,22 @@
 	const int numdoftotal = 2 *numdofm+numdofs;
 
 	/*Intermediaries */
-	int         i,j,ig;
-	IssmDouble      Jdet;
-	IssmDouble      viscosity,stokesreconditioning; //viscosity
-	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	IssmDouble      xyz_list[NUMVERTICES][3];
-	IssmDouble      B[4][numdofs+3];
-	IssmDouble      Bprime[4][numdofm];
-	IssmDouble      B2[3][numdofm];
-	IssmDouble      Bprime2[3][numdofs+3];
-	IssmDouble      D[4][4]={0.0};            // material matrix, simple scalar matrix.
-	IssmDouble      D2[3][3]={0.0};            // material matrix, simple scalar matrix.
-	IssmDouble      D_scalar;
-	IssmDouble      Ke_gg[numdofs][numdofm]={0.0}; //local element stiffness matrix 
-	IssmDouble      Ke_gg2[numdofm][numdofs]={0.0}; //local element stiffness matrix 
-	IssmDouble      Ke_gg_gaussian[numdofs+3][numdofm]; //stiffness matrix evaluated at the gaussian point.
-	IssmDouble      Ke_gg_gaussian2[numdofm][numdofs+3]; //stiffness matrix evaluated at the gaussian point.
+	int         i,j;
+	IssmDouble Jdet;
+	IssmDouble viscosity,stokesreconditioning; //viscosity
+	IssmDouble epsilon[6]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble B[4][numdofs+3];
+	IssmDouble Bprime[4][numdofm];
+	IssmDouble B2[3][numdofm];
+	IssmDouble Bprime2[3][numdofs+3];
+	IssmDouble D[4][4]={0.0};            // material matrix, simple scalar matrix.
+	IssmDouble D2[3][3]={0.0};            // material matrix, simple scalar matrix.
+	IssmDouble D_scalar;
+	IssmDouble Ke_gg[numdofs][numdofm]={0.0}; //local element stiffness matrix 
+	IssmDouble Ke_gg2[numdofm][numdofs]={0.0}; //local element stiffness matrix 
+	IssmDouble Ke_gg_gaussian[numdofs+3][numdofm]; //stiffness matrix evaluated at the gaussian point.
+	IssmDouble Ke_gg_gaussian2[numdofm][numdofs+3]; //stiffness matrix evaluated at the gaussian point.
 	GaussPenta *gauss=NULL;
 	GaussTria  *gauss_tria=NULL;
 	Node       *node_list[numnodes];
@@ -6028,7 +6078,7 @@
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
 	gauss_tria=new GaussTria();
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 		gauss->SynchronizeGaussTria(gauss_tria);
@@ -6085,22 +6135,22 @@
 	const int numdoftot = numdof+numdofm;
 
 	/*Intermediaries */
-	int        i,j,ig;
+	int        i,j;
 	int        analysis_type,approximation;
-	IssmDouble     stokesreconditioning;
-	IssmDouble     viscosity,alpha2_gauss,Jdet2d;
-	IssmDouble	  bed_normal[3];
-	IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble	  xyz_list_tria[NUMVERTICES2D][3];
-	IssmDouble     LMacAyealStokes[8][numdof2dm];
-	IssmDouble     LprimeMacAyealStokes[8][numdof2d];
-	IssmDouble     DLMacAyealStokes[8][8]={0.0};
-	IssmDouble     LStokesMacAyeal[4][numdof2d];
-	IssmDouble     LprimeStokesMacAyeal[4][numdof2dm];
-	IssmDouble     DLStokesMacAyeal[4][4]={0.0};
-	IssmDouble     Ke_drag_gaussian[numdof2dm][numdof2d];
-	IssmDouble     Ke_drag_gaussian2[numdof2d][numdof2dm];
+	IssmDouble stokesreconditioning;
+	IssmDouble viscosity,alpha2_gauss,Jdet2d;
+	IssmDouble bed_normal[3];
+	IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble LMacAyealStokes[8][numdof2dm];
+	IssmDouble LprimeMacAyealStokes[8][numdof2d];
+	IssmDouble DLMacAyealStokes[8][8]={0.0};
+	IssmDouble LStokesMacAyeal[4][numdof2d];
+	IssmDouble LprimeStokesMacAyeal[4][numdof2dm];
+	IssmDouble DLStokesMacAyeal[4][4]={0.0};
+	IssmDouble Ke_drag_gaussian[numdof2dm][numdof2d];
+	IssmDouble Ke_drag_gaussian2[numdof2d][numdof2dm];
 	Friction*  friction=NULL;
 	GaussPenta *gauss=NULL;
 	Node       *node_list[numnodes];
@@ -6136,7 +6186,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(0,1,2,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -6165,7 +6215,7 @@
 		DLStokesMacAyeal[1][1]=alpha2_gauss*gauss->weight*Jdet2d;
 		DLStokesMacAyeal[2][2]=-alpha2_gauss*gauss->weight*Jdet2d*bed_normal[0]*bed_normal[2];
 		DLStokesMacAyeal[3][3]=-alpha2_gauss*gauss->weight*Jdet2d*bed_normal[1]*bed_normal[2];
-		
+
 		TripleMultiply( &LMacAyealStokes[0][0],8,numdof2dm,1,
 					&DLMacAyealStokes[0][0],8,8,0,
 					&LprimeMacAyealStokes[0][0],8,numdof2d,0,
@@ -6386,7 +6436,7 @@
 	const int    numdof2d=2*NUMVERTICES2D;
 
 	/*Intermediaries */
-	int         i,j,ig,approximation;
+	int         i,j,approximation;
 	IssmDouble  Jdet;
 	IssmDouble  viscosity , oldviscosity, newviscosity, viscosity_overshoot;
 	IssmDouble  epsilon[5],oldepsilon[5];       /* epsilon=[exx,eyy,exy,exz,eyz];*/
@@ -6422,7 +6472,7 @@
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
 	gauss_tria=new GaussTria();
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 		gauss->SynchronizeGaussTria(gauss_tria);
@@ -6637,16 +6687,16 @@
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig;
+	int        i,j;
 	int        approximation;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     Jdet;
-	IssmDouble     viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
-	IssmDouble     epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	IssmDouble     D_scalar;
-	IssmDouble     D[5][5]={0.0};            // material matrix, simple scalar matrix.
-	IssmDouble     B[5][numdof];
-	IssmDouble     Bprime[5][numdof];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble Jdet;
+	IssmDouble viscosity,oldviscosity,newviscosity,viscosity_overshoot; //viscosity
+	IssmDouble epsilon[5],oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble D_scalar;
+	IssmDouble D[5][5]={0.0};            // material matrix, simple scalar matrix.
+	IssmDouble B[5][numdof];
+	IssmDouble Bprime[5][numdof];
 	Tria*      tria=NULL;
 	GaussPenta *gauss=NULL;
 
@@ -6664,7 +6714,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -6700,19 +6750,19 @@
 
 	/*Constants*/
 	const int numdof   = NDOF2*NUMVERTICES;
-	
+
 	/*Intermediaries */
-	int       i,j,ig;
+	int       i,j;
 	int       analysis_type;
-	IssmDouble    xyz_list[NUMVERTICES][3];
-	IssmDouble    xyz_list_tria[NUMVERTICES2D][3]={0.0};
-	IssmDouble    slope_magnitude,alpha2,Jdet;
-	IssmDouble    slope[3]={0.0,0.0,0.0};
-	IssmDouble    MAXSLOPE=.06; // 6 %
-	IssmDouble    MOUNTAINKEXPONENT=10;
-	IssmDouble    L[2][numdof];
-	IssmDouble    DL[2][2]={{ 0,0 },{0,0}}; //for basal drag
-	IssmDouble    DL_scalar;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3]={0.0};
+	IssmDouble slope_magnitude,alpha2,Jdet;
+	IssmDouble slope[3]={0.0,0.0,0.0};
+	IssmDouble MAXSLOPE=.06; // 6 %
+	IssmDouble MOUNTAINKEXPONENT=10;
+	IssmDouble L[2][numdof];
+	IssmDouble DL[2][2]={{ 0,0 },{0,0}}; //for basal drag
+	IssmDouble DL_scalar;
 	Friction  *friction = NULL;
 	GaussPenta *gauss=NULL;
 
@@ -6735,7 +6785,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(0,1,2,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -6751,10 +6801,10 @@
 		if (slope_magnitude>MAXSLOPE){
 			alpha2=pow((IssmDouble)10,MOUNTAINKEXPONENT);
 		}
-		
+
 		DL_scalar=alpha2*gauss->weight*Jdet;
 		for (i=0;i<2;i++) DL[i][i]=DL_scalar;
-		
+
 		TripleMultiply( &L[0][0],2,numdof,1,
 					&DL[0][0],2,2,0,
 					&L[0][0],2,numdof,0,
@@ -6804,15 +6854,15 @@
 ElementMatrix* Penta::CreateKMatrixDiagnosticStokesViscous(void){
 
 	/*Intermediaries */
-	int        i,j,ig,approximation;
-	IssmDouble     Jdet,viscosity,stokesreconditioning;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	IssmDouble     B[8][27];
-	IssmDouble     B_prime[8][27];
-	IssmDouble     D_scalar;
-	IssmDouble     D[8][8]={0.0};
-	IssmDouble     Ke_temp[27][27]={0.0}; //for the six nodes and the bubble 
+	int        i,approximation;
+	IssmDouble Jdet,viscosity,stokesreconditioning;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble B[8][27];
+	IssmDouble B_prime[8][27];
+	IssmDouble D_scalar;
+	IssmDouble D[8][8]={0.0};
+	IssmDouble Ke_temp[27][27]={0.0}; //for the six nodes and the bubble 
 	GaussPenta *gauss=NULL;
 
 	/*If on water or not Stokes, skip stiffness: */
@@ -6829,7 +6879,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -6869,16 +6919,16 @@
 	const int numdof2d=NUMVERTICES2D*NDOF4;
 
 	/*Intermediaries */
-	int        i,j,ig;
+	int        i,j;
 	int        analysis_type,approximation;
-	IssmDouble     alpha2,Jdet2d;
-	IssmDouble     stokesreconditioning,viscosity;
-	IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble	  xyz_list_tria[NUMVERTICES2D][3];
-	IssmDouble     LStokes[2][numdof2d];
-	IssmDouble     DLStokes[2][2]={0.0};
-	IssmDouble     Ke_drag_gaussian[numdof2d][numdof2d];
+	IssmDouble alpha2,Jdet2d;
+	IssmDouble stokesreconditioning,viscosity;
+	IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble LStokes[2][numdof2d];
+	IssmDouble DLStokes[2][2]={0.0};
+	IssmDouble Ke_drag_gaussian[numdof2d][numdof2d];
 	Friction*  friction=NULL;
 	GaussPenta *gauss=NULL;
 
@@ -6901,7 +6951,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(0,1,2,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -6926,7 +6976,7 @@
 
 	/*DO NOT Transform Coordinate System: this stiffness matrix is already expressed in tangential coordinates*/
 	//TransformStiffnessMatrixCoord(Ke,nodes,NUMVERTICES,XYZPEnum);
-	
+
 	/*Clean up and return*/
 	delete gauss;
 	delete friction;
@@ -6935,7 +6985,7 @@
 /*}}}*/
 /*FUNCTION Penta::CreateKMatrixDiagnosticVert {{{*/
 ElementMatrix* Penta::CreateKMatrixDiagnosticVert(void){
-	
+
 	/*compute all stiffness matrices for this element*/
 	ElementMatrix* Ke1=CreateKMatrixDiagnosticVertVolume();
 	ElementMatrix* Ke2=CreateKMatrixDiagnosticVertSurface();
@@ -6955,12 +7005,11 @@
 	const int    numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries */
-	int         i,j,ig;
-	IssmDouble      Jdet;
-	IssmDouble      xyz_list[NUMVERTICES][3];
-	IssmDouble      B[NDOF1][NUMVERTICES];
-	IssmDouble      Bprime[NDOF1][NUMVERTICES];
-	IssmDouble      DL_scalar;
+	IssmDouble  Jdet;
+	IssmDouble  xyz_list[NUMVERTICES][3];
+	IssmDouble  B[NDOF1][NUMVERTICES];
+	IssmDouble  Bprime[NDOF1][NUMVERTICES];
+	IssmDouble  DL_scalar;
 	GaussPenta  *gauss=NULL;
 
 	/*Initialize Element matrix*/
@@ -6971,7 +7020,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(2,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -7001,12 +7050,12 @@
 	const int numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries */
-	int       i,j,ig;
-	IssmDouble    xyz_list[NUMVERTICES][3];
-	IssmDouble    xyz_list_tria[NUMVERTICES2D][3];
-	IssmDouble    surface_normal[3];
-	IssmDouble    Jdet2d,DL_scalar;
-	IssmDouble    basis[NUMVERTICES];
+	int       i,j;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble surface_normal[3];
+	IssmDouble Jdet2d,DL_scalar;
+	IssmDouble basis[NUMVERTICES];
 	GaussPenta *gauss=NULL;
 
 	/*Initialize Element matrix*/
@@ -7019,7 +7068,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(3,4,5,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -7060,15 +7109,15 @@
 	const int   numdof=NUMVERTICES*NDOF4;
 
 	/*Intermediaries */
-	int         i,j,ig;
+	int         i,j;
 	int         approximation;
-	IssmDouble      viscosity,Jdet;
-	IssmDouble      stokesreconditioning;
-	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	IssmDouble      dw[3];
-	IssmDouble      xyz_list[NUMVERTICES][3];
-	IssmDouble      basis[6]; //for the six nodes of the penta
-	IssmDouble      dbasis[3][6]; //for the six nodes of the penta
+	IssmDouble  viscosity,Jdet;
+	IssmDouble  stokesreconditioning;
+	IssmDouble  epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble  dw[3];
+	IssmDouble  xyz_list[NUMVERTICES][3];
+	IssmDouble  basis[6]; //for the six nodes of the penta
+	IssmDouble  dbasis[3][6]; //for the six nodes of the penta
 	GaussPenta *gauss=NULL;
 
 	/*Initialize Element vector and return if necessary*/
@@ -7086,7 +7135,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -7122,17 +7171,17 @@
 	const int numdof=NUMVERTICES*NDOF4;
 
 	/*Intermediaries*/
-	int         i,j,ig;
+	int         i,j;
 	int         approximation,analysis_type;
-	IssmDouble      Jdet,Jdet2d;
-	IssmDouble      stokesreconditioning;
-	IssmDouble	   bed_normal[3];
-	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	IssmDouble      viscosity, w, alpha2_gauss;
-	IssmDouble      dw[3];
-	IssmDouble	   xyz_list_tria[NUMVERTICES2D][3];
-	IssmDouble      xyz_list[NUMVERTICES][3];
-	IssmDouble      basis[6]; //for the six nodes of the penta
+	IssmDouble  Jdet,Jdet2d;
+	IssmDouble  stokesreconditioning;
+	IssmDouble	bed_normal[3];
+	IssmDouble  epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble  viscosity, w, alpha2_gauss;
+	IssmDouble  dw[3];
+	IssmDouble	xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble  xyz_list[NUMVERTICES][3];
+	IssmDouble  basis[6]; //for the six nodes of the penta
 	Tria*       tria=NULL;
 	Friction*   friction=NULL;
 	GaussPenta  *gauss=NULL;
@@ -7159,7 +7208,7 @@
 
 	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
 	gauss=new GaussPenta(0,1,2,2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -7211,15 +7260,15 @@
 	const int   numdof=NUMVERTICES*NDOF4;
 
 	/*Intermediaries */
-	int         i,j,ig;
+	int         i;
 	int         approximation;
-	IssmDouble      viscosity,Jdet;
-	IssmDouble      stokesreconditioning;
-	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	IssmDouble      dw[3];
-	IssmDouble      xyz_list[NUMVERTICES][3];
-	IssmDouble      basis[6]; //for the six nodes of the penta
-	IssmDouble      dbasis[3][6]; //for the six nodes of the penta
+	IssmDouble  viscosity,Jdet;
+	IssmDouble  stokesreconditioning;
+	IssmDouble  epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble  dw[3];
+	IssmDouble  xyz_list[NUMVERTICES][3];
+	IssmDouble  basis[6]; //for the six nodes of the penta
+	IssmDouble  dbasis[3][6]; //for the six nodes of the penta
 	GaussPenta *gauss=NULL;
 
 	/*Initialize Element vector and return if necessary*/
@@ -7237,7 +7286,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -7273,17 +7322,17 @@
 	const int numdof=NUMVERTICES*NDOF4;
 
 	/*Intermediaries*/
-	int         i,j,ig;
+	int         i,j;
 	int         approximation,analysis_type;
-	IssmDouble      Jdet,Jdet2d;
-	IssmDouble      stokesreconditioning;
-	IssmDouble	   bed_normal[3];
-	IssmDouble      epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	IssmDouble      viscosity, w, alpha2_gauss;
-	IssmDouble      dw[3];
-	IssmDouble	   xyz_list_tria[NUMVERTICES2D][3];
-	IssmDouble      xyz_list[NUMVERTICES][3];
-	IssmDouble      basis[6]; //for the six nodes of the penta
+	IssmDouble  Jdet,Jdet2d;
+	IssmDouble  stokesreconditioning;
+	IssmDouble	bed_normal[3];
+	IssmDouble  epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble  viscosity, w, alpha2_gauss;
+	IssmDouble  dw[3];
+	IssmDouble	xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble  xyz_list[NUMVERTICES][3];
+	IssmDouble  basis[6]; //for the six nodes of the penta
 	Tria*       tria=NULL;
 	Friction*   friction=NULL;
 	GaussPenta  *gauss=NULL;
@@ -7310,7 +7359,7 @@
 
 	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
 	gauss=new GaussPenta(0,1,2,2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -7420,21 +7469,18 @@
 /*FUNCTION Penta::CreatePVectorDiagnosticHutter{{{*/
 ElementVector* Penta::CreatePVectorDiagnosticHutter(void){
 
-	/*Constants*/
-	const int numdofs=NDOF2*NUMVERTICES;
-
 	/*Intermediaries*/
-	int          i,j,k,ig;
+	int          i,j;
 	int          node0,node1;
 	int          connectivity[2];
-	IssmDouble       Jdet;
-	IssmDouble       xyz_list[NUMVERTICES][3];
-	IssmDouble       xyz_list_segment[2][3];
-	IssmDouble       z_list[NUMVERTICES];
-	IssmDouble       z_segment[2],slope[2];
-	IssmDouble       slope2,constant_part;
-	IssmDouble       rho_ice,gravity,n,B;
-	IssmDouble       ub,vb,z_g,surface,thickness;
+	IssmDouble   Jdet;
+	IssmDouble   xyz_list[NUMVERTICES][3];
+	IssmDouble   xyz_list_segment[2][3];
+	IssmDouble   z_list[NUMVERTICES];
+	IssmDouble   slope[2];
+	IssmDouble   slope2,constant_part;
+	IssmDouble   rho_ice,gravity,n,B;
+	IssmDouble   ub,vb,z_g,surface,thickness;
 	GaussPenta*  gauss=NULL;
 
 	/*Initialize Element vector*/
@@ -7467,7 +7513,7 @@
 
 		/*Loop on the Gauss points: */
 		gauss=new GaussPenta(node0,node1,3);
-		for(ig=gauss->begin();ig<gauss->end();ig++){
+		for(int ig=gauss->begin();ig<gauss->end();ig++){
 			gauss->GaussPoint(ig);
 
 			slopex_input->GetInputValue(&slope[0],gauss);
@@ -7540,12 +7586,12 @@
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	/*Intermediaries*/
-	int         i,j,ig;
-	IssmDouble      Jdet;
-	IssmDouble      slope[3]; //do not put 2! this goes into GetInputDerivativeValue, which addresses slope[3] also!
-	IssmDouble      driving_stress_baseline,thickness;
-	IssmDouble      xyz_list[NUMVERTICES][3];
-	IssmDouble      basis[6];
+	int         i,j;
+	IssmDouble  Jdet;
+	IssmDouble  slope[3]; //do not put 2! this goes into GetInputDerivativeValue, which addresses slope[3] also!
+	IssmDouble  driving_stress_baseline,thickness;
+	IssmDouble  xyz_list[NUMVERTICES][3];
+	IssmDouble  basis[6];
 	GaussPenta  *gauss=NULL;
 
 	/*Initialize Element vector*/
@@ -7558,7 +7604,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(2,3);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -7602,21 +7648,20 @@
 	const int numdofbubble=NDOF4*NUMVERTICES+NDOF3*1;
 
 	/*Intermediaries*/
-	int        i,j,ig;
+	int        i,j;
 	int        approximation;
-	IssmDouble     Jdet,viscosity;
-	IssmDouble     gravity,rho_ice,stokesreconditioning;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
-	IssmDouble     l1l7[7]; //for the six nodes and the bubble 
-	IssmDouble     B[8][numdofbubble];
-	IssmDouble     B_prime[8][numdofbubble];
-	IssmDouble     B_prime_bubble[8][3];
-	IssmDouble     D[8][8]={0.0};
-	IssmDouble     D_scalar;
-	IssmDouble     Pe_gaussian[numdofbubble]={0.0}; //for the six nodes and the bubble 
-	IssmDouble     Ke_temp[numdofbubble][3]={0.0}; //for the six nodes and the bubble 
-	IssmDouble     Ke_gaussian[numdofbubble][3];
+	IssmDouble Jdet,viscosity;
+	IssmDouble gravity,rho_ice,stokesreconditioning;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/
+	IssmDouble l1l7[7]; //for the six nodes and the bubble 
+	IssmDouble B[8][numdofbubble];
+	IssmDouble B_prime[8][numdofbubble];
+	IssmDouble B_prime_bubble[8][3];
+	IssmDouble D[8][8]={0.0};
+	IssmDouble D_scalar;
+	IssmDouble Pe_gaussian[numdofbubble]={0.0}; //for the six nodes and the bubble 
+	IssmDouble Ke_temp[numdofbubble][3]={0.0}; //for the six nodes and the bubble 
 	GaussPenta *gauss=NULL;
 
 	/*Initialize Element vector and return if necessary*/
@@ -7635,7 +7680,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -7679,16 +7724,16 @@
 ElementVector* Penta::CreatePVectorDiagnosticStokesShelf(void){
 
 	/*Intermediaries*/
-	int         i,j,ig;
+	int         i,j;
 	int         approximation,shelf_dampening;
-	IssmDouble      gravity,rho_water,bed,water_pressure;
-	IssmDouble      damper,normal_vel,vx,vy,vz,dt;
-	IssmDouble		xyz_list_tria[NUMVERTICES2D][3];
-	IssmDouble      xyz_list[NUMVERTICES][3];
-	IssmDouble		bed_normal[3];
-	IssmDouble      dz[3];
-	IssmDouble      basis[6]; //for the six nodes of the penta
-	IssmDouble      Jdet2d;
+	IssmDouble  gravity,rho_water,bed,water_pressure;
+	IssmDouble  damper,normal_vel,vx,vy,vz,dt;
+	IssmDouble	xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble  xyz_list[NUMVERTICES][3];
+	IssmDouble	bed_normal[3];
+	IssmDouble  dz[3];
+	IssmDouble  basis[6]; //for the six nodes of the penta
+	IssmDouble  Jdet2d;
 	GaussPenta  *gauss=NULL;
 
 	/*Initialize Element vector and return if necessary*/
@@ -7711,7 +7756,7 @@
 
 	/* Start looping on the number of gauss 2d (nodes on the bedrock) */
 	gauss=new GaussPenta(0,1,2,2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -7764,7 +7809,6 @@
 	const int  numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries*/
-	int        i,ig;
 	int        approximation;
 	IssmDouble     Jdet;
 	IssmDouble     xyz_list[NUMVERTICES][3];
@@ -7788,7 +7832,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(2,2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -7805,7 +7849,7 @@
 		dudx=du[0];
 		dvdy=dv[1];
 
-		for (i=0;i<numdof;i++) pe->values[i] += (dudx+dvdy+dwdz)*Jdet*gauss->weight*basis[i];
+		for(int i=0;i<numdof;i++) pe->values[i] += (dudx+dvdy+dwdz)*Jdet*gauss->weight*basis[i];
 	}
 
 	/*Clean up and return*/
@@ -7816,19 +7860,18 @@
 /*FUNCTION Penta::CreatePVectorDiagnosticVertBase {{{*/
 ElementVector* Penta::CreatePVectorDiagnosticVertBase(void){
 
-
 	/*Constants*/
 	const int    numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig;
+	int        i,j;
 	int        approximation;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     xyz_list_tria[NUMVERTICES2D][3];
-	IssmDouble     Jdet2d;
-	IssmDouble     vx,vy,vz,dbdx,dbdy,basalmeltingvalue;
-	IssmDouble     slope[3];
-	IssmDouble     basis[NUMVERTICES];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble xyz_list_tria[NUMVERTICES2D][3];
+	IssmDouble Jdet2d;
+	IssmDouble vx,vy,vz,dbdx,dbdy,basalmeltingvalue;
+	IssmDouble slope[3];
+	IssmDouble basis[NUMVERTICES];
 	GaussPenta* gauss=NULL;
 
 	if (!IsOnBed()) return NULL;
@@ -7851,7 +7894,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(0,1,2,2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -7939,16 +7982,15 @@
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     Jdet;
-	IssmDouble     eps1dotdphii,eps1dotdphij;
-	IssmDouble     eps2dotdphii,eps2dotdphij;
-	IssmDouble     mu_prime;
-	IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	IssmDouble     eps1[3],eps2[3];
-	IssmDouble     phi[NUMVERTICES];
-	IssmDouble     dphi[3][NUMVERTICES];
+	int        i,j;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble Jdet;
+	IssmDouble eps1dotdphii,eps1dotdphij;
+	IssmDouble eps2dotdphii,eps2dotdphij;
+	IssmDouble mu_prime;
+	IssmDouble epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble eps1[3],eps2[3];
+	IssmDouble dphi[3][NUMVERTICES];
 	GaussPenta *gauss=NULL;
 
 	/*Initialize Jacobian with regular Pattyn (first part of the Gateau derivative)*/
@@ -7961,7 +8003,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -8004,17 +8046,16 @@
 	const int    numdof=NDOF4*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     Jdet;
-	IssmDouble     eps1dotdphii,eps1dotdphij;
-	IssmDouble     eps2dotdphii,eps2dotdphij;
-	IssmDouble     eps3dotdphii,eps3dotdphij;
-	IssmDouble     mu_prime;
-	IssmDouble     epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
-	IssmDouble     eps1[3],eps2[3],eps3[3];
-	IssmDouble     phi[NUMVERTICES];
-	IssmDouble     dphi[3][NUMVERTICES];
+	int        i,j;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble Jdet;
+	IssmDouble eps1dotdphii,eps1dotdphij;
+	IssmDouble eps2dotdphii,eps2dotdphij;
+	IssmDouble eps3dotdphii,eps3dotdphij;
+	IssmDouble mu_prime;
+	IssmDouble epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
+	IssmDouble eps1[3],eps2[3],eps3[3];
+	IssmDouble dphi[3][NUMVERTICES];
 	GaussPenta *gauss=NULL;
 
 	/*Initialize Jacobian with regular Stokes (first part of the Gateau derivative)*/
@@ -8028,7 +8069,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussPenta(5,5);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -8415,7 +8456,7 @@
 		/* get upper Penta*/
 		penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id);
 	}
-	
+
 	/*Free ressources:*/
 	xDelete<int>(doflist);
 }
@@ -8687,7 +8728,7 @@
 /*}}}*/
 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattyn {{{*/
 void  Penta::InputUpdateFromSolutionDiagnosticPattyn(IssmDouble* solution){
-	
+
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	int    i;
@@ -8855,7 +8896,7 @@
 /*}}}*/
 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHutter {{{*/
 void  Penta::InputUpdateFromSolutionDiagnosticHutter(IssmDouble* solution){
-	
+
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	int     i;
@@ -8920,7 +8961,7 @@
 void  Penta::InputUpdateFromSolutionDiagnosticVert(IssmDouble* solution){
 
 	const int numdof=NDOF1*NUMVERTICES;
-	
+
 	int      i;
 	int      approximation;
 	IssmDouble   rho_ice,g;
@@ -8937,7 +8978,6 @@
 	IssmDouble   xyz_list[NUMVERTICES][3];
 	int*     doflist      = NULL;
 
-
 	/*Get the approximation and do nothing if the element in Stokes or None*/
 	inputs->GetInputValue(&approximation,ApproximationEnum);
 	if(approximation==StokesApproximationEnum || approximation==NoneApproximationEnum){
@@ -9022,7 +9062,7 @@
 /*}}}*/
 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticStokes {{{*/
 void  Penta::InputUpdateFromSolutionDiagnosticStokes(IssmDouble* solution){
-	
+
 	const int numdof=NDOF4*NUMVERTICES;
 
 	int     i;
@@ -9062,7 +9102,7 @@
 	this->parameters->FindParam(&stokesreconditioning,DiagnosticStokesreconditioningEnum);
 	for(i=0;i<NUMVERTICES;i++) pressure[i]=pressure[i]*stokesreconditioning;
 	for(i=0;i<NUMVERTICES;i++) vel[i]=pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5);
-	
+
 	/*Now, we have to move the previous inputs  to old 
 	 * status, otherwise, we'll wipe them off: */
 	this->inputs->ChangeEnum(VxEnum,VxPicardEnum);
@@ -9132,4 +9172,3 @@
 }
 /*}}}*/
 #endif
-

Modified: issm/trunk/src/c/classes/objects/Elements/Penta.h
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/Penta.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/Penta.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -33,15 +33,15 @@
 		int          id;
 		int          sid;
 
-		Node       **nodes;        // 6 nodes
-		Material    *material;       // 1 material ice
-		Matpar      *matpar;       // 1 material parameter
-		Penta      **verticalneighbors;   // 2 neighbors: first one under, second one above
+		Node       **nodes;                       // 6 nodes
+		Material    *material;                    // 1 material ice
+		Matpar      *matpar;                      // 1 material parameter
+		Penta      **verticalneighbors;           // 2 neighbors: first one under, second one above
 		int          horizontalneighborsids[3];
 
-		Parameters  *parameters;   //pointer to solution parameters
+		Parameters  *parameters;                  //pointer to solution parameters
 		Inputs      *inputs;
-		Results      *results;
+		Results     *results;
 
 		/*Penta constructors and destructor: {{{*/
 		Penta();
@@ -49,12 +49,11 @@
 		~Penta();
 		/*}}}*/
 		/*Object virtual functions definitions: {{{*/
-		Object*   copy();
-		void	  DeepEcho();
-		void	  Echo();
-		int		  ObjectEnum();
-		int		  Id(); 
-		int		  MyRank();
+		Object *copy();
+		void    DeepEcho();
+		void    Echo();
+		int     ObjectEnum();
+		int     Id();
 		/*}}}*/
 		/*Update virtual functions definitions: {{{*/
 		void  InputUpdateFromConstant(bool constant, int name);
@@ -80,17 +79,20 @@
 		void   ComputeStressTensor();
 		void   Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
 		void   SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
+		void   SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
 		void   CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,Vector<IssmDouble>* df);
 		void   CreatePVector(Vector<IssmDouble>* pf);
 		void   CreateJacobianMatrix(Matrix<IssmDouble>* Jff);
 		void   Delta18oParameterization(void);
 		void   DeleteResults(void);
 		int    GetNodeIndex(Node* node);
+		void   GetNodesSidList(int* sidlist);
+		int    GetNumberOfNodes(void);
 		void   GetSolutionFromInputs(Vector<IssmDouble>* solution);
 		IssmDouble GetZcoord(GaussPenta* gauss);
 		void   GetVectorFromInputs(Vector<IssmDouble>* vector,int name_enum);
 		void   GetVectorFromResults(Vector<IssmDouble>* vector,int offset,int name_enum,int interp);
-		
+
 		int    Sid();
 		void   InputArtificialNoise(int enum_type,IssmDouble min, IssmDouble max);
 		bool   InputConvergence(IssmDouble* eps, int* enums,int num_enums,int* criterionenums,IssmDouble* criterionvalues,int num_criterionenums);
@@ -99,7 +101,7 @@
 		void   InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum=MeshElementsEnum);
 		void   InputDuplicate(int original_enum,int new_enum);
 		void   InputScale(int enum_type,IssmDouble scale_factor);
-		
+
 		void   InputToResult(int enum_type,int step,IssmDouble time);
 		void   MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding);
 		void   PotentialSheetUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding);
@@ -173,8 +175,8 @@
 		ElementVector* CreatePVectorPrognostic(void);
 		ElementVector* CreatePVectorSlope(void);
 		void	  GetDofList(int** pdoflist,int approximation_enum,int setenum);
-		void	  GetDofList1(int* doflist);
-		void    GetSidList(int* sidlist);
+		void	  GetVertexPidList(int* doflist);
+		void    GetVertexSidList(int* sidlist);
 		void    GetConnectivityList(int* connectivity);
 		int     GetElementType(void);
 		void    GetElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz);

Modified: issm/trunk/src/c/classes/objects/Elements/PentaHook.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/PentaHook.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/PentaHook.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -48,7 +48,7 @@
 
 	/*intermediary: */
 	int matpar_id;
-	
+
 	/*retrieve parameters: */
 	iomodel->Constant(&matpar_id,MeshNumberofelementsEnum); matpar_id++;
 
@@ -69,7 +69,6 @@
 /*FUNCTION PentaHook::SetHookNodes{{{*/
 void PentaHook::SetHookNodes(int* node_ids,int analysis_counter){
 	this->hnodes[analysis_counter]= new Hook(node_ids,6);
-
 }
 /*}}}*/
 /*FUNCTION PentaHook::InitHookNeighbors{{{*/

Modified: issm/trunk/src/c/classes/objects/Elements/PentaHook.h
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/PentaHook.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/PentaHook.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,22 +12,20 @@
 class PentaHook{
 
 	public: 
-		int   numanalyses; //number of analysis types
-		Hook** hnodes; // 6 nodes for each analysis type
-		Hook*  hmaterial; // 1 ice material
-		Hook*  hmatpar; // 1 material parameter
-		Hook*  hneighbors; // 2 elements, first down, second up
+		int    numanalyses;   //number of analysis types
+		Hook **hnodes;        // 6 nodes for each analysis type
+		Hook  *hmaterial;     // 1 ice material
+		Hook  *hmatpar;       // 1 material parameter
+		Hook  *hneighbors;    // 2 elements, first down, second up
 
-		/*FUNCTION constructors, destructors {{{*/
+		/*constructors, destructors*/
 		PentaHook();
 		PentaHook(int in_numanalyses,int material_id, IoModel* iomodel);
 		~PentaHook();
+
 		void SetHookNodes(int* node_ids,int analysis_counter);
 		void SpawnTriaHook(TriaHook* triahook,int* indices);
 		void InitHookNeighbors(int* element_ids);
-		/*}}}*/
 };
 
-
 #endif //ifndef _PENTAHOOK_H_
-

Modified: issm/trunk/src/c/classes/objects/Elements/PentaRef.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/PentaRef.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/PentaRef.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -698,7 +698,6 @@
 
 	IssmDouble l1l2l3[NUMNODESP1_2d];
 
-
 	/*Get l1l2l3 in actual coordinate system: */
 	l1l2l3[0]=gauss->coord1*(1-gauss->coord4)/2.0;
 	l1l2l3[1]=gauss->coord2*(1-gauss->coord4)/2.0;
@@ -811,7 +810,6 @@
 
 	IssmDouble l1l2l3[NUMNODESP1_2d];
 
-
 	/*Get l1l2l3 in actual coordinate system: */
 	l1l2l3[0]=gauss->coord1*(1-gauss->coord4)/2.0;
 	l1l2l3[1]=gauss->coord2*(1-gauss->coord4)/2.0;
@@ -881,8 +879,6 @@
 /*FUNCTION PentaRef::GetJacobian {{{*/
 void PentaRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,GaussPenta* gauss){
 
-	int i,j;
-
 	/*The Jacobian is constant over the element, discard the gaussian points. 
 	 * J is assumed to have been allocated of size NDOF2xNDOF2.*/
 
@@ -898,9 +894,9 @@
 	A2=gauss->coord2;
 	A3=gauss->coord3;
 
-	xi=A2-A1;
-	eta=SQRT3*A3;
-	zi=gauss->coord4;
+	xi  = A2-A1;
+	eta = SQRT3*A3;
+	zi  = gauss->coord4;
 
 	x1=*(xyz_list+3*0+0);
 	x2=*(xyz_list+3*1+0);

Modified: issm/trunk/src/c/classes/objects/Elements/PentaRef.h
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/PentaRef.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/PentaRef.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,17 +3,15 @@
  * strain rate generation, etc ...
  */ 
 
-
 #ifndef _PENTAREF_H_
 #define _PENTAREF_H_
 
 class PentaRef{
-	
 
 	public: 
 		int* element_type_list; //P1CG, P1DG, MINI, P2...
 		int  element_type;
-		
+
 		PentaRef();
 		PentaRef(const int nummodels);
 		~PentaRef();

Modified: issm/trunk/src/c/classes/objects/Elements/Tria.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/Tria.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/Tria.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -41,8 +41,7 @@
 Tria::Tria(int tria_id, int tria_sid, int index, IoModel* iomodel,int nummodels)
 	:TriaRef(nummodels)
 	,TriaHook(nummodels,index+1,iomodel){
-		
-		int i;
+
 		/*id: */
 		this->id=tria_id;
 		this->sid=tria_sid;
@@ -126,21 +125,20 @@
 /*FUNCTION Tria::AverageOntoPartition {{{*/
 void  Tria::AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){
 
-	bool      already=false;
-	int       i,j;
-	int       partition[NUMVERTICES];
-	int       offsetsid[NUMVERTICES];
-	int       offsetdof[NUMVERTICES];
-	IssmDouble    area;
-	IssmDouble    mean;
-	IssmDouble    values[3];
+	bool       already = false;
+	int        i,j;
+	int        partition[NUMVERTICES];
+	int        offsetsid[NUMVERTICES];
+	int        offsetdof[NUMVERTICES];
+	IssmDouble area;
+	IssmDouble mean;
 
 	/*First, get the area: */
 	area=this->GetArea();
 
 	/*Figure out the average for this element: */
-	this->GetSidList(&offsetsid[0]);
-	this->GetDofList1(&offsetdof[0]);
+	this->GetVertexSidList(&offsetsid[0]);
+	this->GetVertexPidList(&offsetdof[0]);
 	mean=0;
 	for(i=0;i<NUMVERTICES;i++){
 		partition[i]=reCast<int>(qmu_part[offsetsid[i]]);
@@ -163,6 +161,57 @@
 	}
 }
 /*}}}*/
+/*FUNCTION Tria::SetwiseNodeConnectivity{{{*/
+void Tria::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
+
+	/*Output */
+	int d_nz = 0;
+	int o_nz = 0;
+
+	/*Loop over all nodes*/
+	for(int i=0;i<3;i++){
+
+		if(!flags[this->nodes[i]->Sid()]){
+
+			/*flag current node so that no other element processes it*/
+			flags[this->nodes[i]->Sid()]=true;
+
+			/*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
+			switch(set2_enum){
+				case FsetEnum:
+					if(nodes[i]->indexing.fsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case GsetEnum:
+					if(nodes[i]->indexing.gsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case SsetEnum:
+					if(nodes[i]->indexing.ssize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				default: _error_("not supported");
+			}
+		}
+	}
+
+	/*Assign output pointers: */
+	*pd_nz=d_nz;
+	*po_nz=o_nz;
+}
+/*}}}*/
 /*FUNCTION Tria::CreateKMatrix {{{*/
 void  Tria::CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,Vector<IssmDouble>* df){
 
@@ -174,7 +223,7 @@
 	/*Checks in debugging mode{{{*/
 	_assert_(this->nodes && this->material && this->matpar && this->parameters && this->inputs);
 	/*}}}*/
-	
+
 	/*Skip if water element*/
 	if(IsOnWater()) return;
 
@@ -230,7 +279,6 @@
 	const int  numdof=NUMVERTICES*NDOF1;
 
 	/*Intermediaries */
-	int        i,j,ig;
 	IssmDouble heatcapacity,latentheat;
 	IssmDouble Jdet,D_scalar;
 	IssmDouble xyz_list[NUMVERTICES][3];
@@ -247,7 +295,7 @@
 
 	/* Start looping on the number of gauss  (nodes on the bedrock) */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -289,20 +337,19 @@
 
 	/*Intermediaries */
 	int        stabilization;
-	int        i,j,ig,dim;
-	IssmDouble     Jdettria,DL_scalar,dt,h;
-	IssmDouble     vel,vx,vy,dvxdx,dvydy;
-	IssmDouble     dvx[2],dvy[2];
-	IssmDouble     v_gauss[2]={0.0};
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     L[NUMVERTICES];
-	IssmDouble     B[2][NUMVERTICES];
-	IssmDouble     Bprime[2][NUMVERTICES];
-	IssmDouble     K[2][2]                        ={0.0};
-	IssmDouble     KDL[2][2]                      ={0.0};
-	IssmDouble     DL[2][2]                        ={0.0};
-	IssmDouble     DLprime[2][2]                   ={0.0};
-	GaussTria *gauss=NULL;
+	int        dim;
+	IssmDouble Jdettria,DL_scalar,dt,h;
+	IssmDouble vel,vx,vy,dvxdx,dvydy;
+	IssmDouble dvx[2],dvy[2];
+	IssmDouble v_gauss[2]={0.0};
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble L[NUMVERTICES];
+	IssmDouble B[2][NUMVERTICES];
+	IssmDouble Bprime[2][NUMVERTICES];
+	IssmDouble K[2][2]                        ={0.0};
+	IssmDouble KDL[2][2]                      ={0.0};
+	IssmDouble DL[2][2]                        ={0.0};
+	IssmDouble DLprime[2][2]                   ={0.0};
 
 	/*Initialize Element matrix*/
 	ElementMatrix* Ke=new ElementMatrix(nodes,NUMVERTICES,this->parameters,NoneApproximationEnum);
@@ -325,8 +372,8 @@
 	h=sqrt(2*this->GetArea());
 
 	/* Start  looping on the number of gaussian points: */
-	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	GaussTria *gauss=new GaussTria(2);
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -408,15 +455,15 @@
 	const int    numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig,dim;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     Jdettria,dt,vx,vy;
-	IssmDouble     L[NUMVERTICES];
-	IssmDouble     B[2][NUMVERTICES];
-	IssmDouble     Bprime[2][NUMVERTICES];
-	IssmDouble     DL[2][2]={0.0};
-	IssmDouble     DLprime[2][2]={0.0};
-	IssmDouble     DL_scalar;
+	int        dim;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble Jdettria,dt,vx,vy;
+	IssmDouble L[NUMVERTICES];
+	IssmDouble B[2][NUMVERTICES];
+	IssmDouble Bprime[2][NUMVERTICES];
+	IssmDouble DL[2][2]={0.0};
+	IssmDouble DLprime[2][2]={0.0};
+	IssmDouble DL_scalar;
 	GaussTria  *gauss=NULL;
 
 	/*Initialize Element matrix*/
@@ -439,7 +486,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -498,7 +545,7 @@
 	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
-		
+
 		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
 		D=gauss->weight*Jdet;
 
@@ -527,7 +574,7 @@
 	/*if debugging mode, check that all pointers exist*/
 	_assert_(this->nodes && this->material && this->matpar && this->parameters && this->inputs);
 	/*}}}*/
-	
+
 	/*Skip if water element*/
 	if(IsOnWater()) return;
 
@@ -596,11 +643,10 @@
 	const int    numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig;
-	IssmDouble     Jdettria,dt;
-	IssmDouble     surface_mass_balance_g,basal_melting_g,basal_melting_correction_g,thickness_g;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     L[NUMVERTICES];
+	IssmDouble Jdettria,dt;
+	IssmDouble surface_mass_balance_g,basal_melting_g,basal_melting_correction_g,thickness_g;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble L[NUMVERTICES];
 	GaussTria* gauss=NULL;
 
 	/*Initialize Element vector*/
@@ -617,7 +663,7 @@
 	/*Initialize basal_melting_correction_g to 0, do not forget!:*/
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -632,7 +678,7 @@
 		else
 		 basal_melting_correction_g=0.;
 
-		for(i=0;i<numdof;i++) pe->values[i]+=Jdettria*gauss->weight*(thickness_g+dt*(surface_mass_balance_g-basal_melting_g-basal_melting_correction_g))*L[i];
+		for(int i=0;i<numdof;i++) pe->values[i]+=Jdettria*gauss->weight*(thickness_g+dt*(surface_mass_balance_g-basal_melting_g-basal_melting_correction_g))*L[i];
 	}
 
 	/*Clean up and return*/
@@ -647,11 +693,10 @@
 	const int    numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig;
-	IssmDouble     Jdettria,dt;
-	IssmDouble     surface_mass_balance_g,basal_melting_g,thickness_g;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     L[NUMVERTICES];
+	IssmDouble Jdettria,dt;
+	IssmDouble surface_mass_balance_g,basal_melting_g,thickness_g;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble L[NUMVERTICES];
 	GaussTria* gauss=NULL;
 
 	/*Initialize Element vector*/
@@ -666,7 +711,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -677,7 +722,7 @@
 		basal_melting_input->GetInputValue(&basal_melting_g,gauss);
 		thickness_input->GetInputValue(&thickness_g,gauss);
 
-		for(i=0;i<numdof;i++) pe->values[i]+=Jdettria*gauss->weight*(thickness_g+dt*(surface_mass_balance_g-basal_melting_g))*L[i];
+		for(int i=0;i<numdof;i++) pe->values[i]+=Jdettria*gauss->weight*(thickness_g+dt*(surface_mass_balance_g-basal_melting_g))*L[i];
 	}
 
 	/*Clean up and return*/
@@ -690,14 +735,14 @@
 
 	/*Constants*/
 	const int    numdof=NDOF1*NUMVERTICES;
-	
+
 	/*Intermediaries */
-	int        i,j,ig;
+	int        i;
 	int        analysis_type;
-	IssmDouble     Jdet;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     slope[2];
-	IssmDouble     basis[3];
+	IssmDouble Jdet;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble slope[2];
+	IssmDouble basis[3];
 	GaussTria* gauss=NULL;
 
 	/*Initialize Element vector*/
@@ -713,10 +758,10 @@
 	if ( (analysis_type==BedSlopeXAnalysisEnum) || (analysis_type==BedSlopeYAnalysisEnum)){
 		slope_input=inputs->GetInput(BedEnum);     _assert_(slope_input);
 	}
-		
+
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -784,7 +829,6 @@
 /*FUNCTION Tria::ComputeStressTensor {{{*/
 void  Tria::ComputeStressTensor(){
 
-	int         iv;
 	IssmDouble      xyz_list[NUMVERTICES][3];
 	IssmDouble      pressure,viscosity;
 	IssmDouble      epsilon[3]; /* epsilon=[exx,eyy,exy];*/
@@ -819,7 +863,7 @@
 		sigma_yy[iv]=2*viscosity*epsilon[1]-pressure;
 		sigma_xy[iv]=2*viscosity*epsilon[2];
 	}
-	
+
 	/*Add Stress tensor components into inputs*/
 	this->inputs->AddInput(new TriaP1Input(StressTensorxxEnum,&sigma_xx[0]));
 	this->inputs->AddInput(new TriaP1Input(StressTensorxyEnum,&sigma_xy[0]));
@@ -834,7 +878,7 @@
 /*}}}*/
 /*FUNCTION Tria::Configure {{{*/
 void  Tria::Configure(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
-	
+
 	/*go into parameters and get the analysis_counter: */
 	int analysis_counter;
 	parametersin->FindParam(&analysis_counter,AnalysisCounterEnum);
@@ -893,7 +937,7 @@
 
 	_printLine_("neighboor sids: ");
 	_printLine_(" " << horizontalneighborsids[0] << " " << horizontalneighborsids[1] << " " << horizontalneighborsids[2]);
-	
+
 	return;
 }
 /*}}}*/
@@ -945,7 +989,7 @@
 	this->parameters->FindParam(&Delta18oSurfacePresent,SurfaceforcingsDelta18oSurfaceEnum,finaltime);
 	this->parameters->FindParam(&Delta18oSurfaceLgm,SurfaceforcingsDelta18oSurfaceEnum,(finaltime-(21000*yts)));
 	this->parameters->FindParam(&Delta18oSurfaceTime,SurfaceforcingsDelta18oSurfaceEnum,time);
-	
+
 	/*Compute the temperature and precipitation*/
 	for(int iv=0;iv<NUMVERTICES;iv++){
 		ComputeDelta18oTemperaturePrecipitation(Delta18oSurfacePresent, Delta18oSurfaceLgm, Delta18oSurfaceTime, 
@@ -1026,7 +1070,7 @@
 	x1=xyz_list[0][0]; y1=xyz_list[0][1];
 	x2=xyz_list[1][0]; y2=xyz_list[1][1];
 	x3=xyz_list[2][0]; y3=xyz_list[2][1];
- 
+
 	_assert_(x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1>0);
 	return (x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1)/2;
 }
@@ -1054,14 +1098,6 @@
 	*pdoflist=doflist;
 }
 /*}}}*/
-/*FUNCTION Tria::GetDofList1 {{{*/
-void  Tria::GetDofList1(int* doflist){
-
-	int i;
-	for(i=0;i<3;i++) doflist[i]=nodes[i]->GetDofList1();
-
-}
-/*}}}*/
 /*FUNCTION Tria::GetElementType {{{*/
 int Tria::GetElementType(){
 
@@ -1089,13 +1125,35 @@
 	_error_("Node provided not found among element nodes");
 }
 /*}}}*/
+/*FUNCTION Tria::GetNodesSidList{{{*/
+void Tria::GetNodesSidList(int* sidlist){
+
+	_assert_(sidlist);
+	_assert_(nodes);
+
+	for(int i=0;i<NUMVERTICES;i++){
+		sidlist[i]=nodes[i]->Sid();
+	}
+}
+/*}}}*/
+/*FUNCTION Tria::GetNumberOfNodes{{{*/
+int Tria::GetNumberOfNodes(void){
+
+	if(this->nodes==NULL) return 0;
+
+	switch(this->element_type){
+		case P1Enum:
+			return 3;
+		case P1DGEnum:
+			return 3;
+		default:
+			_error_("Element type "<<EnumToStringx(this->element_type)<<" not supported yet");
+	}
+}
+/*}}}*/
 /*FUNCTION Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype) {{{*/
 void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype){
 
-	/*Intermediaries*/
-	IssmDouble     value[NUMVERTICES];
-	GaussTria *gauss              = NULL;
-
 	/*Recover input*/
 	Input* input=inputs->GetInput(enumtype);
 	if (!input) _error_("Input " << EnumToStringx(enumtype) << " not found in element");
@@ -1104,7 +1162,7 @@
 	_assert_(pvalue);
 
 	/* Start looping on the number of vertices: */
-	gauss=new GaussTria();
+	GaussTria* gauss=new GaussTria();
 	for (int iv=0;iv<NUMVERTICES;iv++){
 		gauss->GaussVertex(iv);
 		input->GetInputValue(&pvalue[iv],gauss);
@@ -1117,8 +1175,6 @@
 /*FUNCTION Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue) {{{*/
 void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){
 
-	IssmDouble     value[NUMVERTICES];
-	GaussTria *gauss = NULL;
 	Input     *input = inputs->GetInput(enumtype);
 
 	/*Checks in debugging mode*/
@@ -1126,25 +1182,21 @@
 
 	/* Start looping on the number of vertices: */
 	if (input){
-		gauss=new GaussTria();
+		GaussTria* gauss=new GaussTria();
 		for (int iv=0;iv<NUMVERTICES;iv++){
 			gauss->GaussVertex(iv);
 			input->GetInputValue(&pvalue[iv],gauss);
 		}
+		delete gauss;
 	}
 	else{
 		for (int iv=0;iv<NUMVERTICES;iv++) pvalue[iv]=defaultvalue;
 	}
-
-	/*clean-up*/
-	delete gauss;
 }
 /*}}}*/
 /*FUNCTION Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue,int index) TO BE REMOVED{{{*/
 void Tria::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue,int index){
 
-	IssmDouble     value[NUMVERTICES];
-	GaussTria *gauss = NULL;
 	Input     *input = inputs->GetInput(enumtype);
 
 	/*Checks in debugging mode*/
@@ -1152,18 +1204,16 @@
 
 	/* Start looping on the number of vertices: */
 	if (input){
-		gauss=new GaussTria();
+		GaussTria* gauss=new GaussTria();
 		for (int iv=0;iv<NUMVERTICES;iv++){
 			gauss->GaussVertex(iv);
 			input->GetInputValue(&pvalue[iv],gauss,index);
 		}
+		delete gauss;
 	}
 	else{
 		for (int iv=0;iv<NUMVERTICES;iv++) pvalue[iv]=defaultvalue;
 	}
-
-	/*clean-up*/
-	delete gauss;
 }
 /*}}}*/
 /*FUNCTION Tria::GetInputValue(IssmDouble* pvalue,Node* node,int enumtype) {{{*/
@@ -1179,11 +1229,19 @@
 	delete gauss;
 }
 /*}}}*/
-/*FUNCTION Tria::GetSidList {{{*/
-void  Tria::GetSidList(int* sidlist){
-	for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetSidList();
+/*FUNCTION Tria::GetVertexPidList {{{*/
+void  Tria::GetVertexPidList(int* doflist){
+
+	int i;
+	for(i=0;i<3;i++) doflist[i]=nodes[i]->GetVertexPid();
+
 }
 /*}}}*/
+/*FUNCTION Tria::GetVertexSidList {{{*/
+void  Tria::GetVertexSidList(int* sidlist){
+	for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetVertexSid();
+}
+/*}}}*/
 /*FUNCTION Tria::GetConnectivityList {{{*/
 void  Tria::GetConnectivityList(int* connectivity){
 	for(int i=0;i<NUMVERTICES;i++) connectivity[i]=nodes[i]->GetConnectivity();
@@ -1242,20 +1300,20 @@
 /*FUNCTION Tria::GetVectorFromInputs{{{*/
 void  Tria::GetVectorFromInputs(Vector<IssmDouble>* vector,int input_enum){
 
-	int doflist1[NUMVERTICES];
+	int vertexpidlist[NUMVERTICES];
 
 	/*Get out if this is not an element input*/
 	if(!IsInput(input_enum)) return;
 
 	/*Prepare index list*/
-	this->GetDofList1(&doflist1[0]);
+	this->GetVertexPidList(&vertexpidlist[0]);
 
 	/*Get input (either in element or material)*/
 	Input* input=inputs->GetInput(input_enum);
 	if(!input) _error_("Input " << EnumToStringx(input_enum) << " not found in element");
 
 	/*We found the enum.  Use its values to fill into the vector, using the vertices ids: */
-	input->GetVectorFromInputs(vector,&doflist1[0]);
+	input->GetVectorFromInputs(vector,&vertexpidlist[0]);
 }
 /*}}}*/
 /*FUNCTION Tria::GetVectorFromResults{{{*/
@@ -1267,11 +1325,11 @@
 		_error_("Results of offset "<<offset<<" is "<<EnumToStringx(elementresult->InstanceEnum())<<" when "<<EnumToStringx(enum_in)<<" was expected");
 	}
 	if(interp==P1Enum){
-		int doflist1[NUMVERTICES];
+		int vertexpidlist[NUMVERTICES];
 		int connectivity[NUMVERTICES];
-		this->GetSidList(&doflist1[0]);
+		this->GetVertexSidList(&vertexpidlist[0]);
 		this->GetConnectivityList(&connectivity[0]);
-		elementresult->GetVectorFromResults(vector,&doflist1[0],&connectivity[0],NUMVERTICES);
+		elementresult->GetVectorFromResults(vector,&vertexpidlist[0],&connectivity[0],NUMVERTICES);
 	}
 	else if(interp==P0Enum){
 		elementresult->GetElementVectorFromResults(vector,sid);
@@ -1283,14 +1341,14 @@
 /*}}}*/
 /*FUNCTION Tria::Id {{{*/
 int    Tria::Id(){
-	
+
 	return id;
 
 }
 /*}}}*/
 /*FUNCTION Tria::Sid {{{*/
 int    Tria::Sid(){
-	
+
 	return sid;
 
 }
@@ -1391,19 +1449,20 @@
 /*FUNCTION Tria::InputToResult{{{*/
 void  Tria::InputToResult(int enum_type,int step,IssmDouble time){
 
-	int    i;
 	Input *input = NULL;	
 
 	/*Go through all the input objects, and find the one corresponding to enum_type, if it exists: */
-	if (enum_type==MaterialsRheologyBbarEnum || enum_type==MaterialsRheologyZbarEnum) input=this->material->inputs->GetInput(enum_type);
-	else input=this->inputs->GetInput(enum_type);
+	if (enum_type==MaterialsRheologyBbarEnum || enum_type==MaterialsRheologyZbarEnum)
+	 input=this->material->inputs->GetInput(enum_type);
+	else
+	 input=this->inputs->GetInput(enum_type);
 	//if (!input) _error_("Input " << EnumToStringx(enum_type) << " not found in tria->inputs");
 	if(!input)return;
 
 	/*If we don't find it, no big deal, just don't do the transfer. Otherwise, build a new Result 
 	 * object out of the input, with the additional step and time information: */
 	this->results->AddObject((Object*)input->SpawnResult(step,time));
-	
+
 	#ifdef _HAVE_CONTROL_
 	if(input->ObjectEnum()==ControlInputEnum){
 		if(((ControlInput*)input)->gradient!=NULL) this->results->AddObject((Object*)((ControlInput*)input)->SpawnGradient(step,time));
@@ -1451,7 +1510,7 @@
 	int        num_control_type;
 	IssmDouble yts;
 	int        num_cm_responses;
-   
+
 	/*Get parameters: */
 	iomodel->Constant(&yts,ConstantsYtsEnum); 
 	iomodel->Constant(&control_analysis,InversionIscontrolEnum);
@@ -1686,7 +1745,7 @@
 
 			/*Get values on the 3 vertices*/
 			for (int i=0;i<3;i++){
-				values[i]=vector[this->nodes[i]->GetVertexDof()];
+				values[i]=vector[this->nodes[i]->GetVertexPid()];
 			}
 
 			/*update input*/
@@ -1718,7 +1777,7 @@
 
 	/*Check that name is an element input*/
 	if (!IsInput(name)) return;
-	
+
 	if ((code==5) || (code==1)){ //boolean
 		this->inputs->AddInput(new BoolInput(name,reCast<bool>(scalar)));
 	}
@@ -1746,7 +1805,6 @@
 	int    numberofelements;
 	IssmDouble yts;
 
-
 	/*Fetch parameters: */
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 	iomodel->Constant(&numberofelements,MeshNumberofelementsEnum);
@@ -1860,7 +1918,7 @@
 /*}}}*/
 /*FUNCTION Tria::IsOnBed {{{*/
 bool Tria::IsOnBed(){
-	
+
 	bool onbed;
 	inputs->GetInputValue(&onbed,MeshElementonbedEnum);
 	return onbed;
@@ -1966,7 +2024,7 @@
 /*FUNCTION Tria::MigrateGroundingLine{{{*/
 void  Tria::MigrateGroundingLine(IssmDouble* old_floating_ice,IssmDouble* sheet_ungrounding){
 
-	int     i,migration_style,unground;
+	int     i,migration_style;
 	bool    elementonshelf = false;
 	IssmDouble  bed_hydro,yts,gl_melting_rate;
 	IssmDouble  rho_water,rho_ice,density;
@@ -1975,6 +2033,7 @@
 
 	/*Recover info at the vertices: */
 	parameters->FindParam(&migration_style,GroundinglineMigrationEnum);
+	parameters->FindParam(&gl_melting_rate,GroundinglineMeltingRateEnum);
 	parameters->FindParam(&yts,ConstantsYtsEnum);
 	GetInputListOnVertices(&h[0],ThicknessEnum);
 	GetInputListOnVertices(&s[0],SurfaceEnum);
@@ -1983,7 +2042,7 @@
 	rho_water=matpar->GetRhoWater();
 	rho_ice=matpar->GetRhoIce();
 	density=rho_ice/rho_water;
-	
+
 	/*go through vertices, and update inputs, considering them to be TriaVertex type: */
 	for(i=0;i<NUMVERTICES;i++){
 		/*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */
@@ -2024,7 +2083,7 @@
 			break;
 		}
 	}
-	
+
    /*Add basal melting rate if element just ungrounded*/
 	if(!this->IsFloating() && elementonshelf==true){
 		for(i=0;i<NUMVERTICES;i++)melting[i]=gl_melting_rate/yts;
@@ -2039,12 +2098,6 @@
 	this->inputs->AddInput(new TriaP1Input(BedEnum,&b[0]));
 }
 /*}}}*/
-/*FUNCTION Tria::MyRank {{{*/
-int    Tria::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Tria::NodalValue {{{*/
 int    Tria::NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units){
 
@@ -2086,7 +2139,7 @@
 
 	/*recover pointer: */
 	row=*prow;
-		
+
 	for(i=0;i<3;i++) vertices_ids[i]=nodes[i]->GetVertexId(); //vertices id start at column 3 of the patch.
 
 	for(i=0;i<this->results->Size();i++){
@@ -2268,6 +2321,8 @@
 	IssmDouble a_neg[NUMVERTICES];				// Hs-SMB relation parameter
 	IssmDouble b_neg[NUMVERTICES];				// Hs-SMB relation paremeter
 	IssmDouble Hc[NUMVERTICES];					// elevation of transition between accumulation regime and ablation regime
+	IssmDouble Href[NUMVERTICES];					// reference elevation from which deviations are used to calculate the SMB adjustment
+	IssmDouble Smbref[NUMVERTICES];				// reference SMB to which deviations are added
 	IssmDouble smb_pos_max[NUMVERTICES];		// maximum SMB value in the accumulation regime
 	IssmDouble smb_pos_min[NUMVERTICES];		// minimum SMB value in the accumulation regime
    IssmDouble rho_water;                   // density of fresh water
@@ -2278,13 +2333,15 @@
 
 	/*Recover SmbGradients*/
 	GetInputListOnVertices(&Hc[0],SurfaceforcingsHcEnum);
+	GetInputListOnVertices(&Href[0],SurfaceforcingsHrefEnum);
+	GetInputListOnVertices(&Smbref[0],SurfaceforcingsSmbrefEnum);
 	GetInputListOnVertices(&smb_pos_max[0],SurfaceforcingsSmbPosMaxEnum);
 	GetInputListOnVertices(&smb_pos_min[0],SurfaceforcingsSmbPosMinEnum);
 	GetInputListOnVertices(&a_pos[0],SurfaceforcingsAPosEnum);
 	GetInputListOnVertices(&b_pos[0],SurfaceforcingsBPosEnum);
 	GetInputListOnVertices(&a_neg[0],SurfaceforcingsANegEnum);
 	GetInputListOnVertices(&b_neg[0],SurfaceforcingsBNegEnum);
-	
+
    /*Recover surface elevatio at vertices: */
 	GetInputListOnVertices(&h[0],ThicknessEnum);
 	GetInputListOnVertices(&s[0],SurfaceEnum);
@@ -2292,26 +2349,35 @@
    /*Get material parameters :*/
    rho_ice=matpar->GetRhoIce();
    rho_water=matpar->GetRhoFreshwater();
-			
+
    // loop over all vertices
    for(i=0;i<NUMVERTICES;i++){
      if(s[i]>Hc[i]){
-	    smb[i]=a_pos[i]+b_pos[i]*s[i];
-		 if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];}
-		 if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];}
+		  if(Href[i]>Hc[i]){smb[i]=Smbref[i]+b_pos[i]*(s[i]-Href[i]);}
+		  if(Href[i]<=Hc[i]){smb[i]=a_pos[i]+b_pos[i]*s[i];}
+		  if(smb[i]>smb_pos_max[i]){smb[i]=smb_pos_max[i];}
+		  if(smb[i]<smb_pos_min[i]){smb[i]=smb_pos_min[i];}
 	  }
 	  else{
-	    smb[i]=a_neg[i]+b_neg[i]*s[i];
+		  if(Href[i]>Hc[i]){smb[i]=a_neg[i]+b_neg[i]*s[i];}
+		  if(Href[i]<=Hc[i]){smb[i]=Smbref[i]+b_neg[i]*(s[i]-Href[i]);}
 	  }
 	  smb[i]=smb[i]/rho_ice;      // SMB in m/y ice		
-	}  //end of the loop over the vertices
+  /*   printf("s %e \n",s[i]); 
+     printf("Hsref %e \n",Href[i]); 
+     printf("Hc %e \n",Hc[i]); 
+     printf("Smbref %e \n",Smbref[i]); 
+     printf("b_neg %e \n",b_neg[i]); 
+     printf("smb %e \n",smb[i]); 
+	  _error_("stop-in-code"); */
+		}  //end of the loop over the vertices
 	  /*Update inputs*/
 	  this->inputs->AddInput(new TriaP1Input(SurfaceforcingsMassBalanceEnum,&smb[0]));
 }
 /*}}}*/
 /*FUNCTION Tria::SetCurrentConfiguration {{{*/
 void  Tria::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
-	
+
 	/*go into parameters and get the analysis_counter: */
 	int analysis_counter;
 	parametersin->FindParam(&analysis_counter,AnalysisCounterEnum);
@@ -2532,7 +2598,7 @@
 	for(i=0;i<3;i++){
 		if (reCast<bool>(vertices_potentially_ungrounding[nodes[i]->Sid()])){
 			vec_nodes_on_iceshelf->SetValue(nodes[i]->Sid(),1,INS_VAL);
-		
+
 			/*If node was not on ice shelf, we flipped*/
 			if(nodes_on_iceshelf[nodes[i]->Sid()]==0){
 				nflipped++;
@@ -2573,15 +2639,14 @@
 /*FUNCTION Tria::MassFlux {{{*/
 IssmDouble Tria::MassFlux( IssmDouble* segment,bool process_units){
 
-	const int    numdofs=2;
-
-	int        i,dim;
-	IssmDouble     mass_flux=0;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     normal[2];
-	IssmDouble     length,rho_ice;
-	IssmDouble     x1,y1,x2,y2,h1,h2;
-	IssmDouble     vx1,vx2,vy1,vy2;
+	const int  numdofs=2;
+	int        dim;
+	IssmDouble mass_flux=0;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble normal[2];
+	IssmDouble length,rho_ice;
+	IssmDouble x1,y1,x2,y2,h1,h2;
+	IssmDouble vx1,vx2,vy1,vy2;
 	GaussTria* gauss_1=NULL;
 	GaussTria* gauss_2=NULL;
 
@@ -2841,10 +2906,10 @@
 	Input* smb_input = inputs->GetInput(SurfaceforcingsMassBalanceEnum); _assert_(smb_input);
 	smb_input->GetInputAverage(&smb);																								// average smb on element in m ice s-1
    Total_Smb=rho_ice*base*smb;																											// smb on element in kg s-1
-	
+
 	/*Process units: */
 	Total_Smb=UnitConversion(Total_Smb,IuToExtEnum,TotalSmbEnum);																// smb on element in GigaTon yr-1
-	
+
 	/*Return: */
 	return Total_Smb;
 }
@@ -2859,7 +2924,7 @@
 	ElementMatrix* Ke1=CreateKMatrixDiagnosticMacAyealViscous();
 	ElementMatrix* Ke2=CreateKMatrixDiagnosticMacAyealFriction();
 	ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2);
-	
+
 	/*clean-up and return*/
 	delete Ke1;
 	delete Ke2;
@@ -2873,15 +2938,15 @@
 	const int  numdof=NDOF2*NUMVERTICES;
 
 	/*Intermediaries*/
-	int        i,j,ig;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     viscosity,newviscosity,oldviscosity;
-	IssmDouble     viscosity_overshoot,thickness,Jdet;
-	IssmDouble     epsilon[3],oldepsilon[3];    /* epsilon=[exx,eyy,exy];    */
-	IssmDouble     B[3][numdof];
-	IssmDouble     Bprime[3][numdof];
-	IssmDouble     D[3][3]   = {0.0};
-	IssmDouble     D_scalar;
+	int        i,j;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble viscosity,newviscosity,oldviscosity;
+	IssmDouble viscosity_overshoot,thickness,Jdet;
+	IssmDouble epsilon[3],oldepsilon[3];    /* epsilon=[exx,eyy,exy];    */
+	IssmDouble B[3][numdof];
+	IssmDouble Bprime[3][numdof];
+	IssmDouble D[3][3]   = {0.0};
+	IssmDouble D_scalar;
 	GaussTria *gauss = NULL;
 
 	/*Initialize Element matrix*/
@@ -2898,7 +2963,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -2937,17 +3002,17 @@
 	const int  numdof=NDOF2*NUMVERTICES;
 
 	/*Intermediaries*/
-	int        i,j,ig;
+	int        i,j;
 	int        analysis_type;
-	IssmDouble     MAXSLOPE  = .06; // 6 %
-	IssmDouble     MOUNTAINKEXPONENT = 10;
-	IssmDouble     slope_magnitude,alpha2;
-	IssmDouble     Jdet;
-	IssmDouble     L[2][numdof];
-	IssmDouble     DL[2][2]  = {{ 0,0 },{0,0}};
-	IssmDouble     DL_scalar;
-	IssmDouble     slope[2]  = {0.0,0.0};
-	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble MAXSLOPE  = .06; // 6 %
+	IssmDouble MOUNTAINKEXPONENT = 10;
+	IssmDouble slope_magnitude,alpha2;
+	IssmDouble Jdet;
+	IssmDouble L[2][numdof];
+	IssmDouble DL[2][2]  = {{ 0,0 },{0,0}};
+	IssmDouble DL_scalar;
+	IssmDouble slope[2]  = {0.0,0.0};
+	IssmDouble xyz_list[NUMVERTICES][3];
 	Friction  *friction = NULL;
 	GaussTria *gauss    = NULL;
 
@@ -2968,7 +3033,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -2983,7 +3048,7 @@
 		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
 		DL_scalar=alpha2*gauss->weight*Jdet;
 		for (i=0;i<2;i++) DL[i][i]=DL_scalar;
-		
+
 		TripleMultiply( &L[0][0],2,numdof,1,
 					&DL[0][0],2,2,0,
 					&L[0][0],2,numdof,0,
@@ -3027,13 +3092,13 @@
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	/*Intermediaries */
-	int            i,j,ig;
-	IssmDouble         driving_stress_baseline,thickness;
-	IssmDouble         Jdet;
-	IssmDouble         xyz_list[NUMVERTICES][3];
-	IssmDouble         slope[2];
-	IssmDouble         basis[3];
-	IssmDouble         pe_g_gaussian[numdof];
+	int            i,j;
+	IssmDouble     driving_stress_baseline,thickness;
+	IssmDouble     Jdet;
+	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble     slope[2];
+	IssmDouble     basis[3];
+	IssmDouble     pe_g_gaussian[numdof];
 	GaussTria*     gauss=NULL;
 
 	/*Initialize Element vector*/
@@ -3047,7 +3112,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3131,16 +3196,16 @@
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     Jdet,thickness;
-	IssmDouble     eps1dotdphii,eps1dotdphij;
-	IssmDouble     eps2dotdphii,eps2dotdphij;
-	IssmDouble     mu_prime;
-	IssmDouble     epsilon[3];/* epsilon=[exx,eyy,exy];*/
-	IssmDouble     eps1[2],eps2[2];
-	IssmDouble     phi[NUMVERTICES];
-	IssmDouble     dphi[2][NUMVERTICES];
+	int        i,j;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble Jdet,thickness;
+	IssmDouble eps1dotdphii,eps1dotdphij;
+	IssmDouble eps2dotdphii,eps2dotdphij;
+	IssmDouble mu_prime;
+	IssmDouble epsilon[3];/* epsilon=[exx,eyy,exy];*/
+	IssmDouble eps1[2],eps2[2];
+	IssmDouble phi[NUMVERTICES];
+	IssmDouble dphi[2][NUMVERTICES];
 	GaussTria *gauss=NULL;
 
 	/*Initialize Jacobian with regular MacAyeal (first part of the Gateau derivative)*/
@@ -3154,7 +3219,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3270,7 +3335,7 @@
 /*}}}*/
 /*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHoriz {{{*/
 void  Tria::InputUpdateFromSolutionDiagnosticHoriz(IssmDouble* solution){
-	
+
 	const int numdof=NDOF2*NUMVERTICES;
 
 	int       i;
@@ -3283,7 +3348,7 @@
 	IssmDouble    vel[NUMVERTICES];
 	IssmDouble    pressure[NUMVERTICES];
 	IssmDouble    thickness[NUMVERTICES];
-	
+
 	/*Get dof list: */
 	GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
 
@@ -3333,9 +3398,9 @@
 /*}}}*/
 /*FUNCTION Tria::InputUpdateFromSolutionDiagnosticHutter {{{*/
 void  Tria::InputUpdateFromSolutionDiagnosticHutter(IssmDouble* solution){
-	
+
 	const int numdof=NDOF2*NUMVERTICES;
-	
+
 	int       i;
 	int*      doflist=NULL;
 	IssmDouble    rho_ice,g;
@@ -3346,7 +3411,7 @@
 	IssmDouble    vel[NUMVERTICES];
 	IssmDouble    pressure[NUMVERTICES];
 	IssmDouble    thickness[NUMVERTICES];
-	
+
 	/*Get dof list: */
 	GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
 
@@ -3431,7 +3496,7 @@
 /*FUNCTION Tria::ControlInputGetGradient{{{*/
 void Tria::ControlInputGetGradient(Vector<IssmDouble>* gradient,int enum_type,int control_index){
 
-	int doflist1[NUMVERTICES];
+	int vertexpidlist[NUMVERTICES];
 	Input* input=NULL;
 
 	if(enum_type==MaterialsRheologyBbarEnum || enum_type==MaterialsRheologyZbarEnum){
@@ -3443,8 +3508,8 @@
 	if (!input) _error_("Input " << EnumToStringx(enum_type) << " not found");
 	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
 
-	GradientIndexing(&doflist1[0],control_index);
-	((ControlInput*)input)->GetGradient(gradient,&doflist1[0]);
+	GradientIndexing(&vertexpidlist[0],control_index);
+	((ControlInput*)input)->GetGradient(gradient,&vertexpidlist[0]);
 
 }/*}}}*/
 /*FUNCTION Tria::ControlInputScaleGradient{{{*/
@@ -3466,7 +3531,7 @@
 /*FUNCTION Tria::ControlInputSetGradient{{{*/
 void Tria::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){
 
-	int    doflist1[NUMVERTICES];
+	int    vertexpidlist[NUMVERTICES];
 	IssmDouble grad_list[NUMVERTICES];
 	Input* grad_input=NULL;
 	Input* input=NULL;
@@ -3480,8 +3545,8 @@
 	if (!input) _error_("Input " << EnumToStringx(enum_type) << " not found");
 	if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput");
 
-	GradientIndexing(&doflist1[0],control_index);
-	for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[doflist1[i]];
+	GradientIndexing(&vertexpidlist[0],control_index);
+	for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[vertexpidlist[i]];
 	grad_input=new TriaP1Input(GradientEnum,grad_list);
 
 	((ControlInput*)input)->SetGradient(grad_input);
@@ -3554,24 +3619,24 @@
 /*FUNCTION Tria::GradjBGradient{{{*/
 void  Tria::GradjBGradient(Vector<IssmDouble>* gradient,int weight_index,int control_index){
 
-	int        i,ig;
-	int        doflist1[NUMVERTICES];
-	IssmDouble     Jdet,weight;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     dbasis[NDOF2][NUMVERTICES];
-	IssmDouble     dk[NDOF2]; 
-	IssmDouble     grade_g[NUMVERTICES]={0.0};
+	int        i;
+	int        vertexpidlist[NUMVERTICES];
+	IssmDouble Jdet,weight;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble dbasis[NDOF2][NUMVERTICES];
+	IssmDouble dk[NDOF2]; 
+	IssmDouble grade_g[NUMVERTICES]={0.0};
 	GaussTria  *gauss=NULL;
 
 	/*Retrieve all inputs we will be needing: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 	Input* rheologyb_input=material->inputs->GetInput(MaterialsRheologyBbarEnum); _assert_(rheologyb_input);
 	Input* weights_input=inputs->GetInput(InversionCostFunctionsCoefficientsEnum);                _assert_(weights_input);
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3585,7 +3650,7 @@
 		/*Build gradje_g_gaussian vector (actually -dJ/ddrag): */
 		for (i=0;i<NUMVERTICES;i++) grade_g[i]+=-weight*Jdet*gauss->weight*(dbasis[0][i]*dk[0]+dbasis[1][i]*dk[1]);
 	}
-	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
+	gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
 	delete gauss;
@@ -3594,24 +3659,24 @@
 /*FUNCTION Tria::GradjZGradient{{{*/
 void  Tria::GradjZGradient(Vector<IssmDouble>* gradient,int weight_index,int control_index){
 
-	int        i,ig;
-	int        doflist1[NUMVERTICES];
-	IssmDouble     Jdet,weight;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     dbasis[NDOF2][NUMVERTICES];
-	IssmDouble     dk[NDOF2]; 
-	IssmDouble     grade_g[NUMVERTICES]={0.0};
+	int        i;
+	int        vertexpidlist[NUMVERTICES];
+	IssmDouble Jdet,weight;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble dbasis[NDOF2][NUMVERTICES];
+	IssmDouble dk[NDOF2]; 
+	IssmDouble grade_g[NUMVERTICES]={0.0};
 	GaussTria  *gauss=NULL;
 
 	/*Retrieve all inputs we will be needing: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 	Input* rheologyz_input=material->inputs->GetInput(MaterialsRheologyZbarEnum); _assert_(rheologyz_input);
 	Input* weights_input=inputs->GetInput(InversionCostFunctionsCoefficientsEnum);                _assert_(weights_input);
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3625,7 +3690,7 @@
 		/*Build gradje_g_gaussian vector (actually -dJ/ddrag): */
 		for (i=0;i<NUMVERTICES;i++) grade_g[i]+=-weight*Jdet*gauss->weight*(dbasis[0][i]*dk[0]+dbasis[1][i]*dk[1]);
 	}
-	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
+	gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
 	delete gauss;
@@ -3635,14 +3700,14 @@
 void  Tria::GradjBMacAyeal(Vector<IssmDouble>* gradient,int control_index){
 
 	/*Intermediaries*/
-	int        i,ig;
+	int        i;
 	int        doflist[NUMVERTICES];
-	IssmDouble     vx,vy,lambda,mu,thickness,Jdet;
-	IssmDouble     viscosity_complement;
-	IssmDouble     dvx[NDOF2],dvy[NDOF2],dadjx[NDOF2],dadjy[NDOF2],dB[NDOF2]; 
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     basis[3],epsilon[3];
-	IssmDouble     grad[NUMVERTICES]={0.0};
+	IssmDouble vx,vy,lambda,mu,thickness,Jdet;
+	IssmDouble viscosity_complement;
+	IssmDouble dvx[NDOF2],dvy[NDOF2],dadjx[NDOF2],dadjy[NDOF2],dB[NDOF2]; 
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble basis[3],epsilon[3];
+	IssmDouble grad[NUMVERTICES]={0.0};
 	GaussTria *gauss = NULL;
 
 	/* Get node coordinates and dof list: */
@@ -3659,7 +3724,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(4);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3692,14 +3757,14 @@
 void  Tria::GradjZMacAyeal(Vector<IssmDouble>* gradient,int control_index){
 
 	/*Intermediaries*/
-	int        i,ig;
+	int        i;
 	int        doflist[NUMVERTICES];
-	IssmDouble     vx,vy,lambda,mu,thickness,Jdet;
-	IssmDouble     viscosity_complement;
-	IssmDouble     dvx[NDOF2],dvy[NDOF2],dadjx[NDOF2],dadjy[NDOF2],dZ[NDOF2]; 
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     basis[3],epsilon[3];
-	IssmDouble     grad[NUMVERTICES]={0.0};
+	IssmDouble vx,vy,lambda,mu,thickness,Jdet;
+	IssmDouble viscosity_complement;
+	IssmDouble dvx[NDOF2],dvy[NDOF2],dadjx[NDOF2],dadjy[NDOF2],dZ[NDOF2]; 
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble basis[3],epsilon[3];
+	IssmDouble grad[NUMVERTICES]={0.0};
 	GaussTria *gauss = NULL;
 
 	/* Get node coordinates and dof list: */
@@ -3716,7 +3781,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(4);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3748,18 +3813,18 @@
 /*FUNCTION Tria::GradjDragMacAyeal {{{*/
 void  Tria::GradjDragMacAyeal(Vector<IssmDouble>* gradient,int control_index){
 
-	int        i,ig;
+	int        i;
 	int        analysis_type;
-	int        doflist1[NUMVERTICES];
+	int        vertexpidlist[NUMVERTICES];
 	int        connectivity[NUMVERTICES];
-	IssmDouble     vx,vy,lambda,mu,alpha_complement,Jdet;
-	IssmDouble     bed,thickness,Neff,drag;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     dk[NDOF2]; 
-	IssmDouble     grade_g[NUMVERTICES]={0.0};
-	IssmDouble     grade_g_gaussian[NUMVERTICES];
-	IssmDouble     basis[3];
-	IssmDouble     epsilon[3]; /* epsilon=[exx,eyy,exy];*/
+	IssmDouble vx,vy,lambda,mu,alpha_complement,Jdet;
+	IssmDouble bed,thickness,Neff,drag;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble dk[NDOF2]; 
+	IssmDouble grade_g[NUMVERTICES]={0.0};
+	IssmDouble grade_g_gaussian[NUMVERTICES];
+	IssmDouble basis[3];
+	IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/
 	Friction*  friction=NULL;
 	GaussTria  *gauss=NULL;
 
@@ -3768,7 +3833,7 @@
 	/*retrive parameters: */
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 	this->GetConnectivityList(&connectivity[0]);
 
 	/*Build frictoin element, needed later: */
@@ -3783,7 +3848,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(4);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3792,7 +3857,7 @@
 
 		/*Build alpha_complement_list: */
 		friction->GetAlphaComplement(&alpha_complement, gauss,VxEnum,VyEnum,VzEnum);
-	
+
 		dragcoefficient_input->GetInputValue(&drag, gauss);
 		adjointx_input->GetInputValue(&lambda, gauss);
 		adjointy_input->GetInputValue(&mu, gauss);
@@ -3804,7 +3869,7 @@
 		for (i=0;i<NUMVERTICES;i++){
 			grade_g_gaussian[i]=-2*drag*alpha_complement*((lambda*vx+mu*vy))*Jdet*gauss->weight*basis[i];
 		}
-		
+
 		/*Add gradje_g_gaussian vector to gradje_g: */
 		for(i=0;i<NUMVERTICES;i++){
 			_assert_(!xIsNan<IssmDouble>(grade_g[i]));
@@ -3826,7 +3891,7 @@
 	//}
 	/*End Analytical gradient*/
 
-	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
+	gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
 	delete gauss;
@@ -3836,25 +3901,25 @@
 /*FUNCTION Tria::GradjDragGradient{{{*/
 void  Tria::GradjDragGradient(Vector<IssmDouble>* gradient, int weight_index,int control_index){
 
-	int        i,ig;
-	int        doflist1[NUMVERTICES];
-	IssmDouble     Jdet,weight;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     dbasis[NDOF2][NUMVERTICES];
-	IssmDouble     dk[NDOF2]; 
-	IssmDouble     grade_g[NUMVERTICES]={0.0};
+	int        i;
+	int        vertexpidlist[NUMVERTICES];
+	IssmDouble Jdet,weight;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble dbasis[NDOF2][NUMVERTICES];
+	IssmDouble dk[NDOF2]; 
+	IssmDouble grade_g[NUMVERTICES]={0.0};
 	GaussTria  *gauss=NULL;
 
 	/*Retrieve all inputs we will be needing: */
 	if(IsFloating())return;
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 	Input* dragcoefficient_input=inputs->GetInput(FrictionCoefficientEnum); _assert_(dragcoefficient_input);
 	Input* weights_input=inputs->GetInput(InversionCostFunctionsCoefficientsEnum);                 _assert_(weights_input);
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3871,7 +3936,7 @@
 			_assert_(!xIsNan<IssmDouble>(grade_g[i]));
 		}
 	}
-	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
+	gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
 	delete gauss;
@@ -3881,34 +3946,34 @@
 void  Tria::GradjDhDtBalancedthickness(Vector<IssmDouble>* gradient,int control_index){
 
 	/*Intermediaries*/
-	int    doflist1[NUMVERTICES];
+	int    vertexpidlist[NUMVERTICES];
 	IssmDouble lambda[NUMVERTICES];
 	IssmDouble gradient_g[NUMVERTICES];
 
 	/*Compute Gradient*/
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 	GetInputListOnVertices(&lambda[0],AdjointEnum);
 	for(int i=0;i<NUMVERTICES;i++) gradient_g[i]=-lambda[i];
 
-	gradient->SetValues(NUMVERTICES,doflist1,gradient_g,INS_VAL);
+	gradient->SetValues(NUMVERTICES,vertexpidlist,gradient_g,INS_VAL);
 }
 /*}}}*/
 /*FUNCTION Tria::GradjVxBalancedthickness{{{*/
 void  Tria::GradjVxBalancedthickness(Vector<IssmDouble>* gradient,int control_index){
 
 	/*Intermediaries*/
-	int        i,ig;
-	int        doflist1[NUMVERTICES];
-	IssmDouble     thickness,Jdet;
-	IssmDouble     basis[3];
-	IssmDouble     Dlambda[2],dp[2];
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     grade_g[NUMVERTICES] = {0.0};
+	int        i;
+	int        vertexpidlist[NUMVERTICES];
+	IssmDouble thickness,Jdet;
+	IssmDouble basis[3];
+	IssmDouble Dlambda[2],dp[2];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble grade_g[NUMVERTICES] = {0.0};
 	GaussTria *gauss                = NULL;
 
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 
 	/*Retrieve all inputs we will be needing: */
 	Input* adjoint_input=inputs->GetInput(AdjointEnum);     _assert_(adjoint_input);
@@ -3916,13 +3981,13 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
 		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
 		GetNodalFunctions(basis, gauss);
-		
+
 		adjoint_input->GetInputDerivativeValue(&Dlambda[0],&xyz_list[0][0],gauss);
 		thickness_input->GetInputValue(&thickness, gauss);
 		thickness_input->GetInputDerivativeValue(&dp[0],&xyz_list[0][0],gauss);
@@ -3930,7 +3995,7 @@
 		for(i=0;i<NUMVERTICES;i++) grade_g[i]+=thickness*Dlambda[0]*Jdet*gauss->weight*basis[i];
 	}
 
-	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
+	gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
 	delete gauss;
@@ -3940,18 +4005,18 @@
 void  Tria::GradjVyBalancedthickness(Vector<IssmDouble>* gradient,int control_index){
 
 	/*Intermediaries*/
-	int        i,ig;
-	int        doflist1[NUMVERTICES];
-	IssmDouble     thickness,Jdet;
-	IssmDouble     basis[3];
-	IssmDouble     Dlambda[2],dp[2];
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     grade_g[NUMVERTICES] = {0.0};
+	int        i;
+	int        vertexpidlist[NUMVERTICES];
+	IssmDouble thickness,Jdet;
+	IssmDouble basis[3];
+	IssmDouble Dlambda[2],dp[2];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble grade_g[NUMVERTICES] = {0.0};
 	GaussTria *gauss                = NULL;
 
 	/* Get node coordinates and dof list: */
 	GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 
 	/*Retrieve all inputs we will be needing: */
 	Input* adjoint_input=inputs->GetInput(AdjointEnum);     _assert_(adjoint_input);
@@ -3959,7 +4024,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -3972,7 +4037,7 @@
 
 		for(i=0;i<NUMVERTICES;i++) grade_g[i]+=thickness*Dlambda[1]*Jdet*gauss->weight*basis[i];
 	}
-	gradient->SetValues(NUMVERTICES,doflist1,grade_g,ADD_VAL);
+	gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL);
 
 	/*Clean up and return*/
 	delete gauss;
@@ -3987,7 +4052,7 @@
 
 	/*get gradient indices*/
 	for(int i=0;i<NUMVERTICES;i++){
-		indexing[i]=num_controls*this->nodes[i]->GetVertexDof() + control_index;
+		indexing[i]=num_controls*this->nodes[i]->GetVertexPid() + control_index;
 	}
 
 }
@@ -3996,12 +4061,11 @@
 IssmDouble Tria::RheologyBbarAbsGradient(bool process_units,int weight_index){
 
 	/* Intermediaries */
-	int        ig;
-	IssmDouble     Jelem = 0;
-	IssmDouble     weight;
-	IssmDouble     Jdet;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     dp[NDOF2];
+	IssmDouble Jelem = 0;
+	IssmDouble weight;
+	IssmDouble Jdet;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble dp[NDOF2];
 	GaussTria *gauss = NULL;
 
 	/*retrieve parameters and inputs*/
@@ -4016,7 +4080,7 @@
 
 	/* Start looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4039,13 +4103,10 @@
 /*FUNCTION Tria::SurfaceAverageVelMisfit {{{*/
 IssmDouble Tria::SurfaceAverageVelMisfit(bool process_units,int weight_index){
 
-	const int    numdof=2*NUMVERTICES;
-
-	int        i,ig;
-	IssmDouble     Jelem=0,S,Jdet;
-	IssmDouble     misfit;
-	IssmDouble     vx,vy,vxobs,vyobs,weight;
-	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble Jelem=0,S,Jdet;
+	IssmDouble misfit;
+	IssmDouble vx,vy,vxobs,vyobs,weight;
+	IssmDouble xyz_list[NUMVERTICES][3];
 	GaussTria *gauss=NULL;
 
 	/*If on water, return 0: */
@@ -4064,7 +4125,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(3);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4100,16 +4161,13 @@
 /*FUNCTION Tria::SurfaceLogVelMisfit {{{*/
 IssmDouble Tria::SurfaceLogVelMisfit(bool process_units,int weight_index){
 
-	const int    numdof=NDOF2*NUMVERTICES;
-
-	int        i,ig;
-	IssmDouble     Jelem=0;
-	IssmDouble     misfit,Jdet;
-	IssmDouble     epsvel=2.220446049250313e-16;
-	IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
-	IssmDouble     velocity_mag,obs_velocity_mag;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     vx,vy,vxobs,vyobs,weight;
+	IssmDouble Jelem=0;
+	IssmDouble misfit,Jdet;
+	IssmDouble epsvel=2.220446049250313e-16;
+	IssmDouble meanvel=3.170979198376458e-05; /*1000 m/yr*/
+	IssmDouble velocity_mag,obs_velocity_mag;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble vx,vy,vxobs,vyobs,weight;
 	GaussTria *gauss=NULL;
 
 	/*If on water, return 0: */
@@ -4127,7 +4185,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(4);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4165,16 +4223,13 @@
 /*FUNCTION Tria::SurfaceLogVxVyMisfit {{{*/
 IssmDouble Tria::SurfaceLogVxVyMisfit(bool process_units,int weight_index){
 
-	const int    numdof=NDOF2*NUMVERTICES;
-
-	int        i,ig;
 	int        fit=-1;
-	IssmDouble     Jelem=0, S=0;
-	IssmDouble     epsvel=2.220446049250313e-16;
-	IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
-	IssmDouble     misfit, Jdet;
-	IssmDouble     vx,vy,vxobs,vyobs,weight;
-	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble Jelem=0, S=0;
+	IssmDouble epsvel=2.220446049250313e-16;
+	IssmDouble meanvel=3.170979198376458e-05; /*1000 m/yr*/
+	IssmDouble misfit, Jdet;
+	IssmDouble vx,vy,vxobs,vyobs,weight;
+	IssmDouble xyz_list[NUMVERTICES][3];
 	GaussTria *gauss=NULL;
 
 	/*If on water, return 0: */
@@ -4189,10 +4244,10 @@
 	Input* vy_input     =inputs->GetInput(VyEnum);        _assert_(vy_input);
 	Input* vxobs_input  =inputs->GetInput(InversionVxObsEnum);     _assert_(vxobs_input);
 	Input* vyobs_input  =inputs->GetInput(InversionVyObsEnum);     _assert_(vyobs_input);
-	
+
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(4);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4231,13 +4286,10 @@
 /*FUNCTION Tria::SurfaceAbsVelMisfit {{{*/
 IssmDouble Tria::SurfaceAbsVelMisfit(bool process_units,int weight_index){
 
-	const int    numdof=NDOF2*NUMVERTICES;
-
-	int        i,ig;
-	IssmDouble     Jelem=0;
-	IssmDouble     misfit,Jdet;
-	IssmDouble     vx,vy,vxobs,vyobs,weight;
-	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble Jelem=0;
+	IssmDouble misfit,Jdet;
+	IssmDouble vx,vy,vxobs,vyobs,weight;
+	IssmDouble xyz_list[NUMVERTICES][3];
 	GaussTria *gauss=NULL;
 
 	/*If on water, return 0: */
@@ -4255,7 +4307,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4291,16 +4343,14 @@
 /*}}}*/
 /*FUNCTION Tria::SurfaceRelVelMisfit {{{*/
 IssmDouble Tria::SurfaceRelVelMisfit(bool process_units,int weight_index){
-	const int  numdof=2*NUMVERTICES;
 
-	int        i,ig;
-	IssmDouble     Jelem=0;
-	IssmDouble     scalex=1,scaley=1;
-	IssmDouble     misfit,Jdet;
-	IssmDouble     epsvel=2.220446049250313e-16;
-	IssmDouble     meanvel=3.170979198376458e-05; /*1000 m/yr*/
-	IssmDouble     vx,vy,vxobs,vyobs,weight;
-	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble  Jelem=0;
+	IssmDouble  scalex=1,scaley=1;
+	IssmDouble  misfit,Jdet;
+	IssmDouble  epsvel=2.220446049250313e-16;
+	IssmDouble  meanvel=3.170979198376458e-05; /*1000 m/yr*/
+	IssmDouble  vx,vy,vxobs,vyobs,weight;
+	IssmDouble  xyz_list[NUMVERTICES][3];
 	GaussTria *gauss=NULL;
 
 	/*If on water, return 0: */
@@ -4318,7 +4368,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(4);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4357,12 +4407,11 @@
 IssmDouble Tria::ThicknessAbsGradient(bool process_units,int weight_index){
 
 	/* Intermediaries */
-	int        ig;
-	IssmDouble     Jelem = 0;
-	IssmDouble     weight;
-	IssmDouble     Jdet;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     dp[NDOF2];
+	IssmDouble Jelem = 0;
+	IssmDouble weight;
+	IssmDouble Jdet;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble dp[NDOF2];
 	GaussTria *gauss = NULL;
 
 	/*retrieve parameters and inputs*/
@@ -4377,7 +4426,7 @@
 
 	/* Start looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4401,7 +4450,6 @@
 IssmDouble Tria::ThicknessAlongGradient(bool process_units,int weight_index){
 
 	/* Intermediaries */
-	int         ig;
 	IssmDouble  Jelem = 0;
 	IssmDouble  weight;
 	IssmDouble  Jdet;
@@ -4424,7 +4472,7 @@
 
 	/* Start looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4453,7 +4501,6 @@
 IssmDouble Tria::ThicknessAcrossGradient(bool process_units,int weight_index){
 
 	/* Intermediaries */
-	int         ig;
 	IssmDouble  Jelem = 0;
 	IssmDouble  weight;
 	IssmDouble  Jdet;
@@ -4476,7 +4523,7 @@
 
 	/* Start looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4505,13 +4552,12 @@
 IssmDouble Tria::ThicknessAbsMisfit(bool process_units,int weight_index){
 
 	/*Intermediaries*/
-	int        i,ig;
-	IssmDouble     thickness,thicknessobs,weight;
-	IssmDouble     Jdet;
-	IssmDouble     Jelem = 0;
-	IssmDouble     xyz_list[NUMVERTICES][3];
+	IssmDouble thickness,thicknessobs,weight;
+	IssmDouble Jdet;
+	IssmDouble Jelem = 0;
+	IssmDouble xyz_list[NUMVERTICES][3];
 	GaussTria *gauss = NULL;
-	IssmDouble     dH[2];
+	IssmDouble dH[2];
 
 	/*If on water, return 0: */
 	if(IsOnWater())return 0;
@@ -4524,7 +4570,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4553,7 +4599,7 @@
 	const int    numdof=1*NUMVERTICES;
 
 	/*Intermediaries */
-	int         i,ig,resp;
+	int         i,resp;
 	IssmDouble  Jdet;
 	IssmDouble  thickness,thicknessobs,weight;
 	int         num_responses;
@@ -4580,7 +4626,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4640,7 +4686,7 @@
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,resp,ig;
+	int        i,resp;
 	int       *responses=NULL;
 	int        num_responses;
 	IssmDouble     Jdet;
@@ -4676,7 +4722,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(4);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -4822,7 +4868,7 @@
 ElementVector* Tria::CreatePVectorAdjointStokes(void){
 
 	/*Intermediaries */
-	int        i,resp,ig;
+	int        i,resp;
 	int       *responses=NULL;
 	int        num_responses;
 	IssmDouble     Jdet;
@@ -4858,7 +4904,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(4);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -5005,12 +5051,11 @@
 IssmDouble Tria::DragCoefficientAbsGradient(bool process_units,int weight_index){
 
 	/* Intermediaries */
-	int        ig;
-	IssmDouble     Jelem = 0;
-	IssmDouble     weight;
-	IssmDouble     Jdet;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     dp[NDOF2];
+	IssmDouble Jelem = 0;
+	IssmDouble weight;
+	IssmDouble Jdet;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble dp[NDOF2];
 	GaussTria *gauss = NULL;
 
 	/*retrieve parameters and inputs*/
@@ -5025,7 +5070,7 @@
 
 	/* Start looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -5074,17 +5119,16 @@
 	const int    numdof=NDOF2*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig;
+	int        i,j;
 	bool       incomplete_adjoint;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     Jdet,thickness;
-	IssmDouble     eps1dotdphii,eps1dotdphij;
-	IssmDouble     eps2dotdphii,eps2dotdphij;
-	IssmDouble     mu_prime;
-	IssmDouble     epsilon[3];/* epsilon=[exx,eyy,exy];*/
-	IssmDouble     eps1[2],eps2[2];
-	IssmDouble     phi[NUMVERTICES];
-	IssmDouble     dphi[2][NUMVERTICES];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble Jdet,thickness;
+	IssmDouble eps1dotdphii,eps1dotdphij;
+	IssmDouble eps2dotdphii,eps2dotdphij;
+	IssmDouble mu_prime;
+	IssmDouble epsilon[3];/* epsilon=[exx,eyy,exy];*/
+	IssmDouble eps1[2],eps2[2];
+	IssmDouble dphi[2][NUMVERTICES];
 	GaussTria *gauss=NULL;
 
 	/*Initialize Jacobian with regular MacAyeal (first part of the Gateau derivative)*/
@@ -5100,7 +5144,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -5204,14 +5248,14 @@
 /*FUNCTION Tria::GetVectorFromControlInputs{{{*/
 void  Tria::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data){
 
-	int doflist1[NUMVERTICES];
+	int vertexpidlist[NUMVERTICES];
 	Input *input=NULL;
 
 	/*Get out if this is not an element input*/
 	if(!IsInput(control_enum)) return;
 
 	/*Prepare index list*/
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 
 	/*Get input (either in element or material)*/
 	if(control_enum==MaterialsRheologyBbarEnum || control_enum==MaterialsRheologyZbarEnum){
@@ -5226,14 +5270,14 @@
 		_error_("input " << EnumToStringx(control_enum) << " is not a ControlInput");
 	}
 
-	((ControlInput*)input)->GetVectorFromInputs(vector,&doflist1[0],data);
+	((ControlInput*)input)->GetVectorFromInputs(vector,&vertexpidlist[0],data);
 }
 /*}}}*/
 /*FUNCTION Tria::SetControlInputsFromVector{{{*/
 void  Tria::SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){
 
 	IssmDouble  values[NUMVERTICES];
-	int     doflist1[NUMVERTICES];
+	int     vertexpidlist[NUMVERTICES];
 	Input  *input     = NULL;
 	Input  *new_input = NULL;
 
@@ -5241,11 +5285,11 @@
 	if(!IsInput(control_enum)) return;
 
 	/*Prepare index list*/
-	GradientIndexing(&doflist1[0],control_index);
+	GradientIndexing(&vertexpidlist[0],control_index);
 
 	/*Get values on vertices*/
 	for (int i=0;i<NUMVERTICES;i++){
-		values[i]=vector[doflist1[i]];
+		values[i]=vector[vertexpidlist[i]];
 	}
 	new_input = new TriaP1Input(control_enum,values);
 
@@ -5295,7 +5339,7 @@
 
 	/* compute VelocityFactor */
 	VelocityFactor= n_man*CR*CR*rho_water*g/mu_water;
-	
+
 	gauss=new GaussTria();
 	for (int iv=0;iv<NUMVERTICES;iv++){
 		gauss->GaussVertex(iv);
@@ -5324,23 +5368,22 @@
 ElementMatrix* Tria::CreateKMatrixHydrology(void){
 
 	/*Constants*/
-	const int    numdof=NDOF1*NUMVERTICES;
+	const int  numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries */
-	IssmDouble     diffusivity;
-	int        i,j,ig;
-	IssmDouble     Jdettria,DL_scalar,dt,h;
-	IssmDouble     vx,vy,vel,dvxdx,dvydy;
-	IssmDouble     dvx[2],dvy[2];
-	IssmDouble     v_gauss[2]={0.0};
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     L[NUMVERTICES];
-	IssmDouble     B[2][NUMVERTICES];
-	IssmDouble     Bprime[2][NUMVERTICES];
-	IssmDouble     K[2][2]                        ={0.0};
-	IssmDouble     KDL[2][2]                      ={0.0};
-	IssmDouble     DL[2][2]                        ={0.0};
-	IssmDouble     DLprime[2][2]                   ={0.0};
+	IssmDouble diffusivity;
+	IssmDouble Jdettria,DL_scalar,dt,h;
+	IssmDouble vx,vy,vel,dvxdx,dvydy;
+	IssmDouble dvx[2],dvy[2];
+	IssmDouble v_gauss[2]={0.0};
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble L[NUMVERTICES];
+	IssmDouble B[2][NUMVERTICES];
+	IssmDouble Bprime[2][NUMVERTICES];
+	IssmDouble K[2][2]                        ={0.0};
+	IssmDouble KDL[2][2]                      ={0.0};
+	IssmDouble DL[2][2]                        ={0.0};
+	IssmDouble DLprime[2][2]                   ={0.0};
 	GaussTria *gauss=NULL;
 
 	/*Skip if water or ice shelf element*/
@@ -5362,7 +5405,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -5432,12 +5475,12 @@
 	const int    numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig;
-	IssmDouble     Jdettria,dt;
-	IssmDouble     basal_melting_g;
-	IssmDouble     old_watercolumn_g;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     basis[numdof];
+	int        i,j;
+	IssmDouble Jdettria,dt;
+	IssmDouble basal_melting_g;
+	IssmDouble old_watercolumn_g;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble basis[numdof];
 	GaussTria* gauss=NULL;
 
 	/*Skip if water or ice shelf element*/
@@ -5455,7 +5498,7 @@
 	/*Initialize basal_melting_correction_g to 0, do not forget!:*/
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -5468,7 +5511,7 @@
 		if(reCast<int,IssmDouble>(dt))for(i=0;i<numdof;i++) pe->values[i]+=Jdettria*gauss->weight*(old_watercolumn_g+dt*basal_melting_g)*basis[i];
 		else  for(i=0;i<numdof;i++) pe->values[i]+=Jdettria*gauss->weight*basal_melting_g*basis[i];
 	}
-		
+
 	/*Clean up and return*/
 	delete gauss;
 	return pe;
@@ -5540,7 +5583,7 @@
 #ifdef _HAVE_DAKOTA_
 /*FUNCTION Tria::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);{{{*/
 void  Tria::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){
-	
+
 	int i,j;
 
 	/*Check that name is an element input*/
@@ -5555,7 +5598,7 @@
 
 			/*Get values on the 3 vertices*/
 			for (i=0;i<3;i++){
-				values[i]=vector[this->nodes[i]->GetSidList()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!)
+				values[i]=vector[this->nodes[i]->GetVertexSid()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!)
 			}
 
 			/*Branch on the specified type of update: */
@@ -5566,7 +5609,7 @@
 					IssmDouble  hydrostatic_ratio[3];
 					IssmDouble  surface[3];
 					IssmDouble  bed[3];
-					
+
 					/*retrieve inputs: */
 					GetInputListOnVertices(&thickness_init[0],ThicknessEnum);
 					GetInputListOnVertices(&hydrostatic_ratio[0],GeometryHydrostaticRatioEnum);
@@ -5639,7 +5682,7 @@
 /*}}}*/
 /*FUNCTION Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type);{{{*/
 void  Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){
-	
+
 	int i,j,t;
 	TransientInput* transientinput=NULL;
 	IssmDouble values[3];
@@ -5653,15 +5696,15 @@
 	switch(type){
 
 		case VertexEnum:
-			
+
 			/*Create transient input: */
-						
+
 			parameters->FindParam(&yts,ConstantsYtsEnum);
 			for(t=0;t<ncols;t++){ //ncols is the number of times
 
 				/*create input values: */
 				for(i=0;i<3;i++){
-					row=this->nodes[i]->GetSidList();
+					row=this->nodes[i]->GetVertexSid();
 					values[i]=(IssmDouble)matrix[ncols*row+t];
 				}
 
@@ -5706,18 +5749,18 @@
 
 	/*Intermediaries */
 	int        stabilization;
-	int        i,j,ig,dim;
-	IssmDouble     Jdettria,vx,vy,dvxdx,dvydy,vel,h;
-	IssmDouble     dvx[2],dvy[2];
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     L[NUMVERTICES];
-	IssmDouble     B[2][NUMVERTICES];
-	IssmDouble     Bprime[2][NUMVERTICES];
-	IssmDouble     K[2][2]                          = {0.0};
-	IssmDouble     KDL[2][2]                        = {0.0};
-	IssmDouble     DL[2][2]                         = {0.0};
-	IssmDouble     DLprime[2][2]                    = {0.0};
-	IssmDouble     DL_scalar;
+	int        i,j,dim;
+	IssmDouble Jdettria,vx,vy,dvxdx,dvydy,vel,h;
+	IssmDouble dvx[2],dvy[2];
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble L[NUMVERTICES];
+	IssmDouble B[2][NUMVERTICES];
+	IssmDouble Bprime[2][NUMVERTICES];
+	IssmDouble K[2][2]                          = {0.0};
+	IssmDouble KDL[2][2]                        = {0.0};
+	IssmDouble DL[2][2]                         = {0.0};
+	IssmDouble DLprime[2][2]                    = {0.0};
+	IssmDouble DL_scalar;
 	GaussTria *gauss                            = NULL;
 
 	/*Initialize Element matrix*/
@@ -5741,7 +5784,7 @@
 
 	/*Start looping on the number of gaussian points:*/
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -5815,13 +5858,13 @@
 	const int  numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries*/
-	int        i,j,ig,dim;
-	IssmDouble     vx,vy,Jdettria;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     B[2][NUMVERTICES];
-	IssmDouble     Bprime[2][NUMVERTICES];
-	IssmDouble     DL[2][2]={0.0};
-	IssmDouble     DL_scalar;
+	int        i,j,dim;
+	IssmDouble vx,vy,Jdettria;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble B[2][NUMVERTICES];
+	IssmDouble Bprime[2][NUMVERTICES];
+	IssmDouble DL[2][2]={0.0};
+	IssmDouble DL_scalar;
 	GaussTria  *gauss=NULL;
 
 	/*Initialize Element matrix*/
@@ -5835,7 +5878,7 @@
 
 	/*Start looping on the number of gaussian points:*/
 	gauss=new GaussTria(2);
-	for (ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -5881,12 +5924,12 @@
 
 	/*Constants*/
 	const int    numdof=NDOF1*NUMVERTICES;
-	
+
 	/*Intermediaries */
-	int        i,j,ig;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     dhdt_g,basal_melting_g,surface_mass_balance_g,Jdettria;
-	IssmDouble     L[NUMVERTICES];
+	int        i,j;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble dhdt_g,basal_melting_g,surface_mass_balance_g,Jdettria;
+	IssmDouble L[NUMVERTICES];
 	GaussTria* gauss=NULL;
 
 	/*Initialize Element vector*/
@@ -5897,10 +5940,10 @@
 	Input* surface_mass_balance_input=inputs->GetInput(SurfaceforcingsMassBalanceEnum); _assert_(surface_mass_balance_input);
 	Input* basal_melting_input=inputs->GetInput(BasalforcingsMeltingRateEnum);          _assert_(basal_melting_input);
 	Input* dhdt_input=inputs->GetInput(BalancethicknessThickeningRateEnum);             _assert_(dhdt_input);
-	
+
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 
@@ -5926,10 +5969,10 @@
 	const int    numdof=NDOF1*NUMVERTICES;
 
 	/*Intermediaries */
-	int        i,j,ig;
-	IssmDouble     xyz_list[NUMVERTICES][3];
-	IssmDouble     basal_melting_g,surface_mass_balance_g,dhdt_g,Jdettria;
-	IssmDouble     L[NUMVERTICES];
+	int        i,j;
+	IssmDouble xyz_list[NUMVERTICES][3];
+	IssmDouble basal_melting_g,surface_mass_balance_g,dhdt_g,Jdettria;
+	IssmDouble L[NUMVERTICES];
 	GaussTria* gauss=NULL;
 
 	/*Initialize Element vector*/
@@ -5943,7 +5986,7 @@
 
 	/* Start  looping on the number of gaussian points: */
 	gauss=new GaussTria(2);
-	for(ig=gauss->begin();ig<gauss->end();ig++){
+	for(int ig=gauss->begin();ig<gauss->end();ig++){
 
 		gauss->GaussPoint(ig);
 

Modified: issm/trunk/src/c/classes/objects/Elements/Tria.h
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/Tria.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/Tria.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,17 +28,17 @@
 
 	public:
 
-		int  id;
-		int  sid;
+		int          id;
+		int          sid;
 
-		Node   **nodes;    // 3 nodes
-		Material  *material;   // 1 material ice
-		Matpar  *matpar;   // 1 material parameter
-		int      horizontalneighborsids[3];
+		Node       **nodes;                       // 3 nodes
+		Material    *material;                    // 1 material ice
+		Matpar      *matpar;                      // 1 material parameter
+		int          horizontalneighborsids[3];
 
-		Parameters *parameters;   //pointer to solution parameters
-		Inputs     *inputs;
-		Results    *results;
+		Parameters  *parameters;                  //pointer to solution parameters
+		Inputs      *inputs;
+		Results     *results;
 
 		/*Tria constructors, destructors {{{*/
 		Tria();
@@ -46,12 +46,11 @@
 		~Tria();
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		int   ObjectEnum();
-		Object* copy();
+		void    Echo();
+		void    DeepEcho();
+		int     Id();
+		int     ObjectEnum();
+		Object *copy();
 		/*}}}*/
 		/*Update virtual functions resolution: {{{*/
 		void  InputUpdateFromSolution(IssmDouble* solutiong);
@@ -76,11 +75,14 @@
 		void   ComputeStressTensor();
 		void   Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
 		void   SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
+		void   SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
 		void   CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,Vector<IssmDouble>* df);
 		void   CreatePVector(Vector<IssmDouble>* pf);
 		void   CreateJacobianMatrix(Matrix<IssmDouble>* Jff);
 		void   Delta18oParameterization(void);
 		int    GetNodeIndex(Node* node);
+		int    GetNumberOfNodes(void);
+		void   GetNodesSidList(int* sidlist);
 		int    Sid();
 		bool   IsOnBed();
 		bool   IsFloating(); 
@@ -136,7 +138,6 @@
 		void   MaxVz(IssmDouble* pmaxvz, bool process_units);
 		#endif
 
-
 		#ifdef _HAVE_CONTROL_
 		IssmDouble DragCoefficientAbsGradient(bool process_units,int weight_index);
 		void   GradientIndexing(int* indexing,int control_index);
@@ -189,8 +190,8 @@
 		IssmDouble         GetArea(void);
 		int            GetElementType(void);
 		void	         GetDofList(int** pdoflist,int approximation_enum,int setenum);
-		void	         GetDofList1(int* doflist);
-		void           GetSidList(int* sidlist);
+		void	         GetVertexPidList(int* doflist);
+		void           GetVertexSidList(int* sidlist);
 		void           GetConnectivityList(int* connectivity);
 		void           GetInputListOnVertices(IssmDouble* pvalue,int enumtype);
 		void           GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue);
@@ -202,7 +203,7 @@
 		bool	         IsInput(int name);
 		void	         SetClone(int* minranks);
 		void	         SurfaceNormal(IssmDouble* surface_normal, IssmDouble xyz_list[3][3]);
-		
+
 		#ifdef _HAVE_DIAGNOSTIC_
 		ElementMatrix* CreateKMatrixDiagnosticMacAyeal(void);
 		ElementMatrix* CreateKMatrixDiagnosticMacAyealViscous(void);

Modified: issm/trunk/src/c/classes/objects/Elements/TriaHook.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/TriaHook.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/TriaHook.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -49,7 +49,7 @@
 
 	/*retrieve parameters: */
 	iomodel->Constant(&matpar_id,MeshNumberofelementsEnum); matpar_id++;
-	
+
 	this->numanalyses=in_numanalyses;
 	this->hnodes= new Hook*[in_numanalyses];
 	this->hmaterial=new Hook(&material_id,1);

Modified: issm/trunk/src/c/classes/objects/Elements/TriaHook.h
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/TriaHook.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/TriaHook.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,7 +16,6 @@
 		Hook*  hmaterial; // 1 ice material
 		Hook*  hmatpar; // 1 material parameter
 
-
 		/*FUNCTION constructors, destructors {{{*/
 		TriaHook();
 		TriaHook(int in_numanalyses,int material_id, IoModel* iomodel);
@@ -26,6 +25,4 @@
 
 };
 
-
 #endif //ifndef _TRIAHOOK_H_
-

Modified: issm/trunk/src/c/classes/objects/Elements/TriaRef.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/TriaRef.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/TriaRef.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -318,7 +318,6 @@
 	x3=*(xyz_list+NUMNODES*2+0);
 	y3=*(xyz_list+NUMNODES*2+1);
 
-
 	*(J+NDOF2*0+0)=0.5*(x2-x1);
 	*(J+NDOF2*1+0)=SQRT3/6.0*(2*x3-x1-x2);
 	*(J+NDOF2*0+1)=0.5*(y2-y1);

Modified: issm/trunk/src/c/classes/objects/Elements/TriaRef.h
===================================================================
--- issm/trunk/src/c/classes/objects/Elements/TriaRef.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Elements/TriaRef.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,19 +3,17 @@
  * strain rate generation, etc ...
  */ 
 
-
 #ifndef _TRIAREF_H_
 #define _TRIAREF_H_
 
 class GaussTria;
 
 class TriaRef{
-	
 
 	public: 
 		int* element_type_list; //P1CG, P1DG, MINI, P2...
 		int  element_type;
-		
+
 		TriaRef();
 		TriaRef(const int nummodels);
 		~TriaRef();

Modified: issm/trunk/src/c/classes/objects/ExternalResults/ExternalResult.h
===================================================================
--- issm/trunk/src/c/classes/objects/ExternalResults/ExternalResult.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ExternalResults/ExternalResult.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief abstract class for ExternalResult object
  */ 
 
-
 #ifndef _EXTERNALRESULT_H_
 #define _EXTERNALRESULT_H_
 
@@ -22,7 +21,7 @@
 class ExternalResult: public Object{
 
 	public: 
-		
+
 		virtual        ~ExternalResult(){};
 		/*Virtual functions:{{{*/
 		virtual int   InstanceEnum()=0;

Modified: issm/trunk/src/c/classes/objects/ExternalResults/GenericExternalResult.h
===================================================================
--- issm/trunk/src/c/classes/objects/ExternalResults/GenericExternalResult.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/ExternalResults/GenericExternalResult.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,6 +19,7 @@
 #include "../../../shared/Numerics/recast.h"
 #include "../../../io/io.h"
 #include "../../../EnumDefinitions/EnumDefinitions.h"
+#include "../../../classes/IssmComm.h"
 #include "./ExternalResult.h"
 /*}}}*/
 
@@ -33,7 +34,7 @@
 		int N;
 		int step;
 		IssmDouble time;
-	
+
 	public:
 		/*Diverse: must be in front, as it is used in what follows*/
 		void GenericEcho(void){/*{{{*/
@@ -98,10 +99,6 @@
 		int Id(void){ /*{{{*/ 
 			return -1; 
 		} /*}}}*/
-		int MyRank(void){ /*{{{*/
-			extern int my_rank;
-			return my_rank; 
-		} /*}}}*/
 		int ObjectEnum(void){ /*{{{*/
 			_error_("template ObjectEnum not implemented for this ResultType\n");
 		} /*}}}*/
@@ -111,12 +108,15 @@
 
 		/*GenericExternalResult management: */
 void WriteData(FILE* fid,bool io_gather){ /*{{{*/
-			
-	extern  int my_rank;
+
+	int     my_rank;
 	int     type;
 	int     size;
 	IssmPDouble  passiveDouble;
-	
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*return if now on cpu 0: */
 	if(my_rank)return;
 
@@ -204,10 +204,13 @@
 } /*}}}*/
 template <> inline void GenericExternalResult<char*>::WriteData(FILE* fid,bool io_gather){ /*{{{*/
 
-	extern  int my_rank;
+	int     my_rank;
 	int     type;
 	int     length;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*return if now on cpu 0: */
 	if(my_rank)return;
 
@@ -234,7 +237,7 @@
 	enum_type=in_enum_type;
 	M=in_M;
 	N=in_N;
-	
+
 	step=in_step;
 	time=in_time;
 
@@ -253,8 +256,6 @@
 	xDelete<IssmPDouble>(value);
 } /*}}}*/
 template <> inline void GenericExternalResult<IssmPDouble*>::Echo(void){ /*{{{*/
-	
-	int i,j;
 
 	_printLine_("GenericExternalResult<IssmPDouble*>:");
 	this->GenericEcho();
@@ -262,12 +263,12 @@
 
 } /*}}}*/
 template <> inline void GenericExternalResult<IssmPDouble*>::DeepEcho(void){ /*{{{*/
-	
+
 	int i,j;
 
 	_printLine_("GenericExternalResult<IssmPDouble*>:");
 	this->GenericEcho();
-	
+
 	_printLine_("   matrix size: " << this->M << "-" << this->N);
 	for (i=0;i<this->M;i++){  
 		_printString_("   [ ");
@@ -282,15 +283,17 @@
 	return new GenericExternalResult<IssmPDouble*>(this->id,this->enum_type,this->value,this->M,this->N,this->step,this->time);
 } /*}}}*/
 template <> inline void GenericExternalResult<IssmPDouble*>::WriteData(FILE* fid,bool io_gather){ /*{{{*/
-	
-	extern  int my_rank;
+
+	int     my_rank;
 	int     length;
 	int     type;
 	int     rows,cols;
 	char   *name    = NULL;
-	extern  int my_rank;
 	IssmPDouble passiveDouble;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	if(io_gather){
 		/*we are gathering the data on cpu 0, don't write on other cpus: */
 		if(my_rank) return;

Modified: issm/trunk/src/c/classes/objects/Inputs/BoolInput.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/BoolInput.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/BoolInput.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,8 +22,8 @@
 	return;
 }
 /*}}}*/
-/*FUNCTION BoolInput::BoolInput(IssmDouble* values){{{*/
-BoolInput::BoolInput(int in_enum_type,IssmBool in_value){
+/*FUNCTION BoolInput::BoolInput(int in_enum_type,bool in_value){{{*/
+BoolInput::BoolInput(int in_enum_type,bool in_value){
 
 	enum_type=in_enum_type;
 	value=in_value;
@@ -52,12 +52,6 @@
 /*FUNCTION BoolInput::Id{{{*/
 int    BoolInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION BoolInput::MyRank{{{*/
-int    BoolInput::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION BoolInput::ObjectEnum{{{*/
 int BoolInput::ObjectEnum(void){
 
@@ -67,12 +61,12 @@
 /*}}}*/
 /*FUNCTION BoolInput::copy{{{*/
 Object* BoolInput::copy() {
-	
+
 	return new BoolInput(this->enum_type,this->value);
 
 }
 /*}}}*/
-	
+
 /*BoolInput management*/
 /*FUNCTION BoolInput::InstanceEnum{{{*/
 int BoolInput::InstanceEnum(void){
@@ -98,7 +92,7 @@
 /*}}}*/
 /*FUNCTION BoolInput::SpawnResult{{{*/
 ElementResult* BoolInput::SpawnResult(int step, IssmDouble time){
-	
+
 	return new BoolElementResult(this->enum_type,this->value,step,time);
 
 }

Modified: issm/trunk/src/c/classes/objects/Inputs/BoolInput.h
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/BoolInput.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/BoolInput.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _BOOLINPUT_H_
 #define _BOOLINPUT_H_
 
@@ -17,21 +16,20 @@
 
 	public:
 		/*just hold 3 values for 3 vertices: */
-		int    enum_type;
-		IssmBool value;
+		int  enum_type;
+		bool value;
 
 		/*BoolInput constructors, destructors: {{{*/
 		BoolInput();
-		BoolInput(int enum_type,IssmBool value);
+		BoolInput(int enum_type,bool value);
 		~BoolInput();
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		int   ObjectEnum();
-		Object* copy();
+		void    Echo();
+		void    DeepEcho();
+		int     Id();
+		int     ObjectEnum();
+		Object *copy();
 		/*}}}*/
 		/*BoolInput management: {{{*/
 		int   InstanceEnum();

Modified: issm/trunk/src/c/classes/objects/Inputs/ControlInput.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/ControlInput.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/ControlInput.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -83,12 +83,6 @@
 /*FUNCTION ControlInput::Id{{{*/
 int    ControlInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION ControlInput::MyRank{{{*/
-int    ControlInput::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION ControlInput::ObjectEnum{{{*/
 int ControlInput::ObjectEnum(void){
 
@@ -98,23 +92,23 @@
 /*}}}*/
 /*FUNCTION ControlInput::copy{{{*/
 Object* ControlInput::copy() {
-	
+
 	ControlInput* output=NULL;
 
 	output = new ControlInput();
 	output->enum_type=this->enum_type;
 	output->control_id=this->control_id;
 
-	if(values)      output->values=(Input*)this->values->copy();
-	if(savedvalues) output->savedvalues=(Input*)this->savedvalues->copy();
-	if(minvalues)   output->minvalues=(Input*)this->minvalues->copy();
-	if(maxvalues)   output->maxvalues=(Input*)this->maxvalues->copy();
-	if(gradient)    output->gradient=(Input*)this->gradient->copy();
+	if(values)      output->values      = dynamic_cast<Input*>(this->values->copy());
+	if(savedvalues) output->savedvalues = dynamic_cast<Input*>(this->savedvalues->copy());
+	if(minvalues)   output->minvalues   = dynamic_cast<Input*>(this->minvalues->copy());
+	if(maxvalues)   output->maxvalues   = dynamic_cast<Input*>(this->maxvalues->copy());
+	if(gradient)    output->gradient    = dynamic_cast<Input*>(this->gradient->copy());
 
 	return output;
 }
 /*}}}*/
-	
+
 /*ControlInput management*/
 /*FUNCTION ControlInput::InstanceEnum{{{*/
 int ControlInput::InstanceEnum(void){
@@ -260,7 +254,7 @@
 	if(!values) _error_("Values of " << EnumToStringx(this->enum_type) << " not found");
 
 	if(savedvalues) delete this->savedvalues;
-	this->savedvalues=(Input*)this->values->copy();
+	this->savedvalues=dynamic_cast<Input*>(this->values->copy());
 }/*}}}*/
 /*FUNCTION ControlInput::UpdateValue{{{*/
 void ControlInput::UpdateValue(IssmDouble scalar){
@@ -268,7 +262,7 @@
 	if(!savedvalues) _error_("Values of " << EnumToStringx(this->enum_type) << " not found");
 
 	if(values) delete this->values;
-	this->values=(Input*)this->savedvalues->copy();
+	this->values=dynamic_cast<Input*>(this->savedvalues->copy());
 	this->values->AXPY(gradient,scalar);
 }/*}}}*/
 /*FUNCTION ControlInput::VerticallyIntegrate{{{*/

Modified: issm/trunk/src/c/classes/objects/Inputs/ControlInput.h
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/ControlInput.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/ControlInput.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _CONTROLINPUT_H_
 #define _CONTROLINPUT_H_
 
@@ -33,7 +32,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Inputs/DatasetInput.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/DatasetInput.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/DatasetInput.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -54,12 +54,6 @@
 /*FUNCTION DatasetInput::Id{{{*/
 int    DatasetInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DatasetInput::MyRank{{{*/
-int    DatasetInput::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION DatasetInput::ObjectEnum{{{*/
 int DatasetInput::ObjectEnum(void){
 
@@ -69,7 +63,7 @@
 /*}}}*/
 /*FUNCTION DatasetInput::copy{{{*/
 Object* DatasetInput::copy() {
-	
+
 	DatasetInput* output=NULL;
 
 	output = new DatasetInput();
@@ -88,13 +82,13 @@
 	/*Create new Datasetinput (copy of current input)*/
 	outinput=new DatasetInput();
 	outinput->enum_type=this->enum_type;
-	outinput->inputs=(Inputs*)this->inputs->SpawnTriaInputs(indices);
+	outinput->inputs=dynamic_cast<Inputs*>(this->inputs->SpawnTriaInputs(indices));
 
 	/*Assign output*/
 	return outinput;
 }
 /*}}}*/
-	
+
 /*DatasetInput management*/
 /*FUNCTION DatasetInput::InstanceEnum{{{*/
 int DatasetInput::InstanceEnum(void){
@@ -115,8 +109,8 @@
 
 	/*Get requested input within dataset*/
 	if(index<0 || index > inputs->Size()-1) _error_("index requested (" << index << ") exceeds dataset size (" << inputs->Size() << ")");
-	Input* input=(Input*)this->inputs->GetObjectByOffset(index);
-	
+	Input* input=dynamic_cast<Input*>(this->inputs->GetObjectByOffset(index));
+
 	input->GetInputValue(pvalue,gauss);
 }
 /*}}}*/

Modified: issm/trunk/src/c/classes/objects/Inputs/DatasetInput.h
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/DatasetInput.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/DatasetInput.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for datasetinput object
  */
 
-
 #ifndef _DATASETINPUT_H_
 #define _DATASETINPUT_H_
 
@@ -16,10 +15,9 @@
 class DatasetInput: public Input{
 
 	public:
-		int    enum_type;
+		int     enum_type;
+		Inputs *inputs;
 
-		Inputs*     inputs;
-
 		/*DatasetInput constructors, destructors: {{{*/
 		DatasetInput();
 		DatasetInput(int enum_type);
@@ -29,7 +27,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id();
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Inputs/DoubleInput.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/DoubleInput.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/DoubleInput.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -52,12 +52,6 @@
 /*FUNCTION DoubleInput::Id{{{*/
 int    DoubleInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleInput::MyRank{{{*/
-int    DoubleInput::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION DoubleInput::ObjectEnum{{{*/
 int DoubleInput::ObjectEnum(void){
 
@@ -67,12 +61,12 @@
 /*}}}*/
 /*FUNCTION DoubleInput::copy{{{*/
 Object* DoubleInput::copy() {
-	
+
 	return new DoubleInput(this->enum_type,this->value);
 
 }
 /*}}}*/
-	
+
 /*DoubleInput management*/
 /*FUNCTION DoubleInput::InstanceEnum{{{*/
 int DoubleInput::InstanceEnum(void){

Modified: issm/trunk/src/c/classes/objects/Inputs/DoubleInput.h
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/DoubleInput.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/DoubleInput.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _DOUBLEINPUT_H_
 #define _DOUBLEINPUT_H_
 
@@ -28,7 +27,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Inputs/Input.h
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/Input.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/Input.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief abstract class for Input object
  */ 
 
-
 #ifndef _INPUT_H_
 #define _INPUT_H_
 
@@ -18,7 +17,7 @@
 class Input: public Object{
 
 	public: 
-		
+
 		virtual        ~Input(){};
 
 		virtual int  InstanceEnum()=0; 
@@ -59,7 +58,7 @@
 		virtual void   Extrude()=0;
 		virtual void   GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist)=0;
 		virtual void   GetValuesPtr(IssmDouble** pvalues,int* pnum_values)=0;
-		
+
 		virtual Input* SpawnTriaInput(int* indices)=0;
 		virtual Input* PointwiseDivide(Input* inputB)=0;
 		virtual Input* PointwiseMax(Input* inputmax)=0;

Modified: issm/trunk/src/c/classes/objects/Inputs/IntInput.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/IntInput.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/IntInput.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -47,12 +47,6 @@
 /*FUNCTION IntInput::Id{{{*/
 int    IntInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION IntInput::MyRank{{{*/
-int    IntInput::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION IntInput::ObjectEnum{{{*/
 int IntInput::ObjectEnum(void){
 
@@ -62,7 +56,7 @@
 /*}}}*/
 /*FUNCTION IntInput::copy{{{*/
 Object* IntInput::copy() {
-	
+
 	return new IntInput(this->enum_type,this->value);
 
 }
@@ -97,7 +91,7 @@
 /*}}}*/
 /*FUNCTION IntInput::SpawnResult{{{*/
 ElementResult* IntInput::SpawnResult(int step, IssmDouble time){
-	
+
 	_error_("not supported yet!");
 
 }

Modified: issm/trunk/src/c/classes/objects/Inputs/IntInput.h
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/IntInput.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/IntInput.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _INTINPUT_H_
 #define _INTINPUT_H_
 
@@ -29,7 +28,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Inputs/PentaP1Input.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/PentaP1Input.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/PentaP1Input.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -63,12 +63,6 @@
 /*FUNCTION PentaP1Input::Id{{{*/
 int    PentaP1Input::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION PentaP1Input::MyRank{{{*/
-int    PentaP1Input::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION PentaP1Input::ObjectEnum{{{*/
 int PentaP1Input::ObjectEnum(void){
 
@@ -76,11 +70,11 @@
 
 }
 /*}}}*/
-	
+
 /*PentaP1Input management*/
 /*FUNCTION PentaP1Input::copy{{{*/
 Object* PentaP1Input::copy() {
-	
+
 	return new PentaP1Input(this->enum_type,this->values);
 
 }
@@ -362,7 +356,7 @@
 /*}}}*/
 /*FUNCTION PentaP1Input::ConstrainMin{{{*/
 void PentaP1Input::ConstrainMin(IssmDouble minimum){
-	
+
 	int i;
 	const int numnodes=6;
 
@@ -430,7 +424,7 @@
 /*}}}*/
 /*FUNCTION PentaP1Input::Scale{{{*/
 void PentaP1Input::Scale(IssmDouble scale_factor){
-	
+
 	int i;
 	const int numnodes=6;
 
@@ -469,7 +463,7 @@
 
 	int i;
 	const int numnodes=6;
-		
+
 	if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
 	if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
 
@@ -521,18 +515,16 @@
 	PentaP1Input* outinput=NULL;
 
 	/*Intermediaries*/
-	int               i;
-	PentaP1Input *xinputB     = NULL;
-	int               B_numvalues;
-	const int         numnodes    = 6;
-	IssmDouble            AdotBvalues[numnodes];
+	PentaP1Input *xinputB  = NULL;
+	const int     numnodes = 6;
+	IssmDouble    AdotBvalues[numnodes];
 
 	/*Check that inputB is of the same type*/
 	if (inputB->ObjectEnum()!=PentaP1InputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
 	xinputB=(PentaP1Input*)inputB;
 
 	/*Create point wise sum*/
-	for(i=0;i<numnodes;i++){
+	for(int i=0;i<numnodes;i++){
 		_assert_(xinputB->values[i]!=0);
 		AdotBvalues[i]=this->values[i]/xinputB->values[i];
 	}
@@ -554,7 +546,6 @@
 	/*Intermediaries*/
 	int               i;
 	PentaP1Input *xinputB     = NULL;
-	int               B_numvalues;
 	const int         numnodes    = 6;
 	IssmDouble            minvalues[numnodes];
 
@@ -585,7 +576,6 @@
 	/*Intermediaries*/
 	int               i;
 	PentaP1Input *xinputB     = NULL;
-	int               B_numvalues;
 	const int         numnodes    = 6;
 	IssmDouble            maxvalues[numnodes];
 

Modified: issm/trunk/src/c/classes/objects/Inputs/PentaP1Input.h
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/PentaP1Input.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/PentaP1Input.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for PentaP1Input object
  */
 
-
 #ifndef _PENTAP1INPUT_H_
 #define _PENTAP1INPUT_H_
 
@@ -17,7 +16,7 @@
 
 	public:
 		/*just hold 6 values for 6 vertices: */
-		int    enum_type;
+		int        enum_type;
 		IssmDouble values[6];
 
 		/*PentaP1Input constructors, destructors: {{{*/
@@ -26,12 +25,11 @@
 		~PentaP1Input();
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		int   ObjectEnum();
-		Object* copy();
+		void    Echo();
+		void    DeepEcho();
+		int     Id();
+		int     ObjectEnum();
+		Object *copy();
 		/*}}}*/
 		/*PentaP1Input management: {{{*/
 		int   InstanceEnum();

Modified: issm/trunk/src/c/classes/objects/Inputs/TransientInput.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/TransientInput.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/TransientInput.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -78,12 +78,6 @@
 /*FUNCTION TransientInput::Id{{{*/
 int    TransientInput::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION TransientInput::MyRank{{{*/
-int    TransientInput::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION TransientInput::ObjectEnum{{{*/
 int TransientInput::ObjectEnum(void){
 
@@ -108,7 +102,7 @@
 
 }
 /*}}}*/
-	
+
 /*TransientInput management*/
 /*FUNCTION TransientInput::InstanceEnum{{{*/
 int TransientInput::InstanceEnum(void){
@@ -221,7 +215,7 @@
 
 	/*Retrieve interpolated values for this time step: */
 	Input* input=GetTimeInput(time);
-		   
+
 	/*Call input function*/
 	input->GetInputDerivativeValue(p,xyz_list,gauss);
 
@@ -236,7 +230,7 @@
 /*}}}*/
 /*FUNCTION TransientInput::GetInputAverage{{{*/
 void TransientInput::GetInputAverage(IssmDouble* pvalue){
-	
+
 	IssmDouble time;
 
 	/*First, recover current time from parameters: */
@@ -247,7 +241,7 @@
 
 	/*Call input function*/
 	input->GetInputAverage(pvalue);
-			   
+
 	delete input;
 
 }
@@ -301,10 +295,10 @@
 
    /*Retrieve interpolated values for this time step: */
 	Input* input=GetTimeInput(time);
-		   
+
 	/*Call input function*/
 	input->SquareMin(psquaremin,process_units,parameters);
-			   
+
 	delete input;
 
 }
@@ -323,7 +317,7 @@
 
 	/*Call input function*/
 	infnorm=input->InfinityNorm();
-			   
+
 	/*Clean-up and return*/
 	delete input;
 	return infnorm;
@@ -340,10 +334,10 @@
 
    /*Retrieve interpolated values for this time step: */
 	Input* input=GetTimeInput(time);
-		   
+
 	/*Call input function*/
 	max=input->Max();
-			   
+
 	delete input;
 
 	return max;
@@ -405,7 +399,7 @@
 
 	/*Call input function*/
 	minabs=input->MinAbs();
-			   
+
 	/*Clean-up and return*/
 	delete input;
 	return minabs;
@@ -421,67 +415,54 @@
 
 	/*Retrieve interpolated values for this time step: */
 	Input* input=GetTimeInput(time);
-		   
+
 	/*Call input function*/
 	input->GetVectorFromInputs(vector,doflist);
-			   
+
 	delete input;
 
 } /*}}}*/
 /*FUNCTION TransientInput::GetTimeInput{{{*/
 Input* TransientInput::GetTimeInput(IssmDouble intime){
 
-	int     i,j;
-	IssmDouble  deltat;
-	IssmDouble  alpha1,alpha2;
-	bool    found=false;
-	Input*  input=NULL;
-	Input*  input1=NULL;
-	Input*  input2=NULL;
+	IssmDouble deltat;
+	IssmDouble alpha1,alpha2;
+	int        found;
+	int        offset;
 
-	/*Ok, we have the time, go through the timesteps, and figure out which interval we 
+	Input *input  = NULL;
+	Input *input1 = NULL;
+	Input *input2 = NULL;
+
+	/*go through the timesteps, and figure out which interval we 
 	 *fall within. Then interpolate the values on this interval: */
-	if(intime<this->timesteps[0]){
+	found=binary_search(&offset,intime,this->timesteps,this->numtimesteps);
+	if(!found) _error_("Input not found (is TransientInput sorted ?)");
+
+	if (offset==-1){
 		/*get values for the first time: */
+		_assert_(intime<this->timesteps[0]);
 		input=(Input*)((Input*)this->inputs->GetObjectByOffset(0))->copy();
-		found=true;
 	}
-	else if(intime>this->timesteps[this->numtimesteps-1]){
+	else if(offset==(this->numtimesteps-1)){
 		/*get values for the last time: */
-		input=(Input*)((Input*)this->inputs->GetObjectByOffset(numtimesteps-1))->copy();
-		found=true;
+		_assert_(intime>=this->timesteps[offset]);
+		input=(Input*)((Input*)this->inputs->GetObjectByOffset(offset))->copy();
 	}
 	else{
-		/*Find which interval we fall within: */
-		for(i=0;i<this->numtimesteps;i++){
-			if(intime==this->timesteps[i]){
-				/*We are right on one step time: */
-				input=(Input*)((Input*)this->inputs->GetObjectByOffset(i))->copy();
-				found=true;
-				break; //we are done with the time interpolation.
-			}
-			else{
-				if(this->timesteps[i]<intime && intime<this->timesteps[i+1]){
-					/*ok, we have the interval ]i:i+1[. Interpolate linearly for now: */
-					deltat=this->timesteps[i+1]-this->timesteps[i];
-					alpha2=(intime-this->timesteps[i])/deltat;
-					alpha1=(1.0-alpha2);
+		/*get values between two times [offset:offset+1[, Interpolate linearly*/
+		_assert_(intime>=this->timesteps[offset] && intime<this->timesteps[offset+1]);
+		deltat=this->timesteps[offset+1]-this->timesteps[offset];
+		alpha2=(intime-this->timesteps[offset])/deltat;
+		alpha1=(1.0-alpha2);
 
-					input1=(Input*)this->inputs->GetObjectByOffset(i); 
-					input2=(Input*)this->inputs->GetObjectByOffset(i+1);
+		input1=(Input*)this->inputs->GetObjectByOffset(offset); 
+		input2=(Input*)this->inputs->GetObjectByOffset(offset+1);
 
-					input=(Input*)input1->copy();
-					input->Scale(alpha1);
-					input->AXPY(input2,alpha2);
-
-					found=true;
-					break;
-				}
-				else continue; //keep looking on the next interval
-			}
-		}
+		input=(Input*)input1->copy();
+		input->Scale(alpha1);
+		input->AXPY(input2,alpha2);
 	}
-	if(!found)_error_("did not find time interval on which to interpolate forcing values!");
 
 	/*Assign output pointer*/
 	return input;

Modified: issm/trunk/src/c/classes/objects/Inputs/TransientInput.h
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/TransientInput.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/TransientInput.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for transientinput object
  */
 
-
 #ifndef _TRANSIENTINPUT_H_
 #define _TRANSIENTINPUT_H_
 
@@ -16,11 +15,11 @@
 class TransientInput: public Input{
 
 	public:
-		int     enum_type;
-		int     numtimesteps;
-		Inputs* inputs;
-		IssmDouble* timesteps;
-		Parameters* parameters; //to find current time.
+		int         enum_type;
+		int         numtimesteps;
+		Inputs     *inputs;
+		IssmDouble *timesteps;
+		Parameters *parameters;     //to find current time.
 
 		/*TransientInput constructors, destructors: {{{*/
 		TransientInput();
@@ -32,7 +31,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id();
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Inputs/TriaP1Input.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/TriaP1Input.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/TriaP1Input.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -63,12 +63,6 @@
 /*FUNCTION TriaP1Input::Id{{{*/
 int    TriaP1Input::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION TriaP1Input::MyRank{{{*/
-int    TriaP1Input::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION TriaP1Input::ObjectEnum{{{*/
 int TriaP1Input::ObjectEnum(void){
 
@@ -78,12 +72,12 @@
 /*}}}*/
 /*FUNCTION TriaP1Input::copy{{{*/
 Object* TriaP1Input::copy() {
-	
+
 	return new TriaP1Input(this->enum_type,this->values);
 
 }
 /*}}}*/
-	
+
 /*TriaP1Input management*/
 /*FUNCTION TriaP1Input::InstanceEnum{{{*/
 int TriaP1Input::InstanceEnum(void){
@@ -213,7 +207,7 @@
 /*}}}*/
 /*FUNCTION TriaP1Input::ContrainMin{{{*/
 void TriaP1Input::ConstrainMin(IssmDouble minimum){
-	
+
 	int i;
 	const int numnodes=3;
 
@@ -281,7 +275,7 @@
 /*}}}*/
 /*FUNCTION TriaP1Input::Scale{{{*/
 void TriaP1Input::Scale(IssmDouble scale_factor){
-	
+
 	int i;
 	const int numnodes=3;
 
@@ -332,7 +326,7 @@
 
 	int i;
 	const int numnodes=3;
-		
+
 	if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
 	if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
 
@@ -360,11 +354,10 @@
 	TriaP1Input* outinput=NULL;
 
 	/*Intermediaries*/
-	int               i;
-	TriaP1Input *xinputB     = NULL;
-	int               B_numvalues;
-	const int         numnodes    = 3;
-	IssmDouble            minvalues[numnodes];
+	int          i;
+	TriaP1Input *xinputB  = NULL;
+	const int    numnodes = 3;
+	IssmDouble   minvalues[numnodes];
 
 	/*Check that inputB is of the same type*/
 	if (inputB->ObjectEnum()!=TriaP1InputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
@@ -393,7 +386,6 @@
 	/*Intermediaries*/
 	int               i;
 	TriaP1Input *xinputB     = NULL;
-	int               B_numvalues;
 	const int         numnodes    = 3;
 	IssmDouble            maxvalues[numnodes];
 

Modified: issm/trunk/src/c/classes/objects/Inputs/TriaP1Input.h
===================================================================
--- issm/trunk/src/c/classes/objects/Inputs/TriaP1Input.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Inputs/TriaP1Input.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for TriaP1Input object
  */
 
-
 #ifndef _TRIAP1INPUT_H_
 #define _TRIAP1INPUT_H_
 
@@ -17,7 +16,7 @@
 
 	public:
 		/*just hold 3 values for 3 vertices: */
-		int    enum_type;
+		int        enum_type;
 		IssmDouble values[3];
 
 		/*TriaP1Input constructors, destructors: {{{*/
@@ -26,12 +25,11 @@
 		~TriaP1Input();
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		int   ObjectEnum();
-		Object* copy();
+		void    Echo();
+		void    DeepEcho();
+		int     Id();
+		int     ObjectEnum();
+		Object *copy();
 		/*}}}*/
 		/*TriaP1Input management: {{{*/
 		int   InstanceEnum();

Modified: issm/trunk/src/c/classes/objects/KML/KMLFileReadUtils.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KMLFileReadUtils.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KMLFileReadUtils.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -544,7 +544,7 @@
 					  char* ktag,
 					  FILE* fid){
 
-	int     i=-1,j;
+	int     i=-1;
 	char*   kstr;
 	char*   ktok;
 	double* dval2=NULL;

Modified: issm/trunk/src/c/classes/objects/KML/KMLFileReadUtils.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KMLFileReadUtils.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KMLFileReadUtils.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -54,4 +54,3 @@
 				   FILE* fid);
 
 #endif  /* _KMLFILEREADUTILS_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Attribute.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Attribute.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Attribute.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,10 +30,6 @@
 		virtual void  DeepEcho();
 		virtual void  DeepEcho(const char* indent);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
@@ -47,4 +43,3 @@
 
 };
 #endif  /* _KML_ATTRIBUTE_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_ColorStyle.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_ColorStyle.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_ColorStyle.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -35,9 +35,6 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
 		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
@@ -45,4 +42,3 @@
 
 };
 #endif  /* _KML_COLORSTYLE_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Comment.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Comment.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Comment.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,10 +30,6 @@
 		virtual void  DeepEcho();
 		virtual void  DeepEcho(const char* indent);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
@@ -47,4 +43,3 @@
 
 };
 #endif  /* _KML_COMMENT_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Container.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Container.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Container.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -33,14 +33,9 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_CONTAINER_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Document.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Document.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Document.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -124,4 +124,3 @@
 	return;
 }
 /*}}}*/
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Document.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Document.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Document.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,14 +30,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_DOCUMENT_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Feature.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Feature.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Feature.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -44,14 +44,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_FEATURE_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_File.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_File.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_File.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -89,7 +89,6 @@
 	char*        kstri;
 	int          ncom=0;
 	char**       pcom=NULL;
-	KML_Object*  kobj;
 
 /*  get object attributes and check for solo tag  */
 

Modified: issm/trunk/src/c/classes/objects/KML/KML_File.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_File.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_File.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -31,14 +31,9 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_FILE_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Folder.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Folder.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Folder.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,14 +30,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_FOLDER_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Geometry.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Geometry.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Geometry.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -29,14 +29,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_GEOMETRY_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_GroundOverlay.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_GroundOverlay.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_GroundOverlay.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -36,14 +36,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_GROUNDOVERLAY_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Icon.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Icon.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Icon.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -44,14 +44,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_ICON_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_LatLonBox.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_LatLonBox.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_LatLonBox.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -43,7 +43,6 @@
 /*FUNCTION KML_LatLonBox::Echo {{{*/
 void  KML_LatLonBox::Echo(){
 
-
 	_printLine_("KML_LatLonBox:");
 	KML_Object::Echo();
 

Modified: issm/trunk/src/c/classes/objects/KML/KML_LatLonBox.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_LatLonBox.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_LatLonBox.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -35,14 +35,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_LATLONBOX_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_LineString.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_LineString.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_LineString.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -38,14 +38,9 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_LINESTRING_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_LineStyle.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_LineStyle.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_LineStyle.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -62,7 +62,6 @@
 /*FUNCTION KML_LineStyle::DeepEcho {{{*/
 void  KML_LineStyle::DeepEcho(const char* indent){
 
-	int   i;
 	bool  flag=true;
 
 	if(flag) _pprintLine_(indent << "KML_LineStyle:");

Modified: issm/trunk/src/c/classes/objects/KML/KML_LineStyle.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_LineStyle.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_LineStyle.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -31,14 +31,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_LINESTYLE_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_LinearRing.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_LinearRing.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_LinearRing.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -38,14 +38,9 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_LINEARRING_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_MultiGeometry.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_MultiGeometry.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_MultiGeometry.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -34,14 +34,9 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_MULTIGEOMETRY_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Object.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Object.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Object.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -31,10 +31,6 @@
 		virtual void  DeepEcho();
 		virtual void  DeepEcho(const char* indent);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
@@ -53,4 +49,3 @@
 
 };
 #endif  /* _KML_OBJECT_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Overlay.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Overlay.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Overlay.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -36,14 +36,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_OVERLAY_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Placemark.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Placemark.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Placemark.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -34,14 +34,9 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_PLACEMARK_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Point.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Point.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Point.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -36,14 +36,9 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_POINT_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_PolyStyle.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_PolyStyle.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_PolyStyle.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -64,7 +64,6 @@
 /*FUNCTION KML_PolyStyle::DeepEcho {{{*/
 void  KML_PolyStyle::DeepEcho(const char* indent){
 
-	int   i;
 	bool  flag=true;
 
 	if(flag) _pprintLine_(indent << "KML_PolyStyle:");

Modified: issm/trunk/src/c/classes/objects/KML/KML_PolyStyle.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_PolyStyle.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_PolyStyle.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -32,14 +32,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_POLYSTYLE_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Polygon.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Polygon.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Polygon.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -249,7 +249,6 @@
 				xDelete<char>(kstrj);
 			}
 
-
 		else if (!strncmp(kstri,"<",1))
 			KML_Geometry::Read(fid,kstri);
 

Modified: issm/trunk/src/c/classes/objects/KML/KML_Polygon.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Polygon.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Polygon.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -40,14 +40,9 @@
 		void  Read(FILE* fid,char* kstr);
 		void  WriteExp(FILE* fid,const char* nstr,int sgn,double cm,double sp);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_POLYGON_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Style.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Style.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Style.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -38,14 +38,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_STYLE_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_StyleSelector.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_StyleSelector.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_StyleSelector.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -92,4 +92,3 @@
 	return;
 }
 /*}}}*/
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_StyleSelector.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_StyleSelector.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_StyleSelector.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -29,14 +29,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_STYLESELECTOR_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_SubStyle.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_SubStyle.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_SubStyle.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -92,4 +92,3 @@
 	return;
 }
 /*}}}*/
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_SubStyle.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_SubStyle.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_SubStyle.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -29,14 +29,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_SUBSTYLE_H */
-

Modified: issm/trunk/src/c/classes/objects/KML/KML_Unknown.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Unknown.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Unknown.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -78,10 +78,10 @@
 	if (value     ) {
 		valuei=xNew<char>(strlen(value)+1);
 		memcpy(valuei,value,(strlen(value)+1)*sizeof(char)); 
-        
+
 		vtoken=strtok(valuei,nl);
 		if(flag) _pprintString_(indent << "         value: \"" << vtoken);
-    
+
 		while (vtoken=strtok(NULL,nl))
 			if(flag) _pprintString_("\n" << indent << "                 " << vtoken);
 		if(flag) _pprintLine_("\"");
@@ -109,10 +109,10 @@
 	if (value     ) {
 		valuei=xNew<char>(strlen(value)+1);
 		memcpy(valuei,value,(strlen(value)+1)*sizeof(char)); 
-        
+
 		vtoken=strtok(valuei,nl);
 		fprintf(filout,"%s  %s\n",indent,vtoken);
-    
+
 		while (vtoken=strtok(NULL,nl))
 			fprintf(filout,"%s  %s\n",indent,vtoken);
 

Modified: issm/trunk/src/c/classes/objects/KML/KML_Unknown.h
===================================================================
--- issm/trunk/src/c/classes/objects/KML/KML_Unknown.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/KML/KML_Unknown.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -32,14 +32,9 @@
 		void  Write(FILE* fid,const char* indent);
 		void  Read(FILE* fid,char* kstr);
 		int   Id(){_error_("Not implemented yet.");};
-		int   MyRank(){_error_("Not implemented yet.");};
-		void  Marshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
-		int   MarshallSize(){_error_("Not implemented yet.");};
-		void  Demarshall(char** pmarshalled_dataset){_error_("Not implemented yet.");};
 		int   ObjectEnum(){_error_("Not implemented yet.");};
 		Object* copy(){_error_("Not implemented yet.");};
 		/*}}}*/
 
 };
 #endif  /* _KML_UNKNOWN_H */
-

Modified: issm/trunk/src/c/classes/objects/Loads/Friction.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Friction.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Friction.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -190,7 +190,6 @@
 	 * alpha_complement= Neff ^r * vel ^s*/
 
 	/*diverse: */
-	int     i;
 	IssmDouble  r,s;
 	IssmDouble  vx,vy,vz,vmag;
 	IssmDouble  drag_p,drag_q;
@@ -256,7 +255,6 @@
 	 * alpha_complement= Neff ^r * vel ^s*/
 
 	/*diverse: */
-	int     i;
 	IssmDouble  r,s;
 	IssmDouble  vx,vy,vz,vmag;
 	IssmDouble  drag_p,drag_q;

Modified: issm/trunk/src/c/classes/objects/Loads/Friction.h
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Friction.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Friction.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -24,7 +24,7 @@
 		Friction();
 		Friction(const char* element_type, Inputs* inputs,Matpar* matpar, int analysis_type);
 		~Friction();
-	
+
 		void  Echo(void);
 		void  GetAlpha2(IssmDouble* palpha2, GaussTria* gauss,int vxenum,int vyenum,int vzenum);
 		void  GetAlpha2(IssmDouble* palpha2, GaussPenta* gauss,int vxenum,int vyenum,int vzenum);

Modified: issm/trunk/src/c/classes/objects/Loads/Icefront.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Icefront.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Icefront.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -51,7 +51,7 @@
 	int  icefront_mparid;
 	int  icefront_node_ids[NUMVERTICESQUA]; //initialize with largest size
 	int  icefront_fill;
-	
+
 	/*find parameters: */
 	iomodel->Constant(&dim,MeshDimensionEnum);
 	iomodel->Constant(&numberofelements,MeshNumberofelementsEnum);
@@ -89,7 +89,7 @@
 
 	/*Fill*/
 	icefront_fill=reCast<int>(iomodel->Data(DiagnosticIcefrontEnum)[segment_width*i+segment_width-1]);
-	
+
 	/*Ok, we have everything to build the object: */
 	this->id=icefront_id;
 	this->analysis_type=in_analysis_type;
@@ -103,7 +103,7 @@
 	this->inputs=new Inputs();
 	this->inputs->AddInput(new IntInput(FillEnum,icefront_fill));
 	this->inputs->AddInput(new IntInput(TypeEnum,in_icefront_type));
-	
+
 	//parameters and hooked fields: we still can't point to them, they may not even exist. Configure will handle this.
 	this->parameters=NULL;
 	this->nodes= NULL;
@@ -111,7 +111,6 @@
 	this->matpar= NULL;
 }
 
-
 /*}}}*/
 /*FUNCTION Icefront::~Icefront() {{{*/
 Icefront::~Icefront(){
@@ -156,12 +155,6 @@
 /*FUNCTION Icefront::Id {{{*/
 int    Icefront::Id(void){ return id; }
 /*}}}*/
-/*FUNCTION Icefront::MyRank {{{*/
-int    Icefront::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Icefront::ObjectEnum{{{*/
 int Icefront::ObjectEnum(void){
 
@@ -171,7 +164,7 @@
 /*}}}*/
 /*FUNCTION Icefront::copy {{{*/
 Object* Icefront::copy() {
-	
+
 	Icefront* icefront=NULL;
 
 	icefront=new Icefront();
@@ -277,6 +270,58 @@
 	this->CreateKMatrix(Jff,NULL);
 }
 /*}}}*/
+/*FUNCTION Icefront::GetNodesSidList{{{*/
+void Icefront::GetNodesSidList(int* sidlist){
+
+	int type;
+	inputs->GetInputValue(&type,TypeEnum);
+	_assert_(sidlist);
+	_assert_(nodes);
+
+	switch(type){
+		case MacAyeal2dIceFrontEnum:
+		case MacAyeal3dIceFrontEnum:
+			for(int i=0;i<NUMVERTICESSEG;i++) sidlist[i]=nodes[i]->Sid();
+			return;
+#ifdef _HAVE_3D_
+		case PattynIceFrontEnum:
+		case StokesIceFrontEnum:
+			for(int i=0;i<NUMVERTICESQUA;i++) sidlist[i]=nodes[i]->Sid();
+			return;
+#endif
+		default:
+			_error_("Icefront type " << EnumToStringx(type) << " not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Icefront::GetNumberOfNodes{{{*/
+int Icefront::GetNumberOfNodes(void){
+
+	int type;
+	inputs->GetInputValue(&type,TypeEnum);
+
+	switch(type){
+		case MacAyeal2dIceFrontEnum:
+			return NUMVERTICESSEG;
+#ifdef _HAVE_3D_
+		case MacAyeal3dIceFrontEnum:
+			return NUMVERTICESSEG;
+		case PattynIceFrontEnum:
+			return NUMVERTICESQUA;
+		case StokesIceFrontEnum:
+			return NUMVERTICESQUA;
+#endif
+		default:
+			_error_("Icefront type " << EnumToStringx(type) << " not supported yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION Icefront::IsPenalty{{{*/
+bool Icefront::IsPenalty(void){
+	return false;
+}
+/*}}}*/
 /*FUNCTION Icefront::PenaltyCreateKMatrix {{{*/
 void  Icefront::PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs, IssmDouble kmax){
 	/*do nothing: */
@@ -294,6 +339,57 @@
 	this->PenaltyCreateKMatrix(Jff,NULL,kmax);
 }
 /*}}}*/
+/*FUNCTION Icefront::SetwiseNodeConnectivity{{{*/
+void Icefront::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
+
+	/*Output */
+	int d_nz = 0;
+	int o_nz = 0;
+
+	/*Loop over all nodes*/
+	for(int i=0;i<this->GetNumberOfNodes();i++){
+
+		if(!flags[this->nodes[i]->Sid()]){
+
+			/*flag current node so that no other element processes it*/
+			flags[this->nodes[i]->Sid()]=true;
+
+			/*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
+			switch(set2_enum){
+				case FsetEnum:
+					if(nodes[i]->indexing.fsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case GsetEnum:
+					if(nodes[i]->indexing.gsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case SsetEnum:
+					if(nodes[i]->indexing.ssize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				default: _error_("not supported");
+			}
+		}
+	}
+
+	/*Assign output pointers: */
+	*pd_nz=d_nz;
+	*po_nz=o_nz;
+}
+/*}}}*/
 /*FUNCTION Icefront::InAnalysis{{{*/
 bool Icefront::InAnalysis(int in_analysis_type){
 	if (in_analysis_type==this->analysis_type)return true;
@@ -478,10 +574,9 @@
 /*FUNCTION Icefront::CreatePVectorDiagnosticMacAyeal3d{{{*/
 ElementVector* Icefront::CreatePVectorDiagnosticMacAyeal3d(void){
 
-	Icefront* icefront=NULL;
-	Penta*    penta=NULL;
-	Tria*     tria=NULL;
-	bool      onbed;
+	Icefront *icefront = NULL;
+	Penta    *penta    = NULL;
+	Tria     *tria     = NULL;
 
 	/*Cast element onto Penta*/
 	penta   =(Penta*)this->element;
@@ -662,7 +757,6 @@
 /*FUNCTION Icefront::GetDofList {{{*/
 void  Icefront::GetDofList(int** pdoflist,int approximation_enum,int setenum){
 
-	int i,j;
 	int numberofdofs=0;
 	int count=0;
 	int type;
@@ -671,21 +765,20 @@
 	/*output: */
 	int* doflist=NULL;
 
-	
 	/*recover type: */
 	inputs->GetInputValue(&type,TypeEnum);
 
 	/*Some checks for debugging*/
 	_assert_(nodes);
-		
+
 	/*How many nodes? :*/
 	if(type==MacAyeal2dIceFrontEnum || type==MacAyeal3dIceFrontEnum)
 	 numberofnodes=2;
 	else 
 	 numberofnodes=4;
-	
+
 	/*Figure out size of doflist: */
-	for(i=0;i<numberofnodes;i++){
+	for(int i=0;i<numberofnodes;i++){
 		numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
 	}
 
@@ -694,7 +787,7 @@
 
 	/*Populate: */
 	count=0;
-	for(i=0;i<numberofnodes;i++){
+	for(int i=0;i<numberofnodes;i++){
 		nodes[i]->GetDofList(doflist+count,approximation_enum,setenum);
 		count+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
 	}

Modified: issm/trunk/src/c/classes/objects/Loads/Icefront.h
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Icefront.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Icefront.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -47,7 +47,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -71,9 +70,13 @@
 		void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
 		void  CreatePVector(Vector<IssmDouble>* pf);
 		void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff);
+		int   GetNumberOfNodes(void);
+		void  GetNodesSidList(int* sidlist);
+		bool  IsPenalty(void);
 		void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
 		void  PenaltyCreatePVector(Vector<IssmDouble>*  pf, IssmDouble kmax);
 		void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax);
+		void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
 		/*Load management: {{{*/

Modified: issm/trunk/src/c/classes/objects/Loads/Load.h
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Load.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Load.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,7 +4,6 @@
  * It is derived from Load, so DataSets can contain them.
  */ 
 
-
 #ifndef _LOAD_H_
 #define _LOAD_H_
 
@@ -24,9 +23,10 @@
 	public: 
 
 		virtual       ~Load(){};
-		
-		/*Virtual functions: {{{*/
 		virtual void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
+		virtual bool  IsPenalty(void)=0;
+		virtual int   GetNumberOfNodes(void)=0;
+		virtual void  GetNodesSidList(int* sidlist)=0;
 		virtual void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
 		virtual void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs)=0;
 		virtual void  CreatePVector(Vector<IssmDouble>* pf)=0;
@@ -35,6 +35,6 @@
 		virtual void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs, IssmDouble kmax)=0;
 		virtual void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax)=0;
 		virtual bool  InAnalysis(int analysis_type)=0;
-		/*}}}*/
+		virtual void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum)=0;
 };
 #endif

Modified: issm/trunk/src/c/classes/objects/Loads/Numericalflux.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Numericalflux.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Numericalflux.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -33,7 +33,7 @@
 	this->nodes=NULL;
 }
 /*}}}*/
-/*}}}*//*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{*/
+/*FUNCTION Numericalflux::Numericalflux(int id, int i, IoModel* iomodel, int analysis_type) {{{*/
 Numericalflux::Numericalflux(int numericalflux_id,int i, IoModel* iomodel, int in_analysis_type){
 
 	/* Intermediary */
@@ -174,7 +174,7 @@
 	 _printLine_("      NULL");
 	_printLine_("   inputs");
 	inputs->DeepEcho();
-	
+
 }		
 /*}}}*/
 /*FUNCTION Numericalflux::Id {{{*/
@@ -182,12 +182,6 @@
 	return id;
 }
 /*}}}*/
-/*FUNCTION Numericalflux::MyRank {{{*/
-int    Numericalflux::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Numericalflux::ObjectEnum{{{*/
 int Numericalflux::ObjectEnum(void){
 
@@ -197,7 +191,7 @@
 /*}}}*/
 /*FUNCTION Numericalflux::copy {{{*/
 Object* Numericalflux::copy() {
-	
+
 	Numericalflux* numericalflux=NULL;
 
 	numericalflux=new Numericalflux();
@@ -310,6 +304,48 @@
 
 }
 /*}}}*/
+/*FUNCTION Numericalflux::GetNodesSidList{{{*/
+void Numericalflux::GetNodesSidList(int* sidlist){
+
+	int type;
+	inputs->GetInputValue(&type,TypeEnum);
+	_assert_(sidlist);
+	_assert_(nodes);
+
+	switch(type){
+		case InternalEnum:
+			for(int i=0;i<NUMVERTICES_INTERNAL;i++) sidlist[i]=nodes[i]->Sid();
+			return;
+		case BoundaryEnum:
+			for(int i=0;i<NUMVERTICES_BOUNDARY;i++) sidlist[i]=nodes[i]->Sid();
+			return;
+		default:
+			_error_("Numericalflux type " << EnumToStringx(type) << " not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Numericalflux::GetNumberOfNodes{{{*/
+int Numericalflux::GetNumberOfNodes(void){
+
+	int type;
+	inputs->GetInputValue(&type,TypeEnum);
+
+	switch(type){
+		case InternalEnum:
+			return NUMVERTICES_INTERNAL;
+		case BoundaryEnum:
+			return NUMVERTICES_BOUNDARY;
+		default:
+			_error_("Numericalflux type " << EnumToStringx(type) << " not supported yet");
+	}
+
+}
+/*}}}*/
+/*FUNCTION Numericalflux::IsPenalty{{{*/
+bool Numericalflux::IsPenalty(void){
+	return false;
+}
+/*}}}*/
 /*FUNCTION Numericalflux::PenaltyCreateKMatrix {{{*/
 void  Numericalflux::PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,IssmDouble kmax){
 
@@ -332,7 +368,58 @@
 	else return false;
 }
 /*}}}*/
+/*FUNCTION Numericalflux::SetwiseNodeConnectivity{{{*/
+void Numericalflux::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
 
+	/*Output */
+	int d_nz = 0;
+	int o_nz = 0;
+
+	/*Loop over all nodes*/
+	for(int i=0;i<this->GetNumberOfNodes();i++){
+
+		if(!flags[this->nodes[i]->Sid()]){
+
+			/*flag current node so that no other element processes it*/
+			flags[this->nodes[i]->Sid()]=true;
+
+			/*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
+			switch(set2_enum){
+				case FsetEnum:
+					if(nodes[i]->indexing.fsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case GsetEnum:
+					if(nodes[i]->indexing.gsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case SsetEnum:
+					if(nodes[i]->indexing.ssize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				default: _error_("not supported");
+			}
+		}
+	}
+
+	/*Assign output pointers: */
+	*pd_nz=d_nz;
+	*po_nz=o_nz;
+}
+/*}}}*/
+
 /*Numericalflux management*/
 /*FUNCTION Numericalflux::CreateKMatrixPrognostic{{{*/
 ElementMatrix* Numericalflux::CreateKMatrixPrognostic(void){
@@ -409,7 +496,7 @@
 		for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g1[i][j];
 		for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g2[i][j];
 	}
-	
+
 	/*Clean up and return*/
 	delete gauss;
 	return Ke;
@@ -701,7 +788,7 @@
 	const int numdof=NDOF1*NUMVERTICES_BOUNDARY;
 
 	/* Intermediaries*/
-	int        i,j,ig,index1,index2;
+	int        i,ig,index1,index2;
 	IssmDouble     DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN,thickness;
 	IssmDouble     xyz_list[NUMVERTICES_BOUNDARY][3];
 	IssmDouble     normal[2];
@@ -795,11 +882,11 @@
 	const int numdof=NDOF1*NUMVERTICES_BOUNDARY;
 
 	/* Intermediaries*/
-	int        i,j,ig,index1,index2;
-	IssmDouble     DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN,thickness;
-	IssmDouble     xyz_list[NUMVERTICES_BOUNDARY][3];
-	IssmDouble     normal[2];
-	IssmDouble     L[numdof];
+	int        i,ig,index1,index2;
+	IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN,thickness;
+	IssmDouble xyz_list[NUMVERTICES_BOUNDARY][3];
+	IssmDouble normal[2];
+	IssmDouble L[numdof];
 	GaussTria *gauss;
 
 	/*Initialize Load Vector and return if necessary*/

Modified: issm/trunk/src/c/classes/objects/Loads/Numericalflux.h
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Numericalflux.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Numericalflux.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,21 +19,19 @@
 class Numericalflux: public Load {
 
 	public: 
-		int         id;
+		int id;
 		int analysis_type;
 
 		/*Hooks*/
-		Hook*       helement;
-		Hook*       hnodes;
+		Hook *helement;
+		Hook *hnodes;
 
 		/*Corresponding fields*/
-		Element* element;
-		Node**   nodes;
+		Element     *element;
+		Node       **nodes;
+		Parameters  *parameters;
+		Inputs      *inputs;
 
-		Parameters *parameters;
-		Inputs     *inputs;
-
-
 		/*Numericalflux constructors,destructors {{{*/
 		Numericalflux();
 		Numericalflux(int numericalflux_id,int i, IoModel* iomodel,int analysis_type);
@@ -43,7 +41,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -66,10 +63,14 @@
 		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
 		void  CreatePVector(Vector<IssmDouble>* pf);
+		void  GetNodesSidList(int* sidlist);
+		int   GetNumberOfNodes(void);
 		void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
+		bool  IsPenalty(void);
 		void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");};
 		void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
 		void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
+		void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
 		/*Numericalflux management:{{{*/

Modified: issm/trunk/src/c/classes/objects/Loads/Pengrid.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Pengrid.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Pengrid.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,7 +18,7 @@
 #include "../../../shared/shared.h"
 #include "../../../Container/Container.h"
 /*}}}*/
-	
+
 /*Element macros*/
 #define NUMVERTICES   1
 
@@ -33,7 +33,7 @@
 	this->element=NULL;
 	this->hmatpar=NULL;
 	this->matpar=NULL;
-	
+
 	/*not active, not zigzagging: */
 	active=0;
 	zigzag_counter=0;
@@ -43,7 +43,6 @@
 /*FUNCTION Pengrid::Pengrid(int index, int id, IoModel* iomodel,int analysis_type){{{*/
 Pengrid::Pengrid(int id, int index, IoModel* iomodel, int in_analysis_type){ //i is the element index
 
-	int i,j;
 	int pengrid_node_id;
 	int pengrid_matpar_id;
 	int pengrid_element_id;
@@ -63,7 +62,7 @@
 	/*id: */
 	this->id=id;
 	this->analysis_type=in_analysis_type;
-	
+
 	/*hooks: */
 	pengrid_node_id=iomodel->nodecounter+index+1;
 	pengrid_element_id=iomodel->singlenodetoelementconnectivity[index];
@@ -98,7 +97,7 @@
 	return;
 }
 /*}}}*/
-			
+
 /*Object virtual functions definitions:*/
 /*FUNCTION Pengrid::Echo {{{*/
 void Pengrid::Echo(void){
@@ -125,12 +124,6 @@
 /*FUNCTION Pengrid::Id {{{*/
 int    Pengrid::Id(void){ return id; }
 /*}}}*/
-/*FUNCTION Pengrid::MyRank {{{*/
-int    Pengrid::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Pengrid::ObjectEnum{{{*/
 int Pengrid::ObjectEnum(void){
 
@@ -139,7 +132,7 @@
 /*}}}*/
 /*FUNCTION Icefront::copy {{{*/
 Object* Pengrid::copy() {
-	
+
 	Pengrid* pengrid=NULL;
 
 	pengrid=new Pengrid();
@@ -215,6 +208,21 @@
 
 }
 /*}}}*/
+/*FUNCTION Pengrid::GetNodesSidList{{{*/
+void Pengrid::GetNodesSidList(int* sidlist){
+
+	_assert_(sidlist);
+	_assert_(node);
+
+	sidlist[0]=node->Sid();
+}
+/*}}}*/
+/*FUNCTION Pengrid::GetNumberOfNodes{{{*/
+int Pengrid::GetNumberOfNodes(void){
+
+	return NUMVERTICES;
+}
+/*}}}*/
 /*FUNCTION Pengrid::PenaltyCreateMatrix {{{*/
 void  Pengrid::PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,IssmDouble kmax){
 
@@ -286,7 +294,59 @@
 	else return false;
 }
 /*}}}*/
+/*FUNCTION Pengrid::IsPenalty{{{*/
+bool Pengrid::IsPenalty(void){
+	return true;
+}
+/*}}}*/
+/*FUNCTION Pengrid::SetwiseNodeConnectivity{{{*/
+void Pengrid::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
 
+	/*Output */
+	int d_nz = 0;
+	int o_nz = 0;
+
+	if(!flags[this->node->Sid()]){
+
+		/*flag current node so that no other element processes it*/
+		flags[this->node->Sid()]=true;
+
+		/*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
+		switch(set2_enum){
+			case FsetEnum:
+				if(node->indexing.fsize){
+					if(this->node->IsClone())
+					 o_nz += 1;
+					else
+					 d_nz += 1;
+				}
+				break;
+			case GsetEnum:
+				if(node->indexing.gsize){
+					if(this->node->IsClone())
+					 o_nz += 1;
+					else
+					 d_nz += 1;
+				}
+				break;
+			case SsetEnum:
+				if(node->indexing.ssize){
+					if(this->node->IsClone())
+					 o_nz += 1;
+					else
+					 d_nz += 1;
+				}
+				break;
+			default: _error_("not supported");
+		}
+	}
+
+	/*Assign output pointers: */
+	*pd_nz=d_nz;
+	*po_nz=o_nz;
+}
+/*}}}*/
+
 /*Update virtual functions definitions:*/
 /*FUNCTION Pengrid::InputUpdateFromVector(IssmDouble* vector, int name, int type) {{{*/
 void  Pengrid::InputUpdateFromVector(IssmDouble* vector, int name, int type){
@@ -400,7 +460,7 @@
 
 	/*recover pointers: */
 	Penta* penta=(Penta*)element;
-	
+
 	/*check that pengrid is not a clone (penalty to be added only once)*/
 	if (node->IsClone()){
 		unstable=0;
@@ -414,7 +474,7 @@
 
 	//Recover our data:
 	parameters->FindParam(&penalty_lock,ThermalPenaltyLockEnum);
-	
+
 	//Compute pressure melting point
 	t_pmp=matpar->TMeltingPoint(pressure);
 
@@ -427,7 +487,6 @@
 		new_active=0;
 	}
 
-
 	//Figure out stability of this penalty
 	if (active==new_active){
 		unstable=0;
@@ -455,7 +514,7 @@
 #ifdef _HAVE_DIAGNOSTIC_
 /*FUNCTION Pengrid::PenaltyCreateKMatrixDiagnosticStokes {{{*/
 ElementMatrix* Pengrid::PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax){
-	
+
 	const int numdof = NUMVERTICES *NDOF4;
 	IssmDouble    slope[2];
 	IssmDouble    penalty_offset;
@@ -504,7 +563,7 @@
 	penta->GetInputValue(&pressure,node,PressureEnum);
 	penta->GetInputValue(&temperature,node,TemperatureEnum);
 	parameters->FindParam(&penalty_factor,ThermalPenaltyFactorEnum);
-	
+
 	/*Compute pressure melting point*/
 	t_pmp=matpar->GetMeltingPoint()-matpar->GetBeta()*pressure;
 
@@ -538,7 +597,7 @@
 /*}}}*/
 /*FUNCTION Pengrid::PenaltyCreatePVectorMelting {{{*/
 ElementVector* Pengrid::PenaltyCreatePVectorMelting(IssmDouble kmax){
-	
+
 	const int numdof=NUMVERTICES*NDOF1;
 	IssmDouble pressure;
 	IssmDouble temperature;

Modified: issm/trunk/src/c/classes/objects/Loads/Pengrid.h
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Pengrid.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Pengrid.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,7 +19,7 @@
 
 		int		id;
 		int analysis_type;
-		
+
 		/*Hooks*/
 		Hook* hnode;  //hook to 1 node
 		Hook* helement;  //hook to 1 element
@@ -32,7 +32,7 @@
 
 		Parameters* parameters; //pointer to solution parameters
 		Inputs*  inputs;
-	
+
 		/*internals: */
 		int active;
 		int zigzag_counter;
@@ -48,7 +48,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -72,9 +71,13 @@
 		void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
 		void  CreatePVector(Vector<IssmDouble>* pf);
 		void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
+		void  GetNodesSidList(int* sidlist);
+		int   GetNumberOfNodes(void);
+		bool  IsPenalty(void);
 		void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");};
 		void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
 		void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
+		void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
 		/*Pengrid management {{{*/
@@ -96,5 +99,3 @@
 };
 
 #endif  /* _PENGRID_H_ */
-
-

Modified: issm/trunk/src/c/classes/objects/Loads/Penpair.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Penpair.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Penpair.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -33,13 +33,13 @@
 /*}}}*/
 /*FUNCTION Penpair::creation {{{*/
 Penpair::Penpair(int penpair_id, int* penpair_node_ids,int in_analysis_type){
-	
+
 	this->id=penpair_id;
 	this->analysis_type=in_analysis_type;
 	this->hnodes=new Hook(penpair_node_ids,2);
 	this->parameters=NULL;
 	this->nodes=NULL;
-	
+
 	return;
 }
 /*}}}*/
@@ -54,13 +54,11 @@
 /*FUNCTION Penpair::Echo {{{*/
 void Penpair::Echo(void){
 
-	int i;
-
 	_printLine_("Penpair:");
 	_printLine_("   id: " << id);
 	_printLine_("   analysis_type: " << EnumToStringx(analysis_type));
 	hnodes->Echo();
-	
+
 	return;
 }
 /*}}}*/
@@ -78,12 +76,6 @@
 /*FUNCTION Penpair::Id {{{*/
 int    Penpair::Id(void){ return id; }
 /*}}}*/
-/*FUNCTION Penpair::MyRank {{{*/
-int    Penpair::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Penpair::ObjectEnum{{{*/
 int Penpair::ObjectEnum(void){
 
@@ -92,7 +84,7 @@
 /*}}}*/
 /*FUNCTION Penpair::copy {{{*/
 Object* Penpair::copy() {
-	
+
 	Penpair* penpair=NULL;
 
 	penpair=new Penpair();
@@ -112,7 +104,7 @@
 
 }
 /*}}}*/
-		
+
 /*Load virtual functions definitions:*/
 /*FUNCTION Penpair::Configure {{{*/
 void  Penpair::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
@@ -155,6 +147,26 @@
 	this->CreateKMatrix(Jff,NULL);
 }
 /*}}}*/
+/*FUNCTION Penpair::GetNodesSidList{{{*/
+void Penpair::GetNodesSidList(int* sidlist){
+
+	_assert_(sidlist);
+	_assert_(nodes);
+
+	for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->Sid();
+}
+/*}}}*/
+/*FUNCTION Penpair::GetNumberOfNodes{{{*/
+int Penpair::GetNumberOfNodes(void){
+
+	return NUMVERTICES;
+}
+/*}}}*/
+/*FUNCTION Penpair::IsPenalty{{{*/
+bool Penpair::IsPenalty(void){
+	return true;
+}
+/*}}}*/
 /*FUNCTION Penpair::PenaltyCreateKMatrix {{{*/
 void  Penpair::PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs,IssmDouble kmax){
 
@@ -198,7 +210,58 @@
 	else return false;
 }
 /*}}}*/
+/*FUNCTION Penpair::SetwiseNodeConnectivity{{{*/
+void Penpair::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
 
+	/*Output */
+	int d_nz = 0;
+	int o_nz = 0;
+
+	/*Loop over all nodes*/
+	for(int i=0;i<NUMVERTICES;i++){
+
+		if(!flags[this->nodes[i]->Sid()]){
+
+			/*flag current node so that no other element processes it*/
+			flags[this->nodes[i]->Sid()]=true;
+
+			/*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
+			switch(set2_enum){
+				case FsetEnum:
+					if(nodes[i]->indexing.fsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case GsetEnum:
+					if(nodes[i]->indexing.gsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case SsetEnum:
+					if(nodes[i]->indexing.ssize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				default: _error_("not supported");
+			}
+		}
+	}
+
+	/*Assign output pointers: */
+	*pd_nz=d_nz;
+	*po_nz=o_nz;
+}
+/*}}}*/
+
 /*Update virtual functions definitions:*/
 /*FUNCTION Penpair::InputUpdateFromConstant(IssmDouble constant, int name) {{{*/
 void  Penpair::InputUpdateFromConstant(IssmDouble constant, int name){
@@ -269,7 +332,7 @@
 /*}}}*/
 /*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn {{{*/
 ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticMacAyealPattyn(IssmDouble kmax){
-	
+
 	const int numdof=NUMVERTICES*NDOF2;
 	IssmDouble penalty_offset;
 
@@ -296,7 +359,7 @@
 /*}}}*/
 /*FUNCTION Penpair::PenaltyCreateKMatrixDiagnosticStokes {{{*/
 ElementMatrix* Penpair::PenaltyCreateKMatrixDiagnosticStokes(IssmDouble kmax){
-	
+
 	const int numdof=NUMVERTICES*NDOF4;
 	IssmDouble penalty_offset;
 
@@ -316,7 +379,7 @@
 	Ke->values[1*numdof+5]=-kmax*pow((IssmDouble)10.0,penalty_offset);
 	Ke->values[5*numdof+1]=-kmax*pow((IssmDouble)10.0,penalty_offset);
 	Ke->values[5*numdof+5]=+kmax*pow((IssmDouble)10.0,penalty_offset);
-	
+
 	Ke->values[2*numdof+2]=+kmax*pow((IssmDouble)10.0,penalty_offset);
 	Ke->values[2*numdof+6]=-kmax*pow((IssmDouble)10.0,penalty_offset);
 	Ke->values[6*numdof+2]=-kmax*pow((IssmDouble)10.0,penalty_offset);

Modified: issm/trunk/src/c/classes/objects/Loads/Penpair.h
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Penpair.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Penpair.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,14 +16,12 @@
 class Penpair: public Load{
 
 	private: 
-		int		id;
-		int analysis_type;
-		
-		Hook* hnodes;  //hook to 2 nodes
-		Node** nodes;
+		int          id;
+		int          analysis_type;
+		Hook        *hnodes;          //hook to 2 nodes
+		Node       **nodes;
+		Parameters  *parameters;      //pointer to solution parameters
 
-		Parameters* parameters; //pointer to solution parameters
-
 	public:
 
 		/*Penpair constructors, destructors: {{{*/
@@ -35,7 +33,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -59,9 +56,13 @@
 		void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
 		void  CreatePVector(Vector<IssmDouble>* pf);
 		void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff);
+		void  GetNodesSidList(int* sidlist);
+		int   GetNumberOfNodes(void);
+		bool  IsPenalty(void);
 		void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff,Matrix<IssmDouble>* Kfs,IssmDouble kmax);
 		void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
 		void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax);
+		void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
 			/*Penpair management: {{{*/
@@ -73,5 +74,3 @@
 };
 
 #endif  /* _PENPAIR_H_ */
-
-

Modified: issm/trunk/src/c/classes/objects/Loads/Riftfront.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Riftfront.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Riftfront.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -96,7 +96,7 @@
 
 	//intialize inputs, and add as many inputs per element as requested: 
 	this->inputs=new Inputs();
-		
+
 	riftfront_type=SegmentRiftfrontEnum;
 	riftfront_fill = reCast<int,IssmDouble>(*(iomodel->Data(RiftsRiftstructEnum)+RIFTINFOSIZE*i+7));
 	riftfront_friction=*(iomodel->Data(RiftsRiftstructEnum)+RIFTINFOSIZE*i+8);
@@ -108,13 +108,13 @@
 	this->inputs->AddInput(new DoubleInput(FrictionEnum,riftfront_friction));
 	this->inputs->AddInput(new DoubleInput(FractionIncrementEnum,riftfront_fractionincrement));
 	this->inputs->AddInput(new BoolInput(SegmentOnIceShelfEnum,riftfront_shelf));
-	
+
 	//parameters and hooked fields: we still can't point to them, they may not even exist. Configure will handle this.
 	this->parameters=NULL;
 	this->nodes= NULL;
 	this->elements= NULL;
 	this->matpar= NULL;
-		
+
 }
 /*}}}*/
 /*FUNCTION Riftfront::~Riftfront(){{{*/
@@ -136,7 +136,6 @@
 	int fill;
 	IssmDouble friction,fractionincrement;
 
-	
 	/*recover some inputs first: */
 	input=(Input*)this->inputs->GetInput(FillEnum); input->GetInputValue(&fill);
 	input=(Input*)this->inputs->GetInput(FrictionEnum); input->GetInputValue(&friction);
@@ -164,7 +163,7 @@
 	_printLine_("   fractionincrement: " << fractionincrement);
 	_printLine_("   state: " << state);
 	_printLine_("   frozen: " << (frozen ? "true":"false"));
-		
+
 }
 /*}}}*/
 /*FUNCTION Riftfront::DeepEcho{{{*/
@@ -185,12 +184,6 @@
 /*FUNCTION Riftfront::Id {{{*/
 int    Riftfront::Id(void){ return id; }
 /*}}}*/
-/*FUNCTION Riftfront::MyRank {{{*/
-int    Riftfront::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Riftfront::ObjectEnum{{{*/
 int Riftfront::ObjectEnum(void){
 
@@ -200,7 +193,7 @@
 /*}}}*/
 /*FUNCTION Riftfront::copy {{{*/
 Object* Riftfront::copy() {
-	
+
 	Riftfront* riftfront=NULL;
 
 	riftfront=new Riftfront();
@@ -239,12 +232,12 @@
 	riftfront->normal[1]=this->normal[1];
 	riftfront->length=this->length;
 	riftfront->fraction=this->fraction;
-	
+
 	return riftfront;
 
 }
 /*}}}*/
-		
+
 /*Update virtual functions definitions:*/
 /*FUNCTION Riftfront::InputUpdateFromConstant(bool constant,int name) {{{*/
 void  Riftfront::InputUpdateFromConstant(bool constant,int name){
@@ -281,7 +274,6 @@
 }
 /*}}}*/
 
-
 /*Load virtual functions definitions:*/
 /*FUNCTION Riftfront::Configure {{{*/
 void  Riftfront::Configure(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
@@ -302,6 +294,11 @@
 
 }
 /*}}}*/
+/*FUNCTION Riftfront::IsPenalty{{{*/
+bool Riftfront::IsPenalty(void){
+	return true;
+}
+/*}}}*/
 /*FUNCTION Riftfront::SetCurrentConfiguration {{{*/
 void  Riftfront::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){
 
@@ -371,25 +368,89 @@
 	return;
 }
 /*}}}*/
+/*FUNCTION Riftfront::GetNodesSidList{{{*/
+void Riftfront::GetNodesSidList(int* sidlist){
+
+	_assert_(sidlist);
+	_assert_(nodes);
+
+	for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->Sid();
+}
+/*}}}*/
+/*FUNCTION Riftfront::GetNumberOfNodes{{{*/
+int Riftfront::GetNumberOfNodes(void){
+
+	return NUMVERTICES;
+}
+/*}}}*/
 /*FUNCTION Riftfront::InAnalysis{{{*/
 bool Riftfront::InAnalysis(int in_analysis_type){
 	if (in_analysis_type==this->analysis_type) return true;
 	else return false;
 }
 /*}}}*/
+/*FUNCTION Riftfront::SetwiseNodeConnectivity{{{*/
+void Riftfront::SetwiseNodeConnectivity(int* pd_nz,int* po_nz,Node* node,bool* flags,int set1_enum,int set2_enum){
 
+	/*Output */
+	int d_nz = 0;
+	int o_nz = 0;
+
+	/*Loop over all nodes*/
+	for(int i=0;i<NUMVERTICES;i++){
+
+		if(!flags[this->nodes[i]->Sid()]){
+
+			/*flag current node so that no other element processes it*/
+			flags[this->nodes[i]->Sid()]=true;
+
+			/*if node is clone, we have an off-diagonal non-zero, else it is a diagonal non-zero*/
+			switch(set2_enum){
+				case FsetEnum:
+					if(nodes[i]->indexing.fsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case GsetEnum:
+					if(nodes[i]->indexing.gsize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				case SsetEnum:
+					if(nodes[i]->indexing.ssize){
+						if(this->nodes[i]->IsClone())
+						 o_nz += 1;
+						else
+						 d_nz += 1;
+					}
+					break;
+				default: _error_("not supported");
+			}
+		}
+	}
+
+	/*Assign output pointers: */
+	*pd_nz=d_nz;
+	*po_nz=o_nz;
+}
+/*}}}*/
+
 /*Riftfront numerics*/
 /*FUNCTION Riftfront::PenaltyCreateKMatrixDiagnosticHoriz {{{*/
 ElementMatrix* Riftfront::PenaltyCreateKMatrixDiagnosticHoriz(IssmDouble kmax){
 
 	const int   numdof = NDOF2*NUMVERTICES;
-	int         i,j;
 	int         dofs[1]             = {0};
-	IssmDouble      Ke_gg[4][4];
-	IssmDouble      thickness;
-	IssmDouble      h[2];
-	IssmDouble      penalty_offset;
-	IssmDouble      friction;
+	IssmDouble  thickness;
+	IssmDouble  h[2];
+	IssmDouble  penalty_offset;
+	IssmDouble  friction;
 
 	/*Objects: */
 	Tria       *tria1               = NULL;
@@ -465,26 +526,26 @@
 /*FUNCTION Riftfront::PenaltyCreatePVectorDiagnosticHoriz {{{*/
 ElementVector* Riftfront::PenaltyCreatePVectorDiagnosticHoriz(IssmDouble kmax){
 
-	const int   numdof = NDOF2*NUMVERTICES;
-	int         i,j;
-	IssmDouble      rho_ice;
-	IssmDouble      rho_water;
-	IssmDouble      gravity;
-	IssmDouble      thickness;
-	IssmDouble      h[2];
-	IssmDouble      bed;
-	IssmDouble      b[2];
-	IssmDouble      pressure;
-	IssmDouble      pressure_litho;
-	IssmDouble      pressure_air;
-	IssmDouble      pressure_melange;
-	IssmDouble      pressure_water;
-	int         fill;
-	bool        shelf;
+	const int  numdof = NDOF2*NUMVERTICES;
+	int        j;
+	IssmDouble rho_ice;
+	IssmDouble rho_water;
+	IssmDouble gravity;
+	IssmDouble thickness;
+	IssmDouble h[2];
+	IssmDouble bed;
+	IssmDouble b[2];
+	IssmDouble pressure;
+	IssmDouble pressure_litho;
+	IssmDouble pressure_air;
+	IssmDouble pressure_melange;
+	IssmDouble pressure_water;
+	int        fill;
+	bool       shelf;
 
 	/*Objects: */
-	Tria       *tria1               = NULL;
-	Tria       *tria2               = NULL;
+	Tria *tria1 = NULL;
+	Tria *tria2 = NULL;
 
 	/*enum of element? */
 	if(elements[0]->ObjectEnum()!=TriaEnum)_error_("only Tria element allowed for Riftfront load!");
@@ -568,10 +629,8 @@
 int Riftfront::Constrain(int* punstable){
 
 	const int   numnodes        = 2;
-	IssmDouble      max_penetration;
 	IssmDouble      penetration;
 	int         activate;
-	int         found;
 	int         unstable;
 	IssmDouble      vx1;
 	IssmDouble      vy1;
@@ -601,13 +660,12 @@
 
 		if(this->state==OpenEnum)this->active=0;
 		if(this->state==ClosedEnum)this->active=1;
-		
+
 		/*this segment is like frozen, no instability here: */
 		*punstable=0;
 		return 1;
 	}
 
-
 	/*recover parameters: */
 	this->inputs->GetInputValue(&fractionincrement,FractionIncrementEnum);
 
@@ -673,7 +731,6 @@
 /*FUNCTION Riftfront::IsMaterialStable {{{*/
 int   Riftfront::IsMaterialStable(void){
 
-	int found=0;
 	IssmDouble converged=0;
 
 	this->inputs->GetInputValue(&converged,ConvergedEnum);
@@ -692,9 +749,7 @@
 int   Riftfront::MaxPenetration(IssmDouble* ppenetration){
 
 	const int     numnodes=2;
-	IssmDouble        max_penetration;
 	IssmDouble        penetration=0;
-	int           found;
 	IssmDouble      vx1;
 	IssmDouble      vy1;
 	IssmDouble      vx2;
@@ -728,7 +783,7 @@
 
 	/*If we are zigzag locked, same thing: */
 	if(this->counter>this->penalty_lock)penetration=-1;
-	
+
 	/*assign output pointer: */
 	*ppenetration=penetration;
 	return 1;
@@ -743,7 +798,6 @@
 	IssmDouble    vy2;
 
 	IssmDouble    penetration;
-	int       found;
 
 	/*Objects: */
 	Tria     *tria1       = NULL;
@@ -767,7 +821,7 @@
 
 	/*Now, we return penetration only if we are active!: */
 	if(this->active==0)penetration=0;
-	
+
 	/*assign output pointer: */
 	*ppenetration=penetration;
 	return 1;
@@ -776,21 +830,17 @@
 /*FUNCTION Riftfront::PotentialUnstableConstraint {{{*/
 int   Riftfront::PotentialUnstableConstraint(int* punstable){
 
-
 	const int   numnodes        = 2;
-	IssmDouble      max_penetration;
-	IssmDouble      penetration;
-	int         activate;
+	IssmDouble  penetration;
 	int         unstable;
-	int         found;
-	IssmDouble      vx1;
-	IssmDouble      vy1;
-	IssmDouble      vx2;
-	IssmDouble      vy2;
+	IssmDouble  vx1;
+	IssmDouble  vy1;
+	IssmDouble  vx2;
+	IssmDouble  vy2;
 
 	/*Objects: */
-	Tria       *tria1           = NULL;
-	Tria       *tria2           = NULL;
+	Tria       *tria1 = NULL;
+	Tria       *tria2 = NULL;
 
 	/*enum of element? */
 	if(elements[0]->ObjectEnum()!=TriaEnum)_error_("only Tria element allowed for Riftfront load!");
@@ -832,7 +882,6 @@
 	const int   numnodes    = 2;
 	IssmDouble      penetration;
 	int         unstable;
-	int         found;
 	IssmDouble      vx1;
 	IssmDouble      vy1;
 	IssmDouble      vx2;

Modified: issm/trunk/src/c/classes/objects/Loads/Riftfront.h
===================================================================
--- issm/trunk/src/c/classes/objects/Loads/Riftfront.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Loads/Riftfront.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -24,27 +24,26 @@
 		Hook* hnodes;
 		Hook* helements;
 		Hook* hmatpar;
-		
+
 		/*Corresponding fields*/
 		Matpar   *matpar;
 		Node    **nodes;
 		Element **elements;
 
 		/*computational: */
-		int      penalty_lock;
-		bool     active;
-		bool     frozen;
-		int      counter;
-		bool     prestable;
-		bool     material_converged;
-		IssmDouble   normal[2];
-		IssmDouble   length;
-		IssmDouble   fraction;
-		int      state;
-		
-		Parameters* parameters; //pointer to solution parameters
-		Inputs*  inputs;
+		int         penalty_lock;
+		bool        active;
+		bool        frozen;
+		int         counter;
+		bool        prestable;
+		bool        material_converged;
+		IssmDouble  normal[2];
+		IssmDouble  length;
+		IssmDouble  fraction;
+		int         state;
 
+		Parameters *parameters;           //pointer to solution parameters
+		Inputs     *inputs;
 
 		/*Riftfrontconstructors,destructors: {{{*/
 		Riftfront();
@@ -55,7 +54,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -79,9 +77,13 @@
 		void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
 		void  CreatePVector(Vector<IssmDouble>* pf);
 		void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
+		void  GetNodesSidList(int* sidlist);
+		int   GetNumberOfNodes(void);
+		bool  IsPenalty(void);
 		void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");};
 		void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
 		void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
+		void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
 		bool  InAnalysis(int analysis_type);
 		/*}}}*/
 		/*Riftfront specific routines: {{{*/

Modified: issm/trunk/src/c/classes/objects/Materials/Matdamageice.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Materials/Matdamageice.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Materials/Matdamageice.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,7 @@
 #include "../../../EnumDefinitions/EnumDefinitions.h"
 #include "../../../shared/shared.h"
 #include "../../../include/include.h"
-		
+
 /*Matdamageice constructors and destructor*/
 /*FUNCTION Matdamageice::Matdamageice(){{{*/
 Matdamageice::Matdamageice(){
@@ -27,7 +27,6 @@
 Matdamageice::Matdamageice(int matice_mid,int index, IoModel* iomodel){
 
 	/*Intermediaries:*/
-	int    i;
 	int    matice_eid;
 
 	/*Initialize id*/
@@ -81,12 +80,6 @@
 /*FUNCTION Matdamageice::Id {{{*/
 int    Matdamageice::Id(void){ return mid; }
 /*}}}*/
-/*FUNCTION Matdamageice::MyRank {{{*/
-int    Matdamageice::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Matdamageice::ObjectEnum{{{*/
 int Matdamageice::ObjectEnum(void){
 
@@ -209,7 +202,7 @@
 
 			/*Prepare index list*/
 			int doflist1[3];
-			for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertexDof();
+			for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertexPid();
 
 			/*Get input (either in element or material)*/
 			Input* input=inputs->GetInput(input_enum);
@@ -304,7 +297,7 @@
 	 * If epsilon is NULL, it means this is the first time Emg is being run, and we 
 	 * return g, initial viscosity.
 	 */
-	
+
 	/*output: */
 	IssmDouble viscosity3d;
 
@@ -346,7 +339,7 @@
 			}
 			else{
 				e=(n-1)/2/n;
-			
+
 				viscosity3d=B/(2*pow(A,e));
 			}
 		}
@@ -375,7 +368,7 @@
 	 * If epsilon is NULL, it means this is the first time Emg is being run, and we 
 	 * return g, initial viscosity.
 	 */
-	
+
 	/*output: */
 	IssmDouble viscosity3d;
 
@@ -392,7 +385,7 @@
 	n=GetN();
 	Z=GetZ();
 	B=Z*GetB();
-	
+
 	if (n==1){
 		/*Viscous behaviour! viscosity3d=B: */
 		viscosity3d=B/2;
@@ -445,7 +438,7 @@
 	 * If epsilon is NULL, it means this is the first time Gradjb is being run, and we 
 	 * return mu20, initial viscosity.
 	 */
-	
+
 	/*output: */
 	IssmDouble viscosity_complement;
 
@@ -473,7 +466,7 @@
 		}
 		else{
 			e=(n-1)/(2*n);
-		
+
 			viscosity_complement=1/(2*pow(A,e));
 		}
 	}
@@ -485,7 +478,7 @@
 	_assert_(B>0);
 	_assert_(n>0);
 	_assert_(viscosity_complement>0);
-		
+
 	/*Return: */
 	*pviscosity_complement=viscosity_complement;
 }
@@ -501,7 +494,7 @@
 	 * If epsilon is NULL, it means this is the first time Gradjb is being run, and we 
 	 * return mu20, initial viscosity.
 	 */
-	
+
 	/*output: */
 	IssmDouble viscosity_complement;
 
@@ -529,7 +522,7 @@
 		}
 		else{
 			e=(n-1)/(2*n);
-		
+
 			viscosity_complement=B/(2*pow(A,e));
 		}
 	}
@@ -541,7 +534,7 @@
 	_assert_(B>0);
 	_assert_(n>0);
 	_assert_(viscosity_complement>0);
-		
+
 	/*Return: */
 	*pviscosity_complement=viscosity_complement;
 }
@@ -588,7 +581,7 @@
 	IssmDouble mu,n,eff2;
 
 	/*input strain rate: */
-	IssmDouble exx,eyy,exy,exz;
+	IssmDouble exx,eyy,exy;
 
 	/*Get visocisty and n*/
 	GetViscosity2d(&mu,epsilon);
@@ -639,7 +632,7 @@
 
 				case TriaEnum: {
 					IssmDouble values[3];
-					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexDof()];
+					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexPid()];
 					this->inputs->AddInput(new TriaP1Input(name,values));
 					return;
 				}
@@ -681,7 +674,7 @@
 
 				case TriaEnum: {
 					IssmDouble values[3];
-					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetSidList()]; //use sid list, to index into serial oriented vector 
+					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexSid()]; //use sid list, to index into serial oriented vector 
 					this->inputs->AddInput(new TriaP1Input(name,values));
 					/*Special case for rheology B in 2D: Pourave land for this solution{{{*/
 					if(name==MaterialsRheologyBEnum){
@@ -706,8 +699,6 @@
 		default: _error_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
 	}
 
-
-
 }
 /*}}}*/
 /*FUNCTION Matdamageice::InputUpdateFromMatrixDakota(int* vector, int name, int type) {{{*/

Modified: issm/trunk/src/c/classes/objects/Materials/Matdamageice.h
===================================================================
--- issm/trunk/src/c/classes/objects/Materials/Matdamageice.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Materials/Matdamageice.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -27,7 +27,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Materials/Material.h
===================================================================
--- issm/trunk/src/c/classes/objects/Materials/Material.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Materials/Material.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief abstract class for Material object
  */ 
 
-
 #ifndef _MATERIAL_H_
 #define _MATERIAL_H_
 

Modified: issm/trunk/src/c/classes/objects/Materials/Matice.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Materials/Matice.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Materials/Matice.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,7 @@
 #include "../../../EnumDefinitions/EnumDefinitions.h"
 #include "../../../shared/shared.h"
 #include "../../../include/include.h"
-		
+
 /*Matice constructors and destructor*/
 /*FUNCTION Matice::Matice(){{{*/
 Matice::Matice(){
@@ -27,7 +27,6 @@
 Matice::Matice(int matice_mid,int index, IoModel* iomodel){
 
 	/*Intermediaries:*/
-	int    i;
 	int    matice_eid;
 
 	/*Initialize id*/
@@ -81,12 +80,6 @@
 /*FUNCTION Matice::Id {{{*/
 int    Matice::Id(void){ return mid; }
 /*}}}*/
-/*FUNCTION Matice::MyRank {{{*/
-int    Matice::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Matice::ObjectEnum{{{*/
 int Matice::ObjectEnum(void){
 
@@ -189,7 +182,7 @@
 
 			/*Prepare index list*/
 			int doflist1[3];
-			for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertexDof();
+			for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertexPid();
 
 			/*Get input (either in element or material)*/
 			Input* input=inputs->GetInput(input_enum);
@@ -282,7 +275,7 @@
 	 * If epsilon is NULL, it means this is the first time Emg is being run, and we 
 	 * return g, initial viscosity.
 	 */
-	
+
 	/*output: */
 	IssmDouble viscosity3d;
 
@@ -323,7 +316,7 @@
 			}
 			else{
 				e=(n-1)/2/n;
-			
+
 				viscosity3d=B/(2*pow(A,e));
 			}
 		}
@@ -352,7 +345,7 @@
 	 * If epsilon is NULL, it means this is the first time Emg is being run, and we 
 	 * return g, initial viscosity.
 	 */
-	
+
 	/*output: */
 	IssmDouble viscosity3d;
 
@@ -368,7 +361,7 @@
 	eps0=pow((IssmDouble)10,(IssmDouble)-27);
 	B=GetB();
 	n=GetN();
-	
+
 	if (n==1){
 		/*Viscous behaviour! viscosity3d=B: */
 		viscosity3d=B/2;
@@ -421,7 +414,7 @@
 	 * If epsilon is NULL, it means this is the first time Gradjb is being run, and we 
 	 * return mu20, initial viscosity.
 	 */
-	
+
 	/*output: */
 	IssmDouble viscosity_complement;
 
@@ -449,7 +442,7 @@
 		}
 		else{
 			e=(n-1)/(2*n);
-		
+
 			viscosity_complement=1/(2*pow(A,e));
 		}
 	}
@@ -461,7 +454,7 @@
 	_assert_(B>0);
 	_assert_(n>0);
 	_assert_(viscosity_complement>0);
-		
+
 	/*Return: */
 	*pviscosity_complement=viscosity_complement;
 }
@@ -508,7 +501,7 @@
 	IssmDouble mu,n,eff2;
 
 	/*input strain rate: */
-	IssmDouble exx,eyy,exy,exz;
+	IssmDouble exx,eyy,exy;
 
 	/*Get visocisty and n*/
 	GetViscosity2d(&mu,epsilon);
@@ -559,7 +552,7 @@
 
 				case TriaEnum: {
 					IssmDouble values[3];
-					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexDof()];
+					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexPid()];
 					this->inputs->AddInput(new TriaP1Input(name,values));
 					return;
 				}
@@ -601,7 +594,7 @@
 
 				case TriaEnum: {
 					IssmDouble values[3];
-					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetSidList()]; //use sid list, to index into serial oriented vector 
+					for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexSid()]; //index into serial oriented vector 
 					this->inputs->AddInput(new TriaP1Input(name,values));
 					/*Special case for rheology B in 2D: Pourave land for this solution{{{*/
 					if(name==MaterialsRheologyBEnum){
@@ -626,8 +619,6 @@
 		default: _error_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
 	}
 
-
-
 }
 /*}}}*/
 /*FUNCTION Matice::InputUpdateFromMatrixDakota(int* vector, int name, int type) {{{*/

Modified: issm/trunk/src/c/classes/objects/Materials/Matice.h
===================================================================
--- issm/trunk/src/c/classes/objects/Materials/Matice.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Materials/Matice.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,8 +14,8 @@
 class Matice: public Material{
 
 	private: 
-		int	   mid;
-		Hook* helement;
+		int   mid;
+		Hook *helement;
 
 	public:
 		/*Matice constructors, destructors: {{{*/
@@ -27,7 +27,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Materials/Matpar.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Materials/Matpar.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Materials/Matpar.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,7 @@
 #include "../../../shared/shared.h"
 #include "../../../include/include.h"
 #include "../../../EnumDefinitions/EnumDefinitions.h"
-		
+
 /*Matpar constructors and destructor*/
 /*FUNCTION Matpar::Matpar() {{{*/
 Matpar::Matpar(){
@@ -38,7 +38,7 @@
 	iomodel->Constant(&this->mixed_layer_capacity,MaterialsMixedLayerCapacityEnum);
 	iomodel->Constant(&this->thermal_exchange_velocity,MaterialsThermalExchangeVelocityEnum);
 	iomodel->Constant(&this->g,ConstantsGEnum);
-	
+
 	iomodel->Constant(&this->hydro_CR,HydrologyCREnum);
 	iomodel->Constant(&this->kn,HydrologyKnEnum);
 	iomodel->Constant(&this->hydro_n,HydrologyNEnum);
@@ -84,12 +84,6 @@
 /*FUNCTION Matpar::Id {{{*/
 int    Matpar::Id(void){ return mid; }
 /*}}}*/
-/*FUNCTION Matpar::MyRank {{{*/
-int    Matpar::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Matpar::ObjectEnum{{{*/
 int Matpar::ObjectEnum(void){
 
@@ -249,7 +243,7 @@
 /*}}}*/
 /*FUNCTION Matpar::GetRhoIce {{{*/
 IssmDouble Matpar::GetRhoIce(){
-	
+
 	return rho_ice;
 }
 /*}}}*/
@@ -328,7 +322,7 @@
 
 	/*Ouput*/
 	IssmDouble temperature,waterfraction;
-	
+
 	if(enthalpy<PureIceEnthalpy(pressure)){
 		temperature=referencetemperature+enthalpy/heatcapacity;
 		waterfraction=0;
@@ -348,7 +342,7 @@
 
 	/*Ouput*/
 	IssmDouble enthalpy;
-	
+
 	if(temperature<TMeltingPoint(pressure)){
 		enthalpy=heatcapacity*(temperature-referencetemperature);
 	}

Modified: issm/trunk/src/c/classes/objects/Materials/Matpar.h
===================================================================
--- issm/trunk/src/c/classes/objects/Materials/Matpar.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Materials/Matpar.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -42,12 +42,11 @@
 		~Matpar();
 
 		/*Object virtual functions definitions:{{{ */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		int   ObjectEnum();
-		Object* copy();
+		void    Echo();
+		void    DeepEcho();
+		int     Id();
+		int     ObjectEnum();
+		Object *copy();
 		/*}}}*/
 		/*Update virtual functions resolution: {{{*/
 		void   InputUpdateFromVector(IssmDouble* vector, int name, int type);

Modified: issm/trunk/src/c/classes/objects/Node.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Node.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Node.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -57,20 +57,20 @@
 	//intialize inputs, and add as many inputs per element as requested: 
 	this->inputs=new Inputs();
 	if (iomodel->Data(MeshVertexonbedEnum))
-	 this->inputs->AddInput(new BoolInput(MeshVertexonbedEnum,reCast<IssmBool>(iomodel->Data(MeshVertexonbedEnum)[io_index])));
+	 this->inputs->AddInput(new BoolInput(MeshVertexonbedEnum,reCast<bool>(iomodel->Data(MeshVertexonbedEnum)[io_index])));
 	if (iomodel->Data(MeshVertexonsurfaceEnum))
-	 this->inputs->AddInput(new BoolInput(MeshVertexonsurfaceEnum,reCast<IssmBool>(iomodel->Data(MeshVertexonsurfaceEnum)[io_index])));
+	 this->inputs->AddInput(new BoolInput(MeshVertexonsurfaceEnum,reCast<bool>(iomodel->Data(MeshVertexonsurfaceEnum)[io_index])));
 	if (iomodel->Data(MaskVertexonfloatingiceEnum))
-	 this->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,reCast<IssmBool>(iomodel->Data(MaskVertexonfloatingiceEnum)[io_index])));
+	 this->inputs->AddInput(new BoolInput(MaskVertexonfloatingiceEnum,reCast<bool>(iomodel->Data(MaskVertexonfloatingiceEnum)[io_index])));
 	if (iomodel->Data(MaskVertexongroundediceEnum))
-	  this->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,reCast<IssmBool>(iomodel->Data(MaskVertexongroundediceEnum)[io_index])));
+	  this->inputs->AddInput(new BoolInput(MaskVertexongroundediceEnum,reCast<bool>(iomodel->Data(MaskVertexongroundediceEnum)[io_index])));
 	if (analysis_type==DiagnosticHorizAnalysisEnum)
 	 this->inputs->AddInput(new IntInput(ApproximationEnum,reCast<IssmInt>(iomodel->Data(FlowequationVertexEquationEnum)[io_index])));
 	/*set single point constraints: */
 
 	/*spc all nodes on water*/
 	if (!iomodel->Data(MaskVertexonwaterEnum)) _error_("iomodel->nodeonwater is NULL");
-	if (reCast<IssmBool>(iomodel->Data(MaskVertexonwaterEnum)[io_index])){
+	if (reCast<bool>(iomodel->Data(MaskVertexonwaterEnum)[io_index])){
 		for(k=1;k<=gsize;k++){
 			this->FreezeDof(k);
 		}
@@ -136,7 +136,7 @@
 		if (dim==3){
 			/*On a 3d mesh, we may have collapsed elements, hence dead nodes. Freeze them out: */
 			_assert_(iomodel->Data(MeshVertexonbedEnum));
-			if (!(reCast<IssmBool>(iomodel->Data(MeshVertexonbedEnum)[io_index]))){
+			if (!(reCast<bool>(iomodel->Data(MeshVertexonbedEnum)[io_index]))){
 				for(k=1;k<=gsize;k++){
 					this->FreezeDof(k);
 				}
@@ -166,7 +166,6 @@
 	_printLine_("   hvertex:     not displayed");
 	_printLine_("   inputs:      " << inputs);
 
-
 }
 /*}}}*/
 /*FUNCTION Node::DeepEcho{{{*/
@@ -181,19 +180,11 @@
 	hvertex->DeepEcho();
 	_printLine_("   inputs");
 
-
 }
 /*}}}*/
 /*FUNCTION Node::Id{{{*/
 int    Node::Id(void){ return id; }
 /*}}}*/
-/*FUNCTION Node::MyRank{{{*/
-int    Node::MyRank(void){ 
-	extern int my_rank;
-
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Node::ObjectEnum{{{*/
 int Node::ObjectEnum(void){
 
@@ -233,22 +224,12 @@
 	else _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
 
 } /*}}}*/
-/*FUNCTION Node::GetDofList1{{{*/
-int  Node::GetDofList1(void){
-
-	Vertex* vertex=NULL;
-
-	vertex=(Vertex*)this->hvertex->delivers();
-
-	return vertex->dof;
-}
-/*}}}*/
 /*FUNCTION Node::GetDofList{{{*/
 void  Node::GetDofList(int* outdoflist,int approximation_enum,int setenum){
 	int i;
 	int count=0;
 	int count2=0;
-		
+
 	if(approximation_enum==NoneApproximationEnum){
 		if(setenum==GsetEnum)for(i=0;i<this->indexing.gsize;i++) outdoflist[i]=indexing.gdoflist[i];
 		if(setenum==FsetEnum)for(i=0;i<this->indexing.fsize;i++) outdoflist[i]=indexing.fdoflist[i];
@@ -305,22 +286,12 @@
 	}
 }
 /*}}}*/
-/*FUNCTION Node::GetSidList{{{*/
-int  Node::GetSidList(void){
-
-	Vertex* vertex=NULL;
-
-	vertex=(Vertex*)this->hvertex->delivers();
-
-	return vertex->sid;
-}
-/*}}}*/
 /*FUNCTION Node::GetLocalDofList{{{*/
 void  Node::GetLocalDofList(int* outdoflist,int approximation_enum,int setenum){
 	int i;
 	int count=0;
 	int count2=0;
-		
+
 	if(approximation_enum==NoneApproximationEnum){
 		if(setenum==GsetEnum)for(i=0;i<this->indexing.gsize;i++) outdoflist[i]=i;
 		else if(setenum==FsetEnum){
@@ -426,15 +397,25 @@
 	return vertex->id;
 }
 /*}}}*/
-/*FUNCTION Node::GetVertexDof {{{*/
-int   Node::GetVertexDof(void){
+/*FUNCTION Node::GetVertexPid{{{*/
+int   Node::GetVertexPid(void){
 
 	Vertex*  vertex=NULL;
 
 	vertex=(Vertex*)hvertex->delivers();
-	return vertex->dof;
+	return vertex->pid;
 }
 /*}}}*/
+/*FUNCTION Node::GetVertexSid{{{*/
+int  Node::GetVertexSid(void){
+
+	Vertex* vertex=NULL;
+
+	vertex=(Vertex*)this->hvertex->delivers();
+
+	return vertex->sid;
+}
+/*}}}*/
 #ifdef _HAVE_DIAGNOSTIC_
 /*FUNCTION Node::GetCoordinateSystem{{{*/
 void Node::GetCoordinateSystem(IssmDouble* coord_system_out){
@@ -445,16 +426,6 @@
 }
 /*}}}*/
 #endif
-/*FUNCTION Node::SetVertexDof {{{*/
-void   Node::SetVertexDof(int in_dof){
-
-	Vertex*  vertex=NULL;
-
-	vertex=(Vertex*)hvertex->delivers();
-	vertex->dof=in_dof;
-
-}
-/*}}}*/
 /*FUNCTION Node::InAnalysis{{{*/
 bool Node::InAnalysis(int in_analysis_type){
 	if (in_analysis_type==this->analysis_type) return true;
@@ -466,8 +437,6 @@
 /*FUNCTION Node::ApplyConstraints{{{*/
 void  Node::ApplyConstraint(int dof,IssmDouble value){
 
-	int index;
-
 	/*Dof should be added in the s set, describing which 
 	 * dofs are constrained to a certain value (dirichlet boundary condition*/
 	DofInSSet(dof-1);
@@ -494,7 +463,7 @@
 
 		/*g set: */
 		pv_g->SetValue(indexing.gdoflist[i],gvalue,INS_VAL);
-		
+
 		/*f set: */
 		value=(IssmDouble)this->indexing.f_set[i];
 		pv_f->SetValue(indexing.gdoflist[i],value,INS_VAL);
@@ -505,7 +474,6 @@
 
 	}
 
-
 }
 /*}}}*/
 /*FUNCTION Node::CreateNodalConstraints{{{*/
@@ -526,7 +494,7 @@
 				count++;
 			}
 		}
-		
+
 		/*Add values into constraint vector: */
 		ys->SetValues(this->indexing.ssize,this->indexing.sdoflist,values,INS_VAL);
 	}
@@ -534,7 +502,6 @@
 	/*Free ressources:*/
 	xDelete<IssmDouble>(values);
 
-
 }
 /*}}}*/
 /*FUNCTION Node::DofInSSet {{{*/
@@ -559,7 +526,7 @@
 /*}}}*/
 /*FUNCTION Node::FreezeDof{{{*/
 void  Node::FreezeDof(int dof){
-	
+
 	DofInSSet(dof-1); //with 0 displacement for this dof.
 
 }
@@ -588,7 +555,7 @@
 
 	/*Get number of degrees of freedom in a node, for a certain set (g,f or s-set)
 	 *and for a certain approximation type: */
-	
+
 	int i;
 	int numdofs=0;
 
@@ -665,7 +632,7 @@
 /*}}}*/
 /*FUNCTION Node::IsClone {{{*/
 int   Node::IsClone(){
-	
+
 	return indexing.clone;
 
 }
@@ -694,7 +661,7 @@
 /*}}}*/
 /*FUNCTION Node::IsFloating {{{*/
 int   Node::IsFloating(){
-	
+
 	bool onshelf;
 
 	/*recover parameters: */
@@ -886,12 +853,11 @@
 }
 /*}}}*/
 
-/* DofObject routines:*/
+/* indexing routines:*/
 /*FUNCTION Node::DistributeDofs{{{*/
 void  Node::DistributeDofs(int* pdofcount,int setenum){
 
 	int i;
-	extern int my_rank;
 	int dofcount;
 
 	dofcount=*pdofcount;
@@ -899,15 +865,13 @@
 	/*Initialize: */
 	if(setenum==FsetEnum) this->indexing.InitSet(setenum);
 	if(setenum==SsetEnum) this->indexing.InitSet(setenum);
-	
-		
+
 	/*For clone nodfs, don't distribute dofs, we will get them from another cpu in UpdateCloneDofs!*/
 	if(indexing.clone){
 		return;
 	}
 
 	/*This node should distribute dofs for setenum set (eg, f_set or s_set), go ahead: */
-
 	if(setenum==GsetEnum){
 		for(i=0;i<this->indexing.gsize;i++){
 			indexing.gdoflist[i]=dofcount+i;
@@ -928,18 +892,15 @@
 	}
 	else _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
 
-
 	/*Assign output pointers: */
 	*pdofcount=dofcount;
-
 }
 /*}}}*/
-/*FUNCTION Node::Off_setDofs{{{*/
+/*FUNCTION Node::OffsetDofs{{{*/
 void  Node::OffsetDofs(int dofcount,int setenum){
-	
+
 	int i;
-	extern int my_rank;
-	
+
 	if(indexing.clone){
 		/*This node is a clone, don't off_set the dofs!: */
 		return;
@@ -962,16 +923,24 @@
 void  Node::ShowTrueDofs(int* truedofs, int ncols,int setenum){
 
 	int j;
-	extern int my_rank;
-	
+
 	/*Are we a clone? : */
-	if(indexing.clone)return;
+	if(indexing.clone) return;
 
 	/*Ok, we are not a clone, just plug our dofs into truedofs: */
-	if(setenum==GsetEnum)for(j=0;j<this->indexing.gsize;j++)  *(truedofs+ncols*sid+j)=indexing.gdoflist[j];
-	else if(setenum==FsetEnum)for(j=0;j<this->indexing.fsize;j++)  *(truedofs+ncols*sid+j)=indexing.fdoflist[j];
-	else if(setenum==SsetEnum)for(j=0;j<this->indexing.ssize;j++)  *(truedofs+ncols*sid+j)=indexing.sdoflist[j];
-	else _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
+	switch(setenum){
+		case GsetEnum:
+			for(j=0;j<this->indexing.gsize;j++) truedofs[ncols*sid+j]=indexing.gdoflist[j];
+			break;
+		case FsetEnum:
+			for(j=0;j<this->indexing.fsize;j++) truedofs[ncols*sid+j]=indexing.fdoflist[j];
+			break;
+		case SsetEnum:
+			for(j=0;j<this->indexing.ssize;j++) truedofs[ncols*sid+j]=indexing.sdoflist[j];
+			break;
+		default:
+			_error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
+	}
 
 }
 /*}}}*/
@@ -979,34 +948,42 @@
 void  Node::UpdateCloneDofs(int* alltruedofs,int ncols,int setenum){
 
 	int j;
-	extern int my_rank;
-	
+
 	/*If we are not a clone, don't update, we already have dofs!: */
-	if(indexing.clone==0)return;
+	if(!indexing.clone)return;
 
-
 	/*Ok, we are a clone node, but we did not create the dofs for this node.
-	 *      * Therefore, our doflist is garbage right now. Go pick it up in the alltruedofs: */
-	if(setenum==GsetEnum)for(j=0;j<this->indexing.gsize;j++) indexing.gdoflist[j]=*(alltruedofs+ncols*sid+j);
-	else if(setenum==FsetEnum)for(j=0;j<this->indexing.fsize;j++) indexing.fdoflist[j]=*(alltruedofs+ncols*sid+j);
-	else if(setenum==SsetEnum)for(j=0;j<this->indexing.ssize;j++) indexing.sdoflist[j]=*(alltruedofs+ncols*sid+j);
-	else _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
-
+	 *Therefore, our doflist is garbage right now. Go pick it up in the alltruedofs: */
+	switch(setenum){
+		case GsetEnum:
+			for(j=0;j<this->indexing.gsize;j++) indexing.gdoflist[j]=alltruedofs[ncols*sid+j];
+			break;
+		case FsetEnum:
+			for(j=0;j<this->indexing.fsize;j++) indexing.fdoflist[j]=alltruedofs[ncols*sid+j];
+			break;
+		case SsetEnum:
+			for(j=0;j<this->indexing.ssize;j++) indexing.sdoflist[j]=alltruedofs[ncols*sid+j];
+			break;
+		default:
+			_error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!");
+	}
 }
 /*}}}*/
 /*FUNCTION Node::SetClone {{{*/
 void  Node::SetClone(int* minranks){
 
-	extern int my_rank;
+	int my_rank;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	if (minranks[sid]==my_rank){
-		indexing.clone=0;
+		indexing.clone=false;
 	}
 	else{
 		/*!there is a cpu with lower rank that has the same node, 
 		therefore, I am a clone*/
-		indexing.clone=1; 	
+		indexing.clone=true;	
 	}
-
 }
 /*}}}*/

Modified: issm/trunk/src/c/classes/objects/Node.h
===================================================================
--- issm/trunk/src/c/classes/objects/Node.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Node.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -24,30 +24,28 @@
 
 	public: 
 
-		int	    id;  //unique arbitrary id.
-		int     sid; //sid for "serial" id, ie the rank of this node in the nodes dataset, if the dataset was serial on 1 cpu.
-				
-		DofIndexing    indexing;
-		Hook*          hvertex;
-		Inputs*        inputs; //properties of this node
-		int            analysis_type;
-		IssmDouble         coord_system[3][3];
+		int id;    //unique arbitrary id.
+		int sid;   //"serial" id (rank of this node if the dataset was serial on 1 cpu)
 
+		DofIndexing  indexing;
+		Hook        *hvertex;
+		Inputs      *inputs;               //properties of this node
+		int          analysis_type;
+		IssmDouble   coord_system[3][3];
+
 		/*Node constructors, destructors {{{*/
 		Node();
 		Node(int node_id,int node_sid, int vertex_id,int io_index, IoModel* iomodel,int analysis_type);
 		~Node();
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
-		void  Echo();
-		void  DeepEcho();
-		int   Id(); 
-		int   MyRank();
-		int   ObjectEnum();
-		Object* copy(){_error_("Not implemented yet (similar to Elements)");};
+		void    Echo();
+		void    DeepEcho();
+		int     Id();
+		int     ObjectEnum();
+		Object *copy()        {_error_("Not implemented yet (similar to Elements)"); };
 		/*}}}*/
 		/*Update virtual functions definitions: {{{*/
-		
 		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromVector(int* vector, int name, int type);
 		void  InputUpdateFromVector(bool* vector, int name, int type);
@@ -66,12 +64,9 @@
 		void   CreateNodalConstraints(Vector<IssmDouble>* ys);
 		void   SetCurrentConfiguration(DataSet* nodes,Vertices* vertices);
 		int    Sid(void); 
-		int    GetVertexDof(void);
-		int    GetVertexId(void);
 #ifdef _HAVE_DIAGNOSTIC_
 		void   GetCoordinateSystem(IssmDouble* coord_system_out);
 #endif
-		void   SetVertexDof(int in_dof);
 		bool   InAnalysis(int analysis_type);
 		int    GetApproximation();
 		int    GetNumberOfDofs(int approximation_enum,int setenum);
@@ -85,8 +80,9 @@
 		int    GetConnectivity();
 		void   GetDofList(int* poutdoflist,int approximation_enum,int setenum);
 		void   GetLocalDofList(int* poutdoflist,int approximation_enum,int setenum);
-		int    GetDofList1(void);
-		int    GetSidList(void);
+		int    GetVertexId(void);
+		int    GetVertexPid(void);
+		int    GetVertexSid(void);
 		IssmDouble GetX();
 		IssmDouble GetY();
 		IssmDouble GetZ();
@@ -99,9 +95,6 @@
 		void   UpdateSpcs(IssmDouble* ys);
 		void   VecMerge(Vector<IssmDouble>* ug, IssmDouble* vector_serial,int setenum);
 		void   VecReduce(Vector<IssmDouble>* vector, IssmDouble* ug_serial,int setnum);
-		
-		/*}}}*/
-		/*Dof Object routines {{{*/
 		void  DistributeDofs(int* pdofcount,int setenum);
 		void  OffsetDofs(int dofcount,int setenum);
 		void  ShowTrueDofs(int* truerows,int ncols,int setenum);

Modified: issm/trunk/src/c/classes/objects/Object.h
===================================================================
--- issm/trunk/src/c/classes/objects/Object.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Object.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -7,7 +7,6 @@
  * DataSet.
  */
 
-
 #ifndef _OBJECT_H_
 #define _OBJECT_H_
 
@@ -19,7 +18,6 @@
 		virtual void  Echo()=0;
 		virtual void  DeepEcho()=0;
 		virtual int   Id()=0;
-		virtual int   MyRank()=0;
 		virtual int   ObjectEnum()=0;
 		virtual Object* copy()=0;
 

Modified: issm/trunk/src/c/classes/objects/Options/GenericOption.h
===================================================================
--- issm/trunk/src/c/classes/objects/Options/GenericOption.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Options/GenericOption.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,12 +28,12 @@
 
 	public:
 
-		char* name;
-		OptionType value;
+		char       *name;
+		OptionType  value;
 
-		int   numel; //in case OptionType is an array
-		int   ndims; //in case OptionType is a multi-dimensional array: */
-		int*  size;
+		int         numel;   //in case OptionType is an array
+		int         ndims;   //in case OptionType is a multi-dimensional array: */
+		int        *size;
 
 		/*GenericOption constructors, destructors*/
 		GenericOption(){ /*{{{*/
@@ -43,7 +43,6 @@
 			ndims =0;
 			size  =NULL;
 
-
 		} /*}}}*/
 		~GenericOption(){ /*{{{*/
 
@@ -80,10 +79,9 @@
 			_printLine_(indent << "         value: " << value);;
 		} /*}}}*/
 		int   Id(){_error_("Not implemented yet");};
-		int   MyRank(){_error_("Not implemented yet");};
 		int   ObjectEnum(){return GenericOptionEnum;};
 		Object* copy(){_error_("Not implemented yet");};
-		
+
 		/*GenericOption functions: */
 		char* Name(){return name;};
 		int   NumEl(){return numel;};
@@ -92,7 +90,7 @@
 		void  Get(OptionType* pvalue){ *pvalue=value; };
 };
 
-#ifdef _HAVE_ADOLC_ //We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization. 
+#if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_)  //We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization. 
 template <> inline void GenericOption<IssmPDouble*>::Get(IssmPDouble** pvalue){ /*{{{*/
 
 	/*Copy vector*/
@@ -114,11 +112,8 @@
 } /*}}}*/
 template <> inline void GenericOption<char*>::Get(char** pvalue){ /*{{{*/
 
-	char* outstring=NULL;
-	int   stringsize;
-
-	stringsize=strlen(this->value)+1;
-	outstring=xNew<char>(stringsize);
+	int   stringsize=strlen(this->value)+1;
+	char* outstring=xNew<char>(stringsize);
 	xMemCpy<char>(outstring,this->value,stringsize);
 
 	*pvalue=outstring;

Modified: issm/trunk/src/c/classes/objects/Options/Option.h
===================================================================
--- issm/trunk/src/c/classes/objects/Options/Option.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Options/Option.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,20 +17,17 @@
 
 	public:
 
-		
-		/*Option constructors, destructors {{{*/
+		/*Option constructors, destructors*/
 		Option(){};
 		~Option(){};
-		/*}}}*/
-		/*Object virtual functions definitions:{{{*/
+
+		/*Object virtual functions definitions*/
 		virtual void  Echo()= 0;
 		virtual void  DeepEcho()= 0;
 		virtual void  DeepEcho(char  *indent)=0;
 		int           Id(){_error_("Not implemented yet"); };
-		int           MyRank(){_error_("Not implemented yet"); };
 		int           ObjectEnum(){return OptionEnum;              };
 		Object       *copy(){_error_("Not implemented yet"); };
-		/*}}}*/
 
 		/*virtual functions: */
 		virtual char* Name()=0;
@@ -40,4 +37,3 @@
 
 };
 #endif  /* _OPTIONOBJECT_H */
-

Modified: issm/trunk/src/c/classes/objects/Options/OptionUtilities.h
===================================================================
--- issm/trunk/src/c/classes/objects/Options/OptionUtilities.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Options/OptionUtilities.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,4 +21,3 @@
 int StringFromSize(char* cstr, int* size, int ndims);
 
 #endif  /* _OPTIONUTILITIES_H */
-

Modified: issm/trunk/src/c/classes/objects/Params/BoolParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/BoolParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/BoolParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,8 +25,8 @@
 	return;
 }
 /*}}}*/
-/*FUNCTION BoolParam::BoolParam(int enum_type,IssmBool value){{{*/
-BoolParam::BoolParam(int in_enum_type,IssmBool in_value){
+/*FUNCTION BoolParam::BoolParam(int enum_type,bool value){{{*/
+BoolParam::BoolParam(int in_enum_type,bool in_value){
 
 	enum_type=in_enum_type;
 	value=in_value;
@@ -55,12 +55,6 @@
 /*FUNCTION BoolParam::Id{{{*/
 int    BoolParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION BoolParam::MyRank{{{*/
-int    BoolParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION BoolParam::ObjectEnum{{{*/
 int BoolParam::ObjectEnum(void){
 
@@ -70,7 +64,7 @@
 /*}}}*/
 /*FUNCTION BoolParam::copy{{{*/
 Object* BoolParam::copy() {
-	
+
 	return new BoolParam(this->enum_type,this->value);
 
 }

Modified: issm/trunk/src/c/classes/objects/Params/BoolParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/BoolParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/BoolParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _BOOLPARAM_H_
 #define _BOOLPARAM_H_
 
@@ -24,18 +23,17 @@
 	public:
 		/*just hold 3 values for 3 vertices: */
 		int enum_type;
-		IssmBool value;
+		bool value;
 
 		/*BoolParam constructors, destructors: {{{*/
 		BoolParam();
-		BoolParam(int enum_type,IssmBool value);
+		BoolParam(int enum_type,bool value);
 		~BoolParam();
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -55,6 +53,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){this->value=boolean;}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an int");}
@@ -70,7 +69,7 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
-		
+
 		void GetParameterName(char**pname);
 		/*}}}*/
 };

Modified: issm/trunk/src/c/classes/objects/Params/DoubleMatArrayParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/DoubleMatArrayParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/DoubleMatArrayParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -76,7 +76,7 @@
 		matrix=array[i];
 		xDelete<IssmDouble>(matrix);
 	}
-	
+
 	xDelete<IssmDouble*>(array);
 	return;
 }
@@ -99,7 +99,7 @@
 	int i,j,k;
 	int m,n;
 	IssmDouble* matrix=NULL;
-	
+
 	_printLine_("DoubleMatArrayParam:");
 	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	_printLine_("   array size: " << this->M);
@@ -120,12 +120,6 @@
 /*FUNCTION DoubleMatArrayParam::Id{{{*/
 int    DoubleMatArrayParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleMatArrayParam::MyRank{{{*/
-int    DoubleMatArrayParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION DoubleMatArrayParam::ObjectEnum{{{*/
 int DoubleMatArrayParam::ObjectEnum(void){
 
@@ -135,7 +129,7 @@
 /*}}}*/
 /*FUNCTION DoubleMatArrayParam::copy{{{*/
 Object* DoubleMatArrayParam::copy() {
-	
+
 	return new DoubleMatArrayParam(this->enum_type,this->array, this->M, this->mdim_array,this->ndim_array);
 
 }
@@ -155,7 +149,6 @@
 	int*     out_mdim_array=NULL;
 	int*     out_ndim_array=NULL;
 
-
 	out_M=this->M;
 	if(out_M){
 		out_array=xNew<IssmDouble*>(M);
@@ -186,7 +179,6 @@
 		out_ndim_array=NULL;
 	}
 
-
 	/*Assign output pointers:*/
 	if(pout_M) *pout_M=out_M;
 	if(pout_mdim_array) *pout_mdim_array=out_mdim_array;
@@ -221,7 +213,7 @@
 	this->array=xNew<IssmDouble*>(M);
 	this->mdim_array=xNew<int>(M);
 	this->ndim_array=xNew<int>(M);
-	
+
 	xMemCpy<int>(this->mdim_array,in_mdim_array,M);
 	xMemCpy<int>(this->ndim_array,in_ndim_array,M);
 

Modified: issm/trunk/src/c/classes/objects/Params/DoubleMatArrayParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/DoubleMatArrayParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/DoubleMatArrayParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for object holding an array of serial matrices
  */
 
-
 #ifndef _DOUBLEMATARRAYPARAM_H_
 #define _DOUBLEMATARRAYPARAM_H_
 
@@ -22,11 +21,11 @@
 class DoubleMatArrayParam: public Param{
 
 	private: 
-		int      enum_type;
-		IssmDouble** array; //array of matrices
-		int      M; //size of array
-		int*     mdim_array; //m-dimensions of matrices in the array
-		int*     ndim_array; //n-dimensions -f matrices in the array
+		int          enum_type;
+		IssmDouble **array;        //array of matrices
+		int          M;            //size of array
+		int         *mdim_array;   //m-dimensions of matrices in the array
+		int         *ndim_array;   //n-dimensions -f matrices in the array
 
 	public:
 		/*DoubleMatArrayParam constructors, destructors: {{{*/
@@ -38,7 +37,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -58,6 +56,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold an integer");}

Modified: issm/trunk/src/c/classes/objects/Params/DoubleMatParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/DoubleMatParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/DoubleMatParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -57,7 +57,7 @@
 void DoubleMatParam::DeepEcho(void){
 
 	int i,j;
-	
+
 	_printLine_("DoubleMatParam:");
 	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	_printLine_("   matrix size: " << this->M << "x" << this->N);
@@ -71,12 +71,6 @@
 /*FUNCTION DoubleMatParam::Id{{{*/
 int    DoubleMatParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleMatParam::MyRank{{{*/
-int    DoubleMatParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION DoubleMatParam::ObjectEnum{{{*/
 int DoubleMatParam::ObjectEnum(void){
 
@@ -86,7 +80,7 @@
 /*}}}*/
 /*FUNCTION DoubleMatParam::copy{{{*/
 Object* DoubleMatParam::copy() {
-	
+
 	return new DoubleMatParam(this->enum_type,this->value,this->M,this->N);
 
 }

Modified: issm/trunk/src/c/classes/objects/Params/DoubleMatParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/DoubleMatParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/DoubleMatParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _DOUBLEMATPARAM_H_
 #define _DOUBLEMATPARAM_H_
 
@@ -22,10 +21,10 @@
 class DoubleMatParam: public Param{
 
 	protected: 
-		int enum_type;
-		IssmDouble* value;
-		int M;
-		int N;
+		int         enum_type;
+		IssmDouble *value;
+		int         M;
+		int         N;
 
 	public:
 		/*DoubleMatParam constructors, destructors: {{{*/
@@ -37,7 +36,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -57,6 +55,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}

Modified: issm/trunk/src/c/classes/objects/Params/DoubleParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/DoubleParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/DoubleParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -52,12 +52,6 @@
 /*FUNCTION DoubleParam::Id{{{*/
 int    DoubleParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleParam::MyRank{{{*/
-int    DoubleParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION DoubleParam::ObjectEnum{{{*/
 int DoubleParam::ObjectEnum(void){
 
@@ -67,7 +61,7 @@
 /*}}}*/
 /*FUNCTION DoubleParam::copy{{{*/
 Object* DoubleParam::copy() {
-	
+
 	return new DoubleParam(this->enum_type,this->value);
 
 }

Modified: issm/trunk/src/c/classes/objects/Params/DoubleParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/DoubleParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/DoubleParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _DOUBLEPARAM_H_
 #define _DOUBLEPARAM_H_
 
@@ -23,7 +22,7 @@
 
 	private: 
 		/*just hold 3 values for 3 vertices: */
-		int enum_type;
+		int        enum_type;
 		IssmDouble value;
 
 	public:
@@ -36,7 +35,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -56,6 +54,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){this->value=(IssmDouble)boolean;}
 		void  SetValue(int integer){this->value=(IssmDouble)integer;}

Modified: issm/trunk/src/c/classes/objects/Params/DoubleTransientMatParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/DoubleTransientMatParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/DoubleTransientMatParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for DoubleTransientMatParam object
  */
 
-
 #ifndef _DOUBLETRANSIENTMATPARAM_H_
 #define _DOUBLETRANSIENTMATPARAM_H_
 

Modified: issm/trunk/src/c/classes/objects/Params/DoubleVecParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/DoubleVecParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/DoubleVecParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -56,7 +56,7 @@
 void DoubleVecParam::DeepEcho(void){
 
 	int i;
-	
+
 	_printLine_("DoubleVecParam:");
 	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	_printLine_("   vector size: " << this->M);
@@ -68,12 +68,6 @@
 /*FUNCTION DoubleVecParam::Id{{{*/
 int    DoubleVecParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION DoubleVecParam::MyRank{{{*/
-int    DoubleVecParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION DoubleVecParam::ObjectEnum{{{*/
 int DoubleVecParam::ObjectEnum(void){
 
@@ -83,7 +77,7 @@
 /*}}}*/
 /*FUNCTION DoubleVecParam::copy{{{*/
 Object* DoubleVecParam::copy() {
-	
+
 	return new DoubleVecParam(this->enum_type,this->values,this->M);
 
 }

Modified: issm/trunk/src/c/classes/objects/Params/DoubleVecParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/DoubleVecParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/DoubleVecParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _DOUBLEVECPARAM_H_
 #define _DOUBLEVECPARAM_H_
 
@@ -22,9 +21,9 @@
 class DoubleVecParam: public Param{
 
 	private: 
-		int enum_type;
-		IssmDouble* values;
-		int M;
+		int         enum_type;
+		IssmDouble *values;
+		int         M;
 
 	public:
 		/*DoubleVecParam constructors, destructors: {{{*/
@@ -36,7 +35,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -56,6 +54,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
@@ -71,7 +70,7 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
-		
+
 		void GetParameterName(char**pname);
 		/*}}}*/
 };

Modified: issm/trunk/src/c/classes/objects/Params/FileParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/FileParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/FileParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -55,12 +55,6 @@
 /*FUNCTION FileParam::Id{{{*/
 int    FileParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION FileParam::MyRank{{{*/
-int    FileParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION FileParam::ObjectEnum{{{*/
 int FileParam::ObjectEnum(void){
 
@@ -70,7 +64,7 @@
 /*}}}*/
 /*FUNCTION FileParam::copy{{{*/
 Object* FileParam::copy() {
-	
+
 	return new FileParam(this->enum_type,this->value);
 
 }

Modified: issm/trunk/src/c/classes/objects/Params/FileParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/FileParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/FileParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _FILEPARAM_H_
 #define _FILEPARAM_H_
 
@@ -35,7 +34,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -55,6 +53,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){*pfid=value;};
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}

Modified: issm/trunk/src/c/classes/objects/Params/GenericParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/GenericParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/GenericParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -48,7 +48,6 @@
                 }
                 void  Echo() {DeepEcho();};
                 int   Id(){ return -1; };
-                int   MyRank() { extern int my_rank; return my_rank;} ;
                 int   ObjectEnum() {return AdolcParamEnum;};
 
                 // the "copy"  has to implement the base class abstract function
@@ -79,6 +78,7 @@
                 void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a Vec");}
                 void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a Mat");}
                 void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a FILE");}
+				void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a DataSet");}
 
                 void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a bool");}
                 void  SetValue(int integer){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold an integer");}
@@ -98,5 +98,4 @@
                 /*}}}*/
 };
 
-
 #endif /* GENERICPARAM_H_ */

Modified: issm/trunk/src/c/classes/objects/Params/IntMatParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/IntMatParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/IntMatParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -57,7 +57,7 @@
 void IntMatParam::DeepEcho(void){
 
 	int i,j;
-	
+
 	_printLine_("IntMatParam:");
 	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	_printLine_("   matrix size: " << this->M << "x" << this->N);
@@ -71,12 +71,6 @@
 /*FUNCTION IntMatParam::Id{{{*/
 int    IntMatParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION IntMatParam::MyRank{{{*/
-int    IntMatParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION IntMatParam::ObjectEnum{{{*/
 int IntMatParam::ObjectEnum(void){
 
@@ -86,7 +80,7 @@
 /*}}}*/
 /*FUNCTION IntMatParam::copy{{{*/
 Object* IntMatParam::copy() {
-	
+
 	return new IntMatParam(this->enum_type,this->value,this->M,this->N);
 
 }

Modified: issm/trunk/src/c/classes/objects/Params/IntMatParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/IntMatParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/IntMatParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _INTMATPARAM_H_
 #define _INTMATPARAM_H_
 
@@ -37,7 +36,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -57,6 +55,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}

Modified: issm/trunk/src/c/classes/objects/Params/IntParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/IntParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/IntParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -55,12 +55,6 @@
 /*FUNCTION IntParam::Id{{{*/
 int    IntParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION IntParam::MyRank{{{*/
-int    IntParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION IntParam::ObjectEnum{{{*/
 int IntParam::ObjectEnum(void){
 
@@ -70,7 +64,7 @@
 /*}}}*/
 /*FUNCTION IntParam::copy{{{*/
 Object* IntParam::copy() {
-	
+
 	return new IntParam(this->enum_type,this->value);
 
 }

Modified: issm/trunk/src/c/classes/objects/Params/IntParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/IntParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/IntParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _INTPARAM_H_
 #define _INTPARAM_H_
 
@@ -36,7 +35,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -56,6 +54,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a bool");}
 		void  SetValue(int integer){this->value=integer;}

Modified: issm/trunk/src/c/classes/objects/Params/IntVecParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/IntVecParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/IntVecParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -72,7 +72,7 @@
 void IntVecParam::DeepEcho(void){
 
 	int i;
-	
+
 	_printLine_("IntVecParam:");
 	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	_printLine_("   vector size: " << this->M);
@@ -84,12 +84,6 @@
 /*FUNCTION IntVecParam::Id{{{*/
 int    IntVecParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION IntVecParam::MyRank{{{*/
-int    IntVecParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION IntVecParam::ObjectEnum{{{*/
 int IntVecParam::ObjectEnum(void){
 
@@ -99,7 +93,7 @@
 /*}}}*/
 /*FUNCTION IntVecParam::copy{{{*/
 Object* IntVecParam::copy() {
-	
+
 	return new IntVecParam(this->enum_type,this->values,this->M);
 
 }

Modified: issm/trunk/src/c/classes/objects/Params/IntVecParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/IntVecParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/IntVecParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _INTVECPARAM_H_
 #define _INTVECPARAM_H_
 
@@ -37,7 +36,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -57,6 +55,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
@@ -72,7 +71,7 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
 		void  UnitConversion(int direction_enum);
-		
+
 		void GetParameterName(char**pname);
 		/*}}}*/
 };

Modified: issm/trunk/src/c/classes/objects/Params/MatrixParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/MatrixParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/MatrixParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -54,7 +54,6 @@
 /*FUNCTION MatrixParam::DeepEcho{{{*/
 void MatrixParam::DeepEcho(void){
 
-	int i;
 	_printLine_("MatrixParam:");
 	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	this->value->Echo();
@@ -63,12 +62,6 @@
 /*FUNCTION MatrixParam::Id{{{*/
 int    MatrixParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION MatrixParam::MyRank{{{*/
-int    MatrixParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION MatrixParam::ObjectEnum{{{*/
 int MatrixParam::ObjectEnum(void){
 
@@ -78,7 +71,7 @@
 /*}}}*/
 /*FUNCTION MatrixParam::copy{{{*/
 Object* MatrixParam::copy() {
-	
+
 	return new MatrixParam(this->enum_type,this->value);
 
 }
@@ -102,10 +95,10 @@
 /*}}}*/
 /*FUNCTION MatrixParam::SetValue{{{*/
 void  MatrixParam::SetValue(Matrix<IssmDouble>* matrix){
-	
+
 	/*avoid leak: */
 	xdelete(&value);
-	
+
 	/*copy: */
 	value=matrix->Duplicate();
 }

Modified: issm/trunk/src/c/classes/objects/Params/MatrixParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/MatrixParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/MatrixParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for MatrixParam object
  */
 
-
 #ifndef _MATRIXPARAM_H_
 #define _MATRIXPARAM_H_
 
@@ -36,7 +35,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -56,6 +54,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** poutput);
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}

Modified: issm/trunk/src/c/classes/objects/Params/Param.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/Param.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/Param.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief abstract class for Param object
  */ 
 
-
 #ifndef _PARAM_H_
 #define _PARAM_H_
 
@@ -40,7 +39,8 @@
 		virtual void  GetParameterValue(Vector<IssmDouble>** pvec)=0;
 		virtual void  GetParameterValue(Matrix<IssmDouble>** pmat)=0;
 		virtual void  GetParameterValue(FILE** pfid)=0;
-		
+		virtual void  GetParameterValue(DataSet** pdataset)=0;
+
 		virtual void  SetValue(bool boolean)=0;
 		virtual void  SetValue(int integer)=0;
 		virtual void  SetValue(IssmDouble scalar)=0;

Modified: issm/trunk/src/c/classes/objects/Params/StringArrayParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/StringArrayParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/StringArrayParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -45,14 +45,14 @@
 		}
 	}
 	else value=NULL;
-	
+
 }
 /*}}}*/
 /*FUNCTION StringArrayParam::~StringArrayParam(){{{*/
 StringArrayParam::~StringArrayParam(){
-		
+
 	int i;
-	
+
 	char* string=NULL;
 	for(i=0;i<this->numstrings;i++){
 		string=value[i];
@@ -85,12 +85,6 @@
 /*FUNCTION StringArrayParam::Id{{{*/
 int    StringArrayParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION StringArrayParam::MyRank{{{*/
-int    StringArrayParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION StringArrayParam::ObjectEnum{{{*/
 int StringArrayParam::ObjectEnum(void){
 
@@ -100,7 +94,7 @@
 /*}}}*/
 /*FUNCTION StringArrayParam::copy{{{*/
 Object* StringArrayParam::copy() {
-	
+
 	return new StringArrayParam(this->enum_type,this->value,this->numstrings);
 
 }
@@ -109,7 +103,7 @@
 /*StringArrayParam virtual functions definitions: */
 /*FUNCTION StringArrayParam::GetParameterValue{{{*/
 void  StringArrayParam::GetParameterValue(char*** pstringarray,int* pM){
-	
+
 	int   i;
 	char** outstrings=NULL;
 	int   M;
@@ -145,7 +139,7 @@
 /*}}}*/
 /*FUNCTION StringArrayParam::SetValue{{{*/
 void  StringArrayParam::SetValue(char** stringarray,int M){
-	
+
 	int   i;
 	char *string     = NULL;
 	char *string2    = NULL;

Modified: issm/trunk/src/c/classes/objects/Params/StringArrayParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/StringArrayParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/StringArrayParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _STRINGARRAYPARAM_H_
 #define _STRINGARRAYPARAM_H_
 
@@ -27,7 +26,6 @@
 		char**   value;
 		int      numstrings;
 
-
 	public:
 		/*StringArrayParam constructors, destructors: {{{*/
 		StringArrayParam();
@@ -38,7 +36,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -58,6 +55,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}

Modified: issm/trunk/src/c/classes/objects/Params/StringParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/StringParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/StringParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -32,7 +32,6 @@
 	value=xNew<char>(strlen(in_value)+1);
 	xMemCpy<char>(value,in_value,(strlen(in_value)+1));
 
-	
 }
 /*}}}*/
 /*FUNCTION StringParam::~StringParam(){{{*/
@@ -57,12 +56,6 @@
 /*FUNCTION StringParam::Id{{{*/
 int    StringParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION StringParam::MyRank{{{*/
-int    StringParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION StringParam::ObjectEnum{{{*/
 int StringParam::ObjectEnum(void){
 
@@ -72,7 +65,7 @@
 /*}}}*/
 /*FUNCTION StringParam::copy{{{*/
 Object* StringParam::copy() {
-	
+
 	return new StringParam(this->enum_type,this->value);
 
 }
@@ -81,7 +74,7 @@
 /*StringParam virtual functions definitions: */
 /*FUNCTION StringParam::GetParameterValue{{{*/
 void  StringParam::GetParameterValue(char** pstring){
-	
+
 	char* outstring=NULL;
 	int   stringsize;
 
@@ -101,9 +94,9 @@
 /*}}}*/
 /*FUNCTION StringParam::SetValue{{{*/
 void  StringParam::SetValue(char* string){
-	
+
 	int   stringsize;
-	
+
 	/*avoid leak: */
 	xDelete<char>(this->value);
 

Modified: issm/trunk/src/c/classes/objects/Params/StringParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/StringParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/StringParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _STRINGPARAM_H_
 #define _STRINGPARAM_H_
 
@@ -23,8 +22,8 @@
 
 	private: 
 		/*just hold 3 values for 3 vertices: */
-		int enum_type;
-		char* value;
+		int   enum_type;
+		char *value;
 
 	public:
 		/*StringParam constructors, destructors: {{{*/
@@ -36,7 +35,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -56,6 +54,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}

Modified: issm/trunk/src/c/classes/objects/Params/TransientParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/TransientParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/TransientParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -60,12 +60,10 @@
 /*FUNCTION TransientParam::DeepEcho{{{*/
 void TransientParam::DeepEcho(void){
 
-	int i,j;
-	
 	_printLine_("TransientParam:");
 	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	_printLine_("   size: " << this->N);
-	for(i=0;i<this->N;i++){
+	for(int i=0;i<this->N;i++){
 		_printLine_(   "time: " << this->timesteps[i] << " value: " << this->values[i]);
 	}
 }
@@ -73,12 +71,6 @@
 /*FUNCTION TransientParam::Id{{{*/
 int    TransientParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION TransientParam::MyRank{{{*/
-int    TransientParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION TransientParam::ObjectEnum{{{*/
 int TransientParam::ObjectEnum(void){
 
@@ -88,7 +80,7 @@
 /*}}}*/
 /*FUNCTION TransientParam::copy{{{*/
 Object* TransientParam::copy() {
-	
+
 	return new TransientParam(this->enum_type,this->values,this->timesteps,this->N);
 
 }

Modified: issm/trunk/src/c/classes/objects/Params/TransientParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/TransientParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/TransientParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _TRANSIENTPARAM_H_
 #define _TRANSIENTPARAM_H_
 
@@ -22,10 +21,10 @@
 class TransientParam: public Param{
 
 	protected: 
-		int enum_type;
-		int N;
-		IssmDouble* values;
-		IssmDouble* timesteps;
+		int         enum_type;
+		int         N;
+		IssmDouble *values;
+		IssmDouble *timesteps;
 
 	public:
 		/*TransientParam constructors, destructors: {{{*/
@@ -37,7 +36,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -57,6 +55,7 @@
 		void  GetParameterValue(Vector<IssmDouble>** pvec){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a Vec");}
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(FILE** pfid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold an integer");}

Modified: issm/trunk/src/c/classes/objects/Params/VectorParam.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Params/VectorParam.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/VectorParam.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -56,7 +56,6 @@
 /*FUNCTION VectorParam::DeepEcho{{{*/
 void VectorParam::DeepEcho(void){
 
-	int i;
 	_printLine_("VectorParam:");
 	_printLine_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
 	value->Echo();
@@ -65,12 +64,6 @@
 /*FUNCTION VectorParam::Id{{{*/
 int    VectorParam::Id(void){ return -1; }
 /*}}}*/
-/*FUNCTION VectorParam::MyRank{{{*/
-int    VectorParam::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION VectorParam::ObjectEnum{{{*/
 int VectorParam::ObjectEnum(void){
 
@@ -80,7 +73,7 @@
 /*}}}*/
 /*FUNCTION VectorParam::copy{{{*/
 Object* VectorParam::copy() {
-	
+
 	return new VectorParam(this->enum_type,this->value);
 
 }
@@ -108,7 +101,7 @@
 
 	/*avoid leak: */
 	xdelete(&value);
-	
+
 	/*copy: */
 	value=vector->Duplicate();
 	vector->Copy(value);

Modified: issm/trunk/src/c/classes/objects/Params/VectorParam.h
===================================================================
--- issm/trunk/src/c/classes/objects/Params/VectorParam.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Params/VectorParam.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  *  \brief: header file for triavertexinput object
  */
 
-
 #ifndef _VECTORPARAM_H_
 #define _VECTORPARAM_H_
 
@@ -36,7 +35,6 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
@@ -56,6 +54,7 @@
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(Vector<IssmDouble>** poutput);
 		void  GetParameterValue(FILE** pfid){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
+		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
 
 		void  SetValue(bool boolean){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}

Modified: issm/trunk/src/c/classes/objects/Segment.h
===================================================================
--- issm/trunk/src/c/classes/objects/Segment.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Segment.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,31 +14,30 @@
 class Segment: public Object{
 
 	public:
-		int eid;
+		int        eid;
 		doubletype x1;
 		doubletype y1;
 		doubletype x2;
 		doubletype y2;
 
-
 		/*Segment constructors, destructors :*/
 		/*FUNCTION Segment() default constructor {{{*/
 		Segment(){
-			this->eid=UNDEF;
-			this->x1=UNDEF;
-			this->y1=UNDEF;
-			this->x2=UNDEF;
-			this->y2=UNDEF;
+			this->eid = UNDEF;
+			this->x1  = UNDEF;
+			this->y1  = UNDEF;
+			this->x2  = UNDEF;
+			this->y2  = UNDEF;
 		}
 		/*}}}*/
 		/*FUNCTION Segment(int eid, doubletype x1,doubletype y1,doubletype x2, doubletype y2){{{*/
 		Segment(int segment_eid, doubletype segment_x1,doubletype segment_y1,doubletype segment_x2, doubletype segment_y2){
 
-			this->eid=segment_eid;
-			this->x1=segment_x1;
-			this->y1=segment_y1;
-			this->x2=segment_x2;
-			this->y2=segment_y2;
+			this->eid = segment_eid;
+			this->x1  = segment_x1;
+			this->y1  = segment_y1;
+			this->x2  = segment_x2;
+			this->y2  = segment_y2;
 
 		}
 		/*}}}*/
@@ -66,13 +65,6 @@
 		/*FUNCTION Id{{{*/
 		int    Id(void){ return eid; }
 		/*}}}*/
-		/*FUNCTION MyRank{{{*/
-		int    MyRank(void){ 
-			extern int my_rank;
-
-			return my_rank; 
-		}
-		/*}}}*/
 		/*FUNCTION ObjectEnum{{{*/
 		int ObjectEnum(void){
 
@@ -83,9 +75,7 @@
 		/*FUNCTION copy {{{*/
 		Object* copy() {
 			return new Segment(this->eid,this->x1,this->y1,this->x2,this->y2);
-
 		}
-
 		/*}}}*/
 
 };

Modified: issm/trunk/src/c/classes/objects/Vertex.cpp
===================================================================
--- issm/trunk/src/c/classes/objects/Vertex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Vertex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -48,12 +48,12 @@
 	/*all the initialization has been done by the initializer, just fill in the id: */
 	this->id=vertex_id;
 	this->sid=vertex_sid;
+	this->pid=UNDEF;
 	this->x=vertex_x;
 	this->y=vertex_y;
 	this->z=vertex_z;
 	this->sigma=vertex_sigma;
 	this->connectivity=vertex_connectivity;
-	this->dof=UNDEF;
 
 	return;
 }
@@ -66,12 +66,12 @@
 	_printLine_("Vertex:");
 	_printLine_("   id: " << id);
 	_printLine_("   sid: " << sid);
+	_printLine_("   pid: " << pid);
 	_printLine_("   x: " << x);
 	_printLine_("   y: " << y);
 	_printLine_("   z: " << z);
 	_printLine_("   sigma: " << sigma);
 	_printLine_("   connectivity: " << connectivity);
-	_printLine_("   dof: " << dof);
 	_printLine_("   clone: " << clone);
 
 	return;
@@ -85,12 +85,6 @@
 /*FUNCTION Vertex::Id{{{*/
 int    Vertex::Id(void){ return id; }
 /*}}}*/
-/*FUNCTION Vertex::MyRank {{{*/
-int    Vertex::MyRank(void){ 
-	extern int my_rank;
-	return my_rank; 
-}
-/*}}}*/
 /*FUNCTION Vertex::ObjectEnum{{{*/
 int Vertex::ObjectEnum(void){
 
@@ -106,113 +100,96 @@
 }
 /*}}}*/
 
-/* DofObject routines: */
-/*FUNCTION Vertex::DistributeDofs{{{*/
-void  Vertex::DistributeDofs(int* pdofcount){
+/*Vertex management: */
+/*FUNCTION Vertex::Connectivity{{{*/
+int    Vertex::Connectivity(void){return connectivity;}
+/*}}}*/
+/*FUNCTION Vertex::Sid{{{*/
+int    Vertex::Sid(void){ return sid; }
+/*}}}*/
+/*FUNCTION Vertex::UpdateVertexPosition {{{*/
+void  Vertex::UpdatePosition(Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed){
 
-	int i;
-	extern int my_rank;
-	int dofcount;
+	IssmDouble oldz,newz;
+	IssmDouble dt,velz;
 
-	dofcount=*pdofcount;
-	
-	if(this->clone){
-		/*This vertex is a clone! Don't distribute dofs, it will get them from another cpu!*/
-		return;
-	}
+	/*Get time stepping*/
+	parameters->FindParam(&dt,TimesteppingTimeStepEnum);
 
-	/*This vertex should distribute his dof, go ahead: */
-	this->dof=dofcount;
-	dofcount++;
+	/*sigma remains constant. z=bed+sigma*thickness*/
+	oldz = this->z;
+	newz = bed[this->pid]+sigma*thickness[this->pid];
+	velz = (newz-oldz)/dt;
+	this->z = newz;
 
-	/*Assign output pointers: */
-	*pdofcount=dofcount;
+	/*put vz in vector*/
+	vz->SetValue(this->pid,velz,INS_VAL);
+}
+/*}}}*/
+/*FUNCTION Vertex::DistributePids{{{*/
+void  Vertex::DistributePids(int* ppidcount){
 
+	/*retrieve current pid*/
+	int pidcount=*ppidcount;
+
+	/*This vertex is a clone! Don't distribute pids, it will get them from another cpu!*/
+	if(this->clone) return;
+
+	/*This vertex should distribute its pid*/
+	this->pid=pidcount;
+	pidcount++;
+
+	/*Assign output pointers: */
+	*ppidcount=pidcount;
 }
 /*}}}*/
-/*FUNCTION Vertex::OffsetDofs{{{*/
-void  Vertex::OffsetDofs(int dofcount){
-	
-	int i;
-	extern int my_rank;
-	
-	if(this->clone){
-		/*This vertex is a clone, don't offset the dofs!: */
-		return;
-	}
+/*FUNCTION Vertex::OffsetPids{{{*/
+void  Vertex::OffsetPids(int pidcount){
 
-	/*This vertex should offset his dof, go ahead: */
-	this->dof+=dofcount;
+	/*This vertex is a clone, don't offset the pids*/
+	if(this->clone) return;
+
+	/*This vertex should offset his pid, go ahead: */
+	this->pid+=pidcount;
 }
 /*}}}*/
-/*FUNCTION Vertex::ShowTrueDofs{{{*/
-void  Vertex::ShowTrueDofs(int* truedofs){
+/*FUNCTION Vertex::ShowTruePids{{{*/
+void  Vertex::ShowTruePids(int* truepids){
 
-	int j;
-	extern int my_rank;
-	
 	/*Are we a clone? : */
 	if(this->clone)return;
 
-	/*Ok, we are not a clone, just plug our dof into truedofs: */
-	truedofs[this->id-1]=this->dof;
-
+	/*Ok, we are not a clone, just plug our pid into truepids: */
+	truepids[this->sid]=this->pid;
 }
 /*}}}*/
-/*FUNCTION Vertex::UpdateCloneDofs{{{*/
-void  Vertex::UpdateCloneDofs(int* alltruedofs){
+/*FUNCTION Vertex::UpdateClonePids{{{*/
+void  Vertex::UpdateClonePids(int* alltruepids){
 
-	int j;
-	extern int my_rank;
-	
-	/*If we are not a clone, don't update, we already have dofs!: */
-	if(this->clone==0)return;
+	/*If we are not a clone, don't update, we already have pids: */
+	if(!this->clone)return;
 
-	/*Ok, we are a clone node, but we did not create the dof for this vertex 
-	 * Therefore, our dof is garbage right now. Go pick it up in the alltruedofs: */
-	this->dof=alltruedofs[id-1];
+	/*Ok, we are a clone node, but we did not create the pid for this vertex 
+	 * Therefore, our pid is garbage right now. Go pick it up in the alltruepids: */
+	this->pid=alltruepids[this->sid];
 }
 /*}}}*/
 /*FUNCTION Vertex::SetClone {{{*/
 void  Vertex::SetClone(int* minranks){
 
-	extern int my_rank;
+	int my_rank;
 
-	if (minranks[id-1]==my_rank){
-		this->clone=0;
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
+	if (minranks[this->sid]==my_rank){
+		this->clone=false;
 	}
 	else{
 		/*!there is a cpu with lower rank that has the same vertex, 
 		therefore, I am a clone*/
-		this->clone=1; 	
+		this->clone=true;
 	}
 
 }
 /*}}}*/
-
-/*Vertex management: */
-/*FUNCTION Vertex::Connectivity{{{*/
-int    Vertex::Connectivity(void){return connectivity;}
-/*}}}*/
-/*FUNCTION Vertex::Sid{{{*/
-int    Vertex::Sid(void){ return sid; }
-/*}}}*/
-/*FUNCTION Vertex::UpdateVertexPosition {{{*/
-void  Vertex::UpdatePosition(Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed){
-
-	IssmDouble oldz,newz;
-	IssmDouble dt,velz;
-
-	/*Get time stepping*/
-	parameters->FindParam(&dt,TimesteppingTimeStepEnum);
-
-	/*sigma remains constant. z=bed+sigma*thickness*/
-	oldz = this->z;
-	newz = bed[this->dof]+sigma*thickness[this->dof];
-	velz = (newz-oldz)/dt;
-	this->z = newz;
-
-	/*put vz in vector*/
-	vz->SetValue(this->dof,velz,INS_VAL);
-}
-/*}}}*/

Modified: issm/trunk/src/c/classes/objects/Vertex.h
===================================================================
--- issm/trunk/src/c/classes/objects/Vertex.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/Vertex.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,32 +8,27 @@
 /*Headers:*/
 /*{{{*/
 #include "../classes.h"
-class IoModel;
-template <class doubletype> class Vector;
-class Parameters;
 #include "../../shared/Exceptions/exceptions.h"
 #include "../../toolkits/toolkits.h"
 #include "../../include/include.h"
-
+template <class doubletype> class Vector;
+class Parameters;
+class IoModel;
 /*}}}*/
 
-
 class Vertex: public Object{
 
 	public: 
-
-		int    id;
-		int    sid;            //sid for "serial" id, ie the rank of this vertex in the vertices dataset, if the dataset was serial on 1 cpu.
+		bool       clone;
+		int        id;           // random index
+		int        sid;          // "serial" id (rank of this vertex if the dataset was on 1 cpu)
+		int        pid;          // "parallel" id
 		IssmDouble x;
 		IssmDouble y;
 		IssmDouble z;
-		IssmDouble sigma;          //sigma coordinate: (z-bed)/thickness
-		int    connectivity;   //number of vertices connected to this vertex
+		IssmDouble sigma;        //sigma coordinate: (z-bed)/thickness
+		int        connectivity; //number of vertices connected to this vertex
 
-		/*dof management: */
-		int    clone;
-		int    dof; //dof to recover values in a vertex indexed vector
-
 		/*Vertex constructors, destructors {{{*/
 		Vertex();
 		Vertex(int id, int sid,IssmDouble x, IssmDouble y, IssmDouble z, IssmDouble sigma, int connectivity); 
@@ -45,21 +40,17 @@
 		void  Echo();
 		void  DeepEcho();
 		int   Id(); 
-		int   MyRank();
 		int   ObjectEnum();
 		Object* copy();
 		/*}}}*/
-		/*DofObject routines {{{*/
-		void  DistributeDofs(int* pdofcount);
-		void  OffsetDofs(int dofcount);
-		void  ShowTrueDofs(int* borderdofs);
-		void  UpdateCloneDofs(int* allborderdofs);
-		void  SetClone(int* minranks);
-		/*}}}*/
-		/*Vertex management: {{{*/
+		/*Vertex management:*/ 
 		int   Sid(void); 
 		int   Connectivity(void); 
 		void  UpdatePosition(Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed);
-		/*}}}*/
+		void  DistributePids(int* ppidcount);
+		void  OffsetPids(int pidcount);
+		void  ShowTruePids(int* borderpids);
+		void  UpdateClonePids(int* allborderpids);
+		void  SetClone(int* minranks);
 };
 #endif  /* _VERTEX_H */

Modified: issm/trunk/src/c/classes/objects/objects.h
===================================================================
--- issm/trunk/src/c/classes/objects/objects.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/classes/objects/objects.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,6 +12,9 @@
 #include "./Contour.h"
 #include "./Vertex.h"
 #include "./Node.h"
+#include "./Profiler.h"
+#include "./DependentObject.h"
+#include "./IndependentObject.h"
 #include "./Segment.h"
 
 /*Constraints: */
@@ -118,5 +121,6 @@
 #include "./Params/StringArrayParam.h"
 #include "./Params/StringParam.h"
 #include "./Params/TransientParam.h"
+#include "./Params/DataSetParam.h"
 
 #endif

Modified: issm/trunk/src/c/include/globals.h
===================================================================
--- issm/trunk/src/c/include/globals.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/include/globals.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,9 @@
 #ifndef GLOBALS_H_
 #define GLOBALS_H_
 
-int my_rank=0;
-int num_procs=1;
+#include "./types.h"
+#include "../classes/IssmComm.h"
 
+COMM IssmComm::comm;
+
 #endif

Modified: issm/trunk/src/c/include/macros.h
===================================================================
--- issm/trunk/src/c/include/macros.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/include/macros.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,7 +22,7 @@
 /*Printing macro: only cpu number 0 */
 #define _printf_(flag,...) do{if(flag) PrintfFunction(__VA_ARGS__);}while(0)
 /*}}}*/
-/* _error2_ {{{*/
+/* _error_ {{{*/
 /*new Error exception macro*/
 #ifdef _INTEL_WIN_
 #define _error_(StreamArgs)\
@@ -70,26 +70,27 @@
   ((void) 0)
 #endif
 /*}}}*/
-/* ISSMBOOT/ISSMEND {{{*/
+/* ExceptionTrapBegin/ExceptionTrapEnd {{{*/
 
 /*The following macros hide the error exception handling in a matlab module. Just put 
- * ISSMBOOT(); and ISSMEND(); at the beginning and end of a module, and c++ exceptions 
+ * ExceptionTrapBegin(); and ExceptionTrapEnd(); at the beginning and end of a module, and c++ exceptions 
  * will be trapped. Really nifty!*/
 
-#define ISSMBOOT(); \
+#define ExceptionTrapBegin(); \
 	try{
 
-#define ISSMEND(); }\
+#define ExceptionTrapEnd(); }\
 	catch(ErrorException &exception){\
-		exception.Report(); \
-		return 1;\
+		exception.Report();\
+		return 0;\
 	}\
 	catch (exception& e) {\
 		_printf_(true,"Standard exception: %s\n",e.what());\
-		return 1;\
+		return 0;\
 	}\
 	catch(...){\
 		_printf_(true,"An unexpected error occurred");\
+		return 0;\
 	}
 /*}}}*/
 

Modified: issm/trunk/src/c/include/typedefs.h
===================================================================
--- issm/trunk/src/c/include/typedefs.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/include/typedefs.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -35,7 +35,7 @@
 //Most generic way it would seem:
 #define INFINITY (DBL_MAX+DBL_MAX)
 #define NAN (INFINITY-INFINITY)
-	
+
 #endif
 
 #endif //ifndef _ISSMTYPEDEFS_H_

Modified: issm/trunk/src/c/include/types.h
===================================================================
--- issm/trunk/src/c/include/types.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/include/types.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,6 @@
 #ifndef _TYPES_H_
 #define  _TYPES_H_
 
-
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -26,7 +25,7 @@
 //#define MPIU_INT MPI_INT already defined in petsc
 #endif  
 
-#ifdef _HAVE_ADOLC_
+#if defined(_HAVE_ADOLC_) &&  !defined(_WRAPPERS_)
 #include "adolc/adolc.h"
 // for active variables
 typedef adouble IssmDouble;
@@ -39,6 +38,12 @@
 typedef IssmDouble IssmPDouble;
 #endif
 
-typedef bool IssmBool;
+/*Define communicator: */
+#ifdef _HAVE_MPI_
+#include <mpi.h>
+typedef MPI_Comm COMM;
+#else
+typedef int COMM;
+#endif
 
 #endif //ifndef _TYPES_H_

Modified: issm/trunk/src/c/io/Disk/diskio.h
===================================================================
--- issm/trunk/src/c/io/Disk/diskio.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/io/Disk/diskio.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,5 +9,6 @@
 
 FILE* pfopen(char* filename,const char* format);
 void  pfclose(FILE* fid,char* filename);
+void WriteLockFile(char* filename);
 
 #endif	/* _IO_H_ */

Modified: issm/trunk/src/c/io/Disk/pfclose.cpp
===================================================================
--- issm/trunk/src/c/io/Disk/pfclose.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/io/Disk/pfclose.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,7 +15,6 @@
 void pfclose(FILE* fid,char* filename){
 
 	/*Close file handle: */
-	extern int my_rank;
 	_assert_(fid);
 	if(fclose(fid)!=0)_error_("could not close file " << filename);
 }

Modified: issm/trunk/src/c/io/Disk/pfopen.cpp
===================================================================
--- issm/trunk/src/c/io/Disk/pfopen.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/io/Disk/pfopen.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,12 +15,10 @@
 FILE* pfopen(char* filename,const char* format){
 
 	FILE* fid=NULL;
-	extern int my_rank;
-	
+
 	/*Open handle to data on disk: */
 	fid=fopen(filename,format);
 	if(fid==NULL) _error_("could not open file " << filename << " for binary reading or writing"); 
 
 	return fid;
 }
-

Modified: issm/trunk/src/c/io/PrintfFunction.cpp
===================================================================
--- issm/trunk/src/c/io/PrintfFunction.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/io/PrintfFunction.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,13 +14,13 @@
 	/*string to be printed: */
 	char *buffer = NULL;
 	int   n,size = 100;
-	int         string_size;
-	extern int  my_rank;
-	extern int  num_procs;
-                                                                                                                                                                                                     
+	int   my_rank;
 	//variable list of arguments
 	va_list args;
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	while(true){
 
 		/*allocate buffer for given string size*/
@@ -51,14 +51,22 @@
 	return 1;
 }
 int PrintfFunction(const string & message){
-	extern int  my_rank;
+	int  my_rank;
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	if(my_rank==0){
 		printf("%s\n",message.c_str());
 	}
 	return 1;
 }
 int PrintfFunction2(const string & message){
-	extern int  my_rank;
+	int  my_rank;
+
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	if(my_rank==0){
 		printf("%s",message.c_str());
 	}

Modified: issm/trunk/src/c/issm.h
===================================================================
--- issm/trunk/src/c/issm.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/issm.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,6 +11,7 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
+#include "./include/globals.h" //only include this header file once!
 #include "./include/include.h"
 #include "./shared/shared.h"
 #include "./classes/classes.h"

Modified: issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.cpp
===================================================================
--- issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 #include "../../shared/shared.h"
 
 int AverageFilterx(double** pimageout,double* image, int lines,int samps,int smooth){
-	
+
 	double      temp;
 	int         numvalues;
 	long			i, j;

Modified: issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.h
===================================================================
--- issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/AverageFilterx/AverageFilterx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,6 +10,5 @@
 
 /* local prototypes: */
 int AverageFilterx(double** pimageout,double* imagein, int lines,int samp,int smooth);
-	
-#endif /* AVERAGEFILTERX_H */
 
+#endif /* AVERAGEFILTERX_H */

Modified: issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp
===================================================================
--- issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,12 +17,9 @@
 #include "../../toolkits/toolkits.h"
 #include "../modules.h"
 
-			
 void AverageOntoPartitionx(double** paverage, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* vertex_response){
 
-	int     i,j,k;
 	int     dummy;
-
 	int     npart;
 	double *qmu_part  = NULL;
 	int     numberofvertices;
@@ -48,8 +45,8 @@
 	vec_average=new Vector<IssmDouble>(npart);
 
 	/*loop on each element, and add contribution of the element to the partition (surface weighted average): */
-	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+	for(int i=0;i<elements->Size();i++){
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->AverageOntoPartition(partition_contributions,partition_areas,vertex_response,qmu_part);
 	}
 

Modified: issm/trunk/src/c/modules/Bamgx/Bamgx.cpp
===================================================================
--- issm/trunk/src/c/modules/Bamgx/Bamgx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Bamgx/Bamgx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,8 +19,8 @@
 	int    nbsmooth;
 
 	/*intermediary*/
+	int i;
 	int noerr=1;
-	int i,j,num;
 	double costheta=2;
 	double hminaniso=1e-100; 
 	Mesh* Thr=NULL;

Modified: issm/trunk/src/c/modules/Chacox/Chacox.cpp
===================================================================
--- issm/trunk/src/c/modules/Chacox/Chacox.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Chacox/Chacox.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,8 +20,7 @@
 )
 {
 	#ifdef _HAVE_CHACO_ //only works if Chaco library has been compiled in.
-	
-	
+
 	extern int Using_Main;	/* is main routine being called? */
 	extern char *PARAMS_FILENAME;	/* name of file with parameter updates */
 	extern double EIGEN_TOLERANCE;	/* tolerance for eigen calculations */
@@ -62,8 +61,6 @@
 	int i,tvwgt;
 	double tgoal;
 
-
-
 	if (DEBUG_TRACE > 0) {
 		_printLine_("<Entering main>");
 	}
@@ -186,10 +183,9 @@
 	if (DEBUG_TRACE > 1) {
 		_printLine_("<Leaving main>");
 	}
-	
+
 	return(0);
 
-
 	#else //ifdef _HAVE_CHACO_
 	return (0);
 	#endif

Modified: issm/trunk/src/c/modules/Chacox/Chacox.h
===================================================================
--- issm/trunk/src/c/modules/Chacox/Chacox.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Chacox/Chacox.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -43,5 +43,4 @@
 #undef __FUNCT__ 
 #define __FUNCT__  "Chacox"
 
-
 #endif  /* _CHACOX_H */

Modified: issm/trunk/src/c/modules/Chacox/chaco_seconds.cpp
===================================================================
--- issm/trunk/src/c/modules/Chacox/chaco_seconds.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Chacox/chaco_seconds.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -7,10 +7,8 @@
 #include   <sys/resource.h>
 #endif
 
-
-
 double chaco_seconds(void){
-    
+
 	double    curtime;
 
 #ifdef RUSAGE_SELF
@@ -21,7 +19,7 @@
 	 *as it clobbers the prototype int getrusag(int target,rusage* results) which 
 	 *is defined in the <sys/time.h> and <sys/resource.h> header files. Leaving it 
 	 *for reference in case we have a problem here in the future*/
- 
+
     getrusage(RUSAGE_SELF, &rusage);
     curtime = ((rusage.ru_utime.tv_sec + rusage.ru_stime.tv_sec) +
 	    1.0e-6 * (rusage.ru_utime.tv_usec + rusage.ru_stime.tv_usec));

Modified: issm/trunk/src/c/modules/Chacox/input_parse.cpp
===================================================================
--- issm/trunk/src/c/modules/Chacox/input_parse.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Chacox/input_parse.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,7 +4,6 @@
 
 #include "./Chacox.h"
 
-
 #undef __FUNCT__ 
 #define __FUNCT__  "input_parse"
 

Modified: issm/trunk/src/c/modules/Chacox/user_params.cpp
===================================================================
--- issm/trunk/src/c/modules/Chacox/user_params.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Chacox/user_params.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,7 +13,6 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
-
 #ifdef _HAVE_CHACO_ //only works if dakota library has been compiled in.
 
 #include "params.h"
@@ -21,7 +20,6 @@
 #define  TRUE  1
 #define  FALSE 0
 
-
 /* Input and ouput control parameters */
 
 int       CHECK_INPUT = TRUE;	 /* Check input for consistency? (TRUE/FALSE) */
@@ -34,7 +32,6 @@
 int       PROMPT = FALSE;	 /* Prompt for input? (TRUE/FALSE) */
 int       PRINT_HEADERS = FALSE; /* Print pretty output headers (TRUE/FALSE) */
 
-
 /* Eigenvector calculation parameters */
 
 int       LANCZOS_TYPE = 3;	/* type of Lanczos to use */
@@ -56,7 +53,6 @@
 int       LANCZOS_TIME = FALSE;	/* Detailed Lanczos times? (TRUE/FALSE) */
 int       TIME_KERNELS = FALSE;	/* Time numerical kernels? (TRUE/FALSE) */
 
-
 /* Other parameters for spectral methods */
 
 int       MAKE_CONNECTED = TRUE;/* Connect graph if using spectral method? */
@@ -68,7 +64,6 @@
 int       COARSE_NLEVEL_RQI = 2;/* # levels between RQI calls in uncoarsening */
 int       OPT3D_NTRIES = 5;	/* # local opts to look for global min in opt3d */
 
-
 /* Kernighan--Lin/Fiduccia--Mattheyses parameters */
 
 int       KL_METRIC = 2;	/* KL interset cost: 1=>cuts, 2=>hops */
@@ -78,7 +73,6 @@
 int       KL_UNDO_LIST = TRUE;	/* Only resort changed vtxs? (TRUE/FALSE) */
 double    KL_IMBALANCE = 0.0;	/* Fractional imbalance allowed by KL */
 
-
 /* Coarsening parameters */
 
 double    COARSEN_RATIO_MIN = .7;  /* Min vtx reduction each coarsen stage */
@@ -90,14 +84,12 @@
 int       COARSEN_EWGTS = TRUE;	   /* Sum edge weights in coarsening? (TRUE/FALSE) */
 int       KL_ONLY_BNDY = TRUE;	   /* Start moving vtxs on boundary? (TRUE/FALSE) */
 
-
 /* Parameters for post-processing options */
 
 int       REFINE_PARTITION = FALSE;	/* Postprocess to improve cuts? */
 int       INTERNAL_VERTICES = FALSE;	/* ... to up internal vtxs? (TRUE/FALSE) */
 int       REFINE_MAP = FALSE;		/* ... to reduce hops? (TRUE/FALSE) */
 
-
 /* Architecture and simulator parameters */
 
 int       ARCHITECTURE = 0;	/* 0=> hypercube, d=> d-dimensional mesh (0..3)*/
@@ -128,7 +120,6 @@
 int       FREE_GRAPH = FALSE;	/* Free input graph data? (TRUE/FALSE) */
 char     *PARAMS_FILENAME = "User_Params";	/* File of parameter changes */
 
-
 /* Parameters that control debugging output */
 
 int       DEBUG_EVECS = 0;	/* Debug flag for eigenvector generation (0..5) */
@@ -150,5 +141,4 @@
 int       DEBUG_TRACE = 0;	/* Trace main execution path (0..2) */
 int       DEBUG_MACH_PARAMS = 0;/* Print computed machine params? (0..1) */
 
-
 #endif //ifdef _HAVE_CHACO_ 

Modified: issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp
===================================================================
--- issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,7 +28,7 @@
 
 	/*Compute basal stress for each element: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->ComputeBasalStress(sigma);
 	}
 
@@ -37,5 +37,5 @@
 
 	/*Assign output pointers: */
 	*psigma=sigma;
-	
+
 }

Modified: issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.h
===================================================================
--- issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ComputeBasalStressx/ComputeBasalStressx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,4 +12,3 @@
 void	ComputeBasalStressx( Vector<IssmDouble>** pp_g,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
 
 #endif  /* _COMPUTEBASALSTRESSX_H */
-

Modified: issm/trunk/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.cpp
===================================================================
--- issm/trunk/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,7 +28,7 @@
 
 	/*Compute basal stress for each element: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->ComputeStrainRate(eps);
 	}
 
@@ -37,5 +37,5 @@
 
 	/*Assign output pointers: */
 	*peps=eps;
-	
+
 }

Modified: issm/trunk/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.h
===================================================================
--- issm/trunk/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ComputeStrainRatex/ComputeStrainRatex.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,4 +12,3 @@
 void	ComputeStrainRatex(Vector<IssmDouble>** eps_g,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
 
 #endif  /* _COMPUTESTRAINRATEX_H */
-

Modified: issm/trunk/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp
===================================================================
--- issm/trunk/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -23,10 +23,10 @@
 
 	/*Get analysis type: */
 	parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
-	
+
 	if(VerboseMProcessor()) _pprintLine_("      Configuring elements...");
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->Configure(elements,loads,nodes,materials,parameters);
 	}
 	if(VerboseMProcessor()) _pprintLine_("      Configuring loads...");
@@ -43,7 +43,7 @@
 			node->Configure(nodes,vertices);
 		}
 	}
-	
+
 	if(VerboseMProcessor()) _pprintLine_("      Configuring materials...");
 	for (i=0;i<materials->Size();i++){
 		material=(Material*)materials->GetObjectByOffset(i);

Modified: issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStateLocal.h
===================================================================
--- issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStateLocal.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStateLocal.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -26,4 +26,3 @@
 int    RiftIsMaterialStable(Loads* loads);
 
 #endif  /* _CONSTRAINTSSTATEX_H */
-

Modified: issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp
===================================================================
--- issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,11 +12,6 @@
 
 void ConstraintsStatex(int* pconverged, int* pnum_unstable_constraints, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads,Materials* materials,  Parameters* parameters){
 
-	int i;
-
-	extern int num_procs;
-	extern int my_rank;
-	
 	/*output: */
 	int converged=0;
 	int num_unstable_constraints=0;
@@ -45,7 +40,7 @@
 		num_unstable_constraints=0;
 		converged=1;
 	}
-		
+
 	/*Assign output pointers: */
 	*pconverged=converged;
 	*pnum_unstable_constraints=num_unstable_constraints;

Modified: issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.h
===================================================================
--- issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,4 +14,3 @@
 void ConstraintsStatex(int* pconverged, int* pnum_unstable_constraints, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads,Materials* materials,  Parameters* parameters); 
 
 #endif  /* _CONSTRAINTSSTATEX_H */
-

Modified: issm/trunk/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp
===================================================================
--- issm/trunk/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,9 +14,8 @@
 /*RiftIsPresent(Loads* loads,int configuration_type){{{*/
 int RiftIsPresent(Loads* loads,int configuration_type){
 
-
 	int i;
-	
+
 	int found=0;
 	int mpi_found=0;
 
@@ -32,8 +31,8 @@
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
+	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm());                
 	found=mpi_found;
 	#endif
 
@@ -45,11 +44,10 @@
 
 	int num_unstable_constraints=0;
 	int converged=0;
-	int potential;
 
 	RiftConstrain(&num_unstable_constraints,loads,configuration_type);
 	if(num_unstable_constraints==0)converged=1;
-	
+
 	if(RiftIsFrozen(loads,configuration_type)){
 		converged=1;
 		num_unstable_constraints=0;
@@ -68,7 +66,7 @@
 void RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int configuration_type){
 
 	int			i;
-	
+
 	/* generic object pointer: */
 	Riftfront* riftfront=NULL;
 	Load*      load=NULL;
@@ -76,7 +74,7 @@
 	int unstable;
 	int sum_num_unstable_constraints;
 	int num_unstable_constraints=0;	
-		
+
 	/*Enforce constraints: */
 	for (i=0;i<loads->Size();i++){
 
@@ -95,11 +93,11 @@
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
+	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm());                
 	num_unstable_constraints=sum_num_unstable_constraints;
 	#endif
-	
+
 	/*Assign output pointers: */
 	*pnum_unstable_constraints=num_unstable_constraints;
 
@@ -109,7 +107,7 @@
 int RiftIsFrozen(Loads* loads,int configuration_type){
 
 	int			i;
-	
+
 	/* generic object pointer: */
 	Load*      load=NULL;
 	Riftfront* riftfront=NULL;
@@ -120,7 +118,7 @@
 	for (i=0;i<loads->Size();i++){
 
 		if (RiftfrontEnum==loads->GetEnum(i)){
-			
+
 			load=(Load*)loads->GetObjectByOffset(i);
 			if(load->InAnalysis(configuration_type)){
 
@@ -132,11 +130,11 @@
 			}
 		}
 	}
-	
+
 	/*Is there just one found? that would mean we have frozen! : */
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_MAX,0,MPI_COMM_WORLD );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
+	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm());                
 	found=mpi_found;
 	#endif
 
@@ -147,7 +145,7 @@
 void RiftFreezeConstraints(Loads* loads,int configuration_type){
 
 	int			i;
-	
+
 	/* generic object pointer: */
 	Load*      load=NULL;
 	Riftfront* riftfront=NULL;
@@ -159,7 +157,7 @@
 
 			load=(Load*)loads->GetObjectByOffset(i);
 			if(load->InAnalysis(configuration_type)){
-				
+
 				riftfront=(Riftfront*)load;
 				riftfront->FreezeConstraints();
 			}
@@ -175,7 +173,7 @@
 int RiftIsMaterialStable(Loads* loads){
 
 	int i;
-	
+
 	Riftfront* riftfront=NULL;
 	int found=0;
 	int mpi_found=0;
@@ -195,8 +193,8 @@
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
+	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm());                
 	found=mpi_found;
 	#endif
 
@@ -206,9 +204,8 @@
 /*RiftIsPreStable(Loads* loads){{{*/
 int RiftIsPreStable(Loads* loads){
 
-
 	int i;
-	
+
 	Riftfront* riftfront=NULL;
 	int found=0;
 	int mpi_found=0;
@@ -228,8 +225,8 @@
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
+	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm());                
 	found=mpi_found;
 	#endif
 
@@ -245,9 +242,8 @@
 /*RiftSetPreStable(Loads* loads){{{*/
 void RiftSetPreStable(Loads* loads){
 
-
 	int i;
-	
+
 	Riftfront* riftfront=NULL;
 	int found=0;
 	int mpi_found=0;
@@ -267,14 +263,14 @@
 void RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads){
 
 	int			i;
-	
+
 	/* generic object pointer: */
 	Riftfront* riftfront=NULL;
 
 	int unstable;
 	int sum_num_unstable_constraints;
 	int num_unstable_constraints=0;	
-		
+
 	/*Enforce constraints: */
 	for (i=0;i<loads->Size();i++){
 
@@ -289,11 +285,11 @@
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
+	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm());                
 	num_unstable_constraints=sum_num_unstable_constraints;
 	#endif
-	
+
 	/*Assign output pointers: */
 	*pnum_unstable_constraints=num_unstable_constraints;
 
@@ -303,7 +299,7 @@
 void RiftMaxPenetrationInInputs(Loads* loads){
 
 	int			i;
-	
+
 	/* generic object pointer: */
 	Riftfront* riftfront=NULL;
 
@@ -329,8 +325,8 @@
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&max_penetration,&mpi_max_penetration,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD );
-	MPI_Bcast(&mpi_max_penetration,1,MPI_DOUBLE,0,MPI_COMM_WORLD);                
+	MPI_Reduce (&max_penetration,&mpi_max_penetration,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
+	MPI_Bcast(&mpi_max_penetration,1,MPI_DOUBLE,0,IssmComm::GetComm());                
 	max_penetration=mpi_max_penetration;
 	#endif
 
@@ -345,7 +341,7 @@
 int RiftPotentialUnstableConstraints(Loads* loads){
 
 	int			i;
-	
+
 	/* generic object pointer: */
 	Riftfront* riftfront=NULL;
 
@@ -368,8 +364,8 @@
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
+	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm());                
 	num_unstable_constraints=sum_num_unstable_constraints;
 	#endif
 

Modified: issm/trunk/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp
===================================================================
--- issm/trunk/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -36,8 +36,8 @@
 	}
 
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,MPI_COMM_WORLD);                
+	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm());                
 	num_unstable_constraints=sum_num_unstable_constraints;
 	#endif
 

Modified: issm/trunk/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp
===================================================================
--- issm/trunk/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -26,10 +26,10 @@
 			}
 		}
 	}
-	
+
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD);                
+	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm());                
 	found=mpi_found;
 	#endif
 

Modified: issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.cpp
===================================================================
--- issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -7,15 +7,10 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
-
 #include "./ContourToMeshx.h"
 
 int ContourToMeshx(SeqVec<double>** pin_nod,SeqVec<double>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue) {
 
-	int noerr=1;
-	int i;
-	int m,n;
-
 	/*Contour:*/
 	double*  in_nod_serial;
 	double   value;
@@ -27,7 +22,6 @@
 	num=_NUMTHREADS_;
 	#endif
 
-
 	/*output: */
 	SeqVec<double>* in_nod=NULL;
 	SeqVec<double>* in_elem=NULL;
@@ -53,7 +47,7 @@
 
 	/*Take care of the case where an element interpolation has been requested: */
 	if ((strcmp(interptype,"element")==0) || (strcmp(interptype,"element and node")==0)){
-		for (n=0;n<nel;n++){
+		for(int n=0;n<nel;n++){
 			if ( (in_nod_serial[ (int)*(index+3*n+0) -1] == 1) && (in_nod_serial[ (int)*(index+3*n+1) -1] == 1) && (in_nod_serial[ (int)*(index+3*n+2) -1] == 1) ){
 				value=1; in_elem->SetValue(n,value,INS_VAL);
 			}
@@ -70,5 +64,5 @@
 	/*Free ressources:*/
 	xDelete<double>(in_nod_serial);
 
-	return noerr;
+	return 1;
 }

Modified: issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.h
===================================================================
--- issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
 	ContourToMeshx.h
 */
 
-
 #ifndef _CONTOURTOMESHX_H
 #define _CONTOURTOMESHX_H
 
@@ -21,7 +20,6 @@
 
 } ContourToMeshxThreadStruct;
 
-
 /* local prototypes: */
 int ContourToMeshx(SeqVec<double>** pin_nods,SeqVec<double>** pin_elem, double* index, double* x, double* y,DataSet* contours,char* interptype,int nel,int nods, int edgevalue);
 

Modified: issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp
===================================================================
--- issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ContourToMeshx/ContourToMeshxt.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 #include "./ContourToMeshx.h"
 
 void* ContourToMeshxt(void* vpthread_handle){
-	
+
 	int noerr=1;
 
 	/*gate variables :*/

Modified: issm/trunk/src/c/modules/ContourToNodesx/ContourToNodesx.cpp
===================================================================
--- issm/trunk/src/c/modules/ContourToNodesx/ContourToNodesx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ContourToNodesx/ContourToNodesx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,14 +6,12 @@
 int ContourToNodesx(SeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, Contour<IssmPDouble>** contours,int numcontours,int edgevalue){
 
 	int i;
-	int m,n;
 
 	/*Contour:*/
 	Contour<IssmPDouble>* contouri=NULL;
 	int      numnodes;
 	double*  xc=NULL;
 	double*  yc=NULL;
-	double   value;
 
 	/*output: */
 	SeqVec<IssmPDouble>* flags=NULL;
@@ -33,21 +31,15 @@
 
 	/*Assign output pointers: */
 	*pflags=flags;
-	
 	return 1;
 }
 
 int ContourToNodesx(SeqVec<IssmPDouble>** pflags,double* x, double* y, int nods, DataSet* contours, int edgevalue){
 
-	int i;
-	int m,n;
-
 	/*Contour:*/
 	Contour<IssmPDouble>* contouri=NULL;
-	int      numnodes;
 	double*  xc=NULL;
 	double*  yc=NULL;
-	double   value;
 
 	/*output: */
 	SeqVec<IssmPDouble>* flags=NULL;
@@ -55,7 +47,7 @@
 
 	/*Loop through all contours: */
 	if(contours){
-		for (i=0;i<contours->Size();i++){
+		for(int i=0;i<contours->Size();i++){
 			Contour<IssmPDouble>* contour=(Contour<IssmPDouble>*)contours->GetObjectByOffset(i);
 			IsInPoly(flags,contour->x,contour->y,contour->nods,x,y,0,nods,edgevalue);
 		}

Modified: issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp
===================================================================
--- issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ControlInputScaleGradientx/ControlInputScaleGradientx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,7 +16,6 @@
 	IssmDouble *scalar_list = NULL;
 	IssmDouble  scalar;
 
-
 	/*Retrieve some parameters*/
 	parameters->FindParam(&num_controls,InversionNumControlParametersEnum);
 	parameters->FindParam(&control_type,NULL,InversionControlParametersEnum);

Modified: issm/trunk/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp
===================================================================
--- issm/trunk/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,23 +11,24 @@
 
 void CreateNodalConstraintsx( Vector<IssmDouble>** pys, Nodes* nodes,int configuration_type){
 
-	int i;
-	
-	/*intermediary: */
-	int  numberofdofs;
+	bool  oldalloc  = false;
 
 	/*output: */
 	Vector<IssmDouble>* ys=NULL;
 
 	/*figure out how many dofs we have: */
-	numberofdofs=nodes->NumberOfDofs(configuration_type,SsetEnum);
+	int ssize=nodes->NumberOfDofs(configuration_type,SsetEnum);
+	int slocalsize = nodes->NumberOfDofsLocal(configuration_type,SsetEnum);
 
 	/*allocate:*/
-	ys=new Vector<IssmDouble>(numberofdofs);
+	if(oldalloc)
+	 ys=new Vector<IssmDouble>(ssize);
+	else
+	 ys=new Vector<IssmDouble>(slocalsize,ssize);
 
 	/*go through all nodes, and for the ones corresponding to this configuration_type, fill the 
 	 * constraints vector with the constraint values: */
-	for (i=0;i<nodes->Size();i++){
+	for(int i=0;i<nodes->Size();i++){
 		Node* node=(Node*)nodes->GetObjectByOffset(i);
 		if (node->InAnalysis(configuration_type)){
 			node->CreateNodalConstraints(ys);

Modified: issm/trunk/src/c/modules/Delta18oParameterizationx/Delta18oParameterizationx.cpp
===================================================================
--- issm/trunk/src/c/modules/Delta18oParameterizationx/Delta18oParameterizationx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Delta18oParameterizationx/Delta18oParameterizationx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,10 +14,10 @@
   /*Intermediary*/
   int    i;
   Element* element = NULL;
- 
+
   /*Compute temperature and precipitation fields: */
   for(i=0;i<elements->Size();i++){
-    element=(Element*)elements->GetObjectByOffset(i);
+    element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
     element->Delta18oParameterization();
   }  
 }

Modified: issm/trunk/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp
===================================================================
--- issm/trunk/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,14 +21,14 @@
 
 	/*Compute Misfit: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		J+=element->DragCoefficientAbsGradient(process_units,weight_index);
 	}
 
 	/*Sum all J from all cpus of the cluster:*/
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
 	#endif
 

Modified: issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp
===================================================================
--- issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -40,13 +40,13 @@
 	/*Go through all elements, and for each element, go through its nodes, to get the neighbouring elements. 
 	 * Once we get the neighbouring elements, figure out if they share a segment with the current element. If so, 
 	 * plug them in the connectivity, unless they are already there.: */
-	
+
 	for(n=0;n<nel;n++){
 
 		element=(double)(n+1); //matlab indexing
 
 		for(i=0;i<3;i++){
-		
+
 			node=(int)*(elements+n*3+i); //already matlab indexed, elements comes directly from the workspace.
 			index=node-1;
 
@@ -57,7 +57,7 @@
 				/*for each element connected to node, figure out if it has a commond edge with element: */
 				connectedelement=*(nodeconnectivity+width*index+j);
 				connectedelementindex=(int)(connectedelement-1); //go from matlab indexing to c indexing.
-				
+
 				if(hascommondedge(elements+n*3+0,elements+connectedelementindex*3+0)){
 					/*Ok, this connected element has a commond edge  with element, plug it into elementconnectivity, unless 
 					 *it is already there: */
@@ -79,7 +79,6 @@
 	/*Assign output pointers: */
 	*pelementconnectivity=elementconnectivity;
 }
-				
 
 int hascommondedge(double* element1,double* element2){
 

Modified: issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.h
===================================================================
--- issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ElementConnectivityx/ElementConnectivityx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,4 +9,3 @@
 void	ElementConnectivityx( double** pelementconnectivity, double* elements, int nel, double* nodeconnectivity, int nods, int width);
 
 #endif  /* _ELEMENTCONNECTIVITYX_H */
-

Modified: issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp
===================================================================
--- issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/EnumToStringx/EnumToStringx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,13 +17,25 @@
 	switch(en){
 
 		case AutodiffIsautodiffEnum : return "AutodiffIsautodiff";
-		case AutodiffDependentsEnum : return "AutodiffDependents";
 		case AutodiffNumDependentsEnum : return "AutodiffNumDependents";
-		case AutodiffIndependentsEnum : return "AutodiffIndependents";
+		case AutodiffNumDependentObjectsEnum : return "AutodiffNumDependentObjects";
+		case AutodiffDependentObjectNamesEnum : return "AutodiffDependentObjectNames";
+		case AutodiffDependentObjectTypesEnum : return "AutodiffDependentObjectTypes";
+		case AutodiffDependentObjectIndicesEnum : return "AutodiffDependentObjectIndices";
+		case AutodiffDependentObjectsEnum : return "AutodiffDependentObjects";
 		case AutodiffNumIndependentsEnum : return "AutodiffNumIndependents";
+		case AutodiffNumIndependentObjectsEnum : return "AutodiffNumIndependentObjects";
+		case AutodiffIndependentObjectNamesEnum : return "AutodiffIndependentObjectNames";
+		case AutodiffIndependentObjectTypesEnum : return "AutodiffIndependentObjectTypes";
+		case AutodiffIndependentObjectsEnum : return "AutodiffIndependentObjects";
 		case AutodiffJacobianEnum : return "AutodiffJacobian";
 		case AutodiffXpEnum : return "AutodiffXp";
-		case AutodiffFosForwardOutputEnum : return "AutodiffFosForwardOutput";
+		case AutodiffDriverEnum : return "AutodiffDriver";
+		case AutodiffFosForwardIndexEnum : return "AutodiffFosForwardIndex";
+		case AutodiffFovForwardIndicesEnum : return "AutodiffFovForwardIndices";
+		case AutodiffFosReverseIndexEnum : return "AutodiffFosReverseIndex";
+		case AutodiffMassFluxSegmentsPresentEnum : return "AutodiffMassFluxSegmentsPresent";
+		case AutodiffKeepEnum : return "AutodiffKeep";
 		case BalancethicknessSpcthicknessEnum : return "BalancethicknessSpcthickness";
 		case BalancethicknessStabilizationEnum : return "BalancethicknessStabilization";
 		case BalancethicknessThickeningRateEnum : return "BalancethicknessThickeningRate";
@@ -35,6 +47,7 @@
 		case ConstantsGEnum : return "ConstantsG";
 		case ConstantsReferencetemperatureEnum : return "ConstantsReferencetemperature";
 		case ConstantsYtsEnum : return "ConstantsYts";
+		case DependentObjectEnum : return "DependentObject";
 		case DiagnosticAbstolEnum : return "DiagnosticAbstol";
 		case DiagnosticIcefrontEnum : return "DiagnosticIcefront";
 		case DiagnosticIsnewtonEnum : return "DiagnosticIsnewton";
@@ -74,6 +87,7 @@
 		case HydrologyQEnum : return "HydrologyQ";
 		case HydrologySpcwatercolumnEnum : return "HydrologySpcwatercolumn";
 		case HydrologyStabilizationEnum : return "HydrologyStabilization";
+		case IndependentObjectEnum : return "IndependentObject";
 		case InversionControlParametersEnum : return "InversionControlParameters";
 		case InversionCostFunctionEnum : return "InversionCostFunction";
 		case InversionCostFunctionThresholdEnum : return "InversionCostFunctionThreshold";
@@ -147,8 +161,12 @@
 		case PrognosticSpcthicknessEnum : return "PrognosticSpcthickness";
 		case PrognosticStabilizationEnum : return "PrognosticStabilization";
 		case PrognosticVertexPairingEnum : return "PrognosticVertexPairing";
+		case PrognosticNumRequestedOutputsEnum : return "PrognosticNumRequestedOutputs";
+		case PrognosticRequestedOutputsEnum : return "PrognosticRequestedOutputs";
 		case QmuIsdakotaEnum : return "QmuIsdakota";
-		case QmuMassFluxSegmentsEnum : return "QmuMassFluxSegments";
+		case MassFluxSegmentsEnum : return "MassFluxSegments";
+		case MassFluxSegmentsPresentEnum : return "MassFluxSegmentsPresent";
+		case QmuMassFluxSegmentsPresentEnum : return "QmuMassFluxSegmentsPresent";
 		case QmuNumberofpartitionsEnum : return "QmuNumberofpartitions";
 		case QmuNumberofresponsesEnum : return "QmuNumberofresponses";
 		case QmuPartitionEnum : return "QmuPartition";
@@ -183,6 +201,8 @@
 		case SurfaceforcingsIssmbgradientsEnum : return "SurfaceforcingsIssmbgradients";
 		case SurfaceforcingsMonthlytemperaturesEnum : return "SurfaceforcingsMonthlytemperatures";
 		case SurfaceforcingsHcEnum : return "SurfaceforcingsHc";
+		case SurfaceforcingsHrefEnum : return "SurfaceforcingsHref";
+		case SurfaceforcingsSmbrefEnum : return "SurfaceforcingsSmbref";
 		case SurfaceforcingsSmbPosMaxEnum : return "SurfaceforcingsSmbPosMax";
 		case SurfaceforcingsSmbPosMinEnum : return "SurfaceforcingsSmbPosMin";
 		case SurfaceforcingsAPosEnum : return "SurfaceforcingsAPos";
@@ -269,6 +289,7 @@
 		case DatasetInputEnum : return "DatasetInput";
 		case DofIndexingEnum : return "DofIndexing";
 		case DoubleInputEnum : return "DoubleInput";
+		case DataSetParamEnum : return "DataSetParam";
 		case DoubleMatArrayParamEnum : return "DoubleMatArrayParam";
 		case DoubleMatParamEnum : return "DoubleMatParam";
 		case DoubleParamEnum : return "DoubleParam";
@@ -298,6 +319,7 @@
 		case PenpairEnum : return "Penpair";
 		case PentaEnum : return "Penta";
 		case PentaP1InputEnum : return "PentaP1Input";
+		case ProfilerEnum : return "Profiler";
 		case MatrixParamEnum : return "MatrixParam";
 		case VectorParamEnum : return "VectorParam";
 		case RiftfrontEnum : return "Riftfront";
@@ -466,6 +488,8 @@
 		case NodalEnum : return "Nodal";
 		case OldGradientEnum : return "OldGradient";
 		case OutputFilePointerEnum : return "OutputFilePointer";
+		case OutputFileNameEnum : return "OutputFileName";
+		case LockFileNameEnum : return "LockFileName";
 		case PetscOptionsAnalysesEnum : return "PetscOptionsAnalyses";
 		case PetscOptionsStringsEnum : return "PetscOptionsStrings";
 		case QmuErrNameEnum : return "QmuErrName";

Modified: issm/trunk/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp
===================================================================
--- issm/trunk/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Exp2Kmlx/Exp2Kmlx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -294,4 +294,3 @@
 
 	return(iret);
 }
-

Modified: issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp
===================================================================
--- issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -26,13 +26,13 @@
 	/*Get size of vector: */
 	gsize=nodes->NumberOfDofs(configuration_type,GsetEnum);
 	if (gsize==0) _error_("Allocating a Vec of size 0 as gsize=0 for configuration: " << EnumToStringx(configuration_type));
-	
+
 	/*Initialize solution: */
 	solution=new Vector<IssmDouble>(gsize);
-	
+
 	/*Go through elements and plug solution: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->GetSolutionFromInputs(solution);
 	}
 

Modified: issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h
===================================================================
--- issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,4 +12,3 @@
 void GetSolutionFromInputsx( Vector<IssmDouble>** psolution, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters);
 
 #endif  /* _GETSOLUTIONFROMINPUTSXX_H */
-

Modified: issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp
===================================================================
--- issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -36,10 +36,10 @@
 }
 
 void GetVectorFromControlInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, const char* data){
-	
+
 	/*output: */
 	IssmDouble* vector=NULL;
-	
+
 	/*intermediary: */
 	Vector<IssmDouble>* vec_vector=NULL;
 

Modified: issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h
===================================================================
--- issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/GetVectorFromControlInputsx/GetVectorFromControlInputsx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,4 +12,3 @@
 void	GetVectorFromControlInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,const char* data="value");
 
 #endif  /* _GETVECTORFROMCONTROLINPUTSXX_H */
-

Modified: issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp
===================================================================
--- issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,7 +20,7 @@
 
 		/*Look up in elements*/
 		for(i=0;i<elements->Size();i++){
-			Element* element=(Element*)elements->GetObjectByOffset(i);
+			Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 			element->GetVectorFromInputs(vector,name);
 		}
 
@@ -41,10 +41,10 @@
 }
 
 void GetVectorFromInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters, int name, int type){
-	
+
 	/*output: */
 	IssmDouble* vector=NULL;
-	
+
 	/*intermediary: */
 	Vector<IssmDouble>* vec_vector=NULL;
 

Modified: issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h
===================================================================
--- issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,4 +12,3 @@
 void	GetVectorFromInputsx( IssmDouble** pvector, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,int name,int type);
 
 #endif  /* _GETVECTORFROMINPUTSXX_H */
-

Modified: issm/trunk/src/c/modules/Gradjx/Gradjx.cpp
===================================================================
--- issm/trunk/src/c/modules/Gradjx/Gradjx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Gradjx/Gradjx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,7 +18,7 @@
 	int     *control_type  = NULL;
 	Vector<IssmDouble>  *gradient      = NULL;
 	Vector<IssmDouble> **gradient_list = NULL;
-	
+
 	/*retrieve some parameters: */
 	parameters->FindParam(&num_controls,InversionNumControlParametersEnum);   _assert_(num_controls);
 	parameters->FindParam(&control_type,NULL,InversionControlParametersEnum);

Modified: issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,9 +18,9 @@
 	IssmDouble*  old_floatingice                  = NULL;
 	Vector<IssmDouble>*      vec_old_floatingice              = NULL;
 	Element* element                          = NULL;
-	
+
 	if(VerboseModule()) _pprintLine_("   Migrating grounding line");
-	
+
 	/*retrieve parameters: */
 	parameters->FindParam(&migration_style,GroundinglineMigrationEnum);
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
@@ -42,7 +42,7 @@
 
 	/*Migrate grounding line : */
 	for(i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->MigrateGroundingLine(old_floatingice,vertices_ungrounding);
 	}
 
@@ -94,7 +94,7 @@
 
 	/*Fill vector vertices_potentially_floating: */
 	for(i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->PotentialSheetUngrounding(vec_vertices_potentially_ungrounding);
 	}
 
@@ -120,7 +120,6 @@
 	Node*    node                                  = NULL;
 	Element* element                               = NULL;
 
-
 	/*recover parameters: */
 	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
 	numberofvertices=vertices->NumberOfVertices();
@@ -131,13 +130,13 @@
 
 	nflipped=1; //bootstrap
 	while(nflipped){
-		
+
 		/*Vector of size number of elements*/
 		vec_elements_neighboring_floatingice=new Vector<IssmDouble>(elements->NumberOfElements(),true);
 
 		/*Figure out if any of the nodes of the element will be floating -> elements neighbouting the floating ice*/
 		for(i=0;i<elements->Size();i++){
-			element=(Element*)elements->GetObjectByOffset(i);
+			element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 			vec_elements_neighboring_floatingice->SetValue(element->Sid(),element->IsNodeOnShelfFromFlags(nodes_on_floatingice)?1.0:0.0,INS_VAL);
 		}
 
@@ -148,15 +147,15 @@
 		/*Go through elements_neighboring_floatingce, and update vector of the nodes that will start floating*/
 		local_nflipped=0;
 		for(i=0;i<elements->Size();i++){
-			element=(Element*)elements->GetObjectByOffset(i);
+			element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 			if(reCast<int,IssmDouble>(elements_neighboring_floatingce[element->Sid()])){
 				local_nflipped+=element->UpdatePotentialSheetUngrounding(vertices_potentially_ungrounding,vec_nodes_on_floatingice,nodes_on_floatingice);
 			}
 		}
 		vec_nodes_on_floatingice->Assemble();
-		
+
 		#ifdef _HAVE_MPI_
-		MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+		MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
 		if(VerboseConvergence()) _pprintLine_("   Additional number of vertices allowed to unground: " << nflipped);
 		#else
 		nflipped=local_nflipped;

Modified: issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.cpp
===================================================================
--- issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,16 +9,12 @@
 #include "../../shared/shared.h"
 
 int HoleFillerx(double** pimageout,double* image, int lines,int samps,int smooth){
-	
-	FILE 			*fp1;
-	unsigned long	filesize;
+
 	long			infinit;
 	double          temp;
-	long			i, j, k, l, ii, jj, bytes;
+	long			i, j, k, l, ii, jj;
 	long			iii, jjj;
-	long			test, prevlines, prevpix, test1, test2, thresh,counter;
-	long			bell, cycles, leftovers;
-	float			howlong;
+	long			test;
 	float			nsteps, ssteps, wsteps, esteps;
 	float			nwsteps, nesteps, swsteps, sesteps;
 	float			north, south, east, west;
@@ -28,7 +24,7 @@
 	float			nne, ene, ese, sse;
 	float			ssw, wsw, wnw, nnw;	
 	float			sum;
-	
+
 	time_t			t1, t2;
 
 	/*output: */
@@ -38,13 +34,10 @@
 	double*         image3=NULL;
 	double*         image4=NULL;
 
-	/*Added to original routine: */
-	int             imageoutsize;
-
 	 /*^^^^^^^^^^^^^  Remove pixels close to the holes ^^^^^^^^^^^^^*/
 	image2 = xNew<double>(lines*samps);
 	memcpy(image2,image,lines*samps*sizeof(double));
-	
+
   	for ( i = 0; i < lines; i++ ){
   		for ( j = 0; j < samps; j++ ){
  			if ( *(image+i*samps+j) == 0 ){ 
@@ -83,7 +76,7 @@
 	goto afterfirst2;
 
 	again2:	
-	
+
 	#ifdef _DEBUG2_
 		counter=0;
 		for ( i = 0; i < lines; i++ ) {
@@ -98,7 +91,7 @@
 		_printString_("Number of zeroes remaining: " << lines*samps-counter);
 		fflush( stdout );
 	#endif
-	
+
 	afterfirst2:
 
 /***************** FIRST RUN *********************/
@@ -127,7 +120,7 @@
 			} 
 
 			/* For void edge pixels: */			
-			
+
 			nsteps = 0.0; ssteps = 0.0; esteps = 0.0; wsteps = 0.0;
 			nwsteps = 0.0; nesteps = 0.0; swsteps = 0.0; sesteps = 0.0;
 			north = 0.0; south = 0.0; east = 0.0; west = 0.0;
@@ -138,7 +131,6 @@
 			nne = 0.0; ene = 0.0; ese = 0.0; sse = 0.0;
 			ssw = 0.0; wsw = 0.0; wnw = 0.0; nnw = 0.0;
 
-
 /** NSEW **/
 			for ( ii = i - 1; ii >= 0; ii-- ){   /* North */
 				if ( ii <= 0 ) { north = 0; nsteps = 0; break;}
@@ -149,18 +141,17 @@
 				if ( ii >= lines-1 ){ south = 0; ssteps = 0; break;}
 				if ( *(image2+ii*samps+j) != 0 ){ south = *(image2+ii*samps+j); ssteps = ii - i; break;}
 			}
-				
+
 			for ( jj = j - 1; jj >= 0; jj-- ){   /* West */
 				if ( jj <= 0 ) { west = 0; wsteps = 0; break;}
 				if ( *(image2+i*samps+jj) != 0 ){ west = *(image2+i*samps+jj); wsteps = j - jj; break;}
 			}
-				
+
 			for ( jj = j + 1; jj < samps; jj++ ){ /* East */
 				if ( jj >= samps-1 ){ east = 0; esteps = 0; break;}
 				if ( *(image2+i*samps+jj) != 0 ){ east = *(image2+i*samps+jj); esteps = jj - j; break;}
 			}
 
-				
 /** Diagonals  **/						
 			/* Southeast */
 			for ( k = 1; k < infinit; k++ ){
@@ -168,21 +159,21 @@
 				if (( ii == lines ) || ( jj == samps )){ se = 0; sesteps = 0; break;}
 				if ( *(image2+ii*samps+jj) != 0 ){ se = *(image2+ii*samps+jj); sesteps = 1.4142 * k; break;}
 			}
-			
+
 			/* Northeast */
 			for ( k = 1; k < infinit; k++ ){
 				ii = i - k; jj = j + k;
 				if (( ii == -1 ) || ( jj == samps )){ ne = 0; nesteps = 0; break;}
 				if ( *(image2+ii*samps+jj) != 0 ){ ne = *(image2+ii*samps+jj); nesteps = 1.4142 * k; break;}
 			}
-			
+
 			/* Northwest */
 			for ( k = 1; k < infinit; k++ ){
 				ii = i - k; jj = j - k;
 				if (( ii == -1 ) || ( jj == -1 )){ nw = 0; nwsteps = 0; break;}
 				if ( *(image2+ii*samps+jj) != 0 ){ nw = *(image2+ii*samps+jj); nwsteps = 1.4142 * k; break;}
 			}
-			
+
 			/* Southwest */
 			for ( k = 1; k < infinit; k++ ){
 				ii = i + k; jj = j - k;
@@ -197,21 +188,21 @@
 				if (( ii <= -1 ) || ( jj >= samps )){ nne = 0; nnesteps = 0; break;}
 				if ( *(image2+ii*samps+jj) != 0 ){ nne = *(image2+ii*samps+jj); nnesteps = 2.2361 * k; break;}
 			}
-			
+
 			/* ENE */
 			for ( k = 1; k < infinit; k++ ){
 				ii = i - k; jj = j + (k*2);
 				if (( ii <= -1 ) || ( jj >= samps )){ ene = 0; enesteps = 0; break;}
 				if ( *(image2+ii*samps+jj) != 0 ){ ene = *(image2+ii*samps+jj); enesteps = 2.2361 * k; break;}
 			}
-			
+
 			/* ESE */
 			for ( k = 1; k < infinit; k++ ){
 				ii = i + k; jj = j + (k*2);
 				if (( ii >= lines ) || ( jj >= samps )){ ese = 0; esesteps = 0; break;}
 				if ( *(image2+ii*samps+jj) != 0 ){ ese = *(image2+ii*samps+jj); esesteps = 2.2361 * k; break;}
 			}
-			
+
 			/* SSE */
 			for ( k = 1; k < infinit; k++ ){
 				ii = i + (k*2); jj = j + k;
@@ -225,28 +216,28 @@
 				if (( ii >= lines ) || ( jj <= -1 )){ ssw = 0; sswsteps = 0; break;}
 				if ( *(image2+ii*samps+jj) != 0 ){ ssw = *(image2+ii*samps+jj); sswsteps = 2.2361 * k; break;}
 			}
-			
+
 			/* WSW */
 			for ( k = 1; k < infinit; k++ ){
 				ii = i + k; jj = j - (k*2);
 				if (( ii >= lines ) || ( jj <= -1 )){ wsw = 0; wswsteps = 0; break;}
 				if ( *(image2+ii*samps+jj) != 0 ){ wsw = *(image2+ii*samps+jj); wswsteps = 2.2361 * k; break;}
 			}
-			
+
 			/* WNW */
 			for ( k = 1; k < infinit; k++ ){
 				ii = i - k; jj = j - (k*2);
 				if (( ii <= -1 ) || ( jj <= -1 )){ wnw = 0; wnwsteps = 0; break;}
 				if ( *(image2+ii*samps+jj) != 0 ){ wnw = *(image2+ii*samps+jj); wnwsteps = 2.2361 * k; break;}
 			}
-			
+
 			/* NNW */
 			for ( k = 1; k < infinit; k++ ){
 				ii = i - (k*2); jj = j - k;
 				if (( ii <= -1 ) || ( jj <= -1 )){ nnw = 0; nnwsteps = 0; break;}
 				if ( *(image2+ii*samps+jj) != 0 ){ nnw = *(image2+ii*samps+jj); nnwsteps = 2.2361 * k; break;}
 			}
-			
+
 			elev = 0; range = 0;
 /*NSEW*/			
 			if ( nsteps > 0.5 ){ elev += north /  nsteps; range +=  1.00 /  nsteps;}
@@ -258,7 +249,7 @@
 			if ( nesteps > 0.5 ){ elev +=    ne / nesteps; range +=  1.00 / nesteps;}
 			if ( swsteps > 0.5 ){ elev +=    sw / swsteps; range +=  1.00 / swsteps;}
 			if ( sesteps > 0.5 ){ elev +=    se / sesteps; range +=  1.00 / sesteps;}
-			
+
 /*Other 8*/
 			if ( nnesteps > 0.5 ){ elev += nne / nnesteps; range +=  1.00 / nnesteps;}
 			if ( enesteps > 0.5 ){ elev += ene / enesteps; range +=  1.00 / enesteps;}
@@ -268,13 +259,13 @@
 			if ( wswsteps > 0.5 ){ elev += wsw / wswsteps; range +=  1.00 / wswsteps;}
 			if ( wnwsteps > 0.5 ){ elev += wnw / wnwsteps; range +=  1.00 / wnwsteps;}
 			if ( nnwsteps > 0.5 ){ elev += nnw / nnwsteps; range +=  1.00 / nnwsteps;}
-									
+
 			//temp = ( elev / range ) + 0.5 ;
 			temp = ( elev / range );
 			//+ 0.5 ;
 			//if ( temp > 10000 ) temp = 10000;
 			//if ( temp <     0 ) temp =     0;
-			
+
 			#ifdef _DEBUG2_
 				//_printLine_(temp << " " << elev << " " << range << " ");
 			#endif
@@ -283,35 +274,29 @@
 		}
 	}
 
-
-
 	for ( i = 0; i < lines; i++ ){
 		for ( j = 0; j < samps; j++ ){
 			*(image2+samps*i+j)= *(image3+samps*i+j);
 		}
 	}
 
-
 	for ( i = 0; i < lines; i++ ){
 		for ( j = 0; j < samps; j++ ){
 			if ( *(image2+samps*i+j) == 0 ) goto again2;
 		}
 	}
-	
+
 	if ( smooth == 0 ) goto there2;		
-		
-		
+
 /************************ SMOOTH THE RESULT ***********************/		
-		
+
 	image4 = xNew<double>(lines*samps);
 	memcpy(image4,image3,lines*samps*sizeof(double));
 
-
 	for ( i = 0; i < lines; i++ ) {
 		for ( j = 0; j < samps; j++ ) {
 			if ( *(image4+i*samps+j) != 0 ) { *(image3+i*samps+j) = *(image2+i*samps+j) ; continue; }
 
-
 			for ( k = 1; k < infinit; k++ ) { /* Find the smallest box size with data */ 
 				for ( ii = i-k; ii <= i+k; ii++ ){
 					if ( ii <      0 ) continue;
@@ -323,7 +308,7 @@
 					}
 				}
 			}
-		
+
 			k_nowset:
 			k = k / 4; if ( k < 1 ) k = 1; /* Errrrr.  Make it fourth size */
 			sum = 0;
@@ -342,22 +327,20 @@
 
 	}
 
-		
 there2:		
 
-
 	/*Allocate output image: */
 	imageout=xNew<double>(samps*lines);
 	memcpy(imageout,image3,lines*samps*sizeof(double));
 
 	time(&t2);	
-	
+
 	#ifdef _DEBUG2_
 		_printString_( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
 		_printLine_("Number of zeroes remaining:          0\n");
 		printf ( "\n");
 	#endif
-	
+
 	end:
 
 	/*Assign output pointers: */

Modified: issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.h
===================================================================
--- issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/HoleFillerx/HoleFillerx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
 	HoleFillerx.h
 */
 
-
 #ifndef HOLEFILLERX_H
 #define HOLEFILLERX_H
 
@@ -11,6 +10,5 @@
 
 /* local prototypes: */
 int HoleFillerx(double** pimageout,double* imagein, int lines,int samp,int smooth);
-	
-#endif /* HOLEFILLERX_H */
 
+#endif /* HOLEFILLERX_H */

Modified: issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.cpp
===================================================================
--- issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputArtificialNoisex/InputArtificialNoisex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,7 @@
 
 	/*Update elements, nodes, loads and materials from inputs: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputArtificialNoise(enum_name,min,max);
 	}
 }

Modified: issm/trunk/src/c/modules/InputControlUpdatex/InputControlUpdatex.cpp
===================================================================
--- issm/trunk/src/c/modules/InputControlUpdatex/InputControlUpdatex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputControlUpdatex/InputControlUpdatex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,7 +12,7 @@
 
 	/*Go through elemnets, and ask to carry out the operation on inputs: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputControlUpdate(scalar,save_parameter);
 	}
 }

Modified: issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.cpp
===================================================================
--- issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -23,14 +23,14 @@
 
 	/*Go through elements, and ask them to do the job: */
 	for(i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		converged=element->InputConvergence(eps,enums,num_enums,criterionenums,criterionvalues,num_criterionenums);
 		if(!converged) num_notconverged++;
 	}
 
 	/*In parallel, we need to gather the converged status: */
 	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)&num_notconverged,(void*)&total_notconverged,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+	MPI_Allreduce ( (void*)&num_notconverged,(void*)&total_notconverged,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
 	num_notconverged=total_notconverged;
 	#endif
 	if(VerboseConvergence()) _pprintLine_("      #elements above convergence criterion = " << num_notconverged);

Modified: issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.h
===================================================================
--- issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputConvergencex/InputConvergencex.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,4 +10,3 @@
 bool InputConvergencex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int* enums, int num_enums, int* criterionenums, IssmDouble* criterionvalues,int num_criterionenums);
 
 #endif  /* _INPUTCONVERGENCEX_H */
-

Modified: issm/trunk/src/c/modules/InputDuplicatex/InputDuplicatex.cpp
===================================================================
--- issm/trunk/src/c/modules/InputDuplicatex/InputDuplicatex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputDuplicatex/InputDuplicatex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,11 +9,11 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
 void InputDuplicatex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int original_enum, int new_enum){
-	
+
 	/*Go through elemnets, and ask to reinitialie the input: */
 	int      i;
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputDuplicate(original_enum,new_enum);
 	}
 	for(i=0;i<materials->Size();i++){

Modified: issm/trunk/src/c/modules/InputDuplicatex/InputDuplicatex.h
===================================================================
--- issm/trunk/src/c/modules/InputDuplicatex/InputDuplicatex.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputDuplicatex/InputDuplicatex.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,4 +11,3 @@
 void InputDuplicatex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int reinitialized_enum, int original_enum);
 
 #endif  /* _INPUTDUPLICATEX_H */
-

Modified: issm/trunk/src/c/modules/InputScalex/InputScalex.cpp
===================================================================
--- issm/trunk/src/c/modules/InputScalex/InputScalex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputScalex/InputScalex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,7 +15,7 @@
 
 	/*Go through elemnets, and ask to reinitialie the input: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputScale(enum_type,scale_factor);
 	}
 

Modified: issm/trunk/src/c/modules/InputScalex/InputScalex.h
===================================================================
--- issm/trunk/src/c/modules/InputScalex/InputScalex.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputScalex/InputScalex.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,4 +11,3 @@
 void InputScalex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int enum_type, IssmDouble scale_factor);
 
 #endif  /* _SCALEINPUTX_H */
-

Modified: issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp
===================================================================
--- issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputToResultx/InputToResultx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,7 +22,7 @@
 	/*Go through elemnets, and ask each element to transfer the enum_type input into the results dataset, with step and time information: */
 	for(int i=0;i<elements->Size();i++){
 
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputToResult(enum_type,step,time);
 	}
 

Modified: issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,7 @@
 
 	/*Elements and loads drive the update: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputUpdateFromConstant(constant,name);
 	}
 
@@ -22,19 +22,19 @@
 		Load* load=(Load*)loads->GetObjectByOffset(i);
 		load->InputUpdateFromConstant(constant,name);
 	}
-	
+
 	for(i=0;i<materials->Size();i++){
 		Material* material=(Material*)materials->GetObjectByOffset(i);
 		material->InputUpdateFromConstant(constant,name);
 	}
 }
 void InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int    constant, int name){
-	
+
 	int i;
 
 	/*Elements and loads drive the update: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputUpdateFromConstant(constant,name);
 	}
 
@@ -42,7 +42,7 @@
 		Load* load=(Load*)loads->GetObjectByOffset(i);
 		load->InputUpdateFromConstant(constant,name);
 	}
-	
+
 	for(i=0;i<materials->Size();i++){
 		Material* material=(Material*)materials->GetObjectByOffset(i);
 		material->InputUpdateFromConstant(constant,name);
@@ -54,7 +54,7 @@
 
 	/*Elements and loads drive the update: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputUpdateFromConstant(constant,name);
 	}
 
@@ -62,7 +62,7 @@
 		Load* load=(Load*)loads->GetObjectByOffset(i);
 		load->InputUpdateFromConstant(constant,name);
 	}
-	
+
 	for(i=0;i<materials->Size();i++){
 		Material* material=(Material*)materials->GetObjectByOffset(i);
 		material->InputUpdateFromConstant(constant,name);

Modified: issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,4 +14,3 @@
 void		InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters, IssmDouble constant, int name);
 
 #endif  /* _UPDATEINPUTSFROMCONSTANTXX_H */
-

Modified: issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,7 +13,7 @@
 
 	int     i,j,k,l;
 	int     dummy;
-	
+
 	int     numberofvertices;
 	int     nrows;
 	int     ncols;
@@ -34,20 +34,19 @@
 	 * for each descriptor, take the variable value and plug it into the inputs: */
 
 	for(i=0;i<numvariables;i++){
-	
+
 		descriptor=variables_descriptors[i];
 
 		/*From descriptor, figure out if the variable is scaled, indexed, nodal, or just a simple variable: */
 		if (strncmp(descriptor,"scaled_",7)==0){
-			
+
 			/*Variable is scaled. Determine root name of variable (ex: scaled_DragCoefficient_1 -> DragCoefficient). Allocate distributed_values and fill the 
 			 * distributed_values with the next npart variables: */
-			
+
 			//strcpy(root,strstr(descriptor,"_")+1); *strstr(root,"_")='\0';
 			memcpy(root,strstr(descriptor,"_")+1,(strlen(strstr(descriptor,"_")+1)+1)*sizeof(char));
 			*strstr(root,"_")='\0';
 
-
 			distributed_values=xNew<double>(npart);
 			for(j=0;j<npart;j++){
 				distributed_values[j]=variables[i+j];
@@ -67,21 +66,20 @@
 			}
 
 			#ifdef _DEBUG_
-				PetscSynchronizedPrintf(MPI_COMM_WORLD,"Parameter matrix:");
-				PetscSynchronizedFlush(MPI_COMM_WORLD);
+				PetscSynchronizedPrintf(IssmComm::GetComm(),"Parameter matrix:");
+				PetscSynchronizedFlush(IssmComm::GetComm());
 				for(l=0;l<ncols;l++){
-					PetscSynchronizedPrintf(MPI_COMM_WORLD," time %i\n",l);
-					PetscSynchronizedFlush(MPI_COMM_WORLD);
+					PetscSynchronizedPrintf(IssmComm::GetComm()," time %i\n",l);
+					PetscSynchronizedFlush(IssmComm::GetComm());
 
 					for(k=0;k<numberofvertices;k++){
-						PetscSynchronizedPrintf(MPI_COMM_WORLD," node %i value %g\n",k+1,*(parameter+k*ncols+l));
-						PetscSynchronizedFlush(MPI_COMM_WORLD);
+						PetscSynchronizedPrintf(IssmComm::GetComm()," node %i value %g\n",k+1,*(parameter+k*ncols+l));
+						PetscSynchronizedFlush(IssmComm::GetComm());
 					}
 				}
-				PetscSynchronizedPrintf(MPI_COMM_WORLD," descriptor: %s root %s enum: %i\n",descriptor,root,StringToEnumx(root));
-				PetscSynchronizedFlush(MPI_COMM_WORLD);
+				PetscSynchronizedPrintf(IssmComm::GetComm()," descriptor: %s root %s enum: %i\n",descriptor,root,StringToEnumx(root));
+				PetscSynchronizedFlush(IssmComm::GetComm());
 			#endif
-			  
 
 			/*Update inputs using the parameter matrix: */
 			InputUpdateFromMatrixDakotax( elements,nodes, vertices,loads, materials,  parameters, parameter, nrows,ncols,StringToEnumx(root), VertexEnum);

Modified: issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,4 +11,3 @@
 void  InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials*  materials,Parameters* parameters,double* variables,char* *variables_descriptors,int numvariables);
 
 #endif  /* _INPUTUPDATEFROMDAKOTAXX_H */
-

Modified: issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,7 +21,7 @@
 
 		/*Update elements, nodes, loads and materials from inputs: */
 		for(i=0;i<elements->Size();i++){
-			Element* element=(Element*)elements->GetObjectByOffset(i);
+			Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 			element->InputUpdateFromMatrixDakota(matrix,nrows,ncols,name,type);
 		}
 		for(i=0;i<nodes->Size();i++){

Modified: issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.h
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,4 +12,3 @@
 void InputUpdateFromMatrixDakotax( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* matrix,int nrows,int ncols, int name, int type);
 
 #endif  /* _UPDATEINPUTSFROMMATRIXDAKOTAXX_H */
-

Modified: issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,7 +22,6 @@
 	xDelete<IssmDouble>(serial_solution);
 }
 
-
 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* solution){
 
 	/*Intermediary*/
@@ -31,7 +30,7 @@
 
 	/*Elements drive the update: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputUpdateFromSolution(solution);
 	}
 }

Modified: issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,4 +17,3 @@
 void        InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* solution, int timestep);
 
 #endif  /* _UPDATEINPUTSFROMSOLUTIONXX_H */
-

Modified: issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,14 +20,13 @@
 	xDelete<double>(serial_vector);
 }
 
-	
 void InputUpdateFromVectorDakotax( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* vector, int name, int type){
 
 	int i;
 
 	/*Update elements, nodes, loads and materials from inputs: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputUpdateFromVectorDakota(vector,name,type);
 	}
 	for(i=0;i<nodes->Size();i++){
@@ -45,12 +44,12 @@
 }
 
 void InputUpdateFromVectorDakotax( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int* vector, int name, int type){
-	
+
 	int i;
 
 	/*Update elements, nodes, loads and materials from inputs: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputUpdateFromVectorDakota(vector,name,type);
 	}
 	for(i=0;i<nodes->Size();i++){
@@ -73,7 +72,7 @@
 
 	/*Update elements, nodes, loads and materials from inputs: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputUpdateFromVectorDakota(vector,name,type);
 	}
 	for(i=0;i<nodes->Size();i++){

Modified: issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,4 +15,3 @@
 void	InputUpdateFromVectorDakotax( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,bool* vector, int name,int type);
 
 #endif  /* _UPDATEINPUTSFROMVECTORDAKOTAXX_H */
-

Modified: issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,14 +20,13 @@
 	xDelete<IssmDouble>(serial_vector);
 }
 
-	
 void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,IssmDouble* vector, int name, int type){
 
 	int i;
 
 	/*Update elements, nodes, loads and materials from inputs: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputUpdateFromVector(vector,name,type);
 	}
 	for(i=0;i<nodes->Size();i++){
@@ -45,12 +44,12 @@
 }
 
 void InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int* vector, int name, int type){
-	
+
 	int i;
 
 	/*Update elements, nodes, loads and materials from inputs: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputUpdateFromVector(vector,name,type);
 	}
 	for(i=0;i<nodes->Size();i++){
@@ -73,7 +72,7 @@
 
 	/*Update elements, nodes, loads and materials from inputs: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->InputUpdateFromVector(vector,name,type);
 	}
 	for(i=0;i<nodes->Size();i++){

Modified: issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h
===================================================================
--- issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,4 +15,3 @@
 void	InputUpdateFromVectorx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials,  Parameters* parameters,bool* vector, int name,int type);
 
 #endif  /* _UPDATEINPUTSFROMVECTORXX_H */
-

Modified: issm/trunk/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp
===================================================================
--- issm/trunk/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,11 +20,10 @@
 
 	/*output: */
 	SeqVec<IssmPDouble>* data_mesh=NULL;
-	
+
 	/*Intermediary*/
 	double* x=NULL;
 	double* y=NULL;
-	double  x_grid,y_grid;
 	int     i;
 
 	/*threading: */
@@ -311,7 +310,7 @@
 	/*Checks*/
 	_assert_(x2>x1 && y2>y1);
 	_assert_(x<=x2 && x>=x1 && y<=y2 && y>=y1);
-	
+
 	double xm=(x2-x1)/2;
 	double ym=(y2-y1)/2;
 

Modified: issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp
===================================================================
--- issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,17 +13,14 @@
 			double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length,
 			double* x_prime, double* y_prime, int nods_prime,
 			double* default_values,int num_default_values,Contour<IssmPDouble>** contours,int numcontours){
-	
+
 	/*Output*/
 	SeqVec<IssmPDouble>* data_prime=NULL;
 
 	/*Intermediary*/
-	int    i,j;
+	int    i;
 	int    interpolation_type;
 	bool   debug;
-	double area;
-	double area_1,area_2,area_3;
-	double data_value;
 	double xmin,xmax;
 	double ymin,ymax;
 

Modified: issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h
===================================================================
--- issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,7 +28,6 @@
 	int                 num_default_values;
 	double              *incontour;
 
-
 } InterpFromMesh2dxThreadStruct;
 
 int InterpFromMesh2dx(SeqVec<IssmPDouble>** pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,

Modified: issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp
===================================================================
--- issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InterpFromMesh2dx/InterpFromMesh2dxt.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,7 +17,7 @@
 	InterpFromMesh2dxThreadStruct *gate        = (InterpFromMesh2dxThreadStruct*)handle->gate;
 	int                            my_thread   = handle->id;
 	int                            num_threads = handle->num;
-	
+
 	/*recover parameters :*/
 	int     interpolation_type      = gate->interpolation_type;
 	bool    debug                   = gate->debug;

Modified: issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp
===================================================================
--- issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -68,7 +68,7 @@
 			griddata[i*ncols+j]=default_value;
 		}
 	}
-	
+
 	/*Get extreme coordinates of the grid*/
 	if (xflip){
 		x_grid_min=x_grid[ncols-1]; x_grid_max=x_grid[0];

Modified: issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
===================================================================
--- issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,7 @@
 
 int InterpFromMeshToMesh2dx(double** pdata_interp,int* index_data,double* x_data,double* y_data,int nods_data,int nels_data,
 			double* data,int M_data,int N_data,double* x_interp,double* y_interp,int N_interp,Options* options){
-	
+
 	/*Output*/
 	double* data_interp=NULL;
 
@@ -24,12 +24,11 @@
 	double defaultvalue;
 	R2     r;
 	I2     I;
-	int    i,j,k;
+	int    i,j;
 	int    it;
 	int    i0,i1,i2;
 	double areacoord[3];
 	double aa,bb;
-	double data_value;
 	Icoor2 dete[3];
 
 	/*Checks*/

Modified: issm/trunk/src/c/modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp
===================================================================
--- issm/trunk/src/c/modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/IoModelToConstraintsx/IoModelToConstraintsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,23 +10,19 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
 void IoModelToConstraintsx(Constraints* constraints,IoModel* iomodel,int vector_enum,int analysis_type){
-	
 
 	/*intermediary: */
 	int     i,j;
-	bool    transient     = false;
+	bool        transient        = false;
+	FILE       *fid              = NULL;
+	int         code             = 0;
+	int         vector_layout    = 0;
+	IssmDouble *times            = NULL;
+	IssmDouble *values           = NULL;
+	bool        spcpresent       = false;
+	int         count            = 0;
+	int         numberofvertices;
 
-	FILE   *fid           = NULL;
-	int     code          = 0;
-	int     vector_layout = 0;
-	int     counter;
-	int     nods;
-	IssmDouble* times=NULL;
-	IssmDouble* values=NULL;
-	bool    spcpresent=false;
-	int     count=0;
-	int     numberofvertices;
-
 	/*variables being fetched: */
 	IssmDouble *IssmDoublevector  = NULL;
 	int     M,N;
@@ -47,10 +43,10 @@
 	if(M==numberofvertices){
 		/*static: just create Constraints objects*/
 		count=0;
-	
+
 		/*Create Constraints from x,y,z: */
 		for (i=0;i<numberofvertices;i++){
-			
+
 			/*keep only this partition's nodes:*/
 			if((iomodel->my_vertices[i])){
 
@@ -77,7 +73,7 @@
 
 		/*Create constraints from x,y,z: */
 		for (i=0;i<numberofvertices;i++){
-			
+
 			/*keep only this partition's nodes:*/
 			if((iomodel->my_vertices[i])){
 

Modified: issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp
===================================================================
--- issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/KMLFileReadx/KMLFileReadx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -64,4 +64,3 @@
 
 	return(kfil);
 }
-

Modified: issm/trunk/src/c/modules/KMLOverlayx/KMLOverlayx.cpp
===================================================================
--- issm/trunk/src/c/modules/KMLOverlayx/KMLOverlayx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/KMLOverlayx/KMLOverlayx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -78,7 +78,6 @@
 	(kfile->kmlobj    )->AddObject((Object*)kdoc);
 	kdoc=NULL;
 
-
 /*  write kml file  */
 
 	_pprintLine_("Writing kml document to file.");
@@ -94,4 +93,3 @@
 
 	return;
 }
-

Modified: issm/trunk/src/c/modules/Kml2Expx/Kml2Expx.cpp
===================================================================
--- issm/trunk/src/c/modules/Kml2Expx/Kml2Expx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Kml2Expx/Kml2Expx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -24,7 +24,7 @@
 int Kml2Expx(char* filkml,char* filexp,
 			 int sgn,double cm,double sp){
 
-	int     i,iret=0;
+	int     iret=0;
 	double  *lat=NULL,*lon=NULL;
 
 	KML_Object*  kobj=NULL;
@@ -68,4 +68,3 @@
 
 	return(iret);
 }
-

Modified: issm/trunk/src/c/modules/Krigingx/pKrigingx.cpp
===================================================================
--- issm/trunk/src/c/modules/Krigingx/pKrigingx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Krigingx/pKrigingx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,8 +13,8 @@
 /*FUNCTION pKrigingx{{{*/
 int pKrigingx(double** ppredictions,double **perror,double* obs_x, double* obs_y, double* obs_list, int obs_length,double* x_interp,double* y_interp,int n_interp,Options* options){
 
-	extern int num_procs;
-	extern int my_rank;
+	int num_procs;
+	int my_rank;
 
 	/*output*/
 	double *predictions = NULL;
@@ -27,6 +27,10 @@
 	Variogram    *variogram    = NULL;
 	Observations *observations = NULL;
 
+	/*Get my_rank: */
+	my_rank=IssmComm::GetRank();
+	num_procs=IssmComm::GetSize();
+
 	/*Get some Options*/
 	options->Get(&radius,"searchradius",0.);
 	options->Get(&mindata,"mindata",1);
@@ -63,8 +67,8 @@
 #ifdef _HAVE_MPI_
 		double *sumpredictions =xNew<double>(n_interp);
 		double *sumerror       =xNew<double>(n_interp);
-		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
-		MPI_Allreduce(error,sumerror,n_interp,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
+		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm());
+		MPI_Allreduce(error,sumerror,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm());
 		xDelete<double>(error); error=sumerror;
 		xDelete<double>(predictions); predictions=sumpredictions;
 #endif
@@ -80,7 +84,7 @@
 
 #ifdef _HAVE_MPI_
 		double *sumpredictions =xNew<double>(n_interp);
-		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
+		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm());
 		xDelete<double>(predictions); predictions=sumpredictions;
 #endif
 	}
@@ -97,7 +101,7 @@
 
 #ifdef _HAVE_MPI_
 		double *sumpredictions =xNew<double>(n_interp);
-		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
+		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm());
 		xDelete<double>(predictions); predictions=sumpredictions;
 #endif
 	}

Modified: issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp
===================================================================
--- issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -39,7 +39,7 @@
 	if(fsize){
 		VecMergex(ug,uf,nodes,parameters,FsetEnum);
 	}
-	
+
 	/*Merge s set back into g set: */
 	if(ssize){
 		VecMergex(ug,ys,nodes,parameters,SsetEnum);

Modified: issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h
===================================================================
--- issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,4 +11,3 @@
 void	Mergesolutionfromftogx( Vector<IssmDouble>** pug, Vector<IssmDouble>* uf, Vector<IssmDouble>* ys, Nodes* nodes, Parameters* parameters, bool flag_ys0=false);
 
 #endif  /* _MERGESOLUTIONFROMFTOGX_H */
-

Modified: issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.h
===================================================================
--- issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/MeshPartitionx/MeshPartitionx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,7 +8,6 @@
 #include "../../include/include.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-
 /* local prototypes: */
 template <class doubletype> 
 int MeshPartitionx(int** pepart, int** pnpart, int numberofelements,int numberofnodes,doubletype* elements,
@@ -88,7 +87,7 @@
 
 		/*Extrude epart2d to epart, using numlayers: */
 		epart=xNew<int>(numberofelements);
-		
+
 		count=0;
 		for(i=0;i<(numlayers-1);i++){
 			for(j=0;j<numberofelements2d;j++){
@@ -99,7 +98,7 @@
 
 		/*Extrude npart2d to npart, using numlayers: */
 		npart=xNew<int>(numberofnodes);
-		
+
 		count=0;
 		for(i=0;i<(numlayers);i++){
 			for(j=0;j<numberofnodes2d;j++){
@@ -108,7 +107,7 @@
 			}
 		}
 	}
-	
+
 	/*Assign output pointer:*/
 	*pepart=epart;
 	*pnpart=npart;

Modified: issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp
===================================================================
--- issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegment.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,25 +2,22 @@
  */
 
 #include "./MeshProfileIntersectionx.h"
-		
+
 void ElementSegment(DataSet* segments_dataset,int el,double* xnodes,double* ynodes,double* xsegment,double* ysegment){
 
 	/*We have a tria element (xnodes,ynodes) and a segment (xsegment,ysegment). Find whether they intersect. 
 	 * If they do, create a Segment object with the intersection, and add to segments_dataset dataset: */
 
-	int i;
-	double alpha;
 	double alpha1,alpha2;
 	double beta1,beta2;
 	double gamma1,gamma2;
-	
+
 	int    edge1,edge2,edge3;
 
 	double xel[2],yel[2];
 	double coord1,coord2;
 	double xfinal[2],yfinal[2];
 
-	
 	/*edge 1: */
 	xel[0]=xnodes[0];  yel[0]=ynodes[0]; xel[1]=xnodes[1];  yel[1]=ynodes[1];
 	edge1=SegmentIntersect(&alpha1,&alpha2, xel,yel,xsegment,ysegment); //alpha1: segment coordinate of intersection. alpha2: same thing for second interesection if it exists (colinear edges)
@@ -40,7 +37,7 @@
 		_error_("error: a line cannot go through 3 different vertices!");
 	}
 	else if(    ((edge1==IntersectEnum) && (edge2==IntersectEnum)) || ((edge2==IntersectEnum) && (edge3==IntersectEnum)) || ((edge3==IntersectEnum) && (edge1==IntersectEnum))   ){
-	
+
 		/*segment interscts 2 opposite edges of our triangle, at 2 segment coordinates, pick up the lowest (coord1) and highest (coord2): */
 		if((edge1==IntersectEnum) && (edge2==IntersectEnum)) {coord1=min(alpha1,beta1); coord2=max(alpha1,beta1);}
 		if((edge2==IntersectEnum) && (edge3==IntersectEnum)) {coord1=min(beta1,gamma1); coord2=max(beta1,gamma1);}
@@ -76,7 +73,7 @@
 			if(edge3==IntersectEnum){coord1=gamma1;}
 			coord2=1.0;
 		}
-		
+
 		xfinal[0]=xsegment[0]+coord1*(xsegment[1]-xsegment[0]);
 		xfinal[1]=xsegment[0]+coord2*(xsegment[1]-xsegment[0]);
 		yfinal[0]=ysegment[0]+coord1*(ysegment[1]-ysegment[0]);

Modified: issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegmentsIntersection.cpp
===================================================================
--- issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegmentsIntersection.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/MeshProfileIntersectionx/ElementSegmentsIntersection.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,7 @@
  */
 
 #include "./MeshProfileIntersectionx.h"
-		
+
 void ElementSegmentsIntersection(DataSet* segments_dataset,int el, double* xnodes,double* ynodes,double* xc,double* yc,int numnodes){
 
 	int i;

Modified: issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp
===================================================================
--- issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,7 +6,6 @@
 void MeshProfileIntersectionx( double** psegments, int* pnumsegs, int* index, double* x, double* y, int nel, int nods,  Contour<IssmPDouble>** contours,int numcontours){
 
 	int i,j,k;
-	int m,n;
 
 	/*Contour:*/
 	Contour<IssmPDouble>* contouri=NULL;
@@ -31,7 +30,7 @@
 
 	/*Loop through all contours: */
 	for (i=0;i<numcontours;i++){
-		
+
 		/*retrieve contour info: */
 		contouri=*(contours+i);
 		numnodes=contouri->nods;
@@ -40,7 +39,7 @@
 
 		/*determine segmentsi and numsegsi for this contour and the mesh intersection: */
 		MeshSegmentsIntersection(&segmentsi,&numsegsi,index,x,y,nel,nods,xc,yc,numnodes);
-		
+
 		/*save segmentsi: */
 		allsegments[i]=segmentsi;
 		allnumsegs[i]=numsegsi;

Modified: issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h
===================================================================
--- issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshProfileIntersectionx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
 	MeshProfileIntersectionx.h
 */
 
-
 #ifndef _MESHPROFILEINTERSECTIONX_H
 #define _MESHPROFILEINTERSECTIONX_H
 
@@ -18,4 +17,3 @@
 bool NodeInElement(double* xnodes, double* ynodes, double x, double y);
 
 #endif /* _MESHPROFILEINTERSECTIONX_H */
-

Modified: issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp
===================================================================
--- issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/MeshProfileIntersectionx/MeshSegmentsIntersection.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 	double*  segments=NULL;
 	Segment<double>* segment=NULL;
 	int     numsegs;
-	
+
 	/*intermediary: */
 	DataSet* segments_dataset=NULL;
 	double   xnodes[3];
@@ -34,7 +34,7 @@
 	segments=xNew<double>(5*numsegs);
 	for(i=0;i<numsegs;i++){
 		Segment<double>* segment=(Segment<double>*)segments_dataset->GetObjectByOffset(i);
-		
+
 		/*x1,y1,x2,y2 then element_id: */
 		*(segments+5*i+0)=segment->x1;
 		*(segments+5*i+1)=segment->y1;

Modified: issm/trunk/src/c/modules/MeshProfileIntersectionx/NodeInElement.cpp
===================================================================
--- issm/trunk/src/c/modules/MeshProfileIntersectionx/NodeInElement.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/MeshProfileIntersectionx/NodeInElement.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,10 +18,9 @@
 	y2=ynodes[1];
 	y3=ynodes[2];
 
-
 	/*compute determinant: */
 	det=x1*y2-x1*y3-x3*y2-x2*y1+x2*y3+x3*y1;
-	
+
 	/*area coordinates: */
 	lambda1=((y2-y3)*(x-x3)+(x3-x2)*(y-y3))/det;
 	lambda2=((y3-y1)*(x-x3)+(x1-x3)*(y-y3))/det;

Modified: issm/trunk/src/c/modules/MeshProfileIntersectionx/SegmentIntersect.cpp
===================================================================
--- issm/trunk/src/c/modules/MeshProfileIntersectionx/SegmentIntersect.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/MeshProfileIntersectionx/SegmentIntersect.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 	/*output: */
 	double alpha=-1;
 	double beta=-1;
-	
+
 	double xA,xB,xC,xD,yA,yB,yC,yD;
 	double O2A[2],O2B[2],O1C[2],O1D[2];
 	double n1[2],n2[2];
@@ -29,7 +29,6 @@
 	O1C[0]=xC -(xA/2+xB/2); O1C[1]=yC -(yA/2+yB/2);
 	O1D[0]=xD -(xA/2+xB/2); O1D[1]=yD -(yA/2+yB/2);
 
-
 	n1[0]=yA-yB; n1[1]=xB-xA;  //normal vector to segA
 	n2[0]=yC-yD; n2[1]=xD-xC;  //normal vector to segB
 

Modified: issm/trunk/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,60 +6,130 @@
 #include "../../../toolkits/toolkits.h"
 #include "../../../io/io.h"
 #include "../../../EnumDefinitions/EnumDefinitions.h"
-#include "../../../classes/objects/objects.h"
+#include "../../../classes/classes.h"
 #include "../../../shared/shared.h"
 #include "../../../include/include.h"
+#include "../../Solverx/Solverx.h"
 #include "../ModelProcessorx.h"
 
 void CreateParametersAutodiff(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type){
-	
-	int         i,j;
+
+	int         i;
 	Parameters *parameters       = NULL;
 	bool        autodiff_analysis;
-	int*        dependents       = NULL;
-	int         num_dependents;
-	int*        independents       = NULL;
-	int         num_independents;
-	int         numberofvertices;
+	int         num_dependent_objects;
+	int         num_dep=0;
+	int*        names=NULL;
+	int*        types=NULL;
+	int         dummy;
+	char*       autodiff_driver=NULL;
+	int*        indices=NULL;
+	int         num_indices;
+
 	IssmDouble* xp=NULL;
-	
+	IssmDouble* xp_backup=NULL;
+	int         num_ind,local_num_ind;
+	DataSet*    dependent_objects=NULL;
+
 	/*Get parameters: */
 	parameters=*pparameters;
 
 	/*retrieve some parameters: */
 	iomodel->Constant(&autodiff_analysis,AutodiffIsautodiffEnum);
-	
+
 	if(autodiff_analysis){
 
-		iomodel->Constant(&num_independents,AutodiffNumIndependentsEnum);
-		iomodel->Constant(&num_dependents,AutodiffNumDependentsEnum);
-		iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
+		#ifdef _HAVE_ADOLC_
 
-		/*recover dependents: */
-		parameters->AddObject(iomodel->CopyConstantObject(AutodiffNumDependentsEnum));
-		if(num_dependents){
-			iomodel->FetchData(&dependents,NULL,&num_dependents,AutodiffDependentsEnum);
-			parameters->AddObject(new IntVecParam(AutodiffDependentsEnum,dependents,num_dependents));
+		/*Copy some parameters from IoModel to parameters dataset: */
+		parameters->AddObject(iomodel->CopyConstantObject(AutodiffKeepEnum));
+
+		/*retrieve driver: {{{*/
+		iomodel->Constant(&autodiff_driver,AutodiffDriverEnum);
+		parameters->AddObject(iomodel->CopyConstantObject(AutodiffDriverEnum));
+
+		if(strcmp(autodiff_driver,"fos_forward")==0){
+			parameters->AddObject(iomodel->CopyConstantObject(AutodiffFosForwardIndexEnum));
 		}
+		else if(strcmp(autodiff_driver,"fos_reverse")==0){
+			parameters->AddObject(iomodel->CopyConstantObject(AutodiffFosReverseIndexEnum));
+		}
+		else if(strcmp(autodiff_driver,"fov_forward")==0){
+			/*Retrieve list of indices: */
+			iomodel->FetchData(&indices,&num_indices,&dummy,AutodiffFovForwardIndicesEnum);
+			parameters->AddObject(new IntMatParam(AutodiffFovForwardIndicesEnum,indices,num_indices,1));
+			xDelete<int>(indices);
+		}
+		/*}}}*/
+		/*Deal with dependents first: {{{*/
+		iomodel->Constant(&num_dependent_objects,AutodiffNumDependentObjectsEnum);
+		dependent_objects=new DataSet();
+		num_dep=0;
 
-		/*recover independents: */
-		parameters->AddObject(iomodel->CopyConstantObject(AutodiffNumIndependentsEnum));
-		if(num_independents){
-			iomodel->FetchData(&independents,NULL,&num_independents,AutodiffIndependentsEnum);
-			parameters->AddObject(new IntVecParam(AutodiffIndependentsEnum,independents,num_independents));
+		if(num_dependent_objects){
+			iomodel->FetchData(&names,&dummy,&dummy,AutodiffDependentObjectNamesEnum);
+			iomodel->FetchData(&types,&dummy,&dummy,AutodiffDependentObjectTypesEnum);
+			iomodel->FetchData(&indices,&dummy,&dummy,AutodiffDependentObjectIndicesEnum);
 
-			/*Build state vector, value at which we compute our gradients of dependent variables in adolc: the xp vector  */
-			xp=xNew<IssmDouble>(num_independents*numberofvertices);
-			for(i=0;i<num_independents;i++){
-				IssmDouble* values=iomodel->data[independents[i]];
-				for(j=0;j<numberofvertices;j++){
-					xp[i*numberofvertices+j]=values[j];
-				}
+			for(i=0;i<num_dependent_objects;i++){
+				DependentObject* dep=new DependentObject(names[i],types[i],indices[i]);
+				dependent_objects->AddObject(dep);
+				num_dep+=dep->NumDependents();
 			}
-			parameters->AddObject(new DoubleVecParam(AutodiffXpEnum,xp,num_independents*numberofvertices));
+
+			/*Free ressources:*/
+			xDelete<int>(names);
+			xDelete<int>(types);
 		}
+		parameters->AddObject(new DataSetParam(AutodiffDependentObjectsEnum,dependent_objects));
+		parameters->AddObject(new IntParam(AutodiffNumDependentsEnum,num_dep));
 
-		/*Assign output pointer: */
-		*pparameters=parameters;
+		delete dependent_objects;
+		/*}}}*/
+		/*Deal with independents: {{{*/
+
+		/*Independents have already been recovered in iomodel->DeclareIndependents. Just do some more processing. 
+		 *In particular, figure out num_independents, and create the state vector xp, or size num_independents x 1 :*/
+		num_ind=0;
+		for(i=0;i<iomodel->independent_objects->Size();i++){
+			IndependentObject* ind=(IndependentObject*)iomodel->independent_objects->GetObjectByOffset(i);
+			num_ind+=ind->NumIndependents();
+		}
+		if(num_ind){
+			xp=xNew<IssmDouble>(num_ind);
+			xp_backup=xp;
+			for(i=0;i<iomodel->independent_objects->Size();i++){
+				IndependentObject* ind=(IndependentObject*)iomodel->independent_objects->GetObjectByOffset(i);
+				ind->FillIndependents(iomodel->data,xp);
+				local_num_ind=ind->NumIndependents(); xp=xp+local_num_ind;
+			}
+			xp=xp_backup; parameters->AddObject(new DoubleVecParam(AutodiffXpEnum,xp,num_ind));
+		}
+		parameters->AddObject(new IntParam(AutodiffNumIndependentsEnum,num_ind));
+
+		/*Don't forget to copy  iomodel->independent_objects to parameters: */
+		parameters->AddObject(new DataSetParam(AutodiffIndependentObjectsEnum,iomodel->independent_objects));
+		/*}}}*/
+
+		#endif
 	}
+
+	#ifdef _HAVE_ADOLC_
+		/*initialize a placeholder to store solver pointers: {{{*/
+		GenericParam<Adolc_edf> *theAdolcEDF_p=new GenericParam<Adolc_edf>(AdolcParamEnum);
+		theAdolcEDF_p->GetParameterValue().myEDF_for_solverx_p=reg_ext_fct(EDF_for_solverx);
+		// to save some space:
+		// we know we won't use adolc inside of  the solver:
+		theAdolcEDF_p->GetParameterValue().myEDF_for_solverx_p->nestedAdolc=false;
+		// the solution vector is just allocated and doesn't have a meaningfull prior value
+		theAdolcEDF_p->GetParameterValue().myEDF_for_solverx_p->dp_y_priorRequired=false;
+		// the solver wrapper makes sure the matrix and the right hand side don't change
+		theAdolcEDF_p->GetParameterValue().myEDF_for_solverx_p->dp_x_changes=false;
+		parameters->AddObject(theAdolcEDF_p);
+		/*}}}*/
+	#endif
+
+	/*Assign output pointer: */
+	*pparameters=parameters;
+
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateConstraintsBalancethickness.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateConstraintsBalancethickness.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateConstraintsBalancethickness.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,16 +9,12 @@
 
 void	CreateConstraintsBalancethickness(Constraints** pconstraints, IoModel* iomodel){
 
-	int    stabilization;	
-	
 	/*Fetch parameters: */
+	int    stabilization;	
 	iomodel->Constant(&stabilization,BalancethicknessStabilizationEnum);
 
-	/*Output*/
-	Constraints* constraints = NULL;
-
 	/*Recover pointer: */
-	constraints=*pconstraints;
+	Constraints* constraints=*pconstraints;
 
 	/*Create constraints if they do not exist yet*/
 	if(!constraints) constraints = new Constraints();

Modified: issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateLoadsBalancethickness.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,7 +13,6 @@
 void	CreateLoadsBalancethickness(Loads** ploads, IoModel* iomodel){
 
 	/*Intermediary*/
-	int i;
 	int element;
 	int stabilization;
 	int numberofedges;
@@ -22,15 +21,12 @@
 	iomodel->Constant(&stabilization,BalancethicknessStabilizationEnum);
 	iomodel->Constant(&numberofedges,MeshNumberofedgesEnum);
 
-	/*Output*/
-	Loads*    loads    = NULL;
-
 	/*Recover pointer: */
-	loads=*ploads;
+	Loads* loads=*ploads;
 
 	/*Create loads if they do not exist yet*/
 	if(!loads) loads = new Loads();
-	
+
 	/*Loads only in DG*/
 	if (stabilization==3){
 
@@ -38,7 +34,7 @@
 		iomodel->FetchData(3,MeshEdgesEnum,MeshElementsEnum,ThicknessEnum);
 
 		/*First load data:*/
-		for (i=0;i<numberofedges;i++){
+		for (int i=0;i<numberofedges;i++){
 
 			/*Get left and right elements*/
 			element=reCast<int,IssmDouble>(iomodel->Data(MeshEdgesEnum)[4*i+2])-1; //edges are [node1 node2 elem1 elem2]

Modified: issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Balancethickness/CreateNodesBalancethickness.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,9 +25,6 @@
 	int    numberofvertices;
 	int    stabilization;
 
-	/*DataSets: */
-	Nodes*    nodes = NULL;
-
 	/*Fetch parameters: */
 	iomodel->Constant(&dim,MeshDimensionEnum);
 	iomodel->Constant(&numberofelements,MeshNumberofelementsEnum);
@@ -35,7 +32,7 @@
 	iomodel->Constant(&stabilization,BalancethicknessStabilizationEnum);
 
 	/*Recover pointer: */
-	nodes=*pnodes;
+	Nodes* nodes=*pnodes;
 
 	/*Create nodes if they do not exist yet*/
 	if(!nodes) nodes = new Nodes();

Modified: issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateConstraintsBedSlope.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateConstraintsBedSlope.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateConstraintsBedSlope.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,11 +12,8 @@
 
 void	CreateConstraintsBedSlope(Constraints** pconstraints, IoModel* iomodel){
 
-	/*Output*/
-	Constraints* constraints = NULL;
-	
 	/*Recover pointer: */
-	constraints=*pconstraints;
+	Constraints* constraints=*pconstraints;
 
 	/*Create constraints if they do not exist yet*/
 	if(!constraints) constraints = new Constraints();

Modified: issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateLoadsBedSlope.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateLoadsBedSlope.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateLoadsBedSlope.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,11 +12,8 @@
 
 void	CreateLoadsBedSlope(Loads** ploads, IoModel* iomodel){
 
-	/*DataSet*/
-	Loads*    loads    = NULL;
-
 	/*Recover pointer: */
-	loads=*ploads;
+	Loads* loads=*ploads;
 
 	/*Create loads if they do not exist yet*/
 	if(!loads) loads = new Loads();

Modified: issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateNodesBedSlope.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateNodesBedSlope.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/BedSlope/CreateNodesBedSlope.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,29 +17,26 @@
 	/*Intermediary*/
 	int i;
 	bool continuous_galerkin=true;
-	int    numberofvertices;
 
-	/*DataSets: */
-	Nodes*    nodes = NULL;
-
 	/*Fetch parameters: */
+	int    numberofvertices;
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 
 	/*Recover pointer: */
-	nodes=*pnodes;
+	Nodes* nodes=*pnodes;
 
 	/*Create nodes if they do not exist yet*/
 	if(!nodes) nodes = new Nodes();
-	
+
 	/*Continuous Galerkin partition of nodes: */
 	NodesPartitioning(&iomodel->my_nodes,iomodel->my_elements,iomodel->my_vertices,iomodel,continuous_galerkin);
-	
+
 	/*First fetch data: */
 	iomodel->FetchData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum);
 
 	for (i=0;i<numberofvertices;i++){
 		if(iomodel->my_vertices[i]){
-			
+
 			/*Add node to nodes dataset: */
 			nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,i+1,i,iomodel,BedSlopeAnalysisEnum));
 
@@ -48,7 +45,7 @@
 
 	/*Clean fetched data: */
 	iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum);
-	
+
 	/*Assign output pointer: */
 	*pnodes=nodes;
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/BedSlope/UpdateElementsBedSlope.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -41,7 +41,7 @@
 		iomodel->FetchDataToInput(elements,MeshElementonbedEnum);
 		iomodel->FetchDataToInput(elements,MeshElementonsurfaceEnum);
 	}
-	
+
 	/*Free data: */
 	iomodel->DeleteData(1,MeshElementsEnum);
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,18 +12,17 @@
 #include "../ModelProcessorx.h"
 
 void CreateParametersControl(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type){
-	
-	int         i;
+
 	Parameters *parameters       = NULL;
 	bool        control_analysis;
 	int         nsteps;
 	int         num_control_type;
 	int         num_cm_responses;
 	int        *control_type     = NULL;
-	IssmDouble     *cm_responses     = NULL;
-	IssmDouble     *cm_jump          = NULL;
-	IssmDouble     *optscal          = NULL;
-	IssmDouble     *maxiter          = NULL;
+	IssmDouble *cm_responses     = NULL;
+	IssmDouble *cm_jump          = NULL;
+	IssmDouble *optscal          = NULL;
+	IssmDouble *maxiter          = NULL;
 
 	/*Get parameters: */
 	parameters=*pparameters;

Modified: issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -24,7 +24,6 @@
 	int    num_control_type;
 	bool   control_analysis;
 
-	
 	/*Fetch parameters: */
 	iomodel->Constant(&numberofelements,MeshNumberofelementsEnum);
 	iomodel->Constant(&control_analysis,InversionIscontrolEnum);
@@ -64,7 +63,7 @@
 			counter++;
 		}
 	}
-	
+
 	/*Free data: */
 	iomodel->DeleteData(1+4+6,MeshElementsEnum,InversionControlParametersEnum,InversionCostFunctionsCoefficientsEnum,InversionMinParametersEnum,InversionMaxParametersEnum,BalancethicknessThickeningRateEnum,VxEnum,VyEnum,FrictionCoefficientEnum,MaterialsRheologyBEnum,MaterialsRheologyZEnum);
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/CreateDataSets.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/CreateDataSets.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/CreateDataSets.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,14 +14,13 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 #include "./ModelProcessorx.h"
 
-
 void CreateDataSets(Elements** pelements,Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads,Parameters** pparameters,IoModel* iomodel,char* rootpath,const int solution_type,const int analysis_type,const int nummodels,int analysis_counter){
 
 	bool        continuous = true;
 	Elements   *elements   = NULL;
 	Materials  *materials  = NULL;
 	Parameters *parameters = NULL;
-			
+
 	/*Create elements, vertices and materials, independent of analysis_type: */
 	CreateElementsVerticesAndMaterials(pelements, pvertices, pmaterials, iomodel,nummodels);
 
@@ -39,14 +38,14 @@
 			CreateLoadsDiagnosticHoriz(ploads,iomodel);
 			UpdateElementsDiagnosticHoriz(elements,iomodel,analysis_counter,analysis_type);
 			break;
-		
+
 		case DiagnosticVertAnalysisEnum:
 			CreateNodesDiagnosticVert(pnodes, iomodel);
 			CreateConstraintsDiagnosticVert(pconstraints,iomodel);
 			CreateLoadsDiagnosticVert(ploads,iomodel);
 			UpdateElementsDiagnosticVert(elements,iomodel,analysis_counter,analysis_type);
 			break;
-	
+
 		case DiagnosticHutterAnalysisEnum:
 			CreateNodesDiagnosticHutter(pnodes, iomodel);
 			CreateConstraintsDiagnosticHutter(pconstraints,iomodel);
@@ -54,7 +53,7 @@
 			UpdateElementsDiagnosticHutter(elements,iomodel,analysis_counter,analysis_type);
 			break;
 		#endif
-		
+
 		#ifdef _HAVE_HYDROLOGY_
 		case HydrologyAnalysisEnum:
 			CreateNodesHydrology(pnodes, iomodel);
@@ -71,14 +70,14 @@
 			CreateLoadsThermal(ploads,iomodel);
 			UpdateElementsThermal(elements,iomodel,analysis_counter,analysis_type);
 			break;
-	
+
 		case EnthalpyAnalysisEnum:
 			CreateNodesEnthalpy(pnodes, iomodel);
 			CreateConstraintsEnthalpy(pconstraints,iomodel);
 			CreateLoadsEnthalpy(ploads,iomodel);
 			UpdateElementsEnthalpy(elements,iomodel,analysis_counter,analysis_type);
 			break;
-		
+
 		case MeltingAnalysisEnum:
 			CreateNodesMelting(pnodes, iomodel);
 			CreateConstraintsMelting(pconstraints,iomodel);
@@ -121,7 +120,6 @@
 			break;
 		#endif
 
-
 		default:
 			_error_("analysis_type: " << EnumToStringx(analysis_type) << " not supported yet!");
 	}

Modified: issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,7 +15,7 @@
 void	CreateElementsVerticesAndMaterials(Elements** pelements,Vertices** pvertices,Materials** pmaterials, IoModel* iomodel,const int nummodels){
 
 	/*Intermediary*/
-	int i,j,k,n;
+	int i;
 	int dim,materials_type;
 	int numberofelements;
 	int numberofvertices;
@@ -40,16 +40,16 @@
 	elements  = new Elements();
 	vertices  = new Vertices();
 	materials = new Materials();
-	
+
 	/*First, partition elements and vertices. Nodes will partitioned on a per analysis_type basis. If partitining already done, ignore: */
 	ElementsAndVerticesPartitioning(&iomodel->my_elements,&iomodel->my_vertices,iomodel);
-	
+
 	iomodel->FetchData(2,MeshElementsEnum,MeshElementconnectivityEnum);
 	#ifdef _HAVE_3D_
 	if(dim==3)iomodel->FetchData(2,MeshUpperelementsEnum,MeshLowerelementsEnum);
 	#endif
 	if(control_analysis)iomodel->FetchData(3,InversionControlParametersEnum,InversionMinParametersEnum,InversionMaxParametersEnum);
-	
+
 	/*Create elements*/
 	for (i=0;i<numberofelements;i++){
 		if(iomodel->my_elements[i]){
@@ -61,7 +61,7 @@
 	        #endif
 		}
 	}
-	
+
 	/*Create materials*/
 	switch(materials_type){
 		case MaticeEnum:
@@ -83,18 +83,18 @@
 
 	/*Add new constant material property to materials, at the end: */
 	materials->AddObject(new Matpar(numberofelements+1,iomodel));//put it at the end of the materials
-	
+
 	/*Create vertices: */
 
 	/*Fetch data:*/
 	iomodel->FetchData(6,MeshElementsEnum,MeshXEnum,MeshYEnum,MeshZEnum,BedEnum,ThicknessEnum);
 	CreateNumberNodeToElementConnectivity(iomodel);
-	
+
 	for (i=0;i<numberofvertices;i++){
 
 		/*vertices and nodes (same number, as we are running continuous galerkin formulation): */
 		if(iomodel->my_vertices[i]){
-			
+
 			/*Add vertex to vertices dataset: */
 			vertices->AddObject(new Vertex(i+1,i,i,iomodel));
 		}

Modified: issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/CreateParameters.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,7 +8,6 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
-
 #include "../../Container/Container.h"
 #include "../../toolkits/toolkits.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
@@ -19,18 +18,32 @@
 #include "./ModelProcessorx.h"
 
 void CreateParameters(Parameters** pparameters,IoModel* iomodel,char* rootpath,const int solution_type,int analysis_type,int analysis_counter){
-	
-	int         i;
+
+	int         i,j,m,k;
 	int         numoutputs;
 	Parameters *parameters       = NULL;
 	IssmDouble *requestedoutputs = NULL;
 	bool        isdelta18o;
 
+	/*parameters for mass flux: {{{*/
+	int      mass_flux_num_profiles=0;
+	bool     qmu_mass_flux_present=false;
+	bool     autodiff_mass_flux_present=false;
+	bool     mass_flux_present=false;
+	IssmDouble** array=NULL;
+	int*     mdims_array=NULL;
+	int*     ndims_array=NULL;
+	IssmDouble*  temp_matrix=NULL;
+	int      temp_m,temp_n;
+	IssmDouble*  matrix=NULL;
+	int      count;
+	/*}}}*/
+
 	if(*pparameters)return; //do not create parameters twice!
 
 	/*Initialize dataset: */
 	parameters = new Parameters();
-		
+
 	/*Copy some constants from iomodel */
 	parameters->AddObject(iomodel->CopyConstantObject(MeshDimensionEnum));
 	parameters->AddObject(iomodel->CopyConstantObject(FlowequationIshutterEnum));
@@ -126,15 +139,83 @@
 	parameters->AddObject(new IntParam(DiagnosticNumRequestedOutputsEnum,numoutputs));
 	if(numoutputs)parameters->AddObject(new IntVecParam(DiagnosticRequestedOutputsEnum,requestedoutputs,numoutputs));
 	iomodel->DeleteData(requestedoutputs,DiagnosticRequestedOutputsEnum);
+
 	iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,TransientRequestedOutputsEnum);
 	parameters->AddObject(new IntParam(TransientNumRequestedOutputsEnum,numoutputs));
 	if(numoutputs)parameters->AddObject(new IntVecParam(TransientRequestedOutputsEnum,requestedoutputs,numoutputs));
 	iomodel->DeleteData(requestedoutputs,TransientRequestedOutputsEnum);
+
 	iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,SteadystateRequestedOutputsEnum);
 	parameters->AddObject(new IntParam(SteadystateNumRequestedOutputsEnum,numoutputs));
 	if(numoutputs)parameters->AddObject(new IntVecParam(SteadystateRequestedOutputsEnum,requestedoutputs,numoutputs));
 	iomodel->DeleteData(requestedoutputs,SteadystateRequestedOutputsEnum);
-	
+
+	iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,PrognosticRequestedOutputsEnum);
+	parameters->AddObject(new IntParam(PrognosticNumRequestedOutputsEnum,numoutputs));
+	if(numoutputs)parameters->AddObject(new IntVecParam(PrognosticRequestedOutputsEnum,requestedoutputs,numoutputs));
+	iomodel->DeleteData(requestedoutputs,PrognosticRequestedOutputsEnum);
+
+	/*Deal with mass flux segments: {{{*/
+	iomodel->FetchData(&qmu_mass_flux_present,QmuMassFluxSegmentsPresentEnum);
+	iomodel->FetchData(&autodiff_mass_flux_present,AutodiffMassFluxSegmentsPresentEnum);
+
+	if(qmu_mass_flux_present || autodiff_mass_flux_present)mass_flux_present=true;
+	else mass_flux_present=false;
+	parameters->AddObject(new BoolParam(MassFluxSegmentsPresentEnum,mass_flux_present));
+
+	if(mass_flux_present){
+
+		/*Fetch the mass flux segments necessary to compute the mass fluxes.  Build a DoubleMatArrayParam object out of them: */ 
+		iomodel->FetchData(&array,&mdims_array,&ndims_array,&mass_flux_num_profiles,MassFluxSegmentsEnum);
+		if(mass_flux_num_profiles==0)_error_("mass_flux_num_profiles is 0, when MassFlux computations were requested!");
+
+		/*Go through segments, and extract those that belong to this cpu: */
+		for(i=0;i<mass_flux_num_profiles;i++){
+			temp_matrix=array[i];
+			temp_m=mdims_array[i];
+			temp_n=ndims_array[i];
+
+			m=0;
+			for(j=0;j<temp_m;j++){
+				if (  iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1] )m++;
+			}
+			if(m){
+				matrix=xNewZeroInit<IssmDouble>(5*m);
+				count=0;
+				for(j=0;j<temp_m;j++){
+					if (iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1]){
+						for(k=0;k<5;k++)*(matrix+5*count+k)=*(temp_matrix+5*j+k);
+						count++;
+					}
+				}
+			}
+			else{
+				matrix=NULL;
+			}
+
+			/*Assign: */
+			array[i]=matrix;
+			mdims_array[i]=m;
+			ndims_array[i]=5;
+
+			/*Free temporary matrix: */
+			xDelete<IssmDouble>(temp_matrix);
+		}
+
+		/*Ok, we have an array of segments, different on every cpu. Create a DoubleMatArrayParam object with it: */
+		parameters->AddObject(new DoubleMatArrayParam(MassFluxSegmentsEnum,array,mass_flux_num_profiles,mdims_array,ndims_array));
+
+		/*Free data: */
+		for(i=0;i<mass_flux_num_profiles;i++){
+			IssmDouble* matrix=array[i];
+			xDelete<IssmDouble>(matrix);
+		}
+		xDelete<int>(mdims_array); 
+		xDelete<int>(ndims_array);
+		xDelete<IssmDouble*>(array);
+	}
+	/*}}}*/
+
 	/*Before returning, create parameters in case we are running Qmu or control types runs: */
 	#ifdef _HAVE_CONTROL_
 	CreateParametersControl(&parameters,iomodel,solution_type,analysis_type);

Modified: issm/trunk/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,11 +15,9 @@
 void CreateParametersDakota(Parameters** pparameters,IoModel* iomodel,char* rootpath,int solution_type,int analysis_type){
 
 	/*variable declarations: {{{*/
-	int i,j,k;
-	
+	int i;
 	Parameters* parameters = NULL;
-	int      second_count;
-	
+
 	int*     part=NULL;
 	double*  dpart=NULL;
 
@@ -34,23 +32,10 @@
 	char* qmuinname=NULL;
 	char* qmuerrname=NULL;
 	char* qmuoutname=NULL;
-	
+
 	//descriptors:
 	char tag[50];
-	
-	/*parameters for mass flux: */
-	bool     qmu_mass_flux_present=false;
-	int qmu_mass_flux_num_profiles=0;
-	double** array=NULL;
-	int*     mdims_array=NULL;
-	int*     ndims_array=NULL;
-	
-	double*  matrix=NULL;
-	double*  temp_matrix=NULL;
-	int      M;
-	int      temp_m,temp_n;
-	int      m,n;
-	int      count;
+
 	bool     dakota_analysis=false;
 	char*    name=NULL;
 	int      numberofresponses;
@@ -59,7 +44,7 @@
 	int      ncols;
 
 	/*}}}*/
-	
+
 	/*recover parameters : */
 	parameters=*pparameters;
 
@@ -101,7 +86,7 @@
 		/*}}}*/
 		/*Deal with partitioning: {{{*/
 		/*partition vertices in iomodel->qmu_npart parts, unless a partition is already present: */
-		
+
 		parameters->AddObject(iomodel->CopyConstantObject(QmuNumberofpartitionsEnum));
 		iomodel->FetchData(&dpart,NULL,NULL,QmuPartitionEnum);
 
@@ -116,13 +101,13 @@
 		parameters->AddObject(new DoubleVecParam(QmuPartitionEnum,dpart,numberofvertices));
 		/*}}}*/
 		/*Deal with data needed because of qmu variables: {{{*/
-		
+
 		for(i=0;i<numvariabledescriptors;i++){
 
 			if (strncmp(variabledescriptors[i],"scaled_",7)==0){
 				/*Ok, we are dealing with a variable that is distributed over nodes. Recover the name of the variable (ex: scaled_Thickness): */
 				sscanf(variabledescriptors[i],"scaled_%s",tag);
-				
+
 				/*Recover data: */
 				iomodel->FetchData(&dakota_parameter,&nrows,&ncols,StringToEnumx(tag));
 
@@ -133,73 +118,12 @@
 				else{
 					parameters->AddObject(new DoubleTransientMatParam(StringToEnumx(tag),dakota_parameter,nrows,ncols));
 				}
-				
+
 				/*Free ressources:*/
 				xDelete<double>(dakota_parameter);
 			}
 		}
 		/*}}}*/
-		/*Deal with data needed to compute qmu responses: {{{*/
-		for(i=0;i<numresponsedescriptors;i++){
-			
-			if(strncmp(responsedescriptors[i],"indexed_MassFlux",16)==0){
-				qmu_mass_flux_present=true;
-			}
-		}
-		
-		
-		if(qmu_mass_flux_present){
-			
-			/*Fetch the mass flux segments necessary to compute the mass fluxes.  Build a DoubleMatArrayParam object out of them: */ 
-			iomodel->FetchData(&array,&mdims_array,&ndims_array,&qmu_mass_flux_num_profiles,QmuMassFluxSegmentsEnum);
-			if(qmu_mass_flux_num_profiles==0)_error_("qmu_mass_flux_num_profiles is 0, when MassFlux computations were requested!");
-
-			/*Go through segments, and extract those that belong to this cpu: */
-			for(i=0;i<qmu_mass_flux_num_profiles;i++){
-				temp_matrix=array[i];
-				temp_m=mdims_array[i];
-				temp_n=ndims_array[i];
-
-				m=0;
-				for(j=0;j<temp_m;j++){
-					if (  iomodel->my_elements[(int)(*(temp_matrix+5*j+4))-1])m++;
-				}
-				if(m){
-					matrix=xNewZeroInit<double>(5*m);
-					count=0;
-					for(j=0;j<temp_m;j++){
-						if (iomodel->my_elements[(int)*(temp_matrix+5*j+4)-1]){
-							for(k=0;k<5;k++)*(matrix+5*count+k)=*(temp_matrix+5*j+k);
-							count++;
-						}
-					}
-				}
-				else{
-					matrix=NULL;
-				}
-
-				/*Assign: */
-				array[i]=matrix;
-				mdims_array[i]=m;
-				ndims_array[i]=5;
-
-				/*Free temporary matrix: */
-				xDelete<double>(temp_matrix);
-			}
-
-			/*Ok, we have an array of segments, different on every cpu. Create a DoubleMatArrayParam object with it: */
-			parameters->AddObject(new DoubleMatArrayParam(QmuMassFluxSegmentsEnum,array,qmu_mass_flux_num_profiles,mdims_array,ndims_array));
-
-			/*Free data: */
-			for(i=0;i<qmu_mass_flux_num_profiles;i++){
-				double* matrix=array[i];
-				xDelete<double>(matrix);
-			}
-			xDelete<int>(mdims_array); 
-			xDelete<int>(ndims_array);
-			xDelete<double*>(array);
-		}
-		/*}}}*/
 		/*Free data: {{{*/
 		for(i=0;i<numresponsedescriptors;i++){
 			descriptor=responsedescriptors[i];

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -43,7 +43,6 @@
 	/*Output*/
 	Constraints *constraints      = NULL;
 	SpcStatic   *spcstatic        = NULL;
-	int          node1,node2;
 	int          dim;
 	int          numberofvertices;
 
@@ -63,13 +62,13 @@
 
 	/*Create constraints if they do not exist yet*/
 	if(!constraints) constraints = new Constraints();
-	
+
 	/*Now, is the flag macayaealpattyn on? otherwise, do nothing: */
 	if(!ismacayealpattyn & !isstokes & !isl1l2){
 		*pconstraints=constraints;
 		return;
 	}
-	
+
 	/*Constraints: fetch data: */
 	iomodel->FetchData(&spcvx,&Mx,&Nx,DiagnosticSpcvxEnum);
 	iomodel->FetchData(&spcvy,&My,&Ny,DiagnosticSpcvyEnum);
@@ -323,7 +322,7 @@
 			}
 		}
 	}
-	  
+
 	/*Free data: */
 	iomodel->DeleteData(spcvx,DiagnosticSpcvxEnum);
 	iomodel->DeleteData(spcvy,DiagnosticSpcvyEnum);

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,9 +13,7 @@
 void	CreateLoadsDiagnosticHoriz(Loads** ploads, IoModel* iomodel){
 
 	/*DataSets*/
-	Loads     *loads     = NULL;
 	Icefront  *icefront  = NULL;
-	Riftfront *riftfront = NULL;
 	Pengrid   *pengrid   = NULL;
 
 	/*Intermediary*/
@@ -47,7 +45,7 @@
 	iomodel->Constant(&numrifts,RiftsNumriftsEnum);
 
 	/*Recover pointer: */
-	loads=*ploads;
+	Loads* loads=*ploads;
 
 	/*Create loads if they do not exist yet*/
 	if(!loads) loads = new Loads();
@@ -57,7 +55,7 @@
 		*ploads=loads;
 		return;
 	}
-	
+
 	/*Create pressure loads as boundary conditions. Pay attention to the partitioning if we are running in parallel (the nodes
 	 * referenced by a certain load must belong to the cluster node): */
 	iomodel->FetchData(3,DiagnosticIcefrontEnum,ThicknessEnum,BedEnum);
@@ -69,7 +67,7 @@
 
 	/*First load data:*/
 	for (i=0;i<numberofpressureloads;i++){
-		
+
 		/*Retrieve element to which this icefront belongs: */
 		if (dim==2) segment_width=4; 
 		else segment_width=6;
@@ -77,7 +75,7 @@
 
 		/*Now, if this element is not in the partition, pass: */
 		if(!iomodel->my_elements[element]) continue;
-		
+
 		/*Do not create ice front if Hutter or Stokes elements*/
 		if (reCast<int,IssmDouble>(*(elements_type+element))==HutterApproximationEnum) continue;
 
@@ -131,10 +129,9 @@
 	iomodel->DeleteData(elements_type,FlowequationElementEquationEnum);
 	iomodel->DeleteData(pressureload,DiagnosticIcefrontEnum);
 
-
 	/*Create Penpair for penalties: */
 	iomodel->FetchData(&penalties,&numpenalties,NULL,DiagnosticVertexPairingEnum);
-	
+
 	for(i=0;i<numpenalties;i++){
 
 		if(iomodel->my_vertices[reCast<int,IssmDouble>(penalties[2*i+0]-1)]){
@@ -166,7 +163,7 @@
 			}
 		}
 		iomodel->DeleteData(5,RiftsRiftstructEnum,ThicknessEnum,BedEnum,SurfaceEnum,MaskVertexonfloatingiceEnum);
-		xDelete<Riftfront>(riftfront);
+		xDelete<IssmDouble>(riftinfo);
 	}
 
 	/*Assign output pointer: */

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,9 +20,6 @@
 	int    numberofvertices;
 	bool   isstokes,isl1l2,ismacayealpattyn;
 
-	/*DataSets: */
-	Nodes*    nodes = NULL;
-
 	/*Fetch parameters: */
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 	iomodel->Constant(&isstokes,FlowequationIsstokesEnum);
@@ -30,11 +27,11 @@
 	iomodel->Constant(&ismacayealpattyn,FlowequationIsmacayealpattynEnum);
 
 	/*Recover pointer: */
-	nodes=*pnodes;
+	Nodes* nodes=*pnodes;
 
 	/*First create nodes*/
 	if(!nodes) nodes = new Nodes();
-	
+
 	/*Now, is the flag macayaealpattyn on? otherwise, do nothing: */
 	if(!ismacayealpattyn & !isstokes & !isl1l2){
 		*pnodes=nodes;
@@ -47,11 +44,11 @@
 	/*Create nodes: */
 	iomodel->FetchData(9,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,FlowequationBordermacayealEnum,FlowequationBorderstokesEnum,
 				MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,MaskVertexonwaterEnum,FlowequationVertexEquationEnum,DiagnosticReferentialEnum);
-	
+
 	for (i=0;i<numberofvertices;i++){
 
 		if(iomodel->my_vertices[i]){
-			
+
 			/*Add node to nodes dataset: */
 			nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,i+1,i,iomodel,DiagnosticHorizAnalysisEnum));
 		}

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/UpdateElementsDiagnosticHoriz.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -84,17 +84,17 @@
 	elements->InputDuplicate(VxEnum,VxPicardEnum);
 	elements->InputDuplicate(VxEnum,InversionVxObsEnum);
 	if(dakota_analysis)elements->InputDuplicate(VxEnum,QmuVxEnum);
-	
+
 	elements->InputDuplicate(VyEnum,VyPicardEnum);
 	elements->InputDuplicate(VyEnum,InversionVyObsEnum);
 	if(dakota_analysis)elements->InputDuplicate(VyEnum,QmuVyEnum);
-	
+
 	if(dim==3){
 		elements->InputDuplicate(VzEnum,VzPicardEnum);
 		elements->InputDuplicate(VzEnum,InversionVzObsEnum);
 		if(dakota_analysis)elements->InputDuplicate(VzEnum,QmuVzEnum);
 	}
-	
+
 	/*Free data: */
 	iomodel->DeleteData(2,MeshElementsEnum,FlowequationElementEquationEnum);
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -74,7 +74,7 @@
 
 	/*Free data: */
 	iomodel->DeleteData(3,DiagnosticSpcvxEnum,DiagnosticSpcvyEnum,FlowequationVertexEquationEnum);
-	
+
 	/*Assign output pointer: */
 	*pconstraints=constraints;
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateLoadsDiagnosticHutter.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateLoadsDiagnosticHutter.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateLoadsDiagnosticHutter.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,15 +12,12 @@
 
 void	CreateLoadsDiagnosticHutter(Loads** ploads, IoModel* iomodel){
 
-	/*DataSet*/
-	Loads* loads=NULL;
-
 	/*Recover pointer: */
-	loads=*ploads;
+	Loads* loads=*ploads;
 
 	/*Create loads if they do not exist yet*/
 	if(!loads) loads = new Loads();
-	
+
 	/*Assign output pointer: */
 	*ploads=loads;
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateNodesDiagnosticHutter.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateNodesDiagnosticHutter.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateNodesDiagnosticHutter.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,15 +20,12 @@
 	int    numberofvertices;
 	bool   ishutter;
 
-	/*DataSets: */
-	Nodes*    nodes = NULL;
-
 	/*Fetch parameters: */
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 	iomodel->Constant(&ishutter,FlowequationIshutterEnum);
 
 	/*Recover pointer: */
-	nodes=*pnodes;
+	Nodes* nodes=*pnodes;
 
 	/*Create nodes if they do not exist yet*/
 	if(!nodes) nodes = new Nodes();

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/UpdateElementsDiagnosticHutter.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/UpdateElementsDiagnosticHutter.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/UpdateElementsDiagnosticHutter.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,7 +18,6 @@
 	int    numberofelements;
 	bool   ishutter;
 
-	
 	/*Fetch data needed: */
 	iomodel->Constant(&numberofelements,MeshNumberofelementsEnum);
 	iomodel->Constant(&ishutter,FlowequationIshutterEnum);
@@ -37,10 +36,10 @@
 			counter++;
 		}
 	}
-	
+
 	iomodel->FetchDataToInput(elements,ThicknessEnum);
 	iomodel->FetchDataToInput(elements,GeometryHydrostaticRatioEnum);
-	
+
 	/*Free data: */
 	iomodel->DeleteData(2,MeshElementsEnum,FlowequationElementEquationEnum);
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateConstraintsDiagnosticVert.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,16 +19,13 @@
 	IssmDouble yts;
 	int    numberofvertices;
 
-	/*Output*/
-	Constraints* constraints = NULL;
-
 	/*Fetch parameters: */
 	iomodel->Constant(&dim,MeshDimensionEnum);
 	iomodel->Constant(&yts,ConstantsYtsEnum);
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 
 	/*Recover pointer: */
-	constraints=*pconstraints;
+	Constraints* constraints=*pconstraints;
 
 	/*Create constraints if they do not exist yet*/
 	if(!constraints) constraints = new Constraints();

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateLoadsDiagnosticVert.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateLoadsDiagnosticVert.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateLoadsDiagnosticVert.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,11 +12,8 @@
 
 void	CreateLoadsDiagnosticVert(Loads** ploads, IoModel* iomodel){
 
-	/*DataSet*/
-	Loads* loads=NULL;
-
 	/*Recover pointer: */
-	loads=*ploads;
+	Loads* loads=*ploads;
 
 	/*Create loads if they do not exist yet*/
 	if(!loads) loads = new Loads();

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateNodesDiagnosticVert.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateNodesDiagnosticVert.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/CreateNodesDiagnosticVert.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,15 +20,12 @@
 	int    dim;
 	int    numberofvertices;
 
-	/*DataSets: */
-	Nodes*    nodes = NULL;
-
 	/*Fetch parameters: */
 	iomodel->Constant(&dim,MeshDimensionEnum);
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 
 	/*Recover pointer: */
-	nodes=*pnodes;
+	Nodes* nodes=*pnodes;
 
 	/*Create nodes if they do not exist yet*/
 	if(!nodes) nodes = new Nodes();
@@ -41,7 +38,7 @@
 
 	/*Continuous Galerkin partition of nodes: */
 	NodesPartitioning(&iomodel->my_nodes,iomodel->my_elements,iomodel->my_vertices,iomodel,continuous_galerkin);
-	
+
 	/*First fetch data: */
 	iomodel->FetchData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum);
 
@@ -56,7 +53,7 @@
 
 	/*Clean fetched data: */
 	iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum);
-	
+
 	/*Assign output pointer: */
 	*pnodes=nodes;
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/UpdateElementsDiagnosticVert.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/UpdateElementsDiagnosticVert.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DiagnosticVert/UpdateElementsDiagnosticVert.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -53,5 +53,5 @@
 
 	/*Free data: */
 	iomodel->DeleteData(1,MeshElementsEnum);
-	
+
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,14 +5,13 @@
 #include "../../shared/shared.h"
 #include "../../include/include.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
-	
+
 void DistributeNumDofs(DofIndexing* index,int analysis_type,IssmDouble* vertices_type){
 
 	/*For now, we distribute by analysis_type, later, we will distribute using the analysis_type,
 	 * but also the vertices_type: */
 
 	int numdofs=2; //default numdofs
-	int i;
 	int* doftype=NULL;
 
 	/*ok, according to analysis type: */

Modified: issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,8 +21,8 @@
 
 	int i;
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank;
+	int num_procs;
 	int    numberofelements;
 	int    numberofvertices;
 	int    numberofelements2d;
@@ -46,6 +46,10 @@
 	IssmDouble* riftinfo=NULL;
 	IssmDouble* vertex_pairing=NULL;
 
+	/*Get my_rank:*/
+	my_rank=IssmComm::GetRank();
+	num_procs=IssmComm::GetSize();
+
 	/*Fetch parameters: */
 	iomodel->Constant(&dim,MeshDimensionEnum);
 	iomodel->Constant(&numberofelements,MeshNumberofelementsEnum);
@@ -101,7 +105,7 @@
 		if(my_rank==epart[i]){ 
 
 			my_elements[i]=true;
-			
+
 			/*Now that we are here, we can also start building the list of vertices belonging to this cpu partition: we use 
 			 *the  element index to do this. For each element n, we know index[n][0:2] holds the indices (matlab indexing) 
 			 into the vertices coordinates. If we start plugging 1 into my_vertices for each index[n][i] (i=0:2), then my_vertices 
@@ -109,7 +113,7 @@
 			my_vertices[reCast<int>(*(elements+elements_width*i+0))-1]=1;
 			my_vertices[reCast<int>(*(elements+elements_width*i+1))-1]=1;
 			my_vertices[reCast<int>(*(elements+elements_width*i+2))-1]=1;
-			
+
 			if(elements_width==6){
 				my_vertices[reCast<int>(*(elements+elements_width*i+3))-1]=1;
 				my_vertices[reCast<int>(*(elements+elements_width*i+4))-1]=1;

Modified: issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,12 +22,11 @@
 	bool   spcpresent=false;
 	IssmDouble heatcapacity;
 	IssmDouble referencetemperature;
-	
+
 	/*Output*/
 	IssmDouble *spcvector  = NULL;
 	IssmDouble* times=NULL;
 	IssmDouble* values=NULL;
-	Constraints* constraints = NULL;
 
 	/*Fetch parameters: */
 	iomodel->Constant(&dim,MeshDimensionEnum);
@@ -36,7 +35,7 @@
 	iomodel->Constant(&referencetemperature,ConstantsReferencetemperatureEnum);
 
 	/*Recover pointer: */
-	constraints=*pconstraints;
+	Constraints* constraints=*pconstraints;
 
 	/*Create constraints if they do not exist yet*/
 	if(!constraints) constraints = new Constraints();
@@ -84,7 +83,7 @@
 
 		/*Create constraints from x,y,z: */
 		for (i=0;i<numberofvertices;i++){
-			
+
 			/*keep only this partition's nodes:*/
 			if((iomodel->my_vertices[i])){
 

Modified: issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateLoadsEnthalpy.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateLoadsEnthalpy.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateLoadsEnthalpy.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,16 +12,12 @@
 
 void	CreateLoadsEnthalpy(Loads** ploads, IoModel* iomodel){
 
-	/*DataSet*/
-	Loads* loads=NULL;
-
 	/*Recover pointer: */
-	loads=*ploads;
+	Loads* loads=*ploads;
 
 	/*Create loads if they do not exist yet*/
 	if(!loads) loads = new Loads();
 
-
 	/*Assign output pointer: */
 	*ploads=loads;
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateNodesEnthalpy.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateNodesEnthalpy.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/CreateNodesEnthalpy.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,14 +19,11 @@
 	bool continuous_galerkin=true;
 	int    numberofvertices;
 
-	/*DataSets: */
-	Nodes*    nodes = NULL;
-
 	/*Fetch parameters: */
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
-	
+
 	/*Recover pointer: */
-	nodes=*pnodes;
+	Nodes* nodes=*pnodes;
 
 	/*Create nodes if they do not exist yet*/
 	if(!nodes) nodes = new Nodes();
@@ -39,7 +36,7 @@
 
 	for (i=0;i<numberofvertices;i++){
 		if(iomodel->my_vertices[i]){
-			
+
 			/*Add node to nodes dataset: */
 			nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,i+1,i,iomodel,EnthalpyAnalysisEnum));
 
@@ -48,7 +45,7 @@
 
 	/*Clean fetched data: */
 	iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum);
-	
+
 	/*Assign output pointer: */
 	*pnodes=nodes;
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/UpdateElementsEnthalpy.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/UpdateElementsEnthalpy.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Enthalpy/UpdateElementsEnthalpy.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -58,7 +58,7 @@
 	iomodel->FetchDataToInput(elements,VxEnum);
 	iomodel->FetchDataToInput(elements,VyEnum);
 	iomodel->FetchDataToInput(elements,VzEnum);
-	
+
 	/*Free data: */
 	iomodel->DeleteData(4,MeshElementsEnum,TemperatureEnum,WaterfractionEnum,PressureEnum);
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateConstraintsHydrology.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateConstraintsHydrology.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateConstraintsHydrology.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,16 +13,13 @@
 
 void	CreateConstraintsHydrology(Constraints** pconstraints, IoModel* iomodel){
 
-	/*Output*/
-	Constraints *constraints = NULL;
-
 	/*Recover pointer: */
-	constraints=*pconstraints;
+	Constraints* constraints=*pconstraints;
 
 	/*Create constraints if they do not exist yet*/
 	if(!constraints) constraints = new Constraints();
 	IoModelToConstraintsx(constraints,iomodel,HydrologySpcwatercolumnEnum,HydrologyAnalysisEnum);
-	
+
 	/*Assign output pointer: */
 	*pconstraints=constraints;
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateLoadsHydrology.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateLoadsHydrology.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateLoadsHydrology.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,14 +12,8 @@
 
 void	CreateLoadsHydrology(Loads** ploads, IoModel* iomodel){
 
-	/*Intermediary*/
-	int i;
-
-	/*DataSet*/
-	Loads*    loads    = NULL;
-
 	/*Recover pointer: */
-	loads=*ploads;
+	Loads* loads=*ploads;
 
 	/*Create loads if they do not exist yet*/
 	if(!loads) loads = new Loads();

Modified: issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateNodesHydrology.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateNodesHydrology.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Hydrology/CreateNodesHydrology.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,14 +19,11 @@
 	bool continuous_galerkin=true;
 	int    numberofvertices;
 
-	/*DataSets: */
-	Nodes*    nodes = NULL;
-
 	/*Fetch parameters: */
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
-	
+
 	/*Recover pointer: */
-	nodes=*pnodes;
+	Nodes* nodes=*pnodes;
 
 	/*Create nodes if they do not exist yet*/
 	if(!nodes) nodes = new Nodes();
@@ -45,7 +42,7 @@
 		}
 	}
 	iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum);
-	
+
 	/*Assign output pointer: */
 	*pnodes=nodes;
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/Hydrology/UpdateElementsHydrology.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Hydrology/UpdateElementsHydrology.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Hydrology/UpdateElementsHydrology.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,7 +16,7 @@
 void	UpdateElementsHydrology(Elements* elements, IoModel* iomodel,int analysis_counter,int analysis_type){
 
 	int    numberofelements;
-	
+
 	/*Fetch data needed: */
 	iomodel->Constant(&numberofelements,MeshNumberofelementsEnum);
 	iomodel->FetchData(1,MeshElementsEnum);

Modified: issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateConstraintsMelting.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateConstraintsMelting.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateConstraintsMelting.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,15 +12,8 @@
 
 void	CreateConstraintsMelting(Constraints** pconstraints, IoModel* iomodel){
 
-	/*Intermediary*/
-	int i;
-	int count;
-	
-	/*Intermediary*/
-	Constraints* constraints = NULL;
-
 	/*Recover pointer: */
-	constraints=*pconstraints;
+	Constraints* constraints=*pconstraints;
 
 	/*Create constraints if they do not exist yet*/
 	if(!constraints) constraints = new Constraints();

Modified: issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateLoadsMelting.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateLoadsMelting.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateLoadsMelting.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,14 +13,8 @@
 void	CreateLoadsMelting(Loads** ploads, IoModel* iomodel){
 
 	/*Intermediary*/
-	int i;
-	int    dim;
-	int    numberofvertices;
-
-	/*DataSet*/
-	Loads*    loads    = NULL;
-
-	/*Fetch parameters: */
+	int dim;
+	int numberofvertices;
 	iomodel->Constant(&dim,MeshDimensionEnum);
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 
@@ -28,7 +22,7 @@
 	if (dim==2) _error_("2d meshes not supported yet");
 
 	/*Recover pointer: */
-	loads=*ploads;
+	Loads* loads=*ploads;
 
 	/*Create loads if they do not exist yet*/
 	if(!loads) loads = new Loads();
@@ -37,7 +31,7 @@
 	iomodel->FetchData(2,MeshVertexonbedEnum,MeshElementsEnum);
 	CreateSingleNodeToElementConnectivity(iomodel);
 
-	for (i=0;i<numberofvertices;i++){
+	for(int i=0;i<numberofvertices;i++){
 		if((iomodel->my_vertices[i]==1)){
 			if (reCast<int>(iomodel->Data(MeshVertexonbedEnum)[i])){
 				loads->AddObject(new Pengrid(iomodel->loadcounter+i+1,i,iomodel,MeltingAnalysisEnum));

Modified: issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateNodesMelting.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateNodesMelting.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Melting/CreateNodesMelting.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,14 +19,11 @@
 	bool continuous_galerkin=true;
 	int    numberofvertices;
 
-	/*DataSets: */
-	Nodes*    nodes = NULL;
-	
 	/*Fetch parameters: */
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 
 	/*Recover pointer: */
-	nodes=*pnodes;
+	Nodes* nodes=*pnodes;
 
 	/*Create nodes if they do not exist yet*/
 	if(!nodes) nodes = new Nodes();
@@ -39,7 +36,7 @@
 	for (i=0;i<numberofvertices;i++){
 
 		if(iomodel->my_vertices[i]){
-			
+
 			/*Add node to nodes dataset: */
 			nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,i+1,i,iomodel,MeltingAnalysisEnum));
 

Modified: issm/trunk/src/c/modules/ModelProcessorx/Melting/UpdateElementsMelting.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Melting/UpdateElementsMelting.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Melting/UpdateElementsMelting.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -54,7 +54,7 @@
 	iomodel->FetchDataToInput(elements,MaterialsRheologyNEnum);
 	iomodel->FetchDataToInput(elements,BasalforcingsMeltingRateEnum);
 	iomodel->FetchDataToInput(elements,PressureEnum);
-	
+
 	/*Free data: */
 	iomodel->DeleteData(1,MeshElementsEnum);
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,8 +19,8 @@
 void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters, FILE* IOMODEL,char* rootpath,const int solution_type,const int nummodels,const int* analysis_type_list){
 
 	int   i,analysis_type,dim,verbose;
-	bool  isthermal,isprognostic,isdiagnostic,isgroundingline,isenthalpy,autodiff;
-	
+	bool  isthermal,isprognostic,isdiagnostic,isgroundingline,isenthalpy;
+
 	/*output: */
 	Elements    *elements    = NULL;
 	Nodes       *nodes       = NULL;
@@ -30,7 +30,6 @@
 	Loads       *loads       = NULL;
 	Parameters  *parameters  = NULL;
 
-	
 	/*Initialize IoModel from input file*/
 	IoModel* iomodel = new IoModel(IOMODEL);
 
@@ -42,13 +41,7 @@
 	iomodel->Constant(&isprognostic,TransientIsprognosticEnum);
 	iomodel->Constant(&isdiagnostic,TransientIsdiagnosticEnum);
 	iomodel->Constant(&isgroundingline,TransientIsgroundinglineEnum);
-	iomodel->Constant(&autodiff,AutodiffIsautodiffEnum);
 
-	/*If we are running in AD mode, we need to declare our independent variables now, before 
-	 *and prevent them from being erased during successive calls to iomodel->FetchData and 
-	 iomodel->DeleteData:*/
-	if(autodiff)iomodel->DeclareIndependents();
-
 	SetVerbosityLevel(verbose);
 
 	for(i=0;i<nummodels;i++){
@@ -72,7 +65,7 @@
 		if(solution_type==SteadystateSolutionEnum && analysis_type==ThermalAnalysisEnum && isenthalpy==true) continue;
 		if(solution_type==SteadystateSolutionEnum && analysis_type==MeltingAnalysisEnum && isenthalpy==true) continue;
 		if(solution_type==SteadystateSolutionEnum && analysis_type==EnthalpyAnalysisEnum && isenthalpy==false) continue;
-	
+
 		if(VerboseMProcessor()) _pprintLine_("   creating datasets for analysis " << EnumToStringx(analysis_type));
 		CreateDataSets(&elements,&nodes,&vertices,&materials,&constraints,&loads,&parameters,iomodel,rootpath,solution_type,analysis_type,nummodels,i);
 	}

Modified: issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -108,7 +108,6 @@
 void  SortDataSets(Elements** pelements,Nodes** pnodes,Vertices** pvertices, Loads** ploads, Materials** pmaterials, Constraints** pconstraints, Parameters** pparameters);
 void  UpdateCounters(IoModel* iomodel,Nodes** pnodes,Loads** ploads, Constraints** pconstraints);
 
-
 /*Distribution of dofs: */
 void DistributeNumDofs(DofIndexing* index,int analysis_type,IssmDouble* vertices_type);
 

Modified: issm/trunk/src/c/modules/ModelProcessorx/NodesPartitioning.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/NodesPartitioning.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/NodesPartitioning.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,7 +21,7 @@
 void  ContinuousGalerkinNodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel);
 
 void  NodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel, bool continuous){
-	
+
 	/*First thing, this is a new partition for a new analysis_type, therefore, to avoid a leak, erase the nodes partition that might come through pmy_nodes: */
 	xDelete<bool>(*pmy_nodes);
 
@@ -50,7 +50,6 @@
 	*pmy_nodes=my_nodes;
 }
 
-
 void  DiscontinuousGalerkinNodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel){
 
 	int    numberofelements;
@@ -61,7 +60,7 @@
 	/*each element has it own nodes (as many as vertices) + additional nodes from neighbouring elements for each edge. This yields to a very different partition for 
 	 * the nodes and the vertices. The vertices are similar to continuous galerkin, but the nodes partitioning involves edges, which mess up sorting of 
 	 * ids. */
-	
+
 	int i,j;
 	int    dim;
 

Modified: issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,16 +9,12 @@
 
 void	CreateConstraintsPrognostic(Constraints** pconstraints, IoModel* iomodel){
 
-	int stabilization;
-	
 	/*Fetch parameters: */
+	int stabilization;
 	iomodel->Constant(&stabilization,PrognosticStabilizationEnum);
 
-	/*Output*/
-	Constraints *constraints = NULL;
-
 	/*Recover pointer: */
-	constraints=*pconstraints;
+	Constraints* constraints=*pconstraints;
 
 	/*Create constraints if they do not exist yet*/
 	if(!constraints) constraints = new Constraints();

Modified: issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,16 +22,13 @@
 	int numvertex_pairing;
 	int numberofelements;
 
-	/*DataSet*/
-	Loads*    loads    = NULL;
-	
 	/*Fetch parameters: */
 	iomodel->Constant(&stabilization,PrognosticStabilizationEnum);
 	iomodel->Constant(&numberofelements,MeshNumberofelementsEnum);
 	iomodel->Constant(&numberofedges,MeshNumberofedgesEnum);
 
 	/*Recover pointer: */
-	loads=*ploads;
+	Loads* loads=*ploads;
 
 	/*Create loads if they do not exist yet*/
 	if(!loads) loads = new Loads();

Modified: issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Prognostic/CreateNodesPrognostic.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,9 +25,6 @@
 	int    numberofvertices;
 	int    stabilization;
 
-	/*DataSets: */
-	Nodes*    nodes = NULL;
-
 	/*Fetch parameters: */
 	iomodel->Constant(&dim,MeshDimensionEnum);
 	iomodel->Constant(&numberofelements,MeshNumberofelementsEnum);
@@ -35,7 +32,7 @@
 	iomodel->Constant(&stabilization,PrognosticStabilizationEnum);
 
 	/*Recover pointer: */
-	nodes=*pnodes;
+	Nodes* nodes=*pnodes;
 
 	/*Create nodes if they do not exist yet*/
 	if(!nodes) nodes = new Nodes();

Modified: issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Prognostic/UpdateElementsPrognostic.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -72,6 +72,8 @@
 	}
 	if(issmbgradients){
 	        iomodel->FetchDataToInput(elements,SurfaceforcingsHcEnum);
+	        iomodel->FetchDataToInput(elements,SurfaceforcingsHrefEnum);
+	        iomodel->FetchDataToInput(elements,SurfaceforcingsSmbrefEnum);
 	        iomodel->FetchDataToInput(elements,SurfaceforcingsSmbPosMaxEnum);
 	        iomodel->FetchDataToInput(elements,SurfaceforcingsSmbPosMinEnum);
 	        iomodel->FetchDataToInput(elements,SurfaceforcingsAPosEnum);

Modified: issm/trunk/src/c/modules/ModelProcessorx/SortDataSets.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/SortDataSets.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/SortDataSets.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,6 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 #include "./ModelProcessorx.h"
 
-
 void SortDataSets(Elements** pelements,Nodes** pnodes,Vertices** pvertices, Loads** ploads, Materials** pmaterials, Constraints** pconstraints, Parameters** pparameters){
 
 	Elements* elements=NULL;

Modified: issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateConstraintsSurfaceSlope.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateConstraintsSurfaceSlope.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateConstraintsSurfaceSlope.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,11 +12,8 @@
 
 void	CreateConstraintsSurfaceSlope(Constraints** pconstraints, IoModel* iomodel){
 
-	/*Output*/
-	Constraints* constraints = NULL;
-	
 	/*Recover pointer: */
-	constraints=*pconstraints;
+	Constraints* constraints=*pconstraints;
 
 	/*Create constraints if they do not exist yet*/
 	if(!constraints) constraints = new Constraints();

Modified: issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateLoadsSurfaceSlope.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,11 +12,8 @@
 
 void	CreateLoadsSurfaceSlope(Loads** ploads, IoModel* iomodel){
 
-	/*DataSet*/
-	Loads*    loads    = NULL;
-
 	/*Recover pointer: */
-	loads=*ploads;
+	Loads* loads=*ploads;
 
 	/*Create loads if they do not exist yet*/
 	if(!loads) loads = new Loads();

Modified: issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateNodesSurfaceSlope.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateNodesSurfaceSlope.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/CreateNodesSurfaceSlope.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,32 +15,27 @@
 void	CreateNodesSurfaceSlope(Nodes** pnodes, IoModel* iomodel){
 
 	/*Intermediary*/
-	int i;
 	bool continuous_galerkin=true;
 	int    numberofvertices;
 
-	/*DataSets: */
-	Nodes*    nodes = NULL;
-
 	/*Fetch parameters: */
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 
 	/*Recover pointer: */
-	nodes=*pnodes;
+	Nodes* nodes=*pnodes;
 
 	/*Create nodes if they do not exist yet*/
 	if(!nodes) nodes = new Nodes();
-	
+
 	/*Continuous Galerkin partition of nodes: */
 	NodesPartitioning(&iomodel->my_nodes,iomodel->my_elements,iomodel->my_vertices,iomodel,continuous_galerkin);
-	
+
 	/*First fetch data: */
 	iomodel->FetchData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum);
 
-	for (i=0;i<numberofvertices;i++){
-
+	for(int i=0;i<numberofvertices;i++){
 		if(iomodel->my_vertices[i]){
-			
+
 			/*Add node to nodes dataset: */
 			nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,i+1,i,iomodel,SurfaceSlopeAnalysisEnum));
 
@@ -49,7 +44,7 @@
 
 	/*Clean fetched data: */
 	iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum);
-	
+
 	/*Assign output pointer: */
 	*pnodes=nodes;
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/UpdateElementsSurfaceSlope.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/UpdateElementsSurfaceSlope.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/SurfaceSlope/UpdateElementsSurfaceSlope.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -36,12 +36,12 @@
 	iomodel->FetchDataToInput(elements,SurfaceEnum);
 	iomodel->FetchDataToInput(elements,BedEnum);
 	iomodel->FetchDataToInput(elements,MaskElementonwaterEnum);
-	
+
 	if (dim==3){
 		iomodel->FetchDataToInput(elements,MeshElementonbedEnum);
 		iomodel->FetchDataToInput(elements,MeshElementonsurfaceEnum);
 	}
-	
+
 	/*Free data: */
 	iomodel->DeleteData(1,MeshElementsEnum);
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateConstraintsThermal.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateConstraintsThermal.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateConstraintsThermal.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,19 +13,12 @@
 
 void	CreateConstraintsThermal(Constraints** pconstraints, IoModel* iomodel){
 
-	/*Intermediary*/
-	int i;
-	int count;
-	int    dim;
-	
-	/*Output*/
-	Constraints* constraints = NULL;
-
 	/*Fetch parameters: */
+	int    dim;
 	iomodel->Constant(&dim,MeshDimensionEnum);
 
 	/*Recover pointer: */
-	constraints=*pconstraints;
+	Constraints* constraints=*pconstraints;
 
 	/*Create constraints if they do not exist yet*/
 	if(!constraints) constraints = new Constraints();

Modified: issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateLoadsThermal.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateLoadsThermal.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateLoadsThermal.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,13 +16,10 @@
 	int i;
 	int    dim;
 	int    numberofvertices;
-
-	/*DataSet*/
-	Loads*    loads    = NULL;
 	Pengrid*    pengrid  = NULL;
 
 	/*Recover pointer: */
-	loads=*ploads;
+	Loads* loads=*ploads;
 
 	/*Fetch parameters: */
 	iomodel->Constant(&dim,MeshDimensionEnum);
@@ -39,7 +36,7 @@
 	CreateSingleNodeToElementConnectivity(iomodel);
 
 	for (i=0;i<numberofvertices;i++){
-	
+
 		/*keep only this partition's nodes:*/
 		if((iomodel->my_vertices[i]==1)){
 			if (xIsNan<IssmDouble>(iomodel->Data(ThermalSpctemperatureEnum)[i])){ //No penalty applied on spc nodes!

Modified: issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateNodesThermal.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateNodesThermal.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Thermal/CreateNodesThermal.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,18 +15,14 @@
 void	CreateNodesThermal(Nodes** pnodes, IoModel* iomodel){
 
 	/*Intermediary*/
-	int i;
 	bool continuous_galerkin=true;
-	int    numberofvertices;
 
-	/*DataSets: */
-	Nodes*    nodes = NULL;
-
 	/*Fetch parameters: */
+	int    numberofvertices;
 	iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
 
 	/*Recover pointer: */
-	nodes=*pnodes;
+	Nodes* nodes=*pnodes;
 
 	/*Create nodes if they do not exist yet*/
 	if(!nodes) nodes = new Nodes();
@@ -37,8 +33,7 @@
 	/*Create nodes and vertices: */
 	iomodel->FetchData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum);
 
-	for (i=0;i<numberofvertices;i++){
-
+	for(int i=0;i<numberofvertices;i++){
 		if(iomodel->my_vertices[i]){
 			/*Add node to nodes dataset: */
 			nodes->AddObject(new Node(iomodel->nodecounter+i+1,i,i+1,i,iomodel,ThermalAnalysisEnum));
@@ -48,7 +43,7 @@
 
 	/*Clean fetched data: */
 	iomodel->DeleteData(6,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,MaskVertexongroundediceEnum,MaskVertexonfloatingiceEnum,FlowequationVertexEquationEnum,MaskVertexonwaterEnum);
-	
+
 	/*Assign output pointer: */
 	*pnodes=nodes;
 }

Modified: issm/trunk/src/c/modules/ModelProcessorx/Thermal/UpdateElementsThermal.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/Thermal/UpdateElementsThermal.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/Thermal/UpdateElementsThermal.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -59,7 +59,7 @@
 	iomodel->FetchDataToInput(elements,VxEnum);
 	iomodel->FetchDataToInput(elements,VyEnum);
 	iomodel->FetchDataToInput(elements,VzEnum);
-	
+
 	if(dakota_analysis){
 		elements->InputDuplicate(TemperatureEnum,QmuTemperatureEnum);
 		elements->InputDuplicate(BasalforcingsMeltingRateEnum,QmuMeltingEnum);

Modified: issm/trunk/src/c/modules/ModelProcessorx/UpdateCounters.cpp
===================================================================
--- issm/trunk/src/c/modules/ModelProcessorx/UpdateCounters.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ModelProcessorx/UpdateCounters.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,13 +25,12 @@
 	loads=*ploads;
 	constraints=*pconstraints;
 
-
 	if(nodes) iomodel->nodecounter=nodes->NumberOfNodes();
 	else iomodel->nodecounter=0;
 
 	if(loads)iomodel->loadcounter=loads->NumberOfLoads();
 	else iomodel->loadcounter=0;
-	
+
 	if(constraints)iomodel->constraintcounter=constraints->NumberOfConstraints();
 	else iomodel->constraintcounter=0;
 

Modified: issm/trunk/src/c/modules/NodalValuex/NodalValuex.cpp
===================================================================
--- issm/trunk/src/c/modules/NodalValuex/NodalValuex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/NodalValuex/NodalValuex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 
 void NodalValuex( IssmDouble* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units){
 
-	extern int my_rank;
+	int my_rank;
 	int i;
 	int index;
 	Element* element=NULL;
@@ -20,13 +20,16 @@
 	int sumfound;
 	int cpu_found;
 
+	/*Get my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	/*retrieve element we are interested in: */
 	parameters->FindParam(&index,IndexEnum);
 
 	/*This is the vertex id for which we want to collect the data. Go through elements, and for each 
 	 *element, figure out  if they hold the vertex, and the data. If so, return it: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=(Element*)elements->GetObjectByOffset(i);
+		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		found=element->NodalValue(&value,index,natureofdataenum,process_units);
 		if (found){
 			cpu_found=my_rank;
@@ -36,14 +39,14 @@
 
 	/*Broadcast whether we found the element: */
 	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
+	MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
 	if(!sumfound)_error_("could not find element with vertex with id" << index << " to compute nodal value " << EnumToStringx(natureofdataenum));
 	#endif
 
 	/*Broadcast and plug into response: */
 	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
-	MPI_Bcast(&value,1,MPI_DOUBLE,cpu_found,MPI_COMM_WORLD); 
+	MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
+	MPI_Bcast(&value,1,MPI_DOUBLE,cpu_found,IssmComm::GetComm()); 
 	#else
 	value=cpu_found;
 	#endif

Modified: issm/trunk/src/c/modules/NodalValuex/NodalValuex.h
===================================================================
--- issm/trunk/src/c/modules/NodalValuex/NodalValuex.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/NodalValuex/NodalValuex.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,4 +12,3 @@
 void NodalValuex( IssmDouble* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,bool process_units);
 
 #endif  /* _NODALVALUEX_H */
-

Modified: issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp
===================================================================
--- issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -33,8 +33,6 @@
 	/*output: */
 	double* connectivity=NULL;
 
-
-
 	/*Allocate connectivity: */
 	connectivity=xNewZeroInit<double>(nods*width);
 
@@ -45,12 +43,12 @@
 		element=(double)(n+1); //matlab indexing
 
 		for(i=0;i<3;i++){
-		
+
 			node=(int)*(elements+n*3+i); //already matlab indexed, elements comes directly from the workspace.
 			index=node-1;
 
 			num_elements=(int)*(connectivity+width*index+maxels); //retrieve number of elements already  plugged into the connectivity of this node.
-			
+
 			already_plugged=0;
 			for(j=0;j<num_elements;j++){
 				if (element==*(connectivity+width*index+j)){
@@ -63,7 +61,7 @@
 			/*this elements is not yet plugged  into the connectivity for this node, do it, and increase counter: */
 			*(connectivity+width*index+num_elements)=element;
 			*(connectivity+width*index+maxels)=(double)(num_elements+1);
-			
+
 		}
 	}
 

Modified: issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.h
===================================================================
--- issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/NodeConnectivityx/NodeConnectivityx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,4 +9,3 @@
 void	NodeConnectivityx( double** pconnectivity, int* pwidth,double* elements, int nel, int nods);
 
 #endif  /* _NODECONNECTIVITYX_H */
-

Modified: issm/trunk/src/c/modules/NodesDofx/NodesDofx.cpp
===================================================================
--- issm/trunk/src/c/modules/NodesDofx/NodesDofx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/NodesDofx/NodesDofx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,8 +13,7 @@
 
 	int noerr=1;
 	int found=0;
-	int i;
-	
+
 	/*Do we have any nodes for this analysis type? :*/
 	if(nodes->NumberOfNodes(configuration_type)){ 
 

Modified: issm/trunk/src/c/modules/Orthx/Orthx.cpp
===================================================================
--- issm/trunk/src/c/modules/Orthx/Orthx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Orthx/Orthx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,12 +5,12 @@
 #include "./Orthx.h"
 
 void	Orthx( Vector<IssmDouble>** pnewgradj, Vector<IssmDouble>* gradj, Vector<IssmDouble>* oldgradj){
-	
+
 	/*output: */
 	Vector<IssmDouble>* newgradj=NULL;
 
 	/*intermediary:*/
-	IssmDouble norm_new,norm_old,dot_product;;
+	IssmDouble norm_old,dot_product;;
 
 	/*Initialize output*/
 	newgradj=gradj->Duplicate();

Modified: issm/trunk/src/c/modules/Orthx/Orthx.h
===================================================================
--- issm/trunk/src/c/modules/Orthx/Orthx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Orthx/Orthx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,4 +13,3 @@
 void	Orthx( Vector<IssmDouble>** pnewgradj, Vector<IssmDouble>* gradj, Vector<IssmDouble>* oldgradj);
 
 #endif  /* _ORTHX_H */
-

Modified: issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp
===================================================================
--- issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,10 +14,10 @@
 #include "../../Container/Container.h"
 #include "../../io/io.h"
 #include "../../classes/objects/objects.h"
-		
+
 void OutputResultsx(Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Results* results){
 
-	extern int  my_rank;
+	int         my_rank;
 	FILE       *fid                     = NULL;
 	char       *outputfilename          = NULL;
 	char        cpu_outputfilename[100];        //easier to convert an integer with sprintf
@@ -25,10 +25,13 @@
 	int         solutiontype;
 	char*       solutiontypestring      = NULL;
 	bool        dakota_analysis         = false;
-	
+
 	/*retrieve parameters: */
 	parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
 
+	/*recover my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	if(dakota_analysis){
 		//no need to output anything, Dakota analysis has different outputs
 		return; 
@@ -50,7 +53,7 @@
 
 	/*Now, open file for writing, if not already done: */
 	if(!parameters->Exist(OutputFilePointerEnum)){
-		
+
 		/*We don't have a file pointer. Retrieve the output file name and open it for writing:*/
 		parameters->FindParam(&outputfilename,OutputfilenameEnum);
 
@@ -68,7 +71,7 @@
 			fid=pfopen(cpu_outputfilename ,"wb");
 		}
 		xDelete<char>(outputfilename);
-		
+
 		/*Add file pointer in parameters for further calls to OutputResultsx: */
 		parameters->SetParam(fid,OutputFilePointerEnum);
 	}

Modified: issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.h
===================================================================
--- issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/OutputResultsx/OutputResultsx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,4 +16,3 @@
 void OutputResultsx(Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads,  Materials* materials, Parameters* parameters, Results* results);
 
 #endif  /* _OUTPUTRESULTS_H */
-

Modified: issm/trunk/src/c/modules/OutputRiftsx/OutputRiftsx.cpp
===================================================================
--- issm/trunk/src/c/modules/OutputRiftsx/OutputRiftsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/OutputRiftsx/OutputRiftsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,7 +16,7 @@
 	Vec riftproperties=NULL;
 
 	/*Allocate grad_g: */
-	riftproperties=NewVec(numrifts);
+	riftproperties=NewVec(numrifts,IssmComm::GetComm());
 
 	/*Compute rift properties : */
 	loads->OutputRifts(riftproperties);

Modified: issm/trunk/src/c/modules/OutputRiftsx/OutputRiftsx.h
===================================================================
--- issm/trunk/src/c/modules/OutputRiftsx/OutputRiftsx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/OutputRiftsx/OutputRiftsx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,4 +11,3 @@
 void OutputRiftsx( Vec* priftproperties, Loads* loads, int numrifts);
 
 #endif  /* _OUTPUTRIFTSX_H */
-

Modified: issm/trunk/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp
===================================================================
--- issm/trunk/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ParsePetscOptionsx/ParsePetscOptionsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,7 +22,7 @@
 void ParsePetscOptionsx(Parameters* parameters,FILE* fid){
 
 	char line [1000];
-	extern int my_rank;
+	int my_rank;
 	int i;
 
 	/*intermediary: */
@@ -34,6 +34,9 @@
 	char* catstring=NULL;
 	int   stringlength;
 
+	/*Get my_rank:*/
+	my_rank=IssmComm::GetRank();
+
 	if(my_rank==0){
 
 		/*Now, go through lines and figure out how many analyses we have: */
@@ -55,13 +58,13 @@
 		fseek(fid,0,SEEK_SET);
 		numanalyses=0;
 		while ( fgets(line, sizeof line, fid) ){
-		
+
 			/*skip comments and empty lines: */
 			if ((line[0]=='%') || (line[0]=='\n') || (line[0]==' ') || (line[0]=='\t') || (line[0]=='\r'))continue;
-		
+
 			/*Get rid of end of line: */
 			line[strlen(line)-1]='\0';
-		
+
 			if (line[0]=='+'){ /*this is the analysis line: */
 				analyses[numanalyses]=StringToEnumx(&line[1]);  //skip the '+'
 				numanalyses++;
@@ -95,12 +98,12 @@
 
 	/*Ok, broadcast to other cpus: */
  	#ifdef _HAVE_MPI_
-	MPI_Bcast(&numanalyses,1,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Bcast(&numanalyses,1,MPI_INT,0,IssmComm::GetComm());
 	if(my_rank!=0){
 		analyses=xNew<IssmPDouble>(numanalyses);
 		strings=xNew<char*>(numanalyses);
 	}
-	MPI_Bcast(analyses,numanalyses,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Bcast(analyses,numanalyses,MPI_DOUBLE,0,IssmComm::GetComm());
 	#endif
 	for(i=0;i<numanalyses;i++){
 		char* string=strings[i];
@@ -109,9 +112,9 @@
 		}
 		if(my_rank==0)stringlength=(strlen(string)+1)*sizeof(char);
 		#ifdef _HAVE_MPI_
-		MPI_Bcast(&stringlength,1,MPI_INT,0,MPI_COMM_WORLD);
+		MPI_Bcast(&stringlength,1,MPI_INT,0,IssmComm::GetComm());
 		if(my_rank!=0)string=xNew<char>(stringlength);
-		MPI_Bcast(string,stringlength,MPI_CHAR,0,MPI_COMM_WORLD);
+		MPI_Bcast(string,stringlength,MPI_CHAR,0,IssmComm::GetComm());
 		if(my_rank!=0)strings[i]=string;
 		#endif
 	}

Modified: issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h
===================================================================
--- issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
 	PointCloudFindNeighborsx.h
 */
 
-
 #ifndef _POINTCLOUDFLAGNEIGHBORSX_H
 #define _POINTCLOUDFLAGNEIGHBORSX_H
 
@@ -25,6 +24,4 @@
 
 void* PointCloudFindNeighborsxt(void* vPointCloudFindNeighborsThreadStruct);
 
-
 #endif /* _POINTCLOUDFLAGNEIGHBORSX_H */
-

Modified: issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp
===================================================================
--- issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/PointCloudFindNeighborsx/PointCloudFindNeighborsxt.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -23,7 +23,7 @@
 	gate=(PointCloudFindNeighborsThreadStruct*)handle->gate;
 	my_thread=handle->id;
 	num_threads=handle->num;
-	
+
 	/*recover parameters :*/
 	x=gate->x;
 	y=gate->y;
@@ -56,7 +56,7 @@
 			/*skip himself: */
 			if (j==i)continue;
 			distance=sqrt(pow(x[i]-x[j],2)+ pow(y[i]-y[j],2));
-			
+
 			if(distance<=mindistance){
 
 				/*insert value and go to the next point*/
@@ -73,6 +73,6 @@
 
 	/*Free ressources:*/
 	xDelete<bool>(already);
-	
+
 	return NULL;
 }

Modified: issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp
===================================================================
--- issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -34,14 +34,14 @@
   IssmDouble pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow
   IssmDouble PDup, PDCUT = 2.0;    // PDcut: rain/snow cutoff temperature (C)
   IssmDouble tstar; // monthly mean surface temp
-  
+
   IssmDouble* pdds=NULL; 
   IssmDouble* pds=NULL; 
   Element* element = NULL;
-  
+
   pdds=xNew<IssmDouble>(NPDMAX+1); 
   pds=xNew<IssmDouble>(NPDCMAX+1); 
-  
+
   // initialize PDD (creation of a lookup table)
   tstep = 0.1;
   tsint = tstep*0.5;
@@ -54,7 +54,7 @@
   PDup = siglimc+PDCUT;
 
   itm = reCast<int,IssmDouble>((2*siglim/DT + 1.5));
-  
+
   if (itm >= NPDMAX){
     _printLine_("increase NPDMAX in massBalance.cpp");
     exit (1);
@@ -72,7 +72,7 @@
     pdds[it] = pddt*snormfac;
   }
   pdds[itm+1] = siglim + DT;
-  
+
   //*********compute PD(T) : snow/precip fraction. precipitation falling as snow
   tstepc = 0.1;
   tsint = PDCUT-tstepc*0.5;
@@ -99,13 +99,13 @@
   }
   pds[itm+1] = 0.;
   //     *******END initialize PDD
-  
+
   for(i=0;i<elements->Size();i++){
-    element=(Element*)elements->GetObjectByOffset(i);
+    element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
     element->PositiveDegreeDay(pdds,pds,signorm);
   }
   /*free ressouces: */
   xDelete<IssmDouble>(pdds);
   xDelete<IssmDouble>(pds);
-  
+
 }

Modified: issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.cpp
===================================================================
--- issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,7 +15,6 @@
 	RecursivePropagation(pool, connectivity,index, flags);
 }
 
-
 void RecursivePropagation(double* pool, double* connectivity, int index, double* flags){
 
 	int i;

Modified: issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h
===================================================================
--- issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,4 +10,3 @@
 void PropagateFlagsFromConnectivityx( double* pool, double* connectivity,int index, double* flags);
 
 #endif  /* _PROPAGATEFLAGSFROMCONNECTIVITYX_H */
-

Modified: issm/trunk/src/c/modules/Reduceloadx/Reduceloadx.cpp
===================================================================
--- issm/trunk/src/c/modules/Reduceloadx/Reduceloadx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Reduceloadx/Reduceloadx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,7 +19,7 @@
 	int         Kfsm,Kfsn;
 	int         global_m,global_n;
 	bool        fromlocalsize = true;
-	int         verbose;
+	bool        oldalloc  = false;
 
 	if(VerboseModule()) _pprintLine_("   Dirichlet lifting applied to load vector");
 
@@ -31,7 +31,11 @@
 
 		/*pf = pf - Kfs * y_s;*/
 		Kfs->GetLocalSize(&Kfsm,&Kfsn);
-		Kfsy_s=new Vector<IssmDouble>(Kfsm,fromlocalsize);
+		if(oldalloc)
+		 Kfsy_s=new Vector<IssmDouble>(Kfsm,fromlocalsize);
+		else
+		 Kfsy_s=new Vector<IssmDouble>(Kfsm,global_m);
+
 		if (flag_ys0){
 
 			/*Create y_s0, full of 0: */
@@ -48,7 +52,6 @@
 		pf->AXPY(Kfsy_s,-1.);
 	}
 
-
 	/*Free ressources and return*/
 	xdelete(&y_s0);
 	xdelete(&Kfsy_s);

Modified: issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp
===================================================================
--- issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,28 +4,35 @@
  */
 
 #include "./Reducevectorgtofx.h"
- 
+
 void Reducevectorgtofx(Vector<IssmDouble>** puf, Vector<IssmDouble>* ug, Nodes* nodes,Parameters* parameters){
 
 	/*output: */
 	Vector<IssmDouble>* uf=NULL;
 
 	/*variables: */
-	int i;
-	int configuration_type;
-	int fsize;
-	IssmDouble* ug_serial=NULL;
+	int         configuration_type;
+	int         fsize;
+	IssmDouble *ug_serial = NULL;
+	bool        oldalloc  = false;
 
 	/*first figure out fsize: */
 	parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
 	fsize=nodes->NumberOfDofs(configuration_type,FsetEnum);
 
+	int    analysis_type;
+	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
+	int flocalsize = nodes->NumberOfDofsLocal(analysis_type,FsetEnum);
+
 	if(fsize==0){
 		uf=NULL;
 	}
 	else{
 		/*allocate: */
-		uf=new Vector<IssmDouble>(fsize);
+		if(oldalloc)
+		 uf=new Vector<IssmDouble>(fsize);
+		else
+		 uf=new Vector<IssmDouble>(flocalsize,fsize);
 
 		if(nodes->NumberOfNodes(configuration_type)){ 
 
@@ -33,7 +40,7 @@
 			ug_serial=ug->ToMPISerial();
 
 			/*Go through all nodes, and ask them to retrieve values from ug, and plug them into uf: */
-			for(i=0;i<nodes->Size();i++){
+			for(int i=0;i<nodes->Size();i++){
 
 				Node* node=(Node*)nodes->GetObjectByOffset(i);
 

Modified: issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.h
===================================================================
--- issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,4 +12,3 @@
 void Reducevectorgtofx(Vector<IssmDouble>** puf, Vector<IssmDouble>* ug, Nodes* nodes,Parameters* parameters);
 
 #endif  /* _REDUCEVECTORGTOFX_H */
-

Modified: issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp
===================================================================
--- issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,12 +20,21 @@
 	parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
 	ssize=nodes->NumberOfDofs(configuration_type,SsetEnum);
 
+	int analysis_type;
+	parameters->FindParam(&analysis_type,AnalysisTypeEnum);
+	int slocalsize = nodes->NumberOfDofsLocal(analysis_type,SsetEnum);
+
+	bool oldalloc = false;
+
 	if(ssize==0){
 		ys=NULL;
 	}
 	else{
 		/*allocate: */
-		ys=new Vector<IssmDouble>(ssize);
+		if(oldalloc)
+		 ys=new Vector<IssmDouble>(ssize);
+		else
+		 ys=new Vector<IssmDouble>(slocalsize,ssize);
 
 		if(nodes->NumberOfNodes(configuration_type)){ 
 

Modified: issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.h
===================================================================
--- issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,4 +12,3 @@
 void Reducevectorgtosx(Vector<IssmDouble>** pys, Vector<IssmDouble>* yg, Nodes* nodes,Parameters* parameters);
 
 #endif  /* _REDUCEVECTORGTOSX_H */
-

Modified: issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.cpp
===================================================================
--- issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,11 +12,6 @@
 
 void ResetConstraintsx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads,Materials* materials,  Parameters* parameters){
 
-	int i;
-
-	extern int num_procs;
-	extern int my_rank;
-
 	/*output: */
 	int analysis_type;
 

Modified: issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.h
===================================================================
--- issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ResetConstraintsx/ResetConstraintsx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,4 +13,3 @@
 void ResetConstraintsx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads,Materials* materials,  Parameters* parameters); 
 
 #endif  /* _RESETCONSTRAINTSX_H */
-

Modified: issm/trunk/src/c/modules/ResetCoordinateSystemx/ResetCoordinateSystemx.cpp
===================================================================
--- issm/trunk/src/c/modules/ResetCoordinateSystemx/ResetCoordinateSystemx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ResetCoordinateSystemx/ResetCoordinateSystemx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,7 +12,7 @@
 	Element *element = NULL;
 
 	for (int i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		element->ResetCoordinateSystem();
 	}
 

Modified: issm/trunk/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp
===================================================================
--- issm/trunk/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,14 +21,14 @@
 
 	/*Compute Misfit: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		J+=element->RheologyBbarAbsGradient(process_units,weight_index);
 	}
 
 	/*Sum all J from all cpus of the cluster:*/
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
 	#endif
 

Modified: issm/trunk/src/c/modules/Scotchx/Scotchx.h
===================================================================
--- issm/trunk/src/c/modules/Scotchx/Scotchx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Scotchx/Scotchx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,6 @@
 #ifndef _SCOTCHX_H
 #define _SCOTCHX_H
 
-
 #undef __FUNCT__ 
 #define __FUNCT__  "Scotchx"
 

Modified: issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp
===================================================================
--- issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/SetControlInputsFromVectorx/SetControlInputsFromVectorx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,7 +28,7 @@
 }
 
 void SetControlInputsFromVectorx(Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector<IssmDouble>* vector){
-	
+
 	IssmDouble* serial_vector=NULL;
 
 	serial_vector=vector->ToMPISerial();

Modified: issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp
===================================================================
--- issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Shp2Kmlx/Shp2Kmlx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,7 @@
 			 int sgn){
 
 	#ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
-	
+
 	double  cm,sp;
 
 	if (sgn)
@@ -32,7 +32,7 @@
 			 int sgn,double cm,double sp){
 
 	#ifdef _HAVE_SHAPELIB_ //only works if Shapelib library has been compiled in.
-	
+
 	int     i,j,k,iret=0;
 	int     lwidth=1;
 	double  popac=0.50;
@@ -610,4 +610,3 @@
 	return 0;
 	#endif
 }
-

Modified: issm/trunk/src/c/modules/SmbGradientsx/SmbGradientsx.cpp
===================================================================
--- issm/trunk/src/c/modules/SmbGradientsx/SmbGradientsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/SmbGradientsx/SmbGradientsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,11 +17,11 @@
 //    OUTPUT: mass-balance (m/yr ice): agd(NA)
 
   int    i;
-  
+
   Element* element = NULL;
-  
+
   for(i=0;i<elements->Size();i++){
-    element=(Element*)elements->GetObjectByOffset(i);
+    element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
     element->SmbGradients();
   }
 }

Modified: issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp
===================================================================
--- issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Solverx/DofTypesToIndexSet.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 #else
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
-        
+
 void DofTypesToIndexSet(IS* pisv, IS* pisp, Vec df,int typeenum){
 
 	/*output: */
@@ -61,14 +61,14 @@
 			}
 		}
 		VecRestoreArray(df,&df_local);
-		
+
 		/*Create indices sets: */
 		#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
-		ISCreateGeneral(PETSC_COMM_WORLD,pressure_num,pressure_indices,&isp);
-		ISCreateGeneral(PETSC_COMM_WORLD,velocity_num,velocity_indices,&isv);
+		ISCreateGeneral(IssmComm::GetComm(),pressure_num,pressure_indices,&isp);
+		ISCreateGeneral(IssmComm::GetComm(),velocity_num,velocity_indices,&isv);
 		#else
-		ISCreateGeneral(PETSC_COMM_WORLD,pressure_num,pressure_indices,PETSC_COPY_VALUES,&isp);
-		ISCreateGeneral(PETSC_COMM_WORLD,velocity_num,velocity_indices,PETSC_COPY_VALUES,&isv);
+		ISCreateGeneral(IssmComm::GetComm(),pressure_num,pressure_indices,PETSC_COPY_VALUES,&isp);
+		ISCreateGeneral(IssmComm::GetComm(),velocity_num,velocity_indices,PETSC_COPY_VALUES,&isv);
 		#endif
 	}
 

Modified: issm/trunk/src/c/modules/Solverx/Solverx.cpp
===================================================================
--- issm/trunk/src/c/modules/Solverx/Solverx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Solverx/Solverx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,9 +15,6 @@
 
 void	Solverx(Vector<IssmDouble>** puf, Matrix<IssmDouble>* Kff, Vector<IssmDouble>* pf, Vector<IssmDouble>* uf0,Vector<IssmDouble>* df, Parameters* parameters){
 
-	/*Intermediary: */
-	int analysis_type;
-
 	/*output: */
 	Vector<IssmDouble> *uf=NULL;
 

Modified: issm/trunk/src/c/modules/Solverx/Solverx.h
===================================================================
--- issm/trunk/src/c/modules/Solverx/Solverx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Solverx/Solverx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -26,7 +26,7 @@
 void SolverxSeq(IssmPDouble **pX, IssmPDouble *A, IssmPDouble *B,int n);
 void SolverxSeq(IssmPDouble *X, IssmPDouble *A, IssmPDouble *B,int n);
 
-#ifdef _HAVE_ADOLC_
+#if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_)
 void SolverxSeq(IssmDouble *X,IssmDouble *A,IssmDouble *B,int n, Parameters* parameters);
 // call back functions:
 ADOLC_ext_fct EDF_for_solverx;
@@ -37,4 +37,3 @@
 #endif
 
 #endif  /* _SOLVERX_H */
-

Modified: issm/trunk/src/c/modules/Solverx/SolverxPetsc.cpp
===================================================================
--- issm/trunk/src/c/modules/Solverx/SolverxPetsc.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Solverx/SolverxPetsc.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,7 +19,7 @@
 
 	Vec uf0_vector = NULL;
 	Vec df_vector  = NULL;
-	
+
 	if(uf0) uf0_vector = uf0->vector;
 	if(df)  df_vector  = df->vector;
 
@@ -35,7 +35,6 @@
 
 	/*Intermediary: */
 	int        local_m,local_n,global_m,global_n;
-	int        analysis_type;
 
 	/*Solver */
 	KSP        ksp              = NULL;
@@ -69,7 +68,7 @@
 	_assert_(Kff);
 	MatGetSize(Kff,&global_m,&global_n); _assert_(global_m==global_m);
 	if(!global_n){
-		*puf=NewVec(0); return;
+		*puf=NewVec(0,IssmComm::GetComm()); return;
 	}
 
 	/*Initial guess */
@@ -85,7 +84,7 @@
 		VecDuplicate(uf0,&uf); VecCopy(uf0,uf);
 	}
 	else{
-		MatGetLocalSize(Kff,&local_m,&local_n);uf=NewVec(local_n,fromlocalsize);
+		MatGetLocalSize(Kff,&local_m,&local_n);uf=NewVec(local_n,IssmComm::GetComm(),fromlocalsize);
 	}
 
 	/*Process petsc options to see if we are using special types of external solvers*/
@@ -101,7 +100,7 @@
 	}
 
 	/*Prepare solver*/
-	KSPCreate(MPI_COMM_WORLD,&ksp);
+	KSPCreate(IssmComm::GetComm(),&ksp);
 	KSPSetOperators(ksp,Kff,Kff,DIFFERENT_NONZERO_PATTERN);
 	KSPSetFromOptions(ksp);
 
@@ -147,14 +146,14 @@
 	/*Solve: */
 	if(VerboseSolver())KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD);
 	KSPSolve(ksp,pf,uf);
-	
+
 	/*Check convergence*/
 	KSPGetIterationNumber(ksp,&iteration_number);
 	if (iteration_number<0) _error_("Solver diverged at iteration number: " << -iteration_number);
 
 	/*Free resources:*/
 	KSPFree(&ksp);
-		
+
 	/*Assign output pointers:*/
 	*puf=uf;
 }

Modified: issm/trunk/src/c/modules/Solverx/SolverxSeq.cpp
===================================================================
--- issm/trunk/src/c/modules/Solverx/SolverxSeq.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/Solverx/SolverxSeq.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,6 +11,7 @@
 
 #include "./Solverx.h"
 #include "../../shared/shared.h"
+#include "../../classes/classes.h"
 #include "../../include/include.h"
 #include "../../io/io.h"
 
@@ -18,15 +19,11 @@
 #include <gsl/gsl_linalg.h>
 #endif
 
-#ifdef _HAVE_ADOLC_
-#include "../../shared/Numerics/adolc_edf.h"
-#endif
-
 void SolverxSeq(SeqVec<IssmDouble>** puf,SeqMat<IssmDouble>* Kff, SeqVec<IssmDouble>* pf, Parameters* parameters){/*{{{*/
 
 #ifdef _HAVE_GSL_
 	/*Intermediary: */
-	int M,N,N2,s;
+	int M,N,N2;
 	SeqVec<IssmDouble> *uf = NULL;
 
 	Kff->GetSize(&M,&N);
@@ -34,8 +31,10 @@
 
 	if(N!=N2)_error_("Right hand side vector of size " << N2 << ", when matrix is of size " << M << "-" << N << " !");
 	if(M!=N)_error_("Stiffness matrix should be square!");
+#ifdef _HAVE_ADOLC_
+	ensureContiguousLocations(N);
+#endif
 	IssmDouble *x  = xNew<IssmDouble>(N);
-
 #ifdef _HAVE_ADOLC_
 	SolverxSeq(x,Kff->matrix,pf->vector,N,parameters);
 #else
@@ -68,98 +67,141 @@
 
 #ifdef _HAVE_ADOLC_
 int EDF_for_solverx(int n, IssmPDouble *x, int m, IssmPDouble *y){ /*{{{*/
-    SolverxSeq(y,x, x+m*m, m); // x is where the matrix starts, x+m*m is where the right-hand side starts
-    return 0;
+	SolverxSeq(y,x, x+m*m, m); // x is where the matrix starts, x+m*m is where the right-hand side starts
+	return 0;
 } /*}}}*/
 int EDF_fos_forward_for_solverx(int n, IssmPDouble *inVal, IssmPDouble *inDeriv, int m, IssmPDouble *outVal, IssmPDouble *outDeriv) { /*{{{*/
 #ifdef _HAVE_GSL_
-  // the matrix will be modified by LU decomposition. Use gsl_A copy
-  double* Acopy = xNew<double>(m*m);
-  xMemCpy(Acopy,inVal,m*m);
-  /*Initialize gsl matrices and vectors: */
-  gsl_matrix_view gsl_A = gsl_matrix_view_array (Acopy,m,m);
-  gsl_vector_view gsl_b = gsl_vector_view_array (inVal+m*m,m); // the right hand side starts at address inVal+m*m
-  gsl_permutation *perm_p = gsl_permutation_alloc (m);
-  int  signPerm;
-  // factorize
-  gsl_linalg_LU_decomp (&gsl_A.matrix, perm_p, &signPerm);
-  gsl_vector *gsl_x_p = gsl_vector_alloc (m);
-  // solve for the value
-  gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_b.vector, gsl_x_p);
-  /*Copy result*/
-  xMemCpy(outVal,gsl_vector_ptr(gsl_x_p,0),m);
-  gsl_vector_free(gsl_x_p);
-  // solve for the derivatives acc. to A * dx = r  with r=db - dA * x
-  // compute the RHS
-  double* r=xNew<double>(m);
-  for (int i=0; i<m; i++) {
-    r[i]=inDeriv[m*m+i]; // this is db[i]
-    for (int j=0;j<m; j++) {
-      r[i]-=inDeriv[i*m+j]*outVal[j]; // this is dA[i][j]*x[j]
-    }
-  }
-  gsl_vector_view gsl_r=gsl_vector_view_array(r,m);
-  gsl_vector *gsl_dx_p = gsl_vector_alloc(m);
-  gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_r.vector, gsl_dx_p);
-  xMemCpy(outDeriv,gsl_vector_ptr(gsl_dx_p,0),m);
-  gsl_vector_free(gsl_dx_p);
-  xDelete(r);
-  gsl_permutation_free(perm_p);
-  xDelete(Acopy);
-  #endif
-  return 0;
+	//  for (int i=0; i<m*m; ++i) std::cout << "EDF_fos_forward_for_solverx A["<< i << "]=" << inVal[i] << std::endl;
+	//  for (int i=0; i<m; ++i) std::cout << "EDF_fos_forward_for_solverx b["<< i << "]=" << inVal[i+m*m] << std::endl;
+	// the matrix will be modified by LU decomposition. Use gsl_A copy
+	double* Acopy = xNew<double>(m*m);
+	xMemCpy(Acopy,inVal,m*m);
+	/*Initialize gsl matrices and vectors: */
+	gsl_matrix_view gsl_A = gsl_matrix_view_array (Acopy,m,m);
+	gsl_vector_view gsl_b = gsl_vector_view_array (inVal+m*m,m); // the right hand side starts at address inVal+m*m
+	gsl_permutation *perm_p = gsl_permutation_alloc (m);
+	int  signPerm;
+	// factorize
+	gsl_linalg_LU_decomp (&gsl_A.matrix, perm_p, &signPerm);
+	gsl_vector *gsl_x_p = gsl_vector_alloc (m);
+	// solve for the value
+	gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_b.vector, gsl_x_p);
+	/*Copy result*/
+	xMemCpy(outVal,gsl_vector_ptr(gsl_x_p,0),m);
+	gsl_vector_free(gsl_x_p);
+	//  for (int i=0; i<m; ++i) std::cout << "EDF_fos_forward_for_solverx x["<< i << "]=" << outVal[i] << std::endl;
+	// solve for the derivatives acc. to A * dx = r  with r=db - dA * x
+	// compute the RHS
+	double* r=xNew<double>(m);
+	for (int i=0; i<m; i++) {
+		r[i]=inDeriv[m*m+i]; // this is db[i]
+		for (int j=0;j<m; j++) {
+			r[i]-=inDeriv[i*m+j]*outVal[j]; // this is dA[i][j]*x[j]
+		}
+	}
+	gsl_vector_view gsl_r=gsl_vector_view_array(r,m);
+	gsl_vector *gsl_dx_p = gsl_vector_alloc(m);
+	gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_r.vector, gsl_dx_p);
+	xMemCpy(outDeriv,gsl_vector_ptr(gsl_dx_p,0),m);
+	gsl_vector_free(gsl_dx_p);
+	xDelete(r);
+	gsl_permutation_free(perm_p);
+	xDelete(Acopy);
+#endif
+	return 0;
 } /*}}}*/
 int EDF_fov_forward_for_solverx(int n, IssmPDouble *inVal, int directionCount, IssmPDouble **inDeriv, int m, IssmPDouble *outVal, IssmPDouble **outDeriv) { /*{{{*/
 #ifdef _HAVE_GSL_
-  // the matrix will be modified by LU decomposition. Use gsl_A copy
-  double* Acopy = xNew<double>(m*m);
-  xMemCpy(Acopy,inVal,m*m);
-  /*Initialize gsl matrices and vectors: */
-  gsl_matrix_view gsl_A = gsl_matrix_view_array (Acopy,m,m);
-  gsl_vector_view gsl_b = gsl_vector_view_array (inVal+m*m,m); // the right hand side starts at address inVal+m*m
-  gsl_permutation *perm_p = gsl_permutation_alloc (m);
-  int  signPerm;
-  // factorize
-  gsl_linalg_LU_decomp (&gsl_A.matrix, perm_p, &signPerm);
-  gsl_vector *gsl_x_p = gsl_vector_alloc (m);
-  // solve for the value
-  gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_b.vector, gsl_x_p);
-  /*Copy result*/
-  xMemCpy(outVal,gsl_vector_ptr(gsl_x_p,0),m);
-  gsl_vector_free(gsl_x_p);
-  // solve for the derivatives acc. to A * dx = r  with r=db - dA * x
-  double* r=xNew<double>(m);
-  gsl_vector *gsl_dx_p = gsl_vector_alloc(m);
-  for (int dir=0;dir<directionCount;++dir) {
-    // compute the RHS
-    for (int i=0; i<m; i++) {
-      r[i]=inDeriv[m*m+i][dir]; // this is db[i]
-      for (int j=0;j<m; j++) {
-        r[i]-=inDeriv[i*m+j][dir]*outVal[j]; // this is dA[i][j]*x[j]
-      }
-    }
-    gsl_vector_view gsl_r=gsl_vector_view_array(r,m);
-    gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_r.vector, gsl_dx_p);
-    // reuse r
-    xMemCpy(r,gsl_vector_ptr(gsl_dx_p,0),m);
-    for (int i=0; i<m; i++) {
-      outDeriv[i][dir]=r[i];
-    }
-  }
-  gsl_vector_free(gsl_dx_p);
-  xDelete(r);
-  gsl_permutation_free(perm_p);
-  xDelete(Acopy);
-  #endif
-  return 0;
+	// the matrix will be modified by LU decomposition. Use gsl_A copy
+	double* Acopy = xNew<double>(m*m);
+	xMemCpy(Acopy,inVal,m*m);
+	/*Initialize gsl matrices and vectors: */
+	gsl_matrix_view gsl_A = gsl_matrix_view_array (Acopy,m,m);
+	gsl_vector_view gsl_b = gsl_vector_view_array (inVal+m*m,m); // the right hand side starts at address inVal+m*m
+	gsl_permutation *perm_p = gsl_permutation_alloc (m);
+	int  signPerm;
+	// factorize
+	gsl_linalg_LU_decomp (&gsl_A.matrix, perm_p, &signPerm);
+	gsl_vector *gsl_x_p = gsl_vector_alloc (m);
+	// solve for the value
+	gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_b.vector, gsl_x_p);
+	/*Copy result*/
+	xMemCpy(outVal,gsl_vector_ptr(gsl_x_p,0),m);
+	gsl_vector_free(gsl_x_p);
+	// solve for the derivatives acc. to A * dx = r  with r=db - dA * x
+	double* r=xNew<double>(m);
+	gsl_vector *gsl_dx_p = gsl_vector_alloc(m);
+	for (int dir=0;dir<directionCount;++dir) {
+		// compute the RHS
+		for (int i=0; i<m; i++) {
+			r[i]=inDeriv[m*m+i][dir]; // this is db[i]
+			for (int j=0;j<m; j++) {
+				r[i]-=inDeriv[i*m+j][dir]*outVal[j]; // this is dA[i][j]*x[j]
+			}
+		}
+		gsl_vector_view gsl_r=gsl_vector_view_array(r,m);
+		gsl_linalg_LU_solve (&gsl_A.matrix, perm_p, &gsl_r.vector, gsl_dx_p);
+		// reuse r
+		xMemCpy(r,gsl_vector_ptr(gsl_dx_p,0),m);
+		for (int i=0; i<m; i++) {
+			outDeriv[i][dir]=r[i];
+		}
+	}
+	gsl_vector_free(gsl_dx_p);
+	xDelete(r);
+	gsl_permutation_free(perm_p);
+	xDelete(Acopy);
+#endif
+	return 0;
 }
 /*}}}*/
-int EDF_fos_reverse_for_solverx(int m, double *dp_U, int n, double *dp_Z) { /*{{{*/
-  return 0;
+int EDF_fos_reverse_for_solverx(int m, double *dp_U, int n, double *dp_Z, double* dp_x, double* dp_y) { /*{{{*/
+	// copy to transpose the matrix
+	double* transposed=xNew<double>(m*m);
+	for (int i=0; i<m; ++i) for (int j=0; j<m; ++j) transposed[j*m+i]=dp_x[i*m+j];
+	gsl_matrix_view aTransposed = gsl_matrix_view_array (transposed,m,m);
+	// the adjoint of the solution is our right-hand side
+	gsl_vector_view x_bar=gsl_vector_view_array(dp_U,m);
+	// the last m elements of dp_Z representing the adjoint of the right-hand side we want to compute:
+	gsl_vector_view b_bar=gsl_vector_view_array(dp_Z+m*m,m);
+	gsl_permutation *perm_p = gsl_permutation_alloc (m);
+	int permSign;
+	gsl_linalg_LU_decomp (&aTransposed.matrix, perm_p, &permSign);
+	gsl_linalg_LU_solve (&aTransposed.matrix, perm_p, &x_bar.vector, &b_bar.vector);
+	// now do the adjoint of the matrix
+	for (int i=0; i<m; ++i) for (int j=0; j<m; ++j) dp_Z[i*m+j]-=dp_Z[m*m+i]*dp_y[j];
+	gsl_permutation_free(perm_p);
+	xDelete(transposed);
+	return 0;
 }
 /*}}}*/
+int EDF_fov_reverse_for_solverx(int m, int p, double **dpp_U, int n, double **dpp_Z, double* dp_x, double* dp_y) { /*{{{*/
+	// copy to transpose the matrix
+	double* transposed=xNew<double>(m*m);
+	for (int i=0; i<m; ++i) for (int j=0; j<m; ++j) transposed[j*m+i]=dp_x[i*m+j];
+	gsl_matrix_view aTransposed = gsl_matrix_view_array (transposed,m,m);
+	gsl_permutation *perm_p = gsl_permutation_alloc (m);
+	int permSign;
+	gsl_linalg_LU_decomp (&aTransposed.matrix, perm_p, &permSign);
+	for (int weightsRowIndex=0;weightsRowIndex<p;++weightsRowIndex) {
+		// the adjoint of the solution is our right-hand side
+		gsl_vector_view x_bar=gsl_vector_view_array(dpp_U[weightsRowIndex],m);
+		// the last m elements of dp_Z representing the adjoint of the right-hand side we want to compute:
+		gsl_vector_view b_bar=gsl_vector_view_array(dpp_Z[weightsRowIndex]+m*m,m);
+		gsl_linalg_LU_solve (&aTransposed.matrix, perm_p, &x_bar.vector, &b_bar.vector);
+		// now do the adjoint of the matrix
+		for (int i=0; i<m; ++i) for (int j=0; j<m; ++j) dpp_Z[weightsRowIndex][i*m+j]-=dpp_Z[weightsRowIndex][m*m+i]*dp_y[j];
+	}
+	gsl_permutation_free(perm_p);
+	xDelete(transposed);
+	return 0;
+}
+/*}}}*/
 void SolverxSeq(IssmDouble *X,IssmDouble *A,IssmDouble *B,int n, Parameters* parameters){/*{{{*/
 	// pack inputs to conform to the EDF-prescribed interface
+        // ensure a contiguous block of locations:
+        ensureContiguousLocations(n*(n+1));
         IssmDouble*  adoubleEDFin=xNew<IssmDouble>(n*(n+1));  // packed inputs, i.e. matrix and right hand side
         for(int i=0; i<n*n;i++)adoubleEDFin[i]    =A[i];      // pack matrix
         for(int i=0; i<n;  i++)adoubleEDFin[i+n*n]=B[i];      // pack the right hand side
@@ -169,6 +211,7 @@
 	call_ext_fct(dynamic_cast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p,
 	             n*(n+1), pdoubleEDFin, adoubleEDFin,
 	             n, pdoubleEDFout,X);
+	// for(int i=0; i<n;  i++) {ADOLC_DUMP_MACRO(X[i]);}
 	xDelete(adoubleEDFin);
 	xDelete(pdoubleEDFin);
 	xDelete(pdoubleEDFout);
@@ -180,9 +223,10 @@
 	/*GSL Matrices and vectors: */
 	int              s;
 	gsl_matrix_view  a;
-	gsl_vector_view  b;
-	gsl_vector      *x = NULL;
+	gsl_vector_view  b,x;
 	gsl_permutation *p = NULL;
+//	for (int i=0; i<n*n; ++i) std::cout << "SolverxSeq A["<< i << "]=" << A[i] << std::endl;
+//	for (int i=0; i<n; ++i) std::cout << "SolverxSeq b["<< i << "]=" << B[i] << std::endl;
 	/*A will be modified by LU decomposition. Use copy*/
 	double* Acopy = xNew<double>(n*n);
 	xMemCpy(Acopy,A,n*n);
@@ -190,23 +234,16 @@
 	/*Initialize gsl matrices and vectors: */
 	a = gsl_matrix_view_array (Acopy,n,n);
 	b = gsl_vector_view_array (B,n);
-	x = gsl_vector_alloc (n);
+	x = gsl_vector_view_array (X,n);
 
 	/*Run LU and solve: */
 	p = gsl_permutation_alloc (n);
 	gsl_linalg_LU_decomp (&a.matrix, p, &s);
-	gsl_linalg_LU_solve (&a.matrix, p, &b.vector, x);
+	gsl_linalg_LU_solve (&a.matrix, p, &b.vector, &x.vector);
 
-	//printf ("x = \n");
-	//gsl_vector_fprintf (stdout, x, "%g");
-
-	/*Copy result*/
-	xMemCpy(X,gsl_vector_ptr(x,0),n);
-
 	/*Clean up and assign output pointer*/
 	xDelete(Acopy);
 	gsl_permutation_free(p);
-	gsl_vector_free(x);
 #endif
 }
 /*}}}*/

Modified: issm/trunk/src/c/modules/SpcNodesx/SpcNodesx.cpp
===================================================================
--- issm/trunk/src/c/modules/SpcNodesx/SpcNodesx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/SpcNodesx/SpcNodesx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,7 +12,7 @@
 void SpcNodesx(Nodes* nodes,Constraints* constraints,Parameters* parameters, int analysis_type){
 
 	for(int i=0;i<constraints->Size();i++){
-	
+
 		Constraint* constraint=(Constraint*)constraints->GetObjectByOffset(i);
 
 		/*Check this constraint belongs to this analysis: */

Modified: issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp
===================================================================
--- issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/StringToEnumx/StringToEnumx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,13 +18,25 @@
 
    if(stage==1){
 	      if (strcmp(name,"AutodiffIsautodiff")==0) return AutodiffIsautodiffEnum;
-	      else if (strcmp(name,"AutodiffDependents")==0) return AutodiffDependentsEnum;
 	      else if (strcmp(name,"AutodiffNumDependents")==0) return AutodiffNumDependentsEnum;
-	      else if (strcmp(name,"AutodiffIndependents")==0) return AutodiffIndependentsEnum;
+	      else if (strcmp(name,"AutodiffNumDependentObjects")==0) return AutodiffNumDependentObjectsEnum;
+	      else if (strcmp(name,"AutodiffDependentObjectNames")==0) return AutodiffDependentObjectNamesEnum;
+	      else if (strcmp(name,"AutodiffDependentObjectTypes")==0) return AutodiffDependentObjectTypesEnum;
+	      else if (strcmp(name,"AutodiffDependentObjectIndices")==0) return AutodiffDependentObjectIndicesEnum;
+	      else if (strcmp(name,"AutodiffDependentObjects")==0) return AutodiffDependentObjectsEnum;
 	      else if (strcmp(name,"AutodiffNumIndependents")==0) return AutodiffNumIndependentsEnum;
+	      else if (strcmp(name,"AutodiffNumIndependentObjects")==0) return AutodiffNumIndependentObjectsEnum;
+	      else if (strcmp(name,"AutodiffIndependentObjectNames")==0) return AutodiffIndependentObjectNamesEnum;
+	      else if (strcmp(name,"AutodiffIndependentObjectTypes")==0) return AutodiffIndependentObjectTypesEnum;
+	      else if (strcmp(name,"AutodiffIndependentObjects")==0) return AutodiffIndependentObjectsEnum;
 	      else if (strcmp(name,"AutodiffJacobian")==0) return AutodiffJacobianEnum;
 	      else if (strcmp(name,"AutodiffXp")==0) return AutodiffXpEnum;
-	      else if (strcmp(name,"AutodiffFosForwardOutput")==0) return AutodiffFosForwardOutputEnum;
+	      else if (strcmp(name,"AutodiffDriver")==0) return AutodiffDriverEnum;
+	      else if (strcmp(name,"AutodiffFosForwardIndex")==0) return AutodiffFosForwardIndexEnum;
+	      else if (strcmp(name,"AutodiffFovForwardIndices")==0) return AutodiffFovForwardIndicesEnum;
+	      else if (strcmp(name,"AutodiffFosReverseIndex")==0) return AutodiffFosReverseIndexEnum;
+	      else if (strcmp(name,"AutodiffMassFluxSegmentsPresent")==0) return AutodiffMassFluxSegmentsPresentEnum;
+	      else if (strcmp(name,"AutodiffKeep")==0) return AutodiffKeepEnum;
 	      else if (strcmp(name,"BalancethicknessSpcthickness")==0) return BalancethicknessSpcthicknessEnum;
 	      else if (strcmp(name,"BalancethicknessStabilization")==0) return BalancethicknessStabilizationEnum;
 	      else if (strcmp(name,"BalancethicknessThickeningRate")==0) return BalancethicknessThickeningRateEnum;
@@ -36,6 +48,7 @@
 	      else if (strcmp(name,"ConstantsG")==0) return ConstantsGEnum;
 	      else if (strcmp(name,"ConstantsReferencetemperature")==0) return ConstantsReferencetemperatureEnum;
 	      else if (strcmp(name,"ConstantsYts")==0) return ConstantsYtsEnum;
+	      else if (strcmp(name,"DependentObject")==0) return DependentObjectEnum;
 	      else if (strcmp(name,"DiagnosticAbstol")==0) return DiagnosticAbstolEnum;
 	      else if (strcmp(name,"DiagnosticIcefront")==0) return DiagnosticIcefrontEnum;
 	      else if (strcmp(name,"DiagnosticIsnewton")==0) return DiagnosticIsnewtonEnum;
@@ -75,6 +88,7 @@
 	      else if (strcmp(name,"HydrologyQ")==0) return HydrologyQEnum;
 	      else if (strcmp(name,"HydrologySpcwatercolumn")==0) return HydrologySpcwatercolumnEnum;
 	      else if (strcmp(name,"HydrologyStabilization")==0) return HydrologyStabilizationEnum;
+	      else if (strcmp(name,"IndependentObject")==0) return IndependentObjectEnum;
 	      else if (strcmp(name,"InversionControlParameters")==0) return InversionControlParametersEnum;
 	      else if (strcmp(name,"InversionCostFunction")==0) return InversionCostFunctionEnum;
 	      else if (strcmp(name,"InversionCostFunctionThreshold")==0) return InversionCostFunctionThresholdEnum;
@@ -123,7 +137,10 @@
 	      else if (strcmp(name,"MeshAverageVertexConnectivity")==0) return MeshAverageVertexConnectivityEnum;
 	      else if (strcmp(name,"MeshDimension")==0) return MeshDimensionEnum;
 	      else if (strcmp(name,"MeshEdges")==0) return MeshEdgesEnum;
-	      else if (strcmp(name,"MeshElementconnectivity")==0) return MeshElementconnectivityEnum;
+         else stage=2;
+   }
+   if(stage==2){
+	      if (strcmp(name,"MeshElementconnectivity")==0) return MeshElementconnectivityEnum;
 	      else if (strcmp(name,"MeshElementonbed")==0) return MeshElementonbedEnum;
 	      else if (strcmp(name,"MeshElementonsurface")==0) return MeshElementonsurfaceEnum;
 	      else if (strcmp(name,"MeshElements2d")==0) return MeshElements2dEnum;
@@ -137,10 +154,7 @@
 	      else if (strcmp(name,"MeshNumberofvertices")==0) return MeshNumberofverticesEnum;
 	      else if (strcmp(name,"MeshUpperelements")==0) return MeshUpperelementsEnum;
 	      else if (strcmp(name,"MeshVertexonbed")==0) return MeshVertexonbedEnum;
-         else stage=2;
-   }
-   if(stage==2){
-	      if (strcmp(name,"MeshVertexonsurface")==0) return MeshVertexonsurfaceEnum;
+	      else if (strcmp(name,"MeshVertexonsurface")==0) return MeshVertexonsurfaceEnum;
 	      else if (strcmp(name,"MeshX")==0) return MeshXEnum;
 	      else if (strcmp(name,"MeshY")==0) return MeshYEnum;
 	      else if (strcmp(name,"MeshZ")==0) return MeshZEnum;
@@ -151,8 +165,12 @@
 	      else if (strcmp(name,"PrognosticSpcthickness")==0) return PrognosticSpcthicknessEnum;
 	      else if (strcmp(name,"PrognosticStabilization")==0) return PrognosticStabilizationEnum;
 	      else if (strcmp(name,"PrognosticVertexPairing")==0) return PrognosticVertexPairingEnum;
+	      else if (strcmp(name,"PrognosticNumRequestedOutputs")==0) return PrognosticNumRequestedOutputsEnum;
+	      else if (strcmp(name,"PrognosticRequestedOutputs")==0) return PrognosticRequestedOutputsEnum;
 	      else if (strcmp(name,"QmuIsdakota")==0) return QmuIsdakotaEnum;
-	      else if (strcmp(name,"QmuMassFluxSegments")==0) return QmuMassFluxSegmentsEnum;
+	      else if (strcmp(name,"MassFluxSegments")==0) return MassFluxSegmentsEnum;
+	      else if (strcmp(name,"MassFluxSegmentsPresent")==0) return MassFluxSegmentsPresentEnum;
+	      else if (strcmp(name,"QmuMassFluxSegmentsPresent")==0) return QmuMassFluxSegmentsPresentEnum;
 	      else if (strcmp(name,"QmuNumberofpartitions")==0) return QmuNumberofpartitionsEnum;
 	      else if (strcmp(name,"QmuNumberofresponses")==0) return QmuNumberofresponsesEnum;
 	      else if (strcmp(name,"QmuPartition")==0) return QmuPartitionEnum;
@@ -187,6 +205,8 @@
 	      else if (strcmp(name,"SurfaceforcingsIssmbgradients")==0) return SurfaceforcingsIssmbgradientsEnum;
 	      else if (strcmp(name,"SurfaceforcingsMonthlytemperatures")==0) return SurfaceforcingsMonthlytemperaturesEnum;
 	      else if (strcmp(name,"SurfaceforcingsHc")==0) return SurfaceforcingsHcEnum;
+	      else if (strcmp(name,"SurfaceforcingsHref")==0) return SurfaceforcingsHrefEnum;
+	      else if (strcmp(name,"SurfaceforcingsSmbref")==0) return SurfaceforcingsSmbrefEnum;
 	      else if (strcmp(name,"SurfaceforcingsSmbPosMax")==0) return SurfaceforcingsSmbPosMaxEnum;
 	      else if (strcmp(name,"SurfaceforcingsSmbPosMin")==0) return SurfaceforcingsSmbPosMinEnum;
 	      else if (strcmp(name,"SurfaceforcingsAPos")==0) return SurfaceforcingsAPosEnum;
@@ -240,7 +260,10 @@
 	      else if (strcmp(name,"PrognosticAnalysis")==0) return PrognosticAnalysisEnum;
 	      else if (strcmp(name,"PrognosticSolution")==0) return PrognosticSolutionEnum;
 	      else if (strcmp(name,"SteadystateSolution")==0) return SteadystateSolutionEnum;
-	      else if (strcmp(name,"SurfaceSlopeAnalysis")==0) return SurfaceSlopeAnalysisEnum;
+         else stage=3;
+   }
+   if(stage==3){
+	      if (strcmp(name,"SurfaceSlopeAnalysis")==0) return SurfaceSlopeAnalysisEnum;
 	      else if (strcmp(name,"SurfaceSlopeSolution")==0) return SurfaceSlopeSolutionEnum;
 	      else if (strcmp(name,"SurfaceSlopeXAnalysis")==0) return SurfaceSlopeXAnalysisEnum;
 	      else if (strcmp(name,"SurfaceSlopeYAnalysis")==0) return SurfaceSlopeYAnalysisEnum;
@@ -260,10 +283,7 @@
 	      else if (strcmp(name,"Constraints")==0) return ConstraintsEnum;
 	      else if (strcmp(name,"Loads")==0) return LoadsEnum;
 	      else if (strcmp(name,"Materials")==0) return MaterialsEnum;
-         else stage=3;
-   }
-   if(stage==3){
-	      if (strcmp(name,"Nodes")==0) return NodesEnum;
+	      else if (strcmp(name,"Nodes")==0) return NodesEnum;
 	      else if (strcmp(name,"Parameters")==0) return ParametersEnum;
 	      else if (strcmp(name,"Vertices")==0) return VerticesEnum;
 	      else if (strcmp(name,"Results")==0) return ResultsEnum;
@@ -276,6 +296,7 @@
 	      else if (strcmp(name,"DatasetInput")==0) return DatasetInputEnum;
 	      else if (strcmp(name,"DofIndexing")==0) return DofIndexingEnum;
 	      else if (strcmp(name,"DoubleInput")==0) return DoubleInputEnum;
+	      else if (strcmp(name,"DataSetParam")==0) return DataSetParamEnum;
 	      else if (strcmp(name,"DoubleMatArrayParam")==0) return DoubleMatArrayParamEnum;
 	      else if (strcmp(name,"DoubleMatParam")==0) return DoubleMatParamEnum;
 	      else if (strcmp(name,"DoubleParam")==0) return DoubleParamEnum;
@@ -305,6 +326,7 @@
 	      else if (strcmp(name,"Penpair")==0) return PenpairEnum;
 	      else if (strcmp(name,"Penta")==0) return PentaEnum;
 	      else if (strcmp(name,"PentaP1Input")==0) return PentaP1InputEnum;
+	      else if (strcmp(name,"Profiler")==0) return ProfilerEnum;
 	      else if (strcmp(name,"MatrixParam")==0) return MatrixParamEnum;
 	      else if (strcmp(name,"VectorParam")==0) return VectorParamEnum;
 	      else if (strcmp(name,"Riftfront")==0) return RiftfrontEnum;
@@ -361,7 +383,10 @@
 	      else if (strcmp(name,"SegmentOnIceShelf")==0) return SegmentOnIceShelfEnum;
 	      else if (strcmp(name,"SurfaceAbsVelMisfit")==0) return SurfaceAbsVelMisfitEnum;
 	      else if (strcmp(name,"SurfaceArea")==0) return SurfaceAreaEnum;
-	      else if (strcmp(name,"SurfaceAverageVelMisfit")==0) return SurfaceAverageVelMisfitEnum;
+         else stage=4;
+   }
+   if(stage==4){
+	      if (strcmp(name,"SurfaceAverageVelMisfit")==0) return SurfaceAverageVelMisfitEnum;
 	      else if (strcmp(name,"SurfaceLogVelMisfit")==0) return SurfaceLogVelMisfitEnum;
 	      else if (strcmp(name,"SurfaceLogVxVyMisfit")==0) return SurfaceLogVxVyMisfitEnum;
 	      else if (strcmp(name,"SurfaceRelVelMisfit")==0) return SurfaceRelVelMisfitEnum;
@@ -383,10 +408,7 @@
 	      else if (strcmp(name,"Vy")==0) return VyEnum;
 	      else if (strcmp(name,"VyPicard")==0) return VyPicardEnum;
 	      else if (strcmp(name,"Vz")==0) return VzEnum;
-         else stage=4;
-   }
-   if(stage==4){
-	      if (strcmp(name,"VzMacAyeal")==0) return VzMacAyealEnum;
+	      else if (strcmp(name,"VzMacAyeal")==0) return VzMacAyealEnum;
 	      else if (strcmp(name,"VzPattyn")==0) return VzPattynEnum;
 	      else if (strcmp(name,"VzPicard")==0) return VzPicardEnum;
 	      else if (strcmp(name,"VzStokes")==0) return VzStokesEnum;
@@ -476,13 +498,18 @@
 	      else if (strcmp(name,"Nodal")==0) return NodalEnum;
 	      else if (strcmp(name,"OldGradient")==0) return OldGradientEnum;
 	      else if (strcmp(name,"OutputFilePointer")==0) return OutputFilePointerEnum;
+	      else if (strcmp(name,"OutputFileName")==0) return OutputFileNameEnum;
+	      else if (strcmp(name,"LockFileName")==0) return LockFileNameEnum;
 	      else if (strcmp(name,"PetscOptionsAnalyses")==0) return PetscOptionsAnalysesEnum;
 	      else if (strcmp(name,"PetscOptionsStrings")==0) return PetscOptionsStringsEnum;
 	      else if (strcmp(name,"QmuErrName")==0) return QmuErrNameEnum;
 	      else if (strcmp(name,"QmuInName")==0) return QmuInNameEnum;
 	      else if (strcmp(name,"QmuOutName")==0) return QmuOutNameEnum;
 	      else if (strcmp(name,"Regular")==0) return RegularEnum;
-	      else if (strcmp(name,"Scaled")==0) return ScaledEnum;
+         else stage=5;
+   }
+   if(stage==5){
+	      if (strcmp(name,"Scaled")==0) return ScaledEnum;
 	      else if (strcmp(name,"Separate")==0) return SeparateEnum;
 	      else if (strcmp(name,"Sset")==0) return SsetEnum;
 	      else if (strcmp(name,"Verbose")==0) return VerboseEnum;
@@ -500,7 +527,7 @@
 	      else if (strcmp(name,"OptionLogical")==0) return OptionLogicalEnum;
 	      else if (strcmp(name,"Paterson")==0) return PatersonEnum;
 	      else if (strcmp(name,"Arrhenius")==0) return ArrheniusEnum;
-         else stage=5;
+         else stage=6;
    }
 	/*If we reach this point, the string provided has not been found*/
 	_error_("Enum " << name << " not found");

Modified: issm/trunk/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp
===================================================================
--- issm/trunk/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,14 +21,14 @@
 
 	/*Compute Misfit: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		J+=element->SurfaceAbsVelMisfit(process_units,weight_index);
 	}
 
 	/*Sum all J from all cpus of the cluster:*/
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
 	#endif
 

Modified: issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.cpp
===================================================================
--- issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 #include "../InputUpdateFromConstantx/InputUpdateFromConstantx.h"
 
 void SurfaceAreax( IssmDouble* pS, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters){
-	
+
 	/*Intermediary*/
 	Element* element=NULL;
 	int i;
@@ -19,17 +19,17 @@
 	/*output: */
 	IssmDouble S=0;
 	IssmDouble S_sum;
-	
+
 	/*Compute gradients: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		S+=element->SurfaceArea();
 	}
 
 	/*Sum all J from all cpus of the cluster:*/
 	#ifdef _HAVE_MPI_
- 	MPI_Reduce (&S,&S_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&S_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 
+ 	MPI_Reduce (&S,&S_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&S_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 
 	S=S_sum;
 	#endif
 

Modified: issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.h
===================================================================
--- issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/SurfaceAreax/SurfaceAreax.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,4 +12,3 @@
 void SurfaceAreax( IssmDouble* pS, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters);
 
 #endif  /* _SURFACEAREAX_H */
-

Modified: issm/trunk/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp
===================================================================
--- issm/trunk/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,14 +25,14 @@
 
 	/*Compute Misfit: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		J+=element->SurfaceAverageVelMisfit(process_units,weight_index);
 	}
 
 	/*Sum all J from all cpus of the cluster:*/
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
 	#endif
 

Modified: issm/trunk/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp
===================================================================
--- issm/trunk/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,14 +21,14 @@
 
 	/*Compute Misfit: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		J+=element->SurfaceLogVelMisfit(process_units,weight_index);
 	}
 
 	/*Sum all J from all cpus of the cluster:*/
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
 	#endif
 

Modified: issm/trunk/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp
===================================================================
--- issm/trunk/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,14 +21,14 @@
 
 	/*Compute Misfit: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		J+=element->SurfaceLogVxVyMisfit(process_units,weight_index);
 	}
 
 	/*Sum all J from all cpus of the cluster:*/
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
 	#endif
 

Modified: issm/trunk/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp
===================================================================
--- issm/trunk/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,14 +21,14 @@
 
 	/*Compute Misfit: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		J+=element->SurfaceRelVelMisfit(process_units,weight_index);
 	}
 
 	/*Sum all J from all cpus of the cluster:*/
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
 	#endif
 

Modified: issm/trunk/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp
===================================================================
--- issm/trunk/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,14 +21,14 @@
 
 	/*Compute Misfit: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		J+=element->ThicknessAbsMisfit(process_units,weight_index);
 	}
 
 	/*Sum all J from all cpus of the cluster:*/
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
 	#endif
 

Modified: issm/trunk/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp
===================================================================
--- issm/trunk/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,14 +21,14 @@
 
 	/*Compute Misfit: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		J+=element->ThicknessAcrossGradient(process_units,weight_index);
 	}
 
 	/*Sum all J from all cpus of the cluster:*/
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
 	#endif
 

Modified: issm/trunk/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp
===================================================================
--- issm/trunk/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,14 +21,14 @@
 
 	/*Compute Misfit: */
 	for (i=0;i<elements->Size();i++){
-		element=(Element*)elements->GetObjectByOffset(i);
+		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
 		J+=element->ThicknessAlongGradient(process_units,weight_index);
 	}
 
 	/*Sum all J from all cpus of the cluster:*/
 	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
+	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
 	#endif
 

Modified: issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp
===================================================================
--- issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/TriMeshx/TriMeshx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,17 +10,22 @@
 #include "../../toolkits/toolkits.h"
 #include "../../EnumDefinitions/EnumDefinitions.h"
 /*ANSI_DECLARATORS needed to call triangle library: */
-#ifndef ANSI_DECLARATORS
-#define ANSI_DECLARATORS
-#include "triangle.h"
-#undef ANSI_DECLARATORS
-#else
-#include "triangle.h"
+#if defined(_HAVE_TRIANGLE_)
+	#ifndef ANSI_DECLARATORS
+	#define ANSI_DECLARATORS
+	#include "triangle.h"
+	#undef ANSI_DECLARATORS
+	#else
+	#include "triangle.h"
+	#endif
 #endif
 /*}}}*/
 
 void TriMeshx(SeqMat<IssmPDouble>** pindex,SeqVec<IssmPDouble>** px,SeqVec<IssmPDouble>** py,SeqMat<IssmPDouble>** psegments,SeqVec<IssmPDouble>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){
 
+#if !defined(_HAVE_TRIANGLE_)
+	_error_("triangle has not been installed");
+#else
 	/*indexing: */
 	int i,j;
 
@@ -75,11 +80,11 @@
 			counter++;
 		}
 	}
-	
+
 	/*fill in the point attribute list: */
 	in.pointattributelist = xNew<REAL>(in.numberofpoints*in.numberofpointattributes);
 	for (i=0;i<in.numberofpoints;i++) in.pointattributelist[i] = 0.0;
-	
+
 	/*fill in the point marker list: */
 	in.pointmarkerlist = xNew<int>(in.numberofpoints);
 	for(i=0;i<in.numberofpoints;i++) in.pointmarkerlist[i] = 0;
@@ -95,7 +100,7 @@
 		/*for rifts, we have one less segment as we have vertices*/
 		in.numberofsegments+=contour->nods-1;
 	}
-	
+
 	in.segmentlist = xNew<int>(in.numberofsegments*2);
 	in.segmentmarkerlist = xNewZeroInit<int>(in.numberofsegments);
 	counter=0;
@@ -127,7 +132,7 @@
 		}
 		counter++;
 	}
-	
+
 	/*Build regions: */
 	in.numberofregions = 0;
 
@@ -193,11 +198,12 @@
 	/*Output : */
 	index_matrix=new SeqMat<IssmPDouble>(index,out.numberoftriangles,3,1.0);
 	*pindex=index_matrix;
-	
+
 	segments_matrix=new SeqMat<IssmPDouble>(segments,out.numberofsegments,3,1.0);
 	*psegments=segments_matrix;
 
 	*px=new SeqVec<IssmPDouble>(x,out.numberofpoints);
 	*py=new SeqVec<IssmPDouble>(y,out.numberofpoints);
 	*psegmentmarkerlist=new SeqVec<IssmPDouble>(segmentmarkerlist,out.numberofsegments);
+#endif
 }

Modified: issm/trunk/src/c/modules/TriMeshx/TriMeshx.h
===================================================================
--- issm/trunk/src/c/modules/TriMeshx/TriMeshx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/TriMeshx/TriMeshx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,7 @@
 #ifndef _TRIMESHX_H_
 #define _TRIMESHX_H_
 
-#include "string.h"
+#include <string.h>
 #include "../../Container/Container.h"
 #include "../../classes/objects/objects.h"
 

Modified: issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.cpp
===================================================================
--- issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/TriaSearchx/TriaSearchx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -23,15 +23,10 @@
 	/*Intermediary*/
 	R2     r;
 	I2     I;
-	int    i,j,k;
-	int    i0,i1,i2;
-	double areacoord[3];
-	double aa,bb;
-	double data_value;
+	int    i;
 	Icoor2 dete[3];
-	int verbose=0;
 
-	// read background mesh 
+	/* read background mesh */
 	Mesh Th(index,x,y,nods,nel); 
 	Th.CreateSingleVertexToTriangleConnectivity();
 
@@ -39,7 +34,7 @@
 
 		//Get current point coordinates
 		r.x=x0[i]; r.y=y0[i];
-		
+
 		I=Th.R2ToI2(r);
 
 		//Find triangle holding r/I

Modified: issm/trunk/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp
===================================================================
--- issm/trunk/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
 void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vector<IssmDouble>* yg){
-	
+
 	int configuration_type;
 	IssmDouble* yg_serial=NULL;
 

Modified: issm/trunk/src/c/modules/VecMergex/VecMergex.cpp
===================================================================
--- issm/trunk/src/c/modules/VecMergex/VecMergex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/VecMergex/VecMergex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,11 +17,10 @@
 
 	/*retrieve parameters: */
 	parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
-	
+
 	/*serialize uf: */
 	uf_serial=uf->ToMPISerial();
 
-
 	/*Do we have any nodes for this configuration? :*/
 	if(nodes->NumberOfNodes(configuration_type)){ 
 

Modified: issm/trunk/src/c/modules/VerticesDofx/VerticesDofx.cpp
===================================================================
--- issm/trunk/src/c/modules/VerticesDofx/VerticesDofx.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/VerticesDofx/VerticesDofx.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,24 +10,18 @@
 
 void VerticesDofx( Vertices* vertices, Parameters* parameters) {
 
-	int i;
-
-	int  found=0;
-	extern int num_procs;
-	extern int my_rank;
-	
 	/*intermediary: */
 	int  numberofvertices;
 
 	/*figure out how many vertices we have: */
 	numberofvertices=vertices->NumberOfVertices();
 
-	/*Ensure that only for each cpu, the partition border vertices only will be taken into account once 
-	 * across the cluster. To do so, we flag all the clone vertices: */
+	/*Ensure that only for each cpu, the partition border vertices only will be
+	 * taken into account once across the cluster. To do so, we flag all the
+	 * clone vertices: */
 	vertices->FlagClones(numberofvertices);
 
-	/*Go through all vertices and distribute 1 dof at a time. When a  vertex has already been distributed his dof on a cpu, 
-	 * all other cpus with the same vertex cannot distribute it anymore. Use clone field to be sure of that: */
-	vertices->DistributeDofs(numberofvertices,1); //only 1 dof per vertex.
+	/*Go through all vertices and distribute pids*/
+	vertices->DistributePids(numberofvertices); 
 
 }

Modified: issm/trunk/src/c/modules/VerticesDofx/VerticesDofx.h
===================================================================
--- issm/trunk/src/c/modules/VerticesDofx/VerticesDofx.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/VerticesDofx/VerticesDofx.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,4 +12,3 @@
 void VerticesDofx( Vertices* vertices, Parameters* parameters);
 
 #endif  /* _VERTICESDOFX_H */
-

Modified: issm/trunk/src/c/modules/modules.h
===================================================================
--- issm/trunk/src/c/modules/modules.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/modules/modules.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,8 +6,6 @@
 #define _ISSM_MODULES_H_
 
 /*Modules: */
-#include "./AddExternalResultx/AddExternalResultx.h"
-#include "./AutodiffDriversx/AutodiffDriversx.h"
 #include "./AverageFilterx/AverageFilterx.h"
 #include "./AverageOntoPartitionx/AverageOntoPartitionx.h"
 #include "./Bamgx/Bamgx.h"
@@ -22,9 +20,7 @@
 #include "./ControlInputGetGradientx/ControlInputGetGradientx.h"
 #include "./ControlInputSetGradientx/ControlInputSetGradientx.h"
 #include "./ControlInputScaleGradientx/ControlInputScaleGradientx.h"
-#include "./CostFunctionx/CostFunctionx.h"
 #include "./CreateNodalConstraintsx/CreateNodalConstraintsx.h"
-#include "./DakotaResponsesx/DakotaResponsesx.h"
 #include "./Delta18oParameterizationx/Delta18oParameterizationx.h"
 #include "./DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.h"
 #include "./ElementConnectivityx/ElementConnectivityx.h"
@@ -37,8 +33,6 @@
 #include "./Gradjx/Gradjx.h"
 #include "./GroundinglineMigrationx/GroundinglineMigrationx.h"
 #include "./HoleFillerx/HoleFillerx.h"
-#include "./TotalSmbx/TotalSmbx.h"
-#include "./IceVolumex/IceVolumex.h"
 #include "./InputControlUpdatex/InputControlUpdatex.h"
 #include "./InputConvergencex/InputConvergencex.h"
 #include "./InputDuplicatex/InputDuplicatex.h"
@@ -66,22 +60,9 @@
 #include "./Kml2Expx/Kml2Expx.h"
 #include "./Krigingx/Krigingx.h"
 #include "./Shp2Kmlx/Shp2Kmlx.h"
-#include "./MassFluxx/MassFluxx.h"
-#include "./MaxAbsVxx/MaxAbsVxx.h"
-#include "./MaxAbsVyx/MaxAbsVyx.h"
-#include "./MaxAbsVzx/MaxAbsVzx.h"
-#include "./MaxVelx/MaxVelx.h"
-#include "./ElementResponsex/ElementResponsex.h"
-#include "./MaxVxx/MaxVxx.h"
-#include "./MaxVyx/MaxVyx.h"
-#include "./MaxVzx/MaxVzx.h"
 #include "./Mergesolutionfromftogx/Mergesolutionfromftogx.h"
 #include "./MeshPartitionx/MeshPartitionx.h"
 #include "./MeshProfileIntersectionx/MeshProfileIntersectionx.h"
-#include "./MinVelx/MinVelx.h"
-#include "./MinVxx/MinVxx.h"
-#include "./MinVyx/MinVyx.h"
-#include "./MinVzx/MinVzx.h"
 #include "./SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.h"
 #include "./SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.h"
 #include "./SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.h"
@@ -98,32 +79,23 @@
 #include "./PointCloudFindNeighborsx/PointCloudFindNeighborsx.h"
 #include "./PositiveDegreeDayx/PositiveDegreeDayx.h"
 #include "./PropagateFlagsFromConnectivityx/PropagateFlagsFromConnectivityx.h"
-#include "./Dakotax/Dakotax.h"
 #include "./Reduceloadx/Reduceloadx.h"
 #include "./Reducevectorgtosx/Reducevectorgtosx.h"
 #include "./Reducevectorgtofx/Reducevectorgtofx.h"
-#include "./RequestedOutputsx/RequestedOutputsx.h"
-#include "./RequestedDependentsx/RequestedDependentsx.h"
 #include "./ResetConstraintsx/ResetConstraintsx.h"
 #include "./ResetCoordinateSystemx/ResetCoordinateSystemx.h"
-#include "./Responsex/Responsex.h"
 #include "./RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h"
 #include "./Scotchx/Scotchx.h"
 #include "./SmbGradientsx/SmbGradientsx.h"
 #include "./Solverx/Solverx.h"
 #include "./SpcNodesx/SpcNodesx.h"
 #include "./SurfaceAreax/SurfaceAreax.h"
-#include "./SystemMatricesx/SystemMatricesx.h"
-#include "./CreateJacobianMatrixx/CreateJacobianMatrixx.h"
-#include "./TimeAdaptx/TimeAdaptx.h"
 #include "./TriaSearchx/TriaSearchx.h"
 #include "./TriMeshx/TriMeshx.h"
+#include "./TriMeshProcessRiftsx/TriMeshProcessRiftsx.h"
 #include "./ThicknessAbsMisfitx/ThicknessAbsMisfitx.h"
-#include "./ThicknessAbsGradientx/ThicknessAbsGradientx.h"
 #include "./ThicknessAlongGradientx/ThicknessAlongGradientx.h"
 #include "./ThicknessAcrossGradientx/ThicknessAcrossGradientx.h"
-#include "./UpdateVertexPositionsx/UpdateVertexPositionsx.h"
-#include "./UpdateConstraintsx/UpdateConstraintsx.h"
 #include "./UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.h"
 #include "./VerticesDofx/VerticesDofx.h"
 #include "./VecMergex/VecMergex.h"

Modified: issm/trunk/src/c/shared/Alloc/alloc.cpp
===================================================================
--- issm/trunk/src/c/shared/Alloc/alloc.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Alloc/alloc.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,6 @@
  * the allocation routines described here do not work.
  */
 
-
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -27,7 +26,7 @@
 #include "../../classes/objects/objects.h"
 
 void xdelete(Matrix<IssmDouble>** pv){
-	
+
 	if (pv && *pv){
 		/*There is no mxDelete in the Matlab API -> using delete trips up Matlab. So we 
 		 * don't actually free memory in Matlab, we let the memory manager do that. We only

Modified: issm/trunk/src/c/shared/Alloc/xNewDelete.h
===================================================================
--- issm/trunk/src/c/shared/Alloc/xNewDelete.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Alloc/xNewDelete.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -7,12 +7,11 @@
 
 #include <cassert>
 
-
 // memory management of types 
 // T with non-trivial constructors require 
 // C++ style memory management
 #define USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
-// but for speed on may alternatively use C memory managment
+// but for speed on may alternatively use C memory management
 // but can do so safely only for T that are at most 
 // plain old data structures (POD)
 #ifndef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
@@ -72,6 +71,26 @@
 }
 
 template <class T>
+T** xNewZeroInit(unsigned int dim1, unsigned int dim2) {
+#ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
+  T** aT_pp=xNew<T>(dim1,dim2);
+  for (unsigned int i=0; i<dim1*dim2;++i)
+    (*aT_pp)[i]=(T)0;
+  return aT_pp;
+#else
+  T* buf=(T*)calloc(dim1*dim2*sizeof(T));
+  assert(buf );
+  T** aT_pp =(T**)malloc(dim1*sizeof(T*));
+  assert(aT_pp );
+  for (unsigned int i=0;i<dim1;++i) {
+    aT_pp [i]=buf;
+    buf+=dim2;
+  }
+  return aT_pp ;
+#endif
+}
+
+template <class T>
 void xDelete(T**& aT_pp) {
   if (aT_pp) {
 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
@@ -133,4 +152,3 @@
 }
 
 #endif
-

Modified: issm/trunk/src/c/shared/Bamg/shared.h
===================================================================
--- issm/trunk/src/c/shared/Bamg/shared.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Bamg/shared.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief: header file for all shared  routines.
  */
 
-
 #ifndef _SHAREDBamg_H_
 #define _SHAREDBamg_H_
 

Modified: issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp
===================================================================
--- issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,7 +9,6 @@
 	int* ndof_list=NULL;
 	int *doflist = NULL;
 
-
 	if(numnodes){
 
 		/*Allocate:*/

Modified: issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp
===================================================================
--- issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,7 +15,6 @@
 		ndof_list=xNew<int>(numnodes);
 		ngdof_list_cumulative=xNew<int>(numnodes);
 
-
 		/*Get number of dofs per node, and total for this given set*/
 		numdof=0;
 		numgdof=0;

Modified: issm/trunk/src/c/shared/Elements/Paterson.cpp
===================================================================
--- issm/trunk/src/c/shared/Elements/Paterson.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Elements/Paterson.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,7 +9,7 @@
 #include "../../include/include.h"
 
 IssmDouble Paterson(IssmDouble temperature){
-	
+
 	/*output: */
 	IssmDouble B;
 	IssmDouble T;
@@ -29,7 +29,6 @@
 //	% fittedmodel=fit(Temp,B,'cubicspline');
 //	% B=fittedmodel(temperature);
 
-
 	if(T<=-45.0){
 		B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.000292866376675*pow(T+50,3)+ 0.011672640664130*pow(T+50,2)  -0.325004442485481*(T+50)+  6.524779401948101);
 	}
@@ -60,7 +59,7 @@
 	else if((T>=-5.0) && (T<=-2.0)){
 		B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.003748937622487*pow(T+5,3)+0.015290593619213*pow(T+5,2)  -0.048160403003748*(T+5)+  0.854987973338348);
 	}
-	else if(T>=-2.0){
+	else{
 		B=pow((IssmPDouble)10,(IssmPDouble)8)*(-0.003748937622488*pow(T+2,3)-0.018449844983174*pow(T+2,2)  -0.057638157095631*(T+2)+  0.746900791092860);
 	}
 
@@ -69,6 +68,3 @@
 
 	return B;
 }
-
-
-

Modified: issm/trunk/src/c/shared/Elements/PddSurfaceMassBalance.cpp
===================================================================
--- issm/trunk/src/c/shared/Elements/PddSurfaceMassBalance.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Elements/PddSurfaceMassBalance.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,8 +9,8 @@
   // output:
   IssmDouble B;    // surface mass balance, melt+accumulation
 
-  int    iqj,imonth, j;
-  
+  int    iqj,imonth;
+
   IssmDouble saccu;     // yearly surface accumulation
   IssmDouble smelt;     // yearly melt
   IssmDouble precrunoff;      // yearly runoff
@@ -18,15 +18,14 @@
   IssmDouble water; //water=rain + snowmelt 
   IssmDouble runoff; //meltwater only, does not include rain 
   IssmDouble sconv; //rhow_rain/rhoi / 12 months
-  
-  IssmDouble density;
+
   IssmDouble lapser=6.5/1000., sealev=0.;    // lapse rate. degrees per meter. 7.5 lev's 99 paper, 9 Marshall 99 paper
   IssmDouble desfac = 0.5;                 // desert elevation factor
   IssmDouble s0p=0.;         // should be set to elevation from precip source
   IssmDouble s0t=0.;         // should be set to elevation from temperature source
   IssmDouble st;             // elevation between altitude of the temp record and current altitude
   IssmDouble sp;             // elevation between altitude of the prec record and current altitude
-  
+
   // PDD and PD constants and variables
   IssmDouble siglim;          // sigma limit for the integration which is equal to 2.5 sigmanorm
   IssmDouble signormc = signorm - 0.5;     // sigma of the temperature distribution for cloudy day
@@ -34,31 +33,30 @@
   IssmDouble PDup, pddsig, PDCUT = 2.0; // PDcut: rain/snow cutoff temperature (C)
   IssmDouble DT = 0.02;
   IssmDouble pddt, pd; // pd: snow/precip fraction, precipitation falling as snow
-  
+
   IssmDouble q, qmpt; // q is desert/elev. fact, hnpfac is huybrect fact, and pd is normal dist.
   IssmDouble qm = 0.;        // snow part of the precipitation 
   IssmDouble qmt = 0.;       // precipitation without desertification effect adjustment
   IssmDouble qmp = 0.;       // desertification taken into account
   IssmDouble pdd = 0.;     
   IssmDouble frzndd = 0.;  
-  
+
   IssmDouble tstar;          // monthly mean surface temp
   IssmDouble Tsum= 0.;       // average summer (JJA) temperature
   IssmDouble Tsurf = 0.;     // average annual temperature    
-  
 
   IssmDouble deltm=1./12.;
   int    ismon[12]={11,0,1,2,3,4,5,6,7,8,9,10};
-  
+
   IssmDouble snwm;  // snow that could have been melted in a year.
   IssmDouble snwmf; //  ablation factor for snow per positive degree day.
   IssmDouble smf;   //  ablation factor for ice per pdd (Braithwaite 1995 from tarasov 2002).
-  
+
   IssmDouble dfrz=1.5, CovrLm=2009./3.35e+5, dCovrLm=dfrz*CovrLm; //m*J kg^-1 C^-1 /(J kg^-1)=m/C yr
   IssmDouble supice,supcap,diffndd;
   IssmDouble fsupT=0.5,  fsupndd=0.5;  // Tsurf mode factors for supice
   IssmDouble pddtj, hmx2;
-  
+
   sconv=(rho_water/rho_ice)/12.; //rhow_rain/rhoi / 12 months
 
   /*PDD constant*/
@@ -67,32 +65,32 @@
   siglim0 = siglim/DT + 0.5;
   siglim0c = siglimc/DT + 0.5;
   PDup = siglimc+PDCUT;
-  
+
   // seasonal loop
     for (iqj = 0; iqj < 12; iqj++){
       imonth =  ismon[iqj];
-  
+
       st=(s-s0t)/1000.;
       tstar = monthlytemperatures[imonth] - lapser *max(st,sealev);
       Tsurf = tstar*deltm+Tsurf;        
-      
+
       /*********compute PD ****************/
       if (tstar < PDup){
 	pd = 1.;
 	if (tstar >= -siglimc){ pd = pds[reCast<int,IssmDouble>(tstar/DT + siglim0c)];}}
       else { 
 	pd = 0.;}
-      
+
       /******exp des/elev precip reduction*******/
       sp=(s-s0p)/1000.; // deselev effect is wrt chng in topo
       if (sp>0.0){q = exp(-desfac*sp);}
       else {q = 1.0;}
-      
+
       qmt= qmt + monthlyprec[imonth]*sconv;  //*sconv to convert in m of ice equivalent per month
       qmpt= q*monthlyprec[imonth]*sconv;           
       qmp= qmp + qmpt;
       qm= qm + qmpt*pd;
-      
+
       /*********compute PDD************/
       // ndd(month)=-(tstar-pdd(month)) since ndd+pdd gives expectation of
       // gaussian=T_m, so ndd=-(Tsurf-pdd)
@@ -104,12 +102,12 @@
 	frzndd = frzndd - (tstar-pddsig)*deltm;}
       else{frzndd = frzndd - tstar*deltm; }
   } // end of seasonal loop 
-  
+
   //******************************************************************
     saccu = qm;
     prect = qmp;     // total precipitation during 1 year taking into account des. ef.
     Tsum=Tsum/3;
-    
+
     /***** determine PDD factors *****/
     if(Tsum< -1.) {
       snwmf=2.65*0.001;   //  ablation factor for snow per positive degree day.*0.001 to go from mm to m/ppd
@@ -125,12 +123,12 @@
     }
     snwmf=0.95*snwmf;
     smf=0.95*smf;
-    
+
     /*****  compute PDD ablation and refreezing *****/
     pddt = pdd *365;
     snwm = snwmf*pddt;       // snow that could have been melted in a year
     hmx2 = min(h,dfrz);   // refreeze active layer max depth: dfrz
-    
+
     if(snwm < saccu) {
       water=prect-saccu + snwm; //water=rain + snowmelt
       //     l 2.2= capillary factor
@@ -146,9 +144,9 @@
       //     going to
       //     hold the meltwater around for refreezing? And melt-time will have
       //     low seasonal frzndd
-      
+
       //      Superimposed ice :  Pfeffer et al. 1991, Tarasov 2002
-      
+
       supice= min(hmx2*CovrLm*frzndd+2.2*(saccu-snwm), water); // superimposed ice
       supcap=min(2.2*(saccu-snwm),water);
       runoff=snwm - supice;  //meltwater only, does not include rain
@@ -171,7 +169,7 @@
     //     1 dm supice should not raise Tsurf by 1/dCovrLm = 16.675C
     //     does supice make sense when H< 0.1m? then d=thermoactive ice layer ////
     //     < 0.1 
-    
+
     //     make more sense to just use residual pdd-ndd except that pdd
     //     residual not clear yet
     //     frzndd should not be used up by refreezing in snow, so stick in
@@ -196,10 +194,10 @@
     //yet from site plots, can be ice free with Tsurf=-5.5C
     if(Tsurf<0) {
       Tsurf= min(Tsurf+fsupT*diffndd , 0.);}
-    
+
     B = -smelt+saccu;
     B = B/yts;
     pddtj=pddt;
-  
+
   return B;
 }

Modified: issm/trunk/src/c/shared/Elements/PrintArrays.cpp
===================================================================
--- issm/trunk/src/c/shared/Elements/PrintArrays.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Elements/PrintArrays.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,6 +12,23 @@
 	}  
 	_printLine_("");
 }
+void printsparsity(IssmPDouble* array,int lines,int cols){
+	int count;
+	_printLine_("");
+	for(int i=0;i<lines;i++){  
+		_printString_("   [ ");
+		count = 0;
+		for(int j=0;j<cols;j++){
+			if(array[i*cols+j]!=0.0){
+				_printString_( " X"); count++;
+			}
+			else
+			 _printString_( " .");
+		}
+		_printLine_(" ] "<<i<<" => "<<count);
+	}  
+	_printLine_("");
+}
 void printarray(int* array,int lines,int cols){
 	_printLine_("");
 	for(int i=0;i<lines;i++){  

Modified: issm/trunk/src/c/shared/Elements/TransformLoadVectorCoord.cpp
===================================================================
--- issm/trunk/src/c/shared/Elements/TransformLoadVectorCoord.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Elements/TransformLoadVectorCoord.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,7 +19,7 @@
 
 void TransformLoadVectorCoord(ElementVector* pe,Node** nodes,int numnodes,int* cs_array){
 
-	int     i,j;
+	int     i;
 	int     numdofs   = 0;
 	IssmDouble *transform = NULL;
 	IssmDouble *values    = NULL;

Modified: issm/trunk/src/c/shared/Elements/TransformSolutionCoord.cpp
===================================================================
--- issm/trunk/src/c/shared/Elements/TransformSolutionCoord.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Elements/TransformSolutionCoord.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,7 +20,7 @@
 
 void TransformSolutionCoord(IssmDouble* solution,Node** nodes,int numnodes,int* cs_array){
 
-	int     i,j;
+	int     i;
 	int     numdofs   = 0;
 	IssmDouble *transform = NULL;
 	IssmDouble *values    = NULL;

Modified: issm/trunk/src/c/shared/Elements/elements.h
===================================================================
--- issm/trunk/src/c/shared/Elements/elements.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Elements/elements.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -39,5 +39,6 @@
 /*Print arrays*/
 void printarray(IssmPDouble* array,int lines,int cols=1);
 void printarray(int* array,int lines,int cols=1);
+void printsparsity(IssmPDouble* array,int lines,int cols=1);
 void printbinary(int n);
 #endif //ifndef _SHARED_ELEMENTS_H_

Modified: issm/trunk/src/c/shared/Exceptions/Exceptions.cpp
===================================================================
--- issm/trunk/src/c/shared/Exceptions/Exceptions.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Exceptions/Exceptions.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,49 +11,78 @@
 #include "../shared.h"
 #include "../../include/include.h"
 
-ErrorException::ErrorException(const string &what_arg){
+ErrorException::ErrorException(const string &what_arg){/*{{{*/
 
 	what_str=what_arg;
 	file_name="";
 	function_name="";
 	file_line=0;
-}
+}/*}}}*/
+ErrorException::ErrorException(const string& what_file, const string& what_function,int what_line, const string& what_arg){/*{{{*/
 
-ErrorException::ErrorException(const string& what_file, const string& what_function,int what_line, const string& what_arg){
-
 	what_str=what_arg;
 	file_name=what_file;
 	function_name=what_function;
 	file_line=what_line;
-}
+}/*}}}*/
+ErrorException::~ErrorException() throw(){/*{{{*/
+}/*}}}*/
+const char* ErrorException::what() const throw(){/*{{{*/
+	return what_str.c_str();
+}/*}}}*/
+void ErrorException::Report() const{/*{{{*/
 
-ErrorException::~ErrorException() throw(){
-	extern int num_procs;
-	/*We want the report only for matlab modules, otherwise we get twice the report
-	 * We assume that if num_procs==1, it is a module (FIXME)*/
-	if(num_procs==1) this->Report();
-}
+	int my_rank;
+	int num_procs;
 
-const char* ErrorException::what() const throw(){
-	return what_str.c_str();
-}
+	/*recover my_rank and num_procs:*/
+	my_rank=IssmComm::GetRank();
+	num_procs=IssmComm::GetSize();
 
-void ErrorException::Report() const{
-	extern int my_rank;
-	extern int num_procs;
-
 	if (function_name=="" || file_line==0){ //WINDOWS
 		_printString_("Error message: " << what());
 	}
 	else{
 		if(num_procs==1){
-			_printLine_("\n??? Error using ==> " << file_name.c_str() << ":" << file_line);
+			_printLine_("\n??? Error in ==> " << file_name.c_str() << ":" << file_line);
 			_printLine_(function_name.c_str() << " error message: " << what() << "\n");
 		}
 		else{
-			_printLine_("\n[" << my_rank << "] ??? Error using ==> " << file_name.c_str() << ":" << file_line);
-			_printLine_("[" << my_rank << "] " << function_name.c_str() << " error message: " << what() << "\n");
+			_printLine_("\n[" << my_rank<< "] ??? Error using ==> " << file_name.c_str() << ":" << file_line);
+			_printLine_(  "[" << my_rank << "] " << function_name.c_str() << " error message: " << what() << "\n");
 		}
 	}
 	return;
-}
+}/*}}}*/
+const char* ErrorException::MatlabReport() const{/*{{{*/
+
+	/*Output*/
+	std::ostringstream buffer;
+
+	if (this->file_line==0){ //WINDOWS
+		 buffer << " error message: " << (this->what_str).c_str();
+	}
+	else{
+		buffer << "\nError in ==> " << (this->file_name).c_str() << ":" << file_line << "\n";
+		buffer << (this->function_name).c_str() << " error message: " << (this->what_str).c_str();
+	}
+
+	const string buffer2 = buffer.str();
+	return buffer2.c_str();
+}/*}}}*/
+const char* ErrorException::PythonReport() const{/*{{{*/
+
+	/*Output*/
+	std::ostringstream buffer;
+
+	if (this->file_line==0){ //WINDOWS
+		buffer << " error message: " << (this->what_str).c_str();
+	}
+	else{
+		buffer << "\nError in ==> " << (this->file_name).c_str() << ":" << file_line << "\n";
+		buffer << (this->function_name).c_str() << " error message: " << (this->what_str).c_str();
+	}
+
+	const string buffer2 = buffer.str();
+	return buffer2.c_str();
+}/*}}}*/

Modified: issm/trunk/src/c/shared/Exceptions/exceptions.h
===================================================================
--- issm/trunk/src/c/shared/Exceptions/exceptions.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Exceptions/exceptions.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,7 +15,7 @@
 
 /*We derive our classes from the c++ exception class: */
 class ErrorException: public exception {
-	
+
 	string   what_str;
 	string   function_name;
 	string   file_name;
@@ -27,6 +27,8 @@
 	~ErrorException() throw();
 	virtual const char *what() const throw();
 	void Report() const;
+	const char* MatlabReport() const;
+	const char* PythonReport() const;
 
 };
 

Modified: issm/trunk/src/c/shared/Exceptions/exprintf.cpp
===================================================================
--- issm/trunk/src/c/shared/Exceptions/exprintf.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Exceptions/exprintf.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,6 @@
  * ErrorException(exprintf("%s%i\n","test failed for id:",id));
  */ 
 
-
 #include <stdarg.h>
 #include <stdio.h>
 #include "../Alloc/xNewDelete.h"
@@ -16,7 +15,6 @@
 	/*returned string: */
 	char *buffer = NULL;
 	int   n,size = 100;
-	int   string_size;
 
 	//variable list of arguments
 	va_list args;

Modified: issm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp
===================================================================
--- issm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Exp/DomainOutlineWrite.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 #include "../Exceptions/exceptions.h"
 
 int DomainOutlineWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,bool* closed,char* domainname){
-	
+
 	/*Error management: */
 	int noerr=1;
 	int i,counter;
@@ -32,10 +32,10 @@
 		fprintf(fid,"%s %s\n","##","Name:");
 		fprintf(fid,"%s %s\n","##","Icon:0");
 		fprintf(fid,"%s %s %s %s\n","#","Points","Count","Value");
-		
+
 		/*Write number of profile vertices: */
 		fprintf(fid,"%u %s\n",profnvertices[counter]  ,"1.");
-	
+
 		/*Write next line: */
 		fprintf(fid,"%s %s %s %s %s\n","#","X","pos","Y","pos");
 

Modified: issm/trunk/src/c/shared/Exp/IsInPoly.cpp
===================================================================
--- issm/trunk/src/c/shared/Exp/IsInPoly.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Exp/IsInPoly.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,7 +17,7 @@
 int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue) {
 	int i, j, c = 0;
 	double n1, n2, normp, scalar;
-	
+
 	/*first test, are they colinear? if yes, is the point in the middle of the segment*/
 	if (edgevalue != 2 ){
 		for (i = 0, j = npol-1; i < npol; j = i++) {

Modified: issm/trunk/src/c/shared/Exp/IsInPolySerial.cpp
===================================================================
--- issm/trunk/src/c/shared/Exp/IsInPolySerial.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Exp/IsInPolySerial.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,17 +4,14 @@
 
 #include <math.h>
 
-
 #include "./exp.h"
 
-
 int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue){
 
-	int i,j;
 	double x0,y0;
 
 	/*Go through all vertices of the mesh:*/
-	for (i=0;i<nods;i++){
+	for(int i=0;i<nods;i++){
 		if (in[i]){
 			/*this vertex already is inside one of the contours, continue*/
 			continue;

Modified: issm/trunk/src/c/shared/Exp/exp.h
===================================================================
--- issm/trunk/src/c/shared/Exp/exp.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Exp/exp.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -59,7 +59,7 @@
 /*DomainOutlineRead{{{*/
 template <class doubletype>
 int DomainOutlineRead(int* pnprof,int** pprofnvertices,doubletype*** ppprofx,doubletype*** ppprofy,bool** pclosed,char* domainname){
-	
+
 	/*indexing: */
 	int i,counter;
 
@@ -89,17 +89,17 @@
 	/*Do a first pass through the domainname file, to figure out how many profiles we need to read: */
 	nprof=1;
 	for(;;){
-		fscanf(fid,"%256s %256s\n",chardummy,chardummy);
-		fscanf(fid,"%256s %256s\n",chardummy,chardummy);
-		fscanf(fid,"%256s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy);
-		fscanf(fid,"%20u %256s\n",&n,chardummy);
-		fscanf(fid,"%256s %256s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy,chardummy);
+		fscanf(fid,"%255s %255s\n",chardummy,chardummy);
+		fscanf(fid,"%255s %255s\n",chardummy,chardummy);
+		fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy);
+		fscanf(fid,"%20u %255s\n",&n,chardummy);
+		fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy);
 		for (i=0;i<n;i++) fscanf(fid,"%20lf %20lf\n",&ddummy,&ddummy);
 		/*check whether we are at the end of the file, otherwise, keep reading next profile:*/
 		if (feof(fid)) break;
 		nprof++;
 	}
-	
+
 	/*Allocate and initialize all the profiles: */
 	profnvertices = xNew<int>(nprof);
 	pprofx        = xNew<doubletype*>(nprof);
@@ -117,20 +117,20 @@
 	for(counter=0;counter<nprof;counter++){
 
 		/*Skip header: */
-		fscanf(fid,"%256s %256s\n",chardummy,chardummy);
-		fscanf(fid,"%256s %256s\n",chardummy,chardummy);
-		fscanf(fid,"%256s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy);
-		
+		fscanf(fid,"%255s %255s\n",chardummy,chardummy);
+		fscanf(fid,"%255s %255s\n",chardummy,chardummy);
+		fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy);
+
 		/*Get number of profile vertices: */
-		fscanf(fid,"%20u %256s\n",&n,chardummy);
-	
+		fscanf(fid,"%20u %255s\n",&n,chardummy);
+
 		/*Skip next line: */
-		fscanf(fid,"%256s %256s %256s %256s %256s\n",chardummy,chardummy,chardummy,chardummy,chardummy);
+		fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy);
 
 		/*Allocate vertices: */
 		x=xNew<doubletype>(n);
 		y=xNew<doubletype>(n);
-		
+
 		/*Read vertices: */
 		for (i=0;i<n;i++){
 			fscanf(fid,"%20lf %20lf\n",&x[i],&y[i]);
@@ -169,7 +169,6 @@
 	int                 *profnvertices = NULL;
 	doubletype         **pprofx        = NULL;
 	doubletype         **pprofy        = NULL;
-	Contour<doubletype> *contour       = NULL;
 
 	/*output: */
 	DataSet *domain = NULL;

Modified: issm/trunk/src/c/shared/MemOps/xMemCpy.h
===================================================================
--- issm/trunk/src/c/shared/MemOps/xMemCpy.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/MemOps/xMemCpy.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,4 +16,3 @@
 };
 
 #endif
-

Modified: issm/trunk/src/c/shared/Numerics/BrentSearch.cpp
===================================================================
--- issm/trunk/src/c/shared/Numerics/BrentSearch.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/BrentSearch.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -39,7 +39,7 @@
 	xmax=optpars->xmax;
 	maxiter=optpars->maxiter;
 	cm_jump=optpars->cm_jump;
-	
+
 	/*initialize counter and get response at the boundaries*/
 	iter=0;
 	fxmin = (*f)(xmin,optargs);

Modified: issm/trunk/src/c/shared/Numerics/IsInputConverged.cpp
===================================================================
--- issm/trunk/src/c/shared/Numerics/IsInputConverged.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/IsInputConverged.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,7 +19,7 @@
 
 	/*output: */
 	IssmDouble eps;
-	
+
 	/*intermediary: */
 	IssmDouble *newvalues     = NULL;
 	IssmDouble *oldvalues     = NULL;

Modified: issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp
===================================================================
--- issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/OptimalSearch.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -37,7 +37,7 @@
 	x1       =optpars->xmin;
 	x2       =optpars->xmax;
 	maxiter  =optpars->maxiter;
-	
+
 	//get the value of the function at the first boundary
 	fx1= (*f)(x1,optargs);
 	if (xIsNan<IssmDouble>(fx1)) _error_("Function evaluation returned NaN");

Modified: issm/trunk/src/c/shared/Numerics/OptionsFromAnalysis.cpp
===================================================================
--- issm/trunk/src/c/shared/Numerics/OptionsFromAnalysis.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/OptionsFromAnalysis.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,7 +15,7 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
 char* OptionsFromAnalysis(Parameters* parameters,int analysis_type){
-	
+
 	/*output: */
 	char*   outstring=NULL;
 

Modified: issm/trunk/src/c/shared/Numerics/Synchronize.sh
===================================================================
--- issm/trunk/src/c/shared/Numerics/Synchronize.sh	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/Synchronize.sh	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
 #!/bin/bash
 #Synchronize Verbosity
 #first remove existing files
-rm $ISSM_DIR/src/m/shared/Verb*.m
+rm $ISSM_DIR/src/m/classes/Verb*.m
 
 echo "Synchronizing Verbosity levels..."
 
@@ -49,21 +49,6 @@
 
 	echo "$FILENAME -> 2^$POWER = $BINARY"
 
-	#Add Verbosity Matlab file{{{
-	cat <<END > $ISSM_DIR"/src/m/shared/"$(echo $FILENAME".m")
-function bool=$(echo $FILENAME)()
-%$(echo $FILENAME | awk {'print toupper($1)'}) - Return true if $(echo $LEVELNAME | awk {'print tolower($1)'}) level is activated
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/shared/Numerics/Synchronize.sh
-%            Please read src/c/shared/Numerics/README for more information
-%
-%   Usage:
-%      bool=$FILENAME()
-
-bool=logical(bitand(GetVerbosityLevel(),$BINARY));
-END
-	#}}}
 	#Add case to verbose.m FIELDS{{{
 	if [ $i -eq 1 ]; then cat <<END >> FIELDS
 		%BEGINFIELDS
@@ -134,7 +119,7 @@
 /*FUNCTION SetVerbosityLevel {{{*/
 void SetVerbosityLevel(int level){
 
-	if(level<0) _error2_("vebosity level should be a positive integer (user provided " << level << ")");
+	if(level<0) _error_("vebosity level should be a positive integer (user provided " << level << ")");
 
 	verbositylevel = level;
 

Modified: issm/trunk/src/c/shared/Numerics/UnitConversion.cpp
===================================================================
--- issm/trunk/src/c/shared/Numerics/UnitConversion.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/UnitConversion.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -39,11 +39,10 @@
 	return value;
 }
 
-
 IssmDouble UnitConversionScaleFactor(int type_enum){
 
 	IssmDouble yts=365.0*24.0*3600.0;
-	
+
 	IssmDouble scale;
 	switch(type_enum){
 		case TimesteppingStartTimeEnum:              scale=1.0/yts;break; //yr
@@ -71,6 +70,7 @@
 		case SurfaceforcingsBPosEnum:						scale=yts;break;     //m/yr
 		case SurfaceforcingsANegEnum:						scale=yts;break;     //m/yr
 		case SurfaceforcingsBNegEnum:						scale=yts;break;     //m/yr
+		case SurfaceforcingsSmbrefEnum:					scale=yts;break;     //m/yr
 		case MisfitEnum:                             scale=pow(yts,2);break; //(m/yr)^2
 		case MassFluxEnum:                           scale=pow((IssmDouble)10,-12)*yts;break; // (GigaTon/year)
 		case TotalSmbEnum:                           scale=pow((IssmDouble)10,-12)*yts;break; // (GigaTon/year)

Modified: issm/trunk/src/c/shared/Numerics/Verbosity.cpp
===================================================================
--- issm/trunk/src/c/shared/Numerics/Verbosity.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/Verbosity.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -27,6 +27,7 @@
 bool VerboseConvergence(void){return (GetVerbosityLevel() & 16);} /* 2^4*/
 bool VerboseControl(void){return (GetVerbosityLevel() & 32);} /* 2^5*/
 bool VerboseQmu(void){return (GetVerbosityLevel() & 64);} /* 2^6*/
+bool VerboseAutodiff(void){return (GetVerbosityLevel() & 128);} /* 2^7*/
 
 /*Verbosity Setup*/
 static int verbositylevel=-1;
@@ -40,8 +41,6 @@
 }/*}}}*/
 /*FUNCTION GetVerbosityLevel {{{*/
 int  GetVerbosityLevel(void){
-
 	_assert_(verbositylevel>=0);
 	return verbositylevel;
-
 }/*}}}*/

Modified: issm/trunk/src/c/shared/Numerics/Verbosity.h
===================================================================
--- issm/trunk/src/c/shared/Numerics/Verbosity.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/Verbosity.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,6 +13,7 @@
 bool VerboseConvergence(void);
 bool VerboseControl(void);
 bool VerboseQmu(void);
+bool VerboseAutodiff(void);
 
 /*Setup Verbosity level*/
 void SetVerbosityLevel(int level);

Modified: issm/trunk/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp
===================================================================
--- issm/trunk/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/XZvectorsToCoordinateSystem.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,11 +6,10 @@
 
 void XZvectorsToCoordinateSystem(IssmDouble* T,IssmDouble* xzvectors){
 
-	int		i,j;
 	IssmDouble	x[3],y[3],z[3];
 	IssmDouble	x_norm, y_norm, z_norm;
 
-	for(i=0;i<6;i++){
+	for(int i=0;i<6;i++){
 		if(xIsNan<IssmDouble>(xzvectors[i])){
 			/*At least one NaN found: default to Id*/
 			T[0*3+0] = 1.0;	T[0*3+1] = 0.0;	T[0*3+2] = 0.0;

Modified: issm/trunk/src/c/shared/Numerics/cross.cpp
===================================================================
--- issm/trunk/src/c/shared/Numerics/cross.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/cross.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,4 +19,3 @@
 	result[2]=vector1[0]*vector2[1]-vector1[1]*vector2[0];
 
 }
-

Modified: issm/trunk/src/c/shared/Numerics/isnan.h
===================================================================
--- issm/trunk/src/c/shared/Numerics/isnan.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/isnan.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,8 +5,15 @@
 #ifndef _XISNAN_H_
 #define _XISNAN_H_
 
-#include <cmath>
+#ifdef HAVE_CONFIG_H
+   #include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
 
+/*If include cmath instead of math, isnan on linux64 murdo does not work: */
+#include <math.h>
+
 template <class T> int xIsNan(const T& X) {
 #ifdef _INTEL_WIN_
 		return (X!=X)?1:0;
@@ -15,7 +22,7 @@
 #endif
 }
 
-#ifdef _HAVE_ADOLC_
+#if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_)
 template <> int xIsNan<adouble> (const adouble& X);
 #endif
 

Modified: issm/trunk/src/c/shared/Numerics/recast.h
===================================================================
--- issm/trunk/src/c/shared/Numerics/recast.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Numerics/recast.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,8 +8,14 @@
 #ifndef _RECAST_H_
 #define _RECAST_H_
 
-#ifndef _HAVE_ADOLC_
+#ifdef HAVE_CONFIG_H
+   #include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
 
+#if !defined(_HAVE_ADOLC_) || defined(_WRAPPERS_)
+
 template<class To, class From>
 To reCast(const From& from) {
     return (To)from;

Modified: issm/trunk/src/c/shared/Sorting/binary_search.cpp
===================================================================
--- issm/trunk/src/c/shared/Sorting/binary_search.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Sorting/binary_search.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,16 +10,16 @@
 
 #include <stdio.h>
 
-int binary_search(int* poffset,int target,int* sorted_integers,int num_integers){
+int binary_search(int* poffset,int target,int* sorted_integers,int num_integers){ /*{{{*/
 
 	/*output: */
 	int offset;  //offset, if found
 	int found=0; //found=0 if target is not found, 1 otherwise.
 
 	/*intermediary: */
-	int* beg=NULL;
-	int* end=NULL;
-	int* mid=NULL;
+	int *beg = NULL;
+	int *end = NULL;
+	int *mid = NULL;
 
 	// point to beginning and end of the array
 	beg=sorted_integers;
@@ -46,7 +46,7 @@
 				mid = beg + (end-beg)/2;  //new middle
 			}
 		}
-			  
+
 		//did we find the target?
 		if (*mid == target) {
 			found=1;
@@ -59,7 +59,7 @@
 
 	/*Assign output pointers:*/
 	*poffset=offset;
-	
+
 	/*Return result: */
 	return found;
-}
+} /*}}}*/

Modified: issm/trunk/src/c/shared/Sorting/sorting.h
===================================================================
--- issm/trunk/src/c/shared/Sorting/sorting.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Sorting/sorting.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,5 +6,56 @@
 #define  _SORTING_H_
 
 int binary_search(int* poffset,int target,int* sorted_integers,int num_integers);
+template <typename doubletype> int binary_search(int* poffset,doubletype target,doubletype* list,int length){ /*{{{*/
+	/*
+	 *             l[0]  l[1]  l[2]        l[n]  l[n+1]   l[length-1]
+	 *     <-------+-----+-----+-----+ ... +-----+........+-------------->
+	 * offset: -1     0     1     2           n              length -1
+	 *  
+	 *  offset = -1        target < list[0]
+	 *  offset = n         list[n] <= target < list[n+1]
+	 *  offset = length-1  list[length-1] <= target
+	 */
 
+	/*output: */
+	int offset = 0;
+	int found  = 0;
+
+	/*intermediary: */
+	int n0 = 0;
+	int n1 = int(length/2);
+	int n2 = length-1;
+
+	if(target<list[n0]){
+		found  = 1;
+		offset = -1;
+	}
+	else if(target>=list[n2]){
+		found  = 1;
+		offset = length-1;
+	}
+	else{
+		for(;;){
+			/*did we find the target?*/
+			if(list[n1]<=target && list[n1+1]>target){
+				found  = 1;
+				offset = n1;
+				break;
+			}
+			else if(target < list[n1]){
+				n2 = n1;
+				n1 = n0 + int((n2-n0)/2);
+			}
+			else{
+				n0 = n1;
+				n1 = n0 + int((n2-n0)/2);
+			}
+		}
+	}
+
+	/*Assign output pointer and return*/
+	*poffset=offset;
+	return found;
+} /*}}}*/
+
 #endif //ifndef _SORTING_H_

Modified: issm/trunk/src/c/shared/String/DescriptorIndex.cpp
===================================================================
--- issm/trunk/src/c/shared/String/DescriptorIndex.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/String/DescriptorIndex.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,7 +17,7 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
 int  DescriptorIndex(char* root, int* pindex,char* descriptor){ //We assume root has already been allocated, and we just have to copy into it.
-	
+
 	char * pch=NULL;
 
 	/*retrieve first token, separated by underscore: */

Modified: issm/trunk/src/c/shared/String/sharedstring.h
===================================================================
--- issm/trunk/src/c/shared/String/sharedstring.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/String/sharedstring.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -7,5 +7,8 @@
 
 int  DescriptorIndex(char* root, int* pindex,char* descriptor);
 
+#ifndef WIN32
+int stricmp(const char* a,const char* b);
+#endif
+
 #endif //ifndef _SHAREDSTRING_H_
-

Modified: issm/trunk/src/c/shared/Threads/LaunchThread.cpp
===================================================================
--- issm/trunk/src/c/shared/Threads/LaunchThread.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Threads/LaunchThread.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,7 +30,7 @@
 	int            *status  = NULL;
 	pthread_t      *threads = NULL;
 	pthread_handle *handles = NULL;
-	
+
 	/*dynamically allocate: */
 	threads=xNew<pthread_t>(num_threads);
 	handles=xNew<pthread_handle>(num_threads);
@@ -51,7 +51,7 @@
 			_error_("pthread_join error");
 		}
 	}
-	
+
 	/*Free ressources:*/
 	xDelete<pthread_t>(threads);
 	xDelete<pthread_handle>(handles);
@@ -61,7 +61,7 @@
 	handle.gate=gate;
 	handle.id=0;
 	handle.num=1;
-	
+
 	function((void*)&handle);
 	#endif
 }

Modified: issm/trunk/src/c/shared/Threads/PartitionRange.cpp
===================================================================
--- issm/trunk/src/c/shared/Threads/PartitionRange.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Threads/PartitionRange.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,11 +15,10 @@
 	/*output: */
 	int i0=-1;
 	int i1=-1;
-	
+
 	int step;
 	int i;
 
-
 	/*distribute elements across threads :*/
 	step=(int)floor((double)num_el/(double)num_threads);
 	for(i=0;i<(my_thread+1);i++){
@@ -28,7 +27,6 @@
 		else i1=i0+step;
 	}
 
-
 	/*Assign output pointers:*/
 	*pi0=i0;
 	*pi1=i1;

Modified: issm/trunk/src/c/shared/Threads/issm_threads.h
===================================================================
--- issm/trunk/src/c/shared/Threads/issm_threads.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/Threads/issm_threads.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,7 +13,6 @@
 	int   num;
 } pthread_handle;
 
-
 /*routine that launches "function" in a multi-threaded way if requested, 
  * or just serially if not requested: */
 void LaunchThread(void* function(void*), void* gate,int num_threads);

Modified: issm/trunk/src/c/shared/TriMesh/AssociateSegmentToElement.cpp
===================================================================
--- issm/trunk/src/c/shared/TriMesh/AssociateSegmentToElement.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/TriMesh/AssociateSegmentToElement.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,7 @@
 #include "./trimesh.h"
 
 int AssociateSegmentToElement(double** psegments,int nseg, double* index,int nel){
-	
+
 	/*Error management: */
 	int i;
 	int noerr=1;
@@ -29,5 +29,3 @@
 	*psegments=segments;
 	return noerr;
 }
-
-

Modified: issm/trunk/src/c/shared/TriMesh/OrderSegments.cpp
===================================================================
--- issm/trunk/src/c/shared/TriMesh/OrderSegments.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/TriMesh/OrderSegments.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,7 @@
 #include "./trimesh.h"
 
 int OrderSegments(double** psegments,int nseg, double* index,int nel){
-	
+
 	/*Error management: */
 	int i;
 	int noerr=1;
@@ -18,7 +18,6 @@
 	/*element indices: */
 	int el;
 
-
 	/*Recover segments: */
 	segments=*psegments;
 

Modified: issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp
===================================================================
--- issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/TriMesh/SplitMeshForRifts.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,10 +11,10 @@
 	index  of size nelx3
 	x and y of size nodsx1
 	segments of size nsegsx3*/
-	
+
 	/*Error management: */
 	int noerr=1;
-	
+
 	int i,j,k,l;
 	int node;
 	int el;
@@ -22,7 +22,7 @@
 	int  nriftsegs;
 	int* riftsegments=NULL; 
 	int* flags=NULL;
-	
+
 	int  NumGridElementListOnOneSideOfRift;
 	int* GridElementListOnOneSideOfRift=NULL;
 
@@ -54,7 +54,7 @@
 	flags=xNewZeroInit<int>(nods); //to make sure we don't split the same nodes twice!
 	for (i=0;i<nriftsegs;i++){
 		for (j=0;j<2;j++){
-	
+
 			node=riftsegments[4*i+j+2];
 			if(flags[node-1]){
 				/*This node was already split, skip:*/
@@ -65,9 +65,9 @@
 			}
 
 			if(IsGridOnRift(riftsegments,nriftsegs,node)){
-			
+
 				DetermineGridElementListOnOneSideOfRift(&NumGridElementListOnOneSideOfRift,&GridElementListOnOneSideOfRift,i,nriftsegs,riftsegments,node,index,nel);
-			
+
 				/*Summary: we have for node, a list of elements
 				 * (GridElementListOnOneSideOfRift, of size
 				 * NumGridElementListOnOneSideOfRift) that all contain node 

Modified: issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp
===================================================================
--- issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,7 +16,7 @@
 
 	/*Does this node belong to 4 elements, or just 2? If it belongs to 4 elements, it is inside a rift, 
 	 *if it belongs to 2 elements, it is on the tip of a rift, or it has already been split across the rift (see below).*/
-	
+
 	int i;
 	int j;
 	int count;
@@ -118,10 +118,10 @@
 }/*}}}*/
 /*FUNCTION RiftSegmentsFromSegments{{{*/
 void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments){
-	
+
 	int i,counter;
 	int el,el2;
-	
+
 	int  nriftsegs;
 	int* riftsegments=NULL;
 	int* riftsegments_uncompressed=NULL; 
@@ -178,7 +178,7 @@
 	}
 
 	xDelete<int>(riftsegments_uncompressed);
-	
+
 	/*Assign output pointers: */
 	*priftsegments=riftsegments;
 	*pnriftsegs=nriftsegs;
@@ -265,7 +265,7 @@
 
 	/*Reallocate segments: */
 	segments         =xReNew<double>(segments,         nsegs*3,(nsegs+nriftsegs)*3);
-	segmentmarkerlist=xReNew<double>(segmentmarkerlist,nsegs*3,(nsegs+nriftsegs)*3);
+	segmentmarkerlist=xReNew<double>(segmentmarkerlist,nsegs,(nsegs+nriftsegs));
 
 	/*First, update the existing segments to the new nodes :*/
 	for (i=0;i<nriftsegs;i++){
@@ -343,20 +343,9 @@
 	*psegments=segments;
 	*psegmentmarkerlist=segmentmarkerlist;
 	*pnsegs=nsegs;
-	
+
 	return noerr;
 }/*}}}*/
-/*FUNCTION pnpoly{{{*/
-int pnpoly(int npol, double *xp, double *yp, double x, double y) {
-	int i, j, c = 0;
-	for (i = 0, j = npol-1; i < npol; j = i++) {
-		if ((((yp[i]<=y) && (y<yp[j])) ||
-					((yp[j]<=y) && (y<yp[i]))) &&
-				(x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))
-			c = !c;
-	}
-	return c;
-}/*}}}*/
 /*FUNCTION FindElement{{{*/
 int FindElement(double A,double B,double* index,int nel){
 
@@ -383,7 +372,7 @@
 	double *segments          = NULL;
 	double *segmentmarkerlist = NULL;
 	int numsegs;
-	
+
 	/*output: */
 	int      new_numsegs;
 	int     *riftsnumsegs       = NULL;
@@ -460,7 +449,6 @@
 /*FUNCTION PairRiftElements{{{*/
 int PairRiftElements(int** priftsnumpairs, double*** priftspairs,int numrifts,int* riftsnumsegments, double** riftssegments,double* x,double* y){
 
-
 	int noerr=1;
 	int i,j,k;
 
@@ -692,7 +680,7 @@
 
 	int i;
 	int noerr=1;
-	
+
 	/*output: */
 	int riftflag=0;
 	int numrifts=0;
@@ -716,7 +704,7 @@
 }/*}}}*/
 /*FUNCTION OrderRifts{{{*/
 int OrderRifts(double** priftstips, double** riftssegments,double** riftspairs,int numrifts,int* riftsnumsegments,double* x,double* y,int nods,int nels){
-	
+
 	int noerr=1;
 	int i,j,k,counter;
 
@@ -746,7 +734,7 @@
 		riftsegments=riftssegments[i];
 		riftpairs=riftspairs[i];
 		numsegs=riftsnumsegments[i];
-	
+
 		/*Allocate copy of riftsegments and riftpairs, 
 		 *as well as ordering vector: */
 		riftsegments_copy=xNew<double>(numsegs*3);
@@ -792,7 +780,7 @@
 					break;
 				}
 			}
-		
+
 			if (node4==node2){
 				/*node2 is a tip*/
 				if (tip1==-1){
@@ -817,7 +805,7 @@
 			for (j=0;j<numsegs;j++){
 				node1=(int)*(riftsegments+3*j+0);
 				node2=(int)*(riftsegments+3*j+1);
-				
+
 				if ((node1==node) || (node2==node)){
 					/*Ok, this segment is connected to node, plug its index into order, unless we already plugged it before: */
 					already_ordered=0;
@@ -850,7 +838,7 @@
 			*(riftpairs_copy+2*j+0)=*(riftpairs+2*order[j]+0);
 			*(riftpairs_copy+2*j+1)=*(riftpairs+2*order[j]+1);
 		}
-		
+
 		for (j=0;j<numsegs;j++){
 			*(riftsegments+3*j+0)=*(riftsegments_copy+3*j+0);
 			*(riftsegments+3*j+1)=*(riftsegments_copy+3*j+1);
@@ -872,7 +860,6 @@
 /*FUNCTION PenaltyPairs{{{*/
 int PenaltyPairs(double*** priftspenaltypairs,int** priftsnumpenaltypairs,int numrifts,double** riftssegments,
 		int* riftsnumsegs,double** riftspairs,double* riftstips,double* x,double* y){
-		
 
 	int noerr=1;
 	int i,j,k,k0;
@@ -905,7 +892,7 @@
 
 		/*allocate riftpenaltypairs, and riftnumpenaltypairs: */
 		if((numsegs/2-1)!=0)riftpenaltypairs=xNewZeroInit<double>((numsegs/2-1)*RIFTPENALTYPAIRSWIDTH);
-		
+
 		/*Go through only one flank of the rifts, not counting the tips: */
 		counter=0;
 		for(j=0;j<(numsegs/2);j++){
@@ -996,7 +983,7 @@
 			*(riftpenaltypairs+j*7+4)=*(riftpenaltypairs+j*7+4)/magnitude;
 			*(riftpenaltypairs+j*7+5)=*(riftpenaltypairs+j*7+5)/magnitude;
 		}
-		
+
 		riftspenaltypairs[i]=riftpenaltypairs;
 		riftsnumpenaltypairs[i]=(numsegs/2-1);
 	}
@@ -1035,7 +1022,6 @@
 	y=*py;
 	nods=*pnods;
 
-
 	for (i=0;i<num_seg;i++){
 		node1=*(segments+3*i+0);
 		node2=*(segments+3*i+1);

Modified: issm/trunk/src/c/shared/TriMesh/trimesh.h
===================================================================
--- issm/trunk/src/c/shared/TriMesh/trimesh.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/TriMesh/trimesh.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,7 +21,6 @@
 void RiftSegmentsFromSegments(int* pnriftsegs, int** priftsegments, int nel, double* index, int nsegs,double* segments);
 int DetermineGridElementListOnOneSideOfRift(int* pNumGridElementListOnOneSideOfRift, int** pGridElementListOnOneSideOfRift, int segmentnumber, int nriftsegs, int* riftsegments, int node,double* index,int nel);
 int UpdateSegments(double** psegments,double** psegmentmarkerlist, int* pnsegs, double* index, double* x,double* y,int* riftsegments,int nriftsegs,int nods,int nel);
-int pnpoly(int npol, double *xp, double *yp, double x, double y);
 int FindElement(double A,double B,double* index,int nel);
 int RemoveRifts(double** pindex,double** px,double** py,int* pnods,double** psegments,int* pnumsegs,int numrifts1,int* rifts1numsegs,double** rifts1segments,double** rifts1pairs,int nel);
 int IsRiftPresent(int* priftflag,int* pnumrifts, double* segmentmarkerlist,int nsegs);

Modified: issm/trunk/src/c/shared/shared.h
===================================================================
--- issm/trunk/src/c/shared/shared.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/shared/shared.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,19 +5,18 @@
 #ifndef _SHARED_H_
 #define _SHARED_H_
 
-#include "Alloc/alloc.h"
-#include "Alloc/xNewDelete.h"
-#include "Bamg/shared.h"
-#include "Elements/elements.h"
-#include "Exceptions/exceptions.h"
-#include "Exp/exp.h"
-#include "Matrix/matrix.h"
-#include "MemOps/xMemCpy.h"
-#include "Numerics/numerics.h"
-#include "Sorting/sorting.h"
-#include "Sys/sys.h"
-#include "Threads/issm_threads.h"
-#include "TriMesh/trimesh.h"
-#include "Wrapper/wrappershared.h"
+#include "./Alloc/alloc.h"
+#include "./Alloc/xNewDelete.h"
+#include "./Bamg/shared.h"
+#include "./Elements/elements.h"
+#include "./Exceptions/exceptions.h"
+#include "./Exp/exp.h"
+#include "./Matrix/matrix.h"
+#include "./MemOps/xMemCpy.h"
+#include "./Numerics/numerics.h"
+#include "./Sorting/sorting.h"
+#include "./String/sharedstring.h"
+#include "./Threads/issm_threads.h"
+#include "./TriMesh/trimesh.h"
 
 #endif

Modified: issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp
===================================================================
--- issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/AdjointCorePointerFromSolutionEnum.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-/*!\file:  CorePointerFromSolutionEnum.cpp
+/*!\file:  AdjointCorePointerFromSolutionEnum.cpp
  * \brief: return type of analyses, number of analyses and core solution function.
  */ 
 
@@ -23,7 +23,7 @@
 	void (*adjointcore)(FemModel*)=NULL;
 
 	switch(solutiontype){
-	
+
 		case DiagnosticSolutionEnum:
 			adjointcore=&adjointdiagnostic_core;
 			break;
@@ -37,7 +37,7 @@
 			_error_("No adjoint has been implemented for solution " << EnumToStringx(solutiontype) << " yet");
 			break;
 	}
-	
+
 	/*Assign output pointer:*/
 	_assert_(padjointcore);
 	*padjointcore=adjointcore;

Modified: issm/trunk/src/c/solutions/AnalysisConfiguration.cpp
===================================================================
--- issm/trunk/src/c/solutions/AnalysisConfiguration.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/AnalysisConfiguration.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,7 +25,7 @@
 
 	/*Analyses lists*/
 	switch(solutiontype){
-	
+
 		case DiagnosticSolutionEnum:
 			numanalyses=5;
 			analyses=xNew<int>(numanalyses);
@@ -55,13 +55,13 @@
 			analyses[0]=ThermalAnalysisEnum;
 			analyses[1]=MeltingAnalysisEnum;
 			break;
-		
+
 		case EnthalpySolutionEnum:
 			numanalyses=1;
 			analyses=xNew<int>(numanalyses);
 			analyses[0]=EnthalpyAnalysisEnum;
 			break;
-		
+
 		case HydrologySolutionEnum:
 			numanalyses=3;
 			analyses=xNew<int>(numanalyses);
@@ -107,7 +107,7 @@
 			analyses[7]=EnthalpyAnalysisEnum;
 			analyses[8]=PrognosticAnalysisEnum;
 			break;
-		
+
 		default:
 			_error_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!");
 			break;

Modified: issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp
===================================================================
--- issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/CorePointerFromSolutionEnum.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -23,7 +23,7 @@
 	void (*solutioncore)(FemModel*)=NULL;
 
 	switch(solutiontype){
-	
+
 		case DiagnosticSolutionEnum:
 			#ifdef _HAVE_DIAGNOSTIC_
 			solutioncore=&diagnostic_core;
@@ -98,7 +98,7 @@
 			_error_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!");
 			break;
 	}
-	
+
 	/*Assign output pointer:*/
 	_assert_(psolutioncore);
 	*psolutioncore=solutioncore;

Modified: issm/trunk/src/c/solutions/ProcessArguments.cpp
===================================================================
--- issm/trunk/src/c/solutions/ProcessArguments.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/ProcessArguments.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,11 +18,14 @@
 	char *rootpath       = NULL;
 	char *rootpatharg    = NULL;
 
-	*solution_type=StringToEnumx(argv[1]);
+	/*Check input arguments*/
 	if(argc<2)_error_("Usage error: no solution requested");
 	if(argc<3)_error_("Usage error: missing execution directory");
 	if(argc<4)_error_("Usage error: missing model name");
 
+	/*Get requested solution*/
+	*solution_type=StringToEnumx(argv[1]);
+
 	rootpatharg=argv[2];
 	if(strcmp(strstr(rootpatharg,"/"),"/")!=0){ 
 		rootpath       = xNew<char>(strlen(rootpatharg)+2); sprintf(rootpath,"%s/",rootpatharg);

Modified: issm/trunk/src/c/solutions/ResetBoundaryConditions.cpp
===================================================================
--- issm/trunk/src/c/solutions/ResetBoundaryConditions.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/ResetBoundaryConditions.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,14 +8,13 @@
 #include "../EnumDefinitions/EnumDefinitions.h"
 
 void ResetBoundaryConditions(FemModel* femmodel, int analysis_type){
-	
+
 	/*variables: */
 	Vector<IssmDouble>*    yg    = NULL;
 	Nodes *nodes = NULL;
-	int    i;
 
 	if(VerboseSolution()) _pprintLine_("   updating boundary conditions...");
-			
+
 	/*set current analysis: */
 	femmodel->SetCurrentConfiguration(analysis_type);
 

Modified: issm/trunk/src/c/solutions/adjointbalancethickness_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/adjointbalancethickness_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/adjointbalancethickness_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,7 +13,7 @@
 #include "../solvers/solvers.h"
 
 void adjointbalancethickness_core(FemModel* femmodel){
-	
+
 	/*parameters: */
 	bool save_results;
 
@@ -32,7 +32,7 @@
 	if(VerboseSolution()) _pprintLine_("   computing adjoint");
 	femmodel->SetCurrentConfiguration(BalancethicknessAnalysisEnum,AdjointBalancethicknessAnalysisEnum);
 	solver_adjoint_linear(femmodel);
-	
+
 	/*Save results*/
 	if(save_results){
 		if(VerboseSolution()) _pprintLine_("   saving results");

Modified: issm/trunk/src/c/solutions/adjointdiagnostic_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/adjointdiagnostic_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/adjointdiagnostic_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,7 +13,7 @@
 #include "../solvers/solvers.h"
 
 void adjointdiagnostic_core(FemModel* femmodel){
-	
+
 	/*parameters: */
 	bool isstokes;
 	bool save_results;
@@ -35,7 +35,7 @@
 	if(VerboseSolution()) _pprintLine_("   computing adjoint");
 	femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum,AdjointHorizAnalysisEnum);
 	solver_adjoint_linear(femmodel);
-	
+
 	/*Save results*/
 	if(save_results){
 		if(VerboseSolution()) _pprintLine_("   saving results");

Modified: issm/trunk/src/c/solutions/balancethickness_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/balancethickness_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/balancethickness_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,7 +19,7 @@
 
 	/*activate formulation: */
 	femmodel->SetCurrentConfiguration(BalancethicknessAnalysisEnum);
-	
+
 	/*recover parameters: */
 	femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
 

Modified: issm/trunk/src/c/solutions/bedslope_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/bedslope_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/bedslope_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,7 +25,7 @@
 	solver_linear(femmodel);
 	femmodel->SetCurrentConfiguration(BedSlopeAnalysisEnum,BedSlopeYAnalysisEnum);
 	solver_linear(femmodel);
-	
+
 	if(save_results){
 		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedSlopeXEnum);

Modified: issm/trunk/src/c/solutions/control_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/control_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/control_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,7 +15,7 @@
 void control_core(FemModel* femmodel){
 
 	int     i,n;
-	
+
 	/*parameters: */
 	int     num_controls,num_responses;
 	int     nsteps;
@@ -31,7 +31,7 @@
 	int*    step_responses=NULL;
 	IssmDouble* maxiter=NULL;
 	IssmDouble* cm_jump=NULL;
-		
+
 	/*intermediary: */
 	IssmDouble  search_scalar=1;
 	OptArgs optargs;
@@ -71,11 +71,11 @@
 	/*Initialize responses: */
 	J=xNew<IssmDouble>(nsteps);
 	step_responses=xNew<int>(num_responses);
-		
+
 	/*Initialize some of the BrentSearch arguments: */
 	optargs.femmodel=femmodel;
 	optpars.xmin=0; optpars.xmax=1;
-	
+
 	/*Start looping: */
 	for(n=0;n<nsteps;n++){
 
@@ -83,7 +83,7 @@
 		if(VerboseControl()) _pprintLine_("\n" << "   control method step " << n+1 << "/" << nsteps);
 		for(i=0;i<num_responses;i++) step_responses[i]=reCast<int,IssmDouble>(responses[n*num_responses+i]);
 		femmodel->parameters->SetParam(step_responses,1,num_responses,StepResponsesEnum);
-		
+
 		/*In steady state inversion, compute new temperature field now*/
 		if(solution_type==SteadystateSolutionEnum) solutioncore(femmodel);
 
@@ -103,7 +103,7 @@
 
 		if(VerboseControl()) _pprintLine_("   updating parameter using optimized search scalar"); //true means update save controls
 		InputControlUpdatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,search_scalar,true);
-		
+
 		if(controlconvergence(J[n],tol_cm)) break;
 	}
 

Modified: issm/trunk/src/c/solutions/controlconvergence.cpp
===================================================================
--- issm/trunk/src/c/solutions/controlconvergence.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/controlconvergence.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,7 +18,6 @@
 
 bool controlconvergence(IssmDouble J, IssmDouble tol_cm){
 
-	int i;
 	bool converged=false;
 
 	/*Has convergence been reached?*/

Modified: issm/trunk/src/c/solutions/controltao_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/controltao_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/controltao_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -53,7 +53,7 @@
 	maxiter=nsteps*(int)dummy[0]; xDelete<IssmDouble>(dummy);
 
 	/*Initialize TAO*/
-	TaoCreate(PETSC_COMM_WORLD,&tao);
+	TaoCreate(IssmComm::GetComm(),&tao);
 	if(VerboseControl()) _pprintLine_("   Initializing the Toolkit for Advanced Optimization (TAO)");
 	TaoSetFromOptions(tao);
 	TaoSetType(tao,"tao_blmvm");
@@ -98,6 +98,7 @@
 
 	/*Clean up and return*/
 	xDelete<int>(control_list);
+	xDelete<double>(user.J);
 	xdelete(&X);
 	TaoDestroy(&tao);
 	TaoFinalize();
@@ -140,7 +141,7 @@
 	adjointcore(femmodel);
 
 	/*Compute objective function*/
-	CostFunctionx(fcn,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+	femmodel->CostFunctionx(fcn);
 
 	/*Compute gradient*/
 	Gradjx(&gradient,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
@@ -172,7 +173,7 @@
 
 	/*Retrieve objective functions independently*/
 	for(i=0;i<num_responses;i++){
-		Responsex(&f,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnumToStringx(responses[i]),false,i);
+		femmodel->Responsex(&f,EnumToStringx(responses[i]),false,i);
 		_pprintString_(" "<<setw(12)<<setprecision(7)<<f);
 	}
 	_pprintLine_("");

Modified: issm/trunk/src/c/solutions/diagnostic_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/diagnostic_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/diagnostic_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -59,7 +59,7 @@
 	}
 
 	if(ishutter){
-			
+
 		if(VerboseSolution()) _pprintLine_("   computing hutter velocities");
 
 		//Take the last velocity into account so that the velocity on the MacAyeal domain is not zero
@@ -67,12 +67,12 @@
 
 		femmodel->SetCurrentConfiguration(DiagnosticHutterAnalysisEnum);
 		solver_linear(femmodel);
-		
+
 		if (ismacayealpattyn) ResetBoundaryConditions(femmodel,DiagnosticHorizAnalysisEnum);
 	}
 
 	if ((ismacayealpattyn || isl1l2) ^ isstokes){ // ^ = xor
-		
+
 		if(VerboseSolution()) _pprintLine_("   computing velocities");
 		femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum);
 		if(isnewton)
@@ -94,7 +94,6 @@
 		solver_linear(femmodel);
 	}
 
-
 	if(save_results){
 		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum);
@@ -102,9 +101,11 @@
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VelEnum);
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,PressureEnum);
 		if(dim==3) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VzEnum);
-		RequestedOutputsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,requested_outputs,numoutputs);
+		femmodel->RequestedOutputsx(requested_outputs,numoutputs);
 	}
 
+	if(solution_type==DiagnosticSolutionEnum)femmodel->RequestedDependentsx();
+
 	/*Free ressources:*/
 	xDelete<int>(requested_outputs);
 }

Modified: issm/trunk/src/c/solutions/hydrology_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/hydrology_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/hydrology_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -43,7 +43,7 @@
 
 	/*Loop through time: */
 	for(i=0;i<nsteps;i++){
-		
+
 		if(nsteps)if(VerboseSolution()) _pprintLine_("time step:" << i+1 << "/" << nsteps);
 		time+=dt;
 		femmodel->parameters->SetParam(time,TimeEnum);
@@ -56,11 +56,10 @@
 			//InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,WatercolumnEnum,i+1,time);
 			//InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,HydrologyWaterVxEnum,i+1,time);
 			//InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,HydrologyWaterVyEnum,i+1,time);
-			
+
 			/*unload results*/
 			if(VerboseSolution()) _pprintLine_("   saving temporary results");
 			OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
 		}
 	}
 }
-

Modified: issm/trunk/src/c/solutions/hydrology_core_step.cpp
===================================================================
--- issm/trunk/src/c/solutions/hydrology_core_step.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/hydrology_core_step.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,7 +13,7 @@
 #include "../solvers/solvers.h"
 
 void hydrology_core_step(FemModel* femmodel,int step, IssmDouble time){
-	
+
 	bool modify_loads=true;
 
 	if(VerboseSolution()) _pprintLine_("   computing water column");

Modified: issm/trunk/src/c/solutions/issm.cpp
===================================================================
--- issm/trunk/src/c/solutions/issm.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/issm.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,252 +1,35 @@
 /*!\file:  issm.cpp
- * \brief: ISSM main parallel program
+ * \brief: ISSM main program
  */ 
 
 #include "../issm.h"
-#include "../include/globals.h"
-#include "../shared/Numerics/adolc_edf.h"
 
 int main(int argc,char **argv){
 
-	/*I/O: */
-	FILE *output_fid       = NULL;
-	FILE *petscoptionsfid  = NULL;
-	bool  waitonlock       = false;
-	bool  dakota_analysis,control_analysis,tao_analysis;
+	/*Initialize exception trapping: */
+	ExceptionTrapBegin();
 
-	/*AD: */
-	bool autodiff=false;
-	size_t   tape_stats[11];
+	/*Initialize environment (MPI, PETSC, MUMPS, etc ...)*/
+	COMM comm_init=EnvironmentInit(argc,argv);
 
-	/*FemModel: */
-	FemModel *femmodel = NULL;
+	/*Initialize femmodel from arguments provided command line: */
+	FemModel *femmodel = new FemModel(argc,argv,comm_init);
 
-	/*configuration: */
-	void (*solutioncore)(FemModel*)=NULL; //core solution function pointer
-	int* analyses=NULL;
-	int  numanalyses;
-	int  solution_type;
+	/*Solve: */
+	femmodel->Solve();
 
-	/*File names*/
-	char *lockfilename   = NULL;
-	char *binfilename    = NULL;
-	char *outbinfilename = NULL;
-	char *petscfilename  = NULL;
-	char *rootpath       = NULL;
+	/*Output results: */
+	femmodel->OutputResults();
 
-	/*time*/
-	IssmPDouble   start, finish;
-	IssmPDouble   start_core, finish_core;
-	IssmPDouble   start_init, finish_init;
-	int      ierr;
-
-	/*profiling*/   
-	bool profiling = false;
-	IssmPDouble Time_start, Flops_start;
-	IssmPDouble Solution_time, Memory_use, Current_flops;
-
-	ISSMBOOT();
-
-	
-	/*Initialize environments: Petsc, MPI, etc...: */
-	#ifdef _HAVE_PETSC_
-	ierr=PetscInitialize(&argc,&argv,(char*)0,"");  
-	if(ierr) _error_("Could not initialize Petsc");
-	#else
-	#ifdef _HAVE_MPI_
-	MPI_Init(&argc,&argv);
-	#endif
-	#endif
-
-	#ifdef _HAVE_MPI_
-	MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
-	#else
-	start=(IssmPDouble)clock();
-	#endif
-
-	/*Size and rank: */
-	#ifdef _HAVE_MPI_
-	MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);  
-	MPI_Comm_size(MPI_COMM_WORLD,&num_procs); 
-	#endif
-
-	/*First process inputs*/
-	_pprintLine_("");
-	_pprintLine_("Ice Sheet System Model (" << PACKAGE_NAME << ") version " << PACKAGE_VERSION);
-	_pprintLine_("(website: " << PACKAGE_URL << " contact: " << PACKAGE_BUGREPORT << ")");
-	_pprintLine_("");
-	ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,&rootpath,argc,argv);
-
-	/*out of solution_type, figure out types of analyses needed in the femmodel: */
-	AnalysisConfiguration(&analyses,&numanalyses,solution_type);
-
-	/*before we create the model, start the trace on for AD mode: */
-	#ifdef _HAVE_ADOLC_
-	trace_on(1);
-	#endif
-
-	/*Create femmodel, using input file: */
-	#ifdef _HAVE_MPI_
-	MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
-	#else
-	start_init=(IssmPDouble)clock();
-	#endif
-	femmodel=new FemModel(rootpath,binfilename,outbinfilename,solution_type,analyses,numanalyses);
-	
-	/*get type of solution we are going to run: */
-	CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);
-
-	/*Open output file once for all*/
-	output_fid=pfopen(outbinfilename,"wb");
-	femmodel->parameters->SetParam(output_fid,OutputFilePointerEnum);
-
-	/*add petsc options to parameters: */
-	petscoptionsfid=pfopen(petscfilename,"r");
-	ParsePetscOptionsx(femmodel->parameters,petscoptionsfid);
-	pfclose(petscoptionsfid,petscfilename);
-
-	/*get parameters: */
-	femmodel->parameters->FindParam(&waitonlock,SettingsWaitonlockEnum);
-	femmodel->parameters->FindParam(&dakota_analysis,QmuIsdakotaEnum);
-	femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum);
-	femmodel->parameters->FindParam(&tao_analysis,InversionTaoEnum);
-	femmodel->parameters->FindParam(&profiling,DebugProfilingEnum); 
-	femmodel->parameters->FindParam(&autodiff,AutodiffIsautodiffEnum);
-
-	#ifdef _HAVE_MPI_
-	MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
-	#else
-	finish_init=(IssmPDouble)clock();
-	#endif
-	
-	/*If running AD, then initialize the tape: */
-	#ifdef _HAVE_ADOLC_
-	GenericParam<Adolc_edf> *theAdolcEDF_p=new GenericParam<Adolc_edf>(AdolcParamEnum);
-	theAdolcEDF_p->GetParameterValue().myEDF_for_solverx_p=reg_ext_fct(EDF_for_solverx);
-	femmodel->parameters->AddObject(theAdolcEDF_p);
-	#else
-	if(autodiff) _error_("ISSM was not compiled with ADOLC support, cannot carry out autodiff analysis!");
-	#endif
-
-	_pprintLine_("call computational core:");
-	#ifdef _HAVE_MPI_
-	MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
-	#else
-	start_core=(IssmPDouble)clock();
-	#endif
-	
-	if(profiling)ProfilingStart(&Time_start,&Flops_start);
-
-	if(dakota_analysis){
-		#ifdef _HAVE_DAKOTA_
-		Dakotax(femmodel);
-		#else
-		_error_("ISSM was not compiled with dakota support, cannot carry out dakota analysis!");
-		#endif
-	}
-	else if(control_analysis){
-		#ifdef _HAVE_CONTROL_
-		if(tao_analysis)
-		 controltao_core(femmodel);
-		else
-		 control_core(femmodel);
-		#else
-		_error_("ISSM was not compiled with control support, cannot carry out dakota analysis!");
-		#endif
-	}
-	else{
-		solutioncore(femmodel);
-	}
-
-	if(profiling){
-		ProfilingEnd(&Solution_time,&Memory_use,&Current_flops,Time_start,Flops_start);
-		femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingSolutionTimeEnum, Solution_time, 1, 0));
-		femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingCurrentMemEnum, Memory_use, 1, 0));
-		femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingCurrentFlopsEnum, Current_flops, 1, 0));
-	}
-
-	#ifdef _HAVE_ADOLC_
-	if(autodiff){
-		trace_off();
-		AutodiffDriversx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
-	}
-	#endif
-
-
-	#ifdef _HAVE_MPI_
-	MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
-	#else
-	finish_core=(IssmPDouble)clock();
-	#endif
-	
-	_pprintLine_("write results to disk:");
-	OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
-	
-	/*If running AD, close our tape, print statistics: {{{*/
-	#ifdef _HAVE_ADOLC_
-	if(autodiff){
-		tapestats(1,tape_stats); //reading of tape statistics
-		_pprintLine_("   ADOLC statistics: ");
-		_pprintLine_("   "<<setw(45)<<left<<"Number of independents: " <<tape_stats[0]);
-		_pprintLine_("   "<<setw(45)<<left<<"Number of dependents: " <<tape_stats[1]);
-		_pprintLine_("   "<<setw(45)<<left<<"Maximal number of live active variables: " <<tape_stats[2]);
-		_pprintLine_("   "<<setw(45)<<left<<"Size of value stack (number of overwrites): " <<tape_stats[3]);
-		_pprintLine_("   "<<setw(45)<<left<<"Buffer size (a multiple of eight): " <<tape_stats[4]);
-		_pprintLine_("   "<<setw(45)<<left<<"Total number of operations recorded: " <<tape_stats[5]);
-	}
-	#endif  /*}}}*/
-
-	/*Close output and petsc options file and write lock file if requested*/
-	pfclose(output_fid,lockfilename);
-	if (waitonlock>0){
-		_pprintLine_("write lock file:");
-		WriteLockFile(lockfilename);
-	}
-
-	/*Free resources */
-	xDelete<int>(analyses);
-	xDelete<char>(lockfilename);
-	xDelete<char>(binfilename);
-	xDelete<char>(outbinfilename);
-	xDelete<char>(petscfilename);
-	xDelete<char>(rootpath);
+	/*Wrap up: */
 	delete femmodel;
 
-	/*Get finish time and close*/
-	#ifdef _HAVE_MPI_
-	MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( );
-	_pprintLine_("");
-	_pprintLine_("   "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<finish_init-start_init);
-	_pprintLine_("   "<<setw(40)<<left<<"Core solution elapsed time:"<<finish_core-start_core);
-	_pprintLine_("");
-	_pprintLine_("   Total elapsed time:"<<int((finish-start)/3600)<<" hrs "<<int(int(finish-start)%3600/60)<<" min "<<int(finish-start)%60<<" sec");
-	_pprintLine_("");
-	#else
-	finish=(IssmPDouble)clock();
-	_pprintLine_("");
-	_pprintLine_("   "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<(finish_init-start_init)/CLOCKS_PER_SEC);
-	_pprintLine_("   "<<setw(40)<<left<<"Core solution elapsed time:"<<(finish_core-start_core)/CLOCKS_PER_SEC);
-	_pprintLine_("");
-	_pprintLine_("   Total elapsed time:"
-				<<int((finish-start)/CLOCKS_PER_SEC/3600)<<" hrs "
-				<<int(int(finish-start)/CLOCKS_PER_SEC%3600/60)<<" min "
-				<<int(finish-start)/CLOCKS_PER_SEC%60<<" sec");
-	_pprintLine_("");
-	#endif
-	
-	#ifdef _HAVE_PETSC_
-	_pprintLine_("closing MPI and Petsc");
-	PetscFinalize(); 
-	#else
-	#ifdef _HAVE_MPI_
-	_pprintLine_("closing MPI and Petsc");
-	MPI_Finalize();
-	#endif
-	#endif
+	/*Finalize environment:*/
+	EnvironmentFinalize();
 
-	
-	/*end module: */
-	ISSMEND();
+	/*Finalize exception trapping: */
+	ExceptionTrapEnd();
 
-	return 0; //unix success return;
+	/*Return unix success: */
+	return 0; 
 }

Modified: issm/trunk/src/c/solutions/kriging.cpp
===================================================================
--- issm/trunk/src/c/solutions/kriging.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/kriging.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,12 +3,14 @@
  */ 
 
 #include "../issm.h"
-#include "../include/globals.h"
 
 /*Local prototypes*/
 void ProcessArguments2(char** pbinfilename,char** poutbinfilename,char** plockfilename,char** prootpath,int argc,char **argv);
 void ProcessInputfile(IssmDouble **px,IssmDouble **py,IssmDouble **pdata,int *pnobs,IssmDouble **px_interp,IssmDouble **py_interp,int *pninterp,Options **poptions,FILE* fid);
 
+int my_rank;
+int num_procs;
+
 int main(int argc,char **argv){
 
 	/*I/O: */
@@ -22,6 +24,10 @@
 	char *outbinfilename = NULL;
 	char *rootpath       = NULL;
 
+	MPI_Comm comm;
+	extern int my_rank;
+	extern int num_procs;
+
 	/*Input*/
 	int         ninterp,nobs;
 	IssmDouble *x        = NULL;
@@ -35,23 +41,14 @@
 	IssmDouble *predictions = NULL;
 	IssmDouble *error       = NULL;
 
-	ISSMBOOT();
+	/*Initialize exception trapping: */
+	ExceptionTrapBegin();
 
-	/*Initialize environments: Petsc, MPI, etc...: */
-#ifdef _HAVE_PETSC_
-	int ierr=PetscInitialize(&argc,&argv,(char*)0,"");  
-	if(ierr) _error_("Could not initialize Petsc");
-#else
-#ifdef _HAVE_MPI_
-	MPI_Init(&argc,&argv);
-#endif
-#endif
+	/*Initialize environment (MPI, PETSC, MUMPS, etc ...)*/
+	comm=EnvironmentInit(argc,argv);
 
-	/*Size and rank: */
-#ifdef _HAVE_MPI_
-	MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);  
-	MPI_Comm_size(MPI_COMM_WORLD,&num_procs); 
-#endif
+	MPI_Comm_size(comm,&num_procs);
+	MPI_Comm_rank(comm,&my_rank);
 
 	/*First process inputs*/
 	_pprintLine_("");
@@ -75,7 +72,7 @@
 		results->AddObject(new GenericExternalResult<double*>(results->Size()+1,0,predictions,ninterp,1,1,0));
 		results->AddObject(new GenericExternalResult<double*>(results->Size()+1,1,error,ninterp,1,1,0));
 		for(int i=0;i<results->Size();i++){
-			ExternalResult* result=(ExternalResult*)results->GetObjectByOffset(i);
+			ExternalResult* result=dynamic_cast<ExternalResult*>(results->GetObjectByOffset(i));
 			result->WriteData(output_fid,1);
 		}
 		pfclose(output_fid,outbinfilename);
@@ -100,18 +97,11 @@
 	delete options;
 	delete results;
 
-#ifdef _HAVE_PETSC_
-	_pprintLine_("closing MPI and Petsc");
-	PetscFinalize(); 
-#else
-#ifdef _HAVE_MPI_
-	_pprintLine_("closing MPI and Petsc");
-	MPI_Finalize();
-#endif
-#endif
+	/*Finalize environment:*/
+	EnvironmentFinalize();
 
-	/*end module: */
-	ISSMEND();
+	/*Finalize exception trapping: */
+	ExceptionTrapEnd();
 
 	return 0; //unix success return;
 }
@@ -165,7 +155,7 @@
 	Options *options  = NULL;
 	Option  *option   = NULL;
 
-	int dummy,M,N;
+	int      M,N;
 	IoModel* iomodel = new IoModel();
 	iomodel->fid=fid;
 	iomodel->CheckEnumSync();

Modified: issm/trunk/src/c/solutions/objectivefunction.cpp
===================================================================
--- issm/trunk/src/c/solutions/objectivefunction.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/objectivefunction.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,11 +21,9 @@
 
 IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs){
 
-	int i;  
-	
 	/*output: */
 	IssmDouble J;
-	
+
 	/*parameters: */
 	int        solution_type,analysis_type;
 	bool       isstokes       = false;
@@ -69,7 +67,7 @@
 	}
 
 	/*Compute misfit for this velocity field.*/
-	CostFunctionx(&J, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters);
+	femmodel->CostFunctionx(&J);
 
 	/*Free ressources:*/
 	return J;

Modified: issm/trunk/src/c/solutions/prognostic_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/prognostic_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/prognostic_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,15 +16,21 @@
 	/*parameters: */
 	bool save_results;
 	bool issmbgradients,ispdd,isdelta18o;
+	int  solution_type;
+	int  *requested_outputs = NULL;
+	int  numoutputs=0;
 
 	/*activate formulation: */
 	femmodel->SetCurrentConfiguration(PrognosticAnalysisEnum);
-	
+
 	/*recover parameters: */
 	femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
 	femmodel->parameters->FindParam(&issmbgradients,SurfaceforcingsIssmbgradientsEnum);
 	femmodel->parameters->FindParam(&ispdd,SurfaceforcingsIspddEnum);
 	femmodel->parameters->FindParam(&isdelta18o,SurfaceforcingsIsdelta18oEnum);
+	femmodel->parameters->FindParam(&solution_type,SolutionTypeEnum);
+	femmodel->parameters->FindParam(&numoutputs,PrognosticNumRequestedOutputsEnum);
+	if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,PrognosticRequestedOutputsEnum);
 
 	if(issmbgradients){
 	  _printf_(VerboseSolution(),"	call smb gradients module\n");
@@ -40,9 +46,15 @@
 	}
 	if(VerboseSolution()) _pprintLine_("   call computational core");
 	solver_linear(femmodel);
-	
+
 	if(save_results){
 		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ThicknessEnum);
+		femmodel->RequestedOutputsx(requested_outputs,numoutputs);
 	}
+
+	if(solution_type==PrognosticSolutionEnum)femmodel->RequestedDependentsx();
+
+	/*Free ressources:*/
+	xDelete<int>(requested_outputs);
 }

Modified: issm/trunk/src/c/solutions/solutions.h
===================================================================
--- issm/trunk/src/c/solutions/solutions.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/solutions.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -7,6 +7,7 @@
 
 #include "../classes/objects/objects.h"
 #include "../io/io.h"
+#include "../toolkits/toolkits.h"
 
 struct OptArgs;
 class FemModel;
@@ -29,6 +30,8 @@
 void slopecompute_core(FemModel* femmodel);
 void steadystate_core(FemModel* femmodel);
 void transient_core(FemModel* femmodel);
+void dakota_core(FemModel* femmodel);
+void ad_core(FemModel* femmodel);
 IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs);
 
 //convergence:
@@ -44,10 +47,15 @@
 void WriteLockFile(char* filename);
 void controlrestart(FemModel* femmodel,IssmDouble* J);
 void ResetBoundaryConditions(FemModel* femmodel, int analysis_type);
+COMM EnvironmentInit(int argc,char** argv);
+void EnvironmentFinalize(void);
+int  DakotaSpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter);
+void PrintBanner(void);
 
 //solution configuration
 void AnalysisConfiguration(int** panalyses,int* pnumanalyses, int solutiontype);
 void CorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype);
+void WrapperCorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype,bool nodakotacore=false);
 void AdjointCorePointerFromSolutionEnum(void (**padjointcore)(FemModel*),int solutiontype);
 
 #endif

Modified: issm/trunk/src/c/solutions/steadystate_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/steadystate_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/steadystate_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,7 +28,7 @@
 	int  maxiter;
 	int  numoutputs         = 0;
 	int  *requested_outputs = NULL;
-	
+
 	/* recover parameters:*/
 	femmodel->parameters->FindParam(&save_results,SaveResultsEnum);
 	femmodel->parameters->FindParam(&maxiter,SteadystateMaxiterEnum);
@@ -41,7 +41,7 @@
 	step=1;
 
 	for(;;){
-	
+
 		if(VerboseSolution()) _pprintLine_("   computing temperature and velocity for step: " << step);
 		#ifdef _HAVE_THERMAL_
 		if(isenthalpy==0){
@@ -65,18 +65,18 @@
 			if(VerboseSolution()) _pprintLine_("   maximum number steadystate iterations " << maxiter << " reached");
 			break;
 		}
-		
+
 		if(VerboseSolution()) _pprintLine_("   saving velocity, temperature and pressure to check for convergence at next step");
 		InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum,VxPicardEnum);
 		InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VyEnum,VyPicardEnum);
 		InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VzEnum,VzPicardEnum);
 		InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,PressureEnum,PressurePicardEnum);
 		InputDuplicatex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,TemperatureEnum,TemperatureOldEnum);
-		
+
 		//increase counter
 		step++;
 	}
-	
+
 	if(save_results){
 		if(VerboseSolution()) _pprintLine_("   saving results");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,VxEnum);
@@ -88,7 +88,7 @@
 		if(isenthalpy) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,WaterfractionEnum);
 		if(isenthalpy) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,EnthalpyEnum);
 		if(!isenthalpy) InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BasalforcingsMeltingRateEnum);
-		RequestedOutputsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,requested_outputs,numoutputs);
+		femmodel->RequestedOutputsx(requested_outputs,numoutputs);
 	}
 
 	/*Free ressources:*/

Modified: issm/trunk/src/c/solutions/steadystateconvergence.cpp
===================================================================
--- issm/trunk/src/c/solutions/steadystateconvergence.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/steadystateconvergence.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,7 +17,7 @@
 #include "./solutions.h"
 
 bool steadystateconvergence(FemModel* femmodel){
-	
+
 	/*output: */
 	bool converged=false;
 	bool velocity_converged=false;
@@ -31,7 +31,7 @@
 
 	/*retrieve parameters: */
 	femmodel->parameters->FindParam(&convergencecriterionvalue[0],SteadystateReltolEnum);
-	
+
 	/*figure out convergence at the input level, because we don't have the solution vectors!: */
 	velocity_converged=InputConvergencex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,&velocityenums[0],8,&convergencecriterion[0],&convergencecriterionvalue[0],1);
 	temperature_converged=InputConvergencex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,&temperatureenums[0],2,&convergencecriterion[0],&convergencecriterionvalue[0],1);

Modified: issm/trunk/src/c/solutions/surfaceslope_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/surfaceslope_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/surfaceslope_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,7 +25,7 @@
 	solver_linear(femmodel);
 	femmodel->SetCurrentConfiguration(SurfaceSlopeAnalysisEnum,SurfaceSlopeYAnalysisEnum);
 	solver_linear(femmodel);
-	
+
 	if(save_results){
 		if(VerboseSolution()) _pprintLine_("saving results:");
 		InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceSlopeXEnum);

Modified: issm/trunk/src/c/solutions/thermal_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/thermal_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/thermal_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,7 +15,6 @@
 void thermal_core(FemModel* femmodel){
 
 	/*intermediary*/
-	IssmDouble melting_offset;
 	bool   save_results;
 	bool   dakota_analysis  = false;
 

Modified: issm/trunk/src/c/solutions/transient_core.cpp
===================================================================
--- issm/trunk/src/c/solutions/transient_core.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solutions/transient_core.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,7 +30,7 @@
 	int    dim,groundingline_migration;
 	int    numoutputs         = 0;
 	int    *requested_outputs = NULL;
-	
+
 	/*intermediary: */
 	int    step;
 	IssmDouble time;
@@ -77,7 +77,7 @@
 
 		/*Increment*/
 		if(time_adapt){
-			TimeAdaptx(&dt,femmodel->elements, femmodel->nodes,femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters); 
+			femmodel->TimeAdaptx(&dt);
 			if(time+dt>finaltime) dt=finaltime-time;
 			femmodel->parameters->SetParam(dt,TimesteppingTimeStepEnum);
 		}
@@ -106,7 +106,7 @@
 			_error_("ISSM was not compiled with thermal capabilities. Exiting");
 			#endif
 		}
-		
+
 		if(isdiagnostic){
 			if(VerboseSolution()) _pprintLine_("   computing new velocity");
 			#ifdef _HAVE_DIAGNOSTIC_
@@ -120,7 +120,7 @@
 			if(VerboseSolution()) _pprintLine_("   computing new thickness");
 			prognostic_core(femmodel);
 			if(VerboseSolution()) _pprintLine_("   updating vertices positions");
-			UpdateVertexPositionsx(femmodel->elements, femmodel->nodes,femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters); 
+			femmodel->UpdateVertexPositionsx();
 		}
 
 		if(isgroundingline){
@@ -139,7 +139,7 @@
 			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,BedEnum);
 			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceforcingsMassBalanceEnum);
 			InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,MaskElementonfloatingiceEnum);
-			RequestedOutputsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,requested_outputs,numoutputs);
+			femmodel->RequestedOutputsx(requested_outputs,numoutputs);
 
 			if(isdelta18o){
 			        InputToResultx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,SurfaceforcingsMonthlytemperaturesEnum);
@@ -151,8 +151,8 @@
 		}
 	}
 
-	RequestedDependentsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
-	
+	femmodel->RequestedDependentsx();
+
 	/*Free ressources:*/
 	xDelete<int>(requested_outputs);
 }

Modified: issm/trunk/src/c/solvers/solver_adjoint_linear.cpp
===================================================================
--- issm/trunk/src/c/solvers/solver_adjoint_linear.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solvers/solver_adjoint_linear.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -23,9 +23,9 @@
 
 	/*Recover parameters: */
 	femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
-	UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);
+	femmodel->UpdateConstraintsx();
 
-	SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+	femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL);
 	CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
 	Reduceloadx(pf, Kfs, ys,true); xdelete(&Kfs); //true means spc = 0
 	Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); xdelete(&Kff); xdelete(&pf); xdelete(&df);

Modified: issm/trunk/src/c/solvers/solver_linear.cpp
===================================================================
--- issm/trunk/src/c/solvers/solver_linear.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solvers/solver_linear.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,9 +21,9 @@
 
 	/*Recover parameters: */
 	femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
-	UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);
+	femmodel->UpdateConstraintsx();
 
-	SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+	femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL);
 	CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
 	Reduceloadx(pf, Kfs, ys); xdelete(&Kfs);
 	Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); 

Modified: issm/trunk/src/c/solvers/solver_newton.cpp
===================================================================
--- issm/trunk/src/c/solvers/solver_newton.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solvers/solver_newton.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,6 @@
 
 	/*intermediary: */
 	bool   converged;
-	int    num_unstable_constraints;
 	int    count;
 	IssmDouble kmax;
 	Matrix<IssmDouble>* Kff = NULL;
@@ -37,7 +36,7 @@
 	/*Recover parameters: */
 	femmodel->parameters->FindParam(&max_nonlinear_iterations,DiagnosticMaxiterEnum);
 	femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
-	UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);
+	femmodel->UpdateConstraintsx();
 
 	count=1;
 	converged=false;
@@ -56,7 +55,7 @@
 		xdelete(&old_uf);old_uf=uf;
 
 		/*Solver forward model*/
-		SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+		femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
 		Reduceloadx(pf,Kfs,ys);xdelete(&Kfs);
 		Solverx(&uf,Kff,pf,old_uf,df,femmodel->parameters);xdelete(&df);
@@ -83,14 +82,14 @@
 		}
 
 		/*Prepare next iteration using Newton's method*/
-		SystemMatricesx(&Kff,&Kfs,&pf,NULL,&kmax,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+		femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
 		Reduceloadx(pf,Kfs,ys);   xdelete(&Kfs);
 
 		pJf=pf->Duplicate(); Kff->MatMult(uf,pJf); xdelete(&Kff);
 		pJf->Scale(-1.0); pJf->AXPY(pf,+1.0);     xdelete(&pf);
 
-		CreateJacobianMatrixx(&Jff,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,kmax);
+		femmodel->CreateJacobianMatrixx(&Jff,kmax);
 		Solverx(&duf,Jff,pJf,NULL,NULL,femmodel->parameters); xdelete(&Jff); xdelete(&pJf);
 		uf->AXPY(duf, 1.0); xdelete(&duf);
 		Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&ys);

Modified: issm/trunk/src/c/solvers/solver_nonlinear.cpp
===================================================================
--- issm/trunk/src/c/solvers/solver_nonlinear.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solvers/solver_nonlinear.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,8 +22,8 @@
 	Vector<IssmDouble>* pf  = NULL;
 	Vector<IssmDouble>* df  = NULL;
 	Vector<IssmDouble>* ys  = NULL;
-	
-	Loads* loads=NULL;
+
+	Loads* savedloads=NULL;
 	bool converged;
 	int constraints_converged;
 	int num_unstable_constraints;
@@ -32,23 +32,24 @@
 	/*parameters:*/
 	int min_mechanical_constraints;
 	int max_nonlinear_iterations;
-	int  configuration_type;
+	int configuration_type;
 
 	/*Recover parameters: */
 	femmodel->parameters->FindParam(&min_mechanical_constraints,DiagnosticRiftPenaltyThresholdEnum);
 	femmodel->parameters->FindParam(&max_nonlinear_iterations,DiagnosticMaxiterEnum);
 	femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
-	UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);
+	femmodel->UpdateConstraintsx();
 
 	/*Were loads requested as output? : */
-	if(conserve_loads) loads=(Loads*)femmodel->loads->Copy(); //protect loads from being modified by the solution
-	else               loads=(Loads*)femmodel->loads;         //modify loads  in this solution
+	if(conserve_loads){
+		savedloads = static_cast<Loads*>(femmodel->loads->Copy());
+	}
 
 	count=1;
 	converged=false;
 
 	/*Start non-linear iteration using input velocity: */
-	GetSolutionFromInputsx(&ug, femmodel->elements, femmodel->nodes, femmodel->vertices, loads, femmodel->materials, femmodel->parameters);
+	GetSolutionFromInputsx(&ug, femmodel->elements, femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters);
 	Reducevectorgtofx(&uf, ug, femmodel->nodes,femmodel->parameters);
 
 	//Update once again the solution to make sure that vx and vxold are similar (for next step in transient or steadystate)
@@ -61,7 +62,7 @@
 		xdelete(&old_ug);old_ug=ug;
 		xdelete(&old_uf);old_uf=uf;
 
-		SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,loads,femmodel->materials,femmodel->parameters);
+		femmodel->SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
 		Reduceloadx(pf, Kfs, ys); xdelete(&Kfs);
 		Solverx(&uf, Kff, pf, old_uf, df, femmodel->parameters);
@@ -71,7 +72,7 @@
 		InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum);
 		InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug);
 
-		ConstraintsStatex(&constraints_converged, &num_unstable_constraints, femmodel->elements,femmodel->nodes,femmodel->vertices,loads,femmodel->materials,femmodel->parameters);
+		ConstraintsStatex(&constraints_converged, &num_unstable_constraints, femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
 		if(VerboseConvergence()) _pprintLine_("   number of unstable constraints: " << num_unstable_constraints);
 
 		//rift convergence
@@ -107,7 +108,10 @@
 	if(VerboseConvergence()) _pprintLine_("\n   total number of iterations: " << count-1);
 
 	/*clean-up*/
-	if(conserve_loads) delete loads;
+	if(conserve_loads){
+		delete femmodel->loads;
+		femmodel->loads=savedloads;
+	}
 	xdelete(&uf);
 	xdelete(&ug);
 	xdelete(&old_ug);

Modified: issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp
===================================================================
--- issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solvers/solver_stokescoupling_nonlinear.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,23 +13,21 @@
 void solver_stokescoupling_nonlinear(FemModel* femmodel,bool conserve_loads){
 
 	/*intermediary: */
-	Matrix<IssmDouble>*  Kff_horiz = NULL;
-	Matrix<IssmDouble>* Kfs_horiz   = NULL;
-	Vector<IssmDouble>*  ug_horiz  = NULL;
-	Vector<IssmDouble>*  uf_horiz  = NULL;
-	Vector<IssmDouble>*  old_uf_horiz = NULL;
-	Vector<IssmDouble>*  pf_horiz  = NULL;
-	Vector<IssmDouble>*  df_horiz  = NULL;
-	Matrix<IssmDouble>*  Kff_vert  = NULL;
-	Matrix<IssmDouble>*  Kfs_vert  = NULL;
-	Vector<IssmDouble>*  ug_vert   = NULL;
-	Vector<IssmDouble>*  uf_vert   = NULL;
-	Vector<IssmDouble>*  pf_vert   = NULL;
-	Vector<IssmDouble>*  df_vert   = NULL;
-	Vector<IssmDouble>*  ys   = NULL;
+	Matrix<IssmDouble> *Kff_horiz    = NULL;
+	Matrix<IssmDouble> *Kfs_horiz    = NULL;
+	Vector<IssmDouble> *ug_horiz     = NULL;
+	Vector<IssmDouble> *uf_horiz     = NULL;
+	Vector<IssmDouble> *old_uf_horiz = NULL;
+	Vector<IssmDouble> *pf_horiz     = NULL;
+	Vector<IssmDouble> *df_horiz     = NULL;
+	Matrix<IssmDouble> *Kff_vert     = NULL;
+	Matrix<IssmDouble> *Kfs_vert     = NULL;
+	Vector<IssmDouble> *ug_vert      = NULL;
+	Vector<IssmDouble> *uf_vert      = NULL;
+	Vector<IssmDouble> *pf_vert      = NULL;
+	Vector<IssmDouble> *df_vert      = NULL;
+	Vector<IssmDouble> *ys           = NULL;
 	bool converged;
-	int  constraints_converged;
-	int  num_unstable_constraints;
 	int  count;
 
 	/*parameters:*/
@@ -40,8 +38,8 @@
 	/*Recover parameters: */
 	femmodel->parameters->FindParam(&min_mechanical_constraints,DiagnosticRiftPenaltyThresholdEnum);
 	femmodel->parameters->FindParam(&max_nonlinear_iterations,DiagnosticMaxiterEnum);
-	UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);
-	
+	femmodel->UpdateConstraintsx();
+
 	count=1;
 	converged=false;
 
@@ -55,7 +53,7 @@
 		/*First diagnostic horiz:*/
 		femmodel->SetCurrentConfiguration(DiagnosticHorizAnalysisEnum);
 		femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
-	
+
 		//Update once again the solution to make sure that vx and vxold are similar (for next step in transient or steadystate)
 		InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug_horiz);
 		xdelete(&ug_horiz);
@@ -64,7 +62,7 @@
 		xdelete(&old_uf_horiz); old_uf_horiz=uf_horiz;
 
 		/*solve: */
-		SystemMatricesx(&Kff_horiz, &Kfs_horiz, &pf_horiz, &df_horiz, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+		femmodel->SystemMatricesx(&Kff_horiz, &Kfs_horiz, &pf_horiz, &df_horiz, NULL);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
 		Reduceloadx(pf_horiz, Kfs_horiz, ys); xdelete(&Kfs_horiz);
 		Solverx(&uf_horiz, Kff_horiz, pf_horiz, old_uf_horiz, df_horiz,femmodel->parameters);
@@ -76,9 +74,9 @@
 		/*Second compute vertical velocity: */
 		femmodel->SetCurrentConfiguration(DiagnosticVertAnalysisEnum);
 		femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum);
-		
+
 		/*solve: */
-		SystemMatricesx(&Kff_vert, &Kfs_vert, &pf_vert,  &df_vert,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+		femmodel->SystemMatricesx(&Kff_vert, &Kfs_vert, &pf_vert,  &df_vert,NULL);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
 		Reduceloadx(pf_vert, Kfs_vert, ys); xdelete(&Kfs_vert);
 		Solverx(&uf_vert, Kff_vert, pf_vert, NULL, df_vert,femmodel->parameters); xdelete(&Kff_vert); xdelete(&pf_vert); xdelete(&df_vert);

Modified: issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp
===================================================================
--- issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/solvers/solver_thermal_nonlinear.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -35,7 +35,6 @@
 	bool lowmem=0;
 	int  configuration_type;
 
-
 	/*Recover parameters: */
 	kflag=1; pflag=1;
 	femmodel->parameters->FindParam(&lowmem,SettingsLowmemEnum);
@@ -49,11 +48,11 @@
 	if(VerboseSolution()) _pprintLine_("starting direct shooting method");
 	InputUpdateFromConstantx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,true,ResetPenaltiesEnum);
 	InputUpdateFromConstantx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,false,ConvergedEnum);
-	UpdateConstraintsx(femmodel->nodes,femmodel->constraints,femmodel->parameters);
+	femmodel->UpdateConstraintsx();
 
 	for(;;){
 
-		SystemMatricesx(&Kff, &Kfs, &pf,&df, &melting_offset,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
+		femmodel->SystemMatricesx(&Kff, &Kfs, &pf,&df, &melting_offset);
 		CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type);
 		Reduceloadx(pf, Kfs, ys); xdelete(&Kfs); xdelete(&tf);
 		Solverx(&tf, Kff, pf,tf_old, df, femmodel->parameters);
@@ -75,7 +74,7 @@
 		count++;
 
 		InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum);
-		
+
 		if(converged)break;
 	}
 

Modified: issm/trunk/src/c/toolkits/issm/SeqMat.h
===================================================================
--- issm/trunk/src/c/toolkits/issm/SeqMat.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/issm/SeqMat.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -29,7 +29,7 @@
 class SeqMat{
 
 	public:
-	
+
 		int M,N; 
 		doubletype* matrix;  /*here, doubletype is either IssmDouble or IssmPDouble*/
 
@@ -60,11 +60,18 @@
 			if(M*N) this->matrix=xNewZeroInit<doubletype>(pM*pN);
 		}
 		/*}}}*/
+		/*FUNCTION SeqMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){{{*/
+		SeqMat(int m,int n,int pM,int pN,int* d_nnz,int* o_nnz){
+
+			this->M=pM;
+			this->N=pN;
+			this->matrix=NULL;
+			if(pM*pN) this->matrix=xNewZeroInit<doubletype>(pM*pN);
+		}
+		/*}}}*/
 		/*FUNCTION SeqMat(doubletype* serial_mat,int M,int N,doubletype sparsity){{{*/
 		SeqMat(doubletype* serial_mat,int pM,int pN,doubletype sparsity){
 
-			int i,j;
-
 			this->M=pM;
 			this->N=pN;
 			this->matrix=NULL;

Modified: issm/trunk/src/c/toolkits/issm/SeqVec.h
===================================================================
--- issm/trunk/src/c/toolkits/issm/SeqVec.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/issm/SeqVec.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,7 +28,7 @@
 class SeqVec{
 
 	public:
-	
+
 		doubletype* vector;
 		int M;
 
@@ -48,6 +48,14 @@
 			if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
 		}
 		/*}}}*/
+		/*FUNCTION SeqVec(int m,int M){{{*/
+		SeqVec(int pm,int pM){
+
+			this->M=pM;
+			this->vector=NULL;
+			if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
+		}
+		/*}}}*/
 		/*FUNCTION SeqVec(int M,bool fromlocalsize){{{*/
 		SeqVec(int pM,bool fromlocalsize){
 
@@ -59,8 +67,6 @@
 		/*FUNCTION SeqVec(doubletype* serial_vec,int M){{{*/
 		SeqVec(doubletype* buffer,int pM){
 
-			int i,j;
-
 			this->M=pM;
 			this->vector=NULL;
 			if(this->M){

Modified: issm/trunk/src/c/toolkits/mpi/mpiincludes.h
===================================================================
--- issm/trunk/src/c/toolkits/mpi/mpiincludes.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/mpi/mpiincludes.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,7 +6,7 @@
 #define _MPI_INCLUDES_H_
 
 /*MPI includes: */
-#include "mpi.h"
+#include <mpi.h>
 
 /*Patches: */
 #include "./patches/mpipatches.h"

Modified: issm/trunk/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp
===================================================================
--- issm/trunk/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,8 +5,9 @@
 #include <stdio.h>
 #include <math.h>
 #include "../../../shared/shared.h"
+#include "../../../include/types.h"
 
-int DetermineLocalSize(int global_size){
+int DetermineLocalSize(int global_size,COMM comm){
 
 	/*output: */
 	int  local_size;
@@ -17,9 +18,13 @@
 	int* num_local_rows=NULL;
 
 	/*from MPI: */
-	extern int num_procs;
-	extern int my_rank;
-	
+	int num_procs;
+	int my_rank;
+
+	/*recover my_rank*/
+	MPI_Comm_rank(comm,&my_rank);
+	MPI_Comm_size(comm,&num_procs);
+
 	/*We are  not bound by any library, just use what seems most logical*/
 	num_local_rows=xNew<int>(num_procs);    
 
@@ -29,14 +34,14 @@
 		  more even distribution.*/
 		num_local_rows[i]=(int)floor((double)global_size/(double)num_procs); 
 	}
-	
+
 	/*There may be some rows left. Distribute evenly.*/ 
 	row_rest=global_size - num_procs*(int)floor((double)global_size/(double)num_procs);
 	for (i=0;i<row_rest;i++){
 		num_local_rows[i]++;
 	}
 	local_size=num_local_rows[my_rank];
-	
+
 	/*free ressources: */
 	xDelete<int>(num_local_rows);
 

Modified: issm/trunk/src/c/toolkits/mpi/patches/mpipatches.h
===================================================================
--- issm/trunk/src/c/toolkits/mpi/patches/mpipatches.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/mpi/patches/mpipatches.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,17 +2,11 @@
  *  \brief: prototype header for all ISSM add-ons to MPI
  */
 
-
 #ifndef MPI_PATCHES_H_ 
 #define MPI_PATCHES_H_
 
+#include "../../../include/types.h"
 
-int MPI_Boundariesfromrange(int* plower_row, int* pupper_row,int range);
-int MPI_Lowerrow(int n);
-int MPI_Upperrow(int n);
-int DetermineLocalSize(int global_size);
+int DetermineLocalSize(int global_size,COMM comm);
 
-
-
-
 #endif

Modified: issm/trunk/src/c/toolkits/petsc/objects/PetscMat.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/objects/PetscMat.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/objects/PetscMat.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,30 +30,40 @@
 /*FUNCTION PetscMat::PetscMat(int M,int N){{{*/
 PetscMat::PetscMat(int M,int N){
 
-	this->matrix=NewMat(M,N);
+	this->matrix=NewMat(M,N,IssmComm::GetComm());
 }
 /*}}}*/
 /*FUNCTION PetscMat::PetscMat(int M,int N, IssmDouble sparsity){{{*/
 PetscMat::PetscMat(int M,int N, IssmDouble sparsity){
 
-	this->matrix=NewMat(M,N,sparsity);
+	this->matrix=NewMat(M,N,sparsity,IssmComm::GetComm());
 }
 /*}}}*/
-/*FUNCTION PetscMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity){{{*/
+/*FUNCTION PetscMat::PetscMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){{{*/
+PetscMat::PetscMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz){
+
+	MatCreate(IssmComm::GetComm(),&this->matrix);
+	MatSetSizes(this->matrix,m,n,M,N);
+	MatSetFromOptions(this->matrix);
+	MatMPIAIJSetPreallocation(this->matrix,0,d_nnz,0,o_nnz);
+	//MatSetOption(this->matrix,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE);
+
+}
+/*}}}*/
+/*FUNCTION PetscMat::PetscMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity){{{*/
 PetscMat::PetscMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity){
 
 	int     i;
 	int* idxm=NULL;
 	int* idxn=NULL;
-	
+
 	if(M)idxm=xNew<int>(M);
 	if(N)idxn=xNew<int>(N);
 
 	for(i=0;i<M;i++)idxm[i]=i;
 	for(i=0;i<N;i++)idxn[i]=i;
 
-
-	this->matrix=NewMat(M,N,sparsity);
+	this->matrix=NewMat(M,N,sparsity,IssmComm::GetComm());
 	MatSetValues(this->matrix,M,idxm,N,idxn,serial_mat,INSERT_VALUES);
 	MatAssemblyBegin(this->matrix,MAT_FINAL_ASSEMBLY);
 	MatAssemblyEnd(this->matrix,MAT_FINAL_ASSEMBLY);
@@ -65,9 +75,9 @@
 /*}}}*/
 /*FUNCTION PetscMat::PetscMat(int M,int N, int connectivity, int numberofdofspernode){{{*/
 PetscMat::PetscMat(int M,int N, int connectivity,int numberofdofspernode){
-	
-	this->matrix=NewMat(M,N,connectivity,numberofdofspernode);
 
+	this->matrix=NewMat(M,N,connectivity,numberofdofspernode,IssmComm::GetComm());
+
 }
 /*}}}*/
 /*FUNCTION PetscMat::~PetscMat(){{{*/
@@ -77,6 +87,20 @@
 /*}}}*/
 
 /*PetscMat specific routines: */
+/*FUNCTION PetscMat::AllocationInfo{{{*/
+void PetscMat::AllocationInfo(void){
+
+	MatInfo info;
+	MatGetInfo(this->matrix,MAT_GLOBAL_SUM,&info);
+	_pprintLine_("=========================== Stiffness matrix allocation info ===========================");
+	_pprintLine_("");
+	_pprintLine_(" nz_allocated: "<<info.nz_allocated);
+	_pprintLine_(" nz_used     : "<<info.nz_used);
+	_pprintLine_(" nz_unneeded : "<<info.nz_unneeded<<" ("<<double(info.nz_unneeded)/double(info.nz_allocated)*100.<<"%)");
+	_pprintLine_("");
+	_pprintLine_("========================================================================================");
+}
+/*}}}*/
 /*FUNCTION PetscMat::Echo{{{*/
 void PetscMat::Echo(void){
 
@@ -89,20 +113,16 @@
 	_assert_(this->matrix);
 	MatAssemblyBegin(this->matrix,MAT_FINAL_ASSEMBLY);
 	MatAssemblyEnd(this->matrix,MAT_FINAL_ASSEMBLY);
-	#if _PETSC_MAJOR_ == 2 
-		MatCompress(this->matrix);
-	#endif
 
 }
 /*}}}*/
 /*FUNCTION PetscMat::Norm{{{*/
 IssmDouble PetscMat::Norm(NormMode mode){
 
-
 	IssmDouble norm=0;
 	_assert_(this->matrix);
 	MatNorm(this->matrix,ISSMToPetscNormMode(mode),&norm);
-	
+
 	return norm;
 
 }
@@ -127,16 +147,14 @@
 
 	_assert_(this->matrix);
 	_assert_(X->vector);
-	MatMultPatch(this->matrix,X->vector,AX->vector);
+	MatMultPatch(this->matrix,X->vector,AX->vector,IssmComm::GetComm());
 
 }
 /*}}}*/
 /*FUNCTION PetscMat::Duplicate{{{*/
 PetscMat* PetscMat::Duplicate(void){
 
-	PetscMat* output=NULL;
-
-	output=new PetscMat();
+	PetscMat* output=new PetscMat();
 	_assert_(this->matrix);
 	MatDuplicate(this->matrix,MAT_COPY_VALUES,&output->matrix);
 
@@ -149,7 +167,7 @@
 
 	 IssmDouble* output=NULL;
 
-	 MatToSerial(&output,this->matrix);
+	 MatToSerial(&output,this->matrix,IssmComm::GetComm());
 	 return output;
 
 }

Modified: issm/trunk/src/c/toolkits/petsc/objects/PetscMat.h
===================================================================
--- issm/trunk/src/c/toolkits/petsc/objects/PetscMat.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/objects/PetscMat.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,15 +30,17 @@
 		IssmDouble* amatrix;
 		#endif
 
-		/*PetscMat constructors, destructors {{{*/
+		/*PetscMat constructors, destructors*/
 		PetscMat();
 		PetscMat(int M,int N);
 		PetscMat(int M,int N,IssmDouble sparsity);
+		PetscMat(int m,int n,int M,int N,int* d_nnz,int* o_nnz);
 		PetscMat(IssmDouble* serial_mat,int M,int N,IssmDouble sparsity);
 		PetscMat(int M,int N,int connectivity,int numberofdofspernode);
 		~PetscMat();
-		/*}}}*/
-		/*PetscMat specific routines {{{*/
+
+		/*PetscMat specific routines*/
+		void AllocationInfo(void);
 		void Echo(void);
 		void Assemble(void);
 		IssmDouble Norm(NormMode norm_type);
@@ -49,8 +51,6 @@
 		IssmDouble* ToSerial(void);
 		void SetValues(int m,int* idxm,int n,int* idxn,IssmDouble* values,InsMode mode);
 		void Convert(MatrixType type);
-		/*}}}*/
+};
 
-};
-		
 #endif //#ifndef _PETSCMAT_H_

Modified: issm/trunk/src/c/toolkits/petsc/objects/PetscVec.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/objects/PetscVec.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/objects/PetscVec.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,16 +28,26 @@
 /*}}}*/
 /*FUNCTION PetscVec::PetscVec(int M,bool fromlocalsize){{{*/
 PetscVec::PetscVec(int M,bool fromlocalsize){
-	
-	this->vector=NewVec(M,fromlocalsize);
 
+	this->vector=NewVec(M,IssmComm::GetComm(),fromlocalsize);
+
 }
 /*}}}*/
+/*FUNCTION PetscVec::PetscVec(int m,int M){{{*/
+PetscVec::PetscVec(int m,int M){
+
+	VecCreate(IssmComm::GetComm(),&this->vector);
+	VecSetSizes(this->vector,m,M);
+	VecSetFromOptions(this->vector);
+	VecSet(this->vector,0.0);
+
+}
+/*}}}*/
 /*FUNCTION PetscVec::PetscVec(Vec petsc_vec){{{*/
 PetscVec::PetscVec(Vec petsc_vec){
 
 	if(petsc_vec==NULL){
-		this->vector=NewVec(0);
+		this->vector=NewVec(0,IssmComm::GetComm());
 	}
 	else{
 		/*copy vector*/
@@ -54,7 +64,7 @@
 	if(M)idxm=xNew<int>(M);
 	for(int i=0;i<M;i++) idxm[i]=i;
 
-	this->vector=NewVec(M);
+	this->vector=NewVec(M,IssmComm::GetComm());
 	VecSetValues(this->vector,M,idxm,serial_vec,INSERT_VALUES);
 	VecAssemblyBegin(this->vector);
 	VecAssemblyEnd(this->vector);
@@ -78,7 +88,7 @@
 /*}}}*/
 /*FUNCTION PetscVec::Assemble{{{*/
 void PetscVec::Assemble(void){
-		
+
 	_assert_(this->vector);
 	VecAssemblyBegin(this->vector); 
 	VecAssemblyEnd(this->vector);
@@ -87,7 +97,7 @@
 /*}}}*/
 /*FUNCTION PetscVec::SetValues{{{*/
 void PetscVec::SetValues(int ssize, int* list, IssmDouble* values, InsMode mode){
-	
+
 	_assert_(this->vector);
 	VecSetValues(this->vector,ssize,list,values,ISSMToPetscInsertMode(mode));
 
@@ -127,12 +137,11 @@
 /*}}}*/
 /*FUNCTION PetscVec::Duplicate{{{*/
 PetscVec* PetscVec::Duplicate(void){
-	
-	PetscVec* output=NULL;
+
 	_assert_(this->vector);
 	Vec vec_output=NULL;
 	VecDuplicate(this->vector,&vec_output);
-	output=new PetscVec(vec_output);
+	PetscVec* output=new PetscVec(vec_output);
 	VecFree(&vec_output);
 
 	return output;
@@ -164,9 +173,9 @@
 /*}}}*/
 /*FUNCTION PetscVec::ToMPISerial{{{*/
 IssmDouble* PetscVec::ToMPISerial(void){
-	
+
 	IssmDouble* vec_serial=NULL;
-	VecToMPISerial(&vec_serial, this->vector);
+	VecToMPISerial(&vec_serial, this->vector,IssmComm::GetComm());
 	return vec_serial;
 
 }

Modified: issm/trunk/src/c/toolkits/petsc/objects/PetscVec.h
===================================================================
--- issm/trunk/src/c/toolkits/petsc/objects/PetscVec.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/objects/PetscVec.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,7 +18,6 @@
 #include "../petscincludes.h"
 #include "../../../include/include.h"
 
-
 /*}}}*/
 
 class PetscVec{
@@ -30,15 +29,15 @@
 		IssmDouble* avector;
 		#endif
 
-
-		/*PetscVec constructors, destructors {{{*/
+		/*PetscVec constructors, destructors*/
 		PetscVec();
 		PetscVec(int M,bool fromlocalsize=false);
+		PetscVec(int m,int M);
 		PetscVec(IssmDouble* buffer, int M);
 		PetscVec(Vec petsc_vec);
 		~PetscVec();
-		/*}}}*/
-		/*PetscVec specific routines {{{*/
+
+		/*PetscVec specific routines*/
 		void Echo(void);
 		void Assemble(void);
 		void SetValues(int ssize, int* list, IssmDouble* values, InsMode mode);
@@ -56,7 +55,6 @@
 		void Scale(IssmDouble scale_factor);
 		void PointwiseDivide(PetscVec* x,PetscVec* y);
 		IssmDouble Dot(PetscVec* vector);
-		/*}}}*/
 };
 
 #endif //#ifndef _PETSCVEC_H_

Modified: issm/trunk/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,6 @@
  *  lower row and upper row from a matrix a cpu owns.
  */
 
-
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -13,27 +12,27 @@
 #include <stdio.h>
 #include "../../../shared/shared.h"
 
-void GetOwnershipBoundariesFromRange(int* plower_row,int* pupper_row,int range){
+void GetOwnershipBoundariesFromRange(int* plower_row,int* pupper_row,int range,COMM comm){
 
 	/*externals :*/
-	extern int my_rank;
-	extern int num_procs;
-	
+	int my_rank;
+	int num_procs;
+
+	/*recover my_rank and num_procs:*/
+	MPI_Comm_size(comm,&num_procs);
+	MPI_Comm_rank(comm,&my_rank);
+
 	/*output: */
 	int lower_row,upper_row;
-	
-	/*intermediary :*/
-	int i;
-	int* allranges=NULL;
 
 	/*Gather all range values into allranges, for all nodes*/
-	allranges=xNew<int>(num_procs);
-	MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,MPI_COMM_WORLD);
+	int* allranges=xNew<int>(num_procs);
+	MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,comm);
 
 	/*From all ranges, get lower row and upper row*/
 	lower_row=0;
 	upper_row=lower_row+allranges[0];
-	for (i=1;i<=my_rank;i++){
+	for(int i=1;i<=my_rank;i++){
 		lower_row=lower_row+allranges[i-1];
 		upper_row=upper_row+allranges[i];
 	}

Modified: issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscInsertMode.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief: convert InsertMode from ISSM to Petsc
  */
 
-
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -10,15 +9,14 @@
 #endif
 
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 /*ISSM includes: */
 #include "../../toolkitsenums.h"
 #include "../../../shared/shared.h"
 
-
 InsertMode ISSMToPetscInsertMode(InsMode mode){
 
 	switch(mode){

Modified: issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscMatrixType.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscMatrixType.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscMatrixType.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief: convert MatrixType from ISSM to Petsc
  */
 
-
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -10,17 +9,16 @@
 #endif
 
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 /*ISSM includes: */
 #include "../../toolkitsenums.h"
 #include "../../../shared/shared.h"
 
+const MatType ISSMToPetscMatrixType(MatrixType type){
 
-MatType ISSMToPetscMatrixType(MatrixType type){
-
 	switch(type){
 		case DENSE_SEQUENTIAL:  
 			return MATSEQDENSE;

Modified: issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/ISSMToPetscNormMode.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief: convert NormMode from ISSM to Petsc
  */
 
-
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -10,15 +9,14 @@
 #endif
 
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 /*ISSM includes: */
 #include "../../toolkitsenums.h"
 #include "../../../shared/shared.h"
 
-
 NormType ISSMToPetscNormMode(NormMode mode){
 
 	switch(mode){

Modified: issm/trunk/src/c/toolkits/petsc/patches/KSPFree.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/KSPFree.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/KSPFree.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,11 +8,10 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
-
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 void KSPFree(KSP* pksp){
 
@@ -25,4 +24,3 @@
 	#endif
 
 }
-

Modified: issm/trunk/src/c/toolkits/petsc/patches/MatFree.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/MatFree.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/MatFree.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,11 +8,10 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
-
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscmat.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscmat.h>
+#include <petscksp.h>
 
 void MatFree(Mat* pmat){
 
@@ -25,4 +24,3 @@
 	#endif
 
 }
-

Modified: issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/MatMultPatch.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,29 +9,29 @@
 #endif
 
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 #include "../../../shared/shared.h"
 
 /*Function prototypes: */
-int MatMultCompatible(Mat A,Vec x);
-void VecRelocalize(Vec* outvector,Vec vector,int m);
+int MatMultCompatible(Mat A,Vec x,COMM comm);
+void VecRelocalize(Vec* outvector,Vec vector,int m,COMM comm);
 
-void MatMultPatch(Mat A,Vec X, Vec AX){ //same prototype as MatMult in Petsc
+void MatMultPatch(Mat A,Vec X, Vec AX,COMM comm){ //same prototype as MatMult in Petsc
 
 	int m,n;
 	Vec X_rel=NULL;
 
 	_assert_(A); _assert_(X);
 
-	if (MatMultCompatible(A,X)){
+	if (MatMultCompatible(A,X,comm)){
 		MatMult(A,X,AX); 
 	}
 	else{
 		MatGetLocalSize(A,&m,&n);;
-		VecRelocalize(&X_rel,X,n);
+		VecRelocalize(&X_rel,X,n,comm);
 		MatMult(A,X_rel,AX); ;
 		#if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2)
 		VecDestroy(X_rel);
@@ -41,24 +41,27 @@
 	}
 }
 
-int MatMultCompatible(Mat A,Vec x){
-	
+int MatMultCompatible(Mat A,Vec x,COMM comm){
+
 	/*error management*/
-	
+
 	int local_m,local_n;
-	int lower_row,upper_row,range;
+	int range;
 	int result=1;
 	int sumresult;
-	extern int num_procs;
+	int num_procs;
 
+	/*recover num_procs:*/
+	MPI_Comm_size(comm,&num_procs);
+
 	MatGetLocalSize(A,&local_m,&local_n);;
 	VecGetLocalSize(x,&range);;
-	
+
 	if (local_n!=range)result=0;
-	
+
 	/*synchronize result: */
-	MPI_Reduce (&result,&sumresult,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD );
-	MPI_Bcast(&sumresult,1,MPI_INT,0,MPI_COMM_WORLD);                
+	MPI_Reduce (&result,&sumresult,1,MPI_INT,MPI_SUM,0,comm );
+	MPI_Bcast(&sumresult,1,MPI_INT,0,comm);                
 	if (sumresult!=num_procs){
 		result=0;
 	}
@@ -68,7 +71,7 @@
 	return result;
 }
 
-void VecRelocalize(Vec* poutvector,Vec vector,int m){
+void VecRelocalize(Vec* poutvector,Vec vector,int m,COMM comm){
 
 	/*vector index and vector values*/
 	int* index=NULL;
@@ -77,9 +80,9 @@
 
 	/*output: */
 	Vec outvector=NULL;
-	
+
 	/*Create outvector with local size m*/
-	VecCreate(PETSC_COMM_WORLD,&outvector); ; 
+	VecCreate(comm,&outvector); ; 
 	VecSetSizes(outvector,m,PETSC_DECIDE); ; 
 	VecSetFromOptions(outvector); ; 
 

Modified: issm/trunk/src/c/toolkits/petsc/patches/MatToSerial.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/MatToSerial.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/MatToSerial.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,16 +8,15 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
-
 #include "../petscincludes.h"
 #include "../../../shared/shared.h"
 
-void MatToSerial(double** poutmatrix,Mat matrix){
+void MatToSerial(double** poutmatrix,Mat matrix,COMM comm){
 
 	int i;
-	extern int my_rank;
-	extern int num_procs;
-	
+	int my_rank;
+	int num_procs;
+
 	/*Petsc variables*/
 	PetscInt lower_row,upper_row; 
 	int range;
@@ -27,10 +26,14 @@
 	int* idxn=NULL; 
 	double* local_matrix=NULL; /*matrix local to each node used for temporary holding matrix values*/
 	int buffer[3];
-	
+
+	/*recover my_rank and num_procs:*/
+	MPI_Comm_size(comm,&num_procs);
+	MPI_Comm_rank(comm,&my_rank);
+
 	/*Output*/
 	double* outmatrix=NULL;
-	
+
 	/*get matrix size: */
 	MatGetSize(matrix,&M,&N);
 
@@ -38,46 +41,46 @@
 	MatGetOwnershipRange(matrix,&lower_row,&upper_row);    
 	upper_row--; 
 	range=upper_row-lower_row+1;
-	
+
 	/*Local and global allocation*/
 	if (my_rank==0)outmatrix=xNew<double>(M*N);
-	
+
 	if (range){
 		local_matrix=xNew<double>(N*range);
 		idxm=xNew<int>(range);  
 		idxn=xNew<int>(N);  
-	 
+
 		for (i=0;i<N;i++){
 			*(idxn+i)=i;
 		}
 		for (i=0;i<range;i++){
 			*(idxm+i)=lower_row+i;
 		}
-	
+
 		MatGetValues(matrix,range,idxm,N,idxn,local_matrix);     
 	}
 
 	/*Now each node holds its local_matrix containing range rows. 
 	 * We send these rows to the matrix on node 0*/
-	
+
 	for (i=1;i<num_procs;i++){
 		if (my_rank==i){ 
 			buffer[0]=my_rank;
 			buffer[1]=lower_row;
 			buffer[2]=range;
-			MPI_Send(buffer,3,MPI_INT,0,1,MPI_COMM_WORLD);   
-			if (range)MPI_Send(local_matrix,N*range,MPI_DOUBLE,0,1,MPI_COMM_WORLD); 
+			MPI_Send(buffer,3,MPI_INT,0,1,comm);   
+			if (range)MPI_Send(local_matrix,N*range,MPI_DOUBLE,0,1,comm); 
 		}
 		if (my_rank==0){
-			MPI_Recv(buffer,3,MPI_INT,i,1,MPI_COMM_WORLD,&status); 
-			if (buffer[2])MPI_Recv(outmatrix+(buffer[1]*N),N*buffer[2],MPI_DOUBLE,i,1,MPI_COMM_WORLD,&status);
+			MPI_Recv(buffer,3,MPI_INT,i,1,comm,&status); 
+			if (buffer[2])MPI_Recv(outmatrix+(buffer[1]*N),N*buffer[2],MPI_DOUBLE,i,1,comm,&status);
 		}
 	} 
 	if (my_rank==0){ 
 		//Still have the local_matrix on node 0 to take care of.
 		memcpy(outmatrix,local_matrix,N*range*sizeof(double));
 	} 
-	
+
 	/*Assign output pointer: */
 	*poutmatrix=outmatrix;
 	xDelete<int>(idxm);

Modified: issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/NewMat.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,9 +9,9 @@
 #endif
 
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 #include "./petscpatches.h"
 
@@ -20,7 +20,7 @@
 #include "../../mpi/patches/mpipatches.h"
 
 /*NewMat(int M,int N){{{*/
-Mat NewMat(int M,int N){
+Mat NewMat(int M,int N,COMM comm){
 
 	/*output:*/
 	Mat outmatrix=NULL;
@@ -31,24 +31,24 @@
 	int    d_nz,o_nz,nnz;
 
 	/*Determine local sizes: */
-	m=DetermineLocalSize(M);
-	n=DetermineLocalSize(N);
-	
+	m=DetermineLocalSize(M,comm);
+	n=DetermineLocalSize(N,comm);
+
 	nnz=(int)((double)M*(double)N*sparsity); //number of non zeros.
 	d_nz=(int)((double)nnz/(double)M/2.0); //number of non zeros per row/2
 	o_nz=(int)((double)nnz/(double)M/2.0); //number of non zeros per row/2
 
 	#if _PETSC_MAJOR_ == 3 && _PETSC_MINOR_ > 2
-	MatCreateAIJ(MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 
+	MatCreateAIJ(comm,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 
 	#else
-	MatCreateMPIAIJ(MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 
+	MatCreateMPIAIJ(comm,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 
 	#endif
 
 	return outmatrix;
 }
 /*}}}*/
-/*NewMat(int M,int N,double sparsity){{{*/
-Mat NewMat(int M,int N,double sparsity){
+/*NewMat(int M,int N,double sparsity,COMM comm){{{*/
+Mat NewMat(int M,int N,double sparsity,COMM comm){
 
 	/*output:*/
 	Mat outmatrix=NULL;
@@ -59,29 +59,29 @@
 	int    nnz;
 
 	/*Determine local sizes: */
-	m=DetermineLocalSize(M);
-	n=DetermineLocalSize(N);
-	
+	m=DetermineLocalSize(M,comm);
+	n=DetermineLocalSize(N,comm);
+
 	nnz=(int)((double)M*(double)N*sparsity); //number of non zeros.
 	d_nz=(int)((double)nnz/(double)M/2.0); //number of non zeros per row/2
 	o_nz=(int)((double)nnz/(double)M/2.0); //number of non zeros per row/2
 
 	#if _PETSC_MAJOR_ == 3 && _PETSC_MINOR_ > 2
 	if(sparsity==1){
-		MatCreateDense(MPI_COMM_WORLD,m,n,M,N,NULL,&outmatrix); 
+		MatCreateDense(comm,m,n,M,N,NULL,&outmatrix); 
 	}
 	else{
-		MatCreateAIJ(MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 
+		MatCreateAIJ(comm,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 
 	}
 	#else
-	MatCreateMPIAIJ(MPI_COMM_WORLD,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 
+	MatCreateMPIAIJ(comm,m,n,M,N,d_nz,NULL,o_nz,NULL,&outmatrix); 
 	#endif
 
 	return outmatrix;
 }
 /*}}}*/
 /*NewMat(int M,int N,int connectivity,int numberofdofspernode){{{*/
-Mat NewMat(int M,int N,int connectivity,int numberofdofspernode){
+Mat NewMat(int M,int N,int connectivity,int numberofdofspernode,COMM comm){
 
 	/*output:*/
 	Mat outmatrix=NULL;
@@ -89,29 +89,32 @@
 	/*parameters: */
 	int    m,n;
 	int    d_nz,o_nz;
-	int    nnz;
 
 	#if _PETSC_MAJOR_ >= 3 
+	#ifdef _HAVE_PETSCDEV_
+	MatType type;
+	#else
 	const MatType type;
+	#endif
 	#else
 	MatType type;
 	#endif
 
 	/*Determine local sizes: */
-	m=DetermineLocalSize(M);
-	n=DetermineLocalSize(N);
+	m=DetermineLocalSize(M,comm);
+	n=DetermineLocalSize(N,comm);
 
 	/*Figure out number of non zeros per row: */
 	d_nz=(int)connectivity*numberofdofspernode/2;
 	o_nz=(int)connectivity*numberofdofspernode/2;
 
-	MatCreate(MPI_COMM_WORLD,&outmatrix);
+	MatCreate(comm,&outmatrix);
 	MatSetSizes(outmatrix,m,n,M,N);
 	MatSetFromOptions(outmatrix);
 
 	/*preallocation  according to type: */
 	MatGetType(outmatrix,&type);
-	
+
 	#if _PETSC_MAJOR_ == 2 
 	if((strcmp(type,"mpiaij")==0) || (strcmp(type,"aijmumps")==0)){
 		MatMPIAIJSetPreallocation(outmatrix,d_nz,NULL,o_nz,NULL);

Modified: issm/trunk/src/c/toolkits/petsc/patches/NewVec.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/NewVec.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/NewVec.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,9 +16,8 @@
 #include "./petscpatches.h"
 #include "../../mpi/patches/mpipatches.h"
 
-Vec NewVec(int size,bool fromlocalsize){
+Vec NewVec(int size,COMM comm,bool fromlocalsize){
 
-	int ierr;
 	int local_size;
 
 	/*output: */
@@ -29,11 +28,11 @@
 		local_size=size;
 	}
 	else{
-		local_size=DetermineLocalSize(size);
+		local_size=DetermineLocalSize(size,comm);
 	}
-	
-	VecCreate(PETSC_COMM_WORLD,&vector); 
-	
+
+	VecCreate(comm,&vector); 
+
 	VecSetSizes(vector,local_size,PETSC_DECIDE); 
 	VecSetFromOptions(vector); 
 

Modified: issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,7 +2,6 @@
  * \brief: convert a sparse or dense Petsc matrix into a matlab matrix
  */
 
-
 #ifdef HAVE_CONFIG_H
 	#include <config.h>
 #else
@@ -12,31 +11,25 @@
 #include <string>
 
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 /*Petsc includes: */
 #include "../../../shared/shared.h"
 
-
 void PetscMatrixToDoubleMatrix(double** pmatrix, int* prows, int* pcols,Mat petsc_matrix){
 
-	int i,j,k;
-
 	/*output: */
+	int     i;
 	double* matrix=NULL;
 	int     rows,cols;
 
-	/*intermediary: */
-	int*    idxm=NULL;
-	int*    idxn=NULL;
-
 	/*Some needed information: */
 	MatGetSize(petsc_matrix,&rows,&cols);
 
-	idxm=xNew<int>(rows);
-	idxn=xNew<int>(cols);
+	int* idxm=xNew<int>(rows);
+	int* idxn=xNew<int>(cols);
 
 	for(i=0;i<rows;i++)idxm[i]=i;
 	for(i=0;i<cols;i++)idxn[i]=i;

Modified: issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsDetermineSolverType.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -52,7 +52,6 @@
 		solver_type=SUPERLUDISTPACKAGE;
 	}
 
-
 	#if _PETSC_MAJOR_ >= 3 
 	PetscOptionsGetString(PETSC_NULL,"-pc_factor_mat_solver_package",&option[0],100,&flag);
 	if (strcmp(option,"mumps")==0){
@@ -60,7 +59,6 @@
 	}
 	#endif
 
-	
 	PetscOptionsGetString(PETSC_NULL,"-issm_option_solver",&option[0],100,&flag);
 	if (strcmp(option,"stokes")==0){
 		solver_type=StokesSolverEnum;

Modified: issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,9 +9,9 @@
 #endif
 
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 #include "./petscpatches.h"
 
@@ -20,7 +20,6 @@
 
 void PetscOptionsInsertMultipleString(char* options_string){
 
-
 	/*The list of options is going to be pairs of the type "-option option_value"*/
 	#if _PETSC_MAJOR_ == 2
 		PetscToken *token=NULL ;
@@ -29,22 +28,18 @@
 	#endif
 	char* first=NULL;
 	char* second=NULL;
-	char* final=NULL;
 	size_t len;
-	int ignore_second;
 	int first_token=1;
 
-
 	PetscTokenCreate(options_string,' ',&token);
 	for (;;){
-		
 
 		/*Read next tokens*/
 		if(first_token){
 			PetscTokenFind(token,&first);
 		}
 		PetscTokenFind(token,&second);
-		
+
 		if (!first){
 			/*We are at the end of options*/
 			break;
@@ -58,7 +53,7 @@
 			}
 			/*Reduce first to bare option value*/
 			PetscStrlen(first,&len);
-			while (len > 0 && (first[len-1] == ' ' || first[len-1] == 'n')) {
+			while (len > 0 && first[len-1] == ' ') {
 				len--; first[len] = 0;
 			}
 			PetscOptionsSetValue(first,second);
@@ -69,7 +64,7 @@
 			if (second[0]=='-'){
 				/*Second is another option, ignore it*/
 				PetscStrlen(first,&len);
-				while (len > 0 && (first[len-1] == ' ' || first[len-1] == 'n')) {
+				while (len > 0 && first[len-1] == ' ' ) {
 					len--; first[len] = 0;
 				}
 				PetscOptionsSetValue(first,NULL);
@@ -80,7 +75,7 @@
 			else{
 				/*Second is 'first' option's value*/
 				PetscStrlen(second,&len);
-				while (len > 0 && (second[len-1] == ' ' || second[len-1] == 'n')) {
+				while (len > 0 && second[len-1] == ' ') {
 					len--; second[len] = 0;
 				}
 				PetscOptionsSetValue(first,second);

Modified: issm/trunk/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,26 +10,24 @@
 #include <string>
 
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 #include "../../../shared/shared.h"
 
 void PetscVectorToDoubleVector(double** pvector, int* prows, Vec petsc_vector){
 
-	int     i;
 	int     rows;
-	int    *idxm   = NULL;
 	double *vector = NULL;
 
 	/*Get size of vector: */
 	if(petsc_vector){
 		VecGetSize(petsc_vector,&rows);
 		if(rows){
-			idxm=xNew<int>(rows);
+			int* idxm=xNew<int>(rows);
 			vector=xNew<double>(rows);
-			for(i=0;i<rows;i++)idxm[i]=i;
+			for(int i=0;i<rows;i++)idxm[i]=i;
 			VecGetValues(petsc_vector,rows,idxm,vector);
 			xDelete<int>(idxm);
 		}

Modified: issm/trunk/src/c/toolkits/petsc/patches/SolverEnum.h
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/SolverEnum.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/SolverEnum.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,6 +14,4 @@
 	SUPERLUDISTPACKAGE,
 } EXTERNALPACKAGES; 
 
-
 #endif //ifndef _SOLVERENUM_H_
-

Modified: issm/trunk/src/c/toolkits/petsc/patches/VecDuplicatePatch.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/VecDuplicatePatch.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/VecDuplicatePatch.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,11 +8,10 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
-
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 void VecDuplicatePatch(Vec* output, Vec input){
 

Modified: issm/trunk/src/c/toolkits/petsc/patches/VecFree.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/VecFree.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/VecFree.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,11 +8,10 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
-
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 void VecFree(Vec* pvec){
 
@@ -24,4 +23,3 @@
 	*pvec=NULL;
 
 }
-

Modified: issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,9 +9,9 @@
 #endif
 
 /*Petsc includes: */
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
 
 #include "./petscpatches.h"
 
@@ -20,20 +20,18 @@
 
 void VecMerge(Vec A, Vec B, double* row_partition_vector,int row_partition_size){
 
-	int i;
-	
 	/*Petsc matrix*/
 	int lower_row,upper_row,range;
 	int* idxm=NULL;
 	double* values=NULL;
 
 	/*Vector sizes: */
-	int MA,MB;
+	int MB;
 
 	VecGetSize(B,&MB);
 
 	/*If the dimension of the partitioning vector is not the same as that of vector B, we have a problem: */
-	if ( (row_partition_size !=MB) ){
+	if ((row_partition_size !=MB) ){
 		_error_("Dimensions of partitioning vector incompatible with dimensions of input vector\n");
 	}
 
@@ -46,17 +44,17 @@
 		/*This node owns rows of vector B, get them*/
 		idxm=xNew<int>(range);
 		values=xNew<double>(range);
-		for (i=0;i<range;i++){
-			*(idxm+i)=lower_row+i;
+		for(int i=0;i<range;i++){
+			idxm[i]=lower_row+i;
 		}
 		VecGetValues(B,range,idxm,values);
 		/*Now, modify idxm using the partition vector, and plug values into A*/
-		for (i=0;i<range;i++){
-			*(idxm+i)=(int)*(row_partition_vector+lower_row+i)-1; //-1 because partition vector comes from Matlab, where indices start at 1.
+		for(int i=0;i<range;i++){
+			idxm[i]=int(row_partition_vector[lower_row+i])-1; //-1 because partition vector comes from Matlab, where indices start at 1.
 		}
 		VecSetValues(A,range,idxm,values,INSERT_VALUES);
 	}
-	
+
 	/*Assemble vector*/
 	VecAssemblyBegin(A);
 	VecAssemblyEnd(A);

Modified: issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,15 +8,14 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
-
 #include "../petscincludes.h"
 #include "../../../shared/shared.h"
 
-int VecToMPISerial(double** pgathered_vector, Vec vector){
-	
+int VecToMPISerial(double** pgathered_vector, Vec vector,COMM comm){
+
 	int i;
-	extern int num_procs; 
-	extern int my_rank;
+	int num_procs; 
+	int my_rank;
 
 	/*Petsc*/
 	MPI_Status status;
@@ -24,16 +23,20 @@
 	int range;
 	int * idxn=NULL; 
 	int buffer[3];
-	
+
 	/*intermediary results*/
 	double* local_vector=NULL;
 
 	/*input*/
 	int vector_size;
-	
+
 	/*Output*/
 	double* gathered_vector=NULL; //Global vector holding the final assembled vector on all nodes.
 
+	/*recover my_rank and num_procs*/
+	MPI_Comm_size(comm,&num_procs);
+	MPI_Comm_rank(comm,&my_rank);
+
 	VecGetSize(vector,&vector_size);
 	if(vector_size==0){
 		*pgathered_vector=NULL;
@@ -42,7 +45,7 @@
 
 	/*Allocate gathered vector on all nodes .*/
 	gathered_vector=xNew<double>(vector_size);
-	
+
 	/*Allocate local vectors*/
 	VecGetOwnershipRange(vector,&lower_row,&upper_row);
 	upper_row--;
@@ -65,12 +68,12 @@
 			buffer[0]=my_rank;
 			buffer[1]=lower_row;
 			buffer[2]=range;
-			MPI_Send(buffer,3,MPI_INT,0,1,MPI_COMM_WORLD);  
-			if (range)MPI_Send(local_vector,range,MPI_DOUBLE,0,1,MPI_COMM_WORLD); 
+			MPI_Send(buffer,3,MPI_INT,0,1,comm);  
+			if (range)MPI_Send(local_vector,range,MPI_DOUBLE,0,1,comm); 
 		}
 		if (my_rank==0){
-			MPI_Recv(buffer,3,MPI_INT,i,1,MPI_COMM_WORLD,&status); 
-			if (buffer[2])MPI_Recv(gathered_vector+buffer[1],buffer[2],MPI_DOUBLE,i,1,MPI_COMM_WORLD,&status);
+			MPI_Recv(buffer,3,MPI_INT,i,1,comm,&status); 
+			if (buffer[2])MPI_Recv(gathered_vector+buffer[1],buffer[2],MPI_DOUBLE,i,1,comm,&status);
 		}
 	}
 
@@ -80,14 +83,14 @@
 	}
 
 	/*Now, broadcast gathered_vector from node 0 to other nodes: */
-	MPI_Bcast(gathered_vector,vector_size,MPI_DOUBLE,0,MPI_COMM_WORLD);
+	MPI_Bcast(gathered_vector,vector_size,MPI_DOUBLE,0,comm);
 
 	/*Assign output pointers: */
 	*pgathered_vector=gathered_vector;
-	
+
 	/*free ressources: */
 	xDelete<int>(idxn);
 	xDelete<double>(local_vector);
-	
+
 	return 1;
 }

Modified: issm/trunk/src/c/toolkits/petsc/patches/petscpatches.h
===================================================================
--- issm/trunk/src/c/toolkits/petsc/patches/petscpatches.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/petsc/patches/petscpatches.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,42 +5,39 @@
 #ifndef _PETSC_PATCHES_H_
 #define _PETSC_PATCHES_H_
 
-#include "petscmat.h"
-#include "petscvec.h"
-#include "petscksp.h"
-#include "petscsys.h"
+#include <petscmat.h>
+#include <petscvec.h>
+#include <petscksp.h>
+#include <petscsys.h>
 
 #include "./SolverEnum.h"
 #include "../../toolkitsenums.h"
+#include "../../../include/types.h"
 
 class Parameters;
 
-Vec NewVec(int size,bool fromlocalsize=false);
-Mat NewMat(int M,int N);
-Mat NewMat(int M,int N,double sparsity);
-Mat NewMat(int M,int N,int connectivity,int numberofdofspernode);
+Vec NewVec(int size,COMM comm,bool fromlocalsize=false);
+Mat NewMat(int M,int N,COMM comm);
+Mat NewMat(int M,int N,double sparsity,COMM comm);
+Mat NewMat(int M,int N,int connectivity,int numberofdofspernode, COMM comm);
 
-int VecTranspose(Vec* tvector,Vec vector);
-int VecToMPISerial(double** pgathered_vector, Vec vector);
-void GetOwnershipBoundariesFromRange(int* plower_row,int* pupper_row,int range);
+int VecToMPISerial(double** pgathered_vector, Vec vector,COMM comm);
 void MatFree(Mat* pmat);
 void ISFree(IS* pis);
 void VecFree(Vec* pvec);
 void KSPFree(KSP* pksp);
-void VecPartition(Vec* poutvector,Vec vectorA, double* row_partition_vector, int row_partition_vector_size,bool kffpartitioning);
 int MatPartition(Mat* poutmatrix,Mat matrixA,double* row_partition_vector,int row_partition_vector_size ,
 		double* col_partition_vector,int col_partition_vector_size);
-void MatInvert(Mat* pInv, Mat Matrix);
 void PetscOptionsInsertMultipleString(char* options_string);
 void PetscOptionsDetermineSolverType(int* psolver_type);
 void VecMerge(Vec A, Vec B, double* row_partition_vector,int row_partition_size);
-void MatMultPatch(Mat A,Vec X, Vec AX);
-void MatToSerial(double** poutmatrix,Mat matrix);
+void MatMultPatch(Mat A,Vec X, Vec AX,COMM comm);
+void MatToSerial(double** poutmatrix,Mat matrix,COMM comm);
 void VecDuplicatePatch(Vec* output, Vec input);
 Vec  SerialToVec(double* vector,int vector_size);
 InsertMode ISSMToPetscInsertMode(InsMode mode);
 NormType ISSMToPetscNormMode(NormMode mode);
-MatType ISSMToPetscMatrixType(MatrixType type);
+const MatType ISSMToPetscMatrixType(MatrixType type);
 
 void PetscMatrixToDoubleMatrix(double** pmatrix, int* prows, int* pcols,Mat matrix);
 void PetscVectorToDoubleVector(double** pvector, int* prows, Vec vector);

Modified: issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp
===================================================================
--- issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,13 +3,12 @@
 */
 #include <math.h>
 
-
 #include "../../../shared/shared.h"
 
 int SmallestPrimeFactor(int* output,int input);
 
 int CyclicalFactorization(int* pnprows,int* pnpcols,int num_procs){
-	
+
 	int nprows,npcols;
 	int last_diff;
 	int i;
@@ -39,11 +38,10 @@
 
 int PrimeDecomp(int** pdecomp,int* pdecomp_size,int input){
 
-	int* decomp=NULL;
 	int prime_factor;
 	int i;
 
-	decomp=xNew<int>(input);
+	int* decomp=xNew<int>(input);
 	*decomp=input;
 	for (i=0;i<input;i++){
 		SmallestPrimeFactor(&prime_factor,*(decomp+i));
@@ -64,7 +62,7 @@
 	of integer input
 */
 int SmallestPrimeFactor(int* output,int input){
-	
+
 	int found=0;
 	int i;
 

Modified: issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp
===================================================================
--- issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,19 +13,19 @@
 #include "../../scalapack/FortranMapping.h"
 
 void PlapackInvertMatrixLocalCleanup(PLA_Obj* pa,PLA_Template* ptempl,double** parrayA,int** pidxnA,MPI_Comm* pcomm_2d);
-	
-int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con){ 
+
+int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con,COMM comm){ 
 	/*inv_A does not yet exist, inv_A was just allocated, that's all*/
 
 	/*Error management*/
-	int i,j;
+	int i;
 
 	/*input*/
 	int mA,nA;
 	int local_mA,local_nA;
-	int lower_row,upper_row,range,this_range,this_lower_row;
+	int lower_row,upper_row;
 	MatType type;
-	
+
 	/*Plapack: */
 	MPI_Datatype   datatype;
 	MPI_Comm       comm_2d;
@@ -35,15 +35,10 @@
 	int ierror;
 	int nb,nb_alg;
 	int nprows,npcols;
-	int initialized=0;
 
 	/*Petsc to Plapack: */
 	double    *arrayA=NULL;
 	int* idxnA=NULL;
-	int d_nz,o_nz;
-	
-	/*Feedback to client*/
-	int computation_status;  
 
 	/*Verify that A is square*/
 	MatGetSize(*A,&mA,&nA);
@@ -75,7 +70,7 @@
 	/*Verify that plapack is not already initialized: */
 	if(PLA_Initialized(NULL)==TRUE)PLA_Finalize();
 	/* Create a 2D communicator */
-	PLA_Comm_1D_to_2D(MPI_COMM_WORLD,nprows,npcols,&comm_2d); 
+	PLA_Comm_1D_to_2D(comm,nprows,npcols,&comm_2d); 
 
 	/*Initlialize plapack: */
 	PLA_Init(comm_2d);
@@ -91,7 +86,7 @@
 
 	/* Set the datatype */
 	datatype = MPI_DOUBLE;
-	
+
 	/* Copy A into a*/
 	PLA_Matrix_create(datatype,mA,nA,templ,PLA_ALIGN_FIRST,PLA_ALIGN_FIRST,&a);  
 	PLA_Obj_set_to_zero(a);
@@ -99,7 +94,6 @@
 	any matrix type.*/
 	MatGetOwnershipRange(*A,&lower_row,&upper_row);
 	upper_row--; 
-	range=upper_row-lower_row+1;
 	arrayA = xNew<double>(nA);
 	idxnA  = xNew<int>(nA);
 	for (i=0;i<nA;i++){
@@ -126,7 +120,7 @@
 	PLA_Temp_free(&templ);
 	xDelete<double>(arrayA);
 	xDelete<int>(idxnA);
-	
+
 	/*Finalize PLAPACK*/
 	PLA_Finalize();
 	MPI_Comm_free(&comm_2d);

Modified: issm/trunk/src/c/toolkits/plapack/patches/PlapackToPetsc.cpp
===================================================================
--- issm/trunk/src/c/toolkits/plapack/patches/PlapackToPetsc.cpp	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/plapack/patches/PlapackToPetsc.cpp	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,12 +5,11 @@
 #include "../../petsc/petscincludes.h"
 #include "../plapackincludes.h"
 
-int PlapackToPetsc(Mat* A,int local_mA,int local_nA,int mA,int nA,MatType type,PLA_Obj a,PLA_Template templ,int nprows,int npcols,int nb){
+int PlapackToPetsc(Mat* A,int local_mA,int local_nA,int mA,int nA,MatType type,PLA_Obj a,PLA_Template templ,int nprows,int npcols,int nb,COMM comm){
 
-	
 	int i;
 
-	int lower_row,upper_row,range;
+	int lower_row,upper_row;
 	int* row_nodes=NULL;
 	int* col_nodes=NULL;
 	int* idxm=NULL;
@@ -21,28 +20,26 @@
 	int i0,i1;
 	double* local_buffer=NULL;
 
-
 	/*Create matrix A (right now, we just have an allocated pointer A*/
 	if (strcasecmp_eq(type,MATMPIAIJ)){
 		/*See pretty large here, because we have no idea how many nnz per row*/
 		d_nz=nA/2;
 		o_nz=nA/2;
-		MatCreateMPIAIJ(MPI_COMM_WORLD,local_mA,local_nA, mA,nA,d_nz,PETSC_NULL,o_nz,PETSC_NULL,A);
+		MatCreateMPIAIJ(comm,local_mA,local_nA, mA,nA,d_nz,PETSC_NULL,o_nz,PETSC_NULL,A);
 	}
 	else if(strcasecmp_eq(type,MATMPIDENSE)){
-		MatCreateMPIDense(MPI_COMM_WORLD,local_mA,local_nA, mA,nA,PETSC_NULL,A); 
+		MatCreateMPIDense(comm,local_mA,local_nA, mA,nA,PETSC_NULL,A); 
 	}
-	
+
 	MatGetOwnershipRange(*A,&lower_row,&upper_row);
 	upper_row--;
-	range=upper_row-lower_row+1;
-	
+
 	/*Build the Plapack row and column indices corresponding to the local_buffer stored in a. 
 	  We need those indices to directly plug local_buffer into the Petsc matrix A. We do not 
 	  use PLA_axpy_global_to_matrix to extract a local matrix, because this routine hangs when the 
 	  problem size becomes big. We rely therefore on MatAssembly from Petsc to gather the plapack 
 	  matrix into a Petsc Matrix.*/
-	
+
 	/*Vector physically based block cyclic distribution: */
 	row_nodes=xNew<int>(mA);
 	col_nodes=xNew<int>(nA);
@@ -81,7 +78,7 @@
 
 	/*Get local buffer: */
 	PLA_Obj_local_buffer(a,(void**)&local_buffer);
-	
+
 	/*Insert into invA matrix. Use col oriented insertion, for Plapack is column oriented*/
 	MatSetOption(*A,MAT_COLUMN_ORIENTED);
 	MatSetValues(*A,idxm_count,idxm,idxn_count,idxn,local_buffer,INSERT_VALUES);

Modified: issm/trunk/src/c/toolkits/plapack/patches/plapackpatches.h
===================================================================
--- issm/trunk/src/c/toolkits/plapack/patches/plapackpatches.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/plapack/patches/plapackpatches.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,8 +5,8 @@
 #ifndef _PLAPACK_PATCHES_H_
 #define _PLAPACK_PATCHES_H_
 
-int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con);
-int PlapackToPetsc(Mat* A,int local_mA,int local_nA,int mA,int nA,MatType type,PLA_Obj a,PLA_Template templ,int nprows,int npcols,int nb);
+int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con,COMM comm);
+int PlapackToPetsc(Mat* A,int local_mA,int local_nA,int mA,int nA,MatType type,PLA_Obj a,PLA_Template templ,int nprows,int npcols,int nb,COMM comm);
 int CyclicalFactorization(int* pnprows,int* pnpcols,int num_procs);
 
 #endif

Modified: issm/trunk/src/c/toolkits/plapack/plapackincludes.h
===================================================================
--- issm/trunk/src/c/toolkits/plapack/plapackincludes.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/plapack/plapackincludes.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,17 +11,14 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
+#include <PLA.h>
 
-#include "PLA.h"
-
 /* missing Plapack prototypes: */
 int PLA_General_invert( int method, PLA_Obj A );
 
 /*our own patches: */
 #ifdef _HAVE_PETSC_
-#include "patches/petscpatches.h"
+#include "./patches/petscpatches.h"
 #endif
 
-
 #endif
-

Modified: issm/trunk/src/c/toolkits/scalapack/FortranMapping.h
===================================================================
--- issm/trunk/src/c/toolkits/scalapack/FortranMapping.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/scalapack/FortranMapping.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,6 @@
  *     Description:  Fortran to C define to use Scalapack in a C program
  */
 
-
 /*We transform every call to Fortran functions into their real symbolic name in the Scalapack, Blacs, Lapack and Blas libraries. 
  * We had to look for these exact symbols in these libraries using nm | grep FORTRAN_NAME. In fact, the symbol naming is not well defined: see for example 
  * numroc_ and blacs_gridinit__ (one underscore, then two). */
@@ -22,7 +21,6 @@
 #define PDGETRF(...) pdgetrf_(__VA_ARGS__)
 #define PDGETRI(...) pdgetri_(__VA_ARGS__)
 
-
 /*Here, we clobber the fortran definition of these routines. Remember, every variable in fortran is passed by a pointer, and the 
  * ordering of matrices is column oriented*/
 

Modified: issm/trunk/src/c/toolkits/toolkits.h
===================================================================
--- issm/trunk/src/c/toolkits/toolkits.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/toolkits.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,10 +11,6 @@
 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
 #endif
 
-#ifdef _HAVE_PYTHON_
-#include "./python/pythonincludes.h"
-#endif
-
 #ifdef _HAVE_PETSC_
 #include "./petsc/petscincludes.h"
 #endif
@@ -30,5 +26,4 @@
 #include "./triangle/triangleincludes.h"
 #include "./toolkitsenums.h"
 #include "./issm/issmtoolkit.h"
-
 #endif

Modified: issm/trunk/src/c/toolkits/triangle/triangleincludes.h
===================================================================
--- issm/trunk/src/c/toolkits/triangle/triangleincludes.h	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/c/toolkits/triangle/triangleincludes.h	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,5 +10,4 @@
 #include "triangle.h"
 #endif //#ifdef _C_
 
-
 #endif

Modified: issm/trunk/src/dox/issm.dox
===================================================================
--- issm/trunk/src/dox/issm.dox	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/dox/issm.dox	2012-11-16 16:10:16 UTC (rev 13975)
@@ -45,28 +45,28 @@
 <th  bgcolor=#7AA9DD style="text-align:left;">Language</th><th  bgcolor=#7AA9DD style="text-align:right;">files</th><th  bgcolor=#7AA9DD style="text-align:right;">blank</th><th  bgcolor=#7AA9DD style="text-align:right;">comment</th><th  bgcolor=#7AA9DD style="text-align:right;">code</th><th  bgcolor=#7AA9DD style="text-align:right;">Total</th>
 </th>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">508</td><td  bgcolor=#FFFFFF style="text-align:right;">14595</td><td  bgcolor=#FFFFFF style="text-align:right;">16762</td><td  bgcolor=#FFFFFF style="text-align:right;">56036</td><td  bgcolor=#FFFFFF style="text-align:right;">87393</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> C++ </th><td  bgcolor=#FFFFFF style="text-align:right;">505</td><td  bgcolor=#FFFFFF style="text-align:right;">14316</td><td  bgcolor=#FFFFFF style="text-align:right;">16564</td><td  bgcolor=#FFFFFF style="text-align:right;">56522</td><td  bgcolor=#FFFFFF style="text-align:right;">87402</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">925</td><td  bgcolor=#C6E2FF style="text-align:right;">6851</td><td  bgcolor=#C6E2FF style="text-align:right;">13228</td><td  bgcolor=#C6E2FF style="text-align:right;">30468</td><td  bgcolor=#C6E2FF style="text-align:right;">50547</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> MATLAB </th><td  bgcolor=#C6E2FF style="text-align:right;">913</td><td  bgcolor=#C6E2FF style="text-align:right;">6625</td><td  bgcolor=#C6E2FF style="text-align:right;">13054</td><td  bgcolor=#C6E2FF style="text-align:right;">30160</td><td  bgcolor=#C6E2FF style="text-align:right;">49839</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">378</td><td  bgcolor=#FFFFFF style="text-align:right;">2758</td><td  bgcolor=#FFFFFF style="text-align:right;">2612</td><td  bgcolor=#FFFFFF style="text-align:right;">9818</td><td  bgcolor=#FFFFFF style="text-align:right;">15188</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> C/C++  Header </th><td  bgcolor=#FFFFFF style="text-align:right;">388</td><td  bgcolor=#FFFFFF style="text-align:right;">3069</td><td  bgcolor=#FFFFFF style="text-align:right;">2983</td><td  bgcolor=#FFFFFF style="text-align:right;">11855</td><td  bgcolor=#FFFFFF style="text-align:right;">17907</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td  bgcolor=#C6E2FF style="text-align:right;">7</td><td  bgcolor=#C6E2FF style="text-align:right;">997</td><td  bgcolor=#C6E2FF style="text-align:right;">80</td><td  bgcolor=#C6E2FF style="text-align:right;">8259</td><td  bgcolor=#C6E2FF style="text-align:right;">9336</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> m4 </th><td  bgcolor=#C6E2FF style="text-align:right;">6</td><td  bgcolor=#C6E2FF style="text-align:right;">1052</td><td  bgcolor=#C6E2FF style="text-align:right;">79</td><td  bgcolor=#C6E2FF style="text-align:right;">8993</td><td  bgcolor=#C6E2FF style="text-align:right;">10124</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> Python </th><td  bgcolor=#FFFFFF style="text-align:right;">53</td><td  bgcolor=#FFFFFF style="text-align:right;">400</td><td  bgcolor=#FFFFFF style="text-align:right;">610</td><td  bgcolor=#FFFFFF style="text-align:right;">1424</td><td  bgcolor=#FFFFFF style="text-align:right;">2434</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> Python </th><td  bgcolor=#FFFFFF style="text-align:right;">81</td><td  bgcolor=#FFFFFF style="text-align:right;">2677</td><td  bgcolor=#FFFFFF style="text-align:right;">3936</td><td  bgcolor=#FFFFFF style="text-align:right;">5169</td><td  bgcolor=#FFFFFF style="text-align:right;">11782</td>
 </tr>
 <tr>
 <th  bgcolor=#C6E2FF style="text-align:left;"> Objective  C </th><td  bgcolor=#C6E2FF style="text-align:right;">9</td><td  bgcolor=#C6E2FF style="text-align:right;">98</td><td  bgcolor=#C6E2FF style="text-align:right;">0</td><td  bgcolor=#C6E2FF style="text-align:right;">370</td><td  bgcolor=#C6E2FF style="text-align:right;">468</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> Perl </th><td  bgcolor=#FFFFFF style="text-align:right;">3</td><td  bgcolor=#FFFFFF style="text-align:right;">21</td><td  bgcolor=#FFFFFF style="text-align:right;">23</td><td  bgcolor=#FFFFFF style="text-align:right;">240</td><td  bgcolor=#FFFFFF style="text-align:right;">284</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#FFFFFF style="text-align:right;">5</td><td  bgcolor=#FFFFFF style="text-align:right;">58</td><td  bgcolor=#FFFFFF style="text-align:right;">81</td><td  bgcolor=#FFFFFF style="text-align:right;">268</td><td  bgcolor=#FFFFFF style="text-align:right;">407</td>
 </tr>
 <tr>
-<th  bgcolor=#C6E2FF style="text-align:left;"> Bourne  Shell </th><td  bgcolor=#C6E2FF style="text-align:right;">5</td><td  bgcolor=#C6E2FF style="text-align:right;">47</td><td  bgcolor=#C6E2FF style="text-align:right;">75</td><td  bgcolor=#C6E2FF style="text-align:right;">239</td><td  bgcolor=#C6E2FF style="text-align:right;">361</td>
+<th  bgcolor=#C6E2FF style="text-align:left;"> Perl </th><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">21</td><td  bgcolor=#C6E2FF style="text-align:right;">23</td><td  bgcolor=#C6E2FF style="text-align:right;">240</td><td  bgcolor=#C6E2FF style="text-align:right;">284</td>
 </tr>
 <tr>
 <th  bgcolor=#FFFFFF style="text-align:left;"> IDL </th><td  bgcolor=#FFFFFF style="text-align:right;">1</td><td  bgcolor=#FFFFFF style="text-align:right;">18</td><td  bgcolor=#FFFFFF style="text-align:right;">4</td><td  bgcolor=#FFFFFF style="text-align:right;">124</td><td  bgcolor=#FFFFFF style="text-align:right;">146</td>
@@ -75,7 +75,7 @@
 <th  bgcolor=#C6E2FF style="text-align:left;"> C </th><td  bgcolor=#C6E2FF style="text-align:right;">1</td><td  bgcolor=#C6E2FF style="text-align:right;">2</td><td  bgcolor=#C6E2FF style="text-align:right;">3</td><td  bgcolor=#C6E2FF style="text-align:right;">6</td><td  bgcolor=#C6E2FF style="text-align:right;">11</td>
 </tr>
 <tr>
-<th  bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td  bgcolor=#FFFFFF style="text-align:right;">1890</td><td  bgcolor=#FFFFFF style="text-align:right;">25787</td><td  bgcolor=#FFFFFF style="text-align:right;">33397</td><td  bgcolor=#FFFFFF style="text-align:right;">106984</td><td  bgcolor=#FFFFFF style="text-align:right;">166168</td>
+<th  bgcolor=#FFFFFF style="text-align:left;"> SUM: </th><td  bgcolor=#FFFFFF style="text-align:right;">1912</td><td  bgcolor=#FFFFFF style="text-align:right;">27936</td><td  bgcolor=#FFFFFF style="text-align:right;">36727</td><td  bgcolor=#FFFFFF style="text-align:right;">113707</td><td  bgcolor=#FFFFFF style="text-align:right;">178370</td>
 </tr>
 </table>
 

Modified: issm/trunk/src/m/Makefile.am
===================================================================
--- issm/trunk/src/m/Makefile.am	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/Makefile.am	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,6 +2,7 @@
 #
 #find . -type d -exec ls -d {} \;
 
+if WRAPPERS
 bin_SCRIPTS= ./qmu/*.m \
 				 ./qmu/setupdesign/*.m \
 				 ./qmu/plot/*.m \
@@ -48,3 +49,4 @@
 				 ./solve/*.m \
 				 ./solvers/*.m \
 				 ./materials/*.m
+endif

Modified: issm/trunk/src/m/array/array_numel.m
===================================================================
--- issm/trunk/src/m/array/array_numel.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/array/array_numel.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,7 +16,7 @@
     else
         inum=numel(varargin{iarg});
     end
-    
+
     if ~isequal(inum,1)
         if isequal(anum,1)
             anum=inum;

Modified: issm/trunk/src/m/array/array_size.m
===================================================================
--- issm/trunk/src/m/array/array_size.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/array/array_size.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,7 +16,7 @@
     else
         isize=size(varargin{iarg});
     end
-    
+
     if ~isequal(isize,[1 1])
         if isequal(asize,[1 1])
             asize=isize;

Modified: issm/trunk/src/m/array/str2int.m
===================================================================
--- issm/trunk/src/m/array/str2int.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/array/str2int.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,7 +4,7 @@
 %
 %  function [aint]=str2int(astr,cfl)
 %
-function [aint]=str2int(astr,cfl);
+function [aint]=str2int(astr,cfl)
 
 aint=[];
 
@@ -43,4 +43,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/array/struc_desc.m
===================================================================
--- issm/trunk/src/m/array/struc_desc.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/array/struc_desc.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,7 +21,7 @@
     elseif ischar(varargin{iarg})
         desc=cellstr(varargin{iarg});
     end
-    
+
     for i=1:length(desc)
         sarrayoi=struc_desci(sarray,desc{i});
         if ~isempty(sarrayoi)

Modified: issm/trunk/src/m/boundaryconditions/SetIceSheetBC.m
===================================================================
--- issm/trunk/src/m/boundaryconditions/SetIceSheetBC.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/boundaryconditions/SetIceSheetBC.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -57,7 +57,7 @@
 	md.thermal.spctemperature=NaN*ones(md.mesh.numberofvertices,1);
 	pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface
 	if (length(md.basalforcings.geothermalflux)~=md.mesh.numberofvertices),
-		md.basalforcings.geothermalflux=50*10^-3*ones(md.mesh.numberofvertices,1); %50 mW/m^2
+		md.basalforcings.geothermalflux=50.*10^-3*ones(md.mesh.numberofvertices,1); %50 mW/m^2
 	end
 else
 	disp('      no thermal boundary conditions created: no observed temperature found');

Modified: issm/trunk/src/m/boundaryconditions/SetIceShelfBC.py
===================================================================
--- issm/trunk/src/m/boundaryconditions/SetIceShelfBC.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/boundaryconditions/SetIceShelfBC.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,12 @@
 import os
 import numpy
+from ContourToMesh import *
 
 def SetIceShelfBC(md,icefrontfile=''):
 	"""
 	SETICESHELFBC - Create the boundary conditions for diagnostic and thermal models for a  Ice Shelf with Ice Front
 
-	   Neumann BC are used on the ice front (an ANRGUS contour around the ice front
+	   Neumann BC are used on the ice front (an ARGUS contour around the ice front
 	   must be given in input)
 	   Dirichlet BC are used elsewhere for diagnostic
 
@@ -23,76 +24,81 @@
 	if icefrontfile:
 		if not os.path.exists(icefrontfile):
 			raise IOError("SetIceShelfBC error message: ice front file '%s' not found." % icefrontfile)
-		nodeinsideicefront=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2)
-		nodeonicefront=double(md.mesh.vertexonboundary and nodeinsideicefront)
+		[nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2)
+		nodeonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1)).astype(float)
 	else:
-		nodeonicefront=numpy.zeros(md.mesh.numberofvertices)
+		nodeonicefront=numpy.zeros((md.mesh.numberofvertices))
 
 #	pos=find(md.mesh.vertexonboundary & ~nodeonicefront);
-	pos=[i for i,(vob,noif) in enumerate(zip(md.mesh.vertexonboundary,nodeonicefront)) if vob and not noif]
-	md.diagnostic.spcvx=float('NaN')*numpy.ones(md.mesh.numberofvertices)
-	md.diagnostic.spcvy=float('NaN')*numpy.ones(md.mesh.numberofvertices)
-	md.diagnostic.spcvz=float('NaN')*numpy.ones(md.mesh.numberofvertices)
+	pos=numpy.nonzero(numpy.logical_and(md.mesh.vertexonboundary,numpy.logical_not(nodeonicefront)))[0]
+	md.diagnostic.spcvx=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvy=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
+	md.diagnostic.spcvz=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
 	md.diagnostic.spcvx[pos]=0
 	md.diagnostic.spcvy[pos]=0
 	md.diagnostic.spcvz[pos]=0
-	md.diagnostic.referential=float('NaN')*numpy.ones((md.mesh.numberofvertices,6))
+	md.diagnostic.referential=float('nan')*numpy.ones((md.mesh.numberofvertices,6))
 
 	#Dirichlet Values
-	if numpy.size(md.inversion.vx_obs)==md.mesh.numberofvertices and numpy.size(md.inversion.vy_obs)==md.mesh.numberofvertices:
-		print '      boundary conditions for diagnostic model: spc set as observed velocities'
+	if isinstance(md.inversion.vx_obs,numpy.ndarray) and numpy.size(md.inversion.vx_obs,axis=0)==md.mesh.numberofvertices and isinstance(md.inversion.vy_obs,numpy.ndarray) and numpy.size(md.inversion.vy_obs,axis=0)==md.mesh.numberofvertices:
+		#reshape to rank-2 if necessary to match spc arrays
+		if numpy.ndim(md.inversion.vx_obs)==1:
+			md.inversion.vx_obs=md.inversion.vx_obs.reshape(-1,1)
+		if numpy.ndim(md.inversion.vy_obs)==1:
+			md.inversion.vy_obs=md.inversion.vy_obs.reshape(-1,1)
+		print "      boundary conditions for diagnostic model: spc set as observed velocities"
 		md.diagnostic.spcvx[pos]=md.inversion.vx_obs[pos]
 		md.diagnostic.spcvy[pos]=md.inversion.vy_obs[pos]
 	else:
-		print '      boundary conditions for diagnostic model: spc set as zero'
+		print "      boundary conditions for diagnostic model: spc set as zero"
 
 	#segment on Ice Front
 	#segment on Neumann (Ice Front)
 #	pos=find(nodeonicefront(md.mesh.segments(:,1)) | nodeonicefront(md.mesh.segments(:,2)));
-	pos=[i for i,(noif1,noif2) in enumerate(zip(nodeonicefront[md.mesh.segments[:,0].astype('int')-1],nodeonicefront[md.mesh.segments[:,1].astype('int')-1])) if noif1 or noif2]
+	pos=numpy.nonzero(numpy.logical_or(nodeonicefront[md.mesh.segments[:,0].astype(int)-1],nodeonicefront[md.mesh.segments[:,1].astype(int)-1]))[0]
 	if   md.mesh.dimension==2:
 		pressureload=md.mesh.segments[pos,:]
 	elif md.mesh.dimension==3:
 #		pressureload_layer1=[md.mesh.segments(pos,1:2)  md.mesh.segments(pos,2)+md.mesh.numberofvertices2d  md.mesh.segments(pos,1)+md.mesh.numberofvertices2d  md.mesh.segments(pos,3)];
-		pressureload_layer1=numpy.concatenate((md.mesh.segments[pos,0:2],md.mesh.segments[pos,1]+md.mesh.numberofvertices2d,md.mesh.segments[pos,0]+md.mesh.numberofvertices2d,md.mesh.segments[pos,2]),axis=1)
+		pressureload_layer1=numpy.hstack((md.mesh.segments[pos,0:2],md.mesh.segments[pos,1]+md.mesh.numberofvertices2d,md.mesh.segments[pos,0]+md.mesh.numberofvertices2d,md.mesh.segments[pos,2]))
 		pressureload=numpy.zeros((0,5))
 		for i in xrange(1,md.mesh.numberoflayers):
 #			pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d ];
-			pressureload=numpy.concatenate((pressureload,numpy.concatenate((pressureload_layer1[:,0:3]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d),axis=1)),axis=0)
+			pressureload=numpy.vstack((pressureload,numpy.hstack((pressureload_layer1[:,0:4]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d))))
 
 	#Add water or air enum depending on the element
 #	pressureload=[pressureload 1*md.mask.elementonfloatingice(pressureload(:,end))];
-	pressureload=numpy.concatenate((pressureload,1*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape((-1,1))),axis=1)
+	pressureload=numpy.hstack((pressureload,1.*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape(-1,1)))
 
 	#plug onto model
 	md.diagnostic.icefront=pressureload
 
 	#Create zeros basalforcings and surfaceforcings
 	if numpy.all(numpy.isnan(md.surfaceforcings.precipitation)) and (md.surfaceforcings.ispdd==1):
-		md.surfaceforcings.precipitation=numpy.zeros(md.mesh.numberofvertices)
-		print '      no surfaceforcings.precipitation specified: values set as zero'
+		md.surfaceforcings.precipitation=numpy.zeros((md.mesh.numberofvertices,1))
+		print "      no surfaceforcings.precipitation specified: values set as zero"
 	if numpy.all(numpy.isnan(md.surfaceforcings.mass_balance)) and (md.surfaceforcings.ispdd==0):
-		md.surfaceforcings.mass_balance=numpy.zeros(md.mesh.numberofvertices)
-		print '      no surfaceforcings.mass_balance specified: values set as zero'
+		md.surfaceforcings.mass_balance=numpy.zeros((md.mesh.numberofvertices,1))
+		print "      no surfaceforcings.mass_balance specified: values set as zero"
 	if numpy.all(numpy.isnan(md.basalforcings.melting_rate)):
-		md.basalforcings.melting_rate=numpy.zeros(md.mesh.numberofvertices)
-		print '      no basalforcings.melting_rate specified: values set as zero'
+		md.basalforcings.melting_rate=numpy.zeros((md.mesh.numberofvertices,1))
+		print "      no basalforcings.melting_rate specified: values set as zero"
 	if numpy.all(numpy.isnan(md.balancethickness.thickening_rate)):
-		md.balancethickness.thickening_rate=numpy.zeros(md.mesh.numberofvertices)
-		print '      no balancethickness.thickening_rate specified: values set as zero'
+		md.balancethickness.thickening_rate=numpy.zeros((md.mesh.numberofvertices,1))
+		print "      no balancethickness.thickening_rate specified: values set as zero"
 
-	md.prognostic.spcthickness=float('NaN')*numpy.ones(md.mesh.numberofvertices)
-	md.balancethickness.spcthickness=float('NaN')*numpy.ones(md.mesh.numberofvertices)
+	md.prognostic.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
+	md.balancethickness.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
 
-	if numpy.size(md.initialization.temperature)==md.mesh.numberofvertices:
-		md.thermal.spctemperature=float('NaN')*numpy.ones(md.mesh.numberofvertices)
+	if isinstance(md.initialization.temperature,numpy.ndarray) and numpy.size(md.initialization.temperature,axis=0)==md.mesh.numberofvertices:
+		md.thermal.spctemperature=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
 #		pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface
-		pos=[i for i,vos in enumerate(md.mesh.vertexonsurface) if vos]
-		md.thermal.spctemperature[pos]=md.initialization.temperature[pos]    # impose observed temperature on surface
-		if not numpy.size(md.basalforcings.geothermalflux)==md.mesh.numberofvertices:
-			md.basalforcings.geothermalflux=numpy.zeros(md.mesh.numberofvertices)
+		pos=numpy.nonzero(md.mesh.vertexonsurface)[0]
+		md.thermal.spctemperature[pos]=md.initialization.temperature[pos]    #impose observed temperature on surface
+		if not isinstance(md.basalforcings.geothermalflux,numpy.ndarray) or not numpy.size(md.basalforcings.geothermalflux,axis=0)==md.mesh.numberofvertices:
+			md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices,1))
 	else:
-		print '      no thermal boundary conditions created: no observed temperature found'
+		print "      no thermal boundary conditions created: no observed temperature found"
 
 	return md
 

Modified: issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.m
===================================================================
--- issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/boundaryconditions/SetMarineIceSheetBC.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -52,7 +52,7 @@
 end
 
 md.hydrology.spcwatercolumn=zeros(md.mesh.numberofvertices,2);
-pos=find(md.mesh.vertexonboundary); 
+pos=find(md.mesh.vertexonboundary);
 md.hydrology.spcwatercolumn(pos,1)=1;
 
 %segment on Neumann (Ice Front)
@@ -73,7 +73,6 @@
 %plug onto model
 md.diagnostic.icefront=pressureload;
 
-
 %Create zeros basalforcings and surfaceforcings
 if (isnan(md.surfaceforcings.precipitation) & (md.surfaceforcings.ispdd==1)),
 	md.surfaceforcings.precipitation=zeros(md.mesh.numberofvertices,1);
@@ -100,7 +99,7 @@
 	pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface
 	if (length(md.basalforcings.geothermalflux)~=md.mesh.numberofvertices),
 		md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices,1);
-		md.basalforcings.geothermalflux(find(md.mask.vertexongroundedice))=50*10^-3; %50mW/m2
+		md.basalforcings.geothermalflux(find(md.mask.vertexongroundedice))=50.*10.^-3; %50mW/m2
 	end
 else
 	disp('      no thermal boundary conditions created: no observed temperature found');

Modified: issm/trunk/src/m/classes/autodiff.m
===================================================================
--- issm/trunk/src/m/classes/autodiff.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/autodiff.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,6 +8,7 @@
 		isautodiff   = false;
 		dependents   = {};
 		independents = {};
+		driver       = 'fos_forward';
 	end
 	methods
 		function obj = autodiff(varargin) % {{{
@@ -23,47 +24,182 @@
 		end % }}}
 		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
-		%Early return 
-		if ~obj.isautodiff, return; end
+			%Early return 
+			if ~obj.isautodiff, return; end
 
+			%Driver value:
+			md = checkfield(md,'autodiff.driver','values',{'fos_forward','fov_forward','fov_forward_all','fos_reverse','fov_reverse','fov_reverse_all'});
+
+			%go through our dependents and independents and check consistency: 
+			for i=1:numel(obj.dependents),
+				dep=obj.dependents{i};
+				md=checkconsistency(dep,md,solution,analyses);
+			end
+			for i=1:numel(obj.independents),
+				indep=obj.independents{i};
+				md=checkconsistency(indep,md,i,solution,analyses,obj.driver);
+			end
+
 		end % }}}
 		function disp(obj) % {{{
-			disp(sprintf('   automatic differentiation parameters:'));
+			disp(sprintf('      automatic differentiation parameters:'));
 			fielddisplay(obj,'isautodiff','indicates if the automatic differentiation is activated');
-			fielddisplay(obj,'dependents','list of dependent variables ; ex: {''Thickness'',''FrictionCoefficient''}');
-			fielddisplay(obj,'independents','list of independent variables ; ex: {''IceVolume'',''MassFlux''}');
+			fielddisplay(obj,'dependents','list of dependent variables');
+			fielddisplay(obj,'independents','list of independent variables');
+			fielddisplay(obj,'driver','ADOLC driver (''fos_forward'' or ''fov_forward'')');
 		end % }}}
 		function marshall(obj,fid) % {{{
 
 			WriteData(fid,'object',obj,'fieldname','isautodiff','format','Boolean');
-			
+			WriteData(fid,'object',obj,'fieldname','driver','format','String');
+
 			%early return
-			if ~obj.isautodiff, return; end
+			if ~obj.isautodiff,
+				WriteData(fid,'data',false,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean');
+				WriteData(fid,'data',false,'enum',AutodiffKeepEnum(),'format','Boolean');
+				return;
+			end
 
-			%process dependent variables
-			num_dependents=numel(obj.dependents);
-			WriteData(fid,'data',num_dependents,'enum',AutodiffNumDependentsEnum(),'format','Integer');
-			
-			if(num_dependents),
-				data=zeros(1,num_dependents);
-				for i=1:num_dependents,
-					data(i)=StringToEnum(obj.dependents{i});
+			%process dependent variables {{{
+			num_dependent_objects=numel(obj.dependents);
+			WriteData(fid,'data',num_dependent_objects,'enum',AutodiffNumDependentObjectsEnum(),'format','Integer');
+
+			if(num_dependent_objects),
+				names=zeros(num_dependent_objects,1);
+				types=zeros(num_dependent_objects,1);
+				indices=zeros(num_dependent_objects,1);
+
+				for i=1:num_dependent_objects,
+					dep=obj.dependents{i};
+
+					names(i)=StringToEnum(dep.name);
+					types(i)=dep.typetoscalar();
+					indices(i)=dep.index;
 				end
-				WriteData(fid,'data',data,'enum',AutodiffDependentsEnum(),'format','DoubleMat','mattype',3);
+				WriteData(fid,'data',names,'enum',AutodiffDependentObjectNamesEnum(),'format','IntMat','mattype',3);
+				WriteData(fid,'data',types,'enum',AutodiffDependentObjectTypesEnum(),'format','IntMat','mattype',3);
+				WriteData(fid,'data',indices,'enum',AutodiffDependentObjectIndicesEnum(),'format','IntMat','mattype',3);
 			end
-			
-			%process independent variables
-			num_independents=numel(obj.independents);
-			WriteData(fid,'data',num_independents,'enum',AutodiffNumIndependentsEnum(),'format','Integer');
-			
-			if(num_independents)
-				data=zeros(1,num_independents);
-				for i=1:num_independents,
-					data(i)=StringToEnum(obj.independents{i});
+			%}}}
+			%process independent variables {{{
+			num_independent_objects=numel(obj.independents);
+			WriteData(fid,'data',num_independent_objects,'enum',AutodiffNumIndependentObjectsEnum(),'format','Integer');
+
+			if(num_independent_objects),
+				names=zeros(num_independent_objects,1);
+				types=zeros(num_independent_objects,1);
+
+				for i=1:num_independent_objects,
+					indep=obj.independents{i};
+
+					names(i)=StringToEnum(indep.name);
+					types(i)=indep.typetoscalar();
 				end
-				WriteData(fid,'data',data,'enum',AutodiffIndependentsEnum(),'format','DoubleMat','mattype',3);
+				WriteData(fid,'data',names,'enum',AutodiffIndependentObjectNamesEnum(),'format','IntMat','mattype',3);
+				WriteData(fid,'data',types,'enum',AutodiffIndependentObjectTypesEnum(),'format','IntMat','mattype',3);
 			end
+			%}}}
+			%if driver is fos_forward, build index:  {{{
+			if strcmpi(obj.driver,'fos_forward'),
+				index=0;
 
+				for i=1:num_independent_objects,
+					indep=obj.independents{i};
+					if ~isnan(indep.fos_forward_index),
+						index=index+indep.fos_forward_index;
+						break;
+					else
+						if strcmpi(indep.type,'scalar'),
+							index=index+1;
+						else
+							index=index+indep.nods;
+						end
+					end
+				end
+				index=index-1; %get c-index numbering going
+				WriteData(fid,'data',index,'enum',AutodiffFosForwardIndexEnum(),'format','Integer');
+			end
+			%}}}
+			%if driver is fos_reverse, build index:  {{{
+			if strcmpi(obj.driver,'fos_reverse'),
+				index=0;
+
+				for i=1:num_dependent_objects,
+					dep=obj.dependents{i};
+					if ~isnan(dep.fos_reverse_index),
+						index=index+dep.fos_reverse_index;
+						break;
+					else
+						if strcmpi(dep.type,'scalar'),
+							index=index+1;
+						else
+							index=index+dep.nods;
+						end
+					end
+				end
+				index=index-1; %get c-index numbering going
+				WriteData(fid,'data',index,'enum',AutodiffFosReverseIndexEnum(),'format','Integer');
+			end
+			%}}}
+			%if driver is fov_forward, build indices:  {{{
+			if strcmpi(obj.driver,'fov_forward'),
+				indices=0;
+
+				for i=1:num_independent_objects,
+					indep=obj.independents{i};
+					if ~isempty(indep.fos_forward_index),
+						indices=indices+indep.fov_forward_indices;
+						break;
+					else
+						if strcmpi(indep.type,'scalar'),
+							indices=indices+1;
+						else
+							indices=indices+indep.nods;
+						end
+					end
+				end
+				indices=indices-1; %get c-indices numbering going
+				WriteData(fid,'data',indices,'enum',AutodiffFovForwardIndicesEnum(),'format','IntMat','mattype',3);
+			end
+			%}}}
+			%deal with mass fluxes:  {{{
+			mass_flux_segments=cell(0,1);
+			for i=1:num_dependent_objects,
+				dep=obj.dependents{i};
+				if strcmpi(dep.name,'MassFlux'),
+					mass_flux_segments{end+1,1}=dep.segments;
+				end
+			end
+			if ~isempty(mass_flux_segments), 
+				WriteData(fid,'data',mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray');
+				flag=true;
+			else
+				flag=false;
+			end
+			WriteData(fid,'data',flag,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean');
+			%}}}
+			%deal with trace keep on: {{{
+			keep=false;
+
+			%From ADOLC userdoc: 
+			% The optional integer argument keep of trace on determines whether the numerical values of all active variables are 
+			% recorded in a buffered temporary array or file called the taylor stack. This option takes effect if keep = 1 and 
+			% prepares the scene for an immediately following gradient evaluation by a call to a routine implementing the reverse 
+			% mode as described in the Section 4 and Section 5. 
+			%
+
+			if length(obj.driver)<=3,
+				keep=false; %there is no "_reverse" string within the driver string: 
+			else
+				if strncmpi(obj.driver(4:end),'_reverse',8),
+					keep=true;
+				else
+					keep=false;
+				end
+			end
+			WriteData(fid,'data',keep,'enum',AutodiffKeepEnum(),'format','Boolean');
+			%}}}
+
 		end % }}}
 	end
 end

Modified: issm/trunk/src/m/classes/autodiff.py
===================================================================
--- issm/trunk/src/m/classes/autodiff.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/autodiff.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,7 @@
 #module imports
+import numpy
+from dependent import *
+from independent import *
 from fielddisplay import fielddisplay
 from EnumDefinitions import *
 from checkfield import *
@@ -13,30 +16,181 @@
 	"""
 
 	#properties
-	def __init__(self):
-		# {{{ Properties
-		self.isautodiff = False
+	def __init__(self,*args):    # {{{
+		self.isautodiff   = False
+		self.dependents   = []
+		self.independents = []
+		self.driver       = 'fos_forward'
 
-		#set defaults
-		self.setdefaultparameters()
+		if not len(args):
+			self.setdefaultparameters()
+		else:
+			raise RuntimeError("constructor not supported")
+	# }}}
 
-		#}}}
-	def __repr__(self):
-		# {{{ Display
-		string='   automatic differentiation parameters:'
-		string="%s\n%s"%(string,fielddisplay(self,'isautodiff','indicates if the automatic differentiation is activated'))
-		return string
-		#}}}
-	def setdefaultparameters(self):
-		# {{{setdefaultparameters
+	def __repr__(self):    # {{{
+		s ="      automatic differentiation parameters:\n"
+
+		s+="%s\n" % fielddisplay(self,'isautodiff',"indicates if the automatic differentiation is activated")
+		s+="%s\n" % fielddisplay(self,'dependents',"list of dependent variables")
+		s+="%s\n" % fielddisplay(self,'independents',"list of independent variables")
+		s+="%s\n" % fielddisplay(self,'driver',"ADOLC driver ('fos_forward' or 'fov_forward')")
+
+		return s
+	# }}}
+
+	def setdefaultparameters(self):    # {{{
 		return self
-	#}}}
+	# }}}
 
 	def checkconsistency(self,md,solution,analyses):    # {{{
+
+		#Early return 
+		if not self.isautodiff:
+			return md
+
+		#Driver value:
+		md = checkfield(md,'autodiff.driver','values',['fos_forward','fov_forward','fov_forward_all','fos_reverse','fov_reverse','fov_reverse_all'])
+
+		#go through our dependents and independents and check consistency: 
+		for dep in self.dependents:
+			dep.checkconsistency(md,solution,analyses)
+		for i,indep in enumerate(self.independents):
+			indep.checkconsistency(md,i,solution,analyses,self.driver)
+
 		return md
 	# }}}
 
 	def marshall(self,fid):    # {{{
 		WriteData(fid,'object',self,'fieldname','isautodiff','format','Boolean')
+		WriteData(fid,'object',self,'fieldname','driver','format','String')
+
+		#early return
+		if not self.isautodiff:
+			WriteData(fid,'data',False,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean')
+			WriteData(fid,'data',False,'enum',AutodiffKeepEnum(),'format','Boolean')
+			return
+
+		#process dependent variables {{{
+		num_dependent_objects=len(self.dependents)
+		WriteData(fid,'data',num_dependent_objects,'enum',AutodiffNumDependentObjectsEnum(),'format','Integer')
+
+		if num_dependent_objects:
+			names=numpy.zeros(num_dependent_objects)
+			types=numpy.zeros(num_dependent_objects)
+			indices=numpy.zeros(num_dependent_objects)
+
+			for i,dep in enumerate(self.dependents):
+				names[i]=StringToEnum(dep.name)[0]
+				types[i]=dep.typetoscalar()
+				indices[i]=dep.index
+
+			WriteData(fid,'data',names,'enum',AutodiffDependentObjectNamesEnum(),'format','IntMat','mattype',3)
+			WriteData(fid,'data',types,'enum',AutodiffDependentObjectTypesEnum(),'format','IntMat','mattype',3)
+			WriteData(fid,'data',indices,'enum',AutodiffDependentObjectIndicesEnum(),'format','IntMat','mattype',3)
+		#}}}
+
+		#process independent variables {{{
+		num_independent_objects=len(self.independents)
+		WriteData(fid,'data',num_independent_objects,'enum',AutodiffNumIndependentObjectsEnum(),'format','Integer')
+
+		if num_independent_objects:
+			names=numpy.zeros(num_independent_objects)
+			types=numpy.zeros(num_independent_objects)
+
+			for i,indep in enumerate(self.independents):
+				names[i]=StringToEnum(indep.name)[0]
+				types[i]=indep.typetoscalar()
+
+			WriteData(fid,'data',names,'enum',AutodiffIndependentObjectNamesEnum(),'format','IntMat','mattype',3)
+			WriteData(fid,'data',types,'enum',AutodiffIndependentObjectTypesEnum(),'format','IntMat','mattype',3)
+		#}}}
+
+		#if driver is fos_forward, build index:  {{{
+		if strcmpi(self.driver,'fos_forward'):
+			index=0
+
+			for indep in self.independents:
+				if not numpy.isnan(indep.fos_forward_index):
+					index+=indep.fos_forward_index
+					break
+				else:
+					if strcmpi(indep.type,'scalar'):
+						index+=1
+					else:
+						index+=indep.nods
+
+			index-=1    #get c-index numbering going
+			WriteData(fid,'data',index,'enum',AutodiffFosForwardIndexEnum(),'format','Integer')
+		#}}}
+
+		#if driver is fos_reverse, build index:  {{{
+		if strcmpi(self.driver,'fos_reverse'):
+			index=0
+
+			for dep in self.dependents:
+				if not numpy.isnan(dep.fos_reverse_index):
+					index+=dep.fos_reverse_index
+					break
+				else:
+					if strcmpi(dep.type,'scalar'):
+						index+=1
+					else:
+						index+=dep.nods
+
+			index-=1    #get c-index numbering going
+			WriteData(fid,'data',index,'enum',AutodiffFosReverseIndexEnum(),'format','Integer')
+		#}}}
+
+		#if driver is fov_forward, build indices:  {{{
+		if strcmpi(self.driver,'fov_forward'):
+			indices=0
+
+			for indep in self.independents:
+				if indep.fos_forward_index:
+					indices+=indep.fov_forward_indices
+					break
+				else:
+					if strcmpi(indep.type,'scalar'):
+						indices+=1
+					else:
+						indices+=indep.nods
+
+			indices-=1    #get c-indices numbering going
+			WriteData(fid,'data',indices,'enum',AutodiffFovForwardIndicesEnum(),'format','IntMat','mattype',3)
+		#}}}
+
+		#deal with mass fluxes:  {{{
+		mass_flux_segments=[dep.segments for dep in self.dependents if strcmpi(dep.name,'MassFlux')]
+
+		if mass_flux_segments:
+			WriteData(fid,'data',mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray')
+			flag=True
+		else:
+			flag=False
+		WriteData(fid,'data',flag,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean')
+		#}}}
+
+		#deal with trace keep on: {{{
+		keep=False
+
+		#From ADOLC userdoc: 
+		# The optional integer argument keep of trace on determines whether the numerical values of all active variables are 
+		# recorded in a buffered temporary array or file called the taylor stack. This option takes effect if keep = 1 and 
+		# prepares the scene for an immediately following gradient evaluation by a call to a routine implementing the reverse 
+		# mode as described in the Section 4 and Section 5. 
+		#
+
+		if len(self.driver)<=3:
+			keep=False    #there is no "_reverse" string within the driver string: 
+		else:
+			if strncmpi(self.driver[3:],'_reverse',8):
+				keep=True
+			else:
+				keep=False
+		WriteData(fid,'data',keep,'enum',AutodiffKeepEnum(),'format','Boolean')
+		#}}}
+
+		return
 	# }}}
 

Modified: issm/trunk/src/m/classes/bamggeom.py
===================================================================
--- issm/trunk/src/m/classes/bamggeom.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/bamggeom.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,3 +1,5 @@
+import numpy
+
 class bamggeom(object):
 	"""
 	BAMGGEOM class definition
@@ -7,14 +9,14 @@
 	"""
 
 	def __init__(self,*args):    # {{{
-		self.Vertices=[]
-		self.Edges=[]
-		self.TangentAtEdges=[]
-		self.Corners=[]
-		self.RequiredVertices=[]
-		self.RequiredEdges=[]
-		self.CrackedEdges=[]
-		self.SubDomains=[]
+		self.Vertices=numpy.empty((0,3))
+		self.Edges=numpy.empty((0,3))
+		self.TangentAtEdges=numpy.empty((0,4))
+		self.Corners=numpy.empty((0,1))
+		self.RequiredVertices=numpy.empty((0,1))
+		self.RequiredEdges=numpy.empty((0,1))
+		self.CrackedEdges=numpy.empty((0,0))
+		self.SubDomains=numpy.empty((0,4))
 
 		if not len(args):
 			# if no input arguments, create a default object

Modified: issm/trunk/src/m/classes/bamgmesh.py
===================================================================
--- issm/trunk/src/m/classes/bamgmesh.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/bamgmesh.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,3 +1,5 @@
+import numpy
+
 class bamgmesh(object):
 	"""
 	BAMGMESH class definition
@@ -7,22 +9,22 @@
 	"""
 
 	def __init__(self,*args):    # {{{
-		self.Vertices=[]
-		self.Edges=[]
-		self.Triangles=[]
-		self.Quadrilaterals=[]
-		self.IssmEdges=[]
-		self.IssmSegments=[]
-		self.VerticesOnGeomVertex=[]
-		self.VerticesOnGeomEdge=[]
-		self.EdgesOnGeomEdge=[]
-		self.SubDomains=[]
-		self.SubDomainsFromGeom=[]
-		self.ElementConnectivity=[]
-		self.NodalConnectivity=[]
-		self.NodalElementConnectivity=[]
-		self.CrackedVertices=[]
-		self.CrackedEdges=[]
+		self.Vertices=numpy.empty((0,3))
+		self.Edges=numpy.empty((0,3))
+		self.Triangles=numpy.empty((0,0))
+		self.Quadrilaterals=numpy.empty((0,0))
+		self.IssmEdges=numpy.empty((0,0))
+		self.IssmSegments=numpy.empty((0,0))
+		self.VerticesOnGeomVertex=numpy.empty((0,0))
+		self.VerticesOnGeomEdge=numpy.empty((0,0))
+		self.EdgesOnGeomEdge=numpy.empty((0,0))
+		self.SubDomains=numpy.empty((0,4))
+		self.SubDomainsFromGeom=numpy.empty((0,0))
+		self.ElementConnectivity=numpy.empty((0,0))
+		self.NodalConnectivity=numpy.empty((0,0))
+		self.NodalElementConnectivity=numpy.empty((0,0))
+		self.CrackedVertices=numpy.empty((0,0))
+		self.CrackedEdges=numpy.empty((0,0))
 
 		if not len(args):
 			# if no input arguments, create a default object

Modified: issm/trunk/src/m/classes/clusters/discover.m
===================================================================
--- issm/trunk/src/m/classes/clusters/discover.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/clusters/discover.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -105,7 +105,8 @@
 			 fprintf(fid,'#PBS -o %s.outlog \n',modelname);
 			 fprintf(fid,'#PBS -e %s.errlog \n\n',modelname);
 			 fprintf(fid,'. /usr/share/modules/init/bash\n\n');
-			 fprintf(fid,'module load comp/intel-10.1.023\n');
+			 fprintf(fid,'module purge\n');
+			 fprintf(fid,'module load comp/intel-11.1.038\n');
 			 fprintf(fid,'module load mpi/impi-4.0.3.008\n');
 			 fprintf(fid,'module load lib/mkl-10.1.2.024\n\n');
 			 fprintf(fid,'export PATH="$PATH:."\n\n');

Modified: issm/trunk/src/m/classes/clusters/generic.m
===================================================================
--- issm/trunk/src/m/classes/clusters/generic.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/clusters/generic.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,6 +13,7 @@
 		port=0;
 		interactive=1;
 		codepath=[issmdir() '/bin'];
+		etcpath=[issmdir() '/etc'];
 		executionpath=[issmdir() '/execution'];
 		valgrind=[issmdir() '/externalpackages/valgrind/install/bin/valgrind'];
 		valgrindlib=[issmdir() '/externalpackages/valgrind/install/lib/libmpidebug.so'];
@@ -44,6 +45,7 @@
 			disp(sprintf('    port: %i',cluster.port));
 			disp(sprintf('    codepath: %s',cluster.codepath));
 			disp(sprintf('    executionpath: %s',cluster.executionpath));
+			disp(sprintf('    etcpath: %s',cluster.executionpath));
 			disp(sprintf('    valgrind: %s',cluster.valgrind));
 			disp(sprintf('    valgrindlib: %s',cluster.valgrindlib));
 			disp(sprintf('    valgrindsup: %s',cluster.valgrindsup));
@@ -189,7 +191,7 @@
 			issmscpout(cluster.name,cluster.executionpath,cluster.login,cluster.port,{[dirname '.tar.gz']});
 
 			disp('launching solution sequence on remote cluster');
-			launchcommand=['source ' issmdir '/etc/environment.sh && cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
+			launchcommand=['source ' cluster.etcpath '/environment.sh && cd ' cluster.executionpath ' && rm -rf ./' dirname ' && mkdir ' dirname ...
 				' && cd ' dirname ' && mv ../' dirname '.tar.gz ./ && tar -zxf ' dirname '.tar.gz  && source  ' modelname '.queue '];
 			issmssh(cluster.name,cluster.login,cluster.port,launchcommand);
 		end %}}}

Modified: issm/trunk/src/m/classes/diagnostic.m
===================================================================
--- issm/trunk/src/m/classes/diagnostic.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/diagnostic.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -37,12 +37,12 @@
 
 			 %maximum of non-linear iterations.
 			 obj.maxiter=100;
-			 
+
 			 %Convergence criterion: absolute, relative and residual
 			 obj.restol=10^-4; 
 			 obj.reltol=0.01;
 			 obj.abstol=10;
-			 
+
 			 obj.stokesreconditioning=10^13;
 			 obj.shelf_dampening=0;
 
@@ -91,7 +91,7 @@
 			end
 
 			%singular solution
-			if ~any((~isnan(md.diagnostic.spcvx)+~isnan(md.diagnostic.spcvy))==2),
+			if ~(any(~isnan(md.diagnostic.spcvx)) & any(~isnan(md.diagnostic.spcvy))),
 				md = checkmessage(md,['model is not well posed (singular). You need at least one node with fixed velocity!']);
 			end
 			%CHECK THAT EACH LINES CONTAINS ONLY NAN VALUES OR NO NAN VALUES

Modified: issm/trunk/src/m/classes/diagnostic.py
===================================================================
--- issm/trunk/src/m/classes/diagnostic.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/diagnostic.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,6 +1,7 @@
 #module imports
 import numpy
 import sys
+import copy
 from fielddisplay import fielddisplay
 from EnumDefinitions import *
 from checkfield import *
@@ -185,7 +186,7 @@
 		WriteData(fid,'object',self,'fieldname','requested_outputs','format','DoubleMat','mattype',3)
 
 		#marshall ice front
-		data=self.icefront
+		data=copy.deepcopy(self.icefront)
 		data[numpy.nonzero(data[:,-1]==0),-1]=AirEnum()
 		data[numpy.nonzero(data[:,-1]==1),-1]=WaterEnum()
 		data[numpy.nonzero(data[:,-1]==2),-1]=IceEnum()

Modified: issm/trunk/src/m/classes/flaim.m
===================================================================
--- issm/trunk/src/m/classes/flaim.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/flaim.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -58,7 +58,7 @@
 			fielddisplay(obj,'gridsatequator'     ,'number of grids at equator (determines resolution)');
 			fielddisplay(obj,'usevalueordering'   ,'flag to consider target values for flight path evaluation');
 			fielddisplay(obj,'split_antimeridian' ,'flag to split polygons on the antimeridian');
-			
+
 			disp(sprintf('\n      Optimization:'));
 			fielddisplay(obj,'path_optimize'     ,'optimize? (default false)');
 			fielddisplay(obj,'opt_ndir'     ,{'number of directions to test when moving a point.  If this value = 1, a random direction is tested.',...

Modified: issm/trunk/src/m/classes/flowequation.py
===================================================================
--- issm/trunk/src/m/classes/flowequation.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/flowequation.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,6 @@
 #module imports
 import numpy
+import copy
 from fielddisplay import fielddisplay
 from EnumDefinitions import *
 from checkfield import *
@@ -66,8 +67,8 @@
 				md = checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',[1,2])
 				md = checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements],'values',[1,2])
 			else:
-				md = checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',range(0,7+1))
-				md = checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements],'values',range(0,7+1))
+				md = checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',numpy.arange(0,7+1))
+				md = checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements],'values',numpy.arange(0,7+1))
 			if not (self.ismacayealpattyn or self.ishutter or self.isstokes or self.isl1l2):
 				md.checkmessage("no element types set for this model. At least one of ismacayealpattyn, ishutter or isstokes need to be =1")
 
@@ -88,7 +89,7 @@
 		WriteData(fid,'object',self,'fieldname','borderpattyn','format','DoubleMat','mattype',1)
 		WriteData(fid,'object',self,'fieldname','borderstokes','format','DoubleMat','mattype',1)
 		#convert approximations to enums
-		data=self.vertex_equation
+		data=copy.deepcopy(self.vertex_equation)
 		data[numpy.nonzero(data==0)]=NoneApproximationEnum()
 		data[numpy.nonzero(data==1)]=HutterApproximationEnum()
 		data[numpy.nonzero(data==2)]=MacAyealApproximationEnum()
@@ -99,7 +100,7 @@
 		data[numpy.nonzero(data==7)]=PattynStokesApproximationEnum()
 		data[numpy.nonzero(data==8)]=L1L2ApproximationEnum()
 		WriteData(fid,'data',data,'enum',FlowequationVertexEquationEnum(),'format','DoubleMat','mattype',1)
-		data=self.element_equation
+		data=copy.deepcopy(self.element_equation)
 		data[numpy.nonzero(data==0)]=NoneApproximationEnum()
 		data[numpy.nonzero(data==1)]=HutterApproximationEnum()
 		data[numpy.nonzero(data==2)]=MacAyealApproximationEnum()

Modified: issm/trunk/src/m/classes/groundingline.m
===================================================================
--- issm/trunk/src/m/classes/groundingline.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/groundingline.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,7 +25,6 @@
 			%basal melting rate correction: 
 			obj.melting_rate=0; 
 
-
 		end % }}}
 		function md = checkconsistency(obj,md,solution,analyses) % {{{
 

Modified: issm/trunk/src/m/classes/initialization.py
===================================================================
--- issm/trunk/src/m/classes/initialization.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/initialization.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -23,6 +23,8 @@
 		self.vel           = float('NaN')
 		self.pressure      = float('NaN')
 		self.temperature   = float('NaN')
+		self.surfacetemp   = float('NaN')
+		self.basaltemp     = float('NaN')
 		self.watercolumn   = float('NaN')
 		self.waterfraction = float('NaN')
 
@@ -40,6 +42,8 @@
 		string="%s\n%s"%(string,fielddisplay(self,'vel','velocity norm'))
 		string="%s\n%s"%(string,fielddisplay(self,'pressure','pressure field'))
 		string="%s\n%s"%(string,fielddisplay(self,'temperature','temperature in Kelvins'))
+		string="%s\n%s"%(string,fielddisplay(self,'surfacetemp','surface temperature in Kelvins'))
+		string="%s\n%s"%(string,fielddisplay(self,'basaltemp','basal temperature in Kelvins'))
 		string="%s\n%s"%(string,fielddisplay(self,'watercolumn','thickness of subglacial water'))
 		string="%s\n%s"%(string,fielddisplay(self,'waterfraction','fraction of water in the ice'))
 
@@ -85,6 +89,8 @@
 		WriteData(fid,'data',self.vz,'format','DoubleMat','mattype',1,'enum',VzEnum())
 		WriteData(fid,'data',self.pressure,'format','DoubleMat','mattype',1,'enum',PressureEnum())
 		WriteData(fid,'data',self.temperature,'format','DoubleMat','mattype',1,'enum',TemperatureEnum())
+		WriteData(fid,'data',self.surfacetemp,'format','DoubleMat','mattype',1,'enum',TemperatureSurfaceEnum()) 
+		WriteData(fid,'data',self.basaltemp,'format','DoubleMat','mattype',1,'enum',TemperatureBasalEnum())
 		WriteData(fid,'data',self.watercolumn,'format','DoubleMat','mattype',1,'enum',WatercolumnEnum())
 		WriteData(fid,'data',self.waterfraction,'format','DoubleMat','mattype',1,'enum',WaterfractionEnum())
 	# }}}

Modified: issm/trunk/src/m/classes/inversion.py
===================================================================
--- issm/trunk/src/m/classes/inversion.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/inversion.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,6 @@
 #module imports
 import numpy
+import copy
 from fielddisplay import fielddisplay
 from EnumDefinitions import *
 from StringToEnum import StringToEnum
@@ -95,10 +96,10 @@
 		#usually the gradient_scaling must be of the order of magnitude of the 
 		#inversed parameter (10^8 for B, 50 for drag) and can be decreased
 		#after the first iterations
-		self.gradient_scaling=50*numpy.ones(self.nsteps)
+		self.gradient_scaling=50*numpy.ones((self.nsteps,1))
 
 		#several responses can be used:
-		self.cost_functions=101*numpy.ones(self.nsteps)
+		self.cost_functions=101*numpy.ones((self.nsteps,1))
 
 		#step_threshold is used to speed up control method. When
 		#misfit(1)/misfit(0) < self.step_threshold, we go directly to
@@ -123,12 +124,12 @@
 			return md
 
 		num_controls=numpy.size(md.inversion.control_parameters)
-		num_costfunc=numpy.size(md.inversion.cost_functions,1)
+		num_costfunc=numpy.size(md.inversion.cost_functions,axis=1)
 
 		md = checkfield(md,'inversion.iscontrol','values',[0,1])
 		md = checkfield(md,'inversion.tao','values',[0,1])
 		md = checkfield(md,'inversion.incomplete_adjoint','values',[0,1])
-		md = checkfield(md,'inversion.control_parameters','cell',1,'values',['BalancethicknessThickeningRate','FrictionCoefficient','MaterialsRheologyBbar','Vx','Vy'])
+		md = checkfield(md,'inversion.control_parameters','cell',1,'values',['BalancethicknessThickeningRate','FrictionCoefficient','MaterialsRheologyBbar','MaterialsRheologyZbar','Vx','Vy'])
 		md = checkfield(md,'inversion.nsteps','numel',[1],'>=',1)
 		md = checkfield(md,'inversion.maxiter_per_step','size',[md.inversion.nsteps],'>=',0)
 		md = checkfield(md,'inversion.step_threshold','size',[md.inversion.nsteps])
@@ -170,14 +171,14 @@
 		WriteData(fid,'object',self,'fieldname','thickness_obs','format','DoubleMat','mattype',1)
 
 		#process control parameters
-		num_control_parameters=numpy.size(self.control_parameters)
-		data=[StringToEnum(self.control_parameters[i])[0] for i in xrange(0,num_control_parameters)]
+		num_control_parameters=len(self.control_parameters)
+		data=numpy.array([StringToEnum(control_parameter)[0] for control_parameter in self.control_parameters]).reshape(1,-1)
 		WriteData(fid,'data',data,'enum',InversionControlParametersEnum(),'format','DoubleMat','mattype',3)
 		WriteData(fid,'data',num_control_parameters,'enum',InversionNumControlParametersEnum(),'format','Integer')
 
 		#process cost functions
-		num_cost_functions=size(self.cost_functions,1)
-		data=self.cost_functions
+		num_cost_functions=numpy.size(self.cost_functions,axis=1)
+		data=copy.deepcopy(self.cost_functions)
 		data[numpy.nonzero(data==101)]=SurfaceAbsVelMisfitEnum()
 		data[numpy.nonzero(data==102)]=SurfaceRelVelMisfitEnum()
 		data[numpy.nonzero(data==103)]=SurfaceLogVelMisfitEnum()

Modified: issm/trunk/src/m/classes/matice.py
===================================================================
--- issm/trunk/src/m/classes/matice.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/matice.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -7,7 +7,7 @@
 
 class matice(object):
 	"""
-	MATERIALS class definition
+	MATICE class definition
 
 	   Usage:
 	      matice=matice();

Modified: issm/trunk/src/m/classes/mesh.m
===================================================================
--- issm/trunk/src/m/classes/mesh.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/mesh.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,7 @@
 		numberofelements            = 0;
 		numberofvertices            = 0;
 		numberofedges               = 0;
-		
+
 		lat                         = NaN
 		long                        = NaN
 		hemisphere                  = NaN
@@ -157,7 +157,7 @@
 			fielddisplay(obj,'lowervertex','lower vertex list (NaN for vertex on the lower surface)');
 			fielddisplay(obj,'lowerelements','lower element list (NaN for element on the lower layer');
 			fielddisplay(obj,'vertexonboundary','vertices on the boundary of the domain flag list');
-			
+
 			fielddisplay(obj,'segments','edges on domain boundary (vertex1 vertex2 element)');
 			fielddisplay(obj,'segmentmarkers','number associated to each segment');
 			fielddisplay(obj,'vertexconnectivity','list of vertices connected to vertex_i');

Modified: issm/trunk/src/m/classes/mesh.py
===================================================================
--- issm/trunk/src/m/classes/mesh.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/mesh.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -131,12 +131,12 @@
 		md = checkfield(md,'mesh.x','NaN',1,'size',[md.mesh.numberofvertices])
 		md = checkfield(md,'mesh.y','NaN',1,'size',[md.mesh.numberofvertices])
 		md = checkfield(md,'mesh.z','NaN',1,'size',[md.mesh.numberofvertices])
-		md = checkfield(md,'mesh.elements','NaN',1,'>',0,'values',range(1,md.mesh.numberofvertices+1))
+		md = checkfield(md,'mesh.elements','NaN',1,'>',0,'values',numpy.arange(1,md.mesh.numberofvertices+1))
 		if md.mesh.dimension==2:
 			md = checkfield(md,'mesh.elements','size',[md.mesh.numberofelements,3])
 		else:
 			md = checkfield(md,'mesh.elements','size',[md.mesh.numberofelements,6])
-		if numpy.any(numpy.logical_not(ismember(range(1,md.mesh.numberofvertices+1),md.mesh.elements))):
+		if numpy.any(numpy.logical_not(ismember(numpy.arange(1,md.mesh.numberofvertices+1),md.mesh.elements))):
 			md.checkmessage("orphan nodes have been found. Check the mesh outline")
 		md = checkfield(md,'mesh.dimension','values',[2,3])
 		md = checkfield(md,'mesh.numberoflayers','>=',0)

Modified: issm/trunk/src/m/classes/model/model.m
===================================================================
--- issm/trunk/src/m/classes/model/model.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/model/model.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,1120 +4,1120 @@
 %      md = model(varargin)
 
 classdef model
-    properties (SetAccess=public) %Model fields
-		 % {{{
-		 %Careful here: no other class should be used as default value this is a bug of matlab
-		 mesh             = 0;
-		 mask             = 0;
+	properties (SetAccess=public) %Model fields
+		% {{{
+		%Careful here: no other class should be used as default value this is a bug of matlab
+		mesh             = 0;
+		mask             = 0;
 
-		 geometry         = 0;
-		 constants        = 0;
-		 surfaceforcings  = 0;
-		 basalforcings    = 0;
-		 materials        = 0;
-		 friction         = 0;
-		 flowequation     = 0;
-		 timestepping     = 0;
-		 initialization   = 0;
-		 rifts            = 0;
+		geometry         = 0;
+		constants        = 0;
+		surfaceforcings  = 0;
+		basalforcings    = 0;
+		materials        = 0;
+		friction         = 0;
+		flowequation     = 0;
+		timestepping     = 0;
+		initialization   = 0;
+		rifts            = 0;
 
-		 debug            = 0;
-		 verbose          = 0;
-		 settings         = 0;
-		 solver           = 0;
-		 cluster          = 0;
+		debug            = 0;
+		verbose          = 0;
+		settings         = 0;
+		solver           = 0;
+		cluster          = 0;
 
-		 balancethickness = 0;
-		 diagnostic       = 0;
-		 groundingline    = 0;
-		 hydrology        = 0;
-		 prognostic       = 0;
-		 thermal          = 0;
-		 steadystate      = 0;
-		 transient        = 0;
+		balancethickness = 0;
+		diagnostic       = 0;
+		groundingline    = 0;
+		hydrology        = 0;
+		prognostic       = 0;
+		thermal          = 0;
+		steadystate      = 0;
+		transient        = 0;
 
-		 autodiff         = 0;
-		 flaim            = 0;
-		 inversion        = 0;
-		 qmu              = 0;
+		autodiff         = 0;
+		flaim            = 0;
+		inversion        = 0;
+		qmu              = 0;
 
-		 results          = 0;
-		 radaroverlay     = 0;
-		 miscellaneous    = 0;
-		 private          = 0;
+		results          = 0;
+		radaroverlay     = 0;
+		miscellaneous    = 0;
+		private          = 0;
 
-		 %}}}
-	 end
-	 methods (Static)
-		 function md = loadobj(md) % {{{
-			 % This function is directly called by matlab when a model object is
-			 % loaded. If the input is a struct it is an old version of model and
-			 % old fields must be recovered (make sure they are in the deprecated
-			 % model properties)
+		%}}}
+	end
+	methods (Static)
+		function md = loadobj(md) % {{{
+			% This function is directly called by matlab when a model object is
+			% loaded. If the input is a struct it is an old version of model and
+			% old fields must be recovered (make sure they are in the deprecated
+			% model properties)
 
-			 if verLessThan('matlab','7.9'),
-				 disp('Warning: your matlab version is old and there is a risk that load does not work correctly');
-				 disp('         if the model is not loaded correctly, rename temporarily loadobj so that matlab does not use it');
+			if verLessThan('matlab','7.9'),
+				disp('Warning: your matlab version is old and there is a risk that load does not work correctly');
+				disp('         if the model is not loaded correctly, rename temporarily loadobj so that matlab does not use it');
 
-				 % This is a Matlab bug: all the fields of md have their default value
-				 % Example of error message:
-				 % Warning: Error loading an object of class 'model':
-				 % Undefined function or method 'exist' for input arguments of type 'cell'
-				 %
-				 % This has been fixed in MATLAB 7.9 (R2009b) and later versions
-			 end
+				% This is a Matlab bug: all the fields of md have their default value
+				% Example of error message:
+				% Warning: Error loading an object of class 'model':
+				% Undefined function or method 'exist' for input arguments of type 'cell'
+				%
+				% This has been fixed in MATLAB 7.9 (R2009b) and later versions
+			end
 
-			 if isstruct(md)
-				 disp('Recovering model object from a previous version');
-				 md = structtomodel(model,md);
-			 end
+			if isstruct(md)
+				disp('Recovering model object from a previous version');
+				md = structtomodel(model,md);
+			end
 
-			 %2012 August 4th
-			 if isa(md.materials,'materials'),
-				 disp('Recovering old materials');
-				 if numel(md.materials.rheology_Z)==1 & isnan(md.materials.rheology_Z),
-					 md.materials=matice(md.materials);
-				 else
-					 md.materials=matdamageice(md.materials);
-				 end
-			 end
+			%2012 August 4th
+			if isa(md.materials,'materials'),
+				disp('Recovering old materials');
+				if numel(md.materials.rheology_Z)==1 & isnan(md.materials.rheology_Z),
+					md.materials=matice(md.materials);
+				else
+					md.materials=matdamageice(md.materials);
+				end
+			end
+			%2012 June 28th
+			if sum(sum(isnan(md.mesh.edges)))>0
+				disp('Update model edges from previous version');
+				md.mesh.edges(isnan(md.mesh.edges))=-1;
+			end
 
-		 end% }}}
-	 end
-	 methods
-		 function md = model(varargin) % {{{
+		end% }}}
+	end
+	methods
+		function md = model(varargin) % {{{
 
-			 switch nargin
-				 case 0
-					 md=setdefaultparameters(md);
-				 otherwise
-					 error('model constructor error message: 0 of 1 argument only in input.');
-				 end
-		 end
-		 %}}}
-		 function md = checkmessage(md,string) % {{{
-			 if(nargout~=1) error('wrong usage, model must be an output'); end
-			 disp(['model not consistent: ' string]);
-			 md.private.isconsistent=false;
-		 end
-		 %}}}
-		 function md = collapse(md)% {{{
-			 %COLLAPSE - collapses a 3d mesh into a 2d mesh
-			 %
-			 %   This routine collapses a 3d model into a 2d model
-			 %   and collapses all the fileds of the 3d model by
-			 %   taking their depth-averaged values
-			 %
-			 %   Usage:
-			 %      md=collapse(md)
-			 %
-			 %   See also: EXTRUDE, MODELEXTRACT
+			switch nargin
+				case 0
+					md=setdefaultparameters(md);
+				otherwise
+					error('model constructor error message: 0 of 1 argument only in input.');
+				end
+		end
+		%}}}
+		function md = checkmessage(md,string) % {{{
+			if(nargout~=1) error('wrong usage, model must be an output'); end
+			disp(['model not consistent: ' string]);
+			md.private.isconsistent=false;
+		end
+		%}}}
+		function md = collapse(md)% {{{
+			%COLLAPSE - collapses a 3d mesh into a 2d mesh
+			%
+			%   This routine collapses a 3d model into a 2d model
+			%   and collapses all the fileds of the 3d model by
+			%   taking their depth-averaged values
+			%
+			%   Usage:
+			%      md=collapse(md)
+			%
+			%   See also: EXTRUDE, MODELEXTRACT
 
-			 %Check that the model is really a 3d model
-			 if ~md.mesh.dimension==3,
-				 error('collapse error message: only 3d mesh can be collapsed')
-			 end
+			%Check that the model is really a 3d model
+			if ~md.mesh.dimension==3,
+				error('collapse error message: only 3d mesh can be collapsed')
+			end
 
-			 %Start with changing alle the fields from the 3d mesh 
+			%Start with changing alle the fields from the 3d mesh 
 
-			 %drag is limited to nodes that are on the bedrock.
-			 md.friction.coefficient=project2d(md,md.friction.coefficient,1);
+			%drag is limited to nodes that are on the bedrock.
+			md.friction.coefficient=project2d(md,md.friction.coefficient,1);
 
-			 %p and q (same deal, except for element that are on the bedrock: )
-			 md.friction.p=project2d(md,md.friction.p,1);
-			 md.friction.q=project2d(md,md.friction.q,1);
+			%p and q (same deal, except for element that are on the bedrock: )
+			md.friction.p=project2d(md,md.friction.p,1);
+			md.friction.q=project2d(md,md.friction.q,1);
 
-			 %observations
-			 if ~isnan(md.inversion.vx_obs), md.inversion.vx_obs=project2d(md,md.inversion.vx_obs,md.mesh.numberoflayers); end;
-			 if ~isnan(md.inversion.vy_obs), md.inversion.vy_obs=project2d(md,md.inversion.vy_obs,md.mesh.numberoflayers); end;
-			 if ~isnan(md.inversion.vel_obs), md.inversion.vel_obs=project2d(md,md.inversion.vel_obs,md.mesh.numberoflayers); end;
-			 if ~isnan(md.inversion.cost_functions_coefficients), md.inversion.cost_functions_coefficients=project2d(md,md.inversion.cost_functions_coefficients,md.mesh.numberoflayers); end;
-			 if numel(md.inversion.min_parameters)>1, md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers); end;
-			 if numel(md.inversion.max_parameters)>1, md.inversion.max_parameters=project2d(md,md.inversion.max_parameters,md.mesh.numberoflayers); end;
-			 if ~isnan(md.surfaceforcings.mass_balance),
-				 md.surfaceforcings.mass_balance=project2d(md,md.surfaceforcings.mass_balance,md.mesh.numberoflayers); 
-			 end;
-			 if ~isnan(md.balancethickness.thickening_rate), md.balancethickness.thickening_rate=project2d(md,md.balancethickness.thickening_rate,md.mesh.numberoflayers); end;
+			%observations
+			if ~isnan(md.inversion.vx_obs), md.inversion.vx_obs=project2d(md,md.inversion.vx_obs,md.mesh.numberoflayers); end;
+			if ~isnan(md.inversion.vy_obs), md.inversion.vy_obs=project2d(md,md.inversion.vy_obs,md.mesh.numberoflayers); end;
+			if ~isnan(md.inversion.vel_obs), md.inversion.vel_obs=project2d(md,md.inversion.vel_obs,md.mesh.numberoflayers); end;
+			if ~isnan(md.inversion.cost_functions_coefficients), md.inversion.cost_functions_coefficients=project2d(md,md.inversion.cost_functions_coefficients,md.mesh.numberoflayers); end;
+			if numel(md.inversion.min_parameters)>1, md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers); end;
+			if numel(md.inversion.max_parameters)>1, md.inversion.max_parameters=project2d(md,md.inversion.max_parameters,md.mesh.numberoflayers); end;
+			if ~isnan(md.surfaceforcings.mass_balance),
+				md.surfaceforcings.mass_balance=project2d(md,md.surfaceforcings.mass_balance,md.mesh.numberoflayers); 
+			end;
+			if ~isnan(md.balancethickness.thickening_rate), md.balancethickness.thickening_rate=project2d(md,md.balancethickness.thickening_rate,md.mesh.numberoflayers); end;
 
-			 %results
-			 if ~isnan(md.initialization.vx),md.initialization.vx=DepthAverage(md,md.initialization.vx);end;
-			 if ~isnan(md.initialization.vy),md.initialization.vy=DepthAverage(md,md.initialization.vy);end;
-			 if ~isnan(md.initialization.vz),md.initialization.vz=DepthAverage(md,md.initialization.vz);end;
-			 if ~isnan(md.initialization.vel),md.initialization.vel=DepthAverage(md,md.initialization.vel);end;
-			 if ~isnan(md.initialization.temperature),md.initialization.temperature=DepthAverage(md,md.initialization.temperature);end;
+			%results
+			if ~isnan(md.initialization.vx),md.initialization.vx=DepthAverage(md,md.initialization.vx);end;
+			if ~isnan(md.initialization.vy),md.initialization.vy=DepthAverage(md,md.initialization.vy);end;
+			if ~isnan(md.initialization.vz),md.initialization.vz=DepthAverage(md,md.initialization.vz);end;
+			if ~isnan(md.initialization.vel),md.initialization.vel=DepthAverage(md,md.initialization.vel);end;
+			if ~isnan(md.initialization.temperature),md.initialization.temperature=DepthAverage(md,md.initialization.temperature);end;
 
-			 %bedinfo and surface info
-			 md.mesh.elementonbed=ones(md.mesh.numberofelements2d,1);
-			 md.mesh.elementonsurface=ones(md.mesh.numberofelements2d,1);
-			 md.mesh.vertexonbed=ones(md.mesh.numberofvertices2d,1);
-			 md.mesh.vertexonsurface=ones(md.mesh.numberofvertices2d,1);
+			%bedinfo and surface info
+			md.mesh.elementonbed=ones(md.mesh.numberofelements2d,1);
+			md.mesh.elementonsurface=ones(md.mesh.numberofelements2d,1);
+			md.mesh.vertexonbed=ones(md.mesh.numberofvertices2d,1);
+			md.mesh.vertexonsurface=ones(md.mesh.numberofvertices2d,1);
 
-			 %elementstype
-			 if ~isnan(md.flowequation.element_equation)
-				 md.flowequation.element_equation=project2d(md,md.flowequation.element_equation,1);
-				 md.flowequation.vertex_equation=project2d(md,md.flowequation.vertex_equation,1);
-				 md.flowequation.bordermacayeal=project2d(md,md.flowequation.bordermacayeal,1);
-				 md.flowequation.borderpattyn=project2d(md,md.flowequation.borderpattyn,1);
-				 md.flowequation.borderstokes=project2d(md,md.flowequation.borderstokes,1);
-			 end	
+			%elementstype
+			if ~isnan(md.flowequation.element_equation)
+				md.flowequation.element_equation=project2d(md,md.flowequation.element_equation,1);
+				md.flowequation.vertex_equation=project2d(md,md.flowequation.vertex_equation,1);
+				md.flowequation.bordermacayeal=project2d(md,md.flowequation.bordermacayeal,1);
+				md.flowequation.borderpattyn=project2d(md,md.flowequation.borderpattyn,1);
+				md.flowequation.borderstokes=project2d(md,md.flowequation.borderstokes,1);
+			end	
 
-			 %boundary conditions
-			 md.diagnostic.spcvx=project2d(md,md.diagnostic.spcvx,md.mesh.numberoflayers);
-			 md.diagnostic.spcvy=project2d(md,md.diagnostic.spcvy,md.mesh.numberoflayers);
-			 md.diagnostic.spcvz=project2d(md,md.diagnostic.spcvz,md.mesh.numberoflayers);
-			 md.diagnostic.referential=project2d(md,md.diagnostic.referential,md.mesh.numberoflayers);
-			 md.prognostic.spcthickness=project2d(md,md.prognostic.spcthickness,md.mesh.numberoflayers);
-			 md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.mesh.numberoflayers);
+			%boundary conditions
+			md.diagnostic.spcvx=project2d(md,md.diagnostic.spcvx,md.mesh.numberoflayers);
+			md.diagnostic.spcvy=project2d(md,md.diagnostic.spcvy,md.mesh.numberoflayers);
+			md.diagnostic.spcvz=project2d(md,md.diagnostic.spcvz,md.mesh.numberoflayers);
+			md.diagnostic.referential=project2d(md,md.diagnostic.referential,md.mesh.numberoflayers);
+			md.prognostic.spcthickness=project2d(md,md.prognostic.spcthickness,md.mesh.numberoflayers);
+			md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.mesh.numberoflayers);
 
-			 %Extrusion of Neumann BC
-			 if ~isnan(md.diagnostic.icefront),
-				 numberofneumann2d=size(md.diagnostic.icefront,1)/(md.mesh.numberoflayers-1);
-				 md.diagnostic.icefront=[md.diagnostic.icefront(1:numberofneumann2d,1:2) md.diagnostic.icefront(1:numberofneumann2d,5:6)]; %Add two columns on the first layer 
-			 end
+			%Extrusion of Neumann BC
+			if ~isnan(md.diagnostic.icefront),
+				numberofneumann2d=size(md.diagnostic.icefront,1)/(md.mesh.numberoflayers-1);
+				md.diagnostic.icefront=[md.diagnostic.icefront(1:numberofneumann2d,1:2) md.diagnostic.icefront(1:numberofneumann2d,5:6)]; %Add two columns on the first layer 
+			end
 
-			 %materials
-			 md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B);
-			 md.materials.rheology_n=project2d(md,md.materials.rheology_n,1);
-			 if isa(md.materials,'matdamageice')
-				 md.materials.rheology_Z=DepthAverage(md,md.materials.rheology_Z);
-			 end
+			%materials
+			md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B);
+			md.materials.rheology_n=project2d(md,md.materials.rheology_n,1);
+			if isa(md.materials,'matdamageice')
+				md.materials.rheology_Z=DepthAverage(md,md.materials.rheology_Z);
+			end
 
-			 %special for thermal modeling:
-			 md.basalforcings.melting_rate=project2d(md,md.basalforcings.melting_rate,1); 
-			 md.basalforcings.geothermalflux=project2d(md,md.basalforcings.geothermalflux,1); %bedrock only gets geothermal flux
+			%special for thermal modeling:
+			md.basalforcings.melting_rate=project2d(md,md.basalforcings.melting_rate,1); 
+			md.basalforcings.geothermalflux=project2d(md,md.basalforcings.geothermalflux,1); %bedrock only gets geothermal flux
 
-			 %update of connectivity matrix
-			 md.mesh.average_vertex_connectivity=25;
+			%update of connectivity matrix
+			md.mesh.average_vertex_connectivity=25;
 
-			 %Collapse the mesh
-			 nodes2d=md.mesh.numberofvertices2d;
-			 elements2d=md.mesh.numberofelements2d;
+			%Collapse the mesh
+			nodes2d=md.mesh.numberofvertices2d;
+			elements2d=md.mesh.numberofelements2d;
 
-			 %parameters
-			 md.geometry.surface=project2d(md,md.geometry.surface,1);
-			 md.geometry.thickness=project2d(md,md.geometry.thickness,1);
-			 md.geometry.bed=project2d(md,md.geometry.bed,1);
-			 md.geometry.bathymetry=project2d(md,md.geometry.bathymetry,1);
-			 md.mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1);
-			 md.mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1);
-			 md.mask.elementonfloatingice=project2d(md,md.mask.elementonfloatingice,1);
-			 md.mask.vertexonfloatingice=project2d(md,md.mask.vertexonfloatingice,1);
-			 md.mask.elementongroundedice=project2d(md,md.mask.elementongroundedice,1);
-			 md.mask.vertexongroundedice=project2d(md,md.mask.vertexongroundedice,1);
-			 md.mask.elementonwater=project2d(md,md.mask.elementonwater,1);
-			 md.mask.vertexonwater=project2d(md,md.mask.vertexonwater,1);
+			%parameters
+			md.geometry.surface=project2d(md,md.geometry.surface,1);
+			md.geometry.thickness=project2d(md,md.geometry.thickness,1);
+			md.geometry.bed=project2d(md,md.geometry.bed,1);
+			md.geometry.bathymetry=project2d(md,md.geometry.bathymetry,1);
+			md.mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1);
+			md.mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1);
+			md.mask.elementonfloatingice=project2d(md,md.mask.elementonfloatingice,1);
+			md.mask.vertexonfloatingice=project2d(md,md.mask.vertexonfloatingice,1);
+			md.mask.elementongroundedice=project2d(md,md.mask.elementongroundedice,1);
+			md.mask.vertexongroundedice=project2d(md,md.mask.vertexongroundedice,1);
+			md.mask.elementonwater=project2d(md,md.mask.elementonwater,1);
+			md.mask.vertexonwater=project2d(md,md.mask.vertexonwater,1);
 
-			 %lat long
-			 if numel(md.mesh.lat) ==md.mesh.numberofvertices,  md.mesh.lat=project2d(md,md.mesh.lat,1); end
-			 if numel(md.mesh.long)==md.mesh.numberofvertices, md.mesh.long=project2d(md,md.mesh.long,1); end
+			%lat long
+			if numel(md.mesh.lat) ==md.mesh.numberofvertices,  md.mesh.lat=project2d(md,md.mesh.lat,1); end
+			if numel(md.mesh.long)==md.mesh.numberofvertices, md.mesh.long=project2d(md,md.mesh.long,1); end
 
-			 %Initialize with the 2d mesh
-			 md.mesh.x=md.mesh.x2d;
-			 md.mesh.y=md.mesh.y2d;
-			 md.mesh.z=zeros(size(md.mesh.x2d));
-			 md.mesh.numberofvertices=md.mesh.numberofvertices2d;
-			 md.mesh.numberofelements=md.mesh.numberofelements2d;
-			 md.mesh.elements=md.mesh.elements2d;
+			%Initialize with the 2d mesh
+			md.mesh.x=md.mesh.x2d;
+			md.mesh.y=md.mesh.y2d;
+			md.mesh.z=zeros(size(md.mesh.x2d));
+			md.mesh.numberofvertices=md.mesh.numberofvertices2d;
+			md.mesh.numberofelements=md.mesh.numberofelements2d;
+			md.mesh.elements=md.mesh.elements2d;
 
-			 %Keep a trace of lower and upper nodes
-			 md.mesh.lowervertex=NaN;
-			 md.mesh.uppervertex=NaN;
-			 md.mesh.lowerelements=NaN;
-			 md.mesh.upperelements=NaN;
+			%Keep a trace of lower and upper nodes
+			md.mesh.lowervertex=NaN;
+			md.mesh.uppervertex=NaN;
+			md.mesh.lowerelements=NaN;
+			md.mesh.upperelements=NaN;
 
-			 %Remove old mesh 
-			 md.mesh.x2d=NaN;
-			 md.mesh.y2d=NaN;
-			 md.mesh.elements2d=NaN;
-			 md.mesh.numberofelements2d=md.mesh.numberofelements;
-			 md.mesh.numberofvertices2d=md.mesh.numberofvertices;
-			 md.mesh.numberoflayers=0;
+			%Remove old mesh 
+			md.mesh.x2d=NaN;
+			md.mesh.y2d=NaN;
+			md.mesh.elements2d=NaN;
+			md.mesh.numberofelements2d=md.mesh.numberofelements;
+			md.mesh.numberofvertices2d=md.mesh.numberofvertices;
+			md.mesh.numberoflayers=0;
 
-			 %Update mesh type
-			 md.mesh.dimension=2;
-		 end % }}}
-		 function md2 = extract(md,area) % {{{
-			 %extract - extract a model according to an Argus contour or flag list
-			 %
-			 %   This routine extracts a submodel from a bigger model with respect to a given contour
-			 %   md must be followed by the corresponding exp file or flags list
-			 %   It can either be a domain file (argus type, .exp extension), or an array of element flags. 
-			 %   If user wants every element outside the domain to be 
-			 %   extract2d, add '~' to the name of the domain file (ex: '~Pattyn.exp');
-			 %   an empty string '' will be considered as an empty domain
-			 %   a string 'all' will be considered as the entire domain
-			 %   add an argument 0 if you do not want the elements to be checked (faster)
-			 %
-			 %   Usage:
-			 %      md2=extract(md,area);
-			 %
-			 %   Examples:
-			 %      md2=extract(md,'Domain.exp');
-			 %      md2=extract(md,md.mask.elementonfloatingice);
-			 %
-			 %   See also: EXTRUDE, COLLAPSE
+			%Update mesh type
+			md.mesh.dimension=2;
+		end % }}}
+		function md2 = extract(md,area) % {{{
+			%extract - extract a model according to an Argus contour or flag list
+			%
+			%   This routine extracts a submodel from a bigger model with respect to a given contour
+			%   md must be followed by the corresponding exp file or flags list
+			%   It can either be a domain file (argus type, .exp extension), or an array of element flags. 
+			%   If user wants every element outside the domain to be 
+			%   extract2d, add '~' to the name of the domain file (ex: '~Pattyn.exp');
+			%   an empty string '' will be considered as an empty domain
+			%   a string 'all' will be considered as the entire domain
+			%
+			%   Usage:
+			%      md2=extract(md,area);
+			%
+			%   Examples:
+			%      md2=extract(md,'Domain.exp');
+			%      md2=extract(md,md.mask.elementonfloatingice);
+			%
+			%   See also: EXTRUDE, COLLAPSE
 
-			 %copy model
-			 md1=md;
+			%copy model
+			md1=md;
 
-			 %some checks
-			 if ((nargin~=2) | (nargout~=1)),
-				 help extract
-				 error('extract error message: bad usage');
-			 end
+			%some checks
+			if ((nargin~=2) | (nargout~=1)),
+				help extract
+				error('extract error message: bad usage');
+			end
 
-			 %get check option
-			 if (nargin==3 & varargin{1}==0),
-				 checkoutline=0;
-			 else
-				 checkoutline=1;
-			 end
+			%get elements that are inside area
+			flag_elem=FlagElements(md1,area);
+			if ~any(flag_elem),
+				error('extracted model is empty');
+			end
 
-			 %get elements that are inside area
-			 flag_elem=FlagElements(md1,area);
-			 if ~any(flag_elem),
-				 error('extracted model is empty');
-			 end
+			%kick out all elements with 3 dirichlets
+			spc_elem=find(~flag_elem);
+			spc_node=sort(unique(md1.mesh.elements(spc_elem,:)));
+			flag=ones(md1.mesh.numberofvertices,1);
+			flag(spc_node)=0;
+			pos=find(sum(flag(md1.mesh.elements),2)==0);
+			flag_elem(pos)=0;
 
-			 %kick out all elements with 3 dirichlets
-			 spc_elem=find(~flag_elem);
-			 spc_node=sort(unique(md1.mesh.elements(spc_elem,:)));
-			 flag=ones(md1.mesh.numberofvertices,1);
-			 flag(spc_node)=0;
-			 pos=find(sum(flag(md1.mesh.elements),2)==0);
-			 flag_elem(pos)=0;
+			%extracted elements and nodes lists
+			pos_elem=find(flag_elem);
+			pos_node=sort(unique(md1.mesh.elements(pos_elem,:)));
 
-			 %extracted elements and nodes lists
-			 pos_elem=find(flag_elem);
-			 pos_node=sort(unique(md1.mesh.elements(pos_elem,:)));
+			%keep track of some fields
+			numberofvertices1=md1.mesh.numberofvertices;
+			numberofelements1=md1.mesh.numberofelements;
+			numberofvertices2=length(pos_node);
+			numberofelements2=length(pos_elem);
+			flag_node=zeros(numberofvertices1,1);
+			flag_node(pos_node)=1;
 
-			 %keep track of some fields
-			 numberofvertices1=md1.mesh.numberofvertices;
-			 numberofelements1=md1.mesh.numberofelements;
-			 numberofvertices2=length(pos_node);
-			 numberofelements2=length(pos_elem);
-			 flag_node=zeros(numberofvertices1,1);
-			 flag_node(pos_node)=1;
+			%Create Pelem and Pnode (transform old nodes in new nodes and same thing for the elements)
+			Pelem=zeros(numberofelements1,1);
+			Pelem(pos_elem)=[1:numberofelements2]';
+			Pnode=zeros(numberofvertices1,1);
+			Pnode(pos_node)=[1:numberofvertices2]';
 
-			 %Create Pelem and Pnode (transform old nodes in new nodes and same thing for the elements)
-			 Pelem=zeros(numberofelements1,1);
-			 Pelem(pos_elem)=[1:numberofelements2]';
-			 Pnode=zeros(numberofvertices1,1);
-			 Pnode(pos_node)=[1:numberofvertices2]';
+			%renumber the elements (some nodes won't exist anymore)
+			elements_1=md1.mesh.elements;
+			elements_2=elements_1(pos_elem,:);
+			elements_2(:,1)=Pnode(elements_2(:,1));
+			elements_2(:,2)=Pnode(elements_2(:,2));
+			elements_2(:,3)=Pnode(elements_2(:,3));
+			if md1.mesh.dimension==3,
+				elements_2(:,4)=Pnode(elements_2(:,4));
+				elements_2(:,5)=Pnode(elements_2(:,5));
+				elements_2(:,6)=Pnode(elements_2(:,6));
+			end
 
-			 %renumber the elements (some node won't exist anymore)
-			 elements_1=md1.mesh.elements;
-			 elements_2=elements_1(pos_elem,:);
-			 elements_2(:,1)=Pnode(elements_2(:,1));
-			 elements_2(:,2)=Pnode(elements_2(:,2));
-			 elements_2(:,3)=Pnode(elements_2(:,3));
-			 if md1.mesh.dimension==3,
-				 elements_2(:,4)=Pnode(elements_2(:,4));
-				 elements_2(:,5)=Pnode(elements_2(:,5));
-				 elements_2(:,6)=Pnode(elements_2(:,6));
-			 end
+			%OK, now create the new model!
 
-			 %OK, now create the new model !
+			%take every field from model
+			md2=md1;
 
-			 %take every fields from model
-			 md2=md1;
+			%automatically modify fields
 
-			 %automatically modify fields
+			%loop over model fields
+			model_fields=fields(md1);
+			for i=1:length(model_fields),
+				%get field
+				field=md1.(model_fields{i});
+				fieldsize=size(field);
+				if isobject(field), %recursive call
+					object_fields=fields(md1.(model_fields{i}));
+					for j=1:length(object_fields),
+						%get field
+						field=md1.(model_fields{i}).(object_fields{j});
+						fieldsize=size(field);
+						%size = number of nodes * n
+						if fieldsize(1)==numberofvertices1
+							md2.(model_fields{i}).(object_fields{j})=field(pos_node,:);
+						elseif (fieldsize(1)==numberofvertices1+1)
+							md2.(model_fields{i}).(object_fields{j})=[field(pos_node,:); field(end,:)];
+						%size = number of elements * n
+						elseif fieldsize(1)==numberofelements1
+							md2.(model_fields{i}).(object_fields{j})=field(pos_elem,:);
+						end
+					end
+				else
+					%size = number of nodes * n
+					if fieldsize(1)==numberofvertices1
+						md2.(model_fields{i})=field(pos_node,:);
+					elseif (fieldsize(1)==numberofvertices1+1)
+						md2.(model_fields{i})=[field(pos_node,:); field(end,:)];
+					%size = number of elements * n
+					elseif fieldsize(1)==numberofelements1
+						md2.(model_fields{i})=field(pos_elem,:);
+					end
+				end
+			end
 
-			 %loop over model fields
-			 model_fields=fields(md1);
-			 for i=1:length(model_fields),
-				 %get field
-				 field=md1.(model_fields{i});
-				 fieldsize=size(field);
-				 if isobject(field), %recursive call
-					 object_fields=fields(md1.(model_fields{i}));
-					 for j=1:length(object_fields),
-						 %get field
-						 field=md1.(model_fields{i}).(object_fields{j});
-						 fieldsize=size(field);
-						 %size = number of nodes * n
-						 if fieldsize(1)==numberofvertices1
-							 md2.(model_fields{i}).(object_fields{j})=field(pos_node,:);
-						 elseif (fieldsize(1)==numberofvertices1+1)
-							 md2.(model_fields{i}).(object_fields{j})=[field(pos_node,:); field(end,:)];
-							 %size = number of elements * n
-						 elseif fieldsize(1)==numberofelements1
-							 md2.(model_fields{i}).(object_fields{j})=field(pos_elem,:);
-						 end
-					 end
-				 else
-					 %size = number of nodes * n
-					 if fieldsize(1)==numberofvertices1
-						 md2.(model_fields{i})=field(pos_node,:);
-					 elseif (fieldsize(1)==numberofvertices1+1)
-						 md2.(model_fields{i})=[field(pos_node,:); field(end,:)];
-						 %size = number of elements * n
-					 elseif fieldsize(1)==numberofelements1
-						 md2.(model_fields{i})=field(pos_elem,:);
-					 end
-				 end
-			 end
+			%modify some specific fields
 
-			 %modify some specific fields
+			%Mesh
+			md2.mesh.numberofelements=numberofelements2;
+			md2.mesh.numberofvertices=numberofvertices2;
+			md2.mesh.elements=elements_2;
 
-			 %Mesh
-			 md2.mesh.numberofelements=numberofelements2;
-			 md2.mesh.numberofvertices=numberofvertices2;
-			 md2.mesh.elements=elements_2;
+			%mesh.uppervertex mesh.lowervertex
+			if md1.mesh.dimension==3
+				md2.mesh.uppervertex=md1.mesh.uppervertex(pos_node);
+				pos=find(~isnan(md2.mesh.uppervertex));
+				md2.mesh.uppervertex(pos)=Pnode(md2.mesh.uppervertex(pos));
 
-			 %mesh.uppervertex mesh.lowervertex
-			 if md1.mesh.dimension==3
-				 md2.mesh.uppervertex=md1.mesh.uppervertex(pos_node);
-				 pos=find(~isnan(md2.mesh.uppervertex));
-				 md2.mesh.uppervertex(pos)=Pnode(md2.mesh.uppervertex(pos));
+				md2.mesh.lowervertex=md1.mesh.lowervertex(pos_node);
+				pos=find(~isnan(md2.mesh.lowervertex));
+				md2.mesh.lowervertex(pos)=Pnode(md2.mesh.lowervertex(pos));
 
-				 md2.mesh.lowervertex=md1.mesh.lowervertex(pos_node);
-				 pos=find(~isnan(md2.mesh.lowervertex));
-				 md2.mesh.lowervertex(pos)=Pnode(md2.mesh.lowervertex(pos));
+				md2.mesh.upperelements=md1.mesh.upperelements(pos_elem);
+				pos=find(~isnan(md2.mesh.upperelements));
+				md2.mesh.upperelements(pos)=Pelem(md2.mesh.upperelements(pos));
 
-				 md2.mesh.upperelements=md1.mesh.upperelements(pos_elem);
-				 pos=find(~isnan(md2.mesh.upperelements));
-				 md2.mesh.upperelements(pos)=Pelem(md2.mesh.upperelements(pos));
+				md2.mesh.lowerelements=md1.mesh.lowerelements(pos_elem);
+				pos=find(~isnan(md2.mesh.lowerelements));
+				md2.mesh.lowerelements(pos)=Pelem(md2.mesh.lowerelements(pos));
+			end
 
-				 md2.mesh.lowerelements=md1.mesh.lowerelements(pos_elem);
-				 pos=find(~isnan(md2.mesh.lowerelements));
-				 md2.mesh.lowerelements(pos)=Pelem(md2.mesh.lowerelements(pos));
-			 end
+			%Initial 2d mesh 
+			if md1.mesh.dimension==3
+				flag_elem_2d=flag_elem(1:md1.mesh.numberofelements2d);
+				pos_elem_2d=find(flag_elem_2d);
+				flag_node_2d=flag_node(1:md1.mesh.numberofvertices2d);
+				pos_node_2d=find(flag_node_2d);
 
-			 %Initial 2d mesh 
-			 if md1.mesh.dimension==3
-				 flag_elem_2d=flag_elem(1:md1.mesh.numberofelements2d);
-				 pos_elem_2d=find(flag_elem_2d);
-				 flag_node_2d=flag_node(1:md1.mesh.numberofvertices2d);
-				 pos_node_2d=find(flag_node_2d);
+				md2.mesh.numberofelements2d=length(pos_elem_2d);
+				md2.mesh.numberofvertices2d=length(pos_node_2d);
+				md2.mesh.elements2d=md1.mesh.elements2d(pos_elem_2d,:);
+				md2.mesh.elements2d(:,1)=Pnode(md2.mesh.elements2d(:,1));
+				md2.mesh.elements2d(:,2)=Pnode(md2.mesh.elements2d(:,2));
+				md2.mesh.elements2d(:,3)=Pnode(md2.mesh.elements2d(:,3));
 
-				 md2.mesh.numberofelements2d=length(pos_elem_2d);
-				 md2.mesh.numberofvertices2d=length(pos_node_2d);
-				 md2.mesh.elements2d=md1.mesh.elements2d(pos_elem_2d,:);
-				 md2.mesh.elements2d(:,1)=Pnode(md2.mesh.elements2d(:,1));
-				 md2.mesh.elements2d(:,2)=Pnode(md2.mesh.elements2d(:,2));
-				 md2.mesh.elements2d(:,3)=Pnode(md2.mesh.elements2d(:,3));
+				md2.mesh.x2d=md1.mesh.x(pos_node_2d);
+				md2.mesh.y2d=md1.mesh.y(pos_node_2d);
+			end
 
-				 md2.mesh.x2d=md1.mesh.x(pos_node_2d);
-				 md2.mesh.y2d=md1.mesh.y(pos_node_2d);
-			 end
+			%Edges
+			if size(md2.mesh.edges,2)>1, %do not use ~isnan because there are some NaNs...
+				%renumber first two columns
+				pos=find(md2.mesh.edges(:,4)~=-1);
+				md2.mesh.edges(:  ,1)=Pnode(md2.mesh.edges(:,1));
+				md2.mesh.edges(:  ,2)=Pnode(md2.mesh.edges(:,2));
+				md2.mesh.edges(:  ,3)=Pelem(md2.mesh.edges(:,3));
+				md2.mesh.edges(pos,4)=Pelem(md2.mesh.edges(pos,4));
+				%remove edges when the 2 vertices are not in the domain.
+				md2.mesh.edges=md2.mesh.edges(find(md2.mesh.edges(:,1) & md2.mesh.edges(:,2)),:);
+				%Replace all zeros by -1 in the last two columns
+				pos=find(md2.mesh.edges(:,3)==0);
+				md2.mesh.edges(pos,3)=-1;
+				pos=find(md2.mesh.edges(:,4)==0);
+				md2.mesh.edges(pos,4)=-1;
+				%Invert -1 on the third column with last column (Also invert first two columns!!)
+				pos=find(md2.mesh.edges(:,3)==-1);
+				md2.mesh.edges(pos,3)=md2.mesh.edges(pos,4);
+				md2.mesh.edges(pos,4)=-1;
+				values=md2.mesh.edges(pos,2);
+				md2.mesh.edges(pos,2)=md2.mesh.edges(pos,1);
+				md2.mesh.edges(pos,1)=values;
+				%Finally remove edges that do not belong to any element
+				pos=find(md2.mesh.edges(:,3)==-1 & md2.mesh.edges(:,4)==-1);
+				md2.mesh.edges(pos,:)=[];
+			end
 
-			 %Edges
-			 if size(md2.mesh.edges,2)>1, %do not use ~isnan because there are some NaNs...
-				 %renumber first two columns
-				 pos=find(md2.mesh.edges(:,4)~=-1);
-				 md2.mesh.edges(:  ,1)=Pnode(md2.mesh.edges(:,1)); 
-				 md2.mesh.edges(:  ,2)=Pnode(md2.mesh.edges(:,2)); 
-				 md2.mesh.edges(:  ,3)=Pelem(md2.mesh.edges(:,3));
-				 md2.mesh.edges(pos,4)=Pelem(md2.mesh.edges(pos,4));
-				 %remove edges when the 2 vertices are not in the domain.
-				 md2.mesh.edges=md2.mesh.edges(find(md2.mesh.edges(:,1) & md2.mesh.edges(:,2)),:);
-				 %Replace all zeros by -1 in the last two columns;
-				 pos=find(md2.mesh.edges(:,3)==0);
-				 md2.mesh.edges(pos,3)=-1;
-				 pos=find(md2.mesh.edges(:,4)==0);
-				 md2.mesh.edges(pos,4)=-1;
-				 %Invert -1 on the third column with last column (Also invert first two columns!!)
-				 pos=find(md2.mesh.edges(:,3)==-1);
-				 md2.mesh.edges(pos,3)=md2.mesh.edges(pos,4);
-				 md2.mesh.edges(pos,4)=-1;
-				 values=md2.mesh.edges(pos,2);
-				 md2.mesh.edges(pos,2)=md2.mesh.edges(pos,1);
-				 md2.mesh.edges(pos,1)=values;
-				 %Finally remove edges that do not belong to any element
-				 pos=find(md2.mesh.edges(:,3)==-1 & md2.mesh.edges(:,4)==-1);
-				 md2.mesh.edges(pos,:)=[];
-			 end
+			%Penalties
+			if ~isnan(md2.diagnostic.vertex_pairing),
+				for i=1:size(md1.diagnostic.vertex_pairing,1);
+					md2.diagnostic.vertex_pairing(i,:)=Pnode(md1.diagnostic.vertex_pairing(i,:));
+				end
+				md2.diagnostic.vertex_pairing=md2.diagnostic.vertex_pairing(find(md2.diagnostic.vertex_pairing(:,1)),:);
+			end
+			if ~isnan(md2.prognostic.vertex_pairing),
+				for i=1:size(md1.prognostic.vertex_pairing,1);
+					md2.prognostic.vertex_pairing(i,:)=Pnode(md1.prognostic.vertex_pairing(i,:));
+				end
+				md2.prognostic.vertex_pairing=md2.prognostic.vertex_pairing(find(md2.prognostic.vertex_pairing(:,1)),:);
+			end
 
-			 %Penalties
-			 if ~isnan(md2.diagnostic.vertex_pairing),
-				 for i=1:size(md1.diagnostic.vertex_pairing,1);
-					 md2.diagnostic.vertex_pairing(i,:)=Pnode(md1.diagnostic.vertex_pairing(i,:));
-				 end
-				 md2.diagnostic.vertex_pairing=md2.diagnostic.vertex_pairing(find(md2.diagnostic.vertex_pairing(:,1)),:);
-			 end
-			 if ~isnan(md2.prognostic.vertex_pairing),
-				 for i=1:size(md1.prognostic.vertex_pairing,1);
-					 md2.prognostic.vertex_pairing(i,:)=Pnode(md1.prognostic.vertex_pairing(i,:));
-				 end
-				 md2.prognostic.vertex_pairing=md2.prognostic.vertex_pairing(find(md2.prognostic.vertex_pairing(:,1)),:);
-			 end
+			%recreate segments
+			if md1.mesh.dimension==2
+				md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices);
+				md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity);
+				md2.mesh.segments=contourenvelope(md2);
+				md2.mesh.vertexonboundary=zeros(numberofvertices2,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1;
+			else
+				%First do the connectivity for the contourenvelope in 2d
+				md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements2d,md2.mesh.numberofvertices2d);
+				md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements2d,md2.mesh.vertexconnectivity);
+				md2.mesh.segments=contourenvelope(md2);
+				md2.mesh.vertexonboundary=zeros(numberofvertices2/md2.mesh.numberoflayers,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1;
+				md2.mesh.vertexonboundary=repmat(md2.mesh.vertexonboundary,md2.mesh.numberoflayers,1);
+				%Then do it for 3d as usual
+				md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices);
+				md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity);
+			end
 
-			 %recreate segments
-			 if md1.mesh.dimension==2
-				 md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices);
-				 md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity);
-				 md2.mesh.segments=contourenvelope(md2);
-				 md2.mesh.vertexonboundary=zeros(numberofvertices2,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1;
-			 else
-				 %First do the connectivity for the contourenvelope in 2d
-				 md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements2d,md2.mesh.numberofvertices2d);
-				 md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements2d,md2.mesh.vertexconnectivity);
-				 md2.mesh.segments=contourenvelope(md2);
-				 md2.mesh.vertexonboundary=zeros(numberofvertices2/md2.mesh.numberoflayers,1); md2.mesh.vertexonboundary(md2.mesh.segments(:,1:2))=1;
-				 md2.mesh.vertexonboundary=repmat(md2.mesh.vertexonboundary,md2.mesh.numberoflayers,1);
-				 %Then do it for 3d as usual
-				 md2.mesh.vertexconnectivity=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices);
-				 md2.mesh.elementconnectivity=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity);
-			 end
+			%Boundary conditions: Dirichlets on new boundary
+			%Catch the elements that have not been extracted
+			orphans_elem=find(~flag_elem);
+			orphans_node=unique(md1.mesh.elements(orphans_elem,:))';
+			%Figure out which node are on the boundary between md2 and md1
+			nodestoflag1=intersect(orphans_node,pos_node);
+			nodestoflag2=Pnode(nodestoflag1);
+			if numel(md1.diagnostic.spcvx)>1 & numel(md1.diagnostic.spcvy)>2 & numel(md1.diagnostic.spcvz)>2,
+				if numel(md1.inversion.vx_obs)>1 & numel(md1.inversion.vy_obs)>1
+					md2.diagnostic.spcvx(nodestoflag2)=md2.inversion.vx_obs(nodestoflag2); 
+					md2.diagnostic.spcvy(nodestoflag2)=md2.inversion.vy_obs(nodestoflag2);
+				else
+					md2.diagnostic.spcvx(nodestoflag2)=NaN;
+					md2.diagnostic.spcvy(nodestoflag2)=NaN;
+					disp(' ')
+					disp('!! extract warning: spc values should be checked !!')
+					disp(' ')
+				end
+				%put 0 for vz
+				md2.diagnostic.spcvz(nodestoflag2)=0;
+			end
+			if ~isnan(md1.thermal.spctemperature),
+				md2.thermal.spctemperature(nodestoflag2,1)=1;
+			end
 
-			 %Boundary conditions: Dirichlets on new boundary
-			 %Catch the elements that have not been extracted
-			 orphans_elem=find(~flag_elem);
-			 orphans_node=unique(md1.mesh.elements(orphans_elem,:))';
-			 %Figure out which node are on the boundary between md2 and md1
-			 nodestoflag1=intersect(orphans_node,pos_node);
-			 nodestoflag2=Pnode(nodestoflag1);
-			 if numel(md1.diagnostic.spcvx)>1 & numel(md1.diagnostic.spcvy)>2 & numel(md1.diagnostic.spcvz)>2,
-				 if numel(md1.inversion.vx_obs)>1 & numel(md1.inversion.vy_obs)>1
-					 md2.diagnostic.spcvx(nodestoflag2)=md2.inversion.vx_obs(nodestoflag2); 
-					 md2.diagnostic.spcvy(nodestoflag2)=md2.inversion.vy_obs(nodestoflag2);
-				 else
-					 md2.diagnostic.spcvx(nodestoflag2)=NaN;
-					 md2.diagnostic.spcvy(nodestoflag2)=NaN;
-					 disp(' ')
-					 disp('!! extract warning: spc values should be checked !!')
-					 disp(' ')
-				 end
-				 %put 0 for vz
-				 md2.diagnostic.spcvz(nodestoflag2)=0;
-			 end
-			 if ~isnan(md1.thermal.spctemperature),
-				 md2.thermal.spctemperature(nodestoflag2,1)=1;
-			 end
+			%Diagnostic
+			if ~isnan(md2.diagnostic.icefront)
+				md2.diagnostic.icefront(:,1)=Pnode(md1.diagnostic.icefront(:,1)); 
+				md2.diagnostic.icefront(:,2)=Pnode(md1.diagnostic.icefront(:,2)); 
+				md2.diagnostic.icefront(:,end-1)=Pelem(md1.diagnostic.icefront(:,end-1));
+				if md1.mesh.dimension==3
+					md2.diagnostic.icefront(:,3)=Pnode(md1.diagnostic.icefront(:,3)); 
+					md2.diagnostic.icefront(:,4)=Pnode(md1.diagnostic.icefront(:,4)); 
+				end
+				md2.diagnostic.icefront=md2.diagnostic.icefront(find(md2.diagnostic.icefront(:,1) & md2.diagnostic.icefront(:,2) & md2.diagnostic.icefront(:,end)),:);
+			end
 
-			 %Diagnostic
-			 if ~isnan(md2.diagnostic.icefront)
-				 md2.diagnostic.icefront(:,1)=Pnode(md1.diagnostic.icefront(:,1)); 
-				 md2.diagnostic.icefront(:,2)=Pnode(md1.diagnostic.icefront(:,2)); 
-				 md2.diagnostic.icefront(:,end-1)=Pelem(md1.diagnostic.icefront(:,end-1));
-				 if md1.mesh.dimension==3
-					 md2.diagnostic.icefront(:,3)=Pnode(md1.diagnostic.icefront(:,3)); 
-					 md2.diagnostic.icefront(:,4)=Pnode(md1.diagnostic.icefront(:,4)); 
-				 end
-				 md2.diagnostic.icefront=md2.diagnostic.icefront(find(md2.diagnostic.icefront(:,1) & md2.diagnostic.icefront(:,2) & md2.diagnostic.icefront(:,end)),:);
-			 end
+			%Results fields
+			if isstruct(md1.results),
+				md2.results=struct();
+				solutionfields=fields(md1.results);
+				for i=1:length(solutionfields),
+					%get subfields
+					solutionsubfields=fields(md1.results.(solutionfields{i}));
+					for j=1:length(solutionsubfields),
+						field=md1.results.(solutionfields{i}).(solutionsubfields{j});
+						if length(field)==numberofvertices1,
+							md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_node);
+						elseif length(field)==numberofelements1,
+							md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_elem);
+						else
+							md2.results.(solutionfields{i}).(solutionsubfields{j})=field;
+						end
+					end
+				end
+			end
 
-			 %Results fields
-			 if isstruct(md1.results),
-				 md2.results=struct();
-				 solutionfields=fields(md1.results);
-				 for i=1:length(solutionfields),
-					 %get subfields
-					 solutionsubfields=fields(md1.results.(solutionfields{i}));
-					 for j=1:length(solutionsubfields),
-						 field=md1.results.(solutionfields{i}).(solutionsubfields{j});
-						 if length(field)==numberofvertices1,
-							 md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_node);
-						 elseif length(field)==numberofelements1,
-							 md2.results.(solutionfields{i}).(solutionsubfields{j})=field(pos_elem);
-						 else
-							 md2.results.(solutionfields{i}).(solutionsubfields{j})=field;
-						 end
-					 end
-				 end
-			 end
+			%Keep track of pos_node and pos_elem
+			md2.mesh.extractedvertices=pos_node;
+			md2.mesh.extractedelements=pos_elem;
+		end % }}}
+		function md = extrude(md,varargin) % {{{
+			%EXTRUDE - vertically extrude a 2d mesh
+			%
+			%   vertically extrude a 2d mesh and create corresponding 3d mesh.
+			%   The vertical distribution can:
+			%    - follow a polynomial law
+			%    - follow two polynomial laws, one for the lower part and one for the upper part of the mesh
+			%    - be discribed by a list of coefficients (between 0 and 1)
+			%   
+			%
+			%   Usage:
+			%      md=extrude(md,numlayers,extrusionexponent);
+			%      md=extrude(md,numlayers,lowerexponent,upperexponent);
+			%      md=extrude(md,listofcoefficients);
+			%
+			%   Example:
+			%      md=extrude(md,8,3);
+			%      md=extrude(md,8,3,2);
+			%      md=extrude(md,[0 0.2 0.5 0.7 0.9 0.95 1]);
+			%
+			%   See also: MODELEXTRACT, COLLAPSE
 
-			 %Keep track of pos_node and pos_elem
-			 md2.mesh.extractedvertices=pos_node;
-			 md2.mesh.extractedelements=pos_elem;
-		 end % }}}
-		 function md = extrude(md,varargin) % {{{
-			 %EXTRUDE - vertically extrude a 2d mesh
-			 %
-			 %   vertically extrude a 2d mesh and create corresponding 3d mesh.
-			 %   The vertical distribution can:
-			 %    - follow a polynomial law
-			 %    - follow two polynomial laws, one for the lower part and one for the upper part of the mesh
-			 %    - be discribed by a list of coefficients (between 0 and 1)
-			 %   
-			 %
-			 %   Usage:
-			 %      md=extrude(md,numlayers,extrusionexponent);
-			 %      md=extrude(md,numlayers,lowerexponent,upperexponent);
-			 %      md=extrude(md,listofcoefficients);
-			 %
-			 %   Example:
-			 %      md=extrude(md,8,3);
-			 %      md=extrude(md,8,3,2);
-			 %      md=extrude(md,[0 0.2 0.5 0.7 0.9 0.95 1]);
-			 %
-			 %   See also: MODELEXTRACT, COLLAPSE
+			%some checks on list of arguments
+			if ((nargin>4) | (nargin<2) | (nargout~=1)),
+				help extrude;
+				error('extrude error message');
+			end
 
-			 %some checks on list of arguments
-			 if ((nargin>4) | (nargin<2) | (nargout~=1)),
-				 help extrude;
-				 error('extrude error message');
-			 end
+			%Extrude the mesh
+			if nargin==2, %list of coefficients
+				clist=varargin{1};
+				if any(clist<0) | any(clist>1),
+					error('extrusioncoefficients must be between 0 and 1');
+				end
+				extrusionlist=sort(unique([clist(:);0;1]));
+				numlayers=length(extrusionlist);
+			elseif nargin==3, %one polynomial law
+				if varargin{2}<=0,
+					help extrude;
+					error('extrusionexponent must be >=0');
+				end
+				numlayers=varargin{1};
+				extrusionlist=((0:1:numlayers-1)/(numlayers-1)).^varargin{2};
+			elseif nargin==4, %two polynomial laws
+				numlayers=varargin{1};
+				lowerexp=varargin{2};
+				upperexp=varargin{3};
 
-			 %Extrude the mesh
-			 if nargin==2, %list of coefficients
-				 clist=varargin{1};
-				 if any(clist<0) | any(clist>1),
-					 error('extrusioncoefficients must be between 0 and 1');
-				 end
-				 extrusionlist=sort(unique([clist(:);0;1]));
-				 numlayers=length(extrusionlist);
-			 elseif nargin==3, %one polynomial law
-				 if varargin{2}<=0,
-					 help extrude;
-					 error('extrusionexponent must be >=0');
-				 end
-				 numlayers=varargin{1};
-				 extrusionlist=((0:1:numlayers-1)/(numlayers-1)).^varargin{2};
-			 elseif nargin==4, %two polynomial laws
-				 numlayers=varargin{1};
-				 lowerexp=varargin{2};
-				 upperexp=varargin{3};
+				if varargin{2}<=0 | varargin{3}<=0,
+					help extrude;
+					error('lower and upper extrusionexponents must be >=0');
+				end
 
-				 if varargin{2}<=0 | varargin{3}<=0,
-					 help extrude;
-					 error('lower and upper extrusionexponents must be >=0');
-				 end
+				lowerextrusionlist=[(0:2/(numlayers-1):1).^lowerexp]/2;
+				upperextrusionlist=[(0:2/(numlayers-1):1).^upperexp]/2;
+				extrusionlist=sort(unique([lowerextrusionlist 1-upperextrusionlist]));
 
-				 lowerextrusionlist=[(0:2/(numlayers-1):1).^lowerexp]/2;
-				 upperextrusionlist=[(0:2/(numlayers-1):1).^upperexp]/2;
-				 extrusionlist=sort(unique([lowerextrusionlist 1-upperextrusionlist]));
+			end
 
-			 end
+			if numlayers<2,
+				error('number of layers should be at least 2');
+			end
+			if md.mesh.dimension==3,
+				error('Cannot extrude a 3d mesh (extrude cannot be called more than once)');
+			end
 
-			 if numlayers<2,
-				 error('number of layers should be at least 2');
-			 end
-			 if md.mesh.dimension==3,
-				 error('Cannot extrude a 3d mesh (extrude cannot be called more than once)');
-			 end
+			%Initialize with the 2d mesh
+			x3d=[]; 
+			y3d=[];
+			z3d=[];  %the lower node is on the bed
+			thickness3d=md.geometry.thickness; %thickness and bed for these nodes
+			bed3d=md.geometry.bed;
 
-			 %Initialize with the 2d mesh
-			 x3d=[]; 
-			 y3d=[];
-			 z3d=[];  %the lower node is on the bed
-			 thickness3d=md.geometry.thickness; %thickness and bed for these nodes
-			 bed3d=md.geometry.bed;
+			%Create the new layers
+			for i=1:numlayers,
+				x3d=[x3d; md.mesh.x]; 
+				y3d=[y3d; md.mesh.y];
+				%nodes are distributed between bed and surface accordingly to the given exponent
+				z3d=[z3d; bed3d+thickness3d*extrusionlist(i)]; 
+			end
+			number_nodes3d=size(x3d,1); %number of 3d nodes for the non extruded part of the mesh
 
-			 %Create the new layers
-			 for i=1:numlayers,
-				 x3d=[x3d; md.mesh.x]; 
-				 y3d=[y3d; md.mesh.y];
-				 %nodes are distributed between bed and surface accordingly to the given exponent
-				 z3d=[z3d; bed3d+thickness3d*extrusionlist(i)]; 
-			 end
-			 number_nodes3d=size(x3d,1); %number of 3d nodes for the non extruded part of the mesh
+			%Extrude elements 
+			elements3d=[];
+			for i=1:numlayers-1,
+				elements3d=[elements3d;[md.mesh.elements+(i-1)*md.mesh.numberofvertices md.mesh.elements+i*md.mesh.numberofvertices]]; %Create the elements of the 3d mesh for the non extruded part
+			end
+			number_el3d=size(elements3d,1); %number of 3d nodes for the non extruded part of the mesh
 
-			 %Extrude elements 
-			 elements3d=[];
-			 for i=1:numlayers-1,
-				 elements3d=[elements3d;[md.mesh.elements+(i-1)*md.mesh.numberofvertices md.mesh.elements+i*md.mesh.numberofvertices]]; %Create the elements of the 3d mesh for the non extruded part
-			 end
-			 number_el3d=size(elements3d,1); %number of 3d nodes for the non extruded part of the mesh
+			%Keep a trace of lower and upper nodes
+			mesh.lowervertex=NaN*ones(number_nodes3d,1);
+			mesh.uppervertex=NaN*ones(number_nodes3d,1);
+			mesh.lowervertex(md.mesh.numberofvertices+1:end)=1:(numlayers-1)*md.mesh.numberofvertices;
+			mesh.uppervertex(1:(numlayers-1)*md.mesh.numberofvertices)=md.mesh.numberofvertices+1:number_nodes3d;
+			md.mesh.lowervertex=mesh.lowervertex;
+			md.mesh.uppervertex=mesh.uppervertex;
 
-			 %Keep a trace of lower and upper nodes
-			 mesh.lowervertex=NaN*ones(number_nodes3d,1);
-			 mesh.uppervertex=NaN*ones(number_nodes3d,1);
-			 mesh.lowervertex(md.mesh.numberofvertices+1:end)=1:(numlayers-1)*md.mesh.numberofvertices;
-			 mesh.uppervertex(1:(numlayers-1)*md.mesh.numberofvertices)=md.mesh.numberofvertices+1:number_nodes3d;
-			 md.mesh.lowervertex=mesh.lowervertex;
-			 md.mesh.uppervertex=mesh.uppervertex;
+			%same for lower and upper elements
+			mesh.lowerelements=NaN*ones(number_el3d,1);
+			mesh.upperelements=NaN*ones(number_el3d,1);
+			mesh.lowerelements(md.mesh.numberofelements+1:end)=1:(numlayers-2)*md.mesh.numberofelements;
+			mesh.upperelements(1:(numlayers-2)*md.mesh.numberofelements)=md.mesh.numberofelements+1:(numlayers-1)*md.mesh.numberofelements;
+			md.mesh.lowerelements=mesh.lowerelements;
+			md.mesh.upperelements=mesh.upperelements;
 
-			 %same for lower and upper elements
-			 mesh.lowerelements=NaN*ones(number_el3d,1);
-			 mesh.upperelements=NaN*ones(number_el3d,1);
-			 mesh.lowerelements(md.mesh.numberofelements+1:end)=1:(numlayers-2)*md.mesh.numberofelements;
-			 mesh.upperelements(1:(numlayers-2)*md.mesh.numberofelements)=md.mesh.numberofelements+1:(numlayers-1)*md.mesh.numberofelements;
-			 md.mesh.lowerelements=mesh.lowerelements;
-			 md.mesh.upperelements=mesh.upperelements;
+			%Save old mesh 
+			md.mesh.x2d=md.mesh.x;
+			md.mesh.y2d=md.mesh.y;
+			md.mesh.elements2d=md.mesh.elements;
+			md.mesh.numberofelements2d=md.mesh.numberofelements;
+			md.mesh.numberofvertices2d=md.mesh.numberofvertices;
 
-			 %Save old mesh 
-			 md.mesh.x2d=md.mesh.x;
-			 md.mesh.y2d=md.mesh.y;
-			 md.mesh.elements2d=md.mesh.elements;
-			 md.mesh.numberofelements2d=md.mesh.numberofelements;
-			 md.mesh.numberofvertices2d=md.mesh.numberofvertices;
+			%Update mesh type
+			md.mesh.dimension=3;
 
-			 %Update mesh type
-			 md.mesh.dimension=3;
+			%Build global 3d mesh 
+			md.mesh.elements=elements3d;
+			md.mesh.x=x3d;
+			md.mesh.y=y3d;
+			md.mesh.z=z3d;
+			md.mesh.numberofelements=number_el3d;
+			md.mesh.numberofvertices=number_nodes3d;
+			md.mesh.numberoflayers=numlayers;
 
-			 %Build global 3d mesh 
-			 md.mesh.elements=elements3d;
-			 md.mesh.x=x3d;
-			 md.mesh.y=y3d;
-			 md.mesh.z=z3d;
-			 md.mesh.numberofelements=number_el3d;
-			 md.mesh.numberofvertices=number_nodes3d;
-			 md.mesh.numberoflayers=numlayers;
+			%Ok, now deal with the other fields from the 2d mesh:
 
-			 %Ok, now deal with the other fields from the 2d mesh:
+			%lat long
+			md.mesh.lat=project3d(md,'vector',md.mesh.lat,'type','node');
+			md.mesh.long=project3d(md,'vector',md.mesh.long,'type','node');
 
-			 %lat long
-			 md.mesh.lat=project3d(md,'vector',md.mesh.lat,'type','node');
-			 md.mesh.long=project3d(md,'vector',md.mesh.long,'type','node');
+			%drag coefficient is limited to nodes that are on the bedrock.
+			md.friction.coefficient=project3d(md,'vector',md.friction.coefficient,'type','node','layer',1);
 
-			 %drag coefficient is limited to nodes that are on the bedrock.
-			 md.friction.coefficient=project3d(md,'vector',md.friction.coefficient,'type','node','layer',1);
+			%p and q (same deal, except for element that are on the bedrock: )
+			md.friction.p=project3d(md,'vector',md.friction.p,'type','element');
+			md.friction.q=project3d(md,'vector',md.friction.q,'type','element');
 
-			 %p and q (same deal, except for element that are on the bedrock: )
-			 md.friction.p=project3d(md,'vector',md.friction.p,'type','element');
-			 md.friction.q=project3d(md,'vector',md.friction.q,'type','element');
+			%observations
+			md.inversion.vx_obs=project3d(md,'vector',md.inversion.vx_obs,'type','node');
+			md.inversion.vy_obs=project3d(md,'vector',md.inversion.vy_obs,'type','node');
+			md.inversion.vel_obs=project3d(md,'vector',md.inversion.vel_obs,'type','node');
+			md.surfaceforcings.mass_balance=project3d(md,'vector',md.surfaceforcings.mass_balance,'type','node');
+			md.surfaceforcings.precipitation=project3d(md,'vector',md.surfaceforcings.precipitation,'type','node');
+			md.balancethickness.thickening_rate=project3d(md,'vector',md.balancethickness.thickening_rate,'type','node');
+			md.surfaceforcings.monthlytemperatures=project3d(md,'vector',md.surfaceforcings.monthlytemperatures,'type','node');
 
-			 %observations
-			 md.inversion.vx_obs=project3d(md,'vector',md.inversion.vx_obs,'type','node');
-			 md.inversion.vy_obs=project3d(md,'vector',md.inversion.vy_obs,'type','node');
-			 md.inversion.vel_obs=project3d(md,'vector',md.inversion.vel_obs,'type','node');
-			 md.surfaceforcings.mass_balance=project3d(md,'vector',md.surfaceforcings.mass_balance,'type','node');
-			 md.surfaceforcings.precipitation=project3d(md,'vector',md.surfaceforcings.precipitation,'type','node');
-			 md.balancethickness.thickening_rate=project3d(md,'vector',md.balancethickness.thickening_rate,'type','node');
-			 md.surfaceforcings.monthlytemperatures=project3d(md,'vector',md.surfaceforcings.monthlytemperatures,'type','node');
+			%results
+			if ~isnan(md.initialization.vx),md.initialization.vx=project3d(md,'vector',md.initialization.vx,'type','node');end;
+			if ~isnan(md.initialization.vy),md.initialization.vy=project3d(md,'vector',md.initialization.vy,'type','node');end;
+			if ~isnan(md.initialization.vz),md.initialization.vz=project3d(md,'vector',md.initialization.vz,'type','node');end;
+			if ~isnan(md.initialization.vel),md.initialization.vel=project3d(md,'vector',md.initialization.vel,'type','node');end;
+			if ~isnan(md.initialization.temperature),md.initialization.temperature=project3d(md,'vector',md.initialization.temperature,'type','node');end;
+			if ~isnan(md.initialization.waterfraction),md.initialization.waterfraction=project3d(md,'vector',md.initialization.waterfraction,'type','node');end;
 
-			 %results
-			 if ~isnan(md.initialization.vx),md.initialization.vx=project3d(md,'vector',md.initialization.vx,'type','node');end;
-			 if ~isnan(md.initialization.vy),md.initialization.vy=project3d(md,'vector',md.initialization.vy,'type','node');end;
-			 if ~isnan(md.initialization.vz),md.initialization.vz=project3d(md,'vector',md.initialization.vz,'type','node');end;
-			 if ~isnan(md.initialization.vel),md.initialization.vel=project3d(md,'vector',md.initialization.vel,'type','node');end;
-			 if ~isnan(md.initialization.temperature),md.initialization.temperature=project3d(md,'vector',md.initialization.temperature,'type','node');end;
-			 if ~isnan(md.initialization.waterfraction),md.initialization.waterfraction=project3d(md,'vector',md.initialization.waterfraction,'type','node');end;
+			%bedinfo and surface info
+			md.mesh.elementonbed=project3d(md,'vector',ones(md.mesh.numberofelements2d,1),'type','element','layer',1);
+			md.mesh.elementonsurface=project3d(md,'vector',ones(md.mesh.numberofelements2d,1),'type','element','layer',md.mesh.numberoflayers-1);
+			md.mesh.vertexonbed=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',1);
+			md.mesh.vertexonsurface=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',md.mesh.numberoflayers);
 
-			 %bedinfo and surface info
-			 md.mesh.elementonbed=project3d(md,'vector',ones(md.mesh.numberofelements2d,1),'type','element','layer',1);
-			 md.mesh.elementonsurface=project3d(md,'vector',ones(md.mesh.numberofelements2d,1),'type','element','layer',md.mesh.numberoflayers-1);
-			 md.mesh.vertexonbed=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',1);
-			 md.mesh.vertexonsurface=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',md.mesh.numberoflayers);
+			%elementstype
+			if ~isnan(md.flowequation.element_equation)
+				oldelements_type=md.flowequation.element_equation;
+				md.flowequation.element_equation=zeros(number_el3d,1);
+				md.flowequation.element_equation=project3d(md,'vector',oldelements_type,'type','element');
+			end
 
-			 %elementstype
-			 if ~isnan(md.flowequation.element_equation)
-				 oldelements_type=md.flowequation.element_equation;
-				 md.flowequation.element_equation=zeros(number_el3d,1);
-				 md.flowequation.element_equation=project3d(md,'vector',oldelements_type,'type','element');
-			 end
+			%verticestype
+			if ~isnan(md.flowequation.vertex_equation)
+				oldvertices_type=md.flowequation.vertex_equation;
+				md.flowequation.vertex_equation=zeros(number_nodes3d,1);
+				md.flowequation.vertex_equation=project3d(md,'vector',oldvertices_type,'type','node');
+			end
+			md.flowequation.bordermacayeal=project3d(md,'vector',md.flowequation.bordermacayeal,'type','node');
+			md.flowequation.borderpattyn=project3d(md,'vector',md.flowequation.borderpattyn,'type','node');
+			md.flowequation.borderstokes=project3d(md,'vector',md.flowequation.borderstokes,'type','node');
 
-			 %verticestype
-			 if ~isnan(md.flowequation.vertex_equation)
-				 oldvertices_type=md.flowequation.vertex_equation;
-				 md.flowequation.vertex_equation=zeros(number_nodes3d,1);
-				 md.flowequation.vertex_equation=project3d(md,'vector',oldvertices_type,'type','node');
-			 end
-			 md.flowequation.bordermacayeal=project3d(md,'vector',md.flowequation.bordermacayeal,'type','node');
-			 md.flowequation.borderpattyn=project3d(md,'vector',md.flowequation.borderpattyn,'type','node');
-			 md.flowequation.borderstokes=project3d(md,'vector',md.flowequation.borderstokes,'type','node');
+			%boundary conditions
+			md.diagnostic.spcvx=project3d(md,'vector',md.diagnostic.spcvx,'type','node');
+			md.diagnostic.spcvy=project3d(md,'vector',md.diagnostic.spcvy,'type','node');
+			md.diagnostic.spcvz=project3d(md,'vector',md.diagnostic.spcvz,'type','node');
+			md.thermal.spctemperature=project3d(md,'vector',md.thermal.spctemperature,'type','node','layer',md.mesh.numberoflayers,'padding',NaN);
+			md.prognostic.spcthickness=project3d(md,'vector',md.prognostic.spcthickness,'type','node');
+			md.balancethickness.spcthickness=project3d(md,'vector',md.balancethickness.spcthickness,'type','node');
+			md.diagnostic.referential=project3d(md,'vector',md.diagnostic.referential,'type','node');
 
-			 %boundary conditions
-			 md.diagnostic.spcvx=project3d(md,'vector',md.diagnostic.spcvx,'type','node');
-			 md.diagnostic.spcvy=project3d(md,'vector',md.diagnostic.spcvy,'type','node');
-			 md.diagnostic.spcvz=project3d(md,'vector',md.diagnostic.spcvz,'type','node');
-			 md.thermal.spctemperature=project3d(md,'vector',md.thermal.spctemperature,'type','node','layer',md.mesh.numberoflayers,'padding',NaN);
-			 md.prognostic.spcthickness=project3d(md,'vector',md.prognostic.spcthickness,'type','node');
-			 md.balancethickness.spcthickness=project3d(md,'vector',md.balancethickness.spcthickness,'type','node');
-			 md.diagnostic.referential=project3d(md,'vector',md.diagnostic.referential,'type','node');
+			%in 3d, pressureload: [node1 node2 node3 node4 element]
+			pressureload_layer1=[md.diagnostic.icefront(:,1:2)  md.diagnostic.icefront(:,2)+md.mesh.numberofvertices2d  md.diagnostic.icefront(:,1)+md.mesh.numberofvertices2d  md.diagnostic.icefront(:,3:4)]; %Add two columns on the first layer 
+			pressureload=[];
+			for i=1:numlayers-1,
+				pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d pressureload_layer1(:,6)];
+			end
+			md.diagnostic.icefront=pressureload;
 
-			 %in 3d, pressureload: [node1 node2 node3 node4 element]
-			 pressureload_layer1=[md.diagnostic.icefront(:,1:2)  md.diagnostic.icefront(:,2)+md.mesh.numberofvertices2d  md.diagnostic.icefront(:,1)+md.mesh.numberofvertices2d  md.diagnostic.icefront(:,3:4)]; %Add two columns on the first layer 
-			 pressureload=[];
-			 for i=1:numlayers-1,
-				 pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d pressureload_layer1(:,6)];
-			 end
-			 md.diagnostic.icefront=pressureload;
+			%connectivity
+			md.mesh.elementconnectivity=repmat(md.mesh.elementconnectivity,numlayers-1,1);
+			md.mesh.elementconnectivity(find(md.mesh.elementconnectivity==0))=NaN;
+			for i=2:numlayers-1,
+				md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)...
+					=md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)+md.mesh.numberofelements2d;
+			end
+			md.mesh.elementconnectivity(find(isnan(md.mesh.elementconnectivity)))=0;
 
-			 %connectivity
-			 md.mesh.elementconnectivity=repmat(md.mesh.elementconnectivity,numlayers-1,1);
-			 md.mesh.elementconnectivity(find(md.mesh.elementconnectivity==0))=NaN;
-			 for i=2:numlayers-1,
-				 md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)...
-					 =md.mesh.elementconnectivity((i-1)*md.mesh.numberofelements2d+1:(i)*md.mesh.numberofelements2d,:)+md.mesh.numberofelements2d;
-			 end
-			 md.mesh.elementconnectivity(find(isnan(md.mesh.elementconnectivity)))=0;
+			%materials
+			md.materials.rheology_B=project3d(md,'vector',md.materials.rheology_B,'type','node');
+			md.materials.rheology_n=project3d(md,'vector',md.materials.rheology_n,'type','element');
+			if isa(md.materials,'matdamageice')
+				md.materials.rheology_Z=project3d(md,'vector',md.materials.rheology_Z,'type','node');
+			end
 
-			 %materials
-			 md.materials.rheology_B=project3d(md,'vector',md.materials.rheology_B,'type','node');
-			 md.materials.rheology_n=project3d(md,'vector',md.materials.rheology_n,'type','element');
-			 if isa(md.materials,'matdamageice')
-				 md.materials.rheology_Z=project3d(md,'vector',md.materials.rheology_Z,'type','node');
-			 end
+			%parameters
+			md.geometry.surface=project3d(md,'vector',md.geometry.surface,'type','node');
+			md.geometry.thickness=project3d(md,'vector',md.geometry.thickness,'type','node');
+			md.geometry.hydrostatic_ratio=project3d(md,'vector',md.geometry.hydrostatic_ratio,'type','node');
+			md.geometry.bed=project3d(md,'vector',md.geometry.bed,'type','node');
+			md.geometry.bathymetry=project3d(md,'vector',md.geometry.bathymetry,'type','node');
+			md.mesh.vertexonboundary=project3d(md,'vector',md.mesh.vertexonboundary,'type','node');
+			md.mask.elementonfloatingice=project3d(md,'vector',md.mask.elementonfloatingice,'type','element');
+			md.mask.vertexonfloatingice=project3d(md,'vector',md.mask.vertexonfloatingice,'type','node');
+			md.mask.elementongroundedice=project3d(md,'vector',md.mask.elementongroundedice,'type','element');
+			md.mask.vertexongroundedice=project3d(md,'vector',md.mask.vertexongroundedice,'type','node');
+			md.mask.elementonwater=project3d(md,'vector',md.mask.elementonwater,'type','element');
+			md.mask.vertexonwater=project3d(md,'vector',md.mask.vertexonwater,'type','node');
+			if ~isnan(md.inversion.cost_functions_coefficients),md.inversion.cost_functions_coefficients=project3d(md,'vector',md.inversion.cost_functions_coefficients,'type','node');end;
+			if ~isnan(md.inversion.min_parameters),md.inversion.min_parameters=project3d(md,'vector',md.inversion.min_parameters,'type','node');end;
+			if ~isnan(md.inversion.max_parameters),md.inversion.max_parameters=project3d(md,'vector',md.inversion.max_parameters,'type','node');end;
+			if ~isnan(md.qmu.partition),md.qmu.partition=project3d(md,'vector',md.qmu.partition','type','node');end
+			if(md.surfaceforcings.isdelta18o),md.surfaceforcings.temperatures_lgm=project3d(md,'vector',md.surfaceforcings.temperatures_lgm,'type','node');end
+			if(md.surfaceforcings.isdelta18o),md.surfaceforcings.temperatures_presentday=project3d(md,'vector',md.surfaceforcings.temperatures_presentday,'type','node');end
+			if(md.surfaceforcings.isdelta18o),md.surfaceforcings.precipitations_presentday=project3d(md,'vector',md.surfaceforcings.precipitations_presentday,'type','node');end
 
-			 %parameters
-			 md.geometry.surface=project3d(md,'vector',md.geometry.surface,'type','node');
-			 md.geometry.thickness=project3d(md,'vector',md.geometry.thickness,'type','node');
-			 md.geometry.hydrostatic_ratio=project3d(md,'vector',md.geometry.hydrostatic_ratio,'type','node');
-			 md.geometry.bed=project3d(md,'vector',md.geometry.bed,'type','node');
-			 md.geometry.bathymetry=project3d(md,'vector',md.geometry.bathymetry,'type','node');
-			 md.mesh.vertexonboundary=project3d(md,'vector',md.mesh.vertexonboundary,'type','node');
-			 md.mask.elementonfloatingice=project3d(md,'vector',md.mask.elementonfloatingice,'type','element');
-			 md.mask.vertexonfloatingice=project3d(md,'vector',md.mask.vertexonfloatingice,'type','node');
-			 md.mask.elementongroundedice=project3d(md,'vector',md.mask.elementongroundedice,'type','element');
-			 md.mask.vertexongroundedice=project3d(md,'vector',md.mask.vertexongroundedice,'type','node');
-			 md.mask.elementonwater=project3d(md,'vector',md.mask.elementonwater,'type','element');
-			 md.mask.vertexonwater=project3d(md,'vector',md.mask.vertexonwater,'type','node');
-			 if ~isnan(md.inversion.cost_functions_coefficients),md.inversion.cost_functions_coefficients=project3d(md,'vector',md.inversion.cost_functions_coefficients,'type','node');end;
-			 if ~isnan(md.inversion.min_parameters),md.inversion.min_parameters=project3d(md,'vector',md.inversion.min_parameters,'type','node');end;
-			 if ~isnan(md.inversion.max_parameters),md.inversion.max_parameters=project3d(md,'vector',md.inversion.max_parameters,'type','node');end;
-			 if ~isnan(md.qmu.partition),md.qmu.partition=project3d(md,'vector',md.qmu.partition','type','node');end
-			 if(md.surfaceforcings.isdelta18o),md.surfaceforcings.temperatures_lgm=project3d(md,'vector',md.surfaceforcings.temperatures_lgm,'type','node');end
-			 if(md.surfaceforcings.isdelta18o),md.surfaceforcings.temperatures_presentday=project3d(md,'vector',md.surfaceforcings.temperatures_presentday,'type','node');end
-			 if(md.surfaceforcings.isdelta18o),md.surfaceforcings.precipitations_presentday=project3d(md,'vector',md.surfaceforcings.precipitations_presentday,'type','node');end
+			%Put lithostatic pressure if there is an existing pressure
+			if ~isnan(md.initialization.pressure),
+				md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z);
+			end
 
-			 %Put lithostatic pressure if there is an existing pressure
-			 if ~isnan(md.initialization.pressure),
-				 md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z);
-			 end
+			%special for thermal modeling:
+			md.basalforcings.melting_rate=project3d(md,'vector',md.basalforcings.melting_rate,'type','node','layer',1); 
+			if ~isnan(md.basalforcings.geothermalflux)
+				md.basalforcings.geothermalflux=project3d(md,'vector',md.basalforcings.geothermalflux,'type','node','layer',1); %bedrock only gets geothermal flux
+			end
 
-			 %special for thermal modeling:
-			 md.basalforcings.melting_rate=project3d(md,'vector',md.basalforcings.melting_rate,'type','node','layer',1); 
-			 if ~isnan(md.basalforcings.geothermalflux)
-				 md.basalforcings.geothermalflux=project3d(md,'vector',md.basalforcings.geothermalflux,'type','node','layer',1); %bedrock only gets geothermal flux
-			 end
-
-			 %increase connectivity if less than 25:
-			 if md.mesh.average_vertex_connectivity<=25,
-				 md.mesh.average_vertex_connectivity=100;
-			 end
+			%increase connectivity if less than 25:
+			if md.mesh.average_vertex_connectivity<=25,
+				md.mesh.average_vertex_connectivity=100;
+			end
 			end % }}}
-		 function md = structtomodel(md,structmd) % {{{
+		function md = structtomodel(md,structmd) % {{{
 
-			 if ~isstruct(structmd) error('input model is not a structure'); end
+			if ~isstruct(structmd) error('input model is not a structure'); end
 
-			 %loaded model is a struct, initialize output and recover all fields
-			 md = structtoobj(model,structmd);
+			%loaded model is a struct, initialize output and recover all fields
+			md = structtoobj(model,structmd);
 
-			 %Old field now classes
-			 if (isfield(structmd,'timestepping') & isnumeric(md.timestepping)), md.timestepping=timestepping(); end
-			 if (isfield(structmd,'mask') & isnumeric(md.mask)),md.mask=mask(); end
+			%Old field now classes
+			if (isfield(structmd,'timestepping') & isnumeric(md.timestepping)), md.timestepping=timestepping(); end
+			if (isfield(structmd,'mask') & isnumeric(md.mask)),md.mask=mask(); end
 
-			 %Field name change
-			 if isfield(structmd,'drag'), md.friction.coefficient=structmd.drag; end
-			 if isfield(structmd,'p'), md.friction.p=structmd.p; end
-			 if isfield(structmd,'q'), md.friction.q=structmd.p; end
-			 if isfield(structmd,'melting'), md.basalforcings.melting_rate=structmd.melting; end
-			 if isfield(structmd,'melting_rate'), md.basalforcings.melting_rate=structmd.melting_rate; end
-			 if isfield(structmd,'accumulation'), md.surfaceforcings.mass_balance=structmd.accumulation; end
-			 if isfield(structmd,'numberofgrids'), md.mesh.numberofvertices=structmd.numberofgrids; end
-			 if isfield(structmd,'numberofgrids2d'), md.mesh.numberofvertices2d=structmd.numberofgrids2d; end
-			 if isfield(structmd,'uppergrids'), md.mesh.uppervertex=structmd.uppergrids; end
-			 if isfield(structmd,'lowergrids'), md.mesh.lowervertex=structmd.lowergrids; end
-			 if isfield(structmd,'gridonbed'), md.mesh.vertexonbed=structmd.gridonbed; end
-			 if isfield(structmd,'gridonsurface'), md.mesh.vertexonsurface=structmd.gridonsurface; end
-			 if isfield(structmd,'extractedgrids'), md.mesh.extractedvertices=structmd.extractedgrids; end
-			 if isfield(structmd,'gridoniceshelf'), md.mask.vertexonfloatingice=structmd.gridoniceshelf; end
-			 if isfield(structmd,'gridonicesheet'), md.mask.vertexongroundedice=structmd.gridonicesheet; end
-			 if isfield(structmd,'gridonwater'), md.mask.vertexonwater=structmd.gridonwater; end
-			 if isfield(structmd,'gridonboundary'), md.mesh.vertexonboundary=structmd.gridonboundary; end
-			 if isfield(structmd,'petscoptions') & ~isempty(structmd.petscoptions), md.solver=structmd.petscoptions; end
-			 if isfield(structmd,'g'), md.constants.g=structmd.g; end
-			 if isfield(structmd,'yts'), md.constants.yts=structmd.yts; end
-			 if isfield(structmd,'surface_mass_balance'), md.surfaceforcings.mass_balance=structmd.surface_mass_balance; end
-			 if isfield(structmd,'basal_melting_rate'), md.basalforcings.melting_rate=structmd.basal_melting_rate; end
-			 if isfield(structmd,'basal_melting_rate_correction'), md.basalforcings.melting_rate_correction=structmd.basal_melting_rate_correction; end
-			 if isfield(structmd,'geothermalflux'), md.basalforcings.geothermalflux=structmd.geothermalflux; end
-			 if isfield(structmd,'drag'), md.friction.coefficient=structmd.drag; end
-			 if isfield(structmd,'drag_coefficient'), md.friction.coefficient=structmd.drag_coefficient; end
-			 if isfield(structmd,'drag_p'), md.friction.p=structmd.drag_p; end
-			 if isfield(structmd,'drag_q'), md.friction.q=structmd.drag_q; end
-			 if isfield(structmd,'riftproperties'), %old implementation
-				 md.rifts=rifts();
-				 md.rifts.riftproperties=structmd.riftproperties; 
-				 md.rifts.riftstruct=structmd.rifts;
-				 md.rifts.riftproperties=structmd.riftinfo;
-			 end
-			 if isfield(structmd,'bamg'), md.private.bamg=structmd.bamg; end
-			 if isfield(structmd,'lowmem'), md.settings.lowmem=structmd.lowmem; end
-			 if isfield(structmd,'io_gather'), md.settings.io_gather=structmd.io_gather; end
-			 if isfield(structmd,'spcwatercolumn'), md.hydrology.spcwatercolumn=structmd.spcwatercolumn; end
-			 if isfield(structmd,'hydro_n'), md.hydrology.n=structmd.hydro_n; end
-			 if isfield(structmd,'hydro_p'), md.hydrology.p=structmd.hydro_p; end
-			 if isfield(structmd,'hydro_q'), md.hydrology.q=structmd.hydro_q; end
-			 if isfield(structmd,'hydro_CR'), md.hydrology.CR=structmd.hydro_CR; end
-			 if isfield(structmd,'hydro_kn'), md.hydrology.kn=structmd.hydro_kn; end
-			 if isfield(structmd,'spctemperature'), md.thermal.spctemperature=structmd.spctemperature; end
-			 if isfield(structmd,'min_thermal_constraints'), md.thermal.penalty_threshold=structmd.min_thermal_constraints; end
-			 if isfield(structmd,'artificial_diffusivity'), md.thermal.stabilization=structmd.artificial_diffusivity; end
-			 if isfield(structmd,'max_nonlinear_iterations'), md.thermal.maxiter=structmd.max_nonlinear_iterations; end
-			 if isfield(structmd,'stabilize_constraints'), md.thermal.penalty_lock=structmd.stabilize_constraints; end
-			 if isfield(structmd,'penalty_offset'), md.thermal.penalty_factor=structmd.penalty_offset; end
-			 if isfield(structmd,'name'), md.miscellaneous.name=structmd.name; end
-			 if isfield(structmd,'notes'), md.miscellaneous.notes=structmd.notes; end
-			 if isfield(structmd,'dummy'), md.miscellaneous.dummy=structmd.dummy; end
-			 if isfield(structmd,'dt'), md.timestepping.time_step=structmd.dt; end
-			 if isfield(structmd,'ndt'), md.timestepping.final_time=structmd.ndt; end
-			 if isfield(structmd,'time_adapt'), md.timestepping.time_adapt=structmd.time_adapt; end
-			 if isfield(structmd,'cfl_coefficient'), md.timestepping.cfl_coefficient=structmd.cfl_coefficient; end
-			 if isfield(structmd,'spcthickness'), md.prognostic.spcthickness=structmd.spcthickness; end
-			 if isfield(structmd,'artificial_diffusivity'), md.prognostic.stabilization=structmd.artificial_diffusivity; end
-			 if isfield(structmd,'hydrostatic_adjustment'), md.prognostic.hydrostatic_adjustment=structmd.hydrostatic_adjustment; end
-			 if isfield(structmd,'penalties'), md.prognostic.vertex_pairing=structmd.penalties; end
-			 if isfield(structmd,'penalty_offset'), md.prognostic.penalty_factor=structmd.penalty_offset; end
-			 if isfield(structmd,'B'), md.materials.rheology_B=structmd.B; end
-			 if isfield(structmd,'n'), md.materials.rheology_n=structmd.n; end
-			 if isfield(structmd,'rheology_B'), md.materials.rheology_B=structmd.rheology_B; end
-			 if isfield(structmd,'rheology_n'), md.materials.rheology_n=structmd.rheology_n; end
-			 if isfield(structmd,'elementoniceshelf'), md.mask.elementonfloatingice=structmd.elementoniceshelf; end
-			 if isfield(structmd,'elementonicesheet'), md.mask.elementongroundedice=structmd.elementonicesheet; end
-			 if isfield(structmd,'elementonwater'), md.mask.elementonwater=structmd.elementonwater; end
-			 if isfield(structmd,'nodeoniceshelf'), md.mask.vertexonfloatingice=structmd.nodeoniceshelf; end
-			 if isfield(structmd,'nodeonicesheet'), md.mask.vertexongroundedice=structmd.nodeonicesheet; end
-			 if isfield(structmd,'nodeonwater'), md.mask.vertexonwater=structmd.nodeonwater; end
-			 if isfield(structmd,'spcthickness'), md.balancethickness.spcthickness=structmd.spcthickness; end
-			 if isfield(structmd,'artificial_diffusivity'), md.balancethickness.stabilization=structmd.artificial_diffusivity; end
-			 if isfield(structmd,'dhdt'), md.balancethickness.thickening_rate=structmd.dhdt; end
-			 if isfield(structmd,'ismacayealpattyn'), md.flowequation.ismacayealpattyn=structmd.ismacayealpattyn; end
-			 if isfield(structmd,'ishutter'), md.flowequation.ishutter=structmd.ishutter; end
-			 if isfield(structmd,'isstokes'), md.flowequation.isstokes=structmd.isstokes; end
-			 if isfield(structmd,'elements_type'), md.flowequation.element_equation=structmd.elements_type; end
-			 if isfield(structmd,'vertices_type'), md.flowequation.vertex_equation=structmd.vertices_type; end
-			 if isfield(structmd,'eps_rel'), md.steadystate.reltol=structmd.eps_rel; end
-			 if isfield(structmd,'max_steadystate_iterations'), md.steadystate.maxiter=structmd.max_steadystate_iterations; end
-			 if isfield(structmd,'isdiagnostic'), md.transient.isdiagnostic=structmd.isdiagnostic; end
-			 if isfield(structmd,'isprognostic'), md.transient.isprognostic=structmd.isprognostic; end
-			 if isfield(structmd,'isthermal'), md.transient.isthermal=structmd.isthermal; end
-			 if isfield(structmd,'control_analysis'), md.inversion.iscontrol=structmd.control_analysis; end
-			 if isfield(structmd,'weights'), md.inversion.cost_functions_coefficients=structmd.weights; end
-			 if isfield(structmd,'nsteps'), md.inversion.nsteps=structmd.nsteps; end
-			 if isfield(structmd,'maxiter_per_step'), md.inversion.maxiter_per_step=structmd.maxiter_per_step; end
-			 if isfield(structmd,'cm_min'), md.inversion.min_parameters=structmd.cm_min; end
-			 if isfield(structmd,'cm_max'), md.inversion.max_parameters=structmd.cm_max; end
-			 if isfield(structmd,'vx_obs'), md.inversion.vx_obs=structmd.vx_obs; end
-			 if isfield(structmd,'vy_obs'), md.inversion.vy_obs=structmd.vy_obs; end
-			 if isfield(structmd,'vel_obs'), md.inversion.vel_obs=structmd.vel_obs; end
-			 if isfield(structmd,'thickness_obs'), md.inversion.thickness_obs=structmd.thickness_obs; end
-			 if isfield(structmd,'vx'), md.initialization.vx=structmd.vx; end
-			 if isfield(structmd,'vy'), md.initialization.vy=structmd.vy; end
-			 if isfield(structmd,'vz'), md.initialization.vz=structmd.vz; end
-			 if isfield(structmd,'vel'), md.initialization.vel=structmd.vel; end
-			 if isfield(structmd,'pressure'), md.initialization.pressure=structmd.pressure; end
-			 if isfield(structmd,'temperature'), md.initialization.temperature=structmd.temperature; end
-			 if isfield(structmd,'waterfraction'), md.initialization.waterfraction=structmd.waterfraction; end
-			 if isfield(structmd,'watercolumn'), md.initialization.watercolumn=structmd.watercolumn; end
-			 if isfield(structmd,'surface'), md.geometry.surface=structmd.surface; end
-			 if isfield(structmd,'bed'), md.geometry.bed=structmd.bed; end
-			 if isfield(structmd,'thickness'), md.geometry.thickness=structmd.thickness; end
-			 if isfield(structmd,'bathymetry'), md.geometry.bathymetry=structmd.bathymetry; end
-			 if isfield(structmd,'thickness_coeff'), md.geometry.hydrostatic_ratio=structmd.thickness_coeff; end
-			 if isfield(structmd,'connectivity'), md.mesh.average_vertex_connectivity=structmd.connectivity; end
-			 if isfield(structmd,'extractednodes'), md.mesh.extractedvertices=structmd.extractednodes; end
-			 if isfield(structmd,'extractedelements'), md.mesh.extractedelements=structmd.extractedelements; end
-			 if isfield(structmd,'nodeonboundary'), md.mesh.vertexonboundary=structmd.nodeonboundary; end
-			 if isfield(structmd,'hemisphere'), md.mesh.hemisphere=structmd.hemisphere; end
-			 if isfield(structmd,'lat'), md.mesh.lat=structmd.lat; end
-			 if isfield(structmd,'long'), md.mesh.long=structmd.long; end
-			 if isfield(structmd,'segments'), md.mesh.segments=structmd.segments; end
-			 if isfield(structmd,'segmentmarkers'), md.mesh.segmentmarkers=structmd.segmentmarkers; end
-			 if isfield(structmd,'dim'), md.mesh.dimension=structmd.dim; end
-			 if isfield(structmd,'numlayers'), md.mesh.numberoflayers=structmd.numlayers; end
-			 if isfield(structmd,'numberofelements'), md.mesh.numberofelements=structmd.numberofelements; end
-			 if isfield(structmd,'numberofvertices'), md.mesh.numberofvertices=structmd.numberofvertices; end
-			 if isfield(structmd,'numberofnodes'), md.mesh.numberofvertices=structmd.numberofnodes; end
-			 if isfield(structmd,'numberofedges'), md.mesh.numberofedges=structmd.numberofedges; end
-			 if isfield(structmd,'numberofelements2d'), md.mesh.numberofelements2d=structmd.numberofelements2d; end
-			 if isfield(structmd,'numberofnodes2d'), md.mesh.numberofvertices2d=structmd.numberofnodes2d; end
-			 if isfield(structmd,'nodeconnectivity'), md.mesh.vertexconnectivity=structmd.nodeconnectivity; end
-			 if isfield(structmd,'elementconnectivity'), md.mesh.elementconnectivity=structmd.elementconnectivity; end
-			 if isfield(structmd,'uppernodes'), md.mesh.uppervertex=structmd.uppernodes; end
-			 if isfield(structmd,'lowernodes'), md.mesh.lowervertex=structmd.lowernodes; end
-			 if isfield(structmd,'upperelements'), md.mesh.upperelements=structmd.upperelements; end
-			 if isfield(structmd,'lowerelements'), md.mesh.lowerelements=structmd.lowerelements; end
-			 if isfield(structmd,'elementonbed'), md.mesh.elementonbed=structmd.elementonbed; end
-			 if isfield(structmd,'elementonsurface'), md.mesh.elementonsurface=structmd.elementonsurface; end
-			 if isfield(structmd,'nodeonsurface'), md.mesh.vertexonsurface=structmd.nodeonsurface; end
-			 if isfield(structmd,'nodeonbed'), md.mesh.vertexonbed=structmd.nodeonbed; end
-			 if isfield(structmd,'elements2d'), md.mesh.elements2d=structmd.elements2d; end
-			 if isfield(structmd,'y2d'), md.mesh.y2d=structmd.y2d; end
-			 if isfield(structmd,'x2d'), md.mesh.x2d=structmd.x2d; end
-			 if isfield(structmd,'elements'), md.mesh.elements=structmd.elements; end
-			 if isfield(structmd,'edges'), md.mesh.edges=structmd.edges; end
-			 if isfield(structmd,'y'), md.mesh.y=structmd.y; end
-			 if isfield(structmd,'x'), md.mesh.x=structmd.x; end
-			 if isfield(structmd,'z'), md.mesh.z=structmd.z; end
-			 if isfield(structmd,'mask'), md.flaim.criterion=structmd.mask; end
-			 if isfield(structmd,'pressureload'), md.diagnostic.icefront=structmd.pressureload; end
-			 if isfield(structmd,'diagnostic_ref'), md.diagnostic.referential=structmd.diagnostic_ref; end
-			 if isfield(structmd,'npart'); md.qmu.numberofpartitions=structmd.npart; end
-			 if isfield(structmd,'part'); md.qmu.partition=structmd.part; end
-				 
-			 %Field changes
-			 if (isfield(structmd,'type') & ischar(structmd.type)), 
-				 if strcmpi(structmd.type,'2d'), md.mesh.dimension=2; end
-				 if strcmpi(structmd.type,'3d'), md.mesh.dimension=3; end
-			 end
-			 if isnumeric(md.verbose),
-				 md.verbose=verbose;
-			 end
-			 if size(md.diagnostic.icefront,2)==3 || size(md.diagnostic.icefront,2)==5,
-				 front=md.diagnostic.icefront;
-				 md.diagnostic.icefront=[front 1*md.mask.elementonfloatingice(front(:,end))];
-			 end
-			 if isfield(structmd,'spcvelocity'), 
-				 md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1);
-				 md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1);
-				 md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
-				 pos=find(structmd.spcvelocity(:,1)); md.diagnostic.spcvx(pos)=structmd.spcvelocity(pos,4); 
-				 pos=find(structmd.spcvelocity(:,2)); md.diagnostic.spcvy(pos)=structmd.spcvelocity(pos,5); 
-				 pos=find(structmd.spcvelocity(:,3)); md.diagnostic.spcvz(pos)=structmd.spcvelocity(pos,6); 
-			 end
-			 if isfield(structmd,'spcvx'), 
-				 md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1);
-				 pos=find(~isnan(structmd.spcvx)); md.diagnostic.spcvx(pos)=structmd.spcvx(pos); 
-			 end
-			 if isfield(structmd,'spcvy'),
-				 md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1);
-				 pos=find(~isnan(structmd.spcvy)); md.diagnostic.spcvy(pos)=structmd.spcvy(pos);     
-			 end
-			 if isfield(structmd,'spcvz'),
-				 md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
-				 pos=find(~isnan(structmd.spcvz)); md.diagnostic.spcvz(pos)=structmd.spcvz(pos);     
-			 end
-			 if ~isempty(structmd.pressureload) & ismember(structmd.pressureload(end,end),[118 119 120]),
-				 pos=find(structmd.pressureload(:,end)==120); md.diagnostic.icefront(pos,end)=0;
-				 pos=find(structmd.pressureload(:,end)==118); md.diagnostic.icefront(pos,end)=1;
-				 pos=find(structmd.pressureload(:,end)==119); md.diagnostic.icefront(pos,end)=2;
-			 end
-			 if isfield(structmd,'elements_type') & structmd.elements_type(end,end)>50,
-				 pos=find(structmd.elements_type==59); md.flowequation.element_equation(pos,end)=0;
-				 pos=find(structmd.elements_type==55); md.flowequation.element_equation(pos,end)=1;
-				 pos=find(structmd.elements_type==56); md.flowequation.element_equation(pos,end)=2;
-				 pos=find(structmd.elements_type==60); md.flowequation.element_equation(pos,end)=3;
-				 pos=find(structmd.elements_type==62); md.flowequation.element_equation(pos,end)=4;
-				 pos=find(structmd.elements_type==57); md.flowequation.element_equation(pos,end)=5;
-				 pos=find(structmd.elements_type==58); md.flowequation.element_equation(pos,end)=6;
-				 pos=find(structmd.elements_type==61); md.flowequation.element_equation(pos,end)=7;
-			 end
-			 if isfield(structmd,'vertices_type') & structmd.vertices_type(end,end)>50,
-				 pos=find(structmd.vertices_type==59); md.flowequation.vertex_equation(pos,end)=0;
-				 pos=find(structmd.vertices_type==55); md.flowequation.vertex_equation(pos,end)=1;
-				 pos=find(structmd.vertices_type==56); md.flowequation.vertex_equation(pos,end)=2;
-				 pos=find(structmd.vertices_type==60); md.flowequation.vertex_equation(pos,end)=3;
-				 pos=find(structmd.vertices_type==62); md.flowequation.vertex_equation(pos,end)=4;
-				 pos=find(structmd.vertices_type==57); md.flowequation.vertex_equation(pos,end)=5;
-				 pos=find(structmd.vertices_type==58); md.flowequation.vertex_equation(pos,end)=6;
-				 pos=find(structmd.vertices_type==61); md.flowequation.vertex_equation(pos,end)=7;
-			 end
-			 if isfield(structmd,'rheology_law') & isnumeric(structmd.rheology_law),
-				 if (structmd.rheology_law==272), md.materials.rheology_law='None';      end
-				 if (structmd.rheology_law==368), md.materials.rheology_law='Paterson';  end
-				 if (structmd.rheology_law==369), md.materials.rheology_law='Arrhenius'; end
-			 end
-			 if isfield(structmd,'groundingline_migration') & isnumeric(structmd.groundingline_migration),
-				 if (structmd.groundingline_migration==272), md.groundingline.migration='None';      end
-				 if (structmd.groundingline_migration==273), md.groundingline.migration='AgressiveMigration';  end
-				 if (structmd.groundingline_migration==274), md.groundingline.migration='SoftMigration'; end
-			 end
-			 if isfield(structmd,'control_type') & isnumeric(structmd.control_type),
-				 if (structmd.control_type==143), md.inversion.control_parameters={'FrictionCoefficient'}; end
-				 if (structmd.control_type==190), md.inversion.control_parameters={'RheologyBbar'}; end
-				 if (structmd.control_type==147), md.inversion.control_parameters={'Thickeningrate'}; end
-			 end
-			 if isfield(structmd,'cm_responses') & ismember(structmd.cm_responses(end,end),[165:170 383 388 389]),
-				 pos=find(structmd.cm_responses==166); md.inversion.cost_functions(pos)=101;
-				 pos=find(structmd.cm_responses==167); md.inversion.cost_functions(pos)=102;
-				 pos=find(structmd.cm_responses==168); md.inversion.cost_functions(pos)=103;
-				 pos=find(structmd.cm_responses==169); md.inversion.cost_functions(pos)=104;
-				 pos=find(structmd.cm_responses==170); md.inversion.cost_functions(pos)=105;
-				 pos=find(structmd.cm_responses==165); md.inversion.cost_functions(pos)=201;
-				 pos=find(structmd.cm_responses==389); md.inversion.cost_functions(pos)=501;
-				 pos=find(structmd.cm_responses==388); md.inversion.cost_functions(pos)=502;
-				 pos=find(structmd.cm_responses==382); md.inversion.cost_functions(pos)=503;
-			 end
+			%Field name change
+			if isfield(structmd,'drag'), md.friction.coefficient=structmd.drag; end
+			if isfield(structmd,'p'), md.friction.p=structmd.p; end
+			if isfield(structmd,'q'), md.friction.q=structmd.p; end
+			if isfield(structmd,'melting'), md.basalforcings.melting_rate=structmd.melting; end
+			if isfield(structmd,'melting_rate'), md.basalforcings.melting_rate=structmd.melting_rate; end
+			if isfield(structmd,'accumulation'), md.surfaceforcings.mass_balance=structmd.accumulation; end
+			if isfield(structmd,'numberofgrids'), md.mesh.numberofvertices=structmd.numberofgrids; end
+			if isfield(structmd,'numberofgrids2d'), md.mesh.numberofvertices2d=structmd.numberofgrids2d; end
+			if isfield(structmd,'uppergrids'), md.mesh.uppervertex=structmd.uppergrids; end
+			if isfield(structmd,'lowergrids'), md.mesh.lowervertex=structmd.lowergrids; end
+			if isfield(structmd,'gridonbed'), md.mesh.vertexonbed=structmd.gridonbed; end
+			if isfield(structmd,'gridonsurface'), md.mesh.vertexonsurface=structmd.gridonsurface; end
+			if isfield(structmd,'extractedgrids'), md.mesh.extractedvertices=structmd.extractedgrids; end
+			if isfield(structmd,'gridoniceshelf'), md.mask.vertexonfloatingice=structmd.gridoniceshelf; end
+			if isfield(structmd,'gridonicesheet'), md.mask.vertexongroundedice=structmd.gridonicesheet; end
+			if isfield(structmd,'gridonwater'), md.mask.vertexonwater=structmd.gridonwater; end
+			if isfield(structmd,'gridonboundary'), md.mesh.vertexonboundary=structmd.gridonboundary; end
+			if isfield(structmd,'petscoptions') & ~isempty(structmd.petscoptions), md.solver=structmd.petscoptions; end
+			if isfield(structmd,'g'), md.constants.g=structmd.g; end
+			if isfield(structmd,'yts'), md.constants.yts=structmd.yts; end
+			if isfield(structmd,'surface_mass_balance'), md.surfaceforcings.mass_balance=structmd.surface_mass_balance; end
+			if isfield(structmd,'basal_melting_rate'), md.basalforcings.melting_rate=structmd.basal_melting_rate; end
+			if isfield(structmd,'basal_melting_rate_correction'), md.basalforcings.melting_rate_correction=structmd.basal_melting_rate_correction; end
+			if isfield(structmd,'geothermalflux'), md.basalforcings.geothermalflux=structmd.geothermalflux; end
+			if isfield(structmd,'drag'), md.friction.coefficient=structmd.drag; end
+			if isfield(structmd,'drag_coefficient'), md.friction.coefficient=structmd.drag_coefficient; end
+			if isfield(structmd,'drag_p'), md.friction.p=structmd.drag_p; end
+			if isfield(structmd,'drag_q'), md.friction.q=structmd.drag_q; end
+			if isfield(structmd,'riftproperties'), %old implementation
+				md.rifts=rifts();
+				md.rifts.riftproperties=structmd.riftproperties; 
+				md.rifts.riftstruct=structmd.rifts;
+				md.rifts.riftproperties=structmd.riftinfo;
+			end
+			if isfield(structmd,'bamg'), md.private.bamg=structmd.bamg; end
+			if isfield(structmd,'lowmem'), md.settings.lowmem=structmd.lowmem; end
+			if isfield(structmd,'io_gather'), md.settings.io_gather=structmd.io_gather; end
+			if isfield(structmd,'spcwatercolumn'), md.hydrology.spcwatercolumn=structmd.spcwatercolumn; end
+			if isfield(structmd,'hydro_n'), md.hydrology.n=structmd.hydro_n; end
+			if isfield(structmd,'hydro_p'), md.hydrology.p=structmd.hydro_p; end
+			if isfield(structmd,'hydro_q'), md.hydrology.q=structmd.hydro_q; end
+			if isfield(structmd,'hydro_CR'), md.hydrology.CR=structmd.hydro_CR; end
+			if isfield(structmd,'hydro_kn'), md.hydrology.kn=structmd.hydro_kn; end
+			if isfield(structmd,'spctemperature'), md.thermal.spctemperature=structmd.spctemperature; end
+			if isfield(structmd,'min_thermal_constraints'), md.thermal.penalty_threshold=structmd.min_thermal_constraints; end
+			if isfield(structmd,'artificial_diffusivity'), md.thermal.stabilization=structmd.artificial_diffusivity; end
+			if isfield(structmd,'max_nonlinear_iterations'), md.thermal.maxiter=structmd.max_nonlinear_iterations; end
+			if isfield(structmd,'stabilize_constraints'), md.thermal.penalty_lock=structmd.stabilize_constraints; end
+			if isfield(structmd,'penalty_offset'), md.thermal.penalty_factor=structmd.penalty_offset; end
+			if isfield(structmd,'name'), md.miscellaneous.name=structmd.name; end
+			if isfield(structmd,'notes'), md.miscellaneous.notes=structmd.notes; end
+			if isfield(structmd,'dummy'), md.miscellaneous.dummy=structmd.dummy; end
+			if isfield(structmd,'dt'), md.timestepping.time_step=structmd.dt; end
+			if isfield(structmd,'ndt'), md.timestepping.final_time=structmd.ndt; end
+			if isfield(structmd,'time_adapt'), md.timestepping.time_adapt=structmd.time_adapt; end
+			if isfield(structmd,'cfl_coefficient'), md.timestepping.cfl_coefficient=structmd.cfl_coefficient; end
+			if isfield(structmd,'spcthickness'), md.prognostic.spcthickness=structmd.spcthickness; end
+			if isfield(structmd,'artificial_diffusivity'), md.prognostic.stabilization=structmd.artificial_diffusivity; end
+			if isfield(structmd,'hydrostatic_adjustment'), md.prognostic.hydrostatic_adjustment=structmd.hydrostatic_adjustment; end
+			if isfield(structmd,'penalties'), md.prognostic.vertex_pairing=structmd.penalties; end
+			if isfield(structmd,'penalty_offset'), md.prognostic.penalty_factor=structmd.penalty_offset; end
+			if isfield(structmd,'B'), md.materials.rheology_B=structmd.B; end
+			if isfield(structmd,'n'), md.materials.rheology_n=structmd.n; end
+			if isfield(structmd,'rheology_B'), md.materials.rheology_B=structmd.rheology_B; end
+			if isfield(structmd,'rheology_n'), md.materials.rheology_n=structmd.rheology_n; end
+			if isfield(structmd,'elementoniceshelf'), md.mask.elementonfloatingice=structmd.elementoniceshelf; end
+			if isfield(structmd,'elementonicesheet'), md.mask.elementongroundedice=structmd.elementonicesheet; end
+			if isfield(structmd,'elementonwater'), md.mask.elementonwater=structmd.elementonwater; end
+			if isfield(structmd,'nodeoniceshelf'), md.mask.vertexonfloatingice=structmd.nodeoniceshelf; end
+			if isfield(structmd,'nodeonicesheet'), md.mask.vertexongroundedice=structmd.nodeonicesheet; end
+			if isfield(structmd,'nodeonwater'), md.mask.vertexonwater=structmd.nodeonwater; end
+			if isfield(structmd,'spcthickness'), md.balancethickness.spcthickness=structmd.spcthickness; end
+			if isfield(structmd,'artificial_diffusivity'), md.balancethickness.stabilization=structmd.artificial_diffusivity; end
+			if isfield(structmd,'dhdt'), md.balancethickness.thickening_rate=structmd.dhdt; end
+			if isfield(structmd,'ismacayealpattyn'), md.flowequation.ismacayealpattyn=structmd.ismacayealpattyn; end
+			if isfield(structmd,'ishutter'), md.flowequation.ishutter=structmd.ishutter; end
+			if isfield(structmd,'isstokes'), md.flowequation.isstokes=structmd.isstokes; end
+			if isfield(structmd,'elements_type'), md.flowequation.element_equation=structmd.elements_type; end
+			if isfield(structmd,'vertices_type'), md.flowequation.vertex_equation=structmd.vertices_type; end
+			if isfield(structmd,'eps_rel'), md.steadystate.reltol=structmd.eps_rel; end
+			if isfield(structmd,'max_steadystate_iterations'), md.steadystate.maxiter=structmd.max_steadystate_iterations; end
+			if isfield(structmd,'isdiagnostic'), md.transient.isdiagnostic=structmd.isdiagnostic; end
+			if isfield(structmd,'isprognostic'), md.transient.isprognostic=structmd.isprognostic; end
+			if isfield(structmd,'isthermal'), md.transient.isthermal=structmd.isthermal; end
+			if isfield(structmd,'control_analysis'), md.inversion.iscontrol=structmd.control_analysis; end
+			if isfield(structmd,'weights'), md.inversion.cost_functions_coefficients=structmd.weights; end
+			if isfield(structmd,'nsteps'), md.inversion.nsteps=structmd.nsteps; end
+			if isfield(structmd,'maxiter_per_step'), md.inversion.maxiter_per_step=structmd.maxiter_per_step; end
+			if isfield(structmd,'cm_min'), md.inversion.min_parameters=structmd.cm_min; end
+			if isfield(structmd,'cm_max'), md.inversion.max_parameters=structmd.cm_max; end
+			if isfield(structmd,'vx_obs'), md.inversion.vx_obs=structmd.vx_obs; end
+			if isfield(structmd,'vy_obs'), md.inversion.vy_obs=structmd.vy_obs; end
+			if isfield(structmd,'vel_obs'), md.inversion.vel_obs=structmd.vel_obs; end
+			if isfield(structmd,'thickness_obs'), md.inversion.thickness_obs=structmd.thickness_obs; end
+			if isfield(structmd,'vx'), md.initialization.vx=structmd.vx; end
+			if isfield(structmd,'vy'), md.initialization.vy=structmd.vy; end
+			if isfield(structmd,'vz'), md.initialization.vz=structmd.vz; end
+			if isfield(structmd,'vel'), md.initialization.vel=structmd.vel; end
+			if isfield(structmd,'pressure'), md.initialization.pressure=structmd.pressure; end
+			if isfield(structmd,'temperature'), md.initialization.temperature=structmd.temperature; end
+			if isfield(structmd,'waterfraction'), md.initialization.waterfraction=structmd.waterfraction; end
+			if isfield(structmd,'watercolumn'), md.initialization.watercolumn=structmd.watercolumn; end
+			if isfield(structmd,'surface'), md.geometry.surface=structmd.surface; end
+			if isfield(structmd,'bed'), md.geometry.bed=structmd.bed; end
+			if isfield(structmd,'thickness'), md.geometry.thickness=structmd.thickness; end
+			if isfield(structmd,'bathymetry'), md.geometry.bathymetry=structmd.bathymetry; end
+			if isfield(structmd,'thickness_coeff'), md.geometry.hydrostatic_ratio=structmd.thickness_coeff; end
+			if isfield(structmd,'connectivity'), md.mesh.average_vertex_connectivity=structmd.connectivity; end
+			if isfield(structmd,'extractednodes'), md.mesh.extractedvertices=structmd.extractednodes; end
+			if isfield(structmd,'extractedelements'), md.mesh.extractedelements=structmd.extractedelements; end
+			if isfield(structmd,'nodeonboundary'), md.mesh.vertexonboundary=structmd.nodeonboundary; end
+			if isfield(structmd,'hemisphere'), md.mesh.hemisphere=structmd.hemisphere; end
+			if isfield(structmd,'lat'), md.mesh.lat=structmd.lat; end
+			if isfield(structmd,'long'), md.mesh.long=structmd.long; end
+			if isfield(structmd,'segments'), md.mesh.segments=structmd.segments; end
+			if isfield(structmd,'segmentmarkers'), md.mesh.segmentmarkers=structmd.segmentmarkers; end
+			if isfield(structmd,'dim'), md.mesh.dimension=structmd.dim; end
+			if isfield(structmd,'numlayers'), md.mesh.numberoflayers=structmd.numlayers; end
+			if isfield(structmd,'numberofelements'), md.mesh.numberofelements=structmd.numberofelements; end
+			if isfield(structmd,'numberofvertices'), md.mesh.numberofvertices=structmd.numberofvertices; end
+			if isfield(structmd,'numberofnodes'), md.mesh.numberofvertices=structmd.numberofnodes; end
+			if isfield(structmd,'numberofedges'), md.mesh.numberofedges=structmd.numberofedges; end
+			if isfield(structmd,'numberofelements2d'), md.mesh.numberofelements2d=structmd.numberofelements2d; end
+			if isfield(structmd,'numberofnodes2d'), md.mesh.numberofvertices2d=structmd.numberofnodes2d; end
+			if isfield(structmd,'nodeconnectivity'), md.mesh.vertexconnectivity=structmd.nodeconnectivity; end
+			if isfield(structmd,'elementconnectivity'), md.mesh.elementconnectivity=structmd.elementconnectivity; end
+			if isfield(structmd,'uppernodes'), md.mesh.uppervertex=structmd.uppernodes; end
+			if isfield(structmd,'lowernodes'), md.mesh.lowervertex=structmd.lowernodes; end
+			if isfield(structmd,'upperelements'), md.mesh.upperelements=structmd.upperelements; end
+			if isfield(structmd,'lowerelements'), md.mesh.lowerelements=structmd.lowerelements; end
+			if isfield(structmd,'elementonbed'), md.mesh.elementonbed=structmd.elementonbed; end
+			if isfield(structmd,'elementonsurface'), md.mesh.elementonsurface=structmd.elementonsurface; end
+			if isfield(structmd,'nodeonsurface'), md.mesh.vertexonsurface=structmd.nodeonsurface; end
+			if isfield(structmd,'nodeonbed'), md.mesh.vertexonbed=structmd.nodeonbed; end
+			if isfield(structmd,'elements2d'), md.mesh.elements2d=structmd.elements2d; end
+			if isfield(structmd,'y2d'), md.mesh.y2d=structmd.y2d; end
+			if isfield(structmd,'x2d'), md.mesh.x2d=structmd.x2d; end
+			if isfield(structmd,'elements'), md.mesh.elements=structmd.elements; end
+			if isfield(structmd,'edges'), 
+				md.mesh.edges=structmd.edges; 
+				md.mesh.edges(isnan(md.mesh.edges))=-1;
+			end
+			if isfield(structmd,'y'), md.mesh.y=structmd.y; end
+			if isfield(structmd,'x'), md.mesh.x=structmd.x; end
+			if isfield(structmd,'z'), md.mesh.z=structmd.z; end
+			if isfield(structmd,'mask'), md.flaim.criterion=structmd.mask; end
+			if isfield(structmd,'pressureload'), md.diagnostic.icefront=structmd.pressureload; end
+			if isfield(structmd,'diagnostic_ref'), md.diagnostic.referential=structmd.diagnostic_ref; end
+			if isfield(structmd,'npart'); md.qmu.numberofpartitions=structmd.npart; end
+			if isfield(structmd,'part'); md.qmu.partition=structmd.part; end
 
-			 if isfield(structmd,'artificial_diffusivity') & structmd.artificial_diffusivity==2,
-					 md.thermal.stabilization=2;
-					 md.prognostic.stabilization=1;
-					 md.balancethickness.stabilization=1;
-			 end
-			 if isnumeric(md.prognostic.hydrostatic_adjustment)
-				 if md.prognostic.hydrostatic_adjustment==269,
-					 md.prognostic.hydrostatic_adjustment='Incremental';
-				 else
-					 md.prognostic.hydrostatic_adjustment='Absolute';
-				 end
-			 end
+			%Field changes
+			if (isfield(structmd,'type') & ischar(structmd.type)), 
+				if strcmpi(structmd.type,'2d'), md.mesh.dimension=2; end
+				if strcmpi(structmd.type,'3d'), md.mesh.dimension=3; end
+			end
+			if isnumeric(md.verbose),
+				md.verbose=verbose;
+			end
+			if size(md.diagnostic.icefront,2)==3 || size(md.diagnostic.icefront,2)==5,
+				front=md.diagnostic.icefront;
+				md.diagnostic.icefront=[front 1*md.mask.elementonfloatingice(front(:,end))];
+			end
+			if isfield(structmd,'spcvelocity'), 
+				md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1);
+				md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1);
+				md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
+				pos=find(structmd.spcvelocity(:,1)); md.diagnostic.spcvx(pos)=structmd.spcvelocity(pos,4); 
+				pos=find(structmd.spcvelocity(:,2)); md.diagnostic.spcvy(pos)=structmd.spcvelocity(pos,5); 
+				pos=find(structmd.spcvelocity(:,3)); md.diagnostic.spcvz(pos)=structmd.spcvelocity(pos,6); 
+			end
+			if isfield(structmd,'spcvx'), 
+				md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1);
+				pos=find(~isnan(structmd.spcvx)); md.diagnostic.spcvx(pos)=structmd.spcvx(pos); 
+			end
+			if isfield(structmd,'spcvy'),
+				md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices,1);
+				pos=find(~isnan(structmd.spcvy)); md.diagnostic.spcvy(pos)=structmd.spcvy(pos);     
+			end
+			if isfield(structmd,'spcvz'),
+				md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices,1);
+				pos=find(~isnan(structmd.spcvz)); md.diagnostic.spcvz(pos)=structmd.spcvz(pos);     
+			end
+			if ~isempty(structmd.pressureload) & ismember(structmd.pressureload(end,end),[118 119 120]),
+				pos=find(structmd.pressureload(:,end)==120); md.diagnostic.icefront(pos,end)=0;
+				pos=find(structmd.pressureload(:,end)==118); md.diagnostic.icefront(pos,end)=1;
+				pos=find(structmd.pressureload(:,end)==119); md.diagnostic.icefront(pos,end)=2;
+			end
+			if isfield(structmd,'elements_type') & structmd.elements_type(end,end)>50,
+				pos=find(structmd.elements_type==59); md.flowequation.element_equation(pos,end)=0;
+				pos=find(structmd.elements_type==55); md.flowequation.element_equation(pos,end)=1;
+				pos=find(structmd.elements_type==56); md.flowequation.element_equation(pos,end)=2;
+				pos=find(structmd.elements_type==60); md.flowequation.element_equation(pos,end)=3;
+				pos=find(structmd.elements_type==62); md.flowequation.element_equation(pos,end)=4;
+				pos=find(structmd.elements_type==57); md.flowequation.element_equation(pos,end)=5;
+				pos=find(structmd.elements_type==58); md.flowequation.element_equation(pos,end)=6;
+				pos=find(structmd.elements_type==61); md.flowequation.element_equation(pos,end)=7;
+			end
+			if isfield(structmd,'vertices_type') & structmd.vertices_type(end,end)>50,
+				pos=find(structmd.vertices_type==59); md.flowequation.vertex_equation(pos,end)=0;
+				pos=find(structmd.vertices_type==55); md.flowequation.vertex_equation(pos,end)=1;
+				pos=find(structmd.vertices_type==56); md.flowequation.vertex_equation(pos,end)=2;
+				pos=find(structmd.vertices_type==60); md.flowequation.vertex_equation(pos,end)=3;
+				pos=find(structmd.vertices_type==62); md.flowequation.vertex_equation(pos,end)=4;
+				pos=find(structmd.vertices_type==57); md.flowequation.vertex_equation(pos,end)=5;
+				pos=find(structmd.vertices_type==58); md.flowequation.vertex_equation(pos,end)=6;
+				pos=find(structmd.vertices_type==61); md.flowequation.vertex_equation(pos,end)=7;
+			end
+			if isfield(structmd,'rheology_law') & isnumeric(structmd.rheology_law),
+				if (structmd.rheology_law==272), md.materials.rheology_law='None';      end
+				if (structmd.rheology_law==368), md.materials.rheology_law='Paterson';  end
+				if (structmd.rheology_law==369), md.materials.rheology_law='Arrhenius'; end
+			end
+			if isfield(structmd,'groundingline_migration') & isnumeric(structmd.groundingline_migration),
+				if (structmd.groundingline_migration==272), md.groundingline.migration='None';      end
+				if (structmd.groundingline_migration==273), md.groundingline.migration='AgressiveMigration';  end
+				if (structmd.groundingline_migration==274), md.groundingline.migration='SoftMigration'; end
+			end
+			if isfield(structmd,'control_type') & isnumeric(structmd.control_type),
+				if (structmd.control_type==143), md.inversion.control_parameters={'FrictionCoefficient'}; end
+				if (structmd.control_type==190), md.inversion.control_parameters={'RheologyBbar'}; end
+				if (structmd.control_type==147), md.inversion.control_parameters={'Thickeningrate'}; end
+			end
+			if isfield(structmd,'cm_responses') & ismember(structmd.cm_responses(end,end),[165:170 383 388 389]),
+				pos=find(structmd.cm_responses==166); md.inversion.cost_functions(pos)=101;
+				pos=find(structmd.cm_responses==167); md.inversion.cost_functions(pos)=102;
+				pos=find(structmd.cm_responses==168); md.inversion.cost_functions(pos)=103;
+				pos=find(structmd.cm_responses==169); md.inversion.cost_functions(pos)=104;
+				pos=find(structmd.cm_responses==170); md.inversion.cost_functions(pos)=105;
+				pos=find(structmd.cm_responses==165); md.inversion.cost_functions(pos)=201;
+				pos=find(structmd.cm_responses==389); md.inversion.cost_functions(pos)=501;
+				pos=find(structmd.cm_responses==388); md.inversion.cost_functions(pos)=502;
+				pos=find(structmd.cm_responses==382); md.inversion.cost_functions(pos)=503;
+			end
 
-			 %New fields
-			 if ~isfield(structmd,'upperelements');
-				 md.mesh.upperelements=transpose(1:md.mesh.numberofelements)+md.mesh.numberofelements2d;
-				 md.mesh.upperelements(end-md.mesh.numberofelements2d+1:end)=NaN;
-			 end
-			 if ~isfield(structmd,'lowerelements');
-				 md.mesh.lowerelements=transpose(1:md.mesh.numberofelements)-md.mesh.numberofelements2d;
-				 md.mesh.lowerelements(1:md.mesh.numberofelements2d)=NaN;
-			 end
-				 
-			 if ~isfield(structmd,'diagnostic_ref');
-				 md.diagnostic.referential=NaN*ones(md.mesh.numberofvertices,6);
-			 end
+			if isfield(structmd,'artificial_diffusivity') & structmd.artificial_diffusivity==2,
+					md.thermal.stabilization=2;
+					md.prognostic.stabilization=1;
+					md.balancethickness.stabilization=1;
+			end
+			if isnumeric(md.prognostic.hydrostatic_adjustment)
+				if md.prognostic.hydrostatic_adjustment==269,
+					md.prognostic.hydrostatic_adjustment='Incremental';
+				else
+					md.prognostic.hydrostatic_adjustment='Absolute';
+				end
+			end
 
-		 end% }}}
-		 function md = setdefaultparameters(md) % {{{
+			%New fields
+			if ~isfield(structmd,'upperelements');
+				md.mesh.upperelements=transpose(1:md.mesh.numberofelements)+md.mesh.numberofelements2d;
+				md.mesh.upperelements(end-md.mesh.numberofelements2d+1:end)=NaN;
+			end
+			if ~isfield(structmd,'lowerelements');
+				md.mesh.lowerelements=transpose(1:md.mesh.numberofelements)-md.mesh.numberofelements2d;
+				md.mesh.lowerelements(1:md.mesh.numberofelements2d)=NaN;
+			end
 
-			 %initialize subclasses
-			 md.mesh             = mesh();
-			 md.mask             = mask();
-			 md.constants        = constants();
-			 md.geometry         = geometry();
-			 md.initialization   = initialization();
-			 md.surfaceforcings  = surfaceforcings();
-			 md.basalforcings    = basalforcings();
-			 md.friction         = friction();
-			 md.rifts            = rifts();
-			 md.timestepping     = timestepping();
-			 md.groundingline    = groundingline();
-			 md.materials        = matice();
-			 md.flowequation     = flowequation();
-			 md.debug            = debug();
-			 md.verbose          = verbose('solution',true,'qmu',true,'control',true);
-			 md.settings         = settings();
-			 md.solver           = solver();
-			 if ismumps(),
-				 md.solver           = addoptions(md.solver,DiagnosticVertAnalysisEnum(),mumpsoptions());
-			 else
-				 md.solver           = addoptions(md.solver,DiagnosticVertAnalysisEnum(),iluasmoptions());
-			 end
-			 md.cluster          = generic();
-			 md.balancethickness = balancethickness();
-			 md.diagnostic       = diagnostic();
-			 md.hydrology        = hydrology();
-			 md.prognostic       = prognostic();
-			 md.thermal          = thermal();
-			 md.steadystate      = steadystate();
-			 md.transient        = transient();
-			 md.autodiff         = autodiff();
-			 md.flaim            = flaim();
-			 md.inversion        = inversion();
-			 md.qmu              = qmu();
-			 md.radaroverlay     = radaroverlay();
-			 md.results          = struct();
-			 md.miscellaneous    = miscellaneous();
-			 md.private          = private();
-		 end
-		 %}}}
-		 function disp(obj) % {{{
-			 disp(sprintf('%19s: %-22s -- %s','mesh'            ,['[1x1 ' class(obj.mesh) ']'],'mesh properties'));
-			 disp(sprintf('%19s: %-22s -- %s','mask'            ,['[1x1 ' class(obj.mask) ']'],'defines grounded and floating elements'));
-			 disp(sprintf('%19s: %-22s -- %s','geometry'        ,['[1x1 ' class(obj.geometry) ']'],'surface elevation, bedrock topography, ice thickness,...'));
-			 disp(sprintf('%19s: %-22s -- %s','constants'       ,['[1x1 ' class(obj.constants) ']'],'physical constants'));
-			 disp(sprintf('%19s: %-22s -- %s','surfaceforcings' ,['[1x1 ' class(obj.surfaceforcings) ']'],'surface forcings'));
-			 disp(sprintf('%19s: %-22s -- %s','basalforcings'   ,['[1x1 ' class(obj.basalforcings) ']'],'bed forcings'));
-			 disp(sprintf('%19s: %-22s -- %s','materials'       ,['[1x1 ' class(obj.materials) ']'],'material properties'));
-			 disp(sprintf('%19s: %-22s -- %s','friction'        ,['[1x1 ' class(obj.friction) ']'],'basal friction/drag properties'));
-			 disp(sprintf('%19s: %-22s -- %s','flowequation'    ,['[1x1 ' class(obj.flowequation) ']'],'flow equations'));
-			 disp(sprintf('%19s: %-22s -- %s','timestepping'    ,['[1x1 ' class(obj.timestepping) ']'],'time stepping for transient models'));
-			 disp(sprintf('%19s: %-22s -- %s','initialization'  ,['[1x1 ' class(obj.initialization) ']'],'initial guess/state'));
-			 disp(sprintf('%19s: %-22s -- %s','rifts'           ,['[1x1 ' class(obj.rifts) ']'],'rifts properties'));
-			 disp(sprintf('%19s: %-22s -- %s','debug'           ,['[1x1 ' class(obj.debug) ']'],'debugging tools (valgrind, gprof)'));
-			 disp(sprintf('%19s: %-22s -- %s','verbose'         ,['[1x1 ' class(obj.verbose) ']'],'verbosity level in solve'));
-			 disp(sprintf('%19s: %-22s -- %s','settings'        ,['[1x1 ' class(obj.settings) ']'],'settings properties'));
-			 disp(sprintf('%19s: %-22s -- %s','solver'          ,['[1x1 ' class(obj.solver) ']'],'PETSc options for each solution'));
-			 disp(sprintf('%19s: %-22s -- %s','cluster'         ,['[1x1 ' class(obj.cluster) ']'],'cluster parameters (number of cpus...)'));
-			 disp(sprintf('%19s: %-22s -- %s','balancethickness',['[1x1 ' class(obj.balancethickness) ']'],'parameters for balancethickness solution'));
-			 disp(sprintf('%19s: %-22s -- %s','diagnostic'      ,['[1x1 ' class(obj.diagnostic) ']'],'parameters for diagnostic solution'));
-			 disp(sprintf('%19s: %-22s -- %s','groundingline'   ,['[1x1 ' class(obj.groundingline) ']'],'parameters for groundingline solution'));
-			 disp(sprintf('%19s: %-22s -- %s','hydrology'       ,['[1x1 ' class(obj.hydrology) ']'],'parameters for hydrology solution'));
-			 disp(sprintf('%19s: %-22s -- %s','prognostic'      ,['[1x1 ' class(obj.prognostic) ']'],'parameters for prognostic solution'));
-			 disp(sprintf('%19s: %-22s -- %s','thermal'         ,['[1x1 ' class(obj.thermal) ']'],'parameters for thermal solution'));
-			 disp(sprintf('%19s: %-22s -- %s','steadystate'     ,['[1x1 ' class(obj.steadystate) ']'],'parameters for steadystate solution'));
-			 disp(sprintf('%19s: %-22s -- %s','transient'       ,['[1x1 ' class(obj.transient) ']'],'parameters for transient solution'));
-			 disp(sprintf('%19s: %-22s -- %s','autodiff'        ,['[1x1 ' class(obj.autodiff) ']'],'automatic differentiation parameters'));
-			 disp(sprintf('%19s: %-22s -- %s','flaim'           ,['[1x1 ' class(obj.flaim) ']'],'flaim parameters'));
-			 disp(sprintf('%19s: %-22s -- %s','inversion'       ,['[1x1 ' class(obj.inversion) ']'],'parameters for inverse methods'));
-			 disp(sprintf('%19s: %-22s -- %s','qmu'             ,['[1x1 ' class(obj.qmu) ']'],'dakota properties'));
-			 disp(sprintf('%19s: %-22s -- %s','results'         ,['[1x1 ' class(obj.results) ']'],'model results'));
-			 disp(sprintf('%19s: %-22s -- %s','radaroverlay'    ,['[1x1 ' class(obj.radaroverlay) ']'],'radar image for plot overlay'));
-			 disp(sprintf('%19s: %-22s -- %s','miscellaneous'   ,['[1x1 ' class(obj.miscellaneous) ']'],'miscellaneous fields'));
-		 end % }}}
-	 end
+			if ~isfield(structmd,'diagnostic_ref');
+				md.diagnostic.referential=NaN*ones(md.mesh.numberofvertices,6);
+			end
+
+		end% }}}
+		function md = setdefaultparameters(md) % {{{
+
+			%initialize subclasses
+			md.mesh             = mesh();
+			md.mask             = mask();
+			md.constants        = constants();
+			md.geometry         = geometry();
+			md.initialization   = initialization();
+			md.surfaceforcings  = surfaceforcings();
+			md.basalforcings    = basalforcings();
+			md.friction         = friction();
+			md.rifts            = rifts();
+			md.timestepping     = timestepping();
+			md.groundingline    = groundingline();
+			md.materials        = matice();
+			md.flowequation     = flowequation();
+			md.debug            = debug();
+			md.verbose          = verbose('solution',true,'qmu',true,'control',true);
+			md.settings         = settings();
+			md.solver           = solver();
+			if ismumps(),
+				md.solver           = addoptions(md.solver,DiagnosticVertAnalysisEnum(),mumpsoptions());
+			else
+				md.solver           = addoptions(md.solver,DiagnosticVertAnalysisEnum(),iluasmoptions());
+			end
+			md.cluster          = generic();
+			md.balancethickness = balancethickness();
+			md.diagnostic       = diagnostic();
+			md.hydrology        = hydrology();
+			md.prognostic       = prognostic();
+			md.thermal          = thermal();
+			md.steadystate      = steadystate();
+			md.transient        = transient();
+			md.autodiff         = autodiff();
+			md.flaim            = flaim();
+			md.inversion        = inversion();
+			md.qmu              = qmu();
+			md.radaroverlay     = radaroverlay();
+			md.results          = struct();
+			md.miscellaneous    = miscellaneous();
+			md.private          = private();
+		end
+		%}}}
+		function disp(obj) % {{{
+			disp(sprintf('%19s: %-22s -- %s','mesh'            ,['[1x1 ' class(obj.mesh) ']'],'mesh properties'));
+			disp(sprintf('%19s: %-22s -- %s','mask'            ,['[1x1 ' class(obj.mask) ']'],'defines grounded and floating elements'));
+			disp(sprintf('%19s: %-22s -- %s','geometry'        ,['[1x1 ' class(obj.geometry) ']'],'surface elevation, bedrock topography, ice thickness,...'));
+			disp(sprintf('%19s: %-22s -- %s','constants'       ,['[1x1 ' class(obj.constants) ']'],'physical constants'));
+			disp(sprintf('%19s: %-22s -- %s','surfaceforcings' ,['[1x1 ' class(obj.surfaceforcings) ']'],'surface forcings'));
+			disp(sprintf('%19s: %-22s -- %s','basalforcings'   ,['[1x1 ' class(obj.basalforcings) ']'],'bed forcings'));
+			disp(sprintf('%19s: %-22s -- %s','materials'       ,['[1x1 ' class(obj.materials) ']'],'material properties'));
+			disp(sprintf('%19s: %-22s -- %s','friction'        ,['[1x1 ' class(obj.friction) ']'],'basal friction/drag properties'));
+			disp(sprintf('%19s: %-22s -- %s','flowequation'    ,['[1x1 ' class(obj.flowequation) ']'],'flow equations'));
+			disp(sprintf('%19s: %-22s -- %s','timestepping'    ,['[1x1 ' class(obj.timestepping) ']'],'time stepping for transient models'));
+			disp(sprintf('%19s: %-22s -- %s','initialization'  ,['[1x1 ' class(obj.initialization) ']'],'initial guess/state'));
+			disp(sprintf('%19s: %-22s -- %s','rifts'           ,['[1x1 ' class(obj.rifts) ']'],'rifts properties'));
+			disp(sprintf('%19s: %-22s -- %s','debug'           ,['[1x1 ' class(obj.debug) ']'],'debugging tools (valgrind, gprof)'));
+			disp(sprintf('%19s: %-22s -- %s','verbose'         ,['[1x1 ' class(obj.verbose) ']'],'verbosity level in solve'));
+			disp(sprintf('%19s: %-22s -- %s','settings'        ,['[1x1 ' class(obj.settings) ']'],'settings properties'));
+			disp(sprintf('%19s: %-22s -- %s','solver'          ,['[1x1 ' class(obj.solver) ']'],'PETSc options for each solution'));
+			disp(sprintf('%19s: %-22s -- %s','cluster'         ,['[1x1 ' class(obj.cluster) ']'],'cluster parameters (number of cpus...)'));
+			disp(sprintf('%19s: %-22s -- %s','balancethickness',['[1x1 ' class(obj.balancethickness) ']'],'parameters for balancethickness solution'));
+			disp(sprintf('%19s: %-22s -- %s','diagnostic'      ,['[1x1 ' class(obj.diagnostic) ']'],'parameters for diagnostic solution'));
+			disp(sprintf('%19s: %-22s -- %s','groundingline'   ,['[1x1 ' class(obj.groundingline) ']'],'parameters for groundingline solution'));
+			disp(sprintf('%19s: %-22s -- %s','hydrology'       ,['[1x1 ' class(obj.hydrology) ']'],'parameters for hydrology solution'));
+			disp(sprintf('%19s: %-22s -- %s','prognostic'      ,['[1x1 ' class(obj.prognostic) ']'],'parameters for prognostic solution'));
+			disp(sprintf('%19s: %-22s -- %s','thermal'         ,['[1x1 ' class(obj.thermal) ']'],'parameters for thermal solution'));
+			disp(sprintf('%19s: %-22s -- %s','steadystate'     ,['[1x1 ' class(obj.steadystate) ']'],'parameters for steadystate solution'));
+			disp(sprintf('%19s: %-22s -- %s','transient'       ,['[1x1 ' class(obj.transient) ']'],'parameters for transient solution'));
+			disp(sprintf('%19s: %-22s -- %s','autodiff'        ,['[1x1 ' class(obj.autodiff) ']'],'automatic differentiation parameters'));
+			disp(sprintf('%19s: %-22s -- %s','flaim'           ,['[1x1 ' class(obj.flaim) ']'],'flaim parameters'));
+			disp(sprintf('%19s: %-22s -- %s','inversion'       ,['[1x1 ' class(obj.inversion) ']'],'parameters for inverse methods'));
+			disp(sprintf('%19s: %-22s -- %s','qmu'             ,['[1x1 ' class(obj.qmu) ']'],'dakota properties'));
+			disp(sprintf('%19s: %-22s -- %s','results'         ,['[1x1 ' class(obj.results) ']'],'model results'));
+			disp(sprintf('%19s: %-22s -- %s','radaroverlay'    ,['[1x1 ' class(obj.radaroverlay) ']'],'radar image for plot overlay'));
+			disp(sprintf('%19s: %-22s -- %s','miscellaneous'   ,['[1x1 ' class(obj.miscellaneous) ']'],'miscellaneous fields'));
+		end % }}}
+	end
  end

Modified: issm/trunk/src/m/classes/model/model.py
===================================================================
--- issm/trunk/src/m/classes/model/model.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/model/model.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,6 @@
 #module imports {{{
 import numpy
+import copy
 from mesh import mesh
 from mask import mask
 from geometry import geometry
@@ -29,15 +30,19 @@
 from flaim import flaim
 from inversion import inversion
 from qmu import qmu
+from results import results
 from radaroverlay import radaroverlay
 from miscellaneous import miscellaneous
 from private import private
-from collections import OrderedDict
 from EnumDefinitions import *
 from ismumps import *
 from mumpsoptions import *
 from iluasmoptions import *
 from project3d import *
+from FlagElements import *
+from NodeConnectivity import *
+from ElementConnectivity import *
+from contourenvelope import *
 #}}}
 
 class model(object):
@@ -81,7 +86,7 @@
 		self.inversion        = inversion()
 		self.qmu              = qmu()
 
-		self.results          = OrderedDict()
+		self.results          = results()
 		self.radaroverlay     = radaroverlay()
 		self.miscellaneous    = miscellaneous()
 		self.private          = private()
@@ -166,8 +171,283 @@
 	def checkmessage(self,string):    # {{{
 		print ("model not consistent: %s" % string)
 		self.private.isconsistent=False
+		return self
 	# }}}
 
+	def extract(md,area):    # {{{
+		"""
+		extract - extract a model according to an Argus contour or flag list
+
+		   This routine extracts a submodel from a bigger model with respect to a given contour
+		   md must be followed by the corresponding exp file or flags list
+		   It can either be a domain file (argus type, .exp extension), or an array of element flags. 
+		   If user wants every element outside the domain to be 
+		   extract2d, add '~' to the name of the domain file (ex: '~Pattyn.exp');
+		   an empty string '' will be considered as an empty domain
+		   a string 'all' will be considered as the entire domain
+
+		   Usage:
+		      md2=extract(md,area);
+
+		   Examples:
+		      md2=extract(md,'Domain.exp');
+		      md2=extract(md,md.mask.elementonfloatingice);
+
+		   See also: EXTRUDE, COLLAPSE
+		"""
+
+		#copy model
+		md1=copy.deepcopy(md)
+
+		#get elements that are inside area
+		flag_elem=FlagElements(md1,area)
+		if not numpy.any(flag_elem):
+			raise RuntimeError("extracted model is empty")
+
+		#kick out all elements with 3 dirichlets
+		spc_elem=numpy.nonzero(numpy.logical_not(flag_elem))[0]
+		spc_node=numpy.unique(md1.mesh.elements[spc_elem,:]).astype(int)-1
+		flag=numpy.ones(md1.mesh.numberofvertices)
+		flag[spc_node]=0
+		pos=numpy.nonzero(numpy.logical_not(numpy.sum(flag[md1.mesh.elements.astype(int)-1],axis=1)))[0]
+		flag_elem[pos]=0
+
+		#extracted elements and nodes lists
+		pos_elem=numpy.nonzero(flag_elem)[0]
+		pos_node=numpy.unique(md1.mesh.elements[pos_elem,:]).astype(int)-1
+
+		#keep track of some fields
+		numberofvertices1=md1.mesh.numberofvertices
+		numberofelements1=md1.mesh.numberofelements
+		numberofvertices2=numpy.size(pos_node)
+		numberofelements2=numpy.size(pos_elem)
+		flag_node=numpy.zeros(numberofvertices1)
+		flag_node[pos_node]=1
+
+		#Create Pelem and Pnode (transform old nodes in new nodes and same thing for the elements)
+		Pelem=numpy.zeros(numberofelements1)
+		Pelem[pos_elem]=numpy.arange(1,numberofelements2+1)
+		Pnode=numpy.zeros(numberofvertices1)
+		Pnode[pos_node]=numpy.arange(1,numberofvertices2+1)
+
+		#renumber the elements (some node won't exist anymore)
+		elements_1=copy.deepcopy(md1.mesh.elements)
+		elements_2=elements_1[pos_elem,:]
+		elements_2[:,0]=Pnode[elements_2[:,0].astype(int)-1]
+		elements_2[:,1]=Pnode[elements_2[:,1].astype(int)-1]
+		elements_2[:,2]=Pnode[elements_2[:,2].astype(int)-1]
+		if md1.mesh.dimension==3:
+			elements_2[:,3]=Pnode[elements_2[:,3].astype(int)-1]
+			elements_2[:,4]=Pnode[elements_2[:,4].astype(int)-1]
+			elements_2[:,5]=Pnode[elements_2[:,5].astype(int)-1]
+
+		#OK, now create the new model!
+
+		#take every field from model
+		md2=copy.deepcopy(md1)
+
+		#automatically modify fields
+
+		#loop over model fields
+		model_fields=vars(md1)
+		for fieldi in model_fields:
+			#get field
+			field=getattr(md1,fieldi)
+			fieldsize=numpy.shape(field)
+			if hasattr(field,'__dict__') and not ismember(fieldi,['results'])[0]:    #recursive call
+				object_fields=vars(field)
+				for fieldj in object_fields:
+					#get field
+					field=getattr(getattr(md1,fieldi),fieldj)
+					fieldsize=numpy.shape(field)
+					if len(fieldsize):
+						#size = number of nodes * n
+						if   fieldsize[0]==numberofvertices1:
+							setattr(getattr(md2,fieldi),fieldj,field[pos_node,:])
+						elif fieldsize[0]==numberofvertices1+1:
+							setattr(getattr(md2,fieldi),fieldj,numpy.vstack((field[pos_node,:],field[-1,:])))
+						#size = number of elements * n
+						elif fieldsize[0]==numberofelements1:
+							setattr(getattr(md2,fieldi),fieldj,field[pos_elem,:])
+			else:
+				if len(fieldsize):
+					#size = number of nodes * n
+					if   fieldsize[0]==numberofvertices1:
+						setattr(md2,fieldi,field[pos_node,:])
+					elif fieldsize[0]==numberofvertices1+1:
+						setattr(md2,fieldi,numpy.hstack((field[pos_node,:],field[-1,:])))
+					#size = number of elements * n
+					elif fieldsize[0]==numberofelements1:
+						setattr(md2,fieldi,field[pos_elem,:])
+
+		#modify some specific fields
+
+		#Mesh
+		md2.mesh.numberofelements=numberofelements2
+		md2.mesh.numberofvertices=numberofvertices2
+		md2.mesh.elements=elements_2
+
+		#mesh.uppervertex mesh.lowervertex
+		if md1.mesh.dimension==3:
+			md2.mesh.uppervertex=md1.mesh.uppervertex[pos_node]
+			pos=numpy.nonzero(numpy.logical_not(numpy.isnan(md2.mesh.uppervertex)))[0]
+			md2.mesh.uppervertex[pos]=Pnode[md2.mesh.uppervertex[pos].astype(int)-1]
+
+			md2.mesh.lowervertex=md1.mesh.lowervertex[pos_node]
+			pos=numpy.nonzero(numpy.logical_not(numpy.isnan(md2.mesh.lowervertex)))[0]
+			md2.mesh.lowervertex[pos]=Pnode[md2.mesh.lowervertex[pos].astype(int)-1]
+
+			md2.mesh.upperelements=md1.mesh.upperelements[pos_elem]
+			pos=numpy.nonzero(numpy.logical_not(numpy.isnan(md2.mesh.upperelements)))[0]
+			md2.mesh.upperelements[pos]=Pelem[md2.mesh.upperelements[pos].astype(int)-1]
+
+			md2.mesh.lowerelements=md1.mesh.lowerelements[pos_elem]
+			pos=numpy.nonzero(numpy.logical_not(numpy.isnan(md2.mesh.lowerelements)))[0]
+			md2.mesh.lowerelements[pos]=Pelem[md2.mesh.lowerelements[pos].astype(int)-1]
+
+		#Initial 2d mesh 
+		if md1.mesh.dimension==3:
+			flag_elem_2d=flag_elem[numpy.arange(0,md1.mesh.numberofelements2d)]
+			pos_elem_2d=numpy.nonzero(flag_elem_2d)[0]
+			flag_node_2d=flag_node[numpy.arange(0,md1.mesh.numberofvertices2d)]
+			pos_node_2d=numpy.nonzero(flag_node_2d)[0]
+
+			md2.mesh.numberofelements2d=numpy.size(pos_elem_2d)
+			md2.mesh.numberofvertices2d=numpy.size(pos_node_2d)
+			md2.mesh.elements2d=md1.mesh.elements2d[pos_elem_2d,:]
+			md2.mesh.elements2d[:,0]=Pnode[md2.mesh.elements2d[:,0].astype(int)-1]
+			md2.mesh.elements2d[:,1]=Pnode[md2.mesh.elements2d[:,1].astype(int)-1]
+			md2.mesh.elements2d[:,2]=Pnode[md2.mesh.elements2d[:,2].astype(int)-1]
+
+			md2.mesh.x2d=md1.mesh.x[pos_node_2d]
+			md2.mesh.y2d=md1.mesh.y[pos_node_2d]
+
+		#Edges
+		if len(numpy.shape(md2.mesh.edges))>1 and numpy.size(md2.mesh.edges,axis=1)>1:    #do not use ~isnan because there are some NaNs...
+			#renumber first two columns
+			pos=numpy.nonzero(md2.mesh.edges[:,3]!=-1)[0]
+			md2.mesh.edges[:  ,0]=Pnode[md2.mesh.edges[:,0].astype(int)-1]
+			md2.mesh.edges[:  ,1]=Pnode[md2.mesh.edges[:,1].astype(int)-1]
+			md2.mesh.edges[:  ,2]=Pelem[md2.mesh.edges[:,2].astype(int)-1]
+			md2.mesh.edges[pos,3]=Pelem[md2.mesh.edges[pos,3].astype(int)-1]
+			#remove edges when the 2 vertices are not in the domain.
+			md2.mesh.edges=md2.mesh.edges[numpy.nonzero(numpy.logical_and(md2.mesh.edges[:,0],md2.mesh.edges[:,1]))[0],:]
+			#Replace all zeros by -1 in the last two columns
+			pos=numpy.nonzero(md2.mesh.edges[:,2]==0)[0]
+			md2.mesh.edges[pos,2]=-1
+			pos=numpy.nonzero(md2.mesh.edges[:,3]==0)[0]
+			md2.mesh.edges[pos,3]=-1
+			#Invert -1 on the third column with last column (Also invert first two columns!!)
+			pos=numpy.nonzero(md2.mesh.edges[:,2]==-1)[0]
+			md2.mesh.edges[pos,2]=md2.mesh.edges[pos,3]
+			md2.mesh.edges[pos,3]=-1
+			values=md2.mesh.edges[pos,1]
+			md2.mesh.edges[pos,1]=md2.mesh.edges[pos,0]
+			md2.mesh.edges[pos,0]=values
+			#Finally remove edges that do not belong to any element
+			pos=numpy.nonzero(numpy.logical_and(md2.mesh.edges[:,1]==-1,md2.mesh.edges[:,2]==-1))[0]
+			md2.mesh.edges=numpy.delete(md2.mesh.edges,pos,axis=0)
+
+		#Penalties
+		if numpy.any(numpy.logical_not(numpy.isnan(md2.diagnostic.vertex_pairing))):
+			for i in xrange(numpy.size(md1.diagnostic.vertex_pairing,axis=0)):
+				md2.diagnostic.vertex_pairing[i,:]=Pnode[md1.diagnostic.vertex_pairing[i,:]]
+			md2.diagnostic.vertex_pairing=md2.diagnostic.vertex_pairing[numpy.nonzero(md2.diagnostic.vertex_pairing[:,0])[0],:]
+		if numpy.any(numpy.logical_not(numpy.isnan(md2.prognostic.vertex_pairing))):
+			for i in xrange(numpy.size(md1.prognostic.vertex_pairing,axis=0)):
+				md2.prognostic.vertex_pairing[i,:]=Pnode[md1.prognostic.vertex_pairing[i,:]]
+			md2.prognostic.vertex_pairing=md2.prognostic.vertex_pairing[numpy.nonzero(md2.prognostic.vertex_pairing[:,0])[0],:]
+
+		#recreate segments
+		if md1.mesh.dimension==2:
+			[md2.mesh.vertexconnectivity]=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices)
+			[md2.mesh.elementconnectivity]=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity)
+			md2.mesh.segments=contourenvelope(md2)
+			md2.mesh.vertexonboundary=numpy.zeros(numberofvertices2)
+			md2.mesh.vertexonboundary[md2.mesh.segments[:,0:2].astype(int)-1]=1
+		else:
+			#First do the connectivity for the contourenvelope in 2d
+			[md2.mesh.vertexconnectivity]=NodeConnectivity(md2.mesh.elements2d,md2.mesh.numberofvertices2d)
+			[md2.mesh.elementconnectivity]=ElementConnectivity(md2.mesh.elements2d,md2.mesh.vertexconnectivity)
+			md2.mesh.segments=contourenvelope(md2)
+			md2.mesh.vertexonboundary=numpy.zeros(numberofvertices2/md2.mesh.numberoflayers)
+			md2.mesh.vertexonboundary[md2.mesh.segments[:,0:2].astype(int)-1]=1
+			md2.mesh.vertexonboundary=numpy.tile(md2.mesh.vertexonboundary,md2.mesh.numberoflayers)
+			#Then do it for 3d as usual
+			[md2.mesh.vertexconnectivity]=NodeConnectivity(md2.mesh.elements,md2.mesh.numberofvertices)
+			[md2.mesh.elementconnectivity]=ElementConnectivity(md2.mesh.elements,md2.mesh.vertexconnectivity)
+
+		#Boundary conditions: Dirichlets on new boundary
+		#Catch the elements that have not been extracted
+		orphans_elem=numpy.nonzero(numpy.logical_not(flag_elem))[0]
+		orphans_node=numpy.unique(md1.mesh.elements[orphans_elem,:]).astype(int)-1
+		#Figure out which node are on the boundary between md2 and md1
+		nodestoflag1=numpy.intersect1d(orphans_node,pos_node)
+		nodestoflag2=Pnode[nodestoflag1].astype(int)-1
+		if numpy.size(md1.diagnostic.spcvx)>1 and numpy.size(md1.diagnostic.spcvy)>2 and numpy.size(md1.diagnostic.spcvz)>2:
+			if numpy.size(md1.inversion.vx_obs)>1 and numpy.size(md1.inversion.vy_obs)>1:
+				md2.diagnostic.spcvx[nodestoflag2]=md2.inversion.vx_obs[nodestoflag2] 
+				md2.diagnostic.spcvy[nodestoflag2]=md2.inversion.vy_obs[nodestoflag2]
+			else:
+				md2.diagnostic.spcvx[nodestoflag2]=float('NaN')
+				md2.diagnostic.spcvy[nodestoflag2]=float('NaN')
+				print "\n!! extract warning: spc values should be checked !!\n\n"
+			#put 0 for vz
+			md2.diagnostic.spcvz[nodestoflag2]=0
+		if numpy.any(numpy.logical_not(numpy.isnan(md1.thermal.spctemperature))):
+			md2.thermal.spctemperature[nodestoflag2,0]=1
+
+		#Diagnostic
+		if numpy.any(numpy.logical_not(numpy.isnan(md2.diagnostic.icefront))):
+			md2.diagnostic.icefront[:,0]=Pnode[md1.diagnostic.icefront[:,0].astype(int)-1]
+			md2.diagnostic.icefront[:,1]=Pnode[md1.diagnostic.icefront[:,1].astype(int)-1]
+			md2.diagnostic.icefront[:,-2]=Pelem[md1.diagnostic.icefront[:,-2].astype(int)-1]
+			if md1.mesh.dimension==3:
+				md2.diagnostic.icefront[:,2]=Pnode[md1.diagnostic.icefront[:,2].astype(int)-1]
+				md2.diagnostic.icefront[:,3]=Pnode[md1.diagnostic.icefront[:,3].astype(int)-1]
+			md2.diagnostic.icefront=md2.diagnostic.icefront[numpy.nonzero(numpy.logical_and(numpy.logical_and(md2.diagnostic.icefront[:,0],md2.diagnostic.icefront[:,1]),md2.diagnostic.icefront[:,-1]))[0],:]
+
+		#Results fields
+		if md1.results:
+			md2.results=results()
+			for solutionfield,field in md1.results.__dict__.iteritems():
+				if   isinstance(field,list):
+					setattr(md2.results,solutionfield,[])
+					#get time step
+					for i,fieldi in enumerate(field):
+						if isinstance(fieldi,results) and fieldi:
+							getattr(md2.results,solutionfield).append(results())
+							fieldr=getattr(md2.results,solutionfield)[i]
+							#get subfields
+							for solutionsubfield,subfield in fieldi.__dict__.iteritems():
+								if   numpy.size(subfield)==numberofvertices1:
+									setattr(fieldr,solutionsubfield,subfield[pos_node])
+								elif numpy.size(subfield)==numberofelements1:
+									setattr(fieldr,solutionsubfield,subfield[pos_elem])
+								else:
+									setattr(fieldr,solutionsubfield,subfield)
+						else:
+							getattr(md2.results,solutionfield).append(None)
+				elif isinstance(field,results):
+					setattr(md2.results,solutionfield,results())
+					if isinstance(field,results) and field:
+						fieldr=getattr(md2.results,solutionfield)
+						#get subfields
+						for solutionsubfield,subfield in field.__dict__.iteritems():
+							if   numpy.size(subfield)==numberofvertices1:
+								setattr(fieldr,solutionsubfield,subfield[pos_node])
+							elif numpy.size(subfield)==numberofelements1:
+								setattr(fieldr,solutionsubfield,subfield[pos_elem])
+							else:
+								setattr(fieldr,solutionsubfield,subfield)
+
+		#Keep track of pos_node and pos_elem
+		md2.mesh.extractedvertices=pos_node.astype(float)+1
+		md2.mesh.extractedelements=pos_elem.astype(float)+1
+
+		return md2
+	# }}}
+
 	def extrude(md,*args):    # {{{
 		"""
 		EXTRUDE - vertically extrude a 2d mesh
@@ -241,7 +521,7 @@
 			x3d=numpy.concatenate((x3d,md.mesh.x))
 			y3d=numpy.concatenate((y3d,md.mesh.y))
 			#nodes are distributed between bed and surface accordingly to the given exponent
-			z3d=numpy.concatenate((z3d,bed3d+thickness3d*extrusionlist[i]))
+			z3d=numpy.concatenate((z3d,(bed3d+thickness3d*extrusionlist[i]).reshape(-1)))
 		number_nodes3d=numpy.size(x3d)    #number of 3d nodes for the non extruded part of the mesh
 
 		#Extrude elements 
@@ -401,7 +681,7 @@
 
 		#Put lithostatic pressure if there is an existing pressure
 		if not numpy.any(numpy.isnan(md.initialization.pressure)):
-			md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z)
+			md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z.reshape(-1,1))
 
 		#special for thermal modeling:
 		md.basalforcings.melting_rate=project3d(md,'vector',md.basalforcings.melting_rate,'type','node','layer',1)

Modified: issm/trunk/src/m/classes/modellist.m
===================================================================
--- issm/trunk/src/m/classes/modellist.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/modellist.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -270,7 +270,6 @@
 				return
 			end
 
-
 			%now, tar all the files and then erase them.
 			eval(['!find -iname ''' name '-*'' > file_list.txt']);
 			!tar zcvf ModelList.tar.gz --files-from file_list.txt
@@ -301,7 +300,7 @@
 disp('building queueing script');
 
 %First try and figure out if there is a special script for this particular cluster
-function_name=['BuildMultipleQueueingScript' cluster];
+function_name=['BuildMultipleQueueingScript' cluster]
 
 %some specific treatment of identical cluster, gemini, castor and pollux
 if strcmpi(cluster,'castor') || strcmpi(cluster,'pollux'),
@@ -347,7 +346,7 @@
 %      LaunchMultipleQueueJob(executionpath)
 
 %First try and figure out if there is a special script for thie particular cluster
-function_name=['LaunchMultipleQueueJob' cluster];
+function_name=['LaunchMultipleQueueJob' cluster]
 
 %some specific treatment of identical cluster, gemini, castor and pollux
 if strcmpi(cluster,'castor') || strcmpi(cluster,'pollux'),
@@ -368,7 +367,6 @@
 %   Usage:
 %      LaunchMultipleQueueJobgemini(cluster,name,executionpath)
 
-
 %first, check we have the binary file and the queueing script
 if ~exist([ name '.queue'],'file'),
 	error('LaunchMultipleQueueJobgemini error message: queueing script issing, cannot go forward');

Modified: issm/trunk/src/m/classes/organizer.m
===================================================================
--- issm/trunk/src/m/classes/organizer.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/organizer.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,158 +9,157 @@
 %   Usage:
 %      org = organizer(varargin)
 %
-%
 %   Examples:
 %      org = organizer('repository','Models/','prefix','AGU2015','steps',0);  %build an empty organizer object with a given repository
 
 classdef organizer
     properties (SetAccess=private) 
-		 % {{{
-		 currentstep   =0;
-	 end
+		% {{{
+		currentstep   =0;
+	end
     properties (SetAccess=public) 
-		 repository    ='./';
-		 prefix        ='model.';
-		 trunkprefix   ='';
-		 steps         =[];
-		 requestedsteps=[0];
-		 %}}}
-	 end
-	 methods
-		 function org=organizer(varargin) % {{{
+		repository    ='./';
+		prefix        ='model.';
+		trunkprefix   ='';
+		steps         =[];
+		requestedsteps=[0];
+		%}}}
+	end
+	methods
+		function org=organizer(varargin) % {{{
 
-			 %process options
-			 options=pairoptions(varargin{:});
+			%process options
+			options=pairoptions(varargin{:});
 
-			 %Get prefix
-			 prefix=getfieldvalue(options,'prefix','model.');
-			 if ~ischar(prefix),                            error('prefix is not a string'); end
-			 if ~strcmp(regexprep(prefix,'\s+',''),prefix), error('prefix should not have any white space'); end
-			 org.prefix=prefix;
+			%Get prefix
+			prefix=getfieldvalue(options,'prefix','model.');
+			if ~ischar(prefix),                            error('prefix is not a string'); end
+			if ~strcmp(regexprep(prefix,'\s+',''),prefix), error('prefix should not have any white space'); end
+			org.prefix=prefix;
 
-			 %Get repository
-			 repository=getfieldvalue(options,'repository','./');
-			 if ~ischar(repository),        error('repository is not a string'); end
-			 if exist(repository,'dir')~=7, error(['Directory ' repository ' not found']), end
-			 org.repository=repository;
+			%Get repository
+			repository=getfieldvalue(options,'repository','./');
+			if ~ischar(repository),        error('repository is not a string'); end
+			if exist(repository,'dir')~=7, error(['Directory ' repository ' not found']), end
+			org.repository=repository;
 
-			 %Get repository
-			 org.requestedsteps=getfieldvalue(options,'steps',0);
+			%Get steps
+			org.requestedsteps=getfieldvalue(options,'steps',0);
 
-			 %Get trunk prefix (only if provided by user)
-			 if exist(options,'trunkprefix'),
-				 trunkprefix=getfieldvalue(options,'trunkprefix','');
-				 if ~ischar(trunkprefix),                                 error('trunkprefix is not a string'); end
-				 if ~strcmp(regexprep(trunkprefix,'\s+',''),trunkprefix), error('trunkprefix should not have any white space'); end
-				 org.trunkprefix=trunkprefix;
-			 end
-		 end
-		 %}}}
-		 function disp(org) % {{{
-			 disp(sprintf('   Repository: ''%s''',org.repository));
-			 disp(sprintf('   Prefix:     ''%s''',org.prefix));
-			 if isempty(org.steps)
-				 disp('   no step');
-			 else
-				 for i=1:length(org.steps),
-					 disp(sprintf('   step #%2i: ''%s''',org.steps(i).id,org.steps(i).string));
-				 end
-			 end
-		 end
-		 %}}}
-		 function md=load(org,string),% {{{
+			%Get trunk prefix (only if provided by user)
+			if exist(options,'trunkprefix'),
+				trunkprefix=getfieldvalue(options,'trunkprefix','');
+				if ~ischar(trunkprefix),                                 error('trunkprefix is not a string'); end
+				if ~strcmp(regexprep(trunkprefix,'\s+',''),trunkprefix), error('trunkprefix should not have any white space'); end
+				org.trunkprefix=trunkprefix;
+			end
+		end
+		%}}}
+		function disp(org) % {{{
+			disp(sprintf('   Repository: ''%s''',org.repository));
+			disp(sprintf('   Prefix:     ''%s''',org.prefix));
+			if isempty(org.steps)
+				disp('   no step');
+			else
+				for i=1:length(org.steps),
+					disp(sprintf('   step #%2i: ''%s''',org.steps(i).id,org.steps(i).string));
+				end
+			end
+		end
+		%}}}
+		function md=load(org,string),% {{{
 
-			 %Get model path
-			 if ~ischar(string), error('argument provided is not a string'); end
-			 path=[org.repository '/' org.prefix string];
+			%Get model path
+			if ~ischar(string), error('argument provided is not a string'); end
+			path=[org.repository '/' org.prefix string];
 
-			 %figure out if the model is there
-			 if exist(path,'file'),
-				 struc=load(path,'-mat');
-				 name=char(fieldnames(struc));
-				 md=struc.(name);
-				 if nargout,
-					 varargout{1}=md;
-				 end
-			 else
-				 error(['Could not find ' path ]);
-			 end
-		 end%}}}
-		 function md=loadmodel(org,string),% {{{
+			%figure out if the model is there
+			if exist(path,'file'),
+				struc=load(path,'-mat');
+				name=char(fieldnames(struc));
+				md=struc.(name);
+				if nargout,
+					varargout{1}=md;
+				end
+			else
+				error(['Could not find ' path ]);
+			end
+		end%}}}
+		function md=loadmodel(org,string),% {{{
 
-			 %Get model path
-			 if ~ischar(string), error('argument provided is not a string'); end
-			 path=[org.repository '/' org.prefix string];
+			%Get model path
+			if ~ischar(string), error('argument provided is not a string'); end
+			path=[org.repository '/' org.prefix string];
 
-			 %figure out if the model is there, otherwise, we have to use the default path supplied by user.
-			 if exist(path,'file') | exist([path '.mat'],'file'),
-				 md=loadmodel(path);
-				 return;
-			 end
+			%figure out if the model is there, otherwise, we have to use the default path supplied by user.
+			if exist(path,'file') | exist([path '.mat'],'file'),
+				md=loadmodel(path);
+				return;
+			end
 
-			 %If we are here, the model has not been found. Try trunk prefix if provided
-			 if ~isempty(org.trunkprefix),
-				 path2=[org.repository '/' org.trunkprefix string];
-				 if ~exist(path2,'file'),
-					 error(['Could neither find ' path ', nor ' path2]);
-				 else
-					 disp(['--> Branching ' org.prefix ' from trunk ' org.trunkprefix]);
-					 md=loadmodel(path2);
-					 return;
-				 end
-			 else
-				 error(['Could not find ' path ]);
-			 end
-		 end%}}}
-		 function bool=perform(org,string) % {{{
-			 
-			 bool=false;
+			%If we are here, the model has not been found. Try trunk prefix if provided
+			if ~isempty(org.trunkprefix),
+				path2=[org.repository '/' org.trunkprefix string];
+				if ~exist(path2,'file'),
+					error(['Could find neither ' path ', nor ' path2]);
+				else
+					disp(['--> Branching ' org.prefix ' from trunk ' org.trunkprefix]);
+					md=loadmodel(path2);
+					return;
+				end
+			else
+				error(['Could not find ' path ]);
+			end
+		end%}}}
+		function bool=perform(org,string) % {{{
 
-			 %Some checks
-			 if ~ischar(string),                            error('Step provided should be a string'); end
-			 if ~strcmp(regexprep(string,'\s+',''),string), error('Step provided should not have any white space'); end
-			 if (org.currentstep>0 & ismember({string},{org.steps.string})) 
-				 error(['Step ' string ' already present. Change name']); 
-			 end
+			bool=false;
 
-			 %Add step
-			 org.steps(end+1).id=length(org.steps)+1;
-			 org.steps(end).string=string;
-			 org.currentstep=org.currentstep+1;
+			%Some checks
+			if ~ischar(string),                            error('Step provided should be a string'); end
+			if ~strcmp(regexprep(string,'\s+',''),string), error('Step provided should not have any white space'); end
+			if (org.currentstep>0 & ismember({string},{org.steps.string})) 
+				error(['Step ' string ' already present. Change name']); 
+			end
 
-			 %if requestedsteps = 0, print all steps in org 
-			 if any(org.requestedsteps==0),
-				 if org.currentstep==1,
-					 disp(sprintf('   prefix: %s',org.prefix));
-				 end
-				 disp(sprintf('   step #%2i : %s',org.steps(org.currentstep).id,org.steps(org.currentstep).string));
-			 end
+			%Add step
+			org.steps(end+1).id=length(org.steps)+1;
+			org.steps(end).string=string;
+			org.currentstep=org.currentstep+1;
 
-			 %Ok, now if currentstep is a member of steps, return true
-			 if ismember(org.currentstep,org.requestedsteps),
-				 disp(sprintf('\n   step #%i : %s\n',org.steps(org.currentstep).id,org.steps(org.currentstep).string));
-				 bool=true;
-			 end
+			%if requestedsteps = 0, print all steps in org 
+			if any(org.requestedsteps==0),
+				if org.currentstep==1,
+					disp(sprintf('   prefix: %s',org.prefix));
+				end
+				disp(sprintf('   step #%2i : %s',org.steps(org.currentstep).id,org.steps(org.currentstep).string));
+			end
 
-			 %assign org back to calling workspace
-			 assignin('caller',inputname(1),org);
+			%Ok, now if currentstep is a member of steps, return true
+			if ismember(org.currentstep,org.requestedsteps),
+				disp(sprintf('\n   step #%i : %s\n',org.steps(org.currentstep).id,org.steps(org.currentstep).string));
+				bool=true;
+			end
 
-		 end%}}}
-		 function savemodel(org,md) % {{{
+			%assign org back to calling workspace
+			assignin('caller',inputname(1),org);
 
-			 %check
-			 if (org.currentstep==0), error('Cannot save model because organizer (org) is empty! Make sure you did not skip any perform call'); end
-			 if (org.currentstep>length(org.steps)), error('Cannot save model because organizer (org) is not up to date!'); end
+		end%}}}
+		function savemodel(org,md) % {{{
 
-			 name=[org.repository '/' org.prefix org.steps(org.currentstep).string ];
-			 disp(['saving model as: ' name]);
-			 
-			 %check that md is a model
-			 if ~isa(md,'model'), warning('third argument is not a model'); end
-			 if (org.currentstep>length(org.steps)), error(['organizer error message: element with id ' num2str(org.currentstep) ' not found']); end
+			%check
+			if (org.currentstep==0), error('Cannot save model because organizer (org) is empty! Make sure you did not skip any perform call'); end
+			if (org.currentstep>length(org.steps)), error('Cannot save model because organizer (org) is not up to date!'); end
 
-			 %save model
-			 save(name,'md','-v7.3');
-		 end%}}}
+			name=[org.repository '/' org.prefix org.steps(org.currentstep).string ];
+			disp(['saving model as: ' name]);
+
+			%check that md is a model
+			if ~isa(md,'model'), warning('second argument is not a model'); end
+			if (org.currentstep>length(org.steps)), error(['organizer error message: element with id ' num2str(org.currentstep) ' not found']); end
+
+			%save model
+			save(name,'md','-v7.3');
+		end%}}}
 	end
 end

Modified: issm/trunk/src/m/classes/pairoptions.m
===================================================================
--- issm/trunk/src/m/classes/pairoptions.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/pairoptions.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -174,7 +174,7 @@
 		%      value=getfieldvalue(options,'caxis',[0 2]);
 
 			%some argument checking: 
-			if nargin~=2 & nargin~=3,
+			if nargin~=2 && nargin~=3,
 				help getfieldvalue
 				error('getfieldvalue error message: bad usage');
 			end
@@ -184,11 +184,10 @@
 			end
 
 			%Recover option
-			for i=1:size(obj.list,1),
-				if strcmpi(obj.list{i,1},field)
-					value=obj.list{i,2};
-					return
-				end
+			pos=find(strcmpi(obj.list(:,1),field));
+			if ~isempty(pos),
+				value=obj.list{pos(1),2}; %ignore extra entry
+				return;
 			end
 
 			%The option has not been found, output default if provided

Modified: issm/trunk/src/m/classes/pairoptions.py
===================================================================
--- issm/trunk/src/m/classes/pairoptions.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/pairoptions.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -40,7 +40,7 @@
 				self.list[arg[2*i]] = arg[2*i+1];
 			else:
 				#option is not a string, ignore it
-				print "WARNING: option number %d '%s' is not a string and will be ignored." % (i+1,type(arg[2*i]))
+				print "WARNING: option number %d is not a string and will be ignored." % (i+1)
 	# }}}
 
 	def addfield(self,field,value):    # {{{
@@ -52,7 +52,7 @@
 	# }}}
 
 	def addfielddefault(self,field,value):    # {{{
-		"""ADDFIELDDEFAULT - add a field to an options list if it does not exist"""
+		"""ADDFIELDDEFAULT - add a field to an options list if it does not already exist"""
 		if isinstance(field,(str,unicode)):
 			if field not in self.list:
 				self.list[field] = value
@@ -127,18 +127,20 @@
 			return False
 	# }}}
 
-#	function num = fieldoccurences(obj,field), % {{{
-#	%FIELDOCCURENCES - get number of occurence of a field
-#
-#		%check input 
-#		if ~ischar(field),
-#			error('fieldoccurences error message: field should be a string');
-#		end
-#
-#		%get number of occurence
-#		num=sum(strcmpi(field,obj.list(:,1)));
-#	end % }}}
+	#def fieldoccurences(self,field): #{{{
+	#	'''
+	#	FIELDOCCURENCES - get number of occurence of a field
+	#	'''
+	#
+	#	#check input 
+	#	if not isinstance(field,(str,unicode)):
+	#		raise TypeError("fieldoccurences error message: field should be a string")
 
+	#	#get number of occurence
+	#	# ??
+	#	#return num
+	#	#% }}}
+
 	def getfieldvalue(self,field,default=None):    # {{{
 		"""
 		GETOPTION - get the value of an option

Modified: issm/trunk/src/m/classes/planetmesh.m
===================================================================
--- issm/trunk/src/m/classes/planetmesh.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/planetmesh.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,7 +16,7 @@
 		numberoflayers              = 0;
 		numberofelements            = 0;
 		numberofvertices            = 0;
-		
+
 		lat                         = NaN
 		long                        = NaN
 
@@ -102,7 +102,7 @@
 			disp(sprintf('\n      Properties:'));
 			fielddisplay(obj,'dimension','planetmesh dimension (2d or 3d)');
 			fielddisplay(obj,'numberoflayers','number of extrusion layers');
-			
+
 			fielddisplay(obj,'vertexconnectivity','list of vertices connected to vertex_i');
 			fielddisplay(obj,'elementconnectivity','list of vertices connected to element_i');
 			fielddisplay(obj,'average_vertex_connectivity','average number of vertices connected to one vertex');

Modified: issm/trunk/src/m/classes/prognostic.m
===================================================================
--- issm/trunk/src/m/classes/prognostic.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/prognostic.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,6 +11,7 @@
 		 stabilization          = 0;
 		 vertex_pairing         = NaN;
 		 penalty_factor         = 0;
+		 requested_outputs      = NaN;
 	end
 	methods
 		function obj = prognostic(varargin) % {{{
@@ -44,6 +45,9 @@
 			md = checkfield(md,'prognostic.hydrostatic_adjustment','values',{'Absolute' 'Incremental'});
 			md = checkfield(md,'prognostic.stabilization','values',[0 1 2 3]);
 			md = checkfield(md,'prognostic.min_thickness','>',0);
+			if ~isempty(md.prognostic.requested_outputs),
+				md = checkfield(md,'prognostic.requested_outputs','size',[NaN 1]);
+			end
 
 		end % }}}
 		function disp(obj) % {{{
@@ -56,6 +60,7 @@
 			disp(sprintf('\n      %s','Penalty options:'));
 			fielddisplay(obj,'penalty_factor','offset used by penalties: penalty = Kmax*10^offset');
 			fielddisplay(obj,'vertex_pairing','pairs of vertices that are penalized');
+			fielddisplay(obj,'requested_outputs','additional outputs requested');
 
 		end % }}}
 		function marshall(obj,fid) % {{{
@@ -65,6 +70,7 @@
 			WriteData(fid,'object',obj,'fieldname','stabilization','format','Integer');
 			WriteData(fid,'object',obj,'fieldname','vertex_pairing','format','DoubleMat','mattype',3);
 			WriteData(fid,'object',obj,'fieldname','penalty_factor','format','Double');
+			WriteData(fid,'object',obj,'fieldname','requested_outputs','format','DoubleMat','mattype',3);
 		end % }}}
 	end
 end

Modified: issm/trunk/src/m/classes/prognostic.py
===================================================================
--- issm/trunk/src/m/classes/prognostic.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/prognostic.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,6 +22,7 @@
 		self.stabilization          = 0
 		self.vertex_pairing         = float('NaN')
 		self.penalty_factor         = 0
+		self.requested_outputs      = float('NaN')
 
 		#set defaults
 		self.setdefaultparameters()
@@ -34,6 +35,7 @@
 		string="%s\n%s"%(string,fielddisplay(self,'min_thickness','minimum ice thickness allowed'))
 		string="%s\n%s"%(string,fielddisplay(self,'hydrostatic_adjustment','adjustment of ice shelves surface and bed elevations: ''Incremental'' or ''Absolute'' '))
 		string="%s\n%s"%(string,fielddisplay(self,'stabilization','0->no, 1->artificial_diffusivity, 2->streamline upwinding, 3->discontinuous Galerkin'))
+		string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
 
 		return string
 		#}}}
@@ -66,6 +68,8 @@
 		md = checkfield(md,'prognostic.hydrostatic_adjustment','values',['Absolute','Incremental'])
 		md = checkfield(md,'prognostic.stabilization','values',[0,1,2,3])
 		md = checkfield(md,'prognostic.min_thickness','>',0)
+		if not md.prognostic.requested_outputs:
+			md = checkfield(md,'prognostic.requested_outputs','size',[float('NaN'),1])
 
 		return md
 	# }}}
@@ -77,5 +81,6 @@
 		WriteData(fid,'object',self,'fieldname','stabilization','format','Integer')
 		WriteData(fid,'object',self,'fieldname','vertex_pairing','format','DoubleMat','mattype',3)
 		WriteData(fid,'object',self,'fieldname','penalty_factor','format','Double')
+		WriteData(fid,'object',self,'fieldname','requested_outputs','format','DoubleMat','mattype',3);
 	# }}}
 

Modified: issm/trunk/src/m/classes/qmu/@dakota_method/dakota_method.m
===================================================================
--- issm/trunk/src/m/classes/qmu/@dakota_method/dakota_method.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/@dakota_method/dakota_method.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -48,7 +48,7 @@
     properties
         params   =struct();
     end
-    
+
     methods
         function [dm]=dakota_method(method)
 
@@ -827,7 +827,7 @@
                         end
 
                     end
-                    
+
 %  if more than one argument, issue warning
 
                 otherwise
@@ -851,7 +851,7 @@
                 disp(sprintf('       lcspec: %s'      ,string_cell(dm(i).lcspec)));
                 disp(sprintf('    responses: %s'      ,string_cell(dm(i).responses)));
                 disp(sprintf('       ghspec: %s\n'    ,string_cell(dm(i).ghspec)));
-    
+
 %  display the parameters within the object
 
                 fnames=fieldnames(dm(i).params);
@@ -859,7 +859,7 @@
                 for j=1:numel(fnames)
                     maxlen=max(maxlen,length(fnames{j}));
                 end
-    
+
                 for j=1:numel(fnames)
                     disp(sprintf(['       params.%-' num2str(maxlen+1) 's: %s'],...
                         fnames{j},any2str(dm(i).params.(fnames{j}))));
@@ -869,4 +869,3 @@
         end
     end
 end
-

Modified: issm/trunk/src/m/classes/qmu/@dakota_method/dmeth_params_write.m
===================================================================
--- issm/trunk/src/m/classes/qmu/@dakota_method/dmeth_params_write.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/@dakota_method/dmeth_params_write.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -45,7 +45,7 @@
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end
-        
+
     case {'npsol'}
         param_write(fid,sbeg,'max_iterations','           = ','\n',dm.params);
         param_write(fid,sbeg,'max_function_evaluations',' = ','\n',dm.params);
@@ -63,7 +63,7 @@
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end
-        
+
     case {'conmin'}
         param_write(fid,sbeg,'max_iterations','           = ','\n',dm.params);
         param_write(fid,sbeg,'max_function_evaluations',' = ','\n',dm.params);
@@ -79,7 +79,7 @@
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end
-        
+
     case {'optpp'}
         param_write(fid,sbeg,'max_iterations','           = ','\n',dm.params);
         param_write(fid,sbeg,'max_function_evaluations',' = ','\n',dm.params);
@@ -119,7 +119,7 @@
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end
-        
+
     case {'apps'}
         param_write(fid,sbeg,'max_function_evaluations',' = ','\n',dm.params);
         param_write(fid,sbeg,'constraint_tolerance','     = ','\n',dm.params);
@@ -139,7 +139,7 @@
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end
-        
+
     case {'coliny'}
         param_write(fid,sbeg,'max_iterations','           = ','\n',dm.params);
         param_write(fid,sbeg,'max_function_evaluations',' = ','\n',dm.params);
@@ -211,7 +211,7 @@
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end
-        
+
     case {'ncsu'}
         param_write(fid,sbeg,'max_iterations','           = ','\n',dm.params);
         param_write(fid,sbeg,'max_function_evaluations',' = ','\n',dm.params);
@@ -225,7 +225,7 @@
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end
-        
+
     case {'jega'}
         param_write(fid,sbeg,'max_iterations','           = ','\n',dm.params);
         param_write(fid,sbeg,'max_function_evaluations',' = ','\n',dm.params);
@@ -281,7 +281,7 @@
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end
-        
+
     case {'lsq'}
         switch dm.method
             case {'nl2sol'}
@@ -343,7 +343,7 @@
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end
-        
+
     case {'nond'}
         switch dm.method
             case {'nond_sampling'}
@@ -425,7 +425,7 @@
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end
-        
+
     case {'dace'}
         switch dm.method
             case {'dace'}
@@ -483,7 +483,7 @@
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end
-        
+
     case {'param'}
         param_write(fid,sbeg,'output',' ','\n',dm.params);
         switch dm.method
@@ -511,7 +511,7 @@
 
             case {'multidim_parameter_study'}
                 param_write(fid,sbeg,'partitions',' = ','\n',dm.params);
-            
+
             otherwise
                 error('Unrecognized ''%s'' method: ''%s''.',dm.type,dm.method);
         end

Modified: issm/trunk/src/m/classes/qmu/continuous_design.m
===================================================================
--- issm/trunk/src/m/classes/qmu/continuous_design.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/continuous_design.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -38,7 +38,7 @@
         scale_type='none';
         scale     = 1.;
     end
-    
+
     methods
         function [cdv]=continuous_design(varargin)
 
@@ -64,7 +64,7 @@
                     asizec=num2cell(array_size(varargin{1:min(nargin,6)}));
                     cdv(asizec{:})=continuous_design;
                     clear asizec
-                    
+
                     if ischar(varargin{1})
                         varargin{1}=cellstr(varargin{1});
                     end
@@ -211,7 +211,7 @@
             scale=allequal(scale,1.);
         end
     end
-    
+
     methods (Static)
         function []=dakota_write(fidi,dvar)
 

Modified: issm/trunk/src/m/classes/qmu/continuous_state.m
===================================================================
--- issm/trunk/src/m/classes/qmu/continuous_state.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/continuous_state.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -34,7 +34,7 @@
         lower     =-Inf;
         upper     = Inf;
     end
-    
+
     methods
         function [csv]=continuous_state(varargin)
 
@@ -60,7 +60,7 @@
                     asizec=num2cell(array_size(varargin{1:min(nargin,4)}));
                     csv(asizec{:})=continuous_state;
                     clear asizec
-                    
+
                     if ischar(varargin{1})
                         varargin{1}=cellstr(varargin{1});
                     end
@@ -176,7 +176,7 @@
             scale=[];
         end
     end
-    
+
     methods (Static)
         function []=dakota_write(fidi,dvar)
 

Modified: issm/trunk/src/m/classes/qmu/least_squares_term.m
===================================================================
--- issm/trunk/src/m/classes/qmu/least_squares_term.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/least_squares_term.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -34,7 +34,7 @@
         scale     = 1.;
         weight    = 1.;
     end
-    
+
     methods
         function [lst]=least_squares_term(varargin)
 
@@ -53,7 +53,7 @@
                         asizec=num2cell(array_size(varargin{1:min(nargin,4)}));
                         lst(asizec{:})=least_squares_term;
                         clear asizec
-                    
+
                         if ischar(varargin{1})
                             varargin{1}=cellstr(varargin{1});
                         end
@@ -168,7 +168,7 @@
             target=[];
         end
     end
-    
+
     methods (Static)
         function [rdesc]=dakota_write(fidi,dresp,rdesc)
 

Modified: issm/trunk/src/m/classes/qmu/linear_equality_constraint.m
===================================================================
--- issm/trunk/src/m/classes/qmu/linear_equality_constraint.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/linear_equality_constraint.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -34,7 +34,7 @@
         scale_type='none';
         scale     = 1.;
     end
-    
+
     methods
         function [lec]=linear_equality_constraint(varargin)
 
@@ -68,7 +68,7 @@
                     end
                     lec(asizec{:})=linear_equality_constraint;
                     clear asizec
-                    
+
                     for i=1:numel(lec)
                         if (size(varargin{1},1) > 1)
                             lec(i).matrix    =varargin{1}(i,:);
@@ -166,7 +166,7 @@
             scale=allequal(scale,1.);
         end
     end
-    
+
     methods (Static)
         function []=dakota_write(fidi,dvar)
 

Modified: issm/trunk/src/m/classes/qmu/linear_inequality_constraint.m
===================================================================
--- issm/trunk/src/m/classes/qmu/linear_inequality_constraint.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/linear_inequality_constraint.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -36,7 +36,7 @@
         scale_type='none';
         scale     = 1.;
     end
-    
+
     methods
         function [lic]=linear_inequality_constraint(varargin)
 
@@ -76,7 +76,7 @@
                     end
                     lic(asizec{:})=linear_inequality_constraint;
                     clear asizec
-                    
+
                     for i=1:numel(lic)
                         if (size(varargin{1},1) > 1)
                             lic(i).matrix    =varargin{1}(i,:);
@@ -188,7 +188,7 @@
             scale=allequal(scale,1.);
         end
     end
-    
+
     methods (Static)
         function []=dakota_write(fidi,dvar)
 
@@ -202,4 +202,3 @@
         end
     end
 end
-

Modified: issm/trunk/src/m/classes/qmu/nonlinear_equality_constraint.m
===================================================================
--- issm/trunk/src/m/classes/qmu/nonlinear_equality_constraint.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/nonlinear_equality_constraint.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -34,7 +34,7 @@
         scale_type='none';
         scale     = 1.;
     end
-    
+
     methods
         function [nec]=nonlinear_equality_constraint(varargin)
 
@@ -60,7 +60,7 @@
                     asizec=num2cell(array_size(varargin{1:min(nargin,4)}));
                     nec(asizec{:})=nonlinear_equality_constraint;
                     clear asizec
-                    
+
                     if ischar(varargin{1})
                         varargin{1}=cellstr(varargin{1});
                     end
@@ -170,7 +170,7 @@
             target=allequal(target,0.);
         end
     end
-    
+
     methods (Static)
         function [rdesc]=dakota_write(fidi,dresp,rdesc)
 

Modified: issm/trunk/src/m/classes/qmu/nonlinear_inequality_constraint.m
===================================================================
--- issm/trunk/src/m/classes/qmu/nonlinear_inequality_constraint.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/nonlinear_inequality_constraint.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -36,7 +36,7 @@
         scale_type='none';
         scale     = 1.;
     end
-    
+
     methods
         function [nic]=nonlinear_inequality_constraint(varargin)
 
@@ -68,7 +68,7 @@
                     asizec=num2cell(array_size(varargin{1:min(nargin,5)}));
                     nic(asizec{:})=nonlinear_inequality_constraint;
                     clear asizec
-                    
+
                     if ischar(varargin{1})
                         varargin{1}=cellstr(varargin{1});
                     end
@@ -188,7 +188,7 @@
             target=[];
         end
     end
-    
+
     methods (Static)
         function [rdesc]=dakota_write(fidi,dresp,rdesc)
 

Modified: issm/trunk/src/m/classes/qmu/normal_uncertain.m
===================================================================
--- issm/trunk/src/m/classes/qmu/normal_uncertain.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/normal_uncertain.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -36,7 +36,7 @@
         lower     =-Inf;
         upper     = Inf;
     end
-    
+
     methods
         function [nuv]=normal_uncertain(varargin)
 
@@ -68,7 +68,7 @@
                     asizec=num2cell(array_size(varargin{1:min(nargin,5)}));
                     nuv(asizec{:})=normal_uncertain;
                     clear asizec
-                    
+
                     if ischar(varargin{1})
                         varargin{1}=cellstr(varargin{1});
                     end
@@ -192,7 +192,7 @@
             scale=[];
         end
     end
-    
+
     methods (Static)
         function []=dakota_write(fidi,dvar)
 

Modified: issm/trunk/src/m/classes/qmu/objective_function.m
===================================================================
--- issm/trunk/src/m/classes/qmu/objective_function.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/objective_function.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -34,7 +34,7 @@
         scale     = 1.;
         weight    = 1.;
     end
-    
+
     methods
         function [of]=objective_function(varargin)
 
@@ -53,7 +53,7 @@
                         asizec=num2cell(array_size(varargin{1:min(nargin,4)}));
                         of(asizec{:})=objective_function;
                         clear asizec
-                    
+
                         if ischar(varargin{1})
                             varargin{1}=cellstr(varargin{1});
                         end
@@ -168,7 +168,7 @@
             target=[];
         end
     end
-    
+
     methods (Static)
         function [rdesc]=dakota_write(fidi,dresp,rdesc)
 

Modified: issm/trunk/src/m/classes/qmu/response_function.m
===================================================================
--- issm/trunk/src/m/classes/qmu/response_function.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/response_function.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -36,7 +36,7 @@
         rell      =[];
         grell     =[];
     end
-    
+
     methods
         function [rf]=response_function(varargin)
 
@@ -55,7 +55,7 @@
                         asizec=num2cell(array_size(varargin{1:min(nargin,1)}));
                         rf(asizec{:})=response_function;
                         clear asizec
-                    
+
                         if ischar(varargin{1})
                             varargin{1}=cellstr(varargin{1});
                         end
@@ -165,7 +165,7 @@
             grell=allempty(grell);
         end
     end
-    
+
     methods (Static)
         function [rdesc]=dakota_write(fidi,dresp,rdesc)
 
@@ -177,7 +177,7 @@
 
             [rdesc]=rlist_write(fidi,'response_functions','response_function',rf,rdesc);
         end
-        
+
         function []=dakota_rlev_write(fidi,dresp,params)
 
 %  collect only the responses of the appropriate class

Modified: issm/trunk/src/m/classes/qmu/uniform_uncertain.m
===================================================================
--- issm/trunk/src/m/classes/qmu/uniform_uncertain.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu/uniform_uncertain.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -31,7 +31,7 @@
         lower     =-Inf;
         upper     = Inf;
     end
-    
+
     methods
         function [uuv]=uniform_uncertain(varargin)
 
@@ -63,7 +63,7 @@
                     asizec=num2cell(array_size(varargin{1:min(nargin,3)}));
                     uuv(asizec{:})=uniform_uncertain;
                     clear asizec
-                    
+
                     if ischar(varargin{1})
                         varargin{1}=cellstr(varargin{1});
                     end
@@ -151,7 +151,7 @@
             scale=[];
         end
     end
-    
+
     methods (Static)
         function []=dakota_write(fidi,dvar)
 

Modified: issm/trunk/src/m/classes/qmu.m
===================================================================
--- issm/trunk/src/m/classes/qmu.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -32,7 +32,7 @@
 			end
 		end % }}}
 		function obj = setdefaultparameters(obj) % {{{
-	
+
 		end % }}}
 		function md = checkconsistency(obj,md,solution,analyses) % {{{
 
@@ -141,13 +141,22 @@
 		end % }}}
 		function marshall(obj,fid) % {{{
 			WriteData(fid,'object',obj,'fieldname','isdakota','format','Boolean');
-			if ~obj.isdakota, return; end
+			if ~obj.isdakota, 
+				WriteData(fid,'data',false,'enum',QmuMassFluxSegmentsPresentEnum,'format','Boolean');
+				return; 
+			end
 			WriteData(fid,'object',obj,'fieldname','partition','format','DoubleMat','mattype',2);
 			WriteData(fid,'object',obj,'fieldname','numberofpartitions','format','Integer');
 			WriteData(fid,'object',obj,'fieldname','numberofresponses','format','Integer');
 			WriteData(fid,'object',obj,'fieldname','variabledescriptors','format','StringArray');
 			WriteData(fid,'object',obj,'fieldname','responsedescriptors','format','StringArray');
-			WriteData(fid,'object',obj,'fieldname','mass_flux_segments','format','MatArray');
+			if ~isempty(obj.mass_flux_segments), 
+				WriteData(fid,'data',obj.mass_flux_segments,'enum',MassFluxSegmentsEnum,'format','MatArray');
+				flag=true; 
+			else 
+				flag=false; 
+			end
+			WriteData(fid,'data',flag,'enum',QmuMassFluxSegmentsPresentEnum,'format','Boolean');
 		end % }}}
 	end
 end

Modified: issm/trunk/src/m/classes/qmu.py
===================================================================
--- issm/trunk/src/m/classes/qmu.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/qmu.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -44,7 +44,6 @@
 		# {{{setdefaultparameters
 		return self
 	#}}}
-
 	def checkconsistency(self,md,solution,analyses):    # {{{
 
 		#Early return
@@ -67,7 +66,6 @@
 
 		return md
 	# }}}
-
 	def __repr__(self):    # {{{
 		s ='   qmu parameters:\n'
 
@@ -140,16 +138,21 @@
 
 		return s
 	# }}}
-		
 	def marshall(self,fid):    # {{{
 		WriteData(fid,'object',self,'fieldname','isdakota','format','Boolean')
 		if not self.isdakota:
+			WriteData(fid,'data',False,'enum',QmuMassFluxSegmentsPresentEnum(),'format','Boolean');
 			return
 		WriteData(fid,'object',self,'fieldname','partition','format','DoubleMat','mattype',2)
 		WriteData(fid,'object',self,'fieldname','numberofpartitions','format','Integer')
 		WriteData(fid,'object',self,'fieldname','numberofresponses','format','Integer')
 		WriteData(fid,'object',self,'fieldname','variabledescriptors','format','StringArray')
 		WriteData(fid,'object',self,'fieldname','responsedescriptors','format','StringArray')
-		WriteData(fid,'object',self,'fieldname','mass_flux_segments','format','MatArray')
+		if not self.mass_flux_segments:
+			WriteData(fid,'data',self.mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray');
+			flag=True; 
+		else:
+			flag=False; 
+		WriteData(fid,'data',flag,'enum',QmuMassFluxSegmentsPresentEnum(),'format','Boolean');
 	# }}}
 

Modified: issm/trunk/src/m/classes/rifts.m
===================================================================
--- issm/trunk/src/m/classes/rifts.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/rifts.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -37,10 +37,12 @@
 					%We have segments with rift markers, but no rift structure!
 					md = checkmessage(md,['model should be processed for rifts (run meshprocessrifts)!']);
 				end
-				md = checkfield(md,'rifts.riftstruct.fill','values',[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
+				for i=1:numrifts,
+					md = checkfield(md,sprintf('rifts.riftstruct(%d).fill',i),'values',[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
+				end
 			else
 				if ~isnans(obj.riftstruct),
-					md = checkmessage(md,['riftstruct shoud be NaN since numrifts is 0!']);
+					md = checkmessage(md,['riftstruct should be NaN since numrifts is 0!']);
 				end
 			end
 		end % }}}

Modified: issm/trunk/src/m/classes/rifts.py
===================================================================
--- issm/trunk/src/m/classes/rifts.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/rifts.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,8 +17,8 @@
 	#properties
 	def __init__(self):
 		# {{{ Properties
-		self.riftstruct     = float('NaN')
-		self.riftproperties = float('NaN')
+		self.riftstruct     = []
+		self.riftproperties = []
 
 		#set defaults
 		self.setdefaultparameters()
@@ -52,10 +52,11 @@
 			if numpy.any(md.mesh.segmentmarkers>=2):
 				#We have segments with rift markers, but no rift structure!
 				md.checkmessage("model should be processed for rifts (run meshprocessrifts)!")
-			md = checkfield(md,'rifts.riftstruct.fill','values',[WaterEnum(),AirEnum(),IceEnum(),MelangeEnum()])
+			for i,rift in enumerate(self.riftstruct):
+				md = checkfield(md,"rifts.riftstruct[%d]['fill']" % i,'values',[WaterEnum(),AirEnum(),IceEnum(),MelangeEnum()])
 		else:
-			if numpy.any(numpy.logical_not(isnans(self.riftstruct))):
-				md.checkmessage("riftstruct shoud be NaN since numrifts is 0!")
+			if self.riftstruct and numpy.any(numpy.logical_not(isnans(self.riftstruct))):
+				md.checkmessage("riftstruct should be NaN since numrifts is 0!")
 
 		return md
 	# }}}
@@ -69,20 +70,20 @@
 			numrifts=len(self.riftstruct)
 
 		numpairs=0
-		for i in xrange(0,numrifts):
-			numpairs+=numpy.size(self.riftstruct[i].penaltypairs,0)
+		for rift in self.riftstruct:
+			numpairs+=numpy.size(rift['penaltypairs'],axis=0)
 
 		# 2 for nodes + 2 for elements+ 2 for  normals + 1 for length + 1 for fill + 1 for friction + 1 for fraction + 1 for fractionincrement + 1 for state.
 		data=numpy.zeros((numpairs,12))
 		count=0
-		for i in xrange(0,numrifts):
-			numpairsforthisrift=numpy.size(self.riftstruct[i]['penaltypairs'],0)
-			data[count:count+numpairsforthisrift-1,0:6]=self.riftstruct[i]['penaltypairs']
-			data[count:count+numpairsforthisrift-1,7]=self.riftstruct[i]['fill']
-			data[count:count+numpairsforthisrift-1,8]=self.riftstruct[i]['friction']
-			data[count:count+numpairsforthisrift-1,9]=self.riftstruct[i]['fraction']
-			data[count:count+numpairsforthisrift-1,10]=self.riftstruct[i]['fractionincrement']
-			data[count:count+numpairsforthisrift-1,11]=self.riftstruct[i]['state']
+		for rift in self.riftstruct:
+			numpairsforthisrift=numpy.size(rift['penaltypairs'],0)
+			data[count:count+numpairsforthisrift,0:7]=rift['penaltypairs']
+			data[count:count+numpairsforthisrift,7]=rift['fill']
+			data[count:count+numpairsforthisrift,8]=rift['friction']
+			data[count:count+numpairsforthisrift,9]=rift['fraction']
+			data[count:count+numpairsforthisrift,10]=rift['fractionincrement']
+			data[count:count+numpairsforthisrift,11]=rift['state'].reshape(-1)
 			count+=numpairsforthisrift
 
 		WriteData(fid,'data',numrifts,'enum',RiftsNumriftsEnum(),'format','Integer')

Modified: issm/trunk/src/m/classes/solver.m
===================================================================
--- issm/trunk/src/m/classes/solver.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/solver.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -97,7 +97,7 @@
 						 fprintf(fid,'-%s\n',optionname);
 					 else
 						 %option with value. value can be string or scalar
-						 if isscalar(optionvalue),
+						 if isnumeric(optionvalue),
 							 fprintf(fid,'-%s %g\n',optionname,optionvalue);
 						 elseif ischar(optionvalue),
 							 fprintf(fid,'-%s %s\n',optionname,optionvalue);

Modified: issm/trunk/src/m/classes/surfaceforcings.m
===================================================================
--- issm/trunk/src/m/classes/surfaceforcings.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/surfaceforcings.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,6 +11,8 @@
 		issmbgradients = 0;
 		isdelta18o = 0;
 		hc = NaN;
+		href = NaN;
+		smbref = NaN;
 		smb_pos_max = NaN;
 		smb_pos_min = NaN;
 		a_pos = NaN;
@@ -34,7 +36,7 @@
 			end
 		end % }}}
 		function obj = setdefaultparameters(obj) % {{{
-		  
+
 		  %pdd method not used in default mode
 		  obj.ispdd=0;
 		  obj.issmbgradients=0;
@@ -59,6 +61,8 @@
 					end
 				elseif(obj.issmbgradients)
 					md = checkfield(md,'surfaceforcings.hc','forcing',1,'NaN',1);
+					md = checkfield(md,'surfaceforcings.href','forcing',1,'NaN',1);
+					md = checkfield(md,'surfaceforcings.smbref','forcing',1,'NaN',1);
 					md = checkfield(md,'surfaceforcings.smb_pos_max','forcing',1,'NaN',1);
 					md = checkfield(md,'surfaceforcings.smb_pos_min','forcing',1,'NaN',1);
 					md = checkfield(md,'surfaceforcings.a_pos','forcing',1,'NaN',1);
@@ -88,6 +92,8 @@
 			fielddisplay(obj,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated');
 			fielddisplay(obj,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)');
 			fielddisplay(obj,'hc',' elevation of intersection between accumulation and ablation regime required if smb gradients is activated');
+			fielddisplay(obj,'href',' reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method');
+			fielddisplay(obj,'smbref',' reference smb from which deviation is calculated in smb gradients method');
 			fielddisplay(obj,'smb_pos_max',' maximum value of positive smb required if smb gradients is activated');
 			fielddisplay(obj,'smb_pos_min',' minimum value of positive smb required if smb gradients is activated');
 			fielddisplay(obj,'a_pos',' intercept of hs - smb regression line for accumulation regime required if smb gradients is activated');
@@ -116,6 +122,8 @@
 			WriteData(fid,'object',obj,'fieldname','issmbgradients','format','Boolean');
 			if obj.issmbgradients,
 				WriteData(fid,'object',obj,'fieldname','hc','format','DoubleMat','mattype',1);
+				WriteData(fid,'object',obj,'fieldname','href','format','DoubleMat','mattype',1);
+				WriteData(fid,'object',obj,'fieldname','smbref','format','DoubleMat','mattype',1);
 				WriteData(fid,'object',obj,'fieldname','smb_pos_max','format','DoubleMat','mattype',1);
 				WriteData(fid,'object',obj,'fieldname','smb_pos_min','format','DoubleMat','mattype',1);
 				WriteData(fid,'object',obj,'fieldname','a_pos','format','DoubleMat','mattype',1);

Modified: issm/trunk/src/m/classes/surfaceforcings.py
===================================================================
--- issm/trunk/src/m/classes/surfaceforcings.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/surfaceforcings.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,6 +21,8 @@
 		self.issmbgradients = 0
 		self.isdelta18o = 0
 		self.hc = float('NaN')
+		self.href = float('NaN')
+		self.smbref = float('NaN')
 		self.smb_pos_max = float('NaN')
 		self.smb_pos_min = float('NaN')
 		self.a_pos = float('NaN')
@@ -55,6 +57,8 @@
 		string="%s\n%s"%(string,fielddisplay(self,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated'))
 		string="%s\n%s"%(string,fielddisplay(self,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)'))
 		string="%s\n%s"%(string,fielddisplay(self,'hc',' elevation of intersection between accumulation and ablation regime required if smb gradients is activated'))
+		string="%s\n%s"%(string,fielddisplay(self,'href',' reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method'))
+		string="%s\n%s"%(string,fielddisplay(self,'smbref',' reference smb from which deviation is calculated in smb gradients method'))
 		string="%s\n%s"%(string,fielddisplay(self,'smb_pos_max',' maximum value of positive smb required if smb gradients is activated'))
 		string="%s\n%s"%(string,fielddisplay(self,'smb_pos_min',' minimum value of positive smb required if smb gradients is activated'))
 		string="%s\n%s"%(string,fielddisplay(self,'a_pos',' intercept of hs - smb regression line for accumulation regime required if smb gradients is activated'))
@@ -93,6 +97,8 @@
 					md = checkfield(md,'surfaceforcings.precipitations_presentday','size',[md.mesh.numberofvertices+1,12],'NaN',1)
 			elif self.issmbgradients:
 				md = checkfield(md,'surfaceforcings.hc','forcing',1,'NaN',1)
+				md = checkfield(md,'surfaceforcings.href','forcing',1,'NaN',1)
+				md = checkfield(md,'surfaceforcings.smbref','forcing',1,'NaN',1)
 				md = checkfield(md,'surfaceforcings.smb_pos_max','forcing',1,'NaN',1)
 				md = checkfield(md,'surfaceforcings.smb_pos_min','forcing',1,'NaN',1)
 				md = checkfield(md,'surfaceforcings.a_pos','forcing',1,'NaN',1)
@@ -129,6 +135,8 @@
 
 		if self.issmbgradients:
 			WriteData(fid,'object',self,'fieldname','hc','format','DoubleMat','mattype',1)
+			WriteData(fid,'object',self,'fieldname','href','format','DoubleMat','mattype',1)
+			WriteData(fid,'object',self,'fieldname','smbref','format','DoubleMat','mattype',1)
 			WriteData(fid,'object',self,'fieldname','smb_pos_max','format','DoubleMat','mattype',1)
 			WriteData(fid,'object',self,'fieldname','smb_pos_min','format','DoubleMat','mattype',1)
 			WriteData(fid,'object',self,'fieldname','a_pos','format','DoubleMat','mattype',1)

Modified: issm/trunk/src/m/classes/thermal.m
===================================================================
--- issm/trunk/src/m/classes/thermal.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/thermal.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -46,8 +46,10 @@
 
 			md = checkfield(md,'thermal.stabilization','numel',[1],'values',[0 1 2]);
 			md = checkfield(md,'thermal.spctemperature','forcing',1);
-			if (ismember(EnthalpyAnalysisEnum(),analyses) & md.thermal.isenthalpy & md.mesh.dimension==3),
-				md = checkfield(md,'thermal.spctemperature','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*(md.geometry.surface-md.mesh.z),'message','spctemperature should be below the adjusted melting point');
+			if (ismember(EnthalpyAnalysisEnum(),analyses) & (md.thermal.isenthalpy | solution==EnthalpySolutionEnum()) & md.mesh.dimension==3),
+				pos=find(md.thermal.spctemperature(1:md.mesh.numberofvertices,:)~=NaN);
+				replicate=repmat(md.geometry.surface-md.mesh.z,1,size(md.thermal.spctemperature,2));
+				md = checkfield(md,'thermal.spctemperature(find(md.thermal.spctemperature(1:md.mesh.numberofvertices,:)~=NaN))','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*replicate(pos),'message','spctemperature should be below the adjusted melting point');
 				md = checkfield(md,'thermal.isenthalpy','numel',[1],'values',[0 1]);
 			end
 		end % }}}

Modified: issm/trunk/src/m/classes/thermal.py
===================================================================
--- issm/trunk/src/m/classes/thermal.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/thermal.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,5 @@
 #module imports
+import numpy
 from fielddisplay import fielddisplay
 from EnumDefinitions import *
 from checkfield import *
@@ -68,8 +69,10 @@
 
 		md = checkfield(md,'thermal.stabilization','numel',[1],'values',[0,1,2])
 		md = checkfield(md,'thermal.spctemperature','forcing',1)
-		if EnthalpyAnalysisEnum() in analyses and md.thermal.isenthalpy and md.mesh.dimension==3:
-			md = checkfield(md,'thermal.spctemperature','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*(md.geometry.surface-md.mesh.z),'message',"spctemperature should be below the adjusted melting point")
+		if EnthalpyAnalysisEnum() in analyses and (md.thermal.isenthalpy or solution==EnthalpySolutionEnum()) and md.mesh.dimension==3:
+			pos=numpy.nonzero(numpy.logical_not(numpy.isnan(md.thermal.spctemperature[0:md.mesh.numberofvertices])))
+			replicate=numpy.tile(md.geometry.surface-md.mesh.z,(1,numpy.size(md.thermal.spctemperature,axis=1)))
+			md = checkfield(md,'thermal.spctemperature[numpy.nonzero(numpy.logical_not(numpy.isnan(md.thermal.spctemperature[0:md.mesh.numberofvertices,:])))]','<',md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*replicate[pos],'message',"spctemperature should be below the adjusted melting point")
 			md = checkfield(md,'thermal.isenthalpy','numel',[1],'values',[0,1])
 
 		return md

Modified: issm/trunk/src/m/classes/verbose.m
===================================================================
--- issm/trunk/src/m/classes/verbose.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/verbose.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,6 +8,7 @@
 %      convergence : convergence criteria
 %      control     : control method
 %      qmu         : sensitivity analysis
+%      autodiff    : AD analysis
 %
 %   Usage:
 %      verbose=verbose();
@@ -22,13 +23,14 @@
 	properties (SetAccess=public) 
 		% {{{
 		%BEGINFIELDS
-		mprocessor  = false;
-		module      = false;
-		solution    = false;
-		solver      = false;
-		convergence = false;
-		control     = false;
-		qmu         = false;
+		mprocessor=false;
+		module=false;
+		solution=false;
+		solver=false;
+		convergence=false;
+		control=false;
+		qmu=false;
+		autodiff=false;
 		%ENDFIELDS
 		% }}}
 	end
@@ -82,6 +84,7 @@
 		if (verbose.convergence), binary=bitor(binary,16); end
 		if (verbose.control), binary=bitor(binary,32); end
 		if (verbose.qmu), binary=bitor(binary,64); end
+		if (verbose.autodiff), binary=bitor(binary,128); end
 		%ENDVERB2BIN
 
 		end
@@ -89,13 +92,14 @@
 		function verbose=BinaryToVerbose(verbose,binary) % {{{
 
 		%BEGINBIN2VERB
-		verbose.mprocessor =logical(bitand(binary, 1));
-		verbose.module     =logical(bitand(binary, 2));
-		verbose.solution   =logical(bitand(binary, 4));
-		verbose.solver     =logical(bitand(binary, 8));
-		verbose.convergence=logical(bitand(binary,16));
-		verbose.control    =logical(bitand(binary,32));
-		verbose.qmu        =logical(bitand(binary,64));
+		if bitand(binary,1), verbose.mprocessor=true; else verbose.mprocessor=false; end
+		if bitand(binary,2), verbose.module=true; else verbose.module=false; end
+		if bitand(binary,4), verbose.solution=true; else verbose.solution=false; end
+		if bitand(binary,8), verbose.solver=true; else verbose.solver=false; end
+		if bitand(binary,16), verbose.convergence=true; else verbose.convergence=false; end
+		if bitand(binary,32), verbose.control=true; else verbose.control=false; end
+		if bitand(binary,64), verbose.qmu=true; else verbose.qmu=false; end
+		if bitand(binary,128), verbose.autodiff=true; else verbose.autodiff=false; end
 		%ENDBIN2VERB
 
 		end
@@ -104,7 +108,7 @@
 
 		end % }}}
 		function disp(verbose) % {{{
-			
+
 		%BEGINDISP
 		disp(sprintf('class ''%s''  = ',class(verbose)));
 		disp(sprintf('   %15s : %s','mprocessor',mat2str(verbose.mprocessor)));
@@ -114,6 +118,7 @@
 		disp(sprintf('   %15s : %s','convergence',mat2str(verbose.convergence)));
 		disp(sprintf('   %15s : %s','control',mat2str(verbose.control)));
 		disp(sprintf('   %15s : %s','qmu',mat2str(verbose.qmu)));
+		disp(sprintf('   %15s : %s','autodiff',mat2str(verbose.autodiff)));
 		%ENDDISP
 
 		end

Modified: issm/trunk/src/m/classes/verbose.py
===================================================================
--- issm/trunk/src/m/classes/verbose.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/classes/verbose.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,6 +15,7 @@
 	      convergence : convergence criteria
 	      control     : control method
 	      qmu         : sensitivity analysis
+	      autodiff    : AD analysis
 
 	   Usage:
 	      verbose=verbose();
@@ -35,6 +36,7 @@
 		self.convergence = False
 		self.control     = False
 		self.qmu         = False
+		self.autodiff    = False
 		#ENDFIELDS
 
 		if not len(args):
@@ -60,13 +62,30 @@
 
 			#Cast to logicals
 			listproperties=vars(self)
-			for [fieldname,fieldvalue] in listproperties.iteritems():
+			for fieldname,fieldvalue in listproperties.iteritems():
 				if isinstance(fieldvalue,bool) or isinstance(fieldvalue,(int,long,float)):
 					setattr(self,fieldname,bool(fieldvalue))
 				else:
 					raise TypeError("verbose supported field values are logicals only (True or False)")
 	# }}}
 
+	def __repr__(self):    # {{{
+			
+		#BEGINDISP
+		s ="class '%s'  = \n" % type(self)
+		s+="   %15s : %s\n" % ('mprocessor',self.mprocessor)
+		s+="   %15s : %s\n" % ('module',self.module)
+		s+="   %15s : %s\n" % ('solution',self.solution)
+		s+="   %15s : %s\n" % ('solver',self.solver)
+		s+="   %15s : %s\n" % ('convergence',self.convergence)
+		s+="   %15s : %s\n" % ('control',self.control)
+		s+="   %15s : %s\n" % ('qmu',self.qmu)
+		s+="   %15s : %s\n" % ('autodiff',self.autodiff)
+		#ENDDISP
+
+		return s
+	# }}}
+
 	def VerboseToBinary(self):    # {{{
 
 		#BEGINVERB2BIN
@@ -85,6 +104,8 @@
 			binary=binary | 32
 		if self.qmu:
 			binary=binary | 64
+		if self.autodiff:
+			binary=binary | 128
 		#ENDVERB2BIN
 
 		return binary
@@ -93,13 +114,14 @@
 	def BinaryToVerbose(self,binary):    # {{{
 
 		#BEGINBIN2VERB
-		self.mprocessor =bool(binary &  1)
-		self.module     =bool(binary &  2)
-		self.solution   =bool(binary &  4)
-		self.solver     =bool(binary &  8)
-		self.convergence=bool(binary & 16)
-		self.control    =bool(binary & 32)
-		self.qmu        =bool(binary & 64)
+		self.mprocessor =bool(binary &   1)
+		self.module     =bool(binary &   2)
+		self.solution   =bool(binary &   4)
+		self.solver     =bool(binary &   8)
+		self.convergence=bool(binary &  16)
+		self.control    =bool(binary &  32)
+		self.qmu        =bool(binary &  64)
+		self.autodiff   =bool(binary & 128)
 		#ENDBIN2VERB
 	# }}}
 
@@ -107,23 +129,7 @@
 		return md
 	# }}}
 
-	def __repr__(self):    # {{{
-			
-		#BEGINDISP
-		s ="class '%s'  = \n" % type(self)
-		s+="   %15s : %s\n" % ('mprocessor',self.mprocessor)
-		s+="   %15s : %s\n" % ('module',self.module)
-		s+="   %15s : %s\n" % ('solution',self.solution)
-		s+="   %15s : %s\n" % ('solver',self.solver)
-		s+="   %15s : %s\n" % ('convergence',self.convergence)
-		s+="   %15s : %s\n" % ('control',self.control)
-		s+="   %15s : %s\n" % ('qmu',self.qmu)
-		#ENDDISP
-
-		return s
-	# }}}
-
 	def marshall(self,fid):    # {{{
-			WriteData(fid,'data',self.VerboseToBinary(),'enum',VerboseEnum(),'format','Integer')
+		WriteData(fid,'data',self.VerboseToBinary(),'enum',VerboseEnum(),'format','Integer')
 	# }}}
 

Modified: issm/trunk/src/m/consistency/ismodelselfconsistent.m
===================================================================
--- issm/trunk/src/m/consistency/ismodelselfconsistent.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/consistency/ismodelselfconsistent.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -27,11 +27,7 @@
 	end
 
 	%Check consistency of the object
-	if verLessThan('matlab', '7.6')
-		md=checkconsistency(md.(field),md,solution,analyses);
-	else
-		md=md.(field).checkconsistency(md,solution,analyses);
-	end
+	md=checkconsistency(md.(field),md,solution,analyses);
 end
 
 %error message if mode is not consistent
@@ -46,8 +42,6 @@
 %   Usage:
 %      [analyses, numanalyses]=AnalysisConfiguration(solutiontype);
 
-
-
 switch solutiontype,
 
 	case DiagnosticSolutionEnum(),

Modified: issm/trunk/src/m/contrib/bamg/YamsCall.m
===================================================================
--- issm/trunk/src/m/contrib/bamg/YamsCall.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/contrib/bamg/YamsCall.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -52,10 +52,10 @@
 fprintf(fid,'\n\n%s\n%i\n\n','Triangles',md.mesh.numberofelements);
 fprintf(fid,'%i %i %i %i\n',[md.mesh.elements zeros(md.mesh.numberofelements,1)]');
 numberofelements1=md.mesh.numberofelements;
-	
+
 %Deal with rifts
 if ~isnan(md.rifts.riftstruct),
-	
+
 	%we have the list of triangles that make up the rift. keep those triangles around during refinement.
 	triangles=[];
 	for i=1:size(md.rifts.riftstruct,1),

Modified: issm/trunk/src/m/contrib/bamg/meshread.m
===================================================================
--- issm/trunk/src/m/contrib/bamg/meshread.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/contrib/bamg/meshread.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function Struct=meshread(filename);
+function Struct=meshread(filename)
 
 %some checks
 if ~exist(filename),

Modified: issm/trunk/src/m/contrib/bamg/yams.m
===================================================================
--- issm/trunk/src/m/contrib/bamg/yams.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/contrib/bamg/yams.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function md=yams(md,varargin);
+function md=yams(md,varargin)
 %MESHYAMS - Build model of Antarctica by refining according to observed velocity error estimator
 %
 %   Usage:
@@ -101,7 +101,7 @@
 	end
 
 end
-	
+
 disp(['Final mesh, number of elements: ' num2str(md.mesh.numberofelements)]);
 
 %Now, build the connectivity tables for this mesh.

Modified: issm/trunk/src/m/contrib/gslib/gamv.m
===================================================================
--- issm/trunk/src/m/contrib/gslib/gamv.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/contrib/gslib/gamv.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function output = gamv(x,y,data,varargin);
+function output = gamv(x,y,data,varargin)
 %GAMV - use gslib for Kriging
 %
 %   Usage:

Modified: issm/trunk/src/m/contrib/gslib/gslib.m
===================================================================
--- issm/trunk/src/m/contrib/gslib/gslib.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/contrib/gslib/gslib.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function output = gslib(x,y,data,varargin);
+function output = gslib(x,y,data,varargin)
 %GSLIB - use gslib for Kriging
 %
 %   Usage:

Modified: issm/trunk/src/m/contrib/gslib/pkriging.m
===================================================================
--- issm/trunk/src/m/contrib/gslib/pkriging.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/contrib/gslib/pkriging.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [B E]=pkriging(x,y,observations,x_interp,y_interp,varargin);
+function [B E]=pkriging(x,y,observations,x_interp,y_interp,varargin)
 %PKRIGING - parallel Kriging
 %
 %   Usage:

Modified: issm/trunk/src/m/contrib/gslib/varmap.m
===================================================================
--- issm/trunk/src/m/contrib/gslib/varmap.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/contrib/gslib/varmap.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function output = varmap(x,y,data,varargin);
+function output = varmap(x,y,data,varargin)
 %VARMAP - use gslib for Kriging
 %
 %   Usage:

Modified: issm/trunk/src/m/contrib/hack/tres.m
===================================================================
--- issm/trunk/src/m/contrib/hack/tres.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/contrib/hack/tres.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,17 +21,11 @@
 	if isfield(md.results.DiagnosticSolution,'Pressure'),
 		md.initialization.pressure=md.results.DiagnosticSolution.Pressure;
 	end
-	if md.rifts.numrifts,
+	if ~isempty(md.rifts.riftstruct),
 		if isfield(md.results.DiagnosticSolution,'riftproperties'),
 			md.rifts.riftproperties=md.results.DiagnosticSolution.riftproperties;
 		end
 	end
-	if md.inversion.iscontrol==1,
-		for control_parameters=md.inversion.control_parameters
-			%Will need to be updated... good luck ;)
-			md.(EnumToModelField(control_parameters))=md.results.DiagnosticSolution.(EnumToString(control_parameters));
-		end
-	end
 
 elseif strcmpi(string,'dakota'),
 	md.qmu.results=md.results.dakota;

Modified: issm/trunk/src/m/contrib/massbalance/outflow.m
===================================================================
--- issm/trunk/src/m/contrib/massbalance/outflow.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/contrib/massbalance/outflow.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function flag=outflow(md);
+function flag=outflow(md)
 %OUTFLOW - flag nodes on outflux boundary
 %
 %   Usage:

Modified: issm/trunk/src/m/contrib/uci/expremovestraightsegments.m
===================================================================
--- issm/trunk/src/m/contrib/uci/expremovestraightsegments.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/contrib/uci/expremovestraightsegments.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,10 +10,10 @@
 
 for i=1:length(a),
 	contour=a(i);
-	
+
 	s=sqrt(contour.x.^2+contour.y.^2);
 	d=diff(s);
-	
+
 	pos=find(abs(d)>cutoff);
 	pos=[0;pos;length(contour.x)];
 

Modified: issm/trunk/src/m/enum/EnumDefinitions.py
===================================================================
--- issm/trunk/src/m/enum/EnumDefinitions.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/enum/EnumDefinitions.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,36 +18,66 @@
 
 	return StringToEnum('AutodiffIsautodiff')[0]
 
-def AutodiffDependentsEnum():
+def AutodiffNumDependentsEnum():
 	"""
-	AUTODIFFDEPENDENTSENUM - Enum of AutodiffDependents
+	AUTODIFFNUMDEPENDENTSENUM - Enum of AutodiffNumDependents
 
 	   Usage:
-	      macro=AutodiffDependentsEnum()
+	      macro=AutodiffNumDependentsEnum()
 	"""
 
-	return StringToEnum('AutodiffDependents')[0]
+	return StringToEnum('AutodiffNumDependents')[0]
 
-def AutodiffNumDependentsEnum():
+def AutodiffNumDependentObjectsEnum():
 	"""
-	AUTODIFFNUMDEPENDENTSENUM - Enum of AutodiffNumDependents
+	AUTODIFFNUMDEPENDENTOBJECTSENUM - Enum of AutodiffNumDependentObjects
 
 	   Usage:
-	      macro=AutodiffNumDependentsEnum()
+	      macro=AutodiffNumDependentObjectsEnum()
 	"""
 
-	return StringToEnum('AutodiffNumDependents')[0]
+	return StringToEnum('AutodiffNumDependentObjects')[0]
 
-def AutodiffIndependentsEnum():
+def AutodiffDependentObjectNamesEnum():
 	"""
-	AUTODIFFINDEPENDENTSENUM - Enum of AutodiffIndependents
+	AUTODIFFDEPENDENTOBJECTNAMESENUM - Enum of AutodiffDependentObjectNames
 
 	   Usage:
-	      macro=AutodiffIndependentsEnum()
+	      macro=AutodiffDependentObjectNamesEnum()
 	"""
 
-	return StringToEnum('AutodiffIndependents')[0]
+	return StringToEnum('AutodiffDependentObjectNames')[0]
 
+def AutodiffDependentObjectTypesEnum():
+	"""
+	AUTODIFFDEPENDENTOBJECTTYPESENUM - Enum of AutodiffDependentObjectTypes
+
+	   Usage:
+	      macro=AutodiffDependentObjectTypesEnum()
+	"""
+
+	return StringToEnum('AutodiffDependentObjectTypes')[0]
+
+def AutodiffDependentObjectIndicesEnum():
+	"""
+	AUTODIFFDEPENDENTOBJECTINDICESENUM - Enum of AutodiffDependentObjectIndices
+
+	   Usage:
+	      macro=AutodiffDependentObjectIndicesEnum()
+	"""
+
+	return StringToEnum('AutodiffDependentObjectIndices')[0]
+
+def AutodiffDependentObjectsEnum():
+	"""
+	AUTODIFFDEPENDENTOBJECTSENUM - Enum of AutodiffDependentObjects
+
+	   Usage:
+	      macro=AutodiffDependentObjectsEnum()
+	"""
+
+	return StringToEnum('AutodiffDependentObjects')[0]
+
 def AutodiffNumIndependentsEnum():
 	"""
 	AUTODIFFNUMINDEPENDENTSENUM - Enum of AutodiffNumIndependents
@@ -58,6 +88,46 @@
 
 	return StringToEnum('AutodiffNumIndependents')[0]
 
+def AutodiffNumIndependentObjectsEnum():
+	"""
+	AUTODIFFNUMINDEPENDENTOBJECTSENUM - Enum of AutodiffNumIndependentObjects
+
+	   Usage:
+	      macro=AutodiffNumIndependentObjectsEnum()
+	"""
+
+	return StringToEnum('AutodiffNumIndependentObjects')[0]
+
+def AutodiffIndependentObjectNamesEnum():
+	"""
+	AUTODIFFINDEPENDENTOBJECTNAMESENUM - Enum of AutodiffIndependentObjectNames
+
+	   Usage:
+	      macro=AutodiffIndependentObjectNamesEnum()
+	"""
+
+	return StringToEnum('AutodiffIndependentObjectNames')[0]
+
+def AutodiffIndependentObjectTypesEnum():
+	"""
+	AUTODIFFINDEPENDENTOBJECTTYPESENUM - Enum of AutodiffIndependentObjectTypes
+
+	   Usage:
+	      macro=AutodiffIndependentObjectTypesEnum()
+	"""
+
+	return StringToEnum('AutodiffIndependentObjectTypes')[0]
+
+def AutodiffIndependentObjectsEnum():
+	"""
+	AUTODIFFINDEPENDENTOBJECTSENUM - Enum of AutodiffIndependentObjects
+
+	   Usage:
+	      macro=AutodiffIndependentObjectsEnum()
+	"""
+
+	return StringToEnum('AutodiffIndependentObjects')[0]
+
 def AutodiffJacobianEnum():
 	"""
 	AUTODIFFJACOBIANENUM - Enum of AutodiffJacobian
@@ -78,16 +148,66 @@
 
 	return StringToEnum('AutodiffXp')[0]
 
-def AutodiffFosForwardOutputEnum():
+def AutodiffDriverEnum():
 	"""
-	AUTODIFFFOSFORWARDOUTPUTENUM - Enum of AutodiffFosForwardOutput
+	AUTODIFFDRIVERENUM - Enum of AutodiffDriver
 
 	   Usage:
-	      macro=AutodiffFosForwardOutputEnum()
+	      macro=AutodiffDriverEnum()
 	"""
 
-	return StringToEnum('AutodiffFosForwardOutput')[0]
+	return StringToEnum('AutodiffDriver')[0]
 
+def AutodiffFosForwardIndexEnum():
+	"""
+	AUTODIFFFOSFORWARDINDEXENUM - Enum of AutodiffFosForwardIndex
+
+	   Usage:
+	      macro=AutodiffFosForwardIndexEnum()
+	"""
+
+	return StringToEnum('AutodiffFosForwardIndex')[0]
+
+def AutodiffFovForwardIndicesEnum():
+	"""
+	AUTODIFFFOVFORWARDINDICESENUM - Enum of AutodiffFovForwardIndices
+
+	   Usage:
+	      macro=AutodiffFovForwardIndicesEnum()
+	"""
+
+	return StringToEnum('AutodiffFovForwardIndices')[0]
+
+def AutodiffFosReverseIndexEnum():
+	"""
+	AUTODIFFFOSREVERSEINDEXENUM - Enum of AutodiffFosReverseIndex
+
+	   Usage:
+	      macro=AutodiffFosReverseIndexEnum()
+	"""
+
+	return StringToEnum('AutodiffFosReverseIndex')[0]
+
+def AutodiffMassFluxSegmentsPresentEnum():
+	"""
+	AUTODIFFMASSFLUXSEGMENTSPRESENTENUM - Enum of AutodiffMassFluxSegmentsPresent
+
+	   Usage:
+	      macro=AutodiffMassFluxSegmentsPresentEnum()
+	"""
+
+	return StringToEnum('AutodiffMassFluxSegmentsPresent')[0]
+
+def AutodiffKeepEnum():
+	"""
+	AUTODIFFKEEPENUM - Enum of AutodiffKeep
+
+	   Usage:
+	      macro=AutodiffKeepEnum()
+	"""
+
+	return StringToEnum('AutodiffKeep')[0]
+
 def BalancethicknessSpcthicknessEnum():
 	"""
 	BALANCETHICKNESSSPCTHICKNESSENUM - Enum of BalancethicknessSpcthickness
@@ -198,6 +318,16 @@
 
 	return StringToEnum('ConstantsYts')[0]
 
+def DependentObjectEnum():
+	"""
+	DEPENDENTOBJECTENUM - Enum of DependentObject
+
+	   Usage:
+	      macro=DependentObjectEnum()
+	"""
+
+	return StringToEnum('DependentObject')[0]
+
 def DiagnosticAbstolEnum():
 	"""
 	DIAGNOSTICABSTOLENUM - Enum of DiagnosticAbstol
@@ -588,6 +718,16 @@
 
 	return StringToEnum('HydrologyStabilization')[0]
 
+def IndependentObjectEnum():
+	"""
+	INDEPENDENTOBJECTENUM - Enum of IndependentObject
+
+	   Usage:
+	      macro=IndependentObjectEnum()
+	"""
+
+	return StringToEnum('IndependentObject')[0]
+
 def InversionControlParametersEnum():
 	"""
 	INVERSIONCONTROLPARAMETERSENUM - Enum of InversionControlParameters
@@ -1318,6 +1458,26 @@
 
 	return StringToEnum('PrognosticVertexPairing')[0]
 
+def PrognosticNumRequestedOutputsEnum():
+	"""
+	PROGNOSTICNUMREQUESTEDOUTPUTSENUM - Enum of PrognosticNumRequestedOutputs
+
+	   Usage:
+	      macro=PrognosticNumRequestedOutputsEnum()
+	"""
+
+	return StringToEnum('PrognosticNumRequestedOutputs')[0]
+
+def PrognosticRequestedOutputsEnum():
+	"""
+	PROGNOSTICREQUESTEDOUTPUTSENUM - Enum of PrognosticRequestedOutputs
+
+	   Usage:
+	      macro=PrognosticRequestedOutputsEnum()
+	"""
+
+	return StringToEnum('PrognosticRequestedOutputs')[0]
+
 def QmuIsdakotaEnum():
 	"""
 	QMUISDAKOTAENUM - Enum of QmuIsdakota
@@ -1328,16 +1488,36 @@
 
 	return StringToEnum('QmuIsdakota')[0]
 
-def QmuMassFluxSegmentsEnum():
+def MassFluxSegmentsEnum():
 	"""
-	QMUMASSFLUXSEGMENTSENUM - Enum of QmuMassFluxSegments
+	MASSFLUXSEGMENTSENUM - Enum of MassFluxSegments
 
 	   Usage:
-	      macro=QmuMassFluxSegmentsEnum()
+	      macro=MassFluxSegmentsEnum()
 	"""
 
-	return StringToEnum('QmuMassFluxSegments')[0]
+	return StringToEnum('MassFluxSegments')[0]
 
+def MassFluxSegmentsPresentEnum():
+	"""
+	MASSFLUXSEGMENTSPRESENTENUM - Enum of MassFluxSegmentsPresent
+
+	   Usage:
+	      macro=MassFluxSegmentsPresentEnum()
+	"""
+
+	return StringToEnum('MassFluxSegmentsPresent')[0]
+
+def QmuMassFluxSegmentsPresentEnum():
+	"""
+	QMUMASSFLUXSEGMENTSPRESENTENUM - Enum of QmuMassFluxSegmentsPresent
+
+	   Usage:
+	      macro=QmuMassFluxSegmentsPresentEnum()
+	"""
+
+	return StringToEnum('QmuMassFluxSegmentsPresent')[0]
+
 def QmuNumberofpartitionsEnum():
 	"""
 	QMUNUMBEROFPARTITIONSENUM - Enum of QmuNumberofpartitions
@@ -1678,6 +1858,26 @@
 
 	return StringToEnum('SurfaceforcingsHc')[0]
 
+def SurfaceforcingsHrefEnum():
+	"""
+	SURFACEFORCINGSHREFENUM - Enum of SurfaceforcingsHref
+
+	   Usage:
+	      macro=SurfaceforcingsHrefEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsHref')[0]
+
+def SurfaceforcingsSmbrefEnum():
+	"""
+	SURFACEFORCINGSSMBREFENUM - Enum of SurfaceforcingsSmbref
+
+	   Usage:
+	      macro=SurfaceforcingsSmbrefEnum()
+	"""
+
+	return StringToEnum('SurfaceforcingsSmbref')[0]
+
 def SurfaceforcingsSmbPosMaxEnum():
 	"""
 	SURFACEFORCINGSSMBPOSMAXENUM - Enum of SurfaceforcingsSmbPosMax
@@ -2538,6 +2738,16 @@
 
 	return StringToEnum('DoubleInput')[0]
 
+def DataSetParamEnum():
+	"""
+	DATASETPARAMENUM - Enum of DataSetParam
+
+	   Usage:
+	      macro=DataSetParamEnum()
+	"""
+
+	return StringToEnum('DataSetParam')[0]
+
 def DoubleMatArrayParamEnum():
 	"""
 	DOUBLEMATARRAYPARAMENUM - Enum of DoubleMatArrayParam
@@ -2828,6 +3038,16 @@
 
 	return StringToEnum('PentaP1Input')[0]
 
+def ProfilerEnum():
+	"""
+	PROFILERENUM - Enum of Profiler
+
+	   Usage:
+	      macro=ProfilerEnum()
+	"""
+
+	return StringToEnum('Profiler')[0]
+
 def MatrixParamEnum():
 	"""
 	MATRIXPARAMENUM - Enum of MatrixParam
@@ -4508,6 +4728,26 @@
 
 	return StringToEnum('OutputFilePointer')[0]
 
+def OutputFileNameEnum():
+	"""
+	OUTPUTFILENAMEENUM - Enum of OutputFileName
+
+	   Usage:
+	      macro=OutputFileNameEnum()
+	"""
+
+	return StringToEnum('OutputFileName')[0]
+
+def LockFileNameEnum():
+	"""
+	LOCKFILENAMEENUM - Enum of LockFileName
+
+	   Usage:
+	      macro=LockFileNameEnum()
+	"""
+
+	return StringToEnum('LockFileName')[0]
+
 def PetscOptionsAnalysesEnum():
 	"""
 	PETSCOPTIONSANALYSESENUM - Enum of PetscOptionsAnalyses
@@ -4756,5 +4996,5 @@
 	      macro=MaximumNumberOfEnums()
 	"""
 
-	return 474
+	return 498
 

Modified: issm/trunk/src/m/enum/MaximumNumberOfEnums.m
===================================================================
--- issm/trunk/src/m/enum/MaximumNumberOfEnums.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/enum/MaximumNumberOfEnums.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,4 +8,4 @@
 %   Usage:
 %      macro=MaximumNumberOfEnums()
 
-macro=474;
+macro=498;

Modified: issm/trunk/src/m/enum/OutputfilenameEnum.m
===================================================================
--- issm/trunk/src/m/enum/OutputfilenameEnum.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/enum/OutputfilenameEnum.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-function macro=OutputfilenameEnum()
-%OUTPUTFILENAMEENUM - Enum of Outputfilename
+function macro=OutputFileNameEnum()
+%OUTPUTFILENAMEENUM - Enum of OutputFileName
 %
 %   WARNING: DO NOT MODIFY THIS FILE
 %            this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh
 %            Please read src/c/EnumDefinitions/README for more information
 %
 %   Usage:
-%      macro=OutputfilenameEnum()
+%      macro=OutputFileNameEnum()
 
-macro=StringToEnum('Outputfilename');
+macro=StringToEnum('OutputFileName');

Modified: issm/trunk/src/m/exp/expcoarsen.m
===================================================================
--- issm/trunk/src/m/exp/expcoarsen.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/expcoarsen.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function expcoarsen(newfile,oldfile,resolution);
+function expcoarsen(newfile,oldfile,resolution)
 %EXPCOARSEN - coarsen an exp contour
 %
 %   This routine read an Argus file and remove points with respect to

Modified: issm/trunk/src/m/exp/expcontract.m
===================================================================
--- issm/trunk/src/m/exp/expcontract.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/expcontract.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,7 +6,6 @@
 %
 %   See also EXPMASTER, EXPDOC
 
-
 contour=expread(oldfile);
 num=numel(contour.x);
 

Modified: issm/trunk/src/m/exp/expcreatecontour.m
===================================================================
--- issm/trunk/src/m/exp/expcreatecontour.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/expcreatecontour.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function expcreatecontour(filename);
+function expcreatecontour(filename)
 %EXPCREATECONTOUR - create a contour from a list of points
 %
 %   expcreatecontour: from a list of (x,y) points (retrieve using ginput on an undetermined
@@ -33,4 +33,3 @@
 
 %write contour using expwrite
 expwrite(a,filename);
-

Modified: issm/trunk/src/m/exp/expcreateprofile.m
===================================================================
--- issm/trunk/src/m/exp/expcreateprofile.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/expcreateprofile.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function expcreateprofile(filename);
+function expcreateprofile(filename)
 %EXPCREATEPROFILE - create an Argus file from a list of points
 %
 %   expcreateprofile: from a list of (x,y) points (retrieve using ginput on an undetermined

Modified: issm/trunk/src/m/exp/expexcludeoutliers.m
===================================================================
--- issm/trunk/src/m/exp/expexcludeoutliers.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/expexcludeoutliers.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -7,7 +7,6 @@
 %
 %   See also EXPMASTER, EXPDOC
 
-
 contour=expread(contourname);
 
 for i=1:length(contour),

Modified: issm/trunk/src/m/exp/expflip.m
===================================================================
--- issm/trunk/src/m/exp/expflip.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/expflip.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,10 +5,6 @@
 %
 %
 
-
-
-
-
 a=expread(domainname,1);
 
 for i=1:length(a),

Modified: issm/trunk/src/m/exp/expll2xy.m
===================================================================
--- issm/trunk/src/m/exp/expll2xy.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/expll2xy.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,6 @@
 %      - sgn = Sign of latitude +1 : north latitude (default is mer=45 lat=70)
 %                               -1 : south latitude (default is mer=0  lat=71)
 
-
 %Get central_meridian and standard_parallel depending on hemisphere
 if nargin==4,
 	delta = central_meridian;

Modified: issm/trunk/src/m/exp/expread.m
===================================================================
--- issm/trunk/src/m/exp/expread.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/expread.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function Struct=expread(filename);
+function Struct=expread(filename)
 %EXPREAD - read a file exp and build a Structure
 %
 %   This routine reads a file .exp and build a Structure containing the 

Modified: issm/trunk/src/m/exp/expswapxy.m
===================================================================
--- issm/trunk/src/m/exp/expswapxy.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/expswapxy.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,7 +6,6 @@
 %
 %   See also EXPMASTER, EXPDOC
 
-
 contours=expread(filename,1);
 
 newcontours=contours(1);

Modified: issm/trunk/src/m/exp/exptool.m
===================================================================
--- issm/trunk/src/m/exp/exptool.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/exptool.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -307,7 +307,6 @@
 			backup{counter,3}=numpoints;
 			backup{counter,4}=closed;
 
-
 		case 12
 
 			[A,numprofiles,numpoints,closed]=closeprofile(A,numprofiles,numpoints,closed,prevplot,root,options);

Modified: issm/trunk/src/m/exp/expwrite.m
===================================================================
--- issm/trunk/src/m/exp/expwrite.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/expwrite.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function expwrite(a,filename);
+function expwrite(a,filename)
 %EXPWRITE - write an Argus file from a structure given in input
 %
 %   This routine write an Argus file form a structure containing the fields:
@@ -19,7 +19,7 @@
 	if(length(a(n).x)~=length(a(n).y)),
 		error('contours x and y coordinates must be of identical size');
 	end
-   
+
 	if isfield(a,'name'),
 		if ~isempty(a(n).name),
 			fprintf(fid,'%s%s\n','## Name:',a(n).name);
@@ -29,7 +29,7 @@
 	else
 		fprintf(fid,'%s\n','## Name:');
 	end
-   
+
 	fprintf(fid,'%s\n','## Icon:0');
 	fprintf(fid,'%s\n','# Points Count Value');
 	fprintf(fid,'%i %f\n',[length(a(n).x) a(n).density]);

Modified: issm/trunk/src/m/exp/expxy2ll.m
===================================================================
--- issm/trunk/src/m/exp/expxy2ll.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/expxy2ll.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,6 @@
 %      - sgn = Sign of latitude +1 : north latitude (default is mer=45 lat=70)
 %                               -1 : south latitude (default is mer=0  lat=71)
 
-
 %Get central_meridian and standard_parallel depending on hemisphere
 if nargin==4,
 	delta = central_meridian;

Modified: issm/trunk/src/m/exp/manipulation/addcontour.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/addcontour.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/addcontour.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=addcontour(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=addcontour(A,numprofiles,numpoints,closed,prevplot,root,options)
 %ADDCONTOUR - add a closed contour
 %
 %   this script is used by exptool as an elementary operation
@@ -6,7 +6,7 @@
 %
 %   Usage:
 %      [A,numprofiles,numpoints,closed]=addcontour(A,numprofiles,numpoints,closed,prevplot,root,options)
-		   
+
 	title('click to add a point to the new profile, RETURN to exit','FontSize',14)
 	hold on
 
@@ -17,7 +17,7 @@
 	while loop
 
 		[xi,yi] = ginput(1);
-					  
+
 		if ~isempty(xi)
 			x(end+1,1)=xi;
 			y(end+1,1)=yi;

Modified: issm/trunk/src/m/exp/manipulation/addendprofile.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/addendprofile.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/addendprofile.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=addendprofile(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=addendprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
 %ADDENDPROFILE - add point at the end of a n existing profile
 %
 %   this script is used by exptool as an elementary operation
@@ -6,7 +6,7 @@
 %
 %   Usage:
 %      [A,numprofiles,numpoints,closed]=addendprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
-		
+
 	%some checks
 	if numprofiles==0
 		disp('no profile present, exiting...')

Modified: issm/trunk/src/m/exp/manipulation/addinsideprofile.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/addinsideprofile.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/addinsideprofile.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=addinsideprofile(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=addinsideprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
 %ADDINSIDEPROFILE - add apoint inside a profile
 %
 %   this script is used by exptool as an elementary operation
@@ -6,7 +6,7 @@
 %
 %   Usage:
 %      [A,numprofiles,numpoints,closed]=addinsideprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
-		
+
 	%some checks
 	if numprofiles==0
 		disp('no profile present, exiting...')

Modified: issm/trunk/src/m/exp/manipulation/addprofile.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/addprofile.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/addprofile.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=addprofile(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=addprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
 %ADDPROFILE - add a profile
 %
 %   this script is used by exptool as an elementary operation
@@ -6,7 +6,7 @@
 %
 %   Usage:
 %      [A,numprofiles,numpoints,closed]=addprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
-		   
+
 	title('click to add a point to the new profile, RETURN to exit','FontSize',14)
 	hold on
 
@@ -17,7 +17,7 @@
 	while loop
 
 		[xi,yi] = ginput(1);
-					  
+
 		if ~isempty(xi)
 			x(end+1,1)=xi;
 			y(end+1,1)=yi;

Modified: issm/trunk/src/m/exp/manipulation/closeprofile.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/closeprofile.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/closeprofile.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=closeprofile(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=closeprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
 %CLOSEPROFILE - close one or several profile
 %
 %   this script is used by exptool as an elementary operation
@@ -12,7 +12,7 @@
 		disp('no profile to be closed')
 		return
 	end
-		   
+
 	title('click on the profiles to be closed, RETURN to exit','FontSize',14)
 	hold on
 
@@ -32,7 +32,7 @@
 		end
 
 		[xi,yi] = ginput(1);
-					  
+
 		if ~isempty(xi)
 
 			%get closest profile

Modified: issm/trunk/src/m/exp/manipulation/cutarea.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/cutarea.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/cutarea.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=cutarea(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=cutarea(A,numprofiles,numpoints,closed,prevplot,root,options)
 %CUTAREA - cut several point of a profile
 %
 %
@@ -9,7 +9,7 @@
 %
 %   Usage:
 %      [A,numprofiles,numpoints,closed]=cutarea(A,numprofiles,numpoints,closed,prevplot,root,options)
-		
+
 	hold on
 	loop=1;
 

Modified: issm/trunk/src/m/exp/manipulation/cutprofile.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/cutprofile.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/cutprofile.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
 %CUTPROFILE - cut a profile
 %
 %   this script is used by exptool as an elementary operation
@@ -6,7 +6,7 @@
 %
 %   Usage:
 %      [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
-		
+
 	%some checks
 	if numprofiles==0
 		disp('no profile present, exiting...')

Modified: issm/trunk/src/m/exp/manipulation/mergeprofiles.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/mergeprofiles.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/mergeprofiles.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=mergeprofiles(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=mergeprofiles(A,numprofiles,numpoints,closed,prevplot,root,options)
 %MERGEPROFILES - merge profiles
 %
 %   this script is used by exptool as an elementary operation

Modified: issm/trunk/src/m/exp/manipulation/modifyposition.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/modifyposition.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/modifyposition.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=modifyposition(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=modifyposition(A,numprofiles,numpoints,closed,prevplot,root,options)
 %MODIFYPOSITION - modify the prosition of a point of a profile
 %
 %   this script is used by exptool as an elementary operation
@@ -6,7 +6,7 @@
 %
 %   Usage:
 %      [A,numprofiles,numpoints,closed]=modifyposition(A,numprofiles,numpoints,closed,prevplot,root,options)
-		
+
 	%some checks
 	if numprofiles==0
 		disp('no profile present, exiting..')

Modified: issm/trunk/src/m/exp/manipulation/orientprofile.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/orientprofile.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/orientprofile.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=orientprofile(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=orientprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
 %ORIENTPROFILE - cahnge profile orientation
 %
 %   this script is used by exptool as an elementary operation
@@ -20,9 +20,9 @@
 			disp('no profile to be reoriented, exiting...')
 			return
 		end
-		   
+
 		[xi,yi] = ginput(1);
-					  
+
 		if ~isempty(xi)
 
 			%get closest profile

Modified: issm/trunk/src/m/exp/manipulation/removepoints.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/removepoints.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/removepoints.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=removepoints(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=removepoints(A,numprofiles,numpoints,closed,prevplot,root,options)
 %REMOVEPOINTS - remove a point from a profile
 %
 %   this script is used by exptool as an elementary operation
@@ -6,7 +6,7 @@
 %
 %   Usage:
 %      [A,numprofiles,numpoints,closed]=removepoints(A,numprofiles,numpoints,closed,prevplot,root,options)
-		
+
 	%some checks
 	if numprofiles==0
 		disp('no profile present, exiting...')

Modified: issm/trunk/src/m/exp/manipulation/removeprofile.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/removeprofile.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/removeprofile.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=removeprofile(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=removeprofile(A,numprofiles,numpoints,closed,prevplot,root,options)
 %REMOVEPROFILE - delete a profile
 %
 %   this script is used by exptool as an elementary operation
@@ -20,9 +20,9 @@
 			disp('no profile to be removed, exiting...')
 			return
 		end
-		   
+
 		[xi,yi] = ginput(1);
-					  
+
 		if ~isempty(xi)
 
 			%get closest profile

Modified: issm/trunk/src/m/exp/manipulation/removeseveralpoints.m
===================================================================
--- issm/trunk/src/m/exp/manipulation/removeseveralpoints.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/exp/manipulation/removeseveralpoints.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [A,numprofiles,numpoints,closed]=removeseveralpoints(A,numprofiles,numpoints,closed,prevplot,root,options);
+function [A,numprofiles,numpoints,closed]=removeseveralpoints(A,numprofiles,numpoints,closed,prevplot,root,options)
 %REMOVESEVERALPOINTS - remove several point
 %
 %   this script is used by exptool as an elementary operation
@@ -6,7 +6,7 @@
 %
 %   Usage:
 %      [A,numprofiles,numpoints,closed]=removeseveralpoints(A,numprofiles,numpoints,closed,prevplot,root,options)
-		
+
 	%some checks
 	if numprofiles==0
 		disp('no profile present, exiting...')

Modified: issm/trunk/src/m/extrusion/DepthAverage.m
===================================================================
--- issm/trunk/src/m/extrusion/DepthAverage.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/extrusion/DepthAverage.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function  vector_average=DepthAverage(md,vector);
+function  vector_average=DepthAverage(md,vector)
 %DEPTHAVERAGE - computes depth average of 3d vector, and return value on 2d mesh. 
 %
 %   Usage:

Modified: issm/trunk/src/m/extrusion/project3d.m
===================================================================
--- issm/trunk/src/m/extrusion/project3d.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/extrusion/project3d.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function projected_vector=project3d(md,varargin);
+function projected_vector=project3d(md,varargin)
 %PROJECT3D - vertically project a vector from 2d mesh
 %
 %   vertically project a vector from 2d mesh (split in noncoll and coll areas) into a 3d mesh.

Modified: issm/trunk/src/m/geometry/FlagElements.py
===================================================================
--- issm/trunk/src/m/geometry/FlagElements.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/geometry/FlagElements.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
 import numpy
 import os
 #from basinzoom import *
-#from ContourToMesh import *
+from ContourToMesh import *
 from MatlabFuncs import *
 
 def FlagElements(md,region):
@@ -40,17 +40,18 @@
 			if not os.path.exists(region):
 				if len(region)>3 and not strcmp(region[-4:],'.exp'):
 					raise IOError("Error: File 'region' not found!" % region)
+				raise RuntimeError("FlagElements.py calling basinzoom.py is not complete.")
 				xlim,ylim=basinzoom('basin',region)
 				flag_nodes=numpy.logical_and(numpy.logical_and(md.mesh.x<xlim[1],md.mesh.x>xlim[0]),numpy.logical_and(md.mesh.y<ylim[1],md.mesh.y>ylim[0])).astype(float)
 				flag=numpy.prod(flag_nodes[md.mesh.elements],axis=1)
 			else:
 				#ok, flag elements
-				flag=ContourToMesh(md.mesh.elements[:,0:3],md.mesh.x,md.mesh.y,region,'element',1)
+				[flag,dum]=ContourToMesh(md.mesh.elements[:,0:3].copy(),md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),region,'element',1)
 
 		if invert:
 			flag=numpy.logical_not(flag)
 
-	elif isinstance(region,numpy.nparray) or isinstance(region,bool):
+	elif isinstance(region,numpy.ndarray) or isinstance(region,bool):
 		if not numpy.size(region,0)==md.mesh.numberofelements:
 			raise TypeError("Flaglist for region must be of same size as number of elements in model.")
 		flag=region

Modified: issm/trunk/src/m/geometry/SegIntersect.m
===================================================================
--- issm/trunk/src/m/geometry/SegIntersect.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/geometry/SegIntersect.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -48,7 +48,7 @@
 	O1B=O2O1'*(O2B-O2O1);
 	O1C=O2O1'*O1C;
 	O1D=O2O1'*O1D;
-	
+
 	%test if one point is included in the other segment (->bval=1)
 	if (O1C-O1A)*(O1D-O1A)<0
 		bval=1;

Modified: issm/trunk/src/m/geometry/SegIntersect.py
===================================================================
--- issm/trunk/src/m/geometry/SegIntersect.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/geometry/SegIntersect.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,4 @@
 import numpy
-from MatlabFuncs import *
 
 def SegIntersect(seg1,seg2):
 	"""
@@ -47,7 +46,7 @@
 		return bval
 
 	#if colinear
-	if test1*test2==0 and test3*test4==0 and det(numpy.hstack((n1.reshape((-1,1)),n2.reshape(-1,1))))==0:
+	if test1*test2==0 and test3*test4==0 and numpy.linalg.det(numpy.hstack((n1.reshape((-1,1)),n2.reshape(-1,1))))==0:
 
 		#projection on the axis O1O2
 		O2O1=numpy.array([xA/2.+xB/2.,yB/2.+yA/2.])-numpy.array([xD/2.+xC/2.,yD/2.+yC/2.])

Modified: issm/trunk/src/m/interp/PatchToVec.m
===================================================================
--- issm/trunk/src/m/interp/PatchToVec.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/interp/PatchToVec.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function vec=PatchToVec(Patch);
+function vec=PatchToVec(Patch)
 %PATCHTOVEC - converts a patch to a vector by averaging over each vertex
 %
 %   Usage:

Modified: issm/trunk/src/m/interp/SectionValues.m
===================================================================
--- issm/trunk/src/m/interp/SectionValues.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/interp/SectionValues.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,7 +22,6 @@
 	y=infile.y;
 end
 
-
 %get the specified resolution
 if isnumeric(resolution(1))
 	res_h=resolution(1);

Modified: issm/trunk/src/m/interp/plugvelocities.m
===================================================================
--- issm/trunk/src/m/interp/plugvelocities.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/interp/plugvelocities.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -164,3 +164,4 @@
 else
 	Names.interp='node';
 end
+end

Modified: issm/trunk/src/m/inversions/parametercontrolB.m
===================================================================
--- issm/trunk/src/m/inversions/parametercontrolB.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/inversions/parametercontrolB.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -38,7 +38,6 @@
 	md.inversion.nsteps=nsteps;
 end
 
-
 %cm_min
 cm_min=getfieldvalue(options,'cm_min',paterson(273.15+5)*ones(md.mesh.numberofvertices,1));
 if (length(cm_min)==1)

Modified: issm/trunk/src/m/kml/edgeadjacency.m
===================================================================
--- issm/trunk/src/m/kml/edgeadjacency.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/edgeadjacency.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,7 +30,7 @@
     for j=1:size(elem,2)
         inode1=elem(i,j);
         inode2=elem(i,mod(j,size(elem,2))+1);
-        
+
 %  loop over the elements containing the first node of the edge to see
 %  if they contain the second node of the edge
 

Modified: issm/trunk/src/m/kml/exp2kml.m
===================================================================
--- issm/trunk/src/m/kml/exp2kml.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/exp2kml.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,11 +5,9 @@
 %
 %
 
-
 %First, read exp file
 domain=expread(input);
 
-
 %then transform: 
 string=ge_plot(domain.x,domain.y,'name',domain.name);
 

Modified: issm/trunk/src/m/kml/kml2exp.m
===================================================================
--- issm/trunk/src/m/kml/kml2exp.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml2exp.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,12 +5,9 @@
 %
 %
 
-
-
-
 %First, read polygon kml file.
 structure=kml_shapefile(input);
-	
+
 %create exp file: 
 domain=struct();
 for i=1:length(structure),

Modified: issm/trunk/src/m/kml/kml_colorstyle.m
===================================================================
--- issm/trunk/src/m/kml/kml_colorstyle.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_colorstyle.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,7 +17,7 @@
         color     ='ffffffff';
         colormode ='normal';
     end
-    
+
     methods
         function [kml]=kml_colorstyle(varargin)
 
@@ -159,7 +159,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -195,8 +195,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_container.m
===================================================================
--- issm/trunk/src/m/kml/kml_container.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_container.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,7 +20,7 @@
 classdef kml_container < kml_feature
     properties
     end
-    
+
     methods
         function [kml]=kml_container(varargin)
 
@@ -149,7 +149,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -179,7 +179,7 @@
             end
 
         end
-        
+
 %  delete the object
 
         function []=delete(kml)
@@ -192,8 +192,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_document.m
===================================================================
--- issm/trunk/src/m/kml/kml_document.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_document.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,7 +22,7 @@
     properties
         feature   ={};
     end
-    
+
     methods
         function [kml]=kml_document(varargin)
 
@@ -161,7 +161,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -201,7 +201,7 @@
             end
 
         end
-        
+
 %  delete the object
 
         function []=delete(kml)
@@ -229,8 +229,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_feature.m
===================================================================
--- issm/trunk/src/m/kml/kml_feature.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_feature.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -27,7 +27,7 @@
         styleurl  ='';
         style     ={};
     end
-    
+
     methods
         function [kml]=kml_feature(varargin)
 
@@ -203,7 +203,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -261,7 +261,7 @@
             end
 
         end
-        
+
 %  delete the object
 
         function []=delete(kml)
@@ -288,8 +288,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_file_swrite.m
===================================================================
--- issm/trunk/src/m/kml/kml_file_swrite.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_file_swrite.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -129,4 +129,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/kml/kml_file_write.m
===================================================================
--- issm/trunk/src/m/kml/kml_file_write.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_file_write.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -123,4 +123,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/kml/kml_folder.m
===================================================================
--- issm/trunk/src/m/kml/kml_folder.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_folder.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,7 +22,7 @@
     properties
         feature   ={};
     end
-    
+
     methods
         function [kml]=kml_folder(varargin)
 
@@ -161,7 +161,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -201,7 +201,7 @@
             end
 
         end
-        
+
 %  delete the object
 
         function []=delete(kml)
@@ -229,8 +229,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_geometry.m
===================================================================
--- issm/trunk/src/m/kml/kml_geometry.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_geometry.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,7 +13,7 @@
 classdef kml_geometry < kml_object
     properties
     end
-    
+
     methods
         function [kml]=kml_geometry(varargin)
 
@@ -142,7 +142,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -172,8 +172,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_linearring.m
===================================================================
--- issm/trunk/src/m/kml/kml_linearring.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_linearring.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,7 +21,7 @@
         altmode   ='clampToGround';
         coords    =zeros(0,3);
     end
-    
+
     methods
         function [kml]=kml_linearring(varargin)
 
@@ -164,7 +164,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -202,8 +202,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_linestring.m
===================================================================
--- issm/trunk/src/m/kml/kml_linestring.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_linestring.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,7 +21,7 @@
         altmode   ='clampToGround';
         coords    =zeros(0,3);
     end
-    
+
     methods
         function [kml]=kml_linestring(varargin)
 
@@ -164,7 +164,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -202,8 +202,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_linestyle.m
===================================================================
--- issm/trunk/src/m/kml/kml_linestyle.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_linestyle.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -17,7 +17,7 @@
     properties
         width     =1;
     end
-    
+
     methods
         function [kml]=kml_linestyle(varargin)
 
@@ -142,7 +142,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -169,8 +169,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_mesh_elem.m
===================================================================
--- issm/trunk/src/m/kml/kml_mesh_elem.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_mesh_elem.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -99,7 +99,7 @@
 end
 cmap=colormap;
 close(hfig)
-    
+
 if exist('edata','var')
     if ~exist('cmin','var')
         cmin=min(min(edata));
@@ -174,4 +174,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/kml/kml_mesh_write.m
===================================================================
--- issm/trunk/src/m/kml/kml_mesh_write.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_mesh_write.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -192,7 +192,7 @@
     end
     cmap=colormap;
     close(hfig)
-    
+
     disp(['Writing ' num2str(size(cmap,1)) ' Matlab colors as KML style templates.']);
     for i=1:size(cmap,1)
         klsty=kml_linestyle();
@@ -258,4 +258,3 @@
 delete(kdoc);
 
 end
-

Modified: issm/trunk/src/m/kml/kml_multigeometry.m
===================================================================
--- issm/trunk/src/m/kml/kml_multigeometry.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_multigeometry.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,7 +15,7 @@
     properties
         geometry  ={};
     end
-    
+
     methods
         function [kml]=kml_multigeometry(varargin)
 
@@ -155,7 +155,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -196,7 +196,7 @@
             end
 
         end
-        
+
 %  delete the object
 
         function []=delete(kml)
@@ -224,8 +224,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_object.m
===================================================================
--- issm/trunk/src/m/kml/kml_object.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_object.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,7 @@
     properties
         id        ='';
     end
-    
+
     methods
         function [kml]=kml_object(varargin)
 
@@ -143,7 +143,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -173,8 +173,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_part_edges.m
===================================================================
--- issm/trunk/src/m/kml/kml_part_edges.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_part_edges.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -100,7 +100,7 @@
 end
 cmap=colormap;
 close(hfig)
-    
+
 if exist('edata','var')
     if ~exist('cmin','var')
         cmin=min(min(edata));
@@ -138,7 +138,7 @@
 
     for k=1:md.qmu.numberofpartitions
 %        disp(['partition k=' int2str(k)])
-        
+
 %  for each partition, find all the included elements and determine the
 %  perimeter (including those shared by another partition)
 
@@ -153,7 +153,7 @@
         [edgeadjp]=edgeadjacency(elemp,nodeconp);
         [edgeper,elemper,iloop]=edgeperimeter(elemp,nodeconp,edgeadjp);
         iloop(end+1)=size(edgeper,1)+1;
-        
+
 %  determine the data to be used for the colors (if any)
 
         if exist('ndata','var')
@@ -169,7 +169,7 @@
                 warning('Data for Partition %d is not defined.\n',k)
             end
         end
-        
+
 %  set up the placemark with multigeometry
 
         kplace=kml_placemark();
@@ -210,7 +210,7 @@
             slast=0;
             lat=[];
             long=[];
-            
+
 %  loop over the element edges on the loop of the partition
 
             j=iloop(i);
@@ -240,7 +240,7 @@
                     nlast=edgeper(j,2);
                     slast=0;
                     j=j+1;
-                    
+
 %  element not entirely within partition, so figure out boundary
                 else
 %                    disp(['segment j=' int2str(j) ' from element ' int2str(elemper(j)) ' shared by other partitions.'])
@@ -326,7 +326,7 @@
                                                        md.mesh.lat(elemp(ielem,nlast)) alt];
                             end
                             nlast=0;
-                            
+
 %  write out midpoint of first side
                             kline.coords(end+1,:)=[(md.mesh.long(elemp(ielem,slast))...
                                                    +md.mesh.long(elemp(ielem,mod(slast,3)+1)))/2. ...
@@ -480,4 +480,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/kml/kml_part_elems.m
===================================================================
--- issm/trunk/src/m/kml/kml_part_elems.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_part_elems.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -100,7 +100,7 @@
 end
 cmap=colormap;
 close(hfig)
-    
+
 if exist('edata','var')
     if ~exist('cmin','var')
         cmin=min(min(edata));
@@ -214,4 +214,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/kml/kml_part_flagedges.m
===================================================================
--- issm/trunk/src/m/kml/kml_part_flagedges.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_part_flagedges.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -107,4 +107,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/kml/kml_partitions.m
===================================================================
--- issm/trunk/src/m/kml/kml_partitions.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_partitions.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -101,7 +101,7 @@
 end
 cmap=colormap;
 close(hfig)
-    
+
 if exist('edata','var')
     if ~exist('cmin','var')
         cmin=min(min(edata));
@@ -139,7 +139,7 @@
 
     for k=1:md.qmu.numberofpartitions
 %        disp(['partition k=' int2str(k)])
-        
+
 %  for each partition, find all the included elements and determine the
 %  perimeter (including those shared by another partition)
 
@@ -170,7 +170,7 @@
                 warning('Data for Partition %d is not defined.\n',k)
             end
         end
-        
+
 %  set up the placemark with multigeometry
 
         kplace=kml_placemark();
@@ -196,7 +196,7 @@
 
         kmgeom=kml_multigeometry();
         kmgeom.geometry  ={repmat(kml_polygon(),1,length(iloop)-1)};
-        
+
 %  loop over each loop of the perimeter for the given partition
 
         for i=1:length(iloop)-1
@@ -212,7 +212,7 @@
             slast=0;
             lat=[];
             long=[];
-            
+
 %  loop over the element edges on the loop of the partition
 
             j=iloop(i);
@@ -242,7 +242,7 @@
                     nlast=edgeper(j,2);
                     slast=0;
                     j=j+1;
-                    
+
 %  element not entirely within partition, so figure out boundary
                 else
 %                    disp(['segment j=' int2str(j) ' from element ' int2str(elemper(j)) ' shared by other partitions.'])
@@ -328,7 +328,7 @@
                                                        md.mesh.lat(elemp(ielem,nlast)) alt];
                             end
                             nlast=0;
-                            
+
 %  write out midpoint of first side
                             kring.coords(end+1,:)=[(md.mesh.long(elemp(ielem,slast))...
                                                    +md.mesh.long(elemp(ielem,mod(slast,3)+1)))/2. ...
@@ -483,4 +483,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/kml/kml_placemark.m
===================================================================
--- issm/trunk/src/m/kml/kml_placemark.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_placemark.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,7 +22,7 @@
     properties
         geometry  =kml_geometry.empty();
     end
-    
+
     methods
         function [kml]=kml_placemark(varargin)
 
@@ -162,7 +162,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -203,7 +203,7 @@
             end
 
         end
-        
+
 %  delete the object
 
         function []=delete(kml)
@@ -232,8 +232,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_polygon.m
===================================================================
--- issm/trunk/src/m/kml/kml_polygon.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_polygon.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -23,7 +23,7 @@
         outer     =kml_linearring.empty();
         inner     =kml_linearring.empty();
     end
-    
+
     methods
         function [kml]=kml_polygon(varargin)
 
@@ -182,7 +182,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -233,7 +233,7 @@
             end
 
         end
-        
+
 %  delete the object
 
         function []=delete(kml)
@@ -265,8 +265,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_polystyle.m
===================================================================
--- issm/trunk/src/m/kml/kml_polystyle.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_polystyle.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,7 +19,7 @@
         fill      =true;
         outline   =true;
     end
-    
+
     methods
         function [kml]=kml_polystyle(varargin)
 
@@ -147,7 +147,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -175,8 +175,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_style.m
===================================================================
--- issm/trunk/src/m/kml/kml_style.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_style.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -29,7 +29,7 @@
         balloon   =[];
         list      =[];
     end
-    
+
     methods
         function [kml]=kml_style(varargin)
 
@@ -205,7 +205,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -267,7 +267,7 @@
             end
 
         end
-        
+
 %  delete the object
 
         function []=delete(kml)
@@ -321,8 +321,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_styleselector.m
===================================================================
--- issm/trunk/src/m/kml/kml_styleselector.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_styleselector.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,7 +13,7 @@
 classdef kml_styleselector < kml_object
     properties
     end
-    
+
     methods
         function [kml]=kml_styleselector(varargin)
 
@@ -142,7 +142,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -172,8 +172,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_substyle.m
===================================================================
--- issm/trunk/src/m/kml/kml_substyle.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_substyle.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,7 +13,7 @@
 classdef kml_substyle < kml_object
     properties
     end
-    
+
     methods
         function [kml]=kml_substyle(varargin)
 
@@ -142,7 +142,7 @@
             end
 
         end
-        
+
 %  string write the object
 
         function [sbuf]=kml_swrite(kml,sbuf,indent)
@@ -172,8 +172,7 @@
             end
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/kml/kml_unsh_edges.m
===================================================================
--- issm/trunk/src/m/kml/kml_unsh_edges.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/kml_unsh_edges.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -113,4 +113,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/kml/string_buf.m
===================================================================
--- issm/trunk/src/m/kml/string_buf.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/kml/string_buf.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -172,7 +172,7 @@
            str=sbuf.string(1:sbuf.len);
 
         end
-        
+
 %  reset the object
 
         function [sbuf]=reset(sbuf)
@@ -182,8 +182,7 @@
             len       =0;
 
         end
-        
+
     end
-    
-end
 
+end

Modified: issm/trunk/src/m/materials/paterson.m
===================================================================
--- issm/trunk/src/m/materials/paterson.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/materials/paterson.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
 function rigidity=paterson(temperature)
 %PATERSON - figure out the rigidity of ice for a given temperature
 %
-%   rigidigty (in s^(1/3)Pa) is the flow law paramter in the flow law sigma=B*e(1/3) (Paterson, p97). 
+%   rigidity (in s^(1/3)Pa) is the flow law paramter in the flow law sigma=B*e(1/3) (Paterson, p97). 
 %   temperature is in Kelvin degrees
 %
 %   Usage:

Modified: issm/trunk/src/m/materials/paterson.py
===================================================================
--- issm/trunk/src/m/materials/paterson.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/materials/paterson.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,24 +1,23 @@
-from numpy import *
+import numpy
 
 def paterson(temperature):
+	"""
+	PATERSON - figure out the rigidity of ice for a given temperature
 
-    # Local Variables: pos11, pos5, pos10, temperature, pos, T, pos8, pos9, pos6, pos7, pos4, rigidity, pos2, pos3, pos1
-    # Function calls: length, zeros, argwhere, paterson, error
-    #PATERSON - figure out the rigidity of ice for a given temperature
-    #
-    #   rigidigty (in s^(1/3)Pa) is the flow law paramter in the flow law sigma=B*e(1/3) (Paterson, p97). 
-    #   temperature is in Kelvin degrees
-    #
-    #   Usage:
-    #      rigidity=paterson(temperature)
-    
-	pos=argwhere(temperature<0.)
-	if len(pos):
-		print 'input temperature should be in Kelvin (positive)'
-		return []
-    
+	   rigidity (in s^(1/3)Pa) is the flow law paramter in the flow law sigma=B*e(1/3) (Paterson, p97). 
+	   temperature is in Kelvin degrees
+
+	   Usage:
+	      rigidity=paterson(temperature)
+	"""
+	
+	if numpy.any(temperature<0.):
+		raise RuntimeError("input temperature should be in Kelvin (positive)")
+	
 	T = temperature-273.15
+
 	#The routine below is equivalent to:
+
 	# n=3; T=temperature-273;
 	# %From paterson,
 	# Temp=[0;-2;-5;-10;-15;-20;-25;-30;-35;-40;-45;-50];
@@ -30,21 +29,33 @@
 	# fittedmodel=fit(Temp,B,'cubicspline');
 	# rigidity=fittedmodel(temperature);
 
-	rigidity=zeros(len(T))
-	pos1=argwhere(T<=-45);           rigidity[pos1]=10**8*(-0.000292866376675*(T[pos1]+50)**3+ 0.011672640664130*(T[pos1]+50)**2  -0.325004442485481*(T[pos1]+50)+  6.524779401948101)
-	pos2=argwhere(logical_and(-45<=T,T<-40));   rigidity[pos2]=10**8*(-0.000292866376675*(T[pos2]+45)**3+ 0.007279645014004*(T[pos2]+45)**2  -0.230243014094813*(T[pos2]+45)+  5.154964909039554)
-	pos3=argwhere(logical_and(-40<=T,T<-35));   rigidity[pos3]=10**8*(0.000072737147457*(T[pos3]+40)**3+  0.002886649363879*(T[pos3]+40)**2  -0.179411542205399*(T[pos3]+40)+  4.149132666831214)
-	pos4=argwhere(logical_and(-35<=T,T<-30));   rigidity[pos4]=10**8*(-0.000086144770023*(T[pos4]+35)**3+ 0.003977706575736*(T[pos4]+35)**2  -0.145089762507325*(T[pos4]+35)+  3.333333333333331)
-	pos5=argwhere(logical_and(-30<=T,T<-25));   rigidity[pos5]=10**8*(-0.000043984685769*(T[pos5]+30)**3+ 0.002685535025386*(T[pos5]+30)**2  -0.111773554501713*(T[pos5]+30)+  2.696559088937191)
-	pos6=argwhere(logical_and(-25<=T,T<-20));   rigidity[pos6]=10**8*(-0.000029799523463*(T[pos6]+25)**3+ 0.002025764738854*(T[pos6]+25)**2  -0.088217055680511*(T[pos6]+25)+  2.199331606342181)
-	pos7=argwhere(logical_and(-20<=T,T<-15));   rigidity[pos7]=10**8*(0.000136920904777*(T[pos7]+20)**3+  0.001578771886910*(T[pos7]+20)**2  -0.070194372551690*(T[pos7]+20)+  1.805165505978111)
-	pos8=argwhere(logical_and(-15<=T,T<-10));   rigidity[pos8]=10**8*(-0.000899763781026*(T[pos8]+15)**3+ 0.003632585458564*(T[pos8]+15)**2  -0.044137585824322*(T[pos8]+15)+  1.510778053489523)
-	pos9=argwhere(logical_and(-10<=T,T<-5));    rigidity[pos9]=10**8*(0.001676964325070*(T[pos9]+10)**3-  0.009863871256831*(T[pos9]+10)**2  -0.075294014815659*(T[pos9]+10)+  1.268434288203714)
-	pos10=argwhere(logical_and(-5<=T,T<-2));    rigidity[pos10]=10**8*(-0.003748937622487*(T[pos10]+5)**3+0.015290593619213*(T[pos10]+5)**2  -0.048160403003748*(T[pos10]+5)+  0.854987973338348)
-	pos11=argwhere(-2<=T);           rigidity[pos11]=10**8*(-0.003748937622488*(T[pos11]+2)**3-0.018449844983174*(T[pos11]+2)**2  -0.057638157095631*(T[pos11]+2)+  0.746900791092860)
+	rigidity=numpy.zeros((numpy.size(T,axis=0),1))
+	pos1=numpy.nonzero(T<=-45)
+	rigidity[pos1]=10**8*(-0.000292866376675*(T[pos1]+50)**3+ 0.011672640664130*(T[pos1]+50)**2  -0.325004442485481*(T[pos1]+50)+  6.524779401948101)
+	pos2=numpy.nonzero(numpy.logical_and(-45<=T,T<-40))
+	rigidity[pos2]=10**8*(-0.000292866376675*(T[pos2]+45)**3+ 0.007279645014004*(T[pos2]+45)**2  -0.230243014094813*(T[pos2]+45)+  5.154964909039554)
+	pos3=numpy.nonzero(numpy.logical_and(-40<=T,T<-35))
+	rigidity[pos3]=10**8*(0.000072737147457*(T[pos3]+40)**3+  0.002886649363879*(T[pos3]+40)**2  -0.179411542205399*(T[pos3]+40)+  4.149132666831214)
+	pos4=numpy.nonzero(numpy.logical_and(-35<=T,T<-30))
+	rigidity[pos4]=10**8*(-0.000086144770023*(T[pos4]+35)**3+ 0.003977706575736*(T[pos4]+35)**2  -0.145089762507325*(T[pos4]+35)+  3.333333333333331)
+	pos5=numpy.nonzero(numpy.logical_and(-30<=T,T<-25))
+	rigidity[pos5]=10**8*(-0.000043984685769*(T[pos5]+30)**3+ 0.002685535025386*(T[pos5]+30)**2  -0.111773554501713*(T[pos5]+30)+  2.696559088937191)
+	pos6=numpy.nonzero(numpy.logical_and(-25<=T,T<-20))
+	rigidity[pos6]=10**8*(-0.000029799523463*(T[pos6]+25)**3+ 0.002025764738854*(T[pos6]+25)**2  -0.088217055680511*(T[pos6]+25)+  2.199331606342181)
+	pos7=numpy.nonzero(numpy.logical_and(-20<=T,T<-15))
+	rigidity[pos7]=10**8*(0.000136920904777*(T[pos7]+20)**3+  0.001578771886910*(T[pos7]+20)**2  -0.070194372551690*(T[pos7]+20)+  1.805165505978111)
+	pos8=numpy.nonzero(numpy.logical_and(-15<=T,T<-10))
+	rigidity[pos8]=10**8*(-0.000899763781026*(T[pos8]+15)**3+ 0.003632585458564*(T[pos8]+15)**2  -0.044137585824322*(T[pos8]+15)+  1.510778053489523)
+	pos9=numpy.nonzero(numpy.logical_and(-10<=T,T<-5))
+	rigidity[pos9]=10**8*(0.001676964325070*(T[pos9]+10)**3-  0.009863871256831*(T[pos9]+10)**2  -0.075294014815659*(T[pos9]+10)+  1.268434288203714)
+	pos10=numpy.nonzero(numpy.logical_and(-5<=T,T<-2))
+	rigidity[pos10]=10**8*(-0.003748937622487*(T[pos10]+5)**3+0.015290593619213*(T[pos10]+5)**2  -0.048160403003748*(T[pos10]+5)+  0.854987973338348)
+	pos11=numpy.nonzero(-2<=T)
+	rigidity[pos11]=10**8*(-0.003748937622488*(T[pos11]+2)**3-0.018449844983174*(T[pos11]+2)**2  -0.057638157095631*(T[pos11]+2)+  0.746900791092860)
 
 	#Now make sure that rigidity is positive
-	pos=argwhere(rigidity<0);        rigidity[pos]=1**6 
+	pos=numpy.nonzero(rigidity<0)
+	rigidity[pos]=1**6 
 
 	return rigidity
 

Modified: issm/trunk/src/m/mech/basalstress.m
===================================================================
--- issm/trunk/src/m/mech/basalstress.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mech/basalstress.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,7 +6,6 @@
 %
 %   See also: plot_basaldrag
 
-
 %compute exponents
 s=averaging(md,1./md.friction.p,0);
 r=averaging(md,md.friction.q./md.friction.p,0);

Modified: issm/trunk/src/m/mech/cfl_step.m
===================================================================
--- issm/trunk/src/m/mech/cfl_step.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mech/cfl_step.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function maxtime=cfl_step(md,vx,vy);
+function maxtime=cfl_step(md,vx,vy)
 %CFL_STEP - return the maximum time step for the model in years
 %
 %   Dt < 0.5 / ( u/Dx +v/Dy )

Modified: issm/trunk/src/m/mech/mechanicalproperties.m
===================================================================
--- issm/trunk/src/m/mech/mechanicalproperties.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mech/mechanicalproperties.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -50,13 +50,26 @@
 B_bar=md.materials.rheology_B(index)*summation/3;
 power=(md.materials.rheology_n-1)./(2*md.materials.rheology_n);
 second_inv=(ux.^2+vy.^2+((uy+vx).^2)/4+ux.*vy);
+
 %some corrections
-location=find(second_inv~=0);
-nu(location)=B_bar(location)./(second_inv(location).^power(location));
 location=find(second_inv==0 & power~=0);
 nu(location)=10^18; 	%arbitrary maximum viscosity to apply where there is no effective shear
-location=find(second_inv==0 & power==0);
-nu(location)=B_bar(location);
+
+if isa(md.materials,'matice')
+	location=find(second_inv~=0);
+	nu(location)=B_bar(location)./(second_inv(location).^power(location));
+	location=find(second_inv==0 & power==0);
+	nu(location)=B_bar(location);
+elseif isa(md.materials,'matdamageice')
+	Zinv=md.materials.rheology_Z(index)*summation/3;
+	location=find(second_inv~=0);
+	nu(location)=Zinv(location).*B_bar(location)./(second_inv(location).^power(location));
+	location=find(second_inv==0 & power==0);
+	nu(location)=Zinv(location).*B_bar(location);
+	clear Zinv
+else
+	error(['class of md.materials (' class(md.materials) ') not recognized or not supported']);
+end
 clear B_bar location second_inv power
 
 %compute stress
@@ -75,9 +88,18 @@
 
 	%eigen values and vectors
 	[directions,value]=eig(stress);
+	%sort by absolute value of eigenvalue in descending order
+	[val,idx]=sort(abs(diag(value)),'descend');
+	%re-order eigenvalues and associated vectors 
+	value=value(idx,idx);
+	directions=directions(:,idx);
 	valuesstress(i,:)=[value(1,1) value(2,2)];
 	directionsstress(i,:)=directions(:)';
 	[directions,value]=eig(strain);
+	%same for strainrate
+	[val,idx]=sort(abs(diag(value)),'descend');
+	value=value(idx,idx);
+	directions=directions(:,idx);
 	valuesstrain(i,:)=[value(1,1) value(2,2)];
 	directionsstrain(i,:)=directions(:)';
 end
@@ -88,10 +110,10 @@
 stress.xx=tau_xx;
 stress.yy=tau_yy;
 stress.xy=tau_xy;
-stress.principalvalue2=valuesstress(:,1);
-stress.principalaxis2=directionsstress(:,1:2);
-stress.principalvalue1=valuesstress(:,2);
-stress.principalaxis1=directionsstress(:,3:4);
+stress.principalvalue1=valuesstress(:,1);
+stress.principalaxis1=directionsstress(:,1:2);
+stress.principalvalue2=valuesstress(:,2);
+stress.principalaxis2=directionsstress(:,3:4);
 stress.effectivevalue=1/sqrt(2)*sqrt(stress.xx.^2+stress.yy.^2+2*stress.xy.^2);
 md.results.stress=stress;
 
@@ -99,10 +121,10 @@
 strainrate.xx=ux;
 strainrate.yy=vy;
 strainrate.xy=uyvx;
-strainrate.principalvalue2=valuesstrain(:,1)*(365.25*24*3600); %strain rate in 1/a instead of 1/s
-strainrate.principalaxis2=directionsstrain(:,1:2);
-strainrate.principalvalue1=valuesstrain(:,2)*(365.25*24*3600); %strain rate in 1/a instead of 1/s
-strainrate.principalaxis1=directionsstrain(:,3:4);
+strainrate.principalvalue1=valuesstrain(:,1)*(365.25*24*3600); %strain rate in 1/a instead of 1/s
+strainrate.principalaxis1=directionsstrain(:,1:2);
+strainrate.principalvalue2=valuesstrain(:,2)*(365.25*24*3600); %strain rate in 1/a instead of 1/s
+strainrate.principalaxis2=directionsstrain(:,3:4);
 strainrate.effectivevalue=1/sqrt(2)*sqrt(strainrate.xx.^2+strainrate.yy.^2+2*strainrate.xy.^2);
 md.results.strainrate=strainrate;
 
@@ -110,9 +132,9 @@
 deviatoricstress.xx=tau_xx;
 deviatoricstress.yy=tau_yy;
 deviatoricstress.xy=tau_xy;
-deviatoricstress.principalvalue2=valuesstress(:,1);
-deviatoricstress.principalaxis2=directionsstress(:,1:2);
-deviatoricstress.principalvalue1=valuesstress(:,2);
-deviatoricstress.principalaxis1=directionsstress(:,3:4);
+deviatoricstress.principalvalue1=valuesstress(:,1);
+deviatoricstress.principalaxis1=directionsstress(:,1:2);
+deviatoricstress.principalvalue2=valuesstress(:,2);
+deviatoricstress.principalaxis2=directionsstress(:,3:4);
 deviatoricstress.effectivevalue=1/sqrt(2)*sqrt(stress.xx.^2+stress.yy.^2+2*stress.xy.^2);
 md.results.deviatoricstress=deviatoricstress;

Modified: issm/trunk/src/m/mesh/ComputeHessian.m
===================================================================
--- issm/trunk/src/m/mesh/ComputeHessian.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/ComputeHessian.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,7 +19,7 @@
 if length(field)~=numberofnodes & length(field)~=numberofelements,
 	error('ComputeHessian error message: the given field size not supported yet');
 end
-if strcmpi(type,'node') & strcmpi(type,'element'),
+if ~strcmpi(type,'node') & ~strcmpi(type,'element'),
 	error('ComputeHessian error message: only ''node'' or ''element'' type supported yet');
 end
 
@@ -27,11 +27,11 @@
 line=index(:);
 linesize=3*numberofelements;
 
-%get areas and  nodal functions coefficients N(x,y)=alpha x + beta y + gamma 
+%get areas and nodal functions coefficients N(x,y)=alpha x + beta y + gamma 
 [alpha beta]=GetNodalFunctionsCoeff(index,x,y);
 areas=GetAreas(index,x,y);
 
-%comput weights that holds the volume of all the element holding the node i
+%compute weights that hold the volume of all the element holding the node i
 weights=sparse(line,ones(linesize,1),repmat(areas,3,1),numberofnodes,1);
 
 %compute field on nodes if on elements

Modified: issm/trunk/src/m/mesh/ComputeMetric.m
===================================================================
--- issm/trunk/src/m/mesh/ComputeMetric.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/ComputeMetric.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,28 +8,28 @@
 %   Example:
 %      metric=ComputeMetric(hessian,2/9,10^-1,100,10^5,find(md.nodeonwater)
 
-%first, find the eigen values of eah line of H=[hessian(i,1) hessian(i,2); hessian(i,2)  hessian(i,3)]
+%first, find the eigen values of each line of H=[hessian(i,1) hessian(i,2); hessian(i,2) hessian(i,3)]
 a=hessian(:,1); b=hessian(:,2); d=hessian(:,3);
-lambda1=0.5*((a+d)+sqrt(4*b.^2+(a-d).^2));
-lambda2=0.5*((a+d)-sqrt(4*b.^2+(a-d).^2));
+lambda1=0.5*((a+d)+sqrt(4.*b.^2+(a-d).^2));
+lambda2=0.5*((a+d)-sqrt(4.*b.^2+(a-d).^2));
 pos1=find(lambda1==0);
 pos2=find(lambda2==0);
 pos3=find(b==0 & lambda1==lambda2);
 
 %Modify the eigen values to control the shape of the elements
-lambda1=min(max(abs(lambda1)*scale/epsilon,1/hmax^2),1/hmin^2);
-lambda2=min(max(abs(lambda2)*scale/epsilon,1/hmax^2),1/hmin^2);
+lambda1=min(max(abs(lambda1)*scale/epsilon,1./hmax^2),1./hmin^2);
+lambda2=min(max(abs(lambda2)*scale/epsilon,1./hmax^2),1./hmin^2);
 
 %compute eigen vectors
-norm1=sqrt(8*b.^2+2*(d-a).^2+2*(d-a).*sqrt((a-d).^2+4*b.^2));
-v1x=2*b./norm1;
-v1y=((d-a)+sqrt((a-d).^2+4*b.^2))./norm1;
-norm2=sqrt(8*b.^2+2*(d-a).^2-2*(d-a).*sqrt((a-d).^2+4*b.^2));
-v2x=2*b./norm2;
-v2y=((d-a)-sqrt((a-d).^2+4*b.^2))./norm2;
+norm1=sqrt(8.*b.^2+2.*(d-a).^2+2.*(d-a).*sqrt((a-d).^2+4.*b.^2));
+v1x=2.*b./norm1;
+v1y=((d-a)+sqrt((a-d).^2+4.*b.^2))./norm1;
+norm2=sqrt(8.*b.^2+2.*(d-a).^2-2.*(d-a).*sqrt((a-d).^2+4.*b.^2));
+v2x=2.*b./norm2;
+v2y=((d-a)-sqrt((a-d).^2+4.*b.^2))./norm2;
 
-v1x(pos3)=1; v1y(pos3)=0;
-v2x(pos3)=0; v2y(pos3)=1;
+v1x(pos3)=1.; v1y(pos3)=0.;
+v2x(pos3)=0.; v2y(pos3)=1.;
 
 %Compute new metric (for each node M=V*Lambda*V^-1)
 metric=full([(v1x.*v2y-v1y.*v2x).^(-1).*(lambda1.*v2y.*v1x-lambda2.*v1y.*v2x) ...
@@ -37,11 +37,11 @@
 	(v1x.*v2y-v1y.*v2x).^(-1).*(-lambda1.*v2x.*v1y+lambda2.*v1x.*v2y)]);
 
 %some corrections for 0 eigen values
-metric(pos1,:)=repmat([1/hmax^2 0 1/hmax^2],length(pos1),1);
-metric(pos2,:)=repmat([1/hmax^2 0 1/hmax^2],length(pos2),1);
+metric(pos1,:)=repmat([1./hmax^2 0. 1./hmax^2],length(pos1),1);
+metric(pos2,:)=repmat([1./hmax^2 0. 1./hmax^2],length(pos2),1);
 
 %take care of water elements
-metric(pos,:)=repmat([1/hmax^2 0 1/hmax^2],length(pos),1);
+metric(pos,:)=repmat([1./hmax^2 0. 1./hmax^2],length(pos),1);
 
 %take care of NaNs if any (use Matlab eig in a loop)
 [pos posj]=find(isnan(metric)); clear posj;
@@ -53,8 +53,8 @@
 		[u,v]=eig(full(H));
 		lambda1=v(1,1);
 		lambda2=v(2,2);
-		v(1,1)=min(max(abs(lambda1)*scale/epsilon,1/hmax^2),1/hmin^2);
-		v(2,2)=min(max(abs(lambda2)*scale/epsilon,1/hmax^2),1/hmin^2);
+		v(1,1)=min(max(abs(lambda1)*scale/epsilon,1./hmax^2),1./hmin^2);
+		v(2,2)=min(max(abs(lambda2)*scale/epsilon,1./hmax^2),1./hmin^2);
 
 		metricTria=u*v*u^(-1);
 		metric(pos(i),:)=[metricTria(1,1) metricTria(1,2) metricTria(2,2)];

Modified: issm/trunk/src/m/mesh/ElementsFromEdge.m
===================================================================
--- issm/trunk/src/m/mesh/ElementsFromEdge.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/ElementsFromEdge.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,15 +1,15 @@
-function edgeelements=ElementsFromEdge(elements,A,B) 
+function edgeelements=ElementsFromEdge(elements,A,B)
 %ELEMENTSFROMEDGE: find elements connected to one edge defined by nodes A and B
 %
-% Usage: edgeelements=ElementsFromEdge(elements,A,B) 
+%   Usage: edgeelements=ElementsFromEdge(elements,A,B) 
 %
-% Eg:    edgeelements=ElementsFromEdge(md.mesh.elements,tip1,tip2)
+%   Eg:    edgeelements=ElementsFromEdge(md.mesh.elements,tip1,tip2)
 %
 %
 edgeelements=find(...
-(elements(:,1)==A & elements(:,2)==B )| ...
-(elements(:,1)==A & elements(:,3)==B )| ...
-(elements(:,2)==A & elements(:,3)==B )| ...
-(elements(:,2)==A & elements(:,1)==B )| ...
-(elements(:,3)==A & elements(:,1)==B )| ...
-(elements(:,3)==A & elements(:,2)==B ));
+	(elements(:,1)==A & elements(:,2)==B )| ...
+	(elements(:,1)==A & elements(:,3)==B )| ...
+	(elements(:,2)==A & elements(:,3)==B )| ...
+	(elements(:,2)==A & elements(:,1)==B )| ...
+	(elements(:,3)==A & elements(:,1)==B )| ...
+	(elements(:,3)==A & elements(:,2)==B ));

Modified: issm/trunk/src/m/mesh/FixMesh.m
===================================================================
--- issm/trunk/src/m/mesh/FixMesh.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/FixMesh.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -31,7 +31,7 @@
 
 	%now, the index:
 	pos=find(index2>orphan); index2(pos)=index2(pos)-1;
-	
+
 	%look again for orphans on new mesh
 	flags=zeros(length(x2),1);flags(index2)=1;
 	orphans=find(flags==0);

Modified: issm/trunk/src/m/mesh/MeshQuality.m
===================================================================
--- issm/trunk/src/m/mesh/MeshQuality.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/MeshQuality.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function quality=MeshQuality(md,epsilon,hmin,hmax);
+function quality=MeshQuality(md,epsilon,hmin,hmax)
 %MESHQUALITY - compute mesh quality
 %
 %   Usage:

Modified: issm/trunk/src/m/mesh/NodeInElement.m
===================================================================
--- issm/trunk/src/m/mesh/NodeInElement.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/NodeInElement.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function node_in_element=NodeInElement(newx,newy,elements,x,y,nodeconnectivity);
+function node_in_element=NodeInElement(newx,newy,elements,x,y,nodeconnectivity)
 % NODEINELEMENT - find for a list of nodes (in newx,newy), which elements in the mesh (elements,x,y) they belong to.
 %
 %    Usage:
@@ -24,14 +24,14 @@
 for i=1:length(newx),
 	x0=newx(i);
 	y0=newy(i);
-	
+
 	%first area coordinate
 	area_1=(y3y2.*(x0-x3)-x3x2.*(y0-y3))./delta;
 	%second area coordinate
 	area_2=(x3x1.*(y0-y3)-y3y1.*(x0-x3))./delta;
 	%third area coordinate
 	area_3=1-area_1-area_2;
-	
+
 	%get elements for which all area coordinates are positive (meaning (x0,y0) belongs to these elements
 	pos=find((area_1>=0-epsilon) & (area_2>=0-epsilon) & (area_3>=0-epsilon));
 

Modified: issm/trunk/src/m/mesh/bamg.m
===================================================================
--- issm/trunk/src/m/mesh/bamg.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/bamg.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -54,15 +54,15 @@
 
 %initialize the structures required as input of Bamg
 bamg_options=struct();
-bamg_geometry=bamggeom;
-bamg_mesh=bamgmesh;
+bamg_geometry=bamggeom();
+bamg_mesh=bamgmesh();
 
 % Bamg Geometry parameters {{{
 if exist(options,'domain'),
 
 	%Check that file exists
 	domainfile=getfieldvalue(options,'domain');
-	if ~exist(domainfile,'file') error(['bamg error message: file ' domainfile ' not found ']); end
+	if ~exist(domainfile,'file') error(['bamg error message: file ' domainfile ' not found']); end
 	domain=expread(domainfile);
 
 	%Build geometry 
@@ -78,14 +78,14 @@
 		if i>1,
 			flags=ContourToNodes(domain(i).x,domain(i).y,domain(1),0);
 			if any(~flags),
-				error('bamg error message: All holes should be stricly inside the principal domain');
+				error('bamg error message: All holes should be strictly inside the principal domain');
 			end
 		end
 
 		%Add all points to bamg_geometry
 		nods=domain(i).nods-1; %the domain are closed 1=end;
 		bamg_geometry.Vertices=[bamg_geometry.Vertices; [domain(i).x(1:nods) domain(i).y(1:nods) ones(nods,1)]];
-		bamg_geometry.Edges   =[bamg_geometry.Edges;    [transpose(count+1:count+nods) transpose([count+2:count+nods count+1])  1*ones(nods,1)]];
+		bamg_geometry.Edges   =[bamg_geometry.Edges;    [transpose(count+1:count+nods) transpose([count+2:count+nods count+1])  1.*ones(nods,1)]];
 		if i>1, bamg_geometry.SubDomains=[bamg_geometry.SubDomains; 2 count+1 1 1]; end
 
 		%update counter
@@ -104,16 +104,16 @@
 
 		for i=1:length(rift),
 
-			%detect wether all points of the rift are inside the domain
+			%detect whether all points of the rift are inside the domain
 			flags=ContourToNodes(rift(i).x,rift(i).y,domain(1),0);
 			if ~flags,
-				error('one Rift has all his points outside of the domain outline'),
+				error('one rift has all its points outside of the domain outline'),
 
 			elseif any(~flags),
 				%We LOTS of work to do
 				disp('Rift tip outside of or on the domain has been detected and is being processed...');
 
-				%check that only one point is outsie (for now)
+				%check that only one point is outside (for now)
 				if sum(~flags)~=1,
 					error('bamg error message: only one point outside of the domain is supported yet');
 				end
@@ -136,7 +136,7 @@
 
 						%Get position of the two nodes of the edge in domain
 						i1=j;
-						i2=mod(j+1,domain(1).nods);
+						i2=j+1;
 
 						%rift is crossing edge [i1 i2] of the domain
 						%Get coordinate of intersection point (http://mathworld.wolfram.com/Line-LineIntersection.html)
@@ -151,7 +151,7 @@
 						if (min(tipdis)/segdis) < getfieldvalue(options,'toltip',0),
 							disp('moving tip-domain intersection point');
 
-							%Get position of the closest point
+							%Get position of the closer point
 							if tipdis(1)>tipdis(2),
 								pos=i2;
 							else
@@ -159,12 +159,12 @@
 							end
 
 							%This point is only in Vertices (number pos).
-							%OK, no we can add our own rift
+							%OK, now we can add our own rift
 							nods=rift(i).nods-1;
 							bamg_geometry.Vertices=[bamg_geometry.Vertices; [rift(i).x(2:end) rift(i).y(2:end) ones(nods,1)]];
 							bamg_geometry.Edges=[bamg_geometry.Edges;...
 								pos count+1  (1+i);...
-								[transpose(count+1:count+nods-1) transpose([count+2:count+nods])  (1+i)*ones(nods-1,1)]];
+								[transpose(count+1:count+nods-1) transpose(count+2:count+nods)  (1+i)*ones(nods-1,1)]];
 							count=count+nods;
 
 							break;
@@ -174,20 +174,20 @@
 							bamg_geometry.Vertices=[bamg_geometry.Vertices; x y 1];
 							count=count+1;
 
-							%Decompose the crossing edge in 2 subedges
+							%Decompose the crossing edge into 2 subedges
 							pos=find(bamg_geometry.Edges(:,1)==i1 & bamg_geometry.Edges(:,2)==i2);
-							if isempty(pos) error('bamg error message: a problem occured...'); end
+							if isempty(pos) error('bamg error message: a problem occurred...'); end
 							bamg_geometry.Edges=[bamg_geometry.Edges(1:pos-1,:);...
-								bamg_geometry.Edges(pos,1) count                           bamg_geometry.Edges(pos,3);...
-								count                      bamg_geometry.Edges(pos,2)   bamg_geometry.Edges(pos,3);...
+								bamg_geometry.Edges(pos,1) count                      bamg_geometry.Edges(pos,3);...
+								count                      bamg_geometry.Edges(pos,2) bamg_geometry.Edges(pos,3);...
 								bamg_geometry.Edges(pos+1:end,:)];
 
-							%OK, no we can add our own rift
+							%OK, now we can add our own rift
 							nods=rift(i).nods-1;
 							bamg_geometry.Vertices=[bamg_geometry.Vertices; [rift(i).x(2:end) rift(i).y(2:end) ones(nods,1)]];
 							bamg_geometry.Edges=[bamg_geometry.Edges;...
 								count  count+1  2 ;...
-								[transpose(count+1:count+nods-1) transpose([count+2:count+nods])  (1+i)*ones(nods-1,1)]];
+								[transpose(count+1:count+nods-1) transpose(count+2:count+nods)  (1+i)*ones(nods-1,1)]];
 							count=count+nods;
 
 							break;
@@ -197,7 +197,7 @@
 			else
 				nods=rift(i).nods-1;
 				bamg_geometry.Vertices=[bamg_geometry.Vertices; [rift(i).x(:) rift(i).y(:) ones(nods+1,1)]];
-				bamg_geometry.Edges=[bamg_geometry.Edges; [transpose(count+1:count+nods) transpose([count+2:count+nods+1])  (1+i)*ones(nods,1)]];
+				bamg_geometry.Edges=[bamg_geometry.Edges; [transpose(count+1:count+nods) transpose(count+2:count+nods+1)  (1+i)*ones(nods,1)]];
 				count=count+nods+1;
 			end
 		end
@@ -209,12 +209,12 @@
 		%read tracks
 		track=getfieldvalue(options,'tracks');
 		if all(ischar(track)),
-			A=expread(track); 
+			A=expread(track);
 			track=[A.x A.y];
 		else
 			track=double(track); %for some reason, it is of class "single"
 		end
-		if(size(track,2)==2), track=[track 3*ones(size(track,1),1)]; end
+		if(size(track,2)==2), track=[track 3.*ones(size(track,1),1)]; end
 
 		%only keep those inside
 		flags=ContourToNodes(track(:,1),track(:,2),domainfile,0);
@@ -223,7 +223,7 @@
 		%Add all points to bamg_geometry
 		nods=size(track,1);
 		bamg_geometry.Vertices=[bamg_geometry.Vertices; track];
-		bamg_geometry.Edges=[bamg_geometry.Edges; [transpose(count+1:count+nods-1) transpose([count+2:count+nods])  3*ones(nods-1,1)]];
+		bamg_geometry.Edges=[bamg_geometry.Edges; [transpose(count+1:count+nods-1) transpose(count+2:count+nods)  3.*ones(nods-1,1)]];
 
 		%update counter
 		count=count+nods;
@@ -234,8 +234,8 @@
 
 		%recover RequiredVertices
 		requiredvertices=double(getfieldvalue(options,'RequiredVertices')); %for some reason, it is of class "single"
-		if(size(requiredvertices,2)==2), requiredvertices=[requiredvertices 4*ones(size(requiredvertices,1),1)]; end
-	
+		if(size(requiredvertices,2)==2), requiredvertices=[requiredvertices 4.*ones(size(requiredvertices,1),1)]; end
+
 		%only keep those inside
 		flags=ContourToNodes(requiredvertices(:,1),requiredvertices(:,2),domain(1),0);
 		requiredvertices=requiredvertices(find(flags),:);
@@ -275,29 +275,29 @@
 %}}}
 % Bamg Options {{{
 bamg_options.Crack=getfieldvalue(options,'Crack',0);
-bamg_options.anisomax=getfieldvalue(options,'anisomax',10^30);
-bamg_options.coeff=getfieldvalue(options,'coeff',1);
-bamg_options.cutoff=getfieldvalue(options,'cutoff',10^-5);
+bamg_options.anisomax=getfieldvalue(options,'anisomax',10.^30);
+bamg_options.coeff=getfieldvalue(options,'coeff',1.);
+bamg_options.cutoff=getfieldvalue(options,'cutoff',10.^-5);
 bamg_options.err=getfieldvalue(options,'err',0.01);
 bamg_options.errg=getfieldvalue(options,'errg',0.1);
 bamg_options.field=getfieldvalue(options,'field',[]);
 bamg_options.gradation=getfieldvalue(options,'gradation',1.5);
 bamg_options.Hessiantype=getfieldvalue(options,'Hessiantype',0);
-bamg_options.hmin=getfieldvalue(options,'hmin',10^-100);
-bamg_options.hmax=getfieldvalue(options,'hmax',10^100);
+bamg_options.hmin=getfieldvalue(options,'hmin',10.^-100);
+bamg_options.hmax=getfieldvalue(options,'hmax',10.^100);
 bamg_options.hminVertices=getfieldvalue(options,'hminVertices',[]);
 bamg_options.hmaxVertices=getfieldvalue(options,'hmaxVertices',[]);
 bamg_options.hVertices=getfieldvalue(options,'hVertices',[]);
 bamg_options.KeepVertices=getfieldvalue(options,'KeepVertices',1);
-bamg_options.MaxCornerAngle=getfieldvalue(options,'MaxCornerAngle',10);
+bamg_options.MaxCornerAngle=getfieldvalue(options,'MaxCornerAngle',10.);
 bamg_options.maxnbv=getfieldvalue(options,'maxnbv',10^6);
-bamg_options.maxsubdiv=getfieldvalue(options,'maxsubdiv',10);
+bamg_options.maxsubdiv=getfieldvalue(options,'maxsubdiv',10.);
 bamg_options.metric=getfieldvalue(options,'metric',[]);
 bamg_options.Metrictype=getfieldvalue(options,'Metrictype',0);
 bamg_options.nbjacobi=getfieldvalue(options,'nbjacobi',1);
 bamg_options.nbsmooth=getfieldvalue(options,'nbsmooth',3);
 bamg_options.omega=getfieldvalue(options,'omega',1.8);
-bamg_options.power=getfieldvalue(options,'power',1);
+bamg_options.power=getfieldvalue(options,'power',1.);
 bamg_options.splitcorners=getfieldvalue(options,'splitcorners',1);
 bamg_options.geometricalmetric=getfieldvalue(options,'geometricalmetric',0);
 bamg_options.verbose=getfieldvalue(options,'verbose',1);
@@ -333,14 +333,12 @@
 md.mesh.elementconnectivity(find(isnan(md.mesh.elementconnectivity)))=0;
 
 %Check for orphan
-reshape(md.mesh.elements,3*md.mesh.numberofelements,1);
-(~ismember(1:md.mesh.numberofvertices,sort(unique(reshape(md.mesh.elements,3*md.mesh.numberofelements,1)))));
 if any(~ismember(1:md.mesh.numberofvertices,sort(unique(reshape(md.mesh.elements,3*md.mesh.numberofelements,1)))))
 	error('Output mesh has orphans. Decrease MaxCornerAngle to prevent outside points (ex: 0.01)');
 end
 end 
 
-function geom=processgeometry(geom,tol,outline); % {{{
+function geom=processgeometry(geom,tol,outline) % {{{
 
 %Deal with edges
 disp('Checking Edge crossing...');

Modified: issm/trunk/src/m/mesh/meshconvert.py
===================================================================
--- issm/trunk/src/m/mesh/meshconvert.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/meshconvert.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -51,7 +51,7 @@
 	md.mesh.elementonbed=numpy.ones(md.mesh.numberofelements)
 	md.mesh.elementonsurface=numpy.ones(md.mesh.numberofelements)
 	md.mesh.vertexonboundary=numpy.zeros(md.mesh.numberofvertices)
-	md.mesh.vertexonboundary[md.mesh.segments[:,0:1].astype(int)-1]=1
+	md.mesh.vertexonboundary[md.mesh.segments[:,0:2].astype(int)-1]=1
 
 	return md
 

Modified: issm/trunk/src/m/mesh/planet/mesh_refine_tri4.m
===================================================================
--- issm/trunk/src/m/mesh/planet/mesh_refine_tri4.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/planet/mesh_refine_tri4.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -28,7 +28,6 @@
 % See also: mesh_refine, sphere_tri, sphere_project
 % 
 
-
 % ---this method is not implemented, but the idea here remains...
 % This can be done until some minimal distance (D) of the mean 
 % distance between vertices of all triangles is achieved.  If
@@ -36,7 +35,6 @@
 % Alternatively, it could be done until some minimum mean 
 % area of faces is achieved.  As is, it just refines once.
 
-
 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $
 
 % Licence:  GNU GPL, no implied or express warranties
@@ -79,39 +77,39 @@
 F2 = zeros(Nface*4,3);
 
 for f = 1:Nface,
-    
+
     % Get the triangle vertex indices
     NA = FV.faces(f,1);
     NB = FV.faces(f,2);
     NC = FV.faces(f,3);
-    
+
     % Get the triangle vertex coordinates
     A = FV.vertices(NA,:);
     B = FV.vertices(NB,:);
     C = FV.vertices(NC,:);
-    
+
     % Now find the midpoints between vertices
     a = (A + B) ./ 2;
     b = (B + C) ./ 2;
     c = (C + A) ./ 2;
-    
+
     % Find the length of each median
     %A2blen = sqrt ( sum( (A - b).^2, 2 ) );
     %B2clen = sqrt ( sum( (B - c).^2, 2 ) );
     %C2alen = sqrt ( sum( (C - a).^2, 2 ) );
-    
+
     % Store the midpoint vertices, while
     % checking if midpoint vertex already exists
     [FV, Na] = mesh_find_vertex(FV,a);
     [FV, Nb] = mesh_find_vertex(FV,b);
     [FV, Nc] = mesh_find_vertex(FV,c);
-    
+
     % Create new faces with orig vertices plus midpoints
     F2(f*4-3,:) = [ NA, Na, Nc ];
     F2(f*4-2,:) = [ Na, NB, Nb ];
     F2(f*4-1,:) = [ Nc, Nb, NC ];
     F2(f*4-0,:) = [ Na, Nb, Nc ];
-    
+
 end
 
 % Replace the faces matrix
@@ -121,7 +119,6 @@
 
 return
 
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 function [FV, N] = mesh_find_vertex(FV,vertex)

Modified: issm/trunk/src/m/mesh/planet/planetmixedmesh.m
===================================================================
--- issm/trunk/src/m/mesh/planet/planetmixedmesh.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/planet/planetmixedmesh.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -32,12 +32,12 @@
 for i=1:nphi-1,
 	for j=1:nthetha-1,
 		count=(i-1)*(nthetha-1)+j;
-	
+
 		A=(i-1)*nthetha+j;
 		B=(i-1)*nthetha+j+1;
 		C=(i)*nthetha+j+1;
 		D=(i)*nthetha+j;
-		
+
 		quads(count,:)=[A B C D];
 	end
 end
@@ -63,7 +63,6 @@
 
 quads=[trias;quads];
 
-
 % now add south pole: 
 phii=180*conv;
 x=[x;r.*cos(phii).*sin(phii)];
@@ -84,7 +83,6 @@
 
 quads=[quads;trias];
 
-
 md.mesh.elements=quads;
 md.mesh.x=x;
 md.mesh.y=y;

Modified: issm/trunk/src/m/mesh/planet/sphere_project.m
===================================================================
--- issm/trunk/src/m/mesh/planet/sphere_project.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/planet/sphere_project.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -49,7 +49,6 @@
 % by the radius required.  This avoids the
 % use of arctan functions, which have branches.
 
-
 % Convert Cartesian X,Y,Z to spherical (radians)
 theta = atan2( (Y-yo), (X-xo) );
 phi   = atan2( sqrt( (X-xo).^2 + (Y-yo).^2 ), (Z-zo) );

Modified: issm/trunk/src/m/mesh/planet/sphere_tri.m
===================================================================
--- issm/trunk/src/m/mesh/planet/sphere_tri.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/planet/sphere_tri.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -43,8 +43,6 @@
 % See also: mesh_refine, sphere_project
 %
 
-
-
 % $Revision: 1.2 $ $Date: 2005/07/20 23:07:03 $
 
 % Licence:  GNU GPL, no implied or express warranties
@@ -79,7 +77,6 @@
     winding = 0;
 end
 
-
 % -----------------
 % define the starting shapes
 
@@ -87,26 +84,26 @@
 
 switch shape,
 case 'tetra',
-    
+
     % Vertices of a tetrahedron
     sqrt_3 = 0.5773502692;
-    
+
     tetra.v = [  sqrt_3,  sqrt_3,  sqrt_3 ;   % +X, +Y, +Z  - PPP
                 -sqrt_3, -sqrt_3,  sqrt_3 ;   % -X, -Y, +Z  - MMP
                 -sqrt_3,  sqrt_3, -sqrt_3 ;   % -X, +Y, -Z  - MPM
                  sqrt_3, -sqrt_3, -sqrt_3 ];  % +X, -Y, -Z  - PMM
-	
+
     % Structure describing a tetrahedron
     tetra.f = [ 1, 2, 3;
                 1, 4, 2;
                 3, 2, 4;
                 4, 1, 3 ];
-    
+
     FV.vertices = tetra.v;
     FV.faces    = tetra.f;
-    
+
 case 'oct',
-    
+
     % Six equidistant points lying on the unit sphere
     oct.v = [  1,  0,  0 ;  %  X
               -1,  0,  0 ; 	% -X
@@ -114,7 +111,7 @@
                0, -1,  0 ; 	% -Y
                0,  0,  1 ; 	%  Z
                0,  0, -1 ];	% -Z
-	
+
     % Join vertices to create a unit octahedron
     oct.f = [ 1 5 3 ;    %  X  Z  Y  -  First the top half
               3 5 2 ;    %  Y  Z -X
@@ -124,16 +121,16 @@
               3 2 6 ;    %  Y  Z -Z
               2 4 6 ;    % -X  Z -Z
               4 1 6 ];   % -Y  Z -Z
-    
+
     FV.vertices = oct.v;
     FV.faces    = oct.f;
-    
+
 case 'ico',
-    
+
     % Twelve vertices of icosahedron on unit sphere
     tau = 0.8506508084; % t=(1+sqrt(5))/2, tau=t/sqrt(1+t^2)
     one = 0.5257311121; % one=1/sqrt(1+t^2) , unit sphere
-    
+
     ico.v( 1,:) = [  tau,  one,    0 ]; % ZA
     ico.v( 2,:) = [ -tau,  one,    0 ]; % ZB
     ico.v( 3,:) = [ -tau, -one,    0 ]; % ZC
@@ -146,7 +143,7 @@
     ico.v(10,:) = [   0 , -tau,  one ]; % XB
     ico.v(11,:) = [   0 , -tau, -one ]; % XC
     ico.v(12,:) = [   0 ,  tau, -one ]; % XD
-    
+
     % Structure for unit icosahedron
     ico.f = [  5,  8,  9 ;
                5, 10,  8 ;
@@ -168,27 +165,26 @@
                7, 12,  2 ;
                8, 10,  3 ;
                7,  3, 11 ];
-	
+
     FV.vertices = ico.v;
     FV.faces    = ico.f;
 end
 
-
 % -----------------
 % refine the starting shapes with subdivisions
 if maxlevel,
-    
+
     % Subdivide each starting triangle (maxlevel) times
     for level = 1:maxlevel,
-        
+
         % Subdivide each triangle and normalize the new points thus
         % generated to lie on the surface of a sphere radius r.
         FV = mesh_refine_tri4(FV);
         FV.vertices = sphere_project(FV.vertices,r);
-        
+
         % An alternative might be to define a min distance
         % between vertices and recurse or use fminsearch
-        
+
     end
 end
 

Modified: issm/trunk/src/m/mesh/rifts/meshaddrifts.m
===================================================================
--- issm/trunk/src/m/mesh/rifts/meshaddrifts.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/rifts/meshaddrifts.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function md=meshaddrifts(md,riftname);
+function md=meshaddrifts(md,riftname)
 %MESHADDRIFTS - add rifts to a preloaded mesh (typically, an argus mesh)
 %
 %   Usage:
@@ -11,7 +11,6 @@
 %        will be used to define the rift contour density of the mesh. The open contour density will 
 %        be preserved. There can be as many pairs of closed contour and rift contour as wished.
 
-
 %read rift: 
 domains=expread(riftname,1);
 contours=domains(1:2:end);
@@ -19,20 +18,20 @@
 
 %now loop over rifts: 
 for rift_i=1:length(rifts),
-	
+
 	%refine rift to desired resolution: 
 	contour=contours(rift_i);
 	rift=rifts(rift_i);
-	
+
 	delete('Meshaddrifts.Rift.exp');
 	expwrite(rift,'Meshaddrifts.Rift.Coarse.exp');
 	expcoarsen('Meshaddrifts.Rift.exp','Meshaddrifts.Rift.Coarse.exp',rift.density);
 	delete('Meshaddrifts.Rift.Coarse.exp');
-	
+
 	%extract model:
 	expwrite(contour,'Meshaddrifts.Contour.exp');
 	md2=modelextract(md,'Meshaddrifts.Contour.exp');
-	
+
 	%create domain of md2 model: 
 	md2.mesh.segments=contourenvelope(md2,'Meshaddrifts.Contour.exp');
 	domain_index=md2.mesh.segments(1,1:2);
@@ -40,31 +39,31 @@
 		pos=find(md2.mesh.segments(:,1)==domain_index(end));
 		domain_index(end+1)=md2.mesh.segments(pos,2);
 	end
-	
+
 	domain.x=md2.mesh.x(domain_index);
 	domain.y=md2.mesh.y(domain_index);
 	domain.name='Meshaddrifts.Domain.exp';
 	domain.density=1;
 	expwrite(domain,'Meshaddrifts.Domain.exp');
-	
+
 	%unloop domain index: used for later.
 	domain_index=domain_index(1:end-1);
-	
+
 	%remesh md2 using new domain outline, and rift profile: 
 	md2=meshnodensity(md2,'Meshaddrifts.Domain.exp','Meshaddrifts.Rift.exp');
 	md2=meshprocessrifts(md2);
-	
+
 	%plug md2 mesh into md mesh: 
 	[md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.z,md.mesh.numberofelements,md.mesh.numberofvertices,elconv,nodeconv,elconv2,nodeconv2]=meshplug(md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.z,...
 								md2.mesh.elements,md2.mesh.x,md2.mesh.y,md2.mesh.z,md2.extractednodes,md2.extractedelements,domain_index);
 
 	%update md2 rifts using elconv and nodeconv, and plug them into md: 
 	md2.rifts=updateriftindexing(md2.rifts,elconv2,nodeconv2);
-	
+
 	for i=1:md.rifts.numrifts,
 		md.rifts.riftstruct(i)=updateriftindexing(md.rifts.riftstruct(i),elconv,nodeconv);
 	end
-	
+
 	if md.rifts.numrifts==0,
 		md.rifts.riftstruct=md2.rifts;
 		md.rifts.numrifts=1;
@@ -72,7 +71,7 @@
 		md.rifts.riftstruct(end+1,1)=md2.rifts;
 		md.rifts.numrifts=md.rifts.numrifts+1;
 	end
-	
+
 	md.mesh.segments(:,1:2)=nodeconv(md.mesh.segments(:,1:2));
 	md.mesh.segments(:,3)=elconv(md.mesh.segments(:,3));
 

Modified: issm/trunk/src/m/mesh/rifts/meshplug.m
===================================================================
--- issm/trunk/src/m/mesh/rifts/meshplug.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/rifts/meshplug.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,8 +1,7 @@
-function [elements,x,y,z,numberofelements,numberofnodes,elconv,nodeconv,elconv2,nodeconv2]=meshplug(elements,x,y,z,elements2,x2,y2,z2,extractednodes,extractedelements,domain);
+function [elements,x,y,z,numberofelements,numberofnodes,elconv,nodeconv,elconv2,nodeconv2]=meshplug(elements,x,y,z,elements2,x2,y2,z2,extractednodes,extractedelements,domain)
 %MESHPLUG - embed mesh into another one
 %     See also meshaddrifts
 
-
 %initialize elconv,nodeconv conversion tables from md mesh to new md mesh
 elconv=1:size(elements,1); elconv=elconv';
 nodeconv=1:size(x,1); nodeconv=nodeconv';
@@ -47,11 +46,9 @@
 	nodeconv2(i)=extractednodes(domain(i));
 end
 
-
 %plug elements
 elements=[elements;elements2];
 
-
 %now, increase number of nodes
 x=[x; x2];
 y=[y; y2];
@@ -86,4 +83,3 @@
 temp_nodeconvnum=1:length(temp_nodeconv);
 nodeconv(temp_nodeconv)=temp_nodeconvnum;
 nodeconv(extractednodes_minusborder)=NaN;
-

Modified: issm/trunk/src/m/mesh/rifts/meshprocessoutsiderifts.m
===================================================================
--- issm/trunk/src/m/mesh/rifts/meshprocessoutsiderifts.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/rifts/meshprocessoutsiderifts.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,11 +5,9 @@
 %      md=meshprocessoutsiderifts(md,domain)
 %
 
-
-
 %go through rifts, and figure out which ones touch the domain outline
-for i=1:md.rifts.numrifts,
-	
+for i=1:length(md.rifts.riftstruct),
+
 	%first, flag nodes that belong to the domain outline
 	flags=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,domainoutline,'node',0);
 
@@ -19,7 +17,7 @@
 
 	%we have found outsidetips, tips that touch the domain outline. go through them
 	for j=1:length(outsidetips),
-		
+
 		tip=outsidetips(j);
 		%find tip in the segments, take first segment (there should be 2) that holds tip, 
 		%and node_connected_to_tip is the other node on this segment:
@@ -40,7 +38,7 @@
 
 		elements=[];
 
-		while  flags(B), %as long as B does not belong to the domain outline, keep looking.
+		while flags(B), %as long as B does not belong to the domain outline, keep looking.
 			%detect elements on edge A,B:
 			edgeelements=ElementsFromEdge(md.mesh.elements,A,B);
 			%rule out those we already detected
@@ -51,14 +49,14 @@
 			%new B:
 			B=md.mesh.elements(nextelement,find(~ismember(md.mesh.elements(nextelement,:),[A B])));
 		end
-		
+
 		%take the list of elements on one side of the rift that connect to the tip, 
 		%and duplicate the tip on them, so as to open the rift to the outside.
 		num=length(md.mesh.x)+1;
 		md.mesh.x=[md.mesh.x;md.mesh.x(tip)];
 		md.mesh.y=[md.mesh.y;md.mesh.y(tip)];
 		md.mesh.numberofvertices=num;
-		
+
 		%replace tip in elements
 		newelements=md.mesh.elements(elements,:);
 		pos=find(newelements==tip);
@@ -68,7 +66,7 @@
 
 		%deal with segments
 		tipsegments=find((md.mesh.segments(:,1)==tip) | (md.mesh.segments(:,2)==tip));
-		for  k=1:length(tipsegments),
+		for k=1:length(tipsegments),
 			segment_index=tipsegments(k);
 			pos=find(md.mesh.segments(segment_index,1:2)~=tip);
 			other_node=md.mesh.segments(segment_index,pos);
@@ -80,13 +78,11 @@
 	end
 end
 
-
 %Fill in rest of fields:
 md.mesh.numberofelements=length(md.mesh.elements);
 md.mesh.numberofvertices=length(md.mesh.x);
 md.mesh.z=zeros(md.mesh.numberofvertices,1);
 md.mesh.vertexonboundary=zeros(length(md.mesh.x),1); md.mesh.vertexonboundary(md.mesh.segments(:,1:2))=1;
-md.rifts.numrifts=length(md.rifts.riftstruct);
 md.flowequation.element_equation=3*ones(md.mesh.numberofelements,1);
 md.mesh.vertexonbed=ones(md.mesh.numberofvertices,1);
 md.mesh.vertexonsurface=ones(md.mesh.numberofvertices,1);

Modified: issm/trunk/src/m/mesh/rifts/rifttipsonmesh.m
===================================================================
--- issm/trunk/src/m/mesh/rifts/rifttipsonmesh.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/rifts/rifttipsonmesh.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 %                rifts.
 
 %read rifts from outline file
-rifts=expread(riftoutline,1);
+rifts=expread(riftoutline);
 
 tips=[];
 
@@ -12,15 +12,14 @@
 
 	x_tip=rift.x(1);
 	y_tip=rift.y(1);
-	
+
 	index=find_point(md.mesh.x,md.mesh.y,x_tip,y_tip);
 	tips(end+1)=index;
 
 	x_tip=rift.x(end);
 	y_tip=rift.y(end);
-	
+
 	index=find_point(md.mesh.x,md.mesh.y,x_tip,y_tip);
 	tips(end+1)=index;
 
 end
-

Modified: issm/trunk/src/m/mesh/rifts/rifttipsrefine.m
===================================================================
--- issm/trunk/src/m/mesh/rifts/rifttipsrefine.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/rifts/rifttipsrefine.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function md=rifttipsrefine(md,filename,resolution,circleradius);
+function md=rifttipsrefine(md,filename,resolution,circleradius)
 %RIFTTIPSREFINE - refine mesh near rift tips
 %
 %   Usage:

Modified: issm/trunk/src/m/mesh/roundmesh.m
===================================================================
--- issm/trunk/src/m/mesh/roundmesh.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/roundmesh.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,14 +11,14 @@
 %First we have to create the domain outline 
 
 %Get number of points on the circle
-pointsonedge=floor((2*pi*radius) / resolution);
+pointsonedge=floor((2.*pi*radius) / resolution);
 
 %Calculate the cartesians coordinates of the points
 x_list=ones(pointsonedge,1); y_list=ones(pointsonedge,1);
-theta=(0:2*pi/pointsonedge:2*pi*(1-1/pointsonedge))';
-x_list=radius*x_list.*cos(theta);
-y_list=radius*y_list.*sin(theta);
-A=struct('x',x_list,'y',y_list,'density',1);
+theta=(0.:2.*pi/pointsonedge:2.*pi*(1.-1./pointsonedge))';
+x_list=roundsigfig(radius*x_list.*cos(theta),12);
+y_list=roundsigfig(radius*y_list.*sin(theta),12);
+A=struct('x',x_list,'y',y_list,'density',1.);
 expwrite(A,'RoundDomainOutline.exp');
 
 %Call Bamg
@@ -27,8 +27,22 @@
 
 %move the closest node to the center
 [mini pos]=min(md.mesh.x.^2+md.mesh.y.^2);
-md.mesh.x(pos)=0;
-md.mesh.y(pos)=0;
+md.mesh.x(pos)=0.;
+md.mesh.y(pos)=0.;
 
 %delete domain
 delete('RoundDomainOutline.exp')
+end
+
+function x=roundsigfig(x,n)
+
+digits=ceil(log10(abs(x)));
+x=x./10.^digits;
+x=round(x.*10.^n)./10.^n;
+x=x.*10.^digits;
+
+pos=find(isnan(x));
+x(pos)=0.;
+
+end
+

Modified: issm/trunk/src/m/mesh/triangle.py
===================================================================
--- issm/trunk/src/m/mesh/triangle.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/mesh/triangle.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,56 +1,66 @@
-from numpy import *
-import TriMesh as tm
-import NodeConnectivity as nc
-import ElementConnectivity as ec
+import numpy
+from TriMesh import *
+from NodeConnectivity import *
+from ElementConnectivity import *
+from MatlabFuncs import *
 
-def triangle(md, domainname, resolution,riftname=''):
-	#TRIANGLE - create model mesh using the triangle package
-	#
-	#   This routine creates a model mesh using TriMesh and a domain outline, to within a certain resolution
-	#   where md is a @model object, domainname is the name of an Argus domain outline file, 
-	#   and resolution is a characteristic length for the mesh (same unit as the domain outline
-	#   unit). Riftname is an optional argument (Argus domain outline) describing rifts.
-	#
-	#   Usage:
-	#      md=triangle(md,domainname,resolution)
-	#   or md=triangle(md,domainname, resolution, riftname)
-	#
-	#   Examples:
-	#      md=triangle(md,'DomainOutline.exp',1000);
-	#      md=triangle(md,'DomainOutline.exp',1000,'Rifts.exp');
+def triangle(md,domainname,*args):
+	"""
+	TRIANGLE - create model mesh using the triangle package
 
+	   This routine creates a model mesh using TriMesh and a domain outline, to within a certain resolution
+	   where md is a @model object, domainname is the name of an Argus domain outline file, 
+	   and resolution is a characteristic length for the mesh (same unit as the domain outline
+	   unit). Riftname is an optional argument (Argus domain outline) describing rifts.
 
+	   Usage:
+	      md=triangle(md,domainname,resolution)
+	   or md=triangle(md,domainname, resolution, riftname)
+
+	   Examples:
+	      md=triangle(md,'DomainOutline.exp',1000);
+	      md=triangle(md,'DomainOutline.exp',1000,'Rifts.exp');
+	"""
+
 	#Figure out a characteristic area. Resolution is a node oriented concept (ex a 1000m  resolution node would 
 	#be made of 1000*1000 area squares). 
 
+	if len(args)==1:
+		resolution=args[0]
+		riftname=''
+	if len(args)==2:
+		riftname=args[0]
+		resolution=args[1]
+
 	#Check that mesh was not already run, and warn user: 
-	if md.mesh.numberofelements != 0.:
-		choice = input('This model already has a mesh. Are you sure you want to go ahead? (y/n)')
-		if choice != 'y':
+	if md.mesh.numberofelements:
+		choice = raw_input('This model already has a mesh. Are you sure you want to go ahead? (y/n)')
+		if not strcmp(choice,'y'):
 			print 'no meshing done ... exiting'
-			return []
-		
-	area = resolution**2.
+			return None
 
+	area = resolution**2
+
 	#Mesh using TriMesh
-	[md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers]=tm.TriMesh(domainname,riftname,area)
+	[md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers]=TriMesh(domainname,riftname,area)
 
-
 	#Fill in rest of fields:
-	md.mesh.numberofelements = len(md.mesh.elements)
-	md.mesh.numberofvertices = len(md.mesh.x)
-	md.mesh.z = zeros(md.mesh.numberofvertices)
-	md.mesh.vertexonboundary = zeros(md.mesh.numberofvertices)
+	md.mesh.numberofelements = numpy.size(md.mesh.elements,axis=0)
+	md.mesh.numberofvertices = numpy.size(md.mesh.x)
+	md.mesh.z = numpy.zeros(md.mesh.numberofvertices)
+	md.mesh.vertexonboundary = numpy.zeros(md.mesh.numberofvertices)
 	md.mesh.vertexonboundary[md.mesh.segments[:,0:2].astype(int)-1] = 1.
-	md.mesh.vertexonbed = ones(md.mesh.numberofvertices)
-	md.mesh.vertexonsurface = ones(md.mesh.numberofvertices)
-	md.mesh.elementonbed = ones(md.mesh.numberofelements)
-	md.mesh.elementonsurface = ones(md.mesh.numberofelements)
+	md.mesh.vertexonbed = numpy.ones(md.mesh.numberofvertices)
+	md.mesh.vertexonsurface = numpy.ones(md.mesh.numberofvertices)
+	md.mesh.elementonbed = numpy.ones(md.mesh.numberofelements)
+	md.mesh.elementonsurface = numpy.ones(md.mesh.numberofelements)
 
 	#Now, build the connectivity tables for this mesh.
-	[md.mesh.vertexconnectivity]= nc.NodeConnectivity(md.mesh.elements, md.mesh.numberofvertices)
-	[md.mesh.elementconnectivity] = ec.ElementConnectivity(md.mesh.elements, md.mesh.vertexconnectivity)
-	
+	[md.mesh.vertexconnectivity]= NodeConnectivity(md.mesh.elements, md.mesh.numberofvertices)
+	[md.mesh.elementconnectivity] = ElementConnectivity(md.mesh.elements, md.mesh.vertexconnectivity)
+
 	#type of model
 	md.mesh.dimension = 2.
+
 	return md
+

Modified: issm/trunk/src/m/miscellaneous/MatlabFuncs.py
===================================================================
--- issm/trunk/src/m/miscellaneous/MatlabFuncs.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/miscellaneous/MatlabFuncs.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -52,9 +52,39 @@
 		b=[item in s for item in a]
 
 	else:
-		b=numpy.empty_like(a)
-		for i,item in enumerate(a.flat):
-			b.flat[i]=item in s
+		if not isinstance(s,numpy.ndarray):
+			b=numpy.empty_like(a)
+			for i,item in enumerate(a.flat):
+				b.flat[i]=item in s
+		else:
+			b=numpy.in1d(a.flat,s.flat).reshape(a.shape)
 
 	return b
 
+def det(a):
+	import numpy
+
+	if   a.shape==(1,):
+		return a[0]
+	elif a.shape==(1,1):
+		return a[0,0]
+	elif a.shape==(2,2):
+		return a[0,0]*a[1,1]-a[0,1]*a[1,0]
+	else:
+		raise TypeError("MatlabFunc.det only implemented for shape (2, 2), not for shape %s." % str(a.shape))
+
+def sparse(ivec,jvec,svec,m=0,n=0,nzmax=0):
+	import numpy
+
+	if not m:
+		m=numpy.max(ivec)
+	if not n:
+		n=numpy.max(jvec)
+
+	a=numpy.zeros((m,n))
+
+	for i,j,s in zip(ivec.reshape(-1,order='F'),jvec.reshape(-1,order='F'),svec.reshape(-1,order='F')):
+		a[i-1,j-1]+=s
+
+	return a
+

Modified: issm/trunk/src/m/miscellaneous/fielddisplay.m
===================================================================
--- issm/trunk/src/m/miscellaneous/fielddisplay.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/miscellaneous/fielddisplay.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,7 +12,7 @@
 
 end %function
 
-function parsedisplay(offset,name,field,comment); %{{{
+function parsedisplay(offset,name,field,comment) %{{{
 
 	%string
 	if ischar(field),

Modified: issm/trunk/src/m/miscellaneous/fielddisplay.py
===================================================================
--- issm/trunk/src/m/miscellaneous/fielddisplay.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/miscellaneous/fielddisplay.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -50,6 +50,10 @@
 	elif isinstance(field,(list,tuple)):
 		string=list_display(offset,name,field,comment)
 
+	#None
+	elif field is None:
+		string=displayunit(offset,name,"None",comment)
+
 	else:
 		string=displayunit(offset,name,"not displayed",comment)
 		
@@ -127,7 +131,7 @@
 		elif isinstance(comment,list):
 			string="%s%-23s: %-15s -- %s" % (offset,name,characterization,comment[0])
 			for commenti in comment:
-				string+="\n%s%-23s  %-15s    %s" % (offset,'','',comment[i])
+				string+="\n%s%-23s  %-15s    %s" % (offset,'','',commenti)
 		else:
 			raise RuntimeError("fielddisplay error message: format for comment not supported yet")
 

Modified: issm/trunk/src/m/miscellaneous/isnans.m
===================================================================
--- issm/trunk/src/m/miscellaneous/isnans.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/miscellaneous/isnans.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,6 @@
 %
 %  See also : ISNAN 
 
-
 if isstruct(array), 
 	returnvalue=0;
 elseif iscell(array)

Modified: issm/trunk/src/m/miscellaneous/issmdoc.m
===================================================================
--- issm/trunk/src/m/miscellaneous/issmdoc.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/miscellaneous/issmdoc.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,13 +3,13 @@
 %First get ISSM tier: 
 ISSM_DIR=issmdir();
 
-disp(sprintf('\n%s','  A comprehensive documentation is available on http://issm.jpl.nasa.gov'));
-disp(sprintf('\n%s','  Example: how to create a square ice shelf'));
-disp(sprintf('%s','	   go to ',ISSM_DIR,'/examples/SquareIceshelf'));
-disp(sprintf('%s','	   md=model;                                %creates a new empty model structure'));
-disp(sprintf('%s','	   md=triangle(md,''DomainOutline.exp'',50000);   %creates a mesh of the domain outline with a resolution of 50000m'));
-disp(sprintf('%s','	   md=setmask(md,''all'','''');               %defines the glacier system as an ice shelf (no island)'));
-disp(sprintf('%s','	   md=parameterize(md,''Square.par'');        %fills all the other fields of the model'));
-disp(sprintf('%s','	   md=setflowequation(md,''macayeal'',''all''); %defines all elements as MacAyeal''s'));
-disp(sprintf('%s','	   md=solve(md,DiagnosticSolutionEnum());   %generate the velocity field'));
-disp(sprintf('%s','	   plotmodel(md,''data'',md.results.DiagnosticSolution.Vel);    %displays the velocity (type plotdoc for plotmodel help)'));
+disp('  A comprehensive documentation is available on http://issm.jpl.nasa.gov');
+disp('  Example: how to create a square ice shelf');
+disp(['       go to ',ISSM_DIR,'/examples/SquareIceShelf']);
+disp(sprintf('%-63s %s','       md=model;','%creates a new empty model structure'));
+disp(sprintf('%-63s %s','       md=triangle(md,''DomainOutline.exp'',50000);','%creates a mesh of the domain outline with a resolution of 50000 m'));
+disp(sprintf('%-63s %s','       md=setmask(md,''all'','''');','%defines the glacier system as an ice shelf (no island)'));
+disp(sprintf('%-63s %s','       md=parameterize(md,''Square.par'');','%fills all the other fields of the model'));
+disp(sprintf('%-63s %s','       md=setflowequation(md,''macayeal'',''all'');','%defines all elements as MacAyeal''s SSA'));
+disp(sprintf('%-63s %s','       md=solve(md,DiagnosticSolutionEnum());','%solve for stress balance'));
+disp(sprintf('%-63s %s','       plotmodel(md,''data'',md.results.DiagnosticSolution.Vel);','%displays the velocity (type plotdoc for plotmodel help)'));

Modified: issm/trunk/src/m/miscellaneous/parallelrange.m
===================================================================
--- issm/trunk/src/m/miscellaneous/parallelrange.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/miscellaneous/parallelrange.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,6 @@
 	num_local_rows(i)=floor(globalsize/numprocs);
 end
 
-
 %There may be some rows left. Distribute evenly.
 row_rest=globalsize - numprocs*floor(globalsize/numprocs);
 

Modified: issm/trunk/src/m/os/ismpi.m
===================================================================
--- issm/trunk/src/m/os/ismpi.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/os/ismpi.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,7 +4,6 @@
 %   Usage:
 %       flag=ismpi();
 
-
 configfile=[issmdir() '/bin/config.h']; %should find it in the install target
 if ~exist(configfile,'file'),
 	error(['File ' configfile ' not found. ISSM has not been configured yet!']);

Modified: issm/trunk/src/m/os/ismumps.m
===================================================================
--- issm/trunk/src/m/os/ismumps.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/os/ismumps.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,7 +4,6 @@
 %   Usage:
 %       flag=ismumps();
 
-
 configfile=[issmdir() '/bin/config.h']; %should find it in the install target
 if ~exist(configfile,'file'),
 	error(['File ' configfile ' not found. ISSM has not been configured yet!']);

Modified: issm/trunk/src/m/os/ispetsc.m
===================================================================
--- issm/trunk/src/m/os/ispetsc.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/os/ispetsc.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,7 +4,6 @@
 %   Usage:
 %       flag=ispetsc();
 
-
 configfile=[issmdir() '/bin/config.h']; %should find it in the install target
 if ~exist(configfile,'file'),
 	error(['File ' configfile ' not found. ISSM has not been configured yet!']);

Modified: issm/trunk/src/m/os/issmbbftpin.m
===================================================================
--- issm/trunk/src/m/os/issmbbftpin.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/os/issmbbftpin.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -34,7 +34,7 @@
 		command=[command 'get ' packages{i} ';'];
 	end
 	command=[command '''  pfe1.nas.nasa.gov'];
-	
+
 	eval(command);
 
 	%check bbftp worked
@@ -44,5 +44,4 @@
 		end
 	end
 
-
 end

Modified: issm/trunk/src/m/os/issmbbftpout.m
===================================================================
--- issm/trunk/src/m/os/issmbbftpout.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/os/issmbbftpout.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,13 +18,13 @@
 		eval(['cd ' here]);
 	end
 else 
-	
+
 	%build a string of the type: bbftp -s -u elarour -e 'setnbstream 8; cd /nobackupp10/elarour/Testing/Interactive3/; put Antarctica.tar.gz' pfe1.nas.nasa.gov
 	command=['!bbftp -s -V -u ' login ' -e ''setnbstream 8; cd ' path '; ']
 	for i=1:length(packages),
 		command=[command 'put ' packages{i} ';'];
 	end
 	command=[command '''  pfe1.nas.nasa.gov'];
-	
+
 	eval(command);
 end

Modified: issm/trunk/src/m/os/issmscpin.m
===================================================================
--- issm/trunk/src/m/os/issmscpin.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/os/issmscpin.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,7 +30,7 @@
 
 	if ispc(),
 		%use the putty project pscp.exe: it should be in the path.
-		
+
 		%get ISSM_DIR variable
 		[status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
 		if status, 
@@ -61,13 +61,12 @@
 			string=[string packages{end} '\}'];
 		end
 
-
 		if port,
 			eval(['!scp -P ' num2str(port) ' ' login '@localhost:' path '/' string ' ./']);
 		else
 			eval(['!scp ' login '@' host ':' path '/' string ' ./']);
 		end
-		
+
 		%check scp worked
 		for i=1:numel(packages),
 			if ~exist(['./' packages{i}]),

Modified: issm/trunk/src/m/os/issmscpout.m
===================================================================
--- issm/trunk/src/m/os/issmscpout.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/os/issmscpout.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,7 +21,7 @@
 else 
 	if ispc(),
 		%use the putty project pscp.exe: it should be in the path.
-		
+
 		%get ISSM_DIR variable
 		[status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
 		if status, 
@@ -47,7 +47,7 @@
 			string=[string ' ' packages{i}];
 		end
 		string=[string ' '];
-		
+
 		if port,
 			eval(['!scp -P ' num2str(port) ' ' string ' ' login '@localhost:' path]);
 		else

Modified: issm/trunk/src/m/os/issmssh.m
===================================================================
--- issm/trunk/src/m/os/issmssh.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/os/issmssh.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -13,7 +13,7 @@
 else
 	if ispc(),
 		%use the putty project plink.exe: it should be in the path.
-		
+
 		%get ISSM_DIR variable
 		[status,ISSM_DIR]=system('echo [%ISSM_DIR_WIN%]');
 		if status, 

Modified: issm/trunk/src/m/os/issmssh.py
===================================================================
--- issm/trunk/src/m/os/issmssh.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/os/issmssh.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -39,3 +39,21 @@
 			else:
 				subprocess.call('ssh -l %s %s "%s"' % (login,host,command),shell=True)
 
+	# The following code was added to fix:
+	# "IOError: [Errno 35] Resource temporarily unavailable"
+	# on the Mac when trying to display md after the solution.
+	# (from http://code.google.com/p/robotframework/issues/detail?id=995)
+
+	# Make FreeBSD use blocking I/O like other platforms
+	import sys
+	import fcntl
+	from os import O_NONBLOCK
+
+	fd = sys.stdin.fileno()
+	flags = fcntl.fcntl(fd, fcntl.F_GETFL)
+	fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~O_NONBLOCK)
+
+	fd = sys.stdout.fileno()
+	flags = fcntl.fcntl(fd, fcntl.F_GETFL)
+	fcntl.fcntl(fd, fcntl.F_SETFL, flags & ~O_NONBLOCK)
+

Modified: issm/trunk/src/m/os/oshostname.m
===================================================================
--- issm/trunk/src/m/os/oshostname.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/os/oshostname.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,17 +6,18 @@
 %
 
 if ispc(),
-	[status,hostname]=system('hostname | sed ''s/-//g''');hostname=hostname(1:end-1);
-
+	[status,hostname]=system('hostname | sed ''s/-//g''');
 	if status, 
 		error('oshostname error message: could not run hostname command on windows os');
 	end
-
 else
 	[status,hostname]=system(['hostname -s | sed ''s/-//g''']);
 	if status, 
 		error('oshostname error message: could not run hostname command on *nix os');
 	end
-	hostname=hostname(1:end-1);
-	hostname=ddewhite(hostname);
+
 end
+
+%remove carriage return and blank spaces
+hostname=hostname(1:end-1);
+hostname=ddewhite(hostname);

Modified: issm/trunk/src/m/parameterization/contourenvelope.m
===================================================================
--- issm/trunk/src/m/parameterization/contourenvelope.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/parameterization/contourenvelope.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,7 +19,6 @@
 
 	if ischar(flags),
 		file=flags;
-		file=varargin{1};
 		if ~exist(file),
 			error(['contourenvelope error message: file ' file ' not found']);
 		end
@@ -28,7 +27,7 @@
 		%do nothing for now
 		isfile=0;
 	else
-		error('contourenvelope error message:  second argument should a file or an elements flag');
+		error('contourenvelope error message:  second argument should be a file or an elements flag');
 	end
 end
 
@@ -69,10 +68,10 @@
 		mesh.elementconnectivity(find(ismember(mesh.elementconnectivity,elemout)))=0;
 	else
 		%get flag list of elements and nodes inside the contour
-		nodein=zeros(mesh.numberofvertices,1); 
-		elemin=zeros(mesh.numberofelements,1); 
-		
-		pos=find(flags); 
+		nodein=zeros(mesh.numberofvertices,1);
+		elemin=zeros(mesh.numberofelements,1);
+
+		pos=find(flags);
 		elemin(pos)=1;
 		nodein(mesh.elements(pos,:))=1;
 
@@ -94,7 +93,7 @@
 %Find segments on boundary
 pos=find(elementonboundary);
 num_segments=length(pos);
-segments=zeros(num_segments,3);
+segments=zeros(num_segments*3,3);
 count=1;
 
 for i=1:num_segments,
@@ -137,3 +136,5 @@
 		end
 	end
 end
+segments=segments(1:count-1,:);
+

Modified: issm/trunk/src/m/parameterization/parameterize.m
===================================================================
--- issm/trunk/src/m/parameterization/parameterize.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/parameterization/parameterize.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -55,4 +55,3 @@
 	md.miscellaneous.name=root; 
 end
 md.miscellaneous.notes=['Model created by using parameter file: ' parametername ' on: ' datestr(now)];
-

Modified: issm/trunk/src/m/parameterization/setflowequation.py
===================================================================
--- issm/trunk/src/m/parameterization/setflowequation.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/parameterization/setflowequation.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -93,10 +93,10 @@
 		fullspcnodes=numpy.logical_or(numpy.logical_not(numpy.isnan(md.diagnostic.spcvx)).astype(int)+ \
 		                              numpy.logical_not(numpy.isnan(md.diagnostic.spcvy)).astype(int)+ \
 		                              numpy.logical_not(numpy.isnan(md.diagnostic.spcvz)).astype(int)==3, \
-		                              numpy.logical_and(nodeonpattyn,nodeonstokes)).astype(int)    #find all the nodes on the boundary of the domain without icefront
+		                              numpy.logical_and(nodeonpattyn,nodeonstokes).reshape(-1,1)).astype(int)    #find all the nodes on the boundary of the domain without icefront
 #		fullspcelems=double(sum(fullspcnodes(md.mesh.elements),2)==6);         %find all the nodes on the boundary of the domain without icefront
 		fullspcelems=(numpy.sum(fullspcnodes[md.mesh.elements.astype(int)-1],axis=1)==6).astype(int)    #find all the nodes on the boundary of the domain without icefront
-		stokesflag[numpy.nonzero(fullspcelems)]=0
+		stokesflag[numpy.nonzero(fullspcelems.reshape(-1))]=0
 		nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:].astype(int)-1]=1
 
 	#Then complete with NoneApproximation or the other model used if there is no stokes
@@ -122,13 +122,13 @@
 		#Create the border nodes between Pattyn and MacAyeal and extrude them
 		numnodes2d=md.mesh.numberofvertices2d
 		numlayers=md.mesh.numberoflayers
-		bordernodes2d=numpy.nonzero(numpy.logical_and(nodeonpattyn[1:numnodes2d],nodeonmacayeal[1:numnodes2d]))    #Nodes connected to two different types of elements
+		bordernodes2d=numpy.nonzero(numpy.logical_and(nodeonpattyn[0:numnodes2d],nodeonmacayeal[0:numnodes2d]))[0]+1    #Nodes connected to two different types of elements
 
 		#initialize and fill in penalties structure
 		if numpy.all(numpy.logical_not(numpy.isnan(bordernodes2d))):
 			penalties=numpy.zeros((0,2))
 			for	i in xrange(1,numlayers):
-				penalties=numpy.concatenate((penalties,numpy.concatenate((bordernodes2d,bordernodes2d+md.mesh.numberofvertices2d*(i)),axis=1)),axis=0)
+				penalties=numpy.vstack((penalties,numpy.hstack((bordernodes2d.reshape(-1,1),bordernodes2d.reshape(-1,1)+md.mesh.numberofvertices2d*(i)))))
 			md.diagnostic.vertex_pairing=penalties
 
 	elif strcmpi(coupling_method,'tiling'):
@@ -136,7 +136,7 @@
 			#Find node at the border
 			nodeonmacayealpattyn[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonpattyn))]=1
 			#Macayeal elements in contact with this layer become MacAyealPattyn elements
-			matrixelements=ismember(md.mesh.elements,numpy.nonzero(nodeonmacayealpattyn))
+			matrixelements=ismember(md.mesh.elements.astype(int)-1,numpy.nonzero(nodeonmacayealpattyn)[0])
 			commonelements=numpy.sum(matrixelements,axis=1)!=0
 			commonelements[numpy.nonzero(pattynflag)]=0    #only one layer: the elements previously in macayeal
 			macayealflag[numpy.nonzero(commonelements)]=0    #these elements are now macayealpattynelements
@@ -145,14 +145,14 @@
 			nodeonmacayeal[md.mesh.elements[numpy.nonzero(macayealflag),:].astype(int)-1]=1
 
 			#rule out elements that don't touch the 2 boundaries
-			pos=numpy.nonzero(macayealpattynflag)
-			elist=numpy.zeros(len(pos))
-			elist = elist + numpy.any(numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
-			elist = elist - numpy.any(numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1]  ,axis=1),axis=1)
-			pos1=numpy.nonzero(elist==1)
+			pos=numpy.nonzero(macayealpattynflag)[0]
+			elist=numpy.zeros(numpy.size(pos),dtype=int)
+			elist = elist + numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1).astype(bool)
+			elist = elist - numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1]  ,axis=1).astype(bool)
+			pos1=numpy.nonzero(elist==1)[0]
 			macayealflag[pos[pos1]]=1
 			macayealpattynflag[pos[pos1]]=0
-			pos2=numpy.nonzero(elist==-1)
+			pos2=numpy.nonzero(elist==-1)[0]
 			pattynflag[pos[pos2]]=1
 			macayealpattynflag[pos[pos2]]=0
 
@@ -168,7 +168,7 @@
 			#Find node at the border
 			nodeonpattynstokes[numpy.nonzero(numpy.logical_and(nodeonpattyn,nodeonstokes))]=1
 			#Stokes elements in contact with this layer become PattynStokes elements
-			matrixelements=ismember(md.mesh.elements,numpy.nonzero(nodeonpattynstokes))
+			matrixelements=ismember(md.mesh.elements.astype(int)-1,numpy.nonzero(nodeonpattynstokes)[0])
 			commonelements=numpy.sum(matrixelements,axis=1)!=0
 			commonelements[numpy.nonzero(pattynflag)]=0    #only one layer: the elements previously in macayeal
 			stokesflag[numpy.nonzero(commonelements)]=0    #these elements are now macayealpattynelements
@@ -177,14 +177,14 @@
 			nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:].astype(int)-1]=1
 
 			#rule out elements that don't touch the 2 boundaries
-			pos=numpy.nonzero(pattynstokesflag)
-			elist=numpy.zeros(len(pos))
-			elist = elist + numpy.any(numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
-			elist = elist - numpy.any(numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
-			pos1=numpy.nonzero(elist==1)
+			pos=numpy.nonzero(pattynstokesflag)[0]
+			elist=numpy.zeros(numpy.size(pos),dtype=int)
+			elist = elist + numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1],axis=1).astype(bool)
+			elist = elist - numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1],axis=1).astype(bool)
+			pos1=numpy.nonzero(elist==1)[0]
 			stokesflag[pos[pos1]]=1
 			pattynstokesflag[pos[pos1]]=0
-			pos2=numpy.nonzero(elist==-1)
+			pos2=numpy.nonzero(elist==-1)[0]
 			pattynflag[pos[pos2]]=1
 			pattynstokesflag[pos[pos2]]=0
 
@@ -200,7 +200,7 @@
 			#Find node at the border
 			nodeonmacayealstokes[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonstokes))]=1
 			#Stokes elements in contact with this layer become MacAyealStokes elements
-			matrixelements=ismember(md.mesh.elements,numpy.nonzero(nodeonmacayealstokes))
+			matrixelements=ismember(md.mesh.elements.astype(int)-1,numpy.nonzero(nodeonmacayealstokes)[0])
 			commonelements=numpy.sum(matrixelements,axis=1)!=0
 			commonelements[numpy.nonzero(macayealflag)]=0    #only one layer: the elements previously in macayeal
 			stokesflag[numpy.nonzero(commonelements)]=0    #these elements are now macayealmacayealelements
@@ -209,14 +209,14 @@
 			nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:].astype(int)-1]=1
 
 			#rule out elements that don't touch the 2 boundaries
-			pos=numpy.nonzero(macayealstokesflag)
-			elist=numpy.zeros(len(pos))
-			elist = elist + numpy.any(numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
-			elist = elist - numpy.any(numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1]  ,axis=1),axis=1)
-			pos1=numpy.nonzero(elist==1)
+			pos=numpy.nonzero(macayealstokesflag)[0]
+			elist=numpy.zeros(numpy.size(pos),dtype=int)
+			elist = elist + numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1).astype(bool)
+			elist = elist - numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1]  ,axis=1).astype(bool)
+			pos1=numpy.nonzero(elist==1)[0]
 			macayealflag[pos[pos1]]=1
 			macayealstokesflag[pos[pos1]]=0
-			pos2=numpy.nonzero(elist==-1)
+			pos2=numpy.nonzero(elist==-1)[0]
 			stokesflag[pos[pos2]]=1
 			macayealstokesflag[pos[pos2]]=0
 

Modified: issm/trunk/src/m/parameterization/setmask.py
===================================================================
--- issm/trunk/src/m/parameterization/setmask.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/parameterization/setmask.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,55 +1,51 @@
-from numpy import *
-import FlagElements as fe
+import numpy
+from FlagElements import *
 
 def setmask(md, floatingicename, groundedicename):
-	#SETMASK - establish boundaries between grounded and floating ice.
-	#
-	#   By default, ice is considered grounded. The contour floatingicename defines nodes 
-	#   for which ice is floating. The contour groundedicename defines nodes inside an floatingice, 
-	#   that are grounded (ie: ice rises, islands, etc ...)
-	#   All input files are in the Argus format (extension .exp).
-	#
-	#   Usage:
-	#      md=setmask(md,floatingicename,groundedicename)
-	#
-	#   Examples:
-	#      md=setmask(md,'all','');
-	#      md=setmask(md,'Iceshelves.exp','Islands.exp');
+	"""
+	SETMASK - establish boundaries between grounded and floating ice.
 
-	#%Get assigned fields
+	   By default, ice is considered grounded. The contour floatingicename defines nodes 
+	   for which ice is floating. The contour groundedicename defines nodes inside an floatingice, 
+	   that are grounded (ie: ice rises, islands, etc ...)
+	   All input files are in the Argus format (extension .exp).
+
+	   Usage:
+	      md=setmask(md,floatingicename,groundedicename)
+
+	   Examples:
+	      md=setmask(md,'all','');
+	      md=setmask(md,'Iceshelves.exp','Islands.exp');
+	"""
+
+	#Get assigned fields
 	x = md.mesh.x
 	y = md.mesh.y
 	elements = md.mesh.elements
 
 	#Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{
-	elementonfloatingice = fe.FlagElements(md, floatingicename)
-	elementongroundedice = fe.FlagElements(md, groundedicename) 
+	elementonfloatingice = FlagElements(md, floatingicename)
+	elementongroundedice = FlagElements(md, groundedicename) 
 
 	#Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous 
 	#arrays come from domain outlines that can intersect one another: 
 
-	elementonfloatingice = logical_and(elementonfloatingice,~elementongroundedice)
-	elementongroundedice = ~elementonfloatingice
+	elementonfloatingice = numpy.logical_and(elementonfloatingice,numpy.logical_not(elementongroundedice))
+	elementongroundedice = numpy.logical_not(elementonfloatingice)
 
 	#the order here is important. we choose vertexongroundedice as default on the grounding line.
-	vertexonfloatingice = zeros(md.mesh.numberofvertices,'bool')
-	vertexongroundedice = zeros(md.mesh.numberofvertices,'bool')
+	vertexonfloatingice = numpy.zeros(md.mesh.numberofvertices,'bool')
+	vertexongroundedice = numpy.zeros(md.mesh.numberofvertices,'bool')
+	vertexongroundedice[md.mesh.elements[numpy.nonzero(elementongroundedice),:].astype(int)-1]=True
+	vertexonfloatingice[numpy.nonzero(numpy.logical_not(vertexongroundedice))]=True
+	#}}}
 
-	pos=argwhere(elementongroundedice==1)
-	pos=md.mesh.elements[pos,:]-1
-	if pos.size:
-		vertexongroundedice[pos]=True
-
-	pos=argwhere(~vertexongroundedice)
-	if pos.size:
-		vertexonfloatingice[pos]=True;
-	#%}}}
-
 	#Return: 
-	md.mask.elementonfloatingice = double(elementonfloatingice)
-	md.mask.vertexonfloatingice = double(vertexonfloatingice)
-	md.mask.elementongroundedice = double(elementongroundedice)
-	md.mask.vertexongroundedice = double(vertexongroundedice)
-	md.mask.vertexonwater = zeros(md.mesh.numberofvertices)
-	md.mask.elementonwater = zeros(md.mesh.numberofelements)
+	md.mask.elementonfloatingice = elementonfloatingice.astype(float)
+	md.mask.vertexonfloatingice = vertexonfloatingice.astype(float)
+	md.mask.elementongroundedice = elementongroundedice.astype(float)
+	md.mask.vertexongroundedice = vertexongroundedice.astype(float)
+	md.mask.vertexonwater = numpy.zeros(md.mesh.numberofvertices)
+	md.mask.elementonwater = numpy.zeros(md.mesh.numberofelements)
+
 	return md

Modified: issm/trunk/src/m/partition/AreaAverageOntoPartition.m
===================================================================
--- issm/trunk/src/m/partition/AreaAverageOntoPartition.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/partition/AreaAverageOntoPartition.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -14,7 +14,7 @@
 	end
 	%save 3D model
 	md3d=md;
-	
+
 	md.mesh.elements=md.mesh.elements2d;
 	md.mesh.x=md.mesh.x2d;
 	md.mesh.y=md.mesh.y2d;

Modified: issm/trunk/src/m/partition/adjacency.m
===================================================================
--- issm/trunk/src/m/partition/adjacency.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/partition/adjacency.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function md=adjacency(md);
+function md=adjacency(md)
 %ADJACENCY -  compute adjacency matrix, list of vertices and list of weights.
 %
 %  function to create the adjacency matrix from the connectivity table.

Modified: issm/trunk/src/m/partition/flagedges.m
===================================================================
--- issm/trunk/src/m/partition/flagedges.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/partition/flagedges.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [xsegments ysegments]=flagedges(elements,x,y,partition);
+function [xsegments ysegments]=flagedges(elements,x,y,partition)
 %FLAGEDGES - return pairs of x,y segments, delimiting partitions.
 %
 %   Usage:

Modified: issm/trunk/src/m/partition/partitioner.m
===================================================================
--- issm/trunk/src/m/partition/partitioner.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/partition/partitioner.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -49,14 +49,13 @@
 	disp('skipping adjacency matrix computation as requested in the options');
 end
 
-
 if strcmpi(package,'chaco'),
 
 	%  default method (from chaco.m)
 	method=[1 1 0 0 1 1 50 0 .001 7654321]';
 	method(1)=3;    %  global method (3=inertial (geometric))
 	method(3)=0;    %  vertex weights (0=off, 1=on)
-	
+
 	%specify bisection
 	method(6)=getfieldvalue(options,'section');%  ndims (1=bisection, 2=quadrisection, 3=octasection)
 
@@ -67,7 +66,7 @@
 	else 
 		weights=[];
 	end
-	
+
 	%  partition into nparts
 	part=Chaco(md.qmu.adjacency,weights,[],md.mesh.x, md.mesh.y ,md.mesh.z,method,npart,[])'+1; %index partitions from 1 up. like metis.
 
@@ -78,10 +77,9 @@
 		weights=floor(md.qmu.vertex_weight/min(md.qmu.vertex_weight));
 	end
 	maptab=Scotch(md.qmu.adjacency,[],weights,[],'cmplt',[npart]);
-	
+
 	part=maptab(:,2);%index partitions from 1 up. like metis.
 
-
 elseif strcmpi(package,'linear'),
 
 	part=1:1:md.mesh.numberofvertices;

Modified: issm/trunk/src/m/plot/applyoptions.m
===================================================================
--- issm/trunk/src/m/plot/applyoptions.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/applyoptions.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,6 @@
 %      applyoptions(md,data,options)
 %
 %   See also: PLOTMODEL, PARSE_OPTIONS
-		
 
 %some defaults
 if isfield(md.mesh,'hemisphere'),
@@ -146,7 +145,7 @@
 		set(c,'Position',getfieldvalue(options,'colorbarpos'));
 	end
 	if exist(options,'log'),
-		nlab=5;
+		nlab=length(get(c,'YTick'));
 		logvalue=getfieldvalue(options,'log');
 
 		scaleminmax=caxis;
@@ -175,7 +174,7 @@
 	end
 	if exist(options,'colorbarYLabel'),
 		set(get(c,'Ylabel'),'FontSize',getfieldvalue(options,'colorbarfontsize',fontsize),'String',getfieldvalue(options,'colorbarYLabel'),...
-			'Color',getfieldvalue(options,'FontColor','k'),'Interpreter',getfieldvalue(options,'Interpreter','none'));
+			'Color',getfieldvalue(options,'FontColor','k'));
 	end
 	if exist(options,'colorbarwidth'),
 		posaxes=get(gca,'Position');
@@ -214,9 +213,9 @@
 				set(c,'YTick',tick_vals);
 			end
 		end
-		labels = cell(1,size(tick_vals,1));
-		for i = 1:size(tick_vals,1)
-			labels{i} = sprintf('%-3.4g',round_ice(tick_vals(i),2));
+		labels = cell(1,numel(tick_vals));
+		for i = 1:numel(tick_vals)
+			labels{i} = num2str(tick_vals(i));
 		end
 		set(c,'YTickLabel',labels);
 	end
@@ -225,10 +224,9 @@
 	colorbar('off');
 else
 	%do nothing
-	
+
 end
 
-
 %area
 if exist(options,'area'),
 	antzoom(getfieldvalue(options,'area'));
@@ -268,6 +266,12 @@
 	northarrow(getfieldvalue(options,'northarrow'));
 end
 
+%curved arrow
+if exist(options,'curvedarrow'),
+	curvedoptions=getfieldvalue(options,'curvedarrow');
+	curvedarrow(curvedoptions{:});
+end
+
 %Scale ruler
 if exist(options,'scaleruler'),
 	scaleruler(options);
@@ -319,10 +323,9 @@
 	set(gca,'pos',Axis);
 end
 
-
 %position of figure
 if exist(options,'figposition'),
-	
+
 	figposition=getfieldvalue(options,'figposition');
 	if ischar(figposition),
 		if strcmpi(figposition,'larour'),
@@ -429,7 +432,7 @@
 if exist(options,'scatter')
 	data=getfieldvalue(options,'scatter');
 	hold on
-	plot_scatter(data(:,1),data(:,2),getfieldvalue(options,'scattersize',3),data(:,3),options);
+	plot_scatter(data(:,1),data(:,2),data(:,3),options);
 end
 
 %backgroundcolor

Modified: issm/trunk/src/m/plot/arrow.m
===================================================================
--- issm/trunk/src/m/plot/arrow.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/arrow.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,7 +8,6 @@
 %            'ratio': default .5 (ratio headarrow/length)
 %            'widthratio': default is 1/10 of length
 
-
 %recover options
 options=pairoptions(varargin{:});
 ratio=getfieldvalue(options,'ratio',.5);

Modified: issm/trunk/src/m/plot/checkplotoptions.m
===================================================================
--- issm/trunk/src/m/plot/checkplotoptions.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/checkplotoptions.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function options=checkplotoptions(md,options);
+function options=checkplotoptions(md,options)
 %PARSE_OPTIONS - build a structure that holds all plot options
 %
 %   Usage:
@@ -52,7 +52,7 @@
 			options=changefieldvalue(options,'colorbar',0);
 	end
 end
-	
+
 %text
 if exist(options,'text'),
 	%1: textvalue

Modified: issm/trunk/src/m/plot/colormaps/getcolormap.m
===================================================================
--- issm/trunk/src/m/plot/colormaps/getcolormap.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/colormaps/getcolormap.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -20,7 +20,7 @@
 if ~ischar(map), error('colormap format not supported'); end
 
 if strcmpi(map,'Ala'),
-	map = jet;
+	map = jet(256);
 	map = map(128:end,:);
 elseif strcmpi(map,'redblue'),
 	map = hsv;

Modified: issm/trunk/src/m/plot/colormaps/haxby.m
===================================================================
--- issm/trunk/src/m/plot/colormaps/haxby.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/colormaps/haxby.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function map = haxby(m);
+function map = haxby(m)
 %HAXBY - Haxby color map
 %   HAXBY(M) returns an M-by-3 matrix containing a colormap with Haxby's
 %   colors, commonly used for displaying bathymetry data.

Modified: issm/trunk/src/m/plot/kmlgroundoverlay.m
===================================================================
--- issm/trunk/src/m/plot/kmlgroundoverlay.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/kmlgroundoverlay.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function kmlgroundoverlay(md,options);
+function kmlgroundoverlay(md,options)
 %KMLGROUNDOVERLAY: create ground overlay image in kml format
 %
 %

Modified: issm/trunk/src/m/plot/latlonoverlay.m
===================================================================
--- issm/trunk/src/m/plot/latlonoverlay.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/latlonoverlay.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -116,7 +116,6 @@
 		error('field hemisphere should either be ''n'' or ''s'''); 
 	end
 
-
 	pos=find(x<=xlimits(2) & x>=xlimits(1) & y<=ylimits(2) & y>=ylimits(1));
 	if length(pos)<=1, continue; end
 	x=x(pos);y=y(pos);

Modified: issm/trunk/src/m/plot/plot_BC.m
===================================================================
--- issm/trunk/src/m/plot/plot_BC.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_BC.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_BC(md,options,width,i,data);
+function plot_BC(md,options,width,i,data)
 
 %plot neuman
 plot_icefront(md,options,width,i,data)

Modified: issm/trunk/src/m/plot/plot_basaldrag.m
===================================================================
--- issm/trunk/src/m/plot/plot_basaldrag.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_basaldrag.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_basaldrag(md,options,width,i,type);
+function plot_basaldrag(md,options,width,i,type)
 
 %PLOT_BASALDRAG - plot basal drag
 %

Modified: issm/trunk/src/m/plot/plot_boundaries.m
===================================================================
--- issm/trunk/src/m/plot/plot_boundaries.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_boundaries.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_boundaries(md,options,width,i);
+function plot_boundaries(md,options,width,i)
 %PLOT_BOUNDARIES - plot mesh boundaries
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_contour.m
===================================================================
--- issm/trunk/src/m/plot/plot_contour.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_contour.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_contour(md,datain,options);
+function plot_contour(md,datain,options)
 %PLOT_CONTOUR - plot contours of a given field
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_drivingstress.m
===================================================================
--- issm/trunk/src/m/plot/plot_drivingstress.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_drivingstress.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_drivingstress(md,options,width,i);
+function plot_drivingstress(md,options,width,i)
 %PLOT_DRIVINGSTRESS - plot driving stress
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_edges.m
===================================================================
--- issm/trunk/src/m/plot/plot_edges.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_edges.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_edges(md,options,width,i,datai);
+function plot_edges(md,options,width,i,datai)
 %PLOT_SEGMENTS - plot edges, with different colors according to segment markers.
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_elementnumbering.m
===================================================================
--- issm/trunk/src/m/plot/plot_elementnumbering.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_elementnumbering.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_elementnumbering(md,options,width,i);
+function plot_elementnumbering(md,options,width,i)
 %PLOT_ELEMENTNUMBERING - plot element numbering
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_elementstype.m
===================================================================
--- issm/trunk/src/m/plot/plot_elementstype.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_elementstype.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_elementstype(md,options,width,i);
+function plot_elementstype(md,options,width,i)
 %PLOT_ELEMENTSTYPE - plot elements type
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_highlightelements.m
===================================================================
--- issm/trunk/src/m/plot/plot_highlightelements.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_highlightelements.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_highlightelements(md,options,width,i);
+function plot_highlightelements(md,options,width,i)
 %PLOT_HIGHLIGHTELEMENTS - plot selected elements
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_highlightvertices.m
===================================================================
--- issm/trunk/src/m/plot/plot_highlightvertices.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_highlightvertices.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_highlightvertices(md,options,width,i);
+function plot_highlightvertices(md,options,width,i)
 %PLOT_HIGHLIGHTVERTICES - plot selected vertices
 %
 %   Usage:
@@ -20,7 +20,7 @@
 
 	%Highlight
 	pos=getfieldvalue(options,'highlight',[]);
-	text(x(pos),y(pos),z(pos),num2str(transpose(pos)),...
+	text(x(pos),y(pos),z(pos),num2str(pos(:)),...
 		'backgroundcolor',[1 0 0],'HorizontalAlignment','center','VerticalAlignment','middle');
 else
 	%plot mesh 
@@ -33,7 +33,7 @@
 
 	%Highlight
 	pos=getfieldvalue(options,'highlight',[]);
-	text(x(pos),y(pos),z(pos),num2str(transpose(pos)),...
+	text(x(pos),y(pos),z(pos),num2str(pos(:)),...
 		'backgroundcolor',[1 0 0],'HorizontalAlignment','center','VerticalAlignment','middle');
 end
 

Modified: issm/trunk/src/m/plot/plot_icefront.m
===================================================================
--- issm/trunk/src/m/plot/plot_icefront.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_icefront.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_icefront(md,options,width,i,data);
+function plot_icefront(md,options,width,i,data)
 %PLOT_ICEFRONT - plot segment on neumann BC
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_importancefactors.m
===================================================================
--- issm/trunk/src/m/plot/plot_importancefactors.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_importancefactors.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_importancefactors(md,options,width,ii);
+function plot_importancefactors(md,options,width,ii)
 %PLOT_IMPORTANCEFACTORS - plot importance factors
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_manager.m
===================================================================
--- issm/trunk/src/m/plot/plot_manager.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_manager.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_manager(md,options,subplotwidth,nlines,ncols,i);
+function plot_manager(md,options,subplotwidth,nlines,ncols,i)
 %PLOT__MANAGER - distribute the plots, called by plotmodel
 %
 %   Usage:
@@ -32,15 +32,15 @@
 		case 'highlightelements',
 			plot_highlightelements(md,options,subplotwidth,i);
 			return;
-		
+
 		case 'qmumean',
 			plot_qmumean(md,options,nlines,ncols,i);
 			return;
-		
+
 		case 'qmustddev',
 			plot_qmustddev(md,options,nlines,ncols,i);
 			return;
-		
+
 		case 'qmuhistnorm',
 			plot_qmuhistnorm(md,options,nlines,ncols,i);
 			return;
@@ -117,7 +117,7 @@
 		case 'segments'
 			plot_segments(md,options,subplotwidth,i,data)
 			return
-		
+
 		case 'quiver'
 			data=[md.initialization.vx md.initialization.vy]; %Go ahead and try plot_unit
 
@@ -198,7 +198,7 @@
 	if ((nlines*ncols~=1) | (i~=1)),
 		error('cannot kmlgroundoverlay on multi-plots');
 	end
-	
+
 	%call routine to build kml file and image that goes with it.
 	kmlgroundoverlay(md,options);
 end

Modified: issm/trunk/src/m/plot/plot_mesh.m
===================================================================
--- issm/trunk/src/m/plot/plot_mesh.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_mesh.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_mesh(md,options,nlines,ncols,i);
+function plot_mesh(md,options,nlines,ncols,i)
 %PLOT_MESH - plot model mesh
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_none.m
===================================================================
--- issm/trunk/src/m/plot/plot_none.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_none.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_none(md,options,nlines,ncols,i);
+function plot_none(md,options,nlines,ncols,i)
 %PLOT_NONE - plot nothing, just apply options
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_overlay.m
===================================================================
--- issm/trunk/src/m/plot/plot_overlay.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_overlay.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -25,7 +25,6 @@
 	error('buildoverlay error message: overlay not supported for quiver plots');
 end
 
-
 %radar power
 if ~any(isnan(md.radaroverlay.x)) & ~any(isnan(md.radaroverlay.y)) & ~any(isnan(md.radaroverlay.pwr)),
 	disp('plot_overlay info: the radar image held by the model is being used');
@@ -149,6 +148,8 @@
 if ~isnan(data_min),
 	options=changefieldvalue(options,'caxis',[data_min data_max]); % force caxis so that the colorbar is ready
 end
-options=addfielddefault(options,'axis','equal off');              % default axis
+options=addfielddefault(options,'xlim',xlim);        % default xlim
+options=addfielddefault(options,'ylim',ylim);        % default ylim
+options=addfielddefault(options,'axis','equal off'); % default axis
 applyoptions(md,data,options);
 drawnow

Modified: issm/trunk/src/m/plot/plot_parthist.m
===================================================================
--- issm/trunk/src/m/plot/plot_parthist.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_parthist.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_parthist(md,options,nlines,ncols,i);
+function plot_parthist(md,options,nlines,ncols,i)
 %PLOT_PARTHIST - plot partitioning histogram
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_parthistn.m
===================================================================
--- issm/trunk/src/m/plot/plot_parthistn.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_parthistn.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_parthist(md,options,nlines,ncols,i);
+function plot_parthist(md,options,nlines,ncols,i)
 %PLOT_PARTHIST - plot partitioning histogram
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_parthistw.m
===================================================================
--- issm/trunk/src/m/plot/plot_parthistw.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_parthistw.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_parthist(md,options,nlines,ncols,i);
+function plot_parthist(md,options,nlines,ncols,i)
 %PLOT_PARTHIST - plot partitioning histogram
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_penalties.m
===================================================================
--- issm/trunk/src/m/plot/plot_penalties.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_penalties.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_penalties(md,options,width,i);
+function plot_penalties(md,options,width,i)
 %PLOT_PENALTIES - plot penalties
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_qmu_mass_flux_segments.m
===================================================================
--- issm/trunk/src/m/plot/plot_qmu_mass_flux_segments.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_qmu_mass_flux_segments.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_qmu_mass_flux_segments(md,options,nlines,ncols,i);
+function plot_qmu_mass_flux_segments(md,options,nlines,ncols,i)
 %PLOT_QMU_MASS_FLUX_SEGMENTS - plot segments from the qmu analysis of mass fluxes
 %
 %   Usage:
@@ -26,7 +26,7 @@
 		text(segments(j,1),segments(j,2),['Profile #' num2str(i)]);
 
 		%plot normals
-		
+
 		for j=1:length(segments),
 			xstart=mean([segments(j,1) segments(j,3)]);
 			ystart=mean([segments(j,2) segments(j,4)]);

Modified: issm/trunk/src/m/plot/plot_qmuhistnorm.m
===================================================================
--- issm/trunk/src/m/plot/plot_qmuhistnorm.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_qmuhistnorm.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,9 @@
-function plot_qmuhistnorm(md,options,nlines,ncols,index);
+function plot_qmuhistnorm(md,options,nlines,ncols,index)
 
 %prepare plot
 subplot(nlines,ncols,index); 
 hold on
 
-
 %recover histnorm data
 if ~exist(options,'qmudata')
 	error('plot_qmuhistnorm error message: option qmudata is required');

Modified: issm/trunk/src/m/plot/plot_qmumean.m
===================================================================
--- issm/trunk/src/m/plot/plot_qmumean.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_qmumean.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_qmumean(md,options,nlines,ncols,i);
+function plot_qmumean(md,options,nlines,ncols,i)
 %PLOT_QMUMEAN - plot mean of a scaled response 
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_qmustddev.m
===================================================================
--- issm/trunk/src/m/plot/plot_qmustddev.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_qmustddev.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_qmustddev(md,options,nlines,ncols,i);
+function plot_qmustddev(md,options,nlines,ncols,i)
 %PLOT_QMUMEAN - plot stddev of a scaled response 
 %
 %   Usage:
@@ -46,7 +46,6 @@
 	responses=log(responses)/log(getfieldvalue(options,'log'));
 end
 
-
 %now, project onto vertices
 responses_on_node=responses(md.qmu.partition+1);
 

Modified: issm/trunk/src/m/plot/plot_referential.m
===================================================================
--- issm/trunk/src/m/plot/plot_referential.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_referential.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_referential(md,options,width,i,data);
+function plot_referential(md,options,width,i,data)
 %PLOT_PRESSURELOAD - plot segment on neumann BC
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_riftfraction.m
===================================================================
--- issm/trunk/src/m/plot/plot_riftfraction.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_riftfraction.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_riftfraction(md,options,nlines,ncols,index);
+function plot_riftfraction(md,options,nlines,ncols,index)
 %PLOT_RIFTFRACTION - plot rift fractions
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_riftnumbering.m
===================================================================
--- issm/trunk/src/m/plot/plot_riftnumbering.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_riftnumbering.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_riftnumbering(md,options,nlines,ncols,index);
+function plot_riftnumbering(md,options,nlines,ncols,index)
 %PLOT_RIFTNUMBERING - plot rift penetration + numbering of all rift vertices, as well as rift numbers.
 %
 %   Usage:
@@ -87,7 +87,6 @@
 	end
 end
 
-
 %apply options
 options=addfielddefault(options,'title','Rift/Fault location');
 options=addfielddefault(options,'colorbar',0);

Modified: issm/trunk/src/m/plot/plot_riftpenetration.m
===================================================================
--- issm/trunk/src/m/plot/plot_riftpenetration.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_riftpenetration.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_rifpenetration(md,options,nlines,ncols,index);
+function plot_rifpenetration(md,options,nlines,ncols,index)
 %PLOT_RIFTPENETRATION - plot rift penetration
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_riftrelvel.m
===================================================================
--- issm/trunk/src/m/plot/plot_riftrelvel.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_riftrelvel.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_riftrelvel(md,options,nlines,ncols,index);
+function plot_riftrelvel(md,options,nlines,ncols,index)
 %PLOT_RIFTRELVEL - plot rift relative velocities
 %
 %   Usage:
@@ -15,6 +15,9 @@
 end
 options=addfielddefault(options,'scaling',2);
 
+%markersize: 
+markersize=getfieldvalue(options,'markersize',1);
+
 %recover vx and vy:
 vx=getfieldvalue(options,'riftrelvel_vx',md.initialization.vx);
 vy=getfieldvalue(options,'riftrelvel_vy',md.initialization.vy);
@@ -37,11 +40,6 @@
 subplot(nlines,ncols,index); 
 hold on
 
-%plot mesh boundaries
-for i=1:size(md.mesh.segments,1),
-	plot(x(md.mesh.segments(i,1:2)),y(md.mesh.segments(i,1:2)),'k-');
-end
-
 %plot rifts vel
 h3=[];
 for i=1:quivers.numcolors
@@ -62,7 +60,7 @@
 	h1=plot(x(md.mesh.segments(i,1:2)),y(md.mesh.segments(i,1:2)),'b-');
 end
 for i=1:size(md.rifts.riftstruct,1),
-	
+
 	%get nodes on rift
 	penaltypairs=md.rifts.riftstruct(i).penaltypairs;
 
@@ -80,27 +78,30 @@
 		penetration=(vx2-vx1)*normal(1)+(vy2-vy1)*normal(2);
 		%if penetration is negative, plot in black, positive, plot in red;: ie: if rift is closing, black, if rift is opening, red.
 		if(penetration>0),
-			p2=plot(x(penaltypairs(j,1)) ,y(penaltypairs(j,1)),'*'); set(p2,'Color',[140 140 140]/255);
+			p2=plot(x(penaltypairs(j,1)) ,y(penaltypairs(j,1)),'.','MarkerSize',markersize); set(p2,'Color',[140 140 140]/255);
 			isp2=1;
 		else
-			p1=plot(x(penaltypairs(j,1)) ,y(penaltypairs(j,1)),'k*');
+			p1=plot(x(penaltypairs(j,1)) ,y(penaltypairs(j,1)),'k.','MarkerSize',markersize);
 			isp1=1;
 		end
 	end
 
 	%point out the tips
-	h2=plot(x(md.rifts.riftstruct(i).tips(1)),y(md.rifts.riftstruct(i).tips(1)),'g*');
-	plot(x(md.rifts.riftstruct(i).tips(2)),y(md.rifts.riftstruct(i).tips(2)),'g*');
+	h2=plot(x(md.rifts.riftstruct(i).tips(1)),y(md.rifts.riftstruct(i).tips(1)),'g.','MarkerSize',markersize);
+	plot(x(md.rifts.riftstruct(i).tips(2)),y(md.rifts.riftstruct(i).tips(2)),'g.','MarkerSize',markersize);
 	segments=md.rifts.riftstruct(i).segments(:,1:2);
 end
+
+faulttitle=getfieldvalue(options','faulttitle','faults');
+rifttitle=getfieldvalue(options','rifttitle','rifts');
 %legend
 if strcmpi(getfieldvalue(options,'legend','on'),'on'),
 	if isp1 & isp2
-		l=legend([h1,h2,p1,p2],'mesh boundaries','crack tips','faults','rifts');
+		l=legend([h1,h2,p1,p2],'mesh boundaries','crack tips',faulttitle,rifttitle);
 	elseif isp1
-		l=legend([h1,h2,p1],'mesh boundaries','crack tips','faults');
+		l=legend([h1,h2,p1],'mesh boundaries','crack tips',faulttitle);
 	elseif isp2
-		l=legend([h1,h2,p2],'mesh boundaries','crack tips','rifts');
+		l=legend([h1,h2,p2],'mesh boundaries','crack tips',rifttitle);
 	else
 		l=legend([h1,h2],'mesh boundaries','crack tips');
 	end

Modified: issm/trunk/src/m/plot/plot_rifts.m
===================================================================
--- issm/trunk/src/m/plot/plot_rifts.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_rifts.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_rifts(md,options,nlines,ncols,index);
+function plot_rifts(md,options,nlines,ncols,index)
 %PLOT_RIFTS - plot rifts in a mesh
 %
 %   Usage:
@@ -15,7 +15,7 @@
 %offset to separate rift flanks.
 offset=getfieldvalue(options,'offset',500);
 if isstruct(md.rifts.riftstruct),
-	
+
 	for i=1:size(md.rifts.riftstruct,1),
 		penaltypairs=md.rifts.riftstruct(i).penaltypairs;
 

Modified: issm/trunk/src/m/plot/plot_riftvel.m
===================================================================
--- issm/trunk/src/m/plot/plot_riftvel.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_riftvel.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_riftvel(md,options,nlines,ncols,index);
+function plot_riftvel(md,options,nlines,ncols,index)
 %PLOT_RIFTVEL - plot rift velocity
 %
 %   Usage:
@@ -88,7 +88,6 @@
 	segments=md.rifts.riftstruct(i).segments(:,1:2);
 end
 
-
 %legend
 if isp1 & isp2
 	legend([h1,h2,p1,p2],'mesh boundaries','rift tips',' rifts closing','rifts opening')

Modified: issm/trunk/src/m/plot/plot_sarpwr.m
===================================================================
--- issm/trunk/src/m/plot/plot_sarpwr.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_sarpwr.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_sarpwr(md,options,width,i);
+function plot_sarpwr(md,options,width,i)
 %PLOT_SARPWR - plot radar image
 %
 %   Usage:
@@ -16,7 +16,7 @@
 	md.mesh.y=md.mesh.y*unit;
 	md.mesh.z=md.mesh.z*unit;
 end
-					
+
 imagesc(md.radaroverlay.x,md.radaroverlay.y,double(md.radaroverlay.pwr)),set(gca,'YDir','normal');colormap(gray);
 
 %apply options

Modified: issm/trunk/src/m/plot/plot_scatter.m
===================================================================
--- issm/trunk/src/m/plot/plot_scatter.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_scatter.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,6 +1,6 @@
-function plot_scatter(x,y,level,options),
+function plot_scatter(x,y,level,varargin),
 
-if nargin==3, options=pairoptions(); end
+options=pairoptions(varargin{:}); 
 
 %check input
 if numel(x)~=numel(y) | numel(x)~=numel(level),
@@ -12,6 +12,8 @@
 Max=max(level);
 Siz=length(level);
 nlab=10;
+%Min=0;
+%Max=1300;
 
 %OK, should we create a new colorbar for the occasion?
 if isempty(findobj(gcf,'tag','TMW_COLORBAR')),

Modified: issm/trunk/src/m/plot/plot_section.m
===================================================================
--- issm/trunk/src/m/plot/plot_section.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_section.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -114,7 +114,6 @@
 			plot(s,data_s,'color',color(i,:),'LineWidth',getfieldvalue(options,'linewidth',1))
 			hold on
 
-
 			%3D
 		else
 			%plot section value

Modified: issm/trunk/src/m/plot/plot_segments.m
===================================================================
--- issm/trunk/src/m/plot/plot_segments.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_segments.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_segments(md,options,width,i,datai);
+function plot_segments(md,options,width,i,datai)
 %PLOT_SEGMENTS - plot segments, with different colors according to segment markers.
 %
 %   Usage:
@@ -41,7 +41,6 @@
 	q=quiver(xstart,ystart,xend-xstart,yend-ystart); hold on;
 	h3=plot(xstart,ystart,'r*');
 
-
 else
 	error('plot_segments: 3d plot of segments not supported yet!');
 end

Modified: issm/trunk/src/m/plot/plot_tensor.m
===================================================================
--- issm/trunk/src/m/plot/plot_tensor.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_tensor.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_tensor(md,options,width,i,type);
+function plot_tensor(md,options,width,i,type)
 %PLOT_TENSOR - plot tensor components
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_tensor_components.m
===================================================================
--- issm/trunk/src/m/plot/plot_tensor_components.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_tensor_components.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_tensor_components(md,options,width,i,tensor,type,plot_options);
+function plot_tensor_components(md,options,width,i,tensor,type,plot_options)
 %PLOT_TENSOR_COMPONENT - plot component of a tensor
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_tensor_principal.m
===================================================================
--- issm/trunk/src/m/plot/plot_tensor_principal.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_tensor_principal.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_tensor_principal(md,options,width,i,tensor,type,plot_options);
+function plot_tensor_principal(md,options,width,i,tensor,type,plot_options)
 %PLOT_TENSOR_PRINCIPAL - plot principal values
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_tensor_principalaxis.m
===================================================================
--- issm/trunk/src/m/plot/plot_tensor_principalaxis.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_tensor_principalaxis.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_tensor_principalaxis(md,options,width,i,tensor,type,plot_options);
+function plot_tensor_principalaxis(md,options,width,i,tensor,type,plot_options)
 %PLOT_TENSOR_PRINCIPALAXIS - plot ytensor principal axis
 %
 %   Usage:

Modified: issm/trunk/src/m/plot/plot_thermaltransient_results.m
===================================================================
--- issm/trunk/src/m/plot/plot_thermaltransient_results.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_thermaltransient_results.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,4 +21,3 @@
 string=[string ',''figure'',2,''colorbar#all'',''on'',''fontsize'',' num2str(options.fontsize) ',''fontweight'',' options.fontweight ');'];
 eval(string);
 clear string;
-

Modified: issm/trunk/src/m/plot/plot_transient_movie.m
===================================================================
--- issm/trunk/src/m/plot/plot_transient_movie.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_transient_movie.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_transient_movie(md,options,width,i);
+function plot_transient_movie(md,options,width,i)
 %PLOT_TRANSIENT_MOVIE - plot a transient result as a movie
 %   Usage:
 %      plot_transient_movie(md,options,width,i);

Modified: issm/trunk/src/m/plot/plot_vertexnumbering.m
===================================================================
--- issm/trunk/src/m/plot/plot_vertexnumbering.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plot_vertexnumbering.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function plot_vertexnumbering(md,options,width,i);
+function plot_vertexnumbering(md,options,width,i)
 %PLOT_VERTEXNUMBERING - plot vertex numbering
 %
 %   Usage:
@@ -24,7 +24,7 @@
 
 	%Highlight
 	pos=getfieldvalue(options,'highlight',[]);
-	text(x(pos),y(pos),z(pos),num2str(transpose(pos)),...
+	text(x(pos),y(pos),z(pos),num2str(pos(:)),...
 		'backgroundcolor',[1 0 0],'HorizontalAlignment','center','VerticalAlignment','middle');
 else
 	%plot mesh 
@@ -41,7 +41,7 @@
 
 	%Highlight
 	pos=getfieldvalue(options,'highlight',[]);
-	text(x(pos),y(pos),z(pos),num2str(transpose(pos)),...
+	text(x(pos),y(pos),z(pos),num2str(pos(:)),...
 		'backgroundcolor',[1 0 0],'HorizontalAlignment','center','VerticalAlignment','middle');
 end
 

Modified: issm/trunk/src/m/plot/plotmodel.m
===================================================================
--- issm/trunk/src/m/plot/plotmodel.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/plotmodel.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -31,7 +31,7 @@
 
 %go through subplots
 if numberofplots,
-		
+
 	%Create figure 
 	if strcmpi(getfieldvalue(options.list{1},'visible','on'),'off'),
 		F=figure(figurenumber);clf;

Modified: issm/trunk/src/m/plot/processdata.m
===================================================================
--- issm/trunk/src/m/plot/processdata.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/processdata.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [data datatype]=processdata(md,data,options);
+function [data datatype]=processdata(md,data,options)
 %PROCESSDATA - process data to be plotted
 %
 %   datatype = 1 -> elements
@@ -47,10 +47,10 @@
 	datatype=0;
 end
 
-%get datatype
+%get datasize
 datasize=size(data);
 
-%Process NaN if any (do not now before mask is applied)
+%Process NaN if any (do not know before mask is applied)
 if exist(options,'nan')
 	data(find(isnan(data)))=getfieldvalue(options,'nan',0);
 end
@@ -73,7 +73,7 @@
 	if datasize(1)~=md.mesh.numberofvertices & datasize(1)~=md.mesh.numberofelements & datasize(1)~=md.mesh.numberofvertices*6 & (md.mesh.dimension==3 & ~(datasize(1)==numberofelements2d | datasize(1)==numberofvertices2d))
 		error('plotmodel error message: data not supported yet');
 	end
-	
+
 	%quiver?
 	if datasize(2)>1,
 		datatype=3;

Modified: issm/trunk/src/m/plot/processmesh.m
===================================================================
--- issm/trunk/src/m/plot/processmesh.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/processmesh.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function [x y z elements is2d isplanet]=processmesh(md,data,options);
+function [x y z elements is2d isplanet]=processmesh(md,data,options)
 %PROCESSMESH - process mesh to be plotted
 %
 %   Usage:
@@ -36,7 +36,6 @@
 		z=md.mesh.z;
 	end
 
-
 	if isprop(md.mesh,'elements2d'), elements2d=md.mesh.elements2d; end
 	elements=md.mesh.elements;
 

Modified: issm/trunk/src/m/plot/quiver_colorbar.m
===================================================================
--- issm/trunk/src/m/plot/quiver_colorbar.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/quiver_colorbar.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,7 +30,7 @@
 	%fontsize
 	fontsize=getfieldvalue(options,'fontsize',14);
 	set(hcb,'FontSize',fontsize);
-	
+
 	if exist(options,'colorbartitle'),
 		backup=gca;
 		axes(hcb);lab=title(getfieldvalue(options,'colorbartitle'));

Modified: issm/trunk/src/m/plot/radarpower.m
===================================================================
--- issm/trunk/src/m/plot/radarpower.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/radarpower.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -31,14 +31,14 @@
 %figure out if we should go look for Greenland or Antarctica geotiff, or if user provided one.
 if ~exist(options,'overlay_image'),
 	if strcmpi(md.mesh.hemisphere,'n'),
-		%if ~exist([jplsvn() '/projects/ModelData/MOG/mog150_greenland_map.jpg']),
-		%	error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MOG/mog150_greenland_map.jpg not found.']);
+		%if ~exist(['/u/astrid-r1b/ModelData/MOG/mog150_greenland_map.jpg']),
+		%	error(['radarpower error message: file ' '/u/astrid-r1b/ModelData/MOG/mog150_greenland_map.jpg not found.']);
 		%end
 		%name = 'mog150_greenland_map';
 		%name = 'mog100_hp1_v10';
 		%%name = 'mog500_hp1_v10';
-		%jpgim=[jplsvn() '/projects/ModelData/MOG/' name '.jpg'];
-		%geom=load([jplsvn() '/projects/ModelData/MOG/' name '.jpgw'],'ascii');
+		%jpgim=['/u/astrid-r1b/ModelData/MOG/' name '.jpg'];
+		%geom=load(['/u/astrid-r1b/ModelData/MOG/' name '.jpgw'],'ascii');
 		%%jpgim='/u/astrid-r1b/morlighe/issmjpl/projects/MorlighemGRL2012/Data/Mosaic_amp_asar2010.jpg';
 		%%geom=load('/u/astrid-r1b/morlighe/issmjpl/projects/MorlighemGRL2012/Data/Mosaic_amp_asar2010.jpgw');
 		%jpgim='/u/astrid-r1b/morlighe/issmjpl/projects/MorlighemGRL2012/Data/Russel_asar2010.png';
@@ -64,15 +64,15 @@
 		%md.radaroverlay.x=(xmin:(xmax-xmin)/(size(md.radaroverlay.pwr,2)-1):xmax);
 		%md.radaroverlay.y=(ymin:(ymax-ymin)/(size(md.radaroverlay.pwr,1)-1):ymax);
 		if highres,
-			if ~exist([jplsvn() '/projects/ModelData/MOG/mog100g_r2_hp1.tif']),
-				error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MOG/mog100g_r2_hp1.tif not found.']);
+			if ~exist(['/u/astrid-r1b/ModelData/MOG/mog100_r2_hp1.tif']),
+				error(['radarpower error message: file ' '/u/astrid-r1b/ModelData/MOG/mog100_r2_hp1.tif not found.']);
 			end
-			geotiff_name=[jplsvn() '/projects/ModelData/MOG/mog100_r2_hp1.tif'];
+			geotiff_name=['/u/astrid-r1b/ModelData/MOG/mog100_r2_hp1.tif'];
 		else
-			if ~exist([jplsvn() '/projects/ModelData/MOG/mog500g_r2_hp1.tif']),
-				error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MOG/mog500g_r2_hp1.tif not found.']);
+			if ~exist(['/u/astrid-r1b/ModelData/MOG/mog500_r2_hp1.tif']),
+				error(['radarpower error message: file ' '/u/astrid-r1b/ModelData/MOG/mog500_r2_hp1.tif not found.']);
 			end
-			geotiff_name=[jplsvn() '/projects/ModelData/MOG/mog500_r2_hp1.tif'];
+			geotiff_name=['/u/astrid-r1b/ModelData/MOG/mog500_r2_hp1.tif'];
 		end
 
 		%Name of image
@@ -89,18 +89,17 @@
 		%Erase image
 		system('rm -rf ./temp.tif');
 
-
 	elseif strcmpi(md.mesh.hemisphere,'s'),
 		if highres,
-			if ~exist([jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif']),
-				error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif not found.']);
+			if ~exist(['/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif']),
+				error(['radarpower error message: file ' '/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif not found.']);
 			end
-			geotiff_name=[jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif'];
+			geotiff_name=['/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif'];
 		else
-			if ~exist([jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif']),
-				error(['radarpower error message: file ' jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif not found.']);
+			if ~exist(['/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif']),
+				error(['radarpower error message: file ' '/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif not found.']);
 			end
-			geotiff_name=[jplsvn() '/projects/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif'];
+			geotiff_name=['/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_1km.tif'];
 		end
 
 		%Name of image

Modified: issm/trunk/src/m/plot/subplotmodel.m
===================================================================
--- issm/trunk/src/m/plot/subplotmodel.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/plot/subplotmodel.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function ha=subplotmodel(nlines,ncols,num,options);
+function ha=subplotmodel(nlines,ncols,num,options)
 %SUBPLOTMODEL -  tight subplot that includes margins
 %
 %   Usage:

Modified: issm/trunk/src/m/print/printmodel.m
===================================================================
--- issm/trunk/src/m/print/printmodel.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/print/printmodel.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -23,7 +23,6 @@
 %      printmodel('image','tiff')
 %      printmodel('image','eps','margin','on','frame','on','hardcopy','on')
 
-
 %get options: 
 options=pairoptions(varargin{:});
 
@@ -54,7 +53,6 @@
 %InvertHardcopy off imposes MATLAB to use the same colors
 set(fig, 'InvertHardcopy', getfieldvalue(options,'hardcopy'));
 
-
 %we could have several formats, as a cell array of strings.
 formats=format;
 if ~iscell(formats),

Modified: issm/trunk/src/m/qmu/MassFluxProcessProfile.m
===================================================================
--- issm/trunk/src/m/qmu/MassFluxProcessProfile.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/MassFluxProcessProfile.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function segments=MassFluxProcessProfile(md,directory,profilename);
+function segments=MassFluxProcessProfile(md,directory,profilename)
 %MASSFLUXPROCESSPROFILE: process an argus domain outlien profile into a list of segments.
 %
 % Usage: segments=MassFluxProcessProfile(md);
@@ -6,7 +6,6 @@
 %
 % See also: PROCESS_QMU_RESPONSE_DATA, PREQMU
 
-
 %first read the profile points.
 profile=expread([directory '/' profilename]);
 

Modified: issm/trunk/src/m/qmu/dakota_cdfs.m
===================================================================
--- issm/trunk/src/m/qmu/dakota_cdfs.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/dakota_cdfs.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -135,9 +135,9 @@
                 resp,prob,rel,grel);
         end
     end
-    
+
     varargout{1}=dresp;
-    
+
 elseif exist('samp','var') && ~isempty(samp)
     cdf=zeros(length(resp)+length(prob)+length(rel)+length(grel),...
               4,size(samp,2));
@@ -146,9 +146,9 @@
         [cdf(:,:,i)]=cdfs_samp_calc(samp(:,i),...
             resp,prob,rel,grel);
     end
-    
+
     varargout{1}=cdf;
-    
+
 elseif exist('mean','var'  ) && ~isempty(mean  ) && ...
        exist('stddev','var') && ~isempty(stddev)
     cdf=zeros(length(resp)+length(prob)+length(rel)+length(grel),...
@@ -158,7 +158,7 @@
         [cdf(:,:,i)]=cdfs_lr_calc(mean(i),stddev(i),...
             resp,prob,rel,grel);
     end
-    
+
     varargout{1}=cdf;
 else
     error(['Empty data ''' inputname(2) ''' of type ''' class(varargin{2}) '''.']);
@@ -177,7 +177,7 @@
 
     mu   =mean(samp);
     sigma=std(samp);
-    
+
     cdf=zeros(length(resp)+length(prob)+length(rel)+length(grel),4);
     cdf(:,:)=NaN;
     irow=0;

Modified: issm/trunk/src/m/qmu/dakota_in_data.m
===================================================================
--- issm/trunk/src/m/qmu/dakota_in_data.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/dakota_in_data.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -87,7 +87,6 @@
 
 % dmeth=dmeth_params_merge(dmeth,dparams)
 
-
 %%  variables
 
 fnames=fieldnames(variables);
@@ -98,7 +97,7 @@
 	dvar.(fnames{i})=variables.(fnames{i});
 
 end
-    
+
 %%  responses
 
 fnames=fieldnames(responses);

Modified: issm/trunk/src/m/qmu/dakota_in_params.m
===================================================================
--- issm/trunk/src/m/qmu/dakota_in_params.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/dakota_in_params.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -208,4 +208,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/qmu/dakota_in_parse.m
===================================================================
--- issm/trunk/src/m/qmu/dakota_in_parse.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/dakota_in_parse.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -41,7 +41,7 @@
 %  to foreign countries or providing access to foreign persons."
 %
 function [method,dvar,dresp]=dakota_in_parse(filei)
-    
+
 if ~nargin
     help dakota_in_parse
     return
@@ -630,7 +630,7 @@
 %  start with next token
 
 itoken=itoken+1;
-    
+
 %  read next line if necessary
 
 if (itoken > length(tokens{1}))
@@ -643,7 +643,7 @@
     [ntokens,tokens]=fltokens(fline);
     itoken=1;
 end
-    
+
 end
 
 %%  function to read a list of tokens
@@ -667,7 +667,7 @@
     [ntokens,tokens]=fltokens(fline);
     itoken=1;
 end
-    
+
 %  check for equal sign and skip
 
 if strncmp(tokens{1}{itoken},'=',1)

Modified: issm/trunk/src/m/qmu/dakota_moments.m
===================================================================
--- issm/trunk/src/m/qmu/dakota_moments.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/dakota_moments.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -88,9 +88,9 @@
          dresp(i).meanci,dresp(i).stddevci]=...
             moments_calc(dresp(i).sample,alpha);
     end
-    
+
     varargout{1}=dresp;
-    
+
 elseif exist('samp','var') && ~isempty(samp)
     mean    =zeros(1,size(samp,2));
     stddev  =zeros(1,size(samp,2));
@@ -105,7 +105,7 @@
          meanci(:,i),stddevci(:,i)]=...
             moments_calc(samp(:,i),alpha);
     end
-    
+
     varargout{1}=mean;
     varargout{2}=stddev;
     varargout{3}=meanci;

Modified: issm/trunk/src/m/qmu/dakota_out_parse.m
===================================================================
--- issm/trunk/src/m/qmu/dakota_out_parse.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/dakota_out_parse.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -169,7 +169,7 @@
     desc(1,i)=cellstr(tokens{1}{i+1});
 end
 display(sprintf('Number of columns (Dakota V+R)=%d.',ntokens-1));
-    
+
 %  process rows of matrix
 
 nrow=0;
@@ -300,7 +300,7 @@
         break;
     end
     [ntokens,tokens]=fltokens(fline);
-    
+
 %  add new response function and moments
 
     dresp(end+1).descriptor=tokens{1}{ 1};
@@ -335,7 +335,7 @@
         break;
     end
     [ntokens,tokens]=fltokens(fline);
-   
+
 %  find response function associated with confidence intervals
 
     idresp=0;
@@ -463,11 +463,11 @@
     cmat.column=cell(1,ntokens);
     cmat.row   =cell(1,1);
     cmat.matrix=zeros(1,ntokens);
-    
+
     for i=1:ntokens
         cmat.column(1,i)=cellstr(tokens{1}{i});
     end
-    
+
 %  process rows of matrix, reading until blank line
 
     nrow=0;
@@ -582,7 +582,7 @@
             dresp(idresp).descriptor=tokens{1}{ 6};
             display(sprintf('  %s',dresp(idresp).descriptor));
         end
-    
+
 %  skip column headings of cdf
 
         fline=fgetl(fidi);

Modified: issm/trunk/src/m/qmu/examples/direct.m
===================================================================
--- issm/trunk/src/m/qmu/examples/direct.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/examples/direct.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,8 +3,6 @@
 md.qmu.params.analysis_driver='diagnostic';
 md.qmu.params.evaluation_concurrency=1;
 
-
-
 %or for matlab direct driver
 md.qmu.params.direct=true;
 md.qmu.params.analysis_driver='matlab';

Modified: issm/trunk/src/m/qmu/examples/lrel_mmf.m
===================================================================
--- issm/trunk/src/m/qmu/examples/lrel_mmf.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/examples/lrel_mmf.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -92,4 +92,3 @@
 %plotmodel(md,'data','mesh','partitionedges','on','linewidth',2)
 %part_hist(md.qmu.partition,md.vertex_weight)
 %plotmodel(md,'data',log10(md.results.dakota.dresp_out(9).impfac(md.qmu.partition+1)))
-

Modified: issm/trunk/src/m/qmu/expandvariables.m
===================================================================
--- issm/trunk/src/m/qmu/expandvariables.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/expandvariables.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 fnames=fieldnames(variables);
 
 for i=1:length(fnames)
-    
+
 %  for linear constraints, just copy
 
     if isa(variables.(fnames{i}),'linear_inequality_constraint') || ...

Modified: issm/trunk/src/m/qmu/importancefactors.m
===================================================================
--- issm/trunk/src/m/qmu/importancefactors.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/importancefactors.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,7 +8,6 @@
 %   Example: factors=importancefactors(md,'drag','max_vel');
 %
 
-
 variablenamelength=length(variablename);
 
 %go through all response functions and find the one corresponding to the correct responsename

Modified: issm/trunk/src/m/qmu/lclist_write.m
===================================================================
--- issm/trunk/src/m/qmu/lclist_write.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/lclist_write.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -59,4 +59,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/qmu/plot/plot_boxplot.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_boxplot.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_boxplot.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -61,13 +61,13 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descr=cell (1,length(dresp));
     lsamp=zeros(1,length(dresp));
     for i=1:length(dresp)
@@ -83,7 +83,7 @@
 else
     sampr=varargin{iarg};
     iarg=iarg+1;
-    
+
     if     iarg <= nargin && iscell(varargin{iarg})
         descr=varargin{iarg};
         iarg=iarg+1;
@@ -118,7 +118,7 @@
     end
     iarg=iarg+2;
 end
-    
+
 %%  draw the plot
 
 %  draw box plot

Modified: issm/trunk/src/m/qmu/plot/plot_cdf.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_cdf.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_cdf.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -76,7 +76,7 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
@@ -187,7 +187,7 @@
     end
     set(hl1(i),'Color',cmap(imap,:))
 end
-    
+
 xlim('auto')
 [xlims]=xlim;
 if exist('xmin','var')
@@ -277,7 +277,7 @@
             end
         end
     end
-    
+
     if strcmpi(pdfplt,'line')
         xplot=xpdf;
         yplot=ypdf;

Modified: issm/trunk/src/m/qmu/plot/plot_hist_norm.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_hist_norm.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_hist_norm.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -88,13 +88,13 @@
 if isstruct(varargin{iarg})
     dresp1=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp1=struc_desc(dresp1,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descr=cell (1,length(dresp1));
     lsamp=zeros(1,length(dresp1));
     for i=1:length(dresp1)
@@ -110,7 +110,7 @@
 else
     sampr=varargin{iarg};
     iarg=iarg+1;
-    
+
     lsamp(1:size(sampr,2))=size(sampr,1);
 
     if     iarg <= nargin && iscell(varargin{iarg})
@@ -141,7 +141,7 @@
         dresp2=struc_desc(dresp2,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     mu   =zeros(1,length(dresp2));
     sigma=zeros(1,length(dresp2));
 
@@ -297,7 +297,7 @@
         set(hl1(i),'Color',cmap(imap,:))
     end
 end
-    
+
 xlim('auto')
 [xlims]=xlim;
 if exist('hmin','var')

Modified: issm/trunk/src/m/qmu/plot/plot_hist_norm_ci.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_hist_norm_ci.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_hist_norm_ci.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -77,13 +77,13 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descr=cell (1,length(dresp));
     lsamp=zeros(1,length(dresp));
     for i=1:length(dresp)
@@ -91,7 +91,7 @@
     end
     sampr=zeros(max(lsamp),length(dresp));
     sampr(:,:)=NaN;
-    
+
     mu     =zeros(1,length(dresp));
     sigma  =zeros(1,length(dresp));
     muci   =zeros(2,length(dresp));
@@ -108,7 +108,7 @@
 else
     sampr=varargin{iarg};
     iarg=iarg+1;
-    
+
     lsamp(1:size(sampr,2))=size(sampr,1);
 
     if     iarg <= nargin && iscell(varargin{iarg})
@@ -120,7 +120,7 @@
     else
         descr=cell(1,size(sampr,2));
     end
-    
+
     mu     =zeros(1,size(sampr,2));
     sigma  =zeros(1,size(sampr,2));
     muci   =zeros(2,size(sampr,2));
@@ -324,7 +324,7 @@
         set(hl1(i),'Color',cmap(imap,:))
     end
 end
-    
+
 xlim('auto')
 [xlims]=xlim;
 if exist('hmin','var')

Modified: issm/trunk/src/m/qmu/plot/plot_if_bars.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_if_bars.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_if_bars.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -65,13 +65,13 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descr=cell (1,length(dresp));
     lifr =zeros(1,length(dresp));
     for i=1:length(dresp)
@@ -124,7 +124,7 @@
         [ifmean,index]=sort(ifmean,'ascend' );
     end
     clear ifmean
-    
+
     dvar=dvar(index);
     ifr =ifr (:,index);
 end
@@ -135,11 +135,11 @@
     nif=length(dvar);
     dvar(nif+1,1)=cellstr(sprintf('others < %f',ifmin));
     ifr (:,nif+1)=0.;
-    
+
     nif2=0;
     dvar2=cell (size(dvar));
     ifr2 =zeros(size(ifr ));
-    
+
 %  sum filtered rows and copy unfiltered rows
 
     for i=1:nif
@@ -151,12 +151,12 @@
             ifr2 (:,nif2)=ifr (:,i);
         end
     end
-    
+
 %  copy sums
 
     dvar2(nif2+1)  =dvar(nif+1);
     ifr2 (:,nif2+1)=ifr (:,nif+1);
-    
+
 %  copy back and truncate filtered rows
 
     clear dvar ifr

Modified: issm/trunk/src/m/qmu/plot/plot_if_spec.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_if_spec.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_if_spec.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -71,13 +71,13 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descr=cell (1,length(dresp));
     lifr =zeros(1,length(dresp));
     for i=1:length(dresp)
@@ -136,7 +136,7 @@
         [ifmean,index]=sort(ifmean,'descend');
     end
     clear ifmean
-    
+
     dvar=dvar(index);
     ifr =ifr (:,index);
 end
@@ -147,11 +147,11 @@
     nif=length(dvar);
     dvar(nif+1,1)=cellstr(sprintf('others < %f',ifmin));
     ifr (:,nif+1)=0.;
-    
+
     nif2=0;
     dvar2=cell (size(dvar));
     ifr2 =zeros(size(ifr ));
-    
+
 %  sum filtered rows and copy unfiltered rows
 
     for i=1:nif
@@ -163,12 +163,12 @@
             ifr2 (:,nif2)=ifr (:,i);
         end
     end
-    
+
 %  copy sums
 
     dvar2(nif2+1)  =dvar(nif+1);
     ifr2 (:,nif2+1)=ifr (:,nif+1);
-    
+
 %  copy back and truncate filtered rows
 
     clear dvar ifr

Modified: issm/trunk/src/m/qmu/plot/plot_normdist_bars.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_normdist_bars.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_normdist_bars.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -72,7 +72,7 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
@@ -81,7 +81,7 @@
 else
     sampr=varargin{iarg};
     iarg=iarg+1;
-    
+
     if     iarg <= nargin && iscell(varargin{iarg})
         descr=varargin{iarg};
         iarg=iarg+1;
@@ -91,7 +91,7 @@
     else
         descr=cell(1:size(sampr,2));
     end
-    
+
     dresp=struct([]);
     for i=1:size(sampr,2)
         dresp(end+1).sample=samp(:,i);

Modified: issm/trunk/src/m/qmu/plot/plot_normplot.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_normplot.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_normplot.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -61,13 +61,13 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descr=cell (1,length(dresp));
     lsamp=zeros(1,length(dresp));
     for i=1:length(dresp)
@@ -83,7 +83,7 @@
 else
     sampr=varargin{iarg};
     iarg=iarg+1;
-    
+
     if     iarg <= nargin && iscell(varargin{iarg})
         descr=varargin{iarg};
         iarg=iarg+1;
@@ -118,7 +118,7 @@
     end
     iarg=iarg+2;
 end
-    
+
 %%  draw the plot
 
 %  draw normal probability plot

Modified: issm/trunk/src/m/qmu/plot/plot_prob_bars.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_prob_bars.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_prob_bars.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -56,7 +56,6 @@
 
 %%  assemble the data into a matrix and calculate the increments
 
-
 %%  process input data and assemble into matrices and increments
 
 %  responses
@@ -65,13 +64,13 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descr=cell (1,length(dresp));
     lcdfr=zeros(1,length(dresp));
     for i=1:length(dresp)

Modified: issm/trunk/src/m/qmu/plot/plot_rlev_bars.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_rlev_bars.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_rlev_bars.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -61,13 +61,13 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descr=cell (1,length(dresp));
     lcdfr=zeros(1,length(dresp));
     for i=1:length(dresp)

Modified: issm/trunk/src/m/qmu/plot/plot_rlev_bars_ci.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_rlev_bars_ci.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_rlev_bars_ci.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -73,7 +73,7 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
@@ -82,7 +82,7 @@
 else
     sampr=varargin{iarg};
     iarg=iarg+1;
-    
+
     if     iarg <= nargin && iscell(varargin{iarg})
         descr=varargin{iarg};
         iarg=iarg+1;
@@ -92,7 +92,7 @@
     else
         descr=cell(1:size(sampr,2));
     end
-    
+
     dresp=struct([]);
     for i=1:size(sampr,2)
         dresp(end+1).sample=sampr(:,i);
@@ -135,7 +135,7 @@
             normfit(sampr(:,i),0.05);
         display('Using calculated normal fits from sample data.')
     end
-    
+
     if ~isfield(dresp(i),'cdf') || isempty(dresp(i).cdf)
 %  use minus/plus integer standard deviations
         sdvect=[-4 -3 -2 -1 0 1 2 3 4];

Modified: issm/trunk/src/m/qmu/plot/plot_rvsv_line.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_rvsv_line.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_rvsv_line.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -73,13 +73,13 @@
 if isstruct(varargin{iarg})
     dvar=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dvar=struc_desc(dvar,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descv=cell (1,length(dvar));
     lsamp=zeros(1,length(dvar));
     for i=1:length(dvar)
@@ -95,7 +95,7 @@
 else
     sampv=varargin{iarg};
     iarg=iarg+1;
-    
+
     if     iarg <= nargin && iscell(varargin{iarg})
         descv=varargin{iarg};
         iarg=iarg+1;
@@ -118,13 +118,13 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descr=cell (1,length(dresp));
     lsamp=zeros(1,length(dresp));
     for i=1:length(dresp)
@@ -140,7 +140,7 @@
 else
     sampr=varargin{iarg};
     iarg=iarg+1;
-    
+
     if     iarg <= nargin && iscell(varargin{iarg})
         descr=varargin{iarg};
         iarg=iarg+1;
@@ -176,7 +176,7 @@
     end
     iarg=iarg+2;
 end
-    
+
 if     ~exist('nplotr','var') && ~exist('nplotc','var')
     nplotr=1;
     nplotc=1;
@@ -224,7 +224,7 @@
             set(get(get(hscat(end),'Annotation'),'LegendInformation'),...
                 'IconDisplayStyle','off'); % Exclude line from legend
         end
-        
+
 %  add the annotation
 
         if (ivar*iresp == size(sampv,2)*size(sampr,2)) || ...

Modified: issm/trunk/src/m/qmu/plot/plot_rvsv_scat3.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_rvsv_scat3.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_rvsv_scat3.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -78,13 +78,13 @@
 if isstruct(varargin{iarg})
     dvar=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dvar=struc_desc(dvar,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descv=cell (1,length(dvar));
     lsamp=zeros(1,length(dvar));
     for i=1:length(dvar)
@@ -100,7 +100,7 @@
 else
     sampv=varargin{iarg};
     iarg=iarg+1;
-    
+
     if     iarg <= nargin && iscell(varargin{iarg})
         descv=varargin{iarg};
         iarg=iarg+1;
@@ -127,13 +127,13 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descr=cell (1,length(dresp));
     lsamp=zeros(1,length(dresp));
     for i=1:length(dresp)
@@ -149,7 +149,7 @@
 else
     sampr=varargin{iarg};
     iarg=iarg+1;
-    
+
     if     iarg <= nargin && iscell(varargin{iarg})
         descr=varargin{iarg};
         iarg=iarg+1;
@@ -186,7 +186,7 @@
     end
     iarg=iarg+2;
 end
-    
+
 if     ~exist('nplotr','var') && ~exist('nplotc','var')
     nplotr=ceil(sqrt(size(sampr,2)));
     nplotc=ceil(size(sampr,2)/nplotr);
@@ -207,7 +207,7 @@
 hscat3=[];
 
 for iresp=1:size(sampr,2)
-    
+
 %  initialize the subplot
 
     haxes(end+1)=subplot(nplotr,nplotc,iresp);

Modified: issm/trunk/src/m/qmu/plot/plot_rvsv_surf.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_rvsv_surf.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_rvsv_surf.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -75,13 +75,13 @@
 if isstruct(varargin{iarg})
     dvar=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dvar=struc_desc(dvar,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descv=cell (1,length(dvar));
     lsamp=zeros(1,length(dvar));
     for i=1:length(dvar)
@@ -97,7 +97,7 @@
 else
     sampv=varargin{iarg};
     iarg=iarg+1;
-    
+
     if     iarg <= nargin && iscell(varargin{iarg})
         descv=varargin{iarg};
         iarg=iarg+1;
@@ -124,13 +124,13 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
         iarg=iarg+1;
     end
-    
+
     descr=cell (1,length(dresp));
     lsamp=zeros(1,length(dresp));
     for i=1:length(dresp)
@@ -146,7 +146,7 @@
 else
     sampr=varargin{iarg};
     iarg=iarg+1;
-    
+
     if     iarg <= nargin && iscell(varargin{iarg})
         descr=varargin{iarg};
         iarg=iarg+1;
@@ -183,7 +183,7 @@
     end
     iarg=iarg+2;
 end
-    
+
 if     ~exist('nplotr','var') && ~exist('nplotc','var')
     nplotr=ceil(sqrt(size(sampr,2)));
     nplotc=ceil(size(sampr,2)/nplotr);
@@ -207,7 +207,7 @@
     for i=1:size(sampr,1)
         z(ixi(i),iyi(i))=sampr(i,iresp);
     end
-    
+
 %  initialize the subplot
 
     haxes(iresp)=subplot(nplotr,nplotc,iresp);

Modified: issm/trunk/src/m/qmu/plot/plot_sampdist_bars.m
===================================================================
--- issm/trunk/src/m/qmu/plot/plot_sampdist_bars.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/plot/plot_sampdist_bars.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -71,7 +71,7 @@
 if isstruct(varargin{iarg})
     dresp=varargin{iarg};
     iarg=iarg+1;
-    
+
 %     if iarg <= nargin && (iscell(varargin{iarg}) || ischar(varargin{iarg}))
     if iarg <= nargin && iscell(varargin{iarg})
         dresp=struc_desc(dresp,varargin{iarg});
@@ -80,7 +80,7 @@
 else
     sampr=varargin{iarg};
     iarg=iarg+1;
-    
+
     if     iarg <= nargin && iscell(varargin{iarg})
         descr=varargin{iarg};
         iarg=iarg+1;
@@ -90,7 +90,7 @@
     else
         descr=cell(1:size(sampr,2));
     end
-    
+
     dresp=struct([]);
     for i=1:size(sampr,2)
         dresp(end+1).sample=sampr(:,i);

Modified: issm/trunk/src/m/qmu/process_qmu_options.m
===================================================================
--- issm/trunk/src/m/qmu/process_qmu_options.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/process_qmu_options.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -98,4 +98,3 @@
 outoptions.imethod=imethod;
 outoptions.iparams=iparams;
 outoptions.runmpi=runmpi;
-

Modified: issm/trunk/src/m/qmu/process_qmu_response_data.m
===================================================================
--- issm/trunk/src/m/qmu/process_qmu_response_data.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/process_qmu_response_data.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,6 @@
 %
 % See also PREQMU, PRESOLVE
 
-
 %preliminary data
 process_mass_flux_profiles=0;
 
@@ -21,7 +20,6 @@
 	end
 end
 
-
 %deal with mass flux profiles
 if process_mass_flux_profiles,
 
@@ -29,7 +27,7 @@
 	if isnans(md.qmu.mass_flux_profiles),
 		error('process_qmu_response_data error message: could not find a mass_flux exp profile!');
 	end
-	
+
 	if ~iscell(md.qmu.mass_flux_profiles),
 		error('process_qmu_response_data error message: qmu_mass_flux_profiles field should be a cell array of domain outline names');
 	end

Modified: issm/trunk/src/m/qmu/qmu_correlation.m
===================================================================
--- issm/trunk/src/m/qmu/qmu_correlation.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/qmu_correlation.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 if ~isfield(md.qmu.results,'dresp_dat'),
 	error('qmu_correlation error message: could not find dresp_dat field in dakota results. you need to run montecarlo before computing correlations');
 end
-	
+
 data=md.qmu.results.dresp_dat;
 
 %go through all the rows and figure which one we are interested in.

Modified: issm/trunk/src/m/qmu/qmuisdistributed.m
===================================================================
--- issm/trunk/src/m/qmu/qmuisdistributed.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/qmuisdistributed.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,6 @@
 function found=qmuisdistribted(string)
 %QMUISDISTRIBTED - figure out if a string is a decriptor with a numerical postfix. Like thickness1, or drag10
 
-
 %just take last string element, and see if it is numeric.
 last=string(end);
 

Modified: issm/trunk/src/m/qmu/qmumarshall.m
===================================================================
--- issm/trunk/src/m/qmu/qmumarshall.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/qmumarshall.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -46,7 +46,7 @@
 		qmu_segments=1;
 	end
 end
-			
+
 if qmu_segments,
 	WriteData(fid,md.qmu.mass_flux_num_profiles,'Integer','qmu_mass_flux_num_profiles');
 	for i=1:md.qmu.mass_flux_num_profiles,
@@ -57,7 +57,6 @@
 	WriteData(fid,md.qmu.mass_flux_num_profiles,'Integer','qmu_mass_flux_num_profiles');
 end
 
-
 %write part and npart to disk
 WriteData(fid,md.qmu.numberofpartitions,'Integer','npart');
 WriteData(fid,md.qmu.partition,'Mat','part');
@@ -70,7 +69,7 @@
 
 end
 
-function qmumarshallusage();
+function qmumarshallusage()
 disp(' ');
 disp('function qmumarshall(md.qmu.variables,responses)');
 end

Modified: issm/trunk/src/m/qmu/qmuresponse.m
===================================================================
--- issm/trunk/src/m/qmu/qmuresponse.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/qmuresponse.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -113,4 +113,3 @@
 else
 	error(['qmuresponse error message: unknown descriptor ' descriptor]);
 end
-

Modified: issm/trunk/src/m/qmu/qmuroot.m
===================================================================
--- issm/trunk/src/m/qmu/qmuroot.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/qmuroot.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,4 +10,3 @@
 		root=[root string(i)];
 	end
 end
-

Modified: issm/trunk/src/m/qmu/rlist_write.m
===================================================================
--- issm/trunk/src/m/qmu/rlist_write.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/rlist_write.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -67,4 +67,3 @@
 end
 
 end
-

Modified: issm/trunk/src/m/qmu/sensitivities.m
===================================================================
--- issm/trunk/src/m/qmu/sensitivities.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/sensitivities.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,7 +8,6 @@
 %   Example: sens=sensitivities(md,'DragCoefficient','MaxVel');
 %
 
-
 variablenamelength=length(variablename);
 
 %go through all response functions and find the one corresponding to the correct responsename

Modified: issm/trunk/src/m/qmu/setupdesign/IsScaled.m
===================================================================
--- issm/trunk/src/m/qmu/setupdesign/IsScaled.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/setupdesign/IsScaled.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 	status=1;
 
 case {'RiftsFriction'},
-	
+
 	status=2; %special treatment
 
 otherwise

Modified: issm/trunk/src/m/qmu/setupdesign/QmuSetupVariables.m
===================================================================
--- issm/trunk/src/m/qmu/setupdesign/QmuSetupVariables.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/setupdesign/QmuSetupVariables.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,7 +6,6 @@
 %decide whether this is a distributed variable, which will drive whether we expand it into npart values,
 %or if we just carry it forward as is. 
 
-
 %ok, key off according to type of descriptor:
 if strncmp(descriptor,'scaled_',7),
 	%we have a scaled variable, expand it over the partition.

Modified: issm/trunk/src/m/qmu/vector_write.m
===================================================================
--- issm/trunk/src/m/qmu/vector_write.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/qmu/vector_write.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,7 +30,7 @@
     end
     nitem=nitem+1;
     lsvec=lsvec+1+length(sitem);
-    
+
     if (nitem <= nmax) && (lsvec <= cmax)
         svec=[svec ' ' sitem];
     else

Modified: issm/trunk/src/m/regional/BasinConstrain.m
===================================================================
--- issm/trunk/src/m/regional/BasinConstrain.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/regional/BasinConstrain.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function md=BasinConstrain(md,domain);
+function md=BasinConstrain(md,domain)
 %BASINCONSTRAIN - constrain basin
 %
 %   Constrain basin using a constraint domain outline, 

Modified: issm/trunk/src/m/regional/BasinConstrainShelf.m
===================================================================
--- issm/trunk/src/m/regional/BasinConstrainShelf.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/regional/BasinConstrainShelf.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function md=BasinConstrainShelf(md,domain);
+function md=BasinConstrainShelf(md,domain)
 %BASINCONSTRAIN - constrain basin
 %
 %   Constrain basin using a constraint domain outline, 

Modified: issm/trunk/src/m/regional/basinzoom.m
===================================================================
--- issm/trunk/src/m/regional/basinzoom.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/regional/basinzoom.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -38,7 +38,7 @@
 
 %Ok, find basin we are talking about: 
 load([jplsvn() '/projects/ModelData/Names/Names.mat']);
-		
+
 %Go through names: 
 found=0;
 for i=1:size(names,1),

Modified: issm/trunk/src/m/regional/regionaltransient2d.m
===================================================================
--- issm/trunk/src/m/regional/regionaltransient2d.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/regional/regionaltransient2d.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -30,7 +30,7 @@
 end
 
 %take every fields from model
-mde=modelextract(md1,area);
+mde=md1.extract(area);
 mde.private.bamg=[];
 mde.mesh.extractedvertices=nan;
 mde.mesh.extractedelements=nan;
@@ -130,7 +130,7 @@
 
 	%Diagnostic.  Don't spc the icefront vertices.
 	if ~isnan(md2.diagnostic.icefront)
-		md1s=modelextract(md1,area);
+		md1s=md1.extract(area);
 		%md2.diagnostic.icefront=[md2.mesh.segments 2];
 		e2=md2.mesh.segments(:,end);
 		e1=md1s.mesh.segments(:,end);
@@ -155,4 +155,3 @@
 	if isstruct(md1.results),
 		md2.results=[];
 	end
-

Modified: issm/trunk/src/m/regional/showbasins.m
===================================================================
--- issm/trunk/src/m/regional/showbasins.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/regional/showbasins.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,7 +21,6 @@
 	options=pairoptions(varargin{:});
 end
 
-
 %recover some options, and set defaults
 unitmultiplier=getfieldvalue(options,'unit',1);
 fontsize=getfieldvalue(options,'fontsize',12);

Modified: issm/trunk/src/m/solve/MatlabProcessPatch.m
===================================================================
--- issm/trunk/src/m/solve/MatlabProcessPatch.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solve/MatlabProcessPatch.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-function structure=MatlabProcessPatch(structure);
+function structure=MatlabProcessPatch(structure)
 %PROCESSPATCH - create a structure from a patch
 %
 %   Usage:

Modified: issm/trunk/src/m/solve/MatlabProcessPatch.py
===================================================================
--- issm/trunk/src/m/solve/MatlabProcessPatch.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solve/MatlabProcessPatch.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -7,10 +7,10 @@
 	"""
 
 	#loop over steps
-	for structurei in structure.itervalues():
+	for structurei in structure:
 
 		#return if there is no field Patch
-		if 'Patch' not in structurei:
+		if not hasattr(structurei,'Patch'):
 			continue
 
 		raise SystemError("MatlabProcessPatch not implemented in Python.")

Modified: issm/trunk/src/m/solve/WriteData.m
===================================================================
--- issm/trunk/src/m/solve/WriteData.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solve/WriteData.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -230,7 +230,7 @@
 	string(1)=upper(string(1));
 
 	%Get Enum
-	enum=eval([string 'Enum();']); 
+	enum=StringToEnum(string); 
 end % }}}
 function code=FormatToCode(format) % {{{
 %This routine takes the format string, and hardcodes it into an integer, which 

Modified: issm/trunk/src/m/solve/WriteData.py
===================================================================
--- issm/trunk/src/m/solve/WriteData.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solve/WriteData.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,7 +16,7 @@
 
 	#process options
 	#  the import above the function level doesn't work?
-	from pairoptions import *
+	from pairoptions import pairoptions
 	options=pairoptions(*args)
 
 	#Get data properties
@@ -100,8 +100,10 @@
 
 	elif strcmpi(format,'BooleanMat'):    # {{{
 
-		if isinstance(data,bool):
+		if   isinstance(data,bool):
 			data=numpy.array([data])
+		elif isinstance(data,(list,tuple)):
+			data=numpy.array(data).reshape(-1,1)
 		if len(data.shape) == 1:
 			if numpy.size(data):
 				data=data.reshape(numpy.size(data),1)
@@ -131,8 +133,10 @@
 
 	elif strcmpi(format,'IntMat'):    # {{{
 
-		if isinstance(data,(int,long)):
+		if   isinstance(data,(int,long)):
 			data=numpy.array([data])
+		elif isinstance(data,(list,tuple)):
+			data=numpy.array(data).reshape(-1,1)
 		if len(data.shape) == 1:
 			if numpy.size(data):
 				data=data.reshape(numpy.size(data),1)
@@ -162,8 +166,10 @@
 
 	elif strcmpi(format,'DoubleMat'):    # {{{
 
-		if isinstance(data,(bool,int,long,float)):
+		if   isinstance(data,(bool,int,long,float)):
 			data=numpy.array([data])
+		elif isinstance(data,(list,tuple)):
+			data=numpy.array(data).reshape(-1,1)
 		if len(data.shape) == 1:
 			if numpy.size(data):
 				data=data.reshape(numpy.size(data),1)
@@ -196,8 +202,10 @@
 		#first get length of record
 		recordlength=4+4    #number of records + code
 		for matrix in data:
-			if isinstance(matrix,(bool,int,long,float)):
+			if   isinstance(matrix,(bool,int,long,float)):
 				matrix=numpy.array([matrix])
+			elif isinstance(matrix,(list,tuple)):
+				matrix=numpy.array(matrix).reshape(-1,1)
 			if len(matrix.shape) == 1:
 				if numpy.size(matrix):
 					matrix=matrix.reshape(numpy.size(matrix),1)
@@ -218,8 +226,10 @@
 
 		#write each matrix: 
 		for matrix in data:
-			if isinstance(matrix,(bool,int,long,float)):
+			if   isinstance(matrix,(bool,int,long,float)):
 				matrix=numpy.array([matrix])
+			elif isinstance(matrix,(list,tuple)):
+				matrix=numpy.array(matrix).reshape(-1,1)
 			if len(matrix.shape) == 1:
 				matrix=matrix.reshape(numpy.size(matrix),1)
 
@@ -275,7 +285,7 @@
 		string=string[0].upper()+string[1:]
 
 	#Get Enum
-	exec('enum='+string+'Enum()',globals())
+	enum=StringToEnum(string)[0]
 
 	return enum
 # }}}

Modified: issm/trunk/src/m/solve/loadresultsfromdisk.m
===================================================================
--- issm/trunk/src/m/solve/loadresultsfromdisk.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solve/loadresultsfromdisk.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -49,7 +49,6 @@
 		disp(['loadresultsfromcluster info message: error during solution. Check your errlog and outlog model fields']);
 	end
 
-
 %post processes qmu results if necessary
 else
 

Modified: issm/trunk/src/m/solve/loadresultsfromdisk.py
===================================================================
--- issm/trunk/src/m/solve/loadresultsfromdisk.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solve/loadresultsfromdisk.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,8 @@
 import os
-from collections import OrderedDict
+from results import *
 from parseresultsfromdisk import *
 from EnumToString import EnumToString
+from MatlabFuncs import *
 
 def loadresultsfromdisk(md,filename):
 	"""
@@ -22,34 +23,38 @@
 			raise OSError("binary file '%s' not found." % filename)
 
 		#initialize md.results if not a structure yet
-		if not isinstance(md.results,dict):
-			md.results=OrderedDict()
+		if not isinstance(md.results,results):
+			md.results=results()
 
 		#load results onto model
-		structure=parseresultsfromdisk(filename,~md.settings.io_gather)
+		structure=parseresultsfromdisk(filename,not md.settings.io_gather)
 		if not len(structure):
 			raise RuntimeError("No result found in binary file '%s'. Check for solution crash." % filename)
-		md.results[structure[1]['SolutionType']]=structure;
+		setattr(md.results,structure[0].SolutionType,structure)
 
 		#recover solution_type from results
-		md.private.solution=structure[1]['SolutionType']
+		md.private.solution=structure[0].SolutionType
 
 		#read log files onto fields
 		if os.path.exists(md.miscellaneous.name+'.errlog'):
 			with open(md.miscellaneous.name+'.errlog','r') as f:
-				md.results[structure[1]['SolutionType']]['errlog']=[line[:-1] for line in f]
+				setattr(getattr(md.results,structure[0].SolutionType)[0],'errlog',[line[:-1] for line in f])
 		else:
-			md.results[structure[1]['SolutionType']]['errlog']=[]
+			setattr(getattr(md.results,structure[0].SolutionType)[0],'errlog',[])
 
 		if os.path.exists(md.miscellaneous.name+'.outlog'):
 			with open(md.miscellaneous.name+'.outlog','r') as f:
-				md.results[structure[1]['SolutionType']]['outlog']=[line[:-1] for line in f]
+				setattr(getattr(md.results,structure[0].SolutionType)[0],'outlog',[line[:-1] for line in f])
 		else:
-			md.results[structure[1]['SolutionType']]['outlog']=[]
+			setattr(getattr(md.results,structure[0].SolutionType)[0],'outlog',[])
 
-		if len(md.results[structure[1]['SolutionType']]['errlog']):
+		if len(getattr(md.results,structure[0].SolutionType)[0].errlog):
 			print ("loadresultsfromcluster info message: error during solution. Check your errlog and outlog model fields.")
 
+		#if only one solution, extract it from list for user friendliness
+		if len(structure) == 1 and not strcmp(structure[0].SolutionType,'TransientSolution'):
+			setattr(md.results,structure[0].SolutionType,structure[0])
+
 	#post processes qmu results if necessary
 	else:
 

Modified: issm/trunk/src/m/solve/marshall.m
===================================================================
--- issm/trunk/src/m/solve/marshall.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solve/marshall.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -35,11 +35,7 @@
 
 	%Marshall current object
 	%disp(['marshalling ' field '...']);
-	if verLessThan('matlab', '7.6')
-		marshall(md.(field),fid);
-	else
-		md.(field).marshall(fid);
-	end
+	marshall(md.(field),fid);
 end
 
 %close file

Modified: issm/trunk/src/m/solve/parseresultsfromdisk.m
===================================================================
--- issm/trunk/src/m/solve/parseresultsfromdisk.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solve/parseresultsfromdisk.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -19,7 +19,6 @@
 %   Usage:
 %      results=parseresultsfromdiskioserial(filename)
 
-
 %Open file
 fid=fopen(filename,'rb');
 if(fid==-1),
@@ -54,7 +53,6 @@
 %   Usage:
 %      results=parseresultsfromdiskiosplit(filename)
 
-
 %Open file
 fid=fopen(filename,'rb');
 if(fid==-1),
@@ -176,7 +174,6 @@
 %   Usage:
 %      field=ReadDataDimensions(fid)
 
-
 %read field
 [length,count]=fread(fid,1,'int');
 

Modified: issm/trunk/src/m/solve/parseresultsfromdisk.py
===================================================================
--- issm/trunk/src/m/solve/parseresultsfromdisk.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solve/parseresultsfromdisk.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,6 +1,7 @@
 import struct
 import numpy
 from collections import OrderedDict
+import results as resultsclass
 from MatlabFuncs import *
 from MatlabProcessPatch import *
 
@@ -36,24 +37,24 @@
 	except IOError as e:
 		raise IOError("loadresultsfromdisk error message: could not open '%s' for binary reading." % filename)
 
-	results=OrderedDict()
+	results=[]
 
 	#Read fields until the end of the file.
 	result=ReadData(fid)
 	while result:
+		if result['step'] > len(results):
+			for i in xrange(len(results),result['step']-1):
+				results.append(None)
+			results.append(resultsclass.results())
 		#Get time and step
-		if result['step'] not in results:
-			results[result['step']]=OrderedDict()
-			results[result['step']]['step']=result['step']
-			results[result['step']]['time']=result['time'] 
+		setattr(results[result['step']-1],'step',result['step'])
+		setattr(results[result['step']-1],'time',result['time']) 
 	
 		#Add result
-		if result['step'] in results and \
-		   result['fieldname'] in results[result['step']] and \
-		   not strcmp(result['fieldname'],'SolutionType'):
-			results[result['step']][result['fieldname']]=numpy.concatenate((results[result['step']][result['fieldname']],result['field']),axis=0)
+		if hasattr(results[result['step']-1],result['fieldname']) and not strcmp(result['fieldname'],'SolutionType'):
+			setattr(results[result['step']-1],result['fieldname'],numpy.vstack((getattr(results[result['step']-1],result['fieldname']),result['field'])))
 		else:
-			results[result['step']][result['fieldname']]=result['field']
+			setattr(results[result['step']-1],result['fieldname'],result['field'])
 
 		#read next result
 		result=ReadData(fid)
@@ -77,7 +78,7 @@
 	except IOError as e:
 		raise IOError("loadresultsfromdisk error message: could not open '%s' for binary reading." % filename)
 
-	results=OrderedDict()
+	results=[]
 
 	#if we have done split I/O, ie, we have results that are fragmented across patches, 
 	#do a first pass, and figure out the structure of results
@@ -85,16 +86,18 @@
 	while result:
 
 		#Get time and step
-		if result['step'] not in results:
-			results[result['step']]=OrderedDict()
-			results[result['step']]['step']=result['step']
-			results[result['step']]['time']=result['time'] 
+		if result['step'] > len(results):
+			for i in xrange(len(results),result['step']-1):
+				results.append(None)
+			results.append(resultsclass.results())
+		setattr(results[result['step']-1],'step',result['step'])
+		setattr(results[result['step']-1],'time',result['time']) 
 
 		#Add result
 		if strcmpi(result['fieldname'],'Patch'):
-			results[result['step']][result['fieldname']]=[0,result['N']]
+			setattr(results[result['step']-1],result['fieldname'],[0,result['N']])
 		else:
-			results[result['step']][result['fieldname']]=float('NaN')
+			setattr(results[result['step']-1],result['fieldname'],float('NaN'))
 
 		#read next result
 		result=ReadDataDimensions(fid)
@@ -106,8 +109,8 @@
 
 		#Add result
 		if strcmpi(result['fieldname'],'Patch'):
-			patchdimensions=results[result['step']][result['fieldname']]
-			results[result['step']][result['fieldname']]=[patchdimensions[0]+result['M'],result['N']]
+			patchdimensions=getattr(results[result['step']-1],result['fieldname'])
+			setattr(results[result['step']-1],result['fieldname'],[patchdimensions[0]+result['M'],result['N']])
 
 		#read next result
 		result=ReadDataDimensions(fid)
@@ -115,8 +118,8 @@
 	#allocate patches
 	for result in results.itervalues():
 		if 'Patch' in result:
-			result['Patch']=numpy.zeros(shape=(result['Patch'][0],result['Patch'][1]),dtype=float)
-			result['counter']=0    #use to index into the patch
+			setattr(result,'Patch',numpy.zeros((result['Patch'][0],result['Patch'][1])))
+			setattr(result,'counter',0)    #use to index into the patch
 
 	#third pass, this time to read the real information
 	fid.seek(0)    #rewind
@@ -124,21 +127,22 @@
 	while result:
 
 		#Get time and step
-		if result['step'] not in results:
-			results[result['step']]=OrderedDict()
-			results[result['step']]['step']=result['step']
-			results[result['step']]['time']=result['time'] 
+		if result['step']> len(results):
+			for i in xrange(len(results),result['step']-1):
+				results.append(None)
+			results.append(resultsclass.results())
+		setattr(results[result['step']-1],'step',result['step'])
+		setattr(results[result['step']-1],'time',result['time']) 
 
 		#Add result
 		if strcmpi(result['fieldname'],'Patch'):
-			counter=results[result['step']]['counter']
+			counter=results[result['step']-1].counter
 			counter2=counter+result['field'].shape[0]-1
-			results[result['step']][result['fieldname']][counter:counter2,:]=result['field']
-
+			getattr(results[result['step']-1],result['fieldname'])[counter:counter2,:]=result['field']
 			#increment counter: 
-			results[result['step']]['counter']=counter2+1
+			results[result['step']-1].counter=counter2+1
 		else:
-			results[result['step']][result['fieldname']]=result['field']
+			setattr(results[result['step']-1],result['fieldname'],result['field'])
 
 		#read next result
 		result=ReadData(fid)
@@ -187,7 +191,7 @@
 		result['field']=field
 
 	except struct.error as e:
-		result=OrderedDict()
+		result=None
 
 	return result
 	# }}}
@@ -229,7 +233,7 @@
 		result['N']=N
 
 	except struct.error as e:
-		result=OrderedDict()
+		result=None
 
 	return result
 	# }}}

Modified: issm/trunk/src/m/solve/solve.m
===================================================================
--- issm/trunk/src/m/solve/solve.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solve/solve.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -73,13 +73,11 @@
 	cluster.np=1;
 end
 
-
 %Write all input files
 marshall(md);                                          % bin file
 PetscFile(md.solver,[md.miscellaneous.name '.petsc']); % petsc file
 BuildQueueScript(cluster,md.private.runtimename,md.miscellaneous.name,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof); % queue file
 
-
 %Stop here if batch mode
 if strcmpi(options.batch,'yes')
 	disp('batch mode requested: not launching job interactively');

Modified: issm/trunk/src/m/solve/waitonlock.m
===================================================================
--- issm/trunk/src/m/solve/waitonlock.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solve/waitonlock.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,9 @@
 executionpath=md.cluster.executionpath;
 cluster=md.cluster.name;
 login=md.cluster.login;
-port=md.cluster.port;
+if isprop(md.cluster,'port') 
+	port=md.cluster.port;
+end
 timelimit=md.settings.waitonlock;
 filename=[executionpath '/' md.private.runtimename '/' md.miscellaneous.name '.lock'];
 

Modified: issm/trunk/src/m/solvers/asmoptions.m
===================================================================
--- issm/trunk/src/m/solvers/asmoptions.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solvers/asmoptions.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 %
 %   Usage:
 %      options=asmoptions;
-			 
+
 %retrieve options provided in varargin
 options=pairoptions(varargin{:});
 asm=struct();

Modified: issm/trunk/src/m/solvers/iluasmoptions.m
===================================================================
--- issm/trunk/src/m/solvers/iluasmoptions.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solvers/iluasmoptions.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 %
 %   Usage:
 %      options=iluasmoptions;
-			 
+
 %retrieve options provided in varargin
 options=pairoptions(varargin{:});
 iluasm=struct();

Modified: issm/trunk/src/m/solvers/jacobiasmoptions.m
===================================================================
--- issm/trunk/src/m/solvers/jacobiasmoptions.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solvers/jacobiasmoptions.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 %
 %   Usage:
 %      options=jacobiasmoptions;
-			 
+
 %retrieve options provided in varargin
 options=pairoptions(varargin{:});
 jacobiasm=struct();

Modified: issm/trunk/src/m/solvers/jacobicgoptions.m
===================================================================
--- issm/trunk/src/m/solvers/jacobicgoptions.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solvers/jacobicgoptions.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 %
 %   Usage:
 %      options=jacobiasmoptions;
-			 
+
 %retrieve options provided in varargin
 options=pairoptions(varargin{:});
 jacobicg=struct();

Modified: issm/trunk/src/m/solvers/matlaboptions.m
===================================================================
--- issm/trunk/src/m/solvers/matlaboptions.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solvers/matlaboptions.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 %
 %   Usage:
 %      options=matlaboptions;
-			 
+
 %retrieve options provided in varargin
 options=pairoptions(varargin{:});
 maltab=struct();

Modified: issm/trunk/src/m/solvers/soroptions.m
===================================================================
--- issm/trunk/src/m/solvers/soroptions.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/solvers/soroptions.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,7 +3,7 @@
 %
 %   Usage:
 %      options=soroptions;
-			 
+
 %retrieve options provided in varargin
 options=pairoptions(varargin{:});
 sor=struct();

Modified: issm/trunk/src/m/string/issmprintf.m
===================================================================
--- issm/trunk/src/m/string/issmprintf.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/string/issmprintf.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -7,7 +7,7 @@
 %
 %   Example:
 %      issmprintf(1,'%s\n','string to display');
-	
+
 if flag,
 	disp(sprintf(format,varargin{:}));
 end

Modified: issm/trunk/src/m/string/strsplit.m
===================================================================
--- issm/trunk/src/m/string/strsplit.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/string/strsplit.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -16,8 +16,6 @@
 
 %   mailto:    gie.spaepen at ua.ac.be
 
-
-
 %Check input arguments
 if(nargin < 1)
     error('There is no argument defined');
@@ -86,6 +84,5 @@
     else
         splittedstring = tempsplit;
     end
-    
-        
+
 end

Modified: issm/trunk/src/m/string/strsplit_strict.m
===================================================================
--- issm/trunk/src/m/string/strsplit_strict.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/src/m/string/strsplit_strict.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,7 +4,6 @@
 %   Usage:
 %      output = strsplit_strict(inpstr,delimiter)
 
-
 %Check input arguments
 if(nargin ~= 2)
     error('There is no argument defined');


Property changes on: issm/trunk/src/wrappers
___________________________________________________________________
Added: svn:ignore
   + __pycache__
Makefile
.ignore.txt
Makefile.in
*.mexa64
.deps
*.exe
*.exp
*.lib
*.obj
*.mexw64
*.mexw64.manifest
*.mexw64.map
*.mexw32
*.mexw32.manifest
*.mexw32.map
*.exe.manifest


Modified: issm/trunk/startup.py
===================================================================
--- issm/trunk/startup.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/startup.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -15,75 +15,16 @@
 if(ISSM_DIR==None):
 	raise NameError('"ISSM_DIR" environment variable is empty! You should define ISSM_DIR in your .cshrc or .bashrc!')
 
-#Now add all issm code paths necessary to run issm smoothly. 
-#We capture the error output, so that we can warn the user to update 
-#the variable ISSM_DIR in this file, in case it is not correctly setup. 
-
-#ISSM path. Go through src/py and load everything we find  that looks like a python file
-for root,dirs,files in os.walk(ISSM_DIR+ '/src/py'):
-	if '.svn' in dirs:
-		dirs.remove('.svn')
-	for file in files:
-		if file.find(".py") != -1:
-			if file.find(".pyc") == -1:
-				#add to path 
-				sys.path.append(root)
-				file=os.path.splitext(file)[0]
-				#__import__(file)
-
+#Go through src/m and append any directory that contains a *.py file to PATH 
 for root,dirs,files in os.walk(ISSM_DIR+ '/src/m'):
 	if '.svn' in dirs:
 		dirs.remove('.svn')
 	for file in files:
 		if file.find(".py") != -1:
 			if file.find(".pyc") == -1:
-				#add to path 
-				sys.path.append(root)
-				file=os.path.splitext(file)[0]
-				#__import__(file)
+				if root not in sys.path:
+					sys.path.append(root)
 				
 sys.path.append(ISSM_DIR + '/lib')
 
-#Deal with scipy import: 
-import scipy 
-import numpy
-import nose
-
-#Import modules that are absolutely needed in ISSM {{{
-from model import *
-from mesh import *
-from mask import *
-from geometry import *
-from constants import *
-from surfaceforcings import *
-from basalforcings import *
-from matice import *
-from friction import *
-from flowequation import *
-from fielddisplay import *
-from timestepping import *
-from initialization import *
-from rifts import *
-from debug import *
-from settings import *
-from solver import *
-from ismumps  import * 
-from pairoptions  import * 
-from petscversion  import * 
-from asmoptions import *           
-from iluasmoptions import *        
-from jacobiasmoptions import *     
-from jacobicgoptions import *      
-from matlaboptions import *        
-from mumpsoptions import *         
-from soroptions import *           
-from stokesoptions import *
-from generic import *
-from hydrology import *
-from miscellaneous import *
-from private import *
-from triangle import *
-from setmask import *
-#}}}
-
 print("\n  To get started with ISSM, type issmdoc at the command prompt.\n\n")


Property changes on: issm/trunk/test
___________________________________________________________________
Modified: svn:mergeinfo
   - /issm/branches/trunk-jpl-damage/test:11427-13118
/issm/trunk-jpl/test:10936-11994,11996-12326,12333-12336,12338-12703,12705-12707,12710-13393
   + /issm/branches/trunk-jpl-damage/test:11427-13118
/issm/trunk-jpl/test:10936-11994,11996-12326,12333-12336,12338-12703,12705-12707,12710-13393,13396-13974
Added: svn:ignore
   + AdTests


Modified: issm/trunk/test/Archives/Archive237.nc
===================================================================
(Binary files differ)

Modified: issm/trunk/test/Archives/Archive423.nc
===================================================================
(Binary files differ)

Modified: issm/trunk/test/NightlyRun/ad.m
===================================================================
--- issm/trunk/test/NightlyRun/ad.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/ad.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,26 +1,30 @@
-md=triangle(model,'../Exp/Square.exp',50000);
+md=triangle(model(),'../Exp/Square.exp',100000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.diagnostic.requested_outputs=StressTensorEnum;
+
 md.autodiff.isautodiff=true;
-md.autodiff.independents={'Thickness','Surface'};
-md.autodiff.dependents={'IceVolume'};
-%md=solve(md,TransientSolutionEnum);
-md=solve(md,PrognosticSolutionEnum);
+md.verbose.autodiff=true;
+md.autodiff.independents={...
+	independent('name','Thickness','type','vertex','nods',md.mesh.numberofvertices);
+	%independent('name','Thickness','type','vertex','nods',md.mesh.numberofvertices,'fov_forward_indices',(1:md.mesh.numberofvertices)')
+	%independent('name','Thickness','type','vertex','nods',md.mesh.numberofvertices,'fos_forward_index',1)
+	};
 
-%Fields and tolerances to track changes
-field_names     ={'Vx','Vy','Vel','Pressure',...
-	'StressTensorxx','StressTensoryy','StressTensorxy'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,...
-	1e-13,1e-13,1e-13};
-field_values={...
-	(md.results.TransientSolution.Vx),...
-	(md.results.TransientSolution.Vy),...
-	(md.results.TransientSolution.Vel),...
-	(md.results.TransientSolution.Pressure),...
-	(md.results.TransientSolution.StressTensorxx),...
-	(md.results.TransientSolution.StressTensoryy),...
-	(md.results.TransientSolution.StressTensorxy),...
+md.autodiff.dependents={...
+	dependent('name','MaxVel','type','scalar','fos_reverse_index',1)...
+	%dependent('name','IceVolume','type','scalar')...
+	%dependent('name','MassFlux','type','scalar','exp','../Exp/MassFlux1.exp','mesh',md.mesh,'index',1)...
+	%dependent('name','MassFlux','type','scalar','exp','../Exp/MassFlux2.exp','mesh',md.mesh,'index',2)...
 	};
+
+%md.autodiff.driver='fos_forward';
+md.autodiff.driver='fos_reverse';
+
+md=solve(md,TransientSolutionEnum());
+
+%plot
+nods=md.mesh.numberofvertices;
+jac=md.results.TransientSolution(1).AutodiffJacobian;
+plotmodel(md,'data',jac(1:nods),'data',jac(nods+1:2*nods),'data',jac(2*nods+1:3*nods),'data',jac(3*nods+1:4*nods));

Modified: issm/trunk/test/NightlyRun/runme.m
===================================================================
--- issm/trunk/test/NightlyRun/runme.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/runme.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -66,7 +66,7 @@
 	output='none';
 end
 % }}}
-%GET RANK and NUMPROCS for mutlithreaded runs  {{{
+%GET RANK and NUMPROCS for multithreaded runs  {{{
 rank=getfieldvalue(options,'rank',1);
 numprocs=getfieldvalue(options,'numprocs',1);
 if (numprocs<rank), numprocs=1; end
@@ -105,7 +105,7 @@
 elseif strcmpi(benchmark,'mesh'),
 	test_ids=intersect(test_ids,[1401:1499]);
 elseif strcmpi(benchmark,'adolc'),
-	test_ids=intersect(test_ids,[3001:3010]);
+	test_ids=intersect(test_ids,[3001:3020]);
 elseif strcmpi(benchmark,'validation'),
 	test_ids=intersect(test_ids,[1001:1999]);
 elseif strcmpi(benchmark,'tranforcing'),

Modified: issm/trunk/test/NightlyRun/runme.py
===================================================================
--- issm/trunk/test/NightlyRun/runme.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/runme.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -49,7 +49,7 @@
 
 	#Process options
 	#GET benchmark {{{
-	if not ismember(benchmark,['all','nightly','ismip','eismint','thermal','mesh','validation','tranforcing']):
+	if not ismember(benchmark,['all','nightly','ismip','eismint','thermal','mesh','validation','tranforcing','adolc']):
 		print "runme warning: benchmark '%s' not supported, defaulting to test 'nightly'." % benchmark
 		benchmark='nightly'
 	# }}}
@@ -106,6 +106,8 @@
 		test_ids=test_ids.intersection(set(range(1301,1400)))
 	elif strcmpi(benchmark,'mesh'):
 		test_ids=test_ids.intersection(set(range(1401,1500)))
+	elif strcmpi(benchmark,'adolc'):
+		test_ids=test_ids.intersection(set(range(3001,3020)))
 	elif strcmpi(benchmark,'validation'):
 		test_ids=test_ids.intersection(set(range(1001,2000)))
 	elif strcmpi(benchmark,'tranforcing'):
@@ -214,13 +216,13 @@
 			directory=os.getcwd().split('/')    #  not used?
 			message=me
 			if   strcmpi(output,'nightly'):
-				fid=open(os.path.join(ISSM_DIR+'nightlylog','pythonerror.log'), 'a')
+				fid=open(os.path.join(ISSM_DIR,'nightlylog','pythonerror.log'), 'a')
 				fid.write('%s' % message)
 				fid.write('\n------------------------------------------------------------------\n')
 				fid.close()
 				print 'FAILURE difference: N/A test id: %i test name: %s field: %s' % (id,id_string,'N/A')
 			elif strcmpi(output,'daily'):
-				fid=open(os.path.join(ISSM_DIR+'dailylog','pythonerror.log'), 'a')
+				fid=open(os.path.join(ISSM_DIR,'dailylog','pythonerror.log'), 'a')
 				fid.write('%s' % message)
 				fid.write('\n------------------------------------------------------------------\n')
 				fid.close()
@@ -261,5 +263,7 @@
 
 	md = runme(args.id, args.exclude, args.benchmark, args.procedure, args.output, args.rank, args.numprocs)
 
+	if strcmpi(args.output,'nightly'):
+		print "PYTHONEXITEDCORRECTLY"
+
 	exit(md)
-

Modified: issm/trunk/test/NightlyRun/test101.m
===================================================================
--- issm/trunk/test/NightlyRun/test101.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test101.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',50000);
+md=triangle(model(),'../Exp/Square.exp',50000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.diagnostic.requested_outputs=StressTensorEnum;
-md=solve(md,DiagnosticSolutionEnum);
+md.diagnostic.requested_outputs=StressTensorEnum();
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure',...

Modified: issm/trunk/test/NightlyRun/test101.py
===================================================================
--- issm/trunk/test/NightlyRun/test101.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test101.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -21,11 +21,11 @@
 field_tolerances=[1e-13,1e-13,1e-13,1e-13,\
 	1e-13,1e-13,1e-13]
 field_values=[\
-	md.results['DiagnosticSolution'][1]['Vx'],\
-	md.results['DiagnosticSolution'][1]['Vy'],\
-	md.results['DiagnosticSolution'][1]['Vel'],\
-	md.results['DiagnosticSolution'][1]['Pressure'],\
-	md.results['DiagnosticSolution'][1]['StressTensorxx'],\
-	md.results['DiagnosticSolution'][1]['StressTensoryy'],\
-	md.results['DiagnosticSolution'][1]['StressTensorxy'],\
+	md.results.DiagnosticSolution.Vx,\
+	md.results.DiagnosticSolution.Vy,\
+	md.results.DiagnosticSolution.Vel,\
+	md.results.DiagnosticSolution.Pressure,\
+	md.results.DiagnosticSolution.StressTensorxx,\
+	md.results.DiagnosticSolution.StressTensoryy,\
+	md.results.DiagnosticSolution.StressTensorxy,\
 	]

Modified: issm/trunk/test/NightlyRun/test102.m
===================================================================
--- issm/trunk/test/NightlyRun/test102.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test102.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test102.py
===================================================================
--- issm/trunk/test/NightlyRun/test102.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test102.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 md=triangle(model(),'../Exp/Square.exp',180000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(3,2)
+md.extrude(3,2.)
 md=setflowequation(md,'macayeal','all')
 md.cluster=generic('name',oshostname(),'np',3)
 md=solve(md,DiagnosticSolutionEnum())
@@ -19,10 +19,10 @@
 field_names     =['Vx','Vy','Vz','Vel','Pressure']
 field_tolerances=[1e-13,1e-13,1e-13,1e-13,1e-13]
 field_values=[\
-	md.results['DiagnosticSolution'][1]['Vx'],\
-	md.results['DiagnosticSolution'][1]['Vy'],\
-	md.results['DiagnosticSolution'][1]['Vz'],\
-	md.results['DiagnosticSolution'][1]['Vel'],\
-	md.results['DiagnosticSolution'][1]['Pressure'],\
+	md.results.DiagnosticSolution.Vx,\
+	md.results.DiagnosticSolution.Vy,\
+	md.results.DiagnosticSolution.Vz,\
+	md.results.DiagnosticSolution.Vel,\
+	md.results.DiagnosticSolution.Pressure,\
 	]
 

Modified: issm/trunk/test/NightlyRun/test103.m
===================================================================
--- issm/trunk/test/NightlyRun/test103.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test103.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.diagnostic.requested_outputs=StressTensorEnum;
-md=solve(md,DiagnosticSolutionEnum);
+md.diagnostic.requested_outputs=StressTensorEnum();
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure',...

Modified: issm/trunk/test/NightlyRun/test103.py
===================================================================
--- issm/trunk/test/NightlyRun/test103.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test103.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 md=triangle(model(),'../Exp/Square.exp',180000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(3,2)
+md.extrude(3,2.)
 md=setflowequation(md,'pattyn','all')
 md.cluster=generic('name',oshostname(),'np',3)
 md.diagnostic.requested_outputs=StressTensorEnum()
@@ -22,15 +22,15 @@
 field_tolerances=[1e-09,1e-09,1e-09,1e-09,1e-09,\
 	1e-09,1e-09,1e-09,1e-09,1e-09,1e-09]
 field_values=[\
-	md.results['DiagnosticSolution'][1]['Vx'],\
-	md.results['DiagnosticSolution'][1]['Vy'],\
-	md.results['DiagnosticSolution'][1]['Vz'],\
-	md.results['DiagnosticSolution'][1]['Vel'],\
-	md.results['DiagnosticSolution'][1]['Pressure'],\
-	md.results['DiagnosticSolution'][1]['StressTensorxx'],\
-	md.results['DiagnosticSolution'][1]['StressTensoryy'],\
-	md.results['DiagnosticSolution'][1]['StressTensorzz'],\
-	md.results['DiagnosticSolution'][1]['StressTensorxy'],\
-	md.results['DiagnosticSolution'][1]['StressTensorxz'],\
-	md.results['DiagnosticSolution'][1]['StressTensoryz'],\
+	md.results.DiagnosticSolution.Vx,\
+	md.results.DiagnosticSolution.Vy,\
+	md.results.DiagnosticSolution.Vz,\
+	md.results.DiagnosticSolution.Vel,\
+	md.results.DiagnosticSolution.Pressure,\
+	md.results.DiagnosticSolution.StressTensorxx,\
+	md.results.DiagnosticSolution.StressTensoryy,\
+	md.results.DiagnosticSolution.StressTensorzz,\
+	md.results.DiagnosticSolution.StressTensorxy,\
+	md.results.DiagnosticSolution.StressTensorxz,\
+	md.results.DiagnosticSolution.StressTensoryz,\
 	]

Modified: issm/trunk/test/NightlyRun/test104.m
===================================================================
--- issm/trunk/test/NightlyRun/test104.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test104.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'stokes','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test104.py
===================================================================
--- issm/trunk/test/NightlyRun/test104.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test104.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 md=triangle(model(),'../Exp/Square.exp',180000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(3,2)
+md.extrude(3,2.)
 md=setflowequation(md,'stokes','all')
 md.cluster=generic('name',oshostname(),'np',3)
 md=solve(md,DiagnosticSolutionEnum())
@@ -19,9 +19,9 @@
 field_names     =['Vx','Vy','Vz','Vel','Pressure']
 field_tolerances=[1e-08,1e-08,1e-07,1e-08,1e-08]
 field_values=[\
-	md.results['DiagnosticSolution'][1]['Vx'],\
-	md.results['DiagnosticSolution'][1]['Vy'],\
-	md.results['DiagnosticSolution'][1]['Vz'],\
-	md.results['DiagnosticSolution'][1]['Vel'],\
-	md.results['DiagnosticSolution'][1]['Pressure'],\
+	md.results.DiagnosticSolution.Vx,\
+	md.results.DiagnosticSolution.Vy,\
+	md.results.DiagnosticSolution.Vz,\
+	md.results.DiagnosticSolution.Vel,\
+	md.results.DiagnosticSolution.Pressure,\
 	]

Modified: issm/trunk/test/NightlyRun/test105.m
===================================================================
--- issm/trunk/test/NightlyRun/test105.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test105.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,PrognosticSolutionEnum);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test105.py
===================================================================
--- issm/trunk/test/NightlyRun/test105.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test105.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,5 +18,5 @@
 field_names     =['Thickness']
 field_tolerances=[1e-13]
 field_values=[\
-	md.results['PrognosticSolution'][1]['Thickness'],\
+	md.results.PrognosticSolution.Thickness,\
 	]

Modified: issm/trunk/test/NightlyRun/test106.m
===================================================================
--- issm/trunk/test/NightlyRun/test106.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test106.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=meshconvert(md);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
@@ -6,7 +6,7 @@
 md.cluster=generic('name',oshostname(),'np',3);
 md.prognostic.stabilization=3;
 md.prognostic.spcthickness=md.geometry.thickness;
-md=solve(md,PrognosticSolutionEnum);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test106.py
===================================================================
--- issm/trunk/test/NightlyRun/test106.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test106.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,5 +22,5 @@
 field_names     =['Thickness']
 field_tolerances=[1e-13]
 field_values=[\
-	md.results['PrognosticSolution'][1]['Thickness'],\
+	md.results.PrognosticSolution.Thickness,\
 	]

Modified: issm/trunk/test/NightlyRun/test107.m
===================================================================
--- issm/trunk/test/NightlyRun/test107.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test107.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 md=setflowequation(md,'macayeal','all');
-md=extrude(md,5,3);
+md=extrude(md,5,3.);
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,PrognosticSolutionEnum);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test107.py
===================================================================
--- issm/trunk/test/NightlyRun/test107.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test107.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
 md=setflowequation(md,'macayeal','all')
-md.extrude(5,3)
+md.extrude(5,3.)
 md.cluster=generic('name',oshostname(),'np',3)
 md=solve(md,PrognosticSolutionEnum())
 
@@ -19,5 +19,5 @@
 field_names     =['Thickness']
 field_tolerances=[1e-13]
 field_values=[\
-	md.results['PrognosticSolution'][1]['Thickness'],\
+	md.results.PrognosticSolution.Thickness,\
 	]

Modified: issm/trunk/test/NightlyRun/test108.m
===================================================================
--- issm/trunk/test/NightlyRun/test108.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test108.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,15 +1,15 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.timestepping.time_step=0;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,ThermalSolutionEnum);
+md=solve(md,ThermalSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13};
+field_tolerances={1e-13,1e-5};
 field_values={...
 	(md.results.ThermalSolution.Temperature),...
 	(md.results.ThermalSolution.BasalforcingsMeltingRate),...

Modified: issm/trunk/test/NightlyRun/test108.py
===================================================================
--- issm/trunk/test/NightlyRun/test108.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test108.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 md=triangle(model(),'../Exp/Square.exp',180000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(3,1)
+md.extrude(3,1.)
 md=setflowequation(md,'macayeal','all')
 md.timestepping.time_step=0
 md.cluster=generic('name',oshostname(),'np',3)
@@ -18,8 +18,8 @@
 
 #Fields and tolerances to track changes
 field_names     =['Temperature','BasalforcingsMeltingRate']
-field_tolerances=[1e-13,1e-13]
+field_tolerances=[1e-13,1e-5]
 field_values=[\
-	md.results['ThermalSolution'][1]['Temperature'],\
-	md.results['ThermalSolution'][1]['BasalforcingsMeltingRate'],\
+	md.results.ThermalSolution.Temperature,\
+	md.results.ThermalSolution.BasalforcingsMeltingRate,\
 	]

Modified: issm/trunk/test/NightlyRun/test109.m
===================================================================
--- issm/trunk/test/NightlyRun/test109.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test109.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,14 +1,14 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.transient.isdiagnostic=0;
 md.transient.isprognostic=0;
 md.transient.isthermal=1;
 md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature','BasalforcingsMeltingRate'};

Modified: issm/trunk/test/NightlyRun/test109.py
===================================================================
--- issm/trunk/test/NightlyRun/test109.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test109.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 md=triangle(model(),'../Exp/Square.exp',180000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(3,1)
+md.extrude(3,1.)
 md=setflowequation(md,'macayeal','all')
 md.cluster=generic('name',oshostname(),'np',3)
 md.transient.isdiagnostic=0
@@ -23,6 +23,6 @@
 field_names     =['Temperature','BasalforcingsMeltingRate']
 field_tolerances=[1e-13,1e-13]
 field_values=[\
-	md.results['TransientSolution'][1]['Temperature'],\
-	md.results['TransientSolution'][1]['BasalforcingsMeltingRate'],\
+	md.results.TransientSolution[0].Temperature,\
+	md.results.TransientSolution[0].BasalforcingsMeltingRate,\
 	]

Modified: issm/trunk/test/NightlyRun/test110.m
===================================================================
--- issm/trunk/test/NightlyRun/test110.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test110.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.transient.requested_outputs=IceVolumeEnum();
 
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Volume1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Volume2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Volume3'};

Modified: issm/trunk/test/NightlyRun/test110.py
===================================================================
--- issm/trunk/test/NightlyRun/test110.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test110.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,28 +22,28 @@
 						1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,\
 						1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13]
 field_values=[\
-	md.results['TransientSolution'][1]['Vx'],\
-	md.results['TransientSolution'][1]['Vy'],\
-	md.results['TransientSolution'][1]['Vel'],\
-	md.results['TransientSolution'][1]['Pressure'],\
-	md.results['TransientSolution'][1]['Bed'],\
-	md.results['TransientSolution'][1]['Surface'],\
-	md.results['TransientSolution'][1]['Thickness'],\
-	md.results['TransientSolution'][1]['IceVolume'],\
-	md.results['TransientSolution'][2]['Vx'],\
-	md.results['TransientSolution'][2]['Vy'],\
-	md.results['TransientSolution'][2]['Vel'],\
-	md.results['TransientSolution'][2]['Pressure'],\
-	md.results['TransientSolution'][2]['Bed'],\
-	md.results['TransientSolution'][2]['Surface'],\
-	md.results['TransientSolution'][2]['Thickness'],\
-	md.results['TransientSolution'][2]['IceVolume'],\
-	md.results['TransientSolution'][3]['Vx'],\
-	md.results['TransientSolution'][3]['Vy'],\
-	md.results['TransientSolution'][3]['Vel'],\
-	md.results['TransientSolution'][3]['Pressure'],\
-	md.results['TransientSolution'][3]['Bed'],\
-	md.results['TransientSolution'][3]['Surface'],\
-	md.results['TransientSolution'][3]['Thickness'],\
-	md.results['TransientSolution'][3]['IceVolume'],\
+	md.results.TransientSolution[0].Vx,\
+	md.results.TransientSolution[0].Vy,\
+	md.results.TransientSolution[0].Vel,\
+	md.results.TransientSolution[0].Pressure,\
+	md.results.TransientSolution[0].Bed,\
+	md.results.TransientSolution[0].Surface,\
+	md.results.TransientSolution[0].Thickness,\
+	md.results.TransientSolution[0].IceVolume,\
+	md.results.TransientSolution[1].Vx,\
+	md.results.TransientSolution[1].Vy,\
+	md.results.TransientSolution[1].Vel,\
+	md.results.TransientSolution[1].Pressure,\
+	md.results.TransientSolution[1].Bed,\
+	md.results.TransientSolution[1].Surface,\
+	md.results.TransientSolution[1].Thickness,\
+	md.results.TransientSolution[1].IceVolume,\
+	md.results.TransientSolution[2].Vx,\
+	md.results.TransientSolution[2].Vy,\
+	md.results.TransientSolution[2].Vel,\
+	md.results.TransientSolution[2].Pressure,\
+	md.results.TransientSolution[2].Bed,\
+	md.results.TransientSolution[2].Surface,\
+	md.results.TransientSolution[2].Thickness,\
+	md.results.TransientSolution[2].IceVolume,\
 	]

Modified: issm/trunk/test/NightlyRun/test1101.m
===================================================================
--- issm/trunk/test/NightlyRun/test1101.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1101.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,11 +11,11 @@
 	L=L_list{i};
 	nx=20; %numberof nodes in x direction
 	ny=20;
-	md=model;
+	md=model();
 	md=squaremesh(md,L,L,nx,ny);
 	md=setmask(md,'',''); %ice sheet test
 	md=parameterize(md,'../Par/ISMIPA.par');
-	md=extrude(md,9,1);
+	md=extrude(md,9,1.);
 
 	md=setflowequation(md,'pattyn','all');
 
@@ -39,7 +39,7 @@
 
 	%Compute the diagnostic
 	md.cluster=generic('name',oshostname(),'np',8);
-	md=solve(md,DiagnosticSolutionEnum);
+	md=solve(md,DiagnosticSolutionEnum());
 
 	%Plot the results and save them
 	vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1102.m
===================================================================
--- issm/trunk/test/NightlyRun/test1102.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1102.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 	L=L_list{i};
 	nx=20; %numberof nodes in x direction
 	ny=20;
-	md=model;
+	md=model();
 	md=squaremesh(md,L,L,nx,ny);
 	md=setmask(md,'',''); %ice sheet test
 
@@ -23,7 +23,7 @@
 %	md=modelextract(md,elements);
 
 	md=parameterize(md,'../Par/ISMIPA.par');
-	md=extrude(md,10,1);
+	md=extrude(md,10,1.);
 	md=setflowequation(md,'stokes','all');
 
 	%Create dirichlet on the bed only
@@ -48,7 +48,7 @@
 	md.diagnostic.reltol=NaN;
 	md.diagnostic.restol=1;
 	md.cluster=generic('name',oshostname(),'np',8);
-	md=solve(md,DiagnosticSolutionEnum);
+	md=solve(md,DiagnosticSolutionEnum());
 
 	%Plot the results and save them
 	vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1103.m
===================================================================
--- issm/trunk/test/NightlyRun/test1103.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1103.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -9,11 +9,11 @@
 	L=L_list{i};
 	nx=20; %numberof nodes in x direction
 	ny=20;
-	md=model;
+	md=model();
 	md=squaremesh(md,L,L,nx,ny);
 	md=setmask(md,'',''); %ice sheet test
 	md=parameterize(md,'../Par/ISMIPB.par');
-	md=extrude(md,10,1);
+	md=extrude(md,10,1.);
 
 	md=setflowequation(md,'pattyn','all');
 
@@ -36,7 +36,7 @@
 
 	%Compute the diagnostic
 	md.cluster=generic('name',oshostname(),'np',8);
-	md=solve(md,DiagnosticSolutionEnum);
+	md=solve(md,DiagnosticSolutionEnum());
 
 	%Plot the results and save them
 	vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1104.m
===================================================================
--- issm/trunk/test/NightlyRun/test1104.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1104.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,11 +8,11 @@
 	L=L_list{i};
 	nx=20; %numberof nodes in x direction
 	ny=20;
-	md=model;
+	md=model();
 	md=squaremesh(md,L,L,nx,ny);
 	md=setmask(md,'',''); %ice sheet test
 	md=parameterize(md,'../Par/ISMIPB.par');
-	md=extrude(md,10,1);
+	md=extrude(md,10,1.);
 	md=setflowequation(md,'pattyn','all');
 
 	%Create dirichlet on the bed only
@@ -36,13 +36,13 @@
 	%Compute the diagnostic
 	md.diagnostic.abstol=NaN;
 	md.cluster=generic('name',oshostname(),'np',8);
-	md=solve(md,DiagnosticSolutionEnum);
+	md=solve(md,DiagnosticSolutionEnum());
 	pos=find(md.mesh.x==0 | md.mesh.y==0 | md.mesh.x==max(md.mesh.x) | md.mesh.y==max(md.mesh.y));
 	md.diagnostic.spcvx(pos)=md.results.DiagnosticSolution.Vx(pos);
 	md.diagnostic.spcvy(pos)=md.results.DiagnosticSolution.Vy(pos);
 	md.diagnostic.vertex_pairing=[];
 	md=setflowequation(md,'stokes','all');
-	md=solve(md,DiagnosticSolutionEnum);
+	md=solve(md,DiagnosticSolutionEnum());
 
 	%Plot the results and save them
 	vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1105.m
===================================================================
--- issm/trunk/test/NightlyRun/test1105.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1105.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,11 +11,11 @@
 	L=L_list{i};  %in m (3 times the desired lenght for BC problems)  
 	nx=30; %number of nodes in x direction
 	ny=30;
-	md=model;
+	md=model();
 	md=squaremesh(md,L,L,nx,ny);
 	md=setmask(md,'',''); %ice sheet test
 	md=parameterize(md,'../Par/ISMIPC.par');
-	md=extrude(md,10,1);
+	md=extrude(md,10,1.);
 
 	md=setflowequation(md,'pattyn','all'); 
 
@@ -62,7 +62,7 @@
 
 	%Compute the diagnostic
 	md.cluster=generic('name',oshostname(),'np',8);
-	md=solve(md,DiagnosticSolutionEnum);
+	md=solve(md,DiagnosticSolutionEnum());
 
 	%Plot the results and save them
 	vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1106.m
===================================================================
--- issm/trunk/test/NightlyRun/test1106.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1106.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,11 +6,11 @@
 
 for i=1:length(L_list),
 	L=L_list{i};  
-	md=triangle(model,['../Exp/Square_' num2str(L) '.exp'],L/10); %size 3*L 
+	md=triangle(model(),['../Exp/Square_' num2str(L) '.exp'],L/10.); %size 3*L 
 	md=setmask(md,'',''); %ice sheet test
 	md=parameterize(md,'../Par/ISMIPC.par');
 	md.friction.coefficient=sqrt(md.constants.yts.*(1000+1000*sin(md.mesh.x*2*pi/L).*sin(md.mesh.y*2*pi/L)));
-	md=extrude(md,10,1);
+	md=extrude(md,10,1.);
 
 	%Add spc on the borders
 	pos=find((md.mesh.x==0 | md.mesh.x==max(md.mesh.x) | md.mesh.y==0 | md.mesh.y==max(md.mesh.y)));
@@ -40,7 +40,7 @@
 
 	%Compute the diagnostic
 	md.cluster=generic('name',oshostname(),'np',8);
-	md=solve(md,DiagnosticSolutionEnum);
+	md=solve(md,DiagnosticSolutionEnum());
 
 	%Plot the results and save them
 	vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1107.m
===================================================================
--- issm/trunk/test/NightlyRun/test1107.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1107.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,11 +11,11 @@
 	L=L_list{i};
 	nx=30; %numberof nodes in x direction
 	ny=30;
-	md=model;
+	md=model();
 	md=squaremesh(md,L,L,nx,ny);
 	md=setmask(md,'',''); %ice sheet test
 	md=parameterize(md,'../Par/ISMIPD.par');
-	md=extrude(md,10,1);
+	md=extrude(md,10,1.);
 
 	md=setflowequation(md,'pattyn','all');
 
@@ -57,7 +57,7 @@
 
 	%Compute the diagnostic
 	md.cluster=generic('name',oshostname(),'np',8);
-	md=solve(md,DiagnosticSolutionEnum);
+	md=solve(md,DiagnosticSolutionEnum());
 
 	%Plot the results and save them
 	vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1108.m
===================================================================
--- issm/trunk/test/NightlyRun/test1108.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1108.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,11 +8,11 @@
 	L=L_list{i};
 	nx=30; %numberof nodes in x direction
 	ny=30;
-	md=model;
+	md=model();
 	md=squaremesh(md,L,L,nx,ny);
 	md=setmask(md,'',''); %ice sheet test
 	md=parameterize(md,'../Par/ISMIPD.par');
-	md=extrude(md,10,1);
+	md=extrude(md,10,1.);
 
 	md=setflowequation(md,'pattyn','all');
 
@@ -38,7 +38,7 @@
 	%Compute the diagnostic
 	md.cluster=generic('name',oshostname(),'np',8);
 	md.verbose=verbose('convergence',true);
-	md=solve(md,DiagnosticSolutionEnum);
+	md=solve(md,DiagnosticSolutionEnum());
 	md.diagnostic.reltol=NaN;
 	md.diagnostic.abstol=NaN;
 	md.diagnostic.vertex_pairing=[];
@@ -50,7 +50,7 @@
 	md.diagnostic.spcvx(pos)=md.results.DiagnosticSolution.Vx(pos);
 	md.diagnostic.spcvy(pos)=md.results.DiagnosticSolution.Vy(pos);
 	md=setflowequation(md,'stokes','all');
-	md=solve(md,DiagnosticSolutionEnum);
+	md=solve(md,DiagnosticSolutionEnum());
 
 	%Plot the results and save them
 	vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1109.m
===================================================================
--- issm/trunk/test/NightlyRun/test1109.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1109.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -12,11 +12,11 @@
 	Ly=5000; %in m
 	nx=3; %number of nodes in x direction
 	ny=51;
-	md=model;
+	md=model();
 	md=squaremesh(md,Lx,Ly,nx,ny);
 	md=setmask(md,'',''); %ice sheet test
 	md=parameterize(md,'../Par/ISMIPE.par');
-	md=extrude(md,10,1);
+	md=extrude(md,10,1.);
 
 	if i==1 | i==3,
 		md=setflowequation(md,'pattyn','all');
@@ -48,7 +48,7 @@
 
 	%Compute the diagnostic
 	md.cluster=generic('name',oshostname(),'np',8);
-	md=solve(md,DiagnosticSolutionEnum);
+	md=solve(md,DiagnosticSolutionEnum());
 
 	vx=(md.results.DiagnosticSolution.Vx);
 	vy=(md.results.DiagnosticSolution.Vy);

Modified: issm/trunk/test/NightlyRun/test111.m
===================================================================
--- issm/trunk/test/NightlyRun/test111.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test111.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.transient.requested_outputs=IceVolumeEnum();
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names={...
@@ -14,7 +14,7 @@
 	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3','Volume3'};
 field_tolerances={...
 	1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,1e-13,...
-	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,2e-12,...
+	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,2e-11,...
 	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,1e-11};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...

Modified: issm/trunk/test/NightlyRun/test111.py
===================================================================
--- issm/trunk/test/NightlyRun/test111.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test111.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 md=triangle(model(),'../Exp/Square.exp',200000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(3,1)
+md.extrude(3,1.)
 md=setflowequation(md,'pattyn','all')
 md.cluster=generic('name',oshostname(),'np',3)
 md.transient.requested_outputs=IceVolumeEnum()
@@ -23,40 +23,40 @@
 	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3','Volume3']
 field_tolerances=[\
 	1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,1e-13,\
-	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,2e-12,\
+	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,2e-11,\
 	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,1e-11]
 field_values=[\
-	md.results['TransientSolution'][1]['Vx'],\
-	md.results['TransientSolution'][1]['Vy'],\
-	md.results['TransientSolution'][1]['Vz'],\
-	md.results['TransientSolution'][1]['Vel'],\
-	md.results['TransientSolution'][1]['Pressure'],\
-	md.results['TransientSolution'][1]['Bed'],\
-	md.results['TransientSolution'][1]['Surface'],\
-	md.results['TransientSolution'][1]['Thickness'],\
-	md.results['TransientSolution'][1]['Temperature'],\
-	md.results['TransientSolution'][1]['BasalforcingsMeltingRate'],\
-	md.results['TransientSolution'][1]['IceVolume'],\
-	md.results['TransientSolution'][2]['Vx'],\
-	md.results['TransientSolution'][2]['Vy'],\
-	md.results['TransientSolution'][2]['Vz'],\
-	md.results['TransientSolution'][2]['Vel'],\
-	md.results['TransientSolution'][2]['Pressure'],\
-	md.results['TransientSolution'][2]['Bed'],\
-	md.results['TransientSolution'][2]['Surface'],\
-	md.results['TransientSolution'][2]['Thickness'],\
-	md.results['TransientSolution'][2]['Temperature'],\
-	md.results['TransientSolution'][2]['BasalforcingsMeltingRate'],\
-	md.results['TransientSolution'][2]['IceVolume'],\
-	md.results['TransientSolution'][3]['Vx'],\
-	md.results['TransientSolution'][3]['Vy'],\
-	md.results['TransientSolution'][3]['Vz'],\
-	md.results['TransientSolution'][3]['Vel'],\
-	md.results['TransientSolution'][3]['Pressure'],\
-	md.results['TransientSolution'][3]['Bed'],\
-	md.results['TransientSolution'][3]['Surface'],\
-	md.results['TransientSolution'][3]['Thickness'],\
-	md.results['TransientSolution'][3]['Temperature'],\
-	md.results['TransientSolution'][3]['BasalforcingsMeltingRate'],\
-	md.results['TransientSolution'][3]['IceVolume'],\
+	md.results.TransientSolution[0].Vx,\
+	md.results.TransientSolution[0].Vy,\
+	md.results.TransientSolution[0].Vz,\
+	md.results.TransientSolution[0].Vel,\
+	md.results.TransientSolution[0].Pressure,\
+	md.results.TransientSolution[0].Bed,\
+	md.results.TransientSolution[0].Surface,\
+	md.results.TransientSolution[0].Thickness,\
+	md.results.TransientSolution[0].Temperature,\
+	md.results.TransientSolution[0].BasalforcingsMeltingRate,\
+	md.results.TransientSolution[0].IceVolume,\
+	md.results.TransientSolution[1].Vx,\
+	md.results.TransientSolution[1].Vy,\
+	md.results.TransientSolution[1].Vz,\
+	md.results.TransientSolution[1].Vel,\
+	md.results.TransientSolution[1].Pressure,\
+	md.results.TransientSolution[1].Bed,\
+	md.results.TransientSolution[1].Surface,\
+	md.results.TransientSolution[1].Thickness,\
+	md.results.TransientSolution[1].Temperature,\
+	md.results.TransientSolution[1].BasalforcingsMeltingRate,\
+	md.results.TransientSolution[1].IceVolume,\
+	md.results.TransientSolution[2].Vx,\
+	md.results.TransientSolution[2].Vy,\
+	md.results.TransientSolution[2].Vz,\
+	md.results.TransientSolution[2].Vel,\
+	md.results.TransientSolution[2].Pressure,\
+	md.results.TransientSolution[2].Bed,\
+	md.results.TransientSolution[2].Surface,\
+	md.results.TransientSolution[2].Thickness,\
+	md.results.TransientSolution[2].Temperature,\
+	md.results.TransientSolution[2].BasalforcingsMeltingRate,\
+	md.results.TransientSolution[2].IceVolume,\
 	]

Modified: issm/trunk/test/NightlyRun/test1110.m
===================================================================
--- issm/trunk/test/NightlyRun/test1110.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1110.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,12 +6,12 @@
 	L=100000; %in m
 	nx=30; %numberof nodes in x direction
 	ny=30;
-	md=model;
+	md=model();
 	md=squaremesh(md,L,L,nx,ny);
-	%md=triangle(md,'../Exp/SquareISMIP.exp',5500);
+	%md=triangle(md,'../Exp/SquareISMIP.exp',5500.);
 	md=setmask(md,'',''); %ice sheet test
 	md=parameterize(md,'../Par/ISMIPF.par');
-	md=extrude(md,4,1);
+	md=extrude(md,4,1.);
 
 	if (i==1 | i==2),
 		md=setflowequation(md,'pattyn','all');
@@ -56,7 +56,7 @@
 	%Compute the diagnostic
 	md.cluster=generic('name',oshostname(),'np',8);
 	md.verbose=verbose('convergence',true,'solution',true);
-	md=solve(md,TransientSolutionEnum);
+	md=solve(md,TransientSolutionEnum());
 
 	%save the results
 	results{i}=md.results.TransientSolution(end);

Modified: issm/trunk/test/NightlyRun/test112.m
===================================================================
--- issm/trunk/test/NightlyRun/test112.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test112.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,SurfaceSlopeSolutionEnum);
+md=solve(md,SurfaceSlopeSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'SurfaceSlopeX','SurfaceSlopeY'};

Modified: issm/trunk/test/NightlyRun/test112.py
===================================================================
--- issm/trunk/test/NightlyRun/test112.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test112.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,6 +18,6 @@
 field_names     =['SurfaceSlopeX','SurfaceSlopeY']
 field_tolerances=[1e-13,1e-13]
 field_values=[\
-	md.results['SurfaceSlopeSolution'][1]['SurfaceSlopeX'],\
-	md.results['SurfaceSlopeSolution'][1]['SurfaceSlopeY'],\
+	md.results.SurfaceSlopeSolution.SurfaceSlopeX,\
+	md.results.SurfaceSlopeSolution.SurfaceSlopeY,\
 	]

Modified: issm/trunk/test/NightlyRun/test113.m
===================================================================
--- issm/trunk/test/NightlyRun/test113.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test113.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,5,1);
+md=extrude(md,5,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,SurfaceSlopeSolutionEnum);
+md=solve(md,SurfaceSlopeSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'SurfaceSlopeX','SurfaceSlopeY'};

Modified: issm/trunk/test/NightlyRun/test113.py
===================================================================
--- issm/trunk/test/NightlyRun/test113.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test113.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 md=triangle(model(),'../Exp/Square.exp',150000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(5,1)
+md.extrude(5,1.)
 md=setflowequation(md,'macayeal','all')
 md.cluster=generic('name',oshostname(),'np',3)
 md=solve(md,SurfaceSlopeSolutionEnum())
@@ -19,6 +19,6 @@
 field_names     =['SurfaceSlopeX','SurfaceSlopeY']
 field_tolerances=[1e-13,1e-13]
 field_values=[\
-	md.results['SurfaceSlopeSolution'][1]['SurfaceSlopeX'],\
-	md.results['SurfaceSlopeSolution'][1]['SurfaceSlopeY'],\
+	md.results.SurfaceSlopeSolution.SurfaceSlopeX,\
+	md.results.SurfaceSlopeSolution.SurfaceSlopeY,\
 	]

Modified: issm/trunk/test/NightlyRun/test114.m
===================================================================
--- issm/trunk/test/NightlyRun/test114.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test114.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BedSlopeSolutionEnum);
+md=solve(md,BedSlopeSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'BedSlopeX','BedSlopeY'};

Modified: issm/trunk/test/NightlyRun/test114.py
===================================================================
--- issm/trunk/test/NightlyRun/test114.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test114.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -18,6 +18,6 @@
 field_names     =['BedSlopeX','BedSlopeY']
 field_tolerances=[1e-13,1e-13]
 field_values=[\
-	md.results['BedSlopeSolution'][1]['BedSlopeX'],\
-	md.results['BedSlopeSolution'][1]['BedSlopeY'],\
+	md.results.BedSlopeSolution.BedSlopeX,\
+	md.results.BedSlopeSolution.BedSlopeY,\
 	]

Modified: issm/trunk/test/NightlyRun/test115.m
===================================================================
--- issm/trunk/test/NightlyRun/test115.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test115.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,5,1);
+md=extrude(md,5,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BedSlopeSolutionEnum);
+md=solve(md,BedSlopeSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'BedSlopeX','BedSlopeY'};

Modified: issm/trunk/test/NightlyRun/test115.py
===================================================================
--- issm/trunk/test/NightlyRun/test115.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test115.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,7 +10,7 @@
 md=triangle(model(),'../Exp/Square.exp',150000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(5,1)
+md.extrude(5,1.)
 md=setflowequation(md,'macayeal','all')
 md.cluster=generic('name',oshostname(),'np',3)
 md=solve(md,BedSlopeSolutionEnum())
@@ -19,6 +19,6 @@
 field_names     =['BedSlopeX','BedSlopeY']
 field_tolerances=[1e-13,1e-13]
 field_values=[\
-	md.results['BedSlopeSolution'][1]['BedSlopeX'],\
-	md.results['BedSlopeSolution'][1]['BedSlopeY'],\
+	md.results.BedSlopeSolution.BedSlopeX,\
+	md.results.BedSlopeSolution.BedSlopeY,\
 	]

Modified: issm/trunk/test/NightlyRun/test116.m
===================================================================
--- issm/trunk/test/NightlyRun/test116.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test116.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 %Add boundary conditions on thickness on the border
@@ -6,7 +6,7 @@
 md.balancethickness.spcthickness(pos)=md.geometry.thickness(pos);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BalancethicknessSolutionEnum);
+md=solve(md,BalancethicknessSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test116.py
===================================================================
--- issm/trunk/test/NightlyRun/test116.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test116.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,5 +22,5 @@
 field_names     =['Thickness']
 field_tolerances=[1e-13]
 field_values=[\
-	md.results['BalancethicknessSolution'][1]['Thickness'],\
+	md.results.BalancethicknessSolution.Thickness,\
 	]

Modified: issm/trunk/test/NightlyRun/test117.m
===================================================================
--- issm/trunk/test/NightlyRun/test117.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test117.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,13 +1,13 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,5,1);
+md=extrude(md,5,1.);
 %Add boundary conditions on thickness on the border
 pos=find(md.mesh.vertexonboundary);
 md.balancethickness.spcthickness(pos)=md.geometry.thickness(pos);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BalancethicknessSolutionEnum);
+md=solve(md,BalancethicknessSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test117.py
===================================================================
--- issm/trunk/test/NightlyRun/test117.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test117.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 md=triangle(model(),'../Exp/Square.exp',150000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(5,1)
+md.extrude(5,1.)
 #Add boundary conditions on thickness on the border
 pos=numpy.nonzero(md.mesh.vertexonboundary)
 md.balancethickness.spcthickness[pos]=md.geometry.thickness[pos]
@@ -23,5 +23,5 @@
 field_names     =['Thickness']
 field_tolerances=[1e-13]
 field_values=[\
-	md.results['BalancethicknessSolution'][1]['Thickness'],\
+	md.results.BalancethicknessSolution.Thickness,\
 	]

Modified: issm/trunk/test/NightlyRun/test118.m
===================================================================
--- issm/trunk/test/NightlyRun/test118.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test118.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=meshconvert(md);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
@@ -6,7 +6,7 @@
 md.initialization.vy=md.initialization.vy+400;
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BalancethicknessSolutionEnum);
+md=solve(md,BalancethicknessSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test118.py
===================================================================
--- issm/trunk/test/NightlyRun/test118.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test118.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -22,5 +22,5 @@
 field_names     =['Thickness']
 field_tolerances=[1e-13]
 field_values=[\
-	md.results['BalancethicknessSolution'][1]['Thickness'],\
+	md.results.BalancethicknessSolution.Thickness,\
 	]

Modified: issm/trunk/test/NightlyRun/test119.m
===================================================================
--- issm/trunk/test/NightlyRun/test119.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test119.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,23 +1,23 @@
 
 %Simple mesh
-md=bamg(model,'domain','../Exp/Square.exp','hmax',100000);
+md=bamg(model(),'domain','../Exp/Square.exp','hmax',100000.);
 x1=md.mesh.x;
 y1=md.mesh.y;
 
 %hVertices
-md=bamg(model,'domain','../Exp/Square.exp','hmax',300000,'hvertices',[10000 100000 400000 100000]');
+md=bamg(model(),'domain','../Exp/Square.exp','hmax',300000.,'hVertices',[10000. 100000. 400000. 100000.]');
 x2=md.mesh.x;
 y2=md.mesh.y;
 
 %big mesh
 t0=clock;
-md=bamg(model,'domain','../Exp/Square.exp','hmax',3000);
+md=bamg(model(),'domain','../Exp/Square.exp','hmax',3000.);
 nbelements=md.mesh.numberofelements;
 elapsedtime=etime(clock,t0);
 
 %Fields and tolerances to track changes
-field_names     ={'x1' 'y1' 'x2' 'y2' 'nbelements' 'elapsed time'};
-field_tolerances={1e-13 1e-13 1e-13 1e-13 1e-13 0.5};
+field_names     ={'x1','y1','x2','y2','nbelements','elapsed time'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,0.7};
 field_values={...
 	x1, y1,...
 	x2, y2,...

Modified: issm/trunk/test/NightlyRun/test120.m
===================================================================
--- issm/trunk/test/NightlyRun/test120.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test120.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,12 +1,12 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.timestepping.time_step=0;
 md.cluster=generic('name',oshostname(),'np',3);
 md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md=solve(md,EnthalpySolutionEnum);
+md=solve(md,EnthalpySolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Enthalpy','Waterfraction','Temperature'};

Modified: issm/trunk/test/NightlyRun/test120.py
===================================================================
--- issm/trunk/test/NightlyRun/test120.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test120.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -11,7 +11,7 @@
 md=triangle(model(),'../Exp/Square.exp',180000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(3,1)
+md.extrude(3,1.)
 md=setflowequation(md,'macayeal','all')
 md.timestepping.time_step=0
 md.cluster=generic('name',oshostname(),'np',3)
@@ -22,7 +22,7 @@
 field_names     =['Enthalpy','Waterfraction','Temperature']
 field_tolerances=[1e-13,1e-10,1e-13]
 field_values=[\
-	md.results['EnthalpySolution'][1]['Enthalpy'],\
-	md.results['EnthalpySolution'][1]['Waterfraction'],\
-	md.results['EnthalpySolution'][1]['Temperature'],\
+	md.results.EnthalpySolution.Enthalpy,\
+	md.results.EnthalpySolution.Waterfraction,\
+	md.results.EnthalpySolution.Temperature,\
 	]

Modified: issm/trunk/test/NightlyRun/test1201.m
===================================================================
--- issm/trunk/test/NightlyRun/test1201.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1201.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,7 @@
 
 for stabilization=1:3;
 	%The goal is to test the prognostic model
-	md=bamg(model,'domain','../Exp/SquareEISMINT.exp','hmax',3000);
+	md=bamg(model(),'domain','../Exp/SquareEISMINT.exp','hmax',3000);
 	md=setmask(md,'all','');
 	md=parameterize(md,'../Par/SquareEISMINT.par');
 	md.surfaceforcings.mass_balance(:)=0;
@@ -37,7 +37,7 @@
 	md.transient.isdiagnostic=0;
 	md.settings.output_frequency=500; %keep only last step
 	md.verbose=verbose();
-	md=solve(md,TransientSolutionEnum);
+	md=solve(md,TransientSolutionEnum());
 	results{stabilization}=(md.results.TransientSolution(end).Thickness);
 end
 

Modified: issm/trunk/test/NightlyRun/test1202.m
===================================================================
--- issm/trunk/test/NightlyRun/test1202.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1202.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,15 +2,15 @@
 printingflag=false;
 
 %tests 3 and 4: using Glen's flow law
-md=model;
-md=triangle(md,'../Exp/SquareEISMINT.exp',3550);
+md=model();
+md=triangle(md,'../Exp/SquareEISMINT.exp',3550.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareEISMINT.par');
 md=setflowequation(md,'macayeal','all'); %MacAyeal's model and 2d
 
 %Compute solution for MacAyeal's model 
 md.cluster=generic('name',oshostname(),'np',8);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %plot results
 vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1203.m
===================================================================
--- issm/trunk/test/NightlyRun/test1203.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1203.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,8 +2,8 @@
 printingflag=false;
 
 %test 5 and 6 : 
-md=model;
-md=triangle(md,'../Exp/SquareEISMINT.exp',5100); %test3
+md=model();
+md=triangle(md,'../Exp/SquareEISMINT.exp',5100.); %test3
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareEISMINT.par');
 md=setflowequation(md,'macayeal','all'); %MacAyeal's model and 2d
@@ -14,7 +14,7 @@
 
 %Compute solution for MacAyeal's model 
 md.cluster=generic('name',oshostname(),'np',8);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 vx=(md.results.DiagnosticSolution.Vx);
 vy=(md.results.DiagnosticSolution.Vy);

Modified: issm/trunk/test/NightlyRun/test1204.m
===================================================================
--- issm/trunk/test/NightlyRun/test1204.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1204.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -2,8 +2,8 @@
 printingflag=false;
 
 %tests 3 and 4: using Glen's flow law
-md=model;
-md=triangle(md,'../Exp/SquareEISMINT.exp',3550);
+md=model();
+md=triangle(md,'../Exp/SquareEISMINT.exp',3550.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareEISMINT.par');
 md=setflowequation(md,'macayeal','all'); %MacAyeal's model and 2d
@@ -14,7 +14,7 @@
 
 %Compute solution for MacAyeal's model 
 md.cluster=generic('name',oshostname(),'np',8);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %plot results
 md.initialization.vx=(md.results.DiagnosticSolution.Vx);
@@ -23,7 +23,7 @@
 md.timestepping.time_step=1;
 md.timestepping.final_time=5000;
 md.prognostic.stabilization=1;
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 plotmodel(md,'data',(md.results.TransientSolution(end).Vx))
 if printingflag, 

Modified: issm/trunk/test/NightlyRun/test1205.m
===================================================================
--- issm/trunk/test/NightlyRun/test1205.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1205.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,7 @@
 resolution=30000;
 
 %To begin with the numerical model
-md=model;
+md=model();
 md=roundmesh(md,750000,resolution);
 md=setmask(md,'',''); %We can not test iceshelves nor ice rises with this analytical solution
 md=parameterize(md,'../Par/RoundSheetStaticEISMINT.par');
@@ -17,7 +17,7 @@
 vel_obs=(sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2));
 
 %We extrude the model to have a 3d model
-md=extrude(md,numlayers,1);
+md=extrude(md,numlayers,1.);
 md=setflowequation(md,'hutter','all');
 
 %Spc the nodes on the bed
@@ -28,7 +28,7 @@
 
 %Now we can solve the problem 
 md.cluster=generic('name',oshostname(),'np',8);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Calculate the depth averaged velocity field (2d):
 vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1206.m
===================================================================
--- issm/trunk/test/NightlyRun/test1206.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1206.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,7 @@
 resolution=30000;
 
 %To begin with the numerical model
-md=model;
+md=model();
 md=roundmesh(md,750000,resolution);
 md=setmask(md,'',''); %We can not test iceshelves nor ice rises with this analytical solution
 md=parameterize(md,'../Par/RoundSheetStaticEISMINT.par');
@@ -17,7 +17,7 @@
 vel_obs=(sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2));
 
 %We extrude the model to have a 3d model
-md=extrude(md,numlayers,1);
+md=extrude(md,numlayers,1.);
 md=setflowequation(md,'pattyn','all');
 
 %Spc the nodes on the bed
@@ -28,7 +28,7 @@
 
 %Now we can solve the problem 
 md.cluster=generic('name',oshostname(),'np',8);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Calculate the depth averaged velocity field (2d):
 vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1207.m
===================================================================
--- issm/trunk/test/NightlyRun/test1207.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1207.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,7 @@
 resolution=30000;
 
 %To begin with the numerical model
-md=model;
+md=model();
 md=roundmesh(md,750000,resolution);
 md=setmask(md,'',''); %We can not test iceshelves nor ice rises with this analytical solution
 md=parameterize(md,'../Par/RoundSheetStaticEISMINT.par');
@@ -17,7 +17,7 @@
 vel_obs=(sqrt((md.inversion.vx_obs).^2+(md.inversion.vy_obs).^2));
 
 %We extrude the model to have a 3d model
-md=extrude(md,numlayers,1);
+md=extrude(md,numlayers,1.);
 md=setflowequation(md,'stokes','all');
 
 %Spc the nodes on the bed
@@ -28,7 +28,7 @@
 
 %Now we can solve the problem 
 md.cluster=generic('name',oshostname(),'np',8);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Calculate the depth averaged velocity field (2d):
 vx=(md.results.DiagnosticSolution.Vx);

Modified: issm/trunk/test/NightlyRun/test1208.m
===================================================================
--- issm/trunk/test/NightlyRun/test1208.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1208.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,12 +3,12 @@
 resolution=50000;
 
 %To begin with the numerical model
-md=triangle(model,'../Exp/SquareEISMINT750000.exp',resolution);
+md=triangle(model(),'../Exp/SquareEISMINT750000.exp',resolution);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/RoundSheetEISMINT.par');
 
 %We extrude the model to have a 3d model
-md=extrude(md,numlayers,1);
+md=extrude(md,numlayers,1.);
 md=setflowequation(md,'hutter','all');
 
 %Spc the nodes on the bed
@@ -26,7 +26,7 @@
 
 %Now we can solve the problem 
 md.cluster=generic('name',oshostname(),'np',8);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure','Thickness','Bed','Surface','Temperature','BasalforcingsMeltingRate'};

Modified: issm/trunk/test/NightlyRun/test121.m
===================================================================
--- issm/trunk/test/NightlyRun/test121.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test121.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
@@ -10,7 +10,7 @@
 md.transient.isthermal=1;
 md.transient.isgroundingline=0;
 md.thermal.isenthalpy=1;
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Enthalpy1','Waterfraction1','Temperature1',...

Modified: issm/trunk/test/NightlyRun/test121.py
===================================================================
--- issm/trunk/test/NightlyRun/test121.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test121.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,10 +10,10 @@
 md=triangle(model(),'../Exp/Square.exp',180000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(3,1)
+md.extrude(3,1.)
 md=setflowequation(md,'macayeal','all')
 md.cluster=generic('name',oshostname(),'np',3);
-md.initialization.waterfraction=numpy.zeros(md.mesh.numberofvertices)
+md.initialization.waterfraction=numpy.zeros((md.mesh.numberofvertices,1))
 md.transient.isdiagnostic=0
 md.transient.isprognostic=0
 md.transient.isthermal=1
@@ -27,13 +27,13 @@
 	'Enthalpy3','Waterfraction3','Temperature3']
 field_tolerances=[1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-10,1e-13]
 field_values=[\
-	md.results['TransientSolution'][1]['Enthalpy'],\
-	md.results['TransientSolution'][1]['Waterfraction'],\
-	md.results['TransientSolution'][1]['Temperature'],\
-	md.results['TransientSolution'][2]['Enthalpy'],\
-	md.results['TransientSolution'][2]['Waterfraction'],\
-	md.results['TransientSolution'][2]['Temperature'],\
-	md.results['TransientSolution'][3]['Enthalpy'],\
-	md.results['TransientSolution'][3]['Waterfraction'],\
-	md.results['TransientSolution'][3]['Temperature'],\
+	md.results.TransientSolution[0].Enthalpy,\
+	md.results.TransientSolution[0].Waterfraction,\
+	md.results.TransientSolution[0].Temperature,\
+	md.results.TransientSolution[1].Enthalpy,\
+	md.results.TransientSolution[1].Waterfraction,\
+	md.results.TransientSolution[1].Temperature,\
+	md.results.TransientSolution[2].Enthalpy,\
+	md.results.TransientSolution[2].Waterfraction,\
+	md.results.TransientSolution[2].Temperature,\
 	]

Modified: issm/trunk/test/NightlyRun/test122.m
===================================================================
--- issm/trunk/test/NightlyRun/test122.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test122.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,18 +1,18 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
 md.thermal.isenthalpy=1;
 md.thermal.stabilization=2;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','Enthalpy1','Waterfraction1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3'};
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2', ...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3'};
 field_tolerances={...
 	1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,...
 	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,...

Modified: issm/trunk/test/NightlyRun/test122.py
===================================================================
--- issm/trunk/test/NightlyRun/test122.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test122.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -10,9 +10,9 @@
 md=triangle(model(),'../Exp/Square.exp',200000)
 md=setmask(md,'all','')
 md=parameterize(md,'../Par/SquareShelfConstrained.py')
-md.extrude(3,1)
+md.extrude(3,1.)
 md=setflowequation(md,'pattyn','all')
-md.initialization.waterfraction=numpy.zeros(md.mesh.numberofvertices)
+md.initialization.waterfraction=numpy.zeros((md.mesh.numberofvertices,1))
 md.thermal.isenthalpy=1
 md.thermal.stabilization=2
 md.cluster=generic('name',oshostname(),'np',3)
@@ -20,44 +20,44 @@
 
 #Fields and tolerances to track changes
 field_names     =['Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','Enthalpy1','Waterfraction1',\
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2',\
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3']
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2',\
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3']
 field_tolerances=[\
 	1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,\
 	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,\
 	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09]
 field_values=[\
-	md.results['TransientSolution'][1]['Vx'],\
-	md.results['TransientSolution'][1]['Vy'],\
-	md.results['TransientSolution'][1]['Vz'],\
-	md.results['TransientSolution'][1]['Vel'],\
-	md.results['TransientSolution'][1]['Pressure'],\
-	md.results['TransientSolution'][1]['Bed'],\
-	md.results['TransientSolution'][1]['Surface'],\
-	md.results['TransientSolution'][1]['Thickness'],\
-	md.results['TransientSolution'][1]['Temperature'],\
-	md.results['TransientSolution'][1]['Enthalpy'],\
-	md.results['TransientSolution'][1]['Waterfraction'],\
-	md.results['TransientSolution'][2]['Vx'],\
-	md.results['TransientSolution'][2]['Vy'],\
-	md.results['TransientSolution'][2]['Vz'],\
-	md.results['TransientSolution'][2]['Vel'],\
-	md.results['TransientSolution'][2]['Pressure'],\
-	md.results['TransientSolution'][2]['Bed'],\
-	md.results['TransientSolution'][2]['Surface'],\
-	md.results['TransientSolution'][2]['Thickness'],\
-	md.results['TransientSolution'][2]['Temperature'],\
-	md.results['TransientSolution'][2]['Enthalpy'],\
-	md.results['TransientSolution'][2]['Waterfraction'],\
-	md.results['TransientSolution'][3]['Vx'],\
-	md.results['TransientSolution'][3]['Vy'],\
-	md.results['TransientSolution'][3]['Vz'],\
-	md.results['TransientSolution'][3]['Vel'],\
-	md.results['TransientSolution'][3]['Pressure'],\
-	md.results['TransientSolution'][3]['Bed'],\
-	md.results['TransientSolution'][3]['Surface'],\
-	md.results['TransientSolution'][3]['Thickness'],\
-	md.results['TransientSolution'][3]['Temperature'],\
-	md.results['TransientSolution'][3]['Enthalpy'],\
-	md.results['TransientSolution'][3]['Waterfraction'],\
+	md.results.TransientSolution[0].Vx,\
+	md.results.TransientSolution[0].Vy,\
+	md.results.TransientSolution[0].Vz,\
+	md.results.TransientSolution[0].Vel,\
+	md.results.TransientSolution[0].Pressure,\
+	md.results.TransientSolution[0].Bed,\
+	md.results.TransientSolution[0].Surface,\
+	md.results.TransientSolution[0].Thickness,\
+	md.results.TransientSolution[0].Temperature,\
+	md.results.TransientSolution[0].Enthalpy,\
+	md.results.TransientSolution[0].Waterfraction,\
+	md.results.TransientSolution[1].Vx,\
+	md.results.TransientSolution[1].Vy,\
+	md.results.TransientSolution[1].Vz,\
+	md.results.TransientSolution[1].Vel,\
+	md.results.TransientSolution[1].Pressure,\
+	md.results.TransientSolution[1].Bed,\
+	md.results.TransientSolution[1].Surface,\
+	md.results.TransientSolution[1].Thickness,\
+	md.results.TransientSolution[1].Temperature,\
+	md.results.TransientSolution[1].Enthalpy,\
+	md.results.TransientSolution[1].Waterfraction,\
+	md.results.TransientSolution[2].Vx,\
+	md.results.TransientSolution[2].Vy,\
+	md.results.TransientSolution[2].Vz,\
+	md.results.TransientSolution[2].Vel,\
+	md.results.TransientSolution[2].Pressure,\
+	md.results.TransientSolution[2].Bed,\
+	md.results.TransientSolution[2].Surface,\
+	md.results.TransientSolution[2].Thickness,\
+	md.results.TransientSolution[2].Temperature,\
+	md.results.TransientSolution[2].Enthalpy,\
+	md.results.TransientSolution[2].Waterfraction,\
 	]

Modified: issm/trunk/test/NightlyRun/test1301.m
===================================================================
--- issm/trunk/test/NightlyRun/test1301.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1301.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,11 +4,11 @@
 % surface with an imposed slope (Geothermal flux). if it is not the case, something is thermal modeling has been changed...
 printingflag=false;
 
-md=model;
-md=triangle(md,'../Exp/Square.exp',100000);
+md=model();
+md=triangle(md,'../Exp/Square.exp',100000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareThermal.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'Pattyn','all');
 
 %Some conditions specific to melting test
@@ -25,7 +25,7 @@
 
 %modeled  results
 md.cluster=generic('name',oshostname(),'np',2);
-md=solve(md,ThermalSolutionEnum);
+md=solve(md,ThermalSolutionEnum());
 
 %plot results
 comp_melting=md.results.ThermalSolution.BasalforcingsMeltingRate;

Modified: issm/trunk/test/NightlyRun/test1302.m
===================================================================
--- issm/trunk/test/NightlyRun/test1302.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1302.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -3,11 +3,11 @@
 % at upper surface and an impose flux at its base.
 printingflag=false;
 
-md=model;
-md=triangle(md,'../Exp/Square.exp',100000);
+md=model();
+md=triangle(md,'../Exp/Square.exp',100000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareThermal.par');
-md=extrude(md,30,1);   %NB: the more one extrudes, the better (10-> relative~0.35%, 20->0.1%, 30->0.05%)
+md=extrude(md,30,1.);   %NB: the more one extrudes, the better (10-> relative~0.35%, 20->0.1%, 30->0.05%)
 md=setflowequation(md,'Pattyn','all'); 
 
 %Thermal boundary conditions
@@ -27,7 +27,7 @@
 
 %modeled  results
 md.cluster=generic('name',oshostname(),'np',2);
-md=solve(md,ThermalSolutionEnum);
+md=solve(md,ThermalSolutionEnum());
 
 %plot results
 comp_temp=md.results.ThermalSolution.Temperature;

Modified: issm/trunk/test/NightlyRun/test1303.m
===================================================================
--- issm/trunk/test/NightlyRun/test1303.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1303.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,11 +4,11 @@
 % surface. if it is not the case, something is thermal modeling has been changed...
 printingflag=false;
 
-md=model;
-md=triangle(md,'../Exp/Square.exp',100000);
+md=model();
+md=triangle(md,'../Exp/Square.exp',100000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareThermal.par');
-md=extrude(md,11,2);
+md=extrude(md,11,2.);
 md=setflowequation(md,'Pattyn','all');
 pos1=find(md.mesh.elementonbed);     md.thermal.spctemperature(md.mesh.elements(pos1,1:3))=10;
 pos2=find(md.mesh.elementonsurface); md.thermal.spctemperature(md.mesh.elements(pos2,4:6))=0;
@@ -21,7 +21,7 @@
 
 %modeled  results
 md.cluster=generic('name',oshostname(),'np',2);
-md=solve(md,ThermalSolutionEnum);
+md=solve(md,ThermalSolutionEnum());
 
 %plot results
 comp_temp=md.results.ThermalSolution.Temperature;

Modified: issm/trunk/test/NightlyRun/test1304.m
===================================================================
--- issm/trunk/test/NightlyRun/test1304.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1304.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -4,11 +4,11 @@
 % surface with an imposed slope (Geothermal flux). if it is not the case, something is thermal modeling has been changed...
 printingflag=false;
 
-md=model;
-md=triangle(md,'../Exp/Square.exp',100000);
+md=model();
+md=triangle(md,'../Exp/Square.exp',100000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareThermal.par');
-md=extrude(md,11,1);
+md=extrude(md,11,1.);
 md=setflowequation(md,'Pattyn','all');
 
 pos2=find(md.mesh.elementonsurface); md.thermal.spctemperature(md.mesh.elements(pos2,4:6))=0;
@@ -22,7 +22,7 @@
 
 %modeled  results
 md.cluster=generic('name',oshostname(),'np',2);
-md=solve(md,ThermalSolutionEnum);
+md=solve(md,ThermalSolutionEnum());
 
 %plot results
 comp_temp=md.results.ThermalSolution.Temperature;

Modified: issm/trunk/test/NightlyRun/test1401.m
===================================================================
--- issm/trunk/test/NightlyRun/test1401.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1401.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -6,7 +6,7 @@
 L=1; %in m
 nx=70; %numberof nodes in x direction
 ny=70;
-md=model;
+md=model();
 
 %mesh adaptation loop YAMS
 md=squaremesh(md,L,L,nx,ny);
@@ -71,8 +71,8 @@
 y2=md.mesh.y;
 
 %Fields and tolerances to track changes
-field_names     ={'xyams' 'yyams' 'xbamg' 'ybamg'};
-field_tolerances={1e-13 1e-13 1e-13 1e-13};
+field_names     ={'xyams','yyams','xbamg','ybamg'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13};
 field_values={...
 	x1, y1,...
 	x2, y2,...

Modified: issm/trunk/test/NightlyRun/test1402.m
===================================================================
--- issm/trunk/test/NightlyRun/test1402.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1402.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,7 +5,7 @@
 L=1; %in m
 nx=30; %numberof nodes in x direction
 ny=30;
-md=model;
+md=model();
 
 %mesh adaptation loop YAMS
 md=squaremesh(md,L,L,nx,ny);
@@ -101,8 +101,8 @@
 y2=md.mesh.y;
 
 %Fields and tolerances to track changes
-field_names     ={'xyams' 'yyams' 'xbamg' 'ybamg'};
-field_tolerances={1e-13 1e-13 1e-13 1e-13};
+field_names     ={'xyams','yyams','xbamg','ybamg'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13};
 field_values={...
 	x1, y1,...
 	x2, y2,...

Modified: issm/trunk/test/NightlyRun/test1501.m
===================================================================
--- issm/trunk/test/NightlyRun/test1501.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1501.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,38 +1,38 @@
 printingflag = false;
 
-md=triangle(model,'../Exp/Square.exp',350000);
+md=triangle(model(),'../Exp/Square.exp',350000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.transient.isthermal=0;
 
-md.timestepping.time_step=1;
+md.timestepping.time_step=1.;
 md.settings.output_frequency=1;
-md.timestepping.final_time=2000;
+md.timestepping.final_time=2000.;
 
 %Solve for thinning rate -> -1 * surface mass balance
-smb= 2*ones(md.mesh.numberofvertices,1);   
+smb= 2.*ones(md.mesh.numberofvertices,1);   
 md.surfaceforcings.mass_balance= smb;
 md.basalforcings.melting_rate= smb;
 
-md=solve(md,PrognosticSolutionEnum);
+md=solve(md,PrognosticSolutionEnum());
 
 for i=1:10
-	 md=solve(md,PrognosticSolutionEnum);
+	 md=solve(md,PrognosticSolutionEnum());
 	 md.surfaceforcings.mass_balance= md.surfaceforcings.mass_balance - ((md.results.PrognosticSolution.Thickness)-md.geometry.thickness);
 end
 
 %Set up transient
 smb = md.surfaceforcings.mass_balance;
 
-tooth= [ [ones(400,1)*(smb') - 10]' [ones(400,1)*(smb')]' ];
+tooth= [ [ones(400,1)*(smb') - 10.]' [ones(400,1)*(smb')]' ];
 smb=[ [ones(399,1)*(smb')]' smb  tooth tooth];
 
 md.surfaceforcings.mass_balance= smb;
-md.surfaceforcings.mass_balance(end+1,:)=[1:2000];
+md.surfaceforcings.mass_balance(end+1,:)=[1.:2000.];
 
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','SurfaceforcingsMassBalance1', ...

Modified: issm/trunk/test/NightlyRun/test1502.m
===================================================================
--- issm/trunk/test/NightlyRun/test1502.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1502.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,39 +1,39 @@
 printingflag = false;
 
-md=triangle(model,'../Exp/Square.exp',450000);
+md=triangle(model(),'../Exp/Square.exp',450000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md.cluster=generic('name',oshostname(),'np',2);
 md.transient.isthermal=0;
 
-md.timestepping.time_step=1;
+md.timestepping.time_step=1.;
 md.settings.output_frequency=1;
-md.timestepping.final_time=2000;
+md.timestepping.final_time=2000.;
 
 %Solve for thinning rate -> -1 * surface mass balance
-smb= 2*ones(md.mesh.numberofvertices,1);   
+smb= 2.*ones(md.mesh.numberofvertices,1);   
 md.surfaceforcings.mass_balance= smb;
 md.basalforcings.melting_rate= smb;
 
-md=solve(md,PrognosticSolutionEnum);
+md=solve(md,PrognosticSolutionEnum());
 
 for i=1:10
-	 md=solve(md,PrognosticSolutionEnum);
+	 md=solve(md,PrognosticSolutionEnum());
 	 md.surfaceforcings.mass_balance= md.surfaceforcings.mass_balance - ((md.results.PrognosticSolution.Thickness)-md.geometry.thickness);
 end
 
 %Set up transient
 smb = md.surfaceforcings.mass_balance;
 
-tooth= [ [ones(400,1)*(smb') - 10]' [ones(400,1)*(smb')]' ];
+tooth= [ [ones(400,1)*(smb') - 10.]' [ones(400,1)*(smb')]' ];
 smb=[ [ones(399,1)*(smb')]' smb  tooth tooth];
 
 md.surfaceforcings.mass_balance= smb;
-md.surfaceforcings.mass_balance(end+1,:)=[1:2000];
+md.surfaceforcings.mass_balance(end+1,:)=[1.:2000.];
 
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','SurfaceforcingsMassBalance1', ...

Modified: issm/trunk/test/NightlyRun/test1601.m
===================================================================
--- issm/trunk/test/NightlyRun/test1601.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1601.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,17 +1,17 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
-md.diagnostic.spcvx(find(md.mesh.y>0))=NaN;
-md.initialization.vx(:)=0;
-md.initialization.vy(:)=0;
-md.initialization.vel(:)=0;
+md.diagnostic.spcvx(find(md.mesh.y>0.))=NaN;
+md.initialization.vx(:)=0.;
+md.initialization.vy(:)=0.;
+md.initialization.vel(:)=0.;
 
-md.cluster=generic('name',oshostname,'np',2);
-md=solve(md,DiagnosticSolutionEnum);
+md.cluster=generic('name',oshostname(),'np',2);
+md=solve(md,DiagnosticSolutionEnum());
 vel0=md.results.DiagnosticSolution.Vel;
 
-theta=30*pi/180;
+theta=30.*pi/180.;
 x=md.mesh.x;
 y=md.mesh.y;
 md.mesh.x=cos(theta)*x-sin(theta)*y;
@@ -19,18 +19,18 @@
 
 md.diagnostic.referential(:,1:3)=repmat([cos(theta),sin(theta),0],md.mesh.numberofvertices,1);
 md.diagnostic.referential(:,4:6)=repmat([0,0,1],md.mesh.numberofvertices,1);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 vel1=md.results.DiagnosticSolution.Vel;
 
 plotmodel(md,'data',vel0,'data',vel1,'data',vel1-vel0,'title','Cartesian CS','title','Rotated CS','title','difference')
 disp(['Error between Cartesian and rotated CS: ' num2str(max(abs(vel0-vel1))/(max(abs(vel0))+eps)) ]);
 
 %Now, put CS back to normal except on the side where the spc are applied
-pos=find(x==0 | x==1000000);
+pos=find(x==0. | x==1000000.);
 md.diagnostic.referential(:)=NaN;
 md.diagnostic.referential(pos,1:3)=repmat([cos(theta),sin(theta),0],size(pos,1),1);
 md.diagnostic.referential(pos,4:6)=repmat([0,0,1],size(pos,1),1);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 vel2=md.results.DiagnosticSolution.Vel;
 
 plotmodel(md,'data',vel0,'data',vel2,'data',vel2-vel0,'title','Cartesian CS','title','Rotated CS','title','difference')

Modified: issm/trunk/test/NightlyRun/test1602.m
===================================================================
--- issm/trunk/test/NightlyRun/test1602.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test1602.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,18 +1,18 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
+md=extrude(md,5,1.);
 md=setflowequation(md,'pattyn','all');
-md.diagnostic.spcvx(find(md.mesh.y>0))=NaN;
-md.initialization.vx(:)=0;
-md.initialization.vy(:)=0;
-md.initialization.vel(:)=0;
+md.diagnostic.spcvx(find(md.mesh.y>0.))=NaN;
+md.initialization.vx(:)=0.;
+md.initialization.vy(:)=0.;
+md.initialization.vel(:)=0.;
 
-md.cluster=generic('name',oshostname,'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md.cluster=generic('name',oshostname(),'np',3);
+md=solve(md,DiagnosticSolutionEnum());
 vel0=md.results.DiagnosticSolution.Vel;
 
-theta=30*pi/180;
+theta=30.*pi/180.;
 x=md.mesh.x;
 y=md.mesh.y;
 md.mesh.x=cos(theta)*x-sin(theta)*y;
@@ -20,7 +20,7 @@
 
 md.diagnostic.referential(:,1:3)=repmat([cos(theta),sin(theta),0],md.mesh.numberofvertices,1);
 md.diagnostic.referential(:,4:6)=repmat([0,0,1],md.mesh.numberofvertices,1);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 vel1=md.results.DiagnosticSolution.Vel;
 
 plotmodel(md,'data',vel0,'data',vel1,'data',vel1-vel0,'title','Cartesian CS','title','Rotated CS','title','difference','view#all',2)

Modified: issm/trunk/test/NightlyRun/test201.m
===================================================================
--- issm/trunk/test/NightlyRun/test201.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test201.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test202.m
===================================================================
--- issm/trunk/test/NightlyRun/test202.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test202.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test203.m
===================================================================
--- issm/trunk/test/NightlyRun/test203.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test203.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test204.m
===================================================================
--- issm/trunk/test/NightlyRun/test204.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test204.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'stokes','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test205.m
===================================================================
--- issm/trunk/test/NightlyRun/test205.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test205.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'pattyn','../Exp/SquareHalfRight.exp','fill','macayeal','coupling','penalties');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test206.m
===================================================================
--- issm/trunk/test/NightlyRun/test206.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test206.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.timestepping.time_step=0;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,ThermalSolutionEnum);
+md=solve(md,ThermalSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature','BasalforcingsMeltingRate'};

Modified: issm/trunk/test/NightlyRun/test207.m
===================================================================
--- issm/trunk/test/NightlyRun/test207.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test207.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,18 +1,18 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.transient.isdiagnostic=0;
 md.transient.isprognostic=0;
 md.transient.isthermal=1;
 md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature1','BasalforcingsMeltingRate1','Temperature2','BasalforcingsMeltingRate2','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_tolerances={1e-13,1e-6,1e-13,1e-6,1e-13,1e-6};
 field_values={...
 	(md.results.TransientSolution(1).Temperature),...
 	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...

Modified: issm/trunk/test/NightlyRun/test208.m
===================================================================
--- issm/trunk/test/NightlyRun/test208.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test208.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};

Modified: issm/trunk/test/NightlyRun/test209.m
===================================================================
--- issm/trunk/test/NightlyRun/test209.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test209.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,15 +1,15 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
 field_tolerances={...
 	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-8,...
 	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-8,...

Modified: issm/trunk/test/NightlyRun/test210.m
===================================================================
--- issm/trunk/test/NightlyRun/test210.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test210.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...

Modified: issm/trunk/test/NightlyRun/test211.m
===================================================================
--- issm/trunk/test/NightlyRun/test211.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test211.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'stokes','all');
 md.diagnostic.reltol=NaN;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names={...

Modified: issm/trunk/test/NightlyRun/test212.m
===================================================================
--- issm/trunk/test/NightlyRun/test212.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test212.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
@@ -17,14 +17,14 @@
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'MaterialsRheologyBbar' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_names     ={'Gradient','Misfits','MaterialsRheologyBbar','Pressure','Vel','Vx','Vy'};
 field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
 field_values={...
 	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
+	(md.results.DiagnosticSolution.J),...
 	(md.results.DiagnosticSolution.MaterialsRheologyBbar),...
 	(md.results.DiagnosticSolution.Pressure),...
 	(md.results.DiagnosticSolution.Vel),...

Modified: issm/trunk/test/NightlyRun/test213.m
===================================================================
--- issm/trunk/test/NightlyRun/test213.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test213.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 
 %control parameters
@@ -18,10 +18,10 @@
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'MaterialsRheologyBbar' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_names     ={'Gradient','Misfits','MaterialsRheologyBbar','Pressure','Vel','Vx','Vy'};
 field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
 field_values={...
 	(md.results.DiagnosticSolution.Gradient1),...

Modified: issm/trunk/test/NightlyRun/test214.m
===================================================================
--- issm/trunk/test/NightlyRun/test214.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test214.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 
 %control parameters
@@ -18,14 +18,14 @@
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'MaterialsRheologyBbar' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_names     ={'Gradient','Misfits','MaterialsRheologyBbar','Pressure','Vel','Vx','Vy'};
 field_tolerances={1e-07,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08};
 field_values={...
 	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
+	(md.results.DiagnosticSolution.J),...
 	(md.results.DiagnosticSolution.MaterialsRheologyB),...
 	(md.results.DiagnosticSolution.Pressure),...
 	(md.results.DiagnosticSolution.Vel),...

Modified: issm/trunk/test/NightlyRun/test215.m
===================================================================
--- issm/trunk/test/NightlyRun/test215.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test215.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'stokes','all');
 
 %control parameters
@@ -18,14 +18,14 @@
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'MaterialsRheologyBbar' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_names     ={'Gradient','Misfits','MaterialsRheologyBbar','Pressure','Vel','Vx','Vy'};
 field_tolerances={1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09};
 field_values={...
 	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
+	(md.results.DiagnosticSolution.J),...
 	(md.results.DiagnosticSolution.MaterialsRheologyB),...
 	(md.results.DiagnosticSolution.Pressure),...
 	(md.results.DiagnosticSolution.Vel),...

Modified: issm/trunk/test/NightlyRun/test216.m
===================================================================
--- issm/trunk/test/NightlyRun/test216.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test216.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/SquareHole.exp','../Exp/Rifts.exp',50000);
+md=triangle(model(),'../Exp/SquareHole.exp','../Exp/Rifts.exp',50000.);
 md=meshprocessrifts(md,'../Exp/Square.exp');
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
@@ -11,7 +11,7 @@
 md.diagnostic.rift_penalty_lock=2;
 md.diagnostic.rift_penalty_threshold=0;
 md.rifts.riftstruct.fractionincrement=.1;
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test217.m
===================================================================
--- issm/trunk/test/NightlyRun/test217.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test217.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
@@ -57,7 +57,7 @@
 diagnostic.icefront=[diagnostic.icefront 1*md.mask.elementonfloatingice(diagnostic.icefront(:,end))];
 md.diagnostic.icefront=diagnostic.icefront;
 
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %create analytical solution: strain rate is constant = ((rho_ice*g*h)/4B)^3 (Paterson, 4th Edition, page 292.
 %ey_c=(md.materials.rho_ice*md.constants.g*(1-di)*md.geometry.thickness./(4*md.materials.rheology_B)).^3;

Modified: issm/trunk/test/NightlyRun/test218.m
===================================================================
--- issm/trunk/test/NightlyRun/test218.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test218.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=squaremesh(model,1000000,1000000,5,5);
+md=squaremesh(model(),1000000,1000000,5,5);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
@@ -80,7 +80,7 @@
 md.qmu.isdakota=1;
 
 %solve
-md=solve(md,DiagnosticSolutionEnum,'overwrite','y');
+md=solve(md,DiagnosticSolutionEnum(),'overwrite','y');
 
 %Fields and tolerances to track changes
 md.qmu.results=md.results.dakota;

Modified: issm/trunk/test/NightlyRun/test219.m
===================================================================
--- issm/trunk/test/NightlyRun/test219.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test219.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'pattyn','../Exp/SquareHalfRight.exp','fill','macayeal');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test220.m
===================================================================
--- issm/trunk/test/NightlyRun/test220.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test220.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',120000);
+md=triangle(model(),'../Exp/Square.exp',120000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,2,1);
+md=extrude(md,2,1.);
 md=setflowequation(md,'stokes','../Exp/SquareHalfRight.exp','fill','pattyn');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test221.m
===================================================================
--- issm/trunk/test/NightlyRun/test221.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test221.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',120000);
+md=triangle(model(),'../Exp/Square.exp',120000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,2,1);
+md=extrude(md,2,1.);
 md=setflowequation(md,'stokes','../Exp/SquareHalfRight.exp','fill','macayeal');
 md.cluster=generic('name',oshostname(),'np',3);
 md.diagnostic.viscosity_overshoot=0;
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test222.m
===================================================================
--- issm/trunk/test/NightlyRun/test222.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test222.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.prognostic.hydrostatic_adjustment='Incremental';
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};

Modified: issm/trunk/test/NightlyRun/test223.m
===================================================================
--- issm/trunk/test/NightlyRun/test223.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test223.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
-md.geometry.bed=md.geometry.bed+50; md.geometry.surface=md.geometry.surface+50;
-md.cluster=generic('name',oshostname(),'np',3);
+md.geometry.bed=md.geometry.bed+50.; md.geometry.surface=md.geometry.surface+50.;
+md.cluster=generic('name',oshostname(),'np',1);
 md.prognostic.hydrostatic_adjustment='Incremental';
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};

Modified: issm/trunk/test/NightlyRun/test224.m
===================================================================
--- issm/trunk/test/NightlyRun/test224.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test224.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,16 +1,16 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.prognostic.hydrostatic_adjustment='Incremental';
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
 field_tolerances={...
 	1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,...
 	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06,...

Modified: issm/trunk/test/NightlyRun/test225.m
===================================================================
--- issm/trunk/test/NightlyRun/test225.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test225.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,17 +1,17 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md.geometry.bed=md.geometry.bed+50; md.geometry.surface=md.geometry.surface+50;
-md=extrude(md,3,1);
+md.geometry.bed=md.geometry.bed+50.; md.geometry.surface=md.geometry.surface+50.;
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.prognostic.hydrostatic_adjustment='Incremental';
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
 field_tolerances={...
 	1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,...
 	1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-05,...

Modified: issm/trunk/test/NightlyRun/test226.m
===================================================================
--- issm/trunk/test/NightlyRun/test226.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test226.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.timestepping.time_adapt=1;
-md.timestepping.final_time=10;
-md=solve(md,TransientSolutionEnum);
+md.timestepping.time_adapt=1.;
+md.timestepping.final_time=10.;
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};

Modified: issm/trunk/test/NightlyRun/test227.m
===================================================================
--- issm/trunk/test/NightlyRun/test227.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test227.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,17 +1,17 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.timestepping.time_adapt=1;
-md.timestepping.final_time=10;
-md=solve(md,TransientSolutionEnum);
+md.timestepping.time_adapt=1.;
+md.timestepping.final_time=10.;
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
 field_tolerances={...
 	1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,...
 	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06,...

Modified: issm/trunk/test/NightlyRun/test228.m
===================================================================
--- issm/trunk/test/NightlyRun/test228.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test228.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,22 +1,22 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 
-md.timestepping.time_step=1;
+md.timestepping.time_step=1.;
 md.settings.output_frequency=1;
-md.timestepping.final_time=4;
+md.timestepping.final_time=4.;
 
 %Set up transient
-smb = ones(md.mesh.numberofvertices,1)*3.6;
-smb=[ smb smb*-1 ];
+smb=ones(md.mesh.numberofvertices,1)*3.6;
+smb=[ smb smb*-1. ];
 
-md.surfaceforcings.mass_balance= smb;
-md.surfaceforcings.mass_balance(end+1,:)=[1.5 3];
+md.surfaceforcings.mass_balance=smb;
+md.surfaceforcings.mass_balance(end+1,:)=[1.5 3.];
 md.transient.isthermal=0;
 
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','SurfaceforcingsMassBalance1', ...
@@ -27,7 +27,6 @@
 	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
 	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
 	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
-
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test229.m
===================================================================
--- issm/trunk/test/NightlyRun/test229.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test229.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,22 +1,22 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 
-md.timestepping.time_step=1;
+md.timestepping.time_step=1.;
 md.settings.output_frequency=1;
-md.timestepping.final_time=4;
+md.timestepping.final_time=4.;
 
 %Set up transient
-smb = ones(md.mesh.numberofvertices,1)*3.6;
-smb=[ smb smb*2 ];
+smb=ones(md.mesh.numberofvertices,1)*3.6;
+smb=[ smb smb*2. ];
 
-md.surfaceforcings.mass_balance= smb;
-md.surfaceforcings.mass_balance(end+1,:)=[1.5 3];
+md.surfaceforcings.mass_balance=smb;
+md.surfaceforcings.mass_balance(end+1,:)=[1.5 3.];
 md.transient.isthermal=0;
 
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','SurfaceforcingsMassBalance1', ...
@@ -27,7 +27,6 @@
 	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
 	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
 	1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
-
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test230.m
===================================================================
--- issm/trunk/test/NightlyRun/test230.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test230.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
-md=triangle(model,'../Exp/Square.exp',350000);
+md=triangle(model(),'../Exp/Square.exp',350000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 
@@ -10,25 +10,24 @@
 md.timestepping.final_time=4;
 
 %Set up transient
-smb = ones(md.mesh.numberofvertices,1)*3.6;
-smb=[ smb smb*-1 ];
+smb=ones(md.mesh.numberofvertices,1)*3.6;
+smb=[ smb smb*-1. ];
 
-md.surfaceforcings.mass_balance= smb;
-md.surfaceforcings.mass_balance(end+1,:)=[1.5 3];
+md.surfaceforcings.mass_balance=smb;
+md.surfaceforcings.mass_balance(end+1,:)=[1.5 3.];
 md.transient.isthermal=0;
 
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','SurfaceforcingsMassBalance1', ...
 	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','SurfaceforcingsMassBalance2', ...
-	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','SurfaceforcingsMassBalance3',...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','SurfaceforcingsMassBalance3', ...
 	'Vx4','Vy4','Vz4','Vel4','Pressure4','Bed4','Surface4','Thickness4','SurfaceMassbalance4'};
 field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
 	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
 	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
 	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test231.m
===================================================================
--- issm/trunk/test/NightlyRun/test231.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test231.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
-md=triangle(model,'../Exp/Square.exp',350000);
+md=triangle(model(),'../Exp/Square.exp',350000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 
@@ -10,25 +10,24 @@
 md.timestepping.final_time=4;
 
 %Set up transient
-smb = ones(md.mesh.numberofvertices,1)*3.6;
-smb=[ smb smb*2 ];
+smb=ones(md.mesh.numberofvertices,1)*3.6;
+smb=[ smb smb*2. ];
 
-md.surfaceforcings.mass_balance= smb;
-md.surfaceforcings.mass_balance(end+1,:)=[1.5 3];
+md.surfaceforcings.mass_balance=smb;
+md.surfaceforcings.mass_balance(end+1,:)=[1.5 3.];
 md.transient.isthermal=0;
 
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','SurfaceforcingsMassBalance1', ...
 	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','SurfaceforcingsMassBalance2', ...
-	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','SurfaceforcingsMassBalance3',...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','SurfaceforcingsMassBalance3', ...
 	'Vx4','Vy4','Vz4','Vel4','Pressure4','Bed4','Surface4','Thickness4','SurfaceMassbalance4'};
 field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
 	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
 	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
 	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
-
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test232.m
===================================================================
--- issm/trunk/test/NightlyRun/test232.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test232.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,21 +1,21 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.thermal.spctemperature=[md.thermal.spctemperature, md.thermal.spctemperature+5, md.thermal.spctemperature+10, md.thermal.spctemperature+15; 1.5 2.5 3.5 4];
+md.thermal.spctemperature=[md.thermal.spctemperature, md.thermal.spctemperature+5., md.thermal.spctemperature+10., md.thermal.spctemperature+15.; 1.5 2.5 3.5 4.];
 md.timestepping.time_step=1;
 md.timestepping.final_time=4;
 md.transient.isdiagnostic=0;
 md.transient.isprognostic=0;
 md.transient.isthermal=1;
 md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature1','BasalforcingsMeltingRate1','Temperature2','BasalforcingsMeltingRate2','Temperature3','BasalforcingsMeltingRate3','Temperature4','BasalforcingsMeltingRate4'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_tolerances={1e-13,1e-6,1e-13,1e-6,1e-13,1e-6,1e-13,1e-6};
 field_values={...
 	(md.results.TransientSolution(1).Temperature),...
 	(md.results.TransientSolution(1).BasalforcingsMeltingRate),...

Modified: issm/trunk/test/NightlyRun/test233.m
===================================================================
--- issm/trunk/test/NightlyRun/test233.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test233.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,23 +1,23 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.thermal.spctemperature=[md.thermal.spctemperature, md.thermal.spctemperature+5; 1 2];
+md.thermal.spctemperature=[md.thermal.spctemperature, md.thermal.spctemperature+5.; 1. 2.];
 md.timestepping.time_step=0.5;
-md.timestepping.final_time=2;
-md=solve(md,TransientSolutionEnum);
+md.timestepping.final_time=2.;
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3', ...
-					   'Vx4','Vy4','Vz4','Vel4','Pressure4','Bed4','Surface4','Thickness4','Temperature4','BasalforcingsMeltingRate4'};
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3', ...
+	'Vx4','Vy4','Vz4','Vel4','Pressure4','Bed4','Surface4','Thickness4','Temperature4','BasalforcingsMeltingRate4'};
 field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09, ...
-						1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-07, ...
-						1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06, ...
-						1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06};
+	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-07, ...
+	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06, ...
+	1e-09,1e-09,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-06};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test234.m
===================================================================
--- issm/trunk/test/NightlyRun/test234.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test234.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
@@ -54,7 +54,7 @@
 md.transient.requested_outputs=IceVolumeEnum();
 
 %solve
-md=solve(md,TransientSolutionEnum,'overwrite','y');
+md=solve(md,TransientSolutionEnum(),'overwrite','y');
 md.qmu.results=md.results.dakota;
 
 %Fields and tolerances to track changes

Modified: issm/trunk/test/NightlyRun/test235.m
===================================================================
--- issm/trunk/test/NightlyRun/test235.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test235.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md=setflowequation(md,'macayeal','all');
@@ -54,7 +54,7 @@
 md.transient.requested_outputs=IceVolumeEnum();
 
 %solve
-md=solve(md,TransientSolutionEnum,'overwrite','y');
+md=solve(md,TransientSolutionEnum(),'overwrite','y');
 md.qmu.results=md.results.dakota;
 
 %Fields and tolerances to track changes

Modified: issm/trunk/test/NightlyRun/test236.m
===================================================================
--- issm/trunk/test/NightlyRun/test236.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test236.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 
 % Use of ispdd and isdelta18o methods
@@ -11,17 +11,16 @@
 % creating delta18o
 load '../Data/delta18o.data'
 md.surfaceforcings.delta18o=delta18o;
-%  creating delta18oSurface
+% creating delta18oSurface
 md.surfaceforcings.delta18o_surface(1,1:(length(delta18o))) = 0;
 md.surfaceforcings.delta18o_surface(2,:) = delta18o(2,:);
 
 % creating Present day and lgm temperatures
-% Same temperature over the all region :
-imonth=0:11;
-tmonth(1:12)=238.15+20;
+% Same temperature over the all region:
+tmonth(1:12)=238.15+20.;
 for imonth=0:11
     md.surfaceforcings.temperatures_presentday(1:md.mesh.numberofvertices,imonth+1)=tmonth(imonth+1);
-    md.surfaceforcings.temperatures_lgm(1:md.mesh.numberofvertices,imonth+1)=tmonth(imonth+1)-20;
+    md.surfaceforcings.temperatures_lgm(1:md.mesh.numberofvertices,imonth+1)=tmonth(imonth+1)-20.;
     % Time for the last line:
     md.surfaceforcings.temperatures_presentday(md.mesh.numberofvertices+1,imonth+1)=((imonth+1)/12);
     md.surfaceforcings.temperatures_lgm(md.mesh.numberofvertices+1,imonth+1)=((imonth+1)/12);
@@ -30,7 +29,7 @@
 % creating initialization and spc temperatures initialization and spc
 md.thermal.spctemperature=mean(md.surfaceforcings.temperatures_lgm(1:md.mesh.numberofvertices,1:12),2); %-10*ones(md.mesh.numberofvertices,1);
 md.thermal.spctemperature=repmat(md.thermal.spctemperature,1,md.timestepping.final_time/md.timestepping.time_step);
-itemp = 0:md.timestepping.time_step:md.timestepping.final_time-md.timestepping.time_step;
+itemp=0:md.timestepping.time_step:md.timestepping.final_time-md.timestepping.time_step;
 md.thermal.spctemperature(md.mesh.numberofvertices+1,:)=itemp;
 
 md.initialization.temperature=md.surfaceforcings.temperatures_lgm(1:md.mesh.numberofvertices,1); %*ones(md.mesh.numberofvertices,1);
@@ -43,19 +42,18 @@
 
 % time steps and resolution
 md.timestepping.time_step=20;
-md.timestepping.final_time= 60;
+md.timestepping.final_time=60;
 
 % 
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
-
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};
 field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-						1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-						1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
+	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test237.m
===================================================================
--- issm/trunk/test/NightlyRun/test237.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test237.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',600000);%180000
+md=triangle(model(),'../Exp/Square.exp',600000.);%180000
 md=setmask(md,'all','');
 
 % Use of ispdd and isdelta18o methods
@@ -11,17 +11,16 @@
 % creating delta18o
 load '../Data/delta18o.data'
 md.surfaceforcings.delta18o=delta18o;
-%  creating delta18oSurface
+% creating delta18oSurface
 md.surfaceforcings.delta18o_surface(1,1:(length(delta18o))) = 0;
 md.surfaceforcings.delta18o_surface(2,:) = delta18o(2,:);
 
 % creating Present day and lgm temperatures
-% Same temperature over the all region :
-imonth=0:11;
-tmonth(1:12)=238.15+20;
+% Same temperature over the all region:
+tmonth(1:12)=238.15+20.;
 for imonth=0:11
     md.surfaceforcings.temperatures_presentday(1:md.mesh.numberofvertices,imonth+1)=tmonth(imonth+1);
-    md.surfaceforcings.temperatures_lgm(1:md.mesh.numberofvertices,imonth+1)=tmonth(imonth+1)-20;
+    md.surfaceforcings.temperatures_lgm(1:md.mesh.numberofvertices,imonth+1)=tmonth(imonth+1)-20.;
     % Time for the last line:
     md.surfaceforcings.temperatures_presentday(md.mesh.numberofvertices+1,imonth+1)=((imonth+1)/12);
     md.surfaceforcings.temperatures_lgm(md.mesh.numberofvertices+1,imonth+1)=((imonth+1)/12);
@@ -30,7 +29,7 @@
 % creating initialization and spc temperatures initialization and spc
 md.thermal.spctemperature=mean(md.surfaceforcings.temperatures_lgm(1:md.mesh.numberofvertices,1:12),2); %-10*ones(md.mesh.numberofvertices,1);
 md.thermal.spctemperature=repmat(md.thermal.spctemperature,1,md.timestepping.final_time/md.timestepping.time_step);
-itemp = 0:md.timestepping.time_step:md.timestepping.final_time-md.timestepping.time_step;
+itemp=0:md.timestepping.time_step:md.timestepping.final_time-md.timestepping.time_step;
 md.thermal.spctemperature(md.mesh.numberofvertices+1,:)=itemp;
 
 md.initialization.temperature=md.surfaceforcings.temperatures_lgm(1:md.mesh.numberofvertices,1); %*ones(md.mesh.numberofvertices,1);
@@ -44,23 +43,22 @@
 % time steps and resolution
 md.timestepping.time_step=20;
 md.settings.output_frequency=1;
-md.timestepping.final_time= 60;
+md.timestepping.final_time=60;
 
 %
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
+						'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
+						'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
 field_tolerances={...
-	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-8,...
-	1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-8,...
-	1e-13,1e-13,1e-08,1e-13,1e-13,1e-10,1e-10,1e-10,1e-13,1e-8};
-
+	1e-13,1e-13,1e-13,1e-13,1e-13,1e-8,1e-8,1e-8,1e-13,1e-8,...
+	1e-13,1e-13,1e-13,1e-13,1e-13,1e-8,1e-8,1e-8,1e-13,1e-8,...
+	1e-13,1e-13,1e-08,1e-13,1e-13,1e-8,1e-8,1e-8,1e-13,1e-8};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test270.m
===================================================================
--- issm/trunk/test/NightlyRun/test270.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test270.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,13 +1,13 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md.materials=matdamageice();
 md.materials.rheology_B=paterson(md.initialization.temperature);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 md.materials.rheology_Z=0.5*ones(md.mesh.numberofvertices,1);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test272.m
===================================================================
--- issm/trunk/test/NightlyRun/test272.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test272.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md.materials=matdamageice();
 md.materials.rheology_B=paterson(md.initialization.temperature);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 md.materials.rheology_Z=0.5*ones(md.mesh.numberofvertices,1);
 md=setflowequation(md,'macayeal','all');
 
@@ -13,23 +13,23 @@
 md.inversion.min_parameters=10^-13*ones(md.mesh.numberofvertices,1);
 md.inversion.max_parameters=ones(md.mesh.numberofvertices,1);
 md.inversion.nsteps=2;
-md.inversion.cost_functions=101*ones(md.inversion.nsteps,1);
+md.inversion.cost_functions=101.*ones(md.inversion.nsteps,1);
 md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
 md.inversion.gradient_scaling=0.9*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
+md.inversion.maxiter_per_step=2.*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
 md.inversion.vx_obs=md.initialization.vx; 
 md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'MaterialsRheologyZbar' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_names     ={'Gradient','Misfits','MaterialsRheologyZbar','Pressure','Vel','Vx','Vy'};
 field_tolerances={1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12};
 field_values={...
    (md.results.DiagnosticSolution.Gradient1),...
-   md.results.DiagnosticSolution.J,...
+   (md.results.DiagnosticSolution.J),...
    (md.results.DiagnosticSolution.MaterialsRheologyZbar),...
    (md.results.DiagnosticSolution.Pressure),...
    (md.results.DiagnosticSolution.Vel),...

Modified: issm/trunk/test/NightlyRun/test274.m
===================================================================
--- issm/trunk/test/NightlyRun/test274.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test274.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,15 +1,15 @@
-md=triangle(model,'../Exp/SquareHole.exp','../Exp/Rifts.exp',50000);
+md=triangle(model(),'../Exp/SquareHole.exp','../Exp/Rifts.exp',50000.);
 md=meshprocessrifts(md,'../Exp/Square.exp');
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelf.par');
 md.materials=matdamageice();
 md.materials.rheology_B=paterson(md.initialization.temperature);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 md.materials.rheology_Z=0.5*ones(md.mesh.numberofvertices,1);
 md=setflowequation(md,'macayeal','all');
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test3001.m
===================================================================
--- issm/trunk/test/NightlyRun/test3001.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test3001.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,12 @@
-md=triangle(model,'../Exp/Square.exp',50000);
+md=triangle(model(),'../Exp/Square.exp',50000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.diagnostic.requested_outputs=StressTensorEnum;
+md.diagnostic.requested_outputs=StressTensorEnum();
 md.autodiff.isautodiff=true;
-md=solve(md,DiagnosticSolutionEnum);
+md.verbose=verbose('autodiff',true);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure',...

Modified: issm/trunk/test/NightlyRun/test3002.m
===================================================================
--- issm/trunk/test/NightlyRun/test3002.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test3002.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,12 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.autodiff.isautodiff=true;
-md=solve(md,DiagnosticSolutionEnum);
+md.verbose=verbose('autodiff',true);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test3003.m
===================================================================
--- issm/trunk/test/NightlyRun/test3003.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test3003.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,12 +1,13 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.diagnostic.requested_outputs=StressTensorEnum;
+md.diagnostic.requested_outputs=StressTensorEnum();
 md.autodiff.isautodiff=true;
-md=solve(md,DiagnosticSolutionEnum);
+md.verbose=verbose('autodiff',true);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure',...

Modified: issm/trunk/test/NightlyRun/test3004.m
===================================================================
--- issm/trunk/test/NightlyRun/test3004.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test3004.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,12 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'stokes','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.autodiff.isautodiff=true;
-md=solve(md,DiagnosticSolutionEnum);
+md.verbose=verbose('autodiff',true);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test3005.m
===================================================================
--- issm/trunk/test/NightlyRun/test3005.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test3005.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.autodiff.isautodiff=true;
-md=solve(md,PrognosticSolutionEnum);
+md.verbose=verbose('autodiff',true);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test3006.m
===================================================================
--- issm/trunk/test/NightlyRun/test3006.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test3006.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=meshconvert(md);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
@@ -7,7 +7,8 @@
 md.prognostic.stabilization=3;
 md.prognostic.spcthickness=md.geometry.thickness;
 md.autodiff.isautodiff=true;
-md=solve(md,PrognosticSolutionEnum);
+md.verbose=verbose('autodiff',true);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test3007.m
===================================================================
--- issm/trunk/test/NightlyRun/test3007.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test3007.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,12 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 md=setflowequation(md,'macayeal','all');
-md=extrude(md,5,3);
+md=extrude(md,5,3.);
 md.cluster=generic('name',oshostname(),'np',3);
 md.autodiff.isautodiff=true;
-md=solve(md,PrognosticSolutionEnum);
+md.verbose=verbose('autodiff',true);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test3008.m
===================================================================
--- issm/trunk/test/NightlyRun/test3008.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test3008.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,12 +1,13 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.timestepping.time_step=0;
 md.cluster=generic('name',oshostname(),'np',3);
 md.autodiff.isautodiff=true;
-md=solve(md,ThermalSolutionEnum);
+md.verbose=verbose('autodiff',true);
+md=solve(md,ThermalSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature','BasalforcingsMeltingRate'};

Modified: issm/trunk/test/NightlyRun/test3009.m
===================================================================
--- issm/trunk/test/NightlyRun/test3009.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test3009.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.transient.isdiagnostic=0;
@@ -9,7 +9,8 @@
 md.transient.isthermal=1;
 md.transient.isgroundingline=0;
 md.autodiff.isautodiff=true;
-md=solve(md,TransientSolutionEnum);
+md.verbose=verbose('autodiff',true);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature','BasalforcingsMeltingRate'};

Modified: issm/trunk/test/NightlyRun/test301.m
===================================================================
--- issm/trunk/test/NightlyRun/test301.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test301.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test3010.m
===================================================================
--- issm/trunk/test/NightlyRun/test3010.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test3010.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'all','');
 md=parameterize(md,'../Par/SquareShelfConstrained.par');
 md=setflowequation(md,'macayeal','all');
@@ -6,7 +6,8 @@
 md.transient.requested_outputs=IceVolumeEnum();
 
 md.autodiff.isautodiff=true;
-md=solve(md,TransientSolutionEnum);
+md.verbose=verbose('autodiff',true);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Volume1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Volume2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Volume3'};

Modified: issm/trunk/test/NightlyRun/test302.m
===================================================================
--- issm/trunk/test/NightlyRun/test302.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test302.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=setflowequation(md,'hutter','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test303.m
===================================================================
--- issm/trunk/test/NightlyRun/test303.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test303.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=setflowequation(md,'hutter','../Exp/SquareHalfRight.exp','fill','macayeal');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test304.m
===================================================================
--- issm/trunk/test/NightlyRun/test304.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test304.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test305.m
===================================================================
--- issm/trunk/test/NightlyRun/test305.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test305.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,5,2);
+md=extrude(md,5,2.);
 md=setflowequation(md,'hutter','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test306.m
===================================================================
--- issm/trunk/test/NightlyRun/test306.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test306.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,4,2);
+md=extrude(md,4,2.);
 md=setflowequation(md,'hutter','../Exp/SquareHalfRight.exp','fill','macayeal');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test307.m
===================================================================
--- issm/trunk/test/NightlyRun/test307.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test307.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test308.m
===================================================================
--- issm/trunk/test/NightlyRun/test308.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test308.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'stokes','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test309.m
===================================================================
--- issm/trunk/test/NightlyRun/test309.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test309.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,PrognosticSolutionEnum);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test310.m
===================================================================
--- issm/trunk/test/NightlyRun/test310.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test310.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=meshconvert(md);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
@@ -6,7 +6,7 @@
 md.prognostic.stabilization=3;
 md.prognostic.spcthickness=md.geometry.thickness;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,PrognosticSolutionEnum);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test311.m
===================================================================
--- issm/trunk/test/NightlyRun/test311.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test311.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md=extrude(md,5,0.5);
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,PrognosticSolutionEnum);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test312.m
===================================================================
--- issm/trunk/test/NightlyRun/test312.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test312.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,15 +1,15 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
-md.timestepping.time_step=0;
+md.timestepping.time_step=0.;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,ThermalSolutionEnum);
+md=solve(md,ThermalSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13};
+field_tolerances={1e-13,1e-8};
 field_values={...
 	(md.results.ThermalSolution.Temperature),...
 	(md.results.ThermalSolution.BasalforcingsMeltingRate),...

Modified: issm/trunk/test/NightlyRun/test313.m
===================================================================
--- issm/trunk/test/NightlyRun/test313.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test313.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.verbose=verbose('convergence',true,'solution',true);
@@ -9,7 +9,7 @@
 md.transient.isprognostic=0;
 md.transient.isthermal=1;
 md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature','BasalforcingsMeltingRate'};

Modified: issm/trunk/test/NightlyRun/test314.m
===================================================================
--- issm/trunk/test/NightlyRun/test314.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test314.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=setflowequation(md,'hutter','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};

Modified: issm/trunk/test/NightlyRun/test315.m
===================================================================
--- issm/trunk/test/NightlyRun/test315.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test315.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,18 +1,18 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=extrude(md,5,1.2);
 md=setflowequation(md,'hutter','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
-field_tolerances={1e-13,  1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...,
-						1e-10,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-						1e-10,  1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1',...
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2',...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...,
+	1e-10,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
+	1e-10,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test316.m
===================================================================
--- issm/trunk/test/NightlyRun/test316.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test316.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};

Modified: issm/trunk/test/NightlyRun/test317.m
===================================================================
--- issm/trunk/test/NightlyRun/test317.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test317.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,18 +1,18 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
+field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1',...
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2',...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
 field_tolerances={1e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-09,5e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
+	1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
+	1e-09,5e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test318.m
===================================================================
--- issm/trunk/test/NightlyRun/test318.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test318.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,16 +1,15 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,4,1);
+md=extrude(md,4,1.);
 md=setflowequation(md,'hutter','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
+md=solve(md,SteadystateSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13
-};
+field_tolerances={1e-13,1e-13,1e-10,1e-10,1e-13,1e-11,1e-6};
 field_values={...
 	(md.results.SteadystateSolution.Vx),...
 	(md.results.SteadystateSolution.Vy),...

Modified: issm/trunk/test/NightlyRun/test319.m
===================================================================
--- issm/trunk/test/NightlyRun/test319.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test319.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=setflowequation(md,'macayeal','all');
@@ -6,25 +6,25 @@
 %control parameters
 md.inversion.iscontrol=1;
 md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
+md.inversion.min_parameters=1.*ones(md.mesh.numberofvertices,1);
+md.inversion.max_parameters=200.*ones(md.mesh.numberofvertices,1);
 md.inversion.nsteps=2;
 md.inversion.cost_functions=[103*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
+md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2.*10^-7;
+md.inversion.gradient_scaling=3.*ones(md.inversion.nsteps,1);
 md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_names     ={'Gradient','Misfits','FrictionCoefficient','Pressure','Vel','Vx','Vy'};
 field_tolerances={1e-12,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
 field_values={...
 	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
+	(md.results.DiagnosticSolution.J),...
 	(md.results.DiagnosticSolution.FrictionCoefficient),...
 	(md.results.DiagnosticSolution.Pressure),...
 	(md.results.DiagnosticSolution.Vel),...

Modified: issm/trunk/test/NightlyRun/test320.m
===================================================================
--- issm/trunk/test/NightlyRun/test320.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test320.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,31 +1,31 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 
 %control parameters
 md.inversion.iscontrol=1;
 md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
+md.inversion.min_parameters=1.*ones(md.mesh.numberofvertices,1);
+md.inversion.max_parameters=200.*ones(md.mesh.numberofvertices,1);
 md.inversion.nsteps=2;
 md.inversion.cost_functions=[103*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
+md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2.*10^-7;
+md.inversion.gradient_scaling=3.*ones(md.inversion.nsteps,1);
 md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_names     ={'Gradient','Misfits','FrictionCoefficient','Pressure','Vel','Vx','Vy'};
 field_tolerances={1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12};
 field_values={...
 	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
+	(md.results.DiagnosticSolution.J),...
 	(md.results.DiagnosticSolution.FrictionCoefficient),...
 	(md.results.DiagnosticSolution.Pressure),...
 	(md.results.DiagnosticSolution.Vel),...

Modified: issm/trunk/test/NightlyRun/test321.m
===================================================================
--- issm/trunk/test/NightlyRun/test321.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test321.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,31 +1,31 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 
 %control parameters
 md.inversion.iscontrol=1;
 md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
+md.inversion.min_parameters=1.*ones(md.mesh.numberofvertices,1);
+md.inversion.max_parameters=200.*ones(md.mesh.numberofvertices,1);
 md.inversion.nsteps=2;
 md.inversion.cost_functions=[102*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
+md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2.*10^-7;
+md.inversion.gradient_scaling=3.*ones(md.inversion.nsteps,1);
 md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_names     ={'Gradient','Misfits','FrictionCoefficient','Pressure','Vel','Vx','Vy'};
 field_tolerances={1e-08,1e-07,1e-10,1e-10,1e-09,1e-09,1e-09};
 field_values={...
 	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
+	(md.results.DiagnosticSolution.J),...
 	(md.results.DiagnosticSolution.FrictionCoefficient),...
 	(md.results.DiagnosticSolution.Pressure),...
 	(md.results.DiagnosticSolution.Vel),...

Modified: issm/trunk/test/NightlyRun/test322.m
===================================================================
--- issm/trunk/test/NightlyRun/test322.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test322.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,31 +1,31 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'stokes','all');
 
 %control parameters
 md.inversion.iscontrol=1;
 md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
+md.inversion.min_parameters=1.*ones(md.mesh.numberofvertices,1);
+md.inversion.max_parameters=200.*ones(md.mesh.numberofvertices,1);
 md.inversion.nsteps=2;
 md.inversion.cost_functions=[104*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
+md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2.*10^-7;
+md.inversion.gradient_scaling=3.*ones(md.inversion.nsteps,1);
 md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_names     ={'Gradient','Misfits','FrictionCoefficient','Pressure','Vel','Vx','Vy'};
 field_tolerances={1e-06,1e-08,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09};
 field_values={...
 	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
+	(md.results.DiagnosticSolution.J),...
 	(md.results.DiagnosticSolution.FrictionCoefficient),...
 	(md.results.DiagnosticSolution.Pressure),...
 	(md.results.DiagnosticSolution.Vel),...

Modified: issm/trunk/test/NightlyRun/test323.m
===================================================================
--- issm/trunk/test/NightlyRun/test323.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test323.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.timestepping.time_adapt=1;
-md.timestepping.final_time=600;
-md=solve(md,TransientSolutionEnum);
+md.timestepping.final_time=600.;
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};

Modified: issm/trunk/test/NightlyRun/test324.m
===================================================================
--- issm/trunk/test/NightlyRun/test324.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test324.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,20 +1,20 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=extrude(md,5,1.2);
 md=setflowequation(md,'hutter','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.timestepping.time_adapt=1;
-md.timestepping.final_time=500;
-md=solve(md,TransientSolutionEnum);
+md.timestepping.final_time=500.;
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2'};
-					   %'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
+field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1',...
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2'};
+	%'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','BasalforcingsMeltingRate3'};
 field_tolerances={1e-13,  1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...,
-						5*1e-11,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
-						1e-10,  1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+	5*1e-11,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
+	1e-10,  1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test325.m
===================================================================
--- issm/trunk/test/NightlyRun/test325.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test325.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,12 +1,12 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
-md.timestepping.time_step=0;
+md.timestepping.time_step=0.;
 md.cluster=generic('name',oshostname(),'np',3);
 md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md=solve(md,EnthalpySolutionEnum);
+md=solve(md,EnthalpySolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Enthalpy','Waterfraction','Temperature'};

Modified: issm/trunk/test/NightlyRun/test326.m
===================================================================
--- issm/trunk/test/NightlyRun/test326.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test326.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
@@ -10,7 +10,7 @@
 md.transient.isthermal=1;
 md.transient.isgroundingline=0;
 md.thermal.isenthalpy=1;
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Enthalpy1','Waterfraction1','Temperature1',...

Modified: issm/trunk/test/NightlyRun/test327.m
===================================================================
--- issm/trunk/test/NightlyRun/test327.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test327.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,23 +1,23 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md.initialization.temperature(:)=272;
-md.thermal.spctemperature(find(md.mesh.vertexonsurface))=272;
+md.initialization.temperature(:)=272.;
+md.thermal.spctemperature(find(md.mesh.vertexonsurface))=272.;
 md.thermal.isenthalpy=1;
-md.basalforcings.geothermalflux(:)=5;
-md=solve(md,TransientSolutionEnum);
+md.basalforcings.geothermalflux(:)=5.;
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','Enthalpy1','Waterfraction1', ...
-				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2', ...
-					   'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3'};
+field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','Enthalpy1','Waterfraction1',...
+	'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','Enthalpy2','Waterfraction2',...
+	'Vx3','Vy3','Vz3','Vel3','Pressure3','Bed3','Surface3','Thickness3','Temperature3','Enthalpy3','Waterfraction3'};
 field_tolerances={1e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-09,5e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
+	1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
+	1e-09,5e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test328.m
===================================================================
--- issm/trunk/test/NightlyRun/test328.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test328.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
 md=setflowequation(md,'macayeal','all');
@@ -11,8 +11,17 @@
 md.surfaceforcings.b_neg=250. + 0.000051*md.mesh.x - 0.00011*md.mesh.y;
 md.surfaceforcings.hc=(md.surfaceforcings.a_pos-md.surfaceforcings.a_neg)./(md.surfaceforcings.b_neg-md.surfaceforcings.b_pos);
 md.transient.requested_outputs=TotalSmbEnum();
+md.surfaceforcings.href=md.geometry.surface;
+for i=1:size(md.surfaceforcings.hc),
+	if md.geometry.surface(i)<md.surfaceforcings.hc(i)
+		smbref(i)=md.surfaceforcings.a_neg(i)+md.surfaceforcings.b_neg(i)*md.geometry.surface(i);
+	else
+		smbref(i)=md.surfaceforcings.a_pos(i)+md.surfaceforcings.b_pos(i)*md.geometry.surface(i);
+	end
+end
+md.surfaceforcings.smbref=smbref';
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Bed1','Surface1','Thickness1','SMB1','TotalSmb1','Vx2','Vy2','Vel2','Bed2','Surface2','Thickness2','SMB2','TotalSmb2','Vx3','Vy3','Vel3','Bed3','Surface3','Thickness3','SMB3','TotalSmb3'};

Modified: issm/trunk/test/NightlyRun/test329.m
===================================================================
--- issm/trunk/test/NightlyRun/test329.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test329.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'','');
 md=parameterize(md,'../Par/SquareSheetConstrained.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.surfaceforcings.issmbgradients=1;
 md.surfaceforcings.smb_pos_max=5000. - 0.00005*md.mesh.x + 0.0001*md.mesh.y;
@@ -11,16 +11,24 @@
 md.surfaceforcings.a_neg=-20000. - 0.00005*md.mesh.x + 0.0001*md.mesh.y;
 md.surfaceforcings.b_neg=250. + 0.000051*md.mesh.x - 0.00011*md.mesh.y;
 md.surfaceforcings.hc=(md.surfaceforcings.a_pos-md.surfaceforcings.a_neg)./(md.surfaceforcings.b_neg-md.surfaceforcings.b_pos);
+md.surfaceforcings.href=md.geometry.surface;
+for i=1:size(md.surfaceforcings.hc),
+	if md.geometry.surface(i)<md.surfaceforcings.hc(i)
+		smbref(i)=md.surfaceforcings.a_neg(i)+md.surfaceforcings.b_neg(i)*md.geometry.surface(i);
+	else
+		smbref(i)=md.surfaceforcings.a_pos(i)+md.surfaceforcings.b_pos(i)*md.geometry.surface(i);
+	end
+end
+md.surfaceforcings.smbref=smbref';
 md.transient.requested_outputs=TotalSmbEnum();
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Bed1','Surface1','Thickness1','Temperature1','SMB1','TotalSmb1','Vx2','Vy2','Vz2','Vel2','Bed2','Surface2','Thickness2','Temperature2','SMB2','TotalSmb1','Vx3','Vy3','Vz3','Vel3','Bed3','Surface3','Thickness3','Temperature3','SMB3','TotalSmb1'};
 field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
-						1e-09,5e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
-
+	1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10,...
+	1e-09,5e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test401.m
===================================================================
--- issm/trunk/test/NightlyRun/test401.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test401.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test402.m
===================================================================
--- issm/trunk/test/NightlyRun/test402.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test402.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,4,1);
+md=extrude(md,4,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test403.m
===================================================================
--- issm/trunk/test/NightlyRun/test403.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test403.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
+md=extrude(md,5,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test404.m
===================================================================
--- issm/trunk/test/NightlyRun/test404.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test404.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'stokes','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test405.m
===================================================================
--- issm/trunk/test/NightlyRun/test405.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test405.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
+md=extrude(md,5,1.);
 md=setflowequation(md,'macayeal','../Exp/SquareHalfRight.exp','fill','pattyn','coupling','penalties');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test406.m
===================================================================
--- issm/trunk/test/NightlyRun/test406.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test406.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,15 +1,15 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,4,1);
+md=extrude(md,4,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.timestepping.time_step=0;
-md=solve(md,ThermalSolutionEnum);
+md.timestepping.time_step=0.;
+md=solve(md,ThermalSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-13,1e-13};
+field_tolerances={1e-13,1e-5};
 field_values={...
 	(md.results.ThermalSolution.Temperature),...
 	(md.results.ThermalSolution.BasalforcingsMeltingRate),...

Modified: issm/trunk/test/NightlyRun/test407.m
===================================================================
--- issm/trunk/test/NightlyRun/test407.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test407.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,14 +1,14 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,4,1);
+md=extrude(md,4,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.transient.isdiagnostic=0;
 md.transient.isprognostic=0;
 md.transient.isthermal=1;
 md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature','BasalforcingsMeltingRate'};

Modified: issm/trunk/test/NightlyRun/test408.m
===================================================================
--- issm/trunk/test/NightlyRun/test408.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test408.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'};

Modified: issm/trunk/test/NightlyRun/test409.m
===================================================================
--- issm/trunk/test/NightlyRun/test409.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test409.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','../Exp/SquareHalfRight.exp','fill','pattyn','coupling','penalties');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...

Modified: issm/trunk/test/NightlyRun/test410.m
===================================================================
--- issm/trunk/test/NightlyRun/test410.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test410.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,15 +1,15 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
+md=solve(md,SteadystateSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-10,1e-10,1e-09,1e-10,1e-13,1e-10,1e-06};
+field_tolerances={1e-09,1e-09,1e-09,1e-10,1e-13,1e-10,1e-06};
 field_values={...
 	(md.results.SteadystateSolution.Vx),...
 	(md.results.SteadystateSolution.Vy),...

Modified: issm/trunk/test/NightlyRun/test411.m
===================================================================
--- issm/trunk/test/NightlyRun/test411.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test411.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
 md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
+md=solve(md,SteadystateSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};

Modified: issm/trunk/test/NightlyRun/test412.m
===================================================================
--- issm/trunk/test/NightlyRun/test412.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test412.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',300000);
+md=triangle(model(),'../Exp/Square.exp',300000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
@@ -32,7 +32,7 @@
 md.diagnostic.reltol=10^-5; %tighten for qmu analysese
 
 %solve
-md=solve(md,DiagnosticSolutionEnum,'overwrite','y');
+md=solve(md,DiagnosticSolutionEnum(),'overwrite','y');
 
 %Fields and tolerances to track changes
 md.qmu.results=md.results.dakota;

Modified: issm/trunk/test/NightlyRun/test413.m
===================================================================
--- issm/trunk/test/NightlyRun/test413.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test413.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
@@ -33,7 +33,7 @@
 md.qmu.isdakota=1;
 
 %solve
-md=solve(md,DiagnosticSolutionEnum,'overwrite','y');
+md=solve(md,DiagnosticSolutionEnum(),'overwrite','y');
 
 %Fields and tolerances to track changes
 md.qmu.results=md.results.dakota;

Modified: issm/trunk/test/NightlyRun/test414.m
===================================================================
--- issm/trunk/test/NightlyRun/test414.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test414.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
@@ -47,7 +47,7 @@
 md.diagnostic.reltol=10^-5; %tighten for qmu analyses
 
 %solve
-md=solve(md,DiagnosticSolutionEnum,'overwrite','y');
+md=solve(md,DiagnosticSolutionEnum(),'overwrite','y');
 md.qmu.results=md.results.dakota;
 
 %Fields and tolerances to track changes

Modified: issm/trunk/test/NightlyRun/test415.m
===================================================================
--- issm/trunk/test/NightlyRun/test415.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test415.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,29 +1,29 @@
-md=triangle(model,'../Exp/Square.exp',170000);
+md=triangle(model(),'../Exp/Square.exp',170000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 
 %control parameters
 md.inversion.iscontrol=1;
 md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
+md.inversion.min_parameters=1.*ones(md.mesh.numberofvertices,1);
+md.inversion.max_parameters=200.*ones(md.mesh.numberofvertices,1);
 md.inversion.nsteps=2;
 md.inversion.cost_functions=[103*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
+md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2.*10^-7;
+md.inversion.gradient_scaling=3.*ones(md.inversion.nsteps,1);
 md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.timestepping.time_step=0;
+md.timestepping.time_step=0.;
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,SteadystateSolutionEnum);
+md=solve(md,SteadystateSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy' 'Vz' 'Temperature' 'BasalforcingsMeltingRate'};
-field_tolerances={1e-10,1e-10,1e-11,1e-13,1e-10,1e-09,1e-10,1e-8,1e-09,1e-6};
+field_names     ={'Gradient','Misfits','FrictionCoefficient','Pressure','Vel','Vx','Vy','Vz','Temperature','BasalforcingsMeltingRate'};
+field_tolerances={1e-10,1e-9,1e-10,1e-13,1e-10,1e-09,1e-10,1e-8,1e-09,1e-6};
 field_values={...
 	(md.results.SteadystateSolution.Gradient1),...
 	md.results.SteadystateSolution.J,...

Modified: issm/trunk/test/NightlyRun/test416.m
===================================================================
--- issm/trunk/test/NightlyRun/test416.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test416.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,28 +1,28 @@
-md=triangle(model,'../Exp/Square.exp',170000);
+md=triangle(model(),'../Exp/Square.exp',170000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 
 %control parameters
 md.inversion.iscontrol=1;
 md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
+md.inversion.min_parameters=1.*ones(md.mesh.numberofvertices,1);
+md.inversion.max_parameters=200.*ones(md.mesh.numberofvertices,1);
 md.inversion.nsteps=2;
 md.inversion.cost_functions=[102*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
 md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
+md.inversion.gradient_scaling=3.*ones(md.inversion.nsteps,1);
 md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.3*ones(md.inversion.nsteps,1);
-md.timestepping.time_step=0;
+md.timestepping.time_step=0.;
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,SteadystateSolutionEnum);
+md=solve(md,SteadystateSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy' 'Vz' 'Temperature' 'BasalforcingsMeltingRate'};
+field_names     ={'Gradient','Misfits','FrictionCoefficient','Pressure','Vel','Vx','Vy','Vz','Temperature','BasalforcingsMeltingRate'};
 field_tolerances={1e-08,1e-07,1e-08,1e-08,1e-08,1e-08,1e-08,1e-07,1e-08,1e-05};
 field_values={...
 	(md.results.SteadystateSolution.Gradient1),...

Modified: issm/trunk/test/NightlyRun/test417.m
===================================================================
--- issm/trunk/test/NightlyRun/test417.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test417.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
@@ -49,7 +49,7 @@
 
 md.diagnostic.reltol=10^-5; %tighten for qmu analyses
 
-md=solve(md,DiagnosticSolutionEnum,'overwrite','y');
+md=solve(md,DiagnosticSolutionEnum(),'overwrite','y');
 
 %Fields and tolerances to track changes
 md.qmu.results=md.results.dakota;

Modified: issm/trunk/test/NightlyRun/test418.m
===================================================================
--- issm/trunk/test/NightlyRun/test418.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test418.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,5 +1,5 @@
 %test partitioning, and partition averaging
-md=triangle(model,'../Exp/Square.exp',30000);
+md=triangle(model(),'../Exp/Square.exp',30000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');

Modified: issm/trunk/test/NightlyRun/test419.m
===================================================================
--- issm/trunk/test/NightlyRun/test419.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test419.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
+md=extrude(md,5,1.);
 md=setflowequation(md,'macayeal','../Exp/SquareHalfRight.exp','fill','pattyn');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test420.m
===================================================================
--- issm/trunk/test/NightlyRun/test420.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test420.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/Square.exp',200000);
+md=triangle(model(),'../Exp/Square.exp',200000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
@@ -31,7 +31,7 @@
 md.diagnostic.reltol=10^-5; %tighten for qmu analysese
 
 %solve
-md=solve(md,DiagnosticSolutionEnum,'overwrite','y');
+md=solve(md,DiagnosticSolutionEnum(),'overwrite','y');
 md.qmu.results=md.results.dakota;
 
 %test on thickness

Modified: issm/trunk/test/NightlyRun/test421.m
===================================================================
--- issm/trunk/test/NightlyRun/test421.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test421.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
+md=extrude(md,5,1.);
 md=setflowequation(md,'stokes','../Exp/SquareHalfRight.exp','fill','pattyn');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test422.m
===================================================================
--- issm/trunk/test/NightlyRun/test422.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test422.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
+md=extrude(md,5,1.);
 md=setflowequation(md,'stokes','../Exp/SquareHalfRight.exp','fill','macayeal');
 md.cluster=generic('name',oshostname(),'np',3);
 md.diagnostic.reltol=0.4;
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test423.m
===================================================================
--- issm/trunk/test/NightlyRun/test423.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test423.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,13 +1,13 @@
-radius=1e6;
-shelfextent=2e5;
+radius=1.e6;
+shelfextent=2.e5;
 
-md=roundmesh(model,radius,50000);
+md=roundmesh(model(),radius,50000.);
 %fix center node to 0,0
 rad=sqrt(md.mesh.x.^2+md.mesh.y.^2);
 pos=find(rad==min(rad));
-md.mesh.x(pos)=0; md.mesh.y(pos)=0; %the closest node to the center is changed to be exactly at the center
-xelem=md.mesh.x(md.mesh.elements)*[1;1;1]/3;
-yelem=md.mesh.y(md.mesh.elements)*[1;1;1]/3;
+md.mesh.x(pos)=0.; md.mesh.y(pos)=0.; %the closest node to the center is changed to be exactly at the center
+xelem=md.mesh.x(md.mesh.elements)*[1;1;1]/3.;
+yelem=md.mesh.y(md.mesh.elements)*[1;1;1]/3.;
 rad=sqrt(xelem.^2+yelem.^2);
 flags=zeros(md.mesh.numberofelements,1);
 pos=find(rad>=(radius-shelfextent));
@@ -24,11 +24,11 @@
 
 %test different grounding line dynamics.
 md.groundingline.migration='AgressiveMigration';
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 element_on_iceshelf_agressive=(md.results.TransientSolution.MaskElementonfloatingice);
 
 md.groundingline.migration='SoftMigration';
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 element_on_iceshelf_soft=(md.results.TransientSolution.MaskElementonfloatingice);
 
 %Fields and tolerances to track changes

Modified: issm/trunk/test/NightlyRun/test424.m
===================================================================
--- issm/trunk/test/NightlyRun/test424.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test424.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,21 +1,20 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
-md.initialization.vx(:)=0;
-md.initialization.vy(:)=0;
-md.initialization.vel(:)=0;
-md.geometry.bed=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.bathymetry=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.thickness(:)=1000;
+md.initialization.vx(:)=0.;
+md.initialization.vy(:)=0.;
+md.geometry.bed=-700.-abs(md.mesh.y-500000.)/1000.;
+md.geometry.bathymetry=-700.-abs(md.mesh.y-500000.)/1000.;
+md.geometry.thickness(:)=1000.;
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
-md.surfaceforcings.mass_balance(:)=100;
+md.surfaceforcings.mass_balance(:)=100.;
 md.transient.isdiagnostic=0;
 md.transient.isgroundingline=1;
 md.groundingline.migration='AgressiveMigration';
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Bed1','Surface1','Thickness1','Floatingice1',...

Modified: issm/trunk/test/NightlyRun/test425.m
===================================================================
--- issm/trunk/test/NightlyRun/test425.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test425.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,21 +1,20 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
-md.initialization.vx(:)=0;
-md.initialization.vy(:)=0;
-md.initialization.vel(:)=0;
-md.geometry.bed=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.bathymetry=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.thickness(:)=1300;
+md.initialization.vx(:)=0.;
+md.initialization.vy(:)=0.;
+md.geometry.bed=-700.-abs(md.mesh.y-500000.)/1000.;
+md.geometry.bathymetry=-700.-abs(md.mesh.y-500000.)/1000.;
+md.geometry.thickness(:)=1300.;
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
-md.surfaceforcings.mass_balance(:)=-150;
+md.surfaceforcings.mass_balance(:)=-150.;
 md.transient.isdiagnostic=0;
 md.transient.isgroundingline=1;
 md.groundingline.migration='SoftMigration';
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Bed1','Surface1','Thickness1','Floatingice1',...

Modified: issm/trunk/test/NightlyRun/test426.m
===================================================================
--- issm/trunk/test/NightlyRun/test426.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test426.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,30 +1,28 @@
-md=triangle(model,'../Exp/Square.exp',350000);
+md=triangle(model(),'../Exp/Square.exp',350000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md.initialization.vx(:)=0;
-md.initialization.vy(:)=0;
-md.initialization.vel(:)=0;
-md.geometry.bed=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.bathymetry=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.thickness(:)=1000;
+md.initialization.vx(:)=0.;
+md.initialization.vy(:)=0.;
+md.geometry.bed=-700.-abs(md.mesh.y-500000.)/1000.;
+md.geometry.bathymetry=-700.-abs(md.mesh.y-500000.)/1000.;
+md.geometry.thickness(:)=1000.;
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
-md.surfaceforcings.mass_balance(:)=100;
-md=extrude(md,3,1);
+md.surfaceforcings.mass_balance(:)=100.;
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
-
 md.transient.isdiagnostic=0;
 md.transient.isgroundingline=1;
 md.groundingline.migration='AgressiveMigration';
 md.cluster=generic('name',oshostname(),'np',3);
 
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Bed1','Surface1','Thickness1','Floatingice1',...
 	'Bed2','Surface2','Thickness2','Floatingice2',...
 	'Bed3','Surface3','Thickness3','Floatingice3'};
 field_tolerances={1e-13,1e-13,1e-13,1e-13,...
-	1e-11,1e-11,1e-11,1e-13,...
+	1e-11,1e-10,1e-11,1e-13,...
 	1e-10,1e-10,1e-10,1e-13};
 field_values={...
 	(md.results.TransientSolution(1).Bed),...

Modified: issm/trunk/test/NightlyRun/test427.m
===================================================================
--- issm/trunk/test/NightlyRun/test427.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test427.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,22 +1,21 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md.initialization.vx(:)=0;
-md.initialization.vy(:)=0;
-md.initialization.vel(:)=0;
-md.geometry.bed=-700-abs(md.mesh.y-500000)/1000;
-md.geometry.bathymetry=-700-abs(md.mesh.y-500000)/1000;
+md.initialization.vx(:)=0.;
+md.initialization.vy(:)=0.;
+md.geometry.bed=-700.-abs(md.mesh.y-500000.)/1000.;
+md.geometry.bathymetry=-700.-abs(md.mesh.y-500000.)/1000.;
 md.geometry.thickness(:)=1300;
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
 md=setflowequation(md,'macayeal','all');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 
 md.surfaceforcings.mass_balance(:)=-150;
 md.transient.isdiagnostic=0;
 md.transient.isgroundingline=1;
 md.groundingline.migration='SoftMigration';
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Bed1','Surface1','Thickness1','Floatingice1',...

Modified: issm/trunk/test/NightlyRun/test428.m
===================================================================
--- issm/trunk/test/NightlyRun/test428.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test428.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
 md=setflowequation(md,'macayeal','all');
 md.diagnostic.isnewton=1;
 md.diagnostic.restol=0.0001;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test429.m
===================================================================
--- issm/trunk/test/NightlyRun/test429.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test429.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,12 +1,12 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,5,1);
+md=extrude(md,5,1.);
 md=setflowequation(md,'pattyn','all');
 md.diagnostic.isnewton=1;
 md.diagnostic.restol=0.0001;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test430.m
===================================================================
--- issm/trunk/test/NightlyRun/test430.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test430.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,12 +1,12 @@
-md=triangle(model,'../Exp/Square.exp',180000);
+md=triangle(model(),'../Exp/Square.exp',180000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'stokes','all');
 md.diagnostic.isnewton=1;
 md.diagnostic.restol=0.0001;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test431.m
===================================================================
--- issm/trunk/test/NightlyRun/test431.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test431.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,13 +1,13 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.timestepping.time_step=0;
+md.timestepping.time_step=0.;
 md.thermal.isenthalpy=1;
 md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md=solve(md,SteadystateSolutionEnum);
+md=solve(md,SteadystateSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','Water fraction','Enthalpy'};

Modified: issm/trunk/test/NightlyRun/test432.m
===================================================================
--- issm/trunk/test/NightlyRun/test432.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test432.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,13 +1,13 @@
-md=triangle(model,'../Exp/Square.exp',150000);
+md=triangle(model(),'../Exp/Square.exp',150000.);
 md=setmask(md,'../Exp/SquareShelf.exp','');
 md=parameterize(md,'../Par/SquareSheetShelf.par');
-md=extrude(md,3,2);
+md=extrude(md,3,2.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.timestepping.time_step=0;
+md.timestepping.time_step=0.;
 md.thermal.isenthalpy=1;
 md.initialization.waterfraction=zeros(md.mesh.numberofvertices,1);
-md=solve(md,SteadystateSolutionEnum);
+md=solve(md,SteadystateSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','Water fraction','Enthalpy'};

Modified: issm/trunk/test/NightlyRun/test501.m
===================================================================
--- issm/trunk/test/NightlyRun/test501.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test501.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
+md=triangle(model(),'../Exp/Pig.exp',20000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test502.m
===================================================================
--- issm/trunk/test/NightlyRun/test502.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test502.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
+md=triangle(model(),'../Exp/Pig.exp',20000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
 md=extrude(md,3,0.9);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test503.m
===================================================================
--- issm/trunk/test/NightlyRun/test503.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test503.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
+md=triangle(model(),'../Exp/Pig.exp',20000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
 md=extrude(md,3,0.9);
 md=setflowequation(md,'stokes','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure'};

Modified: issm/trunk/test/NightlyRun/test504.m
===================================================================
--- issm/trunk/test/NightlyRun/test504.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test504.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
+md=triangle(model(),'../Exp/Pig.exp',20000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2'};

Modified: issm/trunk/test/NightlyRun/test505.m
===================================================================
--- issm/trunk/test/NightlyRun/test505.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test505.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,15 +1,16 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
+md=triangle(model(),'../Exp/Pig.exp',30000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
 				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2'};
-field_tolerances={1e-12,1e-12,1e-12,1e-12,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-12,1e-12,1e-12,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
+field_tolerances={1e-12,1e-12,1e-10,1e-12,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,...
+						1e-13,1e-12,1e-10,1e-12,1e-13,1e-11,1e-11,1e-12,1e-11,1e-8};
 field_values={...
 	(md.results.TransientSolution(1).Vx),...
 	(md.results.TransientSolution(1).Vy),...

Modified: issm/trunk/test/NightlyRun/test506.m
===================================================================
--- issm/trunk/test/NightlyRun/test506.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test506.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
+md=triangle(model(),'../Exp/Pig.exp',30000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,2,1);
+md=extrude(md,2,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...

Modified: issm/trunk/test/NightlyRun/test507.m
===================================================================
--- issm/trunk/test/NightlyRun/test507.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test507.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,13 +1,12 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
+md=triangle(model(),'../Exp/Pig.exp',30000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,2,1);
+md=extrude(md,2,1.);
 md=setflowequation(md,'stokes','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
-%The thickness wants to be lower than 1 so we contrain it to 1
 field_names     ={'Vx1','Vy1','Vz1','Vel1','Pressure1','Bed1','Surface1','Thickness1','Temperature1','BasalforcingsMeltingRate1', ...
 				      'Vx2','Vy2','Vz2','Vel2','Pressure2','Bed2','Surface2','Thickness2','Temperature2','BasalforcingsMeltingRate2'};
 field_tolerances={1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-06,1e-06,1e-06,1e-06,1e-06,1e-06,1e-06,1e-06,1e-06,1e-06};

Modified: issm/trunk/test/NightlyRun/test508.m
===================================================================
--- issm/trunk/test/NightlyRun/test508.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test508.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,16 +1,15 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
+md=triangle(model(),'../Exp/Pig.exp',30000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
 md=extrude(md,4,1.1);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
+md.timestepping.time_step=0.;
+md=solve(md,SteadystateSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-08
-};
+field_tolerances={1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-08};
 field_values={...
 	(md.results.SteadystateSolution.Vx),...
 	(md.results.SteadystateSolution.Vy),...

Modified: issm/trunk/test/NightlyRun/test509.m
===================================================================
--- issm/trunk/test/NightlyRun/test509.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test509.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
+md=triangle(model(),'../Exp/Pig.exp',30000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
+md.timestepping.time_step=0.;
+md=solve(md,SteadystateSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};

Modified: issm/trunk/test/NightlyRun/test510.m
===================================================================
--- issm/trunk/test/NightlyRun/test510.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test510.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,16 +1,15 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
+md=triangle(model(),'../Exp/Pig.exp',20000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,2,1);
+md=extrude(md,2,1.);
 md=setflowequation(md,'stokes','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md.timestepping.time_step=0;
-md=solve(md,SteadystateSolutionEnum);
+md.timestepping.time_step=0.;
+md=solve(md,SteadystateSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Vx','Vy','Vz','Vel','Pressure','Temperature','BasalforcingsMeltingRate'};
-field_tolerances={1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-06
-};
+field_tolerances={1e-08,1e-08,1e-08,1e-08,1e-08,1e-08,1e-06};
 field_values={...
 	(md.results.SteadystateSolution.Vx),...
 	(md.results.SteadystateSolution.Vy),...

Modified: issm/trunk/test/NightlyRun/test511.m
===================================================================
--- issm/trunk/test/NightlyRun/test511.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test511.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,36 +1,36 @@
-md=triangle(model,'../Exp/Pig.exp',10000);
+md=triangle(model(),'../Exp/Pig.exp',10000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
 
 %impose hydrostatic equilibrium (required by Stokes)
 md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness;
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'stokes','all');
 md=extract(md,md.mask.elementonfloatingice);
 
 %control parameters
 md.inversion.iscontrol=1;
 md.inversion.control_parameters={'MaterialsRheologyBbar'};
-md.inversion.min_parameters=10^6*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=2*10^9*ones(md.mesh.numberofvertices,1);
+md.inversion.min_parameters=10.^6*ones(md.mesh.numberofvertices,1);
+md.inversion.max_parameters=2.*10^9*ones(md.mesh.numberofvertices,1);
 md.inversion.nsteps=2;
 md.inversion.cost_functions=101*ones(md.inversion.nsteps,1);
 md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
-md.inversion.gradient_scaling=10^8*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
+md.inversion.gradient_scaling=10.^8*ones(md.inversion.nsteps,1);
+md.inversion.maxiter_per_step=2.*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'MaterialsRheologyB' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_names     ={'Gradient','Misfits','MaterialsRheologyB','Pressure','Vel','Vx','Vy'};
 field_tolerances={1e-11,1e-12,1e-12,1e-09,1e-12,1e-12,1e-12,1e-12,1e-12,1e-12};
 field_values={...
 	(md.results.DiagnosticSolution.Gradient1),...
-	md.results.DiagnosticSolution.J,...
+	(md.results.DiagnosticSolution.J),...
 	(md.results.DiagnosticSolution.MaterialsRheologyB),...
 	(md.results.DiagnosticSolution.Pressure),...
 	(md.results.DiagnosticSolution.Vel),...

Modified: issm/trunk/test/NightlyRun/test512.m
===================================================================
--- issm/trunk/test/NightlyRun/test512.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test512.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,27 +1,27 @@
-md=triangle(model,'../Exp/Pig.exp',20000);
+md=triangle(model(),'../Exp/Pig.exp',20000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 
 %control parameters
 md.inversion.iscontrol=1;
 md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
+md.inversion.min_parameters=1.*ones(md.mesh.numberofvertices,1);
+md.inversion.max_parameters=200.*ones(md.mesh.numberofvertices,1);
 md.inversion.nsteps=2;
 md.inversion.cost_functions=[103*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
+md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2.*10^-7;
+md.inversion.gradient_scaling=3.*ones(md.inversion.nsteps,1);
 md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,DiagnosticSolutionEnum);
+md=solve(md,DiagnosticSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy'};
+field_names     ={'Gradient','Misfits','FrictionCoefficient','Pressure','Vel','Vx','Vy'};
 field_tolerances={1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-11};
 field_values={...
 	(md.results.DiagnosticSolution.Gradient1),...

Modified: issm/trunk/test/NightlyRun/test513.m
===================================================================
--- issm/trunk/test/NightlyRun/test513.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test513.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,29 +1,29 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
+md=triangle(model(),'../Exp/Pig.exp',30000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 
 %control parameters
 md.inversion.iscontrol=1;
 md.inversion.control_parameters={'FrictionCoefficient'};
-md.inversion.min_parameters=1*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=200*ones(md.mesh.numberofvertices,1);
+md.inversion.min_parameters=1.*ones(md.mesh.numberofvertices,1);
+md.inversion.max_parameters=200.*ones(md.mesh.numberofvertices,1);
 md.inversion.nsteps=2;
 md.inversion.cost_functions=[103*ones(md.inversion.nsteps,1)  501*ones(md.inversion.nsteps,1)];
-md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2*10^-7;
-md.inversion.gradient_scaling=3*ones(md.inversion.nsteps,1);
-md.inversion.maxiter_per_step=2*ones(md.inversion.nsteps,1);
+md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,2); md.inversion.cost_functions_coefficients(:,2)=2.*10^-7;
+md.inversion.gradient_scaling=3.*ones(md.inversion.nsteps,1);
+md.inversion.maxiter_per_step=2.*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
 md.inversion.vx_obs=md.initialization.vx; md.inversion.vy_obs=md.initialization.vy;
-md.timestepping.time_step=0;
+md.timestepping.time_step=0.;
 
 md.thermal.penalty_lock=5;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,SteadystateSolutionEnum);
+md=solve(md,SteadystateSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'FrictionCoefficient' 'Pressure' 'Vel' 'Vx' 'Vy' 'Vz' 'Temperature' 'BasalforcingsMeltingRate'};
+field_names     ={'Gradient','Misfits','FrictionCoefficient','Pressure','Vel','Vx','Vy','Vz','Temperature','BasalforcingsMeltingRate'};
 field_tolerances={1e-10,1e-10,1e-10,1e-10,1e-6,1e-6,1e-6,1e-6,1e-6,1e-06};
 field_values={...
 	(md.results.SteadystateSolution.Gradient1),...

Modified: issm/trunk/test/NightlyRun/test514.m
===================================================================
--- issm/trunk/test/NightlyRun/test514.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test514.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,12 +1,12 @@
 %Simple mesh 1
-hVertices=10000*ones(27,1);
-hVertices(1:5)=1000;
-md=bamg(model,'domain','../Exp/Pig.exp','hmax',20000,'hVertices',hVertices,'gradation',3,'geometricalmetric',1);
+hVertices=10000.*ones(27,1);
+hVertices(1:5)=1000.;
+md=bamg(model(),'domain','../Exp/Pig.exp','hmax',20000.,'hVertices',hVertices,'gradation',3.,'geometricalmetric',1);
 x1=md.mesh.x;
 y1=md.mesh.y;
 
 %Simple mesh 2
-md=bamg(model,'domain','../Exp/Pig.exp','hmax',10000);
+md=bamg(model(),'domain','../Exp/Pig.exp','hmax',10000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
 x2=md.mesh.x;
@@ -14,37 +14,37 @@
 
 %refine existing mesh 1
 hessian=ComputeHessian(md.mesh.elements,md.mesh.x,md.mesh.y,md.inversion.vy_obs,'node');
-metric=ComputeMetric(hessian,2/9,1,1000,25*10^3,[]);
+metric=ComputeMetric(hessian,2./9.,1.,1000.,25.*10.^3,[]);
 md.miscellaneous.dummy=metric;
-md2=bamg(md,'metric',md.miscellaneous.dummy,'hmin',1000,'hmax',20000,'gradation',3,'geometricalmetric',1);
+md2=bamg(md,'metric',md.miscellaneous.dummy,'hmin',1000.,'hmax',20000.,'gradation',3.,'geometricalmetric',1);
 x3=md2.mesh.x;
 y3=md2.mesh.y;
 
 %refine existing mesh 2
-md2=bamg(md,'metric',md.miscellaneous.dummy,'hmin',1000,'hmax',20000,'gradation',3,'geometricalmetric',1,'anisomax',1);
+md2=bamg(md,'metric',md.miscellaneous.dummy,'hmin',1000.,'hmax',20000.,'gradation',3.,'geometricalmetric',1,'anisomax',1.);
 x4=md2.mesh.x;
 y4=md2.mesh.y;
 
 %refine existing mesh 3
 hVertices=NaN*ones(md.mesh.numberofvertices,1);
 hVertices(find(md.mesh.vertexonboundary))=500;
-md2=bamg(md,'metric',md.miscellaneous.dummy,'hmin',1000,'hmax',20000,'gradation',3,'geometricalmetric',1,'anisomax',1,'hVertices',hVertices);
+md2=bamg(md,'metric',md.miscellaneous.dummy,'hmin',1000.,'hmax',20000.,'gradation',3.,'geometricalmetric',1,'anisomax',1.,'hVertices',hVertices);
 x5=md2.mesh.x;
 y5=md2.mesh.y;
 
 %refine existing mesh 4
-md2=bamg(md,'field',md.inversion.vy_obs,'hmin',1000,'hmax',20000,'gradation',3,'geometricalmetric',1,'Hessiantype',0,'err',1);
+md2=bamg(md,'field',md.inversion.vy_obs,'hmin',1000.,'hmax',20000.,'gradation',3.,'geometricalmetric',1,'Hessiantype',0,'err',1.);
 x6=md2.mesh.x;
 y6=md2.mesh.y;
 
 %refine existing mesh 5
-md2=bamg(md,'field',[md.inversion.vy_obs md.geometry.thickness],'hmin',1000,'hmax',20000,'gradation',3,'geometricalmetric',1,'Hessiantype',1,'err',[10 100]); 
+md2=bamg(md,'field',[md.inversion.vy_obs md.geometry.thickness],'hmin',1000.,'hmax',20000.,'gradation',3.,'geometricalmetric',1,'Hessiantype',1,'err',[10. 100.]); 
 x7=md2.mesh.x;
 y7=md2.mesh.y;
 
 %Fields and tolerances to track changes
-field_names     ={'x1' 'y1' 'x2' 'y2' 'x3' 'y3' 'x4' 'y4' 'x5' 'y5' 'x6' 'y6'  'x7' 'y7' };
-field_tolerances={1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13 1e-13};
+field_names     ={'x1y1x2y2x3y3x4y4x5y5x6y6'  'x7y7' };
+field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
 field_values={...
 	x1, y1,...
 	y2, y2,...

Modified: issm/trunk/test/NightlyRun/test515.m
===================================================================
--- issm/trunk/test/NightlyRun/test515.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test515.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
+md=triangle(model(),'../Exp/Pig.exp',30000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.thermal.stabilization=2;
 md.cluster=generic('name',oshostname(),'np',3);
@@ -9,7 +9,7 @@
 md.transient.isprognostic=0;
 md.transient.isthermal=1;
 md.transient.isgroundingline=0;
-md=solve(md,TransientSolutionEnum);
+md=solve(md,TransientSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature1','BasalforcingsMeltingRate1', ...

Modified: issm/trunk/test/NightlyRun/test516.m
===================================================================
--- issm/trunk/test/NightlyRun/test516.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test516.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,13 +1,13 @@
-md=triangle(model,'../Exp/Pig.exp',30000);
+md=triangle(model(),'../Exp/Pig.exp',30000.);
 md=setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp');
 md=parameterize(md,'../Par/Pig.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'pattyn','all');
 md.thermal.stabilization=2;
 md.cluster=generic('name',oshostname(),'np',3);
 md.timestepping.time_step=0;
 md.thermal.penalty_threshold=40;
-md=solve(md,ThermalSolutionEnum);
+md=solve(md,ThermalSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Temperature','BasalforcingsMeltingRate'};

Modified: issm/trunk/test/NightlyRun/test601.m
===================================================================
--- issm/trunk/test/NightlyRun/test601.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test601.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,PrognosticSolutionEnum);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test602.m
===================================================================
--- issm/trunk/test/NightlyRun/test602.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test602.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=meshconvert(md);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
@@ -6,7 +6,7 @@
 md.prognostic.stabilization=3;
 md.prognostic.spcthickness=md.geometry.thickness;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,PrognosticSolutionEnum);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test603.m
===================================================================
--- issm/trunk/test/NightlyRun/test603.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test603.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
-md=extrude(md,6,1);
+md=extrude(md,6,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,PrognosticSolutionEnum);
+md=solve(md,PrognosticSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test604.m
===================================================================
--- issm/trunk/test/NightlyRun/test604.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test604.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,SurfaceSlopeSolutionEnum);
+md=solve(md,SurfaceSlopeSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'SurfaceSlopeX','SurfaceSlopeY'};

Modified: issm/trunk/test/NightlyRun/test605.m
===================================================================
--- issm/trunk/test/NightlyRun/test605.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test605.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
 md=extrude(md,5,1.5);
 md=setflowequation(md,'pattyn','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,SurfaceSlopeSolutionEnum);
+md=solve(md,SurfaceSlopeSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'SurfaceSlopeX','SurfaceSlopeY'};

Modified: issm/trunk/test/NightlyRun/test606.m
===================================================================
--- issm/trunk/test/NightlyRun/test606.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test606.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BedSlopeSolutionEnum);
+md=solve(md,BedSlopeSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'BedSlopeX','BedSlopeY'};

Modified: issm/trunk/test/NightlyRun/test607.m
===================================================================
--- issm/trunk/test/NightlyRun/test607.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test607.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
-md=extrude(md,2,1);
+md=extrude(md,2,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BedSlopeSolutionEnum);
+md=solve(md,BedSlopeSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'BedSlopeX','BedSlopeY'};

Modified: issm/trunk/test/NightlyRun/test608.m
===================================================================
--- issm/trunk/test/NightlyRun/test608.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test608.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,9 +1,9 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BalancethicknessSolutionEnum);
+md=solve(md,BalancethicknessSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test609.m
===================================================================
--- issm/trunk/test/NightlyRun/test609.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test609.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=meshconvert(md);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
 md=setflowequation(md,'macayeal','all');
 md.balancethickness.stabilization=3;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BalancethicknessSolutionEnum);
+md=solve(md,BalancethicknessSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test610.m
===================================================================
--- issm/trunk/test/NightlyRun/test610.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test610.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,10 +1,10 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
-md=extrude(md,3,1);
+md=extrude(md,3,1.);
 md=setflowequation(md,'macayeal','all');
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BalancethicknessSolutionEnum);
+md=solve(md,BalancethicknessSolutionEnum());
 
 %Fields and tolerances to track changes
 field_names     ={'Thickness'};

Modified: issm/trunk/test/NightlyRun/test611.m
===================================================================
--- issm/trunk/test/NightlyRun/test611.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test611.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
 md=setflowequation(md,'macayeal','all');
@@ -9,19 +9,19 @@
 md.inversion.iscontrol=1;
 md.inversion.control_parameters={'BalancethicknessThickeningRate'};
 md.inversion.thickness_obs=md.geometry.thickness;
-md.inversion.min_parameters=-50*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=50*ones(md.mesh.numberofvertices,1);
+md.inversion.min_parameters=-50.*ones(md.mesh.numberofvertices,1);
+md.inversion.max_parameters=50.*ones(md.mesh.numberofvertices,1);
 md.inversion.cost_functions=201*ones(md.inversion.nsteps,1);
 md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
-md.inversion.gradient_scaling=10/md.constants.yts*ones(md.inversion.nsteps,1);
+md.inversion.gradient_scaling=10./md.constants.yts*ones(md.inversion.nsteps,1);
 md.inversion.maxiter_per_step=4*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BalancethicknessSolutionEnum);
+md=solve(md,BalancethicknessSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'BalancethicknessThickeningRate' 'Thickness'};
+field_names     ={'Gradient','Misfits','BalancethicknessThickeningRate','Thickness'};
 field_tolerances={1e-12,1e-12,1e-12,1e-12,1e-12,1e-12};
 field_values={...
 	(md.results.BalancethicknessSolution.Gradient1),...

Modified: issm/trunk/test/NightlyRun/test612.m
===================================================================
--- issm/trunk/test/NightlyRun/test612.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test612.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=meshconvert(md);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
@@ -10,19 +10,19 @@
 md.inversion.iscontrol=1;
 md.inversion.control_parameters={'BalancethicknessThickeningRate'};
 md.inversion.thickness_obs=md.geometry.thickness;
-md.inversion.min_parameters=-50*ones(md.mesh.numberofvertices,1);
-md.inversion.max_parameters=50*ones(md.mesh.numberofvertices,1);
+md.inversion.min_parameters=-50.*ones(md.mesh.numberofvertices,1);
+md.inversion.max_parameters=50.*ones(md.mesh.numberofvertices,1);
 md.inversion.cost_functions=201*ones(md.inversion.nsteps,1);
 md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
-md.inversion.gradient_scaling=10/md.constants.yts*ones(md.inversion.nsteps,1);
+md.inversion.gradient_scaling=10./md.constants.yts*ones(md.inversion.nsteps,1);
 md.inversion.maxiter_per_step=4*ones(md.inversion.nsteps,1);
 md.inversion.step_threshold=0.99*ones(md.inversion.nsteps,1);
 
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BalancethicknessSolutionEnum);
+md=solve(md,BalancethicknessSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient' 'Misfits' 'BalancethicknessThickeningRate' 'Thickness'};
+field_names     ={'Gradient','Misfits','BalancethicknessThickeningRate','Thickness'};
 field_tolerances={1e-12,1e-12,1e-12,1e-12,1e-12,1e-12};
 field_values={...
 	(md.results.BalancethicknessSolution.Gradient1),...

Modified: issm/trunk/test/NightlyRun/test613.m
===================================================================
--- issm/trunk/test/NightlyRun/test613.m	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/NightlyRun/test613.m	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,4 +1,4 @@
-md=triangle(model,'../Exp/79North.exp',10000);
+md=triangle(model(),'../Exp/79North.exp',10000.);
 md=meshconvert(md);
 md=setmask(md,'../Exp/79NorthShelf.exp','');
 md=parameterize(md,'../Par/79North.par');
@@ -12,13 +12,12 @@
 %control parameters
 md.inversion.thickness_obs=md.geometry.thickness;
 md.inversion.iscontrol=1;
-md.inversion.thickness_obs=md.geometry.thickness;
 md.inversion.nsteps=2;
-md.inversion.control_parameters={'Vx' 'Vy'};
+md.inversion.control_parameters={'Vx','Vy'};
 md.balancethickness.stabilization=1;
-md.inversion.gradient_scaling=[10/md.constants.yts*ones(md.inversion.nsteps,1) 10/md.constants.yts*ones(md.inversion.nsteps,1)];
-md.inversion.min_parameters=[-2000*ones(md.mesh.numberofvertices,1) -2000*ones(md.mesh.numberofvertices,1)];
-md.inversion.max_parameters=[+2000*ones(md.mesh.numberofvertices,1) +2000*ones(md.mesh.numberofvertices,1)];
+md.inversion.gradient_scaling=[10./md.constants.yts*ones(md.inversion.nsteps,1) 10./md.constants.yts*ones(md.inversion.nsteps,1)];
+md.inversion.min_parameters=[-2000.*ones(md.mesh.numberofvertices,1) -2000.*ones(md.mesh.numberofvertices,1)];
+md.inversion.max_parameters=[+2000.*ones(md.mesh.numberofvertices,1) +2000.*ones(md.mesh.numberofvertices,1)];
 md.inversion.cost_functions=201*ones(md.inversion.nsteps,1);
 md.inversion.cost_functions_coefficients=ones(md.mesh.numberofvertices,1);
 md.inversion.maxiter_per_step=4*ones(md.inversion.nsteps,1);
@@ -26,15 +25,15 @@
 
 md.verbose.control=1;
 md.cluster=generic('name',oshostname(),'np',3);
-md=solve(md,BalancethicknessSolutionEnum);
+md=solve(md,BalancethicknessSolutionEnum());
 
 %Fields and tolerances to track changes
-field_names     ={'Gradient1' 'Gradient2' 'Misfits' 'Vx' 'Vy' 'Thickness'};
+field_names     ={'Gradient1','Gradient2','Misfits','Vx','Vy','Thickness'};
 field_tolerances={1e-12,1e-12,1e-12,1e-12,1e-12,1e-12};
 field_values={...
 	(md.results.BalancethicknessSolution.Gradient1),...
 	(md.results.BalancethicknessSolution.Gradient2),...
-	md.results.BalancethicknessSolution.J,...
+	(md.results.BalancethicknessSolution.J),...
 	(md.results.BalancethicknessSolution.Vx),...
 	(md.results.BalancethicknessSolution.Vy),...
 	(md.results.BalancethicknessSolution.Thickness)

Modified: issm/trunk/test/Par/79North.par
===================================================================
--- issm/trunk/test/Par/79North.par	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/Par/79North.par	2012-11-16 16:10:16 UTC (rev 13975)
@@ -8,8 +8,8 @@
 index=transpose(ncread('../Data/79North.nc','index'));
 surface=transpose(ncread('../Data/79North.nc','surface'));
 thickness=transpose(ncread('../Data/79North.nc','thickness'));
-md.initialization.vx       =InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y);
-md.initialization.vy       =InterpFromMeshToMesh2d(index,x,y,vy,md.mesh.x,md.mesh.y);
+md.initialization.vx =InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y);
+md.initialization.vy =InterpFromMeshToMesh2d(index,x,y,vy,md.mesh.x,md.mesh.y);
 md.geometry.surface  =InterpFromMeshToMesh2d(index,x,y,surface,md.mesh.x,md.mesh.y);
 md.geometry.thickness=InterpFromMeshToMesh2d(index,x,y,thickness,md.mesh.x,md.mesh.y);
 md.geometry.bed=md.geometry.surface-md.geometry.thickness;
@@ -22,17 +22,16 @@
 
 %Friction
 pos=find(md.mask.elementonfloatingice);
-md.friction.coefficient=50*ones(md.mesh.numberofvertices,1);
-md.friction.coefficient(md.mesh.elements(pos,:))=0;
+md.friction.coefficient=50.*ones(md.mesh.numberofvertices,1);
+md.friction.coefficient(md.mesh.elements(pos,:))=0.;
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=ones(md.mesh.numberofelements,1);
 
 %Ice shelf melting and surface mass balance 
+pos=find(md.mask.elementonfloatingice);
 md.basalforcings.melting_rate=zeros(md.mesh.numberofvertices,1);
-pos=zeros(md.mesh.numberofvertices,1);
-pos(md.mesh.elements(find(md.mask.elementonfloatingice),:))=1;
-md.basalforcings.melting_rate(find(pos))=10;
-md.surfaceforcings.mass_balance=15*ones(md.mesh.numberofvertices,1);
+md.basalforcings.melting_rate(md.mesh.elements(pos,:))=10;
+md.surfaceforcings.mass_balance=15.*ones(md.mesh.numberofvertices,1);
 
 %Numerical parameters
 md.diagnostic.viscosity_overshoot=0.3;
@@ -40,8 +39,8 @@
 md.thermal.stabilization=1;
 md.verbose=verbose(0);
 md.settings.waitonlock=30;
-md.timestepping.time_step=1;
-md.timestepping.final_time=3;
+md.timestepping.time_step=1.;
+md.timestepping.final_time=3.;
 md.diagnostic.restol=0.05;
 md.diagnostic.reltol=0.005;
 md.steadystate.reltol=0.005;

Modified: issm/trunk/test/Par/RoundSheetShelf.par
===================================================================
--- issm/trunk/test/Par/RoundSheetShelf.par	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/Par/RoundSheetShelf.par	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,11 +1,11 @@
 %Start defining model parameters here
 
 di=md.materials.rho_ice/md.materials.rho_water;
-rad=1e6;
-shelfextent=2e5;
+rad=1.e6;
+shelfextent=2.e5;
 %Geometry
-hmin=300;
-hmax=1000;
+hmin=300.;
+hmax=1000.;
 radius=sqrt((md.mesh.x).*md.mesh.x+(md.mesh.y).*md.mesh.y);
 ymin=min(radius);
 ymax=max(radius);
@@ -13,42 +13,42 @@
 md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness;
 
 pos=find(md.mask.vertexongroundedice);
-md.geometry.bed(pos)=md.geometry.bed(pos)-300*(radius(pos)-(rad-shelfextent))/(rad-shelfextent);
+md.geometry.bed(pos)=md.geometry.bed(pos)-300.*(radius(pos)-(rad-shelfextent))/(rad-shelfextent);
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
 
 pos=find(radius<200000);
-md.geometry.thickness(pos)=100;
-md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20;
+md.geometry.thickness(pos)=100.;
+md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20.;
 md.geometry.surface(pos)=md.geometry.bed(pos)+md.geometry.thickness(pos);
 
-
-pos=find(md.mesh.x<.2*1e6 & md.mesh.x>-.2*1e6 & md.mesh.y>0);
-md.geometry.thickness(pos)=100;
-md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20;
+pos=find(md.mesh.x<0.2*1.e6 & md.mesh.x>-0.2*1.e6 & md.mesh.y>0.);
+md.geometry.thickness(pos)=100.;
+md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20.;
 md.geometry.surface(pos)=md.geometry.bed(pos)+md.geometry.thickness(pos);
 
-pos=find(md.mesh.x<.1*1e6 & md.mesh.x>-.1*1e6 & md.mesh.y<-.5*1e6 & md.mesh.y>-.6*1e6);
-md.geometry.thickness(pos)=100;
-md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20;
+pos=find(md.mesh.x<0.1*1.e6 & md.mesh.x>-0.1*1.e6 & md.mesh.y<-0.5*1.e6 & md.mesh.y>-0.6*1.e6);
+md.geometry.thickness(pos)=100.;
+md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20.;
 md.geometry.surface(pos)=md.geometry.bed(pos)+md.geometry.thickness(pos);
 
 %plug holes into the ice sheet, to test for grounding line migration. 
 di=md.materials.rho_ice/md.materials.rho_water;
 rad=sqrt(md.mesh.x.^2+md.mesh.y.^2);
-pos=find(rad<200000);
-md.geometry.thickness(pos)=100;
-md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20;
+pos=find(rad<200000.);
+md.geometry.thickness(pos)=100.;
+md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20.;
 md.geometry.surface(pos)=md.geometry.bed(pos)+md.geometry.thickness(pos);
 
-pos=find(md.mesh.x<.2*1e6 & md.mesh.x>-.2*1e6 & md.mesh.y>0);
-md.geometry.thickness(pos)=100;
-md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20;
+pos=find(md.mesh.x<0.2*1.e6 & md.mesh.x>-0.2*1.e6 & md.mesh.y>0.);
+md.geometry.thickness(pos)=100.;
+md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20.;
 md.geometry.surface(pos)=md.geometry.bed(pos)+md.geometry.thickness(pos);
 
-pos=find(md.mesh.x<.1*1e6 & md.mesh.x>-.1*1e6 & md.mesh.y<-.5*1e6 & md.mesh.y>-.6*1e6);
-md.geometry.thickness(pos)=100;
-md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20;
+pos=find(md.mesh.x<0.1*1.e6 & md.mesh.x>-0.1*1.e6 & md.mesh.y<-0.5*1.e6 & md.mesh.y>-0.6*1.e6);
+md.geometry.thickness(pos)=100.;
+md.geometry.bed(pos)=-di*md.geometry.thickness(pos)-20.;
 md.geometry.surface(pos)=md.geometry.bed(pos)+md.geometry.thickness(pos);
+
 %Initial velocity 
 md.initialization.vx=zeros(md.mesh.numberofvertices,1);
 md.initialization.vy=zeros(md.mesh.numberofvertices,1);
@@ -56,19 +56,19 @@
 md.initialization.pressure=zeros(md.mesh.numberofvertices,1);
 
 %Materials
-md.initialization.temperature=(273-20)*ones(md.mesh.numberofvertices,1);
+md.initialization.temperature=(273.-20.)*ones(md.mesh.numberofvertices,1);
 md.materials.rheology_B=paterson(md.initialization.temperature);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
 %Surface mass balance and basal melting
-md.surfaceforcings.mass_balance=-10*ones(md.mesh.numberofvertices,1);
+md.surfaceforcings.mass_balance=-10.*ones(md.mesh.numberofvertices,1);
 md.basalforcings.melting_rate=zeros(md.mesh.numberofvertices,1);
-pos=find(md.mask.vertexonfloatingice);md.basalforcings.melting_rate(pos)=10;
+pos=find(md.mask.vertexonfloatingice);md.basalforcings.melting_rate(pos)=10.;
 md.basalforcings.geothermalflux=ones(md.mesh.numberofvertices,1);
 
 %Friction
 pos=find(md.mask.elementonfloatingice);
-md.friction.coefficient=20*ones(md.mesh.numberofvertices,1);
+md.friction.coefficient=20.*ones(md.mesh.numberofvertices,1);
 md.friction.coefficient(md.mesh.elements(pos,:))=0;
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=ones(md.mesh.numberofelements,1);
@@ -83,13 +83,13 @@
 md.diagnostic.reltol=0.05;
 md.steadystate.reltol=0.05;
 md.diagnostic.abstol=NaN;
-md.timestepping.time_step=5;
-md.timestepping.final_time=5;
+md.timestepping.time_step=5.;
+md.timestepping.final_time=5.;
 
 %bathymetry and grounding line migration:
 md.groundingline.migration='AgressiveMigration';
 md.geometry.bathymetry=md.geometry.bed;
-pos=find(md.mask.vertexonfloatingice); md.geometry.bathymetry(pos)=md.geometry.bed(pos)-900;
+pos=find(md.mask.vertexonfloatingice); md.geometry.bathymetry(pos)=md.geometry.bed(pos)-900.;
 
 %Deal with boundary conditions:
 md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices,1);
@@ -106,7 +106,7 @@
 md.balancethickness.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
 md.prognostic.spcthickness=NaN*ones(md.mesh.numberofvertices,1);
 md.diagnostic.referential=NaN*ones(md.mesh.numberofvertices,6);
-md.thermal.spctemperature=737*ones(md.mesh.numberofvertices,1);
+md.thermal.spctemperature=737.*ones(md.mesh.numberofvertices,1);
 
 %Change name so that no test have the same name
 A=dbstack;

Modified: issm/trunk/test/Par/SquareSheetConstrained.par
===================================================================
--- issm/trunk/test/Par/SquareSheetConstrained.par	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/Par/SquareSheetConstrained.par	2012-11-16 16:10:16 UTC (rev 13975)
@@ -5,8 +5,9 @@
 hmax=1000;
 ymin=min(md.mesh.y);
 ymax=max(md.mesh.y);
+
 md.geometry.thickness=hmax+(hmin-hmax)*(md.mesh.y-ymin)/(ymax-ymin);
-md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness+20;
+md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness+20.;
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
 
 %Initial velocity 
@@ -15,6 +16,7 @@
 vx    = transpose(ncread('../Data/SquareSheetConstrained.nc','vx'));
 vy    = transpose(ncread('../Data/SquareSheetConstrained.nc','vy'));
 index = transpose(ncread('../Data/SquareSheetConstrained.nc','index'));
+
 md.initialization.vx=InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y);
 md.initialization.vy=InterpFromMeshToMesh2d(index,x,y,vy,md.mesh.x,md.mesh.y);
 clear vx vy x y index;
@@ -22,29 +24,29 @@
 md.initialization.pressure=zeros(md.mesh.numberofvertices,1);
 
 %Materials
-md.initialization.temperature=(273-20)*ones(md.mesh.numberofvertices,1);
+md.initialization.temperature=(273.-20.)*ones(md.mesh.numberofvertices,1);
 md.materials.rheology_B=paterson(md.initialization.temperature);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
 %Friction
 pos=find(md.mask.elementonfloatingice);
-md.friction.coefficient=20*ones(md.mesh.numberofvertices,1);
+md.friction.coefficient=20.*ones(md.mesh.numberofvertices,1);
 md.friction.coefficient(md.mesh.elements(pos,:))=0;
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=ones(md.mesh.numberofelements,1);
 
 %Numerical parameters
 md.diagnostic.viscosity_overshoot=0.0;
-md.prognostic.stabilization=1;
-md.thermal.stabilization=1;
+md.prognostic.stabilization=1.;
+md.thermal.stabilization=1.;
 md.verbose=verbose(0);
 md.settings.waitonlock=30;
 md.diagnostic.restol=0.05;
 md.steadystate.reltol=0.05;
 md.diagnostic.reltol=0.05;
 md.diagnostic.abstol=NaN;
-md.timestepping.time_step=1;
-md.timestepping.final_time=3;
+md.timestepping.time_step=1.;
+md.timestepping.final_time=3.;
 
 %Boundary conditions:
 md=SetIceSheetBC(md);

Modified: issm/trunk/test/Par/SquareSheetShelf.par
===================================================================
--- issm/trunk/test/Par/SquareSheetShelf.par	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/Par/SquareSheetShelf.par	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,14 +1,14 @@
 %Start defining model parameters here
 
 %Geometry
-hmin=300;
-hmax=1000;
+hmin=300.;
+hmax=1000.;
 ymin=min(md.mesh.y);
 ymax=max(md.mesh.y);
 md.geometry.thickness=hmax+(hmin-hmax)*(md.mesh.y-ymin)/(ymax-ymin);
 md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness;
 bed_sheet=-md.materials.rho_ice/md.materials.rho_water*(hmax+(hmin-hmax)*(ymax/2-ymin)/(ymax-ymin));
-pos=find(md.mesh.y<=ymax/2);
+pos=find(md.mesh.y<=ymax/2.);
 md.geometry.bed(pos)=bed_sheet;
 md.geometry.surface=md.geometry.bed+md.geometry.thickness;
 
@@ -25,18 +25,18 @@
 md.initialization.pressure=zeros(md.mesh.numberofvertices,1);
 
 %Materials
-md.initialization.temperature=(273-20)*ones(md.mesh.numberofvertices,1);
+md.initialization.temperature=(273.-20.)*ones(md.mesh.numberofvertices,1);
 md.materials.rheology_B=paterson(md.initialization.temperature);
-md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_n=3.*ones(md.mesh.numberofelements,1);
 
 %Accumulation and melting
-md.surfaceforcings.mass_balance=10*ones(md.mesh.numberofvertices,1);
-md.basalforcings.melting_rate=5*ones(md.mesh.numberofvertices,1);
+md.surfaceforcings.mass_balance=10.*ones(md.mesh.numberofvertices,1);
+md.basalforcings.melting_rate=5.*ones(md.mesh.numberofvertices,1);
 
 %Friction
 pos=find(md.mask.elementonfloatingice);
-md.friction.coefficient=20*ones(md.mesh.numberofvertices,1);
-md.friction.coefficient(md.mesh.elements(pos,:))=0;
+md.friction.coefficient=20.*ones(md.mesh.numberofvertices,1);
+md.friction.coefficient(md.mesh.elements(pos,:))=0.;
 md.friction.p=ones(md.mesh.numberofelements,1);
 md.friction.q=ones(md.mesh.numberofelements,1);
 
@@ -50,8 +50,8 @@
 md.steadystate.reltol=0.05;
 md.diagnostic.reltol=0.05;
 md.diagnostic.abstol=NaN;
-md.timestepping.time_step=1;
-md.timestepping.final_time=3;
+md.timestepping.time_step=1.;
+md.timestepping.final_time=3.;
 
 %Deal with boundary conditions:
 md=SetMarineIceSheetBC(md,'../Exp/SquareFront.exp');

Modified: issm/trunk/test/Par/SquareShelfConstrained.py
===================================================================
--- issm/trunk/test/Par/SquareShelfConstrained.py	2012-11-16 16:04:11 UTC (rev 13974)
+++ issm/trunk/test/Par/SquareShelfConstrained.py	2012-11-16 16:10:16 UTC (rev 13975)
@@ -1,7 +1,7 @@
 import os.path
+import netCDF4
+import numpy
 import inspect
-import netCDF4
-from numpy import *
 from verbose import *
 from InterpFromMeshToMesh2d import InterpFromMeshToMesh2d
 from paterson import *
@@ -9,58 +9,62 @@
 
 #Start defining model parameters here
 #Geometry
-hmin = 300.
-hmax = 1000.
-ymin = min(md.mesh.y)
-ymax = max(md.mesh.y)
+hmin=300.
+hmax=1000.
+ymin=numpy.min(md.mesh.y)
+ymax=numpy.max(md.mesh.y)
 
-md.geometry.thickness = hmax+(hmin-hmax)*(md.mesh.y-ymin)/(ymax-ymin)
+md.geometry.thickness=hmax+(hmin-hmax)*(md.mesh.y.reshape(-1,1)-ymin)/(ymax-ymin)
 md.geometry.bed=-md.materials.rho_ice/md.materials.rho_water*md.geometry.thickness
-md.geometry.surface = md.geometry.bed+md.geometry.thickness
+md.geometry.surface=md.geometry.bed+md.geometry.thickness
 
 #Initial velocity 
 f = netCDF4.Dataset('../Data/SquareShelfConstrained.nc','r')
 #Reshape as Rank-1 arrays
-x=reshape(f.variables['x'][:],(-1))
-y=reshape(f.variables['y'][:],(-1))
+x=numpy.reshape(f.variables['x'][:],(-1))
+y=numpy.reshape(f.variables['y'][:],(-1))
 vx=f.variables['vx'][:]
 vy=f.variables['vy'][:]
-#deal with 'F' oriented matlab matrices!
-index=f.variables['index'][:].astype(float)
-index=reshape(index.T,(len(index),3),order='F')
+index=f.variables['index'][:]
 f.close()
 
-[md.initialization.vx] = InterpFromMeshToMesh2d(index, x, y, vx, md.mesh.x, md.mesh.y)
-[md.initialization.vy] = InterpFromMeshToMesh2d(index, x, y, vy, md.mesh.x, md.mesh.y)
-md.initialization.vz = zeros(md.mesh.numberofvertices)
-md.initialization.pressure = zeros(md.mesh.numberofvertices)
+[md.initialization.vx]=InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y)
+[md.initialization.vy]=InterpFromMeshToMesh2d(index,x,y,vy,md.mesh.x,md.mesh.y)
+md.initialization.vz=numpy.zeros((md.mesh.numberofvertices,1))
+md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,1))
+
 #Materials
-md.initialization.temperature = (273.-20)*ones(md.mesh.numberofvertices)
-md.materials.rheology_B = paterson(md.initialization.temperature)
-md.materials.rheology_n = 3.*ones(md.mesh.numberofelements)
+md.initialization.temperature=(273.-20.)*numpy.ones((md.mesh.numberofvertices,1))
+md.materials.rheology_B=paterson(md.initialization.temperature)
+md.materials.rheology_n=3.*numpy.ones((md.mesh.numberofelements,1))
+
 #Surface mass balance and basal melting
-md.surfaceforcings.mass_balance = 10.*ones(md.mesh.numberofvertices)
-md.basalforcings.melting_rate = 5.*ones(md.mesh.numberofvertices)
+md.surfaceforcings.mass_balance=10.*numpy.ones((md.mesh.numberofvertices,1))
+md.basalforcings.melting_rate=5.*numpy.ones((md.mesh.numberofvertices,1))
+
 #Friction
-pos = nonzero(md.mask.elementonfloatingice)
-md.friction.coefficient = 20.*ones(md.mesh.numberofvertices)
-md.friction.coefficient[md.mesh.elements[pos,:].astype(int)-1] =0.
-md.friction.p = ones(md.mesh.numberofelements)
-md.friction.q = ones(md.mesh.numberofelements)
+pos=numpy.nonzero(md.mask.elementonfloatingice)
+md.friction.coefficient=20.*numpy.ones((md.mesh.numberofvertices,1))
+md.friction.coefficient[md.mesh.elements[pos,:].astype(int)-1]=0.
+md.friction.p=numpy.ones((md.mesh.numberofelements,1))
+md.friction.q=numpy.ones((md.mesh.numberofelements,1))
+
 #Numerical parameters
-md.diagnostic.viscosity_overshoot = 0.0
-md.prognostic.stabilization = 1.
-md.thermal.stabilization = 1.
-md.verbose = verbose()
-md.settings.waitonlock = 30.
-md.diagnostic.restol = 0.05
-md.diagnostic.reltol = 0.05
-md.steadystate.reltol = 0.05
-md.diagnostic.abstol = nan
-md.timestepping.time_step = 1.
-md.timestepping.final_time = 3.
+md.diagnostic.viscosity_overshoot=0.0
+md.prognostic.stabilization=1.
+md.thermal.stabilization=1.
+md.verbose = verbose(0)
+md.settings.waitonlock=30.
+md.diagnostic.restol=0.05
+md.diagnostic.reltol=0.05
+md.steadystate.reltol=0.05
+md.diagnostic.abstol=float('nan')
+md.timestepping.time_step=1.
+md.timestepping.final_time=3.
+
 #Deal with boundary conditions:
 md = SetIceShelfBC(md)
+
 #Change name so that no tests have the same name
 if len(inspect.stack()) > 2:
 	md.miscellaneous.name = os.path.basename(inspect.stack()[2][1]).split('.')[0]



More information about the issm-svn mailing list