Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
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!
34module output
35 use num_types, only : dp
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_base
45 procedure, pass(this) :: free_base => output_free_base
46 procedure, pass(this) :: set_counter => output_set_counter
47 procedure, pass(this) :: set_start_counter => output_set_start_counter
49 procedure, pass(this) :: configure_file => output_configure_file
50 procedure(output_sample), pass(this), deferred :: sample
51 procedure(output_free), pass(this), deferred :: free
52 end type output_t
53
55 type, public :: output_ptr_t
56 class(output_t), pointer :: ptr => null()
57 end type output_ptr_t
58
60 abstract interface
61 subroutine output_sample(this, t)
62 import :: output_t
63 import dp
64 class(output_t), intent(inout) :: this
65 real(kind=dp), intent(in) :: t
66 end subroutine output_sample
67
68 subroutine output_free(this)
69 import :: output_t
70 class(output_t), intent(inout) :: this
71 end subroutine output_free
72 end interface
73
74contains
75
79 subroutine output_init_base(this, fname, precision, layout, overwrite)
80 class(output_t), intent(inout) :: this
81 character(len=*), intent(inout) :: fname
82 integer, intent(in), optional :: precision
83 integer, intent(in), optional :: layout
84 logical, intent(in), optional :: overwrite
85
86 call this%file_%init(fname, precision = precision, layout = layout, &
87 overwrite = overwrite)
88
89 ! file_%init allocates a new file_type, so settings have to be re-applied.
90 call this%configure_file()
91
92 end subroutine output_init_base
93
95 subroutine output_configure_file(this)
96 class(output_t), intent(inout) :: this
97 end subroutine output_configure_file
98
100 subroutine output_set_counter(this, n)
101 class(output_t), intent(inout) :: this
102 integer, intent(in) :: n
103 call this%file_%set_counter(n)
104 end subroutine output_set_counter
105
107 subroutine output_set_start_counter(this, n)
108 class(output_t), intent(inout) :: this
109 integer, intent(in) :: n
110 call this%file_%set_start_counter(n)
111 end subroutine output_set_start_counter
112
114 subroutine output_free_base(this)
115 class(output_t), intent(inout) :: this
116 call this%file_%free()
117 end subroutine output_free_base
118
119end module output
Abstract interface for sampling an output type at time t.
Definition output.f90:61
Module for file I/O operations.
Definition file.f90:34
integer, parameter, public dp
Definition num_types.f90:10
Defines an output.
Definition output.f90:34
subroutine output_configure_file(this)
Applies settings to the file (does nothing unless overridden).
Definition output.f90:96
subroutine output_set_start_counter(this, n)
Update the start of output's file counter.
Definition output.f90:108
subroutine output_set_counter(this, n)
Update the output's file counter.
Definition output.f90:101
subroutine output_init_base(this, fname, precision, layout, overwrite)
Output constructor.
Definition output.f90:80
subroutine output_free_base(this)
Free the output.
Definition output.f90:115
A wrapper around a polymorphic generic_file_t that handles its init. This is essentially a factory fo...
Definition file.f90:56
Wrapper around an output_t pointer.
Definition output.f90:55
Abstract type defining an output type.
Definition output.f90:41