OpenCMISS-Iron Internal API Documentation
strings.f90
Go to the documentation of this file.
1 
43 
45 MODULE strings
46 
47  USE base_routines
48  USE constants
49  USE kinds
51 
52 #include "macros.h"
53 
54  IMPLICIT NONE
55 
56  PRIVATE
57 
58  !Module parameters
59 
60  !Module types
61 
62  !Interfaces
63 
66  MODULE PROCEDURE character_to_lowercase_c
67  MODULE PROCEDURE character_to_lowercase_vs
68  END INTERFACE character_to_lowercase
69 
72  MODULE PROCEDURE character_to_lowercase_c
73  MODULE PROCEDURE character_to_lowercase_vs
74  END INTERFACE charactertolowercase
75 
78  MODULE PROCEDURE character_to_uppercase_c
79  MODULE PROCEDURE character_to_uppercase_vs
80  END INTERFACE character_to_uppercase
81 
84  MODULE PROCEDURE character_to_uppercase_c
85  MODULE PROCEDURE character_to_uppercase_vs
86  END INTERFACE charactertouppercase
87 
89  INTERFACE is_abbreviation
90  MODULE PROCEDURE is_abbreviation_c_c
91  MODULE PROCEDURE is_abbreviation_c_vs
92  MODULE PROCEDURE is_abbreviation_vs_c
93  MODULE PROCEDURE is_abbreviation_vs_vs
94  END INTERFACE is_abbreviation
95 
97  INTERFACE isabbreviation
98  MODULE PROCEDURE is_abbreviation_c_c
99  MODULE PROCEDURE is_abbreviation_c_vs
100  MODULE PROCEDURE is_abbreviation_vs_c
101  MODULE PROCEDURE is_abbreviation_vs_vs
102  END INTERFACE isabbreviation
103 
104  INTERFACE isdigit
105  MODULE PROCEDURE is_digit
106  END INTERFACE isdigit
107 
108  INTERFACE isletter
109  MODULE PROCEDURE is_letter
110  END INTERFACE isletter
111 
112  INTERFACE iswhitespace
113  MODULE PROCEDURE is_whitespace
114  END INTERFACE iswhitespace
115 
118  MODULE PROCEDURE list_to_character_c
119  MODULE PROCEDURE list_to_character_intg
120  MODULE PROCEDURE list_to_character_lintg
121  MODULE PROCEDURE list_to_character_l
122  MODULE PROCEDURE list_to_character_sp
123  MODULE PROCEDURE list_to_character_dp
124  END INTERFACE list_to_character
125 
127  INTERFACE listtocharacter
128  MODULE PROCEDURE list_to_character_c
129  MODULE PROCEDURE list_to_character_intg
130  MODULE PROCEDURE list_to_character_lintg
131  MODULE PROCEDURE list_to_character_l
132  MODULE PROCEDURE list_to_character_sp
133  MODULE PROCEDURE list_to_character_dp
134  END INTERFACE listtocharacter
135 
137  MODULE PROCEDURE logical_to_character
138  END INTERFACE logicaltocharacter
139 
141  MODULE PROCEDURE logical_to_vstring
142  END INTERFACE logicaltovstring
143 
146  MODULE PROCEDURE number_to_character_intg
147  MODULE PROCEDURE number_to_character_lintg
148  MODULE PROCEDURE number_to_character_sp
149  MODULE PROCEDURE number_to_character_dp
150  END INTERFACE number_to_character
151 
154  MODULE PROCEDURE number_to_character_intg
155  MODULE PROCEDURE number_to_character_lintg
156  MODULE PROCEDURE number_to_character_sp
157  MODULE PROCEDURE number_to_character_dp
158  END INTERFACE numbertocharacter
159 
162  MODULE PROCEDURE number_to_vstring_intg
163  MODULE PROCEDURE number_to_vstring_lintg
164  MODULE PROCEDURE number_to_vstring_sp
165  MODULE PROCEDURE number_to_vstring_dp
166  END INTERFACE number_to_vstring
167 
168  !Provided to allow conversion to new code style
169  INTERFACE numbertovstring
170  MODULE PROCEDURE number_to_vstring_intg
171  MODULE PROCEDURE number_to_vstring_lintg
172  MODULE PROCEDURE number_to_vstring_sp
173  MODULE PROCEDURE number_to_vstring_dp
174  END INTERFACE numbertovstring
175 
178  MODULE PROCEDURE string_to_double_c
179  MODULE PROCEDURE string_to_double_vs
180  END INTERFACE string_to_double
181 
183  INTERFACE stringtodouble
184  MODULE PROCEDURE string_to_double_c
185  MODULE PROCEDURE string_to_double_vs
186  END INTERFACE stringtodouble
187 
190  MODULE PROCEDURE string_to_integer_c
191  MODULE PROCEDURE string_to_integer_vs
192  END INTERFACE string_to_integer
193 
195  INTERFACE stringtointeger
196  MODULE PROCEDURE string_to_integer_c
197  MODULE PROCEDURE string_to_integer_vs
198  END INTERFACE stringtointeger
199 
202  MODULE PROCEDURE string_to_long_integer_c
203  MODULE PROCEDURE string_to_long_integer_vs
204  END INTERFACE string_to_long_integer
205 
208  MODULE PROCEDURE string_to_long_integer_c
209  MODULE PROCEDURE string_to_long_integer_vs
210  END INTERFACE stringtolonginteger
211 
214  MODULE PROCEDURE string_to_logical_c
215  MODULE PROCEDURE string_to_logical_vs
216  END INTERFACE string_to_logical
217 
219  INTERFACE stringtological
220  MODULE PROCEDURE string_to_logical_c
221  MODULE PROCEDURE string_to_logical_vs
222  END INTERFACE stringtological
223 
226  MODULE PROCEDURE string_to_single_c
227  MODULE PROCEDURE string_to_single_vs
228  END INTERFACE string_to_single
229 
231  INTERFACE stingtosingle
232  MODULE PROCEDURE string_to_single_c
233  MODULE PROCEDURE string_to_single_vs
234  END INTERFACE stingtosingle
235 
238  MODULE PROCEDURE vstring_to_lowercase_c
239  MODULE PROCEDURE vstring_to_lowercase_vs
240  END INTERFACE vstring_to_lowercase
241 
244  MODULE PROCEDURE vstring_to_lowercase_c
245  MODULE PROCEDURE vstring_to_lowercase_vs
246  END INTERFACE vstringtolowercase
247 
250  MODULE PROCEDURE vstring_to_uppercase_c
251  MODULE PROCEDURE vstring_to_uppercase_vs
252  END INTERFACE vstring_to_uppercase
253 
256  MODULE PROCEDURE vstring_to_uppercase_c
257  MODULE PROCEDURE vstring_to_uppercase_vs
258  END INTERFACE vstringtouppercase
259 
261 
263 
265 
267 
268  PUBLIC list_to_character
269 
270  PUBLIC listtocharacter
271 
273 
275 
277 
279 
281 
283 
285 
287 
288 CONTAINS
289 
290  !
291  !================================================================================================================================
292  !
293 
295  FUNCTION is_abbreviation_c_c(SHORT,LONG,MIN_NUM_CHARACTERS)
297  !Argument variables
298  CHARACTER(LEN=*), INTENT(IN) :: SHORT
299  CHARACTER(LEN=*), INTENT(IN) :: LONG
300  INTEGER(INTG), INTENT(IN) :: MIN_NUM_CHARACTERS
301  !Function variable
302  LOGICAL :: IS_ABBREVIATION_C_C
303  !Local Variables
304  INTEGER(INTG) :: noch,NUM_CHARACTERS
305  CHARACTER(LEN=LEN(SHORT)) :: UPPER_SHORT
306  CHARACTER(LEN=LEN(LONG)) :: UPPER_LONG
307 
308  is_abbreviation_c_c=.false.
309  upper_short=character_to_uppercase(short)
310  upper_long=character_to_uppercase(long)
311  num_characters=min(len(long),len(short))
312  DO noch=min_num_characters,num_characters
313  IF(upper_short==upper_long(:noch)) THEN
314  is_abbreviation_c_c=.true.
315  EXIT
316  ENDIF
317  ENDDO !noch
318 
319  RETURN
320  END FUNCTION is_abbreviation_c_c
321 
322  !
323  !================================================================================================================================
324  !
325 
327  FUNCTION is_abbreviation_c_vs(SHORT,LONG,MIN_NUM_CHARACTERS)
329  !Argument variables
330  CHARACTER(LEN=*), INTENT(IN) :: SHORT
331  TYPE(varying_string), INTENT(IN) :: LONG
332  INTEGER(INTG), INTENT(IN) :: MIN_NUM_CHARACTERS
333  !Function variable
334  LOGICAL :: IS_ABBREVIATION_C_VS
335  !Local Variables
336  INTEGER(INTG) :: noch,NUM_CHARACTERS
337  CHARACTER(LEN=LEN(SHORT)) :: UPPER_SHORT
338  TYPE(varying_string) :: UPPER_LONG
339 
340  is_abbreviation_c_vs=.false.
341  upper_short=character_to_uppercase(short)
342  upper_long=vstring_to_uppercase(long)
343  num_characters=min(len(long),len(short))
344  DO noch=min_num_characters,num_characters
345  IF(upper_short==extract(upper_long,1,noch)) THEN
346  is_abbreviation_c_vs=.true.
347  EXIT
348  ENDIF
349  ENDDO !noch
350 
351  RETURN
352  END FUNCTION is_abbreviation_c_vs
353 
354  !
355  !================================================================================================================================
356  !
357 
359  FUNCTION is_abbreviation_vs_c(SHORT,LONG,MIN_NUM_CHARACTERS)
361  !Argument variables
362  TYPE(varying_string), INTENT(IN) :: SHORT
363  CHARACTER(LEN=*), INTENT(IN) :: LONG
364  INTEGER(INTG), INTENT(IN) :: MIN_NUM_CHARACTERS
365  !Function variable
366  LOGICAL :: IS_ABBREVIATION_VS_C
367  !Local Variables
368  INTEGER(INTG) :: noch,NUM_CHARACTERS
369  TYPE(varying_string) :: UPPER_SHORT
370  CHARACTER(LEN=LEN(LONG)) :: UPPER_LONG
371 
372  is_abbreviation_vs_c=.false.
373  upper_short=vstring_to_uppercase(short)
374  upper_long=character_to_uppercase(long)
375  num_characters=min(len(long),len(short))
376  DO noch=min_num_characters,num_characters
377  IF(upper_short==upper_long(:noch)) THEN
378  is_abbreviation_vs_c=.true.
379  EXIT
380  ENDIF
381  ENDDO !noch
382 
383  RETURN
384  END FUNCTION is_abbreviation_vs_c
385 
386  !
387  !================================================================================================================================
388  !
389 
391  FUNCTION is_abbreviation_vs_vs(SHORT,LONG,MIN_NUM_CHARACTERS)
393  !Argument variables
394  TYPE(varying_string), INTENT(IN) :: SHORT
395  TYPE(varying_string), INTENT(IN) :: LONG
396  INTEGER(INTG), INTENT(IN) :: MIN_NUM_CHARACTERS
397  !Function variable
398  LOGICAL :: IS_ABBREVIATION_VS_VS
399  !Local Variables
400  INTEGER(INTG) :: noch,NUM_CHARACTERS
401  TYPE(varying_string) :: UPPER_SHORT,UPPER_LONG
402 
403  is_abbreviation_vs_vs=.false.
404  upper_short=vstring_to_uppercase(short)
405  upper_long=vstring_to_uppercase(long)
406  num_characters=min(len(long),len(short))
407  DO noch=min_num_characters,num_characters
408  IF(upper_short==extract(upper_long,1,noch)) THEN
409  is_abbreviation_vs_vs=.true.
410  EXIT
411  ENDIF
412  ENDDO !noch
413 
414  RETURN
415  END FUNCTION is_abbreviation_vs_vs
416 
417  !
418  !================================================================================================================================
419  !
420 
422  FUNCTION is_digit(CHARAC)
424  !Argument variables
425  CHARACTER(LEN=1), INTENT(IN) :: CHARAC
426  !Function variable
427  LOGICAL :: IS_DIGIT
428  !Local Variables
429 
430  is_digit=(ichar(charac)>=ichar("0").AND.ichar(charac)<=ichar("9"))
431 
432  RETURN
433  END FUNCTION is_digit
434 
435  !
436  !================================================================================================================================
437  !
438 
440  FUNCTION is_letter(CHARAC)
442  !Argument variables
443  CHARACTER(LEN=1), INTENT(IN) :: CHARAC
444  !Function variable
445  LOGICAL :: IS_LETTER
446  !Local Variables
447 
448  is_letter=((ichar(charac)>=ichar("A").AND.ichar(charac)<=ichar("Z")).OR.&
449  & (ichar(charac)>=ichar("a").AND.ichar(charac)<=ichar("z")))
450 
451  RETURN
452  END FUNCTION is_letter
453 
454  !
455  !================================================================================================================================
456  !
457 
459  FUNCTION is_lowercase(CHARC)
461  !Argument variables
462  CHARACTER(LEN=1), INTENT(IN) :: CHARC
463  !Function variable
464  LOGICAL :: IS_LOWERCASE
465  !Local Variables
466 
467  IF(lge(charc,"a").AND.lle(charc,"z")) THEN
468  is_lowercase=.true.
469  ELSE
470  is_lowercase=.false.
471  ENDIF
472 
473  RETURN
474  END FUNCTION is_lowercase
475 
476  !
477  !================================================================================================================================
478  !
479 
481  FUNCTION is_uppercase(CHARC)
483  !Argument variables
484  CHARACTER(LEN=1), INTENT(IN) :: CHARC
485  !Function variable
486  LOGICAL :: IS_UPPERCASE
487  !Local Variables
488 
489  IF(lge(charc,"A").AND.lle(charc,"Z")) THEN
490  is_uppercase=.true.
491  ELSE
492  is_uppercase=.false.
493  ENDIF
494 
495  RETURN
496  END FUNCTION is_uppercase
497 
498  !
499  !================================================================================================================================
500  !
501 
503  FUNCTION is_whitespace(CHARAC)
505  !Argument variables
506  CHARACTER(LEN=1), INTENT(IN) :: CHARAC
507  !Function variable
508  LOGICAL :: IS_WHITESPACE
509  !Local Variables
510 
511  !!WARNING: Assumes ASCII encoding
512  is_whitespace=(charac==char(32).OR.charac==char(9))
513 
514  RETURN
515  END FUNCTION is_whitespace
516 
517  !
518  !================================================================================================================================
519  !
520 
522  FUNCTION list_to_character_c(NUMBER_IN_LIST,LIST,FORMAT,ERR,ERROR,LIST_LENGTHS)
523 
524  !Argument variables
525  INTEGER(INTG), INTENT(IN) :: NUMBER_IN_LIST
526  CHARACTER(LEN=*), INTENT(IN) :: LIST(number_in_list)
527  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
528  INTEGER(INTG), INTENT(OUT) :: ERR
529  TYPE(varying_string), INTENT(OUT) :: ERROR
530  INTEGER(INTG), OPTIONAL, INTENT(IN) :: LIST_LENGTHS(number_in_list)
531  !Function variable
532  CHARACTER(LEN=MAXSTRLEN) :: LIST_TO_CHARACTER_C
533  !Local variables
534  INTEGER(INTG) :: i,POSITION,LENGTH
535 
536  enters("LIST_TO_CHARACTER_C",err,error,*999)
537 
538  list_to_character_c=""
539  IF(number_in_list>0) THEN
540  IF(PRESENT(list_lengths)) THEN
541  length=list_lengths(1)
542  list_to_character_c=list(1)(1:length)
543  DO i=2,number_in_list
544  IF(length+list_lengths(i)+1<=maxstrlen) THEN
545  list_to_character_c=list_to_character_c(1:length)//","//list(i)(1:list_lengths(i))
546  length=length+list_lengths(i)+1
547  ELSE IF(length+5<=maxstrlen) THEN
548  list_to_character_c=list_to_character_c(1:length)//",...."
549  EXIT
550  ELSE
551  position=index(list_to_character_c(1:maxstrlen-4),",",.true.)
552  IF(position/=0) THEN
553  list_to_character_c=list_to_character_c(1:position)//"...."
554  ELSE
555  list_to_character_c=list_to_character_c(1:maxstrlen-5)//",...."
556  ENDIF
557  EXIT
558  ENDIF
559  ENDDO !i
560  ELSE
561  list_to_character_c=list(1)(1:len_trim(list(1)))
562  DO i=2,number_in_list
563  IF(len_trim(list_to_character_c)+len_trim(list(i))+1<=maxstrlen) THEN
564  list_to_character_c=list_to_character_c(1:len_trim(list_to_character_c))//","//list(i)(1:len_trim(list(i)))
565  ELSE IF(len_trim(list_to_character_c)+5<=maxstrlen) THEN
566  list_to_character_c=list_to_character_c(1:len_trim(list_to_character_c))//",...."
567  EXIT
568  ELSE
569  position=index(list_to_character_c(1:maxstrlen-4),",",.true.)
570  IF(position/=0) THEN
571  list_to_character_c=list_to_character_c(1:position)//"...."
572  ELSE
573  list_to_character_c=list_to_character_c(1:maxstrlen-5)//",...."
574  ENDIF
575  EXIT
576  ENDIF
577  ENDDO !i
578  ENDIF
579  ENDIF
580 
581  exits("LIST_TO_CHARACTER_C")
582  RETURN
583 999 errorsexits("LIST_TO_CHARACTER_C",err,error)
584  RETURN
585  END FUNCTION list_to_character_c
586 
587  !
588  !================================================================================================================================
589  !
590 
592  FUNCTION list_to_character_intg(NUMBER_IN_LIST,LIST,FORMAT,ERR,ERROR)
593 
594  !Argument variables
595  INTEGER(INTG), INTENT(IN) :: NUMBER_IN_LIST
596  INTEGER(INTG), INTENT(IN) :: LIST(number_in_list)
597  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
598  INTEGER(INTG), INTENT(OUT) :: ERR
599  TYPE(varying_string), INTENT(OUT) :: ERROR
600  !Function variable
601  CHARACTER(LEN=MAXSTRLEN) :: LIST_TO_CHARACTER_INTG
602  !Local variables
603  INTEGER(INTG) :: i,POSITION
604  CHARACTER(LEN=MAXSTRLEN) :: LIST_VALUE
605 
606  enters("LIST_TO_CHARACTER_INTG",err,error,*999)
607 
608  list_to_character_intg=""
609  IF(number_in_list>0) THEN
610  list_to_character_intg=number_to_character_intg(list(1),FORMAT,err,error)
611  IF(err/=0) GOTO 999
612  DO i=2,number_in_list
613  list_value=number_to_character_intg(list(i),FORMAT,err,error)
614  IF(err/=0) GOTO 999
615  IF(len_trim(list_to_character_intg)+len_trim(list_value)+1<=maxstrlen) THEN
616  list_to_character_intg=list_to_character_intg(1:len_trim(list_to_character_intg))//","// &
617  & list_value(1:len_trim(list_value))
618  ELSE IF(len_trim(list_to_character_intg)+5<=maxstrlen) THEN
619  list_to_character_intg=list_to_character_intg(1:len_trim(list_to_character_intg))//",...."
620  EXIT
621  ELSE
622  position=index(list_to_character_intg(1:maxstrlen-4),",",.true.)
623  IF(position/=0) THEN
624  list_to_character_intg=list_to_character_intg(1:position)//"...."
625  ELSE
626  list_to_character_intg=list_to_character_intg(1:maxstrlen-5)//",...."
627  ENDIF
628  EXIT
629  ENDIF
630  ENDDO
631  ENDIF
632 
633  exits("LIST_TO_CHARACTER_INTG")
634  RETURN
635 999 errorsexits("LIST_TO_CHARACTER_INTG",err,error)
636  RETURN
637  END FUNCTION list_to_character_intg
638 
639  !
640  !================================================================================================================================
641  !
642 
644  FUNCTION list_to_character_lintg(NUMBER_IN_LIST,LIST,FORMAT,ERR,ERROR)
645 
646  !Argument variables
647  INTEGER(INTG), INTENT(IN) :: NUMBER_IN_LIST
648  INTEGER(LINTG), INTENT(IN) :: LIST(number_in_list)
649  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
650  INTEGER(INTG), INTENT(OUT) :: ERR
651  TYPE(varying_string), INTENT(OUT) :: ERROR
652  !Function variable
653  CHARACTER(LEN=MAXSTRLEN) :: LIST_TO_CHARACTER_LINTG
654  !Local variables
655  INTEGER(INTG) :: i,POSITION
656  CHARACTER(LEN=MAXSTRLEN) :: LIST_VALUE
657 
658  enters("LIST_TO_CHARACTER_LINTG",err,error,*999)
659 
660  list_to_character_lintg=""
661  IF(number_in_list>0) THEN
662  list_to_character_lintg=number_to_character_lintg(list(1),FORMAT,err,error)
663  IF(err/=0) GOTO 999
664  DO i=2,number_in_list
665  list_value=number_to_character_lintg(list(i),FORMAT,err,error)
666  IF(err/=0) GOTO 999
667  IF(len_trim(list_to_character_lintg)+len_trim(list_value)+1<=maxstrlen) THEN
668  list_to_character_lintg=list_to_character_lintg(1:len_trim(list_to_character_lintg))//","// &
669  & list_value(1:len_trim(list_value))
670  ELSE IF(len_trim(list_to_character_lintg)+5<=maxstrlen) THEN
671  list_to_character_lintg=list_to_character_lintg(1:len_trim(list_to_character_lintg))//",...."
672  EXIT
673  ELSE
674  position=index(list_to_character_lintg(1:maxstrlen-4),",",.true.)
675  IF(position/=0) THEN
676  list_to_character_lintg=list_to_character_lintg(1:position)//"...."
677  ELSE
678  list_to_character_lintg=list_to_character_lintg(1:maxstrlen-5)//",...."
679  ENDIF
680  EXIT
681  ENDIF
682  ENDDO
683  ENDIF
684 
685  exits("LIST_TO_CHARACTER_LINTG")
686  RETURN
687 999 errorsexits("LIST_TO_CHARACTER_LINTG",err,error)
688  RETURN
689  END FUNCTION list_to_character_lintg
690 
691  !
692  !================================================================================================================================
693  !
694 
696  FUNCTION list_to_character_l(NUMBER_IN_LIST,LIST,FORMAT,ERR,ERROR)
697 
698  !Argument variables
699  INTEGER(INTG), INTENT(IN) :: NUMBER_IN_LIST
700  LOGICAL, INTENT(IN) :: LIST(number_in_list)
701  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
702  INTEGER(INTG), INTENT(OUT) :: ERR
703  TYPE(varying_string), INTENT(OUT) :: ERROR
704  !Function variable
705  CHARACTER(LEN=MAXSTRLEN) :: LIST_TO_CHARACTER_L
706  !Local variables
707  INTEGER(INTG) :: i,POSITION
708  CHARACTER(LEN=MAXSTRLEN) :: LIST_VALUE
709 
710  enters("LIST_TO_CHARACTER_L",err,error,*999)
711 
712  list_to_character_l=""
713  IF(number_in_list>0) THEN
714  list_to_character_l=logical_to_character(list(1),err,error)
715  IF(err/=0) GOTO 999
716  DO i=2,number_in_list
717  list_value=logical_to_character(list(i),err,error)
718  IF(err/=0) GOTO 999
719  IF(len_trim(list_to_character_l)+len_trim(list_value)+1<=maxstrlen) THEN
720  list_to_character_l=list_to_character_l(1:len_trim(list_to_character_l))//","//list_value(1:len_trim(list_value))
721  ELSE IF(len_trim(list_to_character_l)+5<=maxstrlen) THEN
722  list_to_character_l=list_to_character_l(1:len_trim(list_to_character_l))//",...."
723  EXIT
724  ELSE
725  position=index(list_to_character_l(1:maxstrlen-4),",",.true.)
726  IF(position/=0) THEN
727  list_to_character_l=list_to_character_l(1:position)//"...."
728  ELSE
729  list_to_character_l=list_to_character_l(1:maxstrlen-5)//",...."
730  ENDIF
731  EXIT
732  ENDIF
733  ENDDO
734  ENDIF
735 
736  exits("LIST_TO_CHARACTER_L")
737  RETURN
738 999 errorsexits("LIST_TO_CHARACTER_L",err,error)
739  RETURN
740  END FUNCTION list_to_character_l
741 
742  !
743  !================================================================================================================================
744  !
745 
747  FUNCTION list_to_character_sp(NUMBER_IN_LIST,LIST,FORMAT,ERR,ERROR)
748 
749  !Argument variables
750  INTEGER(INTG), INTENT(IN) :: NUMBER_IN_LIST
751  REAL(SP), INTENT(IN) :: LIST(number_in_list)
752  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
753  INTEGER(INTG), INTENT(OUT) :: ERR
754  TYPE(varying_string), INTENT(OUT) :: ERROR
755  !Function variable
756  CHARACTER(LEN=MAXSTRLEN) :: LIST_TO_CHARACTER_SP
757  !Local variables
758  INTEGER(INTG) :: i,POSITION
759  CHARACTER(LEN=MAXSTRLEN) :: LIST_VALUE
760 
761  enters("LIST_TO_CHARACTER_SP",err,error,*999)
762 
763  list_to_character_sp=""
764  IF(number_in_list>0) THEN
765  list_to_character_sp=number_to_character_sp(list(1),FORMAT,err,error)
766  IF(err/=0) GOTO 999
767  DO i=2,number_in_list
768  list_value=number_to_character_sp(list(i),FORMAT,err,error)
769  IF(err/=0) GOTO 999
770  IF(len_trim(list_to_character_sp)+len_trim(list_value)+1<=maxstrlen) THEN
771  list_to_character_sp=list_to_character_sp(1:len_trim(list_to_character_sp))//","//list_value(1:len_trim(list_value))
772  ELSE IF(len_trim(list_to_character_sp)+5<=maxstrlen) THEN
773  list_to_character_sp=list_to_character_sp(1:len_trim(list_to_character_sp))//",...."
774  EXIT
775  ELSE
776  position=index(list_to_character_sp(1:maxstrlen-4),",",.true.)
777  IF(position/=0) THEN
778  list_to_character_sp=list_to_character_sp(1:position)//"...."
779  ELSE
780  list_to_character_sp=list_to_character_sp(1:maxstrlen-5)//",...."
781  ENDIF
782  EXIT
783  ENDIF
784  ENDDO
785  ENDIF
786 
787  exits("LIST_TO_CHARACTER_SP")
788  RETURN
789 999 errorsexits("LIST_TO_CHARACTER_SP",err,error)
790  RETURN
791  END FUNCTION list_to_character_sp
792 
793  !
794  !================================================================================================================================
795  !
796 
798  FUNCTION list_to_character_dp(NUMBER_IN_LIST,LIST,FORMAT,ERR,ERROR)
799 
800  !Argument variables
801  INTEGER(INTG), INTENT(IN) :: NUMBER_IN_LIST
802  REAL(DP), INTENT(IN) :: LIST(number_in_list)
803  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
804  INTEGER(INTG), INTENT(OUT) :: ERR
805  TYPE(varying_string), INTENT(OUT) :: ERROR
806  !Function variable
807  CHARACTER(LEN=MAXSTRLEN) :: LIST_TO_CHARACTER_DP
808  !Local variables
809  INTEGER(INTG) :: i,POSITION
810  CHARACTER(LEN=MAXSTRLEN) :: LIST_VALUE
811 
812  enters("LIST_TO_CHARACTER_DP",err,error,*999)
813 
814  list_to_character_dp=""
815  IF(number_in_list>0) THEN
816  list_to_character_dp=number_to_character_dp(list(1),FORMAT,err,error)
817  IF(err/=0) GOTO 999
818  DO i=2,number_in_list
819  list_value=number_to_character_dp(list(i),FORMAT,err,error)
820  IF(err/=0) GOTO 999
821  IF(len_trim(list_to_character_dp)+len_trim(list_value)+1<=maxstrlen) THEN
822  list_to_character_dp=list_to_character_dp(1:len_trim(list_to_character_dp))//","//list_value(1:len_trim(list_value))
823  ELSE IF(len_trim(list_to_character_dp)+5<=maxstrlen) THEN
824  list_to_character_dp=list_to_character_dp(1:len_trim(list_to_character_dp))//",...."
825  EXIT
826  ELSE
827  position=index(list_to_character_dp(1:maxstrlen-4),",",.true.)
828  IF(position/=0) THEN
829  list_to_character_dp=list_to_character_dp(1:position)//"...."
830  ELSE
831  list_to_character_dp=list_to_character_dp(1:maxstrlen-5)//",...."
832  ENDIF
833  EXIT
834  ENDIF
835  ENDDO
836  ENDIF
837 
838  exits("LIST_TO_CHARACTER_DP")
839  RETURN
840 999 errorsexits("LIST_TO_CHARACTER_DP",err,error)
841  RETURN
842  END FUNCTION list_to_character_dp
843 
844  !
845  !================================================================================================================================
846  !
847 
849  FUNCTION logical_to_character(LOGICALVALUE,ERR,ERROR)
850 
851  !Argument variables
852  LOGICAL, INTENT(IN) :: LOGICALVALUE
853  INTEGER(INTG), INTENT(OUT) :: ERR
854  TYPE(varying_string), INTENT(OUT) :: ERROR
855  !Function variable
856  CHARACTER(LEN=MAXSTRLEN) :: LOGICAL_TO_CHARACTER
857  !Local variables
858 
859  enters("LOGICAL_TO_CHARACTER",err,error,*999)
860 
861  IF(logicalvalue) THEN
862  logical_to_character="TRUE"
863  ELSE
864  logical_to_character="FALSE"
865  ENDIF
866 
867  exits("LOGICAL_TO_CHARACTER")
868  RETURN
869 999 errorsexits("LOGICAL_TO_CHARACTER",err,error)
870  RETURN
871  END FUNCTION logical_to_character
872 
873  !
874  !================================================================================================================================
875  !
876 
878  FUNCTION logical_to_vstring(LOGICALVALUE,ERR,ERROR)
879 
880  !Argument variables
881  LOGICAL, INTENT(IN) :: LOGICALVALUE
882  INTEGER(INTG), INTENT(OUT) :: ERR
883  TYPE(varying_string), INTENT(OUT) :: ERROR
884  !Function variable
885  TYPE(varying_string) :: LOGICAL_TO_VSTRING
886  !Local variables
887 
888  enters("LOGICAL_TO_VSTRING",err,error,*999)
889 
890  IF(logicalvalue) THEN
891  logical_to_vstring="TRUE"
892  ELSE
893  logical_to_vstring="FALSE"
894  ENDIF
895 
896  exits("LOGICAL_TO_VSTRING")
897  RETURN
898 999 errorsexits("LOGICAL_TO_VSTRING",err,error)
899  RETURN
900  END FUNCTION logical_to_vstring
901 
902  !
903  !================================================================================================================================
904  !
905 
907  FUNCTION number_to_character_intg(NUMBER,FORMAT,ERR,ERROR)
908 
909  !Argument variables
910  INTEGER(INTG), INTENT(IN) :: NUMBER
911  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
912  INTEGER(INTG), INTENT(OUT) :: ERR
913  TYPE(varying_string), INTENT(OUT) :: ERROR
914  !Function variable
915  CHARACTER(LEN=MAXSTRLEN) :: NUMBER_TO_CHARACTER_INTG
916  !Local variables
917  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_FORMAT
918 
919  enters("NUMBER_TO_CHARACTER_INTG",err,error,*999)
920 
921  IF(FORMAT(1:1)=="*") THEN
922  local_format="(I12)"
923  ELSE
924  local_format="("//FORMAT(1:len_trim(format))//")"
925  ENDIF
926  WRITE(number_to_character_intg,local_format,err=999) number
927 
928  !Trim leading blanks
929  number_to_character_intg=adjustl(number_to_character_intg)
930 
931  exits("NUMBER_TO_CHARACTER_INTG")
932  RETURN
933 999 CALL flagerror("Error converting an integer to a character string",err,error,*998)
934 998 errorsexits("NUMBER_TO_CHARACTER_INTG",err,error)
935  RETURN
936  END FUNCTION number_to_character_intg
937 
938  !
939  !================================================================================================================================
940  !
941 
943  FUNCTION number_to_character_lintg(NUMBER,FORMAT,ERR,ERROR)
944 
945  !Argument variables
946  INTEGER(LINTG), INTENT(IN) :: NUMBER
947  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
948  INTEGER(INTG), INTENT(OUT) :: ERR
949  TYPE(varying_string), INTENT(OUT) :: ERROR
950  !Function variable
951  CHARACTER(LEN=MAXSTRLEN) :: NUMBER_TO_CHARACTER_LINTG
952  !Local variables
953  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_FORMAT
954 
955  enters("NUMBER_TO_CHARACTER_LINTG",err,error,*999)
956 
957  IF(FORMAT(1:1)=="*") THEN
958  local_format="(I18)"
959  ELSE
960  local_format="("//FORMAT(1:len_trim(format))//")"
961  ENDIF
962  WRITE(number_to_character_lintg,local_format,err=999) number
963 
964  !Trim leading blanks
965  number_to_character_lintg=adjustl(number_to_character_lintg)
966 
967  exits("NUMBER_TO_CHARACTER_LINTG")
968  RETURN
969 999 CALL flagerror("Error converting a long integer to a character string",err,error,*998)
970 998 errorsexits("NUMBER_TO_CHARACTER_LINTG",err,error)
971  RETURN
972  END FUNCTION number_to_character_lintg
973 
974  !
975  !================================================================================================================================
976  !
977 
979  FUNCTION number_to_character_sp(NUMBER, FORMAT, ERR, ERROR)
980 
981  !Argument variables
982  REAL(SP), INTENT(IN) :: NUMBER
983  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
984  INTEGER(INTG), INTENT(OUT) :: ERR
985  TYPE(varying_string), INTENT(OUT) :: ERROR
986  !Function variable
987  CHARACTER(LEN=MAXSTRLEN) :: NUMBER_TO_CHARACTER_SP
988  !Local variables
989  INTEGER(INTG) :: ASTERISK_POS,i0,i1,LENGTH
990  CHARACTER(LEN=MAXSTRLEN) :: CI0,CI1
991  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_FORMAT
992 
993  enters("NUMBER_TO_CHARACTER_SP",err,error,*999)
994 
995  asterisk_pos=index(FORMAT,"*")
996  length=len_trim(format)
997  IF(asterisk_pos==1.AND.length==1) THEN !Free format
998  WRITE(number_to_character_sp,*,err=999) number
999  ELSE IF(asterisk_pos>0) THEN !Adjustable format
1000  ci0=FORMAT(asterisk_pos+1:len_trim(format))
1001  READ(ci0,'(BN,I2)') i0
1002  IF(i0<=maxstrlen) THEN
1003  IF(number>=0.0_sp) THEN
1004  IF((number<10.0_sp**(i0-1)).AND.(number>=0.1_sp**(min(i0-2,5)))) THEN
1005  IF(number>1.0_sp) THEN
1006  i1=i0-2-floor(log10(number))
1007  local_format="(I2)"
1008  WRITE(ci1,local_format) i1
1009  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1010  WRITE(number_to_character_sp,local_format,err=999) number
1011  ELSE
1012  local_format="(I2)"
1013  WRITE(ci1,local_format) i0-2
1014  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1015  WRITE(number_to_character_sp,local_format,err=999) number
1016  ENDIF
1017  ELSE
1018  local_format="(I2)"
1019  WRITE(ci1,local_format) i0-6
1020  local_format="(E"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1021  WRITE(number_to_character_sp,local_format,err=999) number
1022  ENDIF
1023  ELSE
1024  IF((-number<10.0_sp**(i0-2)).AND.(-number>=0.01_sp**(min(i0-2,5)))) THEN
1025  IF(-number>=1.0_sp) THEN
1026  i1=i0-3-floor(log10(number))
1027  local_format="(I2)"
1028  WRITE(ci1,'(I2)') i1
1029  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1030  WRITE(number_to_character_sp,local_format,err=999) number
1031  ELSE
1032  local_format="(I2)"
1033  WRITE(ci1,local_format) i0-2
1034  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1035  WRITE(number_to_character_sp,local_format,err=999) number
1036  ENDIF
1037  ELSE
1038  local_format="(I2)"
1039  WRITE(ci1,local_format) i0-6
1040  local_format="(E"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1041  WRITE(number_to_character_sp,local_format,err=999) number
1042  ENDIF
1043  ENDIF
1044  ELSE
1045  CALL flagerror("Invalid FORMAT",err,error,*999)
1046  GOTO 999
1047  ENDIF
1048  ELSE
1049  local_format='('//FORMAT(1:len_trim(format))//')'
1050  WRITE(number_to_character_sp,local_format,err=999) number
1051  ENDIF
1052 
1053  !Add an extra zero if required
1054  IF(number_to_character_sp(len_trim(number_to_character_sp):len_trim(number_to_character_sp))==".") &
1055  & number_to_character_sp=number_to_character_sp(1:len_trim(number_to_character_sp))//"0"
1056  !Trim leading blanks
1057  number_to_character_sp=adjustl(number_to_character_sp)
1058 
1059  exits("NUMBER_TO_CHARACTER_SP")
1060  RETURN
1061 999 CALL flagerror("Error converting a single precision number to a character string",err,error,*998)
1062 998 errorsexits("NUMBER_TO_CHARACTER_SP",err,error)
1063  RETURN
1064  END FUNCTION number_to_character_sp
1065 
1066  !
1067  !================================================================================================================================
1068  !
1069 
1071  FUNCTION number_to_character_dp(NUMBER, FORMAT, ERR, ERROR)
1073  !Argument variables
1074  REAL(DP), INTENT(IN) :: NUMBER
1075  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
1076  INTEGER(INTG), INTENT(OUT) :: ERR
1077  TYPE(varying_string), INTENT(OUT) :: ERROR
1078  !Function variable
1079  CHARACTER(LEN=MAXSTRLEN) :: NUMBER_TO_CHARACTER_DP
1080  !Local variables
1081  INTEGER(INTG) :: ASTERISK_POS,i0,i1,LENGTH
1082  CHARACTER(LEN=2) :: CI0,CI1
1083  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_FORMAT
1084 
1085  enters("NUMBER_TO_CHARACTER_DP",err,error,*999)
1086 
1087  asterisk_pos=index(FORMAT,"*")
1088  length=len_trim(format)
1089  IF(asterisk_pos==1.AND.length==1) THEN !Free format
1090  WRITE(number_to_character_dp,*,err=999) number
1091  ELSE IF(asterisk_pos>0) THEN !Adjustable format
1092  ci0=FORMAT(asterisk_pos+1:len_trim(format))
1093  READ(ci0,'(BN,I2)') i0
1094  IF(i0<=maxstrlen) THEN
1095  IF(number>=0.0_dp) THEN
1096  IF((number<10.0_dp**(i0-1)).AND.(number>=0.1_dp**(min(i0-2,5)))) THEN
1097  IF(number>1.0_dp) THEN
1098  i1=i0-2-floor(log10(number))
1099  local_format="(I2)"
1100  WRITE(ci1,local_format) i1
1101  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1102  WRITE(number_to_character_dp,local_format,err=999) number
1103  ELSE
1104  local_format="(I2)"
1105  WRITE(ci1,local_format) i0-2
1106  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1107  WRITE(number_to_character_dp,local_format,err=999) number
1108  ENDIF
1109  ELSE
1110  local_format="(I2)"
1111  WRITE(ci1,local_format) i0-6
1112  local_format="(E"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1113  WRITE(number_to_character_dp,local_format,err=999) number
1114  ENDIF
1115  ELSE
1116  IF((-number<10.0_dp**(i0-2)).AND.(-number>=0.01_dp**(min(i0-2,5)))) THEN
1117  IF(-number>=1.0_dp) THEN
1118  i1=i0-3-floor(log10(number))
1119  local_format="(I2)"
1120  WRITE(ci1,'(I2)') i1
1121  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1122  WRITE(number_to_character_dp,local_format,err=999) number
1123  ELSE
1124  local_format="(I2)"
1125  WRITE(ci1,local_format) i0-2
1126  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1127  WRITE(number_to_character_dp,local_format,err=999) number
1128  ENDIF
1129  ELSE
1130  local_format="(I2)"
1131  WRITE(ci1,local_format) i0-6
1132  local_format="(E"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1133  WRITE(number_to_character_dp,local_format,err=999) number
1134  ENDIF
1135  ENDIF
1136  ELSE
1137  CALL flagerror("Invalid format",err,error,*999)
1138  ENDIF
1139  ELSE
1140  local_format='('//FORMAT(1:len_trim(format))//')'
1141  WRITE(number_to_character_dp,local_format,err=999) number
1142  ENDIF
1143 
1144  !Add an extra zero if required
1145  IF(number_to_character_dp(len_trim(number_to_character_dp):len_trim(number_to_character_dp))==".") &
1146  & number_to_character_dp=number_to_character_dp(1:len_trim(number_to_character_dp))//"0"
1147  !Trim leading blanks
1148  number_to_character_dp=adjustl(number_to_character_dp)
1149 
1150  exits("NUMBER_TO_CHARACTER_DP")
1151  RETURN
1152 999 CALL flagerror("Error converting double precision number to a character string",err,error,*998)
1153 998 errorsexits("NUMBER_TO_CHARACTER_DP",err,error)
1154  RETURN
1155  END FUNCTION number_to_character_dp
1156 
1157  !
1158  !================================================================================================================================
1159  !
1160 
1162  FUNCTION number_to_vstring_intg(NUMBER,FORMAT,ERR,ERROR)
1164  !Argument variables
1165  INTEGER(INTG), INTENT(IN) :: NUMBER
1166  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
1167  INTEGER(INTG), INTENT(OUT) :: ERR
1168  TYPE(varying_string), INTENT(OUT) :: ERROR
1169  !Function variable
1170  TYPE(varying_string) :: NUMBER_TO_VSTRING_INTG
1171  !Local variables
1172  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_FORMAT,LOCAL_STRING
1173 
1174 !!TODO: put back enters,exits.
1175 
1176 ! ENTERS("NUMBER_TO_VSTRING_INTG",ERR,ERROR,*999)
1177 
1178 !!TODO: remove dependance on LOCAL_STRING
1179 
1180  number_to_vstring_intg=""
1181 
1182  IF(FORMAT(1:1)=="*") THEN
1183  local_format="(I12)"
1184  ELSE
1185  local_format="("//FORMAT(1:len_trim(format))//")"
1186  ENDIF
1187  WRITE(local_string,local_format,err=999) number
1188 
1189  !Trim leading blanks
1190  number_to_vstring_intg=adjustl(local_string(1:len_trim(local_string)))
1191 
1192 ! EXITS("NUMBER_TO_VSTRING_INTG")
1193  RETURN
1194 999 CALL flagerror("Error converting an integer to a varying string",err,error,*998)
1195 998 errorsexits("NUMBER_TO_VSTRING_INTG",err,error)
1196  RETURN
1197  END FUNCTION number_to_vstring_intg
1198 
1199  !
1200  !================================================================================================================================
1201  !
1202 
1204  FUNCTION number_to_vstring_lintg(NUMBER,FORMAT,ERR,ERROR)
1206  !Argument variables
1207  INTEGER(LINTG), INTENT(IN) :: NUMBER
1208  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
1209  INTEGER(INTG), INTENT(OUT) :: ERR
1210  TYPE(varying_string), INTENT(OUT) :: ERROR
1211  !Function variable
1212  TYPE(varying_string) :: NUMBER_TO_VSTRING_LINTG
1213  !Local variables
1214  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_FORMAT,LOCAL_STRING
1215 
1216 !!TODO: put back enters,exits.
1217 
1218 ! ENTERS("NUMBER_TO_VSTRING_LINTG",ERR,ERROR,*999)
1219 
1220 !!TODO: remove dependance on LOCAL_STRING
1221 
1222  number_to_vstring_lintg=""
1223 
1224  IF(FORMAT(1:1)=="*") THEN
1225  local_format="(I18)"
1226  ELSE
1227  local_format="("//FORMAT(1:len_trim(format))//")"
1228  ENDIF
1229  WRITE(local_string,local_format,err=999) number
1230 
1231  !Trim leading blanks
1232  number_to_vstring_lintg=adjustl(local_string(1:len_trim(local_string)))
1233 
1234 ! EXITS("NUMBER_TO_VSTRING_LINTG")
1235  RETURN
1236 999 CALL flagerror("Error converting a long integer to a varying string",err,error,*998)
1237 998 errorsexits("NUMBER_TO_VSTRING_LINTG",err,error)
1238 ! EXITS("NUMBER_TO_VSTRING_LINTG")
1239  RETURN
1240  END FUNCTION number_to_vstring_lintg
1241 
1242  !
1243  !================================================================================================================================
1244  !
1245 
1247  FUNCTION number_to_vstring_sp(NUMBER, FORMAT, ERR, ERROR)
1249  !Argument variables
1250  REAL(SP), INTENT(IN) :: NUMBER
1251  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
1252  INTEGER(INTG), INTENT(OUT) :: ERR
1253  TYPE(varying_string), INTENT(OUT) :: ERROR
1254  !Function variable
1255  TYPE(varying_string) :: NUMBER_TO_VSTRING_SP
1256  !Local variables
1257  INTEGER(INTG) :: ASTERISK_POS,i0,i1,LENGTH
1258  CHARACTER(LEN=MAXSTRLEN) :: CI0,CI1
1259  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_FORMAT,LOCAL_STRING
1260 
1261  enters("NUMBER_TO_VSTRING_SP",err,error,*999)
1262 
1263 !!TODO: remove dependance on LOCAL_STRING
1264 
1265  number_to_vstring_sp=""
1266 
1267  asterisk_pos=index(FORMAT,"*")
1268  length=len_trim(format)
1269  IF(asterisk_pos==1.AND.length==1) THEN !Free format
1270  WRITE(local_string,*,err=999) number
1271  ELSE IF(asterisk_pos>0) THEN !Adjustable format
1272  ci0=FORMAT(asterisk_pos+1:len_trim(format))
1273  READ(ci0,'(BN,I2)') i0
1274  IF(i0<=maxstrlen) THEN
1275  IF(number>=0.0_sp) THEN
1276  IF((number<10.0_sp**(i0-1)).AND.(number>=0.1_sp**(min(i0-2,5)))) THEN
1277  IF(number>1.0_sp) THEN
1278  i1=i0-2-floor(log10(number))
1279  local_format="(I2)"
1280  WRITE(ci1,local_format) i1
1281  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1282  WRITE(local_string,local_format,err=999) number
1283  ELSE
1284  local_format="(I2)"
1285  WRITE(ci1,local_format) i0-2
1286  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1287  WRITE(local_string,local_format,err=999) number
1288  ENDIF
1289  ELSE
1290  local_format="(I2)"
1291  WRITE(ci1,local_format) i0-6
1292  local_format="(E"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1293  WRITE(local_string,local_format,err=999) number
1294  ENDIF
1295  ELSE
1296  IF((-number<10.0_sp**(i0-2)).AND.(-number>=0.01_sp**(min(i0-2,5)))) THEN
1297  IF(-number>=1.0_sp) THEN
1298  i1=i0-3-floor(log10(number))
1299  local_format="(I2)"
1300  WRITE(ci1,'(I2)') i1
1301  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1302  WRITE(local_string,local_format,err=999) number
1303  ELSE
1304  local_format="(I2)"
1305  WRITE(ci1,local_format) i0-2
1306  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1307  WRITE(local_string,local_format,err=999) number
1308  ENDIF
1309  ELSE
1310  local_format="(I2)"
1311  WRITE(ci1,local_format) i0-6
1312  local_format="(E"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1313  WRITE(local_string,local_format,err=999) number
1314  ENDIF
1315  ENDIF
1316  ELSE
1317  CALL flagerror("Invalid format",err,error,*999)
1318  GOTO 999
1319  ENDIF
1320  ELSE
1321  local_format='('//FORMAT(1:len_trim(format))//')'
1322  WRITE(local_string,local_format,err=999) number
1323  ENDIF
1324 
1325  !Add an extra zero if required
1326  IF(local_string(len_trim(local_string):len_trim(local_string))==".") local_string=local_string(1:len_trim(local_string))//"0"
1327 
1328  !Trim leading blanks
1329  number_to_vstring_sp=adjustl(local_string(1:len_trim(local_string)))
1330 
1331  exits("NUMBER_TO_VSTRING_SP")
1332  RETURN
1333 999 CALL flagerror("Error converting a single precision number to a varying string",err,error,*998)
1334 998 errorsexits("NUMBER_TO_VSTRING_SP",err,error)
1335  RETURN
1336  END FUNCTION number_to_vstring_sp
1337 
1338  !
1339  !================================================================================================================================
1340  !
1341 
1343  FUNCTION number_to_vstring_dp(NUMBER, FORMAT, ERR, ERROR)
1345  !Argument variables
1346  REAL(DP), INTENT(IN) :: NUMBER
1347  CHARACTER(LEN=*), INTENT(IN) :: FORMAT
1348  INTEGER(INTG), INTENT(OUT) :: ERR
1349  TYPE(varying_string), INTENT(OUT) :: ERROR
1350  !Function variable
1351  TYPE(varying_string) :: NUMBER_TO_VSTRING_DP
1352  !Local variables
1353  INTEGER(INTG) :: ASTERISK_POS,i0,i1,LENGTH
1354  CHARACTER(LEN=2) :: CI0,CI1
1355  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_FORMAT,LOCAL_STRING
1356 
1357 !!TODO: put back enters,exits.
1358 
1359 ! ENTERS("NUMBER_TO_VSTRING_DP",ERR,ERROR,*999)
1360 
1361 !!TODO: remove dependance on LOCAL_STRING
1362 
1363  number_to_vstring_dp=""
1364 
1365  asterisk_pos=index(FORMAT,"*")
1366  length=len_trim(format)
1367  IF(asterisk_pos==1.AND.length==1) THEN !Free format
1368  WRITE(local_string,*,err=999) number
1369  ELSE IF(asterisk_pos>0) THEN !Adjustable format
1370  ci0=FORMAT(asterisk_pos+1:len_trim(format))
1371  READ(ci0,'(BN,I2)') i0
1372  IF(i0<=maxstrlen) THEN
1373  IF(number>=0.0_dp) THEN
1374  IF((number<10.0_dp**(i0-1)).AND.(number>=0.1_dp**(min(i0-2,5)))) THEN
1375  IF(number>1.0_dp) THEN
1376  i1=i0-2-floor(log10(number))
1377  local_format="(I2)"
1378  WRITE(ci1,local_format) i1
1379  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1380  WRITE(local_string,local_format,err=999) number
1381  ELSE
1382  local_format="(I2)"
1383  WRITE(ci1,local_format) i0-2
1384  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1385  WRITE(local_string,local_format,err=999) number
1386  ENDIF
1387  ELSE
1388  local_format="(I2)"
1389  WRITE(ci1,local_format) i0-6
1390  local_format="(E"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1391  WRITE(local_string,local_format,err=999) number
1392  ENDIF
1393  ELSE
1394  IF((-number<10.0_dp**(i0-2)).AND.(-number>=0.01_dp**(min(i0-2,5)))) THEN
1395  IF(-number>=1.0_dp) THEN
1396  i1=i0-3-floor(log10(number))
1397  local_format="(I2)"
1398  WRITE(ci1,'(I2)') i1
1399  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1400  WRITE(local_string,local_format,err=999) number
1401  ELSE
1402  local_format="(I2)"
1403  WRITE(ci1,local_format) i0-2
1404  local_format="(F"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1405  WRITE(local_string,local_format,err=999) number
1406  ENDIF
1407  ELSE
1408  local_format="(I2)"
1409  WRITE(ci1,local_format) i0-6
1410  local_format="(E"//ci0(1:len_trim(ci0))//"."//ci1(1:len_trim(ci1))//")"
1411  WRITE(local_string,local_format,err=999) number
1412  ENDIF
1413  ENDIF
1414  ELSE
1415  CALL flagerror("Invalid format",err,error,*999)
1416  ENDIF
1417  ELSE
1418  local_format='('//FORMAT(1:len_trim(format))//')'
1419  WRITE(local_string,local_format,err=999) number
1420  ENDIF
1421 
1422  !Add an extra zero if required
1423  IF(local_string(len_trim(local_string):len_trim(local_string))==".") local_string=local_string(1:len_trim(local_string))//"0"
1424 
1425  !!Do you really want to do this???
1426  !Trim leading blanks
1427  !NUMBER_TO_VSTRING_DP=ADJUSTL(LOCAL_STRING(1:LEN_TRIM(LOCAL_STRING)))
1428  number_to_vstring_dp=local_string(1:len_trim(local_string))
1429 
1430 ! EXITS("NUMBER_TO_VSTRING_DP")
1431  RETURN
1432 999 CALL flagerror("Error converting double precision number to a varying string",err,error,*998)
1433 998 errorsexits("NUMBER_TO_VSTRING_DP",err,error)
1434 ! EXITS("NUMBER_TO_VSTRING_DP")
1435  RETURN
1436  END FUNCTION number_to_vstring_dp
1437 
1438  !
1439  !================================================================================================================================
1440  !
1441 
1443  FUNCTION string_to_double_c(STRING, ERR, ERROR)
1445  !Argument variables
1446  CHARACTER(LEN=*), INTENT(IN) :: STRING
1447  INTEGER(INTG), INTENT(OUT) :: ERR
1448  TYPE(varying_string), INTENT(OUT) :: ERROR
1449  !Function variable
1450  REAL(DP) :: STRING_TO_DOUBLE_C
1451  !Local variables
1452 
1453  enters("STRING_TO_DOUBLE_C",err,error,*999)
1454 
1455  READ(string,*,iostat=err,err=999) string_to_double_c
1456 
1457  exits("STRING_TO_DOUBLE_C")
1458  RETURN
1459 999 CALL flagerror("Cannot convert '"//string(1:len_trim(string))//"' to a double real",err,error,*998)
1460 998 errorsexits("STRING_TO_DOUBLE_C",err,error)
1461  RETURN
1462  END FUNCTION string_to_double_c
1463 
1464  !
1465  !================================================================================================================================
1466  !
1467 
1469  FUNCTION string_to_double_vs(STRING, ERR, ERROR)
1471  !Argument variables
1472  TYPE(varying_string), INTENT(IN) :: STRING
1473  INTEGER(INTG), INTENT(OUT) :: ERR
1474  TYPE(varying_string), INTENT(OUT) :: ERROR
1475  !Function variable
1476  REAL(DP) :: STRING_TO_DOUBLE_VS
1477  !Local variables
1478  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_STRING
1479 
1480  enters("STRING_TO_DOUBLE_VS",err,error,*999)
1481 
1482 !!TODO: remove dependance on LOCAL_STRING
1483 
1484  local_string=char(string)
1485  READ(local_string,*,iostat=err,err=999) string_to_double_vs
1486 
1487  exits("STRING_TO_DOUBLE_VS")
1488  RETURN
1489 999 CALL flagerror("Cannot convert '"//char(string)//"' to a double real",err,error,*998)
1490 998 errorsexits("STRING_TO_DOUBLE_VS",err,error)
1491  RETURN
1492  END FUNCTION string_to_double_vs
1493 
1494  !
1495  !================================================================================================================================
1496  !
1497 
1499  FUNCTION string_to_integer_c(STRING, ERR, ERROR)
1501  !Argument variables
1502  CHARACTER(LEN=*), INTENT(IN) :: STRING
1503  INTEGER(INTG), INTENT(OUT) :: ERR
1504  TYPE(varying_string), INTENT(OUT) :: ERROR
1505  !Function variable
1506  INTEGER(INTG) :: STRING_TO_INTEGER_C
1507  !Local variables
1508 
1509  enters("STRING_TO_INTEGER_C",err,error,*999)
1510 
1511  READ(string,*,iostat=err,err=999) string_to_integer_c
1512 
1513  exits("STRING_TO_INTEGER_C")
1514  RETURN
1515 999 CALL flagerror("Cannot convert '"//string(1:len_trim(string))//"' to an integer",err,error,*998)
1516 998 errorsexits("STRING_TO_INTEGER_C",err,error)
1517  RETURN
1518  END FUNCTION string_to_integer_c
1519 
1520  !
1521  !================================================================================================================================
1522  !
1523 
1525  FUNCTION string_to_integer_vs(STRING, ERR, ERROR)
1527  !Argument variables
1528  TYPE(varying_string), INTENT(IN) :: STRING
1529  INTEGER(INTG), INTENT(OUT) :: ERR
1530  TYPE(varying_string), INTENT(OUT) :: ERROR
1531  !Function variable
1532  INTEGER(INTG) :: STRING_TO_INTEGER_VS
1533  !Local variables
1534  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_STRING
1535 
1536  enters("STRING_TO_INTEGER_VS",err,error,*999)
1537 
1538 !!TODO: remove dependance on LOCAL_STRING
1539 
1540  local_string=char(string)
1541  READ(local_string,*,iostat=err,err=999) string_to_integer_vs
1542 
1543  exits("STRING_TO_INTEGER_VS")
1544  RETURN
1545 999 CALL flagerror("Cannot convert '"//char(string)//"' to an integer",err,error,*998)
1546 998 errorsexits("STRING_TO_INTEGER_VS",err,error)
1547  RETURN
1548  END FUNCTION string_to_integer_vs
1549 
1550  !
1551  !================================================================================================================================
1552  !
1553 
1555  FUNCTION string_to_long_integer_c(STRING, ERR, ERROR)
1557  !Argument variables
1558  CHARACTER(LEN=*), INTENT(IN) :: STRING
1559  INTEGER(INTG), INTENT(OUT) :: ERR
1560  TYPE(varying_string), INTENT(OUT) :: ERROR
1561  !Function variable
1562  INTEGER(LINTG) :: STRING_TO_LONG_INTEGER_C
1563  !Local variables
1564 
1565  enters("STRING_TO_LONG_INTEGER_C",err,error,*999)
1566 
1567  READ(string,*,iostat=err,err=999) string_to_long_integer_c
1568 
1569  exits("STRING_TO_LONG_INTEGER_C")
1570  RETURN
1571 999 CALL flagerror("Cannot convert '"//string(1:len_trim(string))//"' to a long integer",err,error,*998)
1572 998 errorsexits("STRING_TO_LONG_INTEGER_C",err,error)
1573  RETURN
1574  END FUNCTION string_to_long_integer_c
1575 
1576  !
1577  !================================================================================================================================
1578  !
1579 
1581  FUNCTION string_to_long_integer_vs(STRING, ERR, ERROR)
1583  !Argument variables
1584  TYPE(varying_string), INTENT(IN) :: STRING
1585  INTEGER(INTG), INTENT(OUT) :: ERR
1586  TYPE(varying_string), INTENT(OUT) :: ERROR
1587  !Function variable
1588  INTEGER(LINTG) :: STRING_TO_LONG_INTEGER_VS
1589  !Local variables
1590  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_STRING
1591 
1592  enters("STRING_TO_LONG_INTEGER_VS",err,error,*999)
1593 
1594 !!TODO: remove dependance on LOCAL_STRING
1595 
1596  local_string=char(string)
1597  READ(local_string,*,iostat=err,err=999) string_to_long_integer_vs
1598 
1599  exits("STRING_TO_LONG_INTEGER_VS")
1600  RETURN
1601 999 CALL flagerror("Cannot convert '"//char(string)//"' to a long integer",err,error,*998)
1602 998 errorsexits("STRING_TO_LONG_INTEGER_VS",err,error)
1603  RETURN
1604  END FUNCTION string_to_long_integer_vs
1605 
1606  !
1607  !================================================================================================================================
1608  !
1609 
1611  FUNCTION string_to_logical_c(STRING,ERR,ERROR)
1613  !Argument variables
1614  CHARACTER(LEN=*), INTENT(IN) :: STRING
1615  INTEGER(INTG), INTENT(OUT) :: ERR
1616  TYPE(varying_string), INTENT(OUT) :: ERROR
1617  !Function variable
1618  LOGICAL :: STRING_TO_LOGICAL_C
1619  !Local variables
1620 
1621  enters("STRING_TO_LOGICAL_C",err,error,*999)
1622 
1623  READ(string,*,iostat=err,err=999) string_to_logical_c
1624 
1625  exits("STRING_TO_LOGICAL_C")
1626  RETURN
1627 999 CALL flagerror("Cannot convert '"//string(1:len_trim(string))//"' to a logical",err,error,*998)
1628 998 errorsexits("STRING_TO_LOGICAL_C",err,error)
1629  RETURN
1630  END FUNCTION string_to_logical_c
1631 
1632  !
1633  !================================================================================================================================
1634  !
1635 
1637  FUNCTION string_to_logical_vs(STRING,ERR,ERROR)
1639  !Argument variables
1640  TYPE(varying_string), INTENT(IN) :: STRING
1641  INTEGER(INTG), INTENT(OUT) :: ERR
1642  TYPE(varying_string), INTENT(OUT) :: ERROR
1643  !Function variable
1644  LOGICAL :: STRING_TO_LOGICAL_VS
1645  !Local variables
1646  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_STRING
1647 
1648  enters("STRING_TO_LOGICAL_VS",err,error,*999)
1649 
1650  local_string=char(string)
1651  READ(local_string,*,iostat=err,err=999) string_to_logical_vs
1652 
1653  exits("STRING_TO_LOGICAL_VS")
1654  RETURN
1655 999 CALL flagerror("Cannot convert '"//char(string)//"' to a logical",err,error,*998)
1656 998 errorsexits("STRING_TO_LOGICAL_VS",err,error)
1657  RETURN
1658  END FUNCTION string_to_logical_vs
1659 
1660  !
1661  !================================================================================================================================
1662  !
1663 
1665  FUNCTION string_to_single_c(STRING, ERR, ERROR)
1667  !Argument variables
1668  CHARACTER(LEN=*), INTENT(IN) :: STRING
1669  INTEGER(INTG), INTENT(OUT) :: ERR
1670  TYPE(varying_string), INTENT(OUT) :: ERROR
1671  !Function variable
1672  REAL(SP) :: STRING_TO_SINGLE_C
1673  !Local variables
1674 
1675  enters("STRING_TO_SINGLE_C",err,error,*999)
1676 
1677  READ(string,*,iostat=err,err=999) string_to_single_c
1678 
1679  exits("STRING_TO_SINGLE_C")
1680  RETURN
1681 999 CALL flagerror("Cannot convert '"//string(1:len_trim(string))//"' to a single real",err,error,*998)
1682 998 errorsexits("STRING_TO_SINGLE_C",err,error)
1683  RETURN
1684  END FUNCTION string_to_single_c
1685 
1686  !
1687  !================================================================================================================================
1688  !
1689 
1691  FUNCTION string_to_single_vs(STRING, ERR, ERROR)
1693  !Argument variables
1694  TYPE(varying_string), INTENT(IN) :: STRING
1695  INTEGER(INTG), INTENT(OUT) :: ERR
1696  TYPE(varying_string), INTENT(OUT) :: ERROR
1697  !Function variable
1698  REAL(SP) :: STRING_TO_SINGLE_VS
1699  !Local variables
1700  CHARACTER(LEN=MAXSTRLEN) :: LOCAL_STRING
1701 
1702  enters("STRING_TO_SINGLE_VS",err,error,*999)
1703 
1704 !!TODO: remove dependance on LOCAL_STRING
1705 
1706  local_string=char(string)
1707  READ(local_string,*,iostat=err,err=999) string_to_single_vs
1708 
1709  exits("STRING_TO_SINGLE_VS")
1710  RETURN
1711 999 CALL flagerror("Cannot convert '"//char(string)//"' to a single real",err,error,*998)
1712 998 errorsexits("STRING_TO_SINGLE_VS",err,error)
1713  RETURN
1714 
1715  END FUNCTION string_to_single_vs
1716 
1717  !
1718  !================================================================================================================================
1719  !
1720 
1721  FUNCTION character_to_lowercase_c(STRING)
1723  !Argument variables
1724  CHARACTER(LEN=*), INTENT(IN) :: STRING
1725  !Function variable
1726  CHARACTER(LEN=LEN(STRING)) :: CHARACTER_TO_LOWERCASE_C
1727  !Local Variables
1728  INTEGER(INTG), PARAMETER :: OFFSET=(ichar("a")-ichar("A"))
1729  INTEGER(INTG) :: i
1730 
1731  character_to_lowercase_c=string
1732  DO i=1,len(string)
1733  IF(is_uppercase(string(i:i))) THEN
1734  character_to_lowercase_c(i:i)=char(ichar(string(i:i))+offset)
1735  ENDIF
1736  ENDDO !i
1737 
1738  RETURN
1739  END FUNCTION character_to_lowercase_c
1740 
1741  !
1742  !================================================================================================================================
1743  !
1744 
1746  FUNCTION character_to_lowercase_vs(STRING)
1748  !Argument variables
1749  TYPE(varying_string), INTENT(IN) :: STRING
1750  !Function variable
1751  CHARACTER(LEN=LEN(STRING)) :: CHARACTER_TO_LOWERCASE_VS
1752  !Local Variables
1753  INTEGER(INTG), PARAMETER :: OFFSET=(ichar("a")-ichar("A"))
1754  INTEGER(INTG) :: i
1755 
1756  character_to_lowercase_vs=char(string)
1757  DO i=1,len(string)
1758  IF(is_uppercase(char(extract(string,i,i)))) THEN
1759  character_to_lowercase_vs(i:i)=char(ichar(extract(string,i,i))+offset)
1760  ENDIF
1761  ENDDO !i
1762 
1763  RETURN
1764  END FUNCTION character_to_lowercase_vs
1765 
1766  !
1767  !================================================================================================================================
1768  !
1769 
1771  FUNCTION vstring_to_lowercase_c(STRING)
1773  !Argument variables
1774  CHARACTER(LEN=*), INTENT(IN) :: STRING
1775  !Function variable
1776  TYPE(varying_string) :: VSTRING_TO_LOWERCASE_C
1777  !Local Variables
1778  INTEGER(INTG), PARAMETER :: OFFSET=(ichar("a")-ichar("A"))
1779  INTEGER(INTG) :: i
1780 
1781  vstring_to_lowercase_c=string
1782  DO i=1,len(string)
1783  IF(is_uppercase(string(i:i))) THEN
1784  vstring_to_lowercase_c=insert(vstring_to_lowercase_c,i,char(ichar(string(i:i))+offset))
1785  ENDIF
1786  ENDDO !i
1787 
1788  RETURN
1789  END FUNCTION vstring_to_lowercase_c
1790 
1791  !
1792  !================================================================================================================================
1793  !
1794 
1796  FUNCTION vstring_to_lowercase_vs(STRING)
1798  !Argument variables
1799  TYPE(varying_string), INTENT(IN) :: STRING
1800  !Function variable
1801  TYPE(varying_string) :: VSTRING_TO_LOWERCASE_VS
1802  !Local Variables
1803  INTEGER(INTG), PARAMETER :: OFFSET=(ichar("a")-ichar("A"))
1804  INTEGER(INTG) :: i
1805 
1806  vstring_to_lowercase_vs=string
1807  DO i=1,len(string)
1808  IF(is_uppercase(char(extract(string,i,i)))) THEN
1809  vstring_to_lowercase_vs=insert(vstring_to_lowercase_vs,i,char(ichar(extract(string,i,i))+offset))
1810  ENDIF
1811  ENDDO !i
1812 
1813  RETURN
1814  END FUNCTION vstring_to_lowercase_vs
1815 
1816  !
1817  !================================================================================================================================
1818  !
1819 
1821  FUNCTION character_to_uppercase_c(STRING)
1823  !Argument variables
1824  CHARACTER(LEN=*), INTENT(IN) :: STRING
1825  !Function variable
1826  CHARACTER(LEN=LEN(STRING)) :: CHARACTER_TO_UPPERCASE_C
1827  !Local Variables
1828  INTEGER(INTG), PARAMETER :: OFFSET=(ichar("A")-ichar("a"))
1829  INTEGER(INTG) :: i
1830 
1831  character_to_uppercase_c=string
1832  DO i=1,len(string)
1833  IF(is_lowercase(string(i:i))) THEN
1834  character_to_uppercase_c(i:i)=char(ichar(string(i:i))+offset)
1835  ENDIF
1836  ENDDO !i
1837 
1838  RETURN
1839  END FUNCTION character_to_uppercase_c
1840 
1841  !
1842  !================================================================================================================================
1843  !
1844 
1846  FUNCTION character_to_uppercase_vs(STRING)
1848  !Argument variables
1849  TYPE(varying_string), INTENT(IN) :: STRING
1850  !Function variable
1851  CHARACTER(LEN=LEN(STRING)) :: CHARACTER_TO_UPPERCASE_VS
1852  !Local Variables
1853  INTEGER(INTG), PARAMETER :: OFFSET=(ichar("A")-ichar("a"))
1854  INTEGER(INTG) :: i
1855 
1856  character_to_uppercase_vs=char(string)
1857  DO i=1,len(string)
1858  IF(is_lowercase(char(extract(string,i,i)))) THEN
1859  character_to_uppercase_vs(i:i)=char(ichar(extract(string,i,i))+offset)
1860  ENDIF
1861  ENDDO !i
1862 
1863  RETURN
1864  END FUNCTION character_to_uppercase_vs
1865 
1866  !
1867  !================================================================================================================================
1868  !
1869 
1871  FUNCTION vstring_to_uppercase_c(STRING)
1873  !Argument variables
1874  CHARACTER(LEN=*), INTENT(IN) :: STRING
1875  !Function variable
1876  TYPE(varying_string) :: VSTRING_TO_UPPERCASE_C
1877  !Local Variables
1878  INTEGER(INTG), PARAMETER :: OFFSET=(ichar("A")-ichar("a"))
1879  INTEGER(INTG) :: i
1880 
1881  vstring_to_uppercase_c=string
1882  DO i=1,len(string)
1883  IF(is_lowercase(string(i:i))) THEN
1884  vstring_to_uppercase_c=insert(vstring_to_uppercase_c,i,char(ichar(string(i:i))+offset))
1885  ENDIF
1886  ENDDO !i
1887 
1888  RETURN
1889  END FUNCTION vstring_to_uppercase_c
1890 
1891  !
1892  !================================================================================================================================
1893  !
1894 
1896  FUNCTION vstring_to_uppercase_vs(STRING)
1898  !Argument variables
1899  TYPE(varying_string), INTENT(IN) :: STRING
1900  !Function variable
1901  TYPE(varying_string) :: VSTRING_TO_UPPERCASE_VS
1902  !Local Variables
1903  INTEGER(INTG), PARAMETER :: OFFSET=(ichar("A")-ichar("a"))
1904  INTEGER(INTG) :: i
1905 
1906  vstring_to_uppercase_vs=string
1907  DO i=1,len(string)
1908  IF(is_lowercase(char(extract(string,i,i)))) THEN
1909  vstring_to_uppercase_vs=insert(vstring_to_uppercase_vs,i,char(ichar(extract(string,i,i))+offset))
1910  ENDIF
1911  ENDDO !i
1912 
1913  RETURN
1914  END FUNCTION vstring_to_uppercase_vs
1915 
1916  !
1917  !================================================================================================================================
1918  !
1919 
1920 END MODULE strings
subroutine, public enters(NAME, ERR, ERROR,)
Records the entry into the named procedure and initialises the error code.
Converts a number to its equivalent character string representation.
Definition: strings.f90:145
Returns .TRUE. if a supplied string is a valid abbreviation of a second supplied string.
Definition: strings.f90:89
Converts a number to its equivalent varying string representation.
Definition: strings.f90:161
character(len=maxstrlen) function number_to_character_lintg(NUMBER, FORMAT, ERR, ERROR)
Converts a long integer number to its equivalent character string representation as determined by the...
Definition: strings.f90:944
type(varying_string) function vstring_to_lowercase_vs(STRING)
Returns a varying string that is the lowercase equivalent of the supplied varying string...
Definition: strings.f90:1797
Returns a varying string which is the uppercase equivalent of the supplied string.
Definition: strings.f90:255
logical function is_abbreviation_vs_vs(SHORT, LONG, MIN_NUM_CHARACTERS)
IS_ABBREVIATION returns .TRUE. if the varying string SHORT is an abbreviation of the varying string L...
Definition: strings.f90:392
Returns a character string which is the lowercase equivalent of the supplied string.
Definition: strings.f90:65
logical function, public is_whitespace(CHARAC)
IS_WHITESPACE returns .TRUE. if the character CHARAC is a whitespace character (i.e. space, tabs, etc.)
Definition: strings.f90:504
This module contains all string manipulation and transformation routines.
Definition: strings.f90:45
Returns a varying string which is the lowercase equivalent of the supplied string.
Definition: strings.f90:237
logical function string_to_logical_vs(STRING, ERR, ERROR)
Converts a varying string representation of a boolean (TRUE or FALSE) to a logical.
Definition: strings.f90:1638
This module provides an iso_varying_string module, conformant to the API specified in ISO/IEC 1539-2:...
Returns a character string which is the uppercase equivalent of the supplied string.
Definition: strings.f90:77
integer(lintg) function string_to_long_integer_c(STRING, ERR, ERROR)
Converts a character string representation of a number to a long integer.
Definition: strings.f90:1556
Converts a list to its equivalent character string representation.
Definition: strings.f90:117
character(len=maxstrlen) function list_to_character_sp(NUMBER_IN_LIST, LIST, FORMAT, ERR, ERROR)
Converts a single precision list to its equivalent character string representation as determined by t...
Definition: strings.f90:748
character(len=len(string)) function character_to_uppercase_vs(STRING)
Returns a character string which is uppercase equivalent of the supplied varying string.
Definition: strings.f90:1847
This module contains all program wide constants.
Definition: constants.f90:45
Returns a character string which is the uppercase equivalent of the supplied string.
Definition: strings.f90:83
Converts a string representation of a boolean value (TRUE or FALSE) to a logical. ...
Definition: strings.f90:213
Converts a number to its equivalent character string representation.
Definition: strings.f90:153
Converts a list to its equivalent character string representation.
Definition: strings.f90:127
Returns .TRUE. if a supplied string is a valid abbreviation of a second supplied string.
Definition: strings.f90:97
Converts a string representation of a boolean value (TRUE or FALSE) to a logical. ...
Definition: strings.f90:219
integer(intg), parameter maxstrlen
Maximum string length fro character strings.
Definition: constants.f90:79
logical function, public is_digit(CHARAC)
IS_DIGIT returns .TRUE. if the character CHARAC is a digit character (i.e. 0..9)
Definition: strings.f90:423
character(len=maxstrlen) function number_to_character_intg(NUMBER, FORMAT, ERR, ERROR)
Converts an integer number to its equivalent character string representation as determined by the sup...
Definition: strings.f90:908
logical function string_to_logical_c(STRING, ERR, ERROR)
Converts a character string representation of a boolean (TRUE or FALSE) to a logical.
Definition: strings.f90:1612
Converts a string representation of a number to a long integer.
Definition: strings.f90:207
subroutine, public exits(NAME)
Records the exit out of the named procedure.
character(len=len(string)) function character_to_lowercase_vs(STRING)
Returns a character string that is the lowercase equivalent of the supplied varying string...
Definition: strings.f90:1747
This module contains all the low-level base routines e.g., all debug, control, and low-level communic...
character(len=len(string)) function character_to_uppercase_c(STRING)
Returns a character string which is uppercase equivalent of the supplied character string...
Definition: strings.f90:1822
type(varying_string) function vstring_to_uppercase_vs(STRING)
Returns a varying string which is uppercase equivalent of the supplied varying string.
Definition: strings.f90:1897
logical function is_abbreviation_vs_c(SHORT, LONG, MIN_NUM_CHARACTERS)
IS_ABBREVIATION returns .TRUE. if the varying string SHORT is an abbreviation of the character string...
Definition: strings.f90:360
character(len=maxstrlen) function list_to_character_c(NUMBER_IN_LIST, LIST, FORMAT, ERR, ERROR, LIST_LENGTHS)
Converts a character list to its equivalent character string representation as determined by the supp...
Definition: strings.f90:523
character(len=maxstrlen) function list_to_character_intg(NUMBER_IN_LIST, LIST, FORMAT, ERR, ERROR)
Converts an integer list to its equivalent character string representation as determined by the suppl...
Definition: strings.f90:593
character(len=maxstrlen) function number_to_character_sp(NUMBER, FORMAT, ERR, ERROR)
Converts a single precision number to its equivalent character string representation as determined by...
Definition: strings.f90:980
Converts a string representation of a number to a long integer.
Definition: strings.f90:201
Converts a string representation of a number to a double precision number.
Definition: strings.f90:183
character(len=maxstrlen) function, public logical_to_character(LOGICALVALUE, ERR, ERROR)
Converts a logical value to either a "TRUE" or "FALSE" character string.
Definition: strings.f90:850
type(varying_string) function vstring_to_uppercase_c(STRING)
Returns a varying string which is uppercase equivalent of the supplied character string.
Definition: strings.f90:1872
Converts a string representation of a number to a single precision number.
Definition: strings.f90:231
logical function is_uppercase(CHARC)
Returns .TRUE. if the supplied character is an uppercase character.
Definition: strings.f90:482
real(dp) function string_to_double_c(STRING, ERR, ERROR)
Converts a character string representation of a number to a double precision number.
Definition: strings.f90:1444
Converts a string representation of a number to a double precision number.
Definition: strings.f90:177
type(varying_string) function vstring_to_lowercase_c(STRING)
Returns a varying string that is the lowercase equivalent of the supplied character string...
Definition: strings.f90:1772
type(varying_string) function, public logical_to_vstring(LOGICALVALUE, ERR, ERROR)
Converts a logical value to either a "TRUE" or "FALSE" varying string.
Definition: strings.f90:879
character(len=maxstrlen) function list_to_character_l(NUMBER_IN_LIST, LIST, FORMAT, ERR, ERROR)
Converts a logical list to its equivalent character string representation as determined by the suppli...
Definition: strings.f90:697
real(sp) function string_to_single_c(STRING, ERR, ERROR)
Converts a character string representation of a number to a single precision number.
Definition: strings.f90:1666
type(varying_string) function number_to_vstring_sp(NUMBER, FORMAT, ERR, ERROR)
Converts a single precision number to its equivalent varying string representation as determined by t...
Definition: strings.f90:1248
type(varying_string) function number_to_vstring_lintg(NUMBER, FORMAT, ERR, ERROR)
Converts a long integer number to its equivalent varying string representation as determined by the s...
Definition: strings.f90:1205
type(varying_string) function number_to_vstring_dp(NUMBER, FORMAT, ERR, ERROR)
Converts a double precision number to its equivalent varying string representation as determined by t...
Definition: strings.f90:1344
integer(intg) function string_to_integer_vs(STRING, ERR, ERROR)
Converts a varying string representation of a number to an integer.
Definition: strings.f90:1526
Returns a character string which is the lowercase equivalent of the supplied string.
Definition: strings.f90:71
Converts a string representation of a number to an integer.
Definition: strings.f90:189
Returns a varying string which is the uppercase equivalent of the supplied string.
Definition: strings.f90:249
character(len=len(string)) function character_to_lowercase_c(STRING)
Definition: strings.f90:1722
character(len=maxstrlen) function list_to_character_lintg(NUMBER_IN_LIST, LIST, FORMAT, ERR, ERROR)
Converts an long integer list to its equivalent character string representation as determined by the ...
Definition: strings.f90:645
logical function is_lowercase(CHARC)
Returns .TRUE. if the supplied character is a lowercase character.
Definition: strings.f90:460
real(sp) function string_to_single_vs(STRING, ERR, ERROR)
Converts a varying string representation of a number to a single precision number.
Definition: strings.f90:1692
Converts a string representation of a number to an integer.
Definition: strings.f90:195
logical function, public is_letter(CHARAC)
IS_LETTER returns .TRUE. if the character CHARAC is a letter character (i.e. A..Z or a...
Definition: strings.f90:441
character(len=maxstrlen) function number_to_character_dp(NUMBER, FORMAT, ERR, ERROR)
Converts a double precision number to its equivalent character string representation as determined by...
Definition: strings.f90:1072
character(len=maxstrlen) function list_to_character_dp(NUMBER_IN_LIST, LIST, FORMAT, ERR, ERROR)
Converts a double precision list to its equivalent character string representation as determined by t...
Definition: strings.f90:799
logical function is_abbreviation_c_c(SHORT, LONG, MIN_NUM_CHARACTERS)
IS_ABBREVIATION returns .TRUE. if the character string SHORT is an abbreviation of the character stri...
Definition: strings.f90:296
Flags an error condition.
Returns a varying string which is the lowercase equivalent of the supplied string.
Definition: strings.f90:243
real(dp) function string_to_double_vs(STRING, ERR, ERROR)
Converts a varying string representation of a number to a double precision number.
Definition: strings.f90:1470
type(varying_string) function number_to_vstring_intg(NUMBER, FORMAT, ERR, ERROR)
Converts an integer number to its equivalent varying string representation as determined by the suppl...
Definition: strings.f90:1163
integer(lintg) function string_to_long_integer_vs(STRING, ERR, ERROR)
Converts a varying string representation of a number to a long integer.
Definition: strings.f90:1582
integer(intg) function string_to_integer_c(STRING, ERR, ERROR)
Converts a character string representation of a number to an integer.
Definition: strings.f90:1500
Converts a string representation of a number to a single precision number.
Definition: strings.f90:225
This module contains all kind definitions.
Definition: kinds.f90:45
logical function is_abbreviation_c_vs(SHORT, LONG, MIN_NUM_CHARACTERS)
IS_ABBREVIATION returns .TRUE. if the character string SHORT is an abbreviation of the varying string...
Definition: strings.f90:328