forked from lesgo-jhu/lesgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
string_util.f90
870 lines (665 loc) · 25 KB
/
string_util.f90
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
!!
!! Copyright (C) 2009-2017 Johns Hopkins University
!!
!! This file is part of lesgo.
!!
!! lesgo is free software: you can redistribute it and/or modify
!! it under the terms of the GNU General Public License as published by
!! the Free Software Foundation, either version 3 of the License, or
!! (at your option) any later version.
!!
!! lesgo is distributed in the hope that it will be useful,
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!! GNU General Public License for more details.
!!
!! You should have received a copy of the GNU General Public License
!! along with lesgo. If not, see <http://www.gnu.org/licenses/>.
!!
!*******************************************************************************
module string_util
!*******************************************************************************
!
! This module contains the generic subroutines and functions for
! manipulating strings
!
implicit none
save
private
public :: string_concat, string_splice, numtostr, eat_whitespace, uppercase, &
split_string, count_string_occur
! Concatenates the string. By default eats all trailing whitespace
interface string_concat
module procedure string_concat_a, string_concat_i, string_concat_r, &
string_concat_ai, string_concat_ar, string_concat_aia, &
string_concat_ara, string_concat_aiai, string_concat_arar, &
string_concat_aiaia, string_concat_arara, string_concat_arai, &
string_concat_araia, string_concat_aiaiai, string_concat_ararar, &
string_concat_aiaiaia, string_concat_ararara
end interface
interface string_splice
module procedure string_splice_aa, string_splice_ai, string_splice_ar, &
string_splice_aia, string_splice_ara, string_splice_aiai, &
string_splice_arar, string_splice_aiaia, string_splice_arara, &
string_splice_araia, string_splice_arai, string_splice_aiaiai, &
string_splice_ararar, string_splice_aiaiaia, string_splice_ararara
end interface string_splice
! Explicit interface for overloaded function to convert
! reals and integer to strings
interface numtostr
module procedure numtostr_r, numtostr_i
end interface
character(*), parameter :: mod_name = 'string_util'
character(*), parameter :: iformat='(i0)'
character(*), parameter :: rformat='(f18.5)'
integer, parameter :: BUFF_LENGTH = 64
contains
!*******************************************************************************
function numtostr_r( a, n ) result(c)
!*******************************************************************************
!
! This function converts the real variable a to a string b
!
! Inputs
! a : real, scalar value to convert
! n : length of string to return
!
use types, only : rprec
implicit none
real(rprec), intent(in) :: a
integer, intent(in) :: n
integer, parameter :: l=2*kind(a)+2
character(l) :: b
character(n) :: c
character(25) :: fmt
write(*,*) 'a : ', a
write(fmt, '("(f",i0,".",i0,")")' ) l, l/2
write(*,*) 'fmt : ', fmt
write(b,fmt) a
write(*,*) 'b : ', b
b = trim(adjustl(b))
c = b(:n)
write(*,*) 'c : ', c
end function numtostr_r
!*******************************************************************************
function numtostr_i( a, n ) result(c)
!*******************************************************************************
!
! This function converts the real variable a to a string b
!
! Inputs
! a : real, scalar value to convert
! n : length of string to return
!
implicit none
integer, intent(in) :: a
integer, intent(in) :: n
integer, parameter :: l = 2*kind(a)+2
character(l) :: b
character(n) :: c
write(b,'(i0)') a
b = adjustl(b)
c = b(:n)
end function numtostr_i
!*******************************************************************************
subroutine eat_whitespace (buff, whtspc)
!*******************************************************************************
!
! eats leading and intermediate whitespace, fill trailing space with
! blanks
!
implicit none
character(*), intent(inout) :: buff
character(*), intent(in), optional :: whtspc !--override default
character(*), parameter :: whtspc_default = achar (9) // achar (32)
!--add more characters here if needed
character (1), parameter :: fill_char = ' '
character (1) :: tmp (len (buff))
character (1) :: fill (len (buff))
fill = fill_char
tmp = transfer (buff, tmp)
if (present (whtspc)) then
tmp = pack (tmp, scan (tmp, whtspc) == 0, fill)
else
tmp = pack (tmp, scan (tmp, whtspc_default) == 0, fill)
end if
buff = transfer (tmp, buff)
end subroutine eat_whitespace
!*******************************************************************************
function uppercase(str) result(ucstr)
!*******************************************************************************
!
! convert specified string to upper case
!
character(*):: str
character(len_trim(str)):: ucstr
integer :: i, ilen, iav, ioffset, iqc, iquote
ilen = len_trim(str)
ioffset = iachar('A')-iachar('a')
iquote = 0
ucstr = str
do i = 1, ilen
iav = iachar(str(i:i))
if(iquote==0 .and. (iav==34 .or.iav==39)) then
iquote = 1
iqc = iav
cycle
end if
if(iquote==1 .and. iav==iqc) then
iquote = 0
cycle
end if
if (iquote==1) cycle
if(iav >= iachar('a') .and. iav <= iachar('z')) then
ucstr(i:i) = achar(iav+ioffset)
else
ucstr(i:i) = str(i:i)
end if
end do
end function uppercase
!*******************************************************************************
subroutine split_string( string, delim, nseg, sarray )
!*******************************************************************************
!
! This subroutine splits 'string' based on the specified delimiter
! 'delim'. The number of segments 'nseg' is determined from the string
! based on the delimiter. The output string vector 'sarray' is allocated
! in this subroutine.
!
use param, only : CHAR_BUFF_LENGTH
use messages
implicit none
character(*), parameter :: sub_name = mod_name // '.split_string'
character(*), intent(in) :: string, delim
integer, intent(out) :: nseg
character(CHAR_BUFF_LENGTH), allocatable, dimension(:), intent(inout) :: sarray
! String buffers (assuming length)
character(1024) :: buff_old, buff
integer :: pos, istop, n
! Length of the delimiter
integer :: delim_len
! Get the length of the delimiter (excluding trailing whitespace)
delim_len = len_trim(delim)
! First make sure string is not empty
if( len_trim(string) == 0 ) call error( sub_name, 'specified string is empty')
! Get the number of segments based on the delimiter count
nseg = count_string_occur (string, delim) + 1
! Now allocate string vector
allocate(sarray(nseg))
! Initialize position of delimiter (rewind a bit)
pos = -delim_len+1
! Initialize stop flag
istop = 0
! Initialize string buffer
buff = string
n = 0
do
n = n + 1
! If there are more segments than what is expected stop searching
if( n > nseg ) exit
! Save old buffer
buff_old = buff
! New buffer starts after first delimiter position of old buffer
buff = trim( adjustl( buff_old(pos+delim_len:) ) )
! Get the position of the first delmiter in the new buffer
pos = index( buff, delim )
if( pos > 0 ) then
sarray(n) = buff(:pos-1)
else
! Assuming this is the last segment
sarray(n) = trim( adjustl( buff ) )
exit
endif
end do
if( n < nseg ) then
call error( sub_name, 'number of found segments less than specified number')
elseif( n > nseg ) then
call error( sub_name, &
'number of found segments greater than specified number')
endif
end subroutine split_string
!*******************************************************************************
function count_string_occur (string, substring, overlap) result( countocc )
!*******************************************************************************
!
! This function counts the number of occurences of 'substring' in
! 'string' --does not count occurence to overlap, e.g. eee is 1 occurence
! of ee, *unless* optional argument overlap = 'yes', then its 2
implicit none
integer :: countocc
character(*), intent(in) :: string, substring
logical, intent(in), optional :: overlap
integer :: i, p, m
m = len (substring) - 1
if (present (overlap)) then
if (overlap) m = 0
end if
countocc = 0
i = index (string, substring)
p = 1
do while (i /= 0)
countocc = countocc + 1
p = p + i + m
i = index (string(p:), substring)
end do
end function count_string_occur
!///////////////////////////////////////////////////////////////////////////////
!/// STRING_CONCAT
!///////////////////////////////////////////////////////////////////////////////
!*******************************************************************************
subroutine string_concat_a(str, str1)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1
str = trim(adjustl(str)) // trim(adjustl(str1))
end subroutine string_concat_a
!*******************************************************************************
subroutine string_concat_r(str, r)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
real(rprec), intent(in) :: r
character(BUFF_LENGTH) :: buff
write(buff,rformat) r
call string_concat( str, buff )
end subroutine string_concat_r
!*******************************************************************************
subroutine string_concat_i(str, i)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
integer, intent(in) :: i
character(BUFF_LENGTH) :: buff
write(buff,iformat) i
call string_concat( str, buff )
end subroutine string_concat_i
!*******************************************************************************
subroutine string_concat_ai(str, str1, i1)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1
integer, intent(in) :: i1
call string_concat(str,str1)
call string_concat(str,i1)
end subroutine string_concat_ai
!*******************************************************************************
subroutine string_concat_ar(str, str1, r1)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1
real(rprec), intent(in) :: r1
call string_concat(str,str1)
call string_concat(str,r1)
end subroutine string_concat_ar
!*******************************************************************************
subroutine string_concat_aia(str, str1, i1, str2)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2
integer, intent(in) :: i1
call string_concat(str,str1)
call string_concat(str,i1)
call string_concat(str,str2)
end subroutine string_concat_aia
!*******************************************************************************
subroutine string_concat_ara(str, str1, r1, str2)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2
real(rprec), intent(in) :: r1
call string_concat(str,str1)
call string_concat(str,r1)
call string_concat(str,str2)
end subroutine string_concat_ara
!*******************************************************************************
subroutine string_concat_aiaia(str, str1, i1, str2, i2, str3)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2, str3
integer, intent(in) :: i1, i2
call string_concat(str,str1)
call string_concat(str,i1)
call string_concat(str,str2)
call string_concat(str,i2)
call string_concat(str,str3)
end subroutine string_concat_aiaia
!*******************************************************************************
subroutine string_concat_arara(str, str1, r1, str2, r2, str3)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2, str3
real(rprec), intent(in) :: r1, r2
call string_concat(str,str1)
call string_concat(str,r1)
call string_concat(str,str2)
call string_concat(str,r2)
call string_concat(str,str3)
end subroutine string_concat_arara
!*******************************************************************************
subroutine string_concat_aiai(str, str1, i1, str2, i2)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2
integer, intent(in) :: i1, i2
call string_concat(str,str1)
call string_concat(str,i1)
call string_concat(str,str2)
call string_concat(str,i2)
end subroutine string_concat_aiai
!*******************************************************************************
subroutine string_concat_arar(str, str1, r1, str2, r2 )
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2
real(rprec), intent(in) :: r1, r2
call string_concat(str,str1)
call string_concat(str,r1)
call string_concat(str,str2)
call string_concat(str,r2)
end subroutine string_concat_arar
!*******************************************************************************
subroutine string_concat_araia(str, str1, r1, str2, i1, str3)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2, str3
real(rprec) :: r1
integer, intent(in) :: i1
call string_concat(str,str1)
call string_concat(str,r1)
call string_concat(str,str2)
call string_concat(str,i1)
call string_concat(str,str3)
end subroutine string_concat_araia
!*******************************************************************************
subroutine string_concat_arai(str, str1, r1, str2, i1)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2
real(rprec) :: r1
integer, intent(in) :: i1
call string_concat(str,str1)
call string_concat(str,r1)
call string_concat(str,str2)
call string_concat(str,i1)
end subroutine string_concat_arai
!*******************************************************************************
subroutine string_concat_aiaiai(str, str1, i1, str2, i2, str3, i3)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2, str3
integer, intent(in) :: i1, i2, i3
call string_concat(str,str1)
call string_concat(str,i1)
call string_concat(str,str2)
call string_concat(str,i2)
call string_concat(str,str3)
call string_concat(str,i3)
end subroutine string_concat_aiaiai
!*******************************************************************************
subroutine string_concat_ararar(str, str1, r1, str2, r2, str3, r3 )
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2, str3
real(rprec), intent(in) :: r1, r2, r3
call string_concat(str,str1)
call string_concat(str,r1)
call string_concat(str,str2)
call string_concat(str,r2)
call string_concat(str,str3)
call string_concat(str,r3)
end subroutine string_concat_ararar
!*******************************************************************************
subroutine string_concat_aiaiaia(str, str1, i1, str2, i2, str3, i3, str4)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2, str3, str4
integer, intent(in) :: i1, i2, i3
call string_concat(str,str1)
call string_concat(str,i1)
call string_concat(str,str2)
call string_concat(str,i2)
call string_concat(str,str3)
call string_concat(str,i3)
call string_concat(str,str4)
end subroutine string_concat_aiaiaia
!*******************************************************************************
subroutine string_concat_ararara(str, str1, r1, str2, r2, str3, r3, str4)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: str
character(*), intent(in) :: str1, str2, str3, str4
real(rprec), intent(in) :: r1, r2, r3
call string_concat(str,str1)
call string_concat(str,r1)
call string_concat(str,str2)
call string_concat(str,r2)
call string_concat(str,str3)
call string_concat(str,r3)
call string_concat(str,str4)
end subroutine string_concat_ararara
!///////////////////////////////////////////////////////////////////////////////
!/// STRING_SPLICE
!///////////////////////////////////////////////////////////////////////////////
!*******************************************************************************
subroutine string_splice_aa( s, s1, s2 )
!*******************************************************************************
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2
s = s1 // s2
end subroutine string_splice_aa
!*******************************************************************************
subroutine string_splice_ar(s, s1, r1)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1
real(rprec), intent(in) :: r1
character(BUFF_LENGTH) :: b1
write(b1,rformat) r1
!call string_splice(s, s1, trim(adjustl(buff)) )
s = s1 // trim(adjustl(b1))
end subroutine string_splice_ar
!*******************************************************************************
subroutine string_splice_ai(s, s1, i1)
!*******************************************************************************
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1
integer, intent(in) :: i1
character(BUFF_LENGTH) :: b1
write(b1,iformat) i1
!call string_splice(s, s1, trim(adjustl(adjustl(b)))
s = s1 // trim(adjustl(b1))
end subroutine string_splice_ai
!*******************************************************************************
subroutine string_splice_aia(s, s1, i1, s2 )
!*******************************************************************************
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2
integer, intent(in) :: i1
character(BUFF_LENGTH) :: b1
write(b1,iformat) i1
s = s1 // trim(adjustl(b1)) // s2
end subroutine string_splice_aia
!*******************************************************************************
subroutine string_splice_ara(s, s1, r1, s2 )
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2
real(rprec), intent(in) :: r1
character(BUFF_LENGTH) :: b1
write(b1,rformat) r1
s = s1 // trim(adjustl(b1)) // s2
end subroutine string_splice_ara
!*******************************************************************************
subroutine string_splice_aiai(s, s1, i1, s2, i2 )
!*******************************************************************************
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2
integer, intent(in) :: i1, i2
character(BUFF_LENGTH) :: b1, b2
write(b1,iformat) i1
write(b2,iformat) i2
s = s1 // trim(adjustl(b1)) // s2 // trim(adjustl(b2))
end subroutine string_splice_aiai
!*******************************************************************************
subroutine string_splice_arar(s, s1, r1, s2, r2 )
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2
real(rprec), intent(in) :: r1, r2
character(BUFF_LENGTH) :: b1, b2
write(b1,rformat) r1
write(b2,rformat) r2
s = s1 // trim(adjustl(b1)) // s2 // trim(adjustl(b2))
end subroutine string_splice_arar
!*******************************************************************************
subroutine string_splice_aiaia(s, s1, i1, s2, i2, s3 )
!*******************************************************************************
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2, s3
integer, intent(in) :: i1, i2
character(BUFF_LENGTH) :: b1, b2
write(b1,iformat) i1
write(b2,iformat) i2
s = s1 // trim(adjustl(b1)) // s2 // trim(adjustl(b2)) // s3
end subroutine string_splice_aiaia
!*******************************************************************************
subroutine string_splice_arara(s, s1, r1, s2, r2, s3 )
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2, s3
real(rprec), intent(in) :: r1, r2
character(BUFF_LENGTH) :: b1, b2
write(b1,rformat) r1
write(b2,rformat) r2
s = s1 // trim(adjustl(b1)) // s2 // trim(adjustl(b2)) // s3
end subroutine string_splice_arara
!*******************************************************************************
subroutine string_splice_araia(s, s1, r1, s2, i2, s3 )
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2, s3
real(rprec), intent(in) :: r1
integer, intent(in) :: i2
character(BUFF_LENGTH) :: b1, b2
write(b1,rformat) r1
write(b2,iformat) i2
s = s1 // trim(adjustl(b1)) // s2 // trim(adjustl(b2)) // s3
end subroutine string_splice_araia
!*******************************************************************************
subroutine string_splice_arai(s, s1, r1, s2, i2)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2
real(rprec), intent(in) :: r1
integer, intent(in) :: i2
character(BUFF_LENGTH) :: b1, b2
write(b1,rformat) r1
write(b2,iformat) i2
s = s1 // trim(adjustl(b1)) // s2 // trim(adjustl(b2))
end subroutine string_splice_arai
!*******************************************************************************
subroutine string_splice_aiaiai(s, s1, i1, s2, i2, s3, i3)
!*******************************************************************************
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2, s3
integer, intent(in) :: i1, i2, i3
character(BUFF_LENGTH) :: b1, b2, b3
write(b1,iformat) i1
write(b2,iformat) i2
write(b3,iformat) i3
s = s1 // trim(adjustl(b1)) // s2 // trim(adjustl(b2)) // s3 // trim(adjustl(b3))
end subroutine string_splice_aiaiai
!*******************************************************************************
subroutine string_splice_ararar(s, s1, r1, s2, r2, s3, r3)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2, s3
real(rprec), intent(in) :: r1, r2, r3
character(BUFF_LENGTH) :: b1, b2, b3
write(b1,rformat) r1
write(b2,rformat) r2
write(b3,rformat) r3
s = s1 // trim(adjustl(b1)) // s2 // trim(adjustl(b2)) // s3 // &
trim(adjustl(b3))
end subroutine string_splice_ararar
!*******************************************************************************
subroutine string_splice_aiaiaia(s, s1, i1, s2, i2, s3, i3, s4)
!*******************************************************************************
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2, s3, s4
integer, intent(in) :: i1, i2, i3
character(BUFF_LENGTH) :: b1, b2, b3
write(b1,iformat) i1
write(b2,iformat) i2
write(b3,iformat) i3
s = s1 // trim(adjustl(b1)) // s2 // trim(adjustl(b2)) // s3 // &
trim(adjustl(b3)) // s4
end subroutine string_splice_aiaiaia
!*******************************************************************************
subroutine string_splice_ararara(s, s1, r1, s2, r2, s3, r3, s4)
!*******************************************************************************
use types, only : rprec
implicit none
character(*), intent(inout) :: s
character(*), intent(in) :: s1, s2, s3, s4
real(rprec), intent(in) :: r1, r2, r3
character(BUFF_LENGTH) :: b1, b2, b3
write(b1,rformat) r1
write(b2,rformat) r2
write(b3,rformat) r3
s = s1 // trim(adjustl(b1)) // s2 // trim(adjustl(b2)) // s3 // &
trim(adjustl(b3)) // s4
end subroutine string_splice_ararara
end module string_util