?? mfm_timemgrex.f
字號(hào):
!\begin{verbatim}!===============================================================================! MFM_TimeMgr F90 Unit Tests and Examples!=============================================================================== program main use MFM_TimeMgmt implicit none integer, parameter :: START_DATE=20011128, START_SECS=43200 integer, parameter :: STOP_DATE=20011203, STOP_SECS=1200 integer, parameter :: STEP_DAYS=1, STEP_SECS=43200 integer, parameter :: NUM_ITS=3 type(MFM_Time) :: stepSize type(MFM_TimeMgr) :: timeMgrNoBase type(MFM_TimeMgr) :: timeMgrNoBase_Reconstruct type(MFM_Date) :: startDate, stopDate, currDate, prevDate type(MFM_Date) :: baseDate logical test, isLast integer i, nsteps integer retCalDate, retDays, retSecs character(60) str integer calType integer nstep integer stepDays, stepSec integer startYYMMDD, startSec integer stopYYMMDD, stopSec integer baseYYMMDD, baseSec integer currYYMMDD, currSec integer calType1 integer nstep1 integer stepDays1, stepSec1 integer startYYMMDD1, startSec1 integer stopYYMMDD1, stopSec1 integer baseYYMMDD1, baseSec1 integer currYYMMDD1, currSec1 print *, "==================================================" print *, "MFM_TimeMgr F90 Unit Tests and Examples" print *, "==================================================" stepSize = MFM_TimeInit(STEP_DAYS, STEP_SECS) startDate = MFM_DateInit(MFM_GREGORIAN, START_DATE, START_SECS) stopDate = MFM_DateInit(MFM_GREGORIAN, STOP_DATE, STOP_SECS) timeMgrNoBase = MFM_TimeMgrInit(stepSize, startDate, stopDate) do while (.NOT. MFM_TimeMgrLastStep(timeMgrNoBase)) call MFM_TimeMgrAdvance(timeMgrNoBase) end do currDate = MFM_TimeMgrGetCurrDate(timeMgrNoBase) call MFM_DateGet(currDate, retCalDate, retSecs) print *, "Ret date ", retCalDate, " Ret secs ", retSecs test = ((retCalDate==20011203) .AND. (retSecs==0)) str = "MFM_TimeMgrGetCurrDate: get current date" call MFM_ErrorTest(test, str) prevDate = MFM_TimeMgrGetPrevDate(timeMgrNoBase) call MFM_DateGet(prevDate, retCalDate, retSecs) print *, "Ret date ", retCalDate, " Ret secs ", retSecs test = ((retCalDate==20011201) .AND. (retSecs==43200)) str = "MFM_TimeMgrGetPrevDate: get previous date" call MFM_ErrorTest(test, str) startDate = MFM_TimeMgrGetStartDate(timeMgrNoBase) call MFM_DateGet(startDate, retCalDate, retSecs) print *, "Ret date ", retCalDate, " Ret secs ", retSecs test = ((retCalDate==START_DATE) .AND. (retSecs==START_SECS)) str = "MFM_TimeMgrGetStartDate: get starting date" call MFM_ErrorTest(test, str) stopDate = MFM_TimeMgrGetStopDate(timeMgrNoBase) call MFM_DateGet(stopDate, retCalDate, retSecs) print *, "Ret date ", retCalDate, " Ret secs ", retSecs test = ((retCalDate==STOP_DATE) .AND. (retSecs==STOP_SECS)) str = "MFM_TimeMgrGetStopDate: get stop date" call MFM_ErrorTest(test, str) baseDate = MFM_TimeMgrGetBaseDate(timeMgrNoBase) call MFM_DateGet(baseDate, retCalDate, retSecs) print *, "Ret date ", retCalDate, " Ret secs ", retSecs test = ((retCalDate==START_DATE) .AND. (retSecs==START_SECS)) str = "MFM_TimeMgrGetBaseDate: get base date" call MFM_ErrorTest(test, str) nsteps = MFM_TimeMgrGetNStep(timeMgrNoBase) print *, "Ret nsteps", nsteps test = (nsteps == 3) str = "MFM_TimeMgrGetNStep: get number of timesteps" call MFM_ErrorTest(test, str) call MFM_TimeMgrSetStepSize(timeMgrNoBase, 4, 3200) call MFM_TimeMgrGetStepSize(timeMgrNoBase, retDays, retSecs) print *, "Ret days ", retDays, " Ret secs ", retSecs test = ((retDays==4) .AND. (retSecs==3200)) str = "MFM_TimeMgrGetStepSize, MFM_TimeMgrSetStepSize: test" call MFM_ErrorTest(test, str) call MFM_TimeMgrSetCurrDate(timeMgrNoBase, START_DATE, START_SECS) call MFM_TimeMgrAdvance(timeMgrNoBase) prevDate = MFM_TimeMgrGetPrevDate(timeMgrNoBase) call MFM_DateGet(prevDate, retCalDate, retSecs) print *, "Ret date ", retCalDate, " Ret secs ", retSecs test = ((retCalDate==START_DATE) .AND. (retSecs==START_SECS)) str = "MFM_TimeMgrSetCurrDate: set curr date" call MFM_ErrorTest(test, str) call MFM_TimeMgrRestartWriteIs(timeMgrNoBase, & calType, & nstep, & stepDays, stepSec, & startYYMMDD, startSec, & stopYYMMDD, stopSec, & baseYYMMDD, baseSec, & currYYMMDD, currSec) print *, "Original TimeMgr:" print *, "CalType ", calType print *, "nstep = ", nstep print *, "stepDays ", stepDays, "stepSec", stepSec print *, "startYYMMDD ", startYYMMDD, "startSec", startSec print *, "stopYYMMDD ", stopYYMMDD, "stopSec", stopSec print *, "baseYYMMDD ", baseYYMMDD, "baseSec", baseSec print *, "currYYMMDD ", currYYMMDD, "currSec", currSec timeMgrNoBase_Reconstruct = & MFM_TimeMgrRestartReadIs( & calType, & nstep, & stepDays, stepSec, & startYYMMDD, startSec, & stopYYMMDD, stopSec, & baseYYMMDD, baseSec, & currYYMMDD, currSec) call MFM_TimeMgrRestartWriteIs(timeMgrNoBase_Reconstruct, & calType1, & nstep1, & stepDays1, stepSec1, & startYYMMDD1, startSec1, & stopYYMMDD1, stopSec1, & baseYYMMDD1, baseSec1, & currYYMMDD1, currSec1) print *, "Reconstructed TimeMgr:" print *, "CalType ", calType1 print *, "nstep = ", nstep1 print *, "stepDays ", stepDays1, "stepSec", stepSec1 print *, "startYYMMDD ", startYYMMDD1, "startSec", startSec1 print *, "stopYYMMDD ", stopYYMMDD1, "stopSec", stopSec1 print *, "baseYYMMDD ", baseYYMMDD1, "baseSec", baseSec1 print *, "currYYMMDD ", currYYMMDD1, "currSec", currSec1 test = (calType==calType1 ) & .and. (nstep==nstep1) & .and. (stepDays==stepDays1) .and. (stepSec==stepSec1) & .and. (startYYMMDD==startYYMMDD1) .and. (startSec==startSec1) & .and. (stopYYMMDD==stopYYMMDD1) .and. (stopSec==stopSec1) & .and. (baseYYMMDD==baseYYMMDD1) .and. (baseSec==baseSec1) & .and. (currYYMMDD==currYYMMDD1) .and. (currSec==currSec1) str = "MFM_TimeMgrRestartWrite, MFM_TimeMgrRestartRead: test" call MFM_ErrorTest(test, str) end program main !\end{verbatim}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -