- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to calculate the Number of Calendar Days in a Year (1 through 365/366) in every step, along with other calculations and output with the other calculated output. I tried to do this as in the attached program, but was not successful. I would appreciate any help or pointers in this regard. I was wondering if there is a Fortran intrinsic function for the calendar day output.
Thank you.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems to me that your question is more about calendars than programming. You say that you wish to output the calendar day, but you did not say what the input was. Here is an interesting online calculator related to this: https://www.fourmilab.ch/documents/calendar/ .
Surely, you are not asking for information on how many days there are in a given year, as your topic title suggests?
I looked at your program and the data files but, without a problem definition statement being available, that was not of much use.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi mecej4,
Following is the description about my question:
et.dat and rf.dat are the input files which have daily data values (the fourth column) listed against the dates (year, month and day listed in the first, second and third columns respectively)
I am trying to calculate a new value called "sto" (as in the attached output file: out.dat, in the fourth column). Along with this new value for every step, I am trying to list the calendar day (called "calday") of the year, in order (1 through 365/366), programmatically. I am trying to do this as indicated in lines 29 to 36 of the attached code: test_calc.f. As can be seen from the output it appears to be doing this for the first year, but then onwards it appears wrong (I intended to start calday=1 whenever the year in the input changed, and then output calday though 365/366 until the year changed.
I do not know where I am going wrong. I would appreciate any help or pointers in this regard.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What your code does not contain is any awareness of how many days each month contains. Since this information comes from a cultural understanding, your program needs information that September hath 30 days, etc., and a provision for leap years.
There are only 32 lines in the program, so I cannot relate to "lines 29 to 36 in #3". Lines 21-28 are based on incorrect reasoning. How can you, for example, find today's day-of-the-year number without knowing that January has 31 days, February had 28 this year, etc.?
I also note that I do not see why the variables iyr, imonth, etc., were declared as arrays when scalars would have sufficed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for your valuable comments and suggestions. I will now try to implement them.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page