Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
chkp_output.f90
Go to the documentation of this file.
1! Copyright (c) 2021-2026, 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!
33!> Defines an output for a checkpoint
35 use checkpoint, only : chkp_t
36 use output, only : output_t
37 use num_types, only : dp
38 implicit none
39 private
40
41 type, public, extends(output_t) :: chkp_output_t
42 type(chkp_t), pointer :: chkp
43 contains
44 procedure, pass(this) :: init => chkp_output_init
45 procedure, pass(this) :: free => chkp_output_free
46 procedure, pass(this) :: sample => chkp_output_sample
47 end type chkp_output_t
48
49contains
50
51 !> Constructor.
52 !! @param chkp The checkpoint to write.
53 !! @param name Optional base name of the files, `fluid` by default.
54 !! @param path Optional path to the write folder, with or without a
55 !! trailing slash.
56 !! @param fmt Optional file format, `hdf5` for HDF5 files.
57 !! @param overwrite Optional, whether each write overwrites the same file.
58 subroutine chkp_output_init(this, chkp, name, path, fmt, overwrite)
59 class(chkp_output_t), intent(inout) :: this
60 type(chkp_t), intent(in), target :: chkp
61 character(len=*), intent(in), optional :: name
62 character(len=*), intent(in), optional :: path
63 character(len=*), intent(in), optional :: fmt
64 logical, intent(in), optional :: overwrite
65 character(len=1024) :: fname
66 character(len=10) :: suffix
67 integer :: path_len
68
69 suffix = '.chkp'
70 if (present(fmt)) then
71 if (fmt .eq. 'hdf5') then
72 suffix = '.h5'
73 end if
74 end if
75
76 fname = 'fluid'
77 if (present(name)) fname = trim(name)
78 if (present(path)) then
79 path_len = len_trim(path)
80 if (path_len .gt. 0) then
81 if (path(path_len:path_len) .eq. '/') then
82 fname = trim(path) // trim(fname)
83 else
84 fname = trim(path) // '/' // trim(fname)
85 end if
86 end if
87 end if
88 fname = trim(fname) // trim(suffix)
89
90 call this%init_base(fname, overwrite = overwrite)
91 this%chkp => chkp
92 end subroutine chkp_output_init
93
94 subroutine chkp_output_free(this)
95 class(chkp_output_t), intent(inout) :: this
96
97 call this%free_base()
98 nullify(this%chkp)
99
100 end subroutine chkp_output_free
101
102 !> Sample a checkpoint at time @a t
103 subroutine chkp_output_sample(this, t)
104 class(chkp_output_t), intent(inout) :: this
105 real(kind=dp), intent(in) :: t
106
107 call this%chkp%sync_host()
108 call this%file_%write(this%chkp, t)
109
110 end subroutine chkp_output_sample
111
112end module chkp_output
Defines format-independent checkpoint registration and restart state.
Defines an output for a checkpoint.
subroutine chkp_output_free(this)
subroutine chkp_output_init(this, chkp, name, path, fmt, overwrite)
Constructor.
subroutine chkp_output_sample(this, t)
Sample a checkpoint at time t.
integer, parameter, public dp
Definition num_types.f90:10
Defines an output.
Definition output.f90:34
Collection of live simulation data registered for checkpointing.
Abstract type defining an output type.
Definition output.f90:41