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