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