You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

CodeComments
    program compute week
implicit none
c compute: norms curr_week_diffs and MIR

c compute 30-yr (1981-2010) daily weather normal data from each Illinois CD

c for analysis year and previous year compute based on CDC EPI week
c in 2016 and 2017, begin day use = saturday to friday
c in 2018, change to sunday to Saturday

c CDC defines ending saturday: The first epi week of the year ends,
c by definition, on the first Saturday of January,
c as long as it falls at least four days into the month.
c Each epi week begins on a Sunday and ends on a Saturday.

c get daily data for analysis year.
c compute weekly normals and weekly current year observations.
c compute weekly difference between analysis year and normals.
c weekly temp avg ( C);
c weekly precip tot (cm);
c weekly degree day avg based on 22 C. (accumate over time from Jan 1 to dec 31)

c first saturday set up through 2020.
c 2017, change to first sunday
c VET-MED first epi week ends on first saturday of january, unless falls after
c January 3, then ends in corresponding december day.

c as per Karki:
c begin jan 1 all years and go thru 365 days.
c weeks: 49-52,1-9 = WInter
c 10-22 = SPring (CDC spring ends week 22)
c 23-35 = SUmmer
c 36-48 = FAll

c bflg=0
c bflg=1

character*1 c
character*2 ST,CD,cstate
character*4 ayear

integer icd, iyear, year,mon,day, i,j,k,m,bflg
integer mm(366),dd(366)
integer icdi
real t(366,30),p(366,30),d(366,30),dum_d,dsum_d
real wt(53,30),wp(53,30),wd(53,30)

real tmax,tmin,tmean,prcp
real wknorm_t(53),wknorm_p(53),wknorm_d(53),wknorm_np(53)
real wksum_t(53),wksum_p(53),wksum_d,wksum_np(53)

real tmn(366),ppt(366),ddd(366)

real wctmn(53),wcppt(53),wcddd(53),wcsum_d
real df_wkt(53),df_wkp(53),df_wkd(53),df_wknp(53)

c integer begday(40),begmon(40)
integer begyr(40),ndays(40)
integer nbegday(40),nbegyr(40),nbegmon(40)
integer bday,bmon,nday,byear,n,end,endk

real WInorm_t,SPnorm_t,SUnorm_t,FAnorm_t
real WIsum_t, SPsum_t, SUsum_t, FAsum_t
real WInorm_d,SPnorm_d,SUnorm_d,FAnorm_d
real WIsum_d, SPsum_d, SUsum_d, FAsum_d

real WInorm_p,SPnorm_p,SUnorm_p,FAnorm_p
real WIsum_p, SPsum_p, SUsum_p, FAsum_p

real WInorm_np,SPnorm_np,SUnorm_np,FAnorm_np
real WIsum_np, SPsum_np, SUsum_np, FAsum_np

real SP_prev_yr_t, SP_prev_yr_d, SP_prev_yr_p, SP_prev_yr_np
real SU_prev_yr_t, SU_prev_yr_d, SU_prev_yr_p, SU_prev_yr_np
real FA_prev_yr_t, FA_prev_yr_d, FA_prev_yr_p, FA_prev_yr_np

real SP_prev_sum_t, SP_prev_sum_d, SP_prev_sum_p, SP_prev_sum_np
real SU_prev_sum_t, SU_prev_sum_d, SU_prev_sum_p, SU_prev_sum_np
real FA_prev_sum_t, FA_prev_sum_d, FA_prev_sum_p, FA_prev_sum_np

real WI_curr_yr_t, WI_curr_yr_d, WI_curr_yr_p, WI_curr_yr_np
real SP_curr_yr_t, SP_curr_yr_d, SP_curr_yr_p, SP_curr_yr_np

real WI_curr_sum_t, WI_curr_sum_d, WI_curr_sum_p, WI_curr_sum_np
real SP_curr_sum_t, SP_curr_sum_d, SP_curr_sum_p, SP_curr_sum_np

real df_WIc_t,df_WIc_p,df_WIc_d, df_WIc_np
real df_SPc_t,df_SPc_p,df_SPc_d, df_SPc_np
real df_SPp_t,df_SPp_p,df_SPp_d, df_SPp_np
real df_SUp_t,df_SUp_p,df_SUp_d, df_SUp_np
real df_FAp_t,df_FAp_p,df_FAp_d, df_FAp_np

character *86 line1
integer wk(53),cumwk(53)
real cd_dylt(53,9),cd_avg_mir(53,13),cd_2012mir(53,13)

real dum1,dum2,dum3,dum4,dum5,dum6,dum7
real mir(53),daylit(53),mir_cur(53)
real mir2012(53,13)
real ACT_mir(52,9),ACTm_mir(52,9),ACTp_mir(52,9)
real cd_act_mir(53,13)

real intercept(13)
real cDW_Lg1(13), cDW_Lg2(13), cDW_Lg3(13), cDW_Lg4(13)
real cPr_Lg1(13), cPr_Lg2(13), cPr_Lg3(13), cPr_Lg4(13)
real cDWLg1xPLg1(13), cDWLg1xPLg2(13)
real cDWLg1xPLg3(13), cDWLg1xPLg4(13)
real cDWLg2xPLg1(13), cDWLg2xPLg2(13)
real cDWLg2xPLg3(13), cDWLg2xPLg4(13)
real cDWLg3xPLg1(13), cDWLg3xPLg2(13)
real cDWLg3xPLg3(13), cDWLg3xPLg4(13)
real cDWLg4xPLg1(13), cDWLg4xPLg2(13)
real cDWLg4xPLg3(13), cDWLg4xPLg4(13)
real cSPc_temp(13), CSPc_prcp(13)
real cWIc_temp(13),cSPp_temp(13),cSUp_temp(13),cFAp_temp(13)
real cWIc_prcp(13),cSPp_prcp(13),cSUp_prcp(13),cFAp_prcp(13)
real cDayLite(13),cDWLg1xDayLite_Lg1(13)
real cDayLite_Lg1(13),cDayLite_Lg2(13)
real cDayLite_Lg3(13),cDayLite_Lg4(13)

integer ilcd,rundate
character*10 valdate
character*6 cprcp6
character*5 lab1
character*20 lab(40)
real prcpd(10,9),mxtemp(10,9),mntemp(11,9),prcp6(13,9)
integer n_mxT,n_mnT,n_ppt
integer ncurr
integer firstmon,firstday
character*2 cfirstmon,cfirstday

integer pday(53),pmon(53),pdd(366),pmm(366)
character*2 cpdd,cpmm
integer nwk(53)
integer pm,pd
integer wmonth(52),wday(52),wweek(52),wyear
character*10 wdate
character*3 wdow
integer emon,eday

c used to comply with epi week beginning in December
c for previous year (iyear-1) and analysis year (iyear)
c for 2016 and 2017
data nbegday/3,2,1,31,29,28,3,2,31,30,
! 29,28,2,1,31,30,29,3,2,1,
! 30,29,28,3,1,31,30,29,3,2,
! 1,31,29,28,3,2,31,30,29,28/
data nbegmon/1,1,1,12,12,12,1,1,12,12,
! 12,12,1,1,12,12,12,1,1,1,
! 12,12,12,1,1,12,12,12,1,1,
! 1,12,12,12,1,1,12,12,12,12/
data nbegyr/1981,1982,1983,1983,1984,1985,1987,1988,1988,1989,
! 1990,1991,1993,1994,1994,1995,1996,1998,1999,2000,
! 2000,2001,2002,2004,2005,2005,2006,2007,2009,2010,
! 2011,2011,2012,2013,2015,2016,2016,2017,2018,2019/


c for 2018
c defining years, months, days, epi weeks for previous year and analysis years
c data nbegday/4,3,2,1,30,29,4,3,1,31,
c ! 30,29,3,2,1,31,30,4,3,2,
c ! 31,30,29,4,2,1,31,30,4,3,
c ! 2,1,30,29,4,3,1,31,30,29/
c data nbegmon/1,1,1,1,12,12,1,1,1,12,
c ! 12,12,1,1,1,12,12,1,1,1,
c ! 12,12,12,1,1,1,12,12,1,1,
c ! 1,1,12,12,1,1,1,12,12,12/
c data nbegyr/1981,1982,1983,1984,1984,1985,1987,1988,1989,1989,
c ! 1990,1991,1993,1994,1995,1995,1996,1998,1999,2000,
c ! 2000,2001,2002,2004,2005,2006,2006,2007,2009,2010,
c ! 2011,2012,2012,2013,2015,2016,2017,2017,2018,2019/

c USE REGARDLESS
data begyr/1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,
! 1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,
! 2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,
! 2011,2012,2013,2014,2015,2016,2017,2018,2019,2020/
data ndays/365,365,365,366,365,365,365,366,365,365,
! 365,366,365,365,365,366,365,365,365,366,
! 365,365,365,366,365,365,365,366,365,365,
! 365,366,365,365,365,366,365,365,365,366/
call getarg (1,ST)
call getarg (1,ST)
call getarg (2,CD)
call getarg (3,ayear)

c read from character to integer
read(ayear,25) iyear
25 format(i4)
read(CD,26) icd
26 format(i2)
c print *, 'CD = ',icd,' ST = ',ST,'iyear= ',iyear

c=','

do j=1,30
do i=1,366
t(i,j) = 999.9
d(i,j) = 0.0
p(i,j) = 999.9
enddo
enddo
  • Initialize
c input for days of week for current year
open(unit=2,file='week_days_2016.csv',status='old',
! form='formatted')
read (2,*) line1
do i=1,52
read (2,*) wmonth(i),wday(i),wweek(i),wyear,wdate,wdow
enddo
close(2)
cMONTH,DAY,WEEK,YEAR,DATE,DOW
c1,2,1,2016,1/2/2016,SAT
  • Read in CDC Week
    • can this be generalized?
c input for normals (1981-2010 daily)
open(unit=3,file=ST//CD//'w_'//ayear,
! status='unknown',form='formatted')

  • No labels