source: NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF/launch_sasf.sh @ 13690

Last change on this file since 13690 was 13690, checked in by laurent, 6 months ago

Improvements for "oce+ice capable" STATION_ASF!

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