function uexa(x,t,kappa,l,io,task) c General information: c Template for writing functions uexa that return exact solutions c for the unsteady heat conduction in a bar. Follow this template c to create different exact solutions. c Copyright 1996 Leon van Dommelen c Version 1.0 Leon van Dommelen 12/16/96 c Usage information: c Function uexa can be called in three different ways depending on c the chosen value of parameter task: c 1. task = 0: c This is the standard call. In this case, uexa should compute c and return the exact temperature at position (x,t). c During such a call, uexa may assume that all input parameters c have appropriate values. c 2. task = -1: c This is the inquiry call. Function uexa should change the c value of task to reflect uexa's properties. In particular, it c should set task to the sum of: c 1: if the solution is symmetric around the left boundary c 2: if the solution is symmetric around the right boundary c 4: if the solution is antisymmetric around the left boundary c 8: if the solution is antisymmetric around the right boundary c 16: if the solution is periodic c 3. Any other value: c If task is positive, subroutine uexa should merely initialize c itself and exit, otherwise it should do nothing at all. c Arguments: c Avoid typos: implicit none c Input: position x, (0 <= x <= l), at which the temperature is needed: double precision x c Input: time t, (0 <= t), at which the temperature is needed: double precision t c Input: conduction constant (restrictions may be needed): double precision kappa c Input: length of the bar (0 < l): double precision l c Input: I/O unit of an already open output file or zero: integer io c Function uexa should only write to this unit if io is positive. c Input/Output: task to perform: integer task c See the usage information above for more information on task. c Output: The temperature at location x and time t (if task = 0): double precision uexa c If task is nonzero, the returned value for uexa is meaningless. c External variables and info for compiling or changing function uexa: c The following utility routines from ../../../lib/util.f were used: c cwrite(module,text,io,show) writes line "text" to I/O unit c "io" if nonzero, and to the screen if "show" is nonzero. external cwrite c fatal(module,text1,text2,text3) kills the program after a c fatal error, printing the lines "text1", "text2" and "text3". external fatal c rwrite(module,text,val,io,show) writes number "val" and its c description "text" to I/O unit "io" if nonzero, and to the screen c if "show" is nonzero. external rwrite c Local variables: c An integer to keep track of whether uexa has been initialized: integer init c Integers that may be returned during the inquiry call (see above): integer syml,symr,asyml,asymr,perlr parameter (syml=1,symr=2,asyml=4,asymr=8,perlr=16) c *************************************************************** c ****** Declare any local variables that uexa needs here ******* c *************************************************************** c Constants defined to make changing precision easier: double precision zero parameter (zero=0.d0) c Data staments: data init/0/ c Executable statements: c Default value of the temperature: uexa=zero c For task = -1, return the properties of the exact solution: if(task.eq.-1)then c ********************************************************* c ******** Sum the properties of uexa over here ********** c ********************************************************* task=? return endif c Ignore other negative tasks: if(task.lt.0)return c Initialization during the first time that uexa is called: if(init.eq.0)then c Show which function is being initialized: call cwrite('uexa', & 'Initialization of exact solution function uexa:',io,0) c ******************************************************** c ********** Briefly describe function uexa here ********* c ******************************************************** call cwrite('uexa', & '- template/u_exa.f Copyright 1996 Leon van Dommelen.',io,0) call cwrite('uexa', & '*** ERROR: You are using the template function!',io,0) c ********************************************************* c ******* Read in any parameters needed over here ********* c ********************************************************* c All done with the initialization: init=1 endif c Further ignore nonzero tasks: if(task.ne.0)return c Check the arguments: c ***************************************************************** c Remove the next check if your function can handle negative kappa: c ***************************************************************** if(kappa.lt.zero)then call rwrite('uexa', & ' uexa: Heat conduction coefficient kappa',kappa,io,1) call fatal('uexa', & 'The heat conduction coefficient must be positive.',' ',' ') endif c ****************************************************************** c Remove the next check if your function can handle negative length: c ****************************************************************** if(l.le.zero)then call rwrite('uexa',' uexa: Bar length l',l,io,1) call fatal('uexa','The bar length must be positive.',' ',' ') endif c ***************************************************************** c Remove the next check if your function can handle negative times: c ***************************************************************** if(t.lt.zero)then call rwrite('uexa',' uexa: Time t',t,io,1) call fatal('uexa','Negative times are not allowed.',' ',' ') endif c ************************************************************* c Remove the next check if your function can handle x<0 or x>l: c ************************************************************* if(x.lt.zero .or. x.gt.l)then call rwrite('uexa',' uexa: Bar length l',l,io,1) call rwrite('uexa',' uexa: Position x',x,io,1) call fatal('uexa', & 'Position x should be in the range from 0 to l.',' ',' ') endif c Compute the temperature: c **************************************************************** c *********** Compute the exact temperature uexa here ************ c **************************************************************** c Exit: c Jump here when done: 900 return end