Closed dongli closed 6 years ago
I can't reproduce this... Also, you need to post more of your code.
cat foo.f90
program foo
use mod_timedelta
implicit none
integer, parameter :: time_step_size_in = 5
type(timedelta) :: time_step_size
time_step_size = timedelta(seconds=time_step_size_in)
end program
$ gfortran --version
GNU Fortran (Homebrew GCC 7.2.0) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gfortran -Wall -Wextra -pedantic -c timedelta.f90
$ gfortran -Wall -Wextra -pedantic foo.f90 timedelta.o
$ ./a.out
@dongli Thank you for reporting this.
Can you show a minimal complete example of how you are using timedelta
?
Specifically, what is the type of time_step_size_in
? My guess is that it is a real
number. timedelta_constructor
function which overloads the default timedelta
constructor, is designed for integer
arguments only. If you try to pass a real
, compiler will not resolve this interface.
An example below with integer arguments works as expected:
use datetime_module,only:timedelta
implicit none
type(timedelta) :: td
td = timedelta(seconds=60)
write(*,*)td % total_seconds()
end
In the above example, if you change 60
to 60.
, you can reproduce your original error message.
Note that you can specify a fraction of seconds like this:
td = timedelta(seconds=60, milliseconds=123)
but the precision is still limited to milliseconds.
This raises a few questions about the design of timedelta
object:
reals
?timedelta
is designed as an immutable. If you ever want to change a component, you just create a new instance.No response from OP, assume resolved.
Code is as following:
and error is:
The Fortran compiler that I am using is
gfortran
7.2.0.