DCS
a Driven-Cavity Open source Simulator code
 All Classes Files Functions Variables Groups Pages
IR_Precision.f90
Go to the documentation of this file.
1 
11 
17 
23 
29 
35 
41 
57 module ir_precision
58 !-----------------------------------------------------------------------------------------------------------------------------------
59 use, intrinsic:: iso_fortran_env, only: stdout => output_unit, stderr => error_unit ! Standard output/error logical units.
60 !-----------------------------------------------------------------------------------------------------------------------------------
61 
62 !-----------------------------------------------------------------------------------------------------------------------------------
63 implicit none
64 private
65 public:: endianl,endianb,endian
69 public:: r_p, fr_p, dr_p, minr_p, maxr_p, bir_p, byr_p, smallr_p, zero
70 public:: i8p, fi8p, di8p, mini8p, maxi8p, bii8p, byi8p
71 public:: i4p, fi4p, di4p, mini4p, maxi4p, bii4p, byi4p
72 public:: i2p, fi2p, di2p, mini2p, maxi2p, bii2p, byi2p
73 public:: i1p, fi1p, di1p, mini1p, maxi1p, bii1p, byi1p
74 public:: i_p, fi_p, di_p, mini_p, maxi_p, bii_p, byi_p
75 public:: nrknd, rpl, frl
76 public:: niknd, ril, fil
77 public:: check_endian
78 public:: bit_size,byte_size
79 public:: str, strz, cton, bstr, bcton
80 public:: ir_initialized,ir_init
81 public:: ir_print
82 !-----------------------------------------------------------------------------------------------------------------------------------
83 
84 !-----------------------------------------------------------------------------------------------------------------------------------
87 logical:: ir_initialized = .false.
88 ! Bit ordering of the running architecture:
89 integer, parameter:: endianl = 1
90 integer, parameter:: endianb = 0
91 integer:: endian = endianl
92 
93 ! The following are the portable kind parameters available.
94 ! Real precision definitions:
95 #ifdef r16p
96 integer, parameter:: r16p = selected_real_kind(33,4931)
97 #else
98 integer, parameter:: r16p = selected_real_kind(15,307)
99 #endif
100 integer, parameter:: r8p = selected_real_kind(15,307)
101 integer, parameter:: r4p = selected_real_kind(6,37)
102 integer, parameter:: r_p = r8p
103 ! Integer precision definitions:
104 integer, parameter:: i8p = selected_int_kind(18)
105 integer, parameter:: i4p = selected_int_kind(9)
106 integer, parameter:: i2p = selected_int_kind(4)
107 integer, parameter:: i1p = selected_int_kind(2)
108 integer, parameter:: i_p = i4p
109 
110 ! Format parameters useful for writing in a well-ascii-format numeric variables.
111 ! Real output formats:
112 character(10), parameter:: fr16p = '(E42.33E4)'
113 character(10), parameter:: fr8p = '(E23.15E3)'
114 character(9), parameter:: fr4p = '(E13.6E2)'
115 character(10), parameter:: fr_p = fr8p
116 ! Real number of digits of output formats:
117 integer, parameter:: dr16p = 42
118 integer, parameter:: dr8p = 23
119 integer, parameter:: dr4p = 13
120 integer, parameter:: dr_p = dr8p
121 ! Integer output formats:
122 character(5), parameter:: fi8p = '(I20)'
123 character(8), parameter:: fi8pzp = '(I20.19)'
124 character(5), parameter:: fi4p = '(I11)'
125 character(8), parameter:: fi4pzp = '(I11.10)'
126 character(4), parameter:: fi2p = '(I6)'
127 character(6), parameter:: fi2pzp = '(I6.5)'
128 character(4), parameter:: fi1p = '(I4)'
129 character(6), parameter:: fi1pzp = '(I4.3)'
130 character(5), parameter:: fi_p = fi4p
131 character(8), parameter:: fi_pzp = fi4pzp
132 ! Integer number of digits of output formats:
133 integer, parameter:: di8p = 20
134 integer, parameter:: di4p = 11
135 integer, parameter:: di2p = 6
136 integer, parameter:: di1p = 4
137 integer, parameter:: di_p = di4p
138 ! List of kinds
139 integer, parameter:: nrknd=4
140 integer, parameter:: RPl(1:NRknd)=[R16P,R8P,R4P,R_P]
141 character(10), parameter:: FRl(1:NRknd)=[FR16P,FR8P,FR4P//' ',FR_P]
142 integer, parameter:: NIknd=5
143 integer, parameter:: RIl(1:NIknd)=[I8P,I4P,I2P,I1P,I_P]
144 character(5), parameter:: FIl(1:NIknd)=[FI8P,FI4P,FI2P//' ',FI1P//' ',FI_P]
145 
146 ! Useful parameters for handling numbers ranges.
147 ! Real min and max values:
148 real(R16P), parameter:: MinR16P = -huge(1._R16P), MaxR16P = huge(1._R16P)
149 real(R8P), parameter:: MinR8P = -huge(1._R8P ), MaxR8P = huge(1._R8P )
150 real(R4P), parameter:: MinR4P = -huge(1._R4P ), MaxR4P = huge(1._R4P )
151 real(R_P), parameter:: MinR_P = MinR8P, MaxR_P = MaxR8P
152 ! Real number of bits/bytes
153 integer(I2P):: BIR16P, BYR16P
154 integer(I1P):: BIR8P, BYR8P
155 integer(I1P):: BIR4P, BYR4P
156 integer(I1P):: BIR_P, BYR_P
157 ! Real smallest values:
158 real(R16P), parameter:: smallR16P = tiny(1._R16P)
159 real(R8P), parameter:: smallR8P = tiny(1._R8P )
160 real(R4P), parameter:: smallR4P = tiny(1._R4P )
161 real(R_P), parameter:: smallR_P = smallR8P
162 ! Integer min and max values:
163 integer(I8P), parameter:: MinI8P = -huge(1_I8P), MaxI8P = huge(1_I8P)
164 integer(I4P), parameter:: MinI4P = -huge(1_I4P), MaxI4P = huge(1_I4P)
165 integer(I2P), parameter:: MinI2P = -huge(1_I2P), MaxI2P = huge(1_I2P)
166 integer(I1P), parameter:: MinI1P = -huge(1_I1P), MaxI1P = huge(1_I1P)
167 integer(I_P), parameter:: MinI_P = MinI4P, MaxI_P = MaxI4P
168 ! Integer number of bits/bytes:
169 integer(I8P), parameter:: BII8P = bit_size(MaxI8P), BYI8P = bit_size(MaxI8P)/8_I8P
170 integer(I4P), parameter:: BII4P = bit_size(MaxI4P), BYI4P = bit_size(MaxI4P)/8_I4P
171 integer(I2P), parameter:: BII2P = bit_size(MaxI2P), BYI2P = bit_size(MaxI2P)/8_I2P
172 integer(I1P), parameter:: BII1P = bit_size(MaxI1P), BYI1P = bit_size(MaxI1P)/8_I1P
173 integer(I_P), parameter:: BII_P = bit_size(MaxI_P), BYI_P = bit_size(MaxI_P)/8_I_P
174 ! Smallest real representable difference by the running calculator.
175 #ifdef pgf95
176 real(R16P), parameter:: ZeroR16 = 0._R16P
177 real(R8P), parameter:: ZeroR8 = 0._R8P
178 real(R4P), parameter:: ZeroR4 = 0._R4P
179 #else
180 real(R16P), parameter:: ZeroR16 = nearest(1._R16P, 1._R16P) - &
181  nearest(1._R16P,-1._R16P)
182 real(R8P), parameter:: ZeroR8 = nearest(1._R8P, 1._R8P) - &
183  nearest(1._R8P,-1._R8P)
184 real(R4P), parameter:: ZeroR4 = nearest(1._R4P, 1._R4P) - &
185  nearest(1._R4P,-1._R4P)
186 #endif
187 real(R_P), parameter:: Zero = ZeroR8
189 !-----------------------------------------------------------------------------------------------------------------------------------
191 !-----------------------------------------------------------------------------------------------------------------------------------
196 interface bit_size
197  module procedure &
198 #ifdef r16p
199  bit_size_r16p, &
200 #endif
204 endinterface
207 interface byte_size
208  module procedure &
210  byte_size_i4p, &
213 #ifdef r16p
215 #endif
219 endinterface
225 interface str
226  module procedure &
227 #ifdef r16p
229 #endif
230  strf_r8p ,str_r8p, &
231  strf_r4p ,str_r4p, &
232  strf_i8p ,str_i8p, &
234  strf_i2p ,str_i2p, &
236 endinterface
243 interface strz
244  module procedure strz_i8p, &
245  strz_i4p, &
246  strz_i2p, &
247  strz_i1p
248 endinterface
253 interface cton
254  module procedure &
255 #ifdef r16p
256  ctor_r16p, &
257 #endif
258  ctor_r8p, &
259  ctor_r4p, &
261  ctoi_i4p, &
262  ctoi_i2p, &
263  ctoi_i1p
264 endinterface
269 interface bstr
270  module procedure &
271 #ifdef r16p
272  bstr_r16p,&
273 #endif
274  bstr_r8p, &
275  bstr_r4p, &
276  bstr_i8p, &
277  bstr_i4p, &
279  bstr_i1p
280 endinterface
285 interface bcton
286  module procedure &
287 #ifdef r16p
288  bctor_r16p, &
289 #endif
290  bctor_r8p, &
291  bctor_r4p, &
292  bctoi_i8p, &
293  bctoi_i4p, &
294  bctoi_i2p, &
295  bctoi_i1p
296 endinterface
297 !-----------------------------------------------------------------------------------------------------------------------------------
298 contains
302  pure function is_little_endian() result(is_little)
303  !---------------------------------------------------------------------------------------------------------------------------------
304  implicit none
305  logical:: is_little
306  integer(I1P):: int1(1:4)
307  !---------------------------------------------------------------------------------------------------------------------------------
308 
309  !---------------------------------------------------------------------------------------------------------------------------------
310  int1 = transfer(1_i4p,int1)
311  is_little = (int1(1)==1_i1p)
312  return
313  !---------------------------------------------------------------------------------------------------------------------------------
314  endfunction is_little_endian
315 
318  subroutine check_endian()
319  !---------------------------------------------------------------------------------------------------------------------------------
320  implicit none
321  !---------------------------------------------------------------------------------------------------------------------------------
323  !---------------------------------------------------------------------------------------------------------------------------------
324  if (is_little_endian()) then
325  endian = endianl
326  else
327  endian = endianb
328  endif
329  return
330  !---------------------------------------------------------------------------------------------------------------------------------
331  endsubroutine check_endian
333 
337  elemental function bit_size_r16p(r) result(bits)
338  !---------------------------------------------------------------------------------------------------------------------------------
339  implicit none
340  real(R16P), intent(IN):: r
341  integer(I2P):: bits
342  integer(I1P):: mold(1)
343  !---------------------------------------------------------------------------------------------------------------------------------
344 
345  !---------------------------------------------------------------------------------------------------------------------------------
346  bits = size(transfer(r,mold),dim=1,kind=i2p)*8_i2p
347  return
348  !---------------------------------------------------------------------------------------------------------------------------------
349  endfunction bit_size_r16p
350 
352  elemental function bit_size_r8p(r) result(bits)
353  !---------------------------------------------------------------------------------------------------------------------------------
354  implicit none
355  real(R8P), intent(IN):: r
356  integer(I1P):: bits
357  integer(I1P):: mold(1)
358  !---------------------------------------------------------------------------------------------------------------------------------
359 
360  !---------------------------------------------------------------------------------------------------------------------------------
361  bits = size(transfer(r,mold),dim=1,kind=i1p)*8_i1p
362  return
363  !---------------------------------------------------------------------------------------------------------------------------------
364  endfunction bit_size_r8p
365 
367  elemental function bit_size_r4p(r) result(bits)
368  !---------------------------------------------------------------------------------------------------------------------------------
369  implicit none
370  real(R4P), intent(IN):: r
371  integer(I1P):: bits
372  integer(I1P):: mold(1)
373  !---------------------------------------------------------------------------------------------------------------------------------
374 
375  !---------------------------------------------------------------------------------------------------------------------------------
376  bits = size(transfer(r,mold),dim=1,kind=i1p)*8_i1p
377  return
378  !---------------------------------------------------------------------------------------------------------------------------------
379  endfunction bit_size_r4p
380 
382  elemental function bit_size_chr(c) result(bits)
383  !---------------------------------------------------------------------------------------------------------------------------------
384  implicit none
385  character(*), intent(IN):: c
386  integer(I4P):: bits
387  integer(I1P):: mold(1)
388  !---------------------------------------------------------------------------------------------------------------------------------
389 
390  !---------------------------------------------------------------------------------------------------------------------------------
391  bits = size(transfer(c,mold),dim=1,kind=i4p)*8_i4p
392  return
393  !---------------------------------------------------------------------------------------------------------------------------------
394  endfunction bit_size_chr
395 
397  elemental function byte_size_i8p(i) result(bytes)
398  !---------------------------------------------------------------------------------------------------------------------------------
399  implicit none
400  integer(I8P), intent(IN):: i
401  integer(I1P):: bytes
402  !---------------------------------------------------------------------------------------------------------------------------------
403 
404  !---------------------------------------------------------------------------------------------------------------------------------
405  bytes = bit_size(i)/8_i1p
406  return
407  !---------------------------------------------------------------------------------------------------------------------------------
408  endfunction byte_size_i8p
409 
411  elemental function byte_size_i4p(i) result(bytes)
412  !---------------------------------------------------------------------------------------------------------------------------------
413  implicit none
414  integer(I4P), intent(IN):: i
415  integer(I1P):: bytes
416  !---------------------------------------------------------------------------------------------------------------------------------
417 
418  !---------------------------------------------------------------------------------------------------------------------------------
419  bytes = bit_size(i)/8_i1p
420  return
421  !---------------------------------------------------------------------------------------------------------------------------------
422  endfunction byte_size_i4p
423 
425  elemental function byte_size_i2p(i) result(bytes)
426  !---------------------------------------------------------------------------------------------------------------------------------
427  implicit none
428  integer(I2P), intent(IN):: i
429  integer(I1P):: bytes
430  !---------------------------------------------------------------------------------------------------------------------------------
431 
432  !---------------------------------------------------------------------------------------------------------------------------------
433  bytes = bit_size(i)/8_i1p
434  return
435  !---------------------------------------------------------------------------------------------------------------------------------
436  endfunction byte_size_i2p
437 
439  elemental function byte_size_i1p(i) result(bytes)
440  !---------------------------------------------------------------------------------------------------------------------------------
441  implicit none
442  integer(I1P), intent(IN):: i
443  integer(I1P):: bytes
444  !---------------------------------------------------------------------------------------------------------------------------------
445 
446  !---------------------------------------------------------------------------------------------------------------------------------
447  bytes = bit_size(i)/8_i1p
448  return
449  !---------------------------------------------------------------------------------------------------------------------------------
450  endfunction byte_size_i1p
451 
453  elemental function byte_size_r16p(r) result(bytes)
454  !---------------------------------------------------------------------------------------------------------------------------------
455  implicit none
456  real(R16P), intent(IN):: r
457  integer(I1P):: bytes
458  !---------------------------------------------------------------------------------------------------------------------------------
459 
460  !---------------------------------------------------------------------------------------------------------------------------------
461  bytes = bit_size(r)/8_i1p
462  return
463  !---------------------------------------------------------------------------------------------------------------------------------
464  endfunction byte_size_r16p
465 
467  elemental function byte_size_r8p(r) result(bytes)
468  !---------------------------------------------------------------------------------------------------------------------------------
469  implicit none
470  real(R8P), intent(IN):: r
471  integer(I1P):: bytes
472  !---------------------------------------------------------------------------------------------------------------------------------
473 
474  !---------------------------------------------------------------------------------------------------------------------------------
475  bytes = bit_size(r)/8_i1p
476  return
477  !---------------------------------------------------------------------------------------------------------------------------------
478  endfunction byte_size_r8p
479 
481  elemental function byte_size_r4p(r) result(bytes)
482  !---------------------------------------------------------------------------------------------------------------------------------
483  implicit none
484  real(R4P), intent(IN):: r
485  integer(I1P):: bytes
486  !---------------------------------------------------------------------------------------------------------------------------------
487 
488  !---------------------------------------------------------------------------------------------------------------------------------
489  bytes = bit_size(r)/8_i1p
490  return
491  !---------------------------------------------------------------------------------------------------------------------------------
492  endfunction byte_size_r4p
493 
495  elemental function byte_size_chr(c) result(bytes)
496  !---------------------------------------------------------------------------------------------------------------------------------
497  implicit none
498  character(*), intent(IN):: c
499  integer(I4P):: bytes
500  !---------------------------------------------------------------------------------------------------------------------------------
501 
502  !---------------------------------------------------------------------------------------------------------------------------------
503  bytes = bit_size(c)/8_i4p
504  return
505  !---------------------------------------------------------------------------------------------------------------------------------
506  endfunction byte_size_chr
507 
509  elemental function strf_r16p(fm,n) result(str)
510  !---------------------------------------------------------------------------------------------------------------------------------
511  implicit none
512  character(*), intent(IN):: fm
513  real(R16P), intent(IN):: n
514  character(DR16P):: str
515  !---------------------------------------------------------------------------------------------------------------------------------
516 
517  !---------------------------------------------------------------------------------------------------------------------------------
518  write(str,trim(fm)) n ! Casting of n to string.
519  return
520  !---------------------------------------------------------------------------------------------------------------------------------
521  endfunction strf_r16p
522 
524  elemental function strf_r8p(fm,n) result(str)
525  !---------------------------------------------------------------------------------------------------------------------------------
526  implicit none
527  character(*), intent(IN):: fm
528  real(R8P), intent(IN):: n
529  character(DR8P):: str
530  !---------------------------------------------------------------------------------------------------------------------------------
531 
532  !---------------------------------------------------------------------------------------------------------------------------------
533  write(str,trim(fm)) n ! Casting of n to string.
534  return
535  !---------------------------------------------------------------------------------------------------------------------------------
536  endfunction strf_r8p
537 
539  elemental function strf_r4p(fm,n) result(str)
540  !---------------------------------------------------------------------------------------------------------------------------------
541  implicit none
542  character(*), intent(IN):: fm
543  real(R4P), intent(IN):: n
544  character(DR4P):: str
545  !---------------------------------------------------------------------------------------------------------------------------------
546 
547  !---------------------------------------------------------------------------------------------------------------------------------
548  write(str,trim(fm)) n ! Casting of n to string.
549  return
550  !---------------------------------------------------------------------------------------------------------------------------------
551  endfunction strf_r4p
552 
554  elemental function strf_i8p(fm,n) result(str)
555  !---------------------------------------------------------------------------------------------------------------------------------
556  implicit none
557  character(*), intent(IN):: fm
558  integer(I8P), intent(IN):: n
559  character(DI8P):: str
560  !---------------------------------------------------------------------------------------------------------------------------------
561 
562  !---------------------------------------------------------------------------------------------------------------------------------
563  write(str,trim(fm)) n ! Casting of n to string.
564  return
565  !---------------------------------------------------------------------------------------------------------------------------------
566  endfunction strf_i8p
567 
569  elemental function strf_i4p(fm,n) result(str)
570  !---------------------------------------------------------------------------------------------------------------------------------
571  implicit none
572  character(*), intent(IN):: fm
573  integer(I4P), intent(IN):: n
574  character(DI4P):: str
575  !---------------------------------------------------------------------------------------------------------------------------------
576 
577  !---------------------------------------------------------------------------------------------------------------------------------
578  write(str,trim(fm)) n ! Casting of n to string.
579  return
580  !---------------------------------------------------------------------------------------------------------------------------------
581  endfunction strf_i4p
582 
584  elemental function strf_i2p(fm,n) result(str)
585  !---------------------------------------------------------------------------------------------------------------------------------
586  implicit none
587  character(*), intent(IN):: fm
588  integer(I2P), intent(IN):: n
589  character(DI2P):: str
590  !---------------------------------------------------------------------------------------------------------------------------------
591 
592  !---------------------------------------------------------------------------------------------------------------------------------
593  write(str,trim(fm)) n ! Casting of n to string.
594  return
595  !---------------------------------------------------------------------------------------------------------------------------------
596  endfunction strf_i2p
597 
599  elemental function strf_i1p(fm,n) result(str)
600  !---------------------------------------------------------------------------------------------------------------------------------
601  implicit none
602  character(*), intent(IN):: fm
603  integer(I1P), intent(IN):: n
604  character(DI1P):: str
605  !---------------------------------------------------------------------------------------------------------------------------------
606 
607  !---------------------------------------------------------------------------------------------------------------------------------
608  write(str,trim(fm)) n ! Casting of n to string.
609  return
610  !---------------------------------------------------------------------------------------------------------------------------------
611  endfunction strf_i1p
612 
614  elemental function str_r16p(no_sign,n) result(str)
615  !---------------------------------------------------------------------------------------------------------------------------------
616  implicit none
617  logical, intent(IN), optional:: no_sign
618  real(R16P), intent(IN):: n
619  character(DR16P):: str
620  !---------------------------------------------------------------------------------------------------------------------------------
621 
622  !---------------------------------------------------------------------------------------------------------------------------------
623  write(str,fr16p) n ! Casting of n to string.
624  if (n>0._r16p) str(1:1)='+' ! Prefixing plus if n>0.
625  if (present(no_sign)) str=str(2:) ! Leaving out the sign.
626  return
627  !---------------------------------------------------------------------------------------------------------------------------------
628  endfunction str_r16p
629 
631  elemental function str_r8p(no_sign,n) result(str)
632  !---------------------------------------------------------------------------------------------------------------------------------
633  implicit none
634  logical, intent(IN), optional:: no_sign
635  real(R8P), intent(IN):: n
636  character(DR8P):: str
637  !---------------------------------------------------------------------------------------------------------------------------------
638 
639  !---------------------------------------------------------------------------------------------------------------------------------
640  write(str,fr8p) n ! Casting of n to string.
641  if (n>0._r8p) str(1:1)='+' ! Prefixing plus if n>0.
642  if (present(no_sign)) str=str(2:) ! Leaving out the sign.
643  return
644  !---------------------------------------------------------------------------------------------------------------------------------
645  endfunction str_r8p
646 
648  elemental function str_r4p(no_sign,n) result(str)
649  !---------------------------------------------------------------------------------------------------------------------------------
650  implicit none
651  logical, intent(IN), optional:: no_sign
652  real(R4P), intent(IN):: n
653  character(DR4P):: str
654  !---------------------------------------------------------------------------------------------------------------------------------
655 
656  !---------------------------------------------------------------------------------------------------------------------------------
657  write(str,fr4p) n ! Casting of n to string.
658  if (n>0._r4p) str(1:1)='+' ! Prefixing plus if n>0.
659  if (present(no_sign)) str=str(2:) ! Leaving out the sign.
660  return
661  !---------------------------------------------------------------------------------------------------------------------------------
662  endfunction str_r4p
663 
665  elemental function str_i8p(no_sign,n) result(str)
666  !---------------------------------------------------------------------------------------------------------------------------------
667  implicit none
668  logical, intent(IN), optional:: no_sign
669  integer(I8P), intent(IN):: n
670  character(DI8P):: str
671  !---------------------------------------------------------------------------------------------------------------------------------
672 
673  !---------------------------------------------------------------------------------------------------------------------------------
674  write(str,fi8p) n ! Casting of n to string.
675  str = adjustl(trim(str)) ! Removing white spaces.
676  if (n>=0_i8p) str='+'//trim(str) ! Prefixing plus if n>0.
677  if (present(no_sign)) str=str(2:) ! Leaving out the sign.
678  return
679  !---------------------------------------------------------------------------------------------------------------------------------
680  endfunction str_i8p
681 
683  elemental function str_i4p(no_sign,n) result(str)
684  !---------------------------------------------------------------------------------------------------------------------------------
685  implicit none
686  logical, intent(IN), optional:: no_sign
687  integer(I4P), intent(IN):: n
688  character(DI4P):: str
689  !---------------------------------------------------------------------------------------------------------------------------------
690 
691  !---------------------------------------------------------------------------------------------------------------------------------
692  write(str,fi4p) n ! Casting of n to string.
693  str = adjustl(trim(str)) ! Removing white spaces.
694  if (n>=0_i4p) str='+'//trim(str) ! Prefixing plus if n>0.
695  if (present(no_sign)) str=str(2:) ! Leaving out the sign.
696  return
697  !---------------------------------------------------------------------------------------------------------------------------------
698  endfunction str_i4p
699 
701  elemental function str_i2p(no_sign,n) result(str)
702  !---------------------------------------------------------------------------------------------------------------------------------
703  implicit none
704  logical, intent(IN), optional:: no_sign
705  integer(I2P), intent(IN):: n
706  character(DI2P):: str
707  !---------------------------------------------------------------------------------------------------------------------------------
708 
709  !---------------------------------------------------------------------------------------------------------------------------------
710  write(str,fi2p) n ! Casting of n to string.
711  str = adjustl(trim(str)) ! Removing white spaces.
712  if (n>=0_i2p) str='+'//trim(str) ! Prefixing plus if n>0.
713  if (present(no_sign)) str=str(2:) ! Leaving out the sign.
714  return
715  !---------------------------------------------------------------------------------------------------------------------------------
716  endfunction str_i2p
717 
719  elemental function str_i1p(no_sign,n) result(str)
720  !---------------------------------------------------------------------------------------------------------------------------------
721  implicit none
722  logical, intent(IN), optional:: no_sign
723  integer(I1P), intent(IN):: n
724  character(DI1P):: str
725  !---------------------------------------------------------------------------------------------------------------------------------
726 
727  !---------------------------------------------------------------------------------------------------------------------------------
728  write(str,fi1p) n ! Casting of n to string.
729  str = adjustl(trim(str)) ! Removing white spaces.
730  if (n>=0_i1p) str='+'//trim(str) ! Prefixing plus if n>0.
731  if (present(no_sign)) str=str(2:) ! Leaving out the sign.
732  return
733  !---------------------------------------------------------------------------------------------------------------------------------
734  endfunction str_i1p
735 
738  elemental function strz_i8p(nz_pad,n) result(str)
739  !---------------------------------------------------------------------------------------------------------------------------------
740  implicit none
741  integer(I4P), intent(IN), optional:: nz_pad
742  integer(I8P), intent(IN):: n
743  character(DI8P):: str
744  !---------------------------------------------------------------------------------------------------------------------------------
745 
746  !---------------------------------------------------------------------------------------------------------------------------------
747  write(str,fi8pzp) n ! Casting of n to string.
748  str=str(2:) ! Leaving out the sign.
749  if (present(nz_pad)) str=str(di8p-nz_pad:di8p-1) ! Leaving out the extra zeros padding
750  return
751  !---------------------------------------------------------------------------------------------------------------------------------
752  endfunction strz_i8p
753 
756  elemental function strz_i4p(nz_pad,n) result(str)
757  !---------------------------------------------------------------------------------------------------------------------------------
758  implicit none
759  integer(I4P), intent(IN), optional:: nz_pad
760  integer(I4P), intent(IN):: n
761  character(DI4P):: str
762  !---------------------------------------------------------------------------------------------------------------------------------
763 
764  !---------------------------------------------------------------------------------------------------------------------------------
765  write(str,fi4pzp) n ! Casting of n to string.
766  str=str(2:) ! Leaving out the sign.
767  if (present(nz_pad)) str=str(di4p-nz_pad:di4p-1) ! Leaving out the extra zeros padding
768  return
769  !---------------------------------------------------------------------------------------------------------------------------------
770  endfunction strz_i4p
771 
774  elemental function strz_i2p(nz_pad,n) result(str)
775  !---------------------------------------------------------------------------------------------------------------------------------
776  implicit none
777  integer(I4P), intent(IN), optional:: nz_pad
778  integer(I2P), intent(IN):: n
779  character(DI2P):: str
780  !---------------------------------------------------------------------------------------------------------------------------------
781 
782  !---------------------------------------------------------------------------------------------------------------------------------
783  write(str,fi2pzp) n ! Casting of n to string.
784  str=str(2:) ! Leaving out the sign.
785  if (present(nz_pad)) str=str(di2p-nz_pad:di2p-1) ! Leaving out the extra zeros padding
786  return
787  !---------------------------------------------------------------------------------------------------------------------------------
788  endfunction strz_i2p
789 
792  elemental function strz_i1p(nz_pad,n) result(str)
793  !---------------------------------------------------------------------------------------------------------------------------------
794  implicit none
795  integer(I4P), intent(IN), optional:: nz_pad
796  integer(I1P), intent(IN):: n
797  character(DI1P):: str
798  !---------------------------------------------------------------------------------------------------------------------------------
799 
800  !---------------------------------------------------------------------------------------------------------------------------------
801  write(str,fi1pzp) n ! Casting of n to string.
802  str=str(2:) ! Leaving out the sign.
803  if (present(nz_pad)) str=str(di1p-nz_pad:di1p-1) ! Leaving out the extra zeros padding
804  return
805  !---------------------------------------------------------------------------------------------------------------------------------
806  endfunction strz_i1p
807 
809  function ctor_r16p(str,knd) result(n)
810  !---------------------------------------------------------------------------------------------------------------------------------
811  implicit none
812  character(*), intent(IN):: str
813  real(R16P), intent(IN):: knd
814  real(R16P):: n
815  integer(I4P):: err
816  !---------------------------------------------------------------------------------------------------------------------------------
817 
818  !---------------------------------------------------------------------------------------------------------------------------------
819  read(str,*,iostat=err) n ! Casting of str to n.
820  if (err/=0) then
821  write(stderr,'(A)') 'Conversion of string "'//str//'" to real failed'
822  write(stderr,'(A,'//fr16p//')') 'Kind parameter ',knd
823  write(stderr,'(A)') 'Function used "ctor_R16P"'
824  endif
825  return
826  !---------------------------------------------------------------------------------------------------------------------------------
827  endfunction ctor_r16p
828 
830  function ctor_r8p(str,knd) result(n)
831  !---------------------------------------------------------------------------------------------------------------------------------
832  implicit none
833  character(*), intent(IN):: str
834  real(R8P), intent(IN):: knd
835  real(R8P):: n
836  integer(I4P):: err
837  !---------------------------------------------------------------------------------------------------------------------------------
838 
839  !---------------------------------------------------------------------------------------------------------------------------------
840  read(str,*,iostat=err) n ! Casting of str to n.
841  if (err/=0) then
842  write(stderr,'(A)') 'Conversion of string "'//str//'" to real failed'
843  write(stderr,'(A,'//fr8p//')') 'Kind parameter ',knd
844  write(stderr,'(A)') 'Function used "ctor_R8P"'
845  endif
846  return
847  !---------------------------------------------------------------------------------------------------------------------------------
848  endfunction ctor_r8p
849 
851  function ctor_r4p(str,knd) result(n)
852  !---------------------------------------------------------------------------------------------------------------------------------
853  implicit none
854  character(*), intent(IN):: str
855  real(R4P), intent(IN):: knd
856  real(R4P):: n
857  integer(I4P):: err
858  !---------------------------------------------------------------------------------------------------------------------------------
859 
860  !---------------------------------------------------------------------------------------------------------------------------------
861  read(str,*,iostat=err) n ! Casting of str to n.
862  if (err/=0) then
863  write(stderr,'(A)') 'Conversion of string "'//str//'" to real failed'
864  write(stderr,'(A,'//fr4p//')') 'Kind parameter ',knd
865  write(stderr,'(A)') 'Function used "ctor_R4P"'
866  endif
867  return
868  !---------------------------------------------------------------------------------------------------------------------------------
869  endfunction ctor_r4p
870 
872  function ctoi_i8p(str,knd) result(n)
873  !---------------------------------------------------------------------------------------------------------------------------------
874  implicit none
875  character(*), intent(IN):: str
876  integer(I8P), intent(IN):: knd
877  integer(I8P):: n
878  integer(I4P):: err
879  !---------------------------------------------------------------------------------------------------------------------------------
880 
881  !---------------------------------------------------------------------------------------------------------------------------------
882  read(str,*,iostat=err) n ! Casting of str to n.
883  if (err/=0) then
884  write(stderr,'(A)') 'Conversion of string "'//str//'" to integer failed'
885  write(stderr,'(A,'//fi8p//')') 'Kind parameter ',knd
886  write(stderr,'(A)') 'Function used "ctoi_I8P"'
887  endif
888  return
889  !---------------------------------------------------------------------------------------------------------------------------------
890  endfunction ctoi_i8p
891 
893  function ctoi_i4p(str,knd) result(n)
894  !---------------------------------------------------------------------------------------------------------------------------------
895  implicit none
896  character(*), intent(IN):: str
897  integer(I4P), intent(IN):: knd
898  integer(I4P):: n
899  integer(I4P):: err
900  !---------------------------------------------------------------------------------------------------------------------------------
901 
902  !---------------------------------------------------------------------------------------------------------------------------------
903  read(str,*,iostat=err) n ! Casting of str to n.
904  if (err/=0) then
905  write(stderr,'(A)') 'Conversion of string "'//str//'" to integer failed'
906  write(stderr,'(A,'//fi4p//')') 'Kind parameter ',knd
907  write(stderr,'(A)') 'Function used "ctoi_I4P"'
908  endif
909  return
910  !---------------------------------------------------------------------------------------------------------------------------------
911  endfunction ctoi_i4p
912 
914  function ctoi_i2p(str,knd) result(n)
915  !---------------------------------------------------------------------------------------------------------------------------------
916  implicit none
917  character(*), intent(IN):: str
918  integer(I2P), intent(IN):: knd
919  integer(I2P):: n
920  integer(I4P):: err
921  !---------------------------------------------------------------------------------------------------------------------------------
922 
923  !---------------------------------------------------------------------------------------------------------------------------------
924  read(str,*,iostat=err) n ! Casting of str to n.
925  if (err/=0) then
926  write(stderr,'(A)') 'Conversion of string "'//str//'" to integer failed'
927  write(stderr,'(A,'//fi2p//')') 'Kind parameter ',knd
928  write(stderr,'(A)') 'Function used "ctoi_I2P"'
929  endif
930  return
931  !---------------------------------------------------------------------------------------------------------------------------------
932  endfunction ctoi_i2p
933 
935  function ctoi_i1p(str,knd) result(n)
936  !---------------------------------------------------------------------------------------------------------------------------------
937  implicit none
938  character(*), intent(IN):: str
939  integer(I1P), intent(IN):: knd
940  integer(I1P):: n
941  integer(I4P):: err
942  !---------------------------------------------------------------------------------------------------------------------------------
943 
944  !---------------------------------------------------------------------------------------------------------------------------------
945  read(str,*,iostat=err) n ! Casting of str to n.
946  if (err/=0) then
947  write(stderr,'(A)') 'Conversion of string "'//str//'" to integer failed'
948  write(stderr,'(A,'//fi1p//')') 'Kind parameter ',knd
949  write(stderr,'(A)') 'Function used "ctoi_I1P"'
950  endif
951  return
952  !---------------------------------------------------------------------------------------------------------------------------------
953  endfunction ctoi_i1p
954 
957  elemental function bstr_r16p(n) result(bstr)
958  !---------------------------------------------------------------------------------------------------------------------------------
959  implicit none
960  real(R8P), intent(IN):: n
961  character(128):: bstr
962  !---------------------------------------------------------------------------------------------------------------------------------
963 
964  !---------------------------------------------------------------------------------------------------------------------------------
965  write(bstr,'(B128.128)')n ! Casting of n to bit-string.
966  return
967  !---------------------------------------------------------------------------------------------------------------------------------
968  endfunction bstr_r16p
969 
972  elemental function bstr_r8p(n) result(bstr)
973  !---------------------------------------------------------------------------------------------------------------------------------
974  implicit none
975  real(R8P), intent(IN):: n
976  character(64):: bstr
977  !---------------------------------------------------------------------------------------------------------------------------------
978 
979  !---------------------------------------------------------------------------------------------------------------------------------
980  write(bstr,'(B64.64)')n ! Casting of n to bit-string.
981  return
982  !---------------------------------------------------------------------------------------------------------------------------------
983  endfunction bstr_r8p
984 
987  elemental function bstr_r4p(n) result(bstr)
988  !---------------------------------------------------------------------------------------------------------------------------------
989  implicit none
990  real(R4P), intent(IN):: n
991  character(32):: bstr
992  !---------------------------------------------------------------------------------------------------------------------------------
993 
994  !---------------------------------------------------------------------------------------------------------------------------------
995  write(bstr,'(B32.32)')n ! Casting of n to bit-string.
996  return
997  !---------------------------------------------------------------------------------------------------------------------------------
998  endfunction bstr_r4p
999 
1002  elemental function bstr_i8p(n) result(bstr)
1003  !---------------------------------------------------------------------------------------------------------------------------------
1004  implicit none
1005  integer(I8P), intent(IN):: n
1006  character(64):: bstr
1007  !---------------------------------------------------------------------------------------------------------------------------------
1008 
1009  !---------------------------------------------------------------------------------------------------------------------------------
1010  write(bstr,'(B64.64)')n ! Casting of n to bit-string.
1011  return
1012  !---------------------------------------------------------------------------------------------------------------------------------
1013  endfunction bstr_i8p
1014 
1017  elemental function bstr_i4p(n) result(bstr)
1018  !---------------------------------------------------------------------------------------------------------------------------------
1019  implicit none
1020  integer(I4P), intent(IN):: n
1021  character(32):: bstr
1022  !---------------------------------------------------------------------------------------------------------------------------------
1023 
1024  !---------------------------------------------------------------------------------------------------------------------------------
1025  write(bstr,'(B32.32)')n ! Casting of n to bit-string.
1026  return
1027  !---------------------------------------------------------------------------------------------------------------------------------
1028  endfunction bstr_i4p
1029 
1032  elemental function bstr_i2p(n) result(bstr)
1033  !---------------------------------------------------------------------------------------------------------------------------------
1034  implicit none
1035  integer(I2P), intent(IN):: n
1036  character(16):: bstr
1037  !---------------------------------------------------------------------------------------------------------------------------------
1038 
1039  !---------------------------------------------------------------------------------------------------------------------------------
1040  write(bstr,'(B16.16)')n ! Casting of n to bit-string.
1041  return
1042  !---------------------------------------------------------------------------------------------------------------------------------
1043  endfunction bstr_i2p
1044 
1047  elemental function bstr_i1p(n) result(bstr)
1048  !---------------------------------------------------------------------------------------------------------------------------------
1049  implicit none
1050  integer(I1P), intent(IN):: n
1051  character(8):: bstr
1052  !---------------------------------------------------------------------------------------------------------------------------------
1053 
1054  !---------------------------------------------------------------------------------------------------------------------------------
1055  write(bstr,'(B8.8)')n ! Casting of n to bit-string.
1056  return
1057  !---------------------------------------------------------------------------------------------------------------------------------
1058  endfunction bstr_i1p
1059 
1061  elemental function bctor_r8p(bstr,knd) result(n)
1062  !---------------------------------------------------------------------------------------------------------------------------------
1063  implicit none
1064  character(*), intent(IN):: bstr
1065  real(R8P), intent(IN):: knd
1066  real(R8P):: n
1067  !---------------------------------------------------------------------------------------------------------------------------------
1068 
1069  !---------------------------------------------------------------------------------------------------------------------------------
1070  read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
1071  return
1072  !---------------------------------------------------------------------------------------------------------------------------------
1073  endfunction bctor_r8p
1074 
1076  elemental function bctor_r4p(bstr,knd) result(n)
1077  !---------------------------------------------------------------------------------------------------------------------------------
1078  implicit none
1079  character(*), intent(IN):: bstr
1080  real(R4P), intent(IN):: knd
1081  real(R4P):: n
1082  !---------------------------------------------------------------------------------------------------------------------------------
1083 
1084  !---------------------------------------------------------------------------------------------------------------------------------
1085  read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
1086  return
1087  !---------------------------------------------------------------------------------------------------------------------------------
1088  endfunction bctor_r4p
1089 
1091  elemental function bctoi_i8p(bstr,knd) result(n)
1092  !---------------------------------------------------------------------------------------------------------------------------------
1093  implicit none
1094  character(*), intent(IN):: bstr
1095  integer(I8P), intent(IN):: knd
1096  integer(I8P):: n
1097  !---------------------------------------------------------------------------------------------------------------------------------
1098 
1099  !---------------------------------------------------------------------------------------------------------------------------------
1100  read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
1101  return
1102  !---------------------------------------------------------------------------------------------------------------------------------
1103  endfunction bctoi_i8p
1104 
1106  elemental function bctoi_i4p(bstr,knd) result(n)
1107  !---------------------------------------------------------------------------------------------------------------------------------
1108  implicit none
1109  character(*), intent(IN):: bstr
1110  integer(I4P), intent(IN):: knd
1111  integer(I4P):: n
1112  !---------------------------------------------------------------------------------------------------------------------------------
1113 
1114  !---------------------------------------------------------------------------------------------------------------------------------
1115  read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
1116  return
1117  !---------------------------------------------------------------------------------------------------------------------------------
1118  endfunction bctoi_i4p
1119 
1121  elemental function bctoi_i2p(bstr,knd) result(n)
1122  !---------------------------------------------------------------------------------------------------------------------------------
1123  implicit none
1124  character(*), intent(IN):: bstr
1125  integer(I2P), intent(IN):: knd
1126  integer(I2P):: n
1127  !---------------------------------------------------------------------------------------------------------------------------------
1128 
1129  !---------------------------------------------------------------------------------------------------------------------------------
1130  read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
1131  return
1132  !---------------------------------------------------------------------------------------------------------------------------------
1133  endfunction bctoi_i2p
1134 
1136  elemental function bctoi_i1p(bstr,knd) result(n)
1137  !---------------------------------------------------------------------------------------------------------------------------------
1138  implicit none
1139  character(*), intent(IN):: bstr
1140  integer(I1P), intent(IN):: knd
1141  integer(I1P):: n
1142  !---------------------------------------------------------------------------------------------------------------------------------
1143 
1144  !---------------------------------------------------------------------------------------------------------------------------------
1145  read(bstr,'(B'//trim(str(.true.,bit_size(knd)))//'.'//trim(str(.true.,bit_size(knd)))//')')n ! Casting of bstr to n.
1146  return
1147  !---------------------------------------------------------------------------------------------------------------------------------
1148  endfunction bctoi_i1p
1150 
1153  subroutine ir_init()
1154  !---------------------------------------------------------------------------------------------------------------------------------
1155  implicit none
1156  !---------------------------------------------------------------------------------------------------------------------------------
1157 
1158  !---------------------------------------------------------------------------------------------------------------------------------
1159  ! checking the bit ordering architecture
1160  call check_endian
1161  ! computing the bits/bytes sizes of real variables
1162  bir8p = bit_size(r=maxr8p) ; byr8p = bir8p/8_i1p
1163  bir4p = bit_size(r=maxr4p) ; byr4p = bir4p/8_i1p
1164  bir_p = bit_size(r=maxr_p) ; byr_p = bir_p/8_i1p
1165 #ifdef r16p
1166  bir16p = bit_size(r=maxr16p) ; byr16p = bir16p/8_i2p
1167 #else
1168  bir16p = int(bir8p,kind=i2p) ; byr16p = bir16p/8_i2p
1169 #endif
1170  ir_initialized = .true.
1171  return
1172  !---------------------------------------------------------------------------------------------------------------------------------
1173  endsubroutine ir_init
1177  subroutine ir_print(myrank,Nproc)
1178  !---------------------------------------------------------------------------------------------------------------------------------
1179  implicit none
1180  integer(I4P), intent(IN), optional:: myrank
1181  integer(I4P), intent(IN), optional:: nproc
1182  character(DI4P):: rks
1183  integer(I4P):: rank,np
1184  !---------------------------------------------------------------------------------------------------------------------------------
1185 
1186  !---------------------------------------------------------------------------------------------------------------------------------
1187  if (.not.ir_initialized) call ir_init
1188  rank = 0 ; if (present(myrank)) rank = myrank ; np = 1 ; if (present(nproc)) np = nproc ; rks = 'rank'//trim(strz(np,rank))
1189  ! printing informations
1190  if (endian==endianl) then
1191  write(stdout,'(A)') trim(rks)//' This architecture has LITTLE Endian bit ordering'
1192  else
1193  write(stdout,'(A)') trim(rks)//' This architecture has BIG Endian bit ordering'
1194  endif
1195  write(stdout,'(A)') trim(rks)//' Reals kind precision definition'
1196  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R16P Kind "',r16p,'" | FR16P format "'//fr16p//'" | DR16P chars "',dr16p,'"'
1197  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R8P Kind "',r8p, '" | FR8P format "'//fr8p// '" | DR8P chars "',dr8p ,'"'
1198  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R4P Kind "',r4p, '" | FR4P format "'//fr4p//'" | DR4P chars "',dr4p ,'"'
1199  write(stdout,'(A)') trim(rks)//' Integers kind precision definition'
1200  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I8P Kind "',i8p,'" | FI8P format "'//fi8p// '" | DI8P chars "',di8p,'"'
1201  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I4P Kind "',i4p,'" | FI4P format "'//fi4p// '" | DI4P chars "',di4p,'"'
1202  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I2P Kind "',i2p,'" | FI2P format "'//fi2p//'" | DI2P chars "',di2p,'"'
1203  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I1P Kind "',i1p,'" | FI1P format "'//fi1p//'" | DI1P chars "',di1p,'"'
1204  write(stdout,'(A)') trim(rks)//' Reals minimum and maximum values'
1205  write(stdout,'(A)') trim(rks)//' MinR16P "'//trim(str(n=minr16p))//'" | MaxR16P "'//trim(str(n=maxr16p))//'"'
1206  write(stdout,'(A)') trim(rks)//' MinR8P "'//trim(str(n=minr8p))// '" | MaxR8P "'//trim(str(n=maxr8p))// '"'
1207  write(stdout,'(A)') trim(rks)//' MinR4P "'//trim(str(n=minr4p))// '" | MaxR4P "'//trim(str(n=maxr4p))// '"'
1208  write(stdout,'(A)') trim(rks)//' Reals bits/bytes sizes'
1209  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R16P bits "',bir16p,'", bytes "',byr16p,'"'
1210  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R8P bits "', bir8p, '", bytes "',byr8p, '"'
1211  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R4P bits "', bir4p, '", bytes "',byr4p, '"'
1212  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' R_P bits "', bir_p, '", bytes "',byr_p, '"'
1213  write(stdout,'(A)') trim(rks)//' Integers minimum and maximum values'
1214  write(stdout,'(A)') trim(rks)//' MinI8P "'//trim(str(n=mini8p))//'" | MaxI8P "'//trim(str(n=maxi8p))//'"'
1215  write(stdout,'(A)') trim(rks)//' MinI4P "'//trim(str(n=mini4p))//'" | MaxI4P "'//trim(str(n=maxi4p))//'"'
1216  write(stdout,'(A)') trim(rks)//' MinI2P "'//trim(str(n=mini2p))//'" | MaxI2P "'//trim(str(n=maxi2p))//'"'
1217  write(stdout,'(A)') trim(rks)//' MinI1P "'//trim(str(n=mini1p))//'" | MaxI1P "'//trim(str(n=maxi1p))//'"'
1218  write(stdout,'(A)') trim(rks)//' Integers bits/bytes sizes'
1219  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I8P bits "',bii8p,'", bytes "',byi8p,'"'
1220  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I4P bits "',bii4p,'", bytes "',byi4p,'"'
1221  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I2P bits "',bii2p,'", bytes "',byi2p,'"'
1222  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I1P bits "',bii1p,'", bytes "',byi1p,'"'
1223  write(stdout,'(A,I2,A,I2,A)')trim(rks)//' I_P bits "',bii_p,'", bytes "',byi_p,'"'
1224  write(stdout,'(A)') trim(rks)//' Machine precisions'
1225  write(stdout,'(A)') trim(rks)//' ZeroR16 "'//trim(str(.true.,zeror16))//'"'
1226  write(stdout,'(A)') trim(rks)//' ZeroR8 "'//trim(str(.true.,zeror8 ))//'"'
1227  write(stdout,'(A)') trim(rks)//' ZeroR4 "'//trim(str(.true.,zeror4 ))//'"'
1228  !---------------------------------------------------------------------------------------------------------------------------------
1229  endsubroutine ir_print
1230 endmodule ir_precision
integer(i2p), public byr16p
Number of bits/bytes of kind=R16P variable.
integer, parameter, public di2p
Number of digits of output format I2P.
character(8), parameter fi4pzp
Output format with zero prefixing for kind=I4P variable.
integer, parameter, public endianl
Little endian parameter.
integer(i_p), parameter, public maxi_p
Min and max values of kind=I_P variable.
integer(i2p), public bir16p
elemental character(dr16p) function str_r16p(no_sign, n)
Procedure for converting real to string.
subroutine, public check_endian()
Subroutine for checking the type of bit ordering (big or little endian) of the running architecture; ...
elemental integer(i1p) function byte_size_i4p(i)
Procedure for computing the number of bytes of an integer variable.
real(r16p), parameter, public smallr16p
Smallest representable value of kind=R16P variable.
real(r4p), parameter, public minr4p
Procedure for converting string to number, real or initeger, (string to number type casting); string...
integer(i8p), parameter, public mini8p
elemental character(di4p) function str_i4p(no_sign, n)
Procedure for converting integer to string.
real(r8p), parameter, public smallr8p
Smallest representable value of kind=R8P variable.
real(r4p), parameter, public smallr4p
Smallest representable value of kind=R4P variable.
elemental character(di4p) function strz_i4p(nz_pad, n)
Procedure for converting integer to string, prefixing with the right number of zeros.
character(8), parameter fi8pzp
Output format with zero prefixing for kind=I8P variable.
character(10), parameter, public fr8p
Output format for kind=R8P variable.
integer(i1p), public bir8p
elemental character(64) function bstr_i8p(n)
Procedure for converting integer to string of bits.
integer(i2p), parameter, public bii2p
integer(i2p) function ctoi_i2p(str, knd)
Procedure for converting string to integer.
elemental integer(i2p) function bit_size_r16p(r)
Procedure for computing the number of bits of a real variable.
integer, parameter, public niknd
Number of defined integer kinds.
integer(i1p), public bir4p
integer, parameter, public r4p
6 digits, range ; 32 bits.
elemental integer(i1p) function byte_size_i8p(i)
Procedure for computing the number of bytes of an integer variable.
integer, parameter, public endianb
Big endian parameter.
elemental integer(i4p) function bit_size_chr(c)
Procedure for computing the number of bits of a character variable.
Procedure for converting number, real and integer, to bit-string (number to bit-string type casting);...
elemental character(di1p) function strz_i1p(nz_pad, n)
Procedure for converting integer to string, prefixing with the right number of zeros.
real(r16p), parameter, public minr16p
Overloading of the "byte_size" function for computing the number of bytes.
real(r4p) function ctor_r4p(str, knd)
Procedure for converting string to real.
elemental character(32) function bstr_r4p(n)
Procedure for converting real to string of bits.
elemental character(di2p) function strz_i2p(nz_pad, n)
Procedure for converting integer to string, prefixing with the right number of zeros.
elemental integer(i4p) function bctoi_i4p(bstr, knd)
Procedure for converting bit-string to integer.
real(r16p), parameter, public zeror16
Smallest representable difference of kind=R16P variable.
character(10), parameter, public fr_p
Output format for kind=R_P variable.
logical, public ir_initialized
Flag for chcecking the initialization of some variables that must be initialized by IR_Init...
integer(i4p), parameter, public byi4p
Number of bits/bytes of kind=I4P variable.
elemental character(dr8p) function strf_r8p(fm, n)
Procedure for converting real to string.
elemental integer(i8p) function bctoi_i8p(bstr, knd)
Procedure for converting bit-string to integer.
integer(i8p), parameter, public byi8p
Number of bits/bytes of kind=I8P variable.
integer(i1p), public byr_p
Number of bits/bytes of kind=R_P variable.
real(r_p), parameter, public smallr_p
Smallest representable value of kind=R_P variable.
elemental character(8) function bstr_i1p(n)
Procedure for converting integer to string of bits.
real(r_p), parameter, public minr_p
character(6), parameter fi2pzp
Output format with zero prefixing for kind=I2P variable.
elemental integer(i1p) function byte_size_r16p(r)
Procedure for computing the number of bytes of a real variable.
integer, parameter, public i8p
Range , 19 digits plus sign; 64 bits.
elemental character(di2p) function str_i2p(no_sign, n)
Procedure for converting integer to string.
elemental character(64) function bstr_r8p(n)
Procedure for converting real to string of bits.
character(5), dimension(1:niknd), parameter, public fil
List of defined integer kinds output format.
elemental character(di4p) function strf_i4p(fm, n)
Procedure for converting integer to string.
integer, parameter, public dr16p
Number of digits of output format FR16P.
integer(i_p), parameter, public bii_p
integer(i1p), parameter, public mini1p
integer(i4p), parameter, public bii4p
integer(i2p), parameter, public mini2p
elemental character(di8p) function str_i8p(no_sign, n)
Procedure for converting integer to string.
integer(i_p), parameter, public byi_p
Number of bits/bytes of kind=I_P variable.
elemental integer(i1p) function byte_size_i2p(i)
Procedure for computing the number of bytes of an integer variable.
integer(i1p), parameter, public byi1p
Number of bits/bytes of kind=I1P variable.
integer(i2p), parameter, public maxi2p
Min and max values of kind=I2P variable.
integer(i4p) function ctoi_i4p(str, knd)
Procedure for converting string to integer.
elemental character(di1p) function str_i1p(no_sign, n)
Procedure for converting integer to string.
Overloading of the intrinsic "bit_size" function for computing the number of bits of (also) real and ...
elemental real(r8p) function bctor_r8p(bstr, knd)
Procedure for converting bit-string to real.
integer(i8p), parameter, public bii8p
elemental character(dr8p) function str_r8p(no_sign, n)
Procedure for converting real to string.
integer, parameter, public i1p
Range , 3 digits plus sign; 8 bits.
character(5), parameter, public fi8p
Output format for kind=I8P variable.
real(r_p), parameter, public maxr_p
Min and max values of kind=R_P variable.
integer(i1p), parameter, public bii1p
elemental character(di8p) function strz_i8p(nz_pad, n)
Procedure for converting integer to string, prefixing with the right number of zeros.
integer(i_p), parameter, public mini_p
real(r16p) function ctor_r16p(str, knd)
Procedure for converting string to real.
elemental character(dr4p) function str_r4p(no_sign, n)
Procedure for converting real to string.
character(5), parameter, public fi4p
Output format for kind=I4P variable.
elemental integer(i2p) function bctoi_i2p(bstr, knd)
Procedure for converting bit-string to integer.
Procedure for converting number, real and integer, to string (number to string type casting); logical...
integer, parameter, public di8p
Number of digits of output format I8P.
integer(i8p), parameter, public maxi8p
Min and max values of kind=I8P variable.
elemental character(32) function bstr_i4p(n)
Procedure for converting integer to string of bits.
integer, parameter, public dr4p
Number of digits of output format FR4P.
integer, public endian
Bit ordering: Little endian (endianL), or Big endian (endianB).
Procedure for converting bit-string to number, real or initeger, (bit-string to number type casting);...
integer(i2p), parameter, public byi2p
Number of bits/bytes of kind=I2P variable.
integer(i1p), public byr8p
Number of bits/bytes of kind=R8P variable.
integer, parameter, public r8p
15 digits, range ; 64 bits.
real(r_p), parameter, public zero
Smallest representable difference of kind=R_P variable.
integer, parameter, public i4p
Range , 10 digits plus sign; 32 bits.
integer, parameter, public dr_p
Number of digits of output format FR_P.
real(r8p), parameter, public minr8p
subroutine, public ir_init()
Subroutine for initilizing module's variables that are not initialized into the definition specificat...
integer, dimension(1:nrknd), parameter, public rpl
List of defined real kinds.
real(r16p), parameter, public maxr16p
Min and max values of kind=R16P variable.
character(6), parameter fi1pzp
Output format with zero prefixing for kind=I1P variable.
integer, parameter, public di4p
Number of digits of output format I4P.
integer, parameter, public dr8p
Number of digits of output format FR8P.
integer(i1p), public bir_p
integer, parameter, public nrknd
Number of defined real kinds.
integer, parameter, public r_p
Default real precision.
real(r4p), parameter, public maxr4p
Min and max values of kind=R4P variable.
character(8), parameter fi_pzp
Output format with zero prefixing for kind=I_P variable.
elemental character(di2p) function strf_i2p(fm, n)
Procedure for converting integer to string.
character(4), parameter, public fi2p
Output format for kind=I2P variable.
integer(i8p) function ctoi_i8p(str, knd)
Procedure for converting string to integer.
elemental integer(i4p) function byte_size_chr(c)
Procedure for computing the number of bytes of a character variable.
integer(i4p), parameter, public maxi4p
Min and max values of kind=I4P variable.
elemental integer(i1p) function byte_size_r8p(r)
Procedure for computing the number of bytes of a real variable.
character(4), parameter, public fi1p
Output format for kind=I1P variable.
character(10), dimension(1:nrknd), parameter, public frl
List of defined real kinds output format.
integer, parameter, public i2p
Range , 5 digits plus sign; 16 bits.
elemental integer(i1p) function byte_size_i1p(i)
Procedure for computing the number of bytes of an integer variable.
character(10), parameter, public fr16p
Output format for kind=R16P variable.
real(r8p) function ctor_r8p(str, knd)
Procedure for converting string to real.
integer(i1p) function ctoi_i1p(str, knd)
Procedure for converting string to integer.
elemental integer(i1p) function bctoi_i1p(bstr, knd)
Procedure for converting bit-string to integer.
integer, parameter, public r16p
Defined as R8P; 64 bits.
Procedure for converting number, integer, to string, prefixing with the right number of zeros (number...
integer(i1p), parameter, public maxi1p
Min and max values of kind=I1P variable.
subroutine, public ir_print(myrank, Nproc)
Subroutine for printing to the standard output the kind definition of reals and integers and the util...
integer, parameter, public di1p
Number of digits of output format I1P.
elemental character(dr4p) function strf_r4p(fm, n)
Procedure for converting real to string.
real(r8p), parameter, public maxr8p
Min and max values of kind=R8P variable.
integer, parameter, public i_p
Default integer precision.
real(r4p), parameter, public zeror4
Smallest representable difference of kind=R4P variable.
character(5), parameter, public fi_p
Output format for kind=I_P variable.
pure logical function is_little_endian()
Procedure for checking if the type of the bit ordering of the running architecture is little endian...
elemental character(16) function bstr_i2p(n)
Procedure for converting integer to string of bits.
elemental character(128) function bstr_r16p(n)
Procedure for converting real to string of bits.
elemental integer(i1p) function byte_size_r4p(r)
Procedure for computing the number of bytes of a real variable.
integer, dimension(1:niknd), parameter, public ril
List of defined integer kinds.
integer(i1p), public byr4p
Number of bits/bytes of kind=R4P variable.
character(9), parameter, public fr4p
Output format for kind=R4P variable.
elemental real(r4p) function bctor_r4p(bstr, knd)
Procedure for converting bit-string to real.
elemental character(dr16p) function strf_r16p(fm, n)
Procedure for converting real to string.
real(r8p), parameter, public zeror8
Smallest representable difference of kind=R8P variable.
integer, parameter, public di_p
Number of digits of output format I_P.
integer(i4p), parameter, public mini4p
elemental character(di1p) function strf_i1p(fm, n)
Procedure for converting integer to string.
elemental integer(i1p) function bit_size_r8p(r)
Procedure for computing the number of bits of a real variable.
elemental character(di8p) function strf_i8p(fm, n)
Procedure for converting integer to string.
elemental integer(i1p) function bit_size_r4p(r)
Procedure for computing the number of bits of a real variable.
Module IR_Precision makes available some portable kind-parameters and some useful procedures to deal ...