Neko  0.9.0
A portable framework for high-order spectral element flow simulations
output.f90
Go to the documentation of this file.
1 ! Copyright (c) 2020-2023, The Neko Authors
2 ! All rights reserved.
3 !
4 ! Redistribution and use in source and binary forms, with or without
5 ! modification, are permitted provided that the following conditions
6 ! are met:
7 !
8 ! * Redistributions of source code must retain the above copyright
9 ! notice, this list of conditions and the following disclaimer.
10 !
11 ! * Redistributions in binary form must reproduce the above
12 ! copyright notice, this list of conditions and the following
13 ! disclaimer in the documentation and/or other materials provided
14 ! with the distribution.
15 !
16 ! * Neither the name of the authors nor the names of its
17 ! contributors may be used to endorse or promote products derived
18 ! from this software without specific prior written permission.
19 !
20 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 ! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 ! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 ! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 ! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 ! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 ! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 ! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 ! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 ! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 ! POSSIBILITY OF SUCH DAMAGE.
32 !
34 module output
35  use num_types, only : rp
36  use file, only : file_t
37  implicit none
38  private
39 
41  type, public, abstract :: output_t
42  type(file_t) :: file_
43  contains
44  procedure, pass(this) :: init_base => output_init
45  procedure, pass(this) :: set_counter => output_set_counter
46  procedure, pass(this) :: set_start_counter => output_set_start_counter
47  procedure(output_sample), pass(this), deferred :: sample
48  end type output_t
49 
51  type, public :: output_ptr_t
52  class(output_t), pointer :: ptr
53  end type output_ptr_t
54 
56  abstract interface
57  subroutine output_sample(this, t)
58  import :: output_t
59  import rp
60  class(output_t), intent(inout) :: this
61  real(kind=rp), intent(in) :: t
62  end subroutine output_sample
63  end interface
64 
65 contains
66 
70  subroutine output_init(this, fname, precision)
71  class(output_t), intent(inout) :: this
72  character(len=*), intent(inout) :: fname
73  integer, intent(in), optional :: precision
74 
75  if (present(precision)) then
76  this%file_ = file_t(fname, precision=precision)
77  else
78  this%file_ = file_t(fname)
79  end if
80 
81  end subroutine output_init
82 
84  subroutine output_set_counter(this, n)
85  class(output_t), intent(inout) :: this
86  integer, intent(in) :: n
87  call this%file_%set_counter(n)
88  end subroutine output_set_counter
89 
91  subroutine output_set_start_counter(this, n)
92  class(output_t), intent(inout) :: this
93  integer, intent(in) :: n
94  call this%file_%set_start_counter(n)
95  end subroutine output_set_start_counter
96 
97 
98 end module output
Abstract interface for sampling an output type at time t.
Definition: output.f90:57
Module for file I/O operations.
Definition: file.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12
Defines an output.
Definition: output.f90:34
subroutine output_set_start_counter(this, n)
Update the start of output's file counter.
Definition: output.f90:92
subroutine output_set_counter(this, n)
Update the output's file counter.
Definition: output.f90:85
subroutine output_init(this, fname, precision)
Output constructor.
Definition: output.f90:71
A wrapper around a polymorphic generic_file_t that handles its init. This is essentially a factory fo...
Definition: file.f90:54
Wrapper around an output_t pointer.
Definition: output.f90:51
Abstract type defining an output type.
Definition: output.f90:41