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 @ 13835

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

Improvment of STATION_ASF over sea-ice...

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