43 integer,
public,
parameter ::
i_l = 1
44 integer,
public,
parameter ::
i_prc = 2
47 integer,
public,
parameter ::
i_dir = 2
50 integer,
public,
parameter ::
i_sw = 1
51 integer,
public,
parameter ::
i_nw = 2
52 integer,
public,
parameter ::
i_ne = 3
53 integer,
public,
parameter ::
i_se = 4
56 integer,
public,
parameter ::
i_w = 1
57 integer,
public,
parameter ::
i_n = 2
58 integer,
public,
parameter ::
i_e = 3
59 integer,
public,
parameter ::
i_s = 4
62 integer,
public,
parameter ::
i_npl = 1
63 integer,
public,
parameter ::
i_spl = 2
98 private :: prc_icoa_rgn_setup
99 private :: prc_icoa_rgn_input
100 private :: prc_icoa_rgn_output
101 private :: prc_icoa_rgn_vertex_walkaround
102 private :: output_info
108 character(len=H_LONG),
private :: prc_icoa_rgn_in_fname =
'' 109 character(len=H_LONG),
private :: prc_icoa_rgn_out_fname =
'' 111 character(len=2),
private,
parameter :: prc_rgn_edgename(4) = (/
'SW',
'NW',
'NE',
'SE'/)
112 character(len=2),
private,
parameter :: prc_rgn_vertname(4) = (/
'W ',
'N ',
'E ',
'S '/)
114 logical,
private :: debug = .false.
138 namelist / param_prc_icoa / &
148 log_info(
"PRC_ICOA_setup",*)
'Setup' 152 log_progress(*)
'start MPI' 154 log_info(
"PRC_ICOA_setup",*)
'Process information ' 164 log_info_cont(
'(1x,A,I12)')
'total process [LOCAL] : ',
prc_nprocs 165 log_info_cont(
'(1x,A,I12)')
'my process ID [LOCAL] : ',
prc_myrank 166 log_info_cont(
'(1x,A,L12)')
'master rank? [LOCAL] : ',
prc_ismaster 168 log_info_cont(
'(1x,A,I12)')
'master rank ID [each world] : ', prc_masterrank
175 log_info(
"PRC_ICOA_setup",*)
'Not found namelist. Default used.' 176 elseif( ierr > 0 )
then 177 log_error(
"PRC_ICOA_setup",*)
'Not appropriate names in namelist PARAM_PRC_ICOA. Check!' 183 log_error(
"PRC_ICOA_setup",*)
'PRC_RGN_level is not appropriate :',
prc_rgn_level 191 log_error(
"PRC_ICOA_setup",*)
'Number of total region must be divisible by the number of process',
prc_rgn_total,
prc_nprocs 200 call prc_icoa_rgn_setup
226 subroutine prc_icoa_rgn_setup
233 namelist / param_prc_icoa_rgn / &
234 prc_icoa_rgn_in_fname, &
235 prc_icoa_rgn_out_fname, &
243 log_info(
"PRC_ICOA_RGN_setup",*)
'Setup' 247 read(
io_fid_conf,nml=param_prc_icoa_rgn,iostat=ierr)
249 log_info(
"PRC_ICOA_RGN_setup",*)
'Not found namelist. Default used.' 250 elseif( ierr > 0 )
then 251 log_error(
"PRC_ICOA_RGN_setup",*)
'Not appropriate names in namelist PARAM_PRC_ICOA_RGN. Check!' 260 if ( prc_icoa_rgn_in_fname /=
'' )
then 261 call prc_icoa_rgn_input( prc_icoa_rgn_in_fname, &
268 log_info(
"PRC_ICOA_RGN_setup",*)
'input file is not specified.' 278 if ( prc_icoa_rgn_out_fname /=
'' )
then 279 call prc_icoa_rgn_output( prc_icoa_rgn_out_fname, &
334 end subroutine prc_icoa_rgn_setup
338 subroutine prc_icoa_rgn_input( &
349 character(len=*),
intent(in) :: in_fname
350 integer,
intent(in) :: pall
351 integer,
intent(in) :: rall
352 integer,
intent(in) :: lall
353 integer,
intent(out) :: edge_tab(2,4,rall)
354 integer,
intent(out) :: lp2r(lall,0:pall-1)
356 integer :: num_of_rgn
358 namelist / rgn_info / &
362 integer :: sw(2) = -1
363 integer :: nw(2) = -1
364 integer :: ne(2) = -1
365 integer :: se(2) = -1
367 namelist / rgn_link_info / &
374 integer :: num_of_proc
376 namelist / proc_info / &
380 integer :: num_of_mng
383 namelist / rgn_mng_info / &
392 log_info(
"PRC_ICOA_RGN_input",*)
'input region management information file: ', trim(in_fname)
396 file = trim(in_fname), &
397 form =
'formatted', &
402 if ( ierr /= 0 )
then 403 log_error(
"PRC_ICOA_RGN_input",*)
'File is not found!', trim(in_fname)
407 read(fid,nml=rgn_info)
409 if ( num_of_rgn /= rall )
then 410 log_error(
"PRC_ICOA_RGN_input",*)
'Missmatch of region number!' 411 log_error_cont(*)
'rall= ', rall,
', num_of_rgn=', num_of_rgn
416 read(fid,nml=rgn_link_info)
424 read(fid,nml=proc_info)
425 if ( num_of_proc /= pall )
then 426 log_error(
"PRC_ICOA_RGN_input",*)
' Missmatch of process number!' 427 log_error_cont(*)
' pall= ', pall,
', num_of_proc=', num_of_proc
432 read(fid,nml=rgn_mng_info)
434 if ( p /= peid )
then 435 log_error(
"PRC_ICOA_RGN_input",*)
'Wrong peid: ', p, peid
439 if ( num_of_mng /= lall )
then 440 log_error(
"PRC_ICOA_RGN_input",*)
'number of local region is not match: ', p, num_of_mng, lall
446 lp2r(l,p) = mng_rgnid(l)
453 end subroutine prc_icoa_rgn_input
457 subroutine prc_icoa_rgn_output( &
468 character(len=*),
intent(in) :: out_fname
469 integer,
intent(in) :: pall
470 integer,
intent(in) :: rall
471 integer,
intent(in) :: lall
472 integer,
intent(in) :: edge_tab(2,4,rall)
473 integer,
intent(in) :: lp2r(lall,pall)
475 integer :: num_of_rgn
477 namelist / rgn_info / &
481 integer :: sw(2) = -1
482 integer :: nw(2) = -1
483 integer :: ne(2) = -1
484 integer :: se(2) = -1
486 namelist / rgn_link_info / &
493 integer :: num_of_proc
495 namelist / proc_info / &
499 integer :: num_of_mng
502 namelist / rgn_mng_info / &
512 log_info(
"PRC_ICOA_RGN_output",*)
'output region management information file: ', trim(out_fname)
516 file = trim(out_fname), &
520 write(fid,nml=rgn_info)
529 write(fid,nml=rgn_link_info)
533 write(fid,nml=proc_info)
541 mng_rgnid(l) = lp2r(l,p)
544 write(fid,nml=rgn_mng_info)
549 log_info(
"PRC_ICOA_RGN_output",*)
'output region management information file at the master process' 553 end subroutine prc_icoa_rgn_output
568 integer,
intent(in) :: rlevel
569 integer,
intent(in) :: pall
570 integer,
intent(in) :: rall
571 integer,
intent(in) :: lall
572 integer,
intent(out) :: edge_tab(2,4,rall)
573 integer,
intent(out) :: lp2r(lall,0:pall-1)
575 integer,
parameter :: nmax_dmd = 10
576 integer :: dmd_data(4,nmax_dmd)
577 integer :: rall_1d, rall_1dmd
579 integer :: d_nb, i_nb, j_nb, rgnid_nb, direction
580 integer :: d, i, j, rgnid
584 log_info(
"PRC_ICOA_RGN_generate",*)
'generate region management information file' 585 log_info_cont(*)
'Topology: icosahedral' 587 dmd_data(:, 1) = (/ 6, 5, 2,10 /)
588 dmd_data(:, 2) = (/ 10, 1, 3, 9 /)
589 dmd_data(:, 3) = (/ 9, 2, 4, 8 /)
590 dmd_data(:, 4) = (/ 8, 3, 5, 7 /)
591 dmd_data(:, 5) = (/ 7, 4, 1, 6 /)
592 dmd_data(:, 6) = (/ 7, 5, 1,10 /)
593 dmd_data(:, 7) = (/ 8, 4, 5, 6 /)
594 dmd_data(:, 8) = (/ 9, 3, 4, 7 /)
595 dmd_data(:, 9) = (/ 10, 2, 3, 8 /)
596 dmd_data(:,10) = (/ 6, 1, 2, 9 /)
599 rall_1dmd = rall_1d*rall_1d
605 rgnid = (d-1)*rall_1dmd + (j-1)*rall_1d + i
612 d_nb = dmd_data(
i_sw,d)
617 d_nb = dmd_data(
i_sw,d)
626 rgnid_nb = (d_nb-1)*rall_1dmd + (j_nb-1)*rall_1d + i_nb
636 d_nb = dmd_data(
i_nw,d)
641 d_nb = dmd_data(
i_nw,d)
650 rgnid_nb = (d_nb-1)*rall_1dmd + (j_nb-1)*rall_1d + i_nb
656 if ( j == rall_1d )
then 660 d_nb = dmd_data(
i_ne,d)
665 d_nb = dmd_data(
i_ne,d)
674 rgnid_nb = (d_nb-1)*rall_1dmd + (j_nb-1)*rall_1d + i_nb
680 if ( i == rall_1d )
then 684 d_nb = dmd_data(
i_se,d)
689 d_nb = dmd_data(
i_se,d)
698 rgnid_nb = (d_nb-1)*rall_1dmd + (j_nb-1)*rall_1d + i_nb
723 subroutine prc_icoa_rgn_vertex_walkaround( &
733 integer,
intent(in) :: rall
734 integer,
intent(in) :: rall_pl
735 integer,
intent(in) :: vlink
736 integer,
intent(in) :: edge_tab(2,4,rall)
738 integer,
intent(out) :: vert_num (4,rall)
739 integer,
intent(out) :: vert_tab (2,4,rall ,vlink)
740 integer,
intent(out) :: vert_tab_pl(2 ,rall_pl,vlink)
742 integer :: rgnid, dir
743 integer :: rgnid_next, dir_next
749 vert_tab(:,:,:,:) = -1
768 rgnid_next = edge_tab(
i_rgnid,dir,rgnid)
769 dir_next = edge_tab(
i_dir, dir,rgnid) - 1
771 if( dir_next == 0 ) dir_next = 4
773 vert_tab(
i_rgnid,d,r,v) = rgnid
774 vert_tab(
i_dir, d,r,v) = dir
779 if( rgnid == r )
exit 786 vert_tab_pl(:,:,:) = -1
789 if ( vert_num(
i_n,r) == vlink )
then 799 if ( vert_num(
i_s,r) == vlink )
then 809 end subroutine prc_icoa_rgn_vertex_walkaround
812 subroutine output_info
817 integer :: rgnid, rgnid_next
818 character(len=2) :: dstr, dstr_next
824 log_info(
"PRC_ICOA_RGN_setup",
'(1x,A)')
'Region management information' 825 log_info_cont(
'(1x,A,A)' )
'Grid sysytem : Icosahedral' 826 log_info_cont(
'(1x,A,I7)')
'number of diamond : ',
prc_rgn_dmd 827 log_info_cont(
'(1x,A,I7)')
'maximum number of vertex linkage : ',
prc_rgn_vlink 829 log_info_cont(
'(1x,A,I7)')
'Region division level (RL) : ',
prc_rgn_level 830 log_info_cont(
'(1x,A,I7,3(A,I4),A)')
'Total number of regular region : ',
prc_rgn_total, &
832 log_info_cont(
'(1x,A,I7)')
'# of region per process : ',
prc_rgn_local 833 log_info_cont(
'(1x,A)' )
'ID of region in my process : ' 842 log_info(
"PRC_ICOA_RGN_setup",
'(1x,A)')
'Detailed region management information' 844 log_info_cont(*)
'--- (l,myrank) => (rgn)' 847 log_info_cont(
'(1x,A,I4,A,I6,A,I6,A)')
'--- (',l,
',',
prc_myrank,
') => (',rgnid,
') ' 851 log_info_cont(*)
'--- Link information' 856 log_info_cont(*)
'--- edge link: (rgn,direction)' 859 dstr = prc_rgn_edgename(d)
861 log_info_cont(
'(5x,A,I6,A,A,A,I6,A,A,A)')
'(',rgnid,
',',dstr,
') -> (', rgnid_next,
',', dstr_next,
')' 864 log_info_cont(*)
'--- vertex link: (rgn)' 866 dstr = prc_rgn_vertname(d)
867 log_info_contna(
'(5x,A,I6,A,A,A)')
'(',rgnid,
',',dstr,
')' 870 log_info_contna(
'(A,I6,A,A,A)')
' -> (',
prc_rgn_vert_tab(
i_rgnid,d,rgnid,v),
',',dstr,
')' 877 log_info_cont(*)
'--- Pole information (in the global scope)' 881 log_info_cont(*)
'--- vertex link: (north pole)' 885 log_info_contna(
'(A,I6,A,A,A)')
' -> (',rgnid,
',',dstr,
')' 889 log_info_contna(
'(A,I6,A,A,A)')
' -> (',rgnid,
',',dstr,
')' 895 log_info_cont(*)
'--- vertex link: (south pole)' 899 log_info_contna(
'(A,I6,A,A,A)')
' -> (',rgnid,
',',dstr,
')' 903 log_info_contna(
'(A,I6,A,A,A)')
' -> (',rgnid,
',',dstr,
')' 909 end subroutine output_info
integer, public prc_universal_nprocs
process num in universal communicator
integer, parameter, public i_prc
process
integer, dimension(:,:,:), allocatable, public prc_rgn_edge_tab
region link information (for 4 edges)
integer, parameter, public i_e
east
integer, parameter, public i_l
local region
logical, public prc_global_ismaster
master process in global communicator?
integer, parameter, public i_se
south east
integer, parameter, public i_spl
south pole
integer, public io_fid_nml
Log file ID (only for output namelist)
integer, public prc_global_myrank
myrank in global communicator
integer, dimension(:,:,:,:), allocatable, public prc_rgn_vert_tab
region link information (for 4 vertexes)
integer, dimension(:), allocatable, public prc_rgn_l2r
l,prc_me => rgn
integer, public io_fid_conf
Config file ID.
integer, parameter, public prc_rgn_local_lim
maximum number of regular region (local)
integer, public prc_universal_comm_world
original communicator
integer, public prc_nprocs
myrank in local communicator
subroutine, public prc_icoa_setup
Setup Processor topology.
integer, public prc_universal_myrank
myrank in universal communicator
integer, parameter, public i_dir
direction
subroutine, public prc_icoa_rgn_generate(rlevel, pall, rall, lall, edge_tab, lp2r)
Generate region management info.
integer, parameter, public i_sw
south west
logical, public io_l
output log or not? (this process)
integer, parameter, public i_w
west
integer, parameter, public i_nw
north west
integer, dimension(:,:), allocatable, public prc_rgn_vert_num
number of region around the vertex (4 vertexes)
integer function, public io_get_available_fid()
search & get available file ID
integer, public prc_rgn_level
region division level
integer, dimension(prc_rgn_total_pl), public prc_rgn_r2p_pl
process ID which have the pole regions
integer, dimension(prc_rgn_total_pl), public prc_rgn_rgn4pl
region, having pole data in the halo
integer, parameter, public prc_masterrank
master process in each communicator
integer, public prc_rgn_total
number of regular region (global total)
integer, public prc_global_nprocs
process num in global communicator
integer, parameter, public prc_rank_pl
process ID which manages the pole regions
integer, public prc_myrank
process num in local communicator
integer, parameter, public i_ne
north east
subroutine, public prc_abort
Abort Process.
integer, public prc_rgn_local
number of regular region (local)
integer, parameter, public i_npl
north pole
integer, parameter, public i_rgnid
region id
logical, public prc_ismaster
master process in local communicator?
integer, public prc_global_comm_world
global communicator
integer, dimension(:,:,:), allocatable, public prc_rgn_vert_tab_pl
region link information (for 4 vertexes)
integer, parameter, public prc_rgn_total_pl
number of pole region
integer, dimension(:,:), allocatable, public prc_rgn_lp2r
l,prc => rgn
integer, parameter, public i_s
south
logical, public prc_universal_ismaster
master process in universal communicator?
integer, public prc_local_comm_world
local communicator
integer, public prc_abort_comm_world
communicator for aborting
logical, public io_nml
output log or not? (for namelist, this process)
integer, parameter, public i_n
north
integer, public prc_rgn_dmd
number of diamonds
logical, public prc_have_pl
this ID manages pole region?
integer, public prc_rgn_vlink
maximum number of vertex linkage, ICO:5
logical, dimension(:), allocatable, public prc_rgn_have_sgp
region have singlar point?
integer, dimension(:,:), allocatable, public prc_rgn_r2lp
rgn => l,prc