gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
hstnmlinfogetnames.f90 File Reference

変数リストを文字列型配列ポインタとして取得 More...

Go to the source code of this file.

Functions/Subroutines

subroutine hstnmlinfogetnames (gthstnml, varnames_ary, err)

Detailed Description

変数リストを文字列型配列ポインタとして取得

Author
Yasuhiro MORIKAWA

Definition in file hstnmlinfogetnames.f90.

Function/Subroutine Documentation

◆ hstnmlinfogetnames()

subroutine hstnmlinfogetnames ( type(gthst_nmlinfo), intent(in) gthstnml,
character(token), dimension(:), pointer varnames_ary,
logical, intent(out), optional err )

登録されている変数名リストを文字型配列ポインタとして返す

gthstnml に設定されている変数リストを文字型配列ポインタに 返します. varnames_ary は空状態にして与えてください.

なお, 与えられた gthstnml が HstNmlInfoCreate によって初期設定 されていない場合, プログラムはエラーを発生させます.

Parameters
[in]gthstnmlgtool_history_nmlinfo_types::GTHST_NMLINFO 型変数
[out]varnames_ary変数名の配列ポインタ. Character array pointer of variable names.
[out]err例外処理用フラグ. Exception handling flag.

Definition at line 40 of file hstnmlinfogetnames.f90.

43 use dc_trace, only: beginsub, endsub
44 use dc_types, only: string, token
46 use netcdf, only: nf90_max_vars
47 implicit none
48 type(GTHST_NMLINFO), intent(in):: gthstnml
49 character(TOKEN), pointer:: varnames_ary(:) ! (out)
50 logical, intent(out), optional:: err
51 ! 例外処理用フラグ.
52 ! デフォルトでは, この手続き内でエラーが
53 ! 生じた場合, プログラムは強制終了します.
54 ! 引数 *err* が与えられる場合,
55 ! プログラムは強制終了せず, 代わりに
56 ! *err* に .true. が代入されます.
57 !
58 ! Exception handling flag.
59 ! By default, when error occur in
60 ! this procedure, the program aborts.
61 ! If this *err* argument is given,
62 ! .true. is substituted to *err* and
63 ! the program does not abort.
64
65 !-----------------------------------
66 ! 作業変数
67 ! Work variables
68 type(GTHST_NMLINFO_ENTRY), pointer:: hptr =>null()
69 integer:: varnums, ary_size
70 character(TOKEN), allocatable:: varnames_ary_tmp1(:), varnames_ary_tmp2(:)
71 integer:: stat
72 character(STRING):: cause_c
73 character(*), parameter:: subname = 'HstNmlInfoNames'
74 continue
75 call beginsub( subname )
76 stat = dc_noerr
77 cause_c = ''
78
79 varnums = 0
80
81 !-----------------------------------------------------------------
82 ! 初期設定のチェック
83 ! Check initialization
84 !-----------------------------------------------------------------
85 if ( .not. gthstnml % initialized ) then
86 stat = dc_enotinit
87 cause_c = 'GTHST_NMLINFO'
88 goto 999
89 end if
90
91 !-----------------------------------------------------------------
92 ! 割り付け
93 ! Allocate
94 !-----------------------------------------------------------------
95 if ( associated(varnames_ary) ) deallocate(varnames_ary)
96 allocate( varnames_ary_tmp1(1:nf90_max_vars) )
97
98 !-----------------------------------------------------------------
99 ! 情報の取り出し
100 ! Fetch information
101 !-----------------------------------------------------------------
102 hptr => gthstnml % gthstnml_list
103 do while ( associated( hptr % next ) )
104 call listnext( gthstnml_list = hptr ) ! (inout)
105 varnums = varnums + 1
106 ary_size = size( varnames_ary_tmp1 )
107 if ( varnums > ary_size ) then
108 allocate( varnames_ary_tmp2(1:ary_size) )
109 varnames_ary_tmp2(1:ary_size) = varnames_ary_tmp1(1:ary_size)
110 deallocate( varnames_ary_tmp1 )
111 allocate( varnames_ary_tmp1(1:varnums*2) )
112 varnames_ary_tmp1(1:ary_size) = varnames_ary_tmp2(1:ary_size)
113 deallocate( varnames_ary_tmp2 )
114 end if
115
116 varnames_ary_tmp1(varnums) = adjustl( hptr % name )
117 end do
118
119 if ( varnums > 0 ) then
120 allocate( varnames_ary(1:varnums) )
121 varnames_ary(1:varnums) = varnames_ary_tmp1(1:varnums)
122 else
123 allocate( varnames_ary(1:1) )
124 varnames_ary = ''
125 end if
126
127 !-----------------------------------------------------------------
128 ! 終了処理, 例外処理
129 ! Termination and Exception handling
130 !-----------------------------------------------------------------
131999 continue
132 nullify( hptr )
133 call storeerror( stat, subname, err, cause_c )
134 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_enotinit
-400 以下: dc ユーティリティのエラー
Definition dc_error.f90:534
integer, parameter, public dc_noerr
エラー等を保持
Definition dc_error.f90:468
デバッグ時の追跡用モジュール
Definition dc_trace.f90:150
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

References dc_trace::beginsub(), dc_error::dc_enotinit, 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: