Re: DAY Number in an Year
- From: Paul Van Delst <Paul.vanDelst@xxxxxxxx>
- Date: Thu, 29 Sep 2005 13:37:15 -0400
prasad413in@xxxxxxxxx wrote:
hello Paul.. Excuse me for being not precise in my question.. Actually what i need is.. I am using lynx in UNIX to fetch the Files from the web.. Those files are updated in real time.. The file format is GA762_2005269.SAO where 2005 and 269 are variabless. I need to download that file for the given Day number of the year and YEAR.. link
./lynx_fetch 2005 269 should download that file and.. ./lynx_fetch 2005 270 downloads other file........... similarly ./lynx_fetch 2004 360 downloads file..
I wrote the script for lynx_fetch.. I need to write the Fortran code for this Day_NO and Year ...
So you provide the day number and the year, and your "lynx_fetch" script constructs a filename from that? Fair enough. So what do you need the Fortran code for? To check the day number and the year input? If this is so, then the first thing you'll want to do is test if the year is a leap year or not. I do it like so:
FUNCTION Is_Leap_Year( Year ) RESULT ( Its_a_Leap_Year )
INTEGER, INTENT( IN ) :: Year
LOGICAL :: Its_a_Leap_Year
Its_a_Leap_Year = .FALSE.
IF ( ( MOD( Year, 4 ) == 0 .AND. MOD( Year, 100 ) /= 0 ) .OR. &
MOD( Year, 400 ) == 0 ) Its_a_Leap_Year = .TRUE.
END FUNCTION Is_Leap_YearThen, if your year is a leap year, you'll know that 366 is a valid day of year. If the year is not a leap year, then 366 is invalid and you can either:
a) exit with an error flagged, or
b) increment the year, and change the day of year (doy) to doy=doy-365. That is, Dec 32rd of the current year would become Jan 1st of the next year. Dunno if that makes sense or not, though.
If I've still got it wrong, I again apologise for my denseness in understanding your problem (I'm gun-shy right now. I've misunderstood several colleagues' questions over the last couple of days due to me assuming that what they said was what they meant... :o)
cheers,
paulv
-- Paul van Delst CIMSS @ NOAA/NCEP/EMC .
- References:
- DAY Number in an Year
- From: prasad413in
- Re: DAY Number in an Year
- From: Paul Van Delst
- Re: DAY Number in an Year
- From: prasad413in
- DAY Number in an Year
- Prev by Date: Re: Intel Fortran license?
- Next by Date: Re: NEWBIE QUESTION
- Previous by thread: Re: DAY Number in an Year
- Next by thread: compilation cascades and new Fortran features
- Index(es):
Relevant Pages
|