file_hdf_l.F90 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. module file_hdf_l
  2. implicit none
  3. ! --- in/out --------------------------
  4. private
  5. public :: ReadAttribute, CheckAttribute
  6. public :: WriteAttribute
  7. ! --- const ----------------------------
  8. include "hdf.f90"
  9. character(len=*), parameter :: mname = 'file_hdf_l'
  10. ! --- interfaces ------------------------
  11. interface ReadAttribute
  12. module procedure obj_ReadAttribute_l_0d
  13. module procedure obj_ReadAttribute_l_1d
  14. !
  15. module procedure sds_ReadAttribute_l_0d
  16. module procedure sds_ReadAttribute_l_1d
  17. !
  18. module procedure dim_ReadAttribute_l_0d
  19. module procedure dim_ReadAttribute_l_1d
  20. !
  21. module procedure hdf_ReadAttribute_l_0d
  22. module procedure hdf_ReadAttribute_l_1d
  23. end interface
  24. interface CheckAttribute
  25. module procedure obj_CheckAttribute_l_0d
  26. module procedure obj_CheckAttribute_l_1d
  27. !
  28. module procedure sds_CheckAttribute_l_0d
  29. module procedure sds_CheckAttribute_l_1d
  30. !
  31. module procedure dim_CheckAttribute_l_0d
  32. module procedure dim_CheckAttribute_l_1d
  33. !
  34. module procedure hdf_CheckAttribute_l_0d
  35. module procedure hdf_CheckAttribute_l_1d
  36. end interface
  37. interface WriteAttribute
  38. module procedure obj_WriteAttribute_l_0d
  39. module procedure obj_WriteAttribute_l_1d
  40. !
  41. module procedure sds_WriteAttribute_l_0d
  42. module procedure sds_WriteAttribute_l_1d
  43. !
  44. module procedure dim_WriteAttribute_l_0d
  45. module procedure dim_WriteAttribute_l_1d
  46. !
  47. module procedure hdf_WriteAttribute_l_0d
  48. module procedure hdf_WriteAttribute_l_1d
  49. end interface
  50. contains
  51. ! ############################################################
  52. ! ###
  53. ! ### objects
  54. ! ###
  55. ! ############################################################
  56. ! ================================================================
  57. ! ===
  58. ! === read attributes
  59. ! ===
  60. ! ================================================================
  61. subroutine obj_ReadAttribute_l_0d( obj_id, name, l, status )
  62. use file_hdf_base, only : wpi
  63. use file_hdf_base, only : FindAttribute, CheckAttributeInfo, GetAttributeInfo
  64. ! --- in/out -------------------------
  65. integer(wpi), intent(in) :: obj_id
  66. character(len=*), intent(in) :: name
  67. logical, intent(out) :: l
  68. integer, intent(out) :: status
  69. ! --- const -------------------------------
  70. character(len=*), parameter :: rname = mname//'/obj_ReadAttribute_l_0d'
  71. ! --- local -------------------------------
  72. integer :: attr_index, data_type
  73. ! --- external ----------------------------
  74. integer(wpi), external :: sfRNAtt
  75. ! --- begin -------------------------------
  76. ! get index:
  77. call FindAttribute( obj_id, name, attr_index, status )
  78. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  79. ! check number of values:
  80. call CheckAttributeInfo( obj_id, attr_index, status, n_values=1 )
  81. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  82. ! extract value:
  83. call GetAttributeInfo( obj_id, attr_index, status, data_type=data_type )
  84. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  85. ! read:
  86. select case ( data_type )
  87. case ( DFNT_INT32 )
  88. status = sfRNAtt( obj_id, attr_index, 1, l )
  89. case default
  90. write (*,'("ERROR - not implemented for data type ",i6)') data_type
  91. write (*,'("ERROR in ",a)') rname; status=1; return
  92. end select
  93. if ( status /= SUCCEED ) then
  94. write (*,'("ERROR - reading attribute : ",a)') trim(name)
  95. write (*,'("ERROR in ",a)') rname; status=1; return
  96. end if
  97. ! ok
  98. status = 0
  99. end subroutine obj_ReadAttribute_l_0d
  100. ! ***
  101. subroutine obj_ReadAttribute_l_1d( obj_id, name, l, status )
  102. use file_hdf_base, only : wpi
  103. use file_hdf_base, only : FindAttribute, CheckAttributeInfo, GetAttributeInfo
  104. ! --- in/out -------------------------
  105. integer(wpi), intent(in) :: obj_id
  106. character(len=*), intent(in) :: name
  107. logical, intent(out) :: l(:)
  108. integer, intent(out) :: status
  109. ! --- const -------------------------------
  110. character(len=*), parameter :: rname = mname//'/obj_ReadAttribute_l_1d'
  111. ! --- local -------------------------------
  112. integer :: attr_index, data_type
  113. ! --- external ----------------------------
  114. integer(wpi), external :: sfRNAtt
  115. ! --- begin -------------------------------
  116. ! get index:
  117. call FindAttribute( obj_id, name, attr_index, status )
  118. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  119. ! check number of values:
  120. call CheckAttributeInfo( obj_id, attr_index, status, n_values=size(l) )
  121. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  122. ! extract value:
  123. call GetAttributeInfo( obj_id, attr_index, status, data_type=data_type )
  124. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  125. ! read:
  126. select case ( data_type )
  127. case ( DFNT_INT32 )
  128. status = sfRNAtt( obj_id, attr_index, size(l), l )
  129. case default
  130. write (*,'("ERROR - not implemented for data type ",i6)') data_type
  131. write (*,'("ERROR in ",a)') rname; status=1; return
  132. end select
  133. if ( status /= SUCCEED ) then
  134. write (*,'("ERROR - reading attribute : ",a)') trim(name)
  135. write (*,'("ERROR in ",a)') rname; status=1; return
  136. end if
  137. ! ok
  138. status = 0
  139. end subroutine obj_ReadAttribute_l_1d
  140. ! ================================================================
  141. ! ===
  142. ! === check attributes
  143. ! ===
  144. ! ================================================================
  145. subroutine obj_CheckAttribute_l_0d( obj_id, name, l, status )
  146. use file_hdf_base, only : wpi
  147. ! --- in/out -------------------------
  148. integer(wpi), intent(in) :: obj_id
  149. character(len=*), intent(in) :: name
  150. logical, intent(in) :: l
  151. integer, intent(inout) :: status
  152. ! --- const -------------------------------
  153. character(len=*), parameter :: rname = mname//'/obj_CheckAttribute_l_0d'
  154. ! --- local -------------------------------
  155. logical :: verbose
  156. logical :: attr_l
  157. ! --- begin -------------------------------
  158. ! write error messages ?
  159. verbose = status == 0
  160. ! read data:
  161. call ReadAttribute( obj_id, name, attr_l, status )
  162. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  163. ! check
  164. if ( attr_l .neqv. l ) then
  165. if (verbose) then
  166. write (*,'("ERROR - foud different attribute values:")')
  167. write (*,'("ERROR - attr name : ",a)') trim(name)
  168. write (*,'("ERROR - requested : ",l2)') l
  169. write (*,'("ERROR - found : ",l2)') attr_l
  170. write (*,'("ERROR in ",a)') rname
  171. end if
  172. status=-1; return
  173. end if
  174. ! ok
  175. status = 0
  176. end subroutine obj_CheckAttribute_l_0d
  177. ! ***
  178. subroutine obj_CheckAttribute_l_1d( obj_id, name, l, status )
  179. use file_hdf_base, only : wpi
  180. ! --- in/out -------------------------
  181. integer(wpi), intent(in) :: obj_id
  182. character(len=*), intent(in) :: name
  183. logical, intent(in) :: l(:)
  184. integer, intent(inout) :: status
  185. ! --- const -------------------------------
  186. character(len=*), parameter :: rname = mname//'/obj_CheckAttribute_l_1d'
  187. ! --- local -------------------------------
  188. logical :: verbose
  189. logical :: attr_l(size(l))
  190. ! --- begin -------------------------------
  191. ! write error messages ?
  192. verbose = status == 0
  193. ! read data:
  194. call ReadAttribute( obj_id, name, attr_l, status )
  195. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  196. ! check
  197. if ( any( attr_l .neqv. l ) ) then
  198. if (verbose) then
  199. write (*,'("ERROR - foud different attribute values:")')
  200. write (*,'("ERROR - attr name : ",a)') trim(name)
  201. write (*,'("ERROR - requested : ",10l2)') l
  202. write (*,'("ERROR - found : ",10l2)') attr_l
  203. write (*,'("ERROR in ",a)') rname
  204. end if
  205. status=-1; return
  206. end if
  207. ! ok
  208. status = 0
  209. end subroutine obj_CheckAttribute_l_1d
  210. ! ================================================================
  211. ! ===
  212. ! === write attributes
  213. ! ===
  214. ! ================================================================
  215. subroutine obj_WriteAttribute_l_0d( obj_id, name, l, status )
  216. use file_hdf_base, only : wpi
  217. ! --- in/out -------------------------
  218. integer(wpi), intent(in) :: obj_id
  219. character(len=*), intent(in) :: name
  220. logical, intent(in) :: l
  221. integer, intent(out) :: status
  222. ! --- const -------------------------------
  223. character(len=*), parameter :: rname = mname//'/obj_WriteAttribute_l_0d'
  224. ! --- external ----------------------------
  225. integer(wpi), external :: sfSNAtt
  226. ! --- begin -------------------------------
  227. ! write attribute:
  228. status = sfSNAtt( obj_id, name, DFNT_INT32, 1, l )
  229. if ( status /= SUCCEED ) then
  230. write (*,'("ERROR - error writing attribute ",a)') trim(name)
  231. write (*,'("ERROR in ",a)') rname; status=1; return
  232. end if
  233. ! ok
  234. status = 0
  235. end subroutine obj_WriteAttribute_l_0d
  236. ! ***
  237. subroutine obj_WriteAttribute_l_1d( obj_id, name, l, status )
  238. use file_hdf_base, only : wpi
  239. ! --- in/out -------------------------
  240. integer(wpi), intent(in) :: obj_id
  241. character(len=*), intent(in) :: name
  242. logical, dimension(:), intent(in) :: l
  243. integer, intent(out) :: status
  244. ! --- const -------------------------------
  245. character(len=*), parameter :: rname = mname//'/obj_WriteAttribute_l_1d'
  246. ! --- external ----------------------------
  247. integer(wpi), external :: sfSNAtt
  248. ! --- begin -------------------------------
  249. ! write attribute:
  250. status = sfSNAtt( obj_id, name, DFNT_INT32, size(l), l )
  251. if ( status /= SUCCEED ) then
  252. write (*,'("ERROR - error writing attribute ",a)') trim(name)
  253. write (*,'("ERROR in ",a)') rname; status=1; return
  254. end if
  255. ! ok
  256. status = 0
  257. end subroutine obj_WriteAttribute_l_1d
  258. ! ############################################################
  259. ! ###
  260. ! ### scientific data sets
  261. ! ###
  262. ! ############################################################
  263. ! ================================================================
  264. ! get attributes
  265. ! ================================================================
  266. subroutine sds_ReadAttribute_l_0d( sds, name, l, status )
  267. use file_hdf_base, only : TSds
  268. ! --- in/out -------------------------
  269. type(Tsds), intent(in) :: sds
  270. character(len=*), intent(in) :: name
  271. logical, intent(out) :: l
  272. integer, intent(out) :: status
  273. ! --- const -------------------------------
  274. character(len=*), parameter :: rname = mname//'/sds_ReadAttribute_l_0d'
  275. ! --- begin -------------------------------
  276. call ReadAttribute( sds%id, name, l, status )
  277. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  278. ! ok
  279. status = 0
  280. end subroutine sds_ReadAttribute_l_0d
  281. ! ***
  282. subroutine sds_ReadAttribute_l_1d( sds, name, l, status )
  283. use file_hdf_base, only : TSds
  284. ! --- in/out -------------------------
  285. type(Tsds), intent(in) :: sds
  286. character(len=*), intent(in) :: name
  287. logical, intent(out) :: l(:)
  288. integer, intent(out) :: status
  289. ! --- const -------------------------------
  290. character(len=*), parameter :: rname = mname//'/sds_ReadAttribute_l_1d'
  291. ! --- begin -------------------------------
  292. call ReadAttribute( sds%id, name, l, status )
  293. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  294. ! ok
  295. status = 0
  296. end subroutine sds_ReadAttribute_l_1d
  297. ! =============================================================
  298. ! === check attributes
  299. ! =============================================================
  300. subroutine sds_CheckAttribute_l_0d( sds, name, l, status )
  301. use file_hdf_base, only : TSds
  302. ! --- in/out -------------------------
  303. type(TSds), intent(in) :: sds
  304. character(len=*), intent(in) :: name
  305. logical, intent(in) :: l
  306. integer, intent(inout) :: status
  307. ! --- const -------------------------------
  308. character(len=*), parameter :: rname = mname//'/sds_CheckAttribute_l_0d'
  309. ! --- local ------------------------------
  310. logical :: verbose
  311. ! --- begin ---------------------------
  312. ! write error messages ?
  313. verbose = status == 0
  314. call CheckAttribute( sds%id, name, l, status )
  315. if (status>0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  316. if (status<0) then
  317. if (verbose) write (*,'("ERROR in ",a)') rname
  318. status=-1; return
  319. end if
  320. ! ok
  321. status = 0
  322. end subroutine sds_CheckAttribute_l_0d
  323. ! ***
  324. subroutine sds_CheckAttribute_l_1d( sds, name, l, status )
  325. use file_hdf_base, only : TSds
  326. ! --- in/out -------------------------
  327. type(TSds), intent(in) :: sds
  328. character(len=*), intent(in) :: name
  329. logical, intent(in) :: l(:)
  330. integer, intent(inout) :: status
  331. ! --- const -------------------------------
  332. character(len=*), parameter :: rname = mname//'/sds_CheckAttribute_l_1d'
  333. ! --- local ------------------------------
  334. logical :: verbose
  335. ! --- begin ---------------------------
  336. ! write error messages ?
  337. verbose = status == 0
  338. call CheckAttribute( sds%id, name, l, status )
  339. if (status>0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  340. if (status<0) then
  341. if (verbose) write (*,'("ERROR in ",a)') rname
  342. status=-1; return
  343. end if
  344. ! ok
  345. status = 0
  346. end subroutine sds_CheckAttribute_l_1d
  347. ! ================================================================
  348. ! write attributes
  349. ! ================================================================
  350. subroutine sds_WriteAttribute_l_0d( sds, name, l, status )
  351. use file_hdf_base, only : TSds
  352. ! --- in/out -------------------------
  353. type(Tsds), intent(in) :: sds
  354. character(len=*), intent(in) :: name
  355. logical, intent(in) :: l
  356. integer, intent(out) :: status
  357. ! --- const -------------------------------
  358. character(len=*), parameter :: rname = mname//'/sds_WriteAttribute_l_0d'
  359. ! --- begin -------------------------------
  360. call WriteAttribute( sds%id, name, l, status )
  361. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  362. ! ok
  363. status = 0
  364. end subroutine sds_WriteAttribute_l_0d
  365. ! ***
  366. subroutine sds_WriteAttribute_l_1d( sds, name, l, status )
  367. use file_hdf_base, only : TSds
  368. ! --- in/out -------------------------
  369. type(Tsds), intent(in) :: sds
  370. character(len=*), intent(in) :: name
  371. logical, intent(in) :: l(:)
  372. integer, intent(out) :: status
  373. ! --- const -------------------------------
  374. character(len=*), parameter :: rname = mname//'/sds_WriteAttribute_l_1d'
  375. ! --- begin -------------------------------
  376. call WriteAttribute( sds%id, name, l, status )
  377. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  378. ! ok
  379. status = 0
  380. end subroutine sds_WriteAttribute_l_1d
  381. ! ############################################################
  382. ! ###
  383. ! ### dimensions
  384. ! ###
  385. ! ############################################################
  386. ! ================================================================
  387. ! get attributes
  388. ! ================================================================
  389. subroutine dim_ReadAttribute_l_0d( sdim, name, l, status )
  390. use file_hdf_base, only : TSdsDim
  391. ! --- in/out -------------------------
  392. type(TSdsDim), intent(in) :: sdim
  393. character(len=*), intent(in) :: name
  394. logical, intent(out) :: l
  395. integer, intent(out) :: status
  396. ! --- const -------------------------------
  397. character(len=*), parameter :: rname = mname//'/dim_ReadAttribute_l_0d'
  398. ! --- begin -------------------------------
  399. call ReadAttribute( sdim%id, name, l, status )
  400. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  401. ! ok
  402. status = 0
  403. end subroutine dim_ReadAttribute_l_0d
  404. ! ***
  405. subroutine dim_ReadAttribute_l_1d( sdim, name, l, status )
  406. use file_hdf_base, only : TSdsDim
  407. ! --- in/out -------------------------
  408. type(TSdsDim), intent(in) :: sdim
  409. character(len=*), intent(in) :: name
  410. logical, intent(out) :: l(:)
  411. integer, intent(out) :: status
  412. ! --- const -------------------------------
  413. character(len=*), parameter :: rname = mname//'/dim_ReadAttribute_l_1d'
  414. ! --- begin -------------------------------
  415. call ReadAttribute( sdim%id, name, l, status )
  416. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  417. ! ok
  418. status = 0
  419. end subroutine dim_ReadAttribute_l_1d
  420. ! =============================================================
  421. ! === check attributes
  422. ! =============================================================
  423. subroutine dim_CheckAttribute_l_0d( sdim, name, l, status )
  424. use file_hdf_base, only : TSdsDim
  425. ! --- in/out -------------------------
  426. type(TSdsDim), intent(in) :: sdim
  427. character(len=*), intent(in) :: name
  428. logical, intent(in) :: l
  429. integer, intent(inout) :: status
  430. ! --- const -------------------------------
  431. character(len=*), parameter :: rname = mname//'/dim_CheckAttribute_l_0d'
  432. ! --- local ------------------------------
  433. logical :: verbose
  434. ! --- begin ---------------------------
  435. ! write error messages ?
  436. verbose = status == 0
  437. call CheckAttribute( sdim%id, name, l, status )
  438. if (status>0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  439. if (status<0) then
  440. if (verbose) write (*,'("ERROR in ",a)') rname
  441. status=-1; return
  442. end if
  443. ! ok
  444. status = 0
  445. end subroutine dim_CheckAttribute_l_0d
  446. ! ***
  447. subroutine dim_CheckAttribute_l_1d( sdim, name, l, status )
  448. use file_hdf_base, only : TSdsDim
  449. ! --- in/out -------------------------
  450. type(TSdsDim), intent(in) :: sdim
  451. character(len=*), intent(in) :: name
  452. logical, intent(in) :: l(:)
  453. integer, intent(inout) :: status
  454. ! --- const -------------------------------
  455. character(len=*), parameter :: rname = mname//'/dim_CheckAttribute_l_1d'
  456. ! --- local ------------------------------
  457. logical :: verbose
  458. ! --- begin ---------------------------
  459. ! write error messages ?
  460. verbose = status == 0
  461. call CheckAttribute( sdim%id, name, l, status )
  462. if (status>0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  463. if (status<0) then
  464. if (verbose) write (*,'("ERROR in ",a)') rname
  465. status=-1; return
  466. end if
  467. ! ok
  468. status = 0
  469. end subroutine dim_CheckAttribute_l_1d
  470. ! ================================================================
  471. ! write attributes
  472. ! ================================================================
  473. subroutine dim_WriteAttribute_l_0d( sdim, name, l, status )
  474. use file_hdf_base, only : TSdsDim
  475. ! --- in/out -------------------------
  476. type(TSdsDim), intent(in) :: sdim
  477. character(len=*), intent(in) :: name
  478. logical, intent(in) :: l
  479. integer, intent(out) :: status
  480. ! --- const -------------------------------
  481. character(len=*), parameter :: rname = mname//'/dim_WriteAttribute_l_0d'
  482. ! --- begin -------------------------------
  483. call WriteAttribute( sdim%id, name, l, status )
  484. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  485. ! ok
  486. status = 0
  487. end subroutine dim_WriteAttribute_l_0d
  488. ! ***
  489. subroutine dim_WriteAttribute_l_1d( sdim, name, l, status )
  490. use file_hdf_base, only : TSdsDim
  491. ! --- in/out -------------------------
  492. type(TSdsDim), intent(in) :: sdim
  493. character(len=*), intent(in) :: name
  494. logical, intent(in) :: l(:)
  495. integer, intent(out) :: status
  496. ! --- const -------------------------------
  497. character(len=*), parameter :: rname = mname//'/dim_WriteAttribute_l_1d'
  498. ! --- begin -------------------------------
  499. call WriteAttribute( sdim%id, name, l, status )
  500. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  501. ! ok
  502. status = 0
  503. end subroutine dim_WriteAttribute_l_1d
  504. ! ############################################################
  505. ! ###
  506. ! ### hdf files
  507. ! ###
  508. ! ############################################################
  509. ! ================================================================
  510. ! get attributes
  511. ! ================================================================
  512. subroutine hdf_ReadAttribute_l_0d( hdf, name, l, status )
  513. use file_hdf_base, only : THdfFile
  514. ! --- in/out -------------------------
  515. type(THdfFile), intent(in) :: hdf
  516. character(len=*), intent(in) :: name
  517. logical, intent(out) :: l
  518. integer, intent(out) :: status
  519. ! --- const -------------------------------
  520. character(len=*), parameter :: rname = mname//'/hdf_ReadAttribute_l_0d'
  521. ! --- begin -------------------------------
  522. call ReadAttribute( hdf%id, name, l, status )
  523. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  524. end subroutine hdf_ReadAttribute_l_0d
  525. ! ***
  526. subroutine hdf_ReadAttribute_l_1d( hdf, name, l, status )
  527. use file_hdf_base, only : THdfFile
  528. ! --- in/out -------------------------
  529. type(THdfFile), intent(in) :: hdf
  530. character(len=*), intent(in) :: name
  531. logical, intent(out) :: l(:)
  532. integer, intent(out) :: status
  533. ! --- const -------------------------------
  534. character(len=*), parameter :: rname = mname//'/hdf_ReadAttribute_l_1d'
  535. ! --- begin -------------------------------
  536. call ReadAttribute( hdf%id, name, l, status )
  537. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  538. ! ok
  539. status = 0
  540. end subroutine hdf_ReadAttribute_l_1d
  541. ! =============================================================
  542. ! === check attributes
  543. ! =============================================================
  544. subroutine hdf_CheckAttribute_l_0d( hdf, name, l, status )
  545. use file_hdf_base, only : THdfFile
  546. ! --- in/out -------------------------
  547. type(THdfFile), intent(in) :: hdf
  548. character(len=*), intent(in) :: name
  549. logical, intent(in) :: l
  550. integer, intent(inout) :: status
  551. ! --- const -------------------------------
  552. character(len=*), parameter :: rname = mname//'/hdf_CheckAttribute_l_0d'
  553. ! --- local ------------------------------
  554. logical :: verbose
  555. ! --- begin ---------------------------
  556. ! write error messages ?
  557. verbose = status == 0
  558. call CheckAttribute( hdf%id, name, l, status )
  559. if (status>0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  560. if (status<0) then
  561. if (verbose) write (*,'("ERROR in ",a)') rname
  562. status=-1; return
  563. end if
  564. ! ok
  565. status = 0
  566. end subroutine hdf_CheckAttribute_l_0d
  567. ! ***
  568. subroutine hdf_CheckAttribute_l_1d( hdf, name, l, status )
  569. use file_hdf_base, only : THdfFile
  570. ! --- in/out -------------------------
  571. type(THdfFile), intent(in) :: hdf
  572. character(len=*), intent(in) :: name
  573. logical, intent(in) :: l(:)
  574. integer, intent(inout) :: status
  575. ! --- const -------------------------------
  576. character(len=*), parameter :: rname = mname//'/hdf_CheckAttribute_l_1d'
  577. ! --- local ------------------------------
  578. logical :: verbose
  579. ! --- begin ---------------------------
  580. ! write error messages ?
  581. verbose = status == 0
  582. call CheckAttribute( hdf%id, name, l, status )
  583. if (status>0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  584. if (status<0) then
  585. if (verbose) write (*,'("ERROR in ",a)') rname
  586. status=-1; return
  587. end if
  588. ! ok
  589. status = 0
  590. end subroutine hdf_CheckAttribute_l_1d
  591. ! ================================================================
  592. ! write attributes
  593. ! ================================================================
  594. subroutine hdf_WriteAttribute_l_0d( hdf, name, l, status )
  595. use file_hdf_base, only : THdfFile
  596. ! --- in/out -------------------------
  597. type(THdfFile), intent(in) :: hdf
  598. character(len=*), intent(in) :: name
  599. logical, intent(in) :: l
  600. integer, intent(inout) :: status
  601. ! --- const -------------------------------
  602. character(len=*), parameter :: rname = mname//'/hdf_WriteAttribute_l_0d'
  603. ! --- begin -------------------------------
  604. call WriteAttribute( hdf%id, name, l, status )
  605. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  606. ! ok
  607. status = 0
  608. end subroutine hdf_WriteAttribute_l_0d
  609. ! ***
  610. subroutine hdf_WriteAttribute_l_1d( hdf, name, l, status )
  611. use file_hdf_base, only : THdfFile
  612. ! --- in/out -------------------------
  613. type(THdfFile), intent(in) :: hdf
  614. character(len=*), intent(in) :: name
  615. logical, intent(in) :: l(:)
  616. integer, intent(out) :: status
  617. ! --- const -------------------------------
  618. character(len=*), parameter :: rname = mname//'/hdf_WriteAttribute_l_1d'
  619. ! --- begin -------------------------------
  620. call WriteAttribute( hdf%id, name, l, status )
  621. if (status/=0) then; write (*,'("ERROR in ",a)') rname; status=1; return; end if
  622. ! ok
  623. status = 0
  624. end subroutine hdf_WriteAttribute_l_1d
  625. end module file_hdf_l