gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
gtvaropen.f90
Go to the documentation of this file.
1!> @file gtvaropen.f90
2!>
3!> @author Yasuhiro MORIKAWA, Eizi TOYODA
4!> @copyright Copyright (C) GFD Dennou Club, 2000-2026. All rights reserved. <br/>
5!> License is BSD-2-Clause. See [COPYRIGHT](@ref COPYRIGHT) in detail
6!>
7!> @en
8!> @brief Open gtool4 data
9!>
10!> This subroutine is provided through gtdata_generic.
11!> @enden
12!>
13!> @ja
14!> @brief gtool4 データのオープン
15!>
16!> このサブルーチンは gtdata_generic から提供されます。
17!> @endja
18!>
19
20!>
21!> @en
22!> @brief Open gtool4 variable
23!>
24!> Opens the gtool variable identified by url and stores it in var.
25!> If writable is set to .true., attempts to open for writing.
26!> The default is to open read-only.
27!> (Note: writable behavior is not yet guaranteed.)
28!>
29!> Variables opened with Open must always be closed with Close.
30!>
31!> If an error occurs and err is provided, err returns .true..
32!> If err is not provided, the program terminates.
33!>
34!> Open is a generic name for 2 subroutines; it is also possible
35!> to open by specifying a dimension of a variable.
36!> @param[out] var Variable handle
37!> @param[in] url Variable URL
38!> @param[in] writable Open for writing (optional)
39!> @param[out] err Error flag (optional)
40!> @enden
41!>
42!> @ja
43!> @brief gtool4 変数を開く
44!>
45!> url で識別される gtool 変数を開き、var に格納します。
46!> writable を .true. に指定すると書き込み可で開こうとします。
47!> デフォルトは書き込み不可で開きます。
48!> (まだ writable の動作は保障されていません)。
49!>
50!> Open された変数は必ず Close されなければなりません。
51!>
52!> エラーが発生した場合、引数 err が与えられる場合は err が
53!> .true. となって返ります。
54!> 引数 err を与えなければプログラムは停止します。
55!>
56!> Open は 2 つのサブルーチンの総称名であり、
57!> ある変数の次元を指定することで開くことも可能です。
58!> @param[out] var 変数ハンドル
59!> @param[in] url 変数URL
60!> @param[in] writable 書き込み可で開く (省略可能)
61!> @param[out] err エラーフラグ (省略可能)
62!> @endja
63!>
64subroutine gtvaropen(var, url, writable, err)
65 use dc_string, only: strhead
66 use dc_types, only: string
67 use gtdata_types, only: gt_variable
68 use gtdata_generic, only: limit
69 use gtdata_internal_map, only: map_create, vtb_class_netcdf, gtvar_dump
72 use dc_url, only: url_chop_iorange
74 use dc_trace, only: beginsub, endsub
76 implicit none
77 type(gt_variable), intent(out):: var
78 character(*), intent(in):: url
79 logical, intent(in), optional:: writable
80 logical, intent(out), optional:: err
81 integer:: ndims, stat, cause_i
82 character(STRING):: cause_c
83 integer, allocatable:: dimlen(:)
84 type(gd_nc_variable):: gdnc
85 character(STRING):: filevar, iorange
86 character(*), parameter:: subname = "GTVarOpen"
87 character(*), parameter:: version = &
88 & '$Name: $' // &
89 & '$Id: gtvaropen.f90,v 1.4 2009-05-25 09:55:57 morikawa Exp $'
90continue
91 call beginsub(subname, fmt='<%c>', c1=trim(url), version=version)
92 stat = dc_noerr
93 cause_i = 0
94 cause_c = ''
95 var = gt_variable(-1)
96 call url_chop_iorange(url, iorange=iorange, remainder=filevar)
97 call open(gdnc, filevar, writable, err)
98 if ( present_and_true(err) ) then
99 stat = gt_enotvar
100 goto 999
101 end if
102 call inquire(gdnc, ndims=ndims)
103 allocate(dimlen(max(1, ndims)))
104 call inquire(gdnc, dimlen=dimlen)
105 call map_create(var, vtb_class_netcdf, gdnc%id, ndims, dimlen, stat)
106 if (stat /= dc_noerr) then
107 cause_i = ndims
108 goto 999
109 end if
110 deallocate(dimlen)
111 call limit(var, trim(iorange))
112 call gtvar_dump(var)
113999 continue
114 call storeerror(stat, subname, err, cause_c = cause_c, cause_i = cause_i)
115 call endsub(subname, 'mapid=%d', i=(/var%mapid/))
116end subroutine gtvaropen
subroutine gtvaropen(var, url, writable, err)
Definition gtvaropen.f90:65
エラー処理用モジュール
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
integer, parameter, public gt_enotvar
Definition dc_error.f90:512
省略可能な制御パラメータの判定
logical function, public present_and_true(arg)
文字型変数の操作
Definition dc_string.f90:83
デバッグ時の追跡用モジュール
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 string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137
変数 URL の文字列解析
Definition dc_url.f90:61
subroutine, public url_chop_iorange(fullname, iorange, remainder)
Definition dc_url.f90:301
subroutine, public map_create(var, class, cid, ndims, allcount, stat)