Ignore:
Timestamp:
03/29/18 10:56:01 (6 years ago)
Author:
omamce
Message:

O.M. : add computation of runoff weights

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/CreateWeightsMask.bash

    r3686 r3718  
    4848#OCE=ORCA025 
    4949 
    50 ATM=ICO30 
     50#ATM=ICO30 
    5151#ATM=ICO40 
    5252#ATM=ICO450 
    53 #ATM=LMD9695 
     53ATM=LMD9695 
    5454#ATM=LMD144X142 
    5555 
     
    180180ncks --alphabetize --history --append --variable OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc   ${ATM}_grid_maskFrom_${OCE}.nc 
    181181 
     182## 
     183## Create mask of coastal ATM point 
     184## =========================================================================== 
     185cat <<EOF > coastal.nco 
     186AtmCoastal = OceFrac * 0.0 ; 
     187where (OceFrac > 0.0 && OceFrac < 1.0 )  AtmCoastal = 1.0 ; 
     188EOF 
     189ncap2 --history --overwrite --script-file coastal.nco ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_coastal_maskFrom_${OCE}.nc 
     190ncks --history --append --variable AtmCoastal ${ATM}_coastal_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
     191rm ${ATM}_coastal_maskFrom_${OCE}.nc 
    182192 
    183193## 
     
    255265 
    256266## 
     267## ATM towards NEMO points - runoff 
     268## =========================================================================== 
     269cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml           iodef.xml 
     270python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${atm_domain_type} 
     271python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${oce_domain_type} 
     272python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${ATM} coastal mask interpolated to ${OCE}" 
     273python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${atm_domain_type} 
     274python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${oce_domain_type} 
     275python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${atm_domain_type} 
     276python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${oce_domain_type} 
     277python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 
     278python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t 1 
     279python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]'                         -k name  -v ${ATM}_grid_maskFrom_${OCE} 
     280python 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 
     281python 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 
     282python 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.nc 
     283 
     284cp iodef.xml iodef_c${atm}_to_t${oce}_1storder.xml 
     285 
     286time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes 
     287 
     288## 
    257289## Change all NetCDF files to NetCDF 3 format (needed for OASIS) 
    258290## =========================================================================== 
    259291for InFile in *.nc ; do 
    260     if [[ $(ncdump -k ${InFile}) = *netCDF-4* ]] ; then 
    261         mv ${InFile} tmp_${InFile} 
    262         ncks --alphabetize --fl_fmt=${FL_FMT} --history  tmp_${InFile}  ${InFile} 
    263     fi 
     292    mv ${InFile} tmp_${InFile} 
     293    ncks --alphabetize --fl_fmt=${FL_FMT} --history  tmp_${InFile}  ${InFile} 
    264294done 
    265295 
     
    385415## =========================================================================== 
    386416for OGRID in ${ListOCEGRID} ; do 
    387     for order in ${Listorder} ; do 
    388         ogrid=${OGRID~} 
    389         agrid=t 
     417    for AGRID in T C ; do 
     418        for order in ${Listorder} ; do 
     419            ogrid=${OGRID~} 
     420            agrid=${AGRID~} 
    390421         
    391         file_o_to_a=rmp_${ogrid}${oce}_to_${agrid}${atm}_${order}order.nc 
    392         file_a_to_o=rmp_${agrid}${atm}_to_${ogrid}${oce}_${order}order.nc 
    393          
    394         cat <<EOF >add_varoce.nco 
     422            file_o_to_a=rmp_${ogrid}${oce}_to_${agrid}${atm}_${order}order.nc 
     423            file_a_to_o=rmp_${agrid}${atm}_to_${ogrid}${oce}_${order}order.nc 
     424             
     425            cat <<EOF >add_varoce.nco 
    395426defdim ("src_grid_size"   , \$x_grid_${OGRID}.size*\$y_grid_${OGRID}.size) ; 
    396427defdim ("src_grid_corners", 4) ; 
     
    417448EOF 
    418449 
    419         ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${file_o_to_a} 
    420         sed --in-place "s/src_/dst_/g" add_varoce.nco 
    421         ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${file_a_to_o} 
    422  
    423         if [[ ${atm} = ico ]] ; then 
    424             cat <<EOF >add_varatm.nco 
     450            [[ -f ${file_o_to_a} ]] && ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${file_o_to_a} 
     451            sed --in-place "s/src_/dst_/g" add_varoce.nco 
     452            [[ -f ${file_a_to_o} ]] && ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${file_a_to_o} 
     453             
     454            if [[ ${atm} = ico ]] ; then 
     455                cat <<EOF >add_varatm.nco 
    425456defdim ("dst_grid_size"   , \$cell.size) ; 
    426457defdim ("dst_grid_corners", 6) ; 
     
    446477dst_grid_area  (:) = aire(:) ; 
    447478EOF 
    448             ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_o_to_a} 
    449             sed --in-place "s/dst_/src_/g" add_varatm.nco 
    450             ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_a_to_o} 
    451              
    452             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 ${file_o_to_a} rmp_tmp.nc 
    453             mv rmp_tmp.nc ${file_o_to_a} 
    454             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 ${file_a_to_o} rmp_tmp.nc 
    455             mv rmp_tmp.nc ${file_a_to_o} 
    456  
    457         fi 
    458         if [[ ${atm} = lmd ]] ; then 
    459             cat <<EOF >add_varatm.nco 
     479                if [[ -f ${file_o_to_a} ]] ; then 
     480                    ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_o_to_a} 
     481                    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 ${file_o_to_a} rmp_tmp.nc 
     482                    mv rmp_tmp.nc ${file_o_to_a} 
     483                fi 
     484                     
     485                sed --in-place "s/dst_/src_/g" add_varatm.nco 
     486                if [[ -f ${file_a_to_o} ]] ; then 
     487                    ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_a_to_o} 
     488                    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 ${file_a_to_o} rmp_tmp.nc 
     489                    mv rmp_tmp.nc ${file_a_to_o} 
     490                fi 
     491            fi 
     492            if [[ ${atm} = lmd ]] ; then 
     493                cat <<EOF >add_varatm.nco 
    460494defdim ("dst_grid_size"   , \$lon.size*\$lat.size) ; 
    461495defdim ("dst_grid_corners", 4) ; 
     
    484518dst_grid_frac (:)  = OceFrac(0,:,:) ; 
    485519EOF 
    486             ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_o_to_a} 
    487             sed --in-place "s/dst/src/g" add_varatm.nco 
    488             ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_a_to_o} 
    489  
    490             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 ${file_o_to_a} rmp_tmp.nc 
    491             mv rmp_tmp.nc ${file_o_to_a} 
    492             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 ${file_a_to_o} rmp_tmp.nc 
    493             mv rmp_tmp.nc ${file_a_to_o} 
    494  
    495         fi 
     520                if [[ -f ${file_o_to_a} ]] ; then 
     521                    ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_o_to_a} 
     522                    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 ${file_o_to_a} rmp_tmp.nc 
     523                    mv rmp_tmp.nc ${file_o_to_a} 
     524                fi 
     525                 
     526                sed --in-place "s/dst/src/g" add_varatm.nco 
     527                if [[ -f ${file_a_to_o} ]] ; then 
     528                    ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_a_to_o} 
     529                    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 ${file_a_to_o} rmp_tmp.nc 
     530                    mv rmp_tmp.nc ${file_a_to_o} 
     531                fi 
     532            fi 
     533        done 
    496534    done 
    497535done 
     
    501539## =========================================================================== 
    502540cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR} 
     541 
     542cp rmp_c${atm}_to_t${oce}_${order}order.nc ${SUBMIT_DIR}/rmp_c${ATM}_to_t${OCE}_1storder.nc 
     543cp dia_c${atm}_to_t${oce}_${order}order.nc ${SUBMIT_DIR}/dia_c${ATM}_to_t${OCE}_1storder.nc 
     544 
    503545for order in ${Listorder} 
    504546do 
    505547    cp dia_t${oce}_to_t${atm}_${order}order.nc ${SUBMIT_DIR}/dia_t${OCE}_to_t${ATM}_${order}order.nc 
    506548    cp rmp_t${oce}_to_t${atm}_${order}order.nc ${SUBMIT_DIR}/rmp_t${OCE}_to_t${ATM}_${order}order.nc 
     549   
    507550    for grid in ${Listocegrid} ; do 
    508551        cp rmp_t${atm}_to_${grid}${oce}_${order}order.nc ${SUBMIT_DIR}/rmp_t${ATM}_to_${grid}${OCE}_${order}order.nc 
Note: See TracChangeset for help on using the changeset viewer.