!/*****************************************************************************/1! *2! * Elmer/Ice, a glaciological add-on to Elmer3! * http://elmerice.elmerfem.org4! *5! *6! * This program is free software; you can redistribute it and/or7! * modify it under the terms of the GNU General Public License8! * as published by the Free Software Foundation; either version 29! * of the License, or (at your option) any later version.10! *11! * This program is distributed in the hope that it will be useful,12! * but WITHOUT ANY WARRANTY; without even the implied warranty of13! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14! * GNU General Public License for more details.15! *16! * You should have received a copy of the GNU General Public License17! * along with this program (in file fem/GPL-2); if not, write to the18! * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,19! * Boston, MA 02110-1301, USA.20! *21! *****************************************************************************/22! ******************************************************************************23! *24! * Authors: F. Gillet-Chaulet (IGE-Grenoble-FR)25! * R. Gladstone (Uni Lapland)26! * Email:27! * Web: http://elmerice.elmerfem.org28! *29! * Original Date:30! * Date modifications:31! *32! *33! *****************************************************************************34!#######################################################################35!#36!# A collection of USER FUNCTIONS to perform variable changes in37!inverse methods; i.e. beta=10^a or beta=a^238!#39!#######################################################################40!# Compute VarOut=10^VarIn41FUNCTION TenPowerA(Model,nodenumber,VarIn) RESULT(VarOut)42USE DefUtils43implicit none44!-----------------45TYPE(Model_t) :: Model46INTEGER :: nodenumber47REAL(kind=dp) :: VarIn,VarOut4849VarOut = 10._dp**(VarIn)5051End FUNCTION TenPowerA52!# Compute DTenPowerA/DA=ln(10)*10^A53!# VarIn=A54FUNCTION TenPowerA_d(Model,nodenumber,VarIn) RESULT(VarOut)55USE DefUtils56implicit none57!-----------------58TYPE(Model_t) :: Model59INTEGER :: nodenumber60REAL(kind=dp) :: VarIn,VarOut6162VarOut = (10.0**(VarIn))*log(10.0)6364End FUNCTION TenPowerA_d65!# Compute DJDA from DJDB if B=10^A: DJDA=DJDB*ln(10)*10^A66!# DJDB=VarIn(1)67!# A=VarIn(2)68FUNCTION Derivative_TenPowerA(Model,nodenumber,VarIn) RESULT(VarOut)69USE DefUtils70implicit none71!-----------------72TYPE(Model_t) :: Model73INTEGER :: nodenumber74REAL(kind=dp) :: VarIn(2),VarOut7576VarOut = VarIn(1)*(10.0**(VarIn(2)))*log(10.0)7778End FUNCTION Derivative_TenPowerA79!# Compute VarOut=Log10(VarIn)80FUNCTION Log10A(Model,nodenumber,VarIn) RESULT(VarOut)81USE DefUtils82implicit none83!-----------------84TYPE(Model_t) :: Model85INTEGER :: nodenumber86REAL(kind=dp) :: VarIn,VarOut8788VarOut=log10(VarIn)8990End FUNCTION Log10A91!# Compute VarOut=VarIn*VarIn92FUNCTION Asquare(Model,nodenumber,VarIn) RESULT(VarOut)93USE DefUtils94implicit none95!-----------------96TYPE(Model_t) :: Model97INTEGER :: nodenumber98REAL(kind=dp) :: VarIn,VarOut99100VarOut = VarIn*VarIn101END FUNCTION Asquare102!# Compute Compute dA^2/dA=2*A103!# VarIn=A104FUNCTION Asquare_d(Model,nodenumber,VarIn) RESULT(VarOut)105USE DefUtils106implicit none107!-----------------108TYPE(Model_t) :: Model109INTEGER :: nodenumber110REAL(kind=dp) :: VarIn,VarOut111112VarOut = 2*VarIn113END FUNCTION Asquare_d114!# Compute DJDA from DJDB if B=A^2: DJDA=DJDB*2A115!# DJDB=VarIn(1)116!# A=VarIn(2)117FUNCTION Derivative_Asquare(Model,nodenumber,VarIn) RESULT(VarOut)118USE DefUtils119implicit none120!-----------------121TYPE(Model_t) :: Model122INTEGER :: nodenumber123REAL(kind=dp) :: VarIn(2),VarOut124125VarOut = 2.0*VarIn(1)*VarIn(2)126127End FUNCTION Derivative_Asquare128!# Compute VarOut=sqrt(VarIn)129FUNCTION SQRTA(Model,nodenumber,VarIn) RESULT(VarOut)130USE DefUtils131implicit none132!-----------------133TYPE(Model_t) :: Model134INTEGER :: nodenumber135REAL(kind=dp) :: VarIn,VarOut136137VarOut = sqrt(VarIn)138END FUNCTION SQRTA139140!# Compute VarOut=10^VarIn, masked141! Input arguments:142! ArgIn(1) VarIn, the variable upon which to operate143! ArgIn(2) mask, a mask variable, typically GroundedMask144FUNCTION TenPowerA_masked(Model,nodenumber,ArgIn) RESULT(VarOut)145USE DefUtils146IMPLICIT none147!-----------------148TYPE(Model_t) :: Model149INTEGER :: nodenumber150REAL(kind=dp) :: ArgIn(2),VarOut151152REAL(kind=dp) :: VarIn,mask153154VarIn = ArgIn(1)155mask = ArgIn(2)156157! Note that the GroundedMask default behaviour is that -1.0 indicates158! floating shelves, 0.0 indicates grounding line nodes and 1.0159! indicates grounded nodes.160IF (mask.LE.0.0_dp) THEN161VarOut = 0.0_dp162ELSE163VarOut = 10._dp**(VarIn)164END IF165END FUNCTION TenPowerA_Masked166167!# Compute DTenPowerA/DA=ln(10)*10^A, masked168! Input arguments:169! ArgIn(1) VarIn, the variable upon which to operate170! ArgIn(2) mask, a mask variable, typically GroundedMask171FUNCTION TenPowerA_d_Masked(Model,nodenumber,ArgIn) RESULT(VarOut)172USE DefUtils173implicit none174!-----------------175TYPE(Model_t) :: Model176INTEGER :: nodenumber177REAL(kind=dp) :: ArgIn(2),VarOut178179REAL(kind=dp) :: VarIn,mask180181VarIn = ArgIn(1)182mask = ArgIn(2)183184IF (mask.LE.0.0_dp) THEN185VarOut = 0.0_dp186ELSE187VarOut = (10.0**(VarIn))*log(10.0)188END IF189190END FUNCTION TenPowerA_d_Masked191192!# This function can be used, for example, when computing193!# viscosity as a function of enhancement factor and an194!# initial guess.195FUNCTION Asquare_Scaled(Model,nodenumber,ArgIn) RESULT(VarOut)196USE DefUtils197implicit none198!-----------------199TYPE(Model_t) :: Model200INTEGER :: nodenumber201REAL(kind=dp) :: ArgIn(2),VarOut202203REAL(kind=dp) :: VarIn204REAL(kind=dp) :: VarScale ! a scaling variable205206VarIn = ArgIn(1)207VarScale = ArgIn(2)208209VarOut = VarIn*VarIn*VarScale210211END FUNCTION Asquare_Scaled212213!# This function can be used, for example, for differentiating214!# by parts the viscosity, when computing viscosity as a215!# function of enhancement factor and an initial guess.216FUNCTION Asquare_d_Scaled(Model,nodenumber,ArgIn) RESULT(VarOut)217USE DefUtils218implicit none219!-----------------220TYPE(Model_t) :: Model221INTEGER :: nodenumber222REAL(kind=dp) :: ArgIn(2),VarOut223224REAL(kind=dp) :: VarIn225REAL(kind=dp) :: VarScale ! a scaling variable226227VarIn = ArgIn(1)228VarScale = ArgIn(2)229230VarOut = 2*VarIn*VarScale231232END FUNCTION Asquare_d_Scaled233234235236