[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 | |
---|
[13690] | 26 | # Atmo + SSX forcing to use and sea-ice support? |
---|
| 27 | NFORC="IDEALIZED" ; i_sea_ice=0 ; SFORC="input_output_VALIDATION_IDEALIZED.nc" |
---|
| 28 | |
---|
| 29 | |
---|
[13676] | 30 | # Root directory NEMOGCM reference depository where to fetch compiled STATION_ASF nemo.exe + default namelists: |
---|
[13682] | 31 | NEMO_REF_DIR="`dirname ${PWD} | sed -e 's|/tests/STATION_ASF||g'`" ; # that should normally do the trick! |
---|
[13676] | 32 | |
---|
| 33 | # NEMOGCM root directory where to fetch compiled STATION_ASF nemo.exe: |
---|
| 34 | SASF_WRK_DIR="${NEMO_REF_DIR}/tests/${CONFIG_BLD}" |
---|
| 35 | |
---|
| 36 | # DATA_IN_DIR => Directory containing sea-surface + atmospheric forcings: |
---|
| 37 | DATA_IN_DIR="${NEMO_REF_DIR}/tests/${CONFIG}/input_data" |
---|
| 38 | |
---|
| 39 | # Directory where to run the simulation: |
---|
| 40 | PROD_DIR="${HOME}/tmp/${CONFIG}" |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | ####### End of normal user configurable section ####### |
---|
| 47 | |
---|
| 48 | #================================================================================ |
---|
| 49 | |
---|
[13682] | 50 | # Should the `analyze_output.py` script provide more output ??? |
---|
| 51 | cmore="" |
---|
| 52 | if [ "$1" != "" ]; then |
---|
| 53 | if [ "$1" = "more" ]; then |
---|
| 54 | cmore="m" |
---|
| 55 | else |
---|
| 56 | echo "Only 'more' is accepted as argument for script `basename $0` !" |
---|
| 57 | exit |
---|
| 58 | fi |
---|
| 59 | fi |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | |
---|
[13676] | 63 | rm -f SBCBLK.success SBCBLK.fail |
---|
| 64 | |
---|
| 65 | HERE=`pwd` |
---|
| 66 | |
---|
| 67 | echo |
---|
| 68 | |
---|
| 69 | # Is the nemo.exe of STATION_ASF compiled with sea-ice support (SI3) ? |
---|
| 70 | i_si3=0 |
---|
| 71 | FCPP="${SASF_WRK_DIR}/cpp_${CONFIG_BLD}.fcm" |
---|
[13686] | 72 | if [ ! -f ${FCPP} ]; then echo " Mhhh, we could not find 'cpp_STATION_ASF.fcm' into `dirname ${FCPP}` !"; exit; fi |
---|
[13676] | 73 | ca=`cat ${FCPP} | grep 'key_si3'` |
---|
| 74 | |
---|
| 75 | if [ "${ca}" = "" ]; then |
---|
| 76 | echo " *** NEMO was NOT compiled with sea-ice support (SI3) !" ; echo |
---|
| 77 | if [ ${i_sea_ice} -eq 1 ]; then |
---|
| 78 | echo " ===> so you cannot request ice-air flux computation !" |
---|
| 79 | echo " ===> please set i_sea_ice=0 or compile STATION_ASF with CPP key 'key_si3' !" |
---|
| 80 | echo ; exit |
---|
| 81 | fi |
---|
| 82 | else |
---|
| 83 | echo " *** NEMO was apparently compiled with sea-ice support (SI3) !" ; echo |
---|
| 84 | i_si3=1 |
---|
| 85 | fi |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | DIR_NL=${NFORC}/oce ; # directory where to find the namelists... |
---|
| 89 | |
---|
| 90 | # NEMO executable to use is: |
---|
| 91 | NEMO_EXE="${SASF_WRK_DIR}/BLD/bin/nemo.exe" |
---|
| 92 | if [ ! -f ${NEMO_EXE} ]; then echo " Mhhh, no compiled 'nemo.exe' found into `dirname ${NEMO_EXE}` !"; exit; fi |
---|
| 93 | |
---|
| 94 | SASF_EXPREF=`pwd` ; # STATION_ASF EXPREF directory from which to use namelists and XIOS xml files... |
---|
| 95 | |
---|
| 96 | |
---|
[13686] | 97 | CFGS_SHARED="${NEMO_REF_DIR}/cfgs/SHARED" |
---|
| 98 | if [ ! -d ${CFGS_SHARED} ]; then echo "PROBLEM!!! => could not find directory ${CFGS_SHARED} !"; exit; fi |
---|
[13676] | 99 | |
---|
[13686] | 100 | if [ ! -d ${DATA_IN_DIR} ]; then echo "PROBLEM!!! => could not find directory 'input_data' with input forcing..."; exit; fi |
---|
| 101 | |
---|
[13676] | 102 | cdt_cmpl="`\ls -l ${NEMO_EXE} | cut -d' ' -f 6,7,8`" |
---|
| 103 | |
---|
| 104 | echo "###########################################################" |
---|
| 105 | echo "# S T A T I O N A i r - S e a F l u x #" |
---|
| 106 | echo "###########################################################" |
---|
| 107 | echo |
---|
| 108 | echo " * NEMO reference root directory is: ${NEMO_REF_DIR}" |
---|
| 109 | echo " * STATION_ASF work directory is: ${SASF_WRK_DIR}" |
---|
| 110 | echo " ==> NEMO EXE to use: ${NEMO_EXE}" |
---|
| 111 | echo " ==> compiled: ${cdt_cmpl} !" |
---|
| 112 | echo |
---|
| 113 | echo " * Input forcing data into: ${DATA_IN_DIR}" |
---|
| 114 | echo " * Production will be done into: ${PROD_DIR}" |
---|
| 115 | echo " * Directory in which namelists and xml files are fetched:" |
---|
| 116 | echo " ==> ${SASF_EXPREF}" |
---|
| 117 | echo |
---|
| 118 | sleep 2 |
---|
| 119 | |
---|
| 120 | mkdir -p ${PROD_DIR} |
---|
| 121 | |
---|
| 122 | rsync -avP ${NEMO_EXE} ${PROD_DIR}/ |
---|
| 123 | ln -sf ${NEMO_EXE} ${PROD_DIR}/nemo.exe.lnk |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | # XIOS xml file |
---|
| 127 | ################ |
---|
| 128 | |
---|
[13686] | 129 | list_xml_ref="field_def_nemo-oce.xml domain_def_nemo.xml grid_def_nemo.xml" |
---|
| 130 | list_xml_cfg="iodef.xml file_def_nemo-oce.xml" |
---|
[13676] | 131 | fcntxt="context_nemo_OCE.xml" |
---|
| 132 | if [ ${i_sea_ice} -eq 1 ]; then |
---|
[13686] | 133 | list_xml_ref+=" field_def_nemo-ice.xml" |
---|
| 134 | list_xml_cfg+=" file_def_nemo-ice.xml" |
---|
[13676] | 135 | fcntxt="context_nemo_OCE+ICE.xml" |
---|
| 136 | fi |
---|
| 137 | |
---|
| 138 | # The "context_nemo.xml" file: |
---|
| 139 | if [ ! -f ${SASF_EXPREF}/${fcntxt} ]; then echo " Mhhh, ${fcntxt} not found into ${SASF_EXPREF} !"; exit; fi |
---|
| 140 | rsync -avPL ${SASF_EXPREF}/${fcntxt} ${PROD_DIR}/context_nemo.xml |
---|
| 141 | |
---|
| 142 | # All remaining "*.xml" files: |
---|
[13686] | 143 | for ff in ${list_xml_cfg} ; do |
---|
[13676] | 144 | if [ ! -f ${SASF_EXPREF}/${ff} ]; then echo " Mhhh, ${ff} not found into ${SASF_EXPREF} !"; exit; fi |
---|
| 145 | rsync -avPL ${SASF_EXPREF}/${ff} ${PROD_DIR}/ |
---|
| 146 | done |
---|
[13686] | 147 | for ff in ${list_xml_ref} ; do |
---|
| 148 | if [ ! -f ${CFGS_SHARED}/${ff} ]; then echo " Mhhh, ${ff} not found into ${CFGS_SHARED} !"; exit; fi |
---|
| 149 | rsync -avPL ${CFGS_SHARED}/${ff} ${PROD_DIR}/ |
---|
[13676] | 150 | done |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | # Copy forcing to work directory: |
---|
| 154 | echo ; echo "Forcing files to use:" |
---|
[13690] | 155 | \ls -l ${DATA_IN_DIR}/${SFORC} |
---|
[13676] | 156 | echo |
---|
[13690] | 157 | rsync -avP ${DATA_IN_DIR}/${SFORC} ${PROD_DIR}/ |
---|
[13676] | 158 | echo; echo |
---|
| 159 | |
---|
| 160 | for CASE in "NCAR" "ECMWF" "COARE3p0" "COARE3p6" "ANDREAS"; do |
---|
| 161 | |
---|
| 162 | echo ; echo |
---|
| 163 | echo "=======================================================================" |
---|
| 164 | echo " Going for experiment: ${CASE} bulk param. with ${NFORC} forcing " |
---|
| 165 | echo "=======================================================================" |
---|
| 166 | echo |
---|
| 167 | |
---|
| 168 | scase=`echo "${CASE}" | tr '[:upper:]' '[:lower:]'` |
---|
| 169 | |
---|
| 170 | rm -f ${PROD_DIR}/namelist_cfg |
---|
| 171 | fnml="${SASF_EXPREF}/${DIR_NL}/namelist_${scase}_cfg" |
---|
| 172 | if [ ! -f ${fnml} ]; then echo " Mhhh, test namelist ${fnml} not found !"; exit; fi |
---|
| 173 | |
---|
| 174 | echo " ===> namelist to use is: ${DIR_NL}/namelist_${scase}_cfg !"; echo |
---|
| 175 | |
---|
| 176 | # The namelists: |
---|
| 177 | rsync -avPL ${SASF_EXPREF}/${DIR_NL}/namelist_${scase}_cfg ${PROD_DIR}/namelist_cfg |
---|
[13686] | 178 | rsync -avPL ${CFGS_SHARED}/namelist_ref ${PROD_DIR}/namelist_ref |
---|
[13676] | 179 | |
---|
| 180 | cd ${PROD_DIR}/ |
---|
| 181 | echo |
---|
| 182 | echo "Launching NEMO !" |
---|
| 183 | ./nemo.exe 1>out_nemo.out 2>err_nemo.err |
---|
| 184 | echo "Done!" |
---|
| 185 | echo |
---|
| 186 | |
---|
| 187 | # Moving output files: |
---|
| 188 | mkdir -p output |
---|
| 189 | mv -f ${CONFIG}-${CASE}_${NFORC}_*_grid*.nc output/ |
---|
| 190 | |
---|
| 191 | # Saving logs: |
---|
| 192 | mkdir -p ${CASE}_${NFORC}_log |
---|
| 193 | mv -f *.out *.err ocean.output output.namelist.dyn ${CASE}_${NFORC}_log/ |
---|
| 194 | |
---|
| 195 | done |
---|
| 196 | |
---|
| 197 | |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | # Now we can compare the results with sanity range! |
---|
| 201 | |
---|
| 202 | echo ; echo ; echo |
---|
| 203 | echo " *** Now time for sanity-check of heat flux and wind stress components ***" |
---|
| 204 | echo |
---|
| 205 | |
---|
| 206 | cd ${HERE} |
---|
[13690] | 207 | python3 ./analyze_output.py ${DATA_IN_DIR}/${SFORC} ${PROD_DIR}/output ${cmore} |
---|
[13676] | 208 | |
---|
| 209 | |
---|