112 real(kind=SINGLE_PRECISION),
intent(in) :: input_real
115 REAL_ROUNDING_PRECISION) / real_rounding_precision
123 character(len=*),
intent(in) :: string
125 integer :: integer_value, ierr
127 if (len(trim(string)) .ne. 0)
then 128 read(string,
'(i10)', iostat=ierr ) integer_value
139 character(len=*),
intent(in) :: string
144 if (len(trim(string)) .ne. 0)
then 145 read(string,
'(f10.2)', iostat=ierr ) real_value
156 character(len=*),
intent(in) :: string
159 if (trim(adjustl(string)) .eq.
"true" .or. trim(adjustl(string)) .eq.
"false" .or. &
160 trim(adjustl(string)) .eq.
".true." .or. trim(adjustl(string)) .eq.
".false." .or. &
161 trim(adjustl(string)) .eq.
".true" .or. trim(adjustl(string)) .eq.
"true." .or. &
162 trim(adjustl(string)) .eq.
".false" .or. trim(adjustl(string)) .eq.
"false.")
string_is_logical = .true.
171 class(*),
pointer,
intent(in) :: generic
172 logical,
intent(in) :: makecopy
173 integer,
intent(in) :: str_length
174 character(len=str_length),
pointer :: generic_to_string, temporary_generic_ptr
177 type is (
character(len=*))
180 temporary_generic_ptr=>generic
181 allocate(generic_to_string, source=temporary_generic_ptr)
183 generic_to_string=>generic
186 generic_to_string=>null()
194 integer,
intent(in) :: input
195 character(len=15) :: integer_to_string
197 write(integer_to_string,
'(i15)' ) input
198 integer_to_string = trim(adjustl(integer_to_string))
205 real(kind=SINGLE_PRECISION),
intent(in) :: input
206 character(len=30) :: real_single_to_string
207 integer,
optional :: decimal_places
208 logical,
optional :: exponent, exponent_small_numbers
210 logical :: transformed
213 if (
present(exponent))
then 215 write(real_single_to_string,
'(es30.10)' ) input
219 if (
present(exponent_small_numbers))
then 220 if (exponent_small_numbers)
then 221 write(real_single_to_string,
'(g30.10)' ) input
225 if (.not. transformed)
then 226 write(real_single_to_string,
'(f30.10)' ) input
227 if (scan(real_single_to_string,
"*") .ne. 0)
write(real_single_to_string,
'(es30.10)' ) input
232 real_single_to_string = trim(adjustl(real_single_to_string))
239 real(kind=DOUBLE_PRECISION),
intent(in) :: input
240 character(len=30) :: real_double_to_string
241 integer,
optional :: decimal_places
242 logical,
optional :: exponent, exponent_small_numbers
244 logical :: transformed
247 if (
present(exponent))
then 249 write(real_double_to_string,
'(es30.10)' ) input
253 if (
present(exponent_small_numbers))
then 254 if (exponent_small_numbers)
then 255 write(real_double_to_string,
'(g30.10)' ) input
259 if (.not. transformed)
then 260 write(real_double_to_string,
'(f30.10)' ) input
261 if (scan(real_double_to_string,
"*") .ne. 0)
write(real_double_to_string,
'(es30.10)' ) input
264 if (
present(decimal_places))
then 268 real_double_to_string = trim(adjustl(real_double_to_string))
276 character(len=*),
intent(inout) :: string_to_parse
277 integer,
intent(in) :: decimal_places
279 integer :: decimal_posn, exp_posn
281 string_to_parse=adjustl(string_to_parse)
282 decimal_posn=index(string_to_parse,
".")
283 exp_posn=index(string_to_parse,
"E")
284 if (decimal_posn .ne. 0 .and. decimal_posn+decimal_places+1 .le. len(string_to_parse))
then 285 if (exp_posn .eq. 0)
then 286 string_to_parse(decimal_posn+decimal_places+1:)=
" " 288 string_to_parse(decimal_posn+decimal_places+1:)=string_to_parse(exp_posn:)
289 string_to_parse(decimal_posn+decimal_places+1+(len(string_to_parse)-exp_posn)+1:)=
" " 299 character(len=*),
intent(inout) :: string_to_parse
300 integer,
intent(in) :: zeros_to_retain
302 integer :: decimal_posn, i, zero_count, nonzero_hit
306 decimal_posn=index(string_to_parse,
".")
307 if (decimal_posn .ne. 0 .and. decimal_posn .lt. len(string_to_parse))
then 308 do i=len(trim(string_to_parse)), decimal_posn, -1
309 if (string_to_parse(i:i) .ne.
"0")
then 313 zero_count=zero_count+1
316 if (zero_count .gt. zeros_to_retain)
then 317 string_to_parse(nonzero_hit+zeros_to_retain:)=
"" 326 logical,
intent(in) :: input
327 character(len=5) :: logical_to_string
330 logical_to_string =
"true" 332 logical_to_string =
"false" 341 class(*),
pointer,
intent(in) :: generic
342 logical,
intent(in) :: makecopy
343 logical,
pointer :: generic_to_logical
348 allocate(generic_to_logical, source=generic)
350 generic_to_logical=>generic
353 generic_to_logical=>null()
361 character(len=*),
intent(in) :: string
363 if (trim(adjustl(string)) .eq.
"true" .or. trim(adjustl(string)) .eq.
".true." .or. &
364 trim(adjustl(string)) .eq.
".true" .or. trim(adjustl(string)) .eq.
"true.")
then 375 integer,
intent(in) :: input
377 if (input .ge. 1)
then 388 real,
intent(in) :: input
390 if (input .ge. 1.0)
then 402 class(*),
pointer,
intent(in) :: generic
403 logical,
intent(in) :: makecopy
404 real(kind=DEFAULT_PRECISION),
pointer :: generic_to_double_real
409 allocate(generic_to_double_real, source=generic)
411 generic_to_double_real=>generic
414 generic_to_double_real=>null()
423 class(*),
pointer,
intent(in) :: generic
424 logical,
intent(in) :: makecopy
425 real,
pointer :: generic_to_real
430 allocate(generic_to_real, source=generic)
432 generic_to_real=>generic
435 allocate(generic_to_real)
438 generic_to_real=>null()
446 character(len=*),
intent(in) :: string
448 if (scan(string,
"E") .ne. 0 .or. scan(string,
"e") .ne. 0)
then 459 integer,
intent(in) :: input
468 logical,
intent(in) :: input
482 class(*),
pointer,
intent(in) :: generic
483 logical,
intent(in) :: makecopy
484 integer,
pointer :: generic_to_integer
489 allocate(generic_to_integer, source=generic)
491 generic_to_integer=>generic
494 generic_to_integer=>null()
502 character(len=*),
intent(in) :: string
511 real,
intent(in) :: input
520 logical,
intent(in) :: input
534 character(len=*),
target,
intent(in) :: string
535 logical,
intent(in) :: makecopy
536 class(*),
pointer :: string_to_generic
539 allocate(string_to_generic, source=string)
541 string_to_generic=>string
550 integer,
target ,
intent(in) :: input
551 logical,
intent(in) :: makecopy
552 class(*),
pointer :: integer_to_generic
555 allocate(integer_to_generic, source=input)
557 integer_to_generic=>input
566 real(kind=SINGLE_PRECISION),
target,
intent(in) :: input
567 logical,
intent(in) :: makecopy
568 class(*),
pointer :: real_single_to_generic
571 allocate(real_single_to_generic, source=input)
573 real_single_to_generic=>input
582 real(kind=DOUBLE_PRECISION),
target,
intent(in) :: input
583 logical,
intent(in) :: makecopy
584 class(*),
pointer :: real_double_to_generic
587 allocate(real_double_to_generic, source=input)
589 real_double_to_generic=>input
598 logical,
target,
intent(in) :: input
599 logical,
intent(in) :: makecopy
600 class(*),
pointer :: logical_to_generic
603 allocate(logical_to_generic, source=input)
605 logical_to_generic=>input
class(*) function, pointer logical_to_generic(input, makecopy)
Converts a logical into its generic data representation.
real function string_to_real(string)
Converts a string to a real.
class(*) function, pointer integer_to_generic(input, makecopy)
Converts an integer into its generic data representation.
logical function integer_to_logical(input)
Converts an integer to a logical.
logical function string_is_real(string)
Determines whether a string is a real or not.
logical function, pointer generic_to_logical(generic, makecopy)
Converts a generic to a logical.
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Converts a data type into the generic (class *) form.
Contains common definitions for the data and datatypes used by MONC.
real function logical_to_real(input)
Converts a logical to a real.
subroutine trim_trailing_zeros(string_to_parse, zeros_to_retain)
A helper subroutine which trims training zeros from the string after a decimal place this is to make ...
Conversion between common inbuilt FORTRAN data types.
Converts data types to strings.
integer, parameter, public single_precision
Single precision (32 bit) kind.
integer function logical_to_integer(input)
Converts a logical to an integer.
logical function string_is_logical(string)
Determines whether a string is a logical or not.
Converts data types to logical.
character(len=30) function real_single_to_string(input, decimal_places, exponent, exponent_small_numbers)
Converts a single precision real to a string.
integer, parameter, public double_precision
Double precision (64 bit) kind.
logical function string_to_logical(string)
Converts a string to a logical.
character(len=30) function real_double_to_string(input, decimal_places, exponent, exponent_small_numbers)
Converts a double precision real to a string.
integer function string_to_integer(string)
Converts a string to an integer.
Determines whether a data item can be represented as a logical or not.
character(len=str_length) function, pointer generic_to_string(generic, makecopy, str_length)
Converts a generic to a string.
logical function string_is_integer(string)
Determines whether a string is an integer or not.
Determines whether a data item can be represented as an integer or not.
Converts data types to real.
logical function real_to_logical(input)
Converts a real to a logical.
real function, pointer generic_to_real(generic, makecopy)
Converts a generic to a real. If this is infact an integer then will do a conversion and allocate poi...
subroutine limit_to_decimal_places(string_to_parse, decimal_places)
Helper subroutine which trims the string down to an upper limit of decimal places, with all numbers beyond this point removed.
real(kind=default_precision) function, pointer, public generic_to_double_real(generic, makecopy)
Converts a generic to a double real.
class(*) function, pointer string_to_generic(string, makecopy)
Converts a string into its generic data representation.
character(len=15) function integer_to_string(input)
Converts an integer to a string.
integer function real_to_integer(input)
Converts a real to an integer.
class(*) function, pointer real_double_to_generic(input, makecopy)
Converts a double real into its generic data representation.
Determines whether a data item can be represented as a real or not.
character(len=5) function logical_to_string(input)
Converts a logical to a string.
class(*) function, pointer real_single_to_generic(input, makecopy)
Converts a single real into its generic data representation.
integer, parameter real_rounding_precision
Converts data types to integers.
integer function, pointer generic_to_integer(generic, makecopy)
Converts a generic to an integer.
real(kind=double_precision) function, public conv_single_real_to_double(input_real)
Converts from a single to double precision real. This applies some rounding to a certain number of de...
real function integer_to_real(input)
Converts an integer to a real.