FMS  2024.03
Flexible Modeling System
fms_io_unstructured_file_unit.inc
1 !***********************************************************************
2 !* GNU Lesser General Public License
3 !*
4 !* This file is part of the GFDL Flexible Modeling System (FMS).
5 !*
6 !* FMS is free software: you can redistribute it and/or modify it under
7 !* the terms of the GNU Lesser General Public License as published by
8 !* the Free Software Foundation, either version 3 of the License, or (at
9 !* your option) any later version.
10 !*
11 !* FMS is distributed in the hope that it will be useful, but WITHOUT
12 !* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 !* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 !* for more details.
15 !*
16 !* You should have received a copy of the GNU Lesser General Public
17 !* License along with FMS. If not, see <http://www.gnu.org/licenses/>.
18 !***********************************************************************
19 !----------
20 !ug support
21 !> @addtogroup fms_io_mod
22 !> @{
23 
24 !>Find the file unit for an inputted file, searching for its variants. If the
25 !!file is not found, then throw a fatal error.
26 subroutine fms_io_unstructured_file_unit(filename, &
27  funit, &
28  domain)
29 
30  !Inputs/Outputs
31  character(len=*),intent(in) :: filename !<The name of a file.
32  integer(INT_KIND),intent(out) :: funit !<The file unit for the input file.
33  type(domainug),intent(in) :: domain !<An unstructured mpp domain.
34 
35  !Local variables
36  logical(INT_KIND) :: found_file !<Flag telling if the file exists.
37  character(len=256) :: actual_file !<Name of the found file.
38  logical(INT_KIND) :: read_dist !<Flag telling if the file is "distributed" (has IO domain
39  !! tile id appended to the end).
40  integer(INT_KIND) :: nfile !<Index of the inputted file in the "files_read" module array.
41 
42  !Get the actual name of the file, searching for all possible variants. If
43  !the file is not found, then throw a fatal error.
44  found_file = fms_io_unstructured_get_file_name(filename, &
45  actual_file, &
46  read_dist, &
47  domain)
48  if (.not. found_file) then
49  call mpp_error(fatal, &
50  "fms_io_unstructured_file_unit: file " &
51  //trim(filename)//" and corresponding variants are" &
52  //" not found.")
53  endif
54 
55  !Get the file unit for the input file.
56  call fms_io_unstructured_get_file_unit(actual_file, &
57  funit, &
58  nfile, &
59  read_dist, &
60  domain)
61 
62  return
63 end subroutine fms_io_unstructured_file_unit
64 !> @}
logical(int_kind) function fms_io_unstructured_get_file_name(orig_file, actual_file, read_dist, domain)
For an inputted file name, check if it or any of its variants exist. For a file named "foo",...
subroutine fms_io_unstructured_get_file_unit(filename, funit, index_file, read_dist, domain)
Return the file unit and index in the "files_read" module array for the inputted file....
subroutine fms_io_unstructured_file_unit(filename, funit, domain)
Find the file unit for an inputted file, searching for its variants. If the file is not found,...