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

Last change on this file since 13676 was 13676, checked in by laurent, 7 months ago

Setting up the new STATION_ASF with sea-ice support

  • Property svn:executable set to *
File size: 7.9 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# Root directory NEMOGCM reference depository where to fetch compiled STATION_ASF nemo.exe + default namelists:
17NEMO_REF_DIR="/home/laurent/DEV/NEMO/NEMOGCM_dev_r13648_ASINTER-04_laurent_bulk_ice"
18
19# NEMOGCM root directory where to fetch compiled STATION_ASF nemo.exe:
20SASF_WRK_DIR="${NEMO_REF_DIR}/tests/${CONFIG_BLD}"
21
22# DATA_IN_DIR => Directory containing sea-surface + atmospheric forcings:
23DATA_IN_DIR="${NEMO_REF_DIR}/tests/${CONFIG}/input_data"
24
25# Directory where to run the simulation:
26PROD_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#############################################################################################
32i_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"
35NFORC="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
44if [ "`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
50fi
51
52HERE=`pwd`
53
54echo
55
56# Is the nemo.exe of STATION_ASF compiled with sea-ice support (SI3) ?
57i_si3=0
58FCPP="${SASF_WRK_DIR}/cpp_${CONFIG_BLD}.fcm"
59if [ ! -f ${FCPP} ]; then echo " Mhhh, we did not find 'cpp_STATION_ASF.fcm' into `dirname ${FCPP}` !"; exit; fi
60ca=`cat ${FCPP} | grep 'key_si3'`
61
62if [ "${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
69else
70    echo " *** NEMO was apparently compiled with sea-ice support (SI3) !" ; echo
71    i_si3=1
72fi
73
74# Ok things are a bit different whether we compute fluxes over open ocean only or open ocean + sea-ice
75if [ ${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}/ice ; # where to fetch the namelists from...
81else
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...
86fi
87if [ ! -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:
92NEMO_EXE="${SASF_WRK_DIR}/BLD/bin/nemo.exe"
93if [ ! -f ${NEMO_EXE} ]; then echo " Mhhh, no compiled 'nemo.exe' found into `dirname ${NEMO_EXE}` !"; exit; fi
94
95SASF_EXPREF=`pwd`  ; # STATION_ASF EXPREF directory from which to use namelists and XIOS xml files...
96
97
98if [ ! -d ${DATA_IN_DIR} ]; then echo "PROBLEM!!! => did not find directory 'input_data' with input forcing..."; exit; fi
99
100cdt_cmpl="`\ls -l ${NEMO_EXE} | cut -d' ' -f 6,7,8`"
101
102echo "###########################################################"
103echo "#        S T A T I O N   A i r  -  S e a   F l u x        #"
104echo "###########################################################"
105echo
106echo "  * NEMO reference root directory is: ${NEMO_REF_DIR}"
107echo "  * STATION_ASF work directory is: ${SASF_WRK_DIR}"
108echo "       ==> NEMO EXE to use: ${NEMO_EXE}"
109echo "           ==> compiled: ${cdt_cmpl} !"
110echo
111echo "  * Input forcing data into: ${DATA_IN_DIR}"
112echo "  * Production will be done into: ${PROD_DIR}"
113echo "  * Directory in which namelists and xml files are fetched:"
114echo "       ==> ${SASF_EXPREF}"
115echo
116sleep 2
117
118mkdir -p ${PROD_DIR}
119
120rsync -avP ${NEMO_EXE}          ${PROD_DIR}/
121ln -sf     ${NEMO_EXE}          ${PROD_DIR}/nemo.exe.lnk
122
123
124# XIOS xml file
125################
126
127list_xml="iodef.xml file_def_nemo-oce.xml field_def_nemo-oce.xml"
128fcntxt="context_nemo_OCE.xml"
129if [ ${i_sea_ice} -eq 1 ]; then
130    list_xml+=" file_def_nemo-ice.xml field_def_nemo-ice.xml"
131    fcntxt="context_nemo_OCE+ICE.xml"
132fi
133
134# The "context_nemo.xml" file:
135if [ ! -f ${SASF_EXPREF}/${fcntxt} ]; then echo " Mhhh, ${fcntxt} not found into ${SASF_EXPREF} !"; exit; fi
136rsync -avPL ${SASF_EXPREF}/${fcntxt} ${PROD_DIR}/context_nemo.xml
137
138# All remaining "*.xml" files:
139for ff in ${list_xml} ; do
140    if [ ! -f ${SASF_EXPREF}/${ff} ]; then echo " Mhhh, ${ff} not found into ${SASF_EXPREF} !"; exit; fi
141    rsync -avPL ${SASF_EXPREF}/${ff} ${PROD_DIR}/
142done
143
144
145# Getting reference/defaults files from reference NEMO distro:
146rdir="${NEMO_REF_DIR}/cfgs/SHARED"
147for ff in "domain_def_nemo.xml" "grid_def_nemo.xml"; do
148    if [ ! -f ${rdir}/${ff} ]; then echo " Mhhh, ${ff} not found into ${rdir} !"; exit; fi
149    ln -sf ${rdir}/${ff} ${PROD_DIR}/.
150done
151
152
153# Copy forcing to work directory:
154echo ; echo "Forcing files to use:"
155\ls -l ${DATA_IN_DIR}/*${FORC}*.nc
156echo
157rsync -avP ${DATA_IN_DIR}/*${FORC}*.nc ${PROD_DIR}/
158echo; echo
159
160
161if [ "${LIST_IA_ALGOS}" = "" ]; then LIST_IA_ALGOS="none"; fi
162
163echo
164
165for OA_A in ${LIST_OA_ALGOS}; do
166    for IA_A in ${LIST_IA_ALGOS}; do
167
168        echo       
169        CASE="${OA_A}"
170        if [ ${i_sea_ice} -eq 1 ] && [ "${IA_A}" != "none" ]; then CASE="${OA_A}-${IA_A}"; fi
171
172        echo ; echo
173        echo "======================================================================="
174        echo " Going for experiment: ${CASE} bulk param. with ${NFORC} forcing "
175        echo "======================================================================="
176        echo
177
178        scase=`echo "${CASE}" | tr '[:upper:]' '[:lower:]'`
179
180        rm -f ${PROD_DIR}/namelist_cfg
181        fnml="${SASF_EXPREF}/${DIR_NL}/namelist_${scase}_cfg"
182        if [ ! -f ${fnml} ]; then echo " Mhhh, test namelist ${fnml} not found !"; exit; fi
183
184        echo "   ===> namelist to use is: ${DIR_NL}/namelist_${scase}_cfg !"; echo
185       
186        # The namelists:
187        rsync -avPL ${SASF_EXPREF}/${DIR_NL}/namelist_${scase}_cfg ${PROD_DIR}/namelist_cfg
188        rsync -avPL ${SASF_EXPREF}/namelist_ref                   ${PROD_DIR}/namelist_ref
189        if [ ${i_sea_ice} -eq 1 ]; then
190            rsync -avPL ${SASF_EXPREF}/namelist_ice_ref ${PROD_DIR}/namelist_ice_ref
191            rsync -avPL ${SASF_EXPREF}/namelist_ice_cfg ${PROD_DIR}/namelist_ice_cfg
192        fi
193       
194        cd ${PROD_DIR}/
195        echo
196        echo "Launching NEMO !"
197        ./nemo.exe 1>out_nemo.out 2>err_nemo.err
198        echo "Done!"
199        echo
200
201        # Moving output files:
202        mkdir -p output
203        mv -f ${CONFIG}-${CASE}_${NFORC}_*_grid*.nc output/
204        if [ ${i_sea_ice} -eq 1 ]; then mv -f ${CONFIG}-${CASE}_${NFORC}_*_icemod.nc output/; fi
205
206        # Saving logs:
207        mkdir -p ${CASE}_${NFORC}_log
208        mv -f *.out *.err ocean.output output.namelist.dyn ${CASE}_${NFORC}_log/
209
210        # Making 3x3 to 1 !
211        cd output/
212        list=`\ls ${CONFIG}*${CASE}_${NFORC}_*.nc | grep -v '_restart_'| grep -v '_1p.nc'`
213        for ff in ${list}; do
214            echo
215            fn=`echo ${ff} | sed -e "s|.nc|_1p.nc|g"`
216            CMD="ncks -O -d x,1 -d y,1 ${ff} -o ${fn}"
217            echo " *** ${CMD}"; ${CMD}
218            echo
219        done
220
221    done
222
223done
Note: See TracBrowser for help on using the repository browser.