SCALE-RM
scale_grid_index.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
13 !-------------------------------------------------------------------------------
15  !-----------------------------------------------------------------------------
16  !
17  !++ used modules
18  !
19  use scale_precision
20  use scale_stdio
21  use scale_prof
22  !-----------------------------------------------------------------------------
23  implicit none
24  private
25  !-----------------------------------------------------------------------------
26  !
27  !++ Public procedure
28  !
29  public :: grid_index_setup
30 
31  !-----------------------------------------------------------------------------
32  !
33  !++ Public parameters & variables
34  !
35  integer, public, parameter :: zdir = 1
36  integer, public, parameter :: xdir = 2
37  integer, public, parameter :: ydir = 3
38 
39 #ifdef _FIXEDINDEX_
40  include "inc_index.h"
41  include "inc_index_common.h"
42 #else
43  integer, public :: kmax = -1
44  integer, public :: imax = -1
45  integer, public :: jmax = -1
46 
47  integer, public :: iblock = -1
48  integer, public :: jblock = -1
49 
50  integer, public, parameter :: khalo = 2
51  integer, public :: ihalo = 2
52  integer, public :: jhalo = 2
53 
54  integer, public :: ka
55  integer, public :: ia
56  integer, public :: ja
57 
58  integer, public :: ks
59  integer, public :: ke
60  integer, public :: is
61  integer, public :: ie
62  integer, public :: js
63  integer, public :: je
64 
65  integer, public :: kijmax = -1
66 #endif
67 
68  ! indices considering boundary
69  integer, public :: imaxb
70  integer, public :: jmaxb
71  integer, public :: isb
72  integer, public :: ieb
73  integer, public :: jsb
74  integer, public :: jeb
75  integer, public :: ieh
76  integer, public :: jeh
77 
78  integer, public :: isg
79  integer, public :: ieg
80  integer, public :: jsg
81  integer, public :: jeg
82 
83  !-----------------------------------------------------------------------------
84  !
85  !++ Private procedure
86  !
87  !-----------------------------------------------------------------------------
88  !
89  !++ Private parameters & variables
90  !
91  !-----------------------------------------------------------------------------
92 contains
93  !-----------------------------------------------------------------------------
95  subroutine grid_index_setup
96  use scale_process, only: &
97  prc_mpistop, &
99  use scale_rm_process, only: &
100  prc_2drank, &
101  prc_num_x, &
102  prc_num_y, &
103  prc_has_w, &
104  prc_has_e, &
105  prc_has_s, &
106  prc_has_n
107  implicit none
108 
109 #ifndef _FIXEDINDEX_
110  namelist / param_index / &
111  kmax, &
112  imax, &
113  jmax, &
114  ihalo, &
115  jhalo, &
116  iblock, &
117  jblock
118 #endif
119 
120  integer :: ierr
121  !---------------------------------------------------------------------------
122 
123  if( io_l ) write(io_fid_log,*)
124  if( io_l ) write(io_fid_log,*) '++++++ Module[GRID_INDEX] / Categ[ATMOS-RM GRID] / Origin[SCALElib]'
125 
126 #ifdef _FIXEDINDEX_
127  if( io_l ) write(io_fid_log,*) '*** No namelists.'
128  if( io_l ) write(io_fid_log,*)
129  if( io_l ) write(io_fid_log,*) '*** fixed index mode'
130 #else
131  !--- read namelist
132  rewind(io_fid_conf)
133  read(io_fid_conf,nml=param_index,iostat=ierr)
134  if( ierr < 0 ) then !--- missing
135  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
136  elseif( ierr > 0 ) then !--- fatal error
137  write(*,*) 'xxx Not appropriate names in namelist PARAM_INDEX. Check!'
138  call prc_mpistop
139  endif
140  if( io_lnml ) write(io_fid_log,nml=param_index)
141 
142  if ( imax < ihalo ) then
143  write(*,*) 'xxx number of grid size IMAX must >= IHALO! ', imax, ihalo
144  call prc_mpistop
145  endif
146  if ( jmax < jhalo ) then
147  write(*,*) 'xxx number of grid size JMAX must >= JHALO! ', jmax, jhalo
148  call prc_mpistop
149  endif
150 
151  ka = kmax + khalo * 2
152  ia = imax + ihalo * 2
153  ja = jmax + jhalo * 2
154 
155  ks = 1 + khalo
156  ke = kmax + khalo
157  is = 1 + ihalo
158  ie = imax + ihalo
159  js = 1 + jhalo
160  je = jmax + jhalo
161 
162  if( iblock == -1 ) iblock = imax
163  if( jblock == -1 ) jblock = jmax
164 
165  kijmax = kmax * imax * jmax
166 #endif
167 
168  !-- Block size must be divisible
169  if ( mod(imax,iblock) > 0 ) then
170  write(*,*) 'xxx number of grid size IMAX must be divisible by IBLOCK! ', imax, iblock
171  call prc_mpistop
172  elseif( mod(jmax,jblock) > 0 ) then
173  write(*,*) 'xxx number of grid size JMAX must be divisible by JBLOCK! ', jmax, jblock
174  call prc_mpistop
175  endif
176 
177  ! horizontal index (global domain)
178  isg = ihalo + 1 + prc_2drank(prc_myrank,1) * imax
180  jsg = jhalo + 1 + prc_2drank(prc_myrank,2) * jmax
182 
183  ! index considering boundary region
184  imaxb = imax
185  jmaxb = jmax
186  isb = is
187  ieb = ie
188  jsb = js
189  jeb = je
190  ieh = ie
191  jeh = je
192  if ( .NOT. prc_has_w ) then
193  imaxb = imaxb + ihalo
194  isb = 1
195  endif
196  if ( .NOT. prc_has_e ) then
197  imaxb = imaxb + ihalo
198  ieb = ia
199  ieh = ie - 1
200  endif
201  if ( .NOT. prc_has_s ) then
202  jmaxb = jmaxb + jhalo
203  jsb = 1
204  endif
205  if ( .NOT. prc_has_n ) then
206  jmaxb = jmaxb + jhalo
207  jeb = ja
208  jeh = je - 1
209  endif
210 
211  if( io_l ) write(io_fid_log,*)
212  if( io_l ) write(io_fid_log,*) '*** Atmosphere grid index information ***'
213  if( io_l ) write(io_fid_log,'(1x,A,I6,A,I6,A,I6)') '*** No. of Computational Grid (global) :', &
214  kmax, ' x ', &
215  imax*prc_num_x, ' x ', &
217  if( io_l ) write(io_fid_log,*)
218  if( io_l ) write(io_fid_log,'(1x,A,I6,A,I6,A,I6)') '*** No. of Computational Grid (local) :', &
219  kmax,' x ',imax,' x ',jmax
220  if( io_l ) write(io_fid_log,'(1x,A,I6,A,I6,A,I6)') '*** No. of Grid (including HALO, local) :', &
221  ka," x ",ia," x ",ja
222  if( io_l ) write(io_fid_log,'(1x,A,I6,A,I6)') '*** Global index of local grid (X) :', &
223  isg," - ",ieg
224  if( io_l ) write(io_fid_log,'(1x,A,I6,A,I6)') '*** Global index of local grid (Y) :', &
225  jsg," - ",jeg
226 
227  end subroutine grid_index_setup
228 
229 end module scale_grid_index
integer, public imax
of computational cells: x
integer, public prc_num_x
x length of 2D processor topology
integer, public is
start point of inner domain: x, local
integer, public je
end point of inner domain: y, local
logical, public prc_has_n
subroutine, public prc_mpistop
Abort MPI.
integer, public jeb
integer, public iblock
block size for cache blocking: x
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:59
integer, parameter, public zdir
logical, public prc_has_e
module STDIO
Definition: scale_stdio.F90:12
integer, parameter, public ydir
integer, public ke
end point of inner domain: z, local
integer, parameter, public xdir
subroutine, public grid_index_setup
Setup.
integer, public imaxb
integer, public jsg
start point of the inner domain: y, global
integer, public jmaxb
logical, public prc_has_s
integer, public ieb
integer, public ieg
end point of the inner domain: x, global
integer, public prc_num_y
y length of 2D processor topology
integer, public isg
start point of the inner domain: x, global
module grid index
integer, public ia
of x whole cells (local, with HALO)
integer, public ka
of z whole cells (local, with HALO)
integer, public jblock
block size for cache blocking: y
integer, public kmax
of computational cells: z
integer, public jhalo
of halo cells: y
integer, public js
start point of inner domain: y, local
module PROCESS
integer, public ks
start point of inner domain: z, local
integer, public prc_myrank
process num in local communicator
integer, parameter, public khalo
of halo cells: z
integer, public jeh
end point of inner domain: y, local (half level)
integer, public ieh
end point of inner domain: x, local (half level)
integer, public kijmax
of computational cells: z*x*y
module RM PROCESS
module profiler
Definition: scale_prof.F90:10
integer, public ie
end point of inner domain: x, local
integer, public jeg
end point of the inner domain: y, global
logical, public io_lnml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:60
module PRECISION
integer, dimension(:,:), allocatable, public prc_2drank
node index in 2D topology
integer, public isb
integer, public io_fid_conf
Config file ID.
Definition: scale_stdio.F90:55
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
integer, public jsb
logical, public prc_has_w
integer, public jmax
of computational cells: y
integer, public ihalo
of halo cells: x
integer, public ja
of y whole cells (local, with HALO)