PageRenderTime 57ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/wrfv2_fire/external/esmf_time_f90/ESMF_TimeInterval.F90

http://github.com/jbeezley/wrf-fire
FORTRAN Modern | 1268 lines | 387 code | 174 blank | 707 comment | 6 complexity | d5450167d82e975c16ccc13b11d4eb4e MD5 | raw file
Possible License(s): AGPL-1.0
  1. !
  2. ! Earth System Modeling Framework
  3. ! Copyright 2002-2003, University Corporation for Atmospheric Research,
  4. ! Massachusetts Institute of Technology, Geophysical Fluid Dynamics
  5. ! Laboratory, University of Michigan, National Centers for Environmental
  6. ! Prediction, Los Alamos National Laboratory, Argonne National Laboratory,
  7. ! NASA Goddard Space Flight Center.
  8. ! Licensed under the University of Illinois-NCSA license.
  9. !
  10. !==============================================================================
  11. !
  12. ! ESMF TimeInterval Module
  13. module ESMF_TimeIntervalMod
  14. !
  15. !==============================================================================
  16. !
  17. ! This file contains the TimeInterval class definition and all TimeInterval
  18. ! class methods.
  19. !
  20. !------------------------------------------------------------------------------
  21. ! INCLUDES
  22. #include <ESMF_TimeMgr.inc>
  23. !
  24. !===============================================================================
  25. !BOPI
  26. ! !MODULE: ESMF_TimeIntervalMod
  27. !
  28. ! !DESCRIPTION:
  29. ! Part of Time Manager F90 API wrapper of C++ implemenation
  30. !
  31. ! Defines F90 wrapper entry points for corresponding
  32. ! C++ implementaion of class {\tt ESMC\_TimeInterval}
  33. !
  34. ! See {\tt ../include/ESMC\_TimeInterval.h} for complete description
  35. !
  36. !------------------------------------------------------------------------------
  37. ! !USES:
  38. ! inherit from ESMF base class
  39. use ESMF_BaseMod
  40. ! inherit from base time class
  41. use ESMF_BaseTimeMod
  42. ! associated derived types
  43. use ESMF_FractionMod, only : ESMF_Fraction
  44. use ESMF_CalendarMod
  45. implicit none
  46. !
  47. !------------------------------------------------------------------------------
  48. ! !PRIVATE TYPES:
  49. private
  50. !------------------------------------------------------------------------------
  51. ! ! ESMF_TimeInterval
  52. !
  53. ! ! F90 class type to match C++ TimeInterval class in size only;
  54. ! ! all dereferencing within class is performed by C++ implementation
  55. type ESMF_TimeInterval
  56. ! time interval is expressed as basetime
  57. type(ESMF_BaseTime) :: basetime ! inherit base class
  58. ! Relative year and month fields support monthly or yearly time
  59. ! intervals. Many operations are undefined when these fields are
  60. ! non-zero!
  61. INTEGER :: YR ! relative year
  62. !jm Month has no meaning for an interval; get rid of it, 20100319
  63. ! INTEGER :: MM ! relative month
  64. end type
  65. !------------------------------------------------------------------------------
  66. ! !PUBLIC TYPES:
  67. public ESMF_TimeInterval
  68. !------------------------------------------------------------------------------
  69. !
  70. ! !PUBLIC MEMBER FUNCTIONS:
  71. public ESMF_TimeIntervalGet
  72. public ESMF_TimeIntervalSet
  73. public ESMFold_TimeIntervalGetString
  74. public ESMF_TimeIntervalAbsValue
  75. public ESMF_TimeIntervalNegAbsValue
  76. ! Required inherited and overridden ESMF_Base class methods
  77. !!!!!!!!! added 20051012, JM
  78. ! public WRFADDITION_TimeIntervalDIVQuot
  79. !!!!!!!!! renamed to simplify testing 20060320, TH
  80. public ESMF_TimeIntervalDIVQuot
  81. ! This convenience routine is only used by other modules in
  82. ! esmf_time_f90.
  83. public ESMF_TimeIntervalIsPositive
  84. ! !PRIVATE MEMBER FUNCTIONS:
  85. ! overloaded operator functions
  86. public operator(/)
  87. private ESMF_TimeIntervalQuotI
  88. public operator(*)
  89. private ESMF_TimeIntervalProdI
  90. ! Inherited and overloaded from ESMF_BaseTime
  91. public operator(+)
  92. private ESMF_TimeIntervalSum
  93. public operator(-)
  94. private ESMF_TimeIntervalDiff
  95. public operator(.EQ.)
  96. private ESMF_TimeIntervalEQ
  97. public operator(.NE.)
  98. private ESMF_TimeIntervalNE
  99. public operator(.LT.)
  100. private ESMF_TimeIntervalLT
  101. public operator(.GT.)
  102. private ESMF_TimeIntervalGT
  103. public operator(.LE.)
  104. private ESMF_TimeIntervalLE
  105. public operator(.GE.)
  106. private ESMF_TimeIntervalGE
  107. !EOPI
  108. !==============================================================================
  109. !
  110. ! INTERFACE BLOCKS
  111. !
  112. !==============================================================================
  113. !BOP
  114. ! !INTERFACE:
  115. interface operator(*)
  116. ! !PRIVATE MEMBER FUNCTIONS:
  117. module procedure ESMF_TimeIntervalProdI
  118. ! !DESCRIPTION:
  119. ! This interface overloads the * operator for the {\tt ESMF\_TimeInterval}
  120. ! class
  121. !
  122. !EOP
  123. end interface
  124. !
  125. !------------------------------------------------------------------------------
  126. !BOP
  127. ! !INTERFACE:
  128. interface operator(/)
  129. ! !PRIVATE MEMBER FUNCTIONS:
  130. module procedure ESMF_TimeIntervalQuotI
  131. ! !DESCRIPTION:
  132. ! This interface overloads the / operator for the
  133. ! {\tt ESMF\_TimeInterval} class
  134. !
  135. !EOP
  136. end interface
  137. !
  138. !------------------------------------------------------------------------------
  139. !BOP
  140. ! !INTERFACE:
  141. interface operator(+)
  142. ! !PRIVATE MEMBER FUNCTIONS:
  143. module procedure ESMF_TimeIntervalSum
  144. ! !DESCRIPTION:
  145. ! This interface overloads the + operator for the
  146. ! {\tt ESMF\_TimeInterval} class
  147. !
  148. !EOP
  149. end interface
  150. !
  151. !------------------------------------------------------------------------------
  152. !BOP
  153. ! !INTERFACE:
  154. interface operator(-)
  155. ! !PRIVATE MEMBER FUNCTIONS:
  156. module procedure ESMF_TimeIntervalDiff
  157. ! !DESCRIPTION:
  158. ! This interface overloads the - operator for the
  159. ! {\tt ESMF\_TimeInterval} class
  160. !
  161. !EOP
  162. end interface
  163. !
  164. !------------------------------------------------------------------------------
  165. !BOP
  166. ! !INTERFACE:
  167. interface operator(.EQ.)
  168. ! !PRIVATE MEMBER FUNCTIONS:
  169. module procedure ESMF_TimeIntervalEQ
  170. ! !DESCRIPTION:
  171. ! This interface overloads the .EQ. operator for the
  172. ! {\tt ESMF\_TimeInterval} class
  173. !
  174. !EOP
  175. end interface
  176. !
  177. !------------------------------------------------------------------------------
  178. !BOP
  179. ! !INTERFACE:
  180. interface operator(.NE.)
  181. ! !PRIVATE MEMBER FUNCTIONS:
  182. module procedure ESMF_TimeIntervalNE
  183. ! !DESCRIPTION:
  184. ! This interface overloads the .NE. operator for the
  185. ! {\tt ESMF\_TimeInterval} class
  186. !
  187. !EOP
  188. end interface
  189. !
  190. !------------------------------------------------------------------------------
  191. !BOP
  192. ! !INTERFACE:
  193. interface operator(.LT.)
  194. ! !PRIVATE MEMBER FUNCTIONS:
  195. module procedure ESMF_TimeIntervalLT
  196. ! !DESCRIPTION:
  197. ! This interface overloads the .LT. operator for the
  198. ! {\tt ESMF\_TimeInterval} class
  199. !
  200. !EOP
  201. end interface
  202. !
  203. !------------------------------------------------------------------------------
  204. !BOP
  205. ! !INTERFACE:
  206. interface operator(.GT.)
  207. ! !PRIVATE MEMBER FUNCTIONS:
  208. module procedure ESMF_TimeIntervalGT
  209. ! !DESCRIPTION:
  210. ! This interface overloads the .GT. operator for the
  211. ! {\tt ESMF\_TimeInterval} class
  212. !
  213. !EOP
  214. end interface
  215. !
  216. !------------------------------------------------------------------------------
  217. !BOP
  218. ! !INTERFACE:
  219. interface operator(.LE.)
  220. ! !PRIVATE MEMBER FUNCTIONS:
  221. module procedure ESMF_TimeIntervalLE
  222. ! !DESCRIPTION:
  223. ! This interface overloads the .LE. operator for the
  224. ! {\tt ESMF\_TimeInterval} class
  225. !
  226. !EOP
  227. end interface
  228. !
  229. !------------------------------------------------------------------------------
  230. !BOP
  231. ! !INTERFACE:
  232. interface operator(.GE.)
  233. ! !PRIVATE MEMBER FUNCTIONS:
  234. module procedure ESMF_TimeIntervalGE
  235. ! !DESCRIPTION:
  236. ! This interface overloads the .GE. operator for the
  237. ! {\tt ESMF\_TimeInterval} class
  238. !
  239. !EOP
  240. end interface
  241. !
  242. !------------------------------------------------------------------------------
  243. !==============================================================================
  244. contains
  245. !==============================================================================
  246. !
  247. ! Generic Get/Set routines which use F90 optional arguments
  248. !
  249. !------------------------------------------------------------------------------
  250. !BOP
  251. ! !IROUTINE: ESMF_TimeIntervalGet - Get value in user-specified units
  252. ! !INTERFACE:
  253. subroutine ESMF_TimeIntervalGet(timeinterval, D, d_r8, S, S_i8, Sn, Sd, &
  254. TimeString, rc )
  255. ! !ARGUMENTS:
  256. type(ESMF_TimeInterval), intent(in) :: timeinterval
  257. integer, intent(out), optional :: D
  258. real(ESMF_KIND_R8), intent(out), optional :: d_r8
  259. integer(ESMF_KIND_I8), intent(out), optional :: S_i8
  260. integer, intent(out), optional :: S
  261. integer, intent(out), optional :: Sn
  262. integer, intent(out), optional :: Sd
  263. character*(*), optional, intent(out) :: TimeString
  264. integer, intent(out), optional :: rc
  265. ! !DESCRIPTION:
  266. ! Get the value of the {\tt ESMF\_TimeInterval} in units specified by the
  267. ! user via F90 optional arguments.
  268. !
  269. ! Time manager represents and manipulates time internally with integers
  270. ! to maintain precision. Hence, user-specified floating point values are
  271. ! converted internally from integers.
  272. !
  273. ! See {\tt ../include/ESMC\_BaseTime.h} and
  274. ! {\tt ../include/ESMC\_TimeInterval.h} for complete description.
  275. !
  276. ! The arguments are:
  277. ! \begin{description}
  278. ! \item[timeinterval]
  279. ! The object instance to query
  280. ! \item[{[YY]}]
  281. ! Integer years (>= 32-bit)
  282. ! \item[{[YYl]}]
  283. ! Integer years (large, >= 64-bit)
  284. ! \item[{[MO]}]
  285. ! Integer months (>= 32-bit)
  286. ! \item[{[MOl]}]
  287. ! Integer months (large, >= 64-bit)
  288. ! \item[{[D]}]
  289. ! Integer days (>= 32-bit)
  290. ! \item[{[Dl]}]
  291. ! Integer days (large, >= 64-bit)
  292. ! \item[{[H]}]
  293. ! Integer hours
  294. ! \item[{[M]}]
  295. ! Integer minutes
  296. ! \item[{[S]}]
  297. ! Integer seconds (>= 32-bit)
  298. ! \item[{[Sl]}]
  299. ! Integer seconds (large, >= 64-bit)
  300. ! \item[{[MS]}]
  301. ! Integer milliseconds
  302. ! \item[{[US]}]
  303. ! Integer microseconds
  304. ! \item[{[NS]}]
  305. ! Integer nanoseconds
  306. ! \item[{[d\_]}]
  307. ! Double precision days
  308. ! \item[{[h\_]}]
  309. ! Double precision hours
  310. ! \item[{[m\_]}]
  311. ! Double precision minutes
  312. ! \item[{[s\_]}]
  313. ! Double precision seconds
  314. ! \item[{[ms\_]}]
  315. ! Double precision milliseconds
  316. ! \item[{[us\_]}]
  317. ! Double precision microseconds
  318. ! \item[{[ns\_]}]
  319. ! Double precision nanoseconds
  320. ! \item[{[Sn]}]
  321. ! Integer fractional seconds - numerator
  322. ! \item[{[Sd]}]
  323. ! Integer fractional seconds - denominator
  324. ! \item[{[rc]}]
  325. ! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
  326. ! \end{description}
  327. !
  328. ! !REQUIREMENTS:
  329. ! TMG1.1
  330. !
  331. ! Added argument to output double precision seconds, S_i8
  332. ! William.Gustafson@pnl.gov; 9-May-2008
  333. !
  334. !EOP
  335. INTEGER(ESMF_KIND_I8) :: seconds
  336. INTEGER :: ierr
  337. ierr = ESMF_SUCCESS
  338. seconds = timeinterval%basetime%S
  339. ! note that S is overwritten below (if present) if other args are also
  340. ! present
  341. IF ( PRESENT(S) ) S = seconds
  342. IF ( PRESENT(S_i8) ) S_i8 = seconds
  343. IF ( PRESENT( D ) ) THEN
  344. D = seconds / SECONDS_PER_DAY
  345. IF ( PRESENT(S) ) S = MOD( seconds, SECONDS_PER_DAY )
  346. IF ( PRESENT(S_i8) ) S_i8 = MOD( seconds, SECONDS_PER_DAY )
  347. ENDIF
  348. IF ( PRESENT( d_r8 ) ) THEN
  349. D_r8 = REAL( seconds, ESMF_KIND_R8 ) / &
  350. REAL( SECONDS_PER_DAY, ESMF_KIND_R8 )
  351. IF ( PRESENT(S) ) S = MOD( seconds, SECONDS_PER_DAY )
  352. IF ( PRESENT(S_i8) ) S_i8 = MOD( seconds, SECONDS_PER_DAY )
  353. ENDIF
  354. IF ( PRESENT(Sn) ) THEN
  355. Sn = timeinterval%basetime%Sn
  356. ENDIF
  357. IF ( PRESENT(Sd) ) THEN
  358. Sd = timeinterval%basetime%Sd
  359. ENDIF
  360. IF ( PRESENT( timeString ) ) THEN
  361. CALL ESMFold_TimeIntervalGetString( timeinterval, timeString, rc=ierr )
  362. ENDIF
  363. IF ( PRESENT(rc) ) rc = ierr
  364. end subroutine ESMF_TimeIntervalGet
  365. !------------------------------------------------------------------------------
  366. !BOP
  367. ! !IROUTINE: ESMF_TimeIntervalSet - Initialize via user-specified unit set
  368. ! !INTERFACE:
  369. subroutine ESMF_TimeIntervalSet(timeinterval, YY, YYl, MM, MOl, D, Dl, &
  370. H, M, S, Sl, MS, US, NS, &
  371. d_, h_, m_, s_, ms_, us_, ns_, &
  372. Sn, Sd, rc)
  373. ! !ARGUMENTS:
  374. type(ESMF_TimeInterval), intent(out) :: timeinterval
  375. integer, intent(in), optional :: YY
  376. integer(ESMF_KIND_I8), intent(in), optional :: YYl
  377. integer, intent(in), optional :: MM
  378. integer(ESMF_KIND_I8), intent(in), optional :: MOl
  379. integer, intent(in), optional :: D
  380. integer(ESMF_KIND_I8), intent(in), optional :: Dl
  381. integer, intent(in), optional :: H
  382. integer, intent(in), optional :: M
  383. integer, intent(in), optional :: S
  384. integer(ESMF_KIND_I8), intent(in), optional :: Sl
  385. integer, intent(in), optional :: MS
  386. integer, intent(in), optional :: US
  387. integer, intent(in), optional :: NS
  388. double precision, intent(in), optional :: d_
  389. double precision, intent(in), optional :: h_
  390. double precision, intent(in), optional :: m_
  391. double precision, intent(in), optional :: s_
  392. double precision, intent(in), optional :: ms_
  393. double precision, intent(in), optional :: us_
  394. double precision, intent(in), optional :: ns_
  395. integer, intent(in), optional :: Sn
  396. integer, intent(in), optional :: Sd
  397. integer, intent(out), optional :: rc
  398. ! locals
  399. INTEGER :: nfeb
  400. ! !DESCRIPTION:
  401. ! Set the value of the {\tt ESMF\_TimeInterval} in units specified by
  402. ! the user via F90 optional arguments
  403. !
  404. ! Time manager represents and manipulates time internally with integers
  405. ! to maintain precision. Hence, user-specified floating point values are
  406. ! converted internally to integers.
  407. !
  408. ! See {\tt ../include/ESMC\_BaseTime.h} and
  409. ! {\tt ../include/ESMC\_TimeInterval.h} for complete description.
  410. !
  411. ! The arguments are:
  412. ! \begin{description}
  413. ! \item[timeinterval]
  414. ! The object instance to initialize
  415. ! \item[{[YY]}]
  416. ! Integer number of interval years (>= 32-bit)
  417. ! \item[{[YYl]}]
  418. ! Integer number of interval years (large, >= 64-bit)
  419. ! \item[{[MM]}]
  420. ! Integer number of interval months (>= 32-bit)
  421. ! \item[{[MOl]}]
  422. ! Integer number of interval months (large, >= 64-bit)
  423. ! \item[{[D]}]
  424. ! Integer number of interval days (>= 32-bit)
  425. ! \item[{[Dl]}]
  426. ! Integer number of interval days (large, >= 64-bit)
  427. ! \item[{[H]}]
  428. ! Integer hours
  429. ! \item[{[M]}]
  430. ! Integer minutes
  431. ! \item[{[S]}]
  432. ! Integer seconds (>= 32-bit)
  433. ! \item[{[Sl]}]
  434. ! Integer seconds (large, >= 64-bit)
  435. ! \item[{[MS]}]
  436. ! Integer milliseconds
  437. ! \item[{[US]}]
  438. ! Integer microseconds
  439. ! \item[{[NS]}]
  440. ! Integer nanoseconds
  441. ! \item[{[d\_]}]
  442. ! Double precision days
  443. ! \item[{[h\_]}]
  444. ! Double precision hours
  445. ! \item[{[m\_]}]
  446. ! Double precision minutes
  447. ! \item[{[s\_]}]
  448. ! Double precision seconds
  449. ! \item[{[ms\_]}]
  450. ! Double precision milliseconds
  451. ! \item[{[us\_]}]
  452. ! Double precision microseconds
  453. ! \item[{[ns\_]}]
  454. ! Double precision nanoseconds
  455. ! \item[{[Sn]}]
  456. ! Integer fractional seconds - numerator
  457. ! \item[{[Sd]}]
  458. ! Integer fractional seconds - denominator
  459. ! \item[{[rc]}]
  460. ! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
  461. ! \end{description}
  462. !
  463. ! !REQUIREMENTS:
  464. ! TMGn.n.n
  465. !EOP
  466. IF ( PRESENT(rc) ) rc = ESMF_FAILURE
  467. ! note that YR and MM are relative
  468. timeinterval%YR = 0
  469. IF ( PRESENT( YY ) ) THEN
  470. timeinterval%YR = YY
  471. ENDIF
  472. !jm timeinterval%MM = 0
  473. !jm IF ( PRESENT( MM ) ) THEN
  474. !jm timeinterval%MM = MM
  475. !jm ENDIF
  476. !jm ! Rollover months to years
  477. !jm IF ( abs(timeinterval%MM) .GE. MONTHS_PER_YEAR ) THEN
  478. !jm timeinterval%YR = timeinterval%YR + timeinterval%MM/MONTHS_PER_YEAR
  479. !jm timeinterval%MM = mod(timeinterval%MM,MONTHS_PER_YEAR)
  480. !jm ENDIF
  481. timeinterval%basetime%S = 0
  482. ! For 365-day calendar, immediately convert years to days since we know
  483. ! how to do it in this case.
  484. !$$$ replace this hack with something saner...
  485. IF ( nfeb( 2004 ) == 28 ) THEN
  486. timeinterval%basetime%S = timeinterval%basetime%S + &
  487. ( 365_ESMF_KIND_I8 * &
  488. INT( timeinterval%YR, ESMF_KIND_I8 ) * SECONDS_PER_DAY )
  489. timeinterval%YR = 0
  490. ENDIF
  491. IF ( PRESENT( D ) ) THEN
  492. timeinterval%basetime%S = timeinterval%basetime%S + &
  493. ( SECONDS_PER_DAY * INT( D, ESMF_KIND_I8 ) )
  494. ENDIF
  495. !$$$ Push H,M,S,Sn,Sd,MS down into BaseTime constructor from EVERYWHERE
  496. !$$$ and THEN add ESMF scaling behavior when other args are present...
  497. IF ( PRESENT( H ) ) THEN
  498. timeinterval%basetime%S = timeinterval%basetime%S + &
  499. ( SECONDS_PER_HOUR * INT( H, ESMF_KIND_I8 ) )
  500. ENDIF
  501. IF ( PRESENT( M ) ) THEN
  502. timeinterval%basetime%S = timeinterval%basetime%S + &
  503. ( SECONDS_PER_MINUTE * INT( M, ESMF_KIND_I8 ) )
  504. ENDIF
  505. IF ( PRESENT( S ) ) THEN
  506. timeinterval%basetime%S = timeinterval%basetime%S + &
  507. INT( S, ESMF_KIND_I8 )
  508. ENDIF
  509. IF ( PRESENT( Sn ) .AND. ( .NOT. PRESENT( Sd ) ) ) THEN
  510. CALL wrf_error_fatal( &
  511. "ESMF_TimeIntervalSet: Must specify Sd if Sn is specified")
  512. ENDIF
  513. IF ( PRESENT( Sd ) .AND. PRESENT( MS ) ) THEN
  514. CALL wrf_error_fatal( &
  515. "ESMF_TimeIntervalSet: Must not specify both Sd and MS")
  516. ENDIF
  517. timeinterval%basetime%Sn = 0
  518. timeinterval%basetime%Sd = 0
  519. IF ( PRESENT( MS ) ) THEN
  520. timeinterval%basetime%Sn = MS
  521. timeinterval%basetime%Sd = 1000_ESMF_KIND_I8
  522. ELSE IF ( PRESENT( Sd ) ) THEN
  523. timeinterval%basetime%Sd = Sd
  524. IF ( PRESENT( Sn ) ) THEN
  525. timeinterval%basetime%Sn = Sn
  526. ENDIF
  527. ENDIF
  528. CALL normalize_timeint( timeinterval )
  529. IF ( PRESENT(rc) ) rc = ESMF_SUCCESS
  530. end subroutine ESMF_TimeIntervalSet
  531. !------------------------------------------------------------------------------
  532. !BOP
  533. ! !IROUTINE: ESMFold_TimeIntervalGetString - Get time interval value in string format
  534. ! !INTERFACE:
  535. subroutine ESMFold_TimeIntervalGetString(timeinterval, TimeString, rc)
  536. ! !ARGUMENTS:
  537. type(ESMF_TimeInterval), intent(in) :: timeinterval
  538. character*(*), intent(out) :: TimeString
  539. integer, intent(out), optional :: rc
  540. ! locals
  541. integer :: signnormtimeint
  542. LOGICAL :: negative
  543. INTEGER(ESMF_KIND_I8) :: iS, iSn, iSd, H, M, S
  544. character (len=1) :: signstr
  545. ! !DESCRIPTION:
  546. ! Convert {\tt ESMF\_TimeInterval}'s value into string format
  547. !
  548. ! The arguments are:
  549. ! \begin{description}
  550. ! \item[timeinterval]
  551. ! The object instance to convert
  552. ! \item[TimeString]
  553. ! The string to return
  554. ! \item[{[rc]}]
  555. ! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
  556. ! \end{description}
  557. !
  558. ! !REQUIREMENTS:
  559. ! TMG1.5.9
  560. !EOP
  561. ! NOTE: YR, MM, Sn, and Sd are not yet included in the returned string...
  562. !PRINT *,'DEBUG ESMFold_TimeIntervalGetString(): YR,MM,S,Sn,Sd = ', &
  563. ! timeinterval%YR, &
  564. ! timeinterval%MM, &
  565. ! timeinterval%basetime%S, &
  566. ! timeinterval%basetime%Sn, &
  567. ! timeinterval%basetime%Sd
  568. negative = ( signnormtimeint( timeInterval ) == -1 )
  569. IF ( negative ) THEN
  570. iS = -timeinterval%basetime%S
  571. iSn = -timeinterval%basetime%Sn
  572. signstr = '-'
  573. ELSE
  574. iS = timeinterval%basetime%S
  575. iSn = timeinterval%basetime%Sn
  576. signstr = ''
  577. ENDIF
  578. iSd = timeinterval%basetime%Sd
  579. H = mod( iS, SECONDS_PER_DAY ) / SECONDS_PER_HOUR
  580. M = mod( iS, SECONDS_PER_HOUR) / SECONDS_PER_MINUTE
  581. S = mod( iS, SECONDS_PER_MINUTE )
  582. !$$$here... need to print Sn and Sd when they are used ???
  583. write(TimeString,FMT="(A,I10.10,'_',I3.3,':',I3.3,':',I3.3)") &
  584. TRIM(signstr), ( iS / SECONDS_PER_DAY ), H, M, S
  585. !write(0,*)'TimeIntervalGetString Sn ',timeinterval%basetime%Sn,' Sd ',timeinterval%basetime%Sd
  586. rc = ESMF_SUCCESS
  587. end subroutine ESMFold_TimeIntervalGetString
  588. !------------------------------------------------------------------------------
  589. !BOP
  590. ! !IROUTINE: ESMF_TimeIntervalAbsValue - Get the absolute value of a time interval
  591. ! !INTERFACE:
  592. function ESMF_TimeIntervalAbsValue(timeinterval)
  593. ! !RETURN VALUE:
  594. type(ESMF_TimeInterval) :: ESMF_TimeIntervalAbsValue
  595. ! !ARGUMENTS:
  596. type(ESMF_TimeInterval), intent(in) :: timeinterval
  597. ! !LOCAL:
  598. integer :: rc
  599. ! !DESCRIPTION:
  600. ! Return a {\tt ESMF\_TimeInterval}'s absolute value.
  601. !
  602. ! The arguments are:
  603. ! \begin{description}
  604. ! \item[timeinterval]
  605. ! The object instance to take the absolute value of.
  606. ! Absolute value returned as value of function.
  607. ! \end{description}
  608. !
  609. ! !REQUIREMENTS:
  610. ! TMG1.5.8
  611. !EOP
  612. CALL timeintchecknormalized( timeinterval, 'ESMF_TimeIntervalAbsValue arg1' )
  613. ESMF_TimeIntervalAbsValue = timeinterval
  614. !$$$here... move implementation into BaseTime
  615. ESMF_TimeIntervalAbsValue%basetime%S = &
  616. abs(ESMF_TimeIntervalAbsValue%basetime%S)
  617. ESMF_TimeIntervalAbsValue%basetime%Sn = &
  618. abs(ESMF_TimeIntervalAbsValue%basetime%Sn )
  619. end function ESMF_TimeIntervalAbsValue
  620. !------------------------------------------------------------------------------
  621. !BOP
  622. ! !IROUTINE: ESMF_TimeIntervalNegAbsValue - Get the negative absolute value of a time interval
  623. ! !INTERFACE:
  624. function ESMF_TimeIntervalNegAbsValue(timeinterval)
  625. ! !RETURN VALUE:
  626. type(ESMF_TimeInterval) :: ESMF_TimeIntervalNegAbsValue
  627. ! !ARGUMENTS:
  628. type(ESMF_TimeInterval), intent(in) :: timeinterval
  629. ! !LOCAL:
  630. integer :: rc
  631. ! !DESCRIPTION:
  632. ! Return a {\tt ESMF\_TimeInterval}'s negative absolute value.
  633. !
  634. ! The arguments are:
  635. ! \begin{description}
  636. ! \item[timeinterval]
  637. ! The object instance to take the negative absolute value of.
  638. ! Negative absolute value returned as value of function.
  639. ! \end{description}
  640. !
  641. ! !REQUIREMENTS:
  642. ! TMG1.5.8
  643. !EOP
  644. CALL timeintchecknormalized( timeinterval, 'ESMF_TimeIntervalNegAbsValue arg1' )
  645. ESMF_TimeIntervalNegAbsValue = timeinterval
  646. !$$$here... move implementation into BaseTime
  647. ESMF_TimeIntervalNegAbsValue%basetime%S = &
  648. -abs(ESMF_TimeIntervalNegAbsValue%basetime%S)
  649. ESMF_TimeIntervalNegAbsValue%basetime%Sn = &
  650. -abs(ESMF_TimeIntervalNegAbsValue%basetime%Sn )
  651. end function ESMF_TimeIntervalNegAbsValue
  652. !------------------------------------------------------------------------------
  653. !
  654. ! This section includes overloaded operators defined only for TimeInterval
  655. ! (not inherited from BaseTime)
  656. ! Note: these functions do not have a return code, since F90 forbids more
  657. ! than 2 arguments for arithmetic overloaded operators
  658. !
  659. !------------------------------------------------------------------------------
  660. !!!!!!!!!!!!!!!!!! added jm 20051012
  661. ! new WRF-specific function, Divide two time intervals and return the whole integer, without remainder
  662. function ESMF_TimeIntervalDIVQuot(timeinterval1, timeinterval2)
  663. ! !RETURN VALUE:
  664. INTEGER :: ESMF_TimeIntervalDIVQuot
  665. ! !ARGUMENTS:
  666. type(ESMF_TimeInterval), intent(in) :: timeinterval1
  667. type(ESMF_TimeInterval), intent(in) :: timeinterval2
  668. ! !LOCAL
  669. INTEGER :: retval, isgn, rc
  670. type(ESMF_TimeInterval) :: zero, i1,i2
  671. ! !DESCRIPTION:
  672. ! Returns timeinterval1 divided by timeinterval2 as a fraction quotient.
  673. !
  674. ! The arguments are:
  675. ! \begin{description}
  676. ! \item[timeinterval1]
  677. ! The dividend
  678. ! \item[timeinterval2]
  679. ! The divisor
  680. ! \end{description}
  681. !
  682. ! !REQUIREMENTS:
  683. ! TMG1.5.5
  684. !EOP
  685. CALL timeintchecknormalized( timeinterval1, 'ESMF_TimeIntervalDIVQuot arg1' )
  686. CALL timeintchecknormalized( timeinterval2, 'ESMF_TimeIntervalDIVQuot arg2' )
  687. call ESMF_TimeIntervalSet( zero, rc=rc )
  688. i1 = timeinterval1
  689. i2 = timeinterval2
  690. isgn = 1
  691. if ( i1 .LT. zero ) then
  692. i1 = ESMF_TimeIntervalProdI(i1, -1)
  693. isgn = -isgn
  694. endif
  695. if ( i2 .LT. zero ) then
  696. i2 = ESMF_TimeIntervalProdI(i2, -1)
  697. isgn = -isgn
  698. endif
  699. ! repeated subtraction
  700. retval = 0
  701. DO WHILE ( i1 .GE. i2 )
  702. i1 = i1 - i2
  703. retval = retval + 1
  704. ENDDO
  705. retval = retval * isgn
  706. ESMF_TimeIntervalDIVQuot = retval
  707. end function ESMF_TimeIntervalDIVQuot
  708. !!!!!!!!!!!!!!!!!!
  709. !------------------------------------------------------------------------------
  710. !BOP
  711. ! !IROUTINE: ESMF_TimeIntervalQuotI - Divide time interval by an integer, return time interval result
  712. ! !INTERFACE:
  713. function ESMF_TimeIntervalQuotI(timeinterval, divisor)
  714. ! !RETURN VALUE:
  715. type(ESMF_TimeInterval) :: ESMF_TimeIntervalQuotI
  716. ! !ARGUMENTS:
  717. type(ESMF_TimeInterval), intent(in) :: timeinterval
  718. integer, intent(in) :: divisor
  719. ! !DESCRIPTION:
  720. ! Divides a {\tt ESMF\_TimeInterval} by an integer divisor, returns
  721. ! quotient as a {\tt ESMF\_TimeInterval}
  722. !
  723. ! The arguments are:
  724. ! \begin{description}
  725. ! \item[timeinterval]
  726. ! The dividend
  727. ! \item[divisor]
  728. ! Integer divisor
  729. ! \end{description}
  730. !
  731. ! !REQUIREMENTS:
  732. ! TMG1.5.6, TMG5.3, TMG7.2
  733. !EOP
  734. !PRINT *,'DEBUG ESMF_TimeIntervalQuotI() A: S,Sn,Sd = ', &
  735. ! timeinterval%basetime%S,timeinterval%basetime%Sn,timeinterval%basetime%Sd
  736. !PRINT *,'DEBUG ESMF_TimeIntervalQuotI() A: divisor = ', divisor
  737. CALL timeintchecknormalized( timeinterval, 'ESMF_TimeIntervalQuotI arg1' )
  738. IF ( divisor == 0 ) THEN
  739. CALL wrf_error_fatal( 'ESMF_TimeIntervalQuotI: divide by zero' )
  740. ENDIF
  741. ESMF_TimeIntervalQuotI = timeinterval
  742. !PRINT *,'DEBUG ESMF_TimeIntervalQuotI() B: S,Sn,Sd = ', &
  743. ! ESMF_TimeIntervalQuotI%basetime%S,ESMF_TimeIntervalQuotI%basetime%Sn,ESMF_TimeIntervalQuotI%basetime%Sd
  744. ESMF_TimeIntervalQuotI%basetime = &
  745. timeinterval%basetime / divisor
  746. !PRINT *,'DEBUG ESMF_TimeIntervalQuotI() C: S,Sn,Sd = ', &
  747. ! ESMF_TimeIntervalQuotI%basetime%S,ESMF_TimeIntervalQuotI%basetime%Sn,ESMF_TimeIntervalQuotI%basetime%Sd
  748. CALL normalize_timeint( ESMF_TimeIntervalQuotI )
  749. !PRINT *,'DEBUG ESMF_TimeIntervalQuotI() D: S,Sn,Sd = ', &
  750. ! ESMF_TimeIntervalQuotI%basetime%S,ESMF_TimeIntervalQuotI%basetime%Sn,ESMF_TimeIntervalQuotI%basetime%Sd
  751. end function ESMF_TimeIntervalQuotI
  752. !------------------------------------------------------------------------------
  753. !BOP
  754. ! !IROUTINE: ESMF_TimeIntervalProdI - Multiply a time interval by an integer
  755. ! !INTERFACE:
  756. function ESMF_TimeIntervalProdI(timeinterval, multiplier)
  757. ! !RETURN VALUE:
  758. type(ESMF_TimeInterval) :: ESMF_TimeIntervalProdI
  759. ! !ARGUMENTS:
  760. type(ESMF_TimeInterval), intent(in) :: timeinterval
  761. integer, intent(in) :: multiplier
  762. ! !LOCAL:
  763. integer :: rc
  764. ! !DESCRIPTION:
  765. ! Multiply a {\tt ESMF\_TimeInterval} by an integer, return product as a
  766. ! {\tt ESMF\_TimeInterval}
  767. !
  768. ! The arguments are:
  769. ! \begin{description}
  770. ! \item[timeinterval]
  771. ! The multiplicand
  772. ! \item[mutliplier]
  773. ! Integer multiplier
  774. ! \end{description}
  775. !
  776. ! !REQUIREMENTS:
  777. ! TMG1.5.7, TMG7.2
  778. !EOP
  779. CALL timeintchecknormalized( timeinterval, 'ESMF_TimeIntervalProdI arg1' )
  780. CALL ESMF_TimeIntervalSet( ESMF_TimeIntervalProdI, rc=rc )
  781. !$$$move this into overloaded operator(*) in BaseTime
  782. ESMF_TimeIntervalProdI%basetime%S = &
  783. timeinterval%basetime%S * INT( multiplier, ESMF_KIND_I8 )
  784. ESMF_TimeIntervalProdI%basetime%Sn = &
  785. timeinterval%basetime%Sn * INT( multiplier, ESMF_KIND_I8 )
  786. ! Don't multiply Sd
  787. ESMF_TimeIntervalProdI%basetime%Sd = timeinterval%basetime%Sd
  788. CALL normalize_timeint( ESMF_TimeIntervalProdI )
  789. end function ESMF_TimeIntervalProdI
  790. !------------------------------------------------------------------------------
  791. !
  792. ! This section includes the inherited ESMF_BaseTime class overloaded operators
  793. !
  794. !------------------------------------------------------------------------------
  795. !BOP
  796. ! !IROUTINE: ESMF_TimeIntervalSum - Add two time intervals together
  797. ! !INTERFACE:
  798. function ESMF_TimeIntervalSum(timeinterval1, timeinterval2)
  799. ! !RETURN VALUE:
  800. type(ESMF_TimeInterval) :: ESMF_TimeIntervalSum
  801. ! !ARGUMENTS:
  802. type(ESMF_TimeInterval), intent(in) :: timeinterval1
  803. type(ESMF_TimeInterval), intent(in) :: timeinterval2
  804. ! !LOCAL:
  805. integer :: rc
  806. ! !DESCRIPTION:
  807. ! Add two {\tt ESMF\_TimeIntervals}, return sum as a
  808. ! {\tt ESMF\_TimeInterval}. Maps overloaded (+) operator interface
  809. ! function to {\tt ESMF\_BaseTime} base class.
  810. !
  811. ! The arguments are:
  812. ! \begin{description}
  813. ! \item[timeinterval1]
  814. ! The augend
  815. ! \item[timeinterval2]
  816. ! The addend
  817. ! \end{description}
  818. !
  819. ! !REQUIREMENTS:
  820. ! TMG1.5.4, TMG2.4.4, TMG2.4.5, TMG2.4.6, TMG5.1, TMG5.2,
  821. ! TMG7.2
  822. !EOP
  823. CALL timeintchecknormalized( timeinterval1, 'ESMF_TimeIntervalSum arg1' )
  824. CALL timeintchecknormalized( timeinterval2, 'ESMF_TimeIntervalSum arg2' )
  825. ESMF_TimeIntervalSum = timeinterval1
  826. ESMF_TimeIntervalSum%basetime = ESMF_TimeIntervalSum%basetime + &
  827. timeinterval2%basetime
  828. CALL normalize_timeint( ESMF_TimeIntervalSum )
  829. end function ESMF_TimeIntervalSum
  830. !------------------------------------------------------------------------------
  831. !BOP
  832. ! !IROUTINE: ESMF_TimeIntervalDiff - Subtract one time interval from another
  833. ! !INTERFACE:
  834. function ESMF_TimeIntervalDiff(timeinterval1, timeinterval2)
  835. ! !RETURN VALUE:
  836. type(ESMF_TimeInterval) :: ESMF_TimeIntervalDiff
  837. ! !ARGUMENTS:
  838. type(ESMF_TimeInterval), intent(in) :: timeinterval1
  839. type(ESMF_TimeInterval), intent(in) :: timeinterval2
  840. ! !LOCAL:
  841. integer :: rc
  842. ! !DESCRIPTION:
  843. ! Subtract timeinterval2 from timeinterval1, return remainder as a
  844. ! {\tt ESMF\_TimeInterval}.
  845. ! Map overloaded (-) operator interface function to {\tt ESMF\_BaseTime}
  846. ! base class.
  847. !
  848. ! The arguments are:
  849. ! \begin{description}
  850. ! \item[timeinterval1]
  851. ! The minuend
  852. ! \item[timeinterval2]
  853. ! The subtrahend
  854. ! \end{description}
  855. !
  856. ! !REQUIREMENTS:
  857. ! TMG1.5.4, TMG2.4.4, TMG2.4.5, TMG2.4.6, TMG5.1, TMG5.2, TMG7.2
  858. !EOP
  859. CALL timeintchecknormalized( timeinterval1, 'ESMF_TimeIntervalDiff arg1' )
  860. CALL timeintchecknormalized( timeinterval2, 'ESMF_TimeIntervalDiff arg2' )
  861. ESMF_TimeIntervalDiff = timeinterval1
  862. ESMF_TimeIntervalDiff%basetime = ESMF_TimeIntervalDiff%basetime - &
  863. timeinterval2%basetime
  864. CALL normalize_timeint( ESMF_TimeIntervalDiff )
  865. end function ESMF_TimeIntervalDiff
  866. !------------------------------------------------------------------------------
  867. !BOP
  868. ! !IROUTINE: ESMF_TimeIntervalEQ - Compare two time intervals for equality
  869. ! !INTERFACE:
  870. function ESMF_TimeIntervalEQ(timeinterval1, timeinterval2)
  871. !
  872. ! !RETURN VALUE:
  873. logical :: ESMF_TimeIntervalEQ
  874. ! !ARGUMENTS:
  875. type(ESMF_TimeInterval), intent(in) :: timeinterval1
  876. type(ESMF_TimeInterval), intent(in) :: timeinterval2
  877. !DESCRIPTION:
  878. ! Return true if both given time intervals are equal, false otherwise.
  879. ! Maps overloaded (==) operator interface function to {\tt ESMF\_BaseTime}
  880. ! base class.
  881. !
  882. ! The arguments are:
  883. ! \begin{description}
  884. ! \item[timeinterval1]
  885. ! First time interval to compare
  886. ! \item[timeinterval2]
  887. ! Second time interval to compare
  888. ! \end{description}
  889. !
  890. ! !REQUIREMENTS:
  891. ! TMG1.5.3, TMG2.4.3, TMG7.2
  892. !EOP
  893. CALL timeintchecknormalized( timeinterval1, 'ESMF_TimeIntervalEQ arg1' )
  894. CALL timeintchecknormalized( timeinterval2, 'ESMF_TimeIntervalEQ arg2' )
  895. !$$$here... move all this out of Meat.F90 ?
  896. ! call ESMC_BaseTime base class function
  897. call c_ESMC_BaseTimeIntEQ(timeinterval1, timeinterval2, ESMF_TimeIntervalEQ)
  898. end function ESMF_TimeIntervalEQ
  899. !------------------------------------------------------------------------------
  900. !BOP
  901. ! !IROUTINE: ESMF_TimeIntervalNE - Compare two time intervals for inequality
  902. ! !INTERFACE:
  903. function ESMF_TimeIntervalNE(timeinterval1, timeinterval2)
  904. !
  905. ! !RETURN VALUE:
  906. logical :: ESMF_TimeIntervalNE
  907. ! !ARGUMENTS:
  908. type(ESMF_TimeInterval), intent(in) :: timeinterval1
  909. type(ESMF_TimeInterval), intent(in) :: timeinterval2
  910. ! !DESCRIPTION:
  911. ! Return true if both given time intervals are not equal, false otherwise.
  912. ! Maps overloaded (/=) operator interface function to {\tt ESMF\_BaseTime}
  913. ! base class.
  914. !
  915. ! The arguments are:
  916. ! \begin{description}
  917. ! \item[timeinterval1]
  918. ! First time interval to compare
  919. ! \item[timeinterval2]
  920. ! Second time interval to compare
  921. ! \end{description}
  922. !
  923. ! !REQUIREMENTS:
  924. ! TMG1.5.3, TMG2.4.3, TMG7.2
  925. !EOP
  926. CALL timeintchecknormalized( timeinterval1, 'ESMF_TimeIntervalNE arg1' )
  927. CALL timeintchecknormalized( timeinterval2, 'ESMF_TimeIntervalNE arg2' )
  928. ! call ESMC_BaseTime base class function
  929. call c_ESMC_BaseTimeIntNE(timeinterval1, timeinterval2, ESMF_TimeIntervalNE)
  930. end function ESMF_TimeIntervalNE
  931. !------------------------------------------------------------------------------
  932. !BOP
  933. ! !IROUTINE: ESMF_TimeIntervalLT - Time interval 1 less than time interval 2 ?
  934. ! !INTERFACE:
  935. function ESMF_TimeIntervalLT(timeinterval1, timeinterval2)
  936. !
  937. ! !RETURN VALUE:
  938. logical :: ESMF_TimeIntervalLT
  939. ! !ARGUMENTS:
  940. type(ESMF_TimeInterval), intent(in) :: timeinterval1
  941. type(ESMF_TimeInterval), intent(in) :: timeinterval2
  942. ! !DESCRIPTION:
  943. ! Return true if first time interval is less than second time interval,
  944. ! false otherwise. Maps overloaded (<) operator interface function to
  945. ! {\tt ESMF\_BaseTime} base class.
  946. !
  947. ! The arguments are:
  948. ! \begin{description}
  949. ! \item[timeinterval1]
  950. ! First time interval to compare
  951. ! \item[timeinterval2]
  952. ! Second time interval to compare
  953. ! \end{description}
  954. !
  955. ! !REQUIREMENTS:
  956. ! TMG1.5.3, TMG2.4.3, TMG7.2
  957. !EOP
  958. CALL timeintchecknormalized( timeinterval1, 'ESMF_TimeIntervalLT arg1' )
  959. CALL timeintchecknormalized( timeinterval2, 'ESMF_TimeIntervalLT arg2' )
  960. ! call ESMC_BaseTime base class function
  961. call c_ESMC_BaseTimeIntLT(timeinterval1, timeinterval2, ESMF_TimeIntervalLT)
  962. end function ESMF_TimeIntervalLT
  963. !------------------------------------------------------------------------------
  964. !BOP
  965. ! !IROUTINE: ESMF_TimeIntervalGT - Time interval 1 greater than time interval 2?
  966. ! !INTERFACE:
  967. function ESMF_TimeIntervalGT(timeinterval1, timeinterval2)
  968. !
  969. ! !RETURN VALUE:
  970. logical :: ESMF_TimeIntervalGT
  971. ! !ARGUMENTS:
  972. type(ESMF_TimeInterval), intent(in) :: timeinterval1
  973. type(ESMF_TimeInterval), intent(in) :: timeinterval2
  974. ! !DESCRIPTION:
  975. ! Return true if first time interval is greater than second time interval,
  976. ! false otherwise. Maps overloaded (>) operator interface function to
  977. ! {\tt ESMF\_BaseTime} base class.
  978. !
  979. ! The arguments are:
  980. ! \begin{description}
  981. ! \item[timeinterval1]
  982. ! First time interval to compare
  983. ! \item[timeinterval2]
  984. ! Second time interval to compare
  985. ! \end{description}
  986. !
  987. ! !REQUIREMENTS:
  988. ! TMG1.5.3, TMG2.4.3, TMG7.2
  989. !EOP
  990. CALL timeintchecknormalized( timeinterval1, 'ESMF_TimeIntervalGT arg1' )
  991. CALL timeintchecknormalized( timeinterval2, 'ESMF_TimeIntervalGT arg2' )
  992. ! call ESMC_BaseTime base class function
  993. call c_ESMC_BaseTimeIntGT(timeinterval1, timeinterval2, ESMF_TimeIntervalGT)
  994. end function ESMF_TimeIntervalGT
  995. !------------------------------------------------------------------------------
  996. !BOP
  997. ! !IROUTINE: ESMF_TimeIntervalLE - Time interval 1 less than or equal to time interval 2 ?
  998. ! !INTERFACE:
  999. function ESMF_TimeIntervalLE(timeinterval1, timeinterval2)
  1000. ! !RETURN VALUE:
  1001. logical :: ESMF_TimeIntervalLE
  1002. ! !ARGUMENTS:
  1003. type(ESMF_TimeInterval), intent(in) :: timeinterval1
  1004. type(ESMF_TimeInterval), intent(in) :: timeinterval2
  1005. ! !DESCRIPTION:
  1006. ! Return true if first time interval is less than or equal to second time
  1007. ! interval, false otherwise.
  1008. ! Maps overloaded (<=) operator interface function to {\tt ESMF\_BaseTime}
  1009. ! base class.
  1010. !
  1011. ! The arguments are:
  1012. ! \begin{description}
  1013. ! \item[timeinterval1]
  1014. ! First time interval to compare
  1015. ! \item[timeinterval2]
  1016. ! Second time interval to compare
  1017. ! \end{description}
  1018. !
  1019. ! !REQUIREMENTS:
  1020. ! TMG1.5.3, TMG2.4.3, TMG7.2
  1021. !EOP
  1022. CALL timeintchecknormalized( timeinterval1, 'ESMF_TimeIntervalLE arg1' )
  1023. CALL timeintchecknormalized( timeinterval2, 'ESMF_TimeIntervalLE arg2' )
  1024. ! call ESMC_BaseTime base class function
  1025. call c_ESMC_BaseTimeIntLE(timeinterval1, timeinterval2, ESMF_TimeIntervalLE)
  1026. end function ESMF_TimeIntervalLE
  1027. !------------------------------------------------------------------------------
  1028. !BOP
  1029. ! !IROUTINE: ESMF_TimeIntervalGE - Time interval 1 greater than or equal to time interval 2 ?
  1030. ! !INTERFACE:
  1031. function ESMF_TimeIntervalGE(timeinterval1, timeinterval2)
  1032. !
  1033. ! !RETURN VALUE:
  1034. logical :: ESMF_TimeIntervalGE
  1035. ! !ARGUMENTS:
  1036. type(ESMF_TimeInterval), intent(in) :: timeinterval1
  1037. type(ESMF_TimeInterval), intent(in) :: timeinterval2
  1038. ! !DESCRIPTION:
  1039. ! Return true if first time interval is greater than or equal to second
  1040. ! time interval, false otherwise. Maps overloaded (>=) operator interface
  1041. ! function to {\tt ESMF\_BaseTime} base class.
  1042. !
  1043. ! The arguments are:
  1044. ! \begin{description}
  1045. ! \item[timeinterval1]
  1046. ! First time interval to compare
  1047. ! \item[timeinterval2]
  1048. ! Second time interval to compare
  1049. ! \end{description}
  1050. !
  1051. ! !REQUIREMENTS:
  1052. ! TMG1.5.3, TMG2.4.3, TMG7.2
  1053. !EOP
  1054. CALL timeintchecknormalized( timeinterval1, 'ESMF_TimeIntervalGE arg1' )
  1055. CALL timeintchecknormalized( timeinterval2, 'ESMF_TimeIntervalGE arg2' )
  1056. ! call ESMC_BaseTime base class function
  1057. call c_ESMC_BaseTimeIntGE(timeinterval1, timeinterval2, ESMF_TimeIntervalGE)
  1058. end function ESMF_TimeIntervalGE
  1059. !------------------------------------------------------------------------------
  1060. !BOP
  1061. ! !IROUTINE: ESMF_TimeIntervalIsPositive - Time interval greater than zero?
  1062. ! !INTERFACE:
  1063. function ESMF_TimeIntervalIsPositive(timeinterval)
  1064. !
  1065. ! !RETURN VALUE:
  1066. logical :: ESMF_TimeIntervalIsPositive
  1067. ! !ARGUMENTS:
  1068. type(ESMF_TimeInterval), intent(in) :: timeinterval
  1069. ! !LOCALS:
  1070. type(ESMF_TimeInterval) :: zerotimeint
  1071. integer :: rcint
  1072. ! !DESCRIPTION:
  1073. ! Return true if time interval is greater than zero,
  1074. ! false otherwise.
  1075. !
  1076. ! The arguments are:
  1077. ! \begin{description}
  1078. ! \item[timeinterval]
  1079. ! Time interval to compare
  1080. ! \end{description}
  1081. !EOP
  1082. CALL timeintchecknormalized( timeinterval, &
  1083. 'ESMF_TimeIntervalIsPositive arg' )
  1084. CALL ESMF_TimeIntervalSet ( zerotimeint, rc=rcint )
  1085. IF ( rcint /= ESMF_SUCCESS ) THEN
  1086. CALL wrf_error_fatal( &
  1087. 'ESMF_TimeIntervalIsPositive: ESMF_TimeIntervalSet failed' )
  1088. ENDIF
  1089. ! hack for bug in PGI 5.1-x
  1090. ! ESMF_TimeIntervalIsPositive = timeinterval > zerotimeint
  1091. ESMF_TimeIntervalIsPositive = ESMF_TimeIntervalGT( timeinterval, &
  1092. zerotimeint )
  1093. end function ESMF_TimeIntervalIsPositive
  1094. end module ESMF_TimeIntervalMod