reaction_surf_complex_aux.F90       coverage:  70.00 %func     56.54 %block


     1) module Reaction_Surface_Complexation_Aux_module
     2)   
     3)   use Reaction_Database_Aux_module
     4) 
     5)   use PFLOTRAN_Constants_module
     6) 
     7)   implicit none
     8)   
     9)   private 
    10) 
    11) #include "petsc/finclude/petscsys.h"
    12)   
    13)   PetscInt, parameter, public :: SRFCMPLX_RXN_NULL = 0
    14)   PetscInt, parameter, public :: SRFCMPLX_RXN_EQUILIBRIUM = 1
    15)   PetscInt, parameter, public :: SRFCMPLX_RXN_MULTIRATE_KINETIC = 2
    16)   PetscInt, parameter, public :: SRFCMPLX_RXN_KINETIC = 3
    17) 
    18)   ! surface complexation surface types
    19)   PetscInt, parameter, public :: NULL_SURFACE = 0
    20)   PetscInt, parameter, public :: COLLOID_SURFACE = 1
    21)   PetscInt, parameter, public :: MINERAL_SURFACE = 2
    22)   PetscInt, parameter, public :: ROCK_SURFACE = 3
    23) 
    24)   type, public :: surface_complex_type
    25)     PetscInt :: id
    26)     character(len=MAXWORDLENGTH) :: name
    27)     character(len=MAXWORDLENGTH) :: free_site_name
    28)     PetscReal :: free_site_stoich
    29)     PetscReal :: Z
    30)     PetscReal :: forward_rate
    31)     PetscReal :: backward_rate
    32)     PetscBool :: print_me
    33)     ! pointer that can be used to index the master list
    34)     type(surface_complex_type), pointer :: ptr
    35)     type(database_rxn_type), pointer :: dbaserxn
    36)     type(surface_complex_type), pointer :: next
    37)   end type surface_complex_type
    38) 
    39)   type, public :: surface_complexation_rxn_type
    40)     PetscInt :: id
    41)     PetscInt :: itype
    42)     PetscInt :: free_site_id
    43)     character(len=MAXWORDLENGTH) :: free_site_name
    44)     PetscBool :: free_site_print_me
    45)     PetscBool :: site_density_print_me
    46)     PetscInt :: surface_itype
    47)     PetscInt :: mineral_id
    48)     character(len=MAXWORDLENGTH) :: surface_name
    49)     PetscReal :: site_density ! site density in mol/m^3 bulk
    50)     PetscReal, pointer :: rates(:)
    51)     PetscReal, pointer :: site_fractions(:)
    52)     PetscReal :: kinmr_scale_factor
    53)     type(surface_complex_type), pointer :: complex_list
    54)     type (surface_complexation_rxn_type), pointer :: next
    55)   end type surface_complexation_rxn_type  
    56)   
    57)   type, public :: srfcplx_constraint_type
    58)     ! Any changes here must be incorporated within ReactionProcessConstraint()
    59)     ! where constraints are reordered
    60)     character(len=MAXWORDLENGTH), pointer :: names(:)
    61)     PetscReal, pointer :: constraint_conc(:)
    62)     ! the term basis below indicates that this quantity is calculated
    63)     ! internally in ReactionEquilibrateConstraint.
    64)     PetscReal, pointer :: basis_free_site_conc(:)
    65)   end type srfcplx_constraint_type
    66) 
    67) 
    68)   type, public :: surface_complexation_type
    69) 
    70)     type(surface_complexation_rxn_type), pointer :: rxn_list
    71)     type(surface_complex_type), pointer :: complex_list
    72) 
    73)     ! surface complexes
    74)     PetscInt :: nsrfcplx
    75)     character(len=MAXWORDLENGTH), pointer :: srfcplx_names(:)
    76)     PetscBool, pointer :: srfcplx_print(:)
    77)     PetscInt, pointer :: srfcplxspecid(:,:)
    78)     PetscReal, pointer :: srfcplxstoich(:,:)
    79)     PetscInt, pointer :: srfcplxh2oid(:)
    80)     PetscReal, pointer :: srfcplxh2ostoich(:)
    81)     PetscReal, pointer :: srfcplx_free_site_stoich(:)
    82)     PetscReal, pointer :: srfcplx_logK(:)
    83)     PetscReal, pointer :: srfcplx_logKcoef(:,:)
    84)     PetscReal, pointer :: srfcplx_Z(:)  ! valence
    85)     
    86)     ! surface complexation reaction (general members)
    87)     PetscInt :: nsrfcplxrxn
    88)     character(len=MAXWORDLENGTH), pointer :: srfcplxrxn_site_names(:)
    89)     PetscBool, pointer :: srfcplxrxn_site_print(:)
    90)     PetscBool, pointer :: srfcplxrxn_site_density_print(:)
    91)     PetscInt, pointer :: srfcplxrxn_to_surf(:)
    92)     PetscInt, pointer :: srfcplxrxn_surf_type(:)
    93)     PetscInt, pointer :: srfcplxrxn_to_complex(:,:)
    94)     ! site density in 
    95)     ! (1) mol/m^3 bulk 
    96)     ! (2) mol/m^3 mineral, which * mineral volume fraction = mol/m^3 bulk
    97)     ! (3) mol/kg rock, which * 1-porosity = mol/m^3 bulk
    98)     PetscReal, pointer :: srfcplxrxn_site_density(:) 
    99)     ! this flag indicates that the stoichiometry for free sites in one of the
   100)     ! reactions is not 1, and thus we must use nonlinear iteration to solve
   101)     PetscBool, pointer :: srfcplxrxn_stoich_flag(:)
   102) 
   103)     ! equilibrium
   104)     PetscInt :: neqsrfcplx
   105)     PetscInt :: neqsrfcplxrxn 
   106)     PetscInt, pointer :: eqsrfcplxrxn_to_srfcplxrxn(:)
   107) !geh: will not use for now.  allocate eqsrfcplx_conc to size of total #
   108) !     of surface complexes
   109)     !PetscInt, pointer :: srfcplx_to_eqsrfcplx(:)
   110)     
   111)     ! kinetic
   112)     PetscInt :: nkinsrfcplx
   113)     PetscInt :: nkinsrfcplxrxn
   114)     PetscInt, pointer :: kinsrfcplxrxn_to_srfcplxrxn(:)
   115)     PetscInt, pointer :: kinsrfcplx_to_name(:,:)
   116)     PetscReal, pointer :: kinsrfcplx_forward_rate(:,:)
   117)     PetscReal, pointer :: kinsrfcplx_backward_rate(:,:)  
   118) 
   119)     ! multirate kinetic surface complexation
   120)     PetscInt :: nkinmrsrfcplx
   121)     PetscInt :: nkinmrsrfcplxrxn 
   122)     PetscInt, pointer :: kinmrsrfcplxrxn_to_srfcplxrxn(:)
   123)     ! the zeroth entry of kinmr_nrate will hold the max nrate
   124)     PetscInt, pointer :: kinmr_nrate(:)
   125)     PetscReal, pointer :: kinmr_rate(:,:)
   126)     PetscReal, pointer :: kinmr_frac(:,:)
   127)     
   128)   end type surface_complexation_type
   129) 
   130)   public :: SurfaceComplexationCreate, &
   131)             SurfaceComplexationRxnCreate, &
   132)             SurfaceComplexCreate, &
   133)             SurfaceComplexConstraintCreate, &
   134)             SrfCplxGetSrfCplxCountInRxnType, &
   135)             SrfCplxMapMasterSrfCplxToRxn, &
   136)             SurfaceComplexationDestroy, &
   137)             SurfaceComplexationRxnDestroy, &
   138)             SurfaceComplexDestroy, &
   139)             SurfaceComplexConstraintDestroy
   140)              
   141) contains
   142) 
   143) ! ************************************************************************** !
   144) 
   145) function SurfaceComplexationCreate()
   146)   ! 
   147)   ! Allocate and initialize surface complexation
   148)   ! object
   149)   ! 
   150)   ! Author: Glenn Hammond
   151)   ! Date: 03/13/12
   152)   ! 
   153) 
   154)   use Option_module
   155) 
   156)   implicit none
   157)   
   158)   type(surface_complexation_type), pointer :: SurfaceComplexationCreate
   159)   
   160)   type(surface_complexation_type), pointer :: surface_complexation
   161) 
   162)   allocate(surface_complexation)  
   163) 
   164)   nullify(surface_complexation%rxn_list)
   165)   nullify(surface_complexation%complex_list)
   166) 
   167)   ! surface complexes
   168)   surface_complexation%nsrfcplx = 0
   169)   
   170)   nullify(surface_complexation%srfcplx_names)
   171)   nullify(surface_complexation%srfcplx_print)
   172) 
   173)   nullify(surface_complexation%srfcplxspecid)
   174)   nullify(surface_complexation%srfcplxstoich)
   175)   nullify(surface_complexation%srfcplxh2oid)
   176)   nullify(surface_complexation%srfcplxh2ostoich)
   177)   nullify(surface_complexation%srfcplx_free_site_stoich)
   178)   nullify(surface_complexation%srfcplx_logK)
   179)   nullify(surface_complexation%srfcplx_logKcoef)
   180)   nullify(surface_complexation%srfcplx_Z)
   181) 
   182)   ! surface complexation reaction (general members)
   183)   surface_complexation%nsrfcplxrxn = 0
   184)   nullify(surface_complexation%srfcplxrxn_site_names)
   185)   nullify(surface_complexation%srfcplxrxn_site_print)
   186)   nullify(surface_complexation%srfcplxrxn_site_density_print)
   187) 
   188)   nullify(surface_complexation%srfcplxrxn_to_surf)
   189)   nullify(surface_complexation%srfcplxrxn_surf_type)
   190)   nullify(surface_complexation%srfcplxrxn_to_complex)
   191)   nullify(surface_complexation%srfcplxrxn_site_density)
   192)   nullify(surface_complexation%srfcplxrxn_stoich_flag) 
   193)   
   194)   ! equilibrium
   195)   surface_complexation%neqsrfcplx = 0
   196)   surface_complexation%neqsrfcplxrxn = 0
   197)   nullify(surface_complexation%eqsrfcplxrxn_to_srfcplxrxn) 
   198)   
   199)   ! kinetic   
   200)   surface_complexation%nkinsrfcplx = 0
   201)   surface_complexation%nkinsrfcplxrxn = 0
   202)   nullify(surface_complexation%kinsrfcplxrxn_to_srfcplxrxn) 
   203)   nullify(surface_complexation%kinsrfcplx_to_name) 
   204)   nullify(surface_complexation%kinsrfcplx_forward_rate)
   205)   nullify(surface_complexation%kinsrfcplx_backward_rate)
   206) 
   207)   ! multirate kinetic surface complexation
   208)   surface_complexation%nkinmrsrfcplx = 0
   209)   surface_complexation%nkinmrsrfcplxrxn = 0
   210)   nullify(surface_complexation%kinmrsrfcplxrxn_to_srfcplxrxn) 
   211)   nullify(surface_complexation%kinmr_nrate)
   212)   nullify(surface_complexation%kinmr_rate)
   213)   nullify(surface_complexation%kinmr_frac)
   214) 
   215)   SurfaceComplexationCreate => surface_complexation
   216)   
   217) end function SurfaceComplexationCreate
   218) 
   219) ! ************************************************************************** !
   220) 
   221) function SurfaceComplexationRxnCreate()
   222)   ! 
   223)   ! Allocate and initialize a surface complexation
   224)   ! reaction
   225)   ! 
   226)   ! Author: Peter Lichtner
   227)   ! Date: 10/21/08
   228)   ! 
   229) 
   230)   implicit none
   231)     
   232)   type(surface_complexation_rxn_type), pointer :: SurfaceComplexationRxnCreate
   233) 
   234)   type(surface_complexation_rxn_type), pointer :: srfcplxrxn
   235)   
   236)   allocate(srfcplxrxn)
   237)   srfcplxrxn%free_site_id = 0
   238)   srfcplxrxn%itype = SRFCMPLX_RXN_NULL
   239)   srfcplxrxn%free_site_name = ''
   240)   srfcplxrxn%free_site_print_me = PETSC_FALSE
   241)   srfcplxrxn%site_density_print_me = PETSC_FALSE
   242) 
   243)   srfcplxrxn%surface_itype = NULL_SURFACE
   244)   srfcplxrxn%mineral_id = 0
   245)   srfcplxrxn%surface_name = ''
   246)   srfcplxrxn%site_density = 0.d0
   247)   srfcplxrxn%kinmr_scale_factor = 1.d0
   248)   nullify(srfcplxrxn%rates)
   249)   nullify(srfcplxrxn%site_fractions)
   250)   
   251)   nullify(srfcplxrxn%complex_list)
   252)   nullify(srfcplxrxn%next)
   253)   
   254)   SurfaceComplexationRxnCreate => srfcplxrxn
   255)   
   256) end function SurfaceComplexationRxnCreate
   257) 
   258) ! ************************************************************************** !
   259) 
   260) function SurfaceComplexCreate()
   261)   ! 
   262)   ! Allocate and initialize a surface complex reaction
   263)   ! 
   264)   ! Author: Peter Lichtner
   265)   ! Date: 10/21/08
   266)   ! 
   267) 
   268)   implicit none
   269)     
   270)   type(surface_complex_type), pointer :: SurfaceComplexCreate
   271) 
   272)   type(surface_complex_type), pointer :: srfcplx
   273)   
   274)   allocate(srfcplx)
   275)   srfcplx%id = 0
   276)   srfcplx%name = ''
   277)   srfcplx%free_site_name = ''
   278)   srfcplx%Z = 0.d0
   279)   srfcplx%free_site_stoich = 0.d0
   280)   srfcplx%forward_rate = 0.d0
   281)   ! default is UNINITIALIZED_INTEGER in case the only the forward rate is defined.  In that case
   282)   ! the backward rate will be calculated as a function of the forward rate and
   283)   ! the equilibrium coefficient (logK).
   284)   srfcplx%backward_rate = UNINITIALIZED_DOUBLE
   285)   srfcplx%print_me = PETSC_FALSE
   286)   nullify(srfcplx%ptr)
   287)   nullify(srfcplx%dbaserxn)
   288)   nullify(srfcplx%next)
   289)   
   290)   SurfaceComplexCreate => srfcplx
   291)   
   292) end function SurfaceComplexCreate
   293) 
   294) ! ************************************************************************** !
   295) 
   296) function SurfaceComplexConstraintCreate(surface_complexation,option)
   297)   ! 
   298)   ! Creates a surface complex constraint object
   299)   ! 
   300)   ! Author: Glenn Hammond
   301)   ! Date: 12/21/09
   302)   ! 
   303) 
   304)   use Option_module
   305)   
   306)   implicit none
   307)   
   308)   type(surface_complexation_type) :: surface_complexation
   309)   type(option_type) :: option
   310)   type(srfcplx_constraint_type), pointer :: SurfaceComplexConstraintCreate
   311) 
   312)   type(srfcplx_constraint_type), pointer :: constraint  
   313) 
   314)   allocate(constraint)
   315)   allocate(constraint%names(surface_complexation%nkinsrfcplx))
   316)   constraint%names = ''
   317)   allocate(constraint%constraint_conc(surface_complexation%nkinsrfcplx))
   318)   constraint%constraint_conc = 0.d0
   319)   allocate(constraint%basis_free_site_conc( &
   320)                            surface_complexation%nkinsrfcplxrxn))
   321)   constraint%basis_free_site_conc = 0.d0
   322) 
   323)   SurfaceComplexConstraintCreate => constraint
   324) 
   325) end function SurfaceComplexConstraintCreate
   326) 
   327) ! ************************************************************************** !
   328) 
   329) function SrfCplxGetSrfCplxCountInRxnType(surface_complexation,rxn_type)
   330)   ! 
   331)   ! Deallocates a surface complexation reaction
   332)   ! 
   333)   ! Author: Glenn Hammond
   334)   ! Date: 03/22/12
   335)   ! 
   336) 
   337)   implicit none
   338)   
   339)   type(surface_complexation_type) :: surface_complexation
   340)   PetscInt :: rxn_type
   341)   
   342)   type(surface_complexation_rxn_type), pointer :: cur_srfcplx_rxn
   343)   type(surface_complex_type), pointer :: cur_srfcplx
   344)   
   345)   PetscInt :: SrfCplxGetSrfCplxCountInRxnType
   346)   
   347)   SrfCplxGetSrfCplxCountInRxnType = 0
   348) 
   349)   ! to determine the number of unique equilibrium surface complexes,
   350)   ! we negate the ids of the complexes in the master list as a flag
   351)   ! to avoid duplicate counts.  We then traverse the list of 
   352)   ! complexes in the rxn and see how many ids are negated
   353)   cur_srfcplx => surface_complexation%complex_list
   354)   do
   355)     if (.not.associated(cur_srfcplx)) exit
   356)     cur_srfcplx%id = -abs(cur_srfcplx%id)
   357)     cur_srfcplx => cur_srfcplx%next
   358)   enddo   
   359)   cur_srfcplx_rxn => surface_complexation%rxn_list
   360)   do
   361)     if (.not.associated(cur_srfcplx_rxn)) exit
   362)     if (cur_srfcplx_rxn%itype == rxn_type) then
   363)       cur_srfcplx => cur_srfcplx_rxn%complex_list
   364)       do
   365)         if (.not.associated(cur_srfcplx)) exit
   366)         ! recall that complexes in rxns point to complexes in master list
   367)         ! through a ptr member of the derived type
   368)         if (cur_srfcplx%ptr%id < 0) then
   369)           cur_srfcplx%ptr%id = abs(cur_srfcplx%ptr%id)
   370)           SrfCplxGetSrfCplxCountInRxnType = SrfCplxGetSrfCplxCountInRxnType + 1
   371)         endif
   372)         cur_srfcplx => cur_srfcplx%next
   373)       enddo
   374)     endif
   375)     cur_srfcplx_rxn => cur_srfcplx_rxn%next
   376)   enddo
   377)   ! unflag complexes (see comment above)
   378)   cur_srfcplx => surface_complexation%complex_list
   379)   do
   380)     if (.not.associated(cur_srfcplx)) exit
   381)     cur_srfcplx%id = abs(cur_srfcplx%id)
   382)     cur_srfcplx => cur_srfcplx%next
   383)   enddo   
   384) 
   385) end function SrfCplxGetSrfCplxCountInRxnType
   386) 
   387) ! ************************************************************************** !
   388) 
   389) subroutine SrfCplxMapMasterSrfCplxToRxn(surface_complexation,rxn_type)
   390)   ! 
   391)   ! Maps surface complexes from the master list
   392)   ! to a compressed rxn list (e.g. for array)
   393)   ! 
   394)   ! Author: Glenn Hammond
   395)   ! Date: 03/22/12
   396)   ! 
   397) 
   398)   implicit none
   399)   
   400)   type(surface_complexation_type) :: surface_complexation
   401)   PetscInt :: rxn_type
   402)   
   403)   type(surface_complexation_rxn_type), pointer :: cur_srfcplx_rxn
   404)   type(surface_complex_type), pointer :: cur_srfcplx
   405)   PetscInt, allocatable :: srfcplx_to_rxnsrfcplx(:)
   406)   PetscInt :: isrfcplx, isrfcplx_in_rxn
   407)   
   408)   isrfcplx = SrfCplxGetSrfCplxCountInRxnType(surface_complexation,rxn_type)
   409)   allocate(srfcplx_to_rxnsrfcplx(isrfcplx))
   410) 
   411)   ! flag the master list
   412)   cur_srfcplx => surface_complexation%complex_list
   413)   isrfcplx = 0
   414)   do
   415)     if (.not.associated(cur_srfcplx)) exit
   416)     ! don't need the ptr here since it is the master list
   417)     isrfcplx = isrfcplx + 1
   418)     cur_srfcplx%id = -abs(cur_srfcplx%id)
   419)     cur_srfcplx => cur_srfcplx%next
   420)   enddo
   421)   allocate(srfcplx_to_rxnsrfcplx(isrfcplx))
   422)   srfcplx_to_rxnsrfcplx = 0
   423)   
   424)   ! determine which surface complexes in master list are include in 
   425)   ! reaction by flagging them
   426)   cur_srfcplx_rxn => surface_complexation%rxn_list
   427)   do
   428)     if (.not.associated(cur_srfcplx_rxn)) exit
   429)     if (cur_srfcplx_rxn%itype == rxn_type) then
   430)       cur_srfcplx => cur_srfcplx_rxn%complex_list
   431)       do
   432)         if (.not.associated(cur_srfcplx)) exit
   433)         cur_srfcplx%ptr%id = abs(cur_srfcplx%ptr%id)
   434)         cur_srfcplx => cur_srfcplx%next
   435)       enddo
   436)     endif
   437)     cur_srfcplx_rxn => cur_srfcplx_rxn%next
   438)   enddo
   439)   
   440)   ! load flagged names in master list into the list of names in the
   441)   ! same order as master list
   442)   ! flag the master list
   443)   cur_srfcplx => surface_complexation%complex_list
   444)   isrfcplx = 0
   445)   isrfcplx_in_rxn = 0
   446)   do
   447)     if (.not.associated(cur_srfcplx)) exit
   448)     ! don't need the ptr here since it is the master list
   449)     isrfcplx = isrfcplx + 1
   450)     if (cur_srfcplx%id > 0) then
   451)       isrfcplx_in_rxn = isrfcplx_in_rxn + 1
   452)       srfcplx_to_rxnsrfcplx(isrfcplx) = isrfcplx_in_rxn
   453)     endif
   454)     ! clear all flags
   455)     cur_srfcplx%ptr%id = abs(cur_srfcplx%ptr%id)
   456)     cur_srfcplx => cur_srfcplx%next
   457)   enddo   
   458)   
   459)   select case(rxn_type)
   460)     case(SRFCMPLX_RXN_EQUILIBRIUM)
   461) !      if (.not.associated(surface_complexation%srfcplx_to_eqsrfcplx)) then
   462) !        allocate(surface_complexation% &
   463) !                   srfcplx_to_eqsrfcplx(size(srfcplx_to_rxnsrfcplx)))
   464) !      endif
   465) !      surface_complexation%srfcplx_to_eqsrfcplx = srfcplx_to_rxnsrfcplx
   466)     case(SRFCMPLX_RXN_MULTIRATE_KINETIC)
   467)     case(SRFCMPLX_RXN_KINETIC)
   468)   end select
   469)   
   470)   deallocate(srfcplx_to_rxnsrfcplx)
   471)   
   472) end subroutine SrfCplxMapMasterSrfCplxToRxn
   473) 
   474) ! ************************************************************************** !
   475) 
   476) subroutine SurfaceComplexationRxnDestroy(srfcplxrxn)
   477)   ! 
   478)   ! Deallocates a surface complexation reaction
   479)   ! 
   480)   ! Author: Glenn Hammond
   481)   ! Date: 10/21/08
   482)   ! 
   483) 
   484)   use Utility_module
   485) 
   486)   implicit none
   487)     
   488)   type(surface_complexation_rxn_type), pointer :: srfcplxrxn
   489) 
   490)   type(surface_complex_type), pointer :: cur_srfcplx, prev_srfcplx
   491)   
   492)   if (.not.associated(srfcplxrxn)) return
   493)   
   494)   cur_srfcplx => srfcplxrxn%complex_list
   495)   do
   496)     if (.not.associated(cur_srfcplx)) exit
   497)     prev_srfcplx => cur_srfcplx
   498)     cur_srfcplx => cur_srfcplx%next
   499)     call SurfaceComplexDestroy(prev_srfcplx)
   500)     nullify(prev_srfcplx)
   501)   enddo
   502)   
   503)   call DeallocateArray(srfcplxrxn%rates)
   504)   call DeallocateArray(srfcplxrxn%site_fractions)
   505)   
   506)   deallocate(srfcplxrxn)  
   507)   nullify(srfcplxrxn)
   508) 
   509) end subroutine SurfaceComplexationRxnDestroy
   510) 
   511) ! ************************************************************************** !
   512) 
   513) subroutine SurfaceComplexDestroy(srfcplx)
   514)   ! 
   515)   ! Deallocates a surface complex
   516)   ! 
   517)   ! Author: Glenn Hammond
   518)   ! Date: 10/21/08
   519)   ! 
   520) 
   521)   implicit none
   522)     
   523)   type(surface_complex_type), pointer :: srfcplx
   524) 
   525)   if (.not.associated(srfcplx)) return
   526)   
   527)   if (associated(srfcplx%dbaserxn)) &
   528)     call DatabaseRxnDestroy(srfcplx%dbaserxn)
   529)   nullify(srfcplx%dbaserxn)
   530)   nullify(srfcplx%next)
   531) 
   532)   deallocate(srfcplx)  
   533)   nullify(srfcplx)
   534) 
   535) end subroutine SurfaceComplexDestroy
   536) 
   537) ! ************************************************************************** !
   538) 
   539) subroutine SurfaceComplexConstraintDestroy(constraint)
   540)   ! 
   541)   ! Destroys a surface complex constraint
   542)   ! object
   543)   ! 
   544)   ! Author: Glenn Hammond
   545)   ! Date: 12/21/09
   546)   ! 
   547) 
   548)   use Utility_module, only : DeallocateArray
   549)   implicit none
   550)   
   551)   type(srfcplx_constraint_type), pointer :: constraint
   552)   
   553)   if (.not.associated(constraint)) return
   554)   
   555)   call DeallocateArray(constraint%names)
   556)   call DeallocateArray(constraint%constraint_conc)
   557)   call DeallocateArray(constraint%basis_free_site_conc)
   558)   
   559)   deallocate(constraint)
   560)   nullify(constraint)
   561) 
   562) end subroutine SurfaceComplexConstraintDestroy
   563) 
   564) ! ************************************************************************** !
   565) 
   566) subroutine SurfaceComplexationDestroy(surface_complexation)
   567)   ! 
   568)   ! Deallocates a reaction object
   569)   ! 
   570)   ! Author: Glenn Hammond
   571)   ! Date: 03/13/12
   572)   ! 
   573) 
   574)   use Utility_module, only: DeallocateArray 
   575)   
   576)   implicit none
   577) 
   578)   type(surface_complexation_type), pointer :: surface_complexation
   579)   
   580)   type(surface_complexation_rxn_type), pointer :: cur_srfcplxrxn, prev_srfcplxrxn
   581)   type(surface_complex_type), pointer :: cur_srfcplx, prev_srfcplx
   582) 
   583)   if (.not.associated(surface_complexation)) return
   584)   
   585)   ! surface complexation reactions
   586)   cur_srfcplxrxn => surface_complexation%rxn_list
   587)   do
   588)     if (.not.associated(cur_srfcplxrxn)) exit
   589)     prev_srfcplxrxn => cur_srfcplxrxn
   590)     cur_srfcplxrxn => cur_srfcplxrxn%next
   591)     call SurfaceComplexationRxnDestroy(prev_srfcplxrxn)
   592)   enddo    
   593)   nullify(surface_complexation%rxn_list)
   594)   
   595)   ! surface complexes
   596)   cur_srfcplx => surface_complexation%complex_list
   597)   do
   598)     if (.not.associated(cur_srfcplx)) exit
   599)     prev_srfcplx => cur_srfcplx
   600)     cur_srfcplx => cur_srfcplx%next
   601)     call SurfaceComplexDestroy(prev_srfcplx)
   602)     nullify(prev_srfcplx)
   603)   enddo
   604) 
   605)   ! surface complexes
   606)   call DeallocateArray(surface_complexation%srfcplx_names)
   607)   call DeallocateArray(surface_complexation%srfcplx_print)
   608)   call DeallocateArray(surface_complexation%srfcplxspecid)
   609)   call DeallocateArray(surface_complexation%srfcplxstoich)
   610)   call DeallocateArray(surface_complexation%srfcplxh2oid)
   611)   call DeallocateArray(surface_complexation%srfcplxh2ostoich)
   612)   call DeallocateArray(surface_complexation%srfcplx_free_site_stoich)
   613)   call DeallocateArray(surface_complexation%srfcplx_logK)
   614)   call DeallocateArray(surface_complexation%srfcplx_logKcoef)
   615)   call DeallocateArray(surface_complexation%srfcplx_Z)
   616)     
   617)   ! surface complexation reaction (general members)
   618)   call DeallocateArray(surface_complexation%srfcplxrxn_site_names)
   619)   call DeallocateArray(surface_complexation%srfcplxrxn_site_print)
   620)   call DeallocateArray(surface_complexation%srfcplxrxn_site_density_print)
   621)   call DeallocateArray(surface_complexation%srfcplxrxn_to_surf)
   622)   call DeallocateArray(surface_complexation%srfcplxrxn_surf_type)
   623)   call DeallocateArray(surface_complexation%srfcplxrxn_to_complex)
   624)   call DeallocateArray(surface_complexation%srfcplxrxn_site_density)
   625)   call DeallocateArray(surface_complexation%srfcplxrxn_stoich_flag)
   626) 
   627)   ! equilibrium
   628)   call DeallocateArray(surface_complexation%eqsrfcplxrxn_to_srfcplxrxn)
   629)     
   630)   ! kinetic
   631)   call DeallocateArray(surface_complexation%kinsrfcplxrxn_to_srfcplxrxn)
   632)   call DeallocateArray(surface_complexation%kinsrfcplx_to_name)
   633)   call DeallocateArray(surface_complexation%kinsrfcplx_forward_rate)
   634)   call DeallocateArray(surface_complexation%kinsrfcplx_backward_rate)
   635) 
   636)   ! multirate kinetic surface complexation
   637)   call DeallocateArray(surface_complexation%kinmrsrfcplxrxn_to_srfcplxrxn)
   638)   call DeallocateArray(surface_complexation%kinmr_nrate)
   639)   call DeallocateArray(surface_complexation%kinmr_rate)
   640)   call DeallocateArray(surface_complexation%kinmr_frac)
   641)   
   642)   deallocate(surface_complexation)
   643)   nullify(surface_complexation)
   644) 
   645) end subroutine SurfaceComplexationDestroy
   646) 
   647) end module Reaction_Surface_Complexation_Aux_module

generated by
Intel(R) C++/Fortran Compiler code-coverage tool
Web-Page Owner: Nobody