Changeset 3901
- Timestamp:
- 06/07/18 15:59:11 (6 years ago)
- Location:
- TOOLS/MOSAIX
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/MOSAIX/ComputeNemoCoast.py
r3725 r3901 27 27 28 28 def usage () : 29 texte = """%(prog)s usage : 30 python %(prog)s [-d] [-i <orca grid file>] [-n <perio>] 29 texte = """Compute a mask for coastal point of NEMO domain 30 31 %(prog)s usage : 32 python %(prog)s [-h|--help] [-d|--debug] [-i <orca grid file>] [-n <perio>] 31 33 -d | --debug : debug 32 34 -i <file> | --input=<file> : input file (default: none) … … 49 51 ## Command line options 50 52 try: 51 myopts, myargs = getopt.getopt ( sys.argv[1:], 'i:n:h', [ 'input=', 'nperio=', 'debug=', ' --help' ] )53 myopts, myargs = getopt.getopt ( sys.argv[1:], 'i:n:h', [ 'input=', 'nperio=', 'debug=', 'help' ] ) 52 54 except getopt.GetoptError as cmdle : 53 55 print ( "Command line error : "+str(cmdle)+"\n" ) … … 66 68 sys.exit(-1) 67 69 68 print ("Input file :" + GridFile)70 print ("Input file : " + GridFile) 69 71 70 72 ## Open grid file … … 115 117 print ("Maximum number of neighbors : "+str(CoastCrit) ) 116 118 117 118 Temp = nemo.lbc ( Temp, nperio=4, cd_type='T' ) 119 Temp = nemo.lbc ( Temp, nperio=nperio, cd_type='T' ) 119 120 120 121 OceCoastal = np.where (OceMask == 1, True, False) * np.where (Temp < CoastCrit, True, False) -
TOOLS/MOSAIX/CreateOasisGrids.bash
r3718 r3901 44 44 # Defines computer 45 45 # ================ 46 if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi 47 if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi 46 if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi 47 if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi 48 if [[ $(hostname) = lsce3005* ]] ; then arch=spip ; center=spip ; fi 49 48 50 PROGRAM=$(basename ${0}) 49 51 … … 60 62 SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 61 63 ;; 62 ( * ) 63 exit -1 64 ;; 64 ( spip ) 65 R_IN=${HOME}/Scratch/IGCM 66 TMPDIR=${HOME}/Scratch/TMP 67 SUBMIT_DIR=$(pwd) 68 MPIRUN=/opt/local/bin/mpirun-openmpi-gcc49 -n 2 69 ;; 70 ( * ) exit -1 ;; 65 71 esac 72 66 73 ## 67 74 ## Command line parameters … … 112 119 # Format for OASIS-MCT files : should be NetCDF3 classic or NetCDF3 64 bits 113 120 # --------------------------------------------------------------------------- 114 FL_FMT =64bit121 FL_FMT3=64bit 115 122 116 123 # … … 123 130 # Creates NetCDF3 version of input files 124 131 # ---------------------------------------------------------------------------- 125 ncks --overwrite --fl_fmt=${FL_FMT} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FL_FMT}.nc 126 ncks --overwrite --fl_fmt=${FL_FMT} --history ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc 132 ncks --overwrite --fl_fmt=${FL_FMT} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FL_FMT3}.nc 133 ncks --overwrite --fl_fmt=${FL_FMT} --history ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc 134 135 127 136 # 128 137 # Creates ocean fields 129 138 # ---------------------------------------------------------------------------- 130 131 for OCEGRID in T U V ; do 132 ncks --fl_fmt=${FL_FMT} -C --history --append --variable nav_lon_grid_${OCEGRID},nav_lat_grid_${OCEGRID},bounds_lon_grid_${OCEGRID},bounds_lat_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc grids_${CplModel}.nc 133 ncks --fl_fmt=${FL_FMT} -C --history --append --variable area_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc areas_${CplModel}.nc 139 for OCEGRID in T U V C ; do 140 ncks --fl_fmt=${FL_FMT3} -C --history --append --variable nav_lon_grid_${OCEGRID},nav_lat_grid_${OCEGRID},bounds_lon_grid_${OCEGRID},bounds_lat_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT3}.nc grids_${CplModel}.nc 141 ncks --fl_fmt=${FL_FMT3} -C --history --append --variable area_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT3}.nc areas_${CplModel}.nc 134 142 # Inverts mask values and switch to integer 135 ncks --fl_fmt=${FL_FMT } --history -C --variable mask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc mask_${OCEGRID}_tmp.nc143 ncks --fl_fmt=${FL_FMT33} --history -C --variable mask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT3}.nc mask_${OCEGRID}_tmp.nc 136 144 ncatted --history \ 137 145 --attribute coordinates,mask_${OCEGRID},d,, \ … … 140 148 mask_${OCEGRID}_tmp.nc 141 149 142 ncap2 --fl_fmt=${FL_FMT} --history --append --script "mask_${OCEGRID}=int(1-mask_${OCEGRID});" mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc 150 ncap2 --fl_fmt=${FL_FMT3} --history --append --script "mask_${OCEGRID}=int(1-mask_${OCEGRID});" mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc 151 rm mask_${OCEGRID}_tmp.nc 143 152 ncatted --history \ 144 153 --attribute long_name,mask_${OCEGRID},o,c,"Land-sea mask" \ … … 147 156 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 148 157 ncpdq --permute nvertex_grid_${OCEGRID},y_grid_${OCEGRID},x_grid_${OCEGRID} grids_${CplModel}_tmp.nc grids_${CplModel}.nc 149 done 150 151 ncks --history --append --variable lon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc 152 158 rm grids_${CplModel}_tmp.nc 159 done 160 161 ncks --history --append --variable lon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc grids_${CplModel}.nc 162 153 163 # 154 164 # We need to have different names for dimensions and variables … … 158 168 159 169 if [[ ${ATM} = dynamico* || ${ATM} = ICO* ]] ; then 160 ncks --fl_fmt=${FL_FMT } --history --append --variable bounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc170 ncks --fl_fmt=${FL_FMT3} --history --append --variable bounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc grids_${CplModel}.nc 161 171 fi 162 172 163 ncks --fl_fmt=${FL_FMT } --history -C --append --variable aire ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc areas_${CplModel}.nc173 ncks --fl_fmt=${FL_FMT3} --history -C --append --variable aire ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc areas_${CplModel}.nc 164 174 ncatted --history --attribute coordinates,aire,d,, \ 165 175 --attribute _FillValue,aire,d,, \ … … 170 180 areas_${CplModel}.nc 171 181 172 ncks --fl_fmt=${FL_FMT } --history -C --variable OceMask ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc OceMask_tmp.nc182 ncks --fl_fmt=${FL_FMT3} --history -C --variable OceMask ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc OceMask_tmp.nc 173 183 ncatted --history \ 174 184 --attribute coordinates,OceMask,d,, \ … … 177 187 --attribute missing_value,OceMask,d,, \ 178 188 OceMask_tmp.nc 179 ncap2 --fl_fmt=${FL_FMT} --history --append --script "OceMask=int(1-OceMask)" OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 189 ncap2 --fl_fmt=${FL_FMT3} --history --append --script "OceMask=int(1-OceMask)" OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 190 rm OceMask_tmp.nc 180 191 ncatted --history \ 181 192 --attribute long_name,OceMask,o,c,"Land-sea mask" \ … … 220 231 EOF 221 232 222 ncap2 --fl_fmt=${FL_FMT } --history --append --script-file add_dim.nco grids_${CplModel}_tmp.nc grids_${CplModel}.nc233 ncap2 --fl_fmt=${FL_FMT3} --history --append --script-file add_dim.nco grids_${CplModel}_tmp.nc grids_${CplModel}.nc 223 234 224 235 mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 225 ncap2 --fl_fmt=${FL_FMT } --history --append --script 'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)' masks_${CplModel}_tmp.nc masks_${CplModel}.nc236 ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)' masks_${CplModel}_tmp.nc masks_${CplModel}.nc 226 237 227 238 mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 228 ncap2 --fl_fmt=${FL_FMT} --history --append --script 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; ' areas_${CplModel}_tmp.nc areas_${CplModel}.nc 239 ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; ' areas_${CplModel}_tmp.nc areas_${CplModel}.nc 240 241 rm -f grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc masks_${CplModel}_tmp.nc 229 242 fi 230 243 … … 236 249 # ----------------------------------------------------------------------- 237 250 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 238 ncap2 --fl_fmt=${FL_FMT} --history --append --script "alon[lat,lon]=alon; alat[lat,lon]=alat" grids_${CplModel}_tmp.nc grids_${CplModel}.nc 251 ncap2 --fl_fmt=${FL_FMT3} --history --append --script "alon[lat,lon]=alon; alat[lat,lon]=alat" grids_${CplModel}_tmp.nc grids_${CplModel}.nc 252 rm -f grids_${CplModel}_tmp.nc 239 253 ncatted --history \ 240 254 --attribute long_name,alon,o,c,"Longitude" \ … … 271 285 EOF 272 286 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 273 ncap2 --fl_fmt=${FL_FMT} --history --script-file add_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc 287 ncap2 --fl_fmt=${FL_FMT3} --history --script-file add_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc 288 rm grids_${CplModel}_tmp.nc 274 289 fi 275 290 276 291 # 277 # Generates grid "o${atm} e": same as t${atm} grid, with surfaces set to 1292 # Generates grid "o${atm}", "o" meaning "one": same as t${atm} grid, with surfaces set to 1 278 293 # and mask to 0 (ocean everywhere, to compute integral over the whole grid)) 279 294 # This grid is used when field are quantities instead of fluxes (i.e river flow) 280 295 # ---------------------------------------------------------------------------- 281 296 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 282 ncap2 --fl_fmt=${FL_FMT } --history --script "o${atm}_lon=alon; o${atm}_lat=alat; bounds_o${atm}_lon=bounds_lon; bounds_o${atm}_lat=bounds_lat; " grids_${CplModel}_tmp.nc grids_${CplModel}.nc297 ncap2 --fl_fmt=${FL_FMT3} --history --script "o${atm}_lon=alon; o${atm}_lat=alat; bounds_o${atm}_lon=bounds_lon; bounds_o${atm}_lat=bounds_lat; " grids_${CplModel}_tmp.nc grids_${CplModel}.nc 283 298 284 299 mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 285 ncap2 --fl_fmt=${FL_FMT } --history --script "o${atm}_aire=aire*0.0d+1.0d; " areas_${CplModel}_tmp.nc areas_${CplModel}.nc300 ncap2 --fl_fmt=${FL_FMT3} --history --script "o${atm}_aire=aire*0.0d+1.0d; " areas_${CplModel}_tmp.nc areas_${CplModel}.nc 286 301 287 302 mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 288 ncap2 --fl_fmt=${FL_FMT} --history --script "o${atm}_mask=int(OceMask)*0+0; " masks_${CplModel}_tmp.nc masks_${CplModel}.nc 303 ncap2 --fl_fmt=${FL_FMT3} --history --script "o${atm}_mask=int(OceMask)*0+0; " masks_${CplModel}_tmp.nc masks_${CplModel}.nc 304 305 rm grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc masks_${CplModel}_tmp.nc 289 306 290 307 # 291 308 # Final renaming 292 309 # ---------------------------------------------------------------------------- 293 for OCEGRID in T U V 310 for OCEGRID in T U V C 294 311 do 295 312 ocegrid=${OCEGRID~} # To lowercase … … 336 353 if [[ $(ncdump -k ${InFile}) = *netCDF-4* ]] ; then 337 354 mv ${InFile} tmp_${InFile} 338 ncks --fl_fmt=${FL_FMT} --history tmp_${InFile} ${InFile} 355 ncks --fl_fmt=${FL_FMT3} --history tmp_${InFile} ${InFile} 356 rm tmp_${InFile} 339 357 fi 340 358 done … … 384 402 ## Cleaning 385 403 ## =========================================================================== 386 #rm *_tmp.nc ${OCE}_coordinates_mask_${FL_FMT }.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc *.nco404 #rm *_tmp.nc ${OCE}_coordinates_mask_${FL_FMT3}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc *.nco 387 405 388 406 exit … … 390 408 # Name of the dimensions ? 391 409 # ---------------------------------------------------------------------------- 392 for OCEGRID in T U V ; do410 for OCEGRID in T U V C ; do 393 411 ocegrid=${OCEGRID~} # Downcase name of grids 394 412 ncrename --history --dimension x_grid_${OCEGRID},x${ocegrid}${oce} grids_${CplModel}.nc -
TOOLS/MOSAIX/CreateWeightsMask.bash
r3734 r3901 36 36 # $Id$ 37 37 # $HeadURL$ 38 export Bold=$(tput bold) 39 export Unde=$(tput smul) ; export OffUnde=$(tput rmul) 40 export Stou=$(tput smso) ; export OffStou=$(tput rmso) 41 export Reve=$(tput rev ) 42 couleurs=( "Black" "Blue" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" ) 43 for i in $(seq 0 7 ) ; do eval "export ${couleurs[$i]}=$(tput setf $i)" ; done 44 export Norm=$(tput sgr0 ) 38 45 39 46 ## … … 58 65 # =========================== 59 66 ListOCEGRID="T U V" 60 ListOrder="1st" # " 2nd67 ListOrder="1st" # 2nd" 61 68 ListNormalize="false true" 62 69 … … 71 78 # Defines computer 72 79 # ================ 73 if [[ $(hostname) = curie* ]]; then arch=curie ; center=tgcc ; fi74 if [[ $(hostname) = irene* ]]; then arch=irene ; center=tgcc ; fi80 if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi 81 if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi 75 82 if [[ $(hostname) = lsce3005* ]] ; then arch=spip ; center=spip ; fi 76 83 … … 95 102 MPIRUN=/opt/local/bin/mpirun-openmpi-gcc49 -n 2 96 103 ;; 97 ( * ) 98 exit -1 99 ;; 104 ( * ) exit -1 ;; 100 105 esac 101 106 … … 127 132 # Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits 128 133 # --------------------------------------------------------------------------- 129 FL_FMT=64bit 134 FMT_OASIS=64bit 135 FMT_XIOS=netcdf4 130 136 131 137 … … 133 139 cp ${SUBMIT_DIR}/*.py . 134 140 135 ## 136 ## NEMO T point towards ATM - 1st order 137 ## =========================================================================== 141 138 142 cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc . 139 143 cp ${R_IN}/ATM/GRID/${ATM}_grid.nc . 140 144 141 ln -s ${OCE}_coordinates_mask.nc oce_grid.nc 142 ln -s ${ATM}_grid.nc atm_grid.nc 143 145 ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc 146 ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${ATM}_grid.nc ${ATM}_grid_${FMT_OASIS}.nc 147 # 148 # Creates OCEAN C grid : redundant point removed to compute proper integrals # A passer dans CreateWeights 149 # ---------------------------------------------------------------------------- 150 cat <<EOF >add_c_grid.nco 151 nav_lon_grid_C = nav_lon_grid_T ; 152 nav_lat_grid_C = nav_lat_grid_T ; 153 bounds_lon_grid_C = bounds_lon_grid_T ; 154 bounds_lat_grid_C = bounds_lat_grid_T ; 155 area_grid_C = area_grid_T ; 156 mask_C = maskutil_T ; 157 EOF 158 159 ncap2 --overwrite --history --script-file add_c_grid.nco ${OCE}_coordinates_mask.nc tmp_${OCE}_coordinates_mask.nc 160 ncks --overwrite --variable nav_lon_grid_C,nav_lat_grid_C,bounds_lon_grid_C,bounds_lat_grid_C,area_grid_C,mask_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc 161 rm tmp_${OCE}_coordinates_mask_${FMT_OASIS}.nc 162 ncrename --dimension x_grid_T,x_grid_C C_${OCE}_coordinates_mask.nc 163 ncrename --dimension y_grid_T,y_grid_C C_${OCE}_coordinates_mask.nc 164 ncrename --dimension nvertex_grid_T,nvertex_grid_C C_${OCE}_coordinates_mask.nc 165 ncks --append C_${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask.nc 166 rm C_${OCE}_coordinates_mask.nc 167 168 ncks --overwrite --fl_fmt=${FMT_OASIS} --history {OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FMT_OASIS}.nc 169 170 ls -al 171 172 ## 173 ## NEMO T point towards ATM - 1st order 174 ## =========================================================================== 144 175 echo ${Green}"${OCE} T toward ${ATM} - 1storder"${Norm} 145 176 cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml iodef.xml … … 162 193 163 194 cp iodef.xml iodef_t${oce}_to_t${atm}_1storder_false.xml 195 ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc 196 ln -fs ${ATM}_grid.nc atm_grid.nc 164 197 165 198 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=no … … 197 230 rm dia_t${oce}_to_t${atm}_1storder_false_mask.nc 198 231 199 ## 200 ## Creates mask of coastal OCE points 201 ## =========================================================================== 202 python ComputeNemoCoast.py -n ${OcePerio} -i oce_grid.nc 203 204 ## 205 ## Creates mask of coastal ATM points 206 ## =========================================================================== 207 cat <<EOF > coastal.nco 208 AtmCoastal = OceFrac * 0.0 ; 209 where (OceFrac > 0.0 && OceFrac < 1.0 ) AtmCoastal = 1.0 ; 210 EOF 211 ncap2 --history --overwrite --script-file coastal.nco ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_coastal_maskFrom_${OCE}.nc 212 ncks --history --append --variable AtmCoastal ${ATM}_coastal_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 213 rm ${ATM}_coastal_maskFrom_${OCE}.nc 232 214 233 215 234 ## … … 247 266 cp iodef.xml iodef_${ocegrid}${oce}_t${atm}_${order}order_${normalize}.xml 248 267 268 ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc 269 ln -fs ${ATM}_grid.nc atm_grid.nc 249 270 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 250 271 fi … … 288 309 cp iodef.xml iodef_t${atm}_to_${ocegrid}${oce}_${order}order_${normalize}.xml 289 310 311 ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc 312 ln -fs ${ATM}_grid.nc atm_grid.nc 290 313 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 291 314 … … 294 317 done 295 318 319 ## 320 ## Creates mask of coastal OCE points 321 ## =========================================================================== 322 python ComputeNemoCoast.py -n ${OcePerio} -i ${OCE}_coordinates_mask.nc # Creates OceCoastal 323 ## 324 ## Creates mask of coastal ATM points 325 ## =========================================================================== 326 cat <<EOF > coastal.nco 327 AtmCoastal = OceFrac * 0.0 ; 328 where (OceFrac > 0.0 && OceFrac < 1.0 ) AtmCoastal = 1.0 ; 329 EOF 330 ncap2 --history --overwrite --script-file coastal.nco ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_coastal_maskFrom_${OCE}.nc 331 ncks --history --append --variable AtmCoastal ${ATM}_coastal_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 332 rm ${ATM}_coastal_maskFrom_${OCE}.nc 333 ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 296 334 ## 297 335 ## ATM towards NEMO points - runoff … … 312 350 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]' -k name -v AtmCoastal 313 351 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_dst"]/field[@id="mask_dst"]' -k name -v OceCoastal 314 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]' -k name -v dia_ c${atm}_to_t${oce}_1storder_${normalize}315 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_ c${atm}_to_t${oce}_1storder_${normalize}.nc352 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]' -k name -v dia_o${atm}_to_c${oce}_1storder_${normalize} 353 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_o${atm}_to_c${oce}_1storder_${normalize}.nc 316 354 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v ${normalize} 317 355 318 cp iodef.xml iodef_ c${atm}_to_t${oce}_1storder_${normalize}.xml356 cp iodef.xml iodef_o${atm}_to_c${oce}_1storder_${normalize}.xml 319 357 358 ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc 359 ln -fs ${ATM}_grid.nc atm_grid.nc 320 360 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 321 done 322 ## 323 ## Change all NetCDF files to NetCDF 3 format (needed for OASIS) 361 362 # Now we should divide weight par source (atm) grid area : run-off is a quantity/s integrated on the grid mox, not a flux 363 done 364 ## 365 ## Copy all NetCDF files to NetCDF 3 format (needed for OASIS) 324 366 ## =========================================================================== 325 367 for InFile in *.nc ; do 326 mv ${InFile} tmp_${InFile} 327 ncks --alphabetize --fl_fmt=${FL_FMT} --history tmp_${InFile} ${InFile} 368 OuFile=$(basename ${InFile} .nc)_${FMT_OASIS}.nc 369 if [[ ! -f ${OuFile} ]] ; then 370 ncks --alphabetize --history --fl_fmt=${FMT_OASIS} ${InFile} ${OuFile} 371 fi 328 372 done 329 373 … … 334 378 #ncatted --history -a coordinates,aire,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc 335 379 ncap2 --overwrite --history --script 'defdim("time_counter",1) ;' ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 380 ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 336 381 337 382 if [[ ${atm} = ico ]] ; then … … 349 394 ${ATM}_grid_maskFrom_${OCE}.nc 350 395 fi 396 ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 397 351 398 if [[ ${atm} = lmd ]] ; then 352 399 cat <<EOF > add_time.nco … … 364 411 fi 365 412 ncks --alphabetize --overwrite --mk_rec time_counter ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 366 413 ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 367 414 368 415 ## … … 373 420 NCO="$(ncks --version |& tail -1|sed 's/ncks //')" 374 421 PYTHON_VER=$( python -i -c "import sys ; print (sys.version.split(' ')[0])" ) 375 for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ; do422 for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc; do 376 423 ncatted --history \ 377 424 --attribute uuid,global,d,, \ … … 421 468 for rmpFile in rmp_*.nc ; do 422 469 mv ${rmpFile} xios_${rmpFile} 423 ncap2 --fl_fmt=${F L_FMT} --history --script-file add_dim.nco xios_${rmpFile} ${rmpFile}470 ncap2 --fl_fmt=${FMT_OASIS} --history --script-file add_dim.nco xios_${rmpFile} ${rmpFile} 424 471 425 472 ncrename --history --dimension n_weight,num_links ${rmpFile} … … 460 507 ## =========================================================================== 461 508 for rmpFile in rmp_* ; do 509 echo ${rmpFile} 462 510 a_to_o=false ; o_to_a=false 463 511 case ${rmpFile} in … … 466 514 esac 467 515 468 for Grid in t u v c ; do # Identify grids 469 case ${rmpFile} in 470 ( rmp_${Grid}${oce}_to_?${atm}_*.nc ) ogrid=${Grid} ;; 471 ( rmp_?${oce}_to_${Grid}${atm}_*.nc ) agrid=${Grid} ;; 472 ( rmp_${Grid}${atm}_to_?${oce}_*.nc ) agrid=${Grid} ;; 473 ( rmp_?${atm}_to_${Grid}${oce}_*.nc ) ogrid=${Grid} ;; 474 esac 516 for Grid in t u v o c ; do # Identify grids 517 [[ ${rmpFile} = rmp_${Grid}${oce}_to_?${atm}_*.nc ]] && ogrid=${Grid} 518 [[ ${rmpFile} = rmp_?${oce}_to_${Grid}${atm}_*.nc ]] && agrid=${Grid} 519 [[ ${rmpFile} = rmp_${Grid}${atm}_to_?${oce}_*.nc ]] && agrid=${Grid} 520 [[ ${rmpFile} = rmp_?${atm}_to_${Grid}${oce}_*.nc ]] && ogrid=${Grid} 475 521 done 476 522 OGRID=${ogrid^} … … 502 548 EOF 503 549 504 [[ ${o_to_a} = true ]] && ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${rmpFile}550 [[ ${o_to_a} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile} 505 551 sed --in-place "s/src_/dst_/g" add_varoce.nco 506 [[ ${a_to_o} = true ]] && ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${rmpFile}552 [[ ${a_to_o} = true ]] && ncap2 --history --append --script-file add_varoce.nco ${OCE}_coordinates_mask_${FMT_OASIS}.nc ${rmpFile} 507 553 508 554 if [[ ${atm} = ico ]] ; then … … 532 578 EOF 533 579 if [[ ${o_to_a} = true ]] ; then 534 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE} .nc ${rmpFile}580 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 535 581 ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 536 582 mv rmp_tmp.nc ${rmpFile} … … 539 585 sed --in-place "s/dst_/src_/g" add_varatm.nco 540 586 if [[ ${a_to_o} = true ]] ; then 541 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE} .nc ${rmpFile}587 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 542 588 ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 543 589 mv rmp_tmp.nc ${rmpFile} … … 573 619 EOF 574 620 if [[ ${o_to_a} = true ]] ; then 575 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE} .nc ${rmpFile}621 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 576 622 ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 577 623 mv rmp_tmp.nc ${rmpFile} … … 580 626 sed --in-place "s/dst/src/g" add_varatm.nco 581 627 if [[ ${a_to_o} = true ]] ; then 582 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE} .nc ${rmpFile}628 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc ${rmpFile} 583 629 ncks --alphabetize --history --overwrite --variable src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${rmpFile} rmp_tmp.nc 584 630 mv rmp_tmp.nc ${rmpFile} … … 586 632 fi 587 633 done 588 634 ls -al ${OCE}_coordinates_mask.nc 589 635 ## 590 636 ## Save results
Note: See TracChangeset
for help on using the changeset viewer.