SCALE-RM
mod_copytopo.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
9 !-------------------------------------------------------------------------------
10 #include "scalelib.h"
12  !-----------------------------------------------------------------------------
13  !
14  !++ used modules
15  !
16  use scale_precision
17  use scale_io
18  use scale_prof
20  use scale_tracer
21  !-----------------------------------------------------------------------------
22  implicit none
23  private
24  !-----------------------------------------------------------------------------
25  !
26  !++ Public procedure
27  !
28  public :: copytopo
29 
30  !-----------------------------------------------------------------------------
31  !
32  !++ Public parameters & variables
33  !
34  !-----------------------------------------------------------------------------
35  !
36  !++ Private procedure
37  !
38  private :: copytopo_transgrid
39  private :: copytopo_setalpha
40  private :: copytopo_input_data
41  private :: copytopo_mix_data
42 
43  !-----------------------------------------------------------------------------
44  !
45  !++ Private parameters & variables
46  !
47  integer, private, parameter :: handle = 1
48 
49  character(len=H_SHORT), private :: COPYTOPO_IN_FILETYPE = ''
50  character(len=H_LONG), private :: COPYTOPO_IN_BASENAME = ''
51  character(len=H_LONG), private :: COPYTOPO_IN_POSTFIX = ''
52  character(len=H_SHORT), private :: COPYTOPO_IN_VARNAME = 'topo'
53  character(len=H_SHORT), private :: COPYTOPO_IN_LONNAME = 'lon'
54  character(len=H_SHORT), private :: COPYTOPO_IN_LATNAME = 'lat'
55  real(RP), private :: COPYTOPO_TRANSITION_DX = -1.0_rp
56  real(RP), private :: COPYTOPO_TRANSITION_DY = -1.0_rp
57  real(RP), private :: COPYTOPO_FRACX = 1.0_rp
58  real(RP), private :: COPYTOPO_FRACY = 1.0_rp
59  real(RP), private :: COPYTOPO_taux = 1.0_rp
60  real(RP), private :: COPYTOPO_tauy = 1.0_rp
61  logical, private :: COPYTOPO_ENTIRE_REGION = .false.
62  logical, private :: COPYTOPO_LINEAR_H = .true.
63  real(RP), private :: COPYTOPO_EXP_H = 2.0_rp
64  character(len=H_SHORT), private :: COPYTOPO_INTRP_TYPE = "LINEAR"
65  integer, private :: COPYTOPO_hypdiff_ORDER = 4
66  integer, private :: COPYTOPO_hypdiff_NITER = 20
67 
68  !-----------------------------------------------------------------------------
69 contains
70  !-----------------------------------------------------------------------------
72  subroutine copytopo( &
73  TOPO_child )
74  use scale_prc, only: &
75  prc_abort
76  implicit none
77 
78  real(rp), intent(inout) :: topo_child(:,:)
79 
80  real(rp) :: ctrx (ia)
81  real(rp) :: ctry (ja)
82  real(rp) :: alpha (ia,ja)
83  real(rp) :: topo_parent(ia,ja)
84 
85  namelist / param_copytopo / &
86  copytopo_in_filetype, &
87  copytopo_in_basename, &
88  copytopo_in_postfix, &
89  copytopo_in_varname, &
90  copytopo_in_lonname, &
91  copytopo_in_latname, &
92  copytopo_transition_dx, &
93  copytopo_transition_dy, &
94  copytopo_fracx, &
95  copytopo_fracy, &
96  copytopo_taux, &
97  copytopo_tauy, &
98  copytopo_entire_region, &
99  copytopo_linear_h, &
100  copytopo_exp_h, &
101  copytopo_hypdiff_order, &
102  copytopo_hypdiff_niter
103 
104  integer :: ierr
105  !---------------------------------------------------------------------------
106 
107  log_newline
108  log_info("COPYTOPO",*) 'Setup'
109 
110  !--- read namelist
111  rewind(io_fid_conf)
112  read(io_fid_conf,nml=param_copytopo,iostat=ierr)
113  if( ierr < 0 ) then !--- missing
114  log_info("COPYTOPO",*) 'Not found namelist. Default used.'
115  elseif( ierr > 0 ) then !--- fatal error
116  log_error("COPYTOPO",*) 'Not appropriate names in namelist PARAM_COPYTOPO. Check!'
117  call prc_abort
118  endif
119  log_nml(param_copytopo)
120 
121  ! copy topography from parent domain to transition region
122 
123  call copytopo_transgrid( ctrx(:), ctry(:) ) ! [OUT]
124 
125  call copytopo_setalpha ( ctrx(:), ctry(:), & ! [IN]
126  alpha(:,:) ) ! [OUT]
127 
128  call copytopo_input_data( topo_parent(:,:) ) ! [OUT]
129 
130  call copytopo_mix_data( topo_parent(:,:), & ! [IN]
131  alpha(:,:), & ! [IN]
132  topo_child(:,:) ) ! [INOUT]
133 
134  return
135  end subroutine copytopo
136 
137  !-----------------------------------------------------------------------------
139  subroutine copytopo_transgrid( &
140  CTRX, &
141  CTRY )
142  use scale_prc, only: &
143  prc_abort, &
144  prc_myrank
145  use scale_prc_cartesc, only: &
146  prc_2drank
147  use scale_const, only: &
148  eps => const_eps
149  use scale_atmos_grid_cartesc, only: &
150  cxg => atmos_grid_cartesc_cxg, &
151  fxg => atmos_grid_cartesc_fxg, &
152  cyg => atmos_grid_cartesc_cyg, &
153  fyg => atmos_grid_cartesc_fyg, &
154  cbfxg => atmos_grid_cartesc_cbfxg, &
155  cbfyg => atmos_grid_cartesc_cbfyg
156  implicit none
157 
158  real(rp), intent(out) :: ctrx(ia)
159  real(rp), intent(out) :: ctry(ja)
160 
161  real(rp) :: ctrxg ( iag)
162  real(rp) :: ctryg ( jag)
163 
164  real(rp) :: bufftotx, transtotx
165  real(rp) :: bufftoty, transtoty
166  integer :: imain, ibuff, itrans
167  integer :: jmain, jbuff, jtrans
168  integer :: copy_is, copy_ie
169  integer :: copy_js, copy_je
170 
171  integer :: i, j, ii, jj
172  !---------------------------------------------------------------------------
173 
174  ! X-direction
175  ! calculate buffer grid size
176 
177  do i = ihalo+1, iag
178  if( abs(cbfxg(i)) < eps ) exit
179  enddo
180  ibuff = i - 1 - ihalo
181  if ( ibuff == 0 ) then
182  bufftotx = 0.0_rp
183  else
184  bufftotx = fxg(ibuff+ihalo) - fxg(ihalo)
185  end if
186 
187  if ( copytopo_transition_dx < 0.0_rp ) then
188  copytopo_transition_dx = bufftotx
189  end if
190  do i = ibuff+ihalo+1, iag
191  if( cxg(i) - bufftotx - fxg(ihalo) >= copytopo_transition_dx ) exit
192  enddo
193  itrans = i - 1 - ihalo - ibuff
194  if ( itrans == 0 ) then
195  transtotx = 0.0_rp
196  else
197  transtotx = fxg(itrans+ibuff+ihalo) - fxg(ihalo) - bufftotx
198  end if
199 
200  imain = iag - 2*ibuff - 2*itrans - 2*ihalo
201 
202  if ( imain < 1 ) then
203  log_error("COPYTOPO_transgrid",*) 'Not appropriate transition width for global domain(X).', copytopo_transition_dx
204  log_error_cont(*) '# of buffer region (one side) = ', ibuff
205  log_error_cont(*) '# of transion region (one side) = ', itrans
206  call prc_abort
207  endif
208 
209  ! calc transition factor (global domaim)
210  ctrxg(:) = 0.0_rp
211 
212  copy_is = 1
213  copy_ie = ihalo+ibuff
214  !$omp parallel do
215  do i = copy_is, copy_ie
216  ctrxg(i) = 1.0_rp
217  enddo
218 
219  if ( itrans > 0 ) then
220  copy_is = ihalo+ibuff+1
221  copy_ie = ihalo+ibuff+itrans
222  !$omp parallel do
223  do i = copy_is, copy_ie
224  ctrxg(i) = (transtotx+bufftotx+fxg(ihalo )-cxg(i)) / transtotx
225  enddo
226  copy_is = iag - ihalo - ibuff - itrans + 1
227  copy_ie = iag - ihalo - ibuff
228  !$omp parallel do
229  do i = copy_is, copy_ie
230  ctrxg(i) = (transtotx+bufftotx-fxg(iag-ihalo)+cxg(i)) / transtotx
231  enddo
232  endif
233 
234  copy_is = iag - ihalo - ibuff + 1
235  copy_ie = iag
236  !$omp parallel do
237  do i = copy_is, copy_ie
238  ctrxg(i) = 1.0_rp
239  enddo
240 
241  ctrxg(:) = max( min( ctrxg(:), 1.0_rp ), 0.0_rp )
242 
243  ! Y-direction
244  ! calculate buffer grid size
245  do j = jhalo+1, jag
246  if( abs(cbfyg(j)) < eps ) exit
247  enddo
248  jbuff = j - 1 - jhalo
249  if ( jbuff == 0 ) then
250  bufftoty = 0.0_rp
251  else
252  bufftoty = fyg(jbuff+jhalo) - fyg(jhalo)
253  end if
254 
255  if ( copytopo_transition_dy < 0.0_rp ) then
256  copytopo_transition_dy = bufftoty
257  end if
258  do j = jbuff+jhalo+1, jag
259  if( cyg(j) - bufftoty - fyg(jhalo) >= copytopo_transition_dy ) exit
260  enddo
261  jtrans = j - 1 - jhalo - jbuff
262  if ( jtrans == 0 ) then
263  transtoty = 0.0_rp
264  else
265  transtoty = fyg(jtrans+jbuff+jhalo) - fyg(jhalo) - bufftoty
266  end if
267 
268  jmain = jag - 2*jbuff - 2*jtrans - 2*jhalo
269 
270  if ( jmain < 1 ) then
271  log_error("COPYTOPO_transgrid",*) 'Not appropriate transition width for global domain(Y).', copytopo_transition_dy
272  log_error_cont(*) '# of buffer region (one side)', jbuff
273  log_error_cont(*) '# of transion region (one side)', jtrans
274  call prc_abort
275  endif
276 
277  ! calc transition factor (global domaim)
278  ctryg(:) = 0.0_rp
279 
280  copy_js = 1
281  copy_je = jhalo+jbuff
282  !$omp parallel do
283  do j = copy_js, copy_je
284  ctryg(j) = 1.0_rp
285  enddo
286 
287  if ( jtrans > 0 ) then
288  copy_js = jhalo+jbuff+1
289  copy_je = jhalo+jbuff+jtrans
290  !$omp parallel do
291  do j = copy_js, copy_je
292  ctryg(j) = (transtoty+bufftoty+fyg(jhalo )-cyg(j)) / transtoty
293  enddo
294  copy_js = jag - jhalo - jbuff - jtrans + 1
295  copy_je = jag - jhalo - jbuff
296  !$omp parallel do
297  do j = copy_js, copy_je
298  ctryg(j) = (transtoty+bufftoty-fyg(jag-jhalo)+cyg(j)) / transtoty
299  enddo
300  endif
301 
302  copy_js = jag - jhalo - jbuff + 1
303  copy_je = jag
304  !$omp parallel do
305  do j = copy_js, copy_je
306  ctryg(j) = 1.0_rp
307  enddo
308 
309  ctryg(:) = max( min( ctryg(:), 1.0_rp ), 0.0_rp )
310 
311 
312 
313  ! horizontal coordinate (local domaim)
314  !$omp parallel do &
315  !$omp private(ii)
316  do i = 1, ia
317  ii = i + prc_2drank(prc_myrank,1) * imax
318  ctrx(i) = ctrxg(ii)
319  enddo
320 
321  !$omp parallel do &
322  !$omp private(jj)
323  do j = 1, ja
324  jj = j + prc_2drank(prc_myrank,2) * jmax
325  ctry(j) = ctryg(jj)
326  enddo
327 
328  log_info("COPYTOPO_transgrid",*) 'COPYTOPO grid Information'
329  log_info_cont(*) 'size of buffer region (x and y; one side) = ', bufftotx, bufftoty
330  log_info_cont(*) '# of buffer region (x and y; one side) = ', ibuff, jbuff
331  log_info_cont(*) 'size of transion region (x and y; one side) = ', transtotx, transtoty
332  log_info_cont(*) '# of transion region (x and y; one side) = ', itrans, jtrans
333 
334 
335  return
336  end subroutine copytopo_transgrid
337 
338 
339  !-----------------------------------------------------------------------------
341  subroutine copytopo_setalpha( &
342  CTRX, &
343  CTRY, &
344  alpha )
345  use scale_const, only: &
346  eps => const_eps
347  use scale_comm_cartesc, only: &
348  comm_vars8, &
349  comm_wait
350  implicit none
351 
352  real(rp), intent(in) :: ctrx (ia)
353  real(rp), intent(in) :: ctry (ja)
354  real(rp), intent(out) :: alpha(ia,ja)
355 
356  real(rp) :: coef_x, alpha_x1
357  real(rp) :: coef_y, alpha_y1
358  real(rp) :: ee1
359 
360  integer :: i, j
361  !---------------------------------------------------------------------------
362 
363  ! check invalid fraction
364  copytopo_fracx = max( min( copytopo_fracx, 1.0_rp ), eps )
365  copytopo_fracy = max( min( copytopo_fracy, 1.0_rp ), eps )
366 
367  if ( copytopo_taux <= 0.0_rp ) then ! invalid tau
368  coef_x = 0.0_rp
369  else
370  coef_x = 1.0_rp / copytopo_taux
371  endif
372 
373  if ( copytopo_tauy <= 0.0_rp ) then ! invalid tau
374  coef_y = 0.0_rp
375  else
376  coef_y = 1.0_rp / copytopo_tauy
377  endif
378 
379  !$omp parallel do &
380  !$omp private(ee1,alpha_x1,alpha_y1)
381  do j = 1, ja
382  do i = 1, ia
383  ee1 = ctrx(i)
384 
385  if ( ee1 <= 1.0_rp - copytopo_fracx ) then
386  ee1 = 0.0_rp
387  else
388  ee1 = ( ee1 - 1.0_rp + copytopo_fracx ) / copytopo_fracx
389  endif
390 
391  if ( copytopo_linear_h ) then
392  alpha_x1 = coef_x * ee1
393  else
394  alpha_x1 = coef_x * ee1 * exp( -(1.0_rp-ee1) * copytopo_exp_h )
395  endif
396 
397  ee1 = ctry(j)
398 
399  if ( ee1 <= 1.0_rp - copytopo_fracy ) then
400  ee1 = 0.0_rp
401  else
402  ee1 = ( ee1 - 1.0_rp + copytopo_fracy ) / copytopo_fracy
403  endif
404 
405  if ( copytopo_linear_h ) then
406  alpha_y1 = coef_y * ee1
407  else
408  alpha_y1 = coef_y * ee1 * exp( -(1.0_rp-ee1) * copytopo_exp_h )
409  endif
410 
411  alpha(i,j) = max( alpha_x1, alpha_y1 )
412  enddo
413  enddo
414 
415  call comm_vars8( alpha(:,:), 1 )
416  call comm_wait ( alpha(:,:), 1 )
417 
418  return
419  end subroutine copytopo_setalpha
420 
421 
422  !-----------------------------------------------------------------------------
424  subroutine copytopo_input_data( &
425  TOPO_parent )
426  use scale_prc, only: &
427  prc_abort, &
429  use scale_const, only: &
430  eps => const_eps, &
431  pi => const_pi
432  use scale_interp, only: &
434  interp_factor2d, &
436  use scale_comm_cartesc, only: &
437  comm_bcast, &
438  comm_vars8, &
439  comm_wait
440  use scale_atmos_grid_cartesc_real, only: &
443  use scale_atmos_grid_cartesc, only: &
444  cx => atmos_grid_cartesc_cx, &
446  use scale_mapprojection, only: &
447  mapprojection_lonlat2xy
448  use scale_filter, only: &
449  filter_hyperdiff
450  use scale_landuse, only: &
452  use scale_comm_cartesc_nest, only: &
453  nest_interp_level => comm_cartesc_nest_interp_level
454  implicit none
455 
456  real(rp), intent(out) :: topo_parent(:,:)
457 
458  integer :: ia_org, ja_org
459 
460  real(rp), allocatable :: lon_org (:,:), lat_org(:,:)
461  real(rp), allocatable :: x_org (:,:), y_org (:,:)
462  real(rp), allocatable :: topo_org(:,:)
463 
464  logical :: single
465 
466  ! for interpolation
467  real(rp) :: dummy(1,1)
468  integer :: idx_i(ia,ja,nest_interp_level)
469  integer :: idx_j(ia,ja,nest_interp_level)
470  real(rp) :: hfact(ia,ja,nest_interp_level)
471  integer :: interp_level
472  logical :: zonal, pole
473 
474  real(rp) :: topo_sign(ia,ja)
475  real(rp) :: ocean_flag
476 
477  integer :: i, j
478  !---------------------------------------------------------------------------
479 
480  select case ( copytopo_in_filetype )
481  case ( 'SCALE' )
482  call copytopo_get_size_scale( ia_org, ja_org ) ! (out)
483  single = .false.
484  case ( 'GrADS' )
485  if ( prc_ismaster ) call copytopo_get_size_grads( ia_org, ja_org ) ! (out)
486  single = .true.
487  case ( 'WRF-ARW' )
488  if ( prc_ismaster ) call copytopo_get_size_wrfarw( ia_org, ja_org ) ! (out)
489  single = .true.
490  case default
491  log_error("COPYTOPO_input_data",*) 'COPYTOPO_IN_FILETYPE must be "SCALE" or "GrADS"'
492  call prc_abort
493  end select
494 
495  if ( single ) then
496  call comm_bcast( ia_org )
497  call comm_bcast( ja_org )
498  end if
499 
500  allocate( lon_org(ia_org,ja_org) )
501  allocate( lat_org(ia_org,ja_org) )
502  allocate( topo_org(ia_org,ja_org) )
503 
504  select case ( copytopo_in_filetype )
505  case ( 'SCALE' )
506  call copytopo_get_data_scale( ia_org, ja_org, & ! (in)
507  lon_org(:,:), lat_org(:,:), topo_org(:,:) ) ! (out)
508  case ( 'GrADS' )
509  if ( prc_ismaster ) &
510  call copytopo_get_data_grads( ia_org, ja_org, & ! (in)
511  lon_org(:,:), lat_org(:,:), topo_org(:,:) ) ! (out)
512  case ( 'WRF-ARW' )
513  if ( prc_ismaster ) &
514  call copytopo_get_data_wrfarw( ia_org, ja_org, & ! (in)
515  lon_org(:,:), lat_org(:,:), topo_org(:,:) ) ! (out)
516  end select
517 
518  if ( single ) then
519  call comm_bcast( lon_org(:,:), ia_org, ja_org )
520  call comm_bcast( lat_org(:,:), ia_org, ja_org )
521  call comm_bcast( topo_org(:,:), ia_org, ja_org )
522  end if
523 
524  call interp_domain_compatibility( lon_org(:,:), lat_org(:,:), dummy(:,:), &
525  lon(:,:), lat(:,:), dummy(:,:), dummy(:,:), &
526  skip_z=.true. )
527 
528  select case ( copytopo_intrp_type )
529  case ( "LINEAR" )
530 
531  allocate( x_org(ia_org,ja_org) )
532  allocate( y_org(ia_org,ja_org) )
533  call mapprojection_lonlat2xy( ia_org, 1, ia_org, ja_org, 1, ja_org, &
534  lon_org(:,:), lat_org(:,:), & ! [IN]
535  x_org(:,:), y_org(:,:) ) ! [OUT]
536 
537  zonal = ( maxval(lon_org) - minval(lon_org) ) > 2.0_rp * pi * 0.9_rp
538  pole = ( maxval(lat_org) > pi * 0.5_rp * 0.9_rp ) .or. ( minval(lat_org) < - pi * 0.5_rp * 0.9_rp )
539  call interp_factor2d( ia_org, ja_org, ia, ja, & ! [IN]
540  x_org(:,:), y_org(:,:), & ! [IN]
541  cx(:), cy(:), & ! [IN]
542  idx_i(:,:,:), idx_j(:,:,:), & ! [OUT]
543  hfact(:,:,:), & ! [OUT]
544  zonal = zonal, pole = pole ) ! [IN]
545  deallocate( x_org, y_org )
546  interp_level = 4
547 
548  case ( "DIST-WEIGHT" )
549 
550  call interp_factor2d( nest_interp_level, & ! [IN]
551  ia_org, ja_org, ia, ja, & ! [IN]
552  lon_org(:,:), lat_org(:,:), & ! [IN]
553  lon(:,:), lat(:,:), & ! [IN]
554  idx_i(:,:,:), idx_j(:,:,:), & ! [OUT]
555  hfact(:,:,:) ) ! [OUT]
556  interp_level = nest_interp_level
557 
558  case default
559  log_error("COPYTOPO_input_data",*) "Unsupported type of COPYTOPO_INTRP_TYPE : ", trim(copytopo_intrp_type)
560  log_error_cont(*) 'It must be "LINEAR" or "DIST-WEIGHT"'
561  call prc_abort
562  end select
563 
564  call interp_interp2d( interp_level, & ! [IN]
565  ia_org, ja_org, & ! [IN]
566  ia, ja, & ! [IN]
567  idx_i(:,:,:), & ! [IN]
568  idx_j(:,:,:), & ! [IN]
569  hfact(:,:,:), & ! [IN]
570  topo_org(:,:), & ! [IN]
571  topo_parent(:,:) ) ! [OUT]
572 
573  deallocate( topo_org, lon_org, lat_org )
574 
575  if ( copytopo_hypdiff_niter > 1 ) then
576  !$omp parallel do &
577  !$omp private(ocean_flag)
578  do j = 1, ja
579  do i = 1, ia
580  ocean_flag = ( 0.5_rp + sign( 0.5_rp, landuse_fact_ocean(i,j) - 1.0_rp + eps ) ) & ! fact_ocean==1
581  * ( 0.5_rp + sign( 0.5_rp, eps - abs(topo_parent(i,j)) ) ) ! |TOPO| > EPS
582  topo_sign(i,j) = sign( 1.0_rp, topo_parent(i,j) ) * ( 1.0_rp - ocean_flag )
583  end do
584  end do
585 
586  call filter_hyperdiff( ia, isb, ieb, ja, jsb, jeb, &
587  topo_parent(:,:), copytopo_hypdiff_order, copytopo_hypdiff_niter, &
588  limiter_sign = topo_sign(:,:) )
589  end if
590 
591 
592  call comm_vars8( topo_parent(:,:), 1 )
593  call comm_wait ( topo_parent(:,:), 1 )
594 
595 
596  return
597  end subroutine copytopo_input_data
598 
599  !-----------------------------------------------------------------------------
601  subroutine copytopo_mix_data( &
602  TOPO_parent, &
603  alpha, &
604  TOPO_child )
605  implicit none
606 
607  real(rp), intent(in) :: topo_parent(:,:) ! topography of parent domain
608  real(rp), intent(in) :: alpha (:,:) ! dumping coefficient (0-1)
609  real(rp), intent(inout) :: topo_child (:,:) ! topography of child domain
610 
611  integer :: i, j
612  !---------------------------------------------------------------------------
613 
614  if ( copytopo_entire_region ) then
615  !$omp parallel do
616  do j = 1, ja
617  do i = 1, ia
618  topo_child(i,j) = topo_parent(i,j)
619  enddo
620  enddo
621  else
622  !$omp parallel do
623  do j = 1, ja
624  do i = 1, ia
625  topo_child(i,j) = ( 1.0_rp-alpha(i,j) ) * topo_child(i,j) &
626  + ( alpha(i,j) ) * topo_parent(i,j)
627  enddo
628  enddo
629  endif
630 
631  return
632  end subroutine copytopo_mix_data
633 
634  !-----------------------------------------------------------------------------
635  subroutine copytopo_get_size_scale( &
636  IA_org, JA_org )
637  use scale_comm_cartesc_nest, only: &
638  nest_tile_num_x => comm_cartesc_nest_tile_num_x, &
639  nest_tile_num_y => comm_cartesc_nest_tile_num_y, &
640  parent_imax, &
642  implicit none
643  integer, intent(out) :: ia_org
644  integer, intent(out) :: ja_org
645 
646  ia_org = parent_imax(handle) * nest_tile_num_x
647  ja_org = parent_jmax(handle) * nest_tile_num_y
648 
649  return
650  end subroutine copytopo_get_size_scale
651 
652  !-----------------------------------------------------------------------------
653  subroutine copytopo_get_data_scale( &
654  IA_org, JA_org, &
655  LON_org, LAT_org, &
656  TOPO_org )
657  use scale_const, only: &
658  d2r => const_d2r
659  use scale_comm_cartesc_nest, only: &
660  nest_domain_shape => comm_cartesc_nest_domain_shape, &
661  nest_tile_id => comm_cartesc_nest_tile_id
662  use scale_file, only: &
663  file_open, &
664  file_read, &
665  file_close
666  implicit none
667  integer, intent(in) :: IA_org, JA_org
668  real(RP), intent(out) :: LON_org (IA_org,JA_org)
669  real(RP), intent(out) :: LAT_org (IA_org,JA_org)
670  real(RP), intent(out) :: TOPO_org(IA_org,JA_org)
671 
672  real(RP), allocatable :: read2D(:,:)
673 
674  integer :: tilei, tilej
675  integer :: cxs, cxe, cys, cye ! for child domain
676  integer :: pxs, pxe, pys, pye ! for parent domain
677  integer :: fid
678 
679  integer :: rank
680  integer :: n
681 
682  do n = 1, size( nest_tile_id(:) )
683  ! read data from split files
684  rank = nest_tile_id(n)
685 
686  call nest_domain_shape( tilei, tilej, & ! [OUT]
687  cxs, cxe, & ! [OUT]
688  cys, cye, & ! [OUT]
689  pxs, pxe, & ! [OUT]
690  pys, pye, & ! [OUT]
691  n ) ! [IN]
692 
693  allocate( read2d(tilei,tilej) )
694 
695  call file_open( copytopo_in_basename, & ! [IN]
696  fid, & ! [OUT]
697  aggregate=.false., rankid=rank ) ! [IN]
698 
699  call file_read( fid, "lon", read2d(:,:) )
700  lon_org(cxs:cxe,cys:cye) = read2d(pxs:pxe,pys:pye) * d2r
701  call file_read( fid, "lat", read2d(:,:) )
702  lat_org(cxs:cxe,cys:cye) = read2d(pxs:pxe,pys:pye) * d2r
703  call file_read( fid, copytopo_in_varname, read2d(:,:) )
704  topo_org(cxs:cxe,cys:cye) = read2d(pxs:pxe,pys:pye)
705  deallocate( read2d )
706 
707  call file_close( fid )
708 
709  enddo
710 
711  return
712  end subroutine copytopo_get_data_scale
713 
714  !-----------------------------------------------------------------------------
715  subroutine copytopo_get_size_grads( &
716  IA_org, JA_org )
717  use scale_file_grads, only: &
718  file_grads_open, &
719  file_grads_get_shape
720  implicit none
721  integer, intent(out) :: IA_org, JA_org
722 
723  integer :: file_id
724  integer :: shape(2)
725 
726  call file_grads_open( copytopo_in_basename, & ! (in)
727  file_id ) ! (out)
728 
729  call file_grads_get_shape( file_id, copytopo_in_varname, & ! (in)
730  shape(:) ) ! (out)
731 
732  ia_org = shape(1)
733  ja_org = shape(2)
734 
735  return
736  end subroutine copytopo_get_size_grads
737 
738  !-----------------------------------------------------------------------------
739  subroutine copytopo_get_data_grads( &
740  IA_org, JA_org, &
741  LON_org, LAT_org, &
742  TOPO_org )
743  use scale_const, only: &
744  d2r => const_d2r
745  use scale_file_grads, only: &
746  file_grads_open, &
749  file_grads_read, &
751  implicit none
752  integer, intent(in) :: IA_org, JA_org
753  real(RP), intent(out) :: LON_org (IA_org,JA_org)
754  real(RP), intent(out) :: LAT_org (IA_org,JA_org)
755  real(RP), intent(out) :: TOPO_org(IA_org,JA_org)
756 
757  integer :: file_id, var_id
758  real(RP) :: lon1D(IA_org), lat1D(JA_org)
759 
760  integer :: i, j
761 
762  call file_grads_open( copytopo_in_basename, & ! (in)
763  file_id ) ! (out)
764 
765  ! lon
766  call file_grads_varid( file_id, copytopo_in_lonname, & ! (in)
767  var_id ) ! (out)
768  if ( file_grads_isoned( file_id, var_id ) ) then
769  call file_grads_read( file_id, var_id, & ! (in)
770  lon1d(:) ) ! (out)
771  !$omp parallel do collapse(2)
772  do j = 1, ja_org
773  do i = 1, ia_org
774  lon_org(i,j) = lon1d(i) * d2r
775  end do
776  end do
777  else
778  call file_grads_read( file_id, var_id, & ! (in)
779  lon_org(:,:), & ! (out)
780  postfix = copytopo_in_postfix ) ! (in)
781  !$omp parallel do collapse(2)
782  do j = 1, ja_org
783  do i = 1, ia_org
784  lon_org(i,j) = lon_org(i,j) * d2r
785  end do
786  end do
787  end if
788 
789  ! lat
790  call file_grads_varid( file_id, copytopo_in_latname, & ! (in)
791  var_id ) ! (out)
792  if ( file_grads_isoned( file_id, var_id ) ) then
793  call file_grads_read( file_id, var_id, & ! (in)
794  lat1d(:) ) ! (out)
795  !$omp parallel do collapse(2)
796  do j = 1, ja_org
797  do i = 1, ia_org
798  lat_org(i,j) = lat1d(j) * d2r
799  end do
800  end do
801  else
802  call file_grads_read( file_id, var_id, & ! (in)
803  lat_org(:,:), & ! (out)
804  postfix = copytopo_in_postfix ) ! (in)
805  !$omp parallel do collapse(2)
806  do j = 1, ja_org
807  do i = 1, ia_org
808  lat_org(i,j) = lat_org(i,j) * d2r
809  end do
810  end do
811  end if
812 
813  ! topo
814  call file_grads_varid( file_id, copytopo_in_varname, & ! (in)
815  var_id ) ! (out)
816  call file_grads_read( file_id, var_id, & ! (in)
817  topo_org(:,:), & ! (out)
818  postfix = copytopo_in_postfix ) ! (in)
819 
820  ! close
821  call file_grads_close( file_id )
822 
823  return
824  end subroutine copytopo_get_data_grads
825 
826  !-----------------------------------------------------------------------------
827  subroutine copytopo_get_size_wrfarw( &
828  IA_org, JA_org )
829  use scale_file_grads, only: &
830  file_grads_open, &
831  file_grads_get_shape
832  use scale_file, only: &
833  file_open, &
835  implicit none
836  integer, intent(out) :: IA_org, JA_org
837 
838  integer :: fid
839 
840  call file_open( copytopo_in_basename, & ! (in)
841  fid, & ! (out)
842  postfix = copytopo_in_postfix, & ! (in)
843  single = .true. ) ! (in)
844 
845  call file_get_dimlength( fid, "west_east", ia_org )
846  call file_get_dimlength( fid, "south_north", ja_org )
847 
848  return
849  end subroutine copytopo_get_size_wrfarw
850 
851  subroutine copytopo_get_data_wrfarw( &
852  IA_org, JA_org, &
853  LON_org, LAT_org, &
854  TOPO_org )
855  use scale_const, only: &
856  d2r => const_d2r
857  use scale_file, only: &
858  file_open, &
859  file_read, &
860  file_close
861  implicit none
862  integer, intent(in) :: IA_org, JA_org
863  real(RP), intent(out) :: LON_org (IA_org,JA_org)
864  real(RP), intent(out) :: LAT_org (IA_org,JA_org)
865  real(RP), intent(out) :: TOPO_org(IA_org,JA_org)
866 
867  integer :: fid
868  integer :: i, j
869 
870  call file_open( copytopo_in_basename, & ! (in)
871  fid, & ! (out)
872  postfix = copytopo_in_postfix, & ! (in)
873  single = .true. ) ! (in)
874 
875  call file_read( fid, "XLAT", lat_org(:,:) )
876 
877  call file_read( fid, "XLONG", lon_org(:,:) )
878 
879  !$omp parallel do collapse(2)
880  do j = 1, ja_org
881  do i = 1, ia_org
882  lat_org(i,j) = lat_org(i,j) * d2r
883  lon_org(i,j) = lon_org(i,j) * d2r
884  end do
885  end do
886 
887  call file_read( fid, "HGT", topo_org(:,:) )
888 
889  call file_close( fid )
890 
891  end subroutine copytopo_get_data_wrfarw
892 
893 end module mod_copytopo
scale_interp::interp_interp2d
subroutine, public interp_interp2d(npoints, IA_ref, JA_ref, IA, JA, idx_i, idx_j, hfact, val_ref, val, threshold_undef, wsum, val2)
Definition: scale_interp.F90:1232
scale_comm_cartesc_nest::comm_cartesc_nest_interp_level
integer, public comm_cartesc_nest_interp_level
horizontal interpolation level
Definition: scale_comm_cartesC_nest.F90:95
scale_atmos_grid_cartesc_index::isb
integer, public isb
Definition: scale_atmos_grid_cartesC_index.F90:63
scale_landuse::landuse_fact_ocean
real(rp), dimension(:,:), allocatable, public landuse_fact_ocean
ocean factor
Definition: scale_landuse.F90:44
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:342
scale_file_grads::file_grads_isoned
logical function, public file_grads_isoned(file_id, var_id)
Definition: scale_file_grads.F90:332
scale_file_grads::file_grads_open
subroutine, public file_grads_open(file_name, file_id)
Open.
Definition: scale_file_grads.F90:102
scale_atmos_grid_cartesc_index::ihalo
integer, public ihalo
Definition: scale_atmos_grid_cartesC_index.F90:44
scale_comm_cartesc_nest::comm_cartesc_nest_tile_id
integer, dimension(:), allocatable, public comm_cartesc_nest_tile_id
parent tile real id
Definition: scale_comm_cartesC_nest.F90:52
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_comm_cartesc_nest
module Communication CartesianC nesting
Definition: scale_comm_cartesC_nest.F90:12
scale_interp
module INTERPOLATION
Definition: scale_interp.F90:12
scale_const::const_eps
real(rp), public const_eps
small number
Definition: scale_const.F90:33
scale_atmos_grid_cartesc::atmos_grid_cartesc_fyg
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_fyg
face coordinate [m]: y, global
Definition: scale_atmos_grid_cartesC.F90:78
scale_prc::prc_myrank
integer, public prc_myrank
process num in local communicator
Definition: scale_prc.F90:90
mod_copytopo::copytopo
subroutine, public copytopo(TOPO_child)
Setup and Main.
Definition: mod_copytopo.F90:74
scale_file_grads::file_grads_varid
subroutine, public file_grads_varid(file_id, var_name, var_id)
Definition: scale_file_grads.F90:300
scale_file::file_get_dimlength
subroutine, public file_get_dimlength(fid, dimname, len, error)
get length of dimension
Definition: scale_file.F90:565
scale_atmos_grid_cartesc_real
module Atmosphere GRID CartesC Real(real space)
Definition: scale_atmos_grid_cartesC_real.F90:11
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_lon
real(rp), dimension(:,:), allocatable, public atmos_grid_cartesc_real_lon
longitude [rad,0-2pi]
Definition: scale_atmos_grid_cartesC_real.F90:48
mod_copytopo::copytopo_get_data_wrfarw
subroutine copytopo_get_data_wrfarw(IA_org, JA_org, LON_org, LAT_org, TOPO_org)
Definition: mod_copytopo.F90:855
mod_copytopo::copytopo_get_data_grads
subroutine copytopo_get_data_grads(IA_org, JA_org, LON_org, LAT_org, TOPO_org)
Definition: mod_copytopo.F90:743
scale_file
module file
Definition: scale_file.F90:15
scale_atmos_grid_cartesc_index::imax
integer, public imax
Definition: scale_atmos_grid_cartesC_index.F90:37
scale_comm_cartesc_nest::parent_jmax
integer, dimension(2), public parent_jmax
parent max number in y-direction
Definition: scale_comm_cartesC_nest.F90:56
scale_atmos_grid_cartesc_index::jeb
integer, public jeb
Definition: scale_atmos_grid_cartesC_index.F90:66
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_const::const_pi
real(rp), public const_pi
pi
Definition: scale_const.F90:31
scale_mapprojection
module Map projection
Definition: scale_mapprojection.F90:12
scale_io
module STDIO
Definition: scale_io.F90:10
scale_atmos_grid_cartesc_index::jag
integer, public jag
Definition: scale_atmos_grid_cartesC_index.F90:74
scale_atmos_grid_cartesc_index::iag
integer, public iag
Definition: scale_atmos_grid_cartesC_index.F90:73
scale_interp::interp_domain_compatibility
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)
Definition: scale_interp.F90:146
scale_file::file_close
subroutine, public file_close(fid, abort)
Definition: scale_file.F90:4738
scale_atmos_grid_cartesc::atmos_grid_cartesc_cxg
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cxg
center coordinate [m]: x, global
Definition: scale_atmos_grid_cartesC.F90:75
scale_atmos_grid_cartesc_index
module atmosphere / grid / cartesC index
Definition: scale_atmos_grid_cartesC_index.F90:12
scale_const
module CONSTANT
Definition: scale_const.F90:11
scale_atmos_grid_cartesc_index::ia
integer, public ia
Definition: scale_atmos_grid_cartesC_index.F90:48
scale_prc_cartesc::prc_2drank
integer, dimension(:,:), allocatable, public prc_2drank
node index in 2D topology
Definition: scale_prc_cartesC.F90:44
scale_file::file_open
subroutine, public file_open(basename, fid, mode, single, aggregate, rankid, postfix)
Definition: scale_file.F90:487
scale_prc_cartesc
module process / cartesC
Definition: scale_prc_cartesC.F90:11
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_file_grads
module file_grads
Definition: scale_file_grads.F90:11
scale_atmos_grid_cartesc_index::jhalo
integer, public jhalo
Definition: scale_atmos_grid_cartesC_index.F90:45
scale_atmos_grid_cartesc::atmos_grid_cartesc_cbfxg
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cbfxg
center buffer factor (0-1): x, global
Definition: scale_atmos_grid_cartesC.F90:85
scale_atmos_grid_cartesc_index::ja
integer, public ja
Definition: scale_atmos_grid_cartesC_index.F90:49
scale_comm_cartesc_nest::comm_cartesc_nest_tile_num_y
integer, public comm_cartesc_nest_tile_num_y
parent tile number in y-direction
Definition: scale_comm_cartesC_nest.F90:51
mod_copytopo
module Copy topography
Definition: mod_copytopo.F90:11
scale_tracer
module TRACER
Definition: scale_tracer.F90:12
scale_atmos_grid_cartesc::atmos_grid_cartesc_fxg
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_fxg
face coordinate [m]: x, global
Definition: scale_atmos_grid_cartesC.F90:77
mod_copytopo::copytopo_get_size_wrfarw
subroutine copytopo_get_size_wrfarw(IA_org, JA_org)
Definition: mod_copytopo.F90:829
scale_comm_cartesc_nest::parent_imax
integer, dimension(2), public parent_imax
parent max number in x-direction
Definition: scale_comm_cartesC_nest.F90:55
scale_comm_cartesc_nest::comm_cartesc_nest_tile_num_x
integer, public comm_cartesc_nest_tile_num_x
parent tile number in x-direction
Definition: scale_comm_cartesC_nest.F90:50
scale_comm_cartesc_nest::comm_cartesc_nest_domain_shape
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)
Definition: scale_comm_cartesC_nest.F90:1061
scale_comm_cartesc
module COMMUNICATION
Definition: scale_comm_cartesC.F90:11
scale_atmos_grid_cartesc::atmos_grid_cartesc_cyg
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cyg
center coordinate [m]: y, global
Definition: scale_atmos_grid_cartesC.F90:76
scale_atmos_grid_cartesc_index::jmax
integer, public jmax
Definition: scale_atmos_grid_cartesC_index.F90:38
scale_atmos_grid_cartesc::atmos_grid_cartesc_cy
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cy
center coordinate [m]: y, local
Definition: scale_atmos_grid_cartesC.F90:56
scale_atmos_grid_cartesc_index::ieb
integer, public ieb
Definition: scale_atmos_grid_cartesC_index.F90:64
scale_filter
module FILTER
Definition: scale_filter.F90:11
mod_copytopo::copytopo_get_size_grads
subroutine copytopo_get_size_grads(IA_org, JA_org)
Definition: mod_copytopo.F90:717
scale_const::const_d2r
real(rp), public const_d2r
degree to radian
Definition: scale_const.F90:32
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_lat
real(rp), dimension(:,:), allocatable, public atmos_grid_cartesc_real_lat
latitude [rad,-pi,pi]
Definition: scale_atmos_grid_cartesC_real.F90:52
scale_atmos_grid_cartesc
module atmosphere / grid / cartesC
Definition: scale_atmos_grid_cartesC.F90:12
scale_landuse
module LANDUSE
Definition: scale_landuse.F90:19
scale_atmos_grid_cartesc::atmos_grid_cartesc_cbfyg
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cbfyg
center buffer factor (0-1): y, global
Definition: scale_atmos_grid_cartesC.F90:86
scale_file_grads::file_grads_close
subroutine, public file_grads_close(file_id)
Definition: scale_file_grads.F90:624
scale_atmos_grid_cartesc_index::jsb
integer, public jsb
Definition: scale_atmos_grid_cartesC_index.F90:65
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:56
scale_atmos_grid_cartesc::atmos_grid_cartesc_cx
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cx
center coordinate [m]: x, local
Definition: scale_atmos_grid_cartesC.F90:55
scale_prc::prc_ismaster
logical, public prc_ismaster
master process in local communicator?
Definition: scale_prc.F90:91
mod_copytopo::copytopo_get_data_scale
subroutine copytopo_get_data_scale(IA_org, JA_org, LON_org, LAT_org, TOPO_org)
Definition: mod_copytopo.F90:657