# makefile for dcpam SyncRot
#
# 2009-06-08 S. Noda
# 2009-05-30 S. Noda
# 2008-11-24 Y. Morikawa
# 2007-06-14 M. Ishiwatari
# 2007-06-13 M. Ishiwatari
# 2007-05-30 M. Ishiwatari
#

#GPVIEW=gpview
GPVIEW=../gpview_custom-ym06

.SUFFIXES : .ps .png .obj .eps

.ps.eps :
#	dclpsrmcm $< | dclpsrot | sed 's/2\.0 W/13.0 W/g' | sed 's/6\.0 W/20.0 W/g' > tmp.ps
	dclpsrot $< | sed 's/2\.0 W/13.0 W/g' | sed 's/6\.0 W/20.0 W/g' > tmp.ps
	eps2eps tmp.ps $@
	rm tmp.ps

.ps.png :
	convert -rotate 90 $< $@

# dcpam5 の結果の場合, 単位は day
STRTIME = 0
ENDTIME = 200
AVRSTRTIME = 150
AVRENDTIME = 200

IMGS = \
Tg_timeseries-xymean \
ps_timeseries-xymean \
OLR_timeseries-xymean \
SLR_timeseries-xymean \
Rain_timeseries-xymean \
EVap_timeseries-xymean \
Sens_timeseries-xymean \
Tg-x0-180_timeseries-xymean \
ps-x0-180_timeseries-xymean \
OLR-x0-180_timeseries-xymean \
SLR-x0-180_timeseries-xymean \
Rain-x0-180_timeseries-xymean \
EVap-x0-180_timeseries-xymean \
Sens-x0-180_timeseries-xymean \
Tg-x180-360_timeseries-xymean \
ps-x180-360_timeseries-xymean \
OLR-x180-360_timeseries-xymean \
SLR-x180-360_timeseries-xymean \
Rain-x180-360_timeseries-xymean \
EVap-x180-360_timeseries-xymean \
Sens-x180-360_timeseries-xymean \
flux_timeseries-xymean \
flux-x0-180_timeseries-xymean \
flux-x180-360_timeseries-xymean \
Tg_xy \
ps_xy \
SSR_xy \
SLR_xy \
Rain_xy \
OLR_xy \
Sens_xy \
EVap_xy \
u_xz-y0 \
u_yz-xmean \
u_yz-x90 \
u_yz-x270 \
v_yz-xmean \
v_yz-x270 \
v_yz-x90 \
T_xy-z0 \
T_xy-sigma0.7 \
T_yz-xmean \
T_yz-x270 \
T_yz-x90 \
T_xz-y0 \
SigDot_xz-y0 \
q_xy-z0 \
q_yz-xmean \
q_yz-x270 \
q_yz-x90 \
SigDot_xz-y0 \
u_xy-sigma0.5 \
v_xy-sigma0.5 \
v_xy-sigma0.2 \
surface-flux_y0 \
surface-flux_y-xmean \
surface-flux_y-x0-180 \
surface-flux_y-x180-360

PSFIGS = $(IMGS:%=%.ps)
EPSFIGS = $(IMGS:%=%.eps)
PNGFIGS = $(IMGS:%=%.png)

all:ps eps png

ps: $(PSFIGS)
eps: $(EPSFIGS)
png: $(PNGFIGS)

#ps_timeseries-xymean.ps \

# SSR_timeseries-xymean.ps \
# SSR-x0-180_timeseries-xymean.ps \
# SSR-x180-360_timeseries-xymean.ps \


# 時系列 (全球平均値)
Tg_timeseries-xymean.ps: Tg.nc
	$(GPVIEW) Tg.nc@SurfTemp --mean lon,lat --wsn=2 && mv dcl.ps $@
ps_timeseries-xymean.ps: Ps.nc
	$(GPVIEW) Ps.nc@Ps --mean lon,lat --wsn=2 && mv dcl.ps $@
OLR_timeseries-xymean.ps: OLR.nc
	$(GPVIEW) OLR.nc@OLR --mean lon,lat --wsn=2 && mv dcl.ps $@
SLR_timeseries-xymean.ps: SLR.nc
	$(GPVIEW) SLR.nc@SLR --mean lon,lat --wsn=2 && mv dcl.ps $@
Rain_timeseries-xymean.ps: Rain.nc
	$(GPVIEW) Rain.nc@Rain --mean lon,lat --wsn=2 && mv dcl.ps $@
EVap_timeseries-xymean.ps: EVap.nc
	$(GPVIEW) EVap.nc@EVap --mean lon,lat --wsn=2 && mv dcl.ps $@
Sens_timeseries-xymean.ps: Sens.nc
	$(GPVIEW) Sens.nc@Sens --mean lon,lat --wsn=2 && mv dcl.ps $@
SSR_timeseries-xymean.ps: SSR.nc
	$(GPVIEW) SSR.nc@SSR --mean lon,lat --wsn=2 && mv dcl.ps $@

# 時系列 (経度0-180 度)
Tg-x0-180_timeseries-xymean.ps: Tg.nc
	$(GPVIEW) Tg.nc@SurfTemp,lon=0:180 --mean=lon,lat --wsn=2 && mv dcl.ps $@
ps-x0-180_timeseries-xymean.ps: Ps.nc
	$(GPVIEW) Ps.nc@Ps,lon=0:180 --mean=lon,lat --wsn=2 && mv dcl.ps $@
OLR-x0-180_timeseries-xymean.ps: OLR.nc
	$(GPVIEW) OLR.nc@OLR,lon=0:180 --mean=lon,lat --wsn=2 && mv dcl.ps $@
SLR-x0-180_timeseries-xymean.ps: SLR.nc
	$(GPVIEW) SLR.nc@SLR,lon=0:180 --mean=lon,lat --wsn=2 && mv dcl.ps $@
Rain-x0-180_timeseries-xymean.ps: Rain.nc
	$(GPVIEW) Rain.nc@Rain,lon=0:180 --mean=lon,lat --wsn=2 && mv dcl.ps $@
EVap-x0-180_timeseries-xymean.ps: EVap.nc
	$(GPVIEW) EVap.nc@EVap,lon=0:180 --mean=lon,lat --wsn=2 && mv dcl.ps $@
Sens-x0-180_timeseries-xymean.ps: Sens.nc
	$(GPVIEW) Sens.nc@Sens,lon=0:180 --mean=lon,lat --wsn=2 && mv dcl.ps $@
SSR-x0-180_timeseries-xymean.ps: SSR.nc
	$(GPVIEW) SSR.nc@SSR,lon=0:180 --mean=lon,lat --wsn=2 && mv dcl.ps $@

# 時系列 (経度180-360 度)
Tg-x180-360_timeseries-xymean.ps: Tg.nc
	$(GPVIEW) Tg.nc@SurfTemp,lon=180:360 --mean=lon,lat --wsn=2 && mv dcl.ps $@
ps-x180-360_timeseries-xymean.ps: Ps.nc
	$(GPVIEW) Ps.nc@Ps,lon=180:360 --mean=lon,lat --wsn=2 && mv dcl.ps $@
OLR-x180-360_timeseries-xymean.ps: OLR.nc
	$(GPVIEW) OLR.nc@OLR,lon=180:360 --mean=lon,lat --wsn=2 && mv dcl.ps $@
SLR-x180-360_timeseries-xymean.ps: SLR.nc
	$(GPVIEW) SLR.nc@SLR,lon=180:360 --mean=lon,lat --wsn=2 && mv dcl.ps $@
Rain-x180-360_timeseries-xymean.ps: Rain.nc
	$(GPVIEW) Rain.nc@Rain,lon=180:360 --mean=lon,lat --wsn=2 && mv dcl.ps $@
EVap-x180-360_timeseries-xymean.ps: EVap.nc
	$(GPVIEW) EVap.nc@EVap,lon=180:360 --mean=lon,lat --wsn=2 && mv dcl.ps $@
Sens-x180-360_timeseries-xymean.ps: Sens.nc
	$(GPVIEW) Sens.nc@Sens,lon=180:360 --mean=lon,lat --wsn=2 && mv dcl.ps $@
SSR-x180-360_timeseries-xymean.ps: SSR.nc
	$(GPVIEW) SSR.nc@SSR,lon=180:360 --mean=lon,lat --wsn=2 && mv dcl.ps $@


# 熱フラックス時間変化 全球平均値 重ね描き
flux_timeseries-xymean.ps: OLR.nc SLR.nc Rain.nc EVap.nc Sens.nc
	$(GPVIEW) OLR.nc@OLR --mean=lon,lat SLR.nc@SLR --mean=lon,lat Rain.nc@Rain --mean=lon,lat EVap.nc@EVap --mean=lon,lat Sens.nc@Sens --mean=lon,lat --overplot=5 --range=0:500 --wsn=2 && mv dcl.ps $@

# 熱フラックス時間変化 経度 0-180 度 重ね描き
flux-x0-180_timeseries-xymean.ps:
	$(GPVIEW) OLR.nc@OLR,lon=0:180 --mean=lon,lat SLR.nc@SLR,lon=0:180 --mean=lon,lat Rain.nc@Rain,lon=0:180 --mean=lon,lat EVap.nc@EVap,lon=0:180 --mean=lon,lat Sens.nc@Sens,lon=0:180 --mean=lon,lat --overplot=5 --range=0:500 --wsn=2 && mv dcl.ps $@

# 熱フラックス時間変化 経度 180-360 度 重ね描き
flux-x180-360_timeseries-xymean.ps:
	$(GPVIEW) OLR.nc@OLR,lon=180:360 --mean=lon,lat SLR.nc@SLR,lon=180:360 --mean=lon,lat Rain.nc@Rain,lon=180:360 --mean=lon,lat EVap.nc@EVap,lon=180:360 --mean=lon,lat Sens.nc@Sens,lon=180:360 --mean=lon,lat --overplot=5 --range=0:500 --wsn=2 && mv dcl.ps $@


# 平面プロット
Tg_xy.ps: Tg.nc
	$(GPVIEW) Tg.nc@SurfTemp,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --cint=5 --range=170:330 --wsn=2 && mv dcl.ps $@
ps_xy.ps: Ps.nc
	$(GPVIEW) Ps.nc@Ps,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --cint=500 --range=94000:104000 --wsn=2 && mv dcl.ps $@
Tg_xy_mono.ps: SurfTemp.nc
	$(GPVIEW) SurfTemp.nc@SurfTemp,time=$(AVRSTRTIME):$(AVRENDTIME) --noshade --mean=time --cint=5 --wsn=2 && mv dcl.ps $@
SSR_xy.ps: SSR.nc
	$(GPVIEW) SSR.nc@SSR,time=$(ENDTIME) --wsn=2 && mv dcl.ps $@
SLR_xy.ps:
	$(GPVIEW) SLR.nc@SLR,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --wsn=2 && mv dcl.ps $@
Rain_xy.ps:
	$(GPVIEW) Rain.nc@Rain,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --range=0:2000 --cint=300 --wsn=2 && mv dcl.ps $@
OLR_xy.ps:
	$(GPVIEW) OLR.nc@OLR,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --cint=10 --wsn=2 && mv dcl.ps $@
Sens_xy.ps:
	$(GPVIEW) Sens.nc@Sens,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --cint=5 --wsn=2 && mv dcl.ps $@
EVap_xy.ps:
	$(GPVIEW) EVap.nc@EVap,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --wsn=2 && mv dcl.ps $@
u_xy-sigma0.5.ps: U.nc
	$(GPVIEW) U.nc@U,sig=0.5,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --range=-80:80 --cint=10  --wsn=2 && mv dcl.ps $@
u_xy-sigma0.2.ps: U.nc
	$(GPVIEW) U.nc@U,sig=0.2,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --range=-80:80 --cint=10  --wsn=2 && mv dcl.ps $@
v_xy-sigma0.5.ps: V.nc
	$(GPVIEW) V.nc@V,sig=0.5,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --range=-20:20 --cint=2  --wsn=2 && mv dcl.ps $@
v_xy-sigma0.2.ps: V.nc
	$(GPVIEW) V.nc@V,sig=0.2,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --range=-50:50 --cint=5  --wsn=2 && mv dcl.ps $@
T_xy-z0.ps: Temp.nc
	$(GPVIEW) Temp.nc@Temp,sig=1,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time  --wsn=2 && mv dcl.ps $@
T_xy-sigma0.7.ps: Temp.nc
	$(GPVIEW) Temp.nc@Temp,sig=0.7,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --range=250:320 --cint=5 --wsn=2 && mv dcl.ps $@

# 赤道断面
u_xz-y0.ps: U.nc
	$(GPVIEW) U.nc@U,lat=0,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --range=-60:90 --cint=5 --wsn=2 && mv dcl.ps $@
SigDot_xz-y0.ps: SigDot.nc
	$(GPVIEW) SigDot.nc@SigmaDot,lat=0,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --range=-5e-6:5e-6 --cint=5e-7 --wsn=2 && mv dcl.ps $@

# 南北断面
u_yz-xmean.ps: U.nc
	$(GPVIEW) U.nc@U,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --mean lon --wsn=2 && mv dcl.ps $@
u_yz-x270.ps: U.nc
	$(GPVIEW) U.nc@U,lon=270,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time  --wsn=2 && mv dcl.ps $@
u_yz-x90.ps: U.nc
	$(GPVIEW) U.nc@U,lon=90,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time  --wsn=2 && mv dcl.ps $@

v_yz-xmean.ps: V.nc
	$(GPVIEW) V.nc@V,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --mean lon --wsn=2 && mv dcl.ps $@
v_yz-x270.ps: V.nc
	$(GPVIEW) V.nc@V,lon=270,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time  --wsn=2 && mv dcl.ps $@
v_yz-x90.ps: V.nc
	$(GPVIEW) V.nc@V,lon=90,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time  --wsn=2 && mv dcl.ps $@

T_yz-xmean.ps: Temp.nc
	$(GPVIEW) Temp.nc@Temp,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --mean lon --wsn=2 && mv dcl.ps $@
T_yz-x270.ps: Temp.nc
	$(GPVIEW) Temp.nc@Temp,lon=270,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time  --wsn=2 && mv dcl.ps $@
T_yz-x90.ps: Temp.nc
	$(GPVIEW) Temp.nc@Temp,lon=90,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --wsn=2 && mv dcl.ps $@
T_xz-y0.ps: Temp.nc
	$(GPVIEW) Temp.nc@Temp,lat=0,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --cint=5 --range=220:320 --wsn=2 && mv dcl.ps $@

q_xy-z0.ps: QVap.nc
	$(GPVIEW) QVap.nc@QVap,sig=1,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --wsn=2 && mv dcl.ps $@
q_yz-xmean.ps: QVap.nc
	$(GPVIEW) QVap.nc@QVap,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --mean lon --wsn=2 && mv dcl.ps $@
q_yz-x270.ps: QVap.nc
	$(GPVIEW) QVap.nc@QVap,lon=270,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --wsn=2 && mv dcl.ps $@
q_yz-x90.ps: QVap.nc
	$(GPVIEW) QVap.nc@QVap,lon=90,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --wsn=2 && mv dcl.ps $@


surface-flux_y0.ps:
	$(GPVIEW) --overplot=5 OLR.nc@OLR,lat=0,time=$(AVRSTRTIME):$(AVRENDTIME) SLR.nc@SLR,lat=0,time=$(AVRSTRTIME):$(AVRENDTIME) Rain.nc@Rain,lat=0,time=$(AVRSTRTIME):$(AVRENDTIME) EVap.nc@EVap,lat=0,time=$(AVRSTRTIME):$(AVRENDTIME) Sens.nc@Sens,lat=0,time=$(AVRSTRTIME):$(AVRENDTIME) --mean=time --index=888 --title='Surface Heat Flux at the Equator' --range=0:500 --wsn=2 && mv dcl.ps $@

surface-flux_y-x0-180.ps:
	$(GPVIEW) --overplot=5 OLR.nc@OLR,lon=0:180,time=$(AVRSTRTIME):$(AVRENDTIME) SLR.nc@SLR,lon=0:180,time=$(AVRSTRTIME):$(AVRENDTIME) Rain.nc@Rain,lon=0:180,time=$(AVRSTRTIME):$(AVRENDTIME) EVap.nc@EVap,lon=0:180,time=$(AVRSTRTIME):$(AVRENDTIME) Sens.nc@Sens,lon=0:180,time=$(AVRSTRTIME):$(AVRENDTIME)  --mean=time,lon --index=888 --title='Surface Heat Flux lon0-180' --range=0:500 --wsn=2 && mv dcl.ps $@

surface-flux_y-x180-360.ps:
	$(GPVIEW) --overplot=5 OLR.nc@OLR,lon=180:360,time=$(AVRSTRTIME):$(AVRENDTIME) SLR.nc@SLR,lon=180:360,time=$(AVRSTRTIME):$(AVRENDTIME) Rain.nc@Rain,lon=180:360,time=$(AVRSTRTIME):$(AVRENDTIME)  EVap.nc@EVap,lon=180:360,time=$(AVRSTRTIME):$(AVRENDTIME) Sens.nc@Sens,lon=180:360,time=$(AVRSTRTIME):$(AVRENDTIME)  --mean=time,lon --index=888 --title='Surface Heat Flux lon180-360' --range=0:500  --wsn=2 && mv dcl.ps $@

surface-flux_y-xmean.ps:
	$(GPVIEW) --overplot=5 OLR.nc@OLR,time=$(AVRSTRTIME):$(AVRENDTIME) SLR.nc@SLR,time=$(AVRSTRTIME):$(AVRENDTIME)  Rain.nc@Rain,time=$(AVRSTRTIME):$(AVRENDTIME) EVap.nc@EVap,time=$(AVRSTRTIME):$(AVRENDTIME) Sens.nc@Sens,time=$(AVRSTRTIME):$(AVRENDTIME)  --mean=time,lon --index=888 --title='Surface Heat Flux zonal mean' --range=0:500 --wsn=2 && mv dcl.ps $@


clean.all: clean clean.fig

clean.fig:
	-rm -f *.ps *.eps *.png

clean:
	-rm -f *~
