gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
gtool_history_internal::gtmpi_vars_mkindex Interface Reference

Public Member Functions

subroutine gtmpi_vars_mkindex (hst, v_ord, err)

Detailed Description

Definition at line 97 of file gtool_history_internal.f90.

Constructor & Destructor Documentation

◆ gtmpi_vars_mkindex()

subroutine gtool_history_internal::gtmpi_vars_mkindex::gtmpi_vars_mkindex ( type(gt_history), intent(inout) hst,
integer, intent(in) v_ord,
logical, intent(out), optional err )

Definition at line 645 of file gtool_history_internal.f90.

646 !
647 ! hst % mpi_vars_index に配列添字情報の登録を行う.
648 !
651 use gtdata_generic, only: inquire
652 use gtdata_types, only: gt_variable
653 use dc_error, only: storeerror, dc_noerr
654 use dc_message, only: messagenotify
655 use dc_url, only: urlsplit
657 use dc_types, only: string, token
658 use mpi
659 implicit none
660 type(GT_HISTORY), intent(inout):: hst
661 integer, intent(in):: v_ord ! 変数 ID
662 logical, intent(out), optional:: err
663 character(TOKEN), pointer:: dims(:) =>null(), dims_space(:) =>null()
664 integer, pointer:: dimsizes_each(:,:) =>null(), dimsizes_all(:) =>null()
665 type(GT_VARIABLE):: dimvar
666 integer:: i, j, ra, numdims, time_dimord
667 integer, pointer:: dimord(:) =>null()
668 integer:: each_index
669 integer, pointer:: idx(:) =>null()
670 integer:: moveup
671 integer:: check_dimsizes_all, check_dimsizes_each
672 character(STRING):: check_varname
673 integer:: err_mpi
674 integer:: stat
675 character(STRING):: cause_c
676 character(*), parameter:: subname = 'gtmpi_vars_mkindex'
677 character(*), parameter:: subnameup = 'HistoryPut'
678 continue
679 call beginsub(subname)
680 cause_c = ""
681 stat = dc_noerr
682 ! rank/=0 は何もせずに終了.
683 ! Finish without actions if rank/=0
684 !
685 ! * 以降の割り付け動作をプロセス 0 でのみ行うと,
686 ! なぜか Cray XT 上で並列計算する際に
687 ! 「異常な数値を ALLOCATE しようとしている」
688 ! というエラーが生じるため, (無駄だが) 全プロセスで以降の
689 ! 割り付け動作を行う.
690 !
691 !!! if ( hst % mpi_myrank /= 0 ) goto 999
692 ! 変数が依存する座標軸情報を取得
693 ! Information of axes depended from the variable
694 !
696 & hst % mpi_varinfo( v_ord ), & ! (in)
697 & dims = dims ) ! (out)
698 ! 時刻次元の排除
699 ! Ignore time dimension
700 !
701 numdims = size( dims )
702 time_dimord = -1
703 allocate( dimord(1) )
704 if ( hst % unlimited_index > 0 ) then
705 do i = 1, numdims
706 if ( hst % mpi_myrank == 0 ) then
707 dimvar = lookup_dimension( hst, dims(i), dimord(1) )
708 end if
709 call mpi_bcast( dimord(1), 1, mpi_integer, 0, mpi_comm_world, err_mpi )
710 if ( hst % unlimited_index == dimord(1) ) time_dimord = i
711 end do
712 end if
713 if ( time_dimord > 0 ) then
714 allocate( dims_space(numdims - 1) )
715 j = 1
716 do i = 1, numdims
717 if ( i == time_dimord ) cycle
718 dims_space(j) = dims(i)
719 j = j + 1
720 end do
721 numdims = numdims - 1
722 deallocate( dims )
723 else
724 dims_space => dims
725 nullify( dims )
726 end if
727 deallocate( dimord )
728 ! スカラーの場合は例外処理
729 ! Exception handling for scalar value
730 !
731 if ( numdims < 1 ) then
732 allocate( hst % mpi_vars_index(v_ord) % &
733 & each2all( 0: hst % mpi_nprocs - 1, 1 ) )
734 allocate( hst % mpi_vars_index(v_ord) % &
735 & allcount( 0: hst % mpi_nprocs - 1 ) )
736 hst % mpi_vars_index(v_ord) % each2all(:,:) = 1
737 hst % mpi_vars_index(v_ord) % allcount(:) = 1
738 goto 999
739 end if
740 ! 配列の割付
741 ! Allocate array
742 !
743 allocate( dimord( numdims ) )
744 allocate( dimsizes_all( numdims ) )
745 allocate( dimsizes_each( 0:hst % mpi_nprocs - 1, numdims ) )
746 ! 個々の次元のサイズの取得
747 ! Get size of each dimension
748 !
749 do i = 1, numdims
750 if ( hst % mpi_myrank == 0 ) then
751 dimvar = lookup_dimension( hst, dims_space(i), dimord(i) )
752 end if
753 call mpi_bcast( dimord(i), 1, mpi_integer, 0, mpi_comm_world, err_mpi )
754 dimsizes_all(i) = hst % mpi_dimdata_all ( dimord(i) ) % length
755 do ra = 0, hst % mpi_nprocs - 1
756 dimsizes_each(ra, i) = hst % mpi_gthr_info( dimord(i) ) % length( ra )
757 end do
758 end do
759 allocate( hst % mpi_vars_index(v_ord) % &
760 & each2all( 0: hst % mpi_nprocs - 1, product(dimsizes_all) ) )
761 allocate( hst % mpi_vars_index(v_ord) % &
762 & allcount( 0: hst % mpi_nprocs - 1 ) )
763 hst % mpi_vars_index(v_ord) % each2all(:,:) = -1
764 do ra = 0, hst % mpi_nprocs - 1
765 hst % mpi_vars_index(v_ord) % allcount(ra) = &
766 & product( dimsizes_each(ra,:) )
767 end do
768 hst % mpi_vars_index(v_ord) % allcount_all = product( dimsizes_all(:) )
769 ! rank/=0 はこの時点で終了
770 ! Finish at this point if rank/=0
771 !
772 if ( hst % mpi_myrank /= 0 ) goto 999
773 allocate( idx(numdims) )
774 do ra = 0, hst % mpi_nprocs - 1
775 idx(:) = 1
776 idx(1) = 0
777 do i = 1, product( dimsizes_each(ra, :) )
778 idx(1) = idx(1) + 1
779 moveup = 0
780 do j = 1, numdims
781 if ( moveup > 0 ) then
782 idx(j) = idx(j) + moveup
783 moveup = 0
784 end if
785 if ( idx(j) > dimsizes_each(ra,j) ) then
786 idx(j) = 1
787 moveup = 1
788 end if
789 end do
790 each_index = hst % mpi_gthr_info(dimord(1)) % index_all (ra,idx(1))
791 do j = 2, numdims
792 each_index = each_index + &
793 & ( hst % mpi_gthr_info(dimord(j)) % index_all (ra,idx(j)) - 1 ) &
794 & * product( dimsizes_all(1:j-1) )
795 end do
796 hst % mpi_vars_index(v_ord) % each2all(ra, i) = each_index
797 end do
798 end do
799 deallocate( idx )
800 ! 不足データが無いかチェック
801 ! Check lack of data
802 !
803 check_dimsizes_all = product( dimsizes_all(:) )
804 check_dimsizes_each = sum( hst % mpi_vars_index(v_ord) % allcount(:) )
805 if ( check_dimsizes_all > check_dimsizes_each ) then
806 call inquire( hst % vars(v_ord), & ! (in)
807 & name = check_varname ) ! (out)
808 call messagenotify('W', subnameup, &
809 & 'collected data (%c) from each node is lack. ' // &
810 & 'collected data size=<%d>, but needed whole data size=<%d>.', &
811 & c1 = trim(check_varname), &
812 & i = (/ check_dimsizes_each, check_dimsizes_all /) )
813 end if
814999 continue
815 call storeerror(stat, subname, err, cause_c)
816 call endsub(subname)
エラー処理用モジュール
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public dc_noerr
エラー等を保持
Definition dc_error.f90:468
メッセージの出力
デバッグ時の追跡用モジュール
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:680
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:476
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:599
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition dc_types.f90:128
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137
変数 URL の文字列解析
Definition dc_url.f90:61

References dc_trace::beginsub(), dc_trace::dbgmessage(), dc_error::dc_noerr, dc_trace::endsub(), dc_error::storeerror(), dc_types::string, and dc_types::token.

Here is the call graph for this function:

The documentation for this interface was generated from the following file: