summaryrefslogtreecommitdiffstats
path: root/fortran/src/H5_buildiface.F90
blob: 9a42cbf69634519b95f596947758a2e136385385 (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
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
!****p* Program/H5_buildiface
!
! NAME
!  Executable: H5_buildiface
!
! FILE
!  fortran/src/H5_buildiface.f90
!
! PURPOSE
!  This stand alone program is used at build time to generate the module
!  H5_gen (H5_gen.F90). It cycles through all the available KIND parameters for
!  integers and reals. The appropriate program and subroutines are then generated
!  depending on which of the KIND values are found.
!
! NOTES
!  This program uses the Fortran 2008 intrinsic function STORAGE_SIZE or SIZEOF 
!  depending on availablity.It generates code that makes use of 
!  STORAGE_SIZE/SIZEOF in H5_gen.F90. STORAGE_SIZE is standard
!  compliant and should always be chosen over SIZEOF.
!
!  The availability of STORAGE_SIZE/SIZEOF is checked at configure time and the TRUE/FALSE
!  condition is set in the configure variable "FORTRAN_HAVE_STORAGE_SIZE" or
!  "FORTRAN_HAVE_SIZEOF".
!
!  The use of C_SIZOF(X) is not used since the argument X must be an interoperable
!  data entity.
!
! COPYRIGHT
!  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
!  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 files COPYING and Copyright.html.  COPYING can be found at the root     *
!  of the source code distribution tree; Copyright.html can be found at the    *
!  root level of an installed copy of the electronic HDF5 document set and     *
!  is linked from the top-level documents page.  It can also be found at       *
!  http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have            *
!  access to either file, you may request a copy from help@hdfgroup.org.       *
!  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
!
! AUTHOR
!  M. Scot Breitenfeld
!
!*****

#include <H5config_f.inc>

PROGRAM H5_buildiface
  USE, INTRINSIC :: ISO_C_BINDING
  IMPLICIT NONE

! These values are valid REAL KINDs (with corresponding C float) found during configure
  H5_H5CONFIG_F_NUM_RKIND
  H5_H5CONFIG_F_RKIND
! These values are valid INTEGER KINDs (with corresponding C integer) found during configure
  H5_H5CONFIG_F_NUM_IKIND
  H5_H5CONFIG_F_IKIND

  INTEGER :: i, j, k
  INTEGER :: ji, jr, jd
#ifdef H5_FORTRAN_HAVE_C_LONG_DOUBLE
  REAL(KIND=C_LONG_DOUBLE) :: c_longdble
#endif
  REAL(KIND=C_DOUBLE) :: c_dble
  REAL(KIND=C_FLOAT) :: c_flt
  INTEGER :: sizeof_var
  CHARACTER(LEN=2) :: chr2
! subroutine rank of array being passed in
  CHARACTER(LEN=2), DIMENSION(1:8), PARAMETER :: chr_rank=(/"_0","_1","_2","_3","_4","_5","_6","_7"/)
! rank definitions
  CHARACTER(LEN=70), DIMENSION(1:8), PARAMETER :: rank_dim_line=(/ &
       '                                                                    ', &
       ', DIMENSION(dims(1))                                                ', &
       ', DIMENSION(dims(1),dims(2))                                        ', &
       ', DIMENSION(dims(1),dims(2),dims(3))                                ', &
       ', DIMENSION(dims(1),dims(2),dims(3),dims(4))                        ', &
       ', DIMENSION(dims(1),dims(2),dims(3),dims(4),dims(5))                ', &
       ', DIMENSION(dims(1),dims(2),dims(3),dims(4),dims(5),dims(6))        ', &
       ', DIMENSION(dims(1),dims(2),dims(3),dims(4),dims(5),dims(6),dims(7))' &
            /)
! pointer to the buffer
  CHARACTER(LEN=37), DIMENSION(1:8), PARAMETER :: f_ptr_line=(/ &
       '    f_ptr = C_LOC(buf)               ', &
       '    f_ptr = C_LOC(buf(1))            ', &
       '    f_ptr = C_LOC(buf(1,1))          ', &
       '    f_ptr = C_LOC(buf(1,1,1))        ', &
       '    f_ptr = C_LOC(buf(1,1,1,1))      ', &
       '    f_ptr = C_LOC(buf(1,1,1,1,1))    ', &
       '    f_ptr = C_LOC(buf(1,1,1,1,1,1))  ', &
       '    f_ptr = C_LOC(buf(1,1,1,1,1,1,1))'  &
            /)
  CHARACTER(LEN=42), DIMENSION(1:8), PARAMETER :: fchr_ptr_line=(/ &
       '    f_ptr = C_LOC(buf(1:1))               ', &
       '    f_ptr = C_LOC(buf(1)(1:1))            ', &
       '    f_ptr = C_LOC(buf(1,1)(1:1))          ', &
       '    f_ptr = C_LOC(buf(1,1,1)(1:1))        ', &
       '    f_ptr = C_LOC(buf(1,1,1,1)(1:1))      ', &
       '    f_ptr = C_LOC(buf(1,1,1,1,1)(1:1))    ', &
       '    f_ptr = C_LOC(buf(1,1,1,1,1,1)(1:1))  ', &
       '    f_ptr = C_LOC(buf(1,1,1,1,1,1,1)(1:1))'  &
            /)

! (a) Generate Fortran H5* interfaces having multiple KIND interfaces.
!
! DEVELOPER'S NOTES:
!
! Only interfaces with arrays of rank 7 and less are provided. Even-though, the F2008 
! standard extended the maximum rank to 15, it was decided that user's should use the
! new APIs to handle those use cases. Handling rank 7 and less is for backward compatibility
! with the Fortran 90/95 APIs codes which could never handle ranks greater than 7.

  OPEN(11,FILE='H5_gen.F90')
  WRITE(11,'(40(A,/))') &
'!****h* ROBODoc/H5_gen.F90',&
'!',&
'! NAME',&
'!  H5_gen',&
'! ',&
'! PURPOSE',&
'!  This module is generated at build by H5_buildiface.F90 to handle all the',&
'!  detected KINDs for APIs being passed INTEGERs, REALs and CHARACTERs. Currently ',&
'!  these are H5A, H5D and H5P APIs',&
'!',&
'! COPYRIGHT',&
'! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *',&
'!   Copyright by The HDF Group.                                               *',&
'!   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 files COPYING and Copyright.html.  COPYING can be found at the root   *',&
'!   of the source code distribution tree; Copyright.html can be found at the  *',&
'!   root level of an installed copy of the electronic HDF5 document set and   *',&
'!   is linked from the top-level documents page.  It can also be found at     *',&
'!   http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *',&
'!   access to either file, you may request a copy from help@hdfgroup.org.     *',&
'! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *',&
'!',&
'! AUTHOR',&
'!  H5_buildiface.F90',&
'!',&
'!*****'

  WRITE(11,'(A)') "MODULE H5_GEN"

  WRITE(11,'(A)') '  USE, INTRINSIC :: ISO_C_BINDING'
  WRITE(11,'(A)') '  USE H5GLOBAL'

  WRITE(11,'(A)') '  USE H5A'
  WRITE(11,'(A)') '  USE H5D'
  WRITE(11,'(A)') '  USE H5P'
  WRITE(11,'(A)') '  IMPLICIT NONE'
!***************
! H5A INTERFACES
!***************
!
! H5Awrite_f
!
  WRITE(11,'(A)') "  INTERFACE h5awrite_f"
  DO i = 1, num_rkinds
     j = rkind(i)
     WRITE(chr2,'(I2)') j
     DO k = 1, 8
        WRITE(11,'(A)') "     MODULE PROCEDURE h5awrite_rkind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k)
     ENDDO
  END DO
  DO i = 1, num_ikinds
     j = ikind(i)
     WRITE(chr2,'(I2)') j
     DO k = 1, 8
        WRITE(11,'(A)') "     MODULE PROCEDURE h5awrite_ikind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k)
     ENDDO
  END DO
  DO k = 2, 8
     WRITE(11,'(A)') "     MODULE PROCEDURE h5awrite_ckind_rank"//chr_rank(k)
  ENDDO
  WRITE(11,'(A)') "  END INTERFACE"

! H5Aread_f
  WRITE(11,'(A)') "  INTERFACE h5aread_f"
  DO i = 1, num_rkinds
     j = rkind(i)
     WRITE(chr2,'(I2)') j
     DO k = 1, 8
        WRITE(11,'(A)') "     MODULE PROCEDURE h5aread_rkind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k)
     ENDDO
  END DO
  DO i = 1, num_ikinds
     j = ikind(i)
     WRITE(chr2,'(I2)') j
     DO k = 1, 8
        WRITE(11,'(A)') "     MODULE PROCEDURE h5aread_ikind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k)
     ENDDO
  END DO
  DO k = 2, 8
     WRITE(11,'(A)') "     MODULE PROCEDURE h5aread_ckind_rank"//chr_rank(k)
  ENDDO
  WRITE(11,'(A)') "  END INTERFACE"
!***************
! H5D INTERFACES
!***************
!
! H5Dwrite_f
  WRITE(11,'(A)') "  INTERFACE h5dwrite_f"
  DO i = 1, num_rkinds
     j = rkind(i)
     WRITE(chr2,'(I2)') j
     DO k = 1, 8
        WRITE(11,'(A)') "     MODULE PROCEDURE h5dwrite_rkind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k)
     ENDDO
  END DO
  DO i = 1, num_ikinds
     j = ikind(i)
     WRITE(chr2,'(I2)') j
     DO k = 1, 8
        WRITE(11,'(A)') "     MODULE PROCEDURE h5dwrite_ikind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k)
     ENDDO
  END DO 
  DO k = 2, 8
     WRITE(11,'(A)') "     MODULE PROCEDURE h5dwrite_ckind_rank"//chr_rank(k)
  END DO
  WRITE(11,'(A)') "  END INTERFACE"

! H5Dread_f
  WRITE(11,'(A)') "  INTERFACE h5dread_f"
  DO i = 1, num_rkinds
     j = rkind(i)
     WRITE(chr2,'(I2)') j
     DO k = 1, 8
        WRITE(11,'(A)') "     MODULE PROCEDURE h5dread_rkind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k)
     ENDDO
  END DO
  DO i = 1, num_ikinds
     j = ikind(i)
     WRITE(chr2,'(I2)') j
     DO k = 1, 8
        WRITE(11,'(A)') "     MODULE PROCEDURE h5dread_ikind_"//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(k)
     ENDDO 
  END DO
  DO k = 2, 8
     WRITE(11,'(A)') "     MODULE PROCEDURE h5dread_ckind_rank"//chr_rank(k)
  ENDDO
  WRITE(11,'(A)') "  END INTERFACE"

!***************
! H5P INTERFACES
!***************
!
! H5Pset_fill_value_f
  WRITE(11,'(A)') "  INTERFACE h5pset_fill_value_f"
  DO i = 1, num_rkinds
     j = rkind(i)
     WRITE(chr2,'(I2)') j
     WRITE(11,'(A)') "     MODULE PROCEDURE h5pset_fill_value_kind_"//TRIM(ADJUSTL(chr2))
  END DO
  WRITE(11,'(A)') "  END INTERFACE"

! H5Pget_fill_value_f
  WRITE(11,'(A)') "  INTERFACE h5pget_fill_value_f"
  DO i = 1, num_rkinds
     j = rkind(i)
     WRITE(chr2,'(I2)') j
     WRITE(11,'(A)') "     MODULE PROCEDURE h5pget_fill_value_kind_"//TRIM(ADJUSTL(chr2))
  END DO
  WRITE(11,'(A)') "  END INTERFACE"

! H5Pset_f
  WRITE(11,'(A)') "  INTERFACE h5pset_f"
  DO i = 1, num_rkinds
     j = rkind(i)
     WRITE(chr2,'(I2)') j
     WRITE(11,'(A)') "     MODULE PROCEDURE h5pset_kind_"//TRIM(ADJUSTL(chr2))
  END DO
  WRITE(11,'(A)') "  END INTERFACE"

! H5Pget_f
  WRITE(11,'(A)') "  INTERFACE h5pget_f"
  DO i = 1, num_rkinds
     j = rkind(i)
     WRITE(chr2,'(I2)') j
     WRITE(11,'(A)') "     MODULE PROCEDURE h5pget_kind_"//TRIM(ADJUSTL(chr2))
  END DO
  WRITE(11,'(A)') "  END INTERFACE"

! H5Pregister_f
  WRITE(11,'(A)') "  INTERFACE h5pregister_f"
  DO i = 1, num_rkinds
     j = rkind(i)
     WRITE(chr2,'(I2)') j
     WRITE(11,'(A)') "     MODULE PROCEDURE h5pregister_kind_"//TRIM(ADJUSTL(chr2))
  END DO
  WRITE(11,'(A)') "  END INTERFACE"

! H5Pinsert_f
  WRITE(11,'(A)') "  INTERFACE h5pinsert_f"
  DO i = 1, num_rkinds
     j = rkind(i)
     WRITE(chr2,'(I2)') j
     WRITE(11,'(A)') "     MODULE PROCEDURE h5pinsert_kind_"//TRIM(ADJUSTL(chr2))
  END DO
  WRITE(11,'(A)') "  END INTERFACE"

  WRITE(11,'(A)') 'CONTAINS'

!**********************
! H5A APIs
!**********************
!
! H5Awrite_f

!****s* H5A (F03)/H5Awrite_f_F90
!
! NAME
!  H5Awrite_f_F90
!
! PURPOSE
!  Writes an attribute.
!
! Inputs:
!  attr_id     - Attribute identifier
!  memtype_id  - Attribute datatype identifier  (in memory)
!  dims        - Array to hold corresponding dimension sizes of data buffer buf;
!                dim(k) has value of the k-th dimension of buffer buf;
!                values are ignored if buf is a scalar
!  buf 	       - Data buffer; may be a scalar or an array
!
! Outputs:
!  hdferr      - Returns 0 if successful and -1 if fails
!
! AUTHOR
!  Elena Pourmal
!  August 12, 1999
!
! HISTORY
!  Explicit Fortran interfaces are added for
!  called C functions (it is needed for Windows
!  port).  February 27, 2001
!
!  dims parameter was added to make code portable;
!  Aprile 4, 2001
!
!  Changed buf intent to INOUT to be consistant
!  with how the C functions handles it. The pg
!  compiler will return 0 if a buf value is not set.
!  February, 2008
!
! NOTES
!  This function is overloaded to write INTEGER,
!  REAL, REAL(KIND=C_DOUBLE) and CHARACTER buffers
!  up to 7 dimensions.
!
! Fortran90 Interface:
!!  SUBROUTINE H5Awrite_f(attr_id, memtype_id, buf, dims, hdferr) 
!!    INTEGER(HID_T)  , INTENT(IN)               :: attr_id
!!    INTEGER(HID_T)  , INTENT(IN)               :: memtype_id
!!    TYPE            , INTENT(IN)               :: buf
!!    INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims
!!    INTEGER         , INTENT(OUT)              :: hdferr
!*****

  DO i = 1, num_rkinds
     k = rkind(i)
     WRITE(chr2,'(I2)') k
     DO j = 1, 8

! DLL definitions for windows
        WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
        WRITE(11,'(A)') '!DEC$attributes dllexport :: h5awrite_rkind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
        WRITE(11,'(A)') '!DEC$endif'

! Subroutine API
        WRITE(11,'(A)') '  SUBROUTINE h5awrite_rkind_'//TRIM(ADJUSTL(chr2))&
             &//'_rank'//chr_rank(j)//'(attr_id, memtype_id, buf, dims, hdferr)'
        WRITE(11,'(A)') '    IMPLICIT NONE'
        WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: attr_id'
        WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: memtype_id'
        WRITE(11,'(A)') '    INTEGER(HSIZE_T)  , INTENT(IN), DIMENSION(*) :: dims'
        WRITE(11,'(A)') '    REAL(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(IN)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
        WRITE(11,'(A)') '    INTEGER           , INTENT(OUT) :: hdferr'
        WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
        
        WRITE(11,'(A)') f_ptr_line(j)
        WRITE(11,'(A)') '    hdferr = H5Awrite_f_c(attr_id, memtype_id, f_ptr)'
        WRITE(11,'(A)') '  END SUBROUTINE h5awrite_rkind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
     ENDDO
  ENDDO
  DO i = 1, num_ikinds
     k = ikind(i)
     WRITE(chr2,'(I2)') k
     DO j = 1, 8

! DLL definitions for windows
        WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
        WRITE(11,'(A)') '!DEC$attributes dllexport :: h5awrite_ikind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
        WRITE(11,'(A)') '!DEC$endif'

! Subroutine API
        WRITE(11,'(A)') '  SUBROUTINE h5awrite_ikind_'//TRIM(ADJUSTL(chr2))&
             &//'_rank'//chr_rank(j)//'(attr_id, memtype_id, buf, dims, hdferr)'
        WRITE(11,'(A)') '    IMPLICIT NONE'
        WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: attr_id'
        WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: memtype_id'
        WRITE(11,'(A)') '    INTEGER(HSIZE_T)  , INTENT(IN), DIMENSION(*) :: dims'
        WRITE(11,'(A)') '    INTEGER(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(INOUT)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
        WRITE(11,'(A)') '    INTEGER           , INTENT(OUT) :: hdferr'
        WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
        
        WRITE(11,'(A)') f_ptr_line(j)
        WRITE(11,'(A)') '    hdferr = H5Awrite_f_c(attr_id, memtype_id, f_ptr)'
        WRITE(11,'(A)') '  END SUBROUTINE h5awrite_ikind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
     ENDDO
  ENDDO
  DO j = 2, 8

! DLL definitions for windows
     WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
     WRITE(11,'(A)') '!DEC$attributes dllexport :: h5awrite_ckind_rank'//chr_rank(j)
     WRITE(11,'(A)') '!DEC$endif'

! Subroutine API
     WRITE(11,'(A)') '  SUBROUTINE h5awrite_ckind_rank'//chr_rank(j)//'(attr_id, memtype_id, buf, dims, hdferr)'
     WRITE(11,'(A)') '    IMPLICIT NONE'
     WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: attr_id'
     WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: memtype_id'
     WRITE(11,'(A)') '    INTEGER(HSIZE_T)  , INTENT(IN), DIMENSION(*) :: dims'
     WRITE(11,'(A)') '    CHARACTER(LEN=*)  , INTENT(IN)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
     WRITE(11,'(A)') '    INTEGER           , INTENT(OUT) :: hdferr'
     WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
     
     WRITE(11,'(A)') fchr_ptr_line(j)
     WRITE(11,'(A)') '    hdferr = H5Awrite_f_c(attr_id, memtype_id, f_ptr)'
     WRITE(11,'(A)') '  END SUBROUTINE h5awrite_ckind_rank'//chr_rank(j)
  ENDDO

!
! H5Aread_f

!****s* H5A (F03)/H5Aread_f_F90
!
! NAME
!  H5Aread_f_F90
!
! PURPOSE
!  Reads an attribute.
!
! Inputs:
!  attr_id     - Attribute identifier
!  memtype_id  - Attribute datatype identifier  (in memory)
!  dims        - Array to hold corresponding dimension sizes of data buffer buf;
!                dim(k) has value of the k-th dimension of buffer buf;
!                values are ignored if buf is a scalar
!
! Outputs:
!  buf 	       - Data buffer; may be a scalar or an array
!  hdferr      - Returns 0 if successful and -1 if fails
!
! AUTHOR
!  Elena Pourmal
!  August 12, 1999
!
! HISTORY
!  Explicit Fortran interfaces are added for
!  called C functions (it is needed for Windows
!  port).  February 27, 2001
!
!  dims parameter was added to make code portable;
!  Aprile 4, 2001
!
!  Changed buf intent to INOUT to be consistant
!  with how the C functions handles it. The pg
!  compiler will return 0 if a buf value is not set.
!  February, 2008
!
! NOTES
!  This function is overloaded to write INTEGER,
!  REAL, REAL(KIND=C_DOUBLE) and CHARACTER buffers
!  up to 7 dimensions.
! Fortran90 Interface:
!!  SUBROUTINE H5Aread_f(attr_id, memtype_id, buf, dims, hdferr) 
!!    INTEGER(HID_T)  , INTENT(IN)               :: attr_id
!!    INTEGER(HID_T)  , INTENT(IN)               :: memtype_id
!!    TYPE            , INTENT(INOUT)            :: buf
!!    INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims
!!    INTEGER         , INTENT(OUT)              :: hdferr
!*****
  DO i = 1, num_rkinds
     k = rkind(i)
     WRITE(chr2,'(I2)') k
     DO j = 1, 8
! DLL definitions for windows
        WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
        WRITE(11,'(A)') '!DEC$attributes dllexport :: h5aread_rkind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
        WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
        WRITE(11,'(A)') '  SUBROUTINE h5aread_rkind_'//TRIM(ADJUSTL(chr2))&
             &//'_rank'//chr_rank(j)//'(attr_id, memtype_id, buf, dims, hdferr)'
        WRITE(11,'(A)') '    IMPLICIT NONE'
        WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: attr_id'
        WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: memtype_id'
        WRITE(11,'(A)') '    INTEGER(HSIZE_T)  , INTENT(IN), DIMENSION(*) :: dims'
        WRITE(11,'(A)') '    REAL(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(INOUT)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
        WRITE(11,'(A)') '    INTEGER           , INTENT(OUT) :: hdferr'
        WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
        
        WRITE(11,'(A)') f_ptr_line(j)
        WRITE(11,'(A)') '    hdferr = H5Aread_f_c(attr_id, memtype_id, f_ptr)'
        WRITE(11,'(A)') '  END SUBROUTINE h5aread_rkind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
     ENDDO
  ENDDO
  DO i = 1, num_ikinds
     k = ikind(i)
     WRITE(chr2,'(I2)') k
     DO j = 1, 8
! DLL definitions for windows
        WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
        WRITE(11,'(A)') '!DEC$attributes dllexport :: h5aread_ikind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
        WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
        WRITE(11,'(A)') '  SUBROUTINE h5aread_ikind_'//TRIM(ADJUSTL(chr2))&
             &//'_rank'//chr_rank(j)//'(attr_id, memtype_id, buf, dims, hdferr)'
        WRITE(11,'(A)') '    IMPLICIT NONE'
        WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: attr_id'
        WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: memtype_id'
        WRITE(11,'(A)') '    INTEGER(HSIZE_T)  , INTENT(IN), DIMENSION(*) :: dims'
        WRITE(11,'(A)') '    INTEGER(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(INOUT)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
        WRITE(11,'(A)') '    INTEGER           , INTENT(OUT) :: hdferr'
        WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
        
        WRITE(11,'(A)') f_ptr_line(j)
        WRITE(11,'(A)') '    hdferr = H5Aread_f_c(attr_id, memtype_id, f_ptr)'
        WRITE(11,'(A)') '  END SUBROUTINE h5aread_ikind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
     ENDDO
  ENDDO
  DO j = 2, 8
! DLL definitions for windows
     WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
     WRITE(11,'(A)') '!DEC$attributes dllexport :: h5aread_ckind_rank'//chr_rank(j)
     WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
     WRITE(11,'(A)') '  SUBROUTINE h5aread_ckind_rank'//chr_rank(j)//'(attr_id, memtype_id, buf, dims, hdferr)'
     WRITE(11,'(A)') '    IMPLICIT NONE'
     WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: attr_id'
     WRITE(11,'(A)') '    INTEGER(HID_T)    , INTENT(IN) :: memtype_id'
     WRITE(11,'(A)') '    INTEGER(HSIZE_T)  , INTENT(IN), DIMENSION(*) :: dims'
     WRITE(11,'(A)') '    CHARACTER(LEN=*), INTENT(IN)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
     WRITE(11,'(A)') '    INTEGER           , INTENT(OUT) :: hdferr'
     WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
     
     WRITE(11,'(A)') fchr_ptr_line(j)
     WRITE(11,'(A)') '    hdferr = H5Aread_f_c(attr_id, memtype_id, f_ptr)'
     WRITE(11,'(A)') '  END SUBROUTINE h5aread_ckind_rank'//chr_rank(j)
  ENDDO

!**********************
! H5D APIs
!**********************
!
! h5dread_f

!
! NAME		
!  h5dread_f
!
! PURPOSE
!  Reads raw data from the specified dataset into buf,
!  converting from file datatype and dataspace to memory
!  datatype and dataspace.
!
! Inputs:
!		dset_id		- dataset identifier
!		mem_type_id	- memory type identifier
!		dims		- 1-dim array of size 7; dims(k) has the size
!				- of k-th dimension of the buf array
! Outputs:
!		buf		- buffer to read data in
!		hdferr:		- error code
!				 	Success:  0
!				 	Failure: -1
! Optional parameters:
!		mem_space_id	- memory dataspace identifier
!		file_space_id 	- file dataspace identifier
!		xfer_prp	- trasfer property list identifier
!
! AUTHOR
!  Elena Pourmal
!  August 12, 1999
!
! HISTORY 	
!  Explicit Fortran interfaces were added for
!  called C functions (it is needed for Windows
!  port).  February 28, 2001
!
!  dims parameter was added to make code portable;
!  n parameter was replaced with dims parameter in
!  the h5dwrite_reference_obj and h5dwrite_reference_dsetreg
!  functions.  April 2, 2001
!
! NOTES	
!  This function is overloaded to read INTEGER,
!  REAL, DOUBLE PRECISION and CHARACTER buffers
!  up to 7 dimensions, and one dimensional buffers
!  of the TYPE(hobj_ref_t_f) and TYPE(hdset_reg_ref_t_f)
!  types.
!
  DO i = 1, num_rkinds
     k = rkind(i)
     WRITE(chr2,'(I2)') k
     DO j = 1, 8
! DLL definitions for windows
        WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
        WRITE(11,'(A)') '!DEC$attributes dllexport :: h5dread_rkind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
        WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
        WRITE(11,'(A)') '  SUBROUTINE h5dread_rkind_'//TRIM(ADJUSTL(chr2))&
             &//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
        WRITE(11,'(A)') '       mem_space_id, file_space_id, xfer_prp)'
        WRITE(11,'(A)') '    USE, INTRINSIC :: ISO_C_BINDING'
        WRITE(11,'(A)') '    IMPLICIT NONE'
        WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: dset_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: mem_type_id'
        WRITE(11,'(A)') '    INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims'
        WRITE(11,'(A)') '    REAL(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(INOUT)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
        WRITE(11,'(A)') '    INTEGER, INTENT(OUT) :: hdferr'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: xfer_prp_default'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: mem_space_id_default'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: file_space_id_default'
        WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
        WRITE(11,'(A)') '    xfer_prp_default = H5P_DEFAULT_F'
        WRITE(11,'(A)') '    mem_space_id_default = H5S_ALL_F'
        WRITE(11,'(A)') '    file_space_id_default = H5S_ALL_F'
        WRITE(11,'(A)') '    IF(PRESENT(xfer_prp)) xfer_prp_default = xfer_prp'
        WRITE(11,'(A)') '    IF(PRESENT(mem_space_id))  mem_space_id_default = mem_space_id'
        WRITE(11,'(A)') '    IF(PRESENT(file_space_id)) file_space_id_default = file_space_id'
        WRITE(11,'(A)') f_ptr_line(j)
        WRITE(11,'(A)') '    hdferr = h5dread_f_c(dset_id, mem_type_id, mem_space_id_default, &'
        WRITE(11,'(A)') '         file_space_id_default, xfer_prp_default, f_ptr)'
        WRITE(11,'(A)') '  END SUBROUTINE h5dread_rkind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)

     ENDDO
  ENDDO

  DO i = 1, num_ikinds
     k = ikind(i)
     WRITE(chr2,'(I2)') k
     DO j = 1, 8
! DLL definitions for windows
        WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
        WRITE(11,'(A)') '!DEC$attributes dllexport :: h5dread_ikind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
        WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
        WRITE(11,'(A)') '  SUBROUTINE h5dread_ikind_'//TRIM(ADJUSTL(chr2))&
             &//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
        WRITE(11,'(A)') '       mem_space_id, file_space_id, xfer_prp)'
        WRITE(11,'(A)') '    USE, INTRINSIC :: ISO_C_BINDING'
        WRITE(11,'(A)') '    IMPLICIT NONE'
        WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: dset_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: mem_type_id'
        WRITE(11,'(A)') '    INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims'
        WRITE(11,'(A)') '    INTEGER(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(INOUT)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
        WRITE(11,'(A)') '    INTEGER, INTENT(OUT) :: hdferr'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: xfer_prp_default'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: mem_space_id_default'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: file_space_id_default'
        WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
        WRITE(11,'(A)') '    xfer_prp_default = H5P_DEFAULT_F'
        WRITE(11,'(A)') '    mem_space_id_default = H5S_ALL_F'
        WRITE(11,'(A)') '    file_space_id_default = H5S_ALL_F'
        WRITE(11,'(A)') '    IF(PRESENT(xfer_prp)) xfer_prp_default = xfer_prp'
        WRITE(11,'(A)') '    IF(PRESENT(mem_space_id))  mem_space_id_default = mem_space_id'
        WRITE(11,'(A)') '    IF(PRESENT(file_space_id)) file_space_id_default = file_space_id'
        WRITE(11,'(A)') f_ptr_line(j)
        WRITE(11,'(A)') '    hdferr = h5dread_f_c(dset_id, mem_type_id, mem_space_id_default, &'
        WRITE(11,'(A)') '         file_space_id_default, xfer_prp_default, f_ptr)'
        WRITE(11,'(A)') '  END SUBROUTINE h5dread_ikind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)

     ENDDO
  ENDDO
  DO j = 2, 8
! DLL definitions for windows
     WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
     WRITE(11,'(A)') '!DEC$attributes dllexport :: h5dread_ckind_rank'//chr_rank(j)
     WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
     WRITE(11,'(A)') '  SUBROUTINE h5dread_ckind_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
     WRITE(11,'(A)') '       mem_space_id, file_space_id, xfer_prp)'
     WRITE(11,'(A)') '    USE, INTRINSIC :: ISO_C_BINDING'
     WRITE(11,'(A)') '    IMPLICIT NONE'
     WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: dset_id'
     WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: mem_type_id'
     WRITE(11,'(A)') '    INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims'
     WRITE(11,'(A)') '    CHARACTER(LEN=*), INTENT(INOUT)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
     WRITE(11,'(A)') '    INTEGER, INTENT(OUT) :: hdferr'
     WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id'
     WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id'
     WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp'
     WRITE(11,'(A)') '    INTEGER(HID_T) :: xfer_prp_default'
     WRITE(11,'(A)') '    INTEGER(HID_T) :: mem_space_id_default'
     WRITE(11,'(A)') '    INTEGER(HID_T) :: file_space_id_default'
     WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
     WRITE(11,'(A)') '    xfer_prp_default = H5P_DEFAULT_F'
     WRITE(11,'(A)') '    mem_space_id_default = H5S_ALL_F'
     WRITE(11,'(A)') '    file_space_id_default = H5S_ALL_F'
     WRITE(11,'(A)') '    IF(PRESENT(xfer_prp)) xfer_prp_default = xfer_prp'
     WRITE(11,'(A)') '    IF(PRESENT(mem_space_id))  mem_space_id_default = mem_space_id'
     WRITE(11,'(A)') '    IF(PRESENT(file_space_id)) file_space_id_default = file_space_id'
     WRITE(11,'(A)') fchr_ptr_line(j)
     WRITE(11,'(A)') '    hdferr = h5dread_f_c(dset_id, mem_type_id, mem_space_id_default, &'
     WRITE(11,'(A)') '         file_space_id_default, xfer_prp_default, f_ptr)'
     WRITE(11,'(A)') '  END SUBROUTINE h5dread_ckind_rank'//chr_rank(j)
  ENDDO
!
! h5dwrite_f

!****s* H5D (F03)/h5dwrite_f_F03
!
! NAME		
!  h5dwrite_f_F03
!
! PURPOSE
!  Writes raw data from a dataset into a buffer. 
!
! Inputs:
!  dset_id	 - Identifier of the dataset to write to.
!  mem_type_id	 - Identifier of the memory datatype.
!  buf		 - Buffer with data to be written to the file.
!  
! Outputs:
!  hdferr        - Returns 0 if successful and -1 if fails
!
! Optional parameters:
!  mem_space_id	 - Identifier of the memory dataspace.
!  file_space_id - Identifier of the dataset's dataspace in the file.
!  xfer_prp	 - Identifier of a transfer property list for this I/O operation.
!
! AUTHOR
!  M. Scot Breitenfeld
!  September 17, 2011
!
! Fortran2003 Interface:
!!  SUBROUTINE h5dwrite_f(dset_id, mem_type_id, buf, hdferr, &
!!                        mem_space_id, file_space_id, xfer_prp)
!!    INTEGER(HID_T), INTENT(IN)              :: dset_id
!!    INTEGER(HID_T), INTENT(IN)              :: mem_type_id
!!    TYPE(C_PTR)   , INTENT(IN)              :: buf
!!    INTEGER       , INTENT(OUT)             :: hdferr
!!    INTEGER(HID_T), INTENT(IN)   , OPTIONAL :: mem_space_id
!!    INTEGER(HID_T), INTENT(IN)   , OPTIONAL :: file_space_id
!!    INTEGER(HID_T), INTENT(IN)   , OPTIONAL :: xfer_prp
!*****
  DO i = 1, num_rkinds
     k = rkind(i)
     WRITE(chr2,'(I2)') k
     DO j = 1, 8
! DLL definitions for windows
        WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
        WRITE(11,'(A)') '!DEC$attributes dllexport :: h5dwrite_rkind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
        WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
        WRITE(11,'(A)') '  SUBROUTINE h5dwrite_rkind_'//TRIM(ADJUSTL(chr2))&
             &//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
        WRITE(11,'(A)') '       mem_space_id, file_space_id, xfer_prp)'
        WRITE(11,'(A)') '    USE, INTRINSIC :: ISO_C_BINDING'
        WRITE(11,'(A)') '    IMPLICIT NONE'
        WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: dset_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: mem_type_id'
        WRITE(11,'(A)') '    INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims'
        WRITE(11,'(A)') '    REAL(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(IN)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
        WRITE(11,'(A)') '    INTEGER, INTENT(OUT) :: hdferr'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: xfer_prp_default'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: mem_space_id_default'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: file_space_id_default'
        WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
        WRITE(11,'(A)') '    xfer_prp_default  = H5P_DEFAULT_F'
        WRITE(11,'(A)') '    mem_space_id_default = H5S_ALL_F'
        WRITE(11,'(A)') '    file_space_id_default = H5S_ALL_F'
        WRITE(11,'(A)') '    IF(PRESENT(xfer_prp)) xfer_prp_default = xfer_prp'
        WRITE(11,'(A)') '    IF(PRESENT(mem_space_id))  mem_space_id_default = mem_space_id'
        WRITE(11,'(A)') '    IF(PRESENT(file_space_id)) file_space_id_default = file_space_id'
        WRITE(11,'(A)') f_ptr_line(j)
        WRITE(11,'(A)') '    hdferr = h5dwrite_f_c(dset_id, mem_type_id, mem_space_id_default, &'
        WRITE(11,'(A)') '         file_space_id_default, xfer_prp_default, f_ptr)'
        WRITE(11,'(A)') '  END SUBROUTINE h5dwrite_rkind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
     ENDDO
  ENDDO

  DO i = 1, num_ikinds
     k = ikind(i)
     WRITE(chr2,'(I2)') k
     DO j = 1, 8
! DLL definitions for windows
        WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
        WRITE(11,'(A)') '!DEC$attributes dllexport :: h5dwrite_ikind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
        WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
        WRITE(11,'(A)') '  SUBROUTINE h5dwrite_ikind_'//TRIM(ADJUSTL(chr2))&
             &//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
        WRITE(11,'(A)') '       mem_space_id, file_space_id, xfer_prp)'
        WRITE(11,'(A)') '    USE, INTRINSIC :: ISO_C_BINDING'
        WRITE(11,'(A)') '    IMPLICIT NONE'
        WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: dset_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: mem_type_id'
        WRITE(11,'(A)') '    INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims'
        WRITE(11,'(A)') '    INTEGER(KIND='//TRIM(ADJUSTL(chr2))//'),INTENT(IN)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
        WRITE(11,'(A)') '    INTEGER, INTENT(OUT) :: hdferr'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id'
        WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: xfer_prp_default'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: mem_space_id_default'
        WRITE(11,'(A)') '    INTEGER(HID_T) :: file_space_id_default'
        WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
        WRITE(11,'(A)') '    xfer_prp_default  = H5P_DEFAULT_F'
        WRITE(11,'(A)') '    mem_space_id_default = H5S_ALL_F'
        WRITE(11,'(A)') '    file_space_id_default = H5S_ALL_F'
        WRITE(11,'(A)') '    IF(PRESENT(xfer_prp)) xfer_prp_default = xfer_prp'
        WRITE(11,'(A)') '    IF(PRESENT(mem_space_id))  mem_space_id_default = mem_space_id'
        WRITE(11,'(A)') '    IF(PRESENT(file_space_id)) file_space_id_default = file_space_id'
        WRITE(11,'(A)') f_ptr_line(j)
        WRITE(11,'(A)') '    hdferr = h5dwrite_f_c(dset_id, mem_type_id, mem_space_id_default, &'
        WRITE(11,'(A)') '         file_space_id_default, xfer_prp_default, f_ptr)'
        WRITE(11,'(A)') '  END SUBROUTINE h5dwrite_ikind_'//TRIM(ADJUSTL(chr2))//'_rank'//chr_rank(j)
     ENDDO
  ENDDO  
  DO j = 2, 8
! DLL definitions for windows
     WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
     WRITE(11,'(A)') '!DEC$attributes dllexport :: h5dwrite_ckind_rank'//chr_rank(j)
     WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
     WRITE(11,'(A)') '  SUBROUTINE h5dwrite_ckind_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
     WRITE(11,'(A)') '       mem_space_id, file_space_id, xfer_prp)'
     WRITE(11,'(A)') '    USE, INTRINSIC :: ISO_C_BINDING'
     WRITE(11,'(A)') '    IMPLICIT NONE'
     WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: dset_id'
     WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: mem_type_id'
     WRITE(11,'(A)') '    INTEGER(HSIZE_T), INTENT(IN), DIMENSION(*) :: dims'
     WRITE(11,'(A)') '    CHARACTER(LEN=*),INTENT(IN)'//TRIM(rank_dim_line(j))//', TARGET :: buf'
     WRITE(11,'(A)') '    INTEGER, INTENT(OUT) :: hdferr'
     WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id'
     WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id'
     WRITE(11,'(A)') '    INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp'
     WRITE(11,'(A)') '    INTEGER(HID_T) :: xfer_prp_default'
     WRITE(11,'(A)') '    INTEGER(HID_T) :: mem_space_id_default'
     WRITE(11,'(A)') '    INTEGER(HID_T) :: file_space_id_default'
     WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
     WRITE(11,'(A)') '    xfer_prp_default  = H5P_DEFAULT_F'
     WRITE(11,'(A)') '    mem_space_id_default = H5S_ALL_F'
     WRITE(11,'(A)') '    file_space_id_default = H5S_ALL_F'
     WRITE(11,'(A)') '    IF(PRESENT(xfer_prp)) xfer_prp_default = xfer_prp'
     WRITE(11,'(A)') '    IF(PRESENT(mem_space_id))  mem_space_id_default = mem_space_id'
     WRITE(11,'(A)') '    IF(PRESENT(file_space_id)) file_space_id_default = file_space_id'
     WRITE(11,'(A)') fchr_ptr_line(j)
     WRITE(11,'(A)') '    hdferr = h5dwrite_f_c(dset_id, mem_type_id, mem_space_id_default, &'
     WRITE(11,'(A)') '         file_space_id_default, xfer_prp_default, f_ptr)'
     WRITE(11,'(A)') '  END SUBROUTINE h5dwrite_ckind_rank'//chr_rank(j)
  ENDDO

!**********************
! H5P APIs
!**********************
!
! H5Pset_fill_value_f
  DO i = 1, num_rkinds
     k = rkind(i)
     WRITE(chr2,'(I2)') k
! DLL definitions for windows
     WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
     WRITE(11,'(A)') '!DEC$attributes dllexport :: h5pset_fill_value_kind_'//TRIM(ADJUSTL(chr2))
     WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
     WRITE(11,'(A)') '  SUBROUTINE h5pset_fill_value_kind_'//TRIM(ADJUSTL(chr2))&
          &//'(prp_id, type_id, fillvalue, hdferr)'
     WRITE(11,'(A)') '    IMPLICIT NONE'
     WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: prp_id'
     WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: type_id'
     WRITE(11,'(A)') '    REAL(KIND='//TRIM(ADJUSTL(chr2))//'), INTENT(IN), TARGET :: fillvalue' 
     WRITE(11,'(A)') '    INTEGER, INTENT(OUT) :: hdferr '
     WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr '
     WRITE(11,'(A)') '    f_ptr = C_LOC(fillvalue)'
     WRITE(11,'(A)') '    hdferr = h5pset_fill_value_c(prp_id, type_id, f_ptr)'
     WRITE(11,'(A)') '  END SUBROUTINE h5pset_fill_value_kind_'//TRIM(ADJUSTL(chr2))
  ENDDO

! H5Pget_fill_value_f
  DO i = 1, num_rkinds
     k = rkind(i)
     WRITE(chr2,'(I2)') k
! DLL definitions for windows
     WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
     WRITE(11,'(A)') '!DEC$attributes dllexport :: h5pget_fill_value_kind_'//TRIM(ADJUSTL(chr2))
     WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
     WRITE(11,'(A)') '  SUBROUTINE h5pget_fill_value_kind_'//TRIM(ADJUSTL(chr2))&
          &//'(prp_id, type_id, fillvalue, hdferr)'
     WRITE(11,'(A)') '    IMPLICIT NONE'
     WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: prp_id'
     WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: type_id'
     WRITE(11,'(A)') '    REAL(KIND='//TRIM(ADJUSTL(chr2))//'), INTENT(OUT), TARGET :: fillvalue'
     WRITE(11,'(A)') '    INTEGER, INTENT(OUT) :: hdferr'
     WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
     WRITE(11,'(A)') '    f_ptr = C_LOC(fillvalue)'
     WRITE(11,'(A)') '    hdferr = h5pget_fill_value_c(prp_id, type_id, f_ptr)'
     WRITE(11,'(A)') '  END SUBROUTINE h5pget_fill_value_kind_'//TRIM(ADJUSTL(chr2))
  ENDDO

! H5Pset_f
  DO i = 1, num_rkinds
     k = rkind(i)
     WRITE(chr2,'(I2)') k
! DLL definitions for windows
     WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
     WRITE(11,'(A)') '!DEC$attributes dllexport :: h5pset_kind_'//TRIM(ADJUSTL(chr2))
     WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
     WRITE(11,'(A)') '  SUBROUTINE h5pset_kind_'//TRIM(ADJUSTL(chr2))&
          &//'(prp_id, name, value, hdferr)'
     WRITE(11,'(A)') '    IMPLICIT NONE'
     WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: prp_id'
     WRITE(11,'(A)') '    CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(IN) :: name'
     WRITE(11,'(A)') '    REAL(KIND='//TRIM(ADJUSTL(chr2))//'), INTENT(IN), TARGET :: value'
     WRITE(11,'(A)') '    INTEGER, INTENT(OUT) :: hdferr'
     WRITE(11,'(A)') '    INTEGER :: name_len'
     WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
     WRITE(11,'(A)') '    f_ptr = C_LOC(value)'
     WRITE(11,'(A)') '    name_len = LEN(name)'
     WRITE(11,'(A)') '    hdferr = h5pget_c(prp_id, name, name_len, f_ptr)'
     
     WRITE(11,'(A)') '  END SUBROUTINE h5pset_kind_'//TRIM(ADJUSTL(chr2))
  ENDDO

! H5Pget_f
  DO i = 1, num_rkinds
     k = rkind(i)
     WRITE(chr2,'(I2)') k
! DLL definitions for windows
     WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
     WRITE(11,'(A)') '!DEC$attributes dllexport :: h5pget_kind_'//TRIM(ADJUSTL(chr2))
     WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
     WRITE(11,'(A)') '  SUBROUTINE h5pget_kind_'//TRIM(ADJUSTL(chr2))&
          &//'(prp_id, name, value, hdferr)'
     WRITE(11,'(A)') '    IMPLICIT NONE'
     WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: prp_id'
     WRITE(11,'(A)') '    CHARACTER(LEN=*), INTENT(IN) :: name'
     WRITE(11,'(A)') '    REAL(KIND='//TRIM(ADJUSTL(chr2))//'),   INTENT(OUT), TARGET :: value'
     WRITE(11,'(A)') '    INTEGER, INTENT(OUT) :: hdferr'
     WRITE(11,'(A)') '    INTEGER :: name_len'
     WRITE(11,'(A)') '    TYPE(C_PTR) :: f_ptr'
     WRITE(11,'(A)') '    f_ptr = C_LOC(value)'
     WRITE(11,'(A)') '    name_len = LEN(name)'
     WRITE(11,'(A)') '    hdferr = h5pget_c(prp_id, name, name_len, f_ptr)'
     WRITE(11,'(A)') '  END SUBROUTINE h5pget_kind_'//TRIM(ADJUSTL(chr2))
  ENDDO

! H5Pregister_f
  DO i = 1, num_rkinds
     k = rkind(i)
     WRITE(chr2,'(I2)') k
! DLL definitions for windows
     WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
     WRITE(11,'(A)') '!DEC$attributes dllexport :: h5pregister_kind_'//TRIM(ADJUSTL(chr2))
     WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
     WRITE(11,'(A)') 'SUBROUTINE h5pregister_kind_'//TRIM(ADJUSTL(chr2))&
          &//'(class, name, size, value, hdferr)'
     WRITE(11,'(A)') '  IMPLICIT NONE'
     WRITE(11,'(A)') '  INTEGER(HID_T), INTENT(IN) :: class'
     WRITE(11,'(A)') '  CHARACTER(LEN=*), INTENT(IN) :: name'
     WRITE(11,'(A)') '  INTEGER(SIZE_T), INTENT(IN) :: size'
     WRITE(11,'(A)') '  REAL(KIND='//TRIM(ADJUSTL(chr2))//'), INTENT(IN), TARGET :: value'
     WRITE(11,'(A)') '  INTEGER, INTENT(OUT) :: hdferr'
     WRITE(11,'(A)') '  INTEGER :: name_len'
     WRITE(11,'(A)') '  TYPE(C_PTR) :: f_ptr'
     WRITE(11,'(A)') '  f_ptr = C_LOC(value)'
     WRITE(11,'(A)') '  name_len = LEN(name)'
     WRITE(11,'(A)') '  hdferr = h5pregister_c(class, name, name_len, size, f_ptr)'
     WRITE(11,'(A)') 'END SUBROUTINE h5pregister_kind_'//TRIM(ADJUSTL(chr2))
  ENDDO

! H5Pinsert_f
  DO i = 1, num_rkinds
     k = rkind(i)
     WRITE(chr2,'(I2)') k
! DLL definitions for windows
     WRITE(11,'(A)') '!DEC$if defined(BUILD_HDF5_DLL)'
     WRITE(11,'(A)') '!DEC$attributes dllexport :: h5pinsert_kind_'//TRIM(ADJUSTL(chr2))
     WRITE(11,'(A)') '!DEC$endif'
! Subroutine API
     WRITE(11,'(A)') '  SUBROUTINE h5pinsert_kind_'//TRIM(ADJUSTL(chr2))&
          &//'(plist, name, size, value, hdferr)'
     WRITE(11,'(A)') '    IMPLICIT NONE'
     WRITE(11,'(A)') '    INTEGER(HID_T), INTENT(IN) :: plist'
     WRITE(11,'(A)') '    CHARACTER(LEN=*), INTENT(IN) :: name'
     WRITE(11,'(A)') '    INTEGER(SIZE_T), INTENT(IN) :: size'
     WRITE(11,'(A)') '    REAL(KIND='//TRIM(ADJUSTL(chr2))//'),   INTENT(IN), TARGET :: value'
     WRITE(11,'(A)') '    INTEGER, INTENT(OUT) :: hdferr'
     WRITE(11,'(A)') '    INTEGER :: name_len'
     WRITE(11,'(A)') '    TYPE(c_ptr) :: f_ptr'
     WRITE(11,'(A)') '    f_ptr = c_loc(value)'
     WRITE(11,'(A)') '    name_len = LEN(name)'
     WRITE(11,'(A)') '    hdferr = h5pinsert_c(plist, name , name_len, size, f_ptr)'
     WRITE(11,'(A)') '  END SUBROUTINE h5pinsert_kind_'//TRIM(ADJUSTL(chr2))
  ENDDO

  WRITE(11,'(A)') 'END MODULE H5_gen'

  CLOSE(11)

END PROGRAM H5_buildiface