ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_dateTime::getCountLeapYears Interface Reference

Generate and return the number of leap years within the closed year interval [since, until] where since represents the origin year, and until represents a later year after since. More...

Detailed Description

Generate and return the number of leap years within the closed year interval [since, until] where since represents the origin year, and until represents a later year after since.

Parameters
[in]until: The input scalar or array of arbitrary rank of type integer of default kind IK, containing the Gregorian Calendar year up to which the number of leap years since since must be returned.
If until < 0, then the number of leap years from the negative year until January, 1, 1 is returned.
[in]since: The input scalar or array of the same shape as until of the same type and kind as until, containing the Gregorian Calendar year that marks the beginning of the period within which the number of leap years must be counted.
(optional, default = 1_IK, i.e., the origin of the Gregorian Calendar.)


Possible calling interfaces

use pm_kind, only: IK
integer(IK) :: countLeapYear
countLeapYear = getCountLeapYears(until)
countLeapYear = getCountLeapYears(until, since)
Generate and return the number of leap years within the closed year interval [since,...
This module contains classes and procedures for computing, manipulating, and styling dates and times.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
Warning
The condition 0 < since < until must hold for the input argument values.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
Remarks
The procedures under discussion are elemental.
The interface of this generic interface is intentionally defined to have until as the first input argument (as opposed to since).
This is to ensure the purity of the procedures under this generic interface.
Making until optional would require a call to the impure Fortran intrinsic date_and_time().
See also
getCountDays


Example usage

1program example
2
3 use pm_kind, only: SK, IK
4 use pm_val2str, only: getStr
5 use pm_io, only: display_type
7 use pm_arrayRange, only: getRange
8 use pm_dateTime, only: getYear
9
10 implicit none
11
12 integer(IK), allocatable :: Year(:)
13 type(display_type) :: disp
14 disp = display_type(file = "main.out.F90")
15
16 call disp%skip()
17 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
18 call disp%show("! Determine if a given Gregorian calendar date is the last of the month.")
19 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
20 call disp%skip()
21
22 call disp%skip()
23 call disp%show("getCountLeapYears(until = 1_IK)")
24 call disp%show( getCountLeapYears(until = 1_IK) )
25 call disp%skip()
26
27 call disp%skip()
28 call disp%show("getCountLeapYears(until = 2000_IK)")
29 call disp%show( getCountLeapYears(until = 2000_IK) )
30 call disp%skip()
31
32 call disp%skip()
33 call disp%show("getYear()")
34 call disp%show( getYear() )
35 call disp%show("getCountLeapYears(until = getYear())")
36 call disp%show( getCountLeapYears(until = getYear()) )
37 call disp%skip()
38
39 call disp%skip()
40 call disp%show("getYear()")
41 call disp%show( getYear() )
42 call disp%show("getCountLeapYears(until = getYear(), since = 1_IK)")
43 call disp%show( getCountLeapYears(until = getYear(), since = 1_IK) )
44 call disp%skip()
45
46 call disp%skip()
47 call disp%show("getCountLeapYears(until = [1_IK, 2_IK, 3_IK, 4_IK])")
48 call disp%show( getCountLeapYears(until = [1_IK, 2_IK, 3_IK, 4_IK]) )
49 call disp%skip()
50
51 call disp%skip()
52 call disp%show("Year = getRange(-5_IK, 5_IK, 1_IK)")
53 Year = getRange(-5_IK, 5_IK, 1_IK)
54 call disp%show("Year")
55 call disp%show( Year )
56 call disp%show("getCountLeapYears(until = Year, since = -5_IK)")
57 call disp%show( getCountLeapYears(until = Year, since = -5_IK) )
58 call disp%skip()
59
60 call disp%skip()
61 call disp%show("Year = getRange(-8_IK, 8_IK, 1_IK)")
62 Year = getRange(-8_IK, 8_IK, 1_IK)
63 call disp%show("Year")
64 call disp%show( Year )
65 call disp%show("getCountLeapYears(until = Year)")
66 call disp%show( getCountLeapYears(until = Year) )
67 call disp%skip()
68
69 call disp%skip()
70 call disp%show("getYear()")
71 call disp%show( getYear() )
72 call disp%show("getCountLeapYears(until = getYear(), since = 1_IK)")
73 call disp%show( getCountLeapYears(until = getYear(), since = 1_IK) )
74 call disp%skip()
75
76 call disp%skip()
77 call disp%show("getYear()")
78 call disp%show( getYear() )
79 call disp%show("getCountLeapYears(until = getYear(), since = [1999_IK, 2000_IK, 2001_IK])")
80 call disp%show( getCountLeapYears(until = getYear(), since = [1999_IK, 2000_IK, 2001_IK]) )
81 call disp%skip()
82
83end program example
Generate minimally-spaced character, integer, real sequences or sequences at fixed intervals of size ...
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
Generate and return the conversion of the input value to an output Fortran string,...
Definition: pm_val2str.F90:167
This module contains procedures and generic interfaces for generating ranges of discrete character,...
integer(IK) function getYear()
Generate and return the current year of the Gregorian calendar.
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
This module contains the generic procedures for converting values of different types and kinds to For...
Definition: pm_val2str.F90:58
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3! Determine if a given Gregorian calendar date is the last of the month.
4!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6
7getCountLeapYears(until = 1_IK)
8+0
9
10
11getCountLeapYears(until = 2000_IK)
12+485
13
14
15getYear()
16+2024
18+491
19
20
21getYear()
22+2024
23getCountLeapYears(until = getYear(), since = 1_IK)
24+491
25
26
27getCountLeapYears(until = [1_IK, 2_IK, 3_IK, 4_IK])
28+0, +0, +0, +1
29
30
31Year = getRange(-5_IK, 5_IK, 1_IK)
32Year
33-5, -4, -3, -2, -1, +0, +1, +2, +3, +4, +5
34getCountLeapYears(until = Year, since = -5_IK)
35+0, +1, +1, +1, +1, +2, +2, +2, +2, +3, +3
36
37
38Year = getRange(-8_IK, 8_IK, 1_IK)
39Year
40-8, -7, -6, -5, -4, -3, -2, -1, +0, +1, +2, +3, +4, +5, +6, +7, +8
41getCountLeapYears(until = Year)
42-3, -2, -2, -2, -2, -1, -1, -1, -1, +0, +0, +0, +1, +1, +1, +1, +2
43
44
45getYear()
46+2024
47getCountLeapYears(until = getYear(), since = 1_IK)
48+491
49
50
51getYear()
52+2024
53getCountLeapYears(until = getYear(), since = [1999_IK, 2000_IK, 2001_IK])
54+7, +7, +6
55
56
Test:
test_pm_dateTime


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, March 22, 2012, 00:00 AM, National Institute for Fusion Studies, The University of Texas at Austin

Definition at line 3783 of file pm_dateTime.F90.


The documentation for this interface was generated from the following file: