Changeset 6669 for TOOLS/CPLRESTART/CreateRestartOce4Oasis.bash
- Timestamp:
- 10/27/23 13:32:18 (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/CPLRESTART/CreateRestartOce4Oasis.bash
r6512 r6669 29 29 # 30 30 # CreateRestartOce4Oasis.bash --ocefile /ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/OCE/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_grid_T.nc --icefile /ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/ICE/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_icemod.nc --icefrc ice_pres --icetem tsice --icealb ialb 31 31 32 # CreateRestartOce4Oasis.bash --ocefile /ccc/store/cont003/gencmip6/p86mart/IGCM_OUT/IPSLCM6/DEVT/pdControl/CM6010.2.rivgeo-LR-pdCtrl/OCE/Output/MO/CM6010.2.rivgeo-LR-pdCtrl_22400101_22491231_1M_grid_T.nc --icefrc siconc 33 32 34 # CreateRestartOce4Oasis.bash --ocefile /ccc/store/cont003/gencmip6/p86maf/IGCM_OUT/IPSLCM6/PROD/piControl/CM61-LR-pi-03/OCE/Output/MO/CM61-LR-pi-03_23400101_23491231_1M_grid_T.nc --icefile /ccc/store/cont003/gencmip6/p86maf/IGCM_OUT/IPSLCM6/PROD/piControl/CM61-LR-pi-03/ICE/Output/MO/CM61-LR-pi-03_23400101_23491231_1M_icemod.nc --icefrc siconc 35 33 36 # CreateRestartOce4Oasis.bash --ocefile /ccc/store/cont003/gen7451/personr/IGCM_OUT/ORCA025_LIM3_PISCES/DEVT/ORCA025ia/eOR025L3P-IA-REF07-MUSCL/OCE/Output/MO/eOR025L3P-IA-REF07-MUSCL_20090101_20091231_1M_grid_T.nc 37 34 38 # CreateRestartOce4Oasis.bash --ocefile /ccc/work/cont003/gencmip6/p48ethe/ICMC-TOOLS/DATA/eOR025L3P-IA-REF07-MUSCL_20090101_20091231_1M_grid_T.nc --icefile /ccc/work/cont003/gencmip6/p48ethe/ICMC-TOOLS/DATA/eOR025L3P-IA-REF07-MUSCL_20090101_20091231_1M_icemod.nc --icefrc siconc/oce --icetem sistem 35 39 # … … 41 45 ## =========================================================================== 42 46 47 ## Creates colors for petty prints 48 ## =============================== 49 export Bold=$(tput bold) 50 export Unde=$(tput smul) ; export OffUnde=$(tput rmul) 51 export Stou=$(tput smso) ; export OffStou=$(tput rmso) 52 export Reve=$(tput rev ) 53 declare -a couleurs=( "Black" "Blue" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" ) 54 [[ "${bash_debug}" = "true" ]] && echod ".bash_login Couleurs : ${couleurs[*]}" 55 [[ "${bash_debug}" = "true" ]] && echod "Demmarrage de la boucle" 56 for i in $(seq 1 7) 57 do 58 [[ "${bash_debug}" = "true" ]] && echod i:${i} 59 [[ "${bash_debug}" = "true" ]] && echod ".bashrc Couleur ${i} : ${couleurs[${i}]}" 60 eval "export ${couleurs[$i]}=$(tput setf $i)" 61 eval "export ${couleurs[$i]}F=$(tput setb $i)" 62 done 63 export Norm=$(tput sgr0 ) 43 64 ## 44 65 ## Command line parameters … … 88 109 set +e 89 110 R_IN=$(ccc_home -u igcmg --cccwork)/IGCM 90 TMPDIR=$ {CCCWORKDIR}/TMP111 TMPDIR=$(ccc_home --cccwork)/TMP/CPLRESTART 91 112 SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 92 113 MpiRun="time ccc_mprun" 93 114 PyRun="time ccc_mprun -n 1" # Needed to force python to run on one process only 94 module purge 95 module load hdf5 96 module load netcdf-c 97 module load nco 98 module load cdo 99 module load python3 100 module load datadir/igcmg 101 module list 115 source $(ccc_home -u igcmg)/MachineEnvironment/irene/env_atlas_irene 102 116 set -e 103 117 ;; … … 113 127 ;; 114 128 esac 115 set -o verbose 116 set -o xtrace 117 set -e 118 119 Nperio="" 120 121 while [[ ${1} = -* ]] ; do 129 130 Nperio='' 131 bVerbose='Yes' 132 bXtrace='Yes' 133 bError='Yes' 134 Fill='yes' 135 136 while [[ ${1} = -* || ${1} = +* ]] ; do 122 137 case ${1} in 123 138 ( -- ) shift ; break ;; … … 132 147 ( --nofill ) Fill="no" ;; 133 148 ( --nperio ) shift ; Nperio="--nperio ${1}" ;; 134 ( -v | --verbose ) set -o verbose;;135 ( -x | --xtrace ) set -o xtrace;;136 ( -xv | -vx ) set -o xtrace verbose;;137 ( -e ) set -e;;138 ( -V | --noverbose ) set +o verbose;;139 ( -X | --noxtrace ) set +o xtrace;;140 ( -XV | -VX ) set +o xtrace verbose;;141 ( -E ) set +e;;142 ( -* ) echo ${Bold} "Unknown option : ${1}"${Norm} ; exit 1 ;;149 ( -v | --verbose ) bVerbose='Yes' ;; 150 ( -x | --xtrace ) bXtrace='Yes' ;; 151 ( -xv | -vx ) bVerbose='Yes' ; bXtrace='Yes' ;; 152 ( -e ) bError='Yes' ;; 153 ( -V | +v | --noverbose ) bVerbose='No' ;; 154 ( -X | +x | --noxtrace ) bXtrace='No' ;; 155 ( -XV | -VX | +vx | +xv ) bVerbose='No'; bXtrace='No' ;; 156 ( -E | +e ) bError='No' ;; 157 ( -* ) echo ${Bold}${Red}"Unknown option : ${1}"${Norm} ; exit 1 ;; 143 158 esac 144 159 shift 145 160 done 146 161 162 [[ "X${bVerbose}" = "XYes" ]] && set -o verbose 163 [[ "X${bVerbose}" = "XNo" ]] && set +o verbose 164 [[ "X${bXtrace}" = "XYes" ]] && set -o xtrace 165 [[ "X${bXtrace}" = "XNo" ]] && set +o xtrace 166 [[ "X${bError}" = "XYes" ]] && set -o errexit 167 [[ "X${bError}" = "XNo" ]] && set +o errexit 147 168 # 148 169 # Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits … … 180 201 181 202 182 echo "Oce sst - Variable ${OceSst} - File ${OceSstFile}" 183 echo "Ice fraction - Variable ${IceFrc} - File ${IceFrcFile}" 184 echo "Ice albedo - Variable ${IceAlb} - File ${IceAlbFile}" 185 echo "Ice temperature - Variable ${IceTem} - File ${IcetemFile}" 186 203 echo ${Blue}"Oce sst - Variable ${OceSst} - File ${OceSstFile}"${Norm} 204 echo ${Blue}"Ice fraction - Variable ${IceFrc} - File ${IceFrcFile}"${Norm} 205 echo ${Blue}"Ice albedo - Variable ${IceAlb} - File ${IceAlbFile}"${Norm} 206 echo ${Blue}"Ice temperature - Variable ${IceTem} - File ${IcetemFile}"${Norm} 207 208 209 if [[ ! -f ${OceSstFile} ]] ; then 210 echo ${Red}"Not found : ${OceSstFile}"${Norm} 211 fi 212 213 if [[ ! -f ${IceFrcFile} ]] ; then 214 echo ${Red}"Not found : ${IceFrcFile}"${Norm} 215 fi 187 216 188 217 ## 189 218 ## Extract variables 190 219 ## =========================================================================== 191 ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${IceFrc} ${IceFrcFile} sstoce_fields.nc192 ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${OceSst} ${OceSstFile} oce_sst.nc193 194 ncks --append --fl_fmt=${FL_FMT} --history oce_sst.ncsstoce_fields.nc220 ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${IceFrc} ${IceFrcFile} ${TMPDIR}/sstoce_fields.nc 221 ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${OceSst} ${OceSstFile} ${TMPDIR}/oce_sst.nc 222 223 ncks --append --fl_fmt=${FL_FMT} --history ${TMPDIR}/oce_sst.nc ${TMPDIR}/sstoce_fields.nc 195 224 if [[ "X${IceAlb}" != "Xnone" ]] ; then 196 ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${IceAlb} ${IceAlbFile} ice_alb.nc197 ncks --append --fl_fmt=${FL_FMT} --history ice_alb.ncsstoce_fields.nc225 ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${IceAlb} ${IceAlbFile} ${TMPDIR}/ice_alb.nc 226 ncks --append --fl_fmt=${FL_FMT} --history ${TMPDIR}/ice_alb.nc ${TMPDIR}/sstoce_fields.nc 198 227 fi 199 228 if [[ "X${IceTem}" != "Xnone" ]] ; then 200 ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${IceTem} ${IceTemFile} ice_tem.nc 201 ncks --append --fl_fmt=${FL_FMT} --history ice_tem.nc sstoce_fields.nc 202 fi 203 ncwa --overwrite --fl_fmt=${FL_FMT} --history --average time_counter sstoce_fields.nc sstoce_fields_notime.nc # Remove time dimension 204 ncatted --history --attribute history,global,d,c,"" sstoce_fields_notime.nc # Clean attributes 229 ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${IceTem} ${IceTemFile} ${TMPDIR}/ice_tem.nc 230 ncks --append --fl_fmt=${FL_FMT} --history ${TMPDIR}/ice_tem.nc ${TMPDIR}/sstoce_fields.nc 231 fi 232 233 # 234 ## Remove time dimension 235 ## =========================================================================== 236 237 ncwa --overwrite --fl_fmt=${FL_FMT} --history --average time_counter ${TMPDIR}/sstoce_fields.nc ${TMPDIR}/sstoce_fields_notime.nc 238 239 # Clean attributes 240 ncatted --history --attribute history,global,d,c,"" ${TMPDIR}/sstoce_fields_notime.nc 205 241 206 242 ## 207 243 ## Find ocean name 208 244 ## =========================================================================== 209 dim_y=$(ncdump -h sstoce_fields_notime.nc | grep "y *=" | grep -v "nvertex" | awk '{print $3}' )210 dim_x=$(ncdump -h sstoce_fields_notime.nc | grep "x *=" | grep -v "nvertex" | awk '{print $3}' )245 dim_y=$(ncdump -h ${TMPDIR}/sstoce_fields_notime.nc | grep "y *=" | grep -v "nvertex" | awk '{print $3}' ) 246 dim_x=$(ncdump -h ${TMPDIR}/sstoce_fields_notime.nc | grep "x *=" | grep -v "nvertex" | awk '{print $3}' ) 211 247 echo ${dim_x} ${dim_y} 212 248 … … 219 255 ## Creates sstoce file 220 256 ## =========================================================================== 221 cat <<EOF > create_sstoce.nco257 cat <<EOF > ${TMPDIR}/create_sstoce.nco 222 258 *OceSst[y,x] = double ( ${OceSst}(:,:) + 273.15d ) ; 223 259 OIceFrc[y,x] = double ( ${IceFrc}(:,:) ) ; … … 226 262 227 263 if [[ "X${IceAlb}" != "Xnone" ]] ; then 228 cat <<EOF >> create_sstoce.nco264 cat <<EOF >> ${TMPDIR}/create_sstoce.nco 229 265 *IceAlb[y,x] = double ( ${IceAlb}(:,:) ) ; 230 266 // 231 267 EOF 232 268 else 233 cat <<EOF >> create_sstoce.nco269 cat <<EOF >> ${TMPDIR}/create_sstoce.nco 234 270 *IceAlb[y,x] = double ( ${DefaultIceAlb}d ) ; 235 271 // … … 238 274 239 275 if [[ "X${IceTem}" != "Xnone" ]] ; then 240 cat <<EOF >> create_sstoce.nco276 cat <<EOF >> ${TMPDIR}/create_sstoce.nco 241 277 *IceTem[y,x] = double ( ${IceTem}(:,:) + 273.15d ) ; 242 278 // 243 279 EOF 244 280 else 245 cat <<EOF >> create_sstoce.nco281 cat <<EOF >> ${TMPDIR}/create_sstoce.nco 246 282 *IceTem[y,x] = double ( ${DefaultIceTem}d + 273.15d ) ; 247 283 // … … 249 285 fi 250 286 251 cat <<EOF >> create_sstoce.nco287 cat <<EOF >> ${TMPDIR}/create_sstoce.nco 252 288 O_SSTSST[y,x] = OceSst (:,:) * (1.0d-OIceFrc(:,:)) ; 253 289 O_AlbIce[y,x] = IceAlb (:,:) * OIceFrc(:,:) ; … … 258 294 EOF 259 295 260 ncap2 --overwrite --fl_fmt=${FL_FMT} --history --script-file create_sstoce.nco sstoce_fields_notime.nc tmp_sstoc.nc 261 ncks --fl_fmt=${FL_FMT} --overwrite --history --variable OIceFrc,O_SSTSST,O_AlbIce,O_TepIce,O_OCurx1,O_OCury1,O_OCurz1 tmp_sstoc.nc sstoc.nc 262 ncatted --history --attribute long_name,O_SSTSST,o,c,"SST weighted by fraction of open ocean" sstoc.nc 263 ncatted --history --attribute long_name,O_AlbIce,o,c,"Albedo weighted by fraction of sea ice" sstoc.nc 264 ncatted --history --attribute long_name,O_TepIce,o,c,"Ice temperature weighted by fraction of sea ice" sstoc.nc 265 266 ncatted --history --attribute comment,O_SSTSST,o,c,"Variable ${OceSst} taken in ${OceSstFile}" sstoc.nc 267 ncatted --history --attribute comment,OIceFrc,o,c,"Variable ${IceFrc} taken in ${IceFrcFile}" sstoc.nc 268 269 if [[ ${IceAlb} = none ]] ; then ncatted --history --attribute comment,O_AlbIce,o,c,"Set to ${DefaultIceAlb}" sstoc.nc 270 else ncatted --history --attribute comment,O_AlbIce,o,c,"Variable ${IceAlb} taken in ${IceAlbFile}" sstoc.nc 271 fi 272 if [[ ${IceTem} = none ]] ; then ncatted --history --attribute comment,O_TepIce,o,c,"Set to ${DefaultIceTem}" sstoc.nc 273 else ncatted --history --attribute comment,O_TepIce,o,c,"Variable ${IceTem} taken in ${IceTemFile}" sstoc.nc 296 ncap2 --overwrite --fl_fmt=${FL_FMT} --history --script-file ${TMPDIR}/create_sstoce.nco ${TMPDIR}/sstoce_fields_notime.nc ${TMPDIR}/tmp_sstoc.nc 297 ncks --fl_fmt=${FL_FMT} --overwrite --history --variable OIceFrc,O_SSTSST,O_AlbIce,O_TepIce,O_OCurx1,O_OCury1,O_OCurz1 ${TMPDIR}/tmp_sstoc.nc ${TMPDIR}/sstoc.nc 298 ncatted --history --attribute long_name,O_SSTSST,o,c,"SST weighted by fraction of open ocean" ${TMPDIR}/sstoc.nc 299 ncatted --history --attribute long_name,O_AlbIce,o,c,"Albedo weighted by fraction of sea ice" ${TMPDIR}/sstoc.nc 300 ncatted --history --attribute long_name,O_TepIce,o,c,"Ice temperature weighted by fraction of sea ice" ${TMPDIR}/sstoc.nc 301 302 ncatted --history --attribute comment,O_SSTSST,o,c,"Variable ${OceSst} taken in ${OceSstFile}" ${TMPDIR}/sstoc.nc 303 ncatted --history --attribute comment,OIceFrc,o,c,"Variable ${IceFrc} taken in ${IceFrcFile}" ${TMPDIR}/sstoc.nc 304 305 if [[ ${IceAlb} = none ]] ; then 306 ncatted --history --attribute comment,O_AlbIce,o,c,"Set to ${DefaultIceAlb}" ${TMPDIR}/sstoc.nc 307 else 308 ncatted --history --attribute comment,O_AlbIce,o,c,"Variable ${IceAlb} taken in ${IceAlbFile}" ${TMPDIR}/sstoc.nc 309 fi 310 311 if [[ ${IceTem} = none ]] ; then 312 ncatted --history --attribute comment,O_TepIce,o,c,"Set to ${DefaultIceTem}" ${TMPDIR}/sstoc.nc 313 else 314 ncatted --history --attribute comment,O_TepIce,o,c,"Variable ${IceTem} taken in ${IceTemFile}" ${TMPDIR}/sstoc.nc 274 315 fi 275 316 … … 278 319 ## =========================================================================== 279 320 if [[ ${Fill} = yes ]] ; then 280 mv sstoc.ncsstoc_nofilled.nc281 python3 FillOceRestart.py --input sstoc_nofilled.nc --outputsstoc.nc ${Nperio}321 mv ${TMPDIR}/sstoc.nc ${TMPDIR}/sstoc_nofilled.nc 322 python3 FillOceRestart.py --input ${TMPDIR}/sstoc_nofilled.nc --output ${TMPDIR}/sstoc.nc ${Nperio} 282 323 fi 283 324 … … 294 335 --attribute Institution,global,o,c,"IPSL https://www.ipsl.fr" \ 295 336 --attribute Model,global,o,c,"${OCE} https://www.nemo-ocean.eu" \ 296 --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}')" \297 337 --attribute originalFiles,global,o,c,"${OceFile} ${IceFile}" \ 298 338 --attribute directory,global,o,c,"$(pwd)" \ … … 313 353 --attribute SVN_Revision,global,o,c,"$Revision$" \ 314 354 --attribute SVN_Id,global,o,c,"$Id$" \ 315 sstoc.nc355 ${TMPDIR}/sstoc.nc 316 356 317 357 ## … … 320 360 #rm -f sstoce_fields.nc sstoce_fields_notime.nc tmp_sstoce.nc oce_fields.nc 321 361 322 mv sstoc.ncsstoc_${OCE}.nc323 324 ## 325 326 echo "TMPDIR : ${TMPDIR}"362 mv ${TMPDIR}/sstoc.nc ${TMPDIR}/sstoc_${OCE}.nc 363 364 ## 365 366 echo ${Blue}"TMPDIR : ${TMPDIR}"${Norm} 327 367 ## =========================================================================== 328 368 ##
Note: See TracChangeset
for help on using the changeset viewer.