Giter VIP home page Giter VIP logo

Comments (3)

zbeekman avatar zbeekman commented on July 4, 2024

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

from datetime-fortran.

milancurcic avatar milancurcic commented on July 4, 2024

@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:

  • Should it be able to accept reals?
  • Should the user be able to set timedelta components? Currently this is not possible because timedelta is designed as an immutable. If you ever want to change a component, you just create a new instance.

from datetime-fortran.

milancurcic avatar milancurcic commented on July 4, 2024

No response from OP, assume resolved.

from datetime-fortran.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.