-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathmodule_internal_header_util.F
1170 lines (1104 loc) · 43.1 KB
/
module_internal_header_util.F
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
MODULE module_internal_header_util
!<DESCRIPTION>
!<PRE>
! Subroutines defined in this module are used to generate (put together) and get (take apart)
! data headers stored in the form of integer vectors.
!
! Data headers serve two purposes:
! - Provide a package-independent metadata storage and retrieval mechanism
! for I/O packages that do not support native metadata.
! - Provide a mechanism for communicating I/O commands from compute
! tasks to quilt tasks when I/O quilt servers are enabled.
!
! Within a data header, character strings are stored one character per integer.
! The number of characters is stored immediately before the first character of
! each string.
!
! In an I/O package that does not support native metadata, routines
! int_gen_*_header() are called to pack information into data headers that
! are then written to files. Routines int_get_*_header() are called to
! extract information from a data headers after they have been read from a
! file.
!
! When I/O quilt server tasks are used, routines int_gen_*_header()
! are called by compute tasks to pack information into data headers
! (commands) that are then sent to the I/O quilt servers. Routines
! int_get_*_header() are called by I/O quilt servers to extract
! information from data headers (commands) received from the compute
! tasks.
!
!</PRE>
!</DESCRIPTION>
INTERFACE int_get_ti_header
MODULE PROCEDURE int_get_ti_header_integer, int_get_ti_header_real
END INTERFACE
INTERFACE int_gen_ti_header
MODULE PROCEDURE int_gen_ti_header_integer, int_gen_ti_header_real
END INTERFACE
INTERFACE int_get_td_header
MODULE PROCEDURE int_get_td_header_integer, int_get_td_header_real
END INTERFACE
INTERFACE int_gen_td_header
MODULE PROCEDURE int_gen_td_header_integer, int_gen_td_header_real
END INTERFACE
PRIVATE :: int_pack_string, int_unpack_string
CONTAINS
!!!!!!!!!!!!! header manipulation routines !!!!!!!!!!!!!!!
INTEGER FUNCTION get_hdr_tag( hdrbuf )
IMPLICIT NONE
INTEGER, INTENT(IN) :: hdrbuf(*)
get_hdr_tag = hdrbuf(2)
RETURN
END FUNCTION get_hdr_tag
INTEGER FUNCTION get_hdr_rec_size( hdrbuf )
IMPLICIT NONE
INTEGER, INTENT(IN) :: hdrbuf(*)
get_hdr_rec_size = hdrbuf(1)
RETURN
END FUNCTION get_hdr_rec_size
SUBROUTINE int_gen_write_field_header ( hdrbuf, hdrbufsize, itypesize, ftypesize, &
DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, &
DomainDesc , MemoryOrder , Stagger , DimNames , &
DomainStart , DomainEnd , &
MemoryStart , MemoryEnd , &
PatchStart , PatchEnd )
!<DESCRIPTION>
!<PRE>
! Items and their starting locations within a "write field" data header.
! Assume that the data header is stored in integer vector "hdrbuf":
! hdrbuf(1) = hdrbufsize
! hdrbuf(2) = headerTag
! hdrbuf(3) = ftypesize
! hdrbuf(4) = DataHandle
! hdrbuf(5) = LEN(TRIM(DateStr))
! hdrbuf(6:5+n1) = DateStr ! n1 = LEN(TRIM(DateStr)) + 1
! hdrbuf(6+n1) = LEN(TRIM(VarName))
! hdrbuf(7+n1:6+n1+n2) = VarName ! n2 = LEN(TRIM(VarName)) + 1
! hdrbuf(7+n1+n2) = FieldType
! hdrbuf(8+n1+n2) = LEN(TRIM(MemoryOrder))
! hdrbuf(9+n1+n2:8+n1+n2+n3) = MemoryOrder ! n3 = LEN(TRIM(MemoryOrder)) + 1
! hdrbuf(9+n1+n2+n3) = LEN(TRIM(Stagger))
! hdrbuf(9+n1+n2+n3:8+n1+n2+n3+n4) = Stagger ! n4 = LEN(TRIM(Stagger)) + 1
! hdrbuf(9+n1+n2+n3+n4) = LEN(TRIM(DimNames(1)))
! hdrbuf(9+n1+n2+n3+n4:8+n1+n2+n3+n4+n5) = DimNames(1) ! n5 = LEN(TRIM(DimNames(1))) + 1
! hdrbuf(9+n1+n2+n3+n4+n5) = LEN(TRIM(DimNames(2)))
! hdrbuf(9+n1+n2+n3+n4+n5:8+n1+n2+n3+n4+n5+n6) = DimNames(2) ! n6 = LEN(TRIM(DimNames(2))) + 1
! hdrbuf(9+n1+n2+n3+n4+n5+n6) = LEN(TRIM(DimNames(3)))
! hdrbuf(9+n1+n2+n3+n4+n5+n6:8+n1+n2+n3+n4+n5+n6+n7) = DimNames(3) ! n7 = LEN(TRIM(DimNames(3))) + 1
! hdrbuf(9+n1+n2+n3+n4+n5+n6+n7) = DomainStart(1)
! hdrbuf(10+n1+n2+n3+n4+n5+n6+n7) = DomainStart(2)
! hdrbuf(11+n1+n2+n3+n4+n5+n6+n7) = DomainStart(3)
! hdrbuf(12+n1+n2+n3+n4+n5+n6+n7) = DomainEnd(1)
! hdrbuf(13+n1+n2+n3+n4+n5+n6+n7) = DomainEnd(2)
! hdrbuf(14+n1+n2+n3+n4+n5+n6+n7) = DomainEnd(3)
! hdrbuf(15+n1+n2+n3+n4+n5+n6+n7) = PatchStart(1)
! hdrbuf(16+n1+n2+n3+n4+n5+n6+n7) = PatchStart(2)
! hdrbuf(17+n1+n2+n3+n4+n5+n6+n7) = PatchStart(3)
! hdrbuf(18+n1+n2+n3+n4+n5+n6+n7) = PatchEnd(1)
! hdrbuf(19+n1+n2+n3+n4+n5+n6+n7) = PatchEnd(2)
! hdrbuf(20+n1+n2+n3+n4+n5+n6+n7) = PatchEnd(3)
! hdrbuf(21+n1+n2+n3+n4+n5+n6+n7) = DomainDesc
!
! Further details for some items:
! hdrbufsize: Size of this data header in bytes.
! headerTag: "Header tag" that tells the I/O quilt servers what kind of
! header this is. For a "write field" header it must be set to
! INT_FIELD. See file intio_tags.h for a complete list of
! these tags.
! ftypesize: Size of field data type in bytes.
! DataHandle: Descriptor for an open data set.
! DomainDesc: Additional argument that may be used by some packages as a
! package-specific domain descriptor.
! Other items are described in detail in the "WRF I/O and Model Coupling API
! Specification".
!
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(INOUT) :: hdrbufsize
INTEGER, INTENT(INOUT) :: itypesize, ftypesize
INTEGER , INTENT(IN) :: DataHandle
CHARACTER*(*), INTENT(IN) :: DateStr
CHARACTER*(*), INTENT(IN) :: VarName
REAL, DIMENSION(*) :: Dummy
INTEGER ,intent(in) :: FieldType
INTEGER ,intent(inout) :: Comm
INTEGER ,intent(inout) :: IOComm
INTEGER ,intent(in) :: DomainDesc
CHARACTER*(*) ,intent(in) :: MemoryOrder
CHARACTER*(*) ,intent(in) :: Stagger
CHARACTER*(*) , dimension (*) ,intent(in) :: DimNames
INTEGER ,dimension(*) ,intent(in) :: DomainStart, DomainEnd
INTEGER ,dimension(*) ,intent(in) :: MemoryStart, MemoryEnd
INTEGER ,dimension(*) ,intent(in) :: PatchStart, PatchEnd
INTEGER i, n
hdrbuf(1) = 0 ! deferred -- this will be length of header
hdrbuf(2) = INT_FIELD
hdrbuf(3) = ftypesize
i = 4
hdrbuf(i) = DataHandle ; i = i+1
call int_pack_string( DateStr, hdrbuf(i), n ) ; i = i + n
call int_pack_string( VarName, hdrbuf(i), n ) ; i = i + n
hdrbuf(i) = FieldType ; i = i+1
call int_pack_string( MemoryOrder, hdrbuf(i), n ) ; i = i + n
call int_pack_string( Stagger, hdrbuf(i), n ) ; i = i + n
call int_pack_string( DimNames(1), hdrbuf(i), n ) ; i = i + n
call int_pack_string( DimNames(2), hdrbuf(i), n ) ; i = i + n
call int_pack_string( DimNames(3), hdrbuf(i), n ) ; i = i + n
hdrbuf(i) = DomainStart(1) ; i = i+1
hdrbuf(i) = DomainStart(2) ; i = i+1
hdrbuf(i) = DomainStart(3) ; i = i+1
hdrbuf(i) = DomainEnd(1) ; i = i+1
hdrbuf(i) = DomainEnd(2) ; i = i+1
hdrbuf(i) = DomainEnd(3) ; i = i+1
hdrbuf(i) = PatchStart(1) ; i = i+1
hdrbuf(i) = PatchStart(2) ; i = i+1
hdrbuf(i) = PatchStart(3) ; i = i+1
hdrbuf(i) = PatchEnd(1) ; i = i+1
hdrbuf(i) = PatchEnd(2) ; i = i+1
hdrbuf(i) = PatchEnd(3) ; i = i+1
hdrbuf(i) = DomainDesc ; i = i+1
hdrbufsize = (i-1) * itypesize ! return the number in bytes
hdrbuf(1) = hdrbufsize
RETURN
END SUBROUTINE int_gen_write_field_header
SUBROUTINE int_get_write_field_header ( hdrbuf, hdrbufsize, itypesize, ftypesize, &
DataHandle , DateStr , VarName , Dummy , FieldType , Comm , IOComm, &
DomainDesc , MemoryOrder , Stagger , DimNames , &
DomainStart , DomainEnd , &
MemoryStart , MemoryEnd , &
PatchStart , PatchEnd )
!<DESCRIPTION>
!<PRE>
! See documentation block in int_gen_write_field_header() for
! a description of a "write field" header.
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(INOUT) :: itypesize, ftypesize
INTEGER , INTENT(OUT) :: DataHandle
CHARACTER*(*), INTENT(INOUT) :: DateStr
CHARACTER*(*), INTENT(INOUT) :: VarName
REAL, DIMENSION(*) :: Dummy
INTEGER :: FieldType
INTEGER :: Comm
INTEGER :: IOComm
INTEGER :: DomainDesc
CHARACTER*(*) :: MemoryOrder
CHARACTER*(*) :: Stagger
CHARACTER*(*) , dimension (*) :: DimNames
INTEGER ,dimension(*) :: DomainStart, DomainEnd
INTEGER ,dimension(*) :: MemoryStart, MemoryEnd
INTEGER ,dimension(*) :: PatchStart, PatchEnd
!Local
CHARACTER*132 mess
INTEGER i, n
hdrbufsize = hdrbuf(1)
IF ( hdrbuf(2) .NE. INT_FIELD ) THEN
write(mess,*)'int_get_write_field_header: hdrbuf(2) ne INT_FIELD ',hdrbuf(2),INT_FIELD
CALL wrf_error_fatal ( mess )
ENDIF
ftypesize = hdrbuf(3)
i = 4
DataHandle = hdrbuf(i) ; i = i+1
call int_unpack_string( DateStr, hdrbuf(i), n ) ; i = i+n
call int_unpack_string( VarName, hdrbuf(i), n ) ; i = i+n
FieldType = hdrbuf(i) ; i = i+1
call int_unpack_string( MemoryOrder, hdrbuf(i), n ) ; i = i+n
call int_unpack_string( Stagger, hdrbuf(i), n ) ; i = i+n
call int_unpack_string( DimNames(1), hdrbuf(i), n ) ; i = i+n
call int_unpack_string( DimNames(2), hdrbuf(i), n ) ; i = i+n
call int_unpack_string( DimNames(3), hdrbuf(i), n ) ; i = i+n
DomainStart(1) = hdrbuf(i) ; i = i+1
DomainStart(2) = hdrbuf(i) ; i = i+1
DomainStart(3) = hdrbuf(i) ; i = i+1
DomainEnd(1) = hdrbuf(i) ; i = i+1
DomainEnd(2) = hdrbuf(i) ; i = i+1
DomainEnd(3) = hdrbuf(i) ; i = i+1
PatchStart(1) = hdrbuf(i) ; i = i+1
PatchStart(2) = hdrbuf(i) ; i = i+1
PatchStart(3) = hdrbuf(i) ; i = i+1
PatchEnd(1) = hdrbuf(i) ; i = i+1
PatchEnd(2) = hdrbuf(i) ; i = i+1
PatchEnd(3) = hdrbuf(i) ; i = i+1
DomainDesc = hdrbuf(i) ; i = i+1
RETURN
END SUBROUTINE int_get_write_field_header
!!!!!!!!
!generate open for read header
SUBROUTINE int_gen_ofr_header( hdrbuf, hdrbufsize, itypesize, &
FileName, SysDepInfo, DataHandle )
!<DESCRIPTION>
!<PRE>
! Items and their starting locations within a "open for read" data header.
! Assume that the data header is stored in integer vector "hdrbuf":
! hdrbuf(1) = hdrbufsize
! hdrbuf(2) = headerTag
! hdrbuf(3) = DataHandle
! hdrbuf(4) = LEN(TRIM(FileName))
! hdrbuf(5:4+n1) = FileName ! n1 = LEN(TRIM(FileName)) + 1
! hdrbuf(5+n1) = LEN(TRIM(SysDepInfo))
! hdrbuf(6+n1:5+n1+n2) = SysDepInfo ! n2 = LEN(TRIM(SysDepInfo)) + 1
!
! Further details for some items:
! hdrbufsize: Size of this data header in bytes.
! headerTag: "Header tag" that tells the I/O quilt servers what kind of
! header this is. For an "open for read" header it must be set to
! INT_OPEN_FOR_READ. See file intio_tags.h for a complete list of
! these tags.
! DataHandle: Descriptor for an open data set.
! FileName: File name.
! SysDepInfo: System dependent information used for optional additional
! I/O control information.
! Other items are described in detail in the "WRF I/O and Model Coupling API
! Specification".
!
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(INOUT) :: itypesize
INTEGER , INTENT(IN) :: DataHandle
CHARACTER*(*), INTENT(INOUT) :: FileName
CHARACTER*(*), INTENT(INOUT) :: SysDepInfo
!Local
INTEGER i, n, i1
!
hdrbuf(1) = 0 !deferred
hdrbuf(2) = INT_OPEN_FOR_READ
i = 3
hdrbuf(i) = DataHandle ; i = i+1
call int_pack_string( TRIM(FileName), hdrbuf(i), n ) ; i = i + n
call int_pack_string( TRIM(SysDepInfo), hdrbuf(i), n ) ; i = i + n
hdrbufsize = (i-1) * itypesize ! return the number in bytes
hdrbuf(1) = hdrbufsize
RETURN
END SUBROUTINE int_gen_ofr_header
!get open for read header
SUBROUTINE int_get_ofr_header( hdrbuf, hdrbufsize, itypesize, &
FileName, SysDepInfo, DataHandle )
!<DESCRIPTION>
!<PRE>
! See documentation block in int_gen_ofr_header() for
! a description of a "open for read" header.
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(INOUT) :: itypesize
INTEGER , INTENT(OUT) :: DataHandle
CHARACTER*(*), INTENT(INOUT) :: FileName
CHARACTER*(*), INTENT(INOUT) :: SysDepInfo
!Local
INTEGER i, n
!
hdrbufsize = hdrbuf(1)
! IF ( hdrbuf(2) .NE. INT_OPEN_FOR_READ ) THEN
! CALL wrf_error_fatal ( "int_get_ofr_header: hdrbuf ne INT_OPEN_FOR_READ")
! ENDIF
i = 3
DataHandle = hdrbuf(i) ; i = i+1
call int_unpack_string( FileName, hdrbuf(i), n ) ; i = i+n
call int_unpack_string( SysDepInfo, hdrbuf(i), n ) ; i = i+n
RETURN
END SUBROUTINE int_get_ofr_header
!!!!!!!!
!generate open for write begin header
SUBROUTINE int_gen_ofwb_header( hdrbuf, hdrbufsize, itypesize, &
FileName, SysDepInfo, io_form, DataHandle )
!<DESCRIPTION>
!<PRE>
! Items and their starting locations within a "open for write begin" data
! header. Assume that the data header is stored in integer vector "hdrbuf":
! hdrbuf(1) = hdrbufsize
! hdrbuf(2) = headerTag
! hdrbuf(3) = DataHandle
! hdrbuf(4) = io_form
! hdrbuf(5) = LEN(TRIM(FileName))
! hdrbuf(6:5+n1) = FileName ! n1 = LEN(TRIM(FileName)) + 1
! hdrbuf(6+n1) = LEN(TRIM(SysDepInfo))
! hdrbuf(7+n1:6+n1+n2) = SysDepInfo ! n2 = LEN(TRIM(SysDepInfo)) + 1
!
! Further details for some items:
! hdrbufsize: Size of this data header in bytes.
! headerTag: "Header tag" that tells the I/O quilt servers what kind of
! header this is. For an "open for write begin" header it must be set to
! INT_OPEN_FOR_WRITE_BEGIN. See file intio_tags.h for a complete list of
! these tags.
! DataHandle: Descriptor for an open data set.
! io_form: I/O format for this file (netCDF, etc.).
! FileName: File name.
! SysDepInfo: System dependent information used for optional additional
! I/O control information.
! Other items are described in detail in the "WRF I/O and Model Coupling API
! Specification".
!
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(INOUT) :: itypesize
INTEGER , INTENT(IN) :: io_form
INTEGER , INTENT(IN) :: DataHandle
CHARACTER*(*), INTENT(INOUT) :: FileName
CHARACTER*(*), INTENT(INOUT) :: SysDepInfo
!Local
INTEGER i, n, j
!
hdrbuf(1) = 0 !deferred
hdrbuf(2) = INT_OPEN_FOR_WRITE_BEGIN
i = 3
hdrbuf(i) = DataHandle ; i = i+1
hdrbuf(i) = io_form ; i = i+1
!j = i
call int_pack_string( FileName, hdrbuf(i), n ) ; i = i + n
!write(0,*)'int_gen_ofwb_header FileName ',TRIM(FileName),hdrbuf(j),n
!j = i
call int_pack_string( SysDepInfo, hdrbuf(i), n ) ; i = i + n
!write(0,*)'int_gen_ofwb_header SysDepInfo ',TRIM(SysDepInfo),hdrbuf(j),n
hdrbufsize = (i-1) * itypesize ! return the number in bytes
hdrbuf(1) = hdrbufsize
!write(0,*)'int_gen_ofwb_header hdrbuf(1) ',hdrbuf(1)
RETURN
END SUBROUTINE int_gen_ofwb_header
!get open for write begin header
SUBROUTINE int_get_ofwb_header( hdrbuf, hdrbufsize, itypesize, &
FileName, SysDepInfo, io_form, DataHandle )
!<DESCRIPTION>
!<PRE>
! See documentation block in int_gen_ofwb_header() for
! a description of a "open for write begin" header.
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(INOUT) :: itypesize
INTEGER , INTENT(OUT) :: DataHandle
INTEGER , INTENT(OUT) :: io_form
CHARACTER*(*), INTENT (INOUT) :: FileName
CHARACTER*(*), INTENT (INOUT) :: SysDepInfo
!Local
INTEGER i, n, j
!
hdrbufsize = hdrbuf(1)
!write(0,*)' int_get_ofwb_header next rec start ',hdrbuf(hdrbufsize+1)
! IF ( hdrbuf(2) .NE. INT_OPEN_FOR_WRITE_BEGIN ) THEN
! CALL wrf_error_fatal ( "int_get_ofwb_header: hdrbuf ne INT_OPEN_FOR_WRITE_BEGIN")
! ENDIF
i = 3
DataHandle = hdrbuf(i) ; i = i+1
!write(0,*)' int_get_ofwb_header next rec',i, hdrbuf(hdrbufsize+1)
io_form = hdrbuf(i) ; i = i+1
!write(0,*)' int_get_ofwb_header next rec',i, hdrbuf(hdrbufsize+1)
!j = i
call int_unpack_string( FileName, hdrbuf(i), n ) ; i = i+n
!write(0,*)'int_get_ofwb_header FileName ',TRIM(FileName),hdrbuf(j),n
!write(0,*)' int_get_ofwb_header next rec',i, hdrbuf(hdrbufsize+1)
!j = i
call int_unpack_string( SysDepInfo, hdrbuf(i), n ) ; i = i+n
!write(0,*)'int_get_ofwb_header SysDepInfo ',TRIM(SysDepInfo),hdrbuf(j),n
!write(0,*)' int_get_ofwb_header next rec',i, hdrbuf(hdrbufsize+1)
!write(0,*)'int_get_ofwb_header hdrbufsize ',hdrbufsize
RETURN
END SUBROUTINE int_get_ofwb_header
!!!!!!!!!!
SUBROUTINE int_gen_handle_header( hdrbuf, hdrbufsize, itypesize, &
DataHandle , code )
!<DESCRIPTION>
!<PRE>
! Items and their starting locations within a "generic handle" data header.
! Several types of data headers contain only a DataHandle and a header tag
! (I/O command). This routine is used for all of them. Assume that
! the data header is stored in integer vector "hdrbuf":
! hdrbuf(1) = hdrbufsize
! hdrbuf(2) = headerTag
! hdrbuf(3) = DataHandle
!
! Further details for some items:
! hdrbufsize: Size of this data header in bytes.
! headerTag: "Header tag" that tells the I/O quilt servers what kind of
! header this is. For a "generic handle" header there are
! several possible values. In this routine, dummy argument
! "code" is used as headerTag.
! DataHandle: Descriptor for an open data set.
!
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(INOUT) :: itypesize
INTEGER ,INTENT(IN) :: DataHandle, code
!Local
INTEGER i
!
hdrbuf(1) = 0 !deferred
hdrbuf(2) = code
i = 3
hdrbuf(i) = DataHandle ; i = i+1
hdrbufsize = (i-1) * itypesize ! return the number in bytes
hdrbuf(1) = hdrbufsize
RETURN
END SUBROUTINE int_gen_handle_header
SUBROUTINE int_get_handle_header( hdrbuf, hdrbufsize, itypesize, &
DataHandle , code )
!<DESCRIPTION>
!<PRE>
! See documentation block in int_gen_handle_header() for
! a description of a "generic handle" header.
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(INOUT) :: itypesize
INTEGER ,INTENT(OUT) :: DataHandle, code
!Local
INTEGER i
!
hdrbufsize = hdrbuf(1)
code = hdrbuf(2)
i = 3
DataHandle = hdrbuf(i) ; i = i+1
RETURN
END SUBROUTINE int_get_handle_header
!!!!!!!!!!!!
SUBROUTINE int_gen_ti_header_integer( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, Element, Data, Count, code )
!<DESCRIPTION>
!<PRE>
! Items and their starting locations within a "time-independent integer"
! data header. Assume that the data header is stored in integer vector
! "hdrbuf":
! hdrbuf(1) = hdrbufsize
! hdrbuf(2) = headerTag
! hdrbuf(3) = DataHandle
! hdrbuf(4) = typesize
! hdrbuf(5) = Count
! hdrbuf(6:6+n1) = Data ! n1 = (Count * typesize / itypesize) + 1
! hdrbuf(7+n1) = LEN(TRIM(Element))
! hdrbuf(8+n1:7+n1+n2) = Element ! n2 = LEN(TRIM(Element)) + 1
!
! Further details for some items:
! hdrbufsize: Size of this data header in bytes.
! headerTag: "Header tag" that tells the I/O quilt servers what kind of
! header this is. For an "time-independent integer" header it must be
! set to INT_DOM_TI_INTEGER. See file intio_tags.h for a complete
! list of these tags.
! DataHandle: Descriptor for an open data set.
! typesize: Size in bytes of each element of Data.
! Count: Number of elements in Data.
! Data: Data to write to file.
! Element: Name of the data.
! Other items are described in detail in the "WRF I/O and Model Coupling API
! Specification".
!
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize, typesize
CHARACTER*(*), INTENT(INOUT) :: Element
INTEGER, INTENT(IN) :: Data(*)
INTEGER, INTENT(IN) :: DataHandle, Count, code
!Local
INTEGER i, n
!
CALL int_gen_ti_header_c ( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, Data, Count, code )
i = hdrbufsize/itypesize + 1 ;
!write(0,*)'int_gen_ti_header_integer ',TRIM(Element)
CALL int_pack_string ( Element, hdrbuf( i ), n ) ; i = i + n
hdrbufsize = n * itypesize + hdrbufsize ! return the number in bytes
hdrbuf(1) = hdrbufsize
RETURN
END SUBROUTINE int_gen_ti_header_integer
SUBROUTINE int_gen_ti_header_integer_varna( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, Element, VarName, Data, Count, code )
!<DESCRIPTION>
!<PRE>
! Items and their starting locations within a "time-independent integer"
! data header. Assume that the data header is stored in integer vector
! "hdrbuf":
! hdrbuf(1) = hdrbufsize
! hdrbuf(2) = headerTag
! hdrbuf(3) = DataHandle
! hdrbuf(4) = typesize
! hdrbuf(5) = Count
! hdrbuf(6:6+n1) = Data ! n1 = (Count * typesize / itypesize) + 1
! hdrbuf(7+n1) = LEN(TRIM(Element))
! hdrbuf(8+n1:7+n1+n2) = Element ! n2 = LEN(TRIM(Element)) + 1
! hdrbuf(8+n1+n2) = LEN(TRIM(VarName)) = n3
! hderbuf(9+n1+n2:8+n1+n2+n3) = TRIM(VarName)
!
! Further details for some items:
! hdrbufsize: Size of this data header in bytes.
! headerTag: "Header tag" that tells the I/O quilt servers what kind of
! header this is. For an "time-independent integer" header it must be
! set to INT_DOM_TI_INTEGER. See file intio_tags.h for a complete
! list of these tags.
! DataHandle: Descriptor for an open data set.
! typesize: Size in bytes of each element of Data.
! Count: Number of elements in Data.
! Data: Data to write to file.
! Element: Name of the data.
! VarName: Variable name. Used for *_<get|put>_var_ti_char but not for
! *_<get|put>_dom_ti_char.
! Other items are described in detail in the "WRF I/O and Model Coupling API
! Specification".
!
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize, typesize
CHARACTER*(*), INTENT(IN) :: Element, VarName
INTEGER, INTENT(IN) :: Data(*)
INTEGER, INTENT(IN) :: DataHandle, Count, code
!Local
INTEGER i, n
!
CALL int_gen_ti_header_c ( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, Data, Count, code )
i = hdrbufsize/itypesize + 1 ;
!write(0,*)'int_gen_ti_header_integer ',TRIM(Element)
CALL int_pack_string ( Element, hdrbuf( i ), n ) ; i = i + n
CALL int_pack_string ( VarName, hdrbuf( i ), n ) ; i = i + n
hdrbufsize = i * itypesize + hdrbufsize ! return the number in bytes
hdrbuf(1) = hdrbufsize
RETURN
END SUBROUTINE int_gen_ti_header_integer_varna
SUBROUTINE int_gen_ti_header_real( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, Element, Data, Count, code )
!<DESCRIPTION>
!<PRE>
! Same as int_gen_ti_header_integer except that Data has type REAL.
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize, typesize
CHARACTER*(*), INTENT(INOUT) :: Element
REAL, INTENT(IN) :: Data(*)
INTEGER, INTENT(IN) :: DataHandle, Count, code
!Local
INTEGER i, n
!
CALL int_gen_ti_header_c ( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, Data, Count, code )
i = hdrbufsize/itypesize + 1 ;
!write(0,*)'int_gen_ti_header_real ',TRIM(Element)
CALL int_pack_string ( Element, hdrbuf( i ), n ) ; i = i + n
hdrbufsize = n * itypesize + hdrbufsize ! return the number in bytes
hdrbuf(1) = hdrbufsize
RETURN
END SUBROUTINE int_gen_ti_header_real
SUBROUTINE int_get_ti_header_integer_varna( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, Element, VarName, Data, Count, code)
!<DESCRIPTION>
!<PRE>
! Same as int_gen_ti_header_integer except that Data is read from
! the file.
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize, typesize
CHARACTER*(*), INTENT(INOUT) :: Element, VarName
INTEGER, INTENT(OUT) :: Data(*)
INTEGER, INTENT(OUT) :: DataHandle, Count, code
!Local
INTEGER i, n
!
CALL int_get_ti_header_c ( hdrbuf, hdrbufsize, n, itypesize, typesize, &
DataHandle, Data, Count, code )
i = n/itypesize + 1
CALL int_unpack_string ( Element, hdrbuf( i ), n ) ; i=i+n;
CALL int_unpack_string ( VarName, hdrbuf( i ), n ) ; i = i + n
! write(0,*)'int_get_ti_header_integer_varna "', &
! TRIM(Element),'" "', TRIM(VarName),'" data(1)=',Data(1)
hdrbufsize = hdrbuf(1)
RETURN
END SUBROUTINE int_get_ti_header_integer_varna
SUBROUTINE int_get_ti_header_integer( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, Element, Data, Count, code )
!<DESCRIPTION>
!<PRE>
! Same as int_gen_ti_header_integer except that Data is read from
! the file.
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize, typesize
CHARACTER*(*), INTENT(INOUT) :: Element
INTEGER, INTENT(OUT) :: Data(*)
INTEGER, INTENT(OUT) :: DataHandle, Count, code
!Local
INTEGER i, n
!
CALL int_get_ti_header_c ( hdrbuf, hdrbufsize, n, itypesize, typesize, &
DataHandle, Data, Count, code )
i = 1
CALL int_unpack_string ( Element, hdrbuf( n/itypesize + 1 ), n ) ;
!write(0,*)'int_get_ti_header_integer ',TRIM(Element), Data(1)
hdrbufsize = hdrbuf(1)
RETURN
END SUBROUTINE int_get_ti_header_integer
SUBROUTINE int_get_ti_header_real( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, Element, Data, Count, code )
!<DESCRIPTION>
!<PRE>
! Same as int_gen_ti_header_real except that Data is read from
! the file.
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize, typesize
CHARACTER*(*), INTENT(INOUT) :: Element
REAL, INTENT(OUT) :: Data(*)
INTEGER, INTENT(OUT) :: DataHandle, Count, code
!Local
INTEGER i, n
!
CALL int_get_ti_header_c ( hdrbuf, hdrbufsize, n, itypesize, typesize, &
DataHandle, Data, Count, code )
i = 1
CALL int_unpack_string ( Element, hdrbuf( n/itypesize + 1 ), n ) ;
!write(0,*)'int_get_ti_header_real ',TRIM(Element), Data(1)
hdrbufsize = hdrbuf(1)
RETURN
END SUBROUTINE int_get_ti_header_real
!!!!!!!!!!!!
SUBROUTINE int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, &
DataHandle, Element, VarName, Data, code )
!<DESCRIPTION>
!<PRE>
! Items and their starting locations within a "time-independent string"
! data header. Assume that the data header is stored in integer vector
! "hdrbuf":
! hdrbuf(1) = hdrbufsize
! hdrbuf(2) = headerTag
! hdrbuf(3) = DataHandle
! hdrbuf(4) = typesize
! hdrbuf(5) = LEN(TRIM(Element))
! hdrbuf(6:5+n1) = Element ! n1 = LEN(TRIM(Element)) + 1
! hdrbuf(6+n1) = LEN(TRIM(Data))
! hdrbuf(7+n1:6+n1+n2) = Data ! n2 = LEN(TRIM(Data)) + 1
! hdrbuf(7+n1+n2) = LEN(TRIM(VarName))
! hdrbuf(8+n1+n2:7+n1+n2+n3) = VarName ! n3 = LEN(TRIM(VarName)) + 1
!
! Further details for some items:
! hdrbufsize: Size of this data header in bytes.
! headerTag: "Header tag" that tells the I/O quilt servers what kind of
! header this is. For an "time-independent string" header it must be
! set to INT_DOM_TI_CHAR. See file intio_tags.h for a complete
! list of these tags.
! DataHandle: Descriptor for an open data set.
! typesize: 1 (size in bytes of a single CHARACTER).
! Element: Name of the data.
! Data: Data to write to file.
! VarName: Variable name. Used for *_<get|put>_var_ti_char but not for
! *_<get|put>_dom_ti_char.
! Other items are described in detail in the "WRF I/O and Model Coupling API
! Specification".
!
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize
CHARACTER*(*), INTENT(IN) :: Element, Data, VarName
INTEGER, INTENT(IN) :: DataHandle, code
!Local
INTEGER :: DummyData
INTEGER i, n, Count, DummyCount
!
DummyCount = 0
CALL int_gen_ti_header_c ( hdrbuf, hdrbufsize, itypesize, 1, &
DataHandle, DummyData, DummyCount, code )
i = hdrbufsize/itypesize+1 ;
CALL int_pack_string ( Element, hdrbuf( i ), n ) ; i = i + n
CALL int_pack_string ( Data , hdrbuf( i ), n ) ; i = i + n
CALL int_pack_string ( VarName , hdrbuf( i ), n ) ; i = i + n
hdrbufsize = (i-1) * itypesize + hdrbufsize ! return the number in bytes
hdrbuf(1) = hdrbufsize
RETURN
END SUBROUTINE int_gen_ti_header_char
SUBROUTINE int_get_ti_header_char( hdrbuf, hdrbufsize, itypesize, &
DataHandle, Element, VarName, Data, code )
!<DESCRIPTION>
!<PRE>
! Same as int_gen_ti_header_char except that Data is read from
! the file.
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize
CHARACTER*(*), INTENT(INOUT) :: Element, Data, VarName
INTEGER, INTENT(OUT) :: DataHandle, code
!Local
INTEGER i, n, DummyCount, typesize
CHARACTER * 132 dummyData
!
CALL int_get_ti_header_c ( hdrbuf, hdrbufsize, n, itypesize, typesize, &
DataHandle, dummyData, DummyCount, code )
i = n/itypesize+1 ;
CALL int_unpack_string ( Element, hdrbuf( i ), n ) ; i = i + n
CALL int_unpack_string ( Data , hdrbuf( i ), n ) ; i = i + n
CALL int_unpack_string ( VarName , hdrbuf( i ), n ) ; i = i + n
hdrbufsize = hdrbuf(1)
RETURN
END SUBROUTINE int_get_ti_header_char
!!!!!!!!!!!!
SUBROUTINE int_gen_td_header_char( hdrbuf, hdrbufsize, itypesize, &
DataHandle, DateStr, Element, Data, code )
!<DESCRIPTION>
!<PRE>
! Items and their starting locations within a "time-dependent string"
! data header. Assume that the data header is stored in integer vector
! "hdrbuf":
! hdrbuf(1) = hdrbufsize
! hdrbuf(2) = headerTag
! hdrbuf(3) = DataHandle
! hdrbuf(4) = typesize
! hdrbuf(5) = LEN(TRIM(Element))
! hdrbuf(6:5+n1) = Element ! n1 = LEN(TRIM(Element)) + 1
! hdrbuf(6+n1) = LEN(TRIM(DateStr))
! hdrbuf(7+n1:6+n1+n2) = DateStr ! n2 = LEN(TRIM(DateStr)) + 1
! hdrbuf(7+n1+n2) = LEN(TRIM(Data))
! hdrbuf(8+n1+n2:7+n1+n2+n3) = Data ! n3 = LEN(TRIM(Data)) + 1
!
! Further details for some items:
! hdrbufsize: Size of this data header in bytes.
! headerTag: "Header tag" that tells the I/O quilt servers what kind of
! header this is. For an "time-dependent string" header it must be
! set to INT_DOM_TD_CHAR. See file intio_tags.h for a complete
! list of these tags.
! DataHandle: Descriptor for an open data set.
! typesize: 1 (size in bytes of a single CHARACTER).
! Element: Name of the data.
! Data: Data to write to file.
! Other items are described in detail in the "WRF I/O and Model Coupling API
! Specification".
!
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize
CHARACTER*(*), INTENT(INOUT) :: DateStr, Element, Data
INTEGER, INTENT(IN) :: DataHandle, code
!Local
INTEGER i, n, DummyCount, DummyData
!
DummyCount = 0
CALL int_gen_ti_header_c ( hdrbuf, hdrbufsize, itypesize, 1, &
DataHandle, DummyData, DummyCount, code )
i = hdrbufsize/itypesize + 1 ;
CALL int_pack_string ( Element, hdrbuf( i ), n ) ; i = i + n
CALL int_pack_string ( DateStr, hdrbuf( i ), n ) ; i = i + n
CALL int_pack_string ( Data , hdrbuf( i ), n ) ; i = i + n
hdrbufsize = (i-1) * itypesize + hdrbufsize ! return the number in bytes
hdrbuf(1) = hdrbufsize
RETURN
END SUBROUTINE int_gen_td_header_char
SUBROUTINE int_get_td_header_char( hdrbuf, hdrbufsize, itypesize, &
DataHandle, DateStr, Element, Data, code )
!<DESCRIPTION>
!<PRE>
! Same as int_gen_td_header_char except that Data is read from
! the file.
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize
CHARACTER*(*), INTENT(INOUT) :: DateStr, Element, Data
INTEGER, INTENT(OUT) :: DataHandle, code
!Local
INTEGER i, n, Count, typesize
!
CALL int_get_ti_header_c ( hdrbuf, hdrbufsize, n, itypesize, typesize, &
DataHandle, Data, Count, code )
i = n/itypesize + 1 ;
CALL int_unpack_string ( Element, hdrbuf( i ), n ) ; i = i + n ;
CALL int_unpack_string ( DateStr, hdrbuf( i ), n ) ; i = i + n ;
CALL int_unpack_string ( Data , hdrbuf( i ), n ) ; i = i + n ;
hdrbufsize = hdrbuf(1)
RETURN
END SUBROUTINE int_get_td_header_char
SUBROUTINE int_gen_td_header_integer( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, DateStr, Element, Data, Count, code )
!<DESCRIPTION>
!<PRE>
! Items and their starting locations within a "time-dependent integer"
! data header. Assume that the data header is stored in integer vector
! "hdrbuf":
! hdrbuf(1) = hdrbufsize
! hdrbuf(2) = headerTag
! hdrbuf(3) = DataHandle
! hdrbuf(4) = typesize
! hdrbuf(5) = Count
! hdrbuf(6:6+n1) = Data ! n1 = (Count * typesize / itypesize) + 1
! hdrbuf(7+n1) = LEN(TRIM(DateStr))
! hdrbuf(8+n1:7+n1+n2) = DateStr ! n2 = LEN(TRIM(DateStr)) + 1
! hdrbuf(8+n1+n2) = LEN(TRIM(Element))
! hdrbuf(9+n1+n2:8+n1+n2+n3) = Element ! n3 = LEN(TRIM(Element)) + 1
!
! Further details for some items:
! hdrbufsize: Size of this data header in bytes.
! headerTag: "Header tag" that tells the I/O quilt servers what kind of
! header this is. For an "time-dependent integer" header it must be
! set to INT_DOM_TD_INTEGER. See file intio_tags.h for a complete
! list of these tags.
! DataHandle: Descriptor for an open data set.
! typesize: 1 (size in bytes of a single CHARACTER).
! Element: Name of the data.
! Count: Number of elements in Data.
! Data: Data to write to file.
! Other items are described in detail in the "WRF I/O and Model Coupling API
! Specification".
!
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize, typesize
CHARACTER*(*), INTENT(INOUT) :: DateStr, Element
INTEGER, INTENT(IN) :: Data(*)
INTEGER, INTENT(IN) :: DataHandle, Count, code
!Local
INTEGER i, n
!
CALL int_gen_ti_header_c ( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, Data, Count, code )
i = hdrbufsize/itypesize + 1 ;
CALL int_pack_string ( DateStr, hdrbuf( i ), n ) ; i = i + n
CALL int_pack_string ( Element, hdrbuf( i ), n ) ; i = i + n
hdrbufsize = (i-1) * itypesize + hdrbufsize ! return the number in bytes
hdrbuf(1) = hdrbufsize
RETURN
END SUBROUTINE int_gen_td_header_integer
SUBROUTINE int_gen_td_header_real( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, DateStr, Element, Data, Count, code )
!<DESCRIPTION>
!<PRE>
! Same as int_gen_td_header_integer except that Data has type REAL.
!</PRE>
!</DESCRIPTION>
IMPLICIT NONE
#include "intio_tags.h"
INTEGER, INTENT(INOUT) :: hdrbuf(*)
INTEGER, INTENT(OUT) :: hdrbufsize
INTEGER, INTENT(IN) :: itypesize, typesize
CHARACTER*(*), INTENT(INOUT) :: DateStr, Element
REAL, INTENT(IN) :: Data(*)
INTEGER, INTENT(IN) :: DataHandle, Count, code
!Local
INTEGER i, n
!
CALL int_gen_ti_header_c ( hdrbuf, hdrbufsize, itypesize, typesize, &
DataHandle, Data, Count, code )
i = hdrbufsize/itypesize + 1 ;
CALL int_pack_string ( DateStr, hdrbuf( i ), n ) ; i = i + n
CALL int_pack_string ( Element, hdrbuf( i ), n ) ; i = i + n
hdrbufsize = (i-1) * itypesize + hdrbufsize ! return the number in bytes
hdrbuf(1) = hdrbufsize
RETURN