Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
fld_file_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!
35 use num_types, only : rp
36 use field_list, only : field_list_t
39 use output, only : output_t
40 implicit none
41 private
42
44 type, public, extends(output_t) :: fld_file_output_t
45 ! The list of fields to save.
46 type(field_list_t) :: fields
47 contains
48 ! Constructor.
49 procedure, pass(this) :: init => fld_file_output_init
50 ! Writes the data.
51 procedure, pass(this) :: sample => fld_file_output_sample
52 end type fld_file_output_t
53
54contains
55
61 subroutine fld_file_output_init(this, precision, name, nfields, path)
62 class(fld_file_output_t), intent (inout) :: this
63 integer, intent(in) :: precision
64 character(len=*), intent(in) :: name
65 character(len=*), intent(in), optional :: path
66 integer, intent(in) :: nfields
67 character(len=1024) :: fname
68
69 if (present(path)) then
70 fname = trim(path) // trim(name) // '.fld'
71 else
72 fname = trim(name) // '.fld'
73 end if
74
75 call this%init_base(fname, precision)
76
77 call this%fields%init(nfields)
78
79 end subroutine fld_file_output_init
80
83 subroutine fld_file_output_sample(this, t)
84 class(fld_file_output_t), intent(inout) :: this
85 real(kind=rp), intent(in) :: t
86 integer :: i
87
88 if (neko_bcknd_device .eq. 1) then
89 associate(fields => this%fields%items)
90 do i = 1, size(fields)
91 call device_memcpy(fields(i)%ptr%x, fields(i)%ptr%x_d, &
92 fields(i)%ptr%dof%size(), device_to_host, &
93 sync=(i .eq. size(fields))) ! Sync on the last field
94 end do
95 end associate
96
97 end if
98
99 call this%file_%write(this%fields, t)
100
101 end subroutine fld_file_output_sample
102
103end module fld_file_output
Copy data between host and device (or device and device)
Definition device.F90:51
Device abstraction, common interface for various accelerators.
Definition device.F90:34
integer, parameter, public device_to_host
Definition device.F90:47
Implements fld_file_output_t.
subroutine fld_file_output_init(this, precision, name, nfields, path)
Constructor.
subroutine fld_file_output_sample(this, t)
Writes the data.
Build configurations.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Defines an output.
Definition output.f90:34
field_list_t, To be able to group fields together
A simple output saving a list of fields to a .fld file.
Abstract type defining an output type.
Definition output.f90:41