38 private :: copytopo_transgrid
39 private :: copytopo_setalpha
40 private :: copytopo_input_data
41 private :: copytopo_mix_data
47 integer,
private,
parameter :: handle = 1
49 character(len=H_LONG),
private :: copytopo_in_basename =
'' 50 real(RP),
private :: copytopo_transition_dx = -1.0_rp
51 real(RP),
private :: copytopo_transition_dy = -1.0_rp
52 real(RP),
private :: copytopo_fracx = 1.0_rp
53 real(RP),
private :: copytopo_fracy = 1.0_rp
54 real(RP),
private :: copytopo_taux = 1.0_rp
55 real(RP),
private :: copytopo_tauy = 1.0_rp
56 logical,
private :: copytopo_entire_region = .false.
57 logical,
private :: copytopo_linear_h = .true.
58 real(RP),
private :: copytopo_exp_h = 2.0_rp
59 integer,
private :: copytopo_filter_order = 2
60 integer,
private :: copytopo_filter_niter = 20
72 real(RP),
intent(inout) :: TOPO_child(:,:)
76 real(RP) :: alpha (
ia,
ja)
77 real(RP) :: TOPO_parent(
ia,
ja)
79 namelist / param_copytopo / &
80 copytopo_in_basename, &
81 copytopo_transition_dx, &
82 copytopo_transition_dy, &
87 copytopo_entire_region, &
90 copytopo_filter_order, &
97 log_info(
"COPYTOPO",*)
'Setup' 103 log_info(
"COPYTOPO",*)
'Not found namelist. Default used.' 104 elseif( ierr > 0 )
then 105 log_error(
"COPYTOPO",*)
'Not appropriate names in namelist PARAM_COPYTOPO. Check!' 108 log_nml(param_copytopo)
112 call copytopo_transgrid( ctrx(:), ctry(:) )
114 call copytopo_setalpha ( ctrx(:), ctry(:), &
117 call copytopo_input_data( topo_parent(:,:) )
119 call copytopo_mix_data( topo_parent(:,:), &
128 subroutine copytopo_transgrid( &
147 real(RP),
intent(out) :: CTRX(
ia)
148 real(RP),
intent(out) :: CTRY(
ja)
150 real(RP) :: CTRXG (
iag)
151 real(RP) :: CTRYG (
jag)
153 real(RP) :: bufftotx, transtotx
154 real(RP) :: bufftoty, transtoty
155 integer :: imain, ibuff, itrans
156 integer :: jmain, jbuff, jtrans
157 integer :: copy_is, copy_ie
158 integer :: copy_js, copy_je
160 integer :: i, j, ii, jj
167 if( abs(cbfxg(i)) < eps )
exit 169 ibuff = i - 1 -
ihalo 170 if ( ibuff == 0 )
then 176 if ( copytopo_transition_dx < 0.0_rp )
then 177 copytopo_transition_dx = bufftotx
180 if( cxg(i) - bufftotx - fxg(
ihalo) >= copytopo_transition_dx )
exit 182 itrans = i - 1 -
ihalo - ibuff
183 if ( itrans == 0 )
then 186 transtotx = fxg(itrans+ibuff+
ihalo) - fxg(
ihalo) - bufftotx
189 imain =
iag - 2*ibuff - 2*itrans - 2*
ihalo 191 if ( imain < 1 )
then 192 log_error(
"COPYTOPO_transgrid",*)
'Not appropriate transition width for global domain(X).', copytopo_transition_dx
193 log_error_cont(*)
'# of buffer region (one side) = ', ibuff
194 log_error_cont(*)
'# of transion region (one side) = ', itrans
202 copy_ie =
ihalo+ibuff
204 do i = copy_is, copy_ie
208 if ( itrans > 0 )
then 209 copy_is =
ihalo+ibuff+1
210 copy_ie =
ihalo+ibuff+itrans
212 do i = copy_is, copy_ie
213 ctrxg(i) = (transtotx+bufftotx+fxg(
ihalo )-cxg(i)) / transtotx
215 copy_is =
iag -
ihalo - ibuff - itrans + 1
218 do i = copy_is, copy_ie
219 ctrxg(i) = (transtotx+bufftotx-fxg(
iag-
ihalo)+cxg(i)) / transtotx
226 do i = copy_is, copy_ie
230 ctrxg(:) = max( min( ctrxg(:), 1.0_rp ), 0.0_rp )
235 if( abs(cbfyg(j)) < eps )
exit 237 jbuff = j - 1 -
jhalo 238 if ( jbuff == 0 )
then 244 if ( copytopo_transition_dy < 0.0_rp )
then 245 copytopo_transition_dy = bufftoty
248 if( cyg(j) - bufftoty - fyg(
jhalo) >= copytopo_transition_dy )
exit 250 jtrans = j - 1 -
jhalo - jbuff
251 if ( jtrans == 0 )
then 254 transtoty = fyg(jtrans+jbuff+
jhalo) - fyg(
jhalo) - bufftoty
257 jmain =
jag - 2*jbuff - 2*jtrans - 2*
jhalo 259 if ( jmain < 1 )
then 260 log_error(
"COPYTOPO_transgrid",*)
'Not appropriate transition width for global domain(Y).', copytopo_transition_dy
261 log_error_cont(*)
'# of buffer region (one side)', jbuff
262 log_error_cont(*)
'# of transion region (one side)', jtrans
270 copy_je =
jhalo+jbuff
272 do j = copy_js, copy_je
276 if ( jtrans > 0 )
then 277 copy_js =
jhalo+jbuff+1
278 copy_je =
jhalo+jbuff+jtrans
280 do j = copy_js, copy_je
281 ctryg(j) = (transtoty+bufftoty+fyg(
jhalo )-cyg(j)) / transtoty
283 copy_js =
jag -
jhalo - jbuff - jtrans + 1
286 do j = copy_js, copy_je
287 ctryg(j) = (transtoty+bufftoty-fyg(
jag-
jhalo)+cyg(j)) / transtoty
294 do j = copy_js, copy_je
298 ctryg(:) = max( min( ctryg(:), 1.0_rp ), 0.0_rp )
317 log_info(
"COPYTOPO_transgrid",*)
'COPYTOPO grid Information' 318 log_info_cont(*)
'size of buffer region (x and y; one side) = ', bufftotx, bufftoty
319 log_info_cont(*)
'# of buffer region (x and y; one side) = ', ibuff, jbuff
320 log_info_cont(*)
'size of transion region (x and y; one side) = ', transtotx, transtoty
321 log_info_cont(*)
'# of transion region (x and y; one side) = ', itrans, jtrans
325 end subroutine copytopo_transgrid
330 subroutine copytopo_setalpha( &
341 real(RP),
intent(in) :: CTRX (
ia)
342 real(RP),
intent(in) :: CTRY (
ja)
343 real(RP),
intent(out) :: alpha(
ia,
ja)
345 real(RP) :: coef_x, alpha_x1
346 real(RP) :: coef_y, alpha_y1
353 copytopo_fracx = max( min( copytopo_fracx, 1.0_rp ), eps )
354 copytopo_fracy = max( min( copytopo_fracy, 1.0_rp ), eps )
356 if ( copytopo_taux <= 0.0_rp )
then 359 coef_x = 1.0_rp / copytopo_taux
362 if ( copytopo_tauy <= 0.0_rp )
then 365 coef_y = 1.0_rp / copytopo_tauy
374 if ( ee1 <= 1.0_rp - copytopo_fracx )
then 377 ee1 = ( ee1 - 1.0_rp + copytopo_fracx ) / copytopo_fracx
380 if ( copytopo_linear_h )
then 381 alpha_x1 = coef_x * ee1
383 alpha_x1 = coef_x * ee1 * exp( -(1.0_rp-ee1) * copytopo_exp_h )
388 if ( ee1 <= 1.0_rp - copytopo_fracy )
then 391 ee1 = ( ee1 - 1.0_rp + copytopo_fracy ) / copytopo_fracy
394 if ( copytopo_linear_h )
then 395 alpha_y1 = coef_y * ee1
397 alpha_y1 = coef_y * ee1 * exp( -(1.0_rp-ee1) * copytopo_exp_h )
400 alpha(i,j) = max( alpha_x1, alpha_y1 )
404 call comm_vars8( alpha(:,:), 1 )
405 call comm_wait ( alpha(:,:), 1 )
408 end subroutine copytopo_setalpha
413 subroutine copytopo_input_data( &
446 real(RP),
intent(out) :: TOPO_parent(:,:)
448 real(RP),
allocatable :: LON_org (:,:)
449 real(RP),
allocatable :: LAT_org (:,:)
450 real(RP),
allocatable :: TOPO_org(:,:)
451 real(RP),
allocatable :: read2D (:,:)
453 real(RP) :: dummy(1,1)
454 integer :: idx_i(
ia,
ja,nest_interp_level)
455 integer :: idx_j(
ia,
ja,nest_interp_level)
456 real(RP) :: hfact(
ia,
ja,nest_interp_level)
458 real(RP) :: TOPO_sign(
ia,
ja)
460 integer :: IA_org, JA_org
461 integer :: tilei, tilej
462 integer :: cxs, cxe, cys, cye
463 integer :: pxs, pxe, pys, pye
466 real(RP) :: ocean_flag
475 allocate( lon_org(ia_org,ja_org) )
476 allocate( lat_org(ia_org,ja_org) )
477 allocate( topo_org(ia_org,ja_org) )
479 do n = 1,
size( nest_tile_id(:) )
481 rank = nest_tile_id(n)
483 call nest_domain_shape( tilei, tilej, &
490 allocate( read2d(tilei,tilej) )
494 aggregate=.false., rankid=rank )
496 call file_read( fid,
"lon", read2d(:,:) )
497 lon_org(cxs:cxe,cys:cye) = read2d(pxs:pxe,pys:pye) * d2r
498 call file_read( fid,
"lat", read2d(:,:) )
499 lat_org(cxs:cxe,cys:cye) = read2d(pxs:pxe,pys:pye) * d2r
500 call file_read( fid,
"TOPO", read2d(:,:) )
501 topo_org(cxs:cxe,cys:cye) = read2d(pxs:pxe,pys:pye)
509 lon(:,:), lat(:,:), dummy(:,:), dummy(:,:), &
532 if ( copytopo_filter_niter > 1 )
then 538 * ( 0.5_rp + sign( 0.5_rp, eps - abs(topo_parent(i,j)) ) )
539 topo_sign(i,j) = sign( 1.0_rp, topo_parent(i,j) ) * ( 1.0_rp - ocean_flag )
544 topo_parent(:,:), copytopo_filter_order, copytopo_filter_niter, &
545 limiter_sign = topo_sign(:,:) )
549 call comm_vars8( topo_parent(:,:), 1 )
550 call comm_wait ( topo_parent(:,:), 1 )
554 end subroutine copytopo_input_data
558 subroutine copytopo_mix_data( &
564 real(RP),
intent(in) :: TOPO_parent(:,:)
565 real(RP),
intent(in) :: alpha (:,:)
566 real(RP),
intent(inout) :: TOPO_child (:,:)
571 if ( copytopo_entire_region )
then 575 topo_child(i,j) = topo_parent(i,j)
582 topo_child(i,j) = ( 1.0_rp-alpha(i,j) ) * topo_child(i,j) &
583 + ( alpha(i,j) ) * topo_parent(i,j)
589 end subroutine copytopo_mix_data
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cxg
center coordinate [m]: x, global
integer, public jmax
of computational cells: y, local
subroutine, public file_close(fid, skip_abort)
integer, public ihalo
of halo cells: x
integer, public comm_cartesc_nest_tile_num_y
parent tile number in y-direction
integer, public imax
of computational cells: x, local
integer, public jhalo
of halo cells: y
integer, public ia
of whole cells: x, local, with HALO
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cyg
center coordinate [m]: y, global
integer, public iag
of computational grids
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cbfxg
center buffer factor (0-1): x, global
real(rp), dimension(:,:), allocatable, public atmos_grid_cartesc_real_lat
latitude [rad,-pi,pi]
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_fxg
face coordinate [m]: x, global
integer, public ja
of whole cells: y, local, with HALO
integer, public io_fid_conf
Config file ID.
real(rp), public const_d2r
degree to radian
subroutine, public copytopo(TOPO_child)
Setup and Main.
real(rp), dimension(:,:), allocatable, public atmos_grid_cartesc_real_lon
longitude [rad,0-2pi]
subroutine, public file_open(basename, fid, mode, single, aggregate, rankid, postfix)
integer, public is
start point of inner domain: x, local
integer, public ie
end point of inner domain: x, local
integer, dimension(2), public parent_jmax
parent max number in y-direction
integer, public comm_cartesc_nest_interp_level
horizontal interpolation level
module atmosphere / grid / cartesC index
integer, public je
end point of inner domain: y, local
real(rp), dimension(:,:), allocatable, public landuse_fact_ocean
ocean factor
module atmosphere / grid / cartesC
subroutine, public interp_domain_compatibility(lon_org, lat_org, topc_org, lon_loc, lat_loc, topc_loc, topf_loc, skip_x, skip_y, skip_z)
integer, public prc_myrank
process num in local communicator
integer, dimension(:,:), allocatable, public prc_2drank
node index in 2D topology
subroutine, public interp_interp2d(npoints, IA_ref, JA_ref, IA, JA, idx_i, idx_j, hfact, val_ref, val)
subroutine, public prc_abort
Abort Process.
integer, public jag
of computational grids
module Communication CartesianC nesting
integer, public js
start point of inner domain: y, local
subroutine, public comm_cartesc_nest_domain_shape(tilei, tilej, cxs, cxe, cys, cye, pxs, pxe, pys, pye, iloc)
Return shape of ParentDomain at the specified rank (for offline)
integer, dimension(:), allocatable, public comm_cartesc_nest_tile_id
parent tile real id
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cbfyg
center buffer factor (0-1): y, global
real(rp), public const_eps
small number
module Atmosphere GRID CartesC Real(real space)
integer, dimension(2), public parent_imax
parent max number in x-direction
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_fyg
face coordinate [m]: y, global
subroutine, public interp_factor2d(npoints, IA_ref, JA_ref, lon_ref, lat_ref, IA, JA, lon, lat, idx_i, idx_j, hfact, search_limit, latlon_structure, weight_order)
integer, public comm_cartesc_nest_tile_num_x
parent tile number in x-direction