# Makefile for strm.{year}
#
# 2004/03/12 D. Tsukahara 
.SUFFIXES : .ps  .nc
.nc.ps:
	$(COMMAND_MEAN) $<
	pstopnm dcl.ps;\
	ppmtogif dcl001.ppm >  dcl.gif;\
	gifsicle --rotate-90 dcl.gif > $@.gif;\
	mv dcl.ps $@
	$(COMMAND_PS2PNG)
	rm dcl.gif dcl001.ppm
COMMAND_MEAN = ruby ../../bin/rgtview.rb  --itr 1 --file
COMMAND_MKNC = ruby ../../bin/gtstrm.rb
COMMAND_PS2PNG = ruby ../../util/ps2png.rb $@
PS_ANNUAL_MEAN   = STRM_{year}-ANN_NCEP.ps
PS_SEASONAL_MEAN = STRM_{year}-MAM_NCEP.ps STRM_{year}-JJA_NCEP.ps STRM_{year}-DJF_NCEP.ps STRM_{year}-SON_NCEP.ps
PS_MONTHLY_MEAN  = STRM_{year}-01_NCEP.ps STRM_{year}-02_NCEP.ps STRM_{year}-03_NCEP.ps STRM_{year}-04_NCEP.ps  \
                       STRM_{year}-05_NCEP.ps STRM_{year}-06_NCEP.ps STRM_{year}-07_NCEP.ps STRM_{year}-08_NCEP.ps  \
                       STRM_{year}-09_NCEP.ps STRM_{year}-10_NCEP.ps STRM_{year}-11_NCEP.ps STRM_{year}-12_NCEP.ps
#############################
all: ncall fig
distclean: clean ncclean
fig: monthly seasonal annualy renameps
annualy: $(PS_ANNUAL_MEAN)
monthly: $(PS_MONTHLY_MEAN)
seasonal: $(PS_SEASONAL_MEAN)
renameps:
	ruby ../../util/rename2.rb -f .ps "" ./*.gif
STRM_{year}-ANN_NCEP.ps: 
	$(COMMAND_MEAN) --title "STRM_{year}-ANN_NCEP" \
	                STRM_{year}-01_NCEP.nc STRM_{year}-02_NCEP.nc STRM_{year}-03_NCEP.nc STRM_{year}-04_NCEP.nc  \
	                STRM_{year}-05_NCEP.nc STRM_{year}-06_NCEP.nc STRM_{year}-07_NCEP.nc STRM_{year}-08_NCEP.nc  \
                        STRM_{year}-09_NCEP.nc STRM_{year}-10_NCEP.nc STRM_{year}-11_NCEP.nc STRM_{year}-12_NCEP.nc ;\
	pstopnm dcl.ps;\
	ppmtogif dcl001.ppm >  dcl.gif;\
	gifsicle --rotate-90 dcl.gif > $@.gif;\
	mv dcl.ps $@;\
	$(COMMAND_PS2PNG);\
	rm dcl.gif dcl001.ppm
STRM_{year}-DJF_NCEP.ps: 
	$(COMMAND_MEAN) --title "STRM_{year}-DJF_NCEP" STRM_{year}-01_NCEP.nc STRM_{year}-02_NCEP.nc ../STRM.{year-1}.NCEP/STRM_{year-1}-12_NCEP.nc;\
	pstopnm dcl.ps;\
	ppmtogif dcl001.ppm >  dcl.gif;\
	gifsicle --rotate-90 dcl.gif > $@.gif;\
	mv dcl.ps $@;\
	$(COMMAND_PS2PNG);\
	rm dcl.gif dcl001.ppm
STRM_{year}-MAM_NCEP.ps: 
	$(COMMAND_MEAN) --title "STRM_{year}-MAM_NCEP" STRM_{year}-04_NCEP.nc STRM_{year}-05_NCEP.nc STRM_{year}-03_NCEP.nc;\
	pstopnm dcl.ps;\
	ppmtogif dcl001.ppm >  dcl.gif;\
	gifsicle --rotate-90 dcl.gif > $@.gif;\
	mv dcl.ps $@;\
	$(COMMAND_PS2PNG);\
	rm dcl.gif dcl001.ppm
STRM_{year}-JJA_NCEP.ps: 
	$(COMMAND_MEAN) --title "STRM_{year}-JJA_NCEP" STRM_{year}-07_NCEP.nc STRM_{year}-08_NCEP.nc STRM_{year}-06_NCEP.nc;\
	pstopnm dcl.ps;\
	ppmtogif dcl001.ppm >  dcl.gif;\
	gifsicle --rotate-90 dcl.gif > $@.gif;\
	mv dcl.ps $@;\
	$(COMMAND_PS2PNG);\
	rm dcl.gif dcl001.ppm
STRM_{year}-SON_NCEP.ps: 
	$(COMMAND_MEAN) --title "STRM_{year}-SON_NCEP" STRM_{year}-10_NCEP.nc STRM_{year}-11_NCEP.nc STRM_{year}-09_NCEP.nc;\
	pstopnm dcl.ps;\
	ppmtogif dcl001.ppm >  dcl.gif;\
	gifsicle --rotate-90 dcl.gif > $@.gif;\
	mv dcl.ps $@;\
	$(COMMAND_PS2PNG);\
	rm dcl.gif dcl001.ppm
clean:
	-rm -f *.ps *~
	-rm -f *.png *~
	-rm -f *.gif *~
## make STRM nc. ##
ncall: ncjan ncfeb ncmar ncapr ncmay ncjun ncjul ncaug ncsep ncoct ncnov ncdec
ncjan:
	$(COMMAND_MKNC) --output STRM_{year}-01_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-01_NCEP.nc
ncfeb:
	$(COMMAND_MKNC) --output STRM_{year}-02_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-02_NCEP.nc
ncmar:
	$(COMMAND_MKNC) --output STRM_{year}-03_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-03_NCEP.nc
ncapr:
	$(COMMAND_MKNC) --output STRM_{year}-04_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-04_NCEP.nc
ncmay:
	$(COMMAND_MKNC) --output STRM_{year}-05_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-05_NCEP.nc
ncjun:
	$(COMMAND_MKNC) --output STRM_{year}-06_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-06_NCEP.nc
ncjul:
	$(COMMAND_MKNC) --output STRM_{year}-07_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-07_NCEP.nc
ncaug:
	$(COMMAND_MKNC) --output STRM_{year}-08_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-08_NCEP.nc
ncsep:
	$(COMMAND_MKNC) --output STRM_{year}-09_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-09_NCEP.nc
ncoct:
	$(COMMAND_MKNC) --output STRM_{year}-10_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-10_NCEP.nc
ncnov:
	$(COMMAND_MKNC) --output STRM_{year}-11_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-11_NCEP.nc
ncdec:
	$(COMMAND_MKNC) --output STRM_{year}-12_NCEP.nc ../../VWND.NCEP/VWND.{year}.NCEP/VWND_{year}-12_NCEP.nc
ncclean:
	-rm -f *.nc *~
