hstnmlinfogetnames.f90
Go to the documentation of this file.
1 != 変数リストを文字列型配列ポインタとして取得
2 != Return list of variables as character array pointer
3 !
4 ! Authors:: Yasuhiro MORIKAWA
5 ! Version:: $Id: hstnmlinfogetnames.f90,v 1.1 2009-05-11 15:15:15 morikawa Exp $
6 ! Tag Name:: $Name: $
7 ! Copyright:: Copyright (C) GFD Dennou Club, 2007-2009. All rights reserved.
8 ! License:: See COPYRIGHT[link:../../../COPYRIGHT]
9 !
10  subroutine hstnmlinfogetnames( gthstnml, varnames_ary, err )
11  !
12  ! *gthstnml* が設定されている変数リストを文字型配列ポインタに
13  ! 返します. varnames_ary は空状態にして与えてください.
14  !
15  ! なお, 与えられた *gthstnml* が HstNmlInfoCreate によって初期設定
16  ! されていない場合, プログラムはエラーを発生させます.
17  !
18  ! List of variables registered in *gthstnml* is returned to
19  ! character array pointer.
20  ! Nullify "varnames_ary" before it is given to this subroutine.
21  !
22  ! If *gthstnml* is not initialized by "HstNmlInfoCreate" yet,
23  ! error is occurred.
24  !
27  use dc_trace, only: beginsub, endsub
29  use dc_types, only: dp, string, token, stdout
31  use netcdf, only: nf90_max_vars
32  implicit none
33  type(gthst_nmlinfo), intent(in):: gthstnml
34  character(TOKEN), pointer:: varnames_ary(:) ! (out)
35  logical, intent(out), optional:: err
36  ! 例外処理用フラグ.
37  ! デフォルトでは, この手続き内でエラーが
38  ! 生じた場合, プログラムは強制終了します.
39  ! 引数 *err* が与えられる場合,
40  ! プログラムは強制終了せず, 代わりに
41  ! *err* に .true. が代入されます.
42  !
43  ! Exception handling flag.
44  ! By default, when error occur in
45  ! this procedure, the program aborts.
46  ! If this *err* argument is given,
47  ! .true. is substituted to *err* and
48  ! the program does not abort.
49 
50  !-----------------------------------
51  ! 作業変数
52  ! Work variables
53  type(gthst_nmlinfo_entry), pointer:: hptr =>null()
54  integer:: varnums, ary_size
55  character(TOKEN), allocatable:: varnames_ary_tmp1(:), varnames_ary_tmp2(:)
56  integer:: stat
57  character(STRING):: cause_c
58  character(*), parameter:: subname = 'HstNmlInfoNames'
59  continue
60  call beginsub( subname )
61  stat = dc_noerr
62  cause_c = ''
63 
64  varnums = 0
65 
66  !-----------------------------------------------------------------
67  ! 初期設定のチェック
68  ! Check initialization
69  !-----------------------------------------------------------------
70  if ( .not. gthstnml % initialized ) then
71  stat = dc_enotinit
72  cause_c = 'GTHST_NMLINFO'
73  goto 999
74  end if
75 
76  !-----------------------------------------------------------------
77  ! 割り付け
78  ! Allocate
79  !-----------------------------------------------------------------
80  if ( associated(varnames_ary) ) deallocate(varnames_ary)
81  allocate( varnames_ary_tmp1(1:nf90_max_vars) )
82 
83  !-----------------------------------------------------------------
84  ! 情報の取り出し
85  ! Fetch information
86  !-----------------------------------------------------------------
87  hptr => gthstnml % gthstnml_list
88  do while ( associated( hptr % next ) )
89  call listnext( gthstnml_list = hptr ) ! (inout)
90  varnums = varnums + 1
91  ary_size = size( varnames_ary_tmp1 )
92  if ( varnums > ary_size ) then
93  allocate( varnames_ary_tmp2(1:ary_size) )
94  varnames_ary_tmp2(1:ary_size) = varnames_ary_tmp1(1:ary_size)
95  deallocate( varnames_ary_tmp1 )
96  allocate( varnames_ary_tmp1(1:varnums*2) )
97  varnames_ary_tmp1(1:ary_size) = varnames_ary_tmp2(1:ary_size)
98  deallocate( varnames_ary_tmp2 )
99  end if
100 
101  varnames_ary_tmp1(varnums) = adjustl( hptr % name )
102  end do
103 
104  if ( varnums > 0 ) then
105  allocate( varnames_ary(1:varnums) )
106  varnames_ary(1:varnums) = varnames_ary_tmp1(1:varnums)
107  else
108  allocate( varnames_ary(1:1) )
109  varnames_ary = ''
110  end if
111 
112  !-----------------------------------------------------------------
113  ! 終了処理, 例外処理
114  ! Termination and Exception handling
115  !-----------------------------------------------------------------
116 999 continue
117  nullify( hptr )
118  call storeerror( stat, subname, err, cause_c )
119  call endsub( subname )
120  end subroutine hstnmlinfogetnames
integer, parameter, public dc_enotinit
Definition: dc_error.f90:557
integer, parameter, public token
単語やキーワードを保持する文字型変数の種別型パラメタ
Definition: dc_types.f90:109
subroutine hstnmlinfogetnames(gthstnml, varnames_ary, err)
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition: dc_error.f90:830
integer, parameter, public dc_noerr
Definition: dc_error.f90:509
character(string) function, public joinchar(carray, expr)
Definition: dc_string.f90:861
integer, parameter, public dp
倍精度実数型変数
Definition: dc_types.f90:83
subroutine, public beginsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca, version)
Definition: dc_trace.f90:351
integer, parameter, public stdout
標準出力の装置番号
Definition: dc_types.f90:98
文字型変数の操作.
Definition: dc_string.f90:24
種別型パラメタを提供します。
Definition: dc_types.f90:49
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:446
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition: dc_types.f90:118