summaryrefslogtreecommitdiffstats
path: root/hl/fortran/src/H5LTfc.c
blob: afe641903d43f3a57379a2578f8b4b23881a1da5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* This files contains C stubs for H5D Fortran APIs */

#include "H5LTprivate.h"
#include "H5LTf90proto.h"
#include "H5Eprivate.h"

/*-------------------------------------------------------------------------
 * Function: H5LTmake_dataset_c
 *
 * Purpose: Call H5LTmake_dataset
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: September 09, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltmake_dataset_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *rank, hsize_t_f *dims,
                   hid_t_f *type_id, void *buf)
{
    int      ret_value = -1;
    herr_t   ret;
    char *   c_name = NULL;
    hsize_t *c_dims = NULL;
    int      i;

    /*
     * convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(name, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    c_dims = (hsize_t *)HDmalloc(sizeof(hsize_t) * ((size_t)*rank));
    if (c_dims == NULL)
        goto done;
    /*
     * transpose dimension arrays because of C-FORTRAN storage order
     */
    for (i = 0; i < *rank; i++) {
        c_dims[i] = dims[*rank - i - 1];
    }

    /*
     * call H5LTmake_dataset function.
     */

    ret = H5LTmake_dataset((hid_t)*loc_id, c_name, (int)*rank, c_dims, (hid_t)*type_id, buf);
    if (ret < 0)
        goto done;

    ret_value = 0;

done:
    if (c_name != NULL)
        HDfree(c_name);
    if (c_dims != NULL)
        HDfree(c_dims);
    return ret_value;
}

/*-------------------------------------------------------------------------
 * Function: H5LTread_dataset_c
 *
 * Purpose: Call H5LTmake_dataset
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: September 09, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltread_dataset_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hid_t_f *type_id, void *buf)
{
    int    ret_value = -1;
    herr_t ret;
    hid_t  c_loc_id;
    hid_t  c_type_id;
    char * c_name = NULL;

    /*
     * convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(name, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    /*
     * call H5LTread_dataset function.
     */
    c_loc_id  = (hid_t)*loc_id;
    c_type_id = (hid_t)*type_id;

    ret = H5LTread_dataset(c_loc_id, c_name, c_type_id, buf);

    if (ret < 0)
        goto done;

    ret_value = 0;

done:
    if (c_name != NULL)
        HDfree(c_name);

    return ret_value;
}

/*-------------------------------------------------------------------------
 * Function: H5LTmake_dataset_string_c
 *
 * Purpose: Call H5LTmake_dataset
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: September 09, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltmake_dataset_string_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *buflen, char *buf)
{
    int    ret_value = -1;
    herr_t ret;
    hid_t  c_loc_id;
    char * c_name = NULL;
    char * c_buf  = NULL;

    /*
     * convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(name, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    c_buf = (char *)HD5f2cstring(buf, (size_t)*buflen);
    if (c_buf == NULL)
        goto done;

    /*
     * call H5LTmake_dataset_string function.
     */
    c_loc_id = (hid_t)*loc_id;

    ret = H5LTmake_dataset_string(c_loc_id, c_name, c_buf);

    if (ret < 0)
        goto done;

    ret_value = 0;

done:
    if (c_name != NULL)
        HDfree(c_name);
    if (c_buf != NULL)
        HDfree(c_buf);

    return ret_value;
}

/*-------------------------------------------------------------------------
 * Function: H5LTread_dataset_string_c
 *
 * Purpose: Call H5LTread_dataset_string
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: September 09, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltread_dataset_string_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, char *buf)
{
    int    ret_value = -1;
    herr_t ret;
    hid_t  c_loc_id;
    char * c_name = NULL;

    /*
     * convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(name, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    /*
     * call H5LTread_dataset_string function.
     */
    c_loc_id = (hid_t)*loc_id;

    ret = H5LTread_dataset_string(c_loc_id, c_name, buf);

    if (ret < 0)
        goto done;

    ret_value = 0;

done:
    if (c_name != NULL)
        HDfree(c_name);

    return ret_value;
}

/*-------------------------------------------------------------------------
 * Function: H5LTset_attribute_int_c
 *
 * Purpose: Call H5LTset_attribute_int
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: October 05, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltset_attribute_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen, _fcd attrname,
                    size_t_f *size, void *buf, char *dtype, size_t_f *sizeof_val)
{
    int    ret_value = -1;
    herr_t ret       = SUCCEED;
    hid_t  c_loc_id;
    char * c_name     = NULL;
    char * c_attrname = NULL;
    char * c_buf      = NULL;
    size_t c_size;

    /*
     * convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(dsetname, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    c_attrname = (char *)HD5f2cstring(attrname, (size_t)*attrnamelen);
    if (c_attrname == NULL)
        goto done;

    /*
     * call H5LTset_attribute_int function.
     */
    c_loc_id = (hid_t)*loc_id;
    c_size   = (size_t)*size;

    if (HDstrncmp(dtype, "I", 1) == 0) {
        if ((size_t)*sizeof_val == sizeof(int))
            ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_INT,
                                               (const int *)buf);
        else if ((size_t)*sizeof_val == sizeof(long))
            ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_LONG,
                                               (const long *)buf);
#if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG
        else if ((size_t)*sizeof_val == sizeof(long long))
            ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_LLONG,
                                               (const long long *)buf);
#endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */
        else
            goto done;
    }
    else if (HDstrncmp(dtype, "R", 1) == 0) {
        if ((size_t)*sizeof_val == sizeof(float))
            ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_FLOAT,
                                               (const float *)buf);
        else if ((size_t)*sizeof_val == sizeof(double))
            ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_DOUBLE,
                                               (const double *)buf);
#if H5_SIZEOF_LONG_DOUBLE != 0
        else if ((size_t)*sizeof_val == sizeof(long double))
            ret = H5LT_set_attribute_numerical(c_loc_id, c_name, c_attrname, c_size, H5T_NATIVE_LDOUBLE,
                                               (const long double *)buf);
#endif
        else
            goto done;
    }
    else if (HDstrncmp(dtype, "C", 1) == 0) {

        c_buf = (char *)HD5f2cstring((_fcd)buf, c_size);
        if (c_buf == NULL)
            goto done;

        ret = H5LTset_attribute_string(c_loc_id, c_name, c_attrname, c_buf);
    }
    if (ret < 0)
        goto done;

    ret_value = 0;

done:
    if (c_name != NULL)
        HDfree(c_name);
    if (c_attrname != NULL)
        HDfree(c_attrname);
    if (c_buf != NULL)
        HDfree(c_buf);

    return ret_value;
}

/*-------------------------------------------------------------------------
 * Function: H5LTget_attribute_c
 *
 * Purpose: Call H5LTget_attribute_int
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: October 05, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltget_attribute_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen, _fcd attrname,
                    void *buf, char *dtype, size_t_f *sizeof_val)
{
    int    ret_value = -1;
    herr_t ret       = SUCCEED;
    hid_t  c_loc_id;
    char * c_name     = NULL;
    char * c_attrname = NULL;

    /*
     * convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(dsetname, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    c_attrname = (char *)HD5f2cstring(attrname, (size_t)*attrnamelen);
    if (c_attrname == NULL)
        goto done;

    /*
     * call H5LTget_attribute_int function.
     */
    c_loc_id = (hid_t)*loc_id;

    if (HDstrncmp(dtype, "I", 1) == 0) {
        if ((size_t)*sizeof_val == sizeof(int))
            ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_INT, buf);
        else if ((size_t)*sizeof_val == sizeof(long))
            ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_LONG, buf);
#if H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG
        else if ((size_t)*sizeof_val == sizeof(long long))
            ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_LLONG, buf);
#endif /* H5_SIZEOF_LONG != H5_SIZEOF_LONG_LONG */
        else
            goto done;
    }
    else if (HDstrncmp(dtype, "R", 1) == 0) {
        if ((size_t)*sizeof_val == sizeof(float))
            ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_FLOAT, buf);
        else if ((size_t)*sizeof_val == sizeof(double))
            ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_DOUBLE, buf);
#if H5_SIZEOF_LONG_DOUBLE != 0
        else if ((size_t)*sizeof_val == sizeof(long double))
            ret = H5LTget_attribute(c_loc_id, c_name, c_attrname, H5T_NATIVE_LDOUBLE, buf);
#endif
        else
            goto done;
    }

    if (ret < 0)
        goto done;

    ret_value = 0;

done:
    if (c_name != NULL)
        HDfree(c_name);
    if (c_attrname != NULL)
        HDfree(c_attrname);

    return ret_value;
}

/*-------------------------------------------------------------------------
 * Function: H5LTget_attribute_string_c
 *
 * Purpose: Call H5LTget_attribute_string
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: October 05, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltget_attribute_string_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen,
                           _fcd attrname, _fcd buf, size_t_f *buf_size)
{
    int    ret_value = -1;
    herr_t ret;
    char * c_name     = NULL;
    char * c_attrname = NULL;
    char * c_buf      = NULL;

    /*
     * Convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(dsetname, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    c_attrname = (char *)HD5f2cstring(attrname, (size_t)*attrnamelen);
    if (c_attrname == NULL)
        goto done;
    /*
     * Allocate buffer to hold C attribute string
     */
    if ((c_buf = (char *)HDmalloc((size_t)*buf_size + 1)) == NULL)
        goto done;

    /*
     * Call H5LTget_attribute_int function.
     */
    ret = H5LTget_attribute_string((hid_t)*loc_id, c_name, c_attrname, c_buf);
    if (ret < 0)
        goto done;

    /*
     * Convert C name to FORTRAN and place it in the given buffer
     */
    HD5packFstring(c_buf, _fcdtocp(buf), (size_t)*buf_size);

    ret_value = 0;

done:
    if (c_name != NULL)
        HDfree(c_name);
    if (c_attrname != NULL)
        HDfree(c_attrname);
    if (c_buf != NULL)
        HDfree(c_buf);

    return ret_value;
}

/*-------------------------------------------------------------------------
 * Function: H5LTget_dataset_ndims_c
 *
 * Purpose: Call H5LTget_dataset_ndims
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: September 09, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltget_dataset_ndims_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, int_f *rank)
{
    int    ret_value = -1;
    herr_t ret;
    hid_t  c_loc_id;
    char * c_name = NULL;
    int    c_rank;

    /*
     * Convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(name, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    /*
     * Call H5LTget_dataset_ndims function.
     */
    c_loc_id = (hid_t)*loc_id;

    ret = H5LTget_dataset_ndims(c_loc_id, c_name, &c_rank);

    if (ret < 0)
        goto done;

    *rank     = (int_f)c_rank;
    ret_value = 0;

done:
    if (c_name != NULL)
        HDfree(c_name);

    return ret_value;
}

/*-------------------------------------------------------------------------
 * Function: h5ltfind_dataset_c
 *
 * Purpose: Call H5LTfind_dataset
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: September 09, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltfind_dataset_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name)
{
    hid_t  c_loc_id;
    char * c_name = NULL;
    herr_t ret;

    /*
     * Convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(name, (size_t)*namelen);
    if (c_name == NULL)
        return -1;

    /*
     * Call H5LTget_dataset_ndims function.
     */
    c_loc_id = (hid_t)*loc_id;

    ret = H5LTfind_dataset(c_loc_id, c_name);

    if (c_name != NULL)
        HDfree(c_name);

    return ret;
}

/*-------------------------------------------------------------------------
 * Function: h5ltget_dataset_info_c
 *
 * Purpose: Call H5LTget_dataset_info
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: September 09, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltget_dataset_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, hsize_t_f *dims, int_f *type_class,
                       size_t_f *type_size)
{
    int         ret_value = -1;
    herr_t      ret;
    hid_t       c_loc_id;
    char *      c_name = NULL;
    H5T_class_t c_classtype;
    size_t      c_type_size;
    hsize_t     c_dims[32];
    int         i;
    int         c_rank;

    /*
     * convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(name, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    /*
     * call H5LTget_dataset_ndims function.
     */
    c_loc_id = (hid_t)*loc_id;

    ret = H5LTget_dataset_info(c_loc_id, c_name, c_dims, &c_classtype, &c_type_size);
    if (ret < 0)
        goto done;

    *type_class = c_classtype;
    *type_size  = (size_t_f)c_type_size;

    /*
     * transpose dimension arrays because of C-FORTRAN storage order
     */

    ret = H5LTget_dataset_ndims(c_loc_id, c_name, &c_rank);
    if (ret < 0)
        goto done;

    for (i = 0; i < c_rank; i++) {
        dims[i] = (hsize_t_f)c_dims[c_rank - i - 1];
    }

    ret_value = 0;

done:
    if (c_name != NULL)
        HDfree(c_name);

    return ret_value;
}

/*-------------------------------------------------------------------------
 * Function: h5ltget_attribute_ndims_c
 *
 * Purpose: Call H5LTget_attribute_ndims
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: October 05, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltget_attribute_ndims_c(hid_t_f *loc_id, size_t_f *namelen, _fcd dsetname, size_t_f *attrnamelen,
                          _fcd attrname, int_f *rank)
{
    int    ret_value = -1;
    herr_t ret;
    hid_t  c_loc_id;
    char * c_name     = NULL;
    char * c_attrname = NULL;
    int    c_rank;

    /*
     * Convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(dsetname, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    c_attrname = (char *)HD5f2cstring(attrname, (size_t)*attrnamelen);
    if (c_attrname == NULL)
        goto done;

    /*
     * Call H5LTset_attribute_ndims function.
     */
    c_loc_id = (hid_t)*loc_id;

    ret = H5LTget_attribute_ndims(c_loc_id, c_name, c_attrname, &c_rank);

    if (ret < 0)
        goto done;

    *rank     = (int_f)c_rank;
    ret_value = 0;

done:
    if (c_name != NULL)
        HDfree(c_name);
    if (c_attrname != NULL)
        HDfree(c_attrname);

    return ret_value;
}

/*-------------------------------------------------------------------------
 * Function: h5ltget_attribute_info_c
 *
 * Purpose: Call H5LTget_attribute_info
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: pvn@ncsa.uiuc.edu
 *
 * Date: September 09, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltget_attribute_info_c(hid_t_f *loc_id, size_t_f *namelen, _fcd name, size_t_f *attrnamelen, _fcd attrname,
                         hsize_t_f *dims, int_f *type_class, size_t_f *type_size)
{
    int         ret_value = -1;
    herr_t      ret;
    hid_t       c_loc_id;
    char *      c_name     = NULL;
    char *      c_attrname = NULL;
    H5T_class_t c_classtype;
    size_t      c_type_size;
    hsize_t     c_dims[32];
    int         i;
    int         c_rank;

    /*
     * convert FORTRAN name to C name
     */
    c_name = (char *)HD5f2cstring(name, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    c_attrname = (char *)HD5f2cstring(attrname, (size_t)*attrnamelen);
    if (c_attrname == NULL)
        goto done;

    /*
     * call H5LTget_attribute_info function.
     */
    c_loc_id = (hid_t)*loc_id;

    ret = H5LTget_attribute_info(c_loc_id, c_name, c_attrname, c_dims, &c_classtype, &c_type_size);
    if (ret < 0)
        goto done;

    *type_class = c_classtype;
    *type_size  = (size_t_f)c_type_size;

    /*
     * transpose dimension arrays because of C-FORTRAN storage order
     */

    ret = H5LTget_attribute_ndims(c_loc_id, c_name, c_attrname, &c_rank);
    if (ret < 0)
        goto done;

    for (i = 0; i < c_rank; i++) {
        dims[i] = (hsize_t_f)c_dims[c_rank - i - 1];
    }

    ret_value = 0;

done:
    if (c_name != NULL)
        HDfree(c_name);
    if (c_attrname != NULL)
        HDfree(c_attrname);

    return ret_value;
}

/*-------------------------------------------------------------------------
 * Function: h5ltpath_valid_c
 *
 * Purpose: Calls h5ltpath_valid
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: M. Scot Breitenfeld
 *
 * Date: February 18, 2012
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */

int_f
h5ltpath_valid_c(hid_t_f *loc_id, _fcd path, size_t_f *pathlen, int_f *check_object_valid_c)
{
    htri_t  ret    = -1;
    char *  c_path = NULL;
    hbool_t check_object_valid;

    /*
     * convert FORTRAN name to C name
     */
    if (NULL == (c_path = (char *)HD5f2cstring(path, (size_t)*pathlen)))
        goto done;

    check_object_valid = FALSE;
    if (*check_object_valid_c == 1)
        check_object_valid = TRUE;

    /*
     * call H5LTpath_valid function.
     */
    ret = H5LTpath_valid((hid_t)*loc_id, c_path, check_object_valid);

done:
    if (c_path != NULL)
        HDfree(c_path);

    return (int_f)ret;
}