FMS  2026.01.01-dev
Flexible Modeling System
fms2_io.F90
1 !***********************************************************************
2 !* Apache License 2.0
3 !*
4 !* This file is part of the GFDL Flexible Modeling System (FMS).
5 !*
6 !* Licensed under the Apache License, Version 2.0 (the "License");
7 !* you may not use this file except in compliance with the License.
8 !* You may obtain a copy of the License at
9 !*
10 !* http://www.apache.org/licenses/LICENSE-2.0
11 !*
12 !* FMS is distributed in the hope that it will be useful, but WITHOUT
13 !* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied;
14 !* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 !* PARTICULAR PURPOSE. See the License for the specific language
16 !* governing permissions and limitations under the License.
17 !***********************************************************************
18 !> @defgroup fms2_io_mod fms2_io_mod
19 !> @ingroup fms2_io
20 !> @brief This module supports netCDF I/O operations.
21 !!
22 !! fms2_io_mod is the top level module that provides open, close, read, and write interfaces to the NetCDF package.
23 !! This module defines public "aliases"(interfaces) to select procedures in fms_netcdf_domain_io_mod for reading/writing
24 !! data on structured grid domains; fms_netcdf_unstructured_domain_io_mod for reading/writing data on unstructured
25 !! grid domains; netcdf_io_mod for reading/writing data that is not parallelized with domain decomposition.
26 !!
27 !! Subroutines and functions in fms_netcdf_domain_io_mod, fms_netcdf_unstructured_domain_io_mod, and
28 !! netcdf_io_mod are intended for internally use only. We highly recommended to only call public interfaces defined
29 !! in this module.
30 !!
31 !! Before any fms2_io_mod I/O operations, a file derived type must be declared.
32 !! Three file derived types are currently available and are described below. Any instances
33 !! of these three file types are referred to as "fileobj" in this module.
34 !!
35 !! - FmsNetcdfFile_t: provides limited number of wrapper procedures to the netCDF4 library. If the
36 !! user provides a pelist to procedures compatible with this type, only the root rank of the pelist
37 !! performs I/O operations by calling the NetCDF library: the root rank either boradcasts the read-in
38 !! data to the remaining ranks in the pelist, or gathers data from the remaining ranks in the pelist before writing.
39 !! If a pelist is not provided, all ranks calling the procedure will perform the IO operation.
40 !!
41 !! - FmsNetcdfDomainFile_t: extends upon FmsNetcdfFile_t and adds supports for "domain-decomposed" reads and writes.
42 !! Here, "domain decomposed" refers to data that is partitioned into subdomains of the decomposed global domain,
43 !! and each MPI rank holds its portion of the global data. The users must provide a domain of type Domain2D from
44 !! mpp_domains_mod when initializing this file object. To specify pe's for performing the IO operations, see
45 !! mpp_set_io_layout
46 !!
47 !! - FmsNetcdfUnstructuredDomainFile_t: also extends upon FmsNetcdfFile_t and adds support for
48 !! “domain-decomposed” reads/writes for data decomposed on subdomains of unstructured grids
49 !! The users must provide a domain of type DomainUG from mpp_domains_mod when initializing this file object.
50 !!
51 !! See mpp_domains_mod documentation for more information on creating a domain decomposition using FMS.
52 !!
53 !! When using the FmsNetcdfDomainFile_t or the FmsNetcdfUnstructuredDomainFile_t types,
54 !! the io_layout controls how the IO operations are parallelized.
55 !! See mpp_domains_mod for more information (TODO!).
56 !!
57 !! Besides standard open/close/read/write operations, this module also provides interfaces for writing and reading
58 !! "diskless" netcdf files via the blackboxio module. This module is used mainly for testing purposes, and should not
59 !! be used in production.
60 !!
61 !! Users can specify additional I/O parameters with the fms2_io_nml namelist which allows users to specify the following
62 !! NetCDF library parameters: Netcdf file format, chunk_size, deflate_level, shuffle. Note, fms2_io accepts the
63 !! Netcdf file format namelist values:"64bit", "class", and "netcdf4". For more information on optimizing NetCDF writing
64 !! operation, see https://docs.unidata.ucar.edu/netcdf-c/current/file_format_specifications.html
65 !!
66 !! @note The legacy IO modules, fms_io_mod and mpp_io_mod, are no longer available.
67 !! If converting legacy code from fms_io/mpp_io to fms2_io, please refer to the migration guide at fms2_io/readme.md.
68 
69 !> @addtogroup fms2_io_mod
70 !> @{
71 module fms2_io_mod
72 use fms_io_utils_mod
73 use netcdf_io_mod
74 use fms_netcdf_domain_io_mod
75 use fms_netcdf_unstructured_domain_io_mod
76 use blackboxio
77 use mpp_mod, only: mpp_init, input_nml_file, mpp_error, fatal
78 use mpp_domains_mod, only: mpp_domains_init
79 implicit none
80 private
81 
82 !> NetCDF constant (enum) for unlimited dimension identification
83 public :: unlimited
84 
85 !> File object types are defined in the helper modules (netcdf_io_mod,fms_netcdf_domain_io_mod,
86 !! fms_netcdf_unstructured_domain_io_mod) but are made public here for user access.
88 
89 !> Interfaces defined below to make public
91 public :: register_axis
92 public :: register_field
93 public :: register_restart_field
94 public :: write_data
95 public :: read_data
96 public :: write_restart
97 public :: write_new_restart
98 public :: read_restart
99 public :: read_new_restart
100 
101 !> Routines/functions from netcdf_io_mod to make public
103 public :: global_att_exists
104 public :: variable_att_exists
107 public :: get_global_attribute
108 public :: get_variable_attribute
109 public :: get_num_dimensions
110 public :: get_dimension_names
111 public :: dimension_exists
112 public :: is_dimension_unlimited
113 public :: get_dimension_size
114 public :: get_num_variables
115 public :: get_variable_names
116 public :: variable_exists
119 public :: get_variable_size
120 public :: flush_file
121 public :: write_restart_bc
122 public :: read_restart_bc
124 public :: get_variable_sense
125 public :: get_variable_missing
126 public :: get_variable_units
127 public :: get_time_calendar
128 public :: is_registered_to_restart
129 public :: check_if_open
130 public :: set_fileobj_time_name
131 public :: valid_t
132 public :: get_valid
133 public :: is_valid
134 
135 !> Routines/functions from fms_netcdf_domain_io_mod to make public
140 
141 !> Routines/functions from fms_io_utils_mod to make public
142 public :: file_exists
143 public :: open_check
144 public :: is_dimension_registered
145 public :: fms2_io_init
146 public :: get_mosaic_tile_grid
147 public :: ascii_read
148 public :: get_mosaic_tile_file
149 public :: parse_mask_table
150 public :: get_filename_appendix
151 public :: set_filename_appendix
152 public :: get_instance_filename
154 !> @}
155 
156 !> @brief Opens a NetCDF dataset on disk and initializes the file object.
157 !!
158 !> Opens a netcdf file for standard data, domain decomposed data, or unstructured domain decomposed data
159 !! and also intializes the fileobj for subsequent IO operations.
160 !!
161 !! <br>Example usage for opening a file with standard non-domain decomposed data:
162 !!
163 !! io_success = open_file(fileobj, "filename", "write")
164 !!
165 !! File mode can be "read"/"write"/"overwrite"/"append"
166 !!
167 !! <br>Example usage for opening a file with domain decomposed data:
168 !!
169 !! io_success = open_file(fileobj, "filename", "write", domain)
170 !!
171 !! Where fileobj is of type @ref fmsnetcdfdomainfile_t or @ref fmsnetcdfunstructureddomainfile_t
172 !!
173 !! Netcdf's collective IO functionality can be enabled when opening a file in order to perform collective read and
174 !! writes. This will use netcdf libraries capabilities for parallel file access, allowing all processors
175 !! to perform data reads and writes. To use this option, hdf5 and netcdf must be built with MPI support.
176 !! Example usage:
177 !!
178 !! io_success = open_file(fileobj, "test_collective_io.nc", "read", domain, nc_format=nc_format, &
179 !! use_collective=.true.)
180 !!
181 !! See fms2_io/readme.md for more information.
182 !!
183 !! @note For individual documentation on the listed routines, please see the appropriate helper module.
184 !! For netcdf files with a structured domain: @ref fms_netcdf_domain_io_mod.
185 !! For netcdf files with an unstructured domain: @ref fms_netcdf_unstructured_domain_io_mod.
186 !! For generic netcdf: @ref netcdf_io_mod.
187 !> @ingroup fms2_io_mod
188 interface open_file
189  module procedure netcdf_file_open_wrap
190  module procedure open_domain_file
191  module procedure open_unstructured_domain_file
192 end interface open_file
193 
194 
195 !> @brief Creates a diskless netcdf or domain file. File is created in memory only via the netcdf library's
196 !! NC_DISKLESS creation mode option. Data will be lost upon file closing.
197 !!
198 !> @return true if successful, false otherwise
199 !!
200 !> <br>Example usage:
201 !!
202 !! io_success = open_virtual_file(fileobj, "filename", pelist)
203 !!
204 !! Opens a virtual file through @ref fmsnetcdffile_t at an optional file path and pelist
205 !!
206 !! io_success = open_virtual_file(fileobj, domain, "filename")
207 !!
208 !! Opens a virtual domain file through @ref fmsnetcdfdomainfile_t or
209 !! @ref fmsnetcdfunstructureddomainfile_t for a given 2D domain at an optional path <br>
210 !!
211 !! @note For individual documentation on the listed routines, please see the appropriate helper module: @ref blackboxio
212 !> @ingroup fms2_io_mod
214  module procedure create_diskless_netcdf_file_wrap
215  module procedure create_diskless_domain_file
217 end interface open_virtual_file
218 
219 !> @brief Close a netcdf or domain file opened with @ref open_file or
220 !! @ref open_virtual_file
221 !!
222 !> <br>Example usage:
223 !!
224 !! call close_file(fileobj)
225 !!
226 !! Closes any given fileobj opened via @ref open_file or @ref open_virtual_file
227 !!
228 !! @note For individual documentation on the listed routines, please see the appropriate helper module.
229 !! For netcdf files with a structured domain: @ref fms_netcdf_domain_io_mod.
230 !! For netcdf files with an unstructured domain: @ref fms_netcdf_unstructured_domain_io_mod.
231 !! For generic netcdf: @ref netcdf_io_mod.
232 !> @ingroup fms2_io_mod
233 interface close_file
234  module procedure netcdf_file_close_wrap
235  module procedure close_domain_file
236  module procedure close_unstructured_domain_file
237 end interface close_file
238 
239 !> @brief Adds a dimension/axis to a given netcdf file object.
240 !!
241 !> <br>Example usage:
242 !!
243 !! call register_axis(fileobj, "lon", "x")
244 !!
245 !! Adds a dimension named "lon" associated with the x axis of the 2D domain file. For unstructured
246 !! domains no x or y axis character is provided.
247 !!
248 !! call register_axis(fileobj, "lon", n)
249 !!
250 !! Adds a dimension named "lon" with length n to a given netcdf file.<br>
251 !!
252 !! @note For individual documentation on the listed routines, please see the appropriate helper module.
253 !! For netcdf files with a structured domain: @ref fms_netcdf_domain_io_mod.
254 !! For netcdf files with an unstructured domain: @ref fms_netcdf_unstructured_domain_io_mod.
255 !! For generic netcdf: @ref netcdf_io_mod.
256 !> @ingroup fms2_io_mod
257 interface register_axis
258  module procedure netcdf_add_dimension
259  module procedure register_compressed_dimension
260  module procedure register_domain_decomposed_dimension
261  module procedure register_unstructured_dimension
262 end interface register_axis
263 
264 !> @brief Defines a new field/variable within the given file. After a variable is registered,
265 !! users can write data to the file via write_data.
266 !> <br>Example usage:
267 !!
268 !! call register_field(fileobj, "lon", "double", (/"lon"/) )
269 !!
270 !! Adds a floating point double precision (kind=8) variable named "lon" to the given file, corresponding to the
271 !! list of dimension names (which must be previously registered in the fileobj with register_axis).
272 !! The dimension name list corresponds to the dimensions of the field.
273 !! <br>Example:
274 !!
275 !! call register_field(fileobj, "variable_2d", "double", (/"lon", "lat"/))
276 !!
277 !! @note For individual documentation on the listed routines, please see the appropriate helper module.
278 !! For netcdf files with a structured domain: @ref fms_netcdf_domain_io_mod.
279 !! For netcdf files with an unstructured domain: @ref fms_netcdf_unstructured_domain_io_mod.
280 !! For generic netcdf: @ref netcdf_io_mod.
281 !> @ingroup fms2_io_mod
282 interface register_field
283  module procedure netcdf_add_variable_wrap
284  module procedure register_domain_variable
286 end interface register_field
287 
288 !> @brief Registers a new restart field.
289 !> <br>Example usage:
290 !!
291 !! call register_restart_field(fileobj, "temperature", data, (/"lon", "time"/) )
292 !!
293 !! Creates a restart variable and stores a pointer to the data.
294 !!
295 !! This differs from the register_field interface in that registered restart fields are stored
296 !! in the fileobj and can be easily read/written via a call to the read_restart/write_restart interfaces.
297 !!
298 !! @note For individual documentation on the listed routines, please see the appropriate helper module.
299 !! For netcdf files with a structured domain: @ref fms_netcdf_domain_io_mod.
300 !! For netcdf files with an unstructured domain: @ref fms_netcdf_unstructured_domain_io_mod.
301 !! For generic netcdf: @ref netcdf_io_mod.
302 !> @ingroup fms2_io_mod
304  module procedure netcdf_add_restart_variable_0d_wrap
305  module procedure netcdf_add_restart_variable_1d_wrap
306  module procedure netcdf_add_restart_variable_2d_wrap
307  module procedure netcdf_add_restart_variable_3d_wrap
308  module procedure netcdf_add_restart_variable_4d_wrap
309  module procedure netcdf_add_restart_variable_5d_wrap
310  module procedure register_domain_restart_variable_0d
311  module procedure register_domain_restart_variable_1d
312  module procedure register_domain_restart_variable_2d
313  module procedure register_domain_restart_variable_3d
314  module procedure register_domain_restart_variable_4d
315  module procedure register_domain_restart_variable_5d
322  module procedure register_restart_region_2d
323  module procedure register_restart_region_3d
324 end interface register_restart_field
325 
326 !> @brief Write data to a registered field within a file
327 !> <br>Example usage:
328 !!
329 !! call write_data(fileobj, "lon", data)
330 !!
331 !! Write the value(s) in data to the field named "lon"
332 !!
333 !> @ingroup fms2_io_mod
334 interface write_data
335  module procedure compressed_write_0d_wrap
336  module procedure compressed_write_1d_wrap
337  module procedure compressed_write_2d_wrap
338  module procedure compressed_write_3d_wrap
339  module procedure compressed_write_4d_wrap
340  module procedure compressed_write_5d_wrap
341  module procedure domain_write_0d
342  module procedure domain_write_1d
343  module procedure domain_write_2d
344  module procedure domain_write_3d
345  module procedure domain_write_4d
346  module procedure domain_write_5d
347  module procedure unstructured_domain_write_0d
348  module procedure unstructured_domain_write_1d
349  module procedure unstructured_domain_write_2d
350  module procedure unstructured_domain_write_3d
351  module procedure unstructured_domain_write_4d
352  module procedure unstructured_domain_write_5d
353 end interface write_data
354 
355 !> @brief Read data from a defined field in a file
356 !!
357 !> <br>Example usage:
358 !!
359 !! call read_data(fileobj, "lat", data)
360 !!
361 !! Read the values for the field "lat" from the file and write them onto data <br>
362 !!
363 !> @ingroup fms2_io_mod
364 interface read_data
365  module procedure compressed_read_0d
366  module procedure compressed_read_1d
367  module procedure compressed_read_2d
368  module procedure compressed_read_3d
369  module procedure compressed_read_4d
370  module procedure compressed_read_5d
371  module procedure domain_read_0d
372  module procedure domain_read_1d
373  module procedure domain_read_2d
374  module procedure domain_read_3d
375  module procedure domain_read_4d
376  module procedure domain_read_5d
377  module procedure unstructured_domain_read_0d
378  module procedure unstructured_domain_read_1d
379  module procedure unstructured_domain_read_2d
380  module procedure unstructured_domain_read_3d
381  module procedure unstructured_domain_read_4d
382  module procedure unstructured_domain_read_5d
383 end interface read_data
384 
385 !> @brief Writes previously registered restart fields to the given restart file
386 !> <br>Example usage:
387 !!
388 !! call write_restart(fileobj)
389 !!
390 !! @note For individual documentation on the listed routines, please see the appropriate helper module.
391 !! For netcdf files with a structured domain: @ref fms_netcdf_domain_io_mod.
392 !! For netcdf files with an unstructured domain: @ref fms_netcdf_unstructured_domain_io_mod.
393 !! For generic netcdf: @ref netcdf_io_mod.
394 !> @ingroup fms2_io_mod
395 interface write_restart
396  module procedure netcdf_save_restart_wrap
397  module procedure save_domain_restart
398  module procedure unstructured_write_restart
399 end interface write_restart
400 
401 !> @brief Writes all restart fields in a given restart file to a new restart file
402 !> <br>Example usage:
403 !!
404 !! call write_new_restart(fileobj, timestamp="tstring", filename="new_restartfilename")
405 !!
406 !! Creates a new restart file, with the provided timestamp and filename, out of the registered
407 !! restart fields in the given restart fileobj.
408 !!
409 !! @note This interface is only intended for use with diskless netcdf files.
410 !!
411 !! @note For individual documentation on the listed routines, please see the appropriate helper module: @ref blackboxio
412 !> @ingroup fms2_io_mod
414  module procedure netcdf_save_restart_wrap2
415  module procedure save_domain_restart_wrap
416  module procedure unstructured_write_restart_wrap
417 end interface write_new_restart
418 
419 !> @brief Reads in restart variables from a given file
420 !> <br>Example usage:
421 !! call read_restart(fileobj)
422 !! Reads registered restart variables from fileobj
423 !!
424 !! @note For individual documentation on the listed routines, please see the appropriate helper module.
425 !! For netcdf files with a structured domain: @ref fms_netcdf_domain_io_mod.
426 !! For generic netcdf: @ref netcdf_io_mod.
427 !> @ingroup fms2_io_mod
428 interface read_restart
429  module procedure netcdf_restore_state
430  module procedure restore_domain_state
431 end interface read_restart
432 
433 !> @brief Read registered restarts from a new file
434 !! Optionally takes directory to write to, model time and filename
435 !> <br>Example usage:
436 !! call read_new_restart(fileobj, unlimted_dimension_level)
437 !!
438 !! call read_new_restart(fileobj, unlimited_dimension_level, directory, timestamp, filename)
439 !!
440 !! @note This interface is only intended for use with diskless netcdf files.
441 !!
442 !! @note For individual documentation on the listed routines, please see the appropriate helper module: @ref blackboxio
443 !> @ingroup fms2_io_mod
445  module procedure netcdf_restore_state_wrap
446  module procedure restore_domain_state_wrap
447 end interface read_new_restart
448 
449 !> @addtogroup fms2_io_mod
450 !> @{
451 
452 logical, private :: fms2_io_is_initialized = .false. !< True after calling fms2_io_init
453 ! Namelist variables
454 integer :: ncchksz = 64*1024 !< User defined chunksize (in bytes) argument in netcdf file
455  !! creation calls. Replaces setting the NC_CHKSZ environment variable.
456 character (len = 10) :: netcdf_default_format = "64bit" !< User defined netcdf file format, acceptable values
457  !! are: "64bit", "classic", "netcdf4". This can be overwritten for a given file
458  !! by specifying "nc_format" in the open_file call.
459 integer :: header_buffer_val = 16384 !< User defined netCDF header buffer size(in bytes) used in
460  !! NF__ENDDEF
461 integer :: deflate_level = default_deflate_level !< Netcdf deflate level to use in nf90_def_var
462  !! (integer between 1 to 9)
463 logical :: shuffle = .false. !< Flag indicating whether to use the netcdf shuffle filter
464 namelist / fms2_io_nml / &
466 
467 contains
468 
469 !> @brief Reads the fms2_io_nml. Needs to be called prior to any usage of fms2_io_mod.
470 subroutine fms2_io_init ()
471  integer :: mystat
472 
473 !> Check if the module has already been initialized
474  if (fms2_io_is_initialized) return
475 !> Call initialization routines that this module depends on
476  call mpp_init()
477  call mpp_domains_init()
478 !> Read the namelist
479  READ (input_nml_file, nml=fms2_io_nml, iostat=mystat)
480 !>Send the namelist variables to their respective modules
481  if (ncchksz .le. 0) then
482  call mpp_error(fatal, "ncchksz in fms2_io_nml must be a positive number.")
483  endif
484  if (header_buffer_val .le. 0) then
485  call mpp_error(fatal, "header_buffer_val in fms2_io_nml must be a positive number.")
486  endif
487  if (deflate_level .lt. 0 .or. deflate_level .gt. 9) then
488  call mpp_error(fatal, &
489  "deflate_level in fms2_io_nml must be a positive number between 1 and 9 as it is required by NetCDF")
490  endif
492  call blackboxio_init (ncchksz)
493 !> Mark the fms2_io as initialized
494  fms2_io_is_initialized = .true.
495 end subroutine fms2_io_init
496 
497 end module fms2_io_mod
498 !> @}
499 ! close documentation grouping
logical function, public create_diskless_netcdf_file_wrap(fileobj, pelist, path)
Wrapper to distinguish interfaces.
Definition: blackboxio.F90:363
logical function, public create_diskless_unstructured_domain_file(fileobj, domain, path)
Create a "diskless" netcdf file to act as a buffer to support our "register data to a file wi...
Definition: blackboxio.F90:595
subroutine, public unstructured_write_restart_wrap(fileobj, unlim_dim_level, directory, timestamp, filename, nc_format)
Wrapper to distinguish interfaces.
Definition: blackboxio.F90:649
subroutine, public save_domain_restart_wrap(fileobj, unlim_dim_level, directory, timestamp, filename, nc_format)
Loop through registered restart variables and write them to a netcdf file.
Definition: blackboxio.F90:523
logical function, public create_diskless_domain_file(fileobj, domain, path)
Create a "diskless" netcdf file to act as a buffer to support our "register data to a file wi...
Definition: blackboxio.F90:453
subroutine, public restore_domain_state_wrap(fileobj, unlim_dim_level, directory, timestamp, filename, ignore_checksum)
Loop through registered restart variables and read them from a netcdf file.
Definition: blackboxio.F90:561
subroutine, public netcdf_restore_state_wrap(fileobj, unlim_dim_level, directory, timestamp, filename)
Loop through registered restart variables and read them from a netcdf file.
Definition: blackboxio.F90:419
subroutine, public blackboxio_init(chksz)
Accepts the namelist fms2_io_nml variables relevant to blackboxio.
Definition: blackboxio.F90:53
subroutine, public netcdf_save_restart_wrap2(fileobj, unlim_dim_level, directory, timestamp, filename, nc_format)
Support for writing new restarts from a diskless file.
Definition: blackboxio.F90:380
subroutine unstructured_domain_read_4d(fileobj, variable_name, buf, unlim_dim_level, corner, edge_lengths, broadcast)
Wrapper to distinguish interfaces.
subroutine unstructured_domain_write_2d(fileobj, variable_name, variable_data, unlim_dim_level, corner, edge_lengths)
Wrapper to distinguish interfaces.
subroutine compressed_write_1d_wrap(fileobj, variable_name, cdata, unlim_dim_level, corner, edge_lengths)
Wrapper to distinguish interfaces.
subroutine compressed_write_5d_wrap(fileobj, variable_name, cdata, unlim_dim_level, corner, edge_lengths)
Wrapper to distinguish interfaces.
subroutine register_unstructured_domain_restart_variable_4d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
subroutine domain_read_0d(fileobj, variable_name, vdata, unlim_dim_level, corner)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
Definition: domain_read.inc:30
subroutine domain_write_3d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
subroutine compressed_read_0d(fileobj, variable_name, cdata, unlim_dim_level, corner)
I/O domain reads in data from the netcdf file and broadcasts the data to the rest of the ranks....
subroutine register_domain_restart_variable_3d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
subroutine unstructured_domain_read_3d(fileobj, variable_name, buf, unlim_dim_level, corner, edge_lengths, broadcast)
Wrapper to distinguish interfaces.
subroutine compressed_read_5d(fileobj, variable_name, cdata, unlim_dim_level, corner, edge_lengths)
I/O domain reads in data from the netcdf file and broadcasts the data to the rest of the ranks....
subroutine compressed_read_3d(fileobj, variable_name, cdata, unlim_dim_level, corner, edge_lengths)
I/O domain reads in data from the netcdf file and broadcasts the data to the rest of the ranks....
logical shuffle
Flag indicating whether to use the netcdf shuffle filter.
Definition: fms2_io.F90:463
subroutine unstructured_domain_write_3d(fileobj, variable_name, variable_data, unlim_dim_level, corner, edge_lengths)
Wrapper to distinguish interfaces.
subroutine domain_write_4d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
subroutine compressed_write_0d_wrap(fileobj, variable_name, cdata, unlim_dim_level, corner)
Wrapper to distinguish interfaces.
subroutine compressed_read_1d(fileobj, variable_name, cdata, unlim_dim_level, corner, edge_lengths)
I/O domain reads in data from the netcdf file and broadcasts the data to the rest of the ranks....
subroutine compressed_read_2d(fileobj, variable_name, cdata, unlim_dim_level, corner, edge_lengths)
I/O domain reads in data from the netcdf file and broadcasts the data to the rest of the ranks....
subroutine register_domain_restart_variable_1d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
subroutine domain_write_1d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
subroutine register_unstructured_domain_restart_variable_2d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
integer header_buffer_val
User defined netCDF header buffer size(in bytes) used in NF__ENDDEF.
Definition: fms2_io.F90:459
subroutine domain_write_5d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
logical, private fms2_io_is_initialized
True after calling fms2_io_init.
Definition: fms2_io.F90:452
subroutine unstructured_domain_write_0d(fileobj, variable_name, variable_data, unlim_dim_level, corner)
Wrapper to distinguish interfaces.
subroutine unstructured_domain_read_0d(fileobj, variable_name, buf, unlim_dim_level, corner, broadcast)
Wrapper to distinguish interfaces.
subroutine register_domain_restart_variable_5d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
integer deflate_level
Netcdf deflate level to use in nf90_def_var (integer between 1 to 9)
Definition: fms2_io.F90:461
subroutine unstructured_domain_write_4d(fileobj, variable_name, variable_data, unlim_dim_level, corner, edge_lengths)
Wrapper to distinguish interfaces.
subroutine compressed_write_2d_wrap(fileobj, variable_name, cdata, unlim_dim_level, corner, edge_lengths)
Wrapper to distinguish interfaces.
subroutine register_unstructured_domain_restart_variable_3d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
integer ncchksz
User defined chunksize (in bytes) argument in netcdf file creation calls. Replaces setting the NC_CHK...
Definition: fms2_io.F90:454
subroutine compressed_write_4d_wrap(fileobj, variable_name, cdata, unlim_dim_level, corner, edge_lengths)
Wrapper to distinguish interfaces.
subroutine domain_write_0d(fileobj, variable_name, vdata, unlim_dim_level, corner)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
subroutine unstructured_domain_read_5d(fileobj, variable_name, buf, unlim_dim_level, corner, edge_lengths, broadcast)
Wrapper to distinguish interfaces.
subroutine compressed_read_4d(fileobj, variable_name, cdata, unlim_dim_level, corner, edge_lengths)
I/O domain reads in data from the netcdf file and broadcasts the data to the rest of the ranks....
subroutine domain_write_2d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
Gather "compute" domain data on the I/O root rank and then have the I/O root write out the data that ...
subroutine domain_read_3d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
subroutine unstructured_domain_read_2d(fileobj, variable_name, buf, unlim_dim_level, corner, edge_lengths, broadcast)
Wrapper to distinguish interfaces.
subroutine register_domain_restart_variable_4d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
subroutine domain_read_1d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
Definition: domain_read.inc:57
subroutine, public fms2_io_init()
Reads the fms2_io_nml. Needs to be called prior to any usage of fms2_io_mod.
Definition: fms2_io.F90:471
subroutine register_unstructured_domain_restart_variable_1d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
subroutine compressed_write_3d_wrap(fileobj, variable_name, cdata, unlim_dim_level, corner, edge_lengths)
Wrapper to distinguish interfaces.
subroutine register_unstructured_domain_restart_variable_5d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
subroutine unstructured_domain_write_1d(fileobj, variable_name, variable_data, unlim_dim_level, corner, edge_lengths)
Wrapper to distinguish interfaces.
subroutine domain_read_2d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
Definition: domain_read.inc:88
subroutine domain_read_4d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
subroutine unstructured_domain_write_5d(fileobj, variable_name, variable_data, unlim_dim_level, corner, edge_lengths)
Wrapper to distinguish interfaces.
subroutine register_unstructured_domain_restart_variable_0d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
subroutine domain_read_5d(fileobj, variable_name, vdata, unlim_dim_level, corner, edge_lengths)
I/O domain root reads in a domain decomposed variable at a specific unlimited dimension level and sca...
character(len=10) netcdf_default_format
User defined netcdf file format, acceptable values are: "64bit", "classic", "netcdf4"....
Definition: fms2_io.F90:456
subroutine register_domain_restart_variable_0d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
subroutine unstructured_domain_read_1d(fileobj, variable_name, buf, unlim_dim_level, corner, edge_lengths, broadcast)
Wrapper to distinguish interfaces.
subroutine register_domain_restart_variable_2d(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Add a domain decomposed variable.
Close a netcdf or domain file opened with open_file or open_virtual_file.
Definition: fms2_io.F90:233
Opens a NetCDF dataset on disk and initializes the file object.
Definition: fms2_io.F90:188
Creates a diskless netcdf or domain file. File is created in memory only via the netcdf library's NC_...
Definition: fms2_io.F90:213
Read data from a defined field in a file.
Definition: fms2_io.F90:364
Read registered restarts from a new file Optionally takes directory to write to, model time and filen...
Definition: fms2_io.F90:444
Reads in restart variables from a given file Example usage: call read_restart(fileobj) Reads registe...
Definition: fms2_io.F90:428
Adds a dimension/axis to a given netcdf file object.
Definition: fms2_io.F90:257
Defines a new field/variable within the given file. After a variable is registered,...
Definition: fms2_io.F90:282
Registers a new restart field. Example usage:
Definition: fms2_io.F90:303
Write data to a registered field within a file Example usage:
Definition: fms2_io.F90:334
Writes all restart fields in a given restart file to a new restart file Example usage:
Definition: fms2_io.F90:413
Writes previously registered restart fields to the given restart file Example usage:
Definition: fms2_io.F90:395
subroutine, public get_instance_filename(name_in, name_out)
Adds the filename_appendix to name_in and sets it as name_out.
subroutine, public ascii_read(ascii_filename, ascii_var, num_lines, max_length)
Read the ascii text from filename ascii_filenameinto string array ascii_var
logical function, public file_exists(path)
Determine if a file exists.
subroutine, public open_check(flag, fname)
subroutine, public nullify_filename_appendix()
Clears the filename_appendix module variable.
subroutine, public get_filename_appendix(string_out)
Writes filename appendix to "string_out".
subroutine, public set_filename_appendix(string_in)
Save "string_in" as a module variable that will added to the filename of the restart files.
Constructs the file name to be used when utilizing a multi-tile mosaic. This is currenly used in the ...
Reads in the mask_table file in the ASCII format from a given path and populates a maskmap array that...
subroutine, public save_domain_restart(fileobj, unlim_dim_level)
Loop through registered restart variables and write them to a netcdf file.
logical function, public is_dimension_registered(fileobj, dimension_name)
Determine whether a domain-decomposed dimension has been registered to the file object.
subroutine, public get_global_io_domain_indices(fileobj, dimname, is, ie, indices)
Get starting/ending global indices of the I/O domain for a domain decomposed file.
subroutine, public register_domain_variable(fileobj, variable_name, variable_type, dimensions, chunksizes)
Add a domain decomposed variable.
subroutine, public get_mosaic_tile_grid(grid_file, mosaic_file, domain, tile_count)
Read a mosaic_file and get the grid filename for the current tile or for the tile specified.
subroutine, public register_domain_decomposed_dimension(fileobj, dim_name, xory, domain_position)
Add a dimension to a file associated with a two-dimensional domain.
logical function, public open_domain_file(fileobj, path, mode, domain, nc_format, is_restart, dont_add_res_to_filename, use_netcdf_mpi, use_collective)
Open a domain netcdf file.
subroutine, public close_domain_file(fileobj)
Close a domain netcdf file.
subroutine, public restore_domain_state(fileobj, unlim_dim_level, ignore_checksum)
Loop through registered restart variables and read them from a netcdf file.
subroutine, public get_compute_domain_dimension_indices(fileobj, dimname, indices)
Return an array of compute domain indices.
Type to represent a netCDF file when on a domain decomposed standard rectangular grid....
subroutine, public register_unstructured_dimension(fileobj, dim_name)
Add an unstructured dimension.
logical function, public open_unstructured_domain_file(fileobj, path, mode, domain, nc_format, is_restart, dont_add_res_to_filename)
Open a netcdf file that is associated with an unstructured domain.
subroutine, public close_unstructured_domain_file(fileobj)
Wrapper to distinguish interfaces.
subroutine, public register_unstructured_domain_variable(fileobj, variable_name, variable_type, dimensions, chunksizes)
Wrapper to distinguish interfaces.
subroutine, public unstructured_write_restart(fileobj, unlim_dim_level)
Wrapper to distinguish interfaces.
Type to represent a netCDF file when on a domain decomposed unstructured grid. Used to do distributed...
subroutine mpp_domains_init(flags)
Initialize domain decomp package.
Error handler.
Definition: mpp.F90:385
subroutine, public netcdf_restore_state(fileobj, unlim_dim_level)
Loop through registered restart variables and read them from a netcdf file.
Definition: netcdf_io.F90:1171
subroutine, public get_variable_size(fileobj, variable_name, dim_sizes, broadcast)
Get the size of a variable's dimensions.
Definition: netcdf_io.F90:1728
subroutine, public netcdf_add_dimension(fileobj, dimension_name, dimension_length, is_compressed)
Add a dimension to a file.
Definition: netcdf_io.F90:901
type(valid_t) function, public get_valid(fileobj, variable_name)
Store the valid range for a variable.
Definition: netcdf_io.F90:1838
subroutine, public read_restart_bc(fileobj, unlim_dim_level, ignore_checksum)
Loop through the registered restart variables (including regional variables) and read them from the n...
Definition: netcdf_io.F90:2325
logical function, public is_dimension_unlimited(fileobj, dimension_name, broadcast)
Determine where or not the dimension is unlimited.
Definition: netcdf_io.F90:1404
integer function, public get_variable_unlimited_dimension_index(fileobj, variable_name, broadcast)
Get the index of a variable's unlimited dimensions.
Definition: netcdf_io.F90:1795
logical function, public netcdf_file_open_wrap(fileobj, path, mode, nc_format, pelist, is_restart, dont_add_res_to_filename)
Wrapper to distinguish interfaces.
Definition: netcdf_io.F90:2086
subroutine, public compressed_start_and_count(fileobj, nelems, npes_start, npes_count)
Gathers a compressed arrays size and offset for each pe.
Definition: netcdf_io.F90:2042
integer function, public get_variable_num_dimensions(fileobj, variable_name, broadcast)
Get the number of dimensions a variable depends on.
Definition: netcdf_io.F90:1624
subroutine, public get_dimension_size(fileobj, dimension_name, dim_size, broadcast)
Get the length of a dimension.
Definition: netcdf_io.F90:1474
subroutine netcdf_add_restart_variable_5d_wrap(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Wrapper to distinguish interfaces.
subroutine netcdf_add_restart_variable_1d_wrap(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Wrapper to distinguish interfaces.
logical function, public global_att_exists(fileobj, attribute_name, broadcast)
Determine if a global attribute exists.
Definition: netcdf_io.F90:1219
subroutine netcdf_add_restart_variable_0d_wrap(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Wrapper to distinguish interfaces.
subroutine netcdf_add_restart_variable_3d_wrap(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Wrapper to distinguish interfaces.
subroutine register_restart_region_3d(fileobj, variable_name, vdata, indices, global_size, pelist, is_root_pe, x_halo, y_halo, jshift, ishift, is_optional)
Registers a regional 3D variable and stores the information needed.
logical function, public dimension_exists(fileobj, dimension_name, broadcast)
Determine if a dimension exists.
Definition: netcdf_io.F90:1368
logical function, public is_registered_to_restart(fileobj, variable_name)
Determine if a variable has been registered to a restart file..
Definition: netcdf_io.F90:2267
subroutine, public register_compressed_dimension(fileobj, dimension_name, npes_corner, npes_nelems)
Add a compressed dimension.
Definition: netcdf_io.F90:954
logical function, public variable_att_exists(fileobj, variable_name, attribute_name, broadcast)
Determine if a variable's attribute exists.
Definition: netcdf_io.F90:1248
subroutine, public get_variable_dimension_names(fileobj, variable_name, dim_names, broadcast)
Get the name of a variable's dimensions.
Definition: netcdf_io.F90:1658
subroutine, public flush_file(fileobj)
flushes the netcdf file into disk
Definition: netcdf_io.F90:2428
subroutine netcdf_add_restart_variable_4d_wrap(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Wrapper to distinguish interfaces.
subroutine, public register_unlimited_compressed_axis(fileobj, dimension_name, dimension_length)
Add a "compressed" unlimited dimension to a netcdf file.
Definition: netcdf_io.F90:867
subroutine, public netcdf_add_variable_wrap(fileobj, variable_name, variable_type, dimensions, chunksizes)
Wrapper to distinguish interfaces.
Definition: netcdf_io.F90:2125
subroutine, public write_restart_bc(fileobj, unlim_dim_level)
Loop through the registered restart variables (including regional variables) and write them to the ne...
Definition: netcdf_io.F90:2362
subroutine, public netcdf_save_restart_wrap(fileobj, unlim_dim_level)
Wrapper to distinguish interfaces.
Definition: netcdf_io.F90:2139
subroutine, public get_variable_names(fileobj, names, broadcast)
Get the names of the variables in a file.
Definition: netcdf_io.F90:1535
subroutine netcdf_add_restart_variable_2d_wrap(fileobj, variable_name, vdata, dimensions, is_optional, chunksizes)
Wrapper to distinguish interfaces.
subroutine, public get_dimension_names(fileobj, names, broadcast)
Get the names of the dimensions in a file.
Definition: netcdf_io.F90:1311
logical function, public check_if_open(fileobj, fname)
Definition: netcdf_io.F90:2289
subroutine, public netcdf_io_init(chksz, header_buffer_val, netcdf_default_format, deflate_level, shuffle)
Accepts the namelist fms2_io_nml variables relevant to netcdf_io_mod.
Definition: netcdf_io.F90:369
integer function, public get_num_variables(fileobj, broadcast)
Determine the number of variables in a file.
Definition: netcdf_io.F90:1508
subroutine, public get_unlimited_dimension_name(fileobj, dimension_name, broadcast)
Get the name of the unlimited dimension.
Definition: netcdf_io.F90:1439
subroutine register_restart_region_2d(fileobj, variable_name, vdata, indices, global_size, pelist, is_root_pe, x_halo, y_halo, jshift, ishift, is_optional)
Registers a regional 2D variable and stores the information needed.
subroutine, public netcdf_file_close_wrap(fileobj)
Wrapper to distinguish interfaces.
Definition: netcdf_io.F90:2116
logical function, public variable_exists(fileobj, variable_name, broadcast)
Determine if a variable exists.
Definition: netcdf_io.F90:1592
integer function, public get_num_dimensions(fileobj, broadcast)
Determine the number of dimensions in a file.
Definition: netcdf_io.F90:1284
The interface is needed to accomodate pgi because it can't handle class * and there was no other way ...
Definition: netcdf_io.F90:357
Type to represent a netCDF file. Can be used with multiple cores but only the root pe will perform an...
Definition: netcdf_io.F90:147
Range type for a netcdf variable.
Definition: netcdf_io.F90:185