47 private :: copytopo_transgrid
48 private :: copytopo_setalpha
49 private :: copytopo_input_data
50 private :: copytopo_mix_data
56 integer,
private,
parameter :: handle = 1
57 integer,
private :: itp_nh = 4
59 character(len=H_LONG),
private :: copytopo_in_basename =
'' 61 real(RP),
private :: copytopo_transition_dx = -1.0_rp
62 real(RP),
private :: copytopo_transition_dy = -1.0_rp
63 real(RP),
private :: copytopo_transfact = -1.0_rp
64 real(RP),
private :: copytopo_fracx = 1.0_rp
65 real(RP),
private :: copytopo_fracy = 1.0_rp
66 real(RP),
private :: copytopo_taux = 1.0_rp
67 real(RP),
private :: copytopo_tauy = 1.0_rp
69 logical,
private :: copytopo_entire_region = .false.
70 logical,
private :: copytopo_linear_h = .true.
71 real(RP),
private :: copytopo_exp_h = 2.0_rp
73 real(RP),
private,
allocatable :: ctrx(:)
74 real(RP),
private,
allocatable :: ctry(:)
75 real(RP),
private,
allocatable :: copytopo_alpha(:,:)
76 real(RP),
private,
allocatable :: topo_pd(:,:)
96 real(RP),
intent(inout) :: topo_cd(:,:)
98 namelist / param_copytopo / &
99 copytopo_in_basename, &
100 copytopo_transition_dx, &
101 copytopo_transition_dy, &
102 copytopo_transfact, &
107 copytopo_entire_region, &
115 if(
io_l )
write(
io_fid_log,*)
'+++ Module[COPYTOPO]/Categ[COPYTOPO]' 121 if(
io_l )
write(
io_fid_log,*)
'*** Not found namelist. Default used.' 122 elseif( ierr > 0 )
then 123 write(*,*)
'xxx Not appropriate names in namelist PARAM_COPYTOPO. Check!' 128 if ( copytopo_transition_dx < 0.0_rp )
then 131 if ( copytopo_transition_dy < 0.0_rp )
then 134 if ( copytopo_transfact < 0.0_rp )
then 140 allocate( copytopo_alpha(
ia,
ja) )
141 allocate( topo_pd(
ia,
ja) )
142 copytopo_alpha(:,:) = 0.0_rp
147 call copytopo_transgrid
149 call copytopo_setalpha
151 call copytopo_input_data( topo_pd )
153 call copytopo_mix_data( topo_cd, &
165 subroutine copytopo_transgrid
188 real(RP),
allocatable :: CTRXG(:)
189 real(RP),
allocatable :: CTRYG(:)
191 real(RP),
allocatable :: buffx(:), buffy(:)
192 real(RP) :: bufftotx, bufftoty
193 real(RP),
allocatable :: transx(:), transy(:)
194 real(RP) :: transtotx, transtoty
197 integer :: imain, ibuff, itrans
198 integer :: jmain, jbuff, jtrans
199 integer :: copy_is, copy_ie, copy_js, copy_je
200 integer :: i, j, ii, jj
207 allocate( buffx(0:iag) )
208 allocate( buffy(0:jag) )
209 allocate( transx(0:iag) )
210 allocate( transy(0:jag) )
211 allocate( ctrxg( iag) )
212 allocate( ctryg( jag) )
222 if( abs(cbfxg(i) - 0.0_rp) < eps )
exit 224 bufftotx = bufftotx + buffx(i)
226 ibuff = i - (
ihalo+1)
229 if( transtotx >= copytopo_transition_dx )
exit 230 transx(i) = transx(i-1) * copytopo_transfact
231 transtotx = transtotx + transx(i)
234 imain = iag - 2*ibuff - 2*itrans - 2*
ihalo 236 if ( imain < 1 )
then 237 write(*,*)
'xxx Not appropriate transition width for global domain(X).', copytopo_transition_dx
238 write(*,*)
' # of buffer region (one side)', ibuff
239 write(*,*)
' # of transion region (one side)', itrans
245 do i = 1,
ihalo+ibuff
249 if ( itrans > 0 )
then 250 copy_is =
ihalo+ibuff+1
251 copy_ie =
ihalo+ibuff+itrans
252 do i = copy_is, copy_ie
253 ctrxg(i) = (transtotx+bufftotx+fxg(
ihalo )-cxg(i)) / transtotx
255 copy_is =
ihalo+ibuff+itrans+imain+1
256 copy_ie =
ihalo+ibuff+itrans+imain+itrans+ibuff
257 do i = copy_is, copy_ie
258 ctrxg(i) = (transtotx+bufftotx-fxg(iag-
ihalo)+cxg(i)) / transtotx
262 copy_is =
ihalo+ibuff+itrans+imain+itrans+ibuff+1
263 copy_ie =
ihalo+ibuff+itrans+imain+itrans+ibuff+
ihalo 264 do i = copy_is, copy_ie
267 ctrxg(:) = max( min( ctrxg(:), 1.0_rp ), 0.0_rp )
277 if( abs(cbfyg(j) - 0.0_rp) < eps )
exit 279 bufftoty = bufftoty + buffy(j)
281 jbuff = j - (
jhalo+1)
284 if( transtoty >= copytopo_transition_dy )
exit 285 transy(j) = transy(j-1) * copytopo_transfact
286 transtoty = transtoty + transy(j)
289 jmain = jag - 2*jbuff - 2*jtrans - 2*
jhalo 291 if ( jmain < 1 )
then 292 write(*,*)
'xxx Not appropriate transition width for global domain(Y).', copytopo_transition_dy
293 write(*,*)
' # of buffer region (one side)', jbuff
294 write(*,*)
' # of transion region (one side)', jtrans
300 do j = 1,
jhalo+jbuff
304 if ( jtrans > 0 )
then 305 copy_js =
jhalo+jbuff+1
306 copy_je =
jhalo+jbuff+jtrans
307 do j = copy_js, copy_je
308 ctryg(j) = (transtoty+bufftoty+fyg(
jhalo )-cyg(j)) / transtoty
310 copy_js =
jhalo+jbuff+jtrans+jmain+1
311 copy_je =
jhalo+jbuff+jtrans+jmain+jtrans+jbuff
312 do j = copy_js, copy_je
313 ctryg(j) = (transtoty+bufftoty-fyg(jag-
jhalo)+cyg(j)) / transtoty
317 copy_js =
jhalo+jbuff+jtrans+jmain+jtrans+jbuff+1
318 copy_je =
jhalo+jbuff+jtrans+jmain+jtrans+jbuff+
jhalo 319 do j = copy_js, copy_je
322 ctryg(:) = max( min( ctryg(:), 1.0_rp ), 0.0_rp )
338 end subroutine copytopo_transgrid
343 subroutine copytopo_setalpha
350 real(RP) :: coef_x, alpha_x1
351 real(RP) :: coef_y, alpha_y1
358 copytopo_fracx = max( min( copytopo_fracx, 1.0_rp ), eps )
359 copytopo_fracy = max( min( copytopo_fracy, 1.0_rp ), eps )
361 if ( copytopo_taux <= 0.0_rp )
then 364 coef_x = 1.0_rp / copytopo_taux
367 if ( copytopo_tauy <= 0.0_rp )
then 370 coef_y = 1.0_rp / copytopo_tauy
376 if ( ee1 <= 1.0_rp - copytopo_fracx )
then 379 ee1 = ( ee1 - 1.0_rp + copytopo_fracx ) / copytopo_fracx
382 if ( copytopo_linear_h )
then 383 alpha_x1 = coef_x * ee1
385 alpha_x1 = coef_x * ee1 * exp( -(1.0_rp-ee1) * copytopo_exp_h )
389 if ( ee1 <= 1.0_rp - copytopo_fracy )
then 392 ee1 = ( ee1 - 1.0_rp + copytopo_fracy ) / copytopo_fracy
395 if ( copytopo_linear_h )
then 396 alpha_y1 = coef_y * ee1
398 alpha_y1 = coef_y * ee1 * exp( -(1.0_rp-ee1) * copytopo_exp_h )
401 copytopo_alpha(i,j) = max( alpha_x1, alpha_y1 )
405 call comm_vars8( copytopo_alpha(:,:), 1 )
406 call comm_wait ( copytopo_alpha(:,:), 1 )
409 end subroutine copytopo_setalpha
414 subroutine copytopo_input_data( &
437 real(RP),
intent(out) :: topo_pd(:,:)
439 real(RP) :: dummy (1,1,1)
440 real(RP),
allocatable :: read2D(:,:)
441 real(RP),
allocatable :: lon_org (:,:)
442 real(RP),
allocatable :: lat_org (:,:)
443 real(RP),
allocatable :: topo_org(:,:)
444 real(RP),
allocatable :: hfact(:,:,:)
445 integer,
allocatable :: igrd (:,:,:)
446 integer,
allocatable :: jgrd (:,:,:)
448 integer :: IALL, JALL
450 integer :: tilei, tilej
453 integer :: cxs, cxe, cys, cye
454 integer :: pxs, pxe, pys, pye
462 allocate( hfact(
ia,
ja, itp_nh ) )
463 allocate( igrd(
ia,
ja, itp_nh ) )
464 allocate( jgrd(
ia,
ja, itp_nh ) )
465 allocate( lon_org( iall, jall ) )
466 allocate( lat_org( iall, jall ) )
467 allocate( topo_org( iall, jall ) )
479 allocate( read2d( tilei,tilej ) )
481 call fileread( read2d(:,:), copytopo_in_basename,
"lon", 1, rank )
482 lon_org(cxs:cxe,cys:cye) = read2d(pxs:pxe,pys:pye) * d2r
483 call fileread( read2d(:,:), copytopo_in_basename,
"lat", 1, rank )
484 lat_org(cxs:cxe,cys:cye) = read2d(pxs:pxe,pys:pye) * d2r
485 call fileread( read2d(:,:), copytopo_in_basename,
"TOPO", 1, rank )
486 topo_org(cxs:cxe,cys:cye) = read2d(pxs:pxe,pys:pye)
492 lon(:,:), lat(:,:), dummy(:,:,:), &
515 call comm_vars8( topo_pd(:,:), 1 )
516 call comm_wait ( topo_pd(:,:), 1 )
519 end subroutine copytopo_input_data
523 subroutine copytopo_mix_data( &
527 real(RP),
intent(inout) :: topo_cd(:,:)
528 real(RP),
intent(in) :: topo_pd(:,:)
534 if ( copytopo_entire_region )
then 535 topo_cd(:,:) = topo_pd(:,:)
539 frac = copytopo_alpha(i,j)
540 topo_cd(i,j) = topo_cd(i,j) * ( 1.0_rp - frac ) &
541 + topo_pd(i,j) * frac
547 end subroutine copytopo_mix_data
integer, public imax
of computational cells: x
integer, public prc_num_x
x length of 2D processor topology
real(rp), public buffer_dx
thickness of buffer region [m]: x
subroutine, public intrpnest_domain_compatibility(lon_org, lat_org, lev_org, lon_loc, lat_loc, lev_loc, skip_x, skip_y, skip_z)
real(rp), public dy
length in the main region [m]: y
real(rp), dimension(:), allocatable, public grid_cyg
center coordinate [m]: y, global
subroutine, public prc_mpistop
Abort MPI.
real(rp), dimension(:), allocatable, public grid_cbfyg
center buffer factor [0-1]: y, global
integer, parameter, public i_dem50m
integer, dimension(2), public parent_jmax
parent max number in y-direction
module GRID (nesting system)
real(rp), dimension(:), allocatable, public grid_cxg
center coordinate [m]: x, global
real(rp), public dx
length in the main region [m]: x
logical, public io_l
output log or not? (this process)
real(rp), dimension(:), allocatable, public grid_fxg
face coordinate [m]: x, global
real(rp), public const_radius
radius of the planet [m]
real(rp), public const_d2r
degree to radian
procedure(intrpnest_intfc_interp_2d), pointer, public intrpnest_interp_2d
integer, dimension(:), allocatable, public nest_tile_id
parent tile real id
integer, public nest_interp_level
horizontal interpolation level
subroutine, public intrpnest_interp_fact_latlon(hfact, igrd, jgrd, mylat, mylon, myIA, myJA, inlat, inlon, inIA, inJA)
integer, parameter, public i_gtopo30
integer, public prc_num_y
y length of 2D processor topology
subroutine, public 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, public ia
of x whole cells (local, with HALO)
integer, parameter, public i_gmted2010
integer, parameter, public i_ignore
integer, public jhalo
of halo cells: y
integer, public nest_tile_num_y
parent tile number in y-direction
integer, public prc_myrank
process num in local communicator
module INTERPOLATION (nesting system)
subroutine, public copytopo(topo_cd)
Setup and Main.
real(rp), public buffer_dy
thickness of buffer region [m]: y
integer, dimension(2), public parent_imax
parent max number in x-direction
real(rp), public const_eps
small number
logical, public io_lnml
output log or not? (for namelist, this process)
real(rp), dimension(:,:), allocatable, public real_lon
longitude [rad,0-2pi]
integer, public nest_tile_num_x
parent tile number in x-direction
integer, public cnvtopo_type
integer, dimension(:,:), allocatable, public prc_2drank
node index in 2D topology
integer, public io_fid_conf
Config file ID.
real(rp), dimension(:,:), allocatable, public real_lat
latitude [rad,-pi,pi]
integer, public io_fid_log
Log file ID.
real(rp), public bufffact
strech factor for dx/dy/dz of buffer region
integer, public jmax
of computational cells: y
real(rp), dimension(:), allocatable, public grid_fyg
face coordinate [m]: y, global
real(rp), dimension(:), allocatable, public grid_cbfxg
center buffer factor [0-1]: x, global
integer, public ihalo
of halo cells: x
integer, public ja
of y whole cells (local, with HALO)