source: LMDZ6/branches/contrails/libf/phylmd/ecrad/test/ckdmip/Makefile @ 5447

Last change on this file since 5447 was 4773, checked in by idelkadi, 12 months ago
  • Update of Ecrad in LMDZ The same organization of the Ecrad offline version is retained in order to facilitate the updating of Ecrad in LMDZ and the comparison between online and offline results. version 1.6.1 of Ecrad (https://github.com/lguez/ecrad.git)
  • Implementation of the double call of Ecrad in LMDZ


File size: 6.1 KB
Line 
1# Makefile for running ecRad on clear-sky CKDMIP profiles. The basic
2# test uses the single input file INPUT below. You can also run ecRad
3# on CKDMIP scenarios (see lower in file). You need the NCO tools
4# ncap2, ncrcat and ncpdq.
5
6# --- BASIC TEST ---
7
8# Type "make" to use the default ecckd gas-optics models, or "make
9# GASMODEL=rrtmg" for the RRTMG gas-optics model.
10
11INPUT     = ckdmip_evaluation1_concentrations_present_reduced.nc
12DRIVER    = ../../bin/ecrad
13CHANGENAM = ../common/change_namelist.sh
14GASMODEL  = ecckd
15CONFIG    = config-$(GASMODEL).nam
16
17all: test
18
19# By default run the sw and lw tests
20test: sw lw
21
22# Longwave ecRad calculation: simply run ecRad with an appropriate
23# config file
24lw: config-$(GASMODEL)_lw.nam
25        $(DRIVER) config-$(GASMODEL)_lw.nam $(INPUT) ckdmip_evaluation1_lw_out.nc
26
27# Shortwave ecRad calculation: run the five solar zenith angles then
28# concatenate the NetCDF files. This uses the GNU make feature "call",
29# here applied to CALCSWSZA which takes two arguments, the input and
30# output files
31sw: config_sw_all
32        $(call CALCSWSZA,$(INPUT),ckdmip_evaluation1_sw_out.nc)
33
34# Create a longwave config file (basically turn of the shortwave)
35config-$(GASMODEL)_lw.nam: $(CONFIG)
36        $(CHANGENAM) $(CONFIG) config-$(GASMODEL)_lw.nam do_sw=false
37
38# Create the namelist files for a particular solar zenith angle,
39# e.g. "make config-rrtmg_sw_0.5.nam" creates a namelist file for the
40# RRTMG gas optics model and a solar zenith angle of 60 degrees.
41config-$(GASMODEL)_sw_%.nam: $(CONFIG)
42        $(CHANGENAM) $(CONFIG) $@ do_lw=false cos_solar_zenith_angle=$*
43
44# Produce config files for each of the five solar zenith angles
45config_sw_all: config-$(GASMODEL)_sw_0.1.nam config-$(GASMODEL)_sw_0.3.nam \
46        config-$(GASMODEL)_sw_0.5.nam config-$(GASMODEL)_sw_0.7.nam config-$(GASMODEL)_sw_0.9.nam
47
48
49# --- HELPER FUNCTIONS ---
50
51# Function to run ecRad shortwave-only on the 50 evaluation profiles
52# for a single value of the solar zenith angle (works only with GNU
53# make), and then to add a mu0 variable storing the cosine of the
54# solar zenith angle. The arguments are (1) the input file name and
55# (2) the cosine of the solar zenith angle.
56CALCSW = \
57        $(DRIVER) config-$(GASMODEL)_sw_$(2).nam $(1) tmp_out.nc; \
58        ncap2 -O -s 'defdim("mu0",1,0);mu0[mu0]={'$(2)'f};mu0@long_name="Cosine of solar zenith angle";flux_dn_sw[mu0,column,half_level]=flux_dn_sw;flux_up_sw[mu0,column,half_level]=flux_up_sw;flux_dn_direct_sw[mu0,column,half_level]=flux_dn_direct_sw' tmp_out.nc tmp_$(2)_out.nc
59
60# Function to run ecRad shortwave-only for all five solar zenith
61# angles, then to contatenate the results into a single file. The
62# arguments are (1) the input file name and (2) the output file name.
63CALCSWSZA = \
64        $(call CALCSW,$(1),0.1); \
65        $(call CALCSW,$(1),0.3); \
66        $(call CALCSW,$(1),0.5); \
67        $(call CALCSW,$(1),0.7); \
68        $(call CALCSW,$(1),0.9); \
69        ncrcat -O tmp_0.1_out.nc tmp_0.3_out.nc tmp_0.5_out.nc tmp_0.7_out.nc tmp_0.9_out.nc tmp_out2.nc; \
70        ncpdq -O -a column,mu0,half_level tmp_out2.nc $(2)
71
72
73# --- CKDMIP SCENARIOS ---
74
75# To run the CKDMIP scenarios you first need to copy the concentration
76# files from http://aux.ecmwf.int/ecpds/home/ckdmip/concentrations/,
77# or ftp from aux.ecmwf.int (username ckdmip, password any non-empty
78# string), which you can do with "make download".  Then do:
79#
80#    make scenarios
81#
82# As in the basic test you can add the GASMODEL=rrtmg to use the RRTMG
83# gas-optics model instead of ecCKD. To use a different configuration
84# of ecCKD than the default, copy config-ecckd.nam to something like
85# config-custom.nam, then add the gas_optics_sw_override_file_name and
86# gas_optics_lw_override_file_name namelist arguments to specify your
87# preferred CKD definition file, and call make with GASMODEL=custom.
88
89CONCDIR    = concentrations
90DATASET    = evaluation1
91FLUXDIR    = fluxes
92LBLFLUXDIR = lbl_fluxes
93
94# Web/FTP location of concentration files (no trailing slash)
95#WEBSOURCE = http://aux.ecmwf.int/ecpds/home/ckdmip
96WEBSOURCE = ftp://ckdmip:blank@aux.ecmwf.int
97
98# List of scenarios to run
99SCENARIOS = present co2-180 co2-280 co2-560 co2-1120 co2-2240 ch4-350 ch4-700 ch4-1200 ch4-2600 ch4-3500 n2o-190 n2o-270 n2o-405 n2o-540
100
101# A longwave and shortwave make rule for each scenario
102SCENARIO_RULES = $(addprefix lw_scenario_,$(SCENARIOS)) $(addprefix sw_scenario_,$(SCENARIOS))
103# A download rule for each scenario
104DOWNLOAD_RULES = $(addprefix download_,$(SCENARIOS))
105
106# Main target of this section runs each scenario longwave and shortwave
107scenarios: $(SCENARIO_RULES)
108
109# Pattern matches a shortwave scenario, invoked by calling the
110# CALCSWSZA function.
111sw_scenario_%: config_sw_all
112        mkdir -p $(FLUXDIR)
113        $(call CALCSWSZA,$(CONCDIR)/ckdmip_$(DATASET)_concentrations_$*.nc,$(FLUXDIR)/ecrad-$(GASMODEL)_$(DATASET)_sw_fluxes_$*.nc)
114
115# Pattern matches a longwave scenario.
116lw_scenario_%: config-$(GASMODEL)_lw.nam
117        mkdir -p $(FLUXDIR)
118        $(DRIVER) config-$(GASMODEL)_lw.nam $(CONCDIR)/ckdmip_$(DATASET)_concentrations_$*.nc $(FLUXDIR)/ecrad-$(GASMODEL)_$(DATASET)_lw_fluxes_$*.nc
119
120# Target to download concentration files from the web to the CONCDIR
121# directory
122download: $(DOWNLOAD_RULES)
123
124# Download one scenario, explicitly overwriting if it already
125# exists. Note that the "h5" files are NetCDF4/HDF5 format so can be
126# read with NetCDF tools
127download_%:
128        mkdir -p $(CONCDIR)
129        wget -nv -O $(CONCDIR)/ckdmip_$(DATASET)_concentrations_$*.nc \
130                $(WEBSOURCE)/concentrations/ckdmip_$(DATASET)_concentrations_$*.nc
131        mkdir -p $(LBLFLUXDIR)
132        wget -nv -O $(LBLFLUXDIR)/ckdmip_$(DATASET)_lw_fluxes_$*.nc \
133                $(WEBSOURCE)/lw_fluxes/$(DATASET)/ckdmip_$(DATASET)_lw_fluxes_$*.h5
134        wget -nv -O $(LBLFLUXDIR)/ckdmip_$(DATASET)_sw_fluxes_$*.nc \
135                $(WEBSOURCE)/sw_fluxes/$(DATASET)/ckdmip_$(DATASET)_sw_fluxes_$*.h5
136
137
138# Clean data files
139clean:
140        rm -f *_out.nc config-*_sw_*.nam config-*_lw.nam tmp*.nc wget-log
141
142distclean: clean
143        rm -rf $(CONCDIR)/ckdmip_$(DATASET)_concentrations_present.nc \
144                $(CONCDIR)/ckdmip_$(DATASET)_*-*.nc \
145                $(FLUXDIR)/ecrad-*_$(DATASET)_lw_fluxes_*.nc \
146                $(FLUXDIR)/ecrad-*_$(DATASET)_sw_fluxes_*.nc \
147                $(LBLFLUXDIR)/ckdmip_$(DATASET)_lw_fluxes_*.nc \
148                $(LBLFLUXDIR)/ckdmip_$(DATASET)_sw_fluxes_*.nc
149
150.PHONY: config_sw_all scenarios sw lw all test clean distclean
Note: See TracBrowser for help on using the repository browser.