63 use mo_append,
only : append
72 integer(i4),
intent(in) :: idomain, nrows, ncols
74 logical,
dimension(:, :),
intent(in) :: mask
76 type(
period),
intent(in),
optional :: laiper_idomain
78 integer(i4) :: ncells, ilai
81 real(dp),
dimension(:, :, :),
allocatable :: lai0_3d
84 real(dp),
dimension(:, :),
allocatable :: lai0_2d
93 'lai', mask, lai0_3d, target_period = laiper_idomain, &
96 call error_message(
'***ERROR: No recognized input format')
104 nlai =
size(lai0_3d, 3)
108 allocate(lai0_2d(ncells,
nlai))
111 lai0_2d(:, ilai) = pack(lai0_3d(:, :, ilai), mask = mask(:, :))
118 deallocate(lai0_2d, lai0_3d)
150 use mo_append,
only : append
152 use mo_ncread,
only : get_ncdim, get_ncvar, get_ncvaratt
153 use mo_string_utils,
only : num2str
154 use mo_utils,
only : eq
159 integer(i4),
intent(in) :: idomain, nrows, ncols
161 logical,
dimension(:, :),
intent(in) :: mask
163 integer(i4) :: ncells, ilai
166 real(dp),
dimension(:, :, :),
allocatable :: lai0_3d
169 real(dp),
dimension(:, :),
allocatable :: lai0_2d
174 character(256) :: fname
177 character(256) :: attvalues
180 integer(i4) :: datatype
183 integer(i4),
dimension(5) :: dimen
186 real(dp) :: nodata_value
192 dimen = get_ncdim(trim(fname),
'lai')
193 if ((dimen(1) .ne. nrows) .or. (dimen(2) .ne. ncols))
then
194 call error_message(
'***ERROR: read_nc: mHM generated x and y are not matching NetCDF dimensions')
196 if (dimen(3) .ne. 12)
then
197 call error_message(
'***ERROR: read_nc: the time dimenion of LAI NetCDF file under the option-1 is not 12')
201 call get_ncvaratt(trim(fname),
'lai',
'_FillValue', attvalues, dtype = datatype)
203 read(attvalues, *) nodata_value
205 call get_ncvar(trim(fname),
'lai', lai0_3d)
210 if (any(eq(lai0_3d(:, :, t), nodata_value) .and. (mask)))
then
211 call error_message(
'***ERROR: read_nc: nodata value within domain ', raise=.false.)
212 call error_message(
' boundary in variable: ',
'lai', raise=.false.)
213 call error_message(
' at timestep : ', trim(num2str(t)))
216 if (any((lai0_3d(:, :, t) .lt. 0.0_dp) .AND. mask(:, :)))
then
217 call error_message(
'***ERROR: read_nc: values in variable lai are lower than ', trim(num2str(0,
'(F7.2)')), raise=.false.)
218 call error_message(
' at timestep : ', trim(num2str(t)), raise=.false.)
219 call error_message(
'File: ', trim(fname), raise=.false.)
220 call error_message(
'Minval at timestep: ', trim(num2str(minval(lai0_3d(:, :, t)),
'(F7.2)')), raise=.false.)
221 call error_message(
'Total minval: ', trim(num2str(minval(lai0_3d(:, :, :)),
'(F7.2)')))
224 if (any((lai0_3d(:, :, t) .gt. 30.0_dp) .AND. mask(:, :)))
then
225 call error_message(
'***ERROR: read_nc: values in variable lai are greater than ', trim(num2str(30,
'(F7.2)')), raise=.false.)
226 call error_message(
' at timestep : ', trim(num2str(t)), raise=.false.)
227 call error_message(
'File: ', trim(fname), raise=.false.)
228 call error_message(
'Maxval at timestep: ', trim(num2str(maxval(lai0_3d(:, :, t)),
'(F7.2)')), raise=.false.)
229 call error_message(
'Total maxval: ', trim(num2str(maxval(lai0_3d(:, :, :)),
'(F7.2)')))
237 nlai =
size(lai0_3d, 3)
241 allocate(lai0_2d(ncells,
nlai))
243 lai0_2d(:, ilai) = pack(lai0_3d(:, :, ilai), mask = mask(:, :))
250 deallocate(lai0_2d, lai0_3d)
subroutine, public read_nc(folder, nrows, ncols, varname, mask, data, target_period, lower, upper, nctimestep, filename, nocheck, maskout, is_meteo, bound_error, ntstepforcingday)
Reads forcing input in NetCDF file format.