gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dc_trace::datadump Interface Reference

Public Member Functions

subroutine datad1dump (header, d, strlen, multi)
subroutine datad2dump (header, d, strlen, multi)
subroutine datad3dump (header, d, strlen, multi)

Detailed Description

Definition at line 181 of file dc_trace.f90.

Member Function/Subroutine Documentation

◆ datad1dump()

subroutine dc_trace::datadump::datad1dump ( character(*), intent(in) header,
real(dp), dimension(:), intent(in) d,
integer, intent(in), optional strlen,
integer, dimension(:), intent(in), optional multi )

Output 1-dimensional data

Outputs multi-dimensional data d (double precision real) as debug messages. The character variable header is used as a prefix for output. By providing strlen, you can specify the number of characters per line (default is dc_types::STRING). By providing multi(:), you can add dimension subscripts after the header.

See dc_trace Example for usage examples.

Note
This subroutine does not change the internal variable level.
Parameters
[in]headerData name (prefix for output)
[in]d1-dimensional double precision real data
[in]strlenNumber of characters per line (optional)
[in]multiHigher dimension subscripts (optional)

Definition at line 743 of file dc_trace.f90.

744 use dc_types, only: string, dp
745 use dc_string, only: tochar
746 character(*), intent(in) :: header
747 real(DP), intent(in) :: d(:)
748 integer, intent(in), optional:: strlen
749 integer, intent(in), optional:: multi(:)
750 integer :: i, j
751 character(STRING):: unit ! データ文字列
752 character(STRING):: unitbuf ! データ文字列バッファ
753 integer :: ucur ! unit に書かれた文字数
754 character(STRING):: cbuf ! read/write 文のバッファ
755 integer :: stat ! ステータス
756 logical :: first ! 1つ目のデータかどうか
757 integer :: begini ! 1つ目のデータの添字
758 integer :: endi ! 最後のデータの添字
759 character(STRING):: cmulti ! 次元添字用文字列
760 character(STRING):: cout ! 出力する文字列
761 character(STRING):: meshead_tmp
762 integer :: meshead_len
763 continue
764 if ( dbg < 0 ) return
765 ! 初期化
766 unit = ''
767 unitbuf = ''
768 ucur = 0
769 stat = 0
770 first = .true.
771 cmulti = ''
772 ! デバッグメッセージヘッダの作成。
773 if (level < 1) then
774 meshead_tmp = ''
775 meshead_len = 0
776 else
777 meshead_tmp = meshead
778 meshead_len = len(meshead)
779 endif
780 ! 次元添字用文字列を作成
781 if (present(multi)) then
782 do j = 1, size(multi)
783 cmulti = trim(cmulti) // ', ' // trim( tochar( multi(j) ) )
784 enddo
785 endif
786 i = 1
787 dim_1_loop : do
788 if (first) begini = i
789 endi = i
790 write(cbuf, "(g40.20)") d(i)
791 if (.not. first) cbuf = ', ' // adjustl(cbuf(1:254))
792 unitbuf = unit
793 call append(unit, ucur, trim(adjustl(cbuf)), stat, strlen)
794 if ( stat /= 0 .or. i == size( d(:) ) ) then
795 ! 一回目は、文字数オーバーでもそのまま出力。
796 if (first) then
797 cout = header // '(' &
798 & // trim(tochar(begini)) &
799 & // trim(cmulti) &
800 & // ')=' // trim(unit)
801 ! 二回目以降は、オーバーしたものは次回へ
802 elseif (stat /= 0 .and. begini == endi-1) then
803 cout = header // '(' &
804 & // trim(tochar(begini)) &
805 & // trim(cmulti) &
806 & // ')='// trim(unitbuf)
807 ! 1つ巻戻す
808 i = i - 1
809 elseif (stat /= 0 .and. begini /= endi-1) then
810 cout = header // '(' &
811 & // trim(tochar(begini)) // '-' &
812 & // trim(tochar(endi-1)) &
813 & // trim(cmulti) &
814 & // ')=' // trim(unitbuf)
815 ! 1つ巻戻す
816 i = i - 1
817 ! i が size(d) まで到達した場合もそのまま出力。
818 elseif ( i == size( d(:) ) ) then
819 cout = header // '(' &
820 & // trim(tochar(begini)) // '-' &
821 & // trim(tochar(endi)) &
822 & // trim(cmulti) &
823 & // ')='// trim(unit)
824 endif
825 write(dbg, "(A, A, A, A)") &
826 & trim(head), repeat( indent, max(level-1, 0) ), &
827 & meshead_tmp(1:meshead_len), trim(cout)
828 ! unit, unitbuf をクリア
829 unit = ''
830 unitbuf = ''
831 ucur = 0
832 first = .true.
833 else
834 first = .false.
835 endif
836 if (i == size( d(:) ) ) exit dim_1_loop
837 i = i + 1
838 enddo dim_1_loop
subroutine append(unitx, ucur, val, stat)
Handling character types.
Definition dc_string.f90:83
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public string
Character length for string
Definition dc_types.f90:137
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92

References dc_trace::dbg, dc_types::dp, and dc_types::string.

◆ datad2dump()

subroutine dc_trace::datadump::datad2dump ( character(*), intent(in) header,
real(dp), dimension(:,:), intent(in) d,
integer, intent(in), optional strlen,
integer, dimension(:), intent(in), optional multi )

Output 2-dimensional data

See DataDump or DataD1Dump for details.

Parameters
[in]headerData name (prefix for output)
[in]d2-dimensional double precision real data
[in]strlenNumber of characters per line (optional)
[in]multiHigher dimension subscripts (optional)

Definition at line 861 of file dc_trace.f90.

862 use dc_types, only: dp
863 character(*), intent(in) :: header
864 real(DP), intent(in) :: d(:,:)
865 integer, intent(in), optional:: strlen
866 integer, intent(in), optional:: multi(:)
867 integer, allocatable :: total(:)
868 integer :: j
869 continue
870 if ( dbg < 0 ) return
871 if (present(multi)) then
872 allocate( total(size(multi)+1) )
873 total(2:size(multi)+1) = multi(:)
874 else
875 allocate( total(1) )
876 endif
877 do j = 1, size( d(:,:), 2 )
878 total(1) = j
879 call datadump(header, d(:,j), strlen=strlen, multi=total(:))
880 enddo
881 deallocate( total )

References dc_trace::dbg, and dc_types::dp.

◆ datad3dump()

subroutine dc_trace::datadump::datad3dump ( character(*), intent(in) header,
real(dp), dimension(:,:,:), intent(in) d,
integer, intent(in), optional strlen,
integer, dimension(:), intent(in), optional multi )

Output 3-dimensional data

See DataDump or DataD1Dump for details.

Parameters
[in]headerData name (prefix for output)
[in]d3-dimensional double precision real data
[in]strlenNumber of characters per line (optional)
[in]multiHigher dimension subscripts (optional)

Definition at line 904 of file dc_trace.f90.

905 use dc_types, only: dp
906 character(*), intent(in) :: header
907 real(DP), intent(in) :: d(:,:,:)
908 integer, intent(in), optional:: strlen
909 integer, intent(in), optional:: multi(:)
910 integer, allocatable :: total(:)
911 integer :: k
912 continue
913 if ( dbg < 0 ) return
914 if (present(multi)) then
915 allocate( total(size(multi)+1) )
916 total(2:size(multi)+1) = multi(:)
917 else
918 allocate( total(1) )
919 endif
920 do k = 1, size( d(:,:,:), 3 )
921 total(1) = k
922 call datadump(header, d(:,:,k), strlen=strlen, multi=total(:))
923 enddo
924 deallocate( total )

References dc_trace::dbg, and dc_types::dp.


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