15 USE mo_kind,
ONLY : i4, dp
17 use mo_message,
only: message, error_message
66 use mo_append,
only : append, paste
67 use mo_constants,
only : yearmonths
84 use mo_string_utils,
only : num2str
85 use mo_timer,
only : timer_get, timer_start, &
90 type(
period),
dimension(:),
intent(in),
optional ::
laiper
93 integer(i4) :: domainid, idomain, ivar, ihorizon, imon,
itimer, ll
102 character(256) :: fname
104 real(dp),
dimension(:, :),
allocatable :: data_dp_2d
106 integer(i4),
dimension(:, :),
allocatable :: data_i4_2d
108 integer(i4),
dimension(:, :),
allocatable :: datamatrix_i4
110 logical,
dimension(:, :),
allocatable :: mask_2d
112 integer(i4),
dimension(:),
allocatable :: dummy_i4
114 type(
grid),
pointer :: level0_idomain
116 real(dp),
parameter :: slope_minval = 0.01_dp
118 real(dp),
parameter :: aspect_minval = 1.00_dp
121 call message(
' Reading data ...')
125 call message(
' Reading dem and lcover ...')
156 call message(
' Reading data for domain: ', trim(adjustl(num2str(domainid))),
' ...')
159 if (
domainmeta%L0DataFrom(idomain) < idomain)
then
161 call message(
' Using data of domain ', &
163 trim(adjustl(num2str(domainid))),
'...')
173 nvars_real :
do ivar = 1, 2
176 call message(
' Reading slope ...')
180 call message(
' Reading aspect ...')
187 level0_idomain%nrows, level0_idomain%ncols, level0_idomain%xllcorner, &
188 level0_idomain%yllcorner, level0_idomain%cellsize, data_dp_2d, mask_2d)
190 data_dp_2d = merge(data_dp_2d,
nodata_dp, mask_2d)
194 call append(
l0_slope, pack(data_dp_2d, level0_idomain%mask))
197 call append(
l0_asp, pack(data_dp_2d, level0_idomain%mask))
200 deallocate(data_dp_2d, mask_2d)
210 call message(
' Reading soil ids ...')
219 write(fname, 172) ihorizon
220 172
format(
'soil_class_horizon_', i2.2,
'.asc')
221 fname = trim(adjustl(
dirmorpho(idomain))) // trim(adjustl(fname))
224 level0_idomain%nrows, level0_idomain%ncols, level0_idomain%xllcorner, &
225 level0_idomain%yllcorner, level0_idomain%cellsize, data_i4_2d, mask_2d)
227 data_i4_2d = merge(data_i4_2d,
nodata_i4, mask_2d)
228 call paste(datamatrix_i4, pack(data_i4_2d, level0_idomain%mask),
nodata_i4)
229 deallocate(data_i4_2d)
232 deallocate(datamatrix_i4)
238 level0_idomain%nrows, level0_idomain%ncols, level0_idomain%xllcorner, &
239 level0_idomain%yllcorner, level0_idomain%cellsize, data_i4_2d, mask_2d)
241 data_i4_2d = merge(data_i4_2d,
nodata_i4, mask_2d)
242 call append(
l0_geounit, pack(data_i4_2d, level0_idomain%mask))
243 deallocate(data_i4_2d, mask_2d)
246 call message(
' Reading LAI ...')
254 nlai = int(yearmonths, i4)
262 level0_idomain%nrows, level0_idomain%ncols, level0_idomain%xllcorner, &
263 level0_idomain%yllcorner, level0_idomain%cellsize, data_i4_2d, mask_2d)
265 data_i4_2d = merge(data_i4_2d,
nodata_i4, mask_2d)
266 allocate(dummy_i4(count(level0_idomain%mask)))
267 dummy_i4 = pack(data_i4_2d, level0_idomain%mask)
268 deallocate(data_i4_2d, mask_2d)
272 allocate(data_dp_2d(count(level0_idomain%mask),
nlai))
275 do ll = 1,
size(
lailut, dim = 1)
276 data_dp_2d(:, imon) = merge(
lailut(ll, imon), data_dp_2d(:, imon), dummy_i4(:) .EQ.
laiunitlist(ll))
280 deallocate(dummy_i4, data_dp_2d)
291 call message(
' Reading latitude/logitude ...')
292 call read_latlon(idomain,
"lon_l0",
"lat_l0",
"level0", level0_idomain)
295 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F9.3)')),
' seconds.')
300 call message(
' in ', trim(num2str(timer_get(
itimer),
'(F9.3)')),
' seconds.')
321 if (.not. any(dummy_i4 .EQ.
geounitlist(ivar)))
then
324 call message(
'***WARNING: Geological unit ', trim(adjustl(num2str(
geounitlist(ivar)))))
325 call message(
' is not appearing in study domain.')
370 use mo_orderpack,
only : unista
371 use mo_string_utils,
only : num2str
376 integer(i4),
dimension(:),
intent(in) :: data
379 integer(i4),
dimension(:),
intent(in) :: lookuptable
382 character(*),
intent(in) :: filename
385 integer(i4),
dimension(:),
allocatable,
intent(out),
optional :: unique_values
387 integer(i4) :: n_unique_elements
389 integer(i4) :: ielement
391 integer(i4),
dimension(:),
allocatable :: temp
394 allocate(temp(
size(
data, 1)))
399 call unista(temp, n_unique_elements)
401 do ielement = 1, n_unique_elements
402 if ( temp(ielement) ==
nodata_i4 )
call error_message( &
403 '***ERROR: Class ', trim(adjustl(num2str(temp(ielement)))), &
404 ' was searched in ', trim(adjustl(filename)), &
405 ' which indicates a masking problem!' &
407 if (.not. any(lookuptable .EQ. temp(ielement)))
then
408 call error_message(
'***ERROR: Class ', trim(adjustl(num2str(temp(ielement)))),
' is missing', raise=.false.)
409 call error_message(
' in input file ', trim(adjustl(filename)),
' ...')
414 if (
present(unique_values))
then
415 allocate(unique_values(n_unique_elements))
416 unique_values(:) = temp(1 : n_unique_elements)
Reads spatial data files of nc or ASCII format.
Provides constants commonly used by mHM, mRM and MPR.
real(dp), parameter, public nodata_dp
integer(i4), parameter, public nodata_i4
subroutine, public read_lcover
TODO: add description.
subroutine, public read_dem
TODO: add description.
Provides common types needed by mHM, mRM and/or mpr.
Provides structures needed by mHM, mRM and/or mpr.
real(dp), dimension(:, :), allocatable, target, public global_parameters
type(domain_meta), public domainmeta
character(256), public dircommonfiles
character(256), dimension(:), allocatable, public dirmorpho
integer(i4), dimension(nprocesses, 3), public processmatrix
type(grid), dimension(:), allocatable, target, public level0
Provides file names and units for mRM.
character(len=*), parameter file_soil_database_1
Soil database file (iFlag_soilDB = 1)
integer, parameter usoilclass
Unit for soil classes input data file.
character(len=*), parameter file_slope
slope input data file
integer, parameter uaspect
Unit for aspect input data file.
character(len=*), parameter file_hydrogeoclass
hydrogeological classes input data file
character(len=*), parameter file_aspect
aspect input data file
integer, parameter uslope
Unit for slope input data file.
integer, parameter ulailut
Unit for LAI classes lookup table file.
character(len=*), parameter file_laiclass
LAI classes input data file.
character(len=*), parameter file_lailut
LAI classes lookup table file.
integer, parameter ulaiclass
Unit for LAI input data file.
integer, parameter uhydrogeoclass
Unit for hydrogeological classes input data file.
character(len=*), parameter file_soil_database
Soil database file (iFlag_soilDB = 0) = classical mHM format.
integer, parameter ugeolut
Unit for geological formation lookup table file.
character(len=*), parameter file_soilclass
soil classes input data file
character(len=*), parameter file_geolut
geological formation lookup table file
Global variables for mpr only.
integer(i4), public ngeounits
integer(i4), dimension(:), allocatable, public geounitkar
integer(i4), dimension(:), allocatable, public geounitlist
type(period), dimension(:), allocatable, public laiper
integer(i4), dimension(:), allocatable, public laiunitlist
integer(i4), dimension(:), allocatable, public l0_geounit
real(dp), dimension(:), allocatable, public l0_asp
real(dp), dimension(:, :), allocatable, public lailut
integer(i4), public nsoilhorizons_mhm
type(soiltype), public soildb
integer(i4), public nlaiclass
integer(i4), dimension(:, :), allocatable, public l0_soilid
real(dp), dimension(:, :), allocatable, public l0_gridded_lai
real(dp), dimension(:), allocatable, public laiboundaries
integer(i4), public iflag_soildb
integer(i4), public timestep_lai_input
real(dp), dimension(:), allocatable, public l0_slope
Prepare daily LAI fields (e.g., MODIS data) for mHM.
subroutine, public prepare_gridded_mean_monthly_lai_data(idomain, nrows, ncols, mask)
prepare_gridded_mean_monthly_LAI_data
subroutine, public prepare_gridded_daily_lai_data(idomain, nrows, ncols, mask, laiper_idomain)
Prepare gridded daily LAI data.
reading latitude and longitude coordinates for each domain
subroutine, public read_latlon(ii, lon_var_name, lat_var_name, level_name, level)
reads latitude and longitude coordinates
Routines reading lookup tables (lut).
subroutine, public read_lai_lut(filename, fileunit, nlai, laiidlist, lai)
Reads LUT containing LAI information.
subroutine, public read_geoformation_lut(filename, fileunit, ngeo, geo_unit, geo_karstic)
Reads LUT containing geological formation information.
Reads spatial input data.
Wrapper for all reading routines.
subroutine check_consistency_lut_map(data, lookuptable, filename, unique_values)
Checks if classes in input maps appear in look up tables.
subroutine, public read_data(laiper)
Reads data.
Generating soil database from input file.
subroutine, public read_soil_lut(filename)
Reads the soil LUT file.