# Makefile for prate.1980
#
# 2004/05/24 D. Tsukahara 
## make ps & png files. ## 

.SUFFIXES : .nc .ps
.nc.ps:
	$(COMMAND_VIEW) $<
	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_VIEW = ruby ../../../bin/rgtview.rb --itr 1 --file --mean lon --min 0 --max 0.0001
COMMAND_PS2PNG = ruby ../../../util/ps2png.rb $@

PHYS_VAL = PRATE

PS_ANNUAL_MEAN   = $(PHYS_VAL)_1980-ANN_NCEP.ps
PS_SEASONAL_MEAN = $(PHYS_VAL)_1980-MAM_NCEP.ps $(PHYS_VAL)_1980-JJA_NCEP.ps $(PHYS_VAL)_1980-DJF_NCEP.ps $(PHYS_VAL)_1980-SON_NCEP.ps
PS_MONTHLY_MEAN  = $(PHYS_VAL)_1980-01_NCEP.ps $(PHYS_VAL)_1980-02_NCEP.ps $(PHYS_VAL)_1980-03_NCEP.ps $(PHYS_VAL)_1980-04_NCEP.ps  \
                       $(PHYS_VAL)_1980-05_NCEP.ps $(PHYS_VAL)_1980-06_NCEP.ps $(PHYS_VAL)_1980-07_NCEP.ps $(PHYS_VAL)_1980-08_NCEP.ps  \
                       $(PHYS_VAL)_1980-09_NCEP.ps $(PHYS_VAL)_1980-10_NCEP.ps $(PHYS_VAL)_1980-11_NCEP.ps $(PHYS_VAL)_1980-12_NCEP.ps
RENAMEPS = ruby ../../../util/rename2.rb -rf .ps.gif .gif .; ruby ../../../util/rename2.rb -rf ZM-PRATE PRATE .

all: fig

fig: monthly seasonal annualy renameps

mklink:
	ln -s ../../../$(PHYS_VAL).NCEP/$(PHYS_VAL).1980.NCEP/*.nc ./

annualy: $(PS_ANNUAL_MEAN)

monthly: $(PS_MONTHLY_MEAN)

seasonal: $(PS_SEASONAL_MEAN)

renameps:
	$(RENAMEPS)

$(PHYS_VAL)_1980-ANN_NCEP.ps: 
	$(COMMAND_VIEW) --title "$(PHYS_VAL)_1980-ANN_NCEP" \
	                $(PHYS_VAL)_1980-01_NCEP.nc $(PHYS_VAL)_1980-02_NCEP.nc $(PHYS_VAL)_1980-03_NCEP.nc $(PHYS_VAL)_1980-04_NCEP.nc  \
	                $(PHYS_VAL)_1980-05_NCEP.nc $(PHYS_VAL)_1980-06_NCEP.nc $(PHYS_VAL)_1980-07_NCEP.nc $(PHYS_VAL)_1980-08_NCEP.nc  \
                        $(PHYS_VAL)_1980-09_NCEP.nc $(PHYS_VAL)_1980-10_NCEP.nc $(PHYS_VAL)_1980-11_NCEP.nc $(PHYS_VAL)_1980-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

$(PHYS_VAL)_1980-DJF_NCEP.ps: 
	$(COMMAND_VIEW) --title "$(PHYS_VAL)_1980-DJF_NCEP" $(PHYS_VAL)_1980-01_NCEP.nc $(PHYS_VAL)_1980-02_NCEP.nc ../$(PHYS_VAL).1979.zonal-mean.NCEP/$(PHYS_VAL)_1979-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

$(PHYS_VAL)_1980-MAM_NCEP.ps: 
	$(COMMAND_VIEW) --title "$(PHYS_VAL)_1980-MAM_NCEP" $(PHYS_VAL)_1980-04_NCEP.nc $(PHYS_VAL)_1980-05_NCEP.nc $(PHYS_VAL)_1980-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

$(PHYS_VAL)_1980-JJA_NCEP.ps: 
	$(COMMAND_VIEW) --title "$(PHYS_VAL)_1980-JJA_NCEP" $(PHYS_VAL)_1980-07_NCEP.nc $(PHYS_VAL)_1980-08_NCEP.nc $(PHYS_VAL)_1980-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

$(PHYS_VAL)_1980-SON_NCEP.ps: 
	$(COMMAND_VIEW) --title "$(PHYS_VAL)_1980-SON_NCEP" $(PHYS_VAL)_1980-10_NCEP.nc $(PHYS_VAL)_1980-11_NCEP.nc $(PHYS_VAL)_1980-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 *~

