output.F90       coverage:  50.00 %func     22.88 %block


     1) module Output_module
     2) 
     3)   use Logging_module 
     4)   use Output_Aux_module
     5) 
     6)  ! use Output_Surface_module
     7)   use Output_HDF5_module
     8)   use Output_Tecplot_module
     9)   use Output_VTK_module
    10)   use Output_Observation_module
    11)   
    12)   use PFLOTRAN_Constants_module
    13) 
    14)   implicit none
    15) 
    16)   private
    17) 
    18) #include "petsc/finclude/petscsys.h"
    19) #include "petsc/finclude/petscvec.h"
    20) #include "petsc/finclude/petscvec.h90"
    21) #include "petsc/finclude/petscdm.h"
    22) #include "petsc/finclude/petscdm.h90"
    23) #include "petsc/finclude/petsclog.h"
    24) 
    25) #if defined(SCORPIO_WRITE)
    26)   include "scorpiof.h"
    27) #endif
    28) 
    29)   PetscInt, parameter :: TECPLOT_INTEGER = 0
    30)   PetscInt, parameter :: TECPLOT_REAL = 1
    31) 
    32)   PetscInt, parameter :: VTK_INTEGER = 0
    33)   PetscInt, parameter :: VTK_REAL = 1
    34) 
    35)   PetscInt, parameter :: TECPLOT_FILE = 0
    36)   PetscInt, parameter ::  HDF5_FILE = 1
    37) 
    38)   
    39)   PetscBool :: observation_first
    40)   PetscBool :: hdf5_first
    41)   PetscBool :: mass_balance_first
    42) 
    43)   public :: OutputInit, &
    44)             Output, &
    45)             OutputPrintCouplers, &
    46)             OutputVariableRead, &
    47)             OutputFileRead, &
    48)             OutputInputRecord
    49) 
    50) contains
    51) 
    52) ! ************************************************************************** !
    53) 
    54) subroutine OutputInit(option,num_steps)
    55)   ! 
    56)   ! Initializes variables
    57)   ! 
    58)   ! Author: Glenn Hammond
    59)   ! Date: 01/22/09
    60)   ! 
    61)   use Option_module
    62)   use Output_Common_module
    63)   use Output_EKG_module
    64) 
    65)   implicit none
    66)   
    67)   type(option_type) :: option
    68)   PetscInt :: num_steps
    69)   
    70)   call OutputCommonInit()
    71)   call OutputObservationInit(num_steps)
    72)   call OutputHDF5Init(num_steps)
    73)   call OutputEKGInit(option,num_steps)
    74) 
    75) end subroutine OutputInit
    76) 
    77) ! ************************************************************************** !
    78) 
    79) subroutine OutputFileRead(realization,output_option,waypoint_list,block_name)
    80)   ! 
    81)   ! Reads the *_FILE block within the OUTPUT block.
    82)   ! 
    83)   ! Author: Jenn Frederick, SNL
    84)   ! Date: 02/23/2016
    85)   ! 
    86) 
    87)   use Option_module
    88)   use Input_Aux_module
    89)   use Output_Aux_module
    90)   use String_module
    91)   use Realization_Subsurface_class
    92)   use Waypoint_module
    93)   use Units_module
    94)   use Utility_module
    95)   use Grid_module
    96)   use Patch_module
    97)   use Region_module
    98) 
    99)   implicit none
   100) 
   101)   class(realization_subsurface_type), pointer :: realization
   102)   type(output_option_type), pointer :: output_option
   103)   type(waypoint_list_type), pointer :: waypoint_list
   104)   character(len=*) :: block_name
   105)   
   106)   type(input_type), pointer :: input
   107)   type(option_type), pointer :: option
   108)   type(patch_type), pointer :: patch
   109)   type(grid_type), pointer :: grid
   110)   type(waypoint_type), pointer :: waypoint
   111)   type(mass_balance_region_type), pointer :: new_massbal_region
   112)   type(mass_balance_region_type), pointer :: cur_mbr
   113)   PetscReal, pointer :: temp_real_array(:)
   114) 
   115)   character(len=MAXWORDLENGTH) :: word
   116)   character(len=MAXWORDLENGTH) :: units, internal_units
   117)   character(len=MAXSTRINGLENGTH) :: string
   118)   PetscReal :: temp_real,temp_real2
   119)   PetscReal :: units_conversion
   120)   PetscInt :: k
   121)   PetscBool :: added
   122)   PetscBool :: vel_cent, vel_face
   123)   PetscBool :: fluxes
   124)   PetscBool :: mass_flowrate, energy_flowrate
   125)   PetscBool :: aveg_mass_flowrate, aveg_energy_flowrate
   126) 
   127)   option => realization%option
   128)   input => realization%input
   129)   patch => realization%patch
   130)   if (associated(patch)) grid => patch%grid
   131) 
   132)   vel_cent = PETSC_FALSE
   133)   vel_face = PETSC_FALSE
   134)   fluxes = PETSC_FALSE
   135)   mass_flowrate = PETSC_FALSE
   136)   energy_flowrate = PETSC_FALSE
   137)   aveg_mass_flowrate = PETSC_FALSE
   138)   aveg_energy_flowrate = PETSC_FALSE
   139)   k = 0
   140)   nullify(temp_real_array)
   141) 
   142)   select case(trim(block_name))
   143)     case('SNAPSHOT_FILE')
   144)     case('OBSERVATION_FILE')
   145)       output_option%print_observation = PETSC_TRUE
   146)     case('MASS_BALANCE_FILE')
   147)       option%compute_mass_balance_new = PETSC_TRUE
   148)   end select
   149) 
   150)   do
   151)     call InputReadPflotranString(input,option)
   152)     if (InputError(input)) exit
   153)     if (InputCheckExit(input,option)) exit
   154)     
   155)     call InputReadWord(input,option,word,PETSC_TRUE)
   156)     string = 'OUTPUT,' // trim(block_name)
   157)     call InputErrorMsg(input,option,'keyword',string)
   158)     call StringToUpper(word)
   159)     
   160)     select case(trim(word))
   161) !......................................
   162)       case('NO_FINAL','NO_PRINT_FINAL')
   163)         select case(trim(block_name))
   164)           case('OBSERVATION_FILE')
   165)             output_option%print_final_obs = PETSC_FALSE
   166)           case('SNAPSHOT_FILE')
   167)             output_option%print_final_snap = PETSC_FALSE
   168)           case('MASS_BALANCE_FILE')
   169)             output_option%print_final_massbal = PETSC_FALSE
   170)         end select
   171) 
   172) !..........................................
   173)       case('NO_INITIAL','NO_PRINT_INITIAL')
   174)         select case(trim(block_name))
   175)           case('OBSERVATION_FILE')
   176)             output_option%print_initial_obs = PETSC_FALSE
   177)           case('SNAPSHOT_FILE')
   178)             output_option%print_initial_snap = PETSC_FALSE
   179)           case('MASS_BALANCE_FILE')
   180)             output_option%print_initial_massbal = PETSC_FALSE
   181)         end select
   182)         
   183) !...............................
   184)       case('TOTAL_MASS_REGIONS')
   185)         select case(trim(block_name))
   186)           case('OBSERVATION_FILE')
   187)             option%io_buffer = 'TOTAL_MASS_REGIONS cannot be specified for &
   188)                                &OUTPUT,OBSERVATION_FILE block.'
   189)             call printErrMsg(option)
   190)           case('SNAPSHOT_FILE')
   191)             option%io_buffer = 'TOTAL_MASS_REGIONS cannot be specified for &
   192)                                &OUTPUT,SNAPSHOT_FILE block.'
   193)             call printErrMsg(option)
   194)           case('MASS_BALANCE_FILE')
   195)             string = 'OUTPUT,' // trim(block_name) // ',TOTAL_MASS_REGIONS'
   196)             output_option%mass_balance_region_flag = PETSC_TRUE
   197)             do
   198)               ! Read region name:
   199)               call InputReadPflotranString(input,option)
   200)               call InputReadStringErrorMsg(input,option,string)
   201)               if (InputCheckExit(input,option)) exit
   202)               ! Region name found; read the region name
   203)               call InputReadWord(input,option,word,PETSC_TRUE)
   204)               call InputErrorMsg(input,option,'keyword',string) 
   205)               ! Create a new mass balance region
   206)               new_massbal_region => OutputMassBalRegionCreate()
   207)               new_massbal_region%region_name = trim(word)
   208)               ! Add the new mass balance region to the list
   209)               added = PETSC_FALSE
   210)               if (.not.associated(output_option%mass_balance_region_list)) then
   211)                 output_option%mass_balance_region_list => new_massbal_region
   212)               else
   213)                 cur_mbr => output_option%mass_balance_region_list
   214)                 do
   215)                   if (.not.associated(cur_mbr)) exit
   216)                   if (.not.associated(cur_mbr%next)) then
   217)                     cur_mbr%next => new_massbal_region
   218)                     added = PETSC_TRUE
   219)                   endif
   220)                   if (added) exit
   221)                   cur_mbr => cur_mbr%next
   222)                 enddo
   223)               endif
   224)               nullify(new_massbal_region)
   225)             enddo ! Read loop
   226)         end select
   227) 
   228) !..................
   229)       case('TIMES')
   230)         string = 'OUTPUT,' // trim(block_name) // ',TIMES'
   231)         call InputReadWord(input,option,word,PETSC_TRUE)
   232)         call InputErrorMsg(input,option,'units',string)
   233)         internal_units = 'sec'
   234)         units_conversion = &
   235)              UnitsConvertToInternal(word,internal_units,option)
   236)         call UtilityReadArray(temp_real_array,NEG_ONE_INTEGER, &
   237)              string,input,option)
   238)         do k = 1, size(temp_real_array)
   239)           waypoint => WaypointCreate()
   240)           waypoint%time = temp_real_array(k)*units_conversion
   241)           select case(trim(block_name))
   242)             case('SNAPSHOT_FILE')
   243)               waypoint%print_snap_output = PETSC_TRUE
   244)             case('OBSERVATION_FILE')
   245)               waypoint%print_obs_output = PETSC_TRUE
   246)             case('MASS_BALANCE_FILE')
   247)               waypoint%print_msbl_output = PETSC_TRUE
   248)           end select    
   249)           call WaypointInsertInList(waypoint,waypoint_list)
   250)         enddo
   251)         call DeallocateArray(temp_real_array)
   252) 
   253) !.....................
   254)       case('PERIODIC')
   255)         string = 'OUTPUT,' // trim(block_name) // ',PERIODIC'
   256)         call InputReadWord(input,option,word,PETSC_TRUE)
   257)         call InputErrorMsg(input,option,'periodic time increment type',string)
   258)         call StringToUpper(word)
   259)         select case(trim(word))
   260)         !.............
   261)           case('TIME')
   262)             string = 'OUTPUT,' // trim(block_name) // ',PERIODIC,TIME'
   263)             call InputReadDouble(input,option,temp_real)
   264)             call InputErrorMsg(input,option,'time increment',string)
   265)             call InputReadWord(input,option,word,PETSC_TRUE)
   266)             call InputErrorMsg(input,option,'time increment units',string)
   267)             internal_units = 'sec'
   268)             units_conversion = UnitsConvertToInternal(word, &
   269)                  internal_units,option) 
   270)             select case(trim(block_name))
   271)               case('SNAPSHOT_FILE')
   272)                 output_option%periodic_snap_output_time_incr = temp_real* &
   273)                      units_conversion
   274)               case('OBSERVATION_FILE')
   275)                 output_option%periodic_obs_output_time_incr = temp_real* &
   276)                      units_conversion
   277)               case('MASS_BALANCE_FILE')
   278)                 output_option%periodic_msbl_output_time_incr = temp_real* &
   279)                      units_conversion
   280)             end select
   281)             call InputReadWord(input,option,word,PETSC_TRUE)
   282)             if (input%ierr == 0) then
   283)               if (StringCompareIgnoreCase(word,'between')) then
   284)                 call InputReadDouble(input,option,temp_real)
   285)                 call InputErrorMsg(input,option,'start time',string)
   286)                 call InputReadWord(input,option,word,PETSC_TRUE)
   287)                 call InputErrorMsg(input,option,'start time units',string)
   288)                 internal_units = 'sec'
   289)                 units_conversion = UnitsConvertToInternal(word, &
   290)                      internal_units,option) 
   291)                 temp_real = temp_real * units_conversion
   292)                 call InputReadWord(input,option,word,PETSC_TRUE)
   293)                 if (.not.StringCompareIgnoreCase(word,'and')) then
   294)                   input%ierr = 1
   295)                 endif
   296)                 call InputErrorMsg(input,option,'and',string)
   297)                 call InputReadDouble(input,option,temp_real2)
   298)                 call InputErrorMsg(input,option,'end time',string)
   299)                 call InputReadWord(input,option,word,PETSC_TRUE)
   300)                 call InputErrorMsg(input,option,'end time units',string)
   301)                 temp_real2 = temp_real2 * units_conversion
   302)                 select case(trim(block_name))
   303)                   case('SNAPSHOT_FILE')
   304)                     do
   305)                       waypoint => WaypointCreate()
   306)                       waypoint%time = temp_real
   307)                       waypoint%print_snap_output = PETSC_TRUE
   308)                       call WaypointInsertInList(waypoint,waypoint_list)
   309)                       temp_real = temp_real + &
   310)                            output_option%periodic_snap_output_time_incr
   311)                       if (temp_real > temp_real2) exit
   312)                     enddo
   313)                     output_option%periodic_snap_output_time_incr = 0.d0
   314)                   case('OBSERVATION_FILE')
   315)                     do
   316)                       waypoint => WaypointCreate()
   317)                       waypoint%time = temp_real
   318)                       waypoint%print_obs_output = PETSC_TRUE
   319)                       call WaypointInsertInList(waypoint,waypoint_list)
   320)                       temp_real = temp_real + &
   321)                            output_option%periodic_obs_output_time_incr
   322)                       if (temp_real > temp_real2) exit
   323)                     enddo
   324)                     output_option%periodic_obs_output_time_incr = 0.d0
   325)                   case('MASS_BALANCE_FILE')
   326)                     do
   327)                       waypoint => WaypointCreate()
   328)                       waypoint%time = temp_real
   329)                       waypoint%print_msbl_output = PETSC_TRUE
   330)                       call WaypointInsertInList(waypoint,waypoint_list)
   331)                       temp_real = temp_real + &
   332)                            output_option%periodic_msbl_output_time_incr
   333)                       if (temp_real > temp_real2) exit
   334)                     enddo
   335)                     output_option%periodic_msbl_output_time_incr = 0.d0
   336)                 end select
   337)               else
   338)                 input%ierr = 1
   339)                 call InputErrorMsg(input,option,'between',string)
   340)               endif
   341)             endif
   342)         !.................
   343)           case('TIMESTEP')
   344)             string = 'OUTPUT,' // trim(block_name) // ',TIMESTEP'
   345)             select case(trim(block_name))
   346)               case('SNAPSHOT_FILE')
   347)                 call InputReadInt(input,option, &
   348)                      output_option%periodic_snap_output_ts_imod)
   349)               case('OBSERVATION_FILE')
   350)                 call InputReadInt(input,option, &
   351)                      output_option%periodic_obs_output_ts_imod)
   352)               case('MASS_BALANCE_FILE')
   353)                 call InputReadInt(input,option, &
   354)                      output_option%periodic_msbl_output_ts_imod)
   355)             end select
   356)             call InputErrorMsg(input,option,'timestep increment',string)
   357)         !.............
   358)           case default
   359)             call InputKeywordUnrecognized(word,'OUTPUT,PERIODIC',option)
   360)         end select
   361) 
   362) !...................
   363)       case('SCREEN')
   364)         string = 'OUTPUT,' // trim(block_name) // ',SCREEN'
   365)         call InputReadWord(input,option,word,PETSC_TRUE)
   366)         call InputErrorMsg(input,option,'time increment',string)
   367)         call StringToUpper(word)
   368)         select case(trim(word))
   369)           case('OFF')
   370)             option%print_to_screen = PETSC_FALSE
   371)           case('PERIODIC')
   372)             string = trim(string) // ',PERIODIC'
   373)             call InputReadInt(input,option,output_option%screen_imod)
   374)             call InputErrorMsg(input,option,'timestep increment',string)
   375)           case default
   376)             call InputKeywordUnrecognized(word,string,option)
   377)         end select
   378) 
   379) !...................
   380)       case('FORMAT')
   381)         string = 'OUTPUT,' // trim(block_name) // ',FORMAT'
   382)         select case(trim(block_name))
   383)           case('OBSERVATION_FILE')
   384)             option%io_buffer = 'FORMAT cannot be specified within &
   385)                  &the OUTPUT,OBSERVATION_FILE block. Observation output is &
   386)                  &written in TECPLOT format only.'
   387)             call printErrMsg(option)
   388)           case('MASS_BALANCE_FILE')
   389)             option%io_buffer = 'FORMAT cannot be specified within &
   390)                  &the OUTPUT,MASS_BALANCE_FILE block. Mass balance output is &
   391)                  &written in TECPLOT format only.'
   392)             call printErrMsg(option)
   393)         end select
   394)         call InputReadWord(input,option,word,PETSC_TRUE)
   395)         call InputErrorMsg(input,option,'keyword',string) 
   396)         call StringToUpper(word)
   397)         select case(trim(word))
   398)         !..............
   399)           case ('HDF5')
   400)             string = trim(string) // ',HDF5'
   401)             output_option%print_hdf5 = PETSC_TRUE
   402)             call InputReadWord(input,option,word,PETSC_TRUE)
   403)             if (input%ierr /= 0) then
   404)               call InputDefaultMsg(input,option,string)
   405)               output_option%print_single_h5_file = PETSC_TRUE
   406)             else
   407)               call StringToUpper(word)
   408)               select case(trim(word))
   409)               !....................
   410)                 case('SINGLE_FILE')
   411)                   output_option%print_single_h5_file = PETSC_TRUE
   412)               !.......................
   413)                 case('MULTIPLE_FILES')
   414)                   string = trim(string) // ',MULTIPLE_FILES'
   415)                   output_option%print_single_h5_file = PETSC_FALSE
   416)                   output_option%times_per_h5_file = 1
   417)                   call InputReadWord(input,option,word,PETSC_TRUE)
   418)                   if (input%ierr == 0) then
   419)                     select case(trim(word))
   420)                       case('TIMES_PER_FILE')
   421)                         string = trim(string) // ',TIMES_PER_FILE'
   422)                         call InputReadInt(input,option, &
   423)                              output_option%times_per_h5_file)
   424)                         call InputErrorMsg(input,option,'timestep increment', &
   425)                                            string)
   426)                       case default
   427)                         call InputKeywordUnrecognized(word,string,option)
   428)                     end select
   429)                   endif
   430)               !.............
   431)                 case default
   432)                   call InputKeywordUnrecognized(word,string,option)
   433)               end select
   434)             endif
   435)         !.............
   436)           case ('MAD')
   437)             output_option%print_mad = PETSC_TRUE
   438)         !.................
   439)           case ('TECPLOT')
   440)             string = trim(string) // ',TECPLOT'
   441)             output_option%print_tecplot = PETSC_TRUE
   442)             call InputReadWord(input,option,word,PETSC_TRUE)
   443)             call InputErrorMsg(input,option,'TECPLOT format',string) 
   444)             call StringToUpper(word)
   445)             select case(trim(word))
   446)               case('POINT')
   447)                 output_option%tecplot_format = TECPLOT_POINT_FORMAT
   448)               case('BLOCK')
   449)                 output_option%tecplot_format = TECPLOT_BLOCK_FORMAT
   450)               case('FEBRICK')
   451)                 output_option%tecplot_format = TECPLOT_FEBRICK_FORMAT
   452)               case default
   453)                 call InputKeywordUnrecognized(word,string,option)
   454)             end select
   455)             if (output_option%tecplot_format == TECPLOT_POINT_FORMAT &
   456)                  .and. option%mycommsize > 1) then
   457)               output_option%tecplot_format = TECPLOT_BLOCK_FORMAT
   458)             endif
   459)             if (grid%itype == IMPLICIT_UNSTRUCTURED_GRID) then
   460)               output_option%tecplot_format = TECPLOT_FEBRICK_FORMAT
   461)             endif
   462)         !.............
   463)           case ('VTK')
   464)             output_option%print_vtk = PETSC_TRUE
   465)         !.............
   466)           case default
   467)             call InputKeywordUnrecognized(word,string,option)
   468)         end select
   469) 
   470) !...................................
   471)       case ('HDF5_WRITE_GROUP_SIZE')
   472)         string = 'OUTPUT,' // trim(block_name) // ',HDF5_WRITE_GROUP_SIZE'
   473)         call InputReadInt(input,option,option%hdf5_write_group_size)
   474)         call InputErrorMsg(input,option,'group size',string)
   475) 
   476) !......................
   477)       case('VARIABLES')
   478)         select case (option%iflowmode)
   479)           case(FLASH2_MODE,MPH_MODE)
   480)             option%io_buffer = 'A variable list cannot be specified for &
   481)                   &the CO2 flow modes. Variables are determined internally.'
   482)             call printErrMsg(option)
   483)         end select
   484)         select case(trim(block_name))
   485)           case('SNAPSHOT_FILE')           
   486)             call OutputVariableRead(input,option, &
   487)                  output_option%output_snap_variable_list)
   488)           case('OBSERVATION_FILE')           
   489)             call OutputVariableRead(input,option, &
   490)                  output_option%output_obs_variable_list)
   491)           case('MASS_BALANCE_FILE')
   492)             option%io_buffer = 'A variable list cannot be specified within &
   493)                  &the MASS_BALANCE_FILE block. Mass balance variables are &
   494)                  &determined internally.'
   495)             call printErrMsg(option)
   496)         end select
   497)         
   498) !.............................
   499)       case('PRINT_COLUMN_IDS')
   500)         output_option%print_column_ids = PETSC_TRUE
   501)         
   502) !.............................
   503)       case('DETAILED')
   504)         select case(trim(block_name))
   505)           case('MASS_BALANCE_FILE') 
   506)             option%mass_bal_detailed = PETSC_TRUE
   507)         end select
   508) 
   509) !...............................
   510)       case('VELOCITY_AT_CENTER')
   511)         vel_cent = PETSC_TRUE
   512)       case('VELOCITY_AT_FACE')
   513)         vel_face = PETSC_TRUE
   514) 
   515) !...................
   516)       case('FLUXES')
   517)         fluxes = PETSC_TRUE
   518)       case('FLOWRATES','FLOWRATE')
   519)         mass_flowrate = PETSC_TRUE
   520)         energy_flowrate = PETSC_TRUE
   521)       case('MASS_FLOWRATE')
   522)         mass_flowrate = PETSC_TRUE
   523)       case('ENERGY_FLOWRATE')
   524)         energy_flowrate = PETSC_TRUE
   525)       case('AVERAGE_FLOWRATES','AVERAGE_FLOWRATE')
   526)         aveg_mass_flowrate = PETSC_TRUE
   527)         aveg_energy_flowrate = PETSC_TRUE
   528)       case('AVERAGE_MASS_FLOWRATE')
   529)         aveg_mass_flowrate = PETSC_TRUE
   530)       case('AVERAGE_ENERGY_FLOWRATE')
   531)         aveg_energy_flowrate = PETSC_TRUE
   532) 
   533) !.................
   534)       case default
   535)         string = 'OUTPUT,' // trim(block_name)
   536)         call InputKeywordUnrecognized(word,string,option)
   537)     end select
   538)   enddo
   539)   
   540) 
   541)   if (vel_cent) then
   542)     if (output_option%print_tecplot) &
   543)          output_option%print_tecplot_vel_cent = PETSC_TRUE
   544)     if (output_option%print_hdf5) &
   545)          output_option%print_hdf5_vel_cent = PETSC_TRUE
   546)     if (output_option%print_vtk) &
   547)          output_option%print_vtk_vel_cent = PETSC_TRUE
   548)   endif
   549) 
   550)   if (vel_face) then
   551)     if (output_option%print_tecplot) &
   552)          output_option%print_tecplot_vel_face = PETSC_TRUE
   553)     if (output_option%print_hdf5) &
   554)          output_option%print_hdf5_vel_face = PETSC_TRUE
   555)   endif
   556) 
   557)   if (fluxes) then
   558)     output_option%print_fluxes = PETSC_TRUE
   559)   endif
   560) 
   561)   if(output_option%aveg_output_variable_list%nvars>0) then
   562)     if(output_option%periodic_snap_output_time_incr==0.d0) then
   563)       option%io_buffer = 'Keyword: AVERAGE_VARIABLES defined without &
   564)                          &PERIODIC TIME being set.'
   565)       call printErrMsg(option)
   566)     endif
   567)     if(.not.output_option%print_hdf5) then
   568)       option%io_buffer = 'Keyword: AVERAGE_VARIABLES only defined for &
   569)                          &FORMAT HDF5'
   570)       call printErrMsg(option)
   571)     endif
   572)   endif
   573) 
   574)   if (mass_flowrate.or.energy_flowrate.or.aveg_mass_flowrate &
   575)        .or.aveg_energy_flowrate) then
   576)     if (output_option%print_hdf5) then
   577)       output_option%print_hdf5_mass_flowrate = mass_flowrate
   578)       output_option%print_hdf5_energy_flowrate = energy_flowrate
   579)       output_option%print_hdf5_aveg_mass_flowrate = aveg_mass_flowrate
   580)       output_option%print_hdf5_aveg_energy_flowrate = aveg_energy_flowrate
   581)       if(aveg_mass_flowrate.or.aveg_energy_flowrate) then
   582)         if(output_option%periodic_snap_output_time_incr==0.d0) then
   583)           option%io_buffer = 'Keyword: AVEGRAGE_FLOWRATES/&
   584)                              &AVEGRAGE_MASS_FLOWRATE/ENERGY_FLOWRATE &
   585)                              &defined without PERIODIC TIME being set.'
   586)           call printErrMsg(option)
   587)         endif
   588)       endif
   589)       option%flow%store_fluxes = PETSC_TRUE
   590)     endif
   591)     if (associated(grid%unstructured_grid%explicit_grid)) then
   592)       option%flow%store_fluxes = PETSC_TRUE
   593)       output_option%print_explicit_flowrate = mass_flowrate
   594)     endif
   595)   endif
   596)   
   597) end subroutine OutputFileRead
   598) 
   599) ! ************************************************************************** !
   600) 
   601) subroutine OutputVariableRead(input,option,output_variable_list)
   602)   ! 
   603)   ! This routine reads a variable from the input file.
   604)   ! 
   605)   ! Author: Gautam Bisht, LBNL; Glenn Hammond PNNL/SNL
   606)   ! Date: 12/21/12
   607)   ! 
   608) 
   609)   use Option_module
   610)   use Input_Aux_module
   611)   use String_module
   612)   use Variables_module
   613) 
   614)   implicit none
   615) 
   616)   type(option_type), pointer :: option
   617)   type(input_type), pointer :: input
   618)   type(output_variable_list_type), pointer :: output_variable_list
   619)   
   620)   character(len=MAXWORDLENGTH) :: word
   621)   character(len=MAXWORDLENGTH) :: name, units
   622)   type(output_variable_type), pointer :: output_variable
   623)   PetscInt :: temp_int
   624) 
   625)   do
   626)     call InputReadPflotranString(input,option)
   627)     if (InputError(input)) exit
   628)     if (InputCheckExit(input,option)) exit
   629)     
   630)     call InputReadWord(input,option,word,PETSC_TRUE)
   631)     call InputErrorMsg(input,option,'keyword','VARIABLES')
   632)     call StringToUpper(word)
   633)     
   634)     select case(trim(word))
   635)       case ('MAXIMUM_PRESSURE')
   636)         name = 'Maximum Pressure'
   637)         units = 'Pa'
   638)         call OutputVariableAddToList(output_variable_list,name, &
   639)                                      OUTPUT_PRESSURE,units, &
   640)                                      MAXIMUM_PRESSURE)
   641)       case ('LIQUID_PRESSURE')
   642)         name = 'Liquid Pressure'
   643)         units = 'Pa'
   644)         call OutputVariableAddToList(output_variable_list,name, &
   645)                                      OUTPUT_PRESSURE,units, &
   646)                                      LIQUID_PRESSURE)
   647)       case ('LIQUID_SATURATION')
   648)         name = 'Liquid Saturation'
   649)         units = ''
   650)         call OutputVariableAddToList(output_variable_list,name, &
   651)                                      OUTPUT_SATURATION,units, &
   652)                                      LIQUID_SATURATION)
   653)       case ('LIQUID_HEAD')
   654)         name = 'Liquid Head'
   655)         units = 'm'
   656)         call OutputVariableAddToList(output_variable_list,name, &
   657)                                      OUTPUT_GENERIC,units, &
   658)                                      LIQUID_HEAD)
   659)         
   660)       case ('LIQUID_DENSITY')
   661)         name = 'Liquid Density'
   662)         call InputReadWord(input,option,word,PETSC_TRUE)
   663)         if (input%ierr == 0) then
   664)           if (StringCompareIgnoreCase(word,'MOLAR')) then
   665)             units = 'kmol/m^3'
   666)             temp_int = LIQUID_DENSITY_MOL
   667)           else
   668)             call InputErrorMsg(input,option,'optional keyword', &
   669)                                'VARIABLES,LIQUID_DENSITY')
   670)           endif
   671)         else
   672)           units = 'kg/m^3'
   673)           temp_int = LIQUID_DENSITY
   674)         endif
   675)         call OutputVariableAddToList(output_variable_list,name, &
   676)                                      OUTPUT_GENERIC,units, &
   677)                                      temp_int)
   678)       case ('LIQUID_MOBILITY')
   679)         name = 'Liquid Mobility'
   680)         units = '1/Pa-s'
   681)         call OutputVariableAddToList(output_variable_list,name, &
   682)                                      OUTPUT_GENERIC,units, &
   683)                                      LIQUID_MOBILITY)
   684)       case ('LIQUID_ENERGY')
   685)         name = 'Liquid Energy'
   686)         call InputReadWord(input,option,word,PETSC_TRUE)
   687)         if (input%ierr == 0) then
   688)           if (StringCompareIgnoreCase(word,'PER_VOLUME')) then
   689)             units = 'MJ/m^3'
   690)             temp_int = ONE_INTEGER
   691)           else
   692)             call InputErrorMsg(input,option,'optional keyword', &
   693)                                'VARIABLES,LIQUID_ENERGY')
   694)           endif
   695)         else
   696)           units = 'MJ/kmol'
   697)           temp_int = ZERO_INTEGER
   698)         endif
   699)         call OutputVariableAddToList(output_variable_list,name, &
   700)                                      OUTPUT_GENERIC,units, &
   701)                                      LIQUID_ENERGY,temp_int)
   702)     
   703)       case ('GAS_PRESSURE')
   704)         name = 'Gas Pressure'
   705)         units = 'Pa'
   706)         call OutputVariableAddToList(output_variable_list,name, &
   707)                                      OUTPUT_PRESSURE,units, &
   708)                                      GAS_PRESSURE)
   709)       case ('GAS_SATURATION')
   710)         name = 'Gas Saturation'
   711)         units = ''
   712)         call OutputVariableAddToList(output_variable_list,name, &
   713)                                      OUTPUT_SATURATION,units, &
   714)                                      GAS_SATURATION)
   715)       case ('GAS_DENSITY')
   716)         name = 'Gas Density'
   717)         call InputReadWord(input,option,word,PETSC_TRUE)
   718)         if (input%ierr == 0) then
   719)           if (StringCompareIgnoreCase(word,'MOLAR')) then
   720)             units = 'kmol/m^3'
   721)             temp_int = GAS_DENSITY_MOL
   722)           else
   723)             call InputErrorMsg(input,option,'optional keyword', &
   724)                                'VARIABLES,GAS_DENSITY')
   725)           endif
   726)         else
   727)           units = 'kg/m^3'
   728)           temp_int = GAS_DENSITY
   729)         endif
   730)         call OutputVariableAddToList(output_variable_list,name, &
   731)                                      OUTPUT_GENERIC,units, &
   732)                                      temp_int)
   733)       case ('GAS_MOBILITY')
   734)         name = 'Gas Mobility'
   735)         units = '1/Pa-s'
   736)         call OutputVariableAddToList(output_variable_list,name, &
   737)                                      OUTPUT_GENERIC,units, &
   738)                                      GAS_MOBILITY)
   739)       case ('GAS_ENERGY')
   740)         name = 'Gas Energy'
   741)         call InputReadWord(input,option,word,PETSC_TRUE)
   742)         if (input%ierr == 0) then
   743)           if (StringCompareIgnoreCase(word,'PER_VOLUME')) then
   744)             units = 'MJ/m^3'
   745)             temp_int = ONE_INTEGER
   746)           else
   747)             input%ierr = 1
   748)             call InputErrorMsg(input,option,'optional keyword', &
   749)                                'VARIABLES,GAS_ENERGY')
   750)           endif
   751)         else
   752)           units = 'MJ/kmol'
   753)           temp_int = ZERO_INTEGER
   754)         endif
   755)         call OutputVariableAddToList(output_variable_list,name, &
   756)                                      OUTPUT_GENERIC,units, &
   757)                                      GAS_ENERGY,temp_int)
   758)       case ('OIL_PRESSURE')
   759)         name = 'Oil Pressure'
   760)         units = 'Pa'
   761)         call OutputVariableAddToList(output_variable_list,name, &
   762)                                      OUTPUT_PRESSURE,units, &
   763)                                      OIL_PRESSURE)
   764)       case ('OIL_SATURATION')
   765)         name = 'Oil Saturation'
   766)         units = ''
   767)         call OutputVariableAddToList(output_variable_list,name, &
   768)                                      OUTPUT_SATURATION,units, &
   769)                                      OIL_SATURATION)
   770)       case ('OIL_DENSITY')
   771)         name = 'Oil Density'
   772)         call InputReadWord(input,option,word,PETSC_TRUE)
   773)         if (input%ierr == 0) then
   774)           if (StringCompareIgnoreCase(word,'MOLAR')) then
   775)             units = 'kmol/m^3'
   776)             temp_int = OIL_DENSITY_MOL
   777)           else
   778)             call InputErrorMsg(input,option,'optional keyword', &
   779)                                'VARIABLES,OIL_DENSITY')
   780)           endif
   781)         else
   782)           units = 'kg/m^3'
   783)           temp_int = OIL_DENSITY
   784)         endif
   785)         call OutputVariableAddToList(output_variable_list,name, &
   786)                                      OUTPUT_GENERIC,units, &
   787)                                      temp_int)
   788)       case ('OIL_MOBILITY')
   789)         name = 'Oil Mobility'
   790)         units = '1/Pa-s'
   791)         call OutputVariableAddToList(output_variable_list,name, &
   792)                                      OUTPUT_GENERIC,units, &
   793)                                      OIL_MOBILITY)
   794)       case ('OIL_ENERGY')
   795)         name = 'Oil Energy'
   796)         call InputReadWord(input,option,word,PETSC_TRUE)
   797)         if (input%ierr == 0) then
   798)           if (StringCompareIgnoreCase(word,'PER_VOLUME')) then
   799)             units = 'MJ/m^3'
   800)             temp_int = ONE_INTEGER
   801)           else
   802)             input%ierr = 1
   803)             call InputErrorMsg(input,option,'optional keyword', &
   804)                                'VARIABLES,OIL_ENERGY')
   805)           endif
   806)         else
   807)           units = 'MJ/kmol'
   808)           temp_int = ZERO_INTEGER
   809)         endif
   810)         call OutputVariableAddToList(output_variable_list,name, &
   811)                                      OUTPUT_GENERIC,units, &
   812)                                      OIL_ENERGY,temp_int)
   813)       case ('LIQUID_MOLE_FRACTIONS')
   814)         name = 'X_g^l'
   815)         units = ''
   816)         call OutputVariableAddToList(output_variable_list,name, &
   817)                                      OUTPUT_GENERIC,units, &
   818)                                      LIQUID_MOLE_FRACTION, &
   819)                                      option%air_id)
   820)         name = 'X_l^l'
   821)         units = ''
   822)         call OutputVariableAddToList(output_variable_list,name, &
   823)                                      OUTPUT_GENERIC,units, &
   824)                                      LIQUID_MOLE_FRACTION, &
   825)                                      option%water_id)
   826)       case ('GAS_MOLE_FRACTIONS')
   827)         name = 'X_g^g'
   828)         units = ''
   829)         call OutputVariableAddToList(output_variable_list,name, &
   830)                                      OUTPUT_GENERIC,units, &
   831)                                      GAS_MOLE_FRACTION, &
   832)                                      option%air_id)
   833)         name = 'X_l^g'
   834)         units = ''
   835)         call OutputVariableAddToList(output_variable_list,name, &
   836)                                      OUTPUT_GENERIC,units, &
   837)                                      GAS_MOLE_FRACTION, &
   838)                                      option%water_id)
   839)       case ('LIQUID_MASS_FRACTIONS')
   840)         name = 'w_g^l'
   841)         units = ''
   842)         call OutputVariableAddToList(output_variable_list,name, &
   843)                                      OUTPUT_GENERIC,units, &
   844)                                      LIQUID_MASS_FRACTION, &
   845)                                      option%air_id)
   846)         name = 'w_l^l'
   847)         units = ''
   848)         call OutputVariableAddToList(output_variable_list,name, &
   849)                                      OUTPUT_GENERIC,units, &
   850)                                      LIQUID_MASS_FRACTION, &
   851)                                      option%water_id)
   852)       case ('GAS_MASS_FRACTIONS')
   853)         name = 'w_g^g'
   854)         units = ''
   855)         call OutputVariableAddToList(output_variable_list,name, &
   856)                                      OUTPUT_GENERIC,units, &
   857)                                      GAS_MASS_FRACTION, &
   858)                                      option%air_id)
   859)         name = 'w_l^g'
   860)         units = ''
   861)         call OutputVariableAddToList(output_variable_list,name, &
   862)                                      OUTPUT_GENERIC,units, &
   863)                                      GAS_MASS_FRACTION, &
   864)                                      option%water_id)
   865)       case ('AIR_PRESSURE')
   866)         name = 'Air Pressure'
   867)         units = 'Pa'
   868)         call OutputVariableAddToList(output_variable_list,name, &
   869)                                      OUTPUT_PRESSURE,units, &
   870)                                      AIR_PRESSURE)
   871)       case ('CAPILLARY_PRESSURE')
   872)         name = 'Capillary Pressure'
   873)         units = 'Pa'
   874)         call OutputVariableAddToList(output_variable_list,name, &
   875)                                      OUTPUT_PRESSURE,units, &
   876)                                      CAPILLARY_PRESSURE)
   877)       case ('VAPOR_PRESSURE')
   878)         name = 'Vapor Pressure'
   879)         units = 'Pa'
   880)         call OutputVariableAddToList(output_variable_list,name, &
   881)                                      OUTPUT_PRESSURE,units, &
   882)                                      VAPOR_PRESSURE)
   883)       case ('SATURATION_PRESSURE')
   884)         name = 'Saturation Pressure'
   885)         units = 'Pa'
   886)         call OutputVariableAddToList(output_variable_list,name, &
   887)                                      OUTPUT_PRESSURE,units, &
   888)                                      SATURATION_PRESSURE)
   889)       case('THERMODYNAMIC_STATE')
   890)         name = 'Thermodynamic State'
   891)          units = ''
   892)          output_variable => OutputVariableCreate(name,OUTPUT_DISCRETE, &
   893)                                                  units,STATE)
   894)          ! toggle output off for observation
   895) !geh: nope, this can change over time.
   896) !geh         output_variable%plot_only = PETSC_TRUE 
   897) 
   898)          output_variable%iformat = 1 ! integer
   899)          call OutputVariableAddToList(output_variable_list,output_variable)
   900)          nullify(output_variable)
   901)       case ('TEMPERATURE')
   902)         name = 'Temperature'
   903)         units = 'C'
   904)         call OutputVariableAddToList(output_variable_list,name, &
   905)                                      OUTPUT_GENERIC,units, &
   906)                                      TEMPERATURE)
   907)       case ('RESIDUAL')
   908)         units = ''
   909)         do temp_int = 1, option%nflowdof
   910)           write(word,*) temp_int
   911)           name = 'Residual_' // trim(adjustl(word))
   912)           call OutputVariableAddToList(output_variable_list,name, &
   913)                                        OUTPUT_GENERIC,units, &
   914)                                        RESIDUAL,temp_int)
   915)         enddo
   916)       case ('POROSITY')
   917)         units = ''
   918)         name = 'Porosity'
   919)         call OutputVariableAddToList(output_variable_list,name, &
   920)                                      OUTPUT_GENERIC,units, &
   921)                                      POROSITY)
   922)       case ('MINERAL_POROSITY')
   923)         units = ''
   924)         name = 'Mineral Porosity'
   925)         call OutputVariableAddToList(output_variable_list,name, &
   926)                                      OUTPUT_GENERIC,units, &
   927)                                      MINERAL_POROSITY)
   928)       case ('EFFECTIVE_POROSITY')
   929)         units = ''
   930)         name = 'Effective Porosity'
   931)         call OutputVariableAddToList(output_variable_list,name, &
   932)                                      OUTPUT_GENERIC,units, &
   933)                                      EFFECTIVE_POROSITY)
   934)       case ('TORTUOSITY')
   935)         units = ''
   936)         name = 'Tortuosity'
   937)         call OutputVariableAddToList(output_variable_list,name, &
   938)                                      OUTPUT_GENERIC,units, &
   939)                                      TORTUOSITY)
   940)       case ('PERMEABILITY','PERMEABILITY_X')
   941)         units = 'm^2'
   942)         name = 'Permeability X'
   943)         call OutputVariableAddToList(output_variable_list,name, &
   944)                                      OUTPUT_GENERIC,units, &
   945)                                      PERMEABILITY)
   946)       case ('PERMEABILITY_Y')
   947)         units = 'm^2'
   948)         name = 'Permeability Y'
   949)         call OutputVariableAddToList(output_variable_list,name, &
   950)                                      OUTPUT_GENERIC,units, &
   951)                                      PERMEABILITY_Y)
   952)       case ('PERMEABILITY_Z')
   953)         units = 'm^2'
   954)         name = 'Permeability Z'
   955)         call OutputVariableAddToList(output_variable_list,name, &
   956)                                      OUTPUT_GENERIC,units, &
   957)                                      PERMEABILITY_Z)
   958)       case ('SOIL_COMPRESSIBILITY')
   959)         units = ''
   960)         name = 'Compressibility'
   961)         call OutputVariableAddToList(output_variable_list,name, &
   962)                                      OUTPUT_GENERIC,units, &
   963)                                      SOIL_COMPRESSIBILITY)
   964)       case ('SOIL_REFERENCE_PRESSURE')
   965)         units = 'Pa'
   966)         name = 'Soil Reference Pressure'
   967)         call OutputVariableAddToList(output_variable_list,name, &
   968)                                      OUTPUT_GENERIC,units, &
   969)                                      SOIL_REFERENCE_PRESSURE)
   970)       case ('PROCESS_ID')
   971)         units = ''
   972)         name = 'Process ID'
   973)         output_variable => OutputVariableCreate(name,OUTPUT_DISCRETE, &
   974)                                                 units,PROCESS_ID)
   975)         output_variable%plot_only = PETSC_TRUE ! toggle output off for observation
   976)         output_variable%iformat = 1 ! integer
   977)         call OutputVariableAddToList(output_variable_list,output_variable)
   978)       case ('VOLUME')
   979)         units = 'm^3'
   980)         name = 'Volume'
   981)         output_variable => OutputVariableCreate(name,OUTPUT_GENERIC, &
   982)                                                 units,VOLUME)
   983)         output_variable%plot_only = PETSC_TRUE ! toggle output off for observation
   984)         output_variable%iformat = 0 ! double
   985)         call OutputVariableAddToList(output_variable_list,output_variable)
   986)       case ('MATERIAL_ID')
   987)         units = ''
   988)         name = 'Material ID'
   989)         output_variable => OutputVariableCreate(name,OUTPUT_DISCRETE, &
   990)                                                 units,MATERIAL_ID)
   991)         output_variable%plot_only = PETSC_TRUE ! toggle output off for observation
   992)         output_variable%iformat = 1 ! integer
   993)         call OutputVariableAddToList(output_variable_list,output_variable)
   994)       case ('MATERIAL_ID_KLUDGE_FOR_VISIT')
   995)         units = ''
   996)         name = 'Kludged material ids for VisIt'
   997)         output_variable => OutputVariableCreate(name,OUTPUT_DISCRETE, &
   998)                                                 units,MATERIAL_ID)
   999)         output_variable%plot_only = PETSC_TRUE ! toggle output off for observation
  1000)         output_variable%iformat = 1 ! integer
  1001)         call OutputVariableAddToList(output_variable_list,output_variable)
  1002)       case default
  1003)         call InputKeywordUnrecognized(word,'VARIABLES',option)
  1004)     end select
  1005) 
  1006)   enddo
  1007) 
  1008) end subroutine OutputVariableRead
  1009) 
  1010) ! ************************************************************************** !
  1011) 
  1012) subroutine Output(realization_base,snapshot_plot_flag,observation_plot_flag, &
  1013)                   massbal_plot_flag)
  1014)   ! 
  1015)   ! Main driver for all output subroutines
  1016)   ! 
  1017)   ! Author: Glenn Hammond
  1018)   ! Date: 10/25/07
  1019)   ! Notes: Modified by Jenn Frederick, 2/23/2016
  1020)   ! 
  1021) 
  1022)   use Realization_Base_class, only : realization_base_type
  1023)   use Option_module, only : OptionCheckTouch, option_type, printMsg, printErrMsg
  1024)   
  1025)   implicit none
  1026)   
  1027)   class(realization_base_type) :: realization_base
  1028)   PetscBool :: snapshot_plot_flag
  1029)   PetscBool :: observation_plot_flag
  1030)   PetscBool :: massbal_plot_flag
  1031) 
  1032)   character(len=MAXSTRINGLENGTH) :: string
  1033)   PetscErrorCode :: ierr
  1034)   PetscLogDouble :: tstart, tend
  1035)   type(option_type), pointer :: option
  1036) 
  1037)   option => realization_base%option
  1038)   
  1039)   call PetscLogStagePush(logging%stage(OUTPUT_STAGE),ierr);CHKERRQ(ierr)
  1040) 
  1041)   ! check for plot request from active directory
  1042)   if (.not.snapshot_plot_flag) then
  1043) 
  1044)     if (option%use_touch_options) then
  1045)       string = 'plot'
  1046)       if (OptionCheckTouch(option,string)) then
  1047)         realization_base%output_option%plot_name = 'plot'
  1048)         snapshot_plot_flag = PETSC_TRUE
  1049)       endif
  1050)     endif
  1051) 
  1052)   endif
  1053) 
  1054) !.................................
  1055)   if (snapshot_plot_flag) then
  1056) 
  1057)     if (realization_base%output_option%print_hdf5) then
  1058)       call PetscTime(tstart,ierr);CHKERRQ(ierr)
  1059)       call PetscLogEventBegin(logging%event_output_hdf5,ierr);CHKERRQ(ierr)
  1060)       if (realization_base%discretization%itype == UNSTRUCTURED_GRID) then
  1061)         select case (realization_base%discretization%grid%itype)
  1062)           case (EXPLICIT_UNSTRUCTURED_GRID)
  1063)              call OutputHDF5UGridXDMFExplicit(realization_base, &
  1064)                   INSTANTANEOUS_VARS)
  1065)           case (IMPLICIT_UNSTRUCTURED_GRID)
  1066)             call OutputHDF5UGridXDMF(realization_base,INSTANTANEOUS_VARS)
  1067)           case (POLYHEDRA_UNSTRUCTURED_GRID)
  1068)             call printErrMsg(option,'Add code for HDF5 output for &
  1069)                                     &Polyhedra mesh')
  1070)         end select
  1071)       else
  1072)         call OutputHDF5(realization_base,INSTANTANEOUS_VARS)
  1073)       endif      
  1074)       call PetscLogEventEnd(logging%event_output_hdf5,ierr);CHKERRQ(ierr)
  1075)       call PetscTime(tend,ierr);CHKERRQ(ierr)
  1076) #ifdef SCORPIO_WRITE
  1077)       if (option%myrank == 0) write (*,'(" Parallel IO Write method is used in &
  1078)         &writing the output, HDF5_WRITE_GROUP_SIZE = ",i5)') &
  1079)         option%hdf5_write_group_size
  1080) #endif
  1081)       write(option%io_buffer,'(f10.2," Seconds to write HDF5 file.")') &
  1082)             tend-tstart
  1083)       call printMsg(option)
  1084)     endif
  1085)    
  1086)     if (realization_base%output_option%print_tecplot) then
  1087)       call PetscTime(tstart,ierr);CHKERRQ(ierr)
  1088)       call PetscLogEventBegin(logging%event_output_tecplot,ierr);CHKERRQ(ierr)
  1089)       select case(realization_base%output_option%tecplot_format)
  1090)         case (TECPLOT_POINT_FORMAT)
  1091)           call OutputTecplotPoint(realization_base)
  1092)         case (TECPLOT_BLOCK_FORMAT,TECPLOT_FEBRICK_FORMAT)
  1093)           call OutputTecplotBlock(realization_base)
  1094)       end select
  1095)       call PetscLogEventEnd(logging%event_output_tecplot,ierr);CHKERRQ(ierr)
  1096)       call PetscTime(tend,ierr);CHKERRQ(ierr)
  1097)       write(option%io_buffer,'(f10.2," Seconds to write to Tecplot file(s)")') &
  1098)             tend-tstart
  1099)       call printMsg(option)        
  1100)     endif
  1101)     
  1102)     if (realization_base%output_option%print_explicit_flowrate) then
  1103)       call PetscTime(tstart,ierr);CHKERRQ(ierr)
  1104)       call PetscLogEventBegin(logging%event_output_tecplot,ierr);CHKERRQ(ierr)
  1105)       call OutputPrintExplicitFlowrates(realization_base)
  1106)       call PetscLogEventEnd(logging%event_output_tecplot,ierr);CHKERRQ(ierr)
  1107)       call PetscTime(tend,ierr);CHKERRQ(ierr)
  1108)       write(option%io_buffer,'(f10.2," Seconds to write to Rates file.")') &
  1109)             tend-tstart
  1110)       call printMsg(option)        
  1111)     endif
  1112) 
  1113)     if (realization_base%output_option%print_vtk) then
  1114)       call PetscTime(tstart,ierr);CHKERRQ(ierr)
  1115)       call PetscLogEventBegin(logging%event_output_vtk,ierr);CHKERRQ(ierr)
  1116)       call OutputVTK(realization_base)
  1117) 
  1118)       call PetscLogEventEnd(logging%event_output_vtk,ierr);CHKERRQ(ierr)
  1119)       call PetscTime(tend,ierr);CHKERRQ(ierr)
  1120)       write(option%io_buffer,'(f10.2," Seconds to write to VTK file(s)")') &
  1121)             tend-tstart
  1122)       call printMsg(option) 
  1123)     endif
  1124)       
  1125)     if (realization_base%output_option%print_mad) then
  1126)       call PetscTime(tstart,ierr);CHKERRQ(ierr)
  1127)       call PetscLogEventBegin(logging%event_output_mad,ierr);CHKERRQ(ierr)
  1128)       call OutputMAD(realization_base)
  1129) 
  1130)       call PetscLogEventEnd(logging%event_output_mad,ierr);CHKERRQ(ierr)
  1131)       call PetscTime(tend,ierr);CHKERRQ(ierr)
  1132)       write(option%io_buffer,'(f10.2," Seconds to write to MAD HDF5 &
  1133)                              &file(s)")') tend-tstart
  1134)       call printMsg(option) 
  1135)     endif
  1136)     
  1137)     ! Print secondary continuum variables vs sec. continuum dist.
  1138)     if (option%use_mc) then
  1139)       if (realization_base%output_option%print_tecplot) then
  1140)         call PetscTime(tstart,ierr);CHKERRQ(ierr)
  1141)         call PetscLogEventBegin(logging%event_output_secondary_tecplot, &
  1142)                                 ierr);CHKERRQ(ierr)
  1143)         call OutputSecondaryContinuumTecplot(realization_base)
  1144)         call PetscLogEventEnd(logging%event_output_secondary_tecplot, &
  1145)                               ierr);CHKERRQ(ierr)
  1146)         call PetscTime(tend,ierr);CHKERRQ(ierr)
  1147)         write(option%io_buffer,'(f10.2," Seconds to write to secondary' // &
  1148)               ' continuum Tecplot file(s)")') &
  1149)               tend-tstart
  1150)         call printMsg(option) 
  1151)       endif
  1152)     endif
  1153)       
  1154)     if (option%compute_statistics) then
  1155)       call ComputeFlowCellVelocityStats(realization_base)
  1156)       call ComputeFlowFluxVelocityStats(realization_base)
  1157)     endif
  1158) 
  1159)   endif
  1160)   
  1161) !.................................
  1162)   if (observation_plot_flag) then
  1163)     call OutputObservation(realization_base)
  1164)   endif
  1165) 
  1166) !.................................
  1167)   if (massbal_plot_flag) then
  1168)     call OutputMassBalance(realization_base)
  1169)   endif
  1170) 
  1171)   ! Output temporally average variables 
  1172)   call OutputAvegVars(realization_base)
  1173) 
  1174)   if (snapshot_plot_flag) then
  1175)     realization_base%output_option%plot_number = &
  1176)       realization_base%output_option%plot_number + 1
  1177)   endif
  1178) 
  1179)   snapshot_plot_flag = PETSC_FALSE
  1180)   observation_plot_flag = PETSC_FALSE
  1181)   massbal_plot_flag = PETSC_FALSE
  1182)   realization_base%output_option%plot_name = ''
  1183) 
  1184)   call PetscLogStagePop(ierr);CHKERRQ(ierr)
  1185) 
  1186) end subroutine Output
  1187) 
  1188) ! ************************************************************************** !
  1189) 
  1190) subroutine OutputInputRecord(output_option,waypoint_list)
  1191)   ! 
  1192)   ! Writes ingested information to the input record file.
  1193)   ! 
  1194)   ! Author: Jenn Frederick, SNL
  1195)   ! Date: 03/17/2016
  1196)   !  
  1197)   use Output_Aux_module
  1198)   use Waypoint_module
  1199) 
  1200)   implicit none
  1201) 
  1202)   type(output_option_type), pointer :: output_option
  1203)   type(waypoint_list_type), pointer :: waypoint_list
  1204)   
  1205)   type(waypoint_type), pointer :: cur_waypoint
  1206)   type(output_variable_type), pointer :: cur_variable
  1207)   character(len=MAXWORDLENGTH) :: word
  1208)   character(len=MAXSTRINGLENGTH) :: snap_string,obs_string,msbl_string
  1209)   PetscBool :: snap_output_found,obs_output_found,msbl_output_found
  1210)   PetscInt :: id = INPUT_RECORD_UNIT  
  1211)   character(len=10) :: Format
  1212)   
  1213)   Format = '(ES14.7)'
  1214) 
  1215)   write(id,'(a)') ' '
  1216)     write(id,'(a)') '---------------------------------------------------------&
  1217)                     &-----------------------'
  1218)   write(id,'(a29)',advance='no') '---------------------------: '
  1219)   write(id,'(a)') 'OUTPUT FILES'
  1220) 
  1221)   write(id,'(a29)',advance='no') 'periodic screen: '
  1222)   if (output_option%screen_imod /= 0) then
  1223)     write(id,'(a)') 'ON'
  1224)     write(id,'(a29)',advance='no') 'screen increment: '
  1225)     write(word,*) output_option%screen_imod
  1226)     write(id,'(a)') adjustl(trim(word))
  1227)   else
  1228)     write(id,'(a)') 'OFF'
  1229)   endif
  1230) 
  1231)   write(id,'(a29)',advance='no') 'output time unit: '
  1232)   write(id,'(a)') trim(output_option%tunit)
  1233) 
  1234)   snap_string = ''
  1235)   obs_string = ''
  1236)   msbl_string = ''
  1237)   snap_output_found = PETSC_FALSE
  1238)   obs_output_found = PETSC_FALSE
  1239)   msbl_output_found = PETSC_FALSE
  1240)   cur_waypoint => waypoint_list%first
  1241)   do
  1242)     if (.not.associated(cur_waypoint)) exit
  1243)     if (cur_waypoint%print_snap_output) then
  1244)       snap_output_found = PETSC_TRUE
  1245)       write(word,Format) cur_waypoint%time / output_option%tconv
  1246)       snap_string = trim(snap_string) // adjustl(trim(word)) // ','
  1247)     endif
  1248)     if (cur_waypoint%print_obs_output) then
  1249)       obs_output_found = PETSC_TRUE
  1250)       write(word,Format) cur_waypoint%time / output_option%tconv
  1251)       obs_string = trim(obs_string) // adjustl(trim(word)) // ','
  1252)     endif
  1253)     if (cur_waypoint%print_msbl_output) then
  1254)       msbl_output_found = PETSC_TRUE
  1255)       write(word,Format) cur_waypoint%time / output_option%tconv
  1256)       msbl_string = trim(msbl_string) // adjustl(trim(word)) // ','
  1257)     endif
  1258)     cur_waypoint => cur_waypoint%next
  1259)   enddo
  1260) 
  1261)   write(id,'(a29)',advance='no') '---------------------------: '
  1262)   write(id,'(a)') 'snapshot file output'
  1263)   if (output_option%print_tecplot) then
  1264)     write(id,'(a29)',advance='no') 'format: '
  1265)     if (output_option%tecplot_format == TECPLOT_POINT_FORMAT) then
  1266)       write(id,'(a)') 'tecplot point'
  1267)     endif
  1268)     if (output_option%tecplot_format == TECPLOT_BLOCK_FORMAT) then
  1269)       write(id,'(a)') 'tecplot block'
  1270)     endif
  1271)     if (output_option%tecplot_format == TECPLOT_FEBRICK_FORMAT) then
  1272)       write(id,'(a)') 'tecplot febrick'
  1273)     endif
  1274)     if (output_option%print_fluxes) then
  1275)       write(id,'(a29)',advance='no') ' '
  1276)       write(id,'(a)') 'print fluxes'
  1277)     endif
  1278)     if (output_option%print_tecplot_vel_cent) then
  1279)       write(id,'(a29)',advance='no') ' '
  1280)       write(id,'(a)') 'velocity on cell centers'
  1281)     endif
  1282)     if (output_option%print_tecplot_vel_face) then
  1283)       write(id,'(a29)',advance='no') ' '
  1284)       write(id,'(a)') 'velocity on cell faces'
  1285)     endif
  1286)   endif
  1287)   if (output_option%print_hdf5) then
  1288)     write(id,'(a29)',advance='no') 'format: '
  1289)     if (output_option%print_single_h5_file) then
  1290)       write(id,'(a)') 'hd5f, single file'
  1291)     endif
  1292)     if (output_option%times_per_h5_file /= 1) then
  1293)       write(word,*) output_option%times_per_h5_file
  1294)       write(id,'(a)') 'hdf5, ' // trim(word) // ' times per file'
  1295)     endif
  1296)     if (output_option%print_hdf5_vel_cent) then
  1297)       write(id,'(a29)',advance='no') ' '
  1298)       write(id,'(a)') 'velocity on cell centers'
  1299)     endif
  1300)     if (output_option%print_hdf5_vel_face) then
  1301)       write(id,'(a29)',advance='no') ' '
  1302)       write(id,'(a)') 'velocity on cell faces'
  1303)     endif
  1304)     if (output_option%print_hdf5_mass_flowrate) then
  1305)       write(id,'(a29)',advance='no') ' '
  1306)       write(id,'(a)') 'mass flow rate'
  1307)     endif
  1308)     if (output_option%print_hdf5_energy_flowrate) then
  1309)       write(id,'(a29)',advance='no') ' '
  1310)       write(id,'(a)') 'energy flow rate'
  1311)     endif
  1312)     if (output_option%print_hdf5_aveg_mass_flowrate) then
  1313)       write(id,'(a29)',advance='no') ' '
  1314)       write(id,'(a)') 'average mass flow rate'
  1315)     endif
  1316)     if (output_option%print_hdf5_aveg_energy_flowrate) then
  1317)       write(id,'(a29)',advance='no') ' '
  1318)       write(id,'(a)') 'average energy flow rate'
  1319)     endif
  1320)     if (output_option%print_explicit_flowrate) then
  1321)       write(id,'(a29)',advance='no') ' '
  1322)       write(id,'(a)') 'explicit flow rate'
  1323)     endif
  1324)   endif
  1325)   if (output_option%print_mad) then
  1326)     write(id,'(a29)',advance='no') 'format: '
  1327)     write(id,'(a)') 'mad'
  1328)   endif
  1329)   if (output_option%print_vtk) then
  1330)     write(id,'(a29)',advance='no') 'format: '
  1331)     write(id,'(a)') 'vtk'
  1332)   endif
  1333)   write(id,'(a29)',advance='no') 'periodic timestep: '
  1334)   if (output_option%periodic_snap_output_ts_imod == 100000000) then
  1335)     write(id,'(a)') 'OFF'
  1336)   else
  1337)     write(id,'(a)') 'ON'
  1338)     write(id,'(a29)',advance='no') 'timestep increment: '
  1339)     write(word,Format) output_option%periodic_snap_output_ts_imod
  1340)     write(id,'(a)') adjustl(trim(word))
  1341)   endif
  1342)   write(id,'(a29)',advance='no') 'periodic time: '
  1343)   if (output_option%periodic_snap_output_time_incr <= 0) then
  1344)     write(id,'(a)') 'OFF'
  1345)   else
  1346)     write(id,'(a)') 'ON'
  1347)     write(id,'(a29)',advance='no') 'time increment: '
  1348)     write(word,Format) output_option%periodic_snap_output_time_incr / &
  1349)                   output_option%tconv
  1350)     write(id,'(a)') adjustl(trim(word)) // &
  1351)                     adjustl(trim(output_option%tunit))
  1352)   endif
  1353)   write(id,'(a29)',advance='no') 'specific times: '
  1354)   if (snap_output_found) then
  1355)     write(id,'(a)') 'ON'
  1356)     write(id,'(a29)',advance='no') 'times (' // &
  1357)                                     trim(output_option%tunit) // '): '
  1358)     write(id,'(a)') trim(snap_string)
  1359)   else
  1360)     write(id,'(a)') 'OFF'
  1361)   endif
  1362)   if (associated(output_option%output_snap_variable_list%first)) then
  1363)     write(id,'(a29)',advance='no') 'variable list: '
  1364)     cur_variable => output_option%output_snap_variable_list%first
  1365)     write(id,'(a)') trim(cur_variable%name) // ' [' // &
  1366)                     trim(cur_variable%units) // ']'
  1367)     cur_variable => cur_variable%next
  1368)     do
  1369)       if (.not.associated(cur_variable)) exit
  1370)       write(id,'(a29)',advance='no') ' '
  1371)       write(id,'(a)') trim(cur_variable%name) // ' [' // &
  1372)            trim(cur_variable%units) // ']'
  1373)       cur_variable => cur_variable%next
  1374)     enddo
  1375)   endif
  1376)   write(id,'(a29)',advance='no') 'print initial time: '
  1377)   if (output_option%print_initial_snap) then
  1378)     write(id,'(a)') 'ON'
  1379)   else
  1380)     write(id,'(a)') 'OFF'
  1381)   endif
  1382)   write(id,'(a29)',advance='no') 'print final time: '
  1383)   if (output_option%print_final_snap) then
  1384)     write(id,'(a)') 'ON'
  1385)   else
  1386)     write(id,'(a)') 'OFF'
  1387)   endif
  1388) 
  1389)   write(id,'(a29)',advance='no') '---------------------------: '
  1390)   write(id,'(a)') 'observation file output'
  1391)   write(id,'(a29)',advance='no') 'format: '
  1392)   write(id,'(a)') 'tecplot'
  1393)   write(id,'(a29)',advance='no') 'periodic timestep: '
  1394)   if (output_option%periodic_obs_output_ts_imod == 100000000) then
  1395)     write(id,'(a)') 'OFF'
  1396)   else
  1397)     write(id,'(a)') 'ON'
  1398)     write(id,'(a29)',advance='no') 'timestep increment: '
  1399)     write(word,Format) output_option%periodic_obs_output_ts_imod
  1400)     write(id,'(a)') adjustl(trim(word))
  1401)   endif
  1402)   write(id,'(a29)',advance='no') 'periodic time: '
  1403)   if (output_option%periodic_obs_output_time_incr <= 0) then
  1404)     write(id,'(a)') 'OFF'
  1405)   else
  1406)     write(id,'(a)') 'ON'
  1407)     write(id,'(a29)',advance='no') 'time increment: '
  1408)     write(word,Format) output_option%periodic_obs_output_time_incr / &
  1409)                   output_option%tconv
  1410)     write(id,'(a)') adjustl(trim(word)) // &
  1411)                     adjustl(trim(output_option%tunit))
  1412)   endif
  1413)   write(id,'(a29)',advance='no') 'specific times: '
  1414)   if (obs_output_found) then
  1415)     write(id,'(a)') 'ON'
  1416)     write(id,'(a29)',advance='no') 'times (' // &
  1417)                                     trim(output_option%tunit) // '): '
  1418)     write(id,'(a)') trim(obs_string)
  1419)   else
  1420)     write(id,'(a)') 'OFF'
  1421)   endif
  1422)   if (associated(output_option%output_obs_variable_list%first)) then
  1423)     write(id,'(a29)',advance='no') 'variable list: '
  1424)     cur_variable => output_option%output_obs_variable_list%first
  1425)     write(id,'(a)') trim(cur_variable%name)
  1426)     cur_variable => cur_variable%next
  1427)     do
  1428)       if (.not.associated(cur_variable)) exit
  1429)       write(id,'(a29)',advance='no') ' '
  1430)       write(id,'(a)') trim(cur_variable%name) // ' [' // &
  1431)            trim(cur_variable%units) // ']'
  1432)       cur_variable => cur_variable%next
  1433)     enddo
  1434)   endif
  1435)   write(id,'(a29)',advance='no') 'print initial time: '
  1436)   if (output_option%print_initial_obs) then
  1437)     write(id,'(a)') 'ON'
  1438)   else
  1439)     write(id,'(a)') 'OFF'
  1440)   endif
  1441)   write(id,'(a29)',advance='no') 'print final time: '
  1442)   if (output_option%print_final_obs) then
  1443)     write(id,'(a)') 'ON'
  1444)   else
  1445)     write(id,'(a)') 'OFF'
  1446)   endif
  1447) 
  1448)   write(id,'(a29)',advance='no') '---------------------------: '
  1449)   write(id,'(a)') 'mass balance file output'
  1450)   write(id,'(a29)',advance='no') 'format: '
  1451)   write(id,'(a)') 'tecplot'
  1452)   write(id,'(a29)',advance='no') 'periodic timestep: '
  1453)   if (output_option%periodic_msbl_output_ts_imod == 100000000) then
  1454)     write(id,'(a)') 'OFF'
  1455)   else
  1456)     write(id,'(a)') 'ON'
  1457)     write(id,'(a29)',advance='no') 'timestep increment: '
  1458)     write(word,Format) output_option%periodic_msbl_output_ts_imod
  1459)     write(id,'(a)') adjustl(trim(word))
  1460)   endif
  1461)   write(id,'(a29)',advance='no') 'periodic time: '
  1462)   if (output_option%periodic_msbl_output_time_incr <= 0) then
  1463)     write(id,'(a)') 'OFF'
  1464)   else
  1465)     write(id,'(a)') 'ON'
  1466)     write(id,'(a29)',advance='no') 'time increment: '
  1467)     write(word,Format) output_option%periodic_msbl_output_time_incr / &
  1468)                   output_option%tconv
  1469)     write(id,'(a)') adjustl(trim(word)) // &
  1470)                     adjustl(trim(output_option%tunit))
  1471)   endif
  1472)   write(id,'(a29)',advance='no') 'specific times: '
  1473)   if (msbl_output_found) then
  1474)     write(id,'(a)') 'ON'
  1475)     write(id,'(a29)',advance='no') 'times (' // &
  1476)                                     trim(output_option%tunit) // '): '
  1477)     write(id,'(a)') trim(msbl_string)
  1478)   else
  1479)     write(id,'(a)') 'OFF'
  1480)   endif
  1481)   write(id,'(a29)',advance='no') 'print initial time: '
  1482)   if (output_option%print_initial_massbal) then
  1483)     write(id,'(a)') 'ON'
  1484)   else
  1485)     write(id,'(a)') 'OFF'
  1486)   endif
  1487)   write(id,'(a29)',advance='no') 'print final time: '
  1488)   if (output_option%print_final_massbal) then
  1489)     write(id,'(a)') 'ON'
  1490)   else
  1491)     write(id,'(a)') 'OFF'
  1492)   endif
  1493)   
  1494) 
  1495) end subroutine OutputInputRecord
  1496) 
  1497) ! ************************************************************************** !
  1498) 
  1499) subroutine OutputMAD(realization_base)
  1500)   ! 
  1501)   ! Print to HDF5 file for MAD final output
  1502)   ! 
  1503)   ! Author: Glenn Hammond
  1504)   ! Date: 10/25/07
  1505)   ! 
  1506) 
  1507)   use Realization_Base_class, only : realization_base_type
  1508)   use Discretization_module
  1509)   use Option_module
  1510)   use Grid_module
  1511)   use Field_module
  1512)   use Patch_module
  1513)   use Reaction_Aux_module
  1514)   use Variables_module
  1515)   use Output_Common_module, only : OutputGetVarFromArray
  1516)  
  1517) #if !defined(PETSC_HAVE_HDF5)
  1518)   implicit none
  1519)   
  1520)   class(realization_base_type) :: realization_base
  1521) 
  1522)   call printMsg(realization_base%option,'')
  1523)   write(realization_base%option%io_buffer, &
  1524)         '("PFLOTRAN must be compiled with HDF5 to ", &
  1525)         &"write HDF5 formatted structured grids.")')
  1526)   call printErrMsg(realization_base%option)
  1527) #else
  1528) 
  1529) ! 64-bit stuff
  1530) #ifdef PETSC_USE_64BIT_INDICES
  1531) !#define HDF_NATIVE_INTEGER H5T_STD_I64LE
  1532) #define HDF_NATIVE_INTEGER H5T_NATIVE_INTEGER
  1533) #else
  1534) #define HDF_NATIVE_INTEGER H5T_NATIVE_INTEGER
  1535) #endif
  1536) 
  1537)   use hdf5
  1538)   use HDF5_module
  1539)   
  1540)   implicit none
  1541) 
  1542)   class(realization_base_type) :: realization_base
  1543) 
  1544)   integer(HID_T) :: file_id
  1545)   integer(HID_T) :: grp_id
  1546)   integer(HID_T) :: file_space_id
  1547)   integer(HID_T) :: realization_set_id
  1548)   integer(HID_T) :: prop_id
  1549)   PetscMPIInt :: rank
  1550)   PetscMPIInt, parameter :: ON=1, OFF=0
  1551)   integer(HSIZE_T) :: dims(3)
  1552)   
  1553)   type(grid_type), pointer :: grid
  1554)   type(discretization_type), pointer :: discretization
  1555)   type(option_type), pointer :: option
  1556)   type(field_type), pointer :: field
  1557)   type(patch_type), pointer :: patch  
  1558)   type(reaction_type), pointer :: reaction
  1559)   type(output_option_type), pointer :: output_option
  1560)   
  1561)   Vec :: global_vec
  1562)   Vec :: natural_vec
  1563)   PetscReal, pointer :: v_ptr
  1564)   
  1565)   character(len=MAXSTRINGLENGTH) :: filename
  1566)   character(len=MAXSTRINGLENGTH) :: string
  1567)   PetscReal, pointer :: array(:)
  1568)   PetscInt :: i
  1569)   PetscInt :: nviz_flow, nviz_tran, nviz_dof
  1570)   PetscInt :: current_component
  1571)   PetscFortranAddr :: app_ptr
  1572)   PetscMPIInt :: hdf5_flag 
  1573)   PetscMPIInt :: hdf5_err
  1574)   PetscErrorCode :: ierr
  1575) 
  1576)   discretization => realization_base%discretization
  1577)   patch => realization_base%patch
  1578)   grid => patch%grid
  1579)   option => realization_base%option
  1580)   field => realization_base%field
  1581)   reaction => realization_base%reaction
  1582)   output_option => realization_base%output_option
  1583) 
  1584) #define ALL
  1585) #ifdef ALL
  1586)   write(string,'(i6)') option%mygroup_id
  1587)   filename = trim(option%global_prefix) // '-MAD-G' // trim(adjustl(string)) // '.h5'
  1588) !  filename = trim(option%global_prefix) // '-MAD.h5'
  1589) 
  1590)   ! initialize fortran interface
  1591)   call h5open_f(hdf5_err)
  1592) 
  1593)   call h5pcreate_f(H5P_FILE_ACCESS_F,prop_id,hdf5_err)
  1594) #ifndef SERIAL_HDF5
  1595)   call h5pset_fapl_mpio_f(prop_id,option%mycomm,MPI_INFO_NULL,hdf5_err)
  1596) #endif
  1597)   ! turn off error reporting
  1598)   call h5eset_auto_f(OFF,hdf5_err)
  1599)   call h5fopen_f(filename,H5F_ACC_RDWR_F,file_id,hdf5_err,prop_id)
  1600)   hdf5_flag = hdf5_err
  1601)   call h5eset_auto_f(ON,hdf5_err)
  1602)   if (hdf5_flag < 0) then 
  1603)     call h5fcreate_f(filename,H5F_ACC_TRUNC_F,file_id,hdf5_err,H5P_DEFAULT_F, &
  1604)                      prop_id)
  1605)   endif
  1606)   call h5pclose_f(prop_id,hdf5_err)
  1607) #else
  1608)   filename = trim(option%global_prefix) // trim(option%group_prefix) // '.h5'
  1609) 
  1610)   ! initialize fortran interface
  1611)   call h5open_f(hdf5_err)
  1612) 
  1613)   call h5pcreate_f(H5P_FILE_ACCESS_F,prop_id,hdf5_err)
  1614) #ifndef SERIAL_HDF5
  1615)   call h5pset_fapl_mpio_f(prop_id,option%mycomm,MPI_INFO_NULL,hdf5_err)
  1616) #endif
  1617)   call h5fcreate_f(filename,H5F_ACC_TRUNC_F,file_id,hdf5_err,H5P_DEFAULT_F, &
  1618)                    prop_id)
  1619)   call h5pclose_f(prop_id,hdf5_err)
  1620) #endif
  1621) 
  1622)   ! write out data sets 
  1623)   call DiscretizationCreateVector(discretization,ONEDOF,global_vec,GLOBAL, &
  1624)                                   option)   
  1625) 
  1626)   ! pressure
  1627)   call OutputGetVarFromArray(realization_base,global_vec,LIQUID_PRESSURE,ZERO_INTEGER)
  1628) #ifdef ALL
  1629)   string = 'Pressure' // trim(option%group_prefix)
  1630) #else
  1631)   string = 'Pressure'
  1632) #endif
  1633)   call HDF5WriteStructDataSetFromVec(string,realization_base,global_vec,file_id,H5T_NATIVE_DOUBLE)
  1634) 
  1635)   call VecDestroy(global_vec,ierr);CHKERRQ(ierr)
  1636) 
  1637)   call h5fclose_f(file_id,hdf5_err)
  1638)   call h5close_f(hdf5_err)
  1639) #endif
  1640) end subroutine OutputMAD
  1641) 
  1642) ! ************************************************************************** !
  1643) 
  1644) subroutine ComputeFlowCellVelocityStats(realization_base)
  1645)   ! 
  1646)   ! Author: Glenn Hammond
  1647)   ! Date: 03/11/08
  1648)   ! 
  1649) 
  1650)   use Realization_Base_class, only : realization_base_type
  1651)   use Grid_module
  1652)   use Option_module
  1653)   use Connection_module
  1654)   use Coupler_module
  1655)   use Field_module
  1656)   use Patch_module
  1657)   use Discretization_module
  1658) 
  1659)   implicit none
  1660)   
  1661)   class(realization_base_type) :: realization_base
  1662)   
  1663)   type(grid_type), pointer :: grid
  1664)   type(option_type), pointer :: option
  1665)   type(field_type), pointer :: field
  1666)   type(patch_type), pointer :: patch  
  1667)   type(discretization_type), pointer :: discretization
  1668)   type(output_option_type), pointer :: output_option
  1669)   PetscInt :: iconn, i, direction, iphase, sum_connection
  1670)   PetscInt :: local_id_up, local_id_dn, local_id
  1671)   PetscInt :: ghosted_id_up, ghosted_id_dn, ghosted_id
  1672)   PetscReal :: flux
  1673)   Vec :: global_vec, global_vec2
  1674) 
  1675)   PetscReal :: average, sum, max, min, std_dev
  1676)   PetscInt :: max_loc, min_loc
  1677)   character(len=MAXSTRINGLENGTH) :: string
  1678)   
  1679)   PetscReal, pointer :: vec_ptr(:), vec2_ptr(:), den_loc_p(:)
  1680)   PetscReal, allocatable :: sum_area(:)
  1681)   PetscErrorCode :: ierr
  1682)   
  1683)   type(coupler_type), pointer :: boundary_condition
  1684)   type(connection_set_list_type), pointer :: connection_set_list
  1685)   type(connection_set_type), pointer :: cur_connection_set
  1686) 
  1687)   patch => realization_base%patch
  1688)   grid => patch%grid
  1689)   option => realization_base%option
  1690)   field => realization_base%field
  1691)   output_option => realization_base%output_option
  1692)   discretization => realization_base%discretization
  1693)     
  1694)   allocate(sum_area(grid%nlmax))
  1695)   call DiscretizationDuplicateVector(discretization,field%work,global_vec)
  1696)   call DiscretizationDuplicateVector(discretization,field%work,global_vec2)
  1697) 
  1698)   do iphase = 1,option%nphase
  1699) 
  1700)     do direction = 1,3
  1701)     
  1702)       sum_area(1:grid%nlmax) = 0.d0
  1703)       call VecSet(global_vec,0.d0,ierr);CHKERRQ(ierr)
  1704)       call VecGetArrayF90(global_vec,vec_ptr,ierr);CHKERRQ(ierr)
  1705) 
  1706)       ! interior velocities  
  1707)       connection_set_list => grid%internal_connection_set_list
  1708)       cur_connection_set => connection_set_list%first
  1709)       sum_connection = 0
  1710)       do 
  1711)         if (.not.associated(cur_connection_set)) exit
  1712)         do iconn = 1, cur_connection_set%num_connections
  1713)           sum_connection = sum_connection + 1
  1714)           ghosted_id_up = cur_connection_set%id_up(iconn)
  1715)           ghosted_id_dn = cur_connection_set%id_dn(iconn)
  1716)           local_id_up = grid%nG2L(ghosted_id_up) ! = zero for ghost nodes
  1717)           local_id_dn = grid%nG2L(ghosted_id_dn) ! = zero for ghost nodes
  1718)           ! velocities are stored as the downwind face of the upwind cell
  1719)           flux = patch%internal_velocities(iphase,sum_connection)* &
  1720)                    cur_connection_set%area(iconn)* &
  1721)                    cur_connection_set%dist(direction,iconn)
  1722)           if (local_id_up > 0) then
  1723)             vec_ptr(local_id_up) = vec_ptr(local_id_up) - flux
  1724)           endif
  1725)           if (local_id_dn > 0) then
  1726)             vec_ptr(local_id_dn) = vec_ptr(local_id_dn) + flux
  1727)           endif
  1728)         enddo
  1729)         cur_connection_set => cur_connection_set%next
  1730)       enddo
  1731) 
  1732)       ! boundary velocities
  1733)       boundary_condition => patch%boundary_condition_list%first
  1734)       sum_connection = 0
  1735)       do
  1736)         if (.not.associated(boundary_condition)) exit
  1737)         cur_connection_set => boundary_condition%connection_set
  1738)         do iconn = 1, cur_connection_set%num_connections
  1739)           sum_connection = sum_connection + 1
  1740)           local_id = cur_connection_set%id_dn(iconn)
  1741)           vec_ptr(local_id) = vec_ptr(local_id)+ &
  1742)                               cur_connection_set%dist(direction,iconn)* &
  1743)                               patch%boundary_velocities(iphase,sum_connection)* &
  1744)                               cur_connection_set%area(iconn)
  1745)         enddo
  1746)         boundary_condition => boundary_condition%next
  1747)       enddo
  1748) 
  1749)       call VecRestoreArrayF90(global_vec,vec_ptr,ierr);CHKERRQ(ierr)
  1750) 
  1751)       call VecSum(global_vec,sum,ierr);CHKERRQ(ierr)
  1752)       average = sum/real(grid%nmax)
  1753)       call VecSet(global_vec2,average,ierr);CHKERRQ(ierr)
  1754)       call VecMax(global_vec,max_loc,max,ierr);CHKERRQ(ierr)
  1755)       call VecMin(global_vec,min_loc,min,ierr);CHKERRQ(ierr)
  1756)       call VecAYPX(global_vec2,-1.d0,global_vec,ierr);CHKERRQ(ierr)
  1757)       call VecNorm(global_vec2,NORM_2,std_dev,ierr);CHKERRQ(ierr)
  1758)       select case(direction)
  1759)         case(X_DIRECTION)
  1760)           string = 'X-Direction,'
  1761)         case(Y_DIRECTION)
  1762)           string = 'Y-Direction,'
  1763)         case(Z_DIRECTION)
  1764)           string = 'Z-Direction,'
  1765)       end select
  1766)       select case(iphase)
  1767)         case(LIQUID_PHASE)
  1768)           string = trim(string) // ' Liquid Phase'
  1769)         case(GAS_PHASE)
  1770)           string = trim(string) // ' Gas Phase'
  1771)       end select
  1772)       string = trim(string) // ' Velocity Statistics [m/' // &
  1773)                trim(output_option%tunit) // ']:'
  1774) 
  1775)       if (option%myrank == option%io_rank) then
  1776)         write(*,'(/,a,/, &
  1777)                      &"Average:",1es12.4,/, &
  1778)                      &"Max:    ",1es12.4,"  Location:",i11,/, &
  1779)                      &"Min:    ",1es12.4,"  Location:",i11,/, &
  1780)                      &"Std Dev:",1es12.4,/)') trim(string), &
  1781)                                               average,max,max_loc+1, &
  1782)                                               min,min_loc+1,std_dev
  1783)         write(option%fid_out,'(/,a,/, &
  1784)                      &"Average:",1es12.4,/, &
  1785)                      &"Max:    ",1es12.4,"  Location:",i11,/, &
  1786)                      &"Min:    ",1es12.4,"  Location:",i11,/, &
  1787)                      &"Std Dev:",1es12.4,/)') trim(string), &
  1788)                                               average,max,max_loc+1, &
  1789)                                               min,min_loc+1,std_dev
  1790)       endif
  1791) 
  1792)     enddo
  1793)   enddo
  1794)   
  1795)   if (allocated(sum_area)) deallocate(sum_area)
  1796)   call VecDestroy(global_vec,ierr);CHKERRQ(ierr)
  1797)   call VecDestroy(global_vec2,ierr);CHKERRQ(ierr)
  1798) 
  1799) end subroutine ComputeFlowCellVelocityStats
  1800) 
  1801) ! ************************************************************************** !
  1802) 
  1803) subroutine ComputeFlowFluxVelocityStats(realization_base)
  1804)   ! 
  1805)   ! Print flux statistics
  1806)   ! 
  1807)   ! Author: Glenn Hammond
  1808)   ! Date: 03/11/08
  1809)   ! 
  1810) !geh - specifically, the flow velocities at the interfaces between cells
  1811)  
  1812)   use Realization_Base_class, only : realization_base_type
  1813)   use Discretization_module
  1814)   use Grid_module
  1815)   use Option_module
  1816)   use Field_module
  1817)   use Connection_module
  1818)   use Patch_module
  1819)   
  1820)   implicit none
  1821) 
  1822)   class(realization_base_type) :: realization_base
  1823)   
  1824)   type(grid_type), pointer :: grid
  1825)   type(option_type), pointer :: option
  1826)   type(field_type), pointer :: field
  1827)   type(patch_type), pointer :: patch
  1828)   type(discretization_type), pointer :: discretization  
  1829)   type(output_option_type), pointer :: output_option
  1830)   
  1831)   character(len=MAXSTRINGLENGTH) :: filename
  1832)   character(len=MAXSTRINGLENGTH) :: string
  1833)   
  1834)   PetscInt :: iphase
  1835)   PetscInt :: direction
  1836)   PetscInt :: local_id, ghosted_id
  1837)   PetscInt :: iconn, sum_connection
  1838)   PetscReal, pointer :: vec_ptr(:)
  1839)   Vec :: global_vec, global_vec2
  1840)   PetscReal :: sum, average, max, min , std_dev
  1841)   PetscInt :: max_loc, min_loc
  1842)   PetscErrorCode :: ierr
  1843) 
  1844)   type(connection_set_list_type), pointer :: connection_set_list
  1845)   type(connection_set_type), pointer :: cur_connection_set
  1846)     
  1847)   discretization => realization_base%discretization
  1848)   patch => realization_base%patch
  1849)   grid => patch%grid
  1850)   option => realization_base%option
  1851)   field => realization_base%field
  1852)   output_option => realization_base%output_option
  1853)   
  1854)   call DiscretizationDuplicateVector(discretization,field%work,global_vec) 
  1855)   call DiscretizationDuplicateVector(discretization,field%work,global_vec2) 
  1856) 
  1857)   do iphase = 1,option%nphase
  1858)     do direction = 1,3
  1859)     
  1860)       call VecZeroEntries(global_vec,ierr);CHKERRQ(ierr)
  1861)       call VecGetArrayF90(global_vec,vec_ptr,ierr);CHKERRQ(ierr)
  1862)       
  1863)       ! place interior velocities in a vector
  1864)       connection_set_list => grid%internal_connection_set_list
  1865)       cur_connection_set => connection_set_list%first
  1866)       sum_connection = 0
  1867)       do 
  1868)         if (.not.associated(cur_connection_set)) exit
  1869)         do iconn = 1, cur_connection_set%num_connections
  1870)           sum_connection = sum_connection + 1
  1871)           ghosted_id = cur_connection_set%id_up(iconn)
  1872)           local_id = grid%nG2L(ghosted_id) ! = zero for ghost nodes
  1873)           ! velocities are stored as the downwind face of the upwind cell
  1874)           if (local_id <= 0 .or. &
  1875)               dabs(cur_connection_set%dist(direction,iconn)) < 0.99d0) cycle
  1876)           vec_ptr(local_id) = patch%internal_velocities(iphase,sum_connection)
  1877)         enddo
  1878)         cur_connection_set => cur_connection_set%next
  1879)       enddo
  1880) 
  1881)       call VecRestoreArrayF90(global_vec,vec_ptr,ierr);CHKERRQ(ierr)
  1882)       
  1883)       ! compute stats
  1884)       call VecSum(global_vec,sum,ierr);CHKERRQ(ierr)
  1885)       average = sum/real(grid%nmax)
  1886)       call VecSet(global_vec2,average,ierr);CHKERRQ(ierr)
  1887)       call VecMax(global_vec,max_loc,max,ierr);CHKERRQ(ierr)
  1888)       call VecMin(global_vec,min_loc,min,ierr);CHKERRQ(ierr)
  1889)       call VecAYPX(global_vec2,-1.d0,global_vec,ierr);CHKERRQ(ierr)
  1890)       call VecNorm(global_vec2,NORM_2,std_dev,ierr);CHKERRQ(ierr)
  1891)       select case(direction)
  1892)         case(X_DIRECTION)
  1893)           string = 'X-Direction,'
  1894)         case(Y_DIRECTION)
  1895)           string = 'Y-Direction,'
  1896)         case(Z_DIRECTION)
  1897)           string = 'Z-Direction,'
  1898)       end select
  1899)       select case(iphase)
  1900)         case(LIQUID_PHASE)
  1901)           string = trim(string) // ' Liquid Phase'
  1902)         case(GAS_PHASE)
  1903)           string = trim(string) // ' Gas Phase'
  1904)       end select
  1905)       string = trim(string) // ' Flux Velocity Statistics [m/' // &
  1906)                trim(output_option%tunit) // ']:'
  1907)       if (option%myrank == option%io_rank) then
  1908)         write(*,'(/,a,/, &
  1909)                      &"Average:",1es12.4,/, &
  1910)                      &"Max:    ",1es12.4,"  Location:",i11,/, &
  1911)                      &"Min:    ",1es12.4,"  Location:",i11,/, &
  1912)                      &"Std Dev:",1es12.4,/)') trim(string), &
  1913)                                               average,max,max_loc+1, &
  1914)                                               min,min_loc+1,std_dev
  1915)         write(option%fid_out,'(/,a,/, &
  1916)                      &"Average:",1es12.4,/, &
  1917)                      &"Max:    ",1es12.4,"  Location:",i11,/, &
  1918)                      &"Min:    ",1es12.4,"  Location:",i11,/, &
  1919)                      &"Std Dev:",1es12.4,/)') trim(string), &
  1920)                                               average,max,max_loc+1, &
  1921)                                               min,min_loc+1,std_dev
  1922)       endif
  1923)     enddo
  1924)   enddo
  1925)   
  1926)   call VecDestroy(global_vec,ierr);CHKERRQ(ierr)
  1927)   call VecDestroy(global_vec2,ierr);CHKERRQ(ierr)
  1928)   
  1929) end subroutine ComputeFlowFluxVelocityStats
  1930) 
  1931) ! ************************************************************************** !
  1932) 
  1933) subroutine OutputPrintCouplers(realization_base,istep)
  1934)   ! 
  1935)   ! Prints values of auxiliary variables associated with
  1936)   ! couplers (boundary and initial conditions, source
  1937)   ! sinks).  Note that since multiple connections for
  1938)   ! couplers can exist for a single cell, the latter will
  1939)   ! overwrite the former.
  1940)   ! 
  1941)   ! Author: Glenn Hammond
  1942)   ! Date: 11/02/11
  1943)   ! 
  1944) 
  1945)   use Realization_Base_class, only : realization_base_type
  1946)   use Coupler_module
  1947)   use Connection_module
  1948)   use Option_module
  1949)   use Debug_module
  1950)   use Field_module
  1951)   use Patch_module
  1952)   use Grid_module
  1953)   use Input_Aux_module
  1954)   use General_Aux_module
  1955) 
  1956)   class(realization_base_type) :: realization_base
  1957)   PetscInt :: istep
  1958)   
  1959)   type(option_type), pointer :: option
  1960)   type(patch_type), pointer :: cur_patch
  1961)   type(field_type), pointer :: field
  1962)   type(coupler_type), pointer :: coupler
  1963)   type(debug_type), pointer :: flow_debug
  1964)   type(grid_type), pointer :: grid
  1965)   character(len=MAXWORDLENGTH) :: word
  1966)   character(len=MAXSTRINGLENGTH) :: string, coupler_string
  1967)   type(connection_set_type), pointer :: cur_connection_set
  1968)   PetscReal, pointer :: vec_ptr(:)
  1969)   PetscInt :: local_id, iconn, iaux
  1970)   PetscInt, allocatable :: iauxvars(:)
  1971)   character(len=MAXWORDLENGTH), allocatable :: auxvar_names(:)
  1972)   PetscErrorCode :: ierr
  1973)   
  1974)   
  1975)   option => realization_base%option
  1976)   flow_debug => realization_base%debug
  1977)   field => realization_base%field
  1978) 
  1979)   if (len_trim(flow_debug%coupler_string) == 0) then
  1980)     option%io_buffer = &
  1981)       'Coupler debugging requested, but no string of coupler names was included.'
  1982)     call printErrMsg(option)
  1983)   endif
  1984) 
  1985)   select case(option%iflowmode)
  1986)     case(RICHARDS_MODE)
  1987)       allocate(iauxvars(1),auxvar_names(1))
  1988)       iauxvars(1) = RICHARDS_PRESSURE_DOF
  1989)       auxvar_names(1) = 'pressure'
  1990)     case(G_MODE)
  1991)       allocate(iauxvars(2),auxvar_names(2))
  1992)       iauxvars(1) = GENERAL_LIQUID_PRESSURE_DOF
  1993)       auxvar_names(1) = 'liquid_pressure'
  1994)       iauxvars(2) = GENERAL_ENERGY_DOF
  1995)       auxvar_names(2) = 'temperature'
  1996)     case default
  1997)       option%io_buffer = &
  1998)         'OutputPrintCouplers() not yet supported for this flow mode'
  1999)       call printErrMsg(option)
  2000)   end select
  2001)   
  2002)   coupler_string = flow_debug%coupler_string
  2003)   ierr = 0
  2004)   do
  2005)     call InputReadWord(coupler_string,word,PETSC_TRUE,ierr)
  2006)     if (ierr /= 0) exit
  2007)     
  2008)     do iaux = 1, size(iauxvars)
  2009)       cur_patch => realization_base%patch_list%first
  2010)       do
  2011)         if (.not.associated(cur_patch)) exit
  2012)         grid => cur_patch%grid
  2013)         coupler => CouplerGetPtrFromList(word,cur_patch%boundary_condition_list)
  2014)         call VecZeroEntries(field%work,ierr);CHKERRQ(ierr)
  2015)         call VecGetArrayF90(field%work,vec_ptr,ierr);CHKERRQ(ierr)
  2016)         if (associated(coupler)) then
  2017)           cur_connection_set => coupler%connection_set
  2018)           do iconn = 1, cur_connection_set%num_connections
  2019)             local_id = cur_connection_set%id_dn(iconn)
  2020)             if (cur_patch%imat(grid%nL2G(local_id)) <= 0) cycle
  2021)             vec_ptr(local_id) = coupler%flow_aux_real_var(iauxvars(iaux),iconn)
  2022)           enddo
  2023)         endif
  2024)         call VecRestoreArrayF90(field%work,vec_ptr,ierr);CHKERRQ(ierr)
  2025)         cur_patch => cur_patch%next
  2026)       enddo
  2027) 
  2028)       if (istep > 0) then
  2029)         write(string,*) istep
  2030)         string = adjustl(string)
  2031)         string = trim(word) // '_' // trim(auxvar_names(iaux)) // '_' // &
  2032)                  trim(string)
  2033)       else 
  2034)         string = trim(word) // '_' // trim(auxvar_names(iaux))
  2035)       endif
  2036)       if (len_trim(option%group_prefix) > 1) then
  2037)         string = trim(string) // trim(option%group_prefix)
  2038)       endif
  2039)       string = trim(string) // '.tec'
  2040)       call OutputVectorTecplot(string,word,realization_base,field%work)
  2041)     enddo
  2042)       
  2043)   enddo
  2044) 
  2045)   deallocate(iauxvars)
  2046)   deallocate(auxvar_names)
  2047) 
  2048) end subroutine OutputPrintCouplers
  2049) 
  2050) ! ************************************************************************** !
  2051) 
  2052) subroutine OutputAvegVars(realization_base)
  2053)   ! 
  2054)   ! This routine temporally averages variables and outputs thems
  2055)   ! 
  2056)   ! Author: Gautam Bisht, LBNL
  2057)   ! Date: 01/10/13
  2058)   ! 
  2059) 
  2060)   use Realization_Base_class, only : realization_base_type
  2061)   use Option_module, only : OptionCheckTouch, option_type, printMsg
  2062)   use Output_Aux_module
  2063)   use Output_Common_module, only : OutputGetVarFromArray  
  2064)   use Field_module
  2065) 
  2066)   implicit none
  2067)   
  2068)   class(realization_base_type) :: realization_base
  2069) 
  2070)   type(option_type), pointer :: option
  2071)   type(output_option_type), pointer :: output_option
  2072)   type(output_variable_type), pointer :: cur_variable
  2073)   type(field_type), pointer :: field  
  2074) 
  2075)   PetscReal :: dtime
  2076)   PetscBool :: aveg_plot_flag
  2077)   PetscInt :: ivar
  2078)   PetscReal,pointer :: aval_p(:),ival_p(:)
  2079)   PetscErrorCode :: ierr  
  2080)   PetscLogDouble :: tstart, tend
  2081) 
  2082)   option => realization_base%option
  2083)   output_option => realization_base%output_option
  2084)   field => realization_base%field
  2085) 
  2086)   ! 
  2087)   if (option%time<1.d-10) return
  2088)   
  2089)   dtime = option%time-output_option%aveg_var_time
  2090)   output_option%aveg_var_dtime = output_option%aveg_var_dtime + dtime
  2091)   output_option%aveg_var_time = output_option%aveg_var_time + dtime
  2092)   
  2093)   if (abs(output_option%aveg_var_dtime - &
  2094)           output_option%periodic_snap_output_time_incr)<1.d0) then
  2095)     aveg_plot_flag=PETSC_TRUE
  2096)   else
  2097)     aveg_plot_flag=PETSC_FALSE
  2098)   endif
  2099) 
  2100)   if (.not.associated(output_option%aveg_output_variable_list%first)) then
  2101)     if (output_option%print_hdf5_aveg_mass_flowrate.or. &
  2102)        output_option%print_hdf5_aveg_energy_flowrate) then
  2103)       ! There is a possibility to output average-flowrates, thus
  2104)       ! call output subroutine depending on mesh type
  2105)       if (realization_base%discretization%itype == UNSTRUCTURED_GRID) then
  2106)         call OutputHDF5UGridXDMF(realization_base,AVERAGED_VARS)
  2107)       else
  2108)       !  call OutputHDF5(realization_base,AVERAGED_VARS)
  2109)       endif
  2110)     endif
  2111)     return
  2112)   endif
  2113)   
  2114)   ivar = 0
  2115)   cur_variable => output_option%aveg_output_variable_list%first
  2116)   do
  2117)     if (.not.associated(cur_variable)) exit
  2118) 
  2119)     ! Get the variable
  2120)     call OutputGetVarFromArray(realization_base,field%work, &
  2121)                                cur_variable%ivar, &
  2122)                                cur_variable%isubvar)
  2123) 
  2124)     ! Cumulatively add the variable*dtime
  2125)     ivar = ivar + 1
  2126)     call VecGetArrayF90(field%work,ival_p,ierr);CHKERRQ(ierr)
  2127)     call VecGetArrayF90(field%avg_vars_vec(ivar),aval_p,ierr);CHKERRQ(ierr)
  2128)     aval_p = aval_p + ival_p*dtime
  2129)     call VecRestoreArrayF90(field%work,ival_p,ierr);CHKERRQ(ierr)
  2130)     call VecRestoreArrayF90(field%avg_vars_vec(ivar),aval_p, &
  2131)                             ierr);CHKERRQ(ierr)
  2132) 
  2133)     ! Check if it is time to output the temporally average variable
  2134)     if (aveg_plot_flag) then
  2135) 
  2136)       ! Divide vector values by 'time'
  2137)       call VecGetArrayF90(field%avg_vars_vec(ivar),aval_p,ierr);CHKERRQ(ierr)
  2138)       aval_p = aval_p/output_option%periodic_snap_output_time_incr
  2139)       call VecRestoreArrayF90(field%avg_vars_vec(ivar),aval_p, &
  2140)                               ierr);CHKERRQ(ierr)
  2141) 
  2142)     endif
  2143)     
  2144)     cur_variable => cur_variable%next
  2145)   enddo
  2146) 
  2147)   if (aveg_plot_flag) then
  2148) 
  2149)     if (realization_base%output_option%print_hdf5) then
  2150)       call PetscTime(tstart,ierr);CHKERRQ(ierr)
  2151)       call PetscLogEventBegin(logging%event_output_hdf5,ierr);CHKERRQ(ierr)
  2152)       if (realization_base%discretization%itype == UNSTRUCTURED_GRID) then
  2153)         call OutputHDF5UGridXDMF(realization_base,AVERAGED_VARS)
  2154)       else
  2155)         call OutputHDF5(realization_base,AVERAGED_VARS)
  2156)       endif      
  2157)       call PetscLogEventEnd(logging%event_output_hdf5,ierr);CHKERRQ(ierr)
  2158)       call PetscTime(tend,ierr);CHKERRQ(ierr)
  2159)       write(option%io_buffer,'(f10.2," Seconds to write HDF5 file.")') tend-tstart
  2160)       call printMsg(option)
  2161)     endif
  2162) 
  2163)     ! Reset the vectors to zero
  2164)     do ivar=1,output_option%aveg_output_variable_list%nvars
  2165)       call VecSet(field%avg_vars_vec(ivar),0.d0,ierr);CHKERRQ(ierr)
  2166)     enddo
  2167) 
  2168)     output_option%aveg_var_dtime=0.d0
  2169) 
  2170)   endif
  2171) 
  2172) 
  2173) end subroutine OutputAvegVars
  2174) 
  2175) end module Output_module

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