[petsc-users] Memory Used When Reading petscrc

David Scott d.scott at epcc.ed.ac.uk
Fri Nov 22 10:35:45 CST 2024


Hello,

I am using the options mechanism of PETSc to configure my CFD code. I
have introduced options describing the size of the domain etc. I have
noticed that this consumes a lot of memory. I have found that the amount
of memory used scales linearly with the number of MPI processes used.
This restricts the number of MPI processes that I can use.

Is there anything that I can do about this or do I need to configure my
code in a different way?

I have attached some code extracted from my application which
demonstrates this along with the output from a running it on 2 MPI
processes.

Best wishes,

David Scott
The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. Is e buidheann carthannais a th’ ann an Oilthigh Dhùn Èideann, clàraichte an Alba, àireamh clàraidh SC005336.
-------------- next part --------------
!! @author Prashant Valluri, Lennon O Naraigh, Iain Bethune,
!! David Scott, Toni Collis, Peter Spelt.
!! @version $Revision: 252 $
!! @copyright (c) 2013-2020, Prashant Valluri, Lennon O Naraigh,
!! Iain Bethune, David Scott, Toni Collis, Peter Spelt.
!! This program is distributed under the BSD Licence See LICENCE.txt
!! for details.

module test_configuration_options

#include <petsc/finclude/petscsys.h>
#include "petsc/finclude/petsc.h"
  use petsc

  implicit none

  PetscScalar :: dx
  PetscScalar :: dy
  PetscScalar :: dz
  PetscScalar :: dt
  logical :: boiling
  logical :: boiling_variant
  logical :: evaporation
  logical, SAVE :: periodic(3)
  DMBoundaryType, SAVE :: boundary(3)

  enum, bind(C)
    enumerator :: BC
    enumerator :: cyclic, neumann, dirichlet, quasi_dirichlet, inlet, outlet
  end enum

  integer(kind(BC)), SAVE :: bc_temp

  integer(kind(BC)), SAVE :: x_upper_bc_T, x_upper_bc_Cl, x_upper_bc_Cv, x_upper_bc_P
  integer(kind(BC)), SAVE :: x_upper_bc_u, x_upper_bc_v, x_upper_bc_w
  integer(kind(BC)), SAVE :: x_lower_bc_T, x_lower_bc_Cl, x_lower_bc_Cv, x_lower_bc_P
  integer(kind(BC)), SAVE :: x_lower_bc_u, x_lower_bc_v, x_lower_bc_w
  integer(kind(BC)), SAVE :: y_upper_bc_T, y_upper_bc_Cl, y_upper_bc_Cv, y_upper_bc_P
  integer(kind(BC)), SAVE :: y_upper_bc_u, y_upper_bc_v, y_upper_bc_w
  integer(kind(BC)), SAVE :: y_lower_bc_T, y_lower_bc_Cl, y_lower_bc_Cv, y_lower_bc_P
  integer(kind(BC)), SAVE :: y_lower_bc_u, y_lower_bc_v, y_lower_bc_w
  integer(kind(BC)), SAVE :: z_upper_bc_T, z_upper_bc_Cl, z_upper_bc_Cv, z_upper_bc_P
  integer(kind(BC)), SAVE :: z_upper_bc_u, z_upper_bc_v, z_upper_bc_w
  integer(kind(BC)), SAVE :: z_lower_bc_T, z_lower_bc_Cl, z_lower_bc_Cv, z_lower_bc_P
  integer(kind(BC)), SAVE :: z_lower_bc_u, z_lower_bc_v, z_lower_bc_w

  double precision, SAVE :: x_upper_bc_T_value, x_upper_bc_Cl_value, x_upper_bc_Cv_value, x_upper_bc_P_value
  double precision, SAVE :: x_lower_bc_T_value, x_lower_bc_Cl_value, x_lower_bc_Cv_value, x_lower_bc_P_value
  double precision, SAVE :: y_upper_bc_T_value, y_upper_bc_Cl_value, y_upper_bc_Cv_value, y_upper_bc_P_value
  double precision, SAVE :: y_lower_bc_T_value, y_lower_bc_Cl_value, y_lower_bc_Cv_value, y_lower_bc_P_value
  double precision, SAVE :: z_upper_bc_T_value, z_upper_bc_Cl_value, z_upper_bc_Cv_value, z_upper_bc_P_value
  double precision, SAVE :: z_lower_bc_T_value, z_lower_bc_Cl_value, z_lower_bc_Cv_value, z_lower_bc_P_value

  integer, parameter :: max_option_name_length = 30
  integer, parameter :: max_msg_length = 2**max_option_name_length + 8 ! 8 for 'Modified'

contains

  subroutine read_initial_configuration_options(global_dim_x, global_dim_y, global_dim_z,    &
       Re, Pe, We, Fr, Bod, Ja, mu_plus, mu_minus, mu_vap, rho_plus, rho_minus, rho_vap,     &
       cp_plus, cp_minus, cp_vap, k_plus, k_minus, k_vap, beta_plus, beta_minus, beta_vap,   &
       dpdx, gx, gz, epn, dTdx, T_ref,                                                       &
       Pref, Apsat, Bpsat, Cpsat, molMassRatio, PeT, PeMD, PeMDI,                            &
       x_upper_bc_T, x_upper_bc_Cl, x_upper_bc_Cv, x_upper_bc_u, x_upper_bc_v, x_upper_bc_w, &
       x_lower_bc_T, x_lower_bc_Cl, x_lower_bc_Cv, x_lower_bc_u, x_lower_bc_v, x_lower_bc_w, &
       y_upper_bc_T, y_upper_bc_Cl, y_upper_bc_Cv, y_upper_bc_u, y_upper_bc_v, y_upper_bc_w, &
       y_lower_bc_T, y_lower_bc_Cl, y_lower_bc_Cv, y_lower_bc_u, y_lower_bc_v, y_lower_bc_w, &
       z_upper_bc_T, z_upper_bc_Cl, z_upper_bc_Cv, z_upper_bc_u, z_upper_bc_v, z_upper_bc_w, &
       z_lower_bc_T, z_lower_bc_Cl, z_lower_bc_Cv, z_lower_bc_u, z_lower_bc_v, z_lower_bc_w, &
       liquid_limit, gaseous_limit, ierr)

    implicit none

    PetscInt, intent(out) :: global_dim_x, global_dim_y, global_dim_z
    double precision, intent(out) :: Re, Pe, We, Fr, Bod, Ja
    double precision, intent(out) :: mu_plus, mu_minus, mu_vap
    double precision, intent(out) :: rho_plus, rho_minus, rho_vap
    double precision, intent(out) :: cp_plus, cp_minus, cp_vap
    double precision, intent(out) :: k_plus, k_minus, k_vap
    double precision, intent(out) :: beta_plus, beta_minus, beta_vap
    double precision, intent(out) :: dpdx
    double precision, intent(out) :: gx, gz
    double precision, intent(out) :: epn
    double precision, intent(out) :: dTdx
    double precision, intent(out) :: T_ref
    double precision, intent(out) :: Pref
    double precision, intent(out) :: Apsat, Bpsat, Cpsat
    double precision, intent(out) :: molMassRatio
    double precision, intent(out) :: PeT
    double precision, intent(out) :: PeMD
    double precision, intent(out) :: PeMDI
    integer(kind(BC)), intent(out) :: x_upper_bc_T, x_upper_bc_Cl, x_upper_bc_Cv
    integer(kind(BC)), intent(out) :: x_upper_bc_u, x_upper_bc_v, x_upper_bc_w
    integer(kind(BC)), intent(out) :: x_lower_bc_T, x_lower_bc_Cl, x_lower_bc_Cv
    integer(kind(BC)), intent(out) :: x_lower_bc_u, x_lower_bc_v, x_lower_bc_w
    integer(kind(BC)), intent(out) :: y_upper_bc_T, y_upper_bc_Cl, y_upper_bc_Cv
    integer(kind(BC)), intent(out) :: y_upper_bc_u, y_upper_bc_v, y_upper_bc_w
    integer(kind(BC)), intent(out) :: y_lower_bc_T, y_lower_bc_Cl, y_lower_bc_Cv
    integer(kind(BC)), intent(out) :: y_lower_bc_u, y_lower_bc_v, y_lower_bc_w
    integer(kind(BC)), intent(out) :: z_upper_bc_T, z_upper_bc_Cl, z_upper_bc_Cv
    integer(kind(BC)), intent(out) :: z_upper_bc_u, z_upper_bc_v, z_upper_bc_w
    integer(kind(BC)), intent(out) :: z_lower_bc_T, z_lower_bc_Cl, z_lower_bc_Cv
    integer(kind(BC)), intent(out) :: z_lower_bc_u, z_lower_bc_v, z_lower_bc_w
    double precision, intent(out) :: liquid_limit
    double precision, intent(out) :: gaseous_limit
    PetscErrorCode, intent(out) :: ierr

    double precision :: MM_minus, MM_vap
    double precision :: Pr, Sc
    double precision :: PeCahnHilliardModifier
!    double precision :: PeDiffusionModifier
    double precision :: Grav, alpha
    double precision :: pi = 4.0d0*atan(1.0d0)
    character(len = max_option_name_length) :: option_name
    character(len = max_msg_length) :: msg
    character(len = max_option_name_length) :: phenomenon
    logical :: found

    option_name = '-phenomenon'
    call PetscOptionsGetString(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, phenomenon, found, ierr)
    if (found) then
      write(msg, *) option_name, '= ',  trim(phenomenon)
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (phenomenon .eq. 'boiling') then
        boiling = .true.
      else
        boiling = .false.
      end if
      if (phenomenon .eq. 'boiling_variant') then
        boiling_variant = .true.
      else
        boiling_variant = .false.
      end if
      if (phenomenon .eq. 'evaporation') then
        evaporation = .true.
      else
        evaporation = .false.
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-global_dim_x'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, global_dim_x, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', global_dim_x
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-global_dim_y'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, global_dim_y, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', global_dim_y
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-global_dim_z'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, global_dim_z, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', global_dim_z
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if(global_dim_z .le. 1) then
        write(msg, *) 'global_dim_z must be greater than 1.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-dt'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, dt, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', dt
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (dt .gt. 0.0d0)) then
        write(msg, *) 'Error:', dt, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    dz = 1.0d0/dble(global_dim_z)
    dx = dz
    dy = dz
    write(msg, *) 'dx =', dx
    call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    write(msg, *) 'dy =', dy
    call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    write(msg, *) 'dz =', dz
    call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    write(msg, *) 'Lx =', dx*global_dim_x
    call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    write(msg, *) 'Ly =', dy*global_dim_y
    call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    write(msg, *) 'Lz =', dz*global_dim_z
    call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)

    option_name = '-epn'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, epn, found, ierr)
    if (found) then
      if (.not. (epn .gt. 0.0d0)) then
        epn = 0.5*dz
        if (boiling) then
          ! We need to allow for different values of Pe.
          PeCahnHilliardModifier = 1.0d0/(epn*epn)
!          PeDiffusionModifier = 1.0d0/(epn*epn)
        else
          PeCahnHilliardModifier = 1.0d0/epn
!          PeDiffusionModifier = 1.0d0/epn
        end if
      else
        PeCahnHilliardModifier = 1.0d0
!        PeDiffusionModifier = 1.0d0
      end if
      write(msg, *) option_name, '=', epn
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
   end if

    option_name = '-Re'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Re, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Re
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Re .gt. 0.0d0)) then
        write(msg, *) 'Error:', Re, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Pe'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Pe, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Pe
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Pe .gt. 0.0d0)) then
        write(msg, *) 'Error:', Pe, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      else
        Pe = Pe * PeCahnHilliardModifier
        write(msg, *) 'Modified Pe =', Pe
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Pr'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Pr, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Pr
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Pr .gt. 0.0d0)) then
        write(msg, *) 'Error:', Pr, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      else
        PeT = Re*Pr
        write(msg, *) 'PeT =', PeT
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-We'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, We, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', We
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (We .gt. 0.0d0)) then
        write(msg, *) 'Error:', We, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Fr'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Fr, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Fr
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Fr .gt. 0.0d0)) then
        write(msg, *) 'Error:', Fr, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Bod'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Bod, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Bod
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Bod .gt. 0.0d0)) then
        write(msg, *) 'Error:', Bod, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Sc'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Sc, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Sc
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Sc .ge. 0.0d0)) then
        write(msg, *) 'Error:', Sc, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      else
        PeMD = Re*Sc
        PeMDI = PeMD
        write(msg, *) 'PeMD =', PeMD
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
        write(msg, *) 'PeMDI =', PeMDI
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
       end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Ja'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Ja, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Ja
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Ja .gt. 0.0d0)) then
        write(msg, *) 'Error:', Ja, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-dTdx'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, dTdx, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', dTdx
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-T_ref'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, T_ref, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', T_ref
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Pref'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Pref, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Pref
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Pref .ge. 0.0d0)) then
        write(msg, *) 'Error:', Pref, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Apsat'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Apsat, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Apsat
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Apsat .ge. 0.0d0)) then
        write(msg, *) 'Error:', Apsat, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Bpsat'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Bpsat, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Bpsat
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Bpsat .ge. 0.0d0)) then
        write(msg, *) 'Error:', Bpsat, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Cpsat'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Cpsat, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Cpsat
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Cpsat .ge. 0.0d0)) then
        write(msg, *) 'Error:', Cpsat, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-MM_minus'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, MM_minus, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', MM_minus
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (MM_minus .gt. 0.0d0)) then
        write(msg, *) 'Error:', MM_minus, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found so using the value 1.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      MM_minus = 1.0d0
    end if

    option_name = '-MM_vap'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, MM_vap, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', MM_vap
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (MM_vap .gt. 0.0d0)) then
        write(msg, *) 'Error:', MM_vap, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found so using the value 0.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      MM_vap = 0.0d0
    end if

    molMassRatio = MM_vap / MM_minus
    write(msg, *) 'molMassRatio =', molMassRatio
    call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)

    option_name = '-mu_plus'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, mu_plus, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', mu_plus
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (mu_plus .gt. 0.0d0)) then
        write(msg, *) 'Error:', mu_plus, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-mu_minus'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, mu_minus, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', mu_minus
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (mu_minus .gt. 0.0d0)) then
        write(msg, *) 'Error:', mu_minus, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-mu_vap'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, mu_vap, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', mu_vap
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (mu_vap .gt. 0.0d0)) then
        write(msg, *) 'Error:', mu_vap, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-rho_plus'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, rho_plus, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', rho_plus
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (rho_plus .gt. 0.0d0)) then
        write(msg, *) 'Error:', rho_plus, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-rho_minus'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, rho_minus, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', rho_minus
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (rho_minus .gt. 0.0d0)) then
        write(msg, *) 'Error:', rho_minus, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-rho_vap'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, rho_vap, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', rho_vap
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (rho_vap .gt. 0.0d0)) then
        write(msg, *) 'Error:', rho_vap, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-cp_plus'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, cp_plus, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', cp_plus
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (cp_plus .gt. 0.0d0)) then
        write(msg, *) 'Error:', cp_plus, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-cp_minus'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, cp_minus, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', cp_minus
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (cp_minus .gt. 0.0d0)) then
        write(msg, *) 'Error:', cp_minus, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-cp_vap'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, cp_vap, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', cp_vap
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (cp_vap .gt. 0.0d0)) then
        write(msg, *) 'Error:', cp_vap, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-k_plus'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, k_plus, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', k_plus
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (k_plus .gt. 0.0d0)) then
        write(msg, *) 'Error:', k_plus, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-k_minus'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, k_minus, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', k_minus
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (k_minus .gt. 0.0d0)) then
        write(msg, *) 'Error:', k_minus, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-k_vap'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, k_vap, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', k_vap
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (k_vap .gt. 0.0d0)) then
        write(msg, *) 'Error:', k_vap, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-beta_plus'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, beta_plus, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', beta_plus
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (beta_plus .ge. 0.0d0)) then
        write(msg, *) 'Error:', beta_plus, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-beta_minus'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, beta_minus, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', beta_minus
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (beta_minus .ge. 0.0d0)) then
        write(msg, *) 'Error:', beta_minus, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-beta_vap'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, beta_vap, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', beta_vap
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (beta_vap .ge. 0.0d0)) then
        write(msg, *) 'Error:', beta_vap, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-dpdx'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, dpdx, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', dpdx
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (dpdx .gt. 0.0d0) then
        write(msg, *) 'Counter current flow.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Grav'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Grav, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Grav
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. (Grav .ge. 0.0d0)) then
        write(msg, *) 'Error: Grav must be non-negative.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-alpha'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, alpha, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', alpha
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. ((-pi .le. alpha) .and. (alpha .le. pi))) then
        write(msg, *) 'Error:', alpha, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    gz = Grav*sin(alpha)
    if (gz == -1.0d0) then
      gx = 0.0d0 ! In this case cos(alpha) = -3.8285686989269494E-016
    else
      gx = Grav*cos(alpha)
    end if
    write(msg, *) 'gz =', gz
    call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    write(msg, *) 'gx =', gx
    call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)

    ! X BCs.

    option_name = '-x_upper_bc_T'
    call get_BC(option_name, x_upper_bc_T, x_upper_bc_T_value, 1)

    option_name = '-x_upper_bc_Cl'
    call get_BC_with_check(option_name, x_upper_bc_Cl, x_upper_bc_Cl_value, 1)

    option_name = '-x_upper_bc_Cv'
    call get_BC_with_check(option_name, x_upper_bc_Cv, x_upper_bc_Cv_value, 1)

    option_name = '-x_upper_bc_P'
    call get_BC_with_check(option_name, x_upper_bc_P, x_upper_bc_P_value, 1)

    option_name = '-x_upper_bc_u'
    call get_BC_with_check_uvw(option_name, x_upper_bc_u, 1)

    option_name = '-x_upper_bc_v'
    call get_BC_with_check_uvw(option_name, x_upper_bc_v, 1)

    option_name = '-x_upper_bc_w'
    call get_BC_with_check_uvw(option_name, x_upper_bc_w, 1)

    option_name = '-x_lower_bc_T'
    call get_BC_with_check(option_name, x_lower_bc_T, x_lower_bc_T_value, 1)

    option_name = '-x_lower_bc_Cl'
    call get_BC_with_check(option_name, x_lower_bc_Cl, x_lower_bc_Cl_value, 1)

    option_name = '-x_lower_bc_Cv'
    call get_BC_with_check(option_name, x_lower_bc_Cv, x_lower_bc_Cv_value, 1)

    option_name = '-x_lower_bc_P'
    call get_BC_with_check(option_name, x_lower_bc_P, x_lower_bc_P_value, 1)

    option_name = '-x_lower_bc_u'
    call get_BC_with_check_uvw(option_name, x_lower_bc_u, 1)

    option_name = '-x_lower_bc_v'
    call get_BC_with_check_uvw(option_name, x_lower_bc_v, 1)

    option_name = '-x_lower_bc_w'
    call get_BC_with_check_uvw(option_name, x_lower_bc_w, 1)

    ! Y BCs

    option_name = '-y_upper_bc_T'
    call get_BC(option_name, y_upper_bc_T, y_upper_bc_T_value, 2)

    option_name = '-y_upper_bc_Cl'
    call get_BC_with_check(option_name, y_upper_bc_Cl, y_upper_bc_Cl_value, 2)

    option_name = '-y_upper_bc_Cv'
    call get_BC_with_check(option_name, y_upper_bc_Cv, y_upper_bc_Cv_value, 2)

    option_name = '-y_upper_bc_P'
    call get_BC_with_check(option_name, y_upper_bc_P, y_upper_bc_P_value, 2)

    option_name = '-y_upper_bc_u'
    call get_BC_with_check_uvw(option_name, y_upper_bc_u, 2)

    option_name = '-y_upper_bc_v'
    call get_BC_with_check_uvw(option_name, y_upper_bc_v, 2)

    option_name = '-y_upper_bc_w'
    call get_BC_with_check_uvw(option_name, y_upper_bc_w, 2)

    option_name = '-y_lower_bc_T'
    call get_BC_with_check(option_name, y_lower_bc_T, y_lower_bc_T_value, 2)

    option_name = '-y_lower_bc_Cl'
    call get_BC_with_check(option_name, y_lower_bc_Cl, y_lower_bc_Cl_value, 2)

    option_name = '-y_lower_bc_Cv'
    call get_BC_with_check(option_name, y_lower_bc_Cv, y_lower_bc_Cv_value, 2)

    option_name = '-y_lower_bc_P'
    call get_BC_with_check(option_name, y_lower_bc_P, y_lower_bc_P_value, 2)

    option_name = '-y_lower_bc_u'
    call get_BC_with_check_uvw(option_name, y_lower_bc_u, 2)

    option_name = '-y_lower_bc_v'
    call get_BC_with_check_uvw(option_name, y_lower_bc_v, 2)

    option_name = '-y_lower_bc_w'
    call get_BC_with_check_uvw(option_name, y_lower_bc_w, 2)

    ! Z BCs.

    option_name = '-z_upper_bc_T'
    call get_BC(option_name, z_upper_bc_T, z_upper_bc_T_value, 3)

    option_name = '-z_upper_bc_Cl'
    call get_BC_with_check(option_name, z_upper_bc_Cl,  z_upper_bc_Cl_value, 3)

    option_name = '-z_upper_bc_Cv'
    call get_BC_with_check(option_name, z_upper_bc_Cv,  z_upper_bc_Cv_value, 3)

    option_name = '-z_upper_bc_P'
    call get_BC_with_check(option_name, z_upper_bc_P, z_upper_bc_P_value, 3)

    option_name = '-z_upper_bc_u'
    call get_BC_with_check_uvw(option_name, z_upper_bc_u, 3)

    option_name = '-z_upper_bc_v'
    call get_BC_with_check_uvw(option_name, z_upper_bc_v, 3)

    option_name = '-z_upper_bc_w'
    call get_BC_with_check_uvw(option_name, z_upper_bc_w, 3)

    option_name = '-z_lower_bc_T'
    call get_BC_with_check(option_name, z_lower_bc_T, z_lower_bc_T_value, 3)

    option_name = '-z_lower_bc_Cl'
    call get_BC_with_check(option_name, z_lower_bc_Cl, z_lower_bc_Cl_value, 3)

    option_name = '-z_lower_bc_Cv'
    call get_BC_with_check(option_name, z_lower_bc_Cv, z_lower_bc_Cv_value, 3)

    option_name = '-z_lower_bc_P'
    call get_BC_with_check(option_name, z_lower_bc_P, z_lower_bc_P_value, 3)

    option_name = '-z_lower_bc_u'
    call get_BC_with_check_uvw(option_name, z_lower_bc_u, 3)

    option_name = '-z_lower_bc_v'
    call get_BC_with_check_uvw(option_name, z_lower_bc_v, 3)

    option_name = '-z_lower_bc_w'
    call get_BC_with_check_uvw(option_name, z_lower_bc_w, 3)

    option_name = '-liquid_limit'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, liquid_limit, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', liquid_limit
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. ((liquid_limit >= 0.0d0) .and. (liquid_limit <= 1.0d0))) then
        write(msg, *) 'Error:', liquid_limit, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-gaseous_limit'
    call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, gaseous_limit, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', gaseous_limit
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. ((gaseous_limit >= 0.0d0) .and. (gaseous_limit <= 1.0d0))) then
        write(msg, *) 'Error:', gaseous_limit, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
      if (.not. (gaseous_limit < liquid_limit)) then
        write(msg, *) 'Error:', gaseous_limit, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

  end subroutine read_initial_configuration_options

  subroutine read_run_time_configuration_options(num_procs_x, num_procs_y, num_procs_z,           &
       imex_Cl, imex_Cv, imex_T, imex_u, imex_v, imex_w,                                          &
       petsc_solver_Cl, petsc_solver_Cv, petsc_solver_T,                                          &
       petsc_solver_u, petsc_solver_v, petsc_solver_w, petsc_solver_p,                            &
       Cl_monitoring_on, Cv_monitoring_on, T_monitoring_on,                                       &
       u_monitoring_on, v_monitoring_on, w_monitoring_on, p_monitoring_on,                        &
       iter_pres_first_100, iter_pres, iter_u, iter_v, iter_w, iter_dim, iter_Cv,                 &
       iter_T, Cl_write_frequency, Cv_write_frequency, u_write_frequency, v_write_frequency,      &
       w_write_frequency, T_write_frequency, backup_frequency, num_timesteps, ierr)

    implicit none

    PetscInt, intent(out) :: num_procs_x, num_procs_y, num_procs_z
    character(len = max_option_name_length), intent(out) :: imex_Cl, imex_Cv, imex_T
    character(len = max_option_name_length), intent(out) :: imex_u, imex_v, imex_w
    logical, intent(out) :: petsc_solver_Cl, petsc_solver_Cv, petsc_solver_T
    logical, intent(out) :: petsc_solver_u, petsc_solver_v, petsc_solver_w, petsc_solver_p
    ! To monitor or not to monitor.
    logical, intent(out) :: Cl_monitoring_on, Cv_monitoring_on, T_monitoring_on
    logical, intent(out) :: u_monitoring_on, v_monitoring_on, w_monitoring_on, p_monitoring_on
    ! Pressure solver configuration
    PetscInt, intent(out) :: iter_pres_first_100, iter_pres
    ! Momentum equation solver configuration.
    PetscInt, intent(out) :: iter_u, iter_v, iter_w
    ! DIM equation solver configuration.
    PetscInt, intent(out) :: iter_dim
    ! Vapour equation solver configuration.
    PetscInt, intent(out) :: iter_Cv
    ! Temperature equation solver configuration.
    PetscInt, intent(out) :: iter_T
    ! Cl HDF5 file output frequency.
    PetscInt, intent(out) :: Cl_write_frequency
    PetscInt, intent(out) :: Cv_write_frequency
    ! u HDF5 file output frequency.
    PetscInt, intent(out) :: u_write_frequency
    ! v HDF5 file output frequency.
    PetscInt, intent(out) :: v_write_frequency
    ! w HDF5 file output frequency.
    PetscInt, intent(out) :: w_write_frequency
    ! T HDF5 file output frequency
    PetscInt, intent(out) :: T_write_frequency
    ! backup (restart) file output frequency
    PetscInt, intent(out) :: backup_frequency
    ! Number of timesteps.
    PetscInt, intent(out) :: num_timesteps
    PetscErrorCode, intent(out) :: ierr

    integer, parameter :: max_msg_length = 2*max_option_name_length

    character(len = max_option_name_length) :: option_name
    character(len = max_msg_length) :: msg
    logical :: found

    option_name = '-num_procs_x'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, num_procs_x, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', num_procs_x
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-num_procs_y'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, num_procs_y, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', num_procs_y
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-num_procs_z'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, num_procs_z, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', num_procs_z
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-imex_Cl'
    call PetscOptionsGetString(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, imex_Cl, found, ierr)
    if (found) then
      write(msg, *) option_name, '= ',  trim(imex_Cl)
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. ((imex_Cl .eq. 'CNAB2') .or. (imex_Cl .eq. 'SBDF'))) then
        write(msg, *) 'Error:', imex_Cl, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-imex_Cv'
    call PetscOptionsGetString(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, imex_Cv, found, ierr)
    if (found) then
      write(msg, *) option_name, '= ',  trim(imex_Cv)
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. ((imex_Cv .eq. 'CNAB2') .or. (imex_Cv .eq. 'SBDF'))) then
        write(msg, *) 'Error:', imex_Cv, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-imex_T'
    call PetscOptionsGetString(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, imex_T, found, ierr)
    if (found) then
      write(msg, *) option_name, '= ',  trim(imex_T)
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. ((imex_T .eq. 'CNAB2') .or. (imex_T .eq. 'SBDF'))) then
        write(msg, *) 'Error:', imex_T, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-imex_u'
    call PetscOptionsGetString(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, imex_u, found, ierr)
    if (found) then
      write(msg, *) option_name, '= ',  trim(imex_u)
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. ((imex_u .eq. 'CNAB3') .or. (imex_u .eq. 'SBDF'))) then
        write(msg, *) 'Error:', imex_u, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-imex_v'
    call PetscOptionsGetString(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, imex_v, found, ierr)
    if (found) then
      write(msg, *) option_name, '= ',  trim(imex_v)
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. ((imex_v .eq. 'CNAB3') .or. (imex_v .eq. 'SBDF'))) then
        write(msg, *) 'Error:', imex_v, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-imex_w'
    call PetscOptionsGetString(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, imex_w, found, ierr)
    if (found) then
      write(msg, *) option_name, '= ',  trim(imex_w)
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      if (.not. ((imex_w .eq. 'CNAB3') .or. (imex_w .eq. 'SBDF'))) then
        write(msg, *) 'Error:', imex_w, 'is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-petsc_solver_Cl'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, petsc_solver_Cl, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', petsc_solver_Cl
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-petsc_solver_Cv'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, petsc_solver_Cv, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', petsc_solver_Cv
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-petsc_solver_T'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, petsc_solver_T, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', petsc_solver_T
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-petsc_solver_u'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, petsc_solver_u, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', petsc_solver_u
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-petsc_solver_v'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, petsc_solver_v, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', petsc_solver_v
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-petsc_solver_w'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, petsc_solver_w, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', petsc_solver_w
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-petsc_solver_p'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, petsc_solver_p, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', petsc_solver_p
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Cl_monitoring_on'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Cl_monitoring_on, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Cl_monitoring_on
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Cv_monitoring_on'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Cv_monitoring_on, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Cv_monitoring_on
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-T_monitoring_on'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, T_monitoring_on, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', T_monitoring_on
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-u_monitoring_on'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, u_monitoring_on, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', u_monitoring_on
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-v_monitoring_on'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, v_monitoring_on, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', v_monitoring_on
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-w_monitoring_on'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, w_monitoring_on, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', w_monitoring_on
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-p_monitoring_on'
    call PetscOptionsGetBool(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, p_monitoring_on, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', p_monitoring_on
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-iter_pres_first_100'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, iter_pres_first_100, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', iter_pres_first_100
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-iter_pres'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, iter_pres, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', iter_pres
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-iter_u'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, iter_u, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', iter_u
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-iter_v'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, iter_v, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', iter_v
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-iter_w'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, iter_w, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', iter_w
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-iter_dim'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, iter_dim, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', iter_dim
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-iter_Cv'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, iter_Cv, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', iter_Cv
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-iter_T'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, iter_T, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', iter_T
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Cl_write_frequency'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Cl_write_frequency, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Cl_write_frequency
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-Cv_write_frequency'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, Cv_write_frequency, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', Cv_write_frequency
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-u_write_frequency'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, u_write_frequency, found, ierr)
    if (found) then
       write(msg, *) option_name, '=', u_write_frequency
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-v_write_frequency'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, v_write_frequency, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', v_write_frequency
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-w_write_frequency'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, w_write_frequency, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', w_write_frequency
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-T_write_frequency'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, T_write_frequency, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', T_write_frequency
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-backup_frequency'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, backup_frequency, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', backup_frequency
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

    option_name = '-num_timesteps'
    call PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, num_timesteps, found, ierr)
    if (found) then
      write(msg, *) option_name, '=', num_timesteps
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

  end subroutine read_run_time_configuration_options


  subroutine get_BC(option_name, b_c, dirichlet_value, dim)

    implicit none

    ! Arguments.
    character(len = max_option_name_length), intent(in) :: option_name
    integer(kind(BC)), intent(out) :: b_c
    double precision, intent(out) :: dirichlet_value
    integer, intent(in) :: dim

    ! Local variables.
    character(len = max_option_name_length) :: boundary_condition
    character(len = max_option_name_length) :: dirichlet_option_name
    logical :: found
    character(len = max_msg_length) :: msg
    PetscErrorCode :: ierr

    call PetscOptionsGetString(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, &
         boundary_condition, found, ierr)
    if (found) then
      write(msg, *) option_name, '= ',  trim(boundary_condition)
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      ! Default values.
      periodic(dim) = .false.
      boundary(dim) = DM_BOUNDARY_NONE
      if (boundary_condition .eq. 'periodic') then
        periodic(dim) = .true.
        boundary(dim) = DM_BOUNDARY_PERIODIC
        b_c = cyclic
      else if (boundary_condition .eq. 'neumann') then
        b_c = neumann
      else if (boundary_condition .eq. 'dirichlet') then
        dirichlet_option_name = trim(option_name) // '_value'
        call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, dirichlet_option_name, &
             dirichlet_value, found, ierr)
        if (found) then
          write(msg, *) dirichlet_option_name, '= ',  dirichlet_value
          call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
          b_c = dirichlet
        else
          b_c = quasi_dirichlet
        end if
      else
        write(msg, *) 'Error: ' // trim(boundary_condition) // ' is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if
    else
      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
    end if

  end subroutine get_BC


  subroutine get_BC_with_check(option_name, b_c, dirichlet_value, dim)

    implicit none

    ! Arguments.
    character(len = max_option_name_length), intent(in) :: option_name
    integer(kind(BC)), intent(out) :: b_c
    double precision, intent(out) :: dirichlet_value
    integer, intent(in) :: dim

    ! Local variables.
    character(len = max_option_name_length) :: boundary_condition
    character(len = max_option_name_length) :: dirichlet_option_name
    logical :: found
    character(len = max_msg_length) :: msg
    PetscErrorCode :: ierr
    logical :: periodic_val

    call PetscOptionsGetString(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, &
         boundary_condition, found, ierr)
    if (found) then

      write(msg, *) option_name, '= ',  trim(boundary_condition)
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      ! Default values.
      periodic_val = .false.
      if (boundary_condition .eq. 'periodic') then
        periodic_val = .true.
        b_c = cyclic
      else if (boundary_condition .eq. 'neumann') then
        b_c = neumann
      else if (boundary_condition .eq. 'dirichlet') then
        dirichlet_option_name = trim(option_name) // '_value'
        call PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, dirichlet_option_name, &
             dirichlet_value, found, ierr)
        if (found) then
          write(msg, *) dirichlet_option_name, '= ',  dirichlet_value
          call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
          b_c = dirichlet
        else
          b_c = quasi_dirichlet
        end if
      else if (boundary_condition .eq. 'inlet') then
        if (option_name .ne. 'x_lower_bc_u') then
          write(msg, *) 'Error: inlet is not a valid value for' // option_name // '.'
          call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
        end if
        bc_temp = inlet
        b_c = inlet
      else if (boundary_condition .eq. 'outlet') then
        if (option_name .ne. 'x_upper_bc_u') then
          write(msg, *) 'Error: outlet is not a valid value for' // option_name // '.'
          call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
        end if
        if (bc_temp .ne. inlet) then
          write(msg, *) 'Error: outlet is not a valid value for x_upper_bc_u as x_lower_bc_u is not an inlet.'
          call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
        end if
        b_c = outlet
      else
        write(msg, *) 'Error: ' // trim(boundary_condition) // ' is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if

      if (periodic_val .neqv. periodic(dim)) then
        write(msg, *) 'Error: ' // 'cannot have a single periodic BC in dimenstion', dim
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if

    else

      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)

    end if

  end subroutine get_BC_with_check


  subroutine get_BC_with_check_uvw(option_name, b_c, dim)

    implicit none

    ! Arguments.
    character(len = max_option_name_length), intent(in) :: option_name
    integer(kind(BC)), intent(out) :: b_c
    integer, intent(in) :: dim

    ! Local variables.
    character(len = max_option_name_length) :: boundary_condition
    logical :: found
    character(len = max_msg_length) :: msg
    PetscErrorCode :: ierr
    logical :: periodic_val

    call PetscOptionsGetString(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, option_name, &
         boundary_condition, found, ierr)
    if (found) then

      write(msg, *) option_name, '= ',  trim(boundary_condition)
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      ! Default values.
      periodic_val = .false.
      if (boundary_condition .eq. 'periodic') then
        periodic_val = .true.
        b_c = cyclic
      else if (boundary_condition .eq. 'neumann') then
        b_c = neumann
      else if (boundary_condition .eq. 'dirichlet') then
        b_c = dirichlet
      else if (boundary_condition .eq. 'inlet') then
        if (option_name .ne. 'x_lower_bc_u') then
          write(msg, *) 'Error: inlet is not a valid value for' // option_name // '.'
          call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
        end if
        bc_temp = inlet
        b_c = inlet
      else if (boundary_condition .eq. 'outlet') then
        if (option_name .ne. 'x_upper_bc_u') then
          write(msg, *) 'Error: outlet is not a valid value for' // option_name // '.'
          call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
        end if
        if (bc_temp .ne. inlet) then
          write(msg, *) 'Error: outlet is not a valid value for x_upper_bc_u as x_lower_bc_u is not an inlet.'
          call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
        end if
        b_c = outlet
      else
        write(msg, *) 'Error: ' // trim(boundary_condition) // ' is not a valid value.'
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if

      if (periodic_val .neqv. periodic(dim)) then
        write(msg, *) 'Error: ' // 'cannot have a single periodic BC in dimenstion', dim
        call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)
      end if

    else

      write(msg, *) 'Error:', option_name, 'not found.'
      call PetscPrintf(PETSC_COMM_WORLD, trim(msg) // NEW_LINE('a'), ierr)

    end if

  end subroutine get_BC_with_check_uvw

end module test_configuration_options
-------------- next part --------------
program test_program

  use petsc
  use test_configuration_options

  implicit none

#include "petsc/finclude/petsc.h"

  PetscInt :: global_dim_x, global_dim_y, global_dim_z
  double precision :: gz, gx
  PetscInt :: num_procs_x, num_procs_y, num_procs_z
  double precision :: liquid_limit
  double precision :: gaseous_limit
  PetscErrorCode :: ierr

  character(len = max_option_name_length) :: imex_Cl, imex_Cv, imex_T
  character(len = max_option_name_length) :: imex_u, imex_v, imex_w
  ! Choices of PETSc or original solvers.
  logical :: petsc_solver_Cl, petsc_solver_Cv, petsc_solver_T
  logical :: petsc_solver_u, petsc_solver_v, petsc_solver_w, petsc_solver_p
  ! To monitor or not to monitor.
  logical :: Cl_monitoring_on, Cv_monitoring_on, T_monitoring_on
  logical :: u_monitoring_on, v_monitoring_on, w_monitoring_on, p_monitoring_on
  ! Pressure solver configuration
  PetscInt :: iter_pres_first_100, iter_pres
  ! Momentum equation solver configuration.
  PetscInt :: iter_u, iter_v, iter_w
  ! DIM equation solver configuration.
  PetscInt :: iter_dim
  PetscInt :: iter_Cv
  ! Temperature equation solver configuration.
  PetscInt :: iter_T
  ! Cl HDF5 file output frequency.
  PetscInt :: Cl_write_frequency
  PetscInt :: Cv_write_frequency
  ! u HDF5 file output frequency.
  PetscInt :: u_write_frequency
  ! v HDF5 file output frequency.
  PetscInt :: v_write_frequency
  ! w HDF5 file output frequency.
  PetscInt :: w_write_frequency
  ! T HDF5 file output frequency.
  PetscInt :: T_write_frequency
  ! backup (restart) file output frequency.
  PetscInt :: backup_frequency
  ! Number of timesteps.
  PetscInt :: num_timesteps

  double precision :: Re, Pe, PeT, We, Fr, Bod, Ja, Fr2, Fr2BodByRe
  double precision :: dpdx
  double precision :: mu_minus, mu_plus, mu_vap
  double precision :: rho_minus, rho_plus, rho_vap
  double precision :: cp_minus, cp_plus, cp_vap
  double precision :: rhocp_minus, rhocp_plus, rhocp_vap
  double precision :: k_plus, k_minus, k_vap
  double precision :: beta_plus, beta_minus, beta_vap
  double precision :: epn
  double precision :: T_ref
  double precision :: Pref
  double precision :: Apsat, Bpsat, Cpsat
  double precision :: molMassRatio
  double precision :: PeMD
  double precision :: PeMDI
  double precision :: dTdx

  PetscLogDouble :: mem
  integer :: mpi_err

  ! ******************************************************************************************

  call PetscInitialize(PETSC_NULL_CHARACTER, ierr)
  call PetscMemoryGetCurrentUsage(mem, ierr)
  write(*, *) 'mem0 = ', mem
  call MPI_Barrier(PETSC_COMM_WORLD, mpi_err)

  call read_initial_configuration_options(global_dim_x, global_dim_y, global_dim_z,          &
       Re, Pe, We, Fr, Bod, Ja, mu_plus, mu_minus, mu_vap, rho_plus, rho_minus, rho_vap,     &
       cp_plus, cp_minus, cp_vap, k_plus, k_minus, k_vap, beta_plus, beta_minus, beta_vap,   &
       dpdx, gx, gz, epn, dTdx, T_ref,                                                       &
       Pref, Apsat, Bpsat, Cpsat, molMassRatio, PeT, PeMD, PeMDI,                            &
       x_upper_bc_T, x_upper_bc_Cl, x_upper_bc_Cv, x_upper_bc_u, x_upper_bc_v, x_upper_bc_w, &
       x_lower_bc_T, x_lower_bc_Cl, x_lower_bc_Cv, x_lower_bc_u, x_lower_bc_v, x_lower_bc_w, &
       y_upper_bc_T, y_upper_bc_Cl, y_upper_bc_Cv, y_upper_bc_u, y_upper_bc_v, y_upper_bc_w, &
       y_lower_bc_T, y_lower_bc_Cl, y_lower_bc_Cv, y_lower_bc_u, y_lower_bc_v, y_lower_bc_w, &
       z_upper_bc_T, z_upper_bc_Cl, z_upper_bc_Cv, z_upper_bc_u, z_upper_bc_v, z_upper_bc_w, &
       z_lower_bc_T, z_lower_bc_Cl, z_lower_bc_Cv, z_lower_bc_u, z_lower_bc_v, z_lower_bc_w, &
       liquid_limit, gaseous_limit, ierr)
  call PetscMemoryGetCurrentUsage(mem, ierr)
  write(*, *) 'mem1 = ', mem
  call MPI_Barrier(PETSC_COMM_WORLD, mpi_err)

  call read_run_time_configuration_options(num_procs_x, num_procs_y, num_procs_z,                 &
       imex_Cl, imex_CV, imex_T, imex_U, imex_v, imex_w,                                          &
       petsc_solver_Cl, petsc_solver_Cv, petsc_solver_T,                                          &
       petsc_solver_u, petsc_solver_v, petsc_solver_w, petsc_solver_p,                            &
       Cl_monitoring_on, Cv_monitoring_on, T_monitoring_on,                                       &
       u_monitoring_on, v_monitoring_on, w_monitoring_on, p_monitoring_on,                        &
       iter_pres_first_100, iter_pres, iter_u, iter_v, iter_w, iter_dim, iter_Cv,                 &
       iter_T, Cl_write_frequency, Cv_write_frequency, u_write_frequency, v_write_frequency,      &
       w_write_frequency, T_write_frequency, backup_frequency, num_timesteps, ierr)
  call PetscMemoryGetCurrentUsage(mem, ierr)
  write(*, *) 'mem2 = ', mem
  call MPI_Barrier(PETSC_COMM_WORLD, mpi_err)

  call PetscFinalize(ierr)

end program test_program
-------------- next part --------------
-global_dim_x 240
-global_dim_y 240
-global_dim_z 320
-phenomenon boiling_variant
-liquid_limit 0.9
-gaseous_limit 0.1

-epn 0.0    # This value causes epn to be computed by the TPLS program.

-Re 221.46
-Pe 1.0    # The Peclet number for the Cahn-Hilliard equation. It is modified in the code.
-Pr 8.4
-Ja 0.18
-Fr 1.01
-We 1.01
-Bod 1.0
-Sc 1.0

-Pref 1.0        # Relates partial pressure to mole fraction.
-Apsat 1.0
-Bpsat 1.0
-Cpsat 1.0
-T_substrate 1.0 # Bespoke option.
-T_ref 0.0       # Used to specify the saturation temperature (a.k.a. T_bulk).
-th_layer 0.36   # Bespoke option.
-dTdx 0.0
-Radius 0.5      # Bespoke option.

-MM_minus 1.0
-MM_vap 1.0

# Properties of the liquid.
-rho_plus 91.07
-mu_plus 32.6
-k_plus 3.94
-cp_plus 1.23
-beta_plus 1.0

# Properties of the inert gas. Boiling so UNUSED.
-rho_minus 1.0
-mu_minus 1.0
-k_minus 1.0
-cp_minus 1.0
-beta_minus 1.0

# Properties of vapour corresponding to the liquid.
-rho_vap 1.0
-mu_vap 1.0
-k_vap 1.0
-cp_vap 1.0
-beta_vap 1.0

-height 0.0         # Bespoke option.
-dpdx 0.0
-Grav 1.0
-alpha -1.570796326794897
-dt 0.0005

-x_upper_bc_T periodic
-x_upper_bc_Cl periodic
-x_upper_bc_Cv periodic
-x_upper_bc_P periodic
-x_upper_bc_u periodic
-x_upper_bc_v periodic
-x_upper_bc_w periodic
-x_lower_bc_T periodic
-x_lower_bc_Cl periodic
-x_lower_bc_Cv periodic
-x_lower_bc_P periodic
-x_lower_bc_u periodic
-x_lower_bc_v periodic
-x_lower_bc_w periodic
-y_upper_bc_T periodic
-y_upper_bc_Cl periodic
-y_upper_bc_Cv periodic
-y_upper_bc_P periodic
-y_upper_bc_u periodic
-y_upper_bc_v periodic
-y_upper_bc_w periodic
-y_lower_bc_T periodic
-y_lower_bc_Cl periodic
-y_lower_bc_Cv periodic
-y_lower_bc_P periodic
-y_lower_bc_u periodic
-y_lower_bc_v periodic
-y_lower_bc_w periodic
-z_upper_bc_T dirichlet    # Fixed temperature.
-z_upper_bc_T_value 0.0    # Set to T_ref (i.e. T_sat).
-z_upper_bc_Cl neumann     # dCl/dz = 0.
-z_upper_bc_Cv dirichlet   # Initialise Cv to 1 everywhere.
-z_upper_bc_P neumann      # dP/dz = rho_wgrid*gz.
-z_upper_bc_u dirichlet    # Set to 0 initially, no slip.
-z_upper_bc_v dirichlet    # Set to 0 initially, no slip.
-z_upper_bc_w neumann      # dw/dz = 0, in or out flow is allowed.
-z_lower_bc_T dirichlet    # Fixed temperature.
-z_lower_bc_T_value 1.0    # Set to T_substrate.
-z_lower_bc_Cl dirichlet   # Fixed composition determined by initialisation.
-z_lower_bc_Cv dirichlet   # Initialise Cv to 1 everywhere.
-z_lower_bc_P neumann      # dP/dz = rho_wgrid*gz.
-z_lower_bc_u dirichlet    # Set to 0 initially, no slip.
-z_lower_bc_v dirichlet    # Set to 0 initially, no slip.
-z_lower_bc_w dirichlet    # Set to 0 initially, no in or out flow.

-num_procs_x 2
-num_procs_y 2
-num_procs_z 2
-petsc_solver_u FALSE
-petsc_solver_v FALSE
-petsc_solver_w FALSE
-petsc_solver_Cl FALSE
-petsc_solver_Cv FALSE
-petsc_solver_T FALSE
-petsc_solver_p FALSE
-imex_u CNAB3
-imex_v CNAB3
-imex_w CNAB3
-imex_Cl SBDF
-imex_Cv CNAB
-imex_T CNAB
-u_monitoring_on FALSE
-v_monitoring_on FALSE
-w_monitoring_on FALSE
-p_monitoring_on FALSE
-Cl_monitoring_on FALSE
-Cv_monitoring_on FALSE
-T_monitoring_on FALSE
-iter_pres_first_100 1000
-iter_pres 1000
-iter_u 30
-iter_v 30
-iter_w 30
-iter_dim 40
-iter_T 40
-Cl_write_frequency 250
-Cv_write_frequency 2500
-T_write_frequency 2500
-u_write_frequency 2500
-v_write_frequency 2500
-w_write_frequency 2500
-backup_frequency 10000
-num_timesteps 10000

-u_ksp_rtol 0.0000001
-u_ksp_view_final_residual
-v_ksp_rtol 0.0000001
-v_ksp_view_final_residual
-w_ksp_rtol 0.0000001
-w_ksp_view_final_residual
-p_ksp_rtol 0.0000001
-p_ksp_type minres
-p_pc_type sor
-p_pc_sor_omega 1.5
-p_ksp_view_final_residual

-options_left
-------------- next part --------------
 mem0 =    16420864.000000000     
 mem0 =    16117760.000000000     
 -phenomenon                   = boiling_variant
 -global_dim_x                 =                  240
 -global_dim_y                 =                  240
 -global_dim_z                 =                  320
 -dt                           =   5.0000000000000001E-004
 dx =   3.1250000000000002E-003
 dy =   3.1250000000000002E-003
 dz =   3.1250000000000002E-003
 Lx =  0.75000000000000000
 Ly =  0.75000000000000000
 Lz =   1.0000000000000000
 -epn                          =   1.5625000000000001E-003
 -Re                           =   221.46000000000001
 -Pe                           =   1.0000000000000000
 Modified Pe =   640.00000000000000
 -Pr                           =   8.4000000000000004
 PeT =   1860.2640000000001
 -We                           =   1.0100000000000000
 -Fr                           =   1.0100000000000000
 -Bod                          =   1.0000000000000000
 -Sc                           =   1.0000000000000000
 PeMD =   221.46000000000001
 PeMDI =   221.46000000000001
 -Ja                           =  0.17999999999999999
 -dTdx                         =   0.0000000000000000
 -T_ref                        =   0.0000000000000000
 -Pref                         =   1.0000000000000000
 -Apsat                        =   1.0000000000000000
 -Bpsat                        =   1.0000000000000000
 -Cpsat                        =   1.0000000000000000
 -MM_minus                     =   1.0000000000000000
 -MM_vap                       =   1.0000000000000000
 molMassRatio =   1.0000000000000000
 -mu_plus                      =   32.600000000000001
 -mu_minus                     =   1.0000000000000000
 -mu_vap                       =   1.0000000000000000
 -rho_plus                     =   91.069999999999993
 -rho_minus                    =   1.0000000000000000
 -rho_vap                      =   1.0000000000000000
 -cp_plus                      =   1.2300000000000000
 -cp_minus                     =   1.0000000000000000
 -cp_vap                       =   1.0000000000000000
 -k_plus                       =   3.9399999999999999
 -k_minus                      =   1.0000000000000000
 -k_vap                        =   1.0000000000000000
 -beta_plus                    =   1.0000000000000000
 -beta_minus                   =   1.0000000000000000
 -beta_vap                     =   1.0000000000000000
 -dpdx                         =   0.0000000000000000
 -Grav                         =   1.0000000000000000
 -alpha                        =  -1.5707963267948970
 gz =  -1.0000000000000000
 gx =   0.0000000000000000
 -x_upper_bc_T                 = periodic
 -x_upper_bc_Cl                = periodic
 -x_upper_bc_Cv                = periodic
 -x_upper_bc_P                 = periodic
 -x_upper_bc_u                 = periodic
 -x_upper_bc_v                 = periodic
 -x_upper_bc_w                 = periodic
 -x_lower_bc_T                 = periodic
 -x_lower_bc_Cl                = periodic
 -x_lower_bc_Cv                = periodic
 -x_lower_bc_P                 = periodic
 -x_lower_bc_u                 = periodic
 -x_lower_bc_v                 = periodic
 -x_lower_bc_w                 = periodic
 -y_upper_bc_T                 = periodic
 -y_upper_bc_Cl                = periodic
 -y_upper_bc_Cv                = periodic
 -y_upper_bc_P                 = periodic
 -y_upper_bc_u                 = periodic
 -y_upper_bc_v                 = periodic
 -y_upper_bc_w                 = periodic
 -y_lower_bc_T                 = periodic
 -y_lower_bc_Cl                = periodic
 -y_lower_bc_Cv                = periodic
 -y_lower_bc_P                 = periodic
 -y_lower_bc_u                 = periodic
 -y_lower_bc_v                 = periodic
 -y_lower_bc_w                 = periodic
 -z_upper_bc_T                 = dirichlet
 -z_upper_bc_T_value           =    0.0000000000000000
 -z_upper_bc_Cl                = neumann
 -z_upper_bc_Cv                = dirichlet
 -z_upper_bc_P                 = neumann
 -z_upper_bc_u                 = dirichlet
 -z_upper_bc_v                 = dirichlet
 -z_upper_bc_w                 = neumann
 -z_lower_bc_T                 = dirichlet
 -z_lower_bc_T_value           =    1.0000000000000000
 -z_lower_bc_Cl                = dirichlet
 -z_lower_bc_Cv                = dirichlet
 -z_lower_bc_P                 = neumann
 -z_lower_bc_u                 = dirichlet
 -z_lower_bc_v                 = dirichlet
 -z_lower_bc_w                 = dirichlet
 -liquid_limit                 =  0.90000000000000002
 mem1 =    4311490560.0000000     
 -gaseous_limit                =  0.10000000000000001
 mem1 =    4311826432.0000000     
 -num_procs_x                  =                    2
 -num_procs_y                  =                    2
 -num_procs_z                  =                    2
 -imex_Cl                      = SBDF
 -imex_Cv                      = CNAB
 Error:CNAB                          is not a valid value.
 -imex_T                       = CNAB
 Error:CNAB                          is not a valid value.
 -imex_u                       = CNAB3
 -imex_v                       = CNAB3
 -imex_w                       = CNAB3
 -petsc_solver_Cl              = F
 -petsc_solver_Cv              = F
 -petsc_solver_T               = F
 -petsc_solver_u               = F
 -petsc_solver_v               = F
 -petsc_solver_w               = F
 -petsc_solver_p               = F
 -Cl_monitoring_on             = F
 -Cv_monitoring_on             = F
 -T_monitoring_on              = F
 -u_monitoring_on              = F
 -v_monitoring_on              = F
 -w_monitoring_on              = F
 -p_monitoring_on              = F
 -iter_pres_first_100          =                 1000
 -iter_pres                    =                 1000
 -iter_u                       =                   30
 -iter_v                       =                   30
 -iter_w                       =                   30
 -iter_dim                     =                   40
 Error:-iter_Cv                      not found.
 -iter_T                       =                   40
 -Cl_write_frequency           =                  250
 -Cv_write_frequency           =                 2500
 -u_write_frequency            =                 2500
 -v_write_frequency            =                 2500
 -w_write_frequency            =                 2500
 -T_write_frequency            =                 2500
 -backup_frequency             =                10000
 -num_timesteps                =                10000
 mem2 =    4311490560.0000000     
 mem2 =    4311826432.0000000     
Summary of Memory Usage in PETSc
Current process memory:                                  total 8.6236e+09 max 4.3120e+09 min 4.3116e+09
Current space PetscMalloc()ed:                           total 3.2736e+04 max 1.6368e+04 min 1.6368e+04
Run with -memory_view to get maximum memory usage
#PETSc Option Table entries:
-alpha -1.570796326794897 # (source: file)
-Apsat 1.0 # (source: file)
-backup_frequency 10000 # (source: file)
-beta_minus 1.0 # (source: file)
-beta_plus 1.0 # (source: file)
-beta_vap 1.0 # (source: file)
-Bod 1.0 # (source: file)
-Bpsat 1.0 # (source: file)
-Cl_monitoring_on FALSE # (source: file)
-Cl_write_frequency 250 # (source: file)
-cp_minus 1.0 # (source: file)
-cp_plus 1.23 # (source: file)
-cp_vap 1.0 # (source: file)
-Cpsat 1.0 # (source: file)
-Cv_monitoring_on FALSE # (source: file)
-Cv_write_frequency 2500 # (source: file)
-d initial_state # (source: command line)
-dpdx 0.0 # (source: file)
-dt 0.0005 # (source: file)
-dTdx 0.0 # (source: file)
-epn 0.0 # (source: file)
-Fr 1.01 # (source: file)
-gaseous_limit 0.1 # (source: file)
-global_dim_x 240 # (source: file)
-global_dim_y 240 # (source: file)
-global_dim_z 320 # (source: file)
-Grav 1.0 # (source: file)
-height 0.0 # (source: file)
-imex_Cl SBDF # (source: file)
-imex_Cv CNAB # (source: file)
-imex_T CNAB # (source: file)
-imex_u CNAB3 # (source: file)
-imex_v CNAB3 # (source: file)
-imex_w CNAB3 # (source: file)
-iter_dim 40 # (source: file)
-iter_pres 1000 # (source: file)
-iter_pres_first_100 1000 # (source: file)
-iter_T 40 # (source: file)
-iter_u 30 # (source: file)
-iter_v 30 # (source: file)
-iter_w 30 # (source: file)
-Ja 0.18 # (source: file)
-k_minus 1.0 # (source: file)
-k_plus 3.94 # (source: file)
-k_vap 1.0 # (source: file)
-liquid_limit 0.9 # (source: file)
-malloc_debug true # (source: command line)
-malloc_dump # (source: command line)
-malloc_view # (source: command line)
-memory_view # (source: command line)
-MM_minus 1.0 # (source: file)
-MM_vap 1.0 # (source: file)
-mu_minus 1.0 # (source: file)
-mu_plus 32.6 # (source: file)
-mu_vap 1.0 # (source: file)
-num_procs_x 2 # (source: file)
-num_procs_y 2 # (source: file)
-num_procs_z 2 # (source: file)
-num_timesteps 10000 # (source: file)
-on_error_malloc_dump # (source: command line)
-options_left # (source: file)
-p_ksp_rtol 0.0000001 # (source: file)
-p_ksp_type minres # (source: file)
-p_ksp_view_final_residual # (source: file)
-p_monitoring_on FALSE # (source: file)
-p_pc_sor_omega 1.5 # (source: file)
-p_pc_type sor # (source: file)
-Pe 1.0 # (source: file)
-petsc_solver_Cl FALSE # (source: file)
-petsc_solver_Cv FALSE # (source: file)
-petsc_solver_p FALSE # (source: file)
-petsc_solver_T FALSE # (source: file)
-petsc_solver_u FALSE # (source: file)
-petsc_solver_v FALSE # (source: file)
-petsc_solver_w FALSE # (source: file)
-phenomenon boiling_variant # (source: file)
-Pr 8.4 # (source: file)
-Pref 1.0 # (source: file)
-Radius 0.5 # (source: file)
-Re 221.46 # (source: file)
-rho_minus 1.0 # (source: file)
-rho_plus 91.07 # (source: file)
-rho_vap 1.0 # (source: file)
-Sc 1.0 # (source: file)
-T_monitoring_on FALSE # (source: file)
-T_ref 0.0 # (source: file)
-T_substrate 1.0 # (source: file)
-T_write_frequency 2500 # (source: file)
-th_layer 0.36 # (source: file)
-u_ksp_rtol 0.0000001 # (source: file)
-u_ksp_view_final_residual # (source: file)
-u_monitoring_on FALSE # (source: file)
-u_write_frequency 2500 # (source: file)
-v_ksp_rtol 0.0000001 # (source: file)
-v_ksp_view_final_residual # (source: file)
-v_monitoring_on FALSE # (source: file)
-v_write_frequency 2500 # (source: file)
-w_ksp_rtol 0.0000001 # (source: file)
-w_ksp_view_final_residual # (source: file)
-w_monitoring_on FALSE # (source: file)
-w_write_frequency 2500 # (source: file)
-We 1.01 # (source: file)
-x_lower_bc_Cl periodic # (source: file)
-x_lower_bc_Cv periodic # (source: file)
-x_lower_bc_P periodic # (source: file)
-x_lower_bc_T periodic # (source: file)
-x_lower_bc_u periodic # (source: file)
-x_lower_bc_v periodic # (source: file)
-x_lower_bc_w periodic # (source: file)
-x_upper_bc_Cl periodic # (source: file)
-x_upper_bc_Cv periodic # (source: file)
-x_upper_bc_P periodic # (source: file)
-x_upper_bc_T periodic # (source: file)
-x_upper_bc_u periodic # (source: file)
-x_upper_bc_v periodic # (source: file)
-x_upper_bc_w periodic # (source: file)
-y_lower_bc_Cl periodic # (source: file)
-y_lower_bc_Cv periodic # (source: file)
-y_lower_bc_P periodic # (source: file)
-y_lower_bc_T periodic # (source: file)
-y_lower_bc_u periodic # (source: file)
-y_lower_bc_v periodic # (source: file)
-y_lower_bc_w periodic # (source: file)
-y_upper_bc_Cl periodic # (source: file)
-y_upper_bc_Cv periodic # (source: file)
-y_upper_bc_P periodic # (source: file)
-y_upper_bc_T periodic # (source: file)
-y_upper_bc_u periodic # (source: file)
-y_upper_bc_v periodic # (source: file)
-y_upper_bc_w periodic # (source: file)
-z_lower_bc_Cl dirichlet # (source: file)
-z_lower_bc_Cv dirichlet # (source: file)
-z_lower_bc_P neumann # (source: file)
-z_lower_bc_T dirichlet # (source: file)
-z_lower_bc_T_value 1.0 # (source: file)
-z_lower_bc_u dirichlet # (source: file)
-z_lower_bc_v dirichlet # (source: file)
-z_lower_bc_w dirichlet # (source: file)
-z_upper_bc_Cl neumann # (source: file)
-z_upper_bc_Cv dirichlet # (source: file)
-z_upper_bc_P neumann # (source: file)
-z_upper_bc_T dirichlet # (source: file)
-z_upper_bc_T_value 0.0 # (source: file)
-z_upper_bc_u dirichlet # (source: file)
-z_upper_bc_v dirichlet # (source: file)
-z_upper_bc_w neumann # (source: file)
#End of PETSc Option Table entries
WARNING! There are options you set that were not used!
WARNING! could be spelling mistake, etc!
There are 17 unused database options. They are:
Option left: name:-d value: initial_state source: command line
Option left: name:-height value: 0.0 source: file
Option left: name:-on_error_malloc_dump (no value) source: command line
Option left: name:-p_ksp_rtol value: 0.0000001 source: file
Option left: name:-p_ksp_type value: minres source: file
Option left: name:-p_ksp_view_final_residual (no value) source: file
Option left: name:-p_pc_sor_omega value: 1.5 source: file
Option left: name:-p_pc_type value: sor source: file
Option left: name:-Radius value: 0.5 source: file
Option left: name:-T_substrate value: 1.0 source: file
Option left: name:-th_layer value: 0.36 source: file
Option left: name:-u_ksp_rtol value: 0.0000001 source: file
Option left: name:-u_ksp_view_final_residual (no value) source: file
Option left: name:-v_ksp_rtol value: 0.0000001 source: file
Option left: name:-v_ksp_view_final_residual (no value) source: file
Option left: name:-w_ksp_rtol value: 0.0000001 source: file
Option left: name:-w_ksp_view_final_residual (no value) source: file
[0] Maximum memory PetscMalloc()ed 29552 maximum size of entire process 4312375296
[0] Memory usage sorted by function
[0] 1 144 PetscBTCreate()
[0] 4 128 PetscCommDuplicate()
[0] 4 64 PetscFunctionListCreate_Private()
[0] 2 528 PetscIntStackCreate()
[0] 2 2064 PetscLogClassArrayCreate()
[0] 2 2064 PetscLogEventArrayCreate()
[0] 1 32 PetscLogRegistryCreate()
[0] 2 80 PetscLogStageArrayCreate()
[0] 1 48 PetscLogStateCreate()
[0] 1 16 PetscOptionsHelpPrintedCreate()
[0] 1 32 PetscPushSignalHandler()
[0] 4 20096 PetscSegBufferCreate()
[0] 190 8688 PetscStrallocpy()
[0] 12 26144 PetscStrreplace()
[0] 2 1312 PetscViewerCreate()
[0] 2 224 PetscViewerCreate_ASCII()
[0] 14 368 petscoptionsgetbool_()
[0] 22 480 petscoptionsgetint_()
[0] 43 768 petscoptionsgetreal_()
[0] 49 784 petscoptionsgetstring_()
[0] 140 7632 petscprintf_()
[1] Maximum memory PetscMalloc()ed 29552 maximum size of entire process 4311990272
[1] Memory usage sorted by function
[1] 1 144 PetscBTCreate()
[1] 4 128 PetscCommDuplicate()
[1] 4 64 PetscFunctionListCreate_Private()
[1] 2 528 PetscIntStackCreate()
[1] 2 2064 PetscLogClassArrayCreate()
[1] 2 2064 PetscLogEventArrayCreate()
[1] 1 32 PetscLogRegistryCreate()
[1] 2 80 PetscLogStageArrayCreate()
[1] 1 48 PetscLogStateCreate()
[1] 1 16 PetscOptionsHelpPrintedCreate()
[1] 1 32 PetscPushSignalHandler()
[1] 4 20096 PetscSegBufferCreate()
[1] 190 8688 PetscStrallocpy()
[1] 12 26144 PetscStrreplace()
[1] 2 1312 PetscViewerCreate()
[1] 2 224 PetscViewerCreate_ASCII()
[1] 14 368 petscoptionsgetbool_()
[1] 22 480 petscoptionsgetint_()
[1] 43 768 petscoptionsgetreal_()
[1] 49 784 petscoptionsgetstring_()
[1] 140 7632 petscprintf_()


More information about the petsc-users mailing list