subroutine bc2(kappa,l,jdim,jmax,ndim,n,x,t,io,task,u) c General information: c Subroutine to set a homogeneous Neumann (insulated) boundary c condition at the right end of a bar. The boundary condition is c implemented using a mirror point one mesh cell outside the bar. c Copyright 1996 Leon van Dommelen c Version 1.0 Leon van Dommelen 12/16/96 c Usage information: c Subroutine bc2 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. Subroutine bc2 sets u(jmax,n) equal c to u(jmax-2,n). Note that this means that u(jmax-2,n) must c already be defined. c 2. task = -1: c This is the inquiry call. Subroutine bc2 changes the value of c task to 4 to indicate that the right-most mesh point is a mirror c point one mesh-cell length outside the bar. c 3. Any other value: c If task is positive, subroutine bc2 merely initializes c itself and exits, otherwise it does nothing at all. c Arguments: c Avoid typos implicit none c Input: conduction constant: double precision kappa c Input: length of the bar: 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 bc2 only writes 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 Input/Output: temperature values: double precision u(0:jdim,0:ndim) c Provided task equals zero, bc2 sets the value of u(jmax,n) to c u(jmax-2,n), which must be defined before calling bc2. c If task is nonzero, u is ignored. c External variables and info for compiling or changing subroutine bc2: 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 iwrite(module,text,val,io,show) writes integer "val" and its c description "text" to I/O unit "io" if nonzero, and to the screen c if "show" is nonzero. external iwrite c Local variables: c An integer to keep track of whether bc2 has been initialized: integer init c Integer code that indicates a mirror-point type boundary condition: integer mirror parameter (mirror=4) c Data statements: data init/0/ c Executable statements: c For task = -1, return the properties of the boundary condition: if(task.eq.-1)then task=mirror return endif c Ignore other negative tasks: if(task.lt.0)return c Initialization during the first time that bc2 is called: if(init.eq.0)then c Show which subroutine is being initialized: call cwrite('bc2', & 'Initialization of right boundary condition bc2:',io,0) call cwrite('bc2', & '- insulated end condition;',io,0) call cwrite('bc2', & '- implemented using a mirror point;',io,0) call cwrite('bc2', & '- insul_mi/bc_2.f Copyright 1996 Leon van Dommelen.',io,0) 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('bc2', & 'Program error: invalid arguments issued to subroutine bc2.', & 'Fix the program code.',' ') if(jmax.lt.3)then call iwrite('bc2', & ' bc2: Number of mesh intervals jmax',jmax,io,1) call fatal('bc2', & 'Mirror point boundary treatments require jmax > 2.',' ',' ') endif c Set the boundary point: u(jmax,n)=u(jmax-2,n) goto 900 c Exit: c Jump here when done: 900 return end