gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
gtool_history_internal Module Reference

Data Types

interface  append_attrs
interface  copy_attrs
interface  set_fake_dim_value
interface  lookup_variable_ord
interface  lookup_variable
interface  lookup_dimension
interface  lookup_var_or_dim
interface  gtmpi_axis_register
interface  gtmpi_vars_mkindex

Functions/Subroutines

subroutine, public append_attrs (varname, attrs, history)
subroutine, public copy_attrs (from, to, err)
subroutine, public set_fake_dim_value (history, dimord)
integer function, public lookup_variable_ord (history, varname)
type(gt_variable) function, public lookup_variable (history, varname, ord)
type(gt_variable) function, public lookup_dimension (history, dimname, ord)
subroutine, public lookup_var_or_dim (history, name, var, err)
subroutine, public gtmpi_axis_register (hst, err)
subroutine, public gtmpi_vars_mkindex (hst, v_ord, err)

Variables

type(gt_history), target, save, public default
character(string), parameter, public gtool4_netcdf_conventions = "http://www.gfd-dennou.org/library/gtool4/conventions/"
character(string), parameter, public gtool4_netcdf_version = "4.3"

Function/Subroutine Documentation

◆ append_attrs()

subroutine, public gtool_history_internal::append_attrs ( character(*), intent(in) varname,
type(gt_history_attr), dimension(:), intent(in) attrs,
type(gt_history), intent(inout), optional, target history )

Definition at line 101 of file gtool_history_internal.f90.

102 !
103 ! GT_HISTORY_ATTR 変数を history の varname 変数に
104 ! 付加するためのサブルーチン. 公開用ではなく,
105 ! HistoryCreate や HistoryAddVariable に GT_HISTORY_AXIS
106 ! や GT_HISTORY_VARINFO が与えられた時に内部的に利用される.
107 !
109 use gtdata_generic, only: put_attr
111 use dc_string , only: strhead, lchar, tochar
113 implicit none
114 character(*), intent(in):: varname
115 type(GT_HISTORY_ATTR), intent(in):: attrs(:)
116 type(GT_HISTORY), intent(inout), target, optional:: history
117 type(GT_HISTORY), pointer:: hst =>null()
118 integer :: i
119 character(*), parameter:: subname = "append_attrs"
120 continue
121 call beginsub(subname, 'varname=<%c>, size(attrs(:))=<%d>', &
122 & c1=trim(varname), i=(/size(attrs(:))/))
123 if (present(history)) then
124 hst => history
125 else
126 hst => default
127 endif
128 ! attrs(:) のサイズ分だけループ
129 do i = 1, size( attrs(:) )
130 ! attrs(i)%attrtype の種別で与える変数を変える
131 if ( strhead( 'char', trim(lchar(attrs(i)%attrtype))) ) then
132 call historyaddattr( &
133 & varname, attrs(i)%attrname, &
134 & trim(attrs(i)%Charvalue), hst )
135 elseif ( strhead( 'int', trim(lchar(attrs(i)%attrtype))) ) then
136 if ( attrs(i)%array ) then
137 call dbgmessage('Intarray(:) is selected.')
138 call historyaddattr( &
139 & varname, attrs(i)%attrname , &
140 & attrs(i)%Intarray, hst )
141 else
142 call dbgmessage('Intvalue is selected')
143 call historyaddattr( &
144 & varname, attrs(i)%attrname , &
145 & attrs(i)%Intvalue, hst )
146 endif
147 elseif ( strhead( 'real', trim(lchar(attrs(i)%attrtype))) ) then
148 if ( attrs(i)%array ) then
149 call dbgmessage('Realarray(:) is selected.')
150 call historyaddattr( &
151 & varname, attrs(i)%attrname, attrs(i)%Realarray, hst)
152 else
153 call dbgmessage('Realvalue is selected')
154 call historyaddattr( &
155 & varname, attrs(i)%attrname, attrs(i)%Realvalue, hst)
156 endif
157 elseif ( strhead( 'double', trim(lchar(attrs(i)%attrtype))) ) then
158 if ( attrs(i)%array ) then
159 call dbgmessage('Doublearray(:) is selected.')
160 call historyaddattr( &
161 & varname, attrs(i)%attrname, attrs(i)%Doublearray, hst)
162 else
163 call dbgmessage('Doublevalue is selected')
164 call historyaddattr( &
165 & varname, attrs(i)%attrname, attrs(i)%Doublevalue, hst)
166 endif
167 elseif ( strhead( 'logical', trim(lchar(attrs(i)%attrtype))) ) then
168 call historyaddattr( &
169 & varname, attrs(i)%attrname, attrs(i)%Logicalvalue, hst)
170 else
171 call dbgmessage('attrtype=<%c>=<%c>is Invalid.' , &
172 & c1=trim(attrs(i)%attrtype) , &
173 & c2=trim(lchar(attrs(i)%attrtype)) )
174 endif
175 enddo
176 call endsub(subname)
Handling character types.
Definition dc_string.f90:83
Debug tracing module.
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

◆ copy_attrs()

subroutine, public gtool_history_internal::copy_attrs ( type(gt_history_attr), dimension(:), intent(in) from,
type(gt_history_attr), dimension(:), intent(out) to,
logical, intent(out), optional err )

Definition at line 178 of file gtool_history_internal.f90.

179 !
180 ! GT_HISTORY_ATTR 変数をコピーするためのサブルーチン
181 ! このモジュール内部で利用されることを想定している.
182 ! from と to の配列サイズは同じであることが想定されている.
183 ! err を与えると, コピーの際何らかの不具合が生じると
184 ! 終了せずに err が真になって返る.
185 !
186 use dc_string,only: lchar, strhead
188 use dc_error, only: storeerror, &
190 use dc_types, only: string
192 implicit none
193 type(GT_HISTORY_ATTR), intent(in) :: from(:)
194 type(GT_HISTORY_ATTR), intent(out) :: to(:)
195 logical, intent(out), optional :: err
196 integer :: i, stat
197 character(STRING) :: cause_c
198 character(STRING), parameter:: subname = "copy_attrs"
199 continue
200 call beginsub(subname)
201 stat = dc_noerr
202 cause_c = ''
203 call dbgmessage('size(from)=<%d>, size(to)=<%d>, So copy <%d> times.', &
204 & i=(/ size(from), size(to), min(size(from),size(to)) /) )
205 if ( size(to) < size(from) ) then
207 cause_c = 'from is larger than to'
208 goto 999
209 end if
210 ! from と to の小さい方に合わせてループ
211 do i = 1, min( size(from), size(to) )
212 ! attrname と attrtype と array はまずコピー
213 to(i)%attrname = from(i)%attrname
214 to(i)%attrtype = from(i)%attrtype
215 to(i)%array = from(i)%array
216 ! from(i)%attrtype の種別でコピーする変数を変える.
217 if ( strhead( 'char', trim(lchar(from(i)%attrtype))) ) then
218 to(i)%Charvalue = from(i)%Charvalue
219 elseif ( strhead( &
220 & lchar('Int'), trim(lchar(from(i)%attrtype)))) then
221 if ( from(i)%array ) then
222 allocate( to(i)%Intarray( size(from(i)%Intarray) ) )
223 to(i)%Intarray = from(i)%Intarray
224 else
225 to(i)%Intvalue = from(i)%Intvalue
226 endif
227 elseif ( strhead( &
228 & lchar('Real'), trim(lchar(from(i)%attrtype)))) then
229 if ( from(i)%array ) then
230 allocate( to(i)%Realarray( size(from(i)%Realarray) ) )
231 to(i)%Realarray = from(i)%Realarray
232 else
233 to(i)%Realvalue = from(i)%Realvalue
234 endif
235 elseif ( strhead( &
236 & lchar('Double'), trim(lchar(from(i)%attrtype)))) then
237 if ( from(i)%array ) then
238 allocate( to(i)%Doublearray( size(from(i)%Doublearray) ) )
239 to(i)%Doublearray = from(i)%Doublearray
240 else
241 to(i)%Doublevalue = from(i)%Doublevalue
242 endif
243 elseif ( strhead( 'logical', trim(lchar(from(i)%attrtype))) ) then
244 to(i)%Logicalvalue = from(i)%Logicalvalue
245 else
246 stat = gt_ebadattrname
247 cause_c = from(i)%attrtype
248 goto 999
249 endif
250 enddo
251999 continue
252 call storeerror(stat, subname, err, cause_c=cause_c)
253 call endsub(subname)
Error handling module.
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
Error storage variables
Definition dc_error.f90:468
integer, parameter, public gt_eargsizemismatch
Definition dc_error.f90:515
integer, parameter, public gt_ebadattrname
Definition dc_error.f90:521
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public string
Character length for string
Definition dc_types.f90:137

◆ gtmpi_axis_register()

subroutine, public gtool_history_internal::gtmpi_axis_register ( type(gt_history), intent(inout) hst,
logical, intent(out), optional err )

Definition at line 452 of file gtool_history_internal.f90.

453 !
454 ! hst % mpi_gthr_info に情報の登録を行う.
455 !
457 use gtdata_generic, only: inquire
458 use gtdata_types, only: gt_variable
460 use dc_message, only: messagenotify
461 use dc_url, only: urlsplit
463 use dc_types, only: string, dp
464 use mpi
465 implicit none
466 type(GT_HISTORY), intent(inout):: hst
467 logical, intent(out), optional:: err
468 integer:: i, j, k, ra, numdims
469 integer:: err_mpi, st_mpi(MPI_STATUS_SIZE)
470 integer, allocatable:: index_all_buf(:)
471 character(STRING):: url, dimname
472 real:: accuracy
473 real(DP):: zero_limit
474 logical:: flag_hit
475 real(DP), pointer:: large =>null(), small =>null()
476 integer:: stat
477 character(STRING):: cause_c
478 character(*), parameter:: subname = 'gtmpi_axis_register'
479 character(*), parameter:: subnameup = 'HistoryPut'
480 continue
481 call beginsub(subname)
482 cause_c = ""
483 stat = dc_noerr
484 numdims = size( hst % dimvars )
485 accuracy = 1.0e-3
486 zero_limit = 1.0e-6_dp
487 allocate( hst % mpi_gthr_info(numdims) )
488 ! 未登録の座標データ (時刻以外) がある場合にはエラー
489 ! Error is occurred when non registered data of axes (excluding time)
490 !
491 do i = 1, numdims
492 if ( hst % unlimited_index == i ) cycle
493 if ( hst % time_nv_index == i ) cycle
494 if ( hst % mpi_myrank == 0 ) then
495 call inquire( hst % dimvars(i), & ! (in)
496 & url = url ) ! (out)
497 call urlsplit( url, & ! (in)
498 & var = dimname ) ! (out)
499 call mpi_bcast( dimname, string, mpi_character, 0, mpi_comm_world, err_mpi )
500 else
501 call mpi_bcast( dimname, string, mpi_character, 0, mpi_comm_world, err_mpi )
502 end if
503 if ( hst % mpi_myrank == 0 ) then
504 if ( hst % mpi_dimdata_all(i) % length < 0 ) then
505 call messagenotify('W', subnameup, &
506 & 'data of axis (%c) in whole area is lack. ' // &
507 & 'Specify the data by "HistoryPutAxisMPI" explicitly.', &
508 & c1 = trim(dimname) )
509 stat = hst_empinoaxisdata
510 cause_c = dimname
511 goto 999
512 end if
513 end if
514 if ( hst % mpi_dimdata_each(i) % length < 0 ) then
515 call messagenotify('W', subnameup, &
516 & 'data of axis (%c) on node (%d) is lack. ' // &
517 & 'Specify the data by "HistoryPut" explicitly.', &
518 & c1 = trim(dimname), i = (/ hst % mpi_myrank /) )
519 stat = hst_empinoaxisdata
520 cause_c = dimname
521 goto 999
522 end if
523 end do
524 ! mpi_gthr_info へ情報を登録
525 ! Register information to "mpi_gthr_info"
526 !
527 do i = 1, numdims
528 if ( hst % unlimited_index == i ) cycle
529 if ( hst % time_nv_index == i ) cycle
530 allocate( &
531 & hst % mpi_gthr_info(i) % length( 0: hst % mpi_nprocs - 1 ) )
532 allocate( &
533 & hst % mpi_gthr_info(i) % &
534 & index_all( 0: hst % mpi_nprocs - 1, &
535 & hst % mpi_dimdata_all(i) % length ) )
536 hst % mpi_gthr_info(i) % index_all(:,:) = -1
537 hst % mpi_gthr_info(i) % length( hst % mpi_myrank ) = &
538 & hst % mpi_dimdata_each(i) % length
539 k = 1
540 do j = 1, hst % mpi_dimdata_all(i) % length
541 flag_hit = .false.
542 if ( abs( hst % mpi_dimdata_all(i) % a_Axis(j) ) > &
543 & abs( hst % mpi_dimdata_each(i) % a_Axis(k) ) ) then
544 large => hst % mpi_dimdata_all(i) % a_Axis(j)
545 small => hst % mpi_dimdata_each(i) % a_Axis(k)
546 else
547 large => hst % mpi_dimdata_each(i) % a_Axis(k)
548 small => hst % mpi_dimdata_all(i) % a_Axis(j)
549 end if
550 if ( large > 0.0_dp .and. small < 0.0_dp &
551 & .or. large < 0.0_dp .and. small > 0.0_dp ) then
552 cycle
553 end if
554 if ( abs( large ) < zero_limit .and. abs( small ) < zero_limit ) then
555 flag_hit = .true.
556 end if
557 if ( .not. flag_hit .and. &
558 & abs( ( large / small ) - 1.0_dp ) < accuracy ) then
559 flag_hit = .true.
560 end if
561 if ( flag_hit ) then
562 hst % mpi_gthr_info(i) % index_all ( hst % mpi_myrank, k ) = j
563 k = k + 1
564 end if
565 if ( k > hst % mpi_gthr_info(i) % length( hst % mpi_myrank ) ) exit
566 end do
567 end do
568 ! rank == 0 で情報を受け取る.
569 ! Receive information by rank == 0
570 !
571 if ( hst % mpi_myrank == 0 ) then
572 do i = 1, numdims
573 if ( hst % unlimited_index == i ) cycle
574 if ( hst % time_nv_index == i ) cycle
575 allocate( index_all_buf( hst % mpi_dimdata_all(i) % length ) )
576 do ra = 1, hst % mpi_nprocs - 1
577 call mpi_recv( &
578 & index_all_buf, &
579 & hst % mpi_dimdata_all(i) % length, &
580 & mpi_integer, ra, 0, mpi_comm_world, st_mpi, err_mpi )
581 hst % mpi_gthr_info(i) % index_all (ra,:) = index_all_buf(:)
582 end do
583 deallocate( index_all_buf )
584 do ra = 1, hst % mpi_nprocs - 1
585 call mpi_recv( &
586 & hst % mpi_gthr_info(i) % length (ra), &
587 & 1, &
588 & mpi_integer, ra, 0, mpi_comm_world, st_mpi, err_mpi )
589 end do
590 end do
591 else
592 do i = 1, numdims
593 if ( hst % unlimited_index == i ) cycle
594 if ( hst % time_nv_index == i ) cycle
595 allocate( index_all_buf( hst % mpi_dimdata_all(i) % length ) )
596 index_all_buf(:) = hst % mpi_gthr_info(i) % index_all (hst % mpi_myrank,:)
597 call mpi_send( &
598 & index_all_buf, &
599 & hst % mpi_dimdata_all(i) % length, &
600 & mpi_integer, 0, 0, mpi_comm_world, err_mpi )
601 deallocate( index_all_buf )
602 call mpi_send( &
603 & hst % mpi_gthr_info(i) % length (hst % mpi_myrank), &
604 & 1, &
605 & mpi_integer, 0, 0, mpi_comm_world, err_mpi )
606 end do
607 end if
608 ! 情報に不足が無いかチェック
609 ! Check lack of information
610 !
611 if ( hst % mpi_myrank == 0 ) then
612 do ra = 0, hst % mpi_nprocs - 1
613 do i = 1, numdims
614 if ( hst % unlimited_index == i ) cycle
615 if ( hst % time_nv_index == i ) cycle
616 end do
617 end do
618 do ra = 0, hst % mpi_nprocs - 1
619 do i = 1, numdims
620 if ( hst % unlimited_index == i ) cycle
621 if ( hst % time_nv_index == i ) cycle
622 do j = 1, hst % mpi_gthr_info(i) % length (ra)
623 if ( hst % mpi_gthr_info(i) % index_all (ra,j) < 1 ) then
624 call inquire( hst % dimvars(i), & ! (in)
625 & url = url ) ! (out)
626 call urlsplit( url, & ! (in)
627 & var = dimname ) ! (out)
628 call messagenotify('W', subnameup, &
629 & 'data of axis (%c) on node (%d) or ' // &
630 & 'in whole area are lack. ' // &
631 & 'Specify the data by "HistoryPut" or "HistoryPutAxisMPI" explicitly.', &
632 & c1 = trim(dimname), i = (/ ra /) )
633 stat = hst_empinoaxisdata
634 cause_c = dimname
635 goto 999
636 end if
637 end do
638 end do
639 end do
640 end if
641999 continue
642 call storeerror(stat, subname, err, cause_c)
643 call endsub(subname)
integer, parameter, public hst_empinoaxisdata
Definition dc_error.f90:574
Message output module.
integer, parameter, public dp
Double Precision Real number
Definition dc_types.f90:92
Variable URL string parser.
Definition dc_url.f90:61

◆ gtmpi_vars_mkindex()

subroutine, public gtool_history_internal::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)
integer, parameter, public token
Character length for word, token
Definition dc_types.f90:128

◆ lookup_dimension()

type(gt_variable) function, public gtool_history_internal::lookup_dimension ( type(gt_history), intent(in) history,
character(len = *), intent(in) dimname,
integer, intent(out), optional ord )

Definition at line 368 of file gtool_history_internal.f90.

369 !
370 ! history 内の dimname という変数名を持つ次元の GT_VARIABLE
371 ! 変数を返す. dimname 末尾の空白は無視される.
372 !
373 use gtdata_generic, only: inquire
374 use dc_types, only: string
377 implicit none
378 type(GT_HISTORY), intent(in):: history
379 character(len = *), intent(in):: dimname
380 integer, intent(out), optional:: ord
381 integer:: ordwork
382 character(len = STRING):: name, cause_c
383 integer:: i, stat
384 character(len = *), parameter:: subname = 'lookup_dimension'
385 continue
386 call beginsub(subname, 'dimname=%c', c1=trim(dimname))
387 stat = dc_noerr
388 if (present(ord)) ord = 0
389 ordwork = 0
390 if (associated(history % dimvars)) then
391 do, i = 1, size(history % dimvars)
392 call inquire(history % dimvars(i), name=name)
393 if (name == trim(dimname)) then
394 result = history % dimvars(i)
395 if (present(ord)) ord = i
396 stat = dc_noerr
397 cause_c = ""
398 goto 999
399 endif
400 enddo
401 endif
402 if (present(ord)) then
403 ord = 0
404 else
405 stat = gt_ebaddimname
406 cause_c = dimname
407 endif
408999 continue
409 call storeerror(stat, subname, cause_c=cause_c)
410 if (present(ord)) ordwork = ord
411 call endsub(subname, 'ord=%d (0:not found)', i=(/ordwork/))
integer, parameter, public gt_ebaddimname
Definition dc_error.f90:511

◆ lookup_var_or_dim()

subroutine, public gtool_history_internal::lookup_var_or_dim ( type(gt_history), intent(in) history,
character(len = *), intent(in) name,
type(gt_variable), intent(out) var,
logical, intent(out) err )

Definition at line 413 of file gtool_history_internal.f90.

414 !
415 ! history 内から, name という名前の次元または変数を探査し,
416 ! var に GT_VARIABLE 変数を返す. 見つかって正常に
417 ! var が返る場合は stat には DC_NOERR が返り,
418 ! history 内から name が発見されない場合には, stat に
419 ! NF90_ENOTVAR が返る.
420 !
421 use dc_error, only: storeerror, dc_noerr, nf90_enotvar
422 use dc_types, only: string
424 implicit none
425 type(GT_HISTORY), intent(in):: history
426 character(len = *), intent(in):: name
427 type(GT_VARIABLE), intent(out):: var
428 logical, intent(out):: err
429 integer:: stat, ord
430 character(STRING) :: cause_c
431 character(len = *), parameter:: subname = 'lookup_var_or_dim'
432 continue
433 call beginsub(subname, 'name=<%c>', c1=trim(name))
434 cause_c = ""
435 stat = dc_noerr
436 var = lookup_variable(history, name, ord)
437 if (ord /= 0) then
438 stat = dc_noerr
439 goto 999
440 endif
441 var = lookup_dimension(history, name, ord)
442 if (ord /= 0) then
443 stat = dc_noerr
444 goto 999
445 endif
446 stat = nf90_enotvar
447 cause_c = "Any vars and dims are not found"
448999 continue
449 call storeerror(stat, subname, err, cause_c)
450 call endsub(subname, 'ord=%d (0:not found)', i=(/ord/))

◆ lookup_variable()

type(gt_variable) function, public gtool_history_internal::lookup_variable ( type(gt_history), intent(in) history,
character(len = *), intent(in) varname,
integer, intent(out), optional ord )

Definition at line 325 of file gtool_history_internal.f90.

326 !
327 ! history 内での変数 varname の ID を取得
328 ! ID を取得できた場合, 返り値 result と ord にそれぞれ
329 ! その ID が返される。
330 ! ID を取得できない場合、ord が渡されていなければその場で終了
331 ! ord が渡されている場合は ord に 0 が返される。
332 !
333 use dc_types, only: string
334 use dc_error, only: storeerror, nf90_enotvar, dc_noerr
336 implicit none
337 type(GT_HISTORY), intent(in):: history
338 character(len = *), intent(in):: varname
339 character(len = STRING) :: cause_c
340 integer, intent(out), optional:: ord
341 integer:: ordwork
342 integer:: i, stat
343 character(len = *), parameter:: subname = 'lookup_variable'
344 continue
345 call beginsub(subname, '%c', c1=trim(varname))
346 stat = dc_noerr
347 cause_c = ''
348 if (present(ord)) ord = 0
349 ordwork = 0
350 i = lookup_variable_ord(history, varname)
351 if (i > 0) then
352 result = history % vars(i)
353 if (present(ord)) ord = i
354 goto 999
355 endif
356 if (present(ord)) then
357 ord = 0
358 else
359 stat = nf90_enotvar
360 cause_c = varname
361 i = 0
362 endif
363999 continue
364 call storeerror(stat, subname, cause_c=cause_c)
365 if (present(ord)) ordwork = ord
366 call endsub(subname, "ord=%d (0: not found)", i=(/ordwork/))

◆ lookup_variable_ord()

integer function, public gtool_history_internal::lookup_variable_ord ( type(gt_history), intent(in) history,
character(len = *), intent(in) varname )

Definition at line 298 of file gtool_history_internal.f90.

299 !
300 ! history 内の varname 変数の変数番号を返す.
301 ! 現在, 明示的に history 変数を与えない場合の変数番号の
302 ! 検索は出来ない.
303 !
304 use dc_types, only: string
305 use gtdata_generic, only: inquire
307 implicit none
308 type(GT_HISTORY), intent(in):: history
309 character(len = *), intent(in):: varname
310 character(len = string):: name
311 character(len = *), parameter:: subname = 'lookup_variable_ord'
312 continue
313 call beginsub(subname, 'var=%c', c1 = trim(varname))
314 if (associated(history % vars)) then
315 do, result = 1, size(history % vars)
316 call inquire(history % vars(result), name=name)
317 if (name == varname) goto 999
318 call dbgmessage('no match <%c> <%c>', c1=trim(name), c2=trim(varname))
319 enddo
320 endif
321 result = 0
322999 continue
323 call endsub(subname, "result=%d", i=(/result/))

◆ set_fake_dim_value()

subroutine, public gtool_history_internal::set_fake_dim_value ( type(gt_history), intent(inout) history,
integer, intent(in) dimord )

Definition at line 255 of file gtool_history_internal.f90.

256 !
257 ! 次元 history % dimvars(dimord) に値が設定されていない場合、
258 ! 「とりあえず」値を設定する。ただし、無制限次元 (時間次元)
259 ! に関しては history % origin, history % interval, history % count
260 ! から「まっとうな」値が設定される。
261 !
262 use gtdata_generic, only: inquire, slice, put
263 use dc_error, only: dumperror
264 use dc_types, only: dp
265! use dc_calendar, only: DCCalConvertByUnit
266! use dc_date, only: EvalByUnit
267 type(GT_HISTORY), intent(inout):: history
268 integer, intent(in):: dimord
269 integer:: length, i
270 real(DP), allocatable:: value(:)
271 logical:: err
272 continue
273 if (dimord == history % unlimited_index) then
274 if (.not. associated(history % count)) return
275 length = maxval(history % count(:))
276 else
277 call inquire(history % dimvars(dimord), size=length)
278 endif
279 if (length == 0) return
280 allocate(value(length))
281 if (dimord == history % unlimited_index) then
282 value(:) = (/(real(i, dp), i = 1, length)/)
283 value(:) = &
284 & history % origin &
285 & + (value(:) - 1.0_dp) * history % interval
286!!$ value(:) = &
287!!$ & EvalByUnit( history % origin, '', history % unlimited_units_symbol ) &
288!!$ & + (value(:) - 1.0) &
289!!$ & * EvalByUnit( history % interval, '', history % unlimited_units_symbol )
290 call slice(history % dimvars(dimord), 1, start=1, count=length)
291 else
292 value(:) = (/(real(i, dp), i = 1, length)/)
293 endif
294 call put(history % dimvars(dimord), value, size(value), err)
295 if (err) call dumperror
296 deallocate(value)
Procedure reference specification. Made as an external function to be replaceable in the future.
Definition dc_error.f90:592

Variable Documentation

◆ default

type(gt_history), target, save, public gtool_history_internal::default

Definition at line 53 of file gtool_history_internal.f90.

53 type(GT_HISTORY), save, target, public:: default

◆ gtool4_netcdf_conventions

character(string), parameter, public gtool_history_internal::gtool4_netcdf_conventions = "http://www.gfd-dennou.org/library/gtool4/conventions/"

Definition at line 61 of file gtool_history_internal.f90.

61 character(STRING), parameter, public:: &
62 & gtool4_netCDF_Conventions = &
63 & "http://www.gfd-dennou.org/library/gtool4/conventions/"

◆ gtool4_netcdf_version

character(string), parameter, public gtool_history_internal::gtool4_netcdf_version = "4.3"

Definition at line 65 of file gtool_history_internal.f90.

65 character(STRING), parameter, public:: &
66 & gtool4_netCDF_version = "4.3"