-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipelibfort_g77.f
1684 lines (1550 loc) · 48.2 KB
/
pipelibfort_g77.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
C SUBROUTINE: getlen
c
C PURPOSE: Determine the length of a string excluding any blank padding
C
C ARGUMENTS: string (INPUT) - any length string
c NOTE: This function discriminates against both blanks,
c and char(0), so the length returned by this
c function is the number of characters which form
c a contiguous string excluding NULLs and blanks
c
C EXAMPLE: string='april '
c len=getlen(string)
c len would equal 5
C
C CALLED BY: functions isparam, iskeywd
c subroutine cmdarg, uptolow
C
C CALLS: len
C
C OPERATING SYSTEM / PORTABILITY NOTES: portable
C
C DATE: 8/20/88
c
C*******************************************************************************
integer function getlen(string)
character*(*) string
c
c Start with the last character and find the first non-blank
c
do 10 next = len(string), 1, -1
if ((string(next : next) .ne. ' ') .and.
+ (string(next : next) .ne. char(0)) ) then
getlen = next
return
endif
10 continue
c
c All characters are blanks or NULLs
c
getlen=0
return
end
c*****************************************************************************
c SUBROUTINE: getparam
c DATE: 8/09/88
c PURPOSE:
C Given an argument, the subroutine returns the word to the LEFT of
c "=".
c OPERATING SYSTEM / POTABILITY NOTES:
c Written in standard Fortran 77. Compatible on all systems.
c
c EXAMPLE:
c Given the argument "col=1"
c Subroutine will return "col" as the parameter
c CALLED BY:
c triconproc, called by pipe fitting pcons. Code in 'pcons.for'
c CALLS:
C index
c
c ARGUMENTS:
C arg(INPUT)--a string of the format:
c parameter=value1(,value2,...)
c param(OUTPUT)--the string to the left of "="
c
c************************************************************************
subroutine getparam(arg, param)
character*(*) arg
character*(*) param
c Local variable declarations
integer k, index
k = index( arg,'=')
c
c If k=0 return the whole argument, since it's a keyword, else return
c the parameter( the part before the = sign
c
if( k .eq. 0 ) then
param = arg
else
param = arg(1:k-1)
endif
return
end
c**********************************************************************
c SUBROUTINE:
c getnumval
c
c DATE:
c 8/10/88
c
c VERSION:
c
c PROJECT:
c command line processing
c
c PURPOSE:
c returns the number of values, that is, the number of items to the
c right of "=" separated by commas.
c
c OPERATING SYSTEM / PORTABILITY:
c Written in standard Fortran 77. Compatible with all systems.
c
c EXAMPLE:
c arg = 'col=1,2'
c subroutine returns 2
c arg = 'col='
c subroutine prints an error message and stops execution. NO RETURN
c
c CALLED BY:
c cld
c
c CALLS:
c index()
c
c ARGUMENTS:
c arg(INPUT)--a string of the format:
c parameter=value1(,value2,....)
c numval(OUTPUT)--the number of items(separated by comma) to the right
c of "="
c
c**************************************************************************
subroutine getnumval(arg, numval)
character*(*) arg
integer numval
c Local variable declaration
integer index, i, nchar, getlen
numval = 0
nchar = 0
c
c skips to the parameter value to the right of =
c
i = index( arg, '=')
if ( i .eq. 0 ) return
i = i + 1
c write(0,*) 'len of arg=', getlen(arg)
do 20 j = i, getlen(arg)
if ( arg(j:j) .eq.' ' ) then
goto 25
else if( arg(j:j) .eq. ',' .and. nchar .gt. 0) then
numval = numval + 1
nchar = 0
else
nchar = nchar + 1
endif
20 continue
25 if ( nchar .gt. 0 ) then
numval = numval + 1
endif
return
end
C*******************************************************************************
C SUBROUTINE: getcharval
c
C PURPOSE: to get character values(items separated by commas) of a parameter
C
C ARGUMENTS: arg(INPUT) - a string of the format:
c parameter = value1(,value2,...)
C value(OUTPUT) - an array of strings, the character values
C
C EXAMPLE: arg='month=august,april'
c call getcharval(arg, value)
c subroutine will return:
c value(1)='august'
c value(2)='april'
C
C CALLED BY: none
C
C CALLS: index, len
C
C OPERATING SYSTEM / PORTABILITY NOTES: portable
C
C DATE: 8/20/88
c
C*******************************************************************************
subroutine getcharval(arg, value)
character*(*) arg
character*(*) value(*)
c Local Variable declaration
integer i,j,k, index, newval, nval, last
c Skipping to the first value
i = index( arg,'=')
newval = i + 1
last = 0
c Parse the values and put them into value array
nval=1
10 i = index(arg(newval:len(arg)),',' )
c
c To handle exception: the last value is not followed by a comma;
c Last value followed by NULL or space
c
if ( i .eq. 0 ) then
last = 1
i = index( arg(newval:len(arg)), char(0))
if (i .eq. 0) i=index( arg(newval:len(arg)), ' ')
endif
c write(0,*) i,'th char is a comma or NULL or space'
value(nval) = arg(newval:newval+i-2)
newval = newval + i
if ( last .eq. 1 ) goto 20
nval=nval+1
goto 10
20 continue
return
end
C*******************************************************************************
C SUBROUTINE: getintval
c
C PURPOSE: to get integer values(items separated by commas) of a parameter
C
C ARGUMENTS: arg(INPUT) - a string of the format:
c parameter = value1(,value2,...)
C value(OUTPUT) - an array of integers
C
C EXAMPLE: arg='irec=1,3'
c call getintval(arg, value)
c subroutine will return:
c value(1)= 1
c value(2)= 3
C
C CALLED BY: none
C
C CALLS: index, len
C
C OPERATING SYSTEM / PORTABILITY NOTES: portable
C
C DATE: 8/20/88
c
C*******************************************************************************
subroutine getintval(arg, value)
character*(*) arg
integer value(*)
c Local variable declaration
integer i,j,k, newval, nval, last
character*150 temp
c Skipping to the first value
i = index( arg,'=')
newval = i + 1
last = 0
c Parse the values and put them into value array
nval=1
10 i = index(arg(newval:len(arg)),',' )
c
c To handle exception: the last value is not followed by a comma;
c Last value followed by NULL or space
c
if ( i .eq. 0 ) then
last = 1
i = index( arg(newval:len(arg)), char(0))
if (i .eq. 0) i=index( arg(newval:len(arg)), ' ')
endif
c write(0,*) i,'th char is a comma or NULL or space'
temp = arg(newval:newval+i-2)
read(temp,*,err=99) value(nval)
newval = newval + i
if ( last .eq. 1 ) goto 20
nval=nval+1
goto 10
20 continue
return
99 write (0,*) 'COMMAND LINE ERROR: CAN"T PARSE ARGUMENT: ', arg
stop
end
C*******************************************************************************
C SUBROUTINE: getrealval
c
C PURPOSE: to get real values(items separated by commas) of a parameter
C
C ARGUMENTS: arg(INPUT) - a string of the format:
c parameter = value1(,value2,...)
C value(OUTPUT) - an array of strings, the real values
C
C EXAMPLE: arg= 'lat=2.5,56.9'
c call getrealval(arg, value)
c subroutine will return:
c value(1)= 2.5
c value(2)= 56.9
C
C CALLED BY: subroutine triconproc in pipe fitting pcons
C
C CALLS: index, len
C
C OPERATING SYSTEM / PORTABILITY NOTES: portable
C
C DATE: 8/20/88
c
C*******************************************************************************
subroutine getrealval(arg, value)
character*(*) arg
real*8 value(*)
c Local variable declaration
integer i,j,k, newval, nval, last
character*150 temp
c Skipping to the first value
i = index( arg,'=')
c write(0,*) '= is at ', i
newval = i + 1
last = 0
c Parse the values and put them into value array
nval=1
c write(0,*) 'arg=', arg
10 i = index(arg(newval:len(arg)),',' )
c
c To handle exception: the last value is not followed by a comma;
c Last value followed by NULL or space
c
if ( i .eq. 0 ) then
last = 1
i = index( arg(newval:len(arg)), char(0))
if (i .eq. 0) i=index( arg(newval:len(arg)), ' ')
c write(0,*) 'last == 1', 'i==', i
endif
c write(0,*) i,'th char is a comma or NULL or space'
temp = arg(newval:newval+i-2)
read(temp,*,err=99) value(nval)
newval = newval + i
if ( last .eq. 1 ) goto 20
nval=nval+1
goto 10
20 continue
return
99 write (0,*) 'COMMAND LINE ERROR: CAN"T PARSE ARGUMENT: ', arg
stop
end
C*******************************************************************************
C SUBROUTINE: uptolow
c
C PURPOSE: Convert a string to all lower case characters
C
C ARGUMENTS: string (INPUT, OUTPUT) - a null terminated string preferred
C
C EXAMPLE: string='ALL CAPS'
C call uptolow(string)
c string now equals 'all caps'
C
C CALLED BY: cmdget
C
C CALLS: integer functions getlen, ichar
C
C OPERATING SYSTEM / PORTABILITY NOTES: portable
C
C DATE: 8/15/88
c
C*******************************************************************************
subroutine uptolow(string)
character*(*) string
c Local declarations
integer getlen
lenstr = getlen(string)
i=1
10 n = ichar(string(i:i))
if( n .eq. 0 .or. i .gt. lenstr) goto 99
if( n .ge. 65 .and. n .le. 90 ) string(i:i) = char( n + 32)
i=i+1
goto 10
99 continue
return
end
C*******************************************************************************
C FUNCTION: colsproc
c
C PURPOSE: 1. To transform the column names into column numbers by:
c a. look up the column name in the array stitle
c b. if found, the array index of the column name in stitle is
c the column number, and stored in array, colnum
c else an error message is generated, and execution is
c stopped
c
c 2. Return the number of columns there are
c
c 3. In case of error : Output ERROR message to unit 0,
c which is set to be sys$error, and stop execution.
c sys$error = terminal ( interactive )
c = log file ( batch )
c To set unit 0 to sys$error, do:
c $assign sys$error for000
C
C ARGUMENTS: cols (INPUT) - the array of column names
c stitle (INPUT) - array of short names for each column of the
c irtm data, as read from the irtm description
c file, irtm.des
c colnum (OUTPUT) - array of column numbers corresponding to
c the column names in array 'cols'
C
C EXAMPLE: ncol=colsproc(cols,stitle, colnum)
C
c ncol is the number of column names in cols that were found
c in 'stitle', returned by this function
c
C CALLED BY: pcons, pbin2d
C
C CALLS: index
C
C OPERATING SYSTEM / PORTABILITY NOTES: portable
C
C HISTORY:
c 9/01/88 Carol Chang. Created it
c 7/23/89 Carol Chang. Added error checking for erroneous column
c names
c
C*******************************************************************************
integer function colsproc(cols, stitle, colnum)
character*(*) stitle(*)
character*(*) cols(*)
integer colnum(*)
ncol=0
i=1
j=1
c
c-- Done translating all the column in cols, when char(0) is encountered
c-- in cols
c
10 if (index(cols(i), char(0)) .eq. 1) goto 30
c
c-- Error : no match with any of the short column names
c
20 if (index(stitle(j), char(0)) .eq. 1) goto 50
c
c-- Match successful. Continue to the next column name
c
if ( cols(i) .eq. stitle(j)) then
ncol=ncol+1
colnum(ncol) = j
goto 40
endif
j=j+1
goto 20
40 continue
i=i+1
j=1
goto 10
50 continue
write(0,*) 'COLSPROC: ERROR: COLUMN ',
+ cols(i), ' is not a correct column name'
stop
30 continue
colsproc=ncol
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c This file contains all the subroutines which handle the descriptor file.
c The subroutines are :
c rdesfil -- reads a descriptor file
c wdesfil -- outputs a descriptor file
c pdesread -- prepares a descriptor file for reading and then reads it
c pdeswrite-- prepares a descriptor file for writing and then writes it
c adddesline -- add a line to the internal arrays which represent the
c descriptor file
c subdesline -- subtract a line from the internal arrays which represent
c the descriptor file
c
c Please read the documentation preceding each subroutine to understand
c the particular subroutine
c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
C*******************************************************************************
C SUBROUTINE: rdesfil
c
C PURPOSE: To read a descriptor file from any unit, process each line
c of the descriptor file into fields, and store these separate
c fields in separate arrays.
C
C ARGUMENTS: unit (INPUT) - the unit to read from
C count (OUTPUT) - The number of a column corresponding to its
c order in a file record.
c An array of integers gotten from the first
c column of the descriptor file
c
c number (OUTPUT) - The number of repetitions of a column in
c a file record. An array of integers gotten
c from the second column of the descriptor file
c
c type (OUTPUT) - data type of each column of a file record.
c An array of strings gotten from the third column
c of the descriptor file
c
c stitle (OUTPUT) - The short name of each column of a file record.
c An array of strings of length 8 gotten from the
c fourth column of the descriptor file
c
c ltitle (OUTPUT) - The long name of each column of a file record.
c An array of strings of length 32 gotten from
c the fifth column of the descriptor file
c
c units (OUTPUT) - The proper measuring units to use for each
c column of a file record. An array of strings
c gotten from the sixth column of the descriptor
c file
c
c format (OUTPUT) - The recommended format for each column of
c a file record. An array of strings gotten
c from the seventh column of the descriptor file
c
c recl (OUTPUT) - The size of a record described by the given
c descriptor file in longwords(4 byte)
c
c nlines (OUTPUT) - The number of lines in the descriptor file
c
C EXAMPLE:
C
C CALLED BY: all pipes except pirtm and pirtm2
C
C CALLS: index
C
C OPERATING SYSTEM / PORTABILITY NOTES: portable
C
C HISTORY: 8/30/88 Carol Chang. Created it
c 9/30/89 Carol Chang. Changed rdesfil to read from any unit,
c leaving the unit-file association, opening of file
c to the higher level routine, preprdes
c
c 6/20/90 Carol Chang. Changed the stopping condition for
c read from EOF to count(irec)=-1 in order to
c make reading descriptor file through the UNIX pipes
c possible on THESUN.
c
c
C*******************************************************************************
subroutine rdesfil(unit, header,stitle,ltitle,
+ nlines)
character*(*) ltitle(*),header
character*(*) stitle(*)
integer unit, nlines
c
c Skip the heading in .des file
c
irec = 1
if (unit .ne. 5 ) then
read(unit,*) header
110 read(unit,*,end=9)
+ stitle(irec),ltitle(irec)
irec=irec+1
goto 110
else
read (unit,*) header
120 read(5,*)
+ stitle(irec),ltitle(irec)
if ( stitle(irec).eq.'end') goto 9
c write(0,*) 'irec=', irec
irec=irec+1
goto 120
endif
9 continue
c
c Mark the end in all the arrays
c
100 nlines = irec-1
c
c Calculate record length
c
c recl=nlines
c write (0,*) 'rdesfil recl,nlines,irec',recl,nlines,irec
return
end
C*******************************************************************************
C SUBROUTINE: wdesfil
c
C PURPOSE: To write the descriptor file to any unit. The descriptor
c file is passed to the subroutine as arrays. These arrays
c are written out using the format consistent with the read
c format in subroutine RDESFIL.
C
C ARGUMENTS: unit (INPUT) - the unit to write to
C count (INPUT) - The number of a column corresponding to its
c order in a file record.
c An array of integers gotten from the first
c column of the descriptor file
c
c number (INPUT) - The number of repetitions of a column in
c a file record. An array of integers gotten
c from the second column of the descriptor file
c
c type (INPUT) - data type of each column of a file record.
c An array of strings gotten from the third column
c of the descriptor file
c
c stitle (INPUT) - The short name of each column of a file record.
c An array of strings of length 8 gotten from the
c fourth column of the descriptor file
c
c ltitle (INPUT) - The long name of each column of a file record.
c An array of strings of length 32 gotten from
c the fifth column of the descriptor file
c
c units (INPUT) - The proper measuring units to use for each
c column of a file record. An array of strings
c gotten from the sixth column of the descriptor file
c
c format (INPUT) - The recommended format for each column of
c a file record. An array of strings gotten
c from the seventh column of the descriptor file
c
c nlines (INPUT) - The number of lines in the descriptor file
c
c
C EXAMPLE:
C
C CALLED BY: all pipes except pirtm and pirtm2
C
C CALLS: index
C
C OPERATING SYSTEM / PORTABILITY NOTES: portable
C
C HISTORY: 9/30/88 Carol Chang. Created it
c 6/20/90 Carol Chang.
c Changed the way of indicating EOF from an end-of-file
c marker using FORTRAN endfile statement to outputing
c a -1 for the count field of the line after the last
c line of the file.
c
c
c
c
C*******************************************************************************
subroutine wdesfil(unit, header, stitle,ltitle,nlines)
character*(*) ltitle(*)
character*(*) header
character*(*) stitle(*)
integer unit, nlines
c
c Write each line of the descriptor file to the unit specified
c
write (unit,*) "'",header,"'"
do 10 irec=1,nlines
write(unit,*) "'",stitle(irec),"'",' ',
& "'",ltitle(irec),"'"
10 continue
return
end
C*******************************************************************************
C SUBROUTINE: preprdes
c
C PURPOSE: To read a descriptor file from a unit
C
C ARGUMENTS: unit (INPUT) - the unit to read from
c des ( INPUT ) - the name of the descriptor file
C count (OUTPUT) - The number of a column corresponding to its
c order in a file record.
c An array of integers gotten from the first
c column of the descriptor file
c
c number (OUTPUT) - The number of repetitions of a column in
c a file record. An array of integers gotten
c from the second column of the descriptor file
c
c type (OUTPUT) - data type of each column of a file record.
c An array of strings gotten from the third column
c of the descriptor file
c
c stitle (OUTPUT) - The short name of each column of a file record.
c An array of strings of length 8 gotten from the
c fourth column of the descriptor file
c
c ltitle (OUTPUT) - The long name of each column of a file record.
c An array of strings of length 32 gotten from
c the fifth column of the descriptor file
c
c units (OUTPUT) - The proper measuring units to use for each
c column of a file record. An array of strings
c gotten from the sixth column of the descriptor
c file
c
c format (OUTPUT) - The recommended format for each column of
c a file record. An array of strings gotten
c from the seventh column of the descriptor file
c
c recl (OUTPUT) - The size( in longwords ) of the record described
c by the descriptor file
c
c nlines (OUTPUT) - The number of lines in the descriptor file
C EXAMPLE:
C
C CALLED BY: all pipes except pirtm and pirtm2
C
C CALLS: index
C
C OPERATING SYSTEM / PORTABILITY NOTES: portable
C
C HISTORY: 9/30/89 Carol Chang. Created it
c
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine pdesread(unit, des, header,stitle,ltitle,
& nlines)
character*(*) des
character*(*) header
character*(*) ltitle(*)
character*(*) stitle(*)
integer nlines, unit, recl
c
c Append '.des' to <des> to form the name of the description file to open
c
if( unit .ne. 5 ) then
call openform(unit, des, 'old')
endif
c
c Read the descriptor file
c
call rdesfil(unit, header,stitle, ltitle,
+ nlines)
c write(0,*) 'PREPRDES: nlines=', nlines
if (unit .ne. 5 ) then
close( unit, err=999 )
endif
999 return
end
C*******************************************************************************
C SUBROUTINE: pdeswrite
c
C PURPOSE: To associate the descriptor file with a unit, and open the
c unit for writing
C
C ARGUMENTS: unit (INPUT) - the unit to write to
c des ( INPUT ) - the name of the descriptor file
C count (INPUT) - The number of a column corresponding to its
c order in a file record.
c An array of integers gotten from the first
c column of the descriptor file
c
c number (INPUT) - The number of repetitions of a column in
c a file record. An array of integers gotten
c from the second column of the descriptor file
c
c type (INPUT) - data type of each column of a file record.
c An array of strings gotten from the third column
c of the descriptor file
c
c stitle (INPUT) - The short name of each column of a file record.
c An array of strings of length 8 gotten from the
c fourth column of the descriptor file
c
c ltitle (INPUT) - The long name of each column of a file record.
c An array of strings of length 32 gotten from
c the fifth column of the descriptor file
c
c units (INPUT) - The proper measuring units to use for each
c column of a file record. An array of strings
c gotten from the sixth column of the descriptor
c file
c
c format (INPUT) - The recommended format for each column of
c a file record. An array of strings gotten
c from the seventh column of the descriptor file
c
c nlines (INPUT) - The number of lines in the descriptor file
c
C EXAMPLE:
C
C CALLED BY: all pipes except pirtm and pirtm2
C
C CALLS: index
C
C OPERATING SYSTEM / PORTABILITY NOTES: portable
c
C HISTORY :
c 9/15/89 Carol Chang. Created it.
C*******************************************************************************
subroutine pdeswrite(unit, des,header,stitle,ltitle,
& nlines)
character*(*) des
character*(*) ltitle(*)
character*(*) stitle(*)
character*(*) header
integer nlines, unit
c
c Append '.des' to <des> to form the name of the description file to open
c
if( unit .ne. 6 ) then
c open(unit=unit, file=outfil, status='new')
call openform(unit, des, 'new')
endif
c
c Output the descriptor file
c
call wdesfil(unit, header, stitle, ltitle,
+ nlines)
if( unit .eq. 6 ) then
write(6,*) "'",'end',"'",' ',"'",'end',"'"
else
close( unit )
endif
999 return
end
c*************************************************************************
C*******************************************************************************
C SUBROUTINE: adddesline
c
C PURPOSE: To add a line( a new field ) to a descriptor file in memory
c ( not physically alter content of the file )
C
C ARGUMENTS: pos(INPUT) -- the line which this new line is to become
c i.e. 8 -- the line to be added will be the
c 8th line
C newcount (INPUT) - The number of a column corresponding to its
c order in a file record.
c
c newnumber (INPUT) - The number of repetitions of a column in
c a file record.
c
c newtype (INPUT) - data type of each column of a file record.
c
c newstitle (INPUT) - The short name of each column of a file record.
c
c newltitle (INPUT) - The long name of each column of a file record.
c
c newunits (INPUT) - The proper measuring units to use for each
c column of a file record.
c
c newformat (INPUT) - The recommended format for each column of
c a file record.
c
C count (OUTPUT) - The number of a column corresponding to its
c order in a file record.
c An array of integers gotten from the first
c column of the descriptor file
c
c number (OUTPUT) - The number of repetitions of a column in
c a file record. An array of integers gotten
c from the second column of the descriptor file
c
c type (OUTPUT) - data type of each column of a file record.
c An array of strings gotten from the third column
c of the descriptor file
c
c stitle (OUTPUT) - The short name of each column of a file record.
c An array of strings of length 8 gotten from the
c fourth column of the descriptor file
c
c ltitle (OUTPUT) - The long name of each column of a file record.
c An array of strings of length 32 gotten from
c the fifth column of the descriptor file
c
c units (OUTPUT) - The proper measuring units to use for each
c column of a file record. An array of strings
c gotten from the sixth column of the descriptor file
c
c format (OUTPUT) - The recommended format for each column of
c a file record. An array of strings gotten
c from the seventh column of the descriptor file
c
c nlines (OUTPUT) - The number of lines in the descriptor file
C
C EXAMPLE: To add a line to the descriptor file, irtm15.des passed
c to the next pipe, do:
c call pdesread(7, 'irtm15', count, number, type, stitle, ltitle,
c & units,format, recl, nlines)
c
c call adddesline( nlines+1, nlines+1, 1, 'r*4', 'sxpol', ' ', ' ',
c + ' ', count, number, type, stitle, ltitle,
c + units, format, nlines)
c call pdeswrite(6, des, count, number, type, stitle, ltitle,
c & units,format, nlines)
c
C CALLED BY: spxy
C
C CALLS:
C
C OPERATING SYSTEM / PORTABILITY NOTES: completely portable
C
C HISTORY:
c 9/15/89 Carol Chang. Created it.
c
C*******************************************************************************
subroutine adddesline(pos, newstitle,
+ newltitle, header,stitle, ltitle,
+ nlines)
c
c Parameters to pass in fields of the line to be added
c
character*(*) newltitle
character*(*) newstitle
integer newcount, newnumber, pos
c
c Parameters to pass in the arrays containing columns of the old des file
c
character*(*) ltitle(*)
character*(*) header, stitle(*)
integer nlines
c
c Local Variables
c
integer tline
c
c Validate the line number
c
if( pos .lt. 1) then
write(0,*) 'ADDDESLINE : line number must be >= 1'
stop
endif
if( pos .gt. nlines + 1 ) then
write(0,*) 'ADDDESLINE : line number exceeded file size range'
stop
endif
c
c Shift everything down 1 to enable the addition of this line
c
tline = nlines + 1
20 if( tline .eq. pos ) then
goto 21
else
stitle(tline) = stitle(tline -1)
ltitle(tline) = ltitle(tline -1)
tline = tline - 1
goto 20
endif
21 continue
c
c Insert the line to be added at line # pos
c
stitle(pos) = newstitle
ltitle(pos) = newltitle