factory_surface.F90       coverage:  25.00 %func     29.63 %block


     1) module Factory_Surface_module
     2) 
     3)   use Simulation_Surface_class
     4) 
     5)   use PFLOTRAN_Constants_module
     6) 
     7)   implicit none
     8) 
     9)   private
    10) 
    11) #include "petsc/finclude/petscsys.h"
    12) 
    13)   public :: SurfaceInitialize, &
    14)             SurfaceInitializePostPETSc, &
    15)             SurfaceReadInput, &
    16) !            HijackSurfaceSimulation, &
    17)             SurfaceJumpStart
    18) 
    19) contains
    20) 
    21) ! ************************************************************************** !
    22) 
    23) subroutine SurfaceInitialize(simulation_base,option)
    24)   ! 
    25)   ! This routine
    26)   ! 
    27)   ! Author: Gautam Bisht, LBNL
    28)   ! Date: 06/27/13
    29)   ! 
    30) 
    31)   use Option_module
    32)   use Input_Aux_module
    33)   use Timestepper_Base_class
    34)   use Simulation_Base_class
    35)   
    36)   implicit none
    37)   
    38)   class(simulation_base_type), pointer :: simulation_base
    39)   type(option_type), pointer :: option
    40) 
    41)   class(simulation_surface_type), pointer :: simulation
    42) 
    43)   ! NOTE: PETSc must already have been initialized here!
    44)   simulation => SurfaceSimulationCreate(option)
    45)   call SurfaceInitializePostPETSc(simulation,option)
    46)   
    47)   simulation_base => simulation
    48) 
    49) end subroutine SurfaceInitialize
    50) 
    51) ! ************************************************************************** !
    52) 
    53) subroutine SurfaceInitializePostPETSc(simulation, option)
    54)   ! 
    55)   ! This routine
    56)   ! 
    57)   ! Author: Gautam Bisht, LBNL
    58)   ! Date: 06/27/13
    59)   ! 
    60) 
    61)   use Option_module
    62)   use Init_Common_module
    63)   
    64)   implicit none
    65)   
    66)   class(simulation_surface_type) :: simulation
    67)   type(option_type), pointer :: option
    68)   
    69)   call SurfaceJumpStart(simulation)
    70) 
    71) end subroutine SurfaceInitializePostPETSc
    72) 
    73) ! ************************************************************************** !
    74) 
    75) subroutine SurfaceJumpStart(simulation)
    76)   ! 
    77)   ! This routine
    78)   ! 
    79)   ! Author: Gautam Bisht, LBNL
    80)   ! Date: 06/28/13
    81)   ! 
    82) 
    83)   use Realization_Surface_class
    84)   use Option_module
    85)   use Timestepper_Surface_class
    86)   use Output_Aux_module
    87)   use Output_module
    88)   use Logging_module  
    89)   use Condition_Control_module
    90)   use Checkpoint_Surface_module
    91)   use Output_Surface_module, only : OutputSurface, OutputSurfaceInit
    92) 
    93)   implicit none
    94) 
    95)   type(simulation_surface_type) :: simulation
    96)   
    97)   class(realization_surface_type), pointer :: surf_realization
    98)   class(timestepper_surface_type), pointer :: master_timestepper
    99)   class(timestepper_surface_type), pointer :: surf_flow_timestepper
   100)   type(option_type), pointer :: option
   101)   type(output_option_type), pointer :: output_option
   102) 
   103)   character(len=MAXSTRINGLENGTH) :: string
   104)   PetscBool :: snapshot_plot_flag,observation_plot_flag,massbal_plot_flag
   105)   PetscBool :: surf_flow_read
   106)   PetscBool :: failure
   107)   PetscErrorCode :: ierr
   108)   PetscReal :: surf_flow_prev_dt
   109) 
   110)   surf_realization => simulation%surf_realization
   111)   output_option => simulation%output_option
   112)   
   113)   select type(ts => simulation%surf_flow_process_model_coupler%timestepper)
   114)     class is(timestepper_surface_type)
   115)       surf_flow_timestepper => ts
   116)   end select
   117)   nullify(master_timestepper)
   118)   
   119)   option => surf_realization%option
   120) 
   121)   call PetscOptionsHasName(PETSC_NULL_OBJECT, &
   122)                            PETSC_NULL_CHARACTER, "-vecload_block_size", & 
   123)                            failure, ierr);CHKERRQ(ierr)
   124)                              
   125)   if (option%steady_state) then
   126)     option%io_buffer = 'Running in steady-state not yet supported for &
   127)                        &surface-flow.'
   128)     call printErrMsg(option)
   129)     return
   130)   endif
   131)   
   132)   master_timestepper => surf_flow_timestepper
   133) 
   134)   snapshot_plot_flag = PETSC_FALSE
   135)   observation_plot_flag = PETSC_FALSE
   136)   massbal_plot_flag = PETSC_FALSE
   137)   surf_flow_read = PETSC_FALSE
   138)   failure = PETSC_FALSE
   139)   
   140) #if 0
   141)   if (option%restart_flag) then
   142)     call SurfaceRestart(surf_realization,surf_flow_prev_dt,surf_flow_read)
   143) 
   144)     if (option%time /= option%surf_flow_time) then
   145)       option%io_buffer = 'option%time does not match option%surf_flow_time' // &
   146)         ' while restarting simulation. Check the restart files.'
   147)       call printErrMsg(option)
   148)     endif
   149) 
   150)     if (surf_flow_read) then
   151)       surf_flow_timestepper%prev_dt = surf_flow_prev_dt
   152)       surf_flow_timestepper%target_time = option%surf_flow_time
   153)       call TSSetTime(surf_flow_timestepper%solver%ts,option%surf_flow_time, &
   154)                      ierr);CHKERRQ(ierr)
   155)     endif
   156) 
   157)   endif
   158) #endif
   159) 
   160)   ! pushed in Init()
   161)   call PetscLogStagePop(ierr);CHKERRQ(ierr)
   162) 
   163)   ! popped in TimestepperFinalizeRun()
   164)   call PetscLogStagePush(logging%stage(TS_STAGE),ierr);CHKERRQ(ierr)
   165) 
   166)   !if TIMESTEPPER->MAX_STEPS < 0, print out solution composition only
   167)   if (master_timestepper%max_time_step < 0) then
   168)     call printMsg(option,'')
   169)     write(option%io_buffer,*) master_timestepper%max_time_step
   170)     option%io_buffer = 'The maximum # of time steps (' // &
   171)                        trim(adjustl(option%io_buffer)) // &
   172)                        '), specified by TIMESTEPPER->MAX_STEPS, ' // &
   173)                        'has been met.  Stopping....'  
   174)     call printMsg(option)
   175)     call printMsg(option,'')
   176)     return
   177)   endif
   178) 
   179)   ! print initial condition output if not a restarted sim
   180)   call OutputSurfaceInit(master_timestepper%steps)
   181)   if (output_option%plot_number == 0 .and. &
   182)       master_timestepper%max_time_step >= 0) then
   183)     if (output_option%print_initial_snap) snapshot_plot_flag = PETSC_TRUE
   184)     if (output_option%print_initial_obs) observation_plot_flag = PETSC_TRUE
   185)     if (output_option%print_initial_massbal) massbal_plot_flag = PETSC_FALSE
   186)     !call OutputSurface(surf_realization,snapshot_plot_flag, &
   187)     !                   observation_plot_flag,massbal_plot_flag)
   188)   endif
   189)   
   190)   !if TIMESTEPPER->MAX_STEPS < 1, print out initial condition only
   191)   if (master_timestepper%max_time_step < 1) then
   192)     call printMsg(option,'')
   193)     write(option%io_buffer,*) master_timestepper%max_time_step
   194)     option%io_buffer = 'The maximum # of time steps (' // &
   195)                        trim(adjustl(option%io_buffer)) // &
   196)                        '), specified by TIMESTEPPER->MAX_STEPS, ' // &
   197)                        'has been met.  Stopping....'  
   198)     call printMsg(option)
   199)     call printMsg(option,'') 
   200)     return
   201)   endif
   202) 
   203)   ! increment plot number so that 000 is always the initial condition, 
   204)   ! and nothing else
   205)   if (output_option%plot_number == 0) output_option%plot_number = 1
   206) 
   207)   if (.not.associated(surf_flow_timestepper%cur_waypoint)) then
   208)     option%io_buffer = &
   209)       'Null flow waypoint list; final time likely equal to start time.'
   210)     call printMsg(option)
   211)     return
   212)   else
   213)     surf_flow_timestepper%dt_max = surf_flow_timestepper%cur_waypoint%dt_max
   214)   endif
   215)           
   216)   surf_flow_timestepper%start_time_step = surf_flow_timestepper%steps + 1
   217)   
   218)   if (surf_realization%debug%print_couplers) then
   219)   !  call OutputPrintSurfaceCouplers(surf_realization,ZERO_INTEGER)
   220)   endif
   221) 
   222) end subroutine SurfaceJumpStart
   223) 
   224) ! ************************************************************************** !
   225) 
   226) subroutine SurfaceReadInput(surf_realization,surf_flow_solver,waypoint_list, &
   227)                             input)
   228)   ! 
   229)   ! This routine reads surface flow data from the input file
   230)   ! grids.
   231)   ! 
   232)   ! Author: Gautam Bisht, ORNL
   233)   ! Date: 02/09/12
   234)   ! 
   235) 
   236)   use Option_module
   237)   use Input_Aux_module
   238)   use String_module
   239)   use Surface_Material_module
   240)   use Realization_Surface_class
   241)   use Grid_module
   242)   use Grid_Structured_module
   243)   use Grid_Unstructured_module
   244)   use Dataset_Base_class
   245)   use Dataset_module
   246)   use Dataset_Common_HDF5_class
   247)   use Grid_Unstructured_Aux_module
   248)   use Discretization_module
   249)   use Region_module
   250)   use Condition_module
   251)   use Coupler_module
   252)   use Checkpoint_module
   253)   use Strata_module
   254)   use Debug_module
   255)   use Units_module
   256)   use Waypoint_module
   257)   use Patch_module
   258)   use Solver_module
   259)   use Output_Aux_module
   260)   use Output_Tecplot_module
   261)   use Output_Surface_module
   262)   use Utility_module, only : DeallocateArray, UtilityReadArray
   263) 
   264)   implicit none
   265) 
   266)   class(realization_surface_type), pointer :: surf_realization
   267)   type(solver_type) :: surf_flow_solver
   268)   type(waypoint_list_type) :: waypoint_list
   269)   type(input_type), pointer :: input
   270)   
   271)   type(option_type), pointer :: option
   272)   type(discretization_type),pointer :: discretization
   273)   type(grid_type), pointer :: grid
   274)   type(grid_unstructured_type), pointer :: un_str_sfgrid
   275)   type(surface_material_property_type),pointer :: surf_material_property
   276)   type(region_type), pointer :: region
   277)   type(flow_condition_type), pointer :: flow_condition
   278)   type(coupler_type), pointer :: coupler
   279)   type(strata_type), pointer :: strata
   280)   class(dataset_base_type), pointer :: dataset
   281) 
   282)   type(patch_type), pointer :: patch
   283)   type(output_option_type), pointer :: output_option
   284)   PetscReal :: units_conversion
   285)   PetscReal, pointer :: temp_real_array(:)
   286)   PetscInt :: i
   287) 
   288)   character(len=MAXWORDLENGTH) :: word 
   289)   character(len=MAXWORDLENGTH) :: internal_units
   290)   character(len=MAXSTRINGLENGTH) :: temp_string
   291)   character(len=MAXWORDLENGTH) :: card
   292)   character(len=1) :: backslash
   293) 
   294)   PetscBool :: velocities
   295)   PetscBool :: mass_flowrate
   296)   PetscBool :: energy_flowrate
   297)   PetscBool :: aveg_mass_flowrate
   298)   PetscBool :: aveg_energy_flowrate
   299) 
   300)   type(waypoint_type), pointer :: waypoint
   301)   PetscReal :: temp_real, temp_real2
   302) 
   303)   backslash = achar(92)  ! 92 = "\" Some compilers choke on \" thinking it
   304)                           ! is a double quote as in c/c++
   305) 
   306)   input%ierr = 0
   307) ! we initialize the word to blanks to avoid error reported by valgrind
   308)   word = ''
   309) 
   310)   option => surf_realization%option
   311)   
   312)   discretization => surf_realization%discretization
   313)   output_option => surf_realization%output_option
   314) 
   315)   patch => surf_realization%patch
   316) 
   317)   if (associated(patch)) grid => patch%grid
   318) 
   319)   do
   320)     call InputReadPflotranString(input,option)
   321)     if (InputCheckExit(input,option)) exit
   322) 
   323)     call InputReadWord(input,option,word,PETSC_TRUE)
   324)     call InputErrorMsg(input,option,'keyword','SURFACE_FLOW')
   325)     call StringToUpper(word)
   326)     write(*,*) 'word :: ',trim(word)
   327) 
   328)     select case(trim(word))
   329)       !.........................................................................
   330)       ! Read surface grid information
   331)       case ('SURF_GRID')
   332)         call InputSkipToEND(input,option,trim(word))
   333)       !.........................................................................
   334)       case ('SURF_FLOW_FORMULATION')
   335)         call InputReadWord(input,option,word,PETSC_TRUE)
   336)         call StringToUpper(word)
   337)         select case(trim(word))
   338)           !case ('KINEMATIC')
   339)           !  option%surface_flow_formulation = KINEMATIC_WAVE
   340)           case ('DIFFUSIVE')
   341)             option%surface_flow_formulation = DIFFUSION_WAVE
   342)           case default
   343)             call InputKeywordUnrecognized(word, &
   344)                   'SURFACE_FLOW,SURF_FLOW_FORMULATION',option)
   345)         end select
   346)       !.........................................................................
   347)       case ('SURF_MAX_MANNING_VELOCITY')
   348)         call InputReadDouble(input,option,temp_real)
   349)         option%max_manning_velocity = temp_real
   350)       !.........................................................................
   351)       case ('SURF_MAX_INFILTRATION_VELOCITY')
   352)         call InputReadDouble(input,option,temp_real)
   353)         option%max_infiltration_velocity = temp_real
   354)       !.........................................................................
   355)       ! Read surface material information
   356)       case ('SURF_MATERIAL_PROPERTY')
   357)         surf_material_property => SurfaceMaterialPropertyCreate()
   358) 
   359)         call InputReadWord(input,option,surf_material_property%name,PETSC_TRUE)
   360)         call InputErrorMsg(input,option,'name','MATERIAL_PROPERTY')
   361)         call SurfaceMaterialPropertyRead(surf_material_property,input,option)
   362)         call SurfaceMaterialPropertyAddToList(surf_material_property, &
   363)                                       surf_realization%surf_material_properties)
   364)         nullify(surf_material_property)
   365) 
   366)       !.........................................................................
   367)       case ('SURF_REGION')
   368)         region => RegionCreate()
   369)         call InputReadWord(input,option,region%name,PETSC_TRUE)
   370)         call InputErrorMsg(input,option,'name','SURF_REGION')
   371)         call printMsg(option,region%name)
   372)         call RegionRead(region,input,option)
   373)         ! we don't copy regions down to patches quite yet, since we
   374)         ! don't want to duplicate IO in reading the regions
   375)         call RegionAddToList(region,surf_realization%surf_regions)
   376)         nullify(region)
   377) 
   378)       !.........................................................................
   379)       case ('SURF_FLOW_CONDITION')
   380)         flow_condition => FlowConditionCreate(option)
   381)         call InputReadWord(input,option,flow_condition%name,PETSC_TRUE)
   382)         call InputErrorMsg(input,option,'SURF_FLOW_CONDITION','name')
   383)         call printMsg(option,flow_condition%name)
   384)         if (option%iflowmode == G_MODE) then
   385)           call FlowConditionGeneralRead(flow_condition,input,option)
   386)         else
   387)           call FlowConditionRead(flow_condition,input,option)
   388)         endif
   389)         call FlowConditionAddToList(flow_condition, &
   390)                                     surf_realization%surf_flow_conditions)
   391)         nullify(flow_condition)
   392) 
   393)       !.........................................................................
   394)       case ('SURF_BOUNDARY_CONDITION')
   395)         coupler => CouplerCreate(BOUNDARY_COUPLER_TYPE)
   396)         call InputReadWord(input,option,coupler%name,PETSC_TRUE)
   397)         call InputDefaultMsg(input,option,'Boundary Condition name')
   398)         call CouplerRead(coupler,input,option)
   399)         call RealizSurfAddCoupler(surf_realization,coupler)
   400)         nullify(coupler)
   401) 
   402)       !.........................................................................
   403)       case ('STRATIGRAPHY','STRATA')
   404)         strata => StrataCreate()
   405)         call StrataRead(strata,input,option)
   406)         call RealizSurfAddStrata(surf_realization,strata)
   407)         nullify(strata)
   408)         
   409)       !.........................................................................
   410)       case ('SURF_INITIAL_CONDITION')
   411)         coupler => CouplerCreate(INITIAL_COUPLER_TYPE)
   412)         call InputReadWord(input,option,coupler%name,PETSC_TRUE)
   413)         call InputDefaultMsg(input,option,'Initial Condition name') 
   414)         call CouplerRead(coupler,input,option)
   415)         call RealizSurfAddCoupler(surf_realization,coupler)
   416)         nullify(coupler)        
   417) 
   418)       !.........................................................................
   419)       case ('SURF_SOURCE_SINK')
   420)         coupler => CouplerCreate(SRC_SINK_COUPLER_TYPE)
   421)         call InputReadWord(input,option,coupler%name,PETSC_TRUE)
   422)         call InputDefaultMsg(input,option,'Source Sink name') 
   423)         call CouplerRead(coupler,input,option)
   424)         call RealizSurfAddCoupler(surf_realization,coupler)
   425)         nullify(coupler)        
   426) 
   427)       !.........................................................................
   428)       case ('SURF_SUBSURFACE_COUPLING')
   429)         call InputReadPflotranString(input,option)
   430)         if (InputCheckExit(input,option)) exit
   431)         call InputReadWord(input,option,word,PETSC_TRUE)
   432)         call StringToUpper(word)
   433)         select case(trim(word))
   434)           case('DECOUPLED')
   435)             option%subsurf_surf_coupling = DECOUPLED
   436)           case('FULLY_COUPLED')
   437)             option%subsurf_surf_coupling = FULLY_COUPLED
   438)           case('SEQ_COUPLED')
   439)             option%subsurf_surf_coupling = SEQ_COUPLED
   440)           case default
   441)             option%io_buffer = 'Invalid value for SURF_SUBSURFACE_COUPLING'
   442)             call printErrMsg(option)
   443)         end select
   444)         call InputSkipToEND(input,option,trim(word))
   445) 
   446)       !.........................................................................
   447)       case ('SURF_DEBUG')
   448)         call DebugRead(surf_realization%debug,input,option)
   449) 
   450)       !.........................................................................
   451)       case ('SURF_OUTPUT')
   452)         velocities = PETSC_FALSE
   453)         mass_flowrate = PETSC_FALSE
   454)         energy_flowrate = PETSC_FALSE
   455)         aveg_mass_flowrate = PETSC_FALSE
   456)         aveg_energy_flowrate = PETSC_FALSE
   457)         do
   458)           call InputReadPflotranString(input,option)
   459)           call InputReadStringErrorMsg(input,option,card)
   460)           if (InputCheckExit(input,option)) exit
   461)           call InputReadWord(input,option,word,PETSC_TRUE)
   462)           call InputErrorMsg(input,option,'keyword','SURF_OUTPUT')
   463)           call StringToUpper(word)
   464)           select case(trim(word))
   465)             case('NO_FINAL','NO_PRINT_FINAL')
   466)               output_option%print_final_snap = PETSC_FALSE
   467)               output_option%print_final_obs = PETSC_FALSE
   468)               output_option%print_final_massbal = PETSC_FALSE
   469)             case('NO_INITIAL','NO_PRINT_INITIAL')
   470)               output_option%print_initial_snap = PETSC_FALSE
   471)               output_option%print_initial_obs = PETSC_FALSE
   472)               output_option%print_initial_massbal = PETSC_FALSE
   473)             case('PERMEABILITY')
   474)               option%io_buffer = 'PERMEABILITY output must now be entered &
   475)                                  &under OUTPUT/VARIABLES card.'
   476)               call printErrMsg(option)
   477) !              output_option%print_permeability = PETSC_TRUE
   478)             case('POROSITY')
   479)               option%io_buffer = 'POROSITY output must now be entered under &
   480)                                  &OUTPUT/VARIABLES card.'
   481)               call printErrMsg(option)
   482) !              output_option%print_porosity = PETSC_TRUE
   483)             case('PRINT_COLUMN_IDS')
   484)               output_option%print_column_ids = PETSC_TRUE
   485)             case('TIMES')
   486)               internal_units = 'sec'
   487)               call InputReadWord(input,option,word,PETSC_TRUE)
   488)               call InputErrorMsg(input,option,'units','SURF_OUTPUT')
   489)               units_conversion = UnitsConvertToInternal(word, &
   490)                                  internal_units,option)
   491)               temp_string = 'SURF_OUTPUT,TIMES'
   492)               nullify(temp_real_array)
   493)               call UtilityReadArray(temp_real_array,NEG_ONE_INTEGER, &
   494)                                     temp_string,input,option)
   495)               do i = 1, size(temp_real_array)
   496)                 waypoint => WaypointCreate()
   497)                 waypoint%time = temp_real_array(i)*units_conversion
   498)                 waypoint%print_snap_output = PETSC_TRUE
   499)                 call WaypointInsertInList(waypoint,waypoint_list)
   500)               enddo
   501)               call DeallocateArray(temp_real_array)
   502)             case('OUTPUT_FILE')
   503)               call InputReadWord(input,option,word,PETSC_TRUE)
   504)               call InputErrorMsg(input,option,'time increment', &
   505)                                  'SURF_OUTPUT,OUTPUT_FILE')
   506)               call StringToUpper(word)
   507)               select case(trim(word))
   508)                 case('OFF')
   509)                   option%print_to_file = PETSC_FALSE
   510)                 case('PERIODIC')
   511)                   call InputReadInt(input,option,output_option%output_file_imod)
   512)                   call InputErrorMsg(input,option,'timestep increment', &
   513)                                      'SURF_OUTPUT,PERIODIC,OUTPUT_FILE')
   514)                 case default
   515)                   call InputKeywordUnrecognized(word, &
   516)                     'SURF_OUTPUT,PERIODIC,OUTPUT_FILE',option)
   517)               end select
   518)             case('SCREEN')
   519)               call InputReadWord(input,option,word,PETSC_TRUE)
   520)               call InputErrorMsg(input,option,'time increment','OUTPUT,SCREEN')
   521)               call StringToUpper(word)
   522)               select case(trim(word))
   523)                 case('OFF')
   524)                   option%print_to_screen = PETSC_FALSE
   525)                 case('PERIODIC')
   526)                   call InputReadInt(input,option,output_option%screen_imod)
   527)                   call InputErrorMsg(input,option,'timestep increment', &
   528)                                      'SURF_OUTPUT,PERIODIC,SCREEN')
   529)                 case default
   530)                   call InputKeywordUnrecognized(word, &
   531)                     'SURF_OUTPUT,PERIODIC,SCREEN',option)
   532)               end select
   533)             case('PERIODIC')
   534)               call InputReadWord(input,option,word,PETSC_TRUE)
   535)               call InputErrorMsg(input,option,'time increment', &
   536)                                  'SURF_OUTPUT,PERIODIC')
   537)               call StringToUpper(word)
   538)               select case(trim(word))
   539)                 case('TIME')
   540)                   internal_units = 'sec'
   541)                   call InputReadDouble(input,option,temp_real)
   542)                   call InputErrorMsg(input,option,'time increment', &
   543)                                      'SURF_OUTPUT,PERIODIC,TIME')
   544)                   call InputReadWord(input,option,word,PETSC_TRUE)
   545)                   call InputErrorMsg(input,option,'time increment units', &
   546)                                      'SURF_OUTPUT,PERIODIC,TIME')
   547)                   units_conversion = UnitsConvertToInternal(word, &
   548)                                      internal_units,option)
   549)                   output_option%periodic_snap_output_time_incr = temp_real* &
   550)                                                             units_conversion
   551)                   call InputReadWord(input,option,word,PETSC_TRUE)
   552)                   if (input%ierr == 0) then
   553)                     if (StringCompareIgnoreCase(word,'between')) then
   554)                       call InputReadDouble(input,option,temp_real)
   555)                       call InputErrorMsg(input,option,'start time', &
   556)                                          'SURF_OUTPUT,PERIODIC,TIME')
   557)                       call InputReadWord(input,option,word,PETSC_TRUE)
   558)                       call InputErrorMsg(input,option,'start time units', &
   559)                                          'SURF_OUTPUT,PERIODIC,TIME')
   560)                       units_conversion = UnitsConvertToInternal(word, &
   561)                                          internal_units,option)
   562)                       temp_real = temp_real * units_conversion
   563)                       call InputReadWord(input,option,word,PETSC_TRUE)
   564)                       if (.not.StringCompareIgnoreCase(word,'and')) then
   565)                         input%ierr = 1
   566)                       endif
   567)                       call InputErrorMsg(input,option,'and', &
   568)                                           'SURF_OUTPUT,PERIODIC,TIME"')
   569)                       call InputReadDouble(input,option,temp_real2)
   570)                       call InputErrorMsg(input,option,'end time', &
   571)                                          'SURF_OUTPUT,PERIODIC,TIME')
   572)                       call InputReadWord(input,option,word,PETSC_TRUE)
   573)                       call InputErrorMsg(input,option,'end time units', &
   574)                                          'SURF_OUTPUT,PERIODIC,TIME')
   575)                       temp_real2 = temp_real2 * units_conversion
   576)                       do
   577)                         waypoint => WaypointCreate()
   578)                         waypoint%time = temp_real
   579)                         waypoint%print_snap_output = PETSC_TRUE
   580)                         call WaypointInsertInList(waypoint,waypoint_list)
   581)                         temp_real = temp_real + &
   582)                                     output_option%periodic_snap_output_time_incr
   583)                         if (temp_real > temp_real2) exit
   584)                       enddo
   585)                       output_option%periodic_snap_output_time_incr = 0.d0
   586)                     else
   587)                       input%ierr = 1
   588)                       call InputErrorMsg(input,option,'between', &
   589)                                           'SURF_OUTPUT,PERIODIC,TIME')
   590)                     endif
   591)                   endif
   592)                 case('TIMESTEP')
   593)                   call InputReadInt(input,option, &
   594)                                     output_option%periodic_snap_output_ts_imod)
   595)                   call InputErrorMsg(input,option,'timestep increment', &
   596)                                      'SURF_OUTPUT,PERIODIC,TIMESTEP')
   597)                 case default
   598)                   call InputKeywordUnrecognized(word, &
   599)                     'SURF_OUTPUT,PERIODIC,TIMESTEP',option)
   600)               end select
   601)             case('PERIODIC_OBSERVATION')
   602)               output_option%print_observation = PETSC_TRUE
   603)               call InputReadWord(input,option,word,PETSC_TRUE)
   604)               call InputErrorMsg(input,option,'time increment', &
   605)                 'SURF_OUTPUT, PERIODIC_OBSERVATION')
   606)               call StringToUpper(word)
   607)               select case(trim(word))
   608)                 case('TIME')
   609)                   internal_units = 'sec'
   610)                   call InputReadDouble(input,option,temp_real)
   611)                   call InputErrorMsg(input,option,'time increment', &
   612)                                      'SURF_OUTPUT,PERIODIC_OBSERVATION,TIME')
   613)                   call InputReadWord(input,option,word,PETSC_TRUE)
   614)                   call InputErrorMsg(input,option,'time increment units', &
   615)                                      'SURF_OUTPUT,PERIODIC_OBSERVATION,TIME')
   616)                   units_conversion = UnitsConvertToInternal(word, &
   617)                                      internal_units,option) 
   618)                   output_option%periodic_obs_output_time_incr = temp_real* &
   619)                                                                units_conversion
   620)                 case('TIMESTEP')
   621)                   call InputReadInt(input,option, &
   622)                                     output_option%periodic_obs_output_ts_imod)
   623)                   call InputErrorMsg(input,option,'timestep increment', &
   624)                                      'SURF_OUTPUT,PERIODIC_OBSERVATION,&
   625)                                      &TIMESTEP')
   626)                 case default
   627)                   call InputKeywordUnrecognized(word, &
   628)                     'SURF_OUTPUT,PERIODIC_OBSERVATION,TIMESTEP',option)
   629)               end select
   630)             case('FORMAT')
   631)               call InputReadWord(input,option,word,PETSC_TRUE)
   632)               call InputErrorMsg(input,option,'keyword','OUTPUT,FORMAT') 
   633)               call StringToUpper(word)
   634)               select case(trim(word))
   635)                 case ('HDF5')
   636)                   output_option%print_hdf5 = PETSC_TRUE
   637)                   call InputReadWord(input,option,word,PETSC_TRUE)
   638)                   call InputDefaultMsg(input,option, &
   639)                                        'OUTPUT,FORMAT,HDF5,# FILES')
   640)                   if (len_trim(word) > 1) then 
   641)                     call StringToUpper(word)
   642)                     select case(trim(word))
   643)                       case('SINGLE_FILE')
   644)                         output_option%print_single_h5_file = PETSC_TRUE
   645)                       case('MULTIPLE_FILES')
   646)                         output_option%print_single_h5_file = PETSC_FALSE
   647)                         output_option%times_per_h5_file = 1
   648)                         call InputReadWord(input,option,word,PETSC_TRUE)
   649)                         if (len_trim(word)>0) then
   650)                           select case(trim(word))
   651)                             case('TIMES_PER_FILE')
   652)                               call InputReadInt(input,option, &
   653)                                               output_option%times_per_h5_file)
   654)                               call InputErrorMsg(input,option,'timestep &
   655)                                      &increment','OUTPUT,FORMAT,MULTIPLE_FILES&
   656)                                      &,TIMES_PER_FILE')
   657)                             case default
   658)                               call InputKeywordUnrecognized(word, &
   659)                                 'SURF_OUTPUT,FORMAT,HDF5,MULTIPLE_FILES',option)
   660)                           end select
   661)                         endif
   662)                       case default
   663)                         call InputKeywordUnrecognized(word, &
   664)                           'SURF_OUTPUT,FORMAT,HDF5',option)
   665)                     end select
   666)                   endif
   667)                 case ('MAD')
   668)                   output_option%print_mad = PETSC_TRUE
   669)                 case ('TECPLOT')
   670)                   output_option%print_tecplot = PETSC_TRUE
   671)                   call InputReadWord(input,option,word,PETSC_TRUE)
   672)                   call InputErrorMsg(input,option,'TECPLOT','OUTPUT,FORMAT') 
   673)                   call StringToUpper(word)
   674)                   select case(trim(word))
   675)                     case('POINT')
   676)                       output_option%tecplot_format = TECPLOT_POINT_FORMAT
   677)                     case('BLOCK')
   678)                       output_option%tecplot_format = TECPLOT_BLOCK_FORMAT
   679)                     case('FEQUADRILATERAL')
   680)                       output_option%tecplot_format = &
   681)                         TECPLOT_FEQUADRILATERAL_FORMAT
   682)                     case default
   683)                       option%io_buffer = 'TECPLOT format (' // trim(word) // &
   684)                                          ') not recongnized.'
   685)                       call printErrMsg(option)
   686)                   end select
   687)                   if (output_option%tecplot_format == TECPLOT_POINT_FORMAT &
   688)                       .and. option%mycommsize > 1) then
   689)                     output_option%tecplot_format = TECPLOT_BLOCK_FORMAT
   690)                   endif
   691)                   if (grid%itype == IMPLICIT_UNSTRUCTURED_GRID) then
   692)                     output_option%tecplot_format = &
   693)                       TECPLOT_FEQUADRILATERAL_FORMAT
   694)                   endif
   695)                 case ('VTK')
   696)                   output_option%print_vtk = PETSC_TRUE
   697)                 case default
   698)                   call InputKeywordUnrecognized(word, &
   699)                          'SURF_OUTPUT,FORMAT',option)
   700)               end select
   701) 
   702)             case('VELOCITY_AT_CENTER')
   703)               velocities = PETSC_TRUE
   704)             case ('HDF5_WRITE_GROUP_SIZE')
   705)               call InputReadInt(input,option,option%hdf5_write_group_size)
   706)               call InputErrorMsg(input,option,'HDF5_WRITE_GROUP_SIZE', &
   707)                                  'Group size')
   708)             case('HYDROGRAPH')
   709)               output_option%print_hydrograph = PETSC_TRUE
   710)             case('PROCESSOR_ID')
   711)               option%io_buffer = 'PROCESSOR_ID output must now be entered &
   712)                                  &under OUTPUT/VARIABLES card as PROCESS_ID.'
   713)               call printErrMsg(option)
   714) !              output_option%print_iproc = PETSC_TRUE
   715)             case('FLOWRATES','FLOWRATE')
   716)               mass_flowrate = PETSC_TRUE
   717)               energy_flowrate = PETSC_TRUE
   718)             case('MASS_FLOWRATE')
   719)               mass_flowrate = PETSC_TRUE
   720)             case('ENERGY_FLOWRATE')
   721)               energy_flowrate = PETSC_TRUE
   722)             case('AVERAGE_FLOWRATES','AVERAGE_FLOWRATE')
   723)               aveg_mass_flowrate = PETSC_TRUE
   724)               aveg_energy_flowrate = PETSC_TRUE
   725)             case('AVERAGE_MASS_FLOWRATE')
   726)               aveg_mass_flowrate = PETSC_TRUE
   727)             case('AVERAGE_ENERGY_FLOWRATE')
   728)               aveg_energy_flowrate = PETSC_TRUE
   729)             case('VARIABLES')
   730)               call OutputSurfaceVariableRead(input,option, &
   731)                      output_option%output_variable_list)
   732)             case('AVERAGE_VARIABLES')
   733)               call OutputSurfaceVariableRead(input,option, &
   734)                      output_option%aveg_output_variable_list)
   735)             case default
   736)               call InputKeywordUnrecognized(word,'SURF_OUTPUT',option)
   737)           end select
   738)         enddo
   739) 
   740)         if (velocities) then
   741)           if (output_option%print_tecplot) &
   742)             output_option%print_tecplot_vel_cent = PETSC_TRUE
   743)           if (output_option%print_hdf5) &
   744)             output_option%print_hdf5_vel_cent = PETSC_TRUE
   745)           if (output_option%print_vtk) &
   746)             output_option%print_vtk_vel_cent = PETSC_TRUE
   747)         endif
   748)         if (mass_flowrate.or.energy_flowrate.or.aveg_mass_flowrate.or. &
   749)             aveg_energy_flowrate) then
   750)           if (output_option%print_hdf5) then
   751)             output_option%print_hdf5_mass_flowrate = mass_flowrate
   752)             output_option%print_hdf5_energy_flowrate = energy_flowrate
   753)             output_option%print_hdf5_aveg_mass_flowrate = aveg_mass_flowrate
   754)             output_option%print_hdf5_aveg_energy_flowrate = aveg_energy_flowrate
   755)             if (aveg_mass_flowrate.or.aveg_energy_flowrate) then
   756)               if (output_option%periodic_snap_output_time_incr==0.d0) then
   757)                 option%io_buffer = 'Keyword: AVEGRAGE_FLOWRATES/ ' // &
   758)                   'AVEGRAGE_MASS_FLOWRATE/ENERGY_FLOWRATE defined without' // &
   759)                   ' PERIODIC TIME being set.'
   760)                 call printErrMsg(option)
   761)               endif
   762)             endif
   763)             option%flow%store_fluxes = PETSC_TRUE
   764)           else
   765)             option%io_buffer='Output FLOWRATES/MASS_FLOWRATE/ENERGY_FLOWRATE ' // &
   766)               'only available in HDF5 format'
   767)             call printErrMsg(option)
   768)           endif
   769)         endif
   770) 
   771)       !.........................................................................
   772)       case('NEWTON_SOLVER')
   773)         call InputReadWord(input,option,word,PETSC_FALSE)
   774)         call StringToUpper(word)
   775)         select case(word)
   776)           case('FLOW')
   777)             call SolverReadNewton(surf_flow_solver,input,option)
   778)         end select
   779) 
   780)       !.........................................................................
   781)       case ('SURF_TIME')
   782)         do
   783)           call InputReadPflotranString(input,option)
   784)           call InputReadStringErrorMsg(input,option,card)
   785)           if (InputCheckExit(input,option)) exit
   786)           call InputReadWord(input,option,word,PETSC_TRUE)
   787)           call InputErrorMsg(input,option,'word','SURF_TIME')
   788)           internal_units = 'sec'
   789)           select case(trim(word))
   790)             case ('INITIAL_TIMESTEP_SIZE')
   791)               call InputReadDouble(input,option,temp_real)
   792)               call InputErrorMsg(input,option,'Initial Timestep Size','TIME') 
   793)               call InputReadWord(input,option,word,PETSC_TRUE)
   794)               call InputErrorMsg(input,option, &
   795)                                  'Initial Timestep Size Time Units','TIME')
   796)               surf_realization%dt_init = &
   797)                 temp_real*UnitsConvertToInternal(word,internal_units,option)
   798)             case('MAXIMUM_TIMESTEP_SIZE')
   799)               call InputReadDouble(input,option,temp_real)
   800)               call InputErrorMsg(input,option,'Maximum Timestep Size','TIME') 
   801)               call InputReadWord(input,option,word,PETSC_TRUE)
   802)               call InputErrorMsg(input,option, &
   803)                                  'Maximum Timestep Size Time Units','TIME')
   804)               surf_realization%dt_max = & 
   805)                 temp_real*UnitsConvertToInternal(word,internal_units,option)
   806)             case('COUPLING_TIMESTEP_SIZE')
   807)               call InputReadDouble(input,option,temp_real)
   808)               call InputErrorMsg(input,option,'Coupling Timestep Size','TIME') 
   809)               call InputReadWord(input,option,word,PETSC_TRUE)
   810)               call InputErrorMsg(input,option, &
   811)                                  'Coupling Timestep Size Time Units','TIME')
   812)               surf_realization%dt_coupling = &
   813)                 temp_real*UnitsConvertToInternal(word,internal_units,option)
   814)             case default
   815)               call InputKeywordUnrecognized(word,'TIME',option)
   816)             end select
   817)         enddo
   818)       !.........................................................................
   819)       case ('SURF_DATASET')
   820)       nullify(dataset)
   821)       call DatasetRead(input,dataset,option)
   822)       call DatasetBaseAddToList(dataset,surf_realization%datasets)
   823)       nullify(dataset)
   824)       
   825)       !.........................................................................
   826)       case ('SURF_RESTART')
   827)         option%io_buffer = 'The SURF_RESTART card within SURFACE_FLOW &
   828)                            &block has been deprecated.'      
   829)         !option%surf_restart_flag = PETSC_TRUE
   830)         !call InputReadNChars(input,option,option%surf_restart_filename, &
   831)         !                     MAXSTRINGLENGTH,PETSC_TRUE)
   832)         !call InputErrorMsg(input,option,'SURF_RESTART','Surface restart &
   833)         !                                               &file name') 
   834)         !call InputReadDouble(input,option,option%restart_time)
   835)         !if (input%ierr == 0) then
   836)         !  call printErrMsg(option,'Setting time to value not supported in &
   837)         !                          &surface-flow')
   838)         !endif
   839)         !option%first_step_after_restart = PETSC_TRUE
   840) 
   841) !......................
   842) 
   843)       case ('SURF_CHECKPOINT')
   844)         option%io_buffer = 'The SURF_CHECKPOINT card within SURFACE_FLOW &
   845)                            &block has been deprecated.'      
   846) !        call CheckpointRead(input,option,surf_realization%checkpoint_option, &
   847) !                            surf_realization%waypoint_list)
   848)         
   849) !......................
   850) 
   851)       case('END_SURFACE_FLOW')
   852)         exit
   853)         
   854)       case default
   855)         call InputKeywordUnrecognized(word,'SURFACE_FLOW',option)
   856)     end select
   857)   enddo
   858) 
   859)   if (option%restart_flag .neqv. option%surf_restart_flag) then
   860)     option%io_buffer='option%restart_flag /= option%surf_restart_flag'
   861)     call printErrMsg(option)
   862)   endif
   863) 
   864) end subroutine SurfaceReadInput
   865) 
   866) end module Factory_Surface_module

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