New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
launch_sasf.sh in NEMO/branches/2020/dev_r13648_ASINTER-04_laurent_bulk_ice/tests/STATION_ASF/EXPREF – NEMO

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

Last change on this file since 13682 was 13682, checked in by laurent, 3 years ago

Still improving the oce+ice capable STATION_ASF...

  • Property svn:executable set to *
File size: 8.0 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="`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:
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#
34NFORC="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
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 could 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}/oce+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
98CFGS_SHARED="${NEMO_REF_DIR}/cfgs/SHARED"
99if [ ! -d ${CFGS_SHARED} ]; then echo "PROBLEM!!! => could not find directory ${CFGS_SHARED} !"; exit; fi
100
101if [ ! -d ${DATA_IN_DIR} ]; then echo "PROBLEM!!! => could not find directory 'input_data' with input forcing..."; exit; fi
102
103cdt_cmpl="`\ls -l ${NEMO_EXE} | cut -d' ' -f 6,7,8`"
104
105echo "###########################################################"
106echo "#        S T A T I O N   A i r  -  S e a   F l u x        #"
107echo "###########################################################"
108echo
109echo "  * NEMO reference root directory is: ${NEMO_REF_DIR}"
110echo "  * STATION_ASF work directory is: ${SASF_WRK_DIR}"
111echo "       ==> NEMO EXE to use: ${NEMO_EXE}"
112echo "           ==> compiled: ${cdt_cmpl} !"
113echo
114echo "  * Input forcing data into: ${DATA_IN_DIR}"
115echo "  * Production will be done into: ${PROD_DIR}"
116echo "  * Directory in which namelists and xml files are fetched:"
117echo "       ==> ${SASF_EXPREF}"
118echo
119sleep 2
120
121mkdir -p ${PROD_DIR}
122
123rsync -avP ${NEMO_EXE}          ${PROD_DIR}/
124ln -sf     ${NEMO_EXE}          ${PROD_DIR}/nemo.exe.lnk
125
126
127# XIOS xml file
128################
129
130list_xml_ref="field_def_nemo-oce.xml domain_def_nemo.xml grid_def_nemo.xml"
131list_xml_cfg="iodef.xml file_def_nemo-oce.xml"
132fcntxt="context_nemo_OCE.xml"
133if [ ${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"
137fi
138
139# The "context_nemo.xml" file:
140if [ ! -f ${SASF_EXPREF}/${fcntxt} ]; then echo " Mhhh, ${fcntxt} not found into ${SASF_EXPREF} !"; exit; fi
141rsync -avPL ${SASF_EXPREF}/${fcntxt} ${PROD_DIR}/context_nemo.xml
142
143# All remaining "*.xml" files:
144for 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}/
147done
148for 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}/
151done
152
153
154# Copy forcing to work directory:
155echo ; echo "Forcing files to use:"
156\ls -l ${DATA_IN_DIR}/*${FORC}*.nc
157echo
158rsync -avP ${DATA_IN_DIR}/*${FORC}*.nc ${PROD_DIR}/
159echo; echo
160
161
162if [ "${LIST_IA_ALGOS}" = "" ]; then LIST_IA_ALGOS="none"; fi
163
164echo
165
166for 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
224done
Note: See TracBrowser for help on using the repository browser.