57   integer,  
public :: 
i_xy  = 1 
    58   integer,  
public :: 
i_uy  = 2 
    59   integer,  
public :: 
i_xv  = 3 
    60   integer,  
public :: 
i_uv  = 4 
    70   private :: gtrans_mapfactor
    71   private :: gtrans_terrainfollowing
    72   private :: gtrans_thin_wall
    73   private :: gtrans_step_mountain
    74   private :: gtrans_write
    80   character(len=H_LONG),  
private :: gtrans_out_basename  = 
''    81   character(len=H_MID),   
private :: gtrans_out_title     = 
'SCALE-RM GEOMETRICS'    82   character(len=H_SHORT), 
private :: gtrans_out_dtype     = 
'DEFAULT'    84   character(len=H_SHORT), 
private :: gtrans_topo_type     = 
'TERRAINFOLLOWING'    85   integer,                
private :: gtrans_thinwall_xdiv = 50
    86   integer,                
private :: gtrans_thinwall_ydiv = 50
    87   logical,                
private :: debug                = .false.
    97     namelist / param_gtrans / &
    98        gtrans_out_basename,  &
   101        gtrans_thinwall_xdiv, &
   102        gtrans_thinwall_ydiv, &
   109     if( 
io_l ) 
write(
io_fid_log,*) 
'++++++ Module[GRIDTRANS] / Categ[ATMOS-RM GRID] / Origin[SCALElib]'   115        if( 
io_l ) 
write(
io_fid_log,*) 
'*** Not found namelist. Default used.'   116     elseif( ierr > 0 ) 
then    117        write(*,*) 
'xxx Not appropriate names in namelist PARAM_GTRANS. Check!'   143     call gtrans_mapfactor
   150     if( 
io_l ) 
write(
io_fid_log,*) 
'*** Terrain coordinate type : ', trim(gtrans_topo_type)
   151     select case(gtrans_topo_type)
   152     case(
'TERRAINFOLLOWING')
   154       call gtrans_terrainfollowing
   157       call gtrans_thin_wall
   158       call gtrans_step_mountain
   160       if( 
io_l ) 
write(
io_fid_log,*) 
'*** => Thin-wall approximation method'   161       call gtrans_thin_wall
   163        write(*,*) 
'xxx Unsupported GTRANS_TOPO_type. STOP'   175   subroutine gtrans_mapfactor
   195   end subroutine gtrans_mapfactor
   217   subroutine gtrans_terrainfollowing
   233     real(RP) :: REAL_CZ_U (  KA,IA,JA)
   234     real(RP) :: REAL_CZ_V (  KA,IA,JA)
   235     real(RP) :: REAL_CZ_UV(  KA,IA,JA)
   236     real(RP) :: REAL_FZ_U (0:KA,IA,JA)
   237     real(RP) :: REAL_FZ_V (0:KA,IA,JA)
   238     real(RP) :: REAL_FZ_UV(0:KA,IA,JA)
   279        real_cz_uv(k,i,j) = 0.25_rp * ( 
real_cz(k,i+1,j+1) + 
real_cz(k,i+1,j) &
   288        real_fz_uv(k,i,j) = 0.25_rp * ( 
real_fz(k,i+1,j+1) + 
real_fz(k,i+1,j) &
   414   end subroutine gtrans_terrainfollowing
   417   subroutine gtrans_thin_wall
   434     real(RP) :: TOPO_ZsfcALL(2*IA,2*JA)
   435     real(RP) :: TOPO_ZsfcXY (IA,JA)
   436     real(RP) :: TOPO_ZsfcUY (IA,JA)
   437     real(RP) :: TOPO_ZsfcXV (IA,JA)
   438     real(RP) :: TOPO_ZsfcUV (IA,JA)
   440     real(RP) :: GTRANS_QLIM (2*KA,2*IA,2*JA,3)
   441     real(RP) :: QDZ(2*KA)
   442     real(RP) :: QDX(2*IA)
   443     real(RP) :: QDY(2*JA)
   445     real(RP) :: XSLOPE, YSLOPE
   447     real(RP) :: DX_piece, DY_piece
   448     real(RP) :: DX, DY, DZ
   450     integer  :: I_QLIMtoLIM(3,7)
   452     integer  :: iii, jjj, n
   453     integer  :: k, i, j, kk, ii, jj
   486     call comm_vars8( topo_zsfcxy(:,:), 1 )
   487     call comm_vars8( topo_zsfcuy(:,:), 2 )
   488     call comm_vars8( topo_zsfcxv(:,:), 3 )
   489     call comm_vars8( topo_zsfcuv(:,:), 4 )
   490     call comm_wait ( topo_zsfcxy(:,:), 1 )
   491     call comm_wait ( topo_zsfcuy(:,:), 2 )
   492     call comm_wait ( topo_zsfcxv(:,:), 3 )
   493     call comm_wait ( topo_zsfcuv(:,:), 4 )
   501        topo_zsfcall(ii  ,jj  ) = topo_zsfcxy(i,j)
   502        topo_zsfcall(ii+1,jj  ) = topo_zsfcuy(i,j)
   503        topo_zsfcall(ii  ,jj+1) = topo_zsfcxv(i,j)
   504        topo_zsfcall(ii+1,jj+1) = topo_zsfcuv(i,j)
   534        dx_piece = qdx(ii) / 
real(GTRANS_ThinWall_XDIV,kind=
rp)
   535        dy_piece = qdy(jj) / 
real(GTRANS_ThinWall_YDIV,kind=
rp)
   538        ztop = sum(qdz(
ks:kk))
   541        yslope = ( topo_zsfcall(ii,jj+1) - topo_zsfcall(ii,jj) ) / qdy(jj)
   543        do jjj = 1, gtrans_thinwall_ydiv
   544           dy = ( 
real(jjj,kind=RP) - 0.5_RP ) * DY_piece
   545           dz = ztop - topo_zsfcall(ii,jj) - yslope * dy
   547           if ( dz > 0.0_rp ) 
then   548              if ( dz < qdz(kk) ) 
then   551                 aqaf(
i_fyz) = aqaf(
i_fyz) + qdz(kk) * dy_piece
   557        xslope = ( topo_zsfcall(ii+1,jj) - topo_zsfcall(ii,jj) ) / qdx(ii)
   559        do iii = 1, gtrans_thinwall_xdiv
   560           dx = ( 
real(iii,kind=RP) - 0.5_RP ) * DX_piece
   561           dz = ztop - topo_zsfcall(ii,jj) + xslope * dx
   563           if ( dz > 0.0_rp ) 
then   564              if ( dz < qdz(kk) ) 
then   567                 aqaf(
i_fxz) = aqaf(
i_fxz) + qdz(kk) * dx_piece
   573        do jjj = 1, gtrans_thinwall_ydiv
   574        do iii = 1, gtrans_thinwall_xdiv
   575           dx = ( 
real(iii,kind=RP) - 0.5_RP ) * DX_piece
   576           dy = ( 
real(jjj,kind=RP) - 0.5_RP ) * DY_piece
   577           dz = ztop - topo_zsfcall(ii,jj) - xslope * dx - yslope * dy
   579           if ( dz > 0.0_rp ) 
then   580              aqaf(
i_fxy) = aqaf(
i_fxy) + dx_piece * dy_piece
   585        gtrans_qlim(kk,ii,jj,
i_fyz) = aqaf(
i_fyz) / ( qdy(jj) * qdz(kk) )
   586        gtrans_qlim(kk,ii,jj,
i_fxz) = aqaf(
i_fxz) / ( qdx(ii) * qdz(kk) )
   587        gtrans_qlim(kk,ii,jj,
i_fxy) = aqaf(
i_fxy) / ( qdy(jj) * qdx(ii) )
   593     i_qlimtolim(1:3,
i_xyz) = (/ 1, 1, 1 /)
   594     i_qlimtolim(1:3,
i_xyw) = (/ 1, 1, 0 /)
   595     i_qlimtolim(1:3,
i_uyw) = (/ 0, 1, 0 /)
   596     i_qlimtolim(1:3,
i_xvw) = (/ 1, 0, 0 /)
   597     i_qlimtolim(1:3,
i_uyz) = (/ 0, 1, 1 /)
   598     i_qlimtolim(1:3,
i_xvz) = (/ 1, 0, 1 /)
   599     i_qlimtolim(1:3,
i_uvz) = (/ 0, 0, 1 /)
   605           ii = (i-1) * 2 + 1 - i_qlimtolim(1,n)
   606           jj = (j-1) * 2 + 1 - i_qlimtolim(2,n)
   607           kk = (k-1) * 2 + 1 - i_qlimtolim(3,n)
   610                                            + gtrans_qlim(kk+1,ii,jj,
i_fyz) + gtrans_qlim(kk+1,ii  ,jj+1,
i_fyz) )
   612                                            + gtrans_qlim(kk+1,ii,jj,
i_fxz) + gtrans_qlim(kk+1,ii+1,jj  ,
i_fxz) )
   614                                            + gtrans_qlim(kk  ,ii,jj,
i_fxy) + gtrans_qlim(kk  ,ii+1,jj  ,
i_fxy) )
   617             write(*,*) 
'xxx Facter miss! Check!'   672   end subroutine gtrans_thin_wall
   675   subroutine gtrans_step_mountain
   751   end subroutine gtrans_step_mountain
   755   subroutine gtrans_write
   771     real(RP) :: check_X_XY(IA,JA)
   772     real(RP) :: check_Y_XY(IA,JA)
   773     real(RP) :: distance  (IA,JA)
   778     if ( gtrans_out_basename /= 
'' ) 
then   783        call fileio_write( 
gtrans_mapf(:,:,1,
i_xy),       gtrans_out_basename, gtrans_out_title, & 
   784                           'MAPF_X_XY', 
'Map factor x-dir at XY', 
'NIL', 
'XY', gtrans_out_dtype  ) 
   785        call fileio_write( 
gtrans_mapf(:,:,2,
i_xy),       gtrans_out_basename, gtrans_out_title, & 
   786                           'MAPF_Y_XY', 
'Map factor y-dir at XY', 
'NIL', 
'XY', gtrans_out_dtype  ) 
   787        call fileio_write( 
gtrans_mapf(:,:,1,
i_uy),       gtrans_out_basename, gtrans_out_title, & 
   788                           'MAPF_X_UY', 
'Map factor x-dir at UY', 
'NIL', 
'UY', gtrans_out_dtype  ) 
   789        call fileio_write( 
gtrans_mapf(:,:,2,
i_uy),       gtrans_out_basename, gtrans_out_title, & 
   790                           'MAPF_Y_UY', 
'Map factor y-dir at UY', 
'NIL', 
'UY', gtrans_out_dtype  ) 
   791        call fileio_write( 
gtrans_mapf(:,:,1,
i_xv),       gtrans_out_basename, gtrans_out_title, & 
   792                           'MAPF_X_XV', 
'Map factor x-dir at XV', 
'NIL', 
'XV', gtrans_out_dtype  ) 
   793        call fileio_write( 
gtrans_mapf(:,:,2,
i_xv),       gtrans_out_basename, gtrans_out_title, & 
   794                           'MAPF_Y_XV', 
'Map factor y-dir at XV', 
'NIL', 
'XV', gtrans_out_dtype  ) 
   795        call fileio_write( 
gtrans_mapf(:,:,1,
i_uv),       gtrans_out_basename, gtrans_out_title, & 
   796                           'MAPF_X_UV', 
'Map factor x-dir at UV', 
'NIL', 
'UV', gtrans_out_dtype  ) 
   797        call fileio_write( 
gtrans_mapf(:,:,2,
i_uv),       gtrans_out_basename, gtrans_out_title, & 
   798                           'MAPF_Y_UV', 
'Map factor y-dir at UV', 
'NIL', 
'UV', gtrans_out_dtype  ) 
   800        call fileio_write( 
gtrans_rotc(:,:,1),            gtrans_out_basename, gtrans_out_title, & 
   801                           'ROTC_COS',  
'Rotation factor (cos)',  
'NIL', 
'XY', gtrans_out_dtype  ) 
   802        call fileio_write( 
gtrans_rotc(:,:,2),            gtrans_out_basename, gtrans_out_title, & 
   803                           'ROTC_SIN',  
'Rotation factor (sin)',  
'NIL', 
'XY', gtrans_out_dtype  ) 
   805        call fileio_write( 
gtrans_rotc(:,:,1),            gtrans_out_basename, gtrans_out_title, & 
   806                           'ROTC_COS',  
'Rotation factor (cos)',  
'NIL', 
'XY', gtrans_out_dtype  ) 
   814        call fileio_write( check_x_xy(:,:),     gtrans_out_basename, gtrans_out_title, & 
   815                           'X_XY', 
'x at XY for check', 
'NIL', 
'XY', gtrans_out_dtype  ) 
   816        call fileio_write( check_y_xy(:,:),     gtrans_out_basename, gtrans_out_title, & 
   817                           'Y_XY', 
'y at XY for check', 
'NIL', 
'XY', gtrans_out_dtype  ) 
   830        call fileio_write( distance(:,:),               gtrans_out_basename, gtrans_out_title, & 
   831                           'distance', 
'distance from basepoint', 
'm', 
'XY', gtrans_out_dtype  ) 
   836   end subroutine gtrans_write
 integer, public is
start point of inner domain: x, local 
 
integer, public je
end point of inner domain: y, local 
 
real(rp), dimension(:), allocatable, public grid_rcdy
reciprocal of center-dy 
 
subroutine, public prc_mpistop
Abort MPI. 
 
real(rp), dimension(:,:,:,:), allocatable, public gtrans_limxy
flux limiter x-y face 
 
real(rp), public real_basepoint_lat
position of base point in real world [rad,-pi,pi] 
 
real(rp), dimension(:,:,:,:), allocatable, public gtrans_j23g
(2,3) element of Jacobian matrix * {G}^1/2 
 
logical, public io_l
output log or not? (this process) 
 
real(rp), dimension(:), allocatable, public grid_rcdx
reciprocal of center-dx 
 
real(rp), dimension(:), allocatable, public grid_cz
center coordinate [m]: z, local=global 
 
real(rp), public const_radius
radius of the planet [m] 
 
integer, public ke
end point of inner domain: z, local 
 
real(rp), public gtrans_j33g
(3,3) element of Jacobian matrix * {G}^1/2 
 
real(rp), dimension(:,:,:), allocatable, public real_fz
geopotential height [m] (cell face ) 
 
real(rp), dimension(:,:,:), allocatable, public real_cz
geopotential height [m] (cell center) 
 
real(rp), dimension(:), allocatable, public grid_rfdy
reciprocal of face-dy 
 
real(rp), dimension(:), allocatable, public grid_rcdz
reciprocal of center-dz 
 
real(rp), dimension(:,:,:,:), allocatable, public gtrans_limyz
flux limiter y-z face 
 
real(rp), dimension(:,:,:,:), allocatable, public gtrans_limxz
flux limiter x-z face 
 
real(rp), dimension(:), allocatable, public grid_fx
face coordinate [m]: x, local 
 
logical, public io_nml
output log or not? (for namelist, this process) 
 
real(rp), dimension(:,:,:,:), allocatable, public gtrans_mapf
map factor 
 
integer, public ia
of whole cells: x, local, with HALO
 
real(rp), dimension(:,:), allocatable, public real_latx
latitude at staggered point (uy) [rad,-pi,pi] 
 
subroutine, public vectr_distance(r, lon1, lat1, lon2, lat2, dist)
Get horizontal distance on the sphere. 
 
integer, public ka
of whole cells: z, local, with HALO
 
real(rp), dimension(:), allocatable, public grid_fz
face coordinate [m]: z, local=global 
 
integer, public js
start point of inner domain: y, local 
 
real(rp), dimension(:,:,:), allocatable, public gtrans_rotc
rotation coefficient 
 
subroutine, public mprj_lonlat2xy(lon, lat, x, y)
(lon,lat) -> (x,y) 
 
real(rp), dimension(:,:,:,:), allocatable, public gtrans_j13g
(1,3) element of Jacobian matrix * {G}^1/2 
 
subroutine, public gtrans_setup
Setup. 
 
subroutine, public mprj_mapfactor(lat, m1, m2)
(x,y) -> (lon,lat) 
 
integer, public ks
start point of inner domain: z, local 
 
real(rp), dimension(:), allocatable, public grid_cx
center coordinate [m]: x, local 
 
integer, public ie
end point of inner domain: x, local 
 
real(rp), dimension(:,:,:,:), allocatable, public gtrans_gsqrt
transformation metrics from Z to Xi, {G}^1/2 
 
subroutine, public real_calc_areavol(MAPF)
Calc control area/volume. 
 
real(rp), dimension(:,:), allocatable, public real_lon
longitude [rad,0-2pi] 
 
real(rp), dimension(:,:), allocatable, public topo_zsfc
absolute ground height [m] 
 
real(rp), dimension(:), allocatable, public grid_rfdx
reciprocal of face-dx 
 
real(rp), dimension(:), allocatable, public grid_rfdz
reciprocal of face-dz 
 
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. 
 
integer, parameter, public rp
 
real(rp), dimension(:,:), allocatable, public real_latxy
latitude at staggered point (uv) [rad,-pi,pi] 
 
integer, public io_fid_nml
Log file ID (only for output namelist) 
 
real(rp), dimension(:), allocatable, public grid_cy
center coordinate [m]: y, local 
 
subroutine gtrans_rotcoef
Calculate rotation coeffient. 
 
real(rp), public real_basepoint_lon
position of base point in real world [rad,0-2pi] 
 
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
 
real(rp), dimension(:), allocatable, public grid_fy
face coordinate [m]: y, local