[13676] | 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 | # Note: the current setup only performs an ocean-only test (no sea-ice), |
---|
| 13 | # even though the current script already recongnises if the nemo.exe |
---|
| 14 | # has been compiled with "key_si3". For now it will just test the |
---|
| 15 | # fluxes over open water. |
---|
| 16 | # |
---|
| 17 | # |
---|
| 18 | # |
---|
| 19 | # |
---|
| 20 | # |
---|
| 21 | ################################################################ |
---|
| 22 | |
---|
| 23 | CONFIG="STATION_ASF" ; # general name of the configuration |
---|
| 24 | CONFIG_BLD="STATION_ASF2" ; # name of config as build in NEMO... (directory inside "tests" actually contains the compiled test-case?) |
---|
| 25 | |
---|
| 26 | # Root directory NEMOGCM reference depository where to fetch compiled STATION_ASF nemo.exe + default namelists: |
---|
| 27 | NEMO_REF_DIR="/home/laurent/DEV/NEMO/NEMOGCM_dev_r13648_ASINTER-04_laurent_bulk_ice" |
---|
| 28 | |
---|
| 29 | # NEMOGCM root directory where to fetch compiled STATION_ASF nemo.exe: |
---|
| 30 | SASF_WRK_DIR="${NEMO_REF_DIR}/tests/${CONFIG_BLD}" |
---|
| 31 | |
---|
| 32 | # DATA_IN_DIR => Directory containing sea-surface + atmospheric forcings: |
---|
| 33 | DATA_IN_DIR="${NEMO_REF_DIR}/tests/${CONFIG}/input_data" |
---|
| 34 | |
---|
| 35 | # Directory where to run the simulation: |
---|
| 36 | PROD_DIR="${HOME}/tmp/${CONFIG}" |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | # Atmo + SSX forcing to use and wheter to compute fluxes over sea-ice as well (i_sea_ice=1) |
---|
| 41 | ############################################################################################# |
---|
| 42 | i_sea_ice=0 ; # default does not compute fluxes over sea-ice |
---|
| 43 | NFORC="IDEALIZED" ; i_sea_ice=0 ; FORC="input_output_VALIDATION_IDEALIZED.nc" |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | ####### End of normal user configurable section ####### |
---|
| 47 | |
---|
| 48 | #================================================================================ |
---|
| 49 | |
---|
| 50 | rm -f SBCBLK.success SBCBLK.fail |
---|
| 51 | |
---|
| 52 | HERE=`pwd` |
---|
| 53 | |
---|
| 54 | echo |
---|
| 55 | |
---|
| 56 | # Is the nemo.exe of STATION_ASF compiled with sea-ice support (SI3) ? |
---|
| 57 | i_si3=0 |
---|
| 58 | FCPP="${SASF_WRK_DIR}/cpp_${CONFIG_BLD}.fcm" |
---|
| 59 | if [ ! -f ${FCPP} ]; then echo " Mhhh, we did not find 'cpp_STATION_ASF.fcm' into `dirname ${FCPP}` !"; exit; fi |
---|
| 60 | ca=`cat ${FCPP} | grep 'key_si3'` |
---|
| 61 | |
---|
| 62 | if [ "${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 |
---|
| 69 | else |
---|
| 70 | echo " *** NEMO was apparently compiled with sea-ice support (SI3) !" ; echo |
---|
| 71 | i_si3=1 |
---|
| 72 | fi |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | DIR_NL=${NFORC}/oce ; # directory where to find the namelists... |
---|
| 76 | |
---|
| 77 | # NEMO executable to use is: |
---|
| 78 | NEMO_EXE="${SASF_WRK_DIR}/BLD/bin/nemo.exe" |
---|
| 79 | if [ ! -f ${NEMO_EXE} ]; then echo " Mhhh, no compiled 'nemo.exe' found into `dirname ${NEMO_EXE}` !"; exit; fi |
---|
| 80 | |
---|
| 81 | SASF_EXPREF=`pwd` ; # STATION_ASF EXPREF directory from which to use namelists and XIOS xml files... |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | if [ ! -d ${DATA_IN_DIR} ]; then echo "PROBLEM!!! => did not find directory 'input_data' with input forcing..."; exit; fi |
---|
| 85 | |
---|
| 86 | cdt_cmpl="`\ls -l ${NEMO_EXE} | cut -d' ' -f 6,7,8`" |
---|
| 87 | |
---|
| 88 | echo "###########################################################" |
---|
| 89 | echo "# S T A T I O N A i r - S e a F l u x #" |
---|
| 90 | echo "###########################################################" |
---|
| 91 | echo |
---|
| 92 | echo " * NEMO reference root directory is: ${NEMO_REF_DIR}" |
---|
| 93 | echo " * STATION_ASF work directory is: ${SASF_WRK_DIR}" |
---|
| 94 | echo " ==> NEMO EXE to use: ${NEMO_EXE}" |
---|
| 95 | echo " ==> compiled: ${cdt_cmpl} !" |
---|
| 96 | echo |
---|
| 97 | echo " * Input forcing data into: ${DATA_IN_DIR}" |
---|
| 98 | echo " * Production will be done into: ${PROD_DIR}" |
---|
| 99 | echo " * Directory in which namelists and xml files are fetched:" |
---|
| 100 | echo " ==> ${SASF_EXPREF}" |
---|
| 101 | echo |
---|
| 102 | sleep 2 |
---|
| 103 | |
---|
| 104 | mkdir -p ${PROD_DIR} |
---|
| 105 | |
---|
| 106 | rsync -avP ${NEMO_EXE} ${PROD_DIR}/ |
---|
| 107 | ln -sf ${NEMO_EXE} ${PROD_DIR}/nemo.exe.lnk |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | # XIOS xml file |
---|
| 111 | ################ |
---|
| 112 | |
---|
| 113 | list_xml="iodef.xml file_def_nemo-oce.xml field_def_nemo-oce.xml" |
---|
| 114 | fcntxt="context_nemo_OCE.xml" |
---|
| 115 | if [ ${i_sea_ice} -eq 1 ]; then |
---|
| 116 | list_xml+=" file_def_nemo-ice.xml field_def_nemo-ice.xml" |
---|
| 117 | fcntxt="context_nemo_OCE+ICE.xml" |
---|
| 118 | fi |
---|
| 119 | |
---|
| 120 | # The "context_nemo.xml" file: |
---|
| 121 | if [ ! -f ${SASF_EXPREF}/${fcntxt} ]; then echo " Mhhh, ${fcntxt} not found into ${SASF_EXPREF} !"; exit; fi |
---|
| 122 | rsync -avPL ${SASF_EXPREF}/${fcntxt} ${PROD_DIR}/context_nemo.xml |
---|
| 123 | |
---|
| 124 | # All remaining "*.xml" files: |
---|
| 125 | for ff in ${list_xml} ; do |
---|
| 126 | if [ ! -f ${SASF_EXPREF}/${ff} ]; then echo " Mhhh, ${ff} not found into ${SASF_EXPREF} !"; exit; fi |
---|
| 127 | rsync -avPL ${SASF_EXPREF}/${ff} ${PROD_DIR}/ |
---|
| 128 | done |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | # Getting reference/defaults files from reference NEMO distro: |
---|
| 132 | rdir="${NEMO_REF_DIR}/cfgs/SHARED" |
---|
| 133 | for ff in "domain_def_nemo.xml" "grid_def_nemo.xml"; do |
---|
| 134 | if [ ! -f ${rdir}/${ff} ]; then echo " Mhhh, ${ff} not found into ${rdir} !"; exit; fi |
---|
| 135 | ln -sf ${rdir}/${ff} ${PROD_DIR}/. |
---|
| 136 | done |
---|
| 137 | |
---|
| 138 | |
---|
| 139 | # Copy forcing to work directory: |
---|
| 140 | echo ; echo "Forcing files to use:" |
---|
| 141 | \ls -l ${DATA_IN_DIR}/${FORC} |
---|
| 142 | echo |
---|
| 143 | rsync -avP ${DATA_IN_DIR}/${FORC} ${PROD_DIR}/ |
---|
| 144 | echo; echo |
---|
| 145 | |
---|
| 146 | for CASE in "NCAR" "ECMWF" "COARE3p0" "COARE3p6" "ANDREAS"; do |
---|
| 147 | |
---|
| 148 | echo ; echo |
---|
| 149 | echo "=======================================================================" |
---|
| 150 | echo " Going for experiment: ${CASE} bulk param. with ${NFORC} forcing " |
---|
| 151 | echo "=======================================================================" |
---|
| 152 | echo |
---|
| 153 | |
---|
| 154 | scase=`echo "${CASE}" | tr '[:upper:]' '[:lower:]'` |
---|
| 155 | |
---|
| 156 | rm -f ${PROD_DIR}/namelist_cfg |
---|
| 157 | fnml="${SASF_EXPREF}/${DIR_NL}/namelist_${scase}_cfg" |
---|
| 158 | if [ ! -f ${fnml} ]; then echo " Mhhh, test namelist ${fnml} not found !"; exit; fi |
---|
| 159 | |
---|
| 160 | echo " ===> namelist to use is: ${DIR_NL}/namelist_${scase}_cfg !"; echo |
---|
| 161 | |
---|
| 162 | # The namelists: |
---|
| 163 | rsync -avPL ${SASF_EXPREF}/${DIR_NL}/namelist_${scase}_cfg ${PROD_DIR}/namelist_cfg |
---|
| 164 | rsync -avPL ${SASF_EXPREF}/namelist_ref ${PROD_DIR}/namelist_ref |
---|
| 165 | |
---|
| 166 | cd ${PROD_DIR}/ |
---|
| 167 | echo |
---|
| 168 | echo "Launching NEMO !" |
---|
| 169 | ./nemo.exe 1>out_nemo.out 2>err_nemo.err |
---|
| 170 | echo "Done!" |
---|
| 171 | echo |
---|
| 172 | |
---|
| 173 | # Moving output files: |
---|
| 174 | mkdir -p output |
---|
| 175 | mv -f ${CONFIG}-${CASE}_${NFORC}_*_grid*.nc output/ |
---|
| 176 | |
---|
| 177 | # Saving logs: |
---|
| 178 | mkdir -p ${CASE}_${NFORC}_log |
---|
| 179 | mv -f *.out *.err ocean.output output.namelist.dyn ${CASE}_${NFORC}_log/ |
---|
| 180 | |
---|
| 181 | done |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | |
---|
| 185 | |
---|
| 186 | # Now we can compare the results with sanity range! |
---|
| 187 | |
---|
| 188 | echo ; echo ; echo |
---|
| 189 | echo " *** Now time for sanity-check of heat flux and wind stress components ***" |
---|
| 190 | echo |
---|
| 191 | |
---|
| 192 | cd ${HERE} |
---|
| 193 | python3 ./analyze_output.py ${DATA_IN_DIR}/${FORC} ${PROD_DIR}/output |
---|
| 194 | |
---|
| 195 | |
---|