global_aux.F90       coverage:  100.00 %func     90.84 %block


     1) module Global_Aux_module
     2) 
     3)   use PFLOTRAN_Constants_module
     4) 
     5)   implicit none
     6)   
     7)   private 
     8) 
     9) #include "petsc/finclude/petscsys.h"
    10) 
    11)   type, public :: global_auxvar_type
    12)     PetscInt :: istate
    13)     PetscReal :: temp
    14)     PetscReal, pointer :: pres(:)
    15)     PetscReal, pointer :: pres_store(:,:)
    16)     PetscReal, pointer :: temp_store(:)
    17)     PetscReal, pointer :: sat(:)
    18)     PetscReal, pointer :: sat_store(:,:)
    19)     PetscReal, pointer :: den(:)  ! kmol/m^3
    20)     PetscReal, pointer :: den_kg(:) ! kg/m^3
    21)     PetscReal, pointer :: den_store(:,:)
    22)     PetscReal, pointer :: den_kg_store(:,:)
    23)     PetscReal, pointer :: fugacoeff(:)
    24)     PetscReal, pointer :: fugacoeff_store(:,:)
    25)     PetscReal, pointer :: m_nacl(:)
    26)     PetscReal, pointer :: xmass(:)
    27)     PetscReal, pointer :: mass_balance(:,:) ! kg
    28)     PetscReal, pointer :: mass_balance_delta(:,:) ! kmol
    29)     PetscReal, pointer :: reaction_rate(:)
    30)     PetscReal, pointer :: reaction_rate_store(:)
    31)     PetscReal, pointer :: dphi(:,:) !geh: why here?
    32) !geh    PetscReal :: scco2_eq_logK ! SC CO2
    33)   end type global_auxvar_type
    34)   
    35)   type, public :: global_type
    36)     PetscReal :: time_t, time_tpdt
    37)     PetscInt :: num_aux, num_aux_bc, num_aux_ss
    38)     type(global_auxvar_type), pointer :: auxvars(:)
    39)     type(global_auxvar_type), pointer :: auxvars_bc(:)
    40)     type(global_auxvar_type), pointer :: auxvars_ss(:)
    41)   end type global_type
    42)   
    43)   interface GlobalAuxVarDestroy
    44)     module procedure GlobalAuxVarSingleDestroy
    45)     module procedure GlobalAuxVarArrayDestroy
    46)   end interface GlobalAuxVarDestroy
    47)   
    48)   public :: GlobalAuxCreate, GlobalAuxDestroy, &
    49)             GlobalAuxVarInit, GlobalAuxVarCopy, &
    50)             GlobalAuxVarDestroy, GlobalAuxVarStrip
    51) 
    52) contains
    53) 
    54) ! ************************************************************************** !
    55) 
    56) function GlobalAuxCreate()
    57)   ! 
    58)   ! Allocate and initialize auxiliary object
    59)   ! 
    60)   ! Author: Glenn Hammond
    61)   ! Date: 02/14/08
    62)   ! 
    63) 
    64)   use Option_module
    65) 
    66)   implicit none
    67)   
    68)   type(global_type), pointer :: GlobalAuxCreate
    69)   
    70)   type(global_type), pointer :: aux
    71) 
    72)   allocate(aux) 
    73)   aux%time_t = 0.d0
    74)   aux%time_tpdt = 0.d0
    75)   aux%num_aux = 0
    76)   aux%num_aux_bc = 0
    77)   aux%num_aux_ss = 0
    78)   nullify(aux%auxvars)
    79)   nullify(aux%auxvars_bc)
    80)   nullify(aux%auxvars_ss)
    81) 
    82)   GlobalAuxCreate => aux
    83)   
    84) end function GlobalAuxCreate
    85) 
    86) ! ************************************************************************** !
    87) 
    88) subroutine GlobalAuxVarInit(auxvar,option)
    89)   ! 
    90)   ! Initialize auxiliary object
    91)   ! 
    92)   ! Author: Glenn Hammond
    93)   ! Date: 02/14/08
    94)   ! 
    95) 
    96)   use Option_module
    97) 
    98)   implicit none
    99)   
   100)   type(global_auxvar_type) :: auxvar
   101)   type(option_type) :: option
   102)   
   103)   auxvar%istate = 0
   104)   auxvar%temp = 0.d0
   105) 
   106)   ! nullify everthing to begin with and allocate later
   107)   nullify(auxvar%pres)
   108)   nullify(auxvar%sat)
   109)   nullify(auxvar%den)
   110)   nullify(auxvar%den_kg)
   111)   nullify(auxvar%pres_store)
   112)   nullify(auxvar%temp_store)
   113)   nullify(auxvar%sat_store)
   114)   nullify(auxvar%den_store)
   115)   nullify(auxvar%den_kg_store)
   116)   nullify(auxvar%fugacoeff)
   117)   nullify(auxvar%fugacoeff_store)
   118)   nullify(auxvar%m_nacl)
   119)   nullify(auxvar%xmass)
   120)   nullify(auxvar%reaction_rate)
   121)   nullify(auxvar%reaction_rate_store)
   122)   nullify(auxvar%mass_balance)
   123)   nullify(auxvar%mass_balance_delta)
   124)   nullify(auxvar%dphi)
   125) 
   126)   if (option%nflowdof > 0) then
   127)     allocate(auxvar%den(option%nphase))
   128)     auxvar%den = 0.d0
   129)   endif
   130)   allocate(auxvar%pres(option%nphase))
   131)   auxvar%pres = 0.d0
   132)   allocate(auxvar%sat(option%nphase))
   133)   auxvar%sat = 0.d0
   134)   allocate(auxvar%den_kg(option%nphase))
   135)   auxvar%den_kg = 0.d0
   136) 
   137)   ! need these for reactive transport only if if flow if computed
   138)   if (option%nflowdof > 0 .and. option%ntrandof > 0) then
   139)     allocate(auxvar%sat_store(option%nphase,TWO_INTEGER))
   140)     auxvar%sat_store = 0.d0
   141)     allocate(auxvar%den_kg_store(option%nphase,TWO_INTEGER))
   142)     auxvar%den_kg_store = 0.d0
   143)   endif
   144)  
   145)   select case(option%iflowmode)
   146)     case(RICHARDS_MODE)
   147) !      if (option%ntrandof > 0) then
   148) !        allocate(auxvar%den_store(option%nphase,TWO_INTEGER))
   149) !        auxvar%den_store = 0.d0
   150) !      endif
   151)     case(IMS_MODE, MPH_MODE, FLASH2_MODE)
   152)       allocate(auxvar%xmass(option%nphase))
   153)       auxvar%xmass = 1.d0
   154)       allocate(auxvar%pres_store(option%nphase,TWO_INTEGER))
   155)       auxvar%pres_store = option%reference_pressure
   156)       allocate(auxvar%temp_store(TWO_INTEGER))
   157)       auxvar%temp_store = 0.d0
   158)       allocate(auxvar%fugacoeff(ONE_INTEGER))
   159)       auxvar%fugacoeff = 1.d0
   160)       allocate(auxvar%fugacoeff_store(ONE_INTEGER,TWO_INTEGER))
   161)       auxvar%fugacoeff_store = 1.d0    
   162)       allocate(auxvar%den_store(option%nphase,TWO_INTEGER))
   163)       auxvar%den_store = 0.d0
   164)       allocate(auxvar%m_nacl(TWO_INTEGER))
   165)       auxvar%m_nacl = option%m_nacl
   166)       allocate(auxvar%reaction_rate(option%nflowspec))
   167)       auxvar%reaction_rate = 0.d0
   168)       allocate(auxvar%reaction_rate_store(option%nflowspec))
   169)       auxvar%reaction_rate_store = 0.d0
   170)     case(TH_MODE)
   171)     ! allocate(auxvar%xmass(option%nphase))
   172)     ! auxvar%xmass = 1.d0
   173)       allocate(auxvar%pres_store(option%nphase,TWO_INTEGER))
   174)       auxvar%pres_store = 0.d0
   175)       allocate(auxvar%temp_store(TWO_INTEGER))
   176)       auxvar%temp_store = 0.d0
   177)     ! allocate(auxvar%fugacoeff(ONE_INTEGER))
   178)     ! auxvar%fugacoeff = 1.d0
   179)     ! allocate(auxvar%fugacoeff_store(ONE_INTEGER,TWO_INTEGER))
   180)     ! auxvar%fugacoeff_store = 1.d0    
   181)       allocate(auxvar%den_store(option%nphase,TWO_INTEGER))
   182)       auxvar%den_store = 0.d0
   183)     ! allocate(auxvar%m_nacl(TWO_INTEGER))
   184)     ! auxvar%m_nacl = option%m_nacl
   185)       nullify(auxvar%xmass)
   186)       nullify(auxvar%fugacoeff)
   187)       nullify(auxvar%fugacoeff_store)
   188)       nullify(auxvar%m_nacl)
   189)       nullify(auxvar%reaction_rate)
   190)       nullify(auxvar%reaction_rate_store)  
   191)     case (G_MODE)
   192)       if (option%ntrandof > 0) then
   193)         allocate(auxvar%pres_store(option%nphase,TWO_INTEGER))
   194)         auxvar%pres_store = 0.d0
   195)         allocate(auxvar%temp_store(TWO_INTEGER))
   196)         auxvar%temp_store = 0.d0
   197) !geh: these are allocated above        
   198) !geh        allocate(auxvar%den_kg_store(option%nphase,TWO_INTEGER))
   199) !geh        auxvar%den_kg_store = 0.d0
   200)       endif
   201)     case default
   202)   end select
   203)   
   204)   if (option%flow%density_depends_on_salinity) then
   205)     allocate(auxvar%m_nacl(ONE_INTEGER))
   206)     auxvar%m_nacl = 0.d0
   207)   endif
   208)   
   209)   if (option%iflag /= 0 .and. option%compute_mass_balance_new) then
   210)     allocate(auxvar%mass_balance(option%nflowspec,option%nphase))
   211)     auxvar%mass_balance = 0.d0
   212)     allocate(auxvar%mass_balance_delta(option%nflowspec,option%nphase))
   213)     auxvar%mass_balance_delta = 0.d0
   214)   endif
   215)   
   216) end subroutine GlobalAuxVarInit
   217) 
   218) ! ************************************************************************** !
   219) 
   220) subroutine GlobalAuxVarCopy(auxvar,auxvar2,option)
   221)   ! 
   222)   ! Copies an auxiliary variable
   223)   ! 
   224)   ! Author: Glenn Hammond
   225)   ! Date: 12/13/07
   226)   ! 
   227) 
   228)   use Option_module
   229) 
   230)   implicit none
   231)   
   232)   type(global_auxvar_type) :: auxvar, auxvar2
   233)   type(option_type) :: option
   234) 
   235)   auxvar2%istate = auxvar%istate
   236)   auxvar2%pres = auxvar%pres
   237)   auxvar2%temp = auxvar%temp
   238)   auxvar2%sat = auxvar%sat
   239)   auxvar2%den = auxvar%den
   240)   auxvar2%den_kg = auxvar%den_kg
   241) !  auxvar2%dphi = auxvar%dphi
   242)   
   243)   if (associated(auxvar2%reaction_rate)) then
   244)     auxvar2%reaction_rate = auxvar%reaction_rate
   245)   endif
   246)   
   247)   if (associated(auxvar2%m_nacl)) then
   248)     auxvar2%m_nacl = auxvar%m_nacl
   249)   endif
   250) 
   251)   if (associated(auxvar2%fugacoeff)) then
   252)     auxvar2%fugacoeff = auxvar%fugacoeff  
   253)   endif
   254)   if (associated(auxvar2%xmass)) then
   255)     auxvar2%xmass = auxvar%xmass  
   256)   endif
   257)   if (associated(auxvar2%pres_store)) then
   258)     auxvar2%pres_store = auxvar%pres_store  
   259)   endif
   260)   if (associated(auxvar2%den_store)) then
   261)     auxvar2%den_store = auxvar%den_store  
   262)   endif
   263)   if (associated(auxvar2%sat_store)) then
   264)     auxvar2%sat_store = auxvar%sat_store  
   265)   endif
   266)   if (associated(auxvar2%den_kg_store)) then
   267)     auxvar2%den_kg_store = auxvar%den_kg_store
   268)   endif
   269)   if (associated(auxvar2%temp_store)) then
   270)     auxvar2%temp_store = auxvar%temp_store  
   271)   endif
   272)   if (associated(auxvar2%fugacoeff_store)) then
   273)     auxvar2%fugacoeff_store = auxvar%fugacoeff_store  
   274)   endif
   275) 
   276)   !geh: here we have to check on both as mass_balance often exists for bcs and
   277)   !     src/sinks but not regular cells.
   278)   if (associated(auxvar%mass_balance) .and. &
   279)       associated(auxvar2%mass_balance)) then
   280)     auxvar2%mass_balance = auxvar%mass_balance
   281)     auxvar2%mass_balance_delta = auxvar%mass_balance_delta
   282)   endif
   283) 
   284) end subroutine GlobalAuxVarCopy
   285) 
   286) ! ************************************************************************** !
   287) 
   288) subroutine GlobalAuxVarSingleDestroy(auxvar)
   289)   ! 
   290)   ! Deallocates a mode auxiliary object
   291)   ! 
   292)   ! Author: Glenn Hammond
   293)   ! Date: 01/10/12
   294)   ! 
   295) 
   296)   implicit none
   297) 
   298)   type(global_auxvar_type), pointer :: auxvar
   299)   
   300)   if (associated(auxvar)) then
   301)     call GlobalAuxVarStrip(auxvar)
   302)     deallocate(auxvar)
   303)   endif
   304)   nullify(auxvar)
   305) 
   306) end subroutine GlobalAuxVarSingleDestroy
   307) 
   308) ! ************************************************************************** !
   309) 
   310) subroutine GlobalAuxVarArrayDestroy(auxvars)
   311)   ! 
   312)   ! Deallocates a mode auxiliary object
   313)   ! 
   314)   ! Author: Glenn Hammond
   315)   ! Date: 01/10/12
   316)   ! 
   317) 
   318)   implicit none
   319) 
   320)   type(global_auxvar_type), pointer :: auxvars(:)
   321)   
   322)   PetscInt :: iaux
   323)   
   324)   if (associated(auxvars)) then
   325)     do iaux = 1, size(auxvars)
   326)       call GlobalAuxVarStrip(auxvars(iaux))
   327)     enddo  
   328)     deallocate(auxvars)
   329)   endif
   330)   nullify(auxvars)
   331) 
   332) end subroutine GlobalAuxVarArrayDestroy
   333) 
   334) ! ************************************************************************** !
   335) 
   336) subroutine GlobalAuxVarStrip(auxvar)
   337)   ! 
   338)   ! Deallocates all members of single auxiliary object
   339)   ! 
   340)   ! Author: Glenn Hammond
   341)   ! Date: 01/10/12
   342)   ! 
   343) 
   344)   use Utility_module, only: DeallocateArray
   345) 
   346)   implicit none
   347) 
   348)   type(global_auxvar_type) :: auxvar
   349)   
   350)   call DeallocateArray(auxvar%pres)
   351)   call DeallocateArray(auxvar%sat)
   352)   call DeallocateArray(auxvar%den)
   353)   call DeallocateArray(auxvar%fugacoeff)
   354)   call DeallocateArray(auxvar%den_kg)
   355)   call DeallocateArray(auxvar%m_nacl)
   356)   call DeallocateArray(auxvar%xmass)
   357)   call DeallocateArray(auxvar%reaction_rate)
   358)   call DeallocateArray(auxvar%dphi)
   359) 
   360)   call DeallocateArray(auxvar%pres_store)
   361)   call DeallocateArray(auxvar%temp_store)
   362)   call DeallocateArray(auxvar%fugacoeff_store)
   363)   call DeallocateArray(auxvar%sat_store)
   364)   call DeallocateArray(auxvar%den_kg_store)
   365)   call DeallocateArray(auxvar%den_store)
   366)   call DeallocateArray(auxvar%reaction_rate_store)
   367)   
   368)   call DeallocateArray(auxvar%mass_balance)
   369)   call DeallocateArray(auxvar%mass_balance_delta)
   370) 
   371) end subroutine GlobalAuxVarStrip
   372) 
   373) ! ************************************************************************** !
   374) 
   375) subroutine GlobalAuxDestroy(aux)
   376)   ! 
   377)   ! Deallocates a mode auxiliary object
   378)   ! 
   379)   ! Author: Glenn Hammond
   380)   ! Date: 02/14/08
   381)   ! 
   382) 
   383)   implicit none
   384) 
   385)   type(global_type), pointer :: aux
   386)   PetscInt :: iaux
   387)   
   388)   if (.not.associated(aux)) return
   389)   
   390)   call GlobalAuxVarDestroy(aux%auxvars)
   391)   call GlobalAuxVarDestroy(aux%auxvars_bc)
   392)   call GlobalAuxVarDestroy(aux%auxvars_ss)
   393)   
   394)   deallocate(aux)
   395)   nullify(aux)
   396)   
   397) end subroutine GlobalAuxDestroy
   398) 
   399) end module Global_Aux_module

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