subroutine initu(kappa,l,jdim,jmax,ndim,n,x,t,io,task,u) c General information: c Template for writing subroutines initu that set the initial c conditions for the unsteady heat conduction in a bar. Follow this c template to create different initial conditions. c Copyright 1996 Leon van Dommelen c Version 1.0 Leon van Dommelen 12/16/96 c Usage information: c Subroutine initu can be called in two different ways depending on c the chosen value of parameter task: c 1. task = 0: c This is the standard call. In this case, initu should store the c correct initial condition for the position (x(j),t(n)) into c u(j,n) for all j = 0, 1, ..., jmax for which 0 <= x(j) <= l. c During such a call, initu may assume that all input parameters c have meaningful values. In particular, initu is allowed to assume c that t(n2) is defined for any time level 0 <= n2 <= n, and that c u(j,n2) is defined for 0 <= n2 < n. c 2. Any other value: c If task is positive, subroutine initu should merely initialize c itself and exit, otherwise it should do nothing at all. c Arguments: c Avoid typos: implicit none c Input: conduction constant (restrictions may be needed): double precision kappa c Input: length of the bar (restrictions may be needed): double precision l c Input: declared maximum mesh point index in arrays x and u: integer jdim c Input: actual maximum mesh point index: integer jmax c Input: declared maximum time level index in arrays t and u: integer ndim c Input: time level to set in array u: integer n c Input: array of the x-positions of the mesh points: double precision x(0:jdim) c Input: array of the mesh times t: double precision t(0:ndim) c Input: I/O unit of an already open output file or zero: integer io c Subroutine initu should only write to this unit if io is positive. c Input: task to perform: integer task c See the usage information above for more information on task. c Input/Output: temperature values: double precision u(0:jdim,0:ndim) c Provided task equals zero, initu must set the values of u(j,n) c for all j = 0, 1, ..., jmax for which 0 <= x(j) <= l. c Subroutine initu is here allowed to assume that all u(j,n2) c are correctly defined for any earlier time level 0 <= n2 < n. c If task is nonzero, u is undefined and should remain untouched. c External variables and info for compiling or changing subroutine initu: 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 Local variables: c An integer to keep track of whether initu has been initialized: integer init c Mesh point index: integer j c *************************************************************** c ****** Declare any local variables that initu needs here ******* c *************************************************************** c Constants defined to make changing precision easier: double precision zero parameter (zero=0.d0) c Data statements: data init/0/ c Executable statements: c Ignore negative tasks completely: if(task.lt.0)return c Initialization during the first time that init_u is called: if(init.eq.0)then c Show which subroutine is being initialized: call cwrite('initu', & 'Initialization of initial data subroutine initu:',io,0) c ******************************************************** c ******** Briefly describe subroutine initu here ******** c ******************************************************** call cwrite('initu', & '- template/init_u.f Copyright 1996 Leon van Dommelen.',io,0) call cwrite('initu', & '*** ERROR: You are using the template subroutine!',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 sanity of some of the arguments: if(jdim.le.0 .or. ndim.lt.0 .or. & jmax.le.0 .or. n.lt.0 .or. & jmax.gt.jdim .or. n.gt.ndim)call fatal('initu', & 'Program error: invalid arguments issued to subroutine out.', & 'Fix the program code.',' ') c Set the initial temperatures: do 100 j=0,jmax if(x(j).lt.zero .or. x(j).gt.l)goto 100 c ************************************************************** c ********* Set the initial temperatures u(j,n) here *********** c ************************************************************** u(j,n)=zero? 100 continue goto 900 c Exit: c Jump here when done: 900 return end