MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
LoadNCInput.F90
Go to the documentation of this file.
1 !> @brief This module contains the LoadNCInputModule
2 !!
3 !! Access interfaces for netcdf reads optioned from a
4 !! traditional modflow 6 input. These interfaces throw
5 !! an error when netcdf libraries aren't compiled in.
6 !<
8 
9  use kindmodule, only: dp, i4b, lgp
13 #if defined(__WITH_NETCDF__)
15 #endif
16 
17  implicit none
18  private
19  public :: netcdf_read_array
20 
22  module procedure nc_read_int1d, nc_read_int2d, &
25  end interface netcdf_read_array
26 
27 contains
28 
29 #if !defined(__WITH_NETCDF__)
30  !> @brief Set an error and exit if NetCDF libraries aren't available
31  !<
32  subroutine error_and_exit(tagname, input_fname)
33  use simvariablesmodule, only: errmsg
35  character(len=*), intent(in) :: tagname
36  character(len=*), intent(in) :: input_fname
37  write (errmsg, '(a)') &
38  'Cannot load NetCDF array for variable "'//trim(tagname)// &
39  '". NetCDF libraries are not available. Ensure Extended MODFLOW 6 in use.'
40  call store_error(errmsg)
41  call store_error_filename(input_fname)
42  end subroutine error_and_exit
43 #endif
44 
45  !> @brief Read a NetCDF integer 1d array
46  !<
47  subroutine nc_read_int1d(int1d, mshape, idt, mf6_input, nc_vars, input_fname, &
48  iout, kper)
49  integer(I4B), dimension(:), pointer, contiguous, intent(in) :: int1d
50  integer(I4B), dimension(:), contiguous, pointer, intent(in) :: mshape !< model shape
51  type(inputparamdefinitiontype), intent(in) :: idt !< input data type object describing this record
52  type(modflowinputtype), intent(in) :: mf6_input
53  type(ncpackagevarstype), pointer, intent(in) :: nc_vars
54  character(len=*), intent(in) :: input_fname
55  integer(I4B), intent(in) :: iout
56  integer(I4B), optional, intent(in) :: kper
57 #if defined(__WITH_NETCDF__)
58  call netcdf_array_load(int1d, mshape, idt, mf6_input, nc_vars, input_fname, &
59  iout, kper)
60 #else
61  call error_and_exit(idt%tagname, input_fname)
62 #endif
63  end subroutine nc_read_int1d
64 
65  !> @brief Read a NetCDF integer 2d array
66  !<
67  subroutine nc_read_int2d(int2d, mshape, idt, mf6_input, nc_vars, input_fname, &
68  iout)
69  integer(I4B), dimension(:, :), pointer, contiguous, intent(in) :: int2d
70  integer(I4B), dimension(:), contiguous, pointer, intent(in) :: mshape !< model shape
71  type(inputparamdefinitiontype), intent(in) :: idt !< input data type object describing this record
72  type(modflowinputtype), intent(in) :: mf6_input
73  type(ncpackagevarstype), pointer, intent(in) :: nc_vars
74  character(len=*), intent(in) :: input_fname
75  integer(I4B), intent(in) :: iout
76 #if defined(__WITH_NETCDF__)
77  call netcdf_array_load(int2d, mshape, idt, mf6_input, nc_vars, input_fname, &
78  iout)
79 #else
80  call error_and_exit(idt%tagname, input_fname)
81 #endif
82  end subroutine nc_read_int2d
83 
84  !> @brief Read a NetCDF integer 3d array
85  !<
86  subroutine nc_read_int3d(int3d, mshape, idt, mf6_input, nc_vars, input_fname, &
87  iout)
88  integer(I4B), dimension(:, :, :), pointer, contiguous, intent(in) :: int3d
89  integer(I4B), dimension(:), contiguous, pointer, intent(in) :: mshape !< model shape
90  type(inputparamdefinitiontype), intent(in) :: idt !< input data type object describing this record
91  type(modflowinputtype), intent(in) :: mf6_input
92  type(ncpackagevarstype), pointer, intent(in) :: nc_vars
93  character(len=*), intent(in) :: input_fname
94  integer(I4B), intent(in) :: iout
95 #if defined(__WITH_NETCDF__)
96  call netcdf_array_load(int3d, mshape, idt, mf6_input, nc_vars, input_fname, &
97  iout)
98 #else
99  call error_and_exit(idt%tagname, input_fname)
100 #endif
101  end subroutine nc_read_int3d
102 
103  !> @brief Read a NetCDF double 1d array
104  !<
105  subroutine nc_read_dbl1d(dbl1d, mshape, idt, mf6_input, nc_vars, input_fname, &
106  iout, kper, iaux)
107  real(DP), dimension(:), pointer, contiguous, intent(in) :: dbl1d
108  integer(I4B), dimension(:), contiguous, pointer, intent(in) :: mshape !< model shape
109  type(inputparamdefinitiontype), intent(in) :: idt !< input data type object describing this record
110  type(modflowinputtype), intent(in) :: mf6_input
111  type(ncpackagevarstype), pointer, intent(in) :: nc_vars
112  character(len=*), intent(in) :: input_fname
113  integer(I4B), intent(in) :: iout
114  integer(I4B), optional, intent(in) :: kper
115  integer(I4B), optional, intent(in) :: iaux
116 #if defined(__WITH_NETCDF__)
117  call netcdf_array_load(dbl1d, mshape, idt, mf6_input, nc_vars, input_fname, &
118  iout, kper=kper, iaux=iaux)
119 #else
120  call error_and_exit(idt%tagname, input_fname)
121 #endif
122  end subroutine nc_read_dbl1d
123 
124  !> @brief Read a NetCDF double 2d array
125  !<
126  subroutine nc_read_dbl2d(dbl2d, mshape, idt, mf6_input, nc_vars, input_fname, &
127  iout)
128  real(DP), dimension(:, :), pointer, contiguous, intent(in) :: dbl2d
129  integer(I4B), dimension(:), contiguous, pointer, intent(in) :: mshape !< model shape
130  type(inputparamdefinitiontype), intent(in) :: idt !< input data type object describing this record
131  type(modflowinputtype), intent(in) :: mf6_input
132  type(ncpackagevarstype), pointer, intent(in) :: nc_vars
133  character(len=*), intent(in) :: input_fname
134  integer(I4B), intent(in) :: iout
135 #if defined(__WITH_NETCDF__)
136  call netcdf_array_load(dbl2d, mshape, idt, mf6_input, nc_vars, input_fname, &
137  iout)
138 #else
139  call error_and_exit(idt%tagname, input_fname)
140 #endif
141  end subroutine nc_read_dbl2d
142 
143  !> @brief Read a NetCDF double 3d array
144  !<
145  subroutine nc_read_dbl3d(dbl3d, mshape, idt, mf6_input, nc_vars, input_fname, &
146  iout)
147  real(DP), dimension(:, :, :), pointer, contiguous, intent(in) :: dbl3d
148  integer(I4B), dimension(:), contiguous, pointer, intent(in) :: mshape !< model shape
149  type(inputparamdefinitiontype), intent(in) :: idt !< input data type object describing this record
150  type(modflowinputtype), intent(in) :: mf6_input
151  type(ncpackagevarstype), pointer, intent(in) :: nc_vars
152  character(len=*), intent(in) :: input_fname
153  integer(I4B), intent(in) :: iout
154 #if defined(__WITH_NETCDF__)
155  call netcdf_array_load(dbl3d, mshape, idt, mf6_input, nc_vars, input_fname, &
156  iout)
157 #else
158  call error_and_exit(idt%tagname, input_fname)
159 #endif
160  end subroutine nc_read_dbl3d
161 
162 end module loadncinputmodule
This module contains the InputDefinitionModule.
This module defines variable data types.
Definition: kind.f90:8
This module contains the LoadNCInputModule.
Definition: LoadNCInput.F90:7
subroutine nc_read_dbl3d(dbl3d, mshape, idt, mf6_input, nc_vars, input_fname, iout)
Read a NetCDF double 3d array.
subroutine nc_read_int1d(int1d, mshape, idt, mf6_input, nc_vars, input_fname, iout, kper)
Read a NetCDF integer 1d array.
Definition: LoadNCInput.F90:49
subroutine error_and_exit(tagname, input_fname)
Set an error and exit if NetCDF libraries aren't available.
Definition: LoadNCInput.F90:33
subroutine nc_read_int2d(int2d, mshape, idt, mf6_input, nc_vars, input_fname, iout)
Read a NetCDF integer 2d array.
Definition: LoadNCInput.F90:69
subroutine nc_read_int3d(int3d, mshape, idt, mf6_input, nc_vars, input_fname, iout)
Read a NetCDF integer 3d array.
Definition: LoadNCInput.F90:88
subroutine nc_read_dbl1d(dbl1d, mshape, idt, mf6_input, nc_vars, input_fname, iout, kper, iaux)
Read a NetCDF double 1d array.
subroutine nc_read_dbl2d(dbl2d, mshape, idt, mf6_input, nc_vars, input_fname, iout)
Read a NetCDF double 2d array.
This module contains the ModflowInputModule.
Definition: ModflowInput.f90:9
This module contains the NCArrayReaderModule.
This module contains the NCFileVarsModule.
Definition: NCFileVars.f90:7
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition: Sim.f90:203
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=maxcharlen) errmsg
error message string
derived type for storing input definition for a file
Type describing input variables for a package in NetCDF file.
Definition: NCFileVars.f90:22