diff --git a/src/extpar_consistency_check.f90 b/src/extpar_consistency_check.f90 index e2ce9e88..379878b5 100644 --- a/src/extpar_consistency_check.f90 +++ b/src/extpar_consistency_check.f90 @@ -176,14 +176,29 @@ PROGRAM extpar_consistency_check & horizon_topo, & & skyview_topo, & & sgsl, & - & allocate_topo_target_fields + & allocate_topo_target_fields, & + & fr_land_topo_globe, & + & hh_topo_globe, & + & hh_topo_max_globe, & + & hh_topo_min_globe, & + & stdh_topo_globe, & + & theta_topo_globe, & + & aniso_topo_globe, & + & slope_topo_globe, & + & z0_topo_globe, & + & slope_asp_topo_globe, & + & slope_ang_topo_globe, & + & horizon_topo_globe, & + & skyview_topo_globe, & + & sgsl_globe, & + & allocate_topo_target_fields_globe USE mo_topo_output_nc, ONLY: read_netcdf_buffer_topo USE mo_topo_routines, ONLY: read_namelists_extpar_orography, & & read_namelists_extpar_scale_sep - USE mo_topo_data, ONLY: lradtopo, nhori, max_tiles, itopo_type, & + USE mo_topo_data, ONLY: lradtopo, lradtopo_globe, nhori, nhori_globe, max_tiles, itopo_type, itopo_type_globe, & & radius, min_circ_cov, max_missing, itype_scaling USE mo_flake_routines, ONLY: read_namelists_extpar_flake @@ -343,18 +358,23 @@ PROGRAM extpar_consistency_check & grib_output_filename, & & grib_sample, & & namelist_file, & !< filename with namelists for for EXTPAR settings + & namelist_file_globe, & !< filename with namelists for for EXTPAR settings ! soil & soil_buffer_file, & !< name for soil buffer file & raw_data_soil_path, & !< path to raw data & raw_data_soil_filename, & !< filename soil raw data - ! orography - & orography_output_file, & + & raw_data_deep_soil_filename, & !< filename deep soil raw data + ! orography & orography_buffer_file, & !< name for orography buffer file & raw_data_orography_path, & !< path to raw data - ! subgrid-scale slope + & orography_buffer_file_globe, & !< name for orography buffer file + & raw_data_orography_path_globe, & !< path to raw data + ! subgrid-scale slope & sgsl_files(1:max_tiles), & !< filenames globe raw data & sgsl_buffer_file, & !< name for orography buffer file - ! land use + & sgsl_files_globe(1:max_tiles), & !< filenames globe raw data + & sgsl_buffer_file_globe, & !< name for orography buffer file + ! land use & raw_data_lu_path, & !< path to raw data & raw_data_lu_filename(1:max_tiles_lu), & !< filename glc2000 raw data !_br 21.02.14 & name_lookup_table_lu, & !< name for look up table @@ -408,6 +428,7 @@ PROGRAM extpar_consistency_check ! aerosol optical thickness & aot_buffer_file, & !< name for aerosol buffer file & topo_files(1:max_tiles), & !< filenames globe raw data + & topo_files_globe(1:max_tiles), & !< filenames globe raw data ! flake & raw_data_flake_path, & & raw_data_flake_filename, & @@ -427,6 +448,8 @@ PROGRAM extpar_consistency_check INTEGER (KIND=i4) :: fill_value_int, & !< value for undefined integer & ntiles_column, & & ntiles_row, & + & ntiles_column_globe, & + & ntiles_row_globe, & & it_cl_type, & & isoil_data, & & ntiles_isa, & @@ -471,10 +494,13 @@ PROGRAM extpar_consistency_check LOGICAL :: last=.FALSE., & ! in TCL leave loop & foundtcl=.FALSE., & ! in TCL - & lsso_param,lsubtract_mean_slope, & + & lsso_param, lsso_param_globe, & + & lsubtract_mean_slope, lsubtract_mean_slope_globe, & + & ldeep_soil, & & l_use_isa =.FALSE., & !< flag if additional urban data are present & l_use_ahf =.FALSE., & !< flag if additional urban data are present & l_use_sgsl=.FALSE., & !< flag if sgsl is used in topo + & l_use_sgsl_globe=.FALSE., & !< flag if sgsl is used in topo & l_preproc_oro=.FALSE., & & l_use_glcc=.FALSE., & !< flag if additional glcc data are present & l_use_emiss=.FALSE., &!< flag if additional CAMEL emissivity data are present @@ -492,7 +518,10 @@ PROGRAM extpar_consistency_check & lfilter_oro, & & lscale_file=.FALSE., & & lxso_first, & - & l_use_corine + & l_use_corine, & + & status_ASTER, & + & status_MERIT, & + & status_GLOBE REAL (KIND=wp) :: t2mclim_hc, & @@ -588,7 +617,9 @@ PROGRAM extpar_consistency_check ! Get lsso_param from namelist - namelist_file = 'INPUT_ORO' + namelist_file = 'INPUT_ORO_ASTER' + inquire(file=namelist_file, exist=status_ASTER) + IF (status_ASTER .eqv. .TRUE.) THEN CALL read_namelists_extpar_orography(namelist_file, & & raw_data_orography_path,& & topo_files, & @@ -601,9 +632,8 @@ PROGRAM extpar_consistency_check & lsso_param, & & lsubtract_mean_slope, & & orography_buffer_file, & - & orography_output_file, & & sgsl_buffer_file) - + IF (l_use_sgsl) THEN !-------------------------------------------------------------------------- !-------------------------------------------------------------------------- @@ -611,7 +641,79 @@ PROGRAM extpar_consistency_check CALL logging%warning( 'Subgrid-slope (SGSL) active') CALL logging%info( '') ENDIF + ENDIF + + namelist_file = 'INPUT_ORO_MERIT' + inquire(file=namelist_file, exist=status_MERIT) + IF (status_MERIT .eqv. .TRUE.) THEN + CALL logging%info( '') + CALL logging%warning( 'MERIT Orography exists: ') + CALL logging%info( '') + + CALL read_namelists_extpar_orography(namelist_file, & + & raw_data_orography_path,& + & topo_files, & + & sgsl_files, & + & ntiles_column, & + & ntiles_row, & + & itopo_type, & + & l_use_sgsl, & + & l_preproc_oro, & + & lsso_param, & + & lsubtract_mean_slope, & + & orography_buffer_file, & + & sgsl_buffer_file) + + IF (l_use_sgsl) THEN + !-------------------------------------------------------------------------- + !-------------------------------------------------------------------------- + CALL logging%info( '') + CALL logging%warning( 'Subgrid-slope (SGSL) active') + CALL logging%info( '') + ENDIF +END IF + + namelist_file = 'INPUT_ORO_GLOBE' + inquire(file=namelist_file, exist=status_GLOBE) ! GLOBE orography needed for correction + IF (status_GLOBE .eqv. .TRUE.) THEN + namelist_file_globe = 'INPUT_ORO_GLOBE' + + CALL logging%info( '') + CALL logging%warning( 'GLOBE Orography exists: ') + CALL logging%info( '') + IF (status_MERIT .eqv. .TRUE.) THEN + CALL read_namelists_extpar_orography(namelist_file_globe, & + & raw_data_orography_path_globe,& + & topo_files_globe, & + & sgsl_files_globe, & + & ntiles_column_globe, & + & ntiles_row_globe, & + & itopo_type_globe, & + & l_use_sgsl_globe, & + & l_preproc_oro, & + & lsso_param_globe, & + & lsubtract_mean_slope_globe, & + & orography_buffer_file_globe, & + & sgsl_buffer_file_globe) + ELSE + CALL read_namelists_extpar_orography(namelist_file, & + & raw_data_orography_path,& + & topo_files, & + & sgsl_files, & + & ntiles_column, & + & ntiles_row, & + & itopo_type, & + & l_use_sgsl, & + & l_preproc_oro, & + & lsso_param, & + & lsubtract_mean_slope, & + & orography_buffer_file, & + & sgsl_buffer_file) + END IF + END IF + + namelist_file = 'INPUT_SOIL' CALL read_namelists_extpar_soil(namelist_file, & isoil_data, & @@ -907,6 +1009,10 @@ PROGRAM extpar_consistency_check CALL allocate_topo_target_fields(tg,nhori,l_use_sgsl, l_use_array_cache) + IF (status_GLOBE .eqv. .TRUE.) THEN + CALL allocate_topo_target_fields_globe(tg,nhori_globe,l_use_sgsl_globe, l_use_array_cache) + END IF + CALL allocate_aot_target_fields(tg, ntime_aot, ntype_aot, l_use_array_cache) CALL allocate_cru_target_fields(tg, l_use_array_cache) @@ -1151,6 +1257,33 @@ PROGRAM extpar_consistency_check & skyview_topo, & & sgsl) + IF (status_MERIT .eqv. .TRUE..AND.status_GLOBE .eqv. .TRUE.) THEN + CALL logging%info('Orography - GLOBE') + CALL logging%info(orography_buffer_file_globe) + + CALL read_netcdf_buffer_topo(orography_buffer_file_globe, & + & tg, & + & igrid_type, & + & fr_land_topo_globe, & + & hh_topo_globe, & + & stdh_topo_globe, & + & z0_topo_globe, & + & lradtopo_globe, & + & lsso_param_globe, & + & l_use_sgsl_globe, & + & nhori_globe, & + & hh_topo_max_globe, & + & hh_topo_min_globe, & + & theta_topo_globe, & + & aniso_topo_globe, & + & slope_topo_globe, & + & slope_asp_topo_globe, & + & slope_ang_topo_globe, & + & horizon_topo_globe, & + & skyview_topo_globe, & + & sgsl_globe) +END IF + IF ( (igrid_type == igrid_icon) .AND. (.NOT. lsso_param) ) THEN ! Provide also SSO fields, filled with zero theta_topo = 0._wp @@ -1233,15 +1366,41 @@ PROGRAM extpar_consistency_check !------------------------------------------------------------------------- CALL logging%info( '') - CALL logging%info('Landuse') + CALL logging%info('MERIT ORO-FIX') !determine land-sea mask + ! Add MERIT workaround from script: + ! merit_merge_flag='true' + !if (( max_lat_dom > -60.0 && min_lat_dom > -60.0 || + ! max_lat_dom < -62.0 && min_lat_dom < -62.0 )) ; then + ! merit_merge_flag='' + !fi + + IF (status_MERIT .eqv. .TRUE..AND.status_GLOBE .eqv. .TRUE.) THEN + fr_land_topo=fr_land_topo_globe + + WHERE (lat_geo <= -60.0 .AND. lat_geo >= -62.0) + fr_land_topo= fr_land_topo_globe + hh_topo = hh_topo_globe + hh_topo_max = hh_topo_max_globe + hh_topo_min = hh_topo_min_globe + stdh_topo = stdh_topo_globe + theta_topo = theta_topo_globe + aniso_topo = aniso_topo_globe + slope_topo = slope_topo_globe + ENDWHERE + +END IF + IF (l_use_glcc) THEN WHERE (lat_geo <=lu_data_southern_boundary) ! glc2000 and globcover 2009 exclude Antarctica fr_land_lu = fr_land_glcc !fr_land_topo ENDWHERE ENDIF + CALL logging%info( '') + CALL logging%info('Landuse') + !set land-sea mask, spread at 0.5 due to poor accuracy of values in GRIB files WHERE (fr_land_lu < 0.5_wp) fr_land_lu = MIN(0.49_wp,fr_land_lu) diff --git a/src/extpar_topo_to_buffer.f90 b/src/extpar_topo_to_buffer.f90 index 00c0cbd1..3e32cbfd 100644 --- a/src/extpar_topo_to_buffer.f90 +++ b/src/extpar_topo_to_buffer.f90 @@ -145,7 +145,6 @@ PROGRAM extpar_topo_to_buffer & topo_files(1:max_tiles), & !< filenames globe raw data & sgsl_files(1:max_tiles), & !< filenames subgrid-slope & orography_buffer_file, & !< name for orography buffer file - & orography_output_file, & !< name for orography output file & sgsl_output_file, & !< name for sgsl output file & raw_data_orography_path, & !< path to raw data & raw_data_scale_sep_orography_path, & !< path to raw data @@ -182,15 +181,50 @@ PROGRAM extpar_topo_to_buffer & lfilter_oro, & & lxso_first - namelist_grid_def = 'INPUT_grid_org' - namelist_scale_sep_data_input = 'INPUT_SCALE_SEP' - namelist_lrad = 'INPUT_RADTOPO' - namelist_topo_data_input = 'INPUT_ORO' - namelist_oro_smooth = 'INPUT_OROSMOOTH' + character(len=256) :: file1, file2, file3 + logical :: status1, status2, status3 + integer :: i, loop_count + + ! INPUT Files: + file1 = "INPUT_ORO_ASTER" + file2 = "INPUT_ORO_MERIT" + file3 = "INPUT_ORO_GLOBE" + + ! Check file existence + inquire(file=file1, exist=status1) + inquire(file=file2, exist=status2) + inquire(file=file3, exist=status3) + + ! Determine loop length + loop_count = 0 + + if (status2 .eqv. .TRUE.) loop_count = 1 ! MERIT exists + if (status3 .eqv. .TRUE.) loop_count = 1 ! GLOBE exists + if (status2 .eqv. .TRUE. .AND. status3.eqv. .TRUE. ) loop_count = 2 ! MERIT .AND. GLOBE exists + if (status1 .eqv. .TRUE.) loop_count = 1 ! ASTER exists -> Only one cycle is needed + + CALL initialize_logging("extpar_topo_to_buffer.log") CALL info_print () + namelist_lrad = 'INPUT_RADTOPO' + CALL read_namelists_extpar_lradtopo(namelist_lrad,lradtopo,nhori, radius,min_circ_cov, max_missing, itype_scaling) + + namelist_grid_def = 'INPUT_grid_org' + CALL init_target_grid(namelist_grid_def,lrad=lradtopo) + + ! Loop over ORO data sets + do i = loop_count,1,-1 + + namelist_scale_sep_data_input = 'INPUT_SCALE_SEP' + + IF (status1 .eqv. .TRUE.) namelist_topo_data_input = 'INPUT_ORO_ASTER' + IF (status3 .eqv. .TRUE. .AND.(i==2.OR.i==1)) namelist_topo_data_input = 'INPUT_ORO_GLOBE' + IF (status2 .eqv. .TRUE. .AND.i==1) namelist_topo_data_input = 'INPUT_ORO_MERIT' + + + namelist_oro_smooth = 'INPUT_OROSMOOTH' !-------------------------------------------------------------------------- !-------------------------------------------------------------------------- @@ -198,6 +232,11 @@ PROGRAM extpar_topo_to_buffer CALL logging%info( '============= start topo_to_buffer =============') CALL logging%info( '') + WRITE(message_text,*) 'Orography data loop count: ',i,' of ',loop_count,' Processing file:' + CALL logging%info(message_text) + CALL logging%info(namelist_topo_data_input) + + !-------------------------------------------------------------------------- !-------------------------------------------------------------------------- CALL logging%info( '') @@ -216,7 +255,6 @@ PROGRAM extpar_topo_to_buffer & lsso_param, & & lsubtract_mean_slope, & & orography_buffer_file, & - & orography_output_file, & & sgsl_output_file) IF (lcompute_sgsl) THEN @@ -270,10 +308,10 @@ PROGRAM extpar_topo_to_buffer & lscale_separation) ENDIF - CALL read_namelists_extpar_lradtopo(namelist_lrad,lradtopo,nhori, radius,min_circ_cov, max_missing, itype_scaling) +! CALL read_namelists_extpar_lradtopo(namelist_lrad,lradtopo,nhori, radius,min_circ_cov, max_missing, itype_scaling) - ! get information on target grid - CALL init_target_grid(namelist_grid_def,lrad=lradtopo) +! ! get information on target grid +! CALL init_target_grid(namelist_grid_def,lrad=lradtopo) igrid_type = tg%igrid_type @@ -537,6 +575,7 @@ PROGRAM extpar_topo_to_buffer netcdf_filename = TRIM(orography_buffer_file) + CALL write_netcdf_buffer_topo(netcdf_filename, & & tg, & & undefined, & @@ -563,31 +602,31 @@ PROGRAM extpar_topo_to_buffer & sgsl) - netcdf_filename = TRIM(orography_output_file) +! netcdf_filename = TRIM(orography_output_file) SELECT CASE(igrid_type) CASE(igrid_icon) - CALL write_netcdf_icon_grid_topo(netcdf_filename, & - & icon_grid, & - & tg, & - & undefined, & - & lon_geo, & - & lat_geo, & - & fr_land_topo, & - & hh_topo, & - & stdh_topo, & - & z0_topo, & - & lsso_param, & - & lradtopo, & - & nhori, & - & hh_topo_max, & - & hh_topo_min, & - & horizon_topo, & - & skyview_topo, & - & theta_topo, & - & aniso_topo, & - & slope_topo) +!!$ CALL write_netcdf_icon_grid_topo(netcdf_filename, & +!!$ & icon_grid, & +!!$ & tg, & +!!$ & undefined, & +!!$ & lon_geo, & +!!$ & lat_geo, & +!!$ & fr_land_topo, & +!!$ & hh_topo, & +!!$ & stdh_topo, & +!!$ & z0_topo, & +!!$ & lsso_param, & +!!$ & lradtopo, & +!!$ & nhori, & +!!$ & hh_topo_max, & +!!$ & hh_topo_min, & +!!$ & horizon_topo, & +!!$ & skyview_topo, & +!!$ & theta_topo, & +!!$ & aniso_topo, & +!!$ & slope_topo) CASE(igrid_cosmo) ! COSMO grid CALL write_netcdf_cosmo_grid_topo(netcdf_filename, & @@ -630,4 +669,6 @@ PROGRAM extpar_topo_to_buffer CALL logging%info( '') CALL logging%info('============= topo_to_buffer done ===============') + end do + END PROGRAM extpar_topo_to_buffer diff --git a/src/mo_topo_data.f90 b/src/mo_topo_data.f90 index 562f4060..df8c65bd 100644 --- a/src/mo_topo_data.f90 +++ b/src/mo_topo_data.f90 @@ -84,6 +84,7 @@ MODULE mo_topo_data & undef_topo, & & varname, & & itopo_type, & + & itopo_type_globe, & & topo_gl, & & topo_aster, & & topo_merit, & @@ -98,7 +99,9 @@ MODULE mo_topo_data & ntiles_row, & & ntiles_column, & & lradtopo, & + & lradtopo_globe, & & nhori, & + & nhori_globe, & & radius, & & min_circ_cov, & & max_missing, & @@ -120,9 +123,11 @@ MODULE mo_topo_data & nc_tile, & & undef_topo, & & itopo_type, & + & itopo_type_globe, & & ntiles_row, & & ntiles_column, & & nhori, & + & nhori_globe, & & radius, & & min_circ_cov, & & itype_scaling @@ -151,7 +156,7 @@ MODULE mo_topo_data & merit_lon_min, & & merit_lon_max - LOGICAL :: lradtopo + LOGICAL :: lradtopo,lradtopo_globe CHARACTER(LEN=80) :: varname @@ -421,6 +426,14 @@ SUBROUTINE deallocate_topo_fields(lcompute_sgsl) IF (errorcode.NE.0) CALL logging%error('Cant deallocate the vector tiles_lat_min',__FILE__,__LINE__) DEALLOCATE (tiles_lat_max, STAT = errorcode) IF (errorcode.NE.0) CALL logging%error('Cant deallocate the vector tiles_lat_max',__FILE__,__LINE__) + DEALLOCATE (tiles_ncolumns, STAT = errorcode) + IF (errorcode.NE.0) CALL logging%error('Cant deallocate the vector tiles_ncolumns',__FILE__,__LINE__) + DEALLOCATE (tiles_nrows, STAT = errorcode) + IF (errorcode.NE.0) CALL logging%error('Cant deallocate the vector tiles_nrows',__FILE__,__LINE__) + DEALLOCATE (raw_topo_line, STAT = errorcode) + IF (errorcode.NE.0) CALL logging%error('Cant deallocate the vector raw_topo_line',__FILE__,__LINE__) + DEALLOCATE (h_tile_row, STAT = errorcode) + IF (errorcode.NE.0) CALL logging%error('Cant deallocate the vector h_tile_row',__FILE__,__LINE__) DEALLOCATE (hh_topo, STAT = errorcode) IF (errorcode.NE.0) CALL logging%error('Cant deallocate the vector hh_topo',__FILE__,__LINE__) DEALLOCATE (hh_topo_max, STAT = errorcode) diff --git a/src/mo_topo_routines.f90 b/src/mo_topo_routines.f90 index b7bba29a..f76cdc6d 100644 --- a/src/mo_topo_routines.f90 +++ b/src/mo_topo_routines.f90 @@ -97,7 +97,6 @@ SUBROUTINE read_namelists_extpar_orography(namelist_file, & & lsso_param, & & lsubtract_mean_slope, & & orography_buffer_file, & - & orography_output_file, & & sgsl_buffer_file) @@ -117,7 +116,6 @@ SUBROUTINE read_namelists_extpar_orography(namelist_file, & & lsubtract_mean_slope CHARACTER (len=1024), INTENT(OUT) :: orography_buffer_file, &!< name for orography buffer file - & orography_output_file, &!< name for orography output file & sgsl_buffer_file !< name for sgsl output file INTEGER(KIND=i4) :: nuin, ierr, nzylen @@ -131,7 +129,7 @@ SUBROUTINE read_namelists_extpar_orography(namelist_file, & & topo_files !> namelist with filenames for orography data output - NAMELIST /orography_io_extpar/ orography_buffer_file, orography_output_file + NAMELIST /orography_io_extpar/ orography_buffer_file !> namelist with filenames for subgrid-slope (SGSL) data output NAMELIST /sgsl_io_extpar/ sgsl_files, sgsl_buffer_file, lpreproc_oro diff --git a/src/mo_topo_tg_fields.f90 b/src/mo_topo_tg_fields.f90 index f5a1db18..ac32b70a 100644 --- a/src/mo_topo_tg_fields.f90 +++ b/src/mo_topo_tg_fields.f90 @@ -44,7 +44,22 @@ MODULE mo_topo_tg_fields & horizon_topo, & & skyview_topo, & & sgsl, & - & allocate_topo_target_fields + & allocate_topo_target_fields, & + & fr_land_topo_globe, & + & hh_topo_globe, & + & hh_topo_max_globe, & + & hh_topo_min_globe, & + & stdh_topo_globe, & + & theta_topo_globe, & + & aniso_topo_globe, & + & slope_topo_globe, & + & z0_topo_globe, & + & slope_asp_topo_globe, & + & slope_ang_topo_globe, & + & horizon_topo_globe, & + & skyview_topo_globe, & + & sgsl_globe, & + & allocate_topo_target_fields_globe @@ -61,8 +76,21 @@ MODULE mo_topo_tg_fields & slope_ang_topo(:,:,:), & !< lradtopo parameter, slope angle & horizon_topo (:,:,:,:), & !< lradtopo parameter, horizon & skyview_topo (:,:,:), & !< lradtopo parameter, skyview - & sgsl(:,:,:) !< subgrid-scale slopes - + & sgsl(:,:,:), & !< subgrid-scale slopes + & hh_topo_globe(:,:,:), & !< mean height + & hh_topo_max_globe(:,:,:), & !< maximum height + & hh_topo_min_globe(:,:,:), & !< minimum height + & stdh_topo_globe(:,:,:), & !< standard deviation of subgrid scale orographic height + & theta_topo_globe(:,:,:), & !< sso parameter, angle of principal axis + & aniso_topo_globe(:,:,:), & !< sso parameter, anisotropie factor + & slope_topo_globe(:,:,:), & !< sso parameter, mean slope + & fr_land_topo_globe(:,:,:), & !< fraction land due to GLOBE raw data + & z0_topo_globe(:,:,:), & !< roughness length due to orography + & slope_asp_topo_globe(:,:,:), & !< lradtopo parameter, slope aspect + & slope_ang_topo_globe(:,:,:), & !< lradtopo parameter, slope angle + & horizon_topo_globe (:,:,:,:), & !< lradtopo parameter, horizon + & skyview_topo_globe (:,:,:), & !< lradtopo parameter, skyview + & sgsl_globe(:,:,:) !< subgrid-scale slopes CONTAINS @@ -201,5 +229,140 @@ SUBROUTINE allocate_topo_target_fields(tg,nhori, lcompute_sgsl, l_use_array_cach END SUBROUTINE allocate_topo_target_fields + !> allocate fields for GLOBE target data + SUBROUTINE allocate_topo_target_fields_globe(tg,nhori, lcompute_sgsl, l_use_array_cache) + + IMPLICIT NONE + + TYPE(target_grid_def), INTENT(IN) :: tg !< structure with target grid description + INTEGER (KIND=i4), INTENT(IN) :: nhori + LOGICAL, INTENT(IN) :: lcompute_sgsl + LOGICAL, INTENT(in) :: l_use_array_cache + + INTEGER(KIND=i4) :: errorcode !< error status variable + + errorcode = 0 + + CALL logging%info('Enter routine: allocate_topo_target_fields_globe') + +if (l_use_array_cache) then + call allocate_cached('fr_land_topo_globe', fr_land_topo_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(fr_land_topo_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array fr_land_topo_globe',__FILE__,__LINE__) + fr_land_topo_globe = 0.0 + +if (l_use_array_cache) then + call allocate_cached('hh_topo_globe', hh_topo_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(hh_topo_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array hh_topo_globe',__FILE__,__LINE__) + hh_topo_globe = 0.0 + +if (l_use_array_cache) then + call allocate_cached('hh_topo_max_globe', hh_topo_max_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(hh_topo_max_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array hh_topo_max_globe',__FILE__,__LINE__) + hh_topo_max_globe = 0.0 + +if (l_use_array_cache) then + call allocate_cached('hh_topo_min_globe', hh_topo_min_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(hh_topo_min_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array hh_topo_min_globe',__FILE__,__LINE__) + hh_topo_min_globe = 0.0 + +if (l_use_array_cache) then + call allocate_cached('stdh_topo_globe', stdh_topo_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(stdh_topo_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array stdh_topo_globe',__FILE__,__LINE__) + stdh_topo_globe = 0.0 + +if (l_use_array_cache) then + call allocate_cached('theta_topo_globe', theta_topo_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(theta_topo_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array theta_topo_globe',__FILE__,__LINE__) + theta_topo_globe = 0.0 + +if (l_use_array_cache) then + call allocate_cached('aniso_topo_globe', aniso_topo_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(aniso_topo_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array aniso_topo_globe',__FILE__,__LINE__) + aniso_topo_globe= 0.0 + +if (l_use_array_cache) then + call allocate_cached('slope_topo_globe', slope_topo_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(slope_topo_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array slope_topo_globe',__FILE__,__LINE__) + slope_topo_globe = 0.0 + + +if (l_use_array_cache) then + call allocate_cached('z0_topo_globe', z0_topo_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(z0_topo_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array z0_topo_globe',__FILE__,__LINE__) + z0_topo_globe = 0.0 + +if (l_use_array_cache) then + call allocate_cached('slope_asp_topo_globe', slope_asp_topo_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(slope_asp_topo_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array slope_asp_topo_globe',__FILE__,__LINE__) + slope_asp_topo_globe = 0.0 + +if (l_use_array_cache) then + call allocate_cached('slope_ang_topo_globe', slope_ang_topo_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(slope_ang_topo_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array slope_ang_topo_globe',__FILE__,__LINE__) + slope_ang_topo_globe = 0.0 + +if (l_use_array_cache) then + call allocate_cached('horizon_topo_globe', horizon_topo_globe, [tg%ie,tg%je,tg%ke,nhori]) +else + allocate(horizon_topo_globe(tg%ie,tg%je,tg%ke,nhori), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array horizon_topo_globe',__FILE__,__LINE__) + horizon_topo_globe = 0.0 + +if (l_use_array_cache) then + call allocate_cached('skyview_topo_globe', skyview_topo_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(skyview_topo_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array skyview_topo_globe',__FILE__,__LINE__) + skyview_topo_globe = 0.0 + + IF (lcompute_sgsl) THEN +if (l_use_array_cache) then + call allocate_cached('sgsl_globe', sgsl_globe, [tg%ie,tg%je,tg%ke]) +else + allocate(sgsl_globe(tg%ie,tg%je,tg%ke), stat=errorcode) +endif + IF(errorcode.NE.0) CALL logging%error('Cant allocate the array sgsl_globe',__FILE__,__LINE__) + sgsl_globe = 0.0 + ENDIF + + CALL logging%info('Exit routine: allocate_topo_target_fields_globe') + + END SUBROUTINE allocate_topo_target_fields_globe + END MODULE mo_topo_tg_fields