43 private :: cnvtopo_gtopo30
44 private :: cnvtopo_gmted2010
45 private :: cnvtopo_dem50m
46 private :: cnvtopo_smooth
52 character(len=H_SHORT),
private :: cnvtopo_smooth_type =
'LAPLACIAN' 53 integer,
private :: cnvtopo_smooth_hypdiff_niter = 20
54 logical,
private :: cnvtopo_smooth_local = .true.
55 integer,
private :: cnvtopo_smooth_itelim = 10000
57 logical,
private :: cnvtopo_copy_parent = .false.
59 real(RP),
private :: cnvtopo_unittile_ddeg = 0.0_rp
60 real(RP),
private :: cnvtopo_oversampling_factor = 2.0_rp
61 real(RP),
private :: cnvtopo_smooth_maxslope_ratio = 1.0_rp
62 real(RP),
private :: cnvtopo_smooth_maxslope = -1.0_rp
64 real(RP),
private :: cnvtopo_smooth_maxslope_limit
89 character(len=H_SHORT) :: cnvtopo_name =
'NONE' 91 namelist / param_cnvtopo / &
96 cnvtopo_unittile_ddeg, &
97 cnvtopo_oversampling_factor, &
98 cnvtopo_smooth_hypdiff_niter, &
99 cnvtopo_smooth_maxslope_ratio, &
100 cnvtopo_smooth_maxslope, &
101 cnvtopo_smooth_local, &
102 cnvtopo_smooth_itelim, &
103 cnvtopo_smooth_type, &
106 real(RP) :: minslope(
ia,
ja)
107 real(RP) :: dxl(
ia-1)
108 real(RP) :: dyl(
ja-1)
109 real(RP) :: dzdx, dzdy
111 real(RP) :: drad(
ia,
ja)
119 if(
io_l )
write(
io_fid_log,*)
'++++++ Module[convert topo] / Categ[preprocess] / Origin[SCALE-RM]' 121 if ( cnvtopo_smooth_local )
then 133 if(
io_l )
write(
io_fid_log,*)
'*** Not found namelist. Default used.' 134 elseif( ierr > 0 )
then 135 write(*,*)
'xxx Not appropriate names in namelist PARAM_CNVTOPO. Check!' 140 select case(cnvtopo_name)
160 write(*,*)
'xxx Unsupported TYPE:', trim(cnvtopo_name)
168 if(
io_l )
write(
io_fid_log,*)
'*** Use GTOPO, global 30 arcsec. data' 170 if(
io_l )
write(
io_fid_log,*)
'*** Use GMTED2010, new global 5 arcsec. data' 174 if(
io_l )
write(
io_fid_log,*)
'*** Use DEM 50m data for Japan region' 179 if(
io_l )
write(
io_fid_log,*)
'*** Use GMTED2010, new global 5 arcsec. data' 181 if(
io_l )
write(
io_fid_log,*)
'*** Use DEM 50m data for Japan region' 186 if(
io_l )
write(
io_fid_log,*)
'*** Use DEM 50m data, Japan region only' 190 if(
io_l )
write(
io_fid_log,*)
'*** Do nothing for topography data' 193 call comm_horizontal_min( drad_min, drad(:,:) )
195 if ( cnvtopo_unittile_ddeg > 0.0_rp )
then 196 cnvtopo_oversampling_factor = ( drad_min / d2r ) / cnvtopo_unittile_ddeg
198 cnvtopo_oversampling_factor = max( 1.0_rp, cnvtopo_oversampling_factor )
199 cnvtopo_unittile_ddeg = ( drad_min / d2r ) / cnvtopo_oversampling_factor
201 if(
io_l )
write(
io_fid_log,*)
'*** The size of tile [deg] = ', cnvtopo_unittile_ddeg
202 if(
io_l )
write(
io_fid_log,*)
'*** oversampling factor = ', cnvtopo_oversampling_factor
205 if( cnvtopo_smooth_maxslope > 0.0_rp )
then 207 cnvtopo_smooth_maxslope_limit = cnvtopo_smooth_maxslope
215 dzdx = atan2( cnvtopo_smooth_maxslope_ratio *
grid_cdz(k), dxl(i) ) / d2r
216 dzdy = atan2( cnvtopo_smooth_maxslope_ratio *
grid_cdz(k), dyl(j) ) / d2r
217 minslope(
is,
js) = min( minslope(
is,
js), dzdx, dzdy )
223 dzdx = atan2( cnvtopo_smooth_maxslope_ratio *
grid_cdz(k), dxl(i) ) / d2r
224 dzdy = atan2( cnvtopo_smooth_maxslope_ratio *
grid_cdz(k), dyl(j) ) / d2r
225 minslope(i,
js) = min( minslope(i,
js), dzdx, dzdy )
232 dzdx = atan2( cnvtopo_smooth_maxslope_ratio *
grid_cdz(k), dxl(i) ) / d2r
233 dzdy = atan2( cnvtopo_smooth_maxslope_ratio *
grid_cdz(k), dyl(j) ) / d2r
234 minslope(
is,j) = min( minslope(
is,j), dzdx, dzdy )
241 dzdx = atan2( cnvtopo_smooth_maxslope_ratio *
grid_cdz(k), dxl(i) ) / d2r
242 dzdy = atan2( cnvtopo_smooth_maxslope_ratio *
grid_cdz(k), dyl(j) ) / d2r
243 minslope(i,j) = min( minslope(i,j), dzdx, dzdy )
248 call comm_horizontal_min( cnvtopo_smooth_maxslope_limit, minslope(:,:) )
270 if(
io_l )
write(
io_fid_log,*)
'++++++ SKIP CONVERT TOPOGRAPHY DATA ++++++' 273 if(
io_l )
write(
io_fid_log,*)
'++++++ START CONVERT TOPOGRAPHY DATA ++++++' 280 call cnvtopo_gmted2010
292 if(
io_l )
write(
io_fid_log,*)
'++++++ END CONVERT TOPOGRAPHY DATA ++++++' 303 subroutine cnvtopo_gtopo30
318 character(len=H_LONG) :: gtopo30_in_catalogue =
'' 319 character(len=H_LONG) :: gtopo30_in_dir =
'' 321 namelist / param_cnvtopo_gtopo30 / &
322 gtopo30_in_catalogue, &
326 integer,
parameter :: tile_nlim = 100
328 real(RP) :: tile_lats (tile_nlim)
329 real(RP) :: tile_late (tile_nlim)
330 real(RP) :: tile_lons (tile_nlim)
331 real(RP) :: tile_lone (tile_nlim)
332 character(len=H_LONG) :: tile_fname(tile_nlim)
335 integer,
parameter :: isize_orig = 4800
336 integer,
parameter :: jsize_orig = 6000
337 integer(2) :: tile_height_orig(isize_orig,jsize_orig)
338 real(RP) :: tile_dlat_orig, tile_dlon_orig
345 integer(2),
allocatable :: tile_height(:,:)
346 real(RP),
allocatable :: tile_lath (:)
347 real(RP),
allocatable :: tile_lonh (:)
348 real(RP) :: tile_dlat, tile_dlon
349 real(RP) :: area, area_fraction
356 real(RP) :: real_lonx_mod(0:
ia,
ja)
357 real(RP) :: domain_lats, domain_late
358 real(RP) :: domain_lons, domain_lone
359 integer :: domain_lonsloc(2), domain_loneloc(2)
362 real(RP) :: topo_sum(
ia,
ja)
363 real(RP) :: area_sum(
ia,
ja)
364 real(RP) :: topo, mask
366 character(len=H_LONG) :: fname
369 logical :: hit_lat, hit_lon
372 integer :: i, j, ii, jj, iii, jjj, t
376 if(
io_l )
write(
io_fid_log,*)
'++++++ Module[convert GTOPO30] / Categ[preprocess] / Origin[SCALE-RM]' 380 read(
io_fid_conf,nml=param_cnvtopo_gtopo30,iostat=ierr)
382 if(
io_l )
write(
io_fid_log,*)
'*** Not found namelist. Default used.' 383 elseif( ierr > 0 )
then 384 write(*,*)
'xxx Not appropriate names in namelist PARAM_CNVTOPO_GTOPO30. Check!' 391 area_sum(i,j) = 0.0_rp
392 topo_sum(i,j) = 0.0_rp
396 real_lonx_mod(:,:) = mod(
real_lonx(:,:)+3.0_dp*pi, 2.0_dp*pi ) - pi
400 domain_lons = minval(real_lonx_mod(:,:))
401 domain_lone = maxval(real_lonx_mod(:,:))
403 domain_lonsloc = minloc(real_lonx_mod(:,:))
404 domain_loneloc = maxloc(real_lonx_mod(:,:))
407 if ( domain_lons < real_lonx_mod(0 ,domain_lonsloc(2)) &
408 .OR. domain_lone > real_lonx_mod(
ia,domain_loneloc(2)) )
then 410 domain_lons = minval(real_lonx_mod(:,:),mask=(real_lonx_mod>0.0_rp))
411 domain_lone = maxval(real_lonx_mod(:,:),mask=(real_lonx_mod<0.0_rp))
414 jos = nint( 30.0_rp / 60.0_rp / 60.0_rp / cnvtopo_unittile_ddeg - 0.5_rp ) + 1
415 ios = nint( 30.0_rp / 60.0_rp / 60.0_rp / cnvtopo_unittile_ddeg - 0.5_rp ) + 1
416 jsize = jsize_orig * jos
417 isize = isize_orig * ios
419 allocate( tile_height(isize,jsize) )
420 allocate( tile_lath(0:jsize) )
421 allocate( tile_lonh(0:isize) )
423 if(
io_l )
write(
io_fid_log,*)
'*** Oversampling (j) orig = ', jsize_orig,
', use = ', jsize
424 if(
io_l )
write(
io_fid_log,*)
'*** Oversampling (i) orig = ', isize_orig,
', use = ', isize
426 tile_dlat_orig = 30.0_rp / 60.0_rp / 60.0_rp * d2r
427 tile_dlon_orig = 30.0_rp / 60.0_rp / 60.0_rp * d2r
428 if(
io_l )
write(
io_fid_log,*)
'*** TILE_DLAT :', tile_dlat_orig/d2r
429 if(
io_l )
write(
io_fid_log,*)
'*** TILE_DLON :', tile_dlon_orig/d2r
431 tile_dlat = tile_dlat_orig / jos
432 tile_dlon = tile_dlon_orig / ios
433 if(
io_l )
write(
io_fid_log,*)
'*** TILE_DLAT (OS) :', tile_dlat/d2r
434 if(
io_l )
write(
io_fid_log,*)
'*** TILE_DLON (OS) :', tile_dlon/d2r
439 fname = trim(gtopo30_in_dir)//
'/'//trim(gtopo30_in_catalogue)
442 if(
io_l )
write(
io_fid_log,*)
'+++ Input catalogue file:', trim(fname)
446 file = trim(fname), &
447 form =
'formatted', &
451 if ( ierr /= 0 )
then 452 write(*,*)
'xxx catalogue file not found!', trim(fname)
457 read(fid,*,iostat=ierr) index, tile_lats(t), tile_late(t), &
458 tile_lons(t), tile_lone(t), &
460 if ( ierr /= 0 )
exit 462 if ( tile_lons(t) >= 180.0_rp )
then 463 tile_lons(t) = tile_lons(t) - 360.0_rp
464 tile_lone(t) = tile_lone(t) - 360.0_rp
466 if ( tile_lons(t) < -180.0_rp ) tile_lons(t) = tile_lons(t) + 360.0_rp
467 if ( tile_lone(t) < -180.0_rp ) tile_lone(t) = tile_lone(t) + 360.0_rp
479 if ( ( tile_lats(t)*d2r >= domain_lats .AND. tile_lats(t)*d2r < domain_late ) &
480 .OR. ( tile_late(t)*d2r >= domain_lats .AND. tile_late(t)*d2r < domain_late ) )
then 484 if ( ( domain_lats >= tile_lats(t)*d2r .AND. domain_lats < tile_late(t)*d2r ) &
485 .OR. ( domain_late >= tile_lats(t)*d2r .AND. domain_late < tile_late(t)*d2r ) )
then 489 if ( check_idl )
then 490 if ( ( tile_lons(t)*d2r >= domain_lons .AND. tile_lons(t)*d2r < pi ) &
491 .OR. ( tile_lons(t)*d2r >= -pi .AND. tile_lons(t)*d2r < domain_lone ) &
492 .OR. ( tile_lone(t)*d2r >= domain_lons .AND. tile_lone(t)*d2r < pi ) &
493 .OR. ( tile_lone(t)*d2r >= -pi .AND. tile_lone(t)*d2r < domain_lone ) )
then 497 if ( ( tile_lons(t)*d2r >= domain_lons .AND. tile_lons(t)*d2r < domain_lone ) &
498 .OR. ( tile_lone(t)*d2r >= domain_lons .AND. tile_lone(t)*d2r < domain_lone ) )
then 503 if ( ( domain_lons >= tile_lons(t)*d2r .AND. domain_lons < tile_lone(t)*d2r ) &
504 .OR. ( domain_lone >= tile_lons(t)*d2r .AND. domain_lone < tile_lone(t)*d2r ) )
then 508 if ( hit_lat .AND. hit_lon )
then 509 fname = trim(gtopo30_in_dir)//
'/'//trim(tile_fname(t))
512 if(
io_l )
write(
io_fid_log,*)
'+++ Input data file :', trim(fname)
513 if(
io_l )
write(
io_fid_log,*)
'*** Domain (LAT) :', domain_lats/d2r, domain_late/d2r
514 if(
io_l )
write(
io_fid_log,*)
'*** (LON) :', domain_lons/d2r, domain_lone/d2r
515 if ( check_idl )
then 516 if(
io_l )
write(
io_fid_log,*)
'*** (Date line exists within the domain)' 518 if(
io_l )
write(
io_fid_log,*)
'*** Tile (LAT) :', tile_lats(t), tile_late(t)
519 if(
io_l )
write(
io_fid_log,*)
'*** (LON) :', tile_lons(t), tile_lone(t)
523 file = trim(fname), &
524 form =
'unformatted', &
527 recl = isize_orig*jsize_orig*2, &
530 if ( ierr /= 0 )
then 531 write(*,*)
'xxx data file not found!' 535 read(fid,rec=1) tile_height_orig(:,:)
539 do jj = 1, jsize_orig
540 do ii = 1, isize_orig
543 jjj = (jj-1) * jos + j
544 iii = (ii-1) * ios + i
546 tile_height(iii,jjj) = tile_height_orig(ii,jsize_orig-jj+1)
552 tile_lath(0) = tile_lats(t) * d2r
554 tile_lath(jj) = tile_lath(jj-1) + tile_dlat
558 tile_lonh(0) = tile_lons(t) * d2r
560 tile_lonh(ii) = tile_lonh(ii-1) + tile_dlon
574 if ( tile_lath(jj ) < domain_lats &
575 .OR. tile_lath(jj-1) > domain_late )
then 579 if ( check_idl )
then 580 if ( tile_lonh(ii ) < domain_lons &
581 .AND. tile_lonh(ii-1) > domain_lone )
then 585 if ( tile_lonh(ii ) < domain_lons &
586 .OR. tile_lonh(ii-1) > domain_lone )
then 591 jloop:
do j =
js-1,
je+1
592 iloop:
do i =
is-1,
ie+1
593 if ( tile_lonh(ii-1) >= real_lonx_mod(i-1,j ) &
594 .AND. tile_lonh(ii-1) < real_lonx_mod(i ,j ) &
595 .AND. tile_lath(jj-1) >=
real_laty(i ,j-1) &
596 .AND. tile_lath(jj-1) <
real_laty(i ,j ) )
then 599 ifrac_l = min( real_lonx_mod(i,j)-tile_lonh(ii-1), tile_dlon ) / tile_dlon
602 jfrac_b = min(
real_laty(i,j)-tile_lath(jj-1), tile_dlat ) / tile_dlat
607 if ( real_lonx_mod(i-1,j) >= real_lonx_mod(i ,j ) &
608 .AND. tile_lath(jj-1) >=
real_laty(i ,j-1) &
609 .AND. tile_lath(jj-1) <
real_laty(i ,j ) )
then 611 if ( tile_lonh(ii-1) >= real_lonx_mod(i-1,j) &
612 .AND. tile_lonh(ii-1) < pi )
then 615 ifrac_l = min( real_lonx_mod(i,j)-tile_lonh(ii-1)+2.0_rp*pi, tile_dlon ) / tile_dlon
618 jfrac_b = min(
real_laty(i,j)-tile_lath(jj-1), tile_dlat ) / tile_dlat
621 elseif( tile_lonh(ii-1) >= -pi &
622 .AND. tile_lonh(ii-1) < real_lonx_mod(i ,j) )
then 625 ifrac_l = min( real_lonx_mod(i,j)-tile_lonh(ii-1), tile_dlon ) / tile_dlon
628 jfrac_b = min(
real_laty(i,j)-tile_lath(jj-1), tile_dlat ) / tile_dlat
637 if( iloc == 1 .AND. jloc == 1 ) cycle
639 topo =
real( TILE_HEIGHT(ii,jj), kind=
rp )
640 mask = 0.5_rp - sign( 0.5_rp, topo )
642 area = radius * radius * tile_dlon * ( sin(tile_lath(jj))-sin(tile_lath(jj-1)) ) * ( 1.0_rp - mask )
646 area_fraction = ( ifrac_l) * ( jfrac_b) * area
647 area_sum(iloc ,jloc ) = area_sum(iloc ,jloc ) + area_fraction
648 topo_sum(iloc ,jloc ) = topo_sum(iloc ,jloc ) + area_fraction * topo
650 area_fraction = (1.0_rp-ifrac_l) * ( jfrac_b) * area
651 area_sum(iloc+1,jloc ) = area_sum(iloc+1,jloc ) + area_fraction
652 topo_sum(iloc+1,jloc ) = topo_sum(iloc+1,jloc ) + area_fraction * topo
654 area_fraction = ( ifrac_l) * (1.0_rp-jfrac_b) * area
655 area_sum(iloc ,jloc+1) = area_sum(iloc ,jloc+1) + area_fraction
656 topo_sum(iloc ,jloc+1) = topo_sum(iloc ,jloc+1) + area_fraction * topo
658 area_fraction = (1.0_rp-ifrac_l) * (1.0_rp-jfrac_b) * area
659 area_sum(iloc+1,jloc+1) = area_sum(iloc+1,jloc+1) + area_fraction
660 topo_sum(iloc+1,jloc+1) = topo_sum(iloc+1,jloc+1) + area_fraction * topo
669 zerosw = 0.5_rp - sign( 0.5_rp, area_sum(i,j)-eps )
670 topo_zsfc(i,j) = topo_sum(i,j) * ( 1.0_rp-zerosw ) / ( area_sum(i,j)-zerosw )
675 end subroutine cnvtopo_gtopo30
679 subroutine cnvtopo_gmted2010
684 end subroutine cnvtopo_gmted2010
688 subroutine cnvtopo_dem50m
703 character(len=H_LONG) :: dem50m_in_catalogue =
'' 704 character(len=H_LONG) :: dem50m_in_dir =
'' 706 namelist / param_cnvtopo_dem50m / &
707 dem50m_in_catalogue, &
711 integer,
parameter :: tile_nlim = 1000
713 real(RP) :: tile_lats (tile_nlim)
714 real(RP) :: tile_late (tile_nlim)
715 real(RP) :: tile_lons (tile_nlim)
716 real(RP) :: tile_lone (tile_nlim)
717 character(len=H_LONG) :: tile_fname(tile_nlim)
720 integer,
parameter :: isize_orig = 1600
721 integer,
parameter :: jsize_orig = 1600
722 real(SP) :: tile_height_orig(isize_orig,jsize_orig)
723 real(RP) :: tile_dlat_orig, tile_dlon_orig
730 real(SP),
allocatable :: tile_height(:,:)
731 real(RP),
allocatable :: tile_lath (:)
732 real(RP),
allocatable :: tile_lonh (:)
733 real(RP) :: tile_dlat, tile_dlon
734 real(RP) :: area, area_fraction
741 real(RP) :: real_lonx_mod(0:
ia,
ja)
742 real(RP) :: domain_lats, domain_late
743 real(RP) :: domain_lons, domain_lone
744 integer :: domain_lonsloc(2), domain_loneloc(2)
747 real(RP) :: topo_sum(
ia,
ja)
748 real(RP) :: area_sum(
ia,
ja)
749 real(RP) :: topo, mask
751 character(len=H_LONG) :: fname
754 logical :: hit_lat, hit_lon
757 integer :: i, j, ii, jj, iii, jjj, t
761 if(
io_l )
write(
io_fid_log,*)
'++++++ Module[convert DEM50M] / Categ[preprocess] / Origin[SCALE-RM]' 765 read(
io_fid_conf,nml=param_cnvtopo_dem50m,iostat=ierr)
767 if(
io_l )
write(
io_fid_log,*)
'*** Not found namelist. Default used.' 768 elseif( ierr > 0 )
then 769 write(*,*)
'xxx Not appropriate names in namelist PARAM_CNVTOPO_DEM50M. Check!' 776 area_sum(i,j) = 0.0_rp
777 topo_sum(i,j) = 0.0_rp
781 real_lonx_mod(:,:) = mod(
real_lonx(:,:)+3.0_dp*pi, 2.0_dp*pi ) - pi
785 domain_lons = minval(real_lonx_mod(:,:))
786 domain_lone = maxval(real_lonx_mod(:,:))
788 domain_lonsloc = minloc(real_lonx_mod(:,:))
789 domain_loneloc = maxloc(real_lonx_mod(:,:))
792 if ( domain_lons < real_lonx_mod(0 ,domain_lonsloc(2)) &
793 .OR. domain_lone > real_lonx_mod(
ia,domain_loneloc(2)) )
then 795 domain_lons = minval(real_lonx_mod(:,:),mask=(real_lonx_mod>0.0_rp))
796 domain_lone = maxval(real_lonx_mod(:,:),mask=(real_lonx_mod<0.0_rp))
799 jos = nint( 5.0_rp / 60.0_rp / 200.0_rp / cnvtopo_unittile_ddeg - 0.5_rp ) + 1
800 ios = nint( 7.5_rp / 60.0_rp / 200.0_rp / cnvtopo_unittile_ddeg - 0.5_rp ) + 1
801 jsize = jsize_orig * jos
802 isize = isize_orig * ios
804 allocate( tile_height(isize,jsize) )
805 allocate( tile_lath(0:jsize) )
806 allocate( tile_lonh(0:isize) )
808 if(
io_l )
write(
io_fid_log,*)
'*** Oversampling (j) orig = ', jsize_orig,
', use = ', jsize
809 if(
io_l )
write(
io_fid_log,*)
'*** Oversampling (i) orig = ', isize_orig,
', use = ', isize
811 tile_dlat_orig = 5.0_rp / 60.0_rp / 200.0_rp * d2r
812 tile_dlon_orig = 7.5_rp / 60.0_rp / 200.0_rp * d2r
813 if(
io_l )
write(
io_fid_log,*)
'*** TILE_DLAT :', tile_dlat_orig/d2r
814 if(
io_l )
write(
io_fid_log,*)
'*** TILE_DLON :', tile_dlon_orig/d2r
816 tile_dlat = tile_dlat_orig / jos
817 tile_dlon = tile_dlon_orig / ios
818 if(
io_l )
write(
io_fid_log,*)
'*** TILE_DLAT (OS) :', tile_dlat/d2r
819 if(
io_l )
write(
io_fid_log,*)
'*** TILE_DLON (OS) :', tile_dlon/d2r
824 fname = trim(dem50m_in_dir)//
'/'//trim(dem50m_in_catalogue)
827 if(
io_l )
write(
io_fid_log,*)
'+++ Input catalogue file:', trim(fname)
831 file = trim(fname), &
832 form =
'formatted', &
836 if ( ierr /= 0 )
then 837 write(*,*)
'xxx catalogue file not found!', trim(fname)
842 read(fid,*,iostat=ierr) index, tile_lats(t), tile_late(t), &
843 tile_lons(t), tile_lone(t), &
845 if ( ierr /= 0 )
exit 847 if ( tile_lons(t) >= 180.0_rp )
then 848 tile_lons(t) = tile_lons(t) - 360.0_rp
849 tile_lone(t) = tile_lone(t) - 360.0_rp
851 if ( tile_lons(t) < -180.0_rp ) tile_lons(t) = tile_lons(t) + 360.0_rp
852 if ( tile_lone(t) < -180.0_rp ) tile_lone(t) = tile_lone(t) + 360.0_rp
864 if ( ( tile_lats(t)*d2r >= domain_lats .AND. tile_lats(t)*d2r < domain_late ) &
865 .OR. ( tile_late(t)*d2r >= domain_lats .AND. tile_late(t)*d2r < domain_late ) )
then 869 if ( ( domain_lats >= tile_lats(t)*d2r .AND. domain_lats < tile_late(t)*d2r ) &
870 .OR. ( domain_late >= tile_lats(t)*d2r .AND. domain_late < tile_late(t)*d2r ) )
then 874 if ( check_idl )
then 875 if ( ( tile_lons(t)*d2r >= domain_lons .AND. tile_lons(t)*d2r < pi ) &
876 .OR. ( tile_lons(t)*d2r >= -pi .AND. tile_lons(t)*d2r < domain_lone ) &
877 .OR. ( tile_lone(t)*d2r >= domain_lons .AND. tile_lone(t)*d2r < pi ) &
878 .OR. ( tile_lone(t)*d2r >= -pi .AND. tile_lone(t)*d2r < domain_lone ) )
then 882 if ( ( tile_lons(t)*d2r >= domain_lons .AND. tile_lons(t)*d2r < domain_lone ) &
883 .OR. ( tile_lone(t)*d2r >= domain_lons .AND. tile_lone(t)*d2r < domain_lone ) )
then 888 if ( ( domain_lons >= tile_lons(t)*d2r .AND. domain_lons < tile_lone(t)*d2r ) &
889 .OR. ( domain_lone >= tile_lons(t)*d2r .AND. domain_lone < tile_lone(t)*d2r ) )
then 893 if ( hit_lat .AND. hit_lon )
then 894 fname = trim(dem50m_in_dir)//
'/'//trim(tile_fname(t))
897 if(
io_l )
write(
io_fid_log,*)
'+++ Input data file :', trim(fname)
898 if(
io_l )
write(
io_fid_log,*)
'*** Domain (LAT) :', domain_lats/d2r, domain_late/d2r
899 if(
io_l )
write(
io_fid_log,*)
'*** (LON) :', domain_lons/d2r, domain_lone/d2r
900 if ( check_idl )
then 901 if(
io_l )
write(
io_fid_log,*)
'*** (Date line exists within the domain)' 903 if(
io_l )
write(
io_fid_log,*)
'*** Tile (LAT) :', tile_lats(t), tile_late(t)
904 if(
io_l )
write(
io_fid_log,*)
'*** (LON) :', tile_lons(t), tile_lone(t)
908 file = trim(fname), &
909 form =
'unformatted', &
912 recl = isize_orig*jsize_orig*4, &
915 if ( ierr /= 0 )
then 916 write(*,*)
'xxx data file not found!' 920 read(fid,rec=1) tile_height_orig(:,:)
924 do jj = 1, jsize_orig
925 do ii = 1, isize_orig
928 jjj = (jj-1) * jos + j
929 iii = (ii-1) * ios + i
931 tile_height(iii,jjj) = tile_height_orig(ii,jj)
937 tile_lath(0) = tile_lats(t) * d2r
939 tile_lath(jj) = tile_lath(jj-1) + tile_dlat
943 tile_lonh(0) = tile_lons(t) * d2r
945 tile_lonh(ii) = tile_lonh(ii-1) + tile_dlon
959 if ( tile_lath(jj ) < domain_lats &
960 .OR. tile_lath(jj-1) > domain_late )
then 964 if ( check_idl )
then 965 if ( tile_lonh(ii ) < domain_lons &
966 .AND. tile_lonh(ii-1) > domain_lone )
then 970 if ( tile_lonh(ii ) < domain_lons &
971 .OR. tile_lonh(ii-1) > domain_lone )
then 976 jloop:
do j =
js-1,
je+1
977 iloop:
do i =
is-1,
ie+1
978 if ( tile_lonh(ii-1) >= real_lonx_mod(i-1,j ) &
979 .AND. tile_lonh(ii-1) < real_lonx_mod(i ,j ) &
980 .AND. tile_lath(jj-1) >=
real_laty(i ,j-1) &
981 .AND. tile_lath(jj-1) <
real_laty(i ,j ) )
then 984 ifrac_l = min( real_lonx_mod(i,j)-tile_lonh(ii-1), tile_dlon ) / tile_dlon
987 jfrac_b = min(
real_laty(i,j)-tile_lath(jj-1), tile_dlat ) / tile_dlat
992 if ( real_lonx_mod(i-1,j) >= real_lonx_mod(i ,j ) &
993 .AND. tile_lath(jj-1) >=
real_laty(i ,j-1) &
994 .AND. tile_lath(jj-1) <
real_laty(i ,j ) )
then 996 if ( tile_lonh(ii-1) >= real_lonx_mod(i-1,j) &
997 .AND. tile_lonh(ii-1) < pi )
then 1000 ifrac_l = min( real_lonx_mod(i,j)-tile_lonh(ii-1)+2.0_rp*pi, tile_dlon ) / tile_dlon
1003 jfrac_b = min(
real_laty(i,j)-tile_lath(jj-1), tile_dlat ) / tile_dlat
1006 elseif( tile_lonh(ii-1) >= -pi &
1007 .AND. tile_lonh(ii-1) < real_lonx_mod(i ,j) )
then 1010 ifrac_l = min( real_lonx_mod(i,j)-tile_lonh(ii-1), tile_dlon ) / tile_dlon
1013 jfrac_b = min(
real_laty(i,j)-tile_lath(jj-1), tile_dlat ) / tile_dlat
1022 if( iloc == 1 .AND. jloc == 1 ) cycle
1024 topo =
real( TILE_HEIGHT(ii,jj), kind=
rp )
1025 mask = 0.5_rp - sign( 0.5_rp,topo )
1027 area = radius * radius * tile_dlon * ( sin(tile_lath(jj))-sin(tile_lath(jj-1)) ) * ( 1.0_rp - mask )
1031 area_fraction = ( ifrac_l) * ( jfrac_b) * area
1032 area_sum(iloc ,jloc ) = area_sum(iloc ,jloc ) + area_fraction
1033 topo_sum(iloc ,jloc ) = topo_sum(iloc ,jloc ) + area_fraction * topo
1035 area_fraction = (1.0_rp-ifrac_l) * ( jfrac_b) * area
1036 area_sum(iloc+1,jloc ) = area_sum(iloc+1,jloc ) + area_fraction
1037 topo_sum(iloc+1,jloc ) = topo_sum(iloc+1,jloc ) + area_fraction * topo
1039 area_fraction = ( ifrac_l) * (1.0_rp-jfrac_b) * area
1040 area_sum(iloc ,jloc+1) = area_sum(iloc ,jloc+1) + area_fraction
1041 topo_sum(iloc ,jloc+1) = topo_sum(iloc ,jloc+1) + area_fraction * topo
1043 area_fraction = (1.0_rp-ifrac_l) * (1.0_rp-jfrac_b) * area
1044 area_sum(iloc+1,jloc+1) = area_sum(iloc+1,jloc+1) + area_fraction
1045 topo_sum(iloc+1,jloc+1) = topo_sum(iloc+1,jloc+1) + area_fraction * topo
1054 mask = 0.5_rp + sign( 0.5_rp, area_sum(i,j)-eps )
1055 zerosw = 0.5_rp - sign( 0.5_rp, area_sum(i,j)-eps )
1056 topo = topo_sum(i,j) * ( 1.0_rp-zerosw ) / ( area_sum(i,j)-zerosw )
1063 end subroutine cnvtopo_dem50m
1067 subroutine cnvtopo_smooth( &
1086 real(RP),
intent(inout) :: zsfc(
ia,
ja)
1088 real(RP) :: dzsfc_dx(1,
ia,
ja,1)
1089 real(RP) :: dzsfc_dy(1,
ia,
ja,1)
1091 real(RP) :: dxl(
ia-1)
1092 real(RP) :: dyl(
ja-1)
1094 real(RP) :: flx_x(
ia,
ja)
1095 real(RP) :: flx_y(
ia,
ja)
1097 real(RP) :: slope(
ia,
ja)
1098 real(RP) :: maxslope
1101 character(len=H_SHORT) :: varname(1)
1108 if(
io_l )
write(
io_fid_log,*)
'*** Apply smoothing. Slope limit = ', cnvtopo_smooth_maxslope_limit
1109 if(
io_l )
write(
io_fid_log,*)
'*** Smoothing type = ', cnvtopo_smooth_type
1110 if(
io_l )
write(
io_fid_log,*)
'*** Smoothing locally = ', cnvtopo_smooth_local
1112 if ( cnvtopo_smooth_local )
then 1123 do ite = 1, cnvtopo_smooth_itelim+1
1131 dzsfc_dx(1,i,j,1) = atan2( ( zsfc(i+1,j)-zsfc(i,j) ), dxl(i) ) / d2r
1134 dzsfc_dx(1,
ia,:,1) = 0.0_rp
1137 dzsfc_dy(1,i,j,1) = atan2( ( zsfc(i,j+1)-zsfc(i,j) ), dyl(j) ) / d2r
1140 dzsfc_dy(1,:,
ja,1) = 0.0_rp
1142 slope(:,:) = max( abs(dzsfc_dx(1,:,:,1)), abs(dzsfc_dy(1,:,:,1)) )
1143 call comm_horizontal_max( maxslope, slope(:,:) )
1145 if(
io_l )
write(
io_fid_log,*)
'*** maximum slope [deg] : ', maxslope
1147 if( maxslope < cnvtopo_smooth_maxslope_limit )
exit 1149 varname(1) =
"DZsfc_DX" 1151 varname(1) =
"DZsfc_DY" 1154 select case( cnvtopo_smooth_type )
1160 zsfc(i,j) = ( 0.2500_rp * zsfc(i ,j ) &
1161 + 0.1250_rp * zsfc(i-1,j ) &
1162 + 0.1250_rp * zsfc(i+1,j ) &
1163 + 0.1250_rp * zsfc(i ,j-1) &
1164 + 0.1250_rp * zsfc(i ,j+1) &
1165 + 0.0625_rp * zsfc(i-1,j-1) &
1166 + 0.0625_rp * zsfc(i+1,j-1) &
1167 + 0.0625_rp * zsfc(i-1,j+1) &
1168 + 0.0625_rp * zsfc(i+1,j+1) )
1176 flx_x(i,j) = zsfc(i+1,j) - zsfc(i,j)
1189 flx_y(i,j) = zsfc(i,j+1) - zsfc(i,j)
1201 if ( cnvtopo_smooth_local )
then 1205 + sign(0.5_rp, max( abs(dzsfc_dx(1,i+1,j ,1)), &
1206 abs(dzsfc_dx(1,i ,j ,1)), &
1207 abs(dzsfc_dx(1,i-1,j ,1)), &
1208 abs(dzsfc_dy(1,i+1,j ,1)), &
1209 abs(dzsfc_dy(1,i+1,j-1,1)), &
1210 abs(dzsfc_dy(1,i ,j ,1)), &
1211 abs(dzsfc_dy(1,i ,j-1,1)) &
1212 ) - cnvtopo_smooth_maxslope_limit )
1213 flx_x(i,j) = flx_x(i,j) &
1221 + sign(0.5_rp, max( abs(dzsfc_dy(1,i ,j+1,1)), &
1222 abs(dzsfc_dy(1,i ,j ,1)), &
1223 abs(dzsfc_dy(1,i ,j-1,1)), &
1224 abs(dzsfc_dx(1,i ,j+1,1)), &
1225 abs(dzsfc_dx(1,i-1,j+1,1)), &
1226 abs(dzsfc_dx(1,i ,j ,1)), &
1227 abs(dzsfc_dx(1,i-1,j ,1)) &
1228 ) - cnvtopo_smooth_maxslope_limit )
1229 flx_y(i,j) = flx_y(i,j) &
1238 zsfc(i,j) = max( 0.0_rp, &
1240 + 0.1_rp * ( ( flx_x(i,j) - flx_x(i-1,j) ) &
1241 + ( flx_y(i,j) - flx_y(i,j-1) ) ) )
1246 write(*,*)
'xxx Invalid smoothing type' 1252 if ( ite > cnvtopo_smooth_itelim )
then 1253 write(*,*)
'xxx not converged' 1261 if ( cnvtopo_smooth_hypdiff_niter > 0 )
then 1270 dzsfc_dx(1,i,j,1) = atan2( ( zsfc(i+1,j)-zsfc(i,j) ), dxl(i) ) / d2r
1273 dzsfc_dx(1,
ia,:,1) = 0.0_rp
1276 dzsfc_dy(1,i,j,1) = atan2( ( zsfc(i,j+1)-zsfc(i,j) ), dyl(j) ) / d2r
1279 dzsfc_dy(1,:,
ja,1) = 0.0_rp
1281 slope(:,:) = max( abs(dzsfc_dx(1,:,:,1)), abs(dzsfc_dy(1,:,:,1)) )
1282 call comm_horizontal_max( maxslope, slope(:,:) )
1284 if(
io_l )
write(
io_fid_log,*)
'*** maximum slope [deg] : ', maxslope
1290 varname(1) =
"DZsfc_DX" 1292 varname(1) =
"DZsfc_DY" 1298 end subroutine cnvtopo_smooth
1303 real(RP),
intent(inout) :: Zsfc(IA,JA)
1304 integer,
intent(in) :: nite
1306 real(RP),
pointer :: p1(:,:)
1307 real(RP),
pointer :: p2(:,:)
1308 real(RP),
target :: work1(IA,JA)
1309 real(RP),
target :: work2(IA,JA)
1317 work2(:,:) = zsfc(:,:)
1324 p2(i,j) = ( - p1(i+1,j) + p1(i,j)*2.0_rp - p1(i-1,j) &
1325 - p1(i,j+1) + p1(i,j)*2.0_rp - p1(i,j-1) ) / 8.0_rp
1329 if ( mod(n,2) == 0 )
then 1339 zsfc(i,j) = max( zsfc(i,j) - p1(i,j), 0.0_rp )
subroutine, public topo_write
Write topography.
integer, public is
start point of inner domain: x, local
integer, public je
end point of inner domain: y, local
subroutine, public topo_fillhalo(Zsfc)
HALO Communication.
real(rp), public dy
length in the main region [m]: y
real(rp), public const_huge
huge number
subroutine, public prc_mpistop
Abort MPI.
real(rp), dimension(:), allocatable, public grid_fdy
y-length of grid(j+1) to grid(j) [m]
real(rp), public dx
length in the main region [m]: x
logical, public io_l
output log or not? (this process)
module Convert topography
logical, public cnvtopo_usedem50m
real(rp), public const_radius
radius of the planet [m]
integer, public ke
end point of inner domain: z, local
real(rp), public const_d2r
degree to radian
logical, public cnvtopo_donothing
logical, public io_nml
output log or not? (for namelist, this process)
integer, public ia
of whole cells: x, local, with HALO
integer function, public io_get_available_fid()
search & get available file ID
real(rp), dimension(:,:), allocatable, public real_dlon
delta longitude
integer, public js
start point of inner domain: y, local
subroutine cnvtopo_hypdiff(Zsfc, nite)
real(rp), dimension(:,:), allocatable, public real_dlat
delta latitude
subroutine, public cnvtopo_setup
Setup.
subroutine, public stat_detail(var, varname, supress_globalcomm)
Search global maximum & minimum value.
integer, public ks
start point of inner domain: z, local
subroutine, public cnvtopo
Driver.
logical, public cnvtopo_usegtopo30
subroutine, public copytopo(topo_cd)
Setup and Main.
integer, public ie
end point of inner domain: x, local
real(rp), public const_eps
small number
real(rp), dimension(:,:), allocatable, public topo_zsfc
absolute ground height [m]
real(rp), dimension(:), allocatable, public grid_cdz
z-length of control volume [m]
real(rp), dimension(:), allocatable, public grid_fdx
x-length of grid(i+1) to grid(i) [m]
real(rp), public const_pi
pi
integer, public io_fid_conf
Config file ID.
integer, public io_fid_log
Log file ID.
integer, parameter, public rp
real(rp), dimension(:,:), allocatable, public real_lonx
longitude at staggered point (uy) [rad,0-2pi]
integer, public io_fid_nml
Log file ID (only for output namelist)
logical, public cnvtopo_usegmted2010
real(rp), dimension(:,:), allocatable, public real_laty
latitude at staggered point (xv) [rad,-pi,pi]
integer, public ja
of whole cells: y, local, with HALO