C Library Functions - ordinal_to_date (3)
NAME
ordinal_to_date(3f) - [M_time:ORDINAL_DAY] when given a valid year and
day of the year returns the DAT array for the date
(LICENSE:MIT)
CONTENTS
Synopsis
Description
Options
Returns
Example
SYNOPSIS
subroutine ordinal_to_date(yyyy, ddd, dat)
integer, intent(in) :: yyyy
integer, intent(in) :: ddd
integer, intent(out) :: dat
DESCRIPTION
When given a valid year, YYYY, and day of the year, DDD, returns the
date as a DAT date array
OPTIONS
|
yyyy |
known year
|
|
ddd |
known ordinal day of the year
|
|
RETURNS
|
dat |
DAT array describing the date
|
|
EXAMPLE
Sample program:
program demo_ordinal_to_date
use M_time, only : ordinal_to_date
implicit none
integer :: yyyy, ddd, mm, dd, yy
integer :: dat(8)
integer :: i, iostat
character(len=:),allocatable :: fakefile(:)
fakefile=[character(len=80) :: 2024 273 ,2024 001]
do i=1,size(fakefile)
! Enter year YYYY and ordinal day of year DD
read(fakefile(i),*,iostat=iostat)yyyy,ddd
if(iostat/=0)exit
! recover month and day from year and day number.
call ordinal_to_date(yyyy, ddd, dat)
yy=dat(1)
mm=dat(2)
dd=dat(3)
write(*,(*(g0)))For Year ,yyyy, and Ordinal day ,ddd
write(*,(*(g0))) Month is ,mm, and Day of Month is ,dd, &
& and Year is ,yy
enddo
end program demo_ordinal_to_date
Result:
> For Year 2024 and Ordinal day 273
> Month is 9 and Day of Month is 29 and Year is 2024
> For Year 2024 and Ordinal day 1
> Month is 1 and Day of Month is 1 and Year is 2024
| Nemo Release 3.1 | ordinal_to_date (3) | June 29, 2025 |
Generated by manServer 1.08 from b1f3717f-edc8-46e1-b8f4-bdb4e73c07f3 using man macros.