Back to home page

darwin3

 
 

    


File indexing completed on 2024-12-17 18:37:24 UTC

view on githubraw file Latest commit 87dd4f7d on 2024-01-17 18:17:24 UTC
87dd4f7d5f Oliv*0001 #include "OASIM_OPTIONS.h"
                0002 #ifdef ALLOW_EXF
                0003 #include "EXF_OPTIONS.h"
                0004 #endif
                0005 
                0006 CBOP
                0007 C     !ROUTINE: OASIM_GetMonthsRec
                0008 C     !INTERFACE:
                0009       SUBROUTINE OASIM_GetMonthsRec(
                0010      I                             fldStartTime, useFldYearlyFields,
                0011      I                             order,
                0012      O                             fac, first, changed,
                0013      O                             count0, count1, year0, year1,
                0014      I                             myTime, myIter, myThid )
                0015 
                0016 C     !DESCRIPTION: \bv
                0017 C     *==========================================================*
                0018 C     | SUBROUTINE OASIM_GetMonthsRec
                0019 C     | o Get flags, counters, and the linear interpolation
                0020 C     |   factor for a given field for the case of monthly,
                0021 C     |   interannual forcing
                0022 C     *==========================================================*
                0023 C     \ev
                0024 
                0025 C     !USES:
                0026       IMPLICIT NONE
                0027 C     == Global variables ==
                0028 #include "cal.h"
                0029 
                0030 C     !INPUT PARAMETERS:
                0031 C     fldStartTime       :: time in seconds of first fld record from the
                0032 C                           beginning of the model integration or, if
                0033 C                           usefldyearlyfields, from the beginning of year
                0034 C     useFldYearlyFields :: when set, use yearly forcing files
                0035 C     order              :: order for time interpolation (0 or 1)
                0036 C     myTime             :: current time in simulation
                0037 C     myIter             :: current iteration number in simulation
                0038 C     myThid             :: my thread identification number
                0039       _RL     fldStartTime
                0040       LOGICAL useFldYearlyFields
                0041       INTEGER order
                0042       _RL     myTime
                0043       INTEGER myIter
                0044       INTEGER myThid
                0045 
                0046 C     !OUTPUT PARAMETERS:
                0047 C     fac     :: weight of record count0 for linear interpolation purposes
                0048 C     first   :: model initialization flag: read two forcing records
                0049 C     changed :: flag indicating that a new forcing record must be read
                0050 C     count0  :: record number for forcing field preceding myTime
                0051 C     count1  :: record number for forcing field following myTime
                0052 C     year0   :: year of forcing file for record preceding myTime
                0053 C     year1   :: year of forcing file for record following myTime
                0054       _RL     fac
                0055       LOGICAL first, changed
                0056       INTEGER count0, count1, year0, year1
                0057 
                0058 #ifdef ALLOW_EXF
                0059 #ifdef ALLOW_CAL
                0060 C     !LOCAL VARIABLES:
                0061       INTEGER startDate(4)
                0062       INTEGER yy, mm, dd, ss, lp, wd
                0063       integer modelsteptime(4)
                0064       integer currentdate(4)
                0065       integer prevdate(4)
                0066       integer prevcount
                0067 CEOP
                0068 
                0069       IF (order .EQ. 0) THEN
                0070 
                0071 c--    Set switches for reading new records.
                0072        first = ((mytime - modelstart) .lt. 0.5*modelstep)
                0073 
                0074        CALL cal_TimeInterval( -modelstep, 'secs', modelsteptime,
                0075      &                        mythid )
                0076 
                0077 c      Determine the current date and the current month.
                0078        call cal_GetDate( myiter, mytime, currentdate, mythid )
                0079        call cal_AddTime( currentdate, modelsteptime, prevdate, mythid )
                0080 
                0081        year0 = currentdate(1)/10000
                0082        count0 = mod(currentdate(1)/100,100)
                0083 
                0084        year1 = year0
                0085        count1 = count0
                0086 C      use only year1, count1
                0087        fac = 0 _d 0
                0088        prevcount = mod(prevdate(1)/100,100)
                0089 c      only check month, not year, as it will always change
                0090        IF ( (.NOT. first) .AND. (prevcount .NE. count0) ) THEN
                0091          changed = .TRUE.
                0092        ELSE
                0093          changed = .FALSE.
                0094        ENDIF
                0095 
                0096       ELSE
                0097 
                0098        CALL cal_GetMonthsRec(
                0099      O                        fac, first, changed,
                0100      O                        count0, count1, year0, year1,
                0101      I                        myTime, myIter, myThid )
                0102 
                0103       ENDIF
                0104 
                0105       IF (.NOT.useFldYearlyFields) THEN
                0106         CALL CAL_GETDATE( 0, fldStartTime, startDate, myThid )
                0107         CALL CAL_CONVDATE( startDate, yy, mm, dd, ss, lp, wd, myThid )
                0108         count0 = (year0-yy)*12 + count0 - mm + 1
                0109         count1 = (year1-yy)*12 + count1 - mm + 1
                0110         year0 = 0
                0111         year1 = 0
                0112       ENDIF
                0113 
                0114 #endif /* ALLOW_CAL */
                0115 #endif /* ALLOW_EXF */
                0116 
                0117       RETURN
                0118       END