0.6.2-dev0
FORCES
FORtran lib for Comp. Env. Sys.
Loading...
Searching...
No Matches
mo_julian Module Reference

Julian date conversion routines. More...

Data Types

interface  setcalendar
 Set module private variable calendar. More...
 

Functions/Subroutines

subroutine setcalendarstring (selector)
 
subroutine setcalendarinteger (selector)
 
pure integer(i4) function selectcalendar (selector)
 Select a calendar.
 
elemental subroutine, public caldat (julian, dd, mm, yy, calendar)
 Day, month and year from Julian day in the current or given calendar.
 
elemental subroutine, public dec2date (julian, dd, mm, yy, hh, nn, ss, calendar)
 Day, month, year, hour, minute, and second from fractional Julian day in the current or given calendar.
 
elemental real(dp) function, public date2dec (dd, mm, yy, hh, nn, ss, calendar)
 Fractional Julian day from day, month, year, hour, minute, second in the current calendar.
 
elemental integer(i4) function, public julday (dd, mm, yy, calendar)
 Julian day from day, month and year in the current or given calendar.
 
elemental subroutine, public caldatjulian (julian, dd, mm, yy)
 Day, month and year from Julian day.
 
elemental real(dp) function date2decjulian (dd, mm, yy, hh, nn, ss)
 Fractional Julian day from day, month, year, hour, minute, second.
 
elemental subroutine dec2datejulian (julian, dd, mm, yy, hh, nn, ss)
 Day, month, year, hour, minute, and second from fractional Julian day.
 
elemental integer(i4) function juldayjulian (dd, mm, yy)
 Julian day from day, month and year.
 
elemental integer(i4) function, public ndays (dd, mm, yy)
 IMSL Julian day from day, month and year.
 
elemental subroutine, public ndyin (julian, dd, mm, yy)
 Day, month and year from IMSL Julian day.
 
elemental subroutine caldat360 (julian, dd, mm, yy)
 Day, month and year from Julian day in a 360 day calendar.
 
elemental integer(i4) function julday360 (dd, mm, yy)
 Julian day from day, month and year in a 360_day calendar.
 
elemental subroutine dec2date360 (julian, dd, mm, yy, hh, nn, ss)
 Day, month, year, hour, minute, and second from fractional Julian day in a 360_day calendar.
 
elemental real(dp) function date2dec360 (dd, mm, yy, hh, nn, ss)
 Fractional Julian day from day, month, year, hour, minute, second in 360 day calendar.
 
elemental subroutine caldat365 (julian, dd, mm, yy)
 Day, month and year from Julian day in a 365 day calendar.
 
elemental integer(i4) function julday365 (dd, mm, yy)
 Julian day from day, month and year in a 365_day calendar.
 
elemental subroutine dec2date365 (julian, dd, mm, yy, hh, nn, ss)
 Day, month, year, hour, minute, and second from fractional Julian day in a 365_day calendar.
 
elemental real(dp) function date2dec365 (dd, mm, yy, hh, nn, ss)
 Fractional Julian day from day, month, year, hour, minute, second in 365 day calendar.
 

Variables

integer(i4), save, private calendar = 1
 

Detailed Description

Julian date conversion routines.

Julian date to and from day, month, year, and also from day, month, year, hour, minute, and second. Also convience routines for Julian dates of IMSL are provided.

Note
Julian day definition starts at noon of the 1st January 4713 BC.
Here, the astronomical definition is used, i.e. the year 1 BC (historic) is counted as 0 (astronomic), 2 BC is -1, etc.
This means that Julian day definition starts as 01.01.-4712 in astronomical units.

julday and caldat start at midnight of the 1st January 4713 BC. So date2dec and julday as well as dec2date and caldat are shifted by half a day.
Use date2dec with dec2date together for fractional Julian dates and use julday with caldat together for integer Julian days.
Changelog
  • Matthias Cuntz, Dec 2011
  • Matthias Cuntz, Jan 2013
    • added date2dec and dec2date
  • Matthias Cuntz, May 2014
    • changed to new algorithm with astronomical units removed numerical recipes
  • David Schaefer, Oct 2015
    • addded 360 day calendar procedures
  • David Schaefer, Jan 2016
    • addded 365 day calendar procedures
  • David Schaefer, Feb 2016
    • implemented wrapper function and the module calendar state
Author
Matthias Cuntz
Date
Dec 2011

Function/Subroutine Documentation

◆ caldat()

elemental subroutine, public mo_julian::caldat ( integer(i4), intent(in)  julian,
integer(i4), intent(out)  dd,
integer(i4), intent(out)  mm,
integer(i4), intent(out)  yy,
integer(i4), intent(in), optional  calendar 
)

Day, month and year from Julian day in the current or given calendar.

Wrapper around the calendar specific caldat procedures. Inverse of the function julday. Here julian is input as a Julian Day Number, and the routine outputs d0d, mm, and yy as the day, month, and year on which the specified Julian Day started at noon.
The zeroth Julian Day depends on the called procedure. See their documentation for details.

Example

Converts julday to dd, mm, yy format

call caldat(julday, dd, mm, yy)
Parameters
[in]integer(i4) :: juldayJulian day
[out]integer(i4) :: ddDay in month of Julian day
[out]integer(i4) :: mmMonth in year of Julian day
[out]integer(i4) :: yyYear of Julian day
[in]integer(i4) :: calendarThe calendar to use, the global calendar will be used by default
Author
David Schaefer
Date
Jan 2015

Definition at line 166 of file mo_julian.f90.

References caldat360(), caldat365(), caldatjulian(), and selectcalendar().

Referenced by dec2datejulian(), and ndyin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ caldat360()

elemental subroutine mo_julian::caldat360 ( integer(i4), intent(in)  julian,
integer(i4), intent(out)  dd,
integer(i4), intent(out)  mm,
integer(i4), intent(out)  yy 
)
private

Day, month and year from Julian day in a 360 day calendar.

Inverse of the function julday360. Here julian is input as a Julian Day Number, and the routine outputs dd, mm, and yy as the day, month, and year on which the specified Julian Day started at noon.

The zeroth Julian Day here is 01.01.0000

Example

call caldat360(julday, dd, mm, yy)
Parameters
[in]integer(i4) :: juldayJulian day
[out]integer(i4) :: ddDay in month of Julian day
[out]integer(i4) :: mmMonth in year of Julian day
[out]integer(i4) :: yyYear of Julian day
Author
David Schaefer
Date
Oct 2015

Definition at line 883 of file mo_julian.f90.

Referenced by caldat(), and dec2date360().

Here is the caller graph for this function:

◆ caldat365()

elemental subroutine mo_julian::caldat365 ( integer(i4), intent(in)  julian,
integer(i4), intent(out)  dd,
integer(i4), intent(out)  mm,
integer(i4), intent(out)  yy 
)
private

Day, month and year from Julian day in a 365 day calendar.

Inverse of the function julday365. Here julian is input as a Julian Day Number, and the routine outputs dd, mm, and yy as the day, month, and year on which the specified Julian Day started at noon.

The zeroth Julian Day here is 01.01.0000

Example

call caldat365(julday, dd, mm, yy)
Parameters
[in]integer(i4) :: juldayJulian day
[out]integer(i4) :: ddDay in month of Julian day
[out]integer(i4) :: mmMonth in year of Julian day
[out]integer(i4) :: yyYear of Julian day
Author
David Schaefer
Date
Dec 2015

Definition at line 1088 of file mo_julian.f90.

Referenced by caldat(), and dec2date365().

Here is the caller graph for this function:

◆ caldatjulian()

elemental subroutine, public mo_julian::caldatjulian ( integer(i4), intent(in)  julian,
integer(i4), intent(out)  dd,
integer(i4), intent(out)  mm,
integer(i4), intent(out)  yy 
)

Day, month and year from Julian day.

Inverse of the function juldayJulian. Here julian is input as a Julian Day Number, and the routine outputs id, mm, and yy as the day, month, and year on which the specified Julian Day started at noon.

The zeroth Julian Day is 01.01.-4712, i.e. the 1st January 4713 BC.

Julian day definition starts at 1st January 4713 BC.
Here, the astronomical definition is used, i.e. the year 1 BC (historic) is counted as 0 (astronomic), 2 BC is -1, etc.
This means that Julian day definition starts as 01.01.-4712 in astronomical units.
Example

2415021 is 01.01.1900
call caldatjulian(2415021, dd, mm, yy)

Literature

  1. http://de.wikipedia.org/wiki/Julianisches_Datum which is different to the english Wiki
  2. http://en.wikipedia.org/wiki/Julian_day It is essentially the same as Numerical Recipes but uses astronomical instead of historical units.
    Parameters
    [in]integer(i4) :: JuldayJulian day
    [out]integer(i4) :: ddDay in month of Julian day
    [out]integer(i4) :: mmMonth in year of Julian day
    [out]integer(i4) :: yyYear of Julian day
    Note
    Julian day definition starts at noon of the 1st January 4713 BC.
    Here, the astronomical definition is used, i.e. the year 1 BC (historic) is counted as 0 (astronomic), 2 BC is -1, etc.
    This means that Julian day definition starts as 01.01.-4712 in astronomical units.
    julday and caldat start at midnight of the 1st January 4713 BC. So date2decJulian and juldayJulian as well as dec2dateJulian and caldatJulian are shifted by half a day.
    Use date2decJulian with dec2dateJulian together for fractional Julian dates and use juldayJulian with caldatJulian together for integer Julian days.
    Author
    Matthias Cuntz
    Date
    Dec 2011
    • modified julday from Numerical Recipes
    May 2014
    • changed to new algorithm with astronomical units
    • removed numerical recipes
    Author
    David Schaefer
    Date
    Jan 2016
    • renamed procodure

Definition at line 385 of file mo_julian.f90.

References mo_kind::dp, mo_kind::i4, and mo_kind::i8.

Referenced by caldat().

Here is the caller graph for this function:

◆ date2dec()

elemental real(dp) function, public mo_julian::date2dec ( integer(i4), intent(in), optional  dd,
integer(i4), intent(in), optional  mm,
integer(i4), intent(in), optional  yy,
integer(i4), intent(in), optional  hh,
integer(i4), intent(in), optional  nn,
integer(i4), intent(in), optional  ss,
integer(i4), intent(in), optional  calendar 
)

Fractional Julian day from day, month, year, hour, minute, second in the current calendar.

Wrapper around the calendar specific date2dec procedures. In this routine date2dec returns the fractional Julian Day that begins at noon of the calendar date specified by month mm, day dd, and year yy, all integer variables.

The zeroth Julian Day depends on the called procedure. See their documentation for details.

Example

Take dd, mm, yy, hh, nn, ss to fractional Julian date

date2dec = date2dec(dd, mm, yy, hh, nn, ss)
Parameters
[in]integer(i4), optional :: ddDay in month of Julian day (default: 1)
[in]integer(i4), optional :: mmMonth in year of Julian day (default: 1)
[in]integer(i4), optional :: yyYear of Julian day (default: 1)
[in]integer(i4), optional :: hhHours of Julian day (default: 0)
[in]integer(i4), optional :: nnMinutes of hour of Julian day (default: 0)
[in]integer(i4), optional :: ssSecondes of minute of hour of Julian day (default: 0)
[in]integer(i4), optional :: calendarThe calendar to use, the global calendar will be used by default
Return values
real(dp) :: date2decFractional Julian day
Author
David Schaefer
Date
Jan 2015

Definition at line 265 of file mo_julian.f90.

References date2dec(), date2dec360(), date2dec365(), date2decjulian(), and selectcalendar().

Referenced by date2dec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ date2dec360()

elemental real(dp) function mo_julian::date2dec360 ( integer(i4), intent(in), optional  dd,
integer(i4), intent(in), optional  mm,
integer(i4), intent(in), optional  yy,
integer(i4), intent(in), optional  hh,
integer(i4), intent(in), optional  nn,
integer(i4), intent(in), optional  ss 
)
private

Fractional Julian day from day, month, year, hour, minute, second in 360 day calendar.

In this routine date2dec360 returns the fractional Julian Day that begins at noon of the calendar date specified by month mm, day dd, and year yy, all integer variables.

The zeroth Julian Day is 01.01.0000 at noon.

Example

date2dec360 = date2dec360(dd, mm, yy, hh, nn, ss)
Parameters
[in]integer(i4), optional :: ddDay in month of Julian day (default: 1)
[in]integer(i4), optional :: mmMonth in year of Julian day (default: 1)
[in]integer(i4), optional :: yyYear of Julian day (default: 1)
[in]integer(i4), optional :: hhHours of Julian day (default: 0)
[in]integer(i4), optional :: nnMinutes of hour of Julian day (default: 0)
[in]integer(i4), optional :: ssSecondes of minute of hour of Julian day (default: 0)
Return values
real(dp) :: date2dec360Fractional Julian day
Author
David Schaefer
Date
Oct 2015

Definition at line 1028 of file mo_julian.f90.

References date2dec360(), mo_kind::dp, and julday360().

Referenced by date2dec(), and date2dec360().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ date2dec365()

elemental real(dp) function mo_julian::date2dec365 ( integer(i4), intent(in), optional  dd,
integer(i4), intent(in), optional  mm,
integer(i4), intent(in), optional  yy,
integer(i4), intent(in), optional  hh,
integer(i4), intent(in), optional  nn,
integer(i4), intent(in), optional  ss 
)
private

Fractional Julian day from day, month, year, hour, minute, second in 365 day calendar.

In this routine date2dec365 returns the fractional Julian Day that begins at noon of the calendar date specified by month mm, day dd, and year yy, all integer variables.

The zeroth Julian Day is 01.01.0000 at noon.

Example

date2dec365 = date2dec365(dd, mm, yy, hh, nn, ss)
Parameters
[in]integer(i4), optional :: ddDay in month of Julian day (default: 1)
[in]integer(i4), optional :: mmMonth in year of Julian day (default: 1)
[in]integer(i4), optional :: yyYear of Julian day (default: 1)
[in]integer(i4), optional :: hhHours of Julian day (default: 0)
[in]integer(i4), optional :: nnMinutes of hour of Julian day (default: 0)
[in]integer(i4), optional :: ssSecondes of minute of hour of Julian day (default: 0)
Return values
real(dp) :: date2dec365Fractional Julian day
Author
David Schaefer
Date
Dec 2015

Definition at line 1243 of file mo_julian.f90.

References date2dec365(), mo_kind::dp, and julday365().

Referenced by date2dec(), and date2dec365().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ date2decjulian()

elemental real(dp) function mo_julian::date2decjulian ( integer(i4), intent(in), optional  dd,
integer(i4), intent(in), optional  mm,
integer(i4), intent(in), optional  yy,
integer(i4), intent(in), optional  hh,
integer(i4), intent(in), optional  nn,
integer(i4), intent(in), optional  ss 
)
private

Fractional Julian day from day, month, year, hour, minute, second.

In this routine date2decJulian returns the fractional Julian Day that begins at noon of the calendar date specified by month mm, day dd, and year yy, all integer variables.

The zeroth Julian Day is 01.01.-4712 at noon, i.e. the 1st January 4713 BC 12:00:00 h.

Julian day definition starts at noon of the 1st January 4713 BC.
Here, the astronomical definition is used, i.e. the year 1 BC (historic) is counted as 0 (astronomic), 2 BC is -1, etc.
This means that Julian day definition starts as 01.01.-4712 in astronomical units.
Example

2415020.5 is 01.01.1900 00:00

julian = date2decjulian(01,01,1990)
2415021.0 is 01.01.1900 12:00

julian = date2decJulian(01,01,1990,12,00)

Literature

  1. http://de.wikipedia.org/wiki/Julianisches_Datum which is different to the english Wiki
  2. http://en.wikipedia.org/wiki/Julian_day It is essentially the same as Numerical Recipes but uses astronomical instead of historical units. Numerical regulation of fractions is after
  3. IDL routine julday.pro. Copyright (c) 1988-2011, ITT Visual Information Solutions.
    Parameters
    [in]integer(i4), optional :: ddDay in month of Julian day (default: 1)
    [in]integer(i4), optional :: mmMonth in year of Julian day (default: 1)
    [in]integer(i4), optional :: yyYear of Julian day (default: 1)
    [in]integer(i4), optional :: hhHours of Julian day (default: 0)
    [in]integer(i4), optional :: nnMinutes of hour of Julian day (default: 0)
    [in]integer(i4), optional :: ssSecondes of minute of hour of Julian day (default: 0)
    Return values
    real(dp) :: date2decFractional Julian day
    Note
    Julian day definition starts at noon of the 1st January 4713 BC.
    Here, the astronomical definition is used, i.e. the year 1 BC (historic) is counted as 0 (astronomic), 2 BC is -1, etc.
    This means that Julian day definition starts as 01.01.-4712 in astronomical units.
    juldayJulian and caldatJulian start at midnight of the 1st January 4713 BC. So date2decJulian and juldayJulian as well as dec2dateJulian and caldatJulian are shifted by half a day.
    Use date2decJulian with dec2dateJulian together for fractional Julian dates and use juldayJulian with caldatJulian together for integer Julian days.
    Author
    Matthias Cuntz
    Date
    Jan 2013
    May 2014
    • changed to new algorithm with astronomical units
    • removed numerical recipes
    Author
    David Schaefer
    Date
    Jan 2016
    • renamed procodure

Definition at line 486 of file mo_julian.f90.

References date2decjulian(), mo_kind::dp, and mo_kind::i8.

Referenced by date2dec(), and date2decjulian().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dec2date()

elemental subroutine, public mo_julian::dec2date ( real(dp), intent(in)  julian,
integer(i4), intent(out), optional  dd,
integer(i4), intent(out), optional  mm,
integer(i4), intent(out), optional  yy,
integer(i4), intent(out), optional  hh,
integer(i4), intent(out), optional  nn,
integer(i4), intent(out), optional  ss,
integer(i4), intent(in), optional  calendar 
)

Day, month, year, hour, minute, and second from fractional Julian day in the current or given calendar.

Wrapper around the calendar specific dec2date procedures. Inverse of the function date2dec. Here dec2date is input as a fractional Julian Day. The routine outputs dd, mm, yy, hh, nn, ss as the day, month, year, hour, minute, and second on which the specified Julian Day started at noon.

The zeroth Julian Day depends on the called procedure. See their documentation for details.

Example

Takes in fraction julian date fJulian to covert to dd, mm, yy, hh, nn, ss

call dec2date(fJulian, dd, mm, yy, hh, nn, ss)
Parameters
[in]real(dp) :: fJulianfractional Julian day
[in]integer(i4), optional :: calendarThe calendar to use, the global calendar will be used by default
[out]integer(i4), optional :: ddDay in month of Julian day
[out]integer(i4), optional :: mmMonth in year of Julian day
[out]integer(i4), optional :: yyYear of Julian day
[out]integer(i4), optional :: hhHour of Julian day
[out]integer(i4), optional :: nnMinute in hour of Julian day
[out]integer(i4), optional :: ssSecond in minute of hour of Julian day
Author
David Schaefer
Date
Jan 2015

Definition at line 217 of file mo_julian.f90.

References dec2date360(), dec2date365(), dec2datejulian(), and selectcalendar().

Here is the call graph for this function:

◆ dec2date360()

elemental subroutine mo_julian::dec2date360 ( real(dp), intent(in)  julian,
integer(i4), intent(out), optional  dd,
integer(i4), intent(out), optional  mm,
integer(i4), intent(out), optional  yy,
integer(i4), intent(out), optional  hh,
integer(i4), intent(out), optional  nn,
integer(i4), intent(out), optional  ss 
)
private

Day, month, year, hour, minute, and second from fractional Julian day in a 360_day calendar.

Inverse of the function date2dec360. Here dec2date360 is input as a fractional Julian Day. The routine outputs dd, mm, yy, hh, nn, ss as the day, month, year, hour, minute, and second on which the specified Julian Day started at noon.

The zeroth Julian Day is 01.01.0000 at noon.

Example

call dec2date360(fJulian, dd, mm, yy, hh, nn, ss)
Parameters
[in]real(dp) :: fJulianfractional Julian day
[out]integer(i4), optional :: ddDay in month of Julian day
[out]integer(i4), optional :: mmMonth in year of Julian day
[out]integer(i4), optional :: yyYear of Julian day
[out]integer(i4), optional :: hhHour of Julian day
[out]integer(i4), optional :: nnMinute in hour of Julian day
[out]integer(i4), optional :: ssSecond in minute of hour of Julian day
Author
David Schaefer
Date
Oct 2015

Definition at line 960 of file mo_julian.f90.

References caldat360(), mo_kind::dp, mo_kind::i4, and julday360().

Referenced by dec2date().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dec2date365()

elemental subroutine mo_julian::dec2date365 ( real(dp), intent(in)  julian,
integer(i4), intent(out), optional  dd,
integer(i4), intent(out), optional  mm,
integer(i4), intent(out), optional  yy,
integer(i4), intent(out), optional  hh,
integer(i4), intent(out), optional  nn,
integer(i4), intent(out), optional  ss 
)
private

Day, month, year, hour, minute, and second from fractional Julian day in a 365_day calendar.

Inverse of the function date2dec. Here dec2date365 is input as a fractional Julian Day. The routine outputs dd, mm, yy, hh, nn, ss as the day, month, year, hour, minute, and second on which the specified Julian Day started at noon.

The zeroth Julian Day is 01.01.0000 at noon.

Example

call dec2date365(fJulian, dd, mm, yy, hh, nn, ss)
Parameters
[in]real(dp) :: fJulianfractional Julian day
[out]integer(i4), optional :: ddDay in month of Julian day
[out]integer(i4), optional :: mmMonth in year of Julian day
[out]integer(i4), optional :: yyYear of Julian day
[out]integer(i4), optional :: hhHour of Julian day
[out]integer(i4), optional :: nnMinute in hour of Julian day
[out]integer(i4), optional :: ssSecond in minute of hour of Julian day
Author
David Schaefer
Date
Dec 2015

Definition at line 1175 of file mo_julian.f90.

References caldat365(), mo_kind::dp, mo_kind::i4, and julday365().

Referenced by dec2date().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dec2datejulian()

elemental subroutine mo_julian::dec2datejulian ( real(dp), intent(in)  julian,
integer(i4), intent(out), optional  dd,
integer(i4), intent(out), optional  mm,
integer(i4), intent(out), optional  yy,
integer(i4), intent(out), optional  hh,
integer(i4), intent(out), optional  nn,
integer(i4), intent(out), optional  ss 
)
private

Day, month, year, hour, minute, and second from fractional Julian day.

Inverse of the function date2decJulian. Here dec2dateJulian is input as a fractional Julian Day, which starts at noon of the 1st January 4713 BC, i.e. 01.01.-4712. The routine outputs dd, mm, yy, hh, nn, ss as the day, month, year, hour, minute, and second on which the specified Julian Day started at noon.

The zeroth Julian Day is 01.01.-4712 at noon, i.e. the 1st January 4713 BC at noon.

Julian day definition starts at 1st January 4713 BC.
Here, the astronomical definition is used, i.e. the year 1 BC (historic) is counted as 0 (astronomic), 2 BC is -1, etc.
This means that Julian day definition starts as 01.01.-4712 in astronomical units.
Example

2415020.5 is 01.01.1900 00:00

call caldatJulian(2415020.5, dd, mm, yy, hh, nn)

2415021.0 is 01.01.1900 12:00

call caldatJulian(2415021., dd, mm, yy, hh, nn, ss)

Literature

  1. http://de.wikipedia.org/wiki/Julianisches_Datum which is different to the english Wiki
  2. http://en.wikipedia.org/wiki/Julian_day It is essentially the same as Numerical Recipes but uses astronomical instead of historical units. Here the sometimes 60 sec as output are corrected at the end.
    Parameters
    [in]real(dp) :: fJulianfractional Julian day
    [out]integer(i4), optional :: ddDay in month of Julian day
    [out]integer(i4), optional :: mmMonth in year of Julian day
    [out]integer(i4), optional :: yyYear of Julian day
    [out]integer(i4), optional :: hhHour of Julian day
    [out]integer(i4), optional :: nnMinute in hour of Julian day
    [out]integer(i4), optional :: ssSecond in minute of hour of Julian day
    Note
    Julian day definition starts at noon of the 1st January 4713 BC.
    Here, the astronomical definition is used, i.e. the year 1 BC (historic) is counted as 0 (astronomic), 2 BC is -1, etc.
    This means that Julian day definition starts as 01.01.-4712 in astronomical units.
    juldayJulian and caldatJulian start at midnight of the 1st January 4713 BC. So date2decJulian and juldayJulian as well as dec2dateJulian and caldatJulian are shifted by half a day.
    Use date2decJulian with dec2dateJulian together for fractional Julian dates and use juldayJulian with caldatJulian together for integer Julian days.
    Author
    Matthias Cuntz
    Date
    Jan 2013
    May 2014
    • changed to new algorithm with astronomical units
    • removed numerical recipes
    Author
    David Schaefer
    Date
    Jan 2016
    • renamed procodure

Definition at line 610 of file mo_julian.f90.

References caldat(), mo_kind::dp, mo_kind::i4, mo_kind::i8, and julday().

Referenced by dec2date().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ julday()

elemental integer(i4) function, public mo_julian::julday ( integer(i4), intent(in)  dd,
integer(i4), intent(in)  mm,
integer(i4), intent(in)  yy,
integer(i4), intent(in), optional  calendar 
)

Julian day from day, month and year in the current or given calendar.

Wrapper around the calendar specific julday procedures. In this routine julday returns the Julian Day Number that begins at noon of the calendar date specified by month mm, day dd, and year yy, all integer variables.

The zeroth Julian Day depends on the called procedure. See their documentation for details.

Example

Take dd, mm, yy, hh, nn, ss to Julian date

date2dec = date2dec(dd, mm, yy)
Parameters
[in]integer(i4) :: ddDay in month of Julian day
[in]integer(i4) :: mmMonth in year of Julian day
[in]integer(i4) :: yyYear of Julian day
[in]integer(i4), optional :: calendarThe calendar to use, the global calendar will be used by default
Return values
integer(i4) :: julianJulian day
Author
David Schaefer
Date
Jan 2015

Definition at line 312 of file mo_julian.f90.

References julday(), julday360(), julday365(), juldayjulian(), and selectcalendar().

Referenced by dec2datejulian(), julday(), and ndays().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ julday360()

elemental integer(i4) function mo_julian::julday360 ( integer(i4), intent(in)  dd,
integer(i4), intent(in)  mm,
integer(i4), intent(in)  yy 
)
private

Julian day from day, month and year in a 360_day calendar.

In this routine julday360 returns the Julian Day Number that begins at noon of the calendar date specified by month mm, day dd, and year yy, all integer variables.

The zeroth Julian Day is 01.01.0000

Example

julian = julday360(dd, mm, yy)
Parameters
[in]integer(i4) :: ddDay in month of Julian day
[in]integer(i4) :: mmMonth in year of Julian day
[in]integer(i4) :: yyYear of Julian day
Return values
integer(i4) :: julianJulian day
Author
David Schaefer
Date
Oct 2015

Definition at line 921 of file mo_julian.f90.

References julday360().

Referenced by date2dec360(), dec2date360(), julday(), and julday360().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ julday365()

elemental integer(i4) function mo_julian::julday365 ( integer(i4), intent(in)  dd,
integer(i4), intent(in)  mm,
integer(i4), intent(in)  yy 
)
private

Julian day from day, month and year in a 365_day calendar.

In this routine julday365 returns the Julian Day Number that begins at noon of the calendar date specified by month mm, day dd, and year yy, all integer variables.

The zeroth Julian Day is 01.01.0000

Example

julian = julday365(dd, mm, yy)
Parameters
[in]integer(i4) :: ddDay in month of Julian day
[in]integer(i4) :: mmMonth in year of Julian day
[in]integer(i4) :: yyYear of Julian day
Return values
integer(i4) :: julianJulian day
Author
David Schaefer
Date
Dec 2015

Definition at line 1134 of file mo_julian.f90.

References julday365().

Referenced by date2dec365(), dec2date365(), julday(), and julday365().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ juldayjulian()

elemental integer(i4) function mo_julian::juldayjulian ( integer(i4), intent(in)  dd,
integer(i4), intent(in)  mm,
integer(i4), intent(in)  yy 
)
private

Julian day from day, month and year.

In this routine juldayJulian returns the Julian Day Number that begins at noon of the calendar date specified by month mm, day dd, and year yy, all integer variables.

The zeroth Julian Day is 01.01.-4712 at noon, i.e. the 1st January 4713 BC 12:00:00 h.

Julian day definition starts at noon of the 1st January 4713 BC.
Here, the astronomical definition is used, i.e. the year 1 BC (historic) is counted as 0 (astronomic), 2 BC is -1, etc.
This means that Julian day definition starts as 01.01.-4712 in astronomical units.
Example

2415021 is 01.01.1900 and 2440588 is 01.01.1970

julian = juldayjulian(01,01,1990)

See also example in test directory

Literature

  1. http://de.wikipedia.org/wiki/Julianisches_Datum which is different to the english Wiki
  2. http://en.wikipedia.org/wiki/Julian_day It is essentially the same as Numerical Recipes but uses astronomical instead of historical units.
    Parameters
    [in]integer(i4) :: ddDay in month of Julian day
    [in]integer(i4) :: mmMonth in year of Julian day
    [in]integer(i4) :: yyYear of Julian day
    Return values
    integer(i4) :: julianJulian day
    Note
    Julian day definition starts at noon of the 1st January 4713 BC.
    Here, the astronomical definition is used, i.e. the year 1 BC (historic) is counted as 0 (astronomic), 2 BC is -1, etc.
    This means that Julian day definition starts as 01.01.-4712 in astronomical units.
    juldayJulian and caldatJulian start at midnight of the 1st January 4713 BC. So date2decJulian and juldayJulian as well as dec2dateJulian and caldatJulian are shifted by half a day.
    Use date2decJulian with dec2dateJulian together for fractional Julian dates and use juldayJulian with caldatJulian together for integer Julian days.
    Author
    Matthias Cuntz
    Date
    Dec 2011
    • modified julday from Numerical Recipes
    May 2014
    • changed to new algorithm with astronomical units
    • removed numerical recipes
    Author
    David Schaefer
    Date
    Jan 2016
    • renamed procodure

Definition at line 744 of file mo_julian.f90.

References mo_kind::dp, mo_kind::i4, mo_kind::i8, and juldayjulian().

Referenced by julday(), and juldayjulian().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ndays()

elemental integer(i4) function, public mo_julian::ndays ( integer(i4), intent(in)  dd,
integer(i4), intent(in)  mm,
integer(i4), intent(in)  yy 
)

IMSL Julian day from day, month and year.

In this routine ndays returns the IMSL Julian Day Number. Julian days begin at noon of the calendar date specified by month mm, day dd, and year yy, all integer variables. IMSL treats 01.01.1900 as a reference and assigns a Julian day 0 to it.

ndays = julday(dd,mm,yy) - julday(01,01,1900)

Example

0 is 01.01.1900

julian = ndays(01,01,1990)

See also example in test directory

Parameters
[in]integer(i4) :: ddDay in month of IMSL Julian day
[in]integer(i4) :: mmMonth in year of IMSL Julian day
[in]integer(i4) :: yyYear of IMSL Julian day
Return values
integer(i4) :: julianIMSL Julian day, i.e. days before or after 01.01.1900
Author
Matthias Cuntz
Date
Dec 2011

Definition at line 808 of file mo_julian.f90.

References julday(), and ndays().

Referenced by ndays().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ndyin()

elemental subroutine, public mo_julian::ndyin ( integer(i4), intent(in)  julian,
integer(i4), intent(out)  dd,
integer(i4), intent(out)  mm,
integer(i4), intent(out)  yy 
)

Day, month and year from IMSL Julian day.

Inverse of the function ndys. Here ISML Julian is input as a Julian Day Number minus the Julian Day Number of 01.01.1900, and the routine outputs id, mm, and yy as the day, month, and year on which the specified Julian Day started at noon.

ndyin is caldat(IMSLJulian + 2415021, dd, mm, yy)

Example

0 is 01.01.1900

call ndyin(0,dd,mm,yy)

See also example in test directory

Parameters
[in]integer(i4) :: julianIMSL Julian day, i.e. days before or after 01.01.1900
[out]integer(i4) :: ddDay in month of IMSL Julian day
[out]integer(i4) :: mmMonth in year of IMSL Julian day
[out]integer(i4) :: yyYear of IMSL Julian day
Author
Matthias Cuntz
Date
Dec 2011

Definition at line 847 of file mo_julian.f90.

References caldat().

Here is the call graph for this function:

◆ selectcalendar()

pure integer(i4) function mo_julian::selectcalendar ( integer(i4), intent(in), optional  selector)
private

Select a calendar.

Returns a valid calendar index, based on the given optional argument and/or the module global private variable calendar. If an invalid selector is passed, its value is ignored and the global calendar value retuned instead.

Example

Returns a valid index which is 3

idx = selectcalendar(3)
Parameters
[in]integer(i4), optional :: selectorCalendar selector {1|2|3}
Author
David Schaefer
Date
Jan 2015

Definition at line 125 of file mo_julian.f90.

References selectcalendar().

Referenced by caldat(), date2dec(), dec2date(), julday(), and selectcalendar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setcalendarinteger()

subroutine mo_julian::setcalendarinteger ( integer(i4), intent(in)  selector)
private

Definition at line 95 of file mo_julian.f90.

◆ setcalendarstring()

subroutine mo_julian::setcalendarstring ( character(*), intent(in)  selector)
private

Definition at line 78 of file mo_julian.f90.

Variable Documentation

◆ calendar

integer(i4), save, private mo_julian::calendar = 1
private

Definition at line 50 of file mo_julian.f90.