Nodes of different colours represent the following:
Solid arrows point from a parent (sub)module to the submodule which is descended from it. Dashed arrows point from a module being used to the module or program unit using it. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
SUBROUTINE SetupEnvironmentTypes
! SUBROUTINE INFORMATION:
! AUTHOR Linda Lawrie
! DATE WRITTEN October 2010
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! Make sure Environment derived type is set prior to getting
! Weather Properties
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
USE General, ONLY: InvJulianDay, JulianDay, BetweenDates
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
! na
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: Loop
INTEGER :: Loop1
INTEGER :: JDay1
INTEGER :: JDay2
INTEGER :: LocalLeapYearAdd
! Transfer weather file information to the Environment derived type
Envrn=TotDesDays+1
! Sizing Periods from Weather File
DO Loop=1,TotRunDesPers
Environment(Envrn)%StartMonth=RunPeriodDesignInput(Loop)%StartMonth
Environment(Envrn)%StartDay=RunPeriodDesignInput(Loop)%StartDay
Environment(Envrn)%StartJDay=JulianDay(RunPeriodDesignInput(Loop)%StartMonth, &
RunPeriodDesignInput(Loop)%StartDay,LeapYearAdd)
Environment(Envrn)%TotalDays=RunPeriodDesignInput(Loop)%TotalDays
Environment(Envrn)%EndMonth=RunPeriodDesignInput(Loop)%EndMonth
Environment(Envrn)%EndDay=RunPeriodDesignInput(Loop)%EndDay
Environment(Envrn)%EndJDay=JulianDay(RunPeriodDesignInput(Loop)%EndMonth, &
RunPeriodDesignInput(Loop)%EndDay,LeapYearAdd)
Environment(Envrn)%NumSimYears=RunPeriodDesignInput(Loop)%NumSimYears
IF (Environment(Envrn)%StartJDay <= Environment(Envrn)%EndJDay) THEN
Environment(Envrn)%TotalDays=(Environment(Envrn)%EndJDay-Environment(Envrn)%StartJDay+1) &
* Environment(Envrn)%NumSimYears
ELSE
Environment(Envrn)%TotalDays=(JulianDay(12,31,LeapYearAdd) &
-Environment(Envrn)%StartJDay+1+Environment(Envrn)%EndJDay) * Environment(Envrn)%NumSimYears
ENDIF
TotRunDesPersDays=TotRunDesPersDays+Environment(Envrn)%TotalDays
Environment(Envrn)%UseDST=RunPeriodDesignInput(Loop)%UseDST
Environment(Envrn)%UseHolidays=RunPeriodDesignInput(Loop)%UseHolidays
Environment(Envrn)%Title=RunPeriodDesignInput(Loop)%Title
Environment(Envrn)%cKindOfEnvrn = RunPeriodDesignInput(Loop)%PeriodType
Environment(Envrn)%KindOfEnvrn = ksRunPeriodDesign
Environment(Envrn)%DayOfWeek=RunPeriodDesignInput(Loop)%DayOfWeek
Environment(Envrn)%MonWeekDay=RunPeriodDesignInput(Loop)%MonWeekDay
Environment(Envrn)%SetWeekDays=.false.
Environment(Envrn)%ApplyWeekendRule=RunPeriodDesignInput(Loop)%ApplyWeekendRule
Environment(Envrn)%UseRain=RunPeriodDesignInput(Loop)%UseRain
Environment(Envrn)%UseSnow=RunPeriodDesignInput(Loop)%UseSnow
Envrn=Envrn+1
ENDDO
! RunPeriods from weather file
DO Loop=1,TotRunPers ! Run Periods.
Environment(Envrn)%StartMonth=RunPeriodInput(Loop)%StartMonth
Environment(Envrn)%StartDay=RunPeriodInput(Loop)%StartDay
Environment(Envrn)%EndMonth=RunPeriodInput(Loop)%EndMonth
Environment(Envrn)%EndDay=RunPeriodInput(Loop)%EndDay
Environment(Envrn)%NumSimYears=RunPeriodInput(Loop)%NumSimYears
IF (RunPeriodInput(Loop)%ActualWeather) THEN
Environment(Envrn)%CurrentYear=RunPeriodInput(Loop)%StartYear
Environment(Envrn)%IsLeapYear=IsLeapYear(RunPeriodInput(Loop)%StartYear)
Environment(Envrn)%TreatYearsAsConsecutive=.true.
Environment(Envrn)%StartYear=RunPeriodInput(Loop)%StartYear
Environment(Envrn)%EndYear=RunPeriodInput(Loop)%EndYear
CALL jgDate(GregorianToJulian,Environment(Envrn)%StartDate, &
Environment(Envrn)%StartYear,Environment(Envrn)%StartMonth,Environment(Envrn)%StartDay)
CALL jgDate(GregorianToJulian,Environment(Envrn)%EndDate, &
Environment(Envrn)%EndYear,Environment(Envrn)%EndMonth,Environment(Envrn)%EndDay)
Environment(Envrn)%StartJDay=Environment(Envrn)%StartDate
Environment(Envrn)%EndJDay=Environment(Envrn)%EndDate
Environment(Envrn)%TotalDays=Environment(Envrn)%EndDate-Environment(Envrn)%StartDate + 1
Environment(Envrn)%RawSimDays=Environment(Envrn)%EndDate-Environment(Envrn)%StartDate + 1
Environment(Envrn)%MatchYear=.true.
Environment(Envrn)%ActualWeather=.true.
ELSEIF (RunPeriodInput(Loop)%BeginYear < 100) THEN ! std RunPeriod
Environment(Envrn)%CurrentYear=0
IF (.not. WFAllowsLeapYears) THEN
Environment(Envrn)%IsLeapYear=.false. ! explicit set
LocalLeapYearAdd=0
ELSE
Environment(Envrn)%IsLeapYear=.true. ! explicit set
LocalLeapYearAdd=1
ENDIF
Environment(Envrn)%TreatYearsAsConsecutive=.false.
Environment(Envrn)%RollDayTypeOnRepeat=RunPeriodInput(Loop)%RollDayTypeOnRepeat
Environment(Envrn)%StartJDay=JulianDay(RunPeriodInput(Loop)%StartMonth,RunPeriodInput(Loop)%StartDay,LocalLeapYearAdd)
Environment(Envrn)%EndJDay=JulianDay(RunPeriodInput(Loop)%EndMonth,RunPeriodInput(Loop)%EndDay,LocalLeapYearAdd)
! need message if isleapyear and wfleapyearind=0
IF (Environment(Envrn)%StartJDay <= Environment(Envrn)%EndJDay) THEN
Environment(Envrn)%RawSimDays=(Environment(Envrn)%EndJDay-Environment(Envrn)%StartJDay+1)
Environment(Envrn)%TotalDays=(Environment(Envrn)%EndJDay-Environment(Envrn)%StartJDay+1) &
* Environment(Envrn)%NumSimYears
ELSE
Environment(Envrn)%RawSimDays=(JulianDay(12,31,LeapYearAdd)-Environment(Envrn)%StartJDay+1+ &
Environment(Envrn)%EndJDay)
Environment(Envrn)%TotalDays=(JulianDay(12,31,LeapYearAdd)-Environment(Envrn)%StartJDay+1+ &
Environment(Envrn)%EndJDay) &
* Environment(Envrn)%NumSimYears
ENDIF
ELSE ! Using Runperiod and StartYear option.
Environment(Envrn)%CurrentYear=RunPeriodInput(Loop)%BeginYear
Environment(Envrn)%IsLeapYear=IsLeapYear(Environment(Envrn)%CurrentYear)
Environment(Envrn)%TreatYearsAsConsecutive=.true.
Environment(Envrn)%RollDayTypeOnRepeat=RunPeriodInput(Loop)%RollDayTypeOnRepeat
Environment(Envrn)%StartJDay=JulianDay(RunPeriodInput(Loop)%StartMonth,RunPeriodInput(Loop)%StartDay,LeapYearAdd)
Environment(Envrn)%EndJDay=JulianDay(RunPeriodInput(Loop)%EndMonth,RunPeriodInput(Loop)%EndDay,LeapYearAdd)
Environment(Envrn)%TotalDays=0
DO Loop1=1,Environment(Envrn)%NumSimYears
IF (.not. IsLeapYear(RunPeriodInput(Loop)%BeginYear-1+Loop1) .or. .not. WFAllowsLeapYears) THEN
JDay1=JulianDay(RunPeriodInput(Loop)%StartMonth,RunPeriodInput(Loop)%StartDay,0)
JDay2=JulianDay(RunPeriodInput(Loop)%EndMonth,RunPeriodInput(Loop)%EndDay,0)
IF (JDay1 <= JDay2) THEN
IF (Loop1 == 1) &
Environment(Envrn)%RawSimDays=(JDay2-Jday1+1)
Environment(Envrn)%TotalDays=Environment(Envrn)%TotalDays+(JDay2-Jday1+1)
ELSE
IF (Loop1 == 1) &
Environment(Envrn)%RawSimDays=JulianDay(12,31,0)-JDay1+1+JDay2
Environment(Envrn)%TotalDays=Environment(Envrn)%TotalDays+ &
JulianDay(12,31,0)-JDay1+1+JDay2
ENDIF
ELSE ! Leap Year
JDay1=JulianDay(RunPeriodInput(Loop)%StartMonth,RunPeriodInput(Loop)%StartDay,1)
JDay2=JulianDay(RunPeriodInput(Loop)%EndMonth,RunPeriodInput(Loop)%EndDay,1)
IF (JDay1 <= JDay2) THEN
Environment(Envrn)%TotalDays=Environment(Envrn)%TotalDays+(JDay2-Jday1+1)
ELSE
Environment(Envrn)%TotalDays=Environment(Envrn)%TotalDays+ &
JulianDay(12,31,1)-JDay1+1+JDay2
ENDIF
ENDIF
ENDDO
ENDIF
Environment(Envrn)%UseDST=RunPeriodInput(Loop)%UseDST
Environment(Envrn)%UseHolidays=RunPeriodInput(Loop)%UseHolidays
IF (RunPeriodInput(Loop)%Title == Blank) THEN
Environment(Envrn)%Title=WeatherFileLocationTitle
ELSE
Environment(Envrn)%Title=RunPeriodInput(Loop)%Title
ENDIF
Environment(Envrn)%cKindOfEnvrn = 'WeatherFileRunPeriod'
Environment(Envrn)%KindOfEnvrn = ksRunPeriodWeather
Environment(Envrn)%DayOfWeek=RunPeriodInput(Loop)%DayOfWeek
Environment(Envrn)%MonWeekDay=RunPeriodInput(Loop)%MonWeekDay
Environment(Envrn)%SetWeekDays=.false.
Environment(Envrn)%ApplyWeekendRule=RunPeriodInput(Loop)%ApplyWeekendRule
Environment(Envrn)%UseRain=RunPeriodInput(Loop)%UseRain
Environment(Envrn)%UseSnow=RunPeriodInput(Loop)%UseSnow
Envrn=Envrn+1
ENDDO
RETURN
END SUBROUTINE SetupEnvironmentTypes