1 | #!/bin/bash |
---|
2 | |
---|
3 | ################################################################ |
---|
4 | # |
---|
5 | # Script to launch a set of STATION_ASF simulations |
---|
6 | # |
---|
7 | # Ocean-only version.... |
---|
8 | # |
---|
9 | # L. Brodeau, 2020 |
---|
10 | # |
---|
11 | ################################################################ |
---|
12 | |
---|
13 | CONFIG="STATION_ASF" ; # general name of the configuration |
---|
14 | CONFIG_BLD="STATION_ASF2" ; # name of config as build in NEMO... (directory inside "tests" actually contains the compiled test-case?) |
---|
15 | |
---|
16 | # Root directory NEMOGCM reference depository where to fetch compiled STATION_ASF nemo.exe + default namelists: |
---|
17 | NEMO_REF_DIR="`dirname ${PWD} | sed -e 's|/tests/STATION_ASF||g'`" ; # that should normally do the trick! |
---|
18 | |
---|
19 | # NEMOGCM root directory where to fetch compiled STATION_ASF nemo.exe: |
---|
20 | SASF_WRK_DIR="${NEMO_REF_DIR}/tests/${CONFIG_BLD}" |
---|
21 | |
---|
22 | # DATA_IN_DIR => Directory containing sea-surface + atmospheric forcings: |
---|
23 | DATA_IN_DIR="${NEMO_REF_DIR}/tests/${CONFIG}/input_data" |
---|
24 | |
---|
25 | # Directory where to run the simulation: |
---|
26 | PROD_DIR="${HOME}/tmp/${CONFIG}" |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | # Atmo + SSX forcing to use and wheter to compute fluxes over sea-ice as well (i_sea_ice=1) |
---|
31 | ############################################################################################# |
---|
32 | i_sea_ice=0 ; # default does not compute fluxes over sea-ice |
---|
33 | # |
---|
34 | NFORC="ERA5_arctic" ; i_sea_ice=1 ; FORC="ERA5_arctic_surface_81N_36p75E_1h" ; # string sufficient to copy relevant files as in "*${FORC}*.nc" |
---|
35 | #NFORC="PAPA" ; FORC="Station_PAPA_50N-145W" ; # string sufficient to copy relevant files as in "*${FORC}*.nc" |
---|
36 | |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | ####### End of normal user configurable section ####### |
---|
41 | |
---|
42 | #================================================================================ |
---|
43 | |
---|
44 | if [ "`which ncks`" = "" ]; then |
---|
45 | echo |
---|
46 | echo "WARNING: you do not seem to have NCO installed here... You should!" |
---|
47 | echo " => anyway! will do without, output fields will remaine 3x3 in space :( " |
---|
48 | echo |
---|
49 | sleep 4 |
---|
50 | fi |
---|
51 | |
---|
52 | HERE=`pwd` |
---|
53 | |
---|
54 | echo |
---|
55 | |
---|
56 | # Is the nemo.exe of STATION_ASF compiled with sea-ice support (SI3) ? |
---|
57 | i_si3=0 |
---|
58 | FCPP="${SASF_WRK_DIR}/cpp_${CONFIG_BLD}.fcm" |
---|
59 | if [ ! -f ${FCPP} ]; then echo " Mhhh, we could not find 'cpp_STATION_ASF.fcm' into `dirname ${FCPP}` !"; exit; fi |
---|
60 | ca=`cat ${FCPP} | grep 'key_si3'` |
---|
61 | |
---|
62 | if [ "${ca}" = "" ]; then |
---|
63 | echo " *** NEMO was NOT compiled with sea-ice support (SI3) !" ; echo |
---|
64 | if [ ${i_sea_ice} -eq 1 ]; then |
---|
65 | echo " ===> so you cannot request ice-air flux computation !" |
---|
66 | echo " ===> please set i_sea_ice=0 or compile STATION_ASF with CPP key 'key_si3' !" |
---|
67 | echo ; exit |
---|
68 | fi |
---|
69 | else |
---|
70 | echo " *** NEMO was apparently compiled with sea-ice support (SI3) !" ; echo |
---|
71 | i_si3=1 |
---|
72 | fi |
---|
73 | |
---|
74 | # Ok things are a bit different whether we compute fluxes over open ocean only or open ocean + sea-ice |
---|
75 | if [ ${i_sea_ice} -eq 1 ]; then |
---|
76 | # OPEN-OCEAN/AIR + SEA-ICE/AIR flux computation |
---|
77 | # - simpler if we only use one Open-ocean/air algo (ECMWF) |
---|
78 | LIST_OA_ALGOS="ECMWF" ; # list of air-sea algorithms to test |
---|
79 | LIST_IA_ALGOS="LG15 LU12 CSTC" ; # list of air-ice algorithms to test |
---|
80 | DIR_NL=${NFORC}/oce+ice ; # where to fetch the namelists from... |
---|
81 | else |
---|
82 | # Only OPEN-OCEAN/AIR flux computation |
---|
83 | LIST_OA_ALGOS="NCAR ECMWF COARE3p6 ANDREAS"; # list of air-sea algorithms to test |
---|
84 | LIST_IA_ALGOS="" |
---|
85 | DIR_NL=${NFORC}/oce ; # where to fetch the namelists from... |
---|
86 | fi |
---|
87 | if [ ! -d ${DIR_NL} ]; then echo " Mhhh, seems like forcing ${NFORC} is not meant to be used with sea-ice/air flux computation !"; exit; fi |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | # NEMO executable to use is: |
---|
92 | NEMO_EXE="${SASF_WRK_DIR}/BLD/bin/nemo.exe" |
---|
93 | if [ ! -f ${NEMO_EXE} ]; then echo " Mhhh, no compiled 'nemo.exe' found into `dirname ${NEMO_EXE}` !"; exit; fi |
---|
94 | |
---|
95 | SASF_EXPREF=`pwd` ; # STATION_ASF EXPREF directory from which to use namelists and XIOS xml files... |
---|
96 | |
---|
97 | |
---|
98 | CFGS_SHARED="${NEMO_REF_DIR}/cfgs/SHARED" |
---|
99 | if [ ! -d ${CFGS_SHARED} ]; then echo "PROBLEM!!! => could not find directory ${CFGS_SHARED} !"; exit; fi |
---|
100 | |
---|
101 | if [ ! -d ${DATA_IN_DIR} ]; then echo "PROBLEM!!! => could not find directory 'input_data' with input forcing..."; exit; fi |
---|
102 | |
---|
103 | cdt_cmpl="`\ls -l ${NEMO_EXE} | cut -d' ' -f 6,7,8`" |
---|
104 | |
---|
105 | echo "###########################################################" |
---|
106 | echo "# S T A T I O N A i r - S e a F l u x #" |
---|
107 | echo "###########################################################" |
---|
108 | echo |
---|
109 | echo " * NEMO reference root directory is: ${NEMO_REF_DIR}" |
---|
110 | echo " * STATION_ASF work directory is: ${SASF_WRK_DIR}" |
---|
111 | echo " ==> NEMO EXE to use: ${NEMO_EXE}" |
---|
112 | echo " ==> compiled: ${cdt_cmpl} !" |
---|
113 | echo |
---|
114 | echo " * Input forcing data into: ${DATA_IN_DIR}" |
---|
115 | echo " * Production will be done into: ${PROD_DIR}" |
---|
116 | echo " * Directory in which namelists and xml files are fetched:" |
---|
117 | echo " ==> ${SASF_EXPREF}" |
---|
118 | echo |
---|
119 | sleep 2 |
---|
120 | |
---|
121 | mkdir -p ${PROD_DIR} |
---|
122 | |
---|
123 | rsync -avP ${NEMO_EXE} ${PROD_DIR}/ |
---|
124 | ln -sf ${NEMO_EXE} ${PROD_DIR}/nemo.exe.lnk |
---|
125 | |
---|
126 | |
---|
127 | # XIOS xml file |
---|
128 | ################ |
---|
129 | |
---|
130 | list_xml_ref="field_def_nemo-oce.xml domain_def_nemo.xml grid_def_nemo.xml" |
---|
131 | list_xml_cfg="iodef.xml file_def_nemo-oce.xml" |
---|
132 | fcntxt="context_nemo_OCE.xml" |
---|
133 | if [ ${i_sea_ice} -eq 1 ]; then |
---|
134 | list_xml_ref+=" field_def_nemo-ice.xml" |
---|
135 | list_xml_cfg+=" file_def_nemo-ice.xml" |
---|
136 | fcntxt="context_nemo_OCE+ICE.xml" |
---|
137 | fi |
---|
138 | |
---|
139 | # The "context_nemo.xml" file: |
---|
140 | if [ ! -f ${SASF_EXPREF}/${fcntxt} ]; then echo " Mhhh, ${fcntxt} not found into ${SASF_EXPREF} !"; exit; fi |
---|
141 | rsync -avPL ${SASF_EXPREF}/${fcntxt} ${PROD_DIR}/context_nemo.xml |
---|
142 | |
---|
143 | # All remaining "*.xml" files: |
---|
144 | for ff in ${list_xml_cfg} ; do |
---|
145 | if [ ! -f ${SASF_EXPREF}/${ff} ]; then echo " Mhhh, ${ff} not found into ${SASF_EXPREF} !"; exit; fi |
---|
146 | rsync -avPL ${SASF_EXPREF}/${ff} ${PROD_DIR}/ |
---|
147 | done |
---|
148 | for ff in ${list_xml_ref} ; do |
---|
149 | if [ ! -f ${CFGS_SHARED}/${ff} ]; then echo " Mhhh, ${ff} not found into ${CFGS_SHARED} !"; exit; fi |
---|
150 | rsync -avPL ${CFGS_SHARED}/${ff} ${PROD_DIR}/ |
---|
151 | done |
---|
152 | |
---|
153 | |
---|
154 | # Copy forcing to work directory: |
---|
155 | echo ; echo "Forcing files to use:" |
---|
156 | \ls -l ${DATA_IN_DIR}/*${FORC}*.nc |
---|
157 | echo |
---|
158 | rsync -avP ${DATA_IN_DIR}/*${FORC}*.nc ${PROD_DIR}/ |
---|
159 | echo; echo |
---|
160 | |
---|
161 | |
---|
162 | if [ "${LIST_IA_ALGOS}" = "" ]; then LIST_IA_ALGOS="none"; fi |
---|
163 | |
---|
164 | echo |
---|
165 | |
---|
166 | for OA_A in ${LIST_OA_ALGOS}; do |
---|
167 | for IA_A in ${LIST_IA_ALGOS}; do |
---|
168 | |
---|
169 | echo |
---|
170 | CASE="${OA_A}" |
---|
171 | if [ ${i_sea_ice} -eq 1 ] && [ "${IA_A}" != "none" ]; then CASE="${OA_A}-${IA_A}"; fi |
---|
172 | |
---|
173 | echo ; echo |
---|
174 | echo "=======================================================================" |
---|
175 | echo " Going for experiment: ${CASE} bulk param. with ${NFORC} forcing " |
---|
176 | echo "=======================================================================" |
---|
177 | echo |
---|
178 | |
---|
179 | scase=`echo "${CASE}" | tr '[:upper:]' '[:lower:]'` |
---|
180 | |
---|
181 | rm -f ${PROD_DIR}/namelist_cfg |
---|
182 | fnml="${SASF_EXPREF}/${DIR_NL}/namelist_${scase}_cfg" |
---|
183 | if [ ! -f ${fnml} ]; then echo " Mhhh, test namelist ${fnml} not found !"; exit; fi |
---|
184 | |
---|
185 | echo " ===> namelist to use is: ${DIR_NL}/namelist_${scase}_cfg !"; echo |
---|
186 | |
---|
187 | # The namelists: |
---|
188 | rsync -avPL ${SASF_EXPREF}/${DIR_NL}/namelist_${scase}_cfg ${PROD_DIR}/namelist_cfg |
---|
189 | rsync -avPL ${CFGS_SHARED}/namelist_ref ${PROD_DIR}/namelist_ref |
---|
190 | if [ ${i_sea_ice} -eq 1 ]; then |
---|
191 | rsync -avPL ${SASF_EXPREF}/namelist_ice_cfg ${PROD_DIR}/namelist_ice_cfg |
---|
192 | rsync -avPL ${CFGS_SHARED}/namelist_ice_ref ${PROD_DIR}/namelist_ice_ref |
---|
193 | fi |
---|
194 | |
---|
195 | cd ${PROD_DIR}/ |
---|
196 | echo |
---|
197 | echo "Launching NEMO !" |
---|
198 | ./nemo.exe 1>out_nemo.out 2>err_nemo.err |
---|
199 | echo "Done!" |
---|
200 | echo |
---|
201 | |
---|
202 | # Moving output files: |
---|
203 | mkdir -p output |
---|
204 | mv -f ${CONFIG}-${CASE}_${NFORC}_*_grid*.nc output/ |
---|
205 | if [ ${i_sea_ice} -eq 1 ]; then mv -f ${CONFIG}-${CASE}_${NFORC}_*_icemod.nc output/; fi |
---|
206 | |
---|
207 | # Saving logs: |
---|
208 | mkdir -p ${CASE}_${NFORC}_log |
---|
209 | mv -f *.out *.err ocean.output output.namelist.dyn ${CASE}_${NFORC}_log/ |
---|
210 | |
---|
211 | # Making 3x3 to 1 ! |
---|
212 | cd output/ |
---|
213 | list=`\ls ${CONFIG}*${CASE}_${NFORC}_*.nc | grep -v '_restart_'| grep -v '_1p.nc'` |
---|
214 | for ff in ${list}; do |
---|
215 | echo |
---|
216 | fn=`echo ${ff} | sed -e "s|.nc|_1p.nc|g"` |
---|
217 | CMD="ncks -O -d x,1 -d y,1 ${ff} -o ${fn}" |
---|
218 | echo " *** ${CMD}"; ${CMD} |
---|
219 | echo |
---|
220 | done |
---|
221 | |
---|
222 | done |
---|
223 | |
---|
224 | done |
---|