Neko  0.8.99
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  abstract interface
52  subroutine output_sample(this, t)
53  import :: output_t
54  import rp
55  class(output_t), intent(inout) :: this
56  real(kind=rp), intent(in) :: t
57  end subroutine output_sample
58  end interface
59 
60 contains
61 
65  subroutine output_init(this, fname, precision)
66  class(output_t), intent(inout) :: this
67  character(len=*), intent(inout) :: fname
68  integer, intent(in), optional :: precision
69 
70  if (present(precision)) then
71  this%file_ = file_t(fname, precision=precision)
72  else
73  this%file_ = file_t(fname)
74  end if
75 
76  end subroutine output_init
77 
79  subroutine output_set_counter(this, n)
80  class(output_t), intent(inout) :: this
81  integer, intent(in) :: n
82  call this%file_%set_counter(n)
83  end subroutine output_set_counter
84 
86  subroutine output_set_start_counter(this, n)
87  class(output_t), intent(inout) :: this
88  integer, intent(in) :: n
89  call this%file_%set_start_counter(n)
90  end subroutine output_set_start_counter
91 
92 
93 end module output
Abstract interface for sampling an output type at time t.
Definition: output.f90:52
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:87
subroutine output_set_counter(this, n)
Update the output's file counter.
Definition: output.f90:80
subroutine output_init(this, fname, precision)
Output constructor.
Definition: output.f90:66
A wrapper around a polymorphic generic_file_t that handles its init. This is essentially a factory fo...
Definition: file.f90:54
Abstract type defining an output type.
Definition: output.f90:41