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
153 use mo_netcdf,
only : ncdataset, ncvariable
154 use mo_string_utils,
only : num2str
155 use mo_utils,
only : eq
160 integer(i4),
intent(in) :: idomain, nrows, ncols
162 logical,
dimension(:, :),
intent(in) :: mask
164 integer(i4) :: ncells, ilai
167 real(dp),
dimension(:, :, :),
allocatable :: lai0_3d
170 real(dp),
dimension(:, :),
allocatable :: lai0_2d
175 character(256) :: fname
177 type(ncdataset) :: nc
179 type(ncvariable) :: var
182 integer(i4),
dimension(:),
allocatable :: dimen
185 real(dp) :: nodata_value
190 nc = ncdataset(trim(fname),
"r")
191 var = nc%getVariable(
'lai')
194 dimen = var%getShape()
195 if ((dimen(1) .ne. nrows) .or. (dimen(2) .ne. ncols))
then
196 call error_message(
'***ERROR: read_nc: mHM generated x and y are not matching NetCDF dimensions')
198 if (dimen(3) .ne. 12)
then
199 call error_message(
'***ERROR: read_nc: the time dimenion of LAI NetCDF file under the option-1 is not 12')
203 call var%getAttribute(
'_FillValue', nodata_value)
205 call var%getData(lai0_3d)
211 if (any(eq(lai0_3d(:, :, t), nodata_value) .and. (mask)))
then
212 call error_message(
'***ERROR: read_nc: nodata value within domain ', raise=.false.)
213 call error_message(
' boundary in variable: ',
'lai', raise=.false.)
214 call error_message(
' at timestep : ', trim(num2str(t)))
217 if (any((lai0_3d(:, :, t) .lt. 0.0_dp) .AND. mask(:, :)))
then
220 lai0_3d(:, :, t) = max(lai0_3d(:, :, t), 0.0_dp)
223 call error_message(
'***ERROR: read_nc: values in variable lai are lower than ', trim(num2str(0,
'(F7.2)')), raise=.false.)
224 call error_message(
' at timestep : ', trim(num2str(t)), raise=.false.)
225 call error_message(
'File: ', trim(fname), raise=.false.)
226 call error_message(
'Minval at timestep: ', trim(num2str(minval(lai0_3d(:, :, t)),
'(F7.2)')), raise=.false.)
227 call error_message(
'Total minval: ', trim(num2str(minval(lai0_3d(:, :, :)),
'(F7.2)')))
230 if (any((lai0_3d(:, :, t) .gt. 30.0_dp) .AND. mask(:, :)))
then
231 call error_message(
'***ERROR: read_nc: values in variable lai are greater than ', trim(num2str(30,
'(F7.2)')), raise=.false.)
232 call error_message(
' at timestep : ', trim(num2str(t)), raise=.false.)
233 call error_message(
'File: ', trim(fname), raise=.false.)
234 call error_message(
'Maxval at timestep: ', trim(num2str(maxval(lai0_3d(:, :, t)),
'(F7.2)')), raise=.false.)
235 call error_message(
'Total maxval: ', trim(num2str(maxval(lai0_3d(:, :, :)),
'(F7.2)')))
243 nlai =
size(lai0_3d, 3)
247 allocate(lai0_2d(ncells,
nlai))
249 lai0_2d(:, ilai) = pack(lai0_3d(:, :, ilai), mask = mask(:, :))
256 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.