Changeset 3639
- Timestamp:
- 03/15/18 10:59:22 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/MOSAIX/CreateWeightsMask.bash
r3632 r3639 45 45 # Defines models 46 46 # ============== 47 OCE=ORCA2.348 #OCE=eORCA1.247 #OCE=ORCA2.3 48 OCE=eORCA1.2 49 49 #OCE=ORCA025 50 50 … … 126 126 ## =========================================================================== 127 127 cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc . 128 cp ${R_IN}/ATM/ ${ATM}/${ATM}_grid.nc .128 cp ${R_IN}/ATM/GRID/${ATM}_grid.nc . 129 129 130 130 ln -s ${OCE}_coordinates_mask.nc oce_grid.nc … … 163 163 where (OceFrac < 0.0 ) OceFrac=0.0 ; 164 164 EOF 165 ncap2 - h--overwrite --script-file correction_masque.nco dia_t${oce}_to_t${atm}_1storder.nc tmp_dia_t${oce}_to_t${atm}_1storder.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder.nc dia_t${oce}_to_t${atm}_1storder.nc166 ncatted - h-a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_1storder.nc165 ncap2 --history --overwrite --script-file correction_masque.nco dia_t${oce}_to_t${atm}_1storder.nc tmp_dia_t${oce}_to_t${atm}_1storder.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder.nc dia_t${oce}_to_t${atm}_1storder.nc 166 ncatted --history -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_1storder.nc 167 167 168 168 ## … … 170 170 ## =========================================================================== 171 171 cp dia_t${oce}_to_t${atm}_1storder.nc dia_t${oce}_to_t${atm}_1storder_mask.nc 172 ncks - h--overwrite -v OceFrac dia_t${oce}_to_t${atm}_1storder_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc173 ncks - h--append -v aire atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc174 [[ ${atm} = *ico* ]] && ncks - h--append -v bounds_lon,bounds_lat atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc172 ncks --alphabetize --history --overwrite -v OceFrac dia_t${oce}_to_t${atm}_1storder_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc 173 ncks --alphabetize --history --append -v aire atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc 174 [[ ${atm} = *ico* ]] && ncks --alphabetize --history --append -v bounds_lon,bounds_lat atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc 175 175 176 176 cat <<EOF > creation_masque.nco … … 178 178 where (OceFrac <= 0.0 ) OceFrac=0 ; 179 179 EOF 180 ncap2 - h--overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_1storder_mask.nc tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc dia_t${oce}_to_t${atm}_1storder_mask.nc181 ncrename - h-v OceFrac,OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc182 183 ncks - h--append -v OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc180 ncap2 --history --overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_1storder_mask.nc tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc dia_t${oce}_to_t${atm}_1storder_mask.nc 181 ncrename --history -v OceFrac,OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc 182 183 ncks --alphabetize --history --append -v OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc 184 184 185 185 … … 263 263 if [[ $(ncdump -k ${InFile}) = *netCDF-4* ]] ; then 264 264 mv ${InFile} tmp_${InFile} 265 ncks -- fl_fmt=${FL_FMT} -htmp_${InFile} ${InFile}265 ncks --alphabetize --fl_fmt=${FL_FMT} --history tmp_${InFile} ${InFile} 266 266 fi 267 267 done … … 277 277 OceMask [time_counter,cell] = OceMask (:) ; 278 278 EOF 279 ncap2 -O - h -Sadd_time.nco ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc280 ncks - O --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}.nc281 ncatted - h\279 ncap2 -O --history --script-file add_time.nco ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 280 ncks --alphabetize -O --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 281 ncatted --history \ 282 282 -a coordinates,OceFrac,c,c,"time_counter cell" \ 283 283 -a coordinates,OceMask,c,c,"time_counter cell" \ … … 290 290 OceMask [time_counter,lat,lon] = OceMask (:,:) ; 291 291 EOF 292 ncap2 -O - h -Sadd_time.nco ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc293 ncks - O --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}.nc294 ncatted - h\292 ncap2 -O --history --script-file add_time.nco ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 293 ncks --alphabetize -O --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 294 ncatted --history \ 295 295 -a coordinates,OceFrac,c,c,"time_counter lat lon" \ 296 296 -a coordinates,OceMask,c,c,"time_counter lat lon" \ … … 306 306 PYTHON_VER=$( python -i -c "import sys ; print (sys.version.split(' ')[0])" ) 307 307 for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ; do 308 ncatted - h\308 ncatted --history \ 309 309 --attribute uuid,global,d,, \ 310 310 --attribute LongName,global,d,, \ … … 354 354 for file in rmp_*${oce}_to_*${atm}_*.nc rmp_*${atm}_to_*${oce}_*.nc ; do 355 355 mv ${file} xios_${file} 356 ncap2 --fl_fmt=${FL_FMT} - h--script-file add_dim.nco xios_${file} ${file}356 ncap2 --fl_fmt=${FL_FMT} --history --script-file add_dim.nco xios_${file} ${file} 357 357 358 ncrename - h--dimension n_weight,num_links ${file}359 ncrename - h--variable src_idx,src_address ${file}360 ncrename - h--variable dst_idx,dst_address ${file}361 ncrename - h--variable weight,remap_matrix ${file}358 ncrename --history --dimension n_weight,num_links ${file} 359 ncrename --history --variable src_idx,src_address ${file} 360 ncrename --history --variable dst_idx,dst_address ${file} 361 ncrename --history --variable weight,remap_matrix ${file} 362 362 case ${file} in 363 ( *1storder.nc ) ncatted - h--attribute map_method,global,o,c,"Conservative Remapping - 1st order" ${file} ;;364 ( *2ndorder.nc ) ncatted - h--attribute map_method,global,o,c,"Conservative Remapping - 2nd order" ${file} ;;363 ( *1storder.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order" ${file} ;; 364 ( *2ndorder.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 2nd order" ${file} ;; 365 365 esac 366 ncatted - h--attribute conventions,global,o,c,"SCRIP" ${file}367 ncatted - h--attribute normalization,global,o,c,"none" ${file}366 ncatted --history --attribute conventions,global,o,c,"SCRIP" ${file} 367 ncatted --history --attribute normalization,global,o,c,"none" ${file} 368 368 369 369 case ${file} in 370 370 ( rmp_*${oce}_to_t${atm}_* ) 371 ncatted - h\371 ncatted --history \ 372 372 --attribute title,global,o,c,"Weights ${OCE} to ${ATM}" \ 373 373 --attribute source_grid,global,o,c,"${oce_domain_type}" \ … … 376 376 ;; 377 377 ( rmp_*${atm}_to_*${oce}_* ) 378 ncatted - h\378 ncatted --history \ 379 379 --attribute title,global,o,c,"Weights ${ATM} to ${OCE}" \ 380 380 --attribute source_grid,global,o,c,"${atm_domain_type}" \ … … 383 383 ;; 384 384 esac 385 done 386 387 ## 388 ## Add missing variables in rmp files 389 ## =========================================================================== 390 for OGRID in ${ListOCEGRID} ; do 391 for order in ${Listorder} ; do 392 ogrid=${OGRID~} 393 agrid=t 394 395 file_o_to_a=rmp_${ogrid}${oce}_to_${agrid}${atm}_${order}order.nc 396 file_a_to_o=rmp_${agrid}${atm}_to_${ogrid}${oce}_${order}order.nc 397 398 cat <<EOF >add_varoce.nco 399 defdim ("src_grid_size" , \$x_grid_${OGRID}.size*\$y_grid_${OGRID}.size) ; 400 defdim ("src_grid_corners", 4) ; 401 defdim ("src_grid_rank" , 2) ; 402 // 403 src_grid_dims[src_grid_rank] = { \$y_grid_${OGRID}.size, \$x_grid_${OGRID}.size } ; 404 // 405 src_grid_center_lat [src_grid_size] = 0.0d ; 406 src_grid_center_lon [src_grid_size] = 0.0d ; 407 src_grid_center_lat (:) = nav_lat_grid_${OGRID}(:,:) ; 408 src_grid_center_lon (:) = nav_lon_grid_${OGRID}(:,:) ; 409 // 410 src_grid_corner_lat [src_grid_size, src_grid_corners] = 0.0d ; 411 src_grid_corner_lon [src_grid_size, src_grid_corners] = 0.0d ; 412 src_grid_corner_lat(:,:) = bounds_lat_grid_${OGRID}(:,:,:) ; 413 src_grid_corner_lon(:,:) = bounds_lon_grid_${OGRID}(:,:,:) ; 414 // 415 src_grid_imask [src_grid_size] = 0 ; 416 src_grid_area [src_grid_size] = 0.0d ; 417 src_grid_frac [src_grid_size] = 1.0d ; 418 src_grid_imask (:) = 1 - mask_${OGRID}(:,:) ; 419 src_grid_imask.int() ; 420 src_grid_area (:) = area_grid_${OGRID}(:,:) ; 421 EOF 422 423 ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${file_o_to_a} 424 sed --in-place "s/src_/dst_/g" add_varoce.nco 425 ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${file_a_to_o} 426 427 if [[ ${atm} = ico ]] ; then 428 cat <<EOF >add_varatm.nco 429 defdim ("dst_grid_size" , \$cell.size) ; 430 defdim ("dst_grid_corners", 6) ; 431 defdim ("dst_grid_rank" , 2) ; 432 // 433 dst_grid_dims[dst_grid_rank] = { \$cell.size, 1 } ; 434 // 435 dst_grid_center_lat [dst_grid_size] = 0.0d ; 436 dst_grid_center_lon [dst_grid_size] = 0.0d ; 437 dst_grid_center_lat (:) = lat(:) ; 438 dst_grid_center_lon (:) = lon(:) ; 439 // 440 dst_grid_corner_lat [dst_grid_size, dst_grid_corners] = 0.0d ; 441 dst_grid_corner_lon [dst_grid_size, dst_grid_corners] = 0.0d ; 442 dst_grid_corner_lat(:,:) = bounds_lat(:,:) ; 443 dst_grid_corner_lon(:,:) = bounds_lon(:,:) ; 444 // 445 dst_grid_imask [dst_grid_size] = 0 ; 446 dst_grid_area [dst_grid_size] = 0.0d ; 447 dst_grid_frac [dst_grid_size] = 1.0d ; 448 dst_grid_imask (:) = 1 - OceMask(0,:) ; 449 dst_grid_imask.int() ; 450 dst_grid_area (:) = aire(:) ; 451 EOF 452 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_o_to_a} 453 sed --in-place "s/dst_/src_/g" add_varatm.nco 454 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_a_to_o} 455 456 ncks --alphabetize --history --overwrite -v 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 ${file_o_to_a} rmp_tmp.nc 457 mv rmp_tmp.nc ${file_o_to_a} 458 ncks --alphabetize --history --overwrite -v 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 ${file_a_to_o} rmp_tmp.nc 459 mv rmp_tmp.nc ${file_a_to_o} 460 461 fi 462 if [[ ${atm} = lmd ]] ; then 463 cat <<EOF >add_varatm.nco 464 defdim ("dst_grid_size" , \$lon.size*\$lat.size) ; 465 defdim ("dst_grid_corners", 4) ; 466 defdim ("dst_grid_rank" , 2) ; 467 // 468 dst_grid_dims[dst_grid_rank] = { \$lat.size, \$lon.size } ; 469 // 470 dst_grid_center_lat [dst_grid_size] = 0.0d ; 471 dst_grid_center_lon [dst_grid_size] = 0.0d ; 472 lat0lon[lat,lon] = lat(:)+0*lon(:) ; 473 lon0lat[lat,lon] = lon(:)+0*lat(:) ; 474 dst_grid_center_lat (:) = lat0lon(:,:) ; 475 dst_grid_center_lon (:) = lon0lat(:,:) ; 476 // 477 //dst_grid_corner_lat [dst_grid_size, dst_grid_corners] = 0.0d ; // Not available for LMDZ lon/lat grid 478 //dst_grid_corner_lon [dst_grid_size, dst_grid_corners] = 0.0d ; 479 //dst_grid_corner_lat(:,:) = bounds_lat(:,:) ; 480 //dst_grid_corner_lon(:,:) = bounds_lon(:,:) ; 481 // 482 dst_grid_imask [dst_grid_size] = 0 ; 483 dst_grid_area [dst_grid_size] = 0.0d ; 484 dst_grid_frac [dst_grid_size] = 1.0d ; 485 dst_grid_imask (:) = 1 - OceMask(0,:,:) ; 486 dst_grid_imask.int() ; 487 dst_grid_area (:) = aire(:,:) ; 488 dst_grid_frac (:) = OceFrac(0,:,:) ; 489 EOF 490 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_o_to_a} 491 sed --in-place "s/dst/src/g" add_varatm.nco 492 ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_a_to_o} 493 494 ncks --alphabetize --history --overwrite -v 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 ${file_o_to_a} rmp_tmp.nc 495 mv rmp_tmp.nc ${file_o_to_a} 496 ncks --alphabetize --history --overwrite -v 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 ${file_a_to_o} rmp_tmp.nc 497 mv rmp_tmp.nc ${file_a_to_o} 498 499 fi 500 done 385 501 done 386 502
Note: See TracChangeset
for help on using the changeset viewer.