Changeset 3719


Ignore:
Timestamp:
03/29/18 14:46:17 (6 years ago)
Author:
omamce
Message:

O.M. : add normalization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/CreateWeightsMask.bash

    r3718 r3719  
    11#!/bin/bash 
    2 #MSUB -r WeightsMask        # nom de la requete 
    3 #MSUB -o Out_WeightsMask    # nom du fichier de sortie 
    4 #MSUB -e Out_WeightsMask    # nom du fichier de sortie 
     2#MSUB -r WeightsMask        # Job name 
     3#MSUB -o Out_WeightsMask    # Standard output 
     4#MSUB -e Out_WeightsMask    # Error output 
    55#MSUB -eo 
    6 #MSUB -n 4              # Reservation des processeurs pour le job 
    7 #MSUB -T 1800           # Limite temps (en secondes) 
     6#MSUB -n 4              # Number of processors 
     7#MSUB -T 1800           # Time limit (seconds) 
    88#MSUB -q standard 
    99#MSUB -Q test 
     
    1212### =========================================================================== 
    1313### 
    14 ### Creates interpolation weights between ORCA and atmospher grids. 
     14### Creates interpolation weights between ORCA and atmosphere grids. 
    1515### Interpolates ORCA mask to atmosphere grid. 
    1616### Weight files are at OASIS-MCT format. 
     
    5858# =========================== 
    5959ListOCEGRID="T U V" 
    60 Listorder="1st" # " 2nd 
     60ListOrder="1st" # " 2nd 
     61ListNormalize="false true" 
    6162 
    6263## =========================================================================== 
     
    99100# Suffixes 
    100101# --------------------------------------------------------------------------- 
    101 Listocegrid=${ListOCEGRID~} 
     102Listocegrid=${ListOCEGRID,,} 
    102103 
    103104case ${OCE} in 
     
    135136python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${atm_domain_type} 
    136137python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name  -v maskutil_T 
    137 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_t${oce}_to_t${atm}_1storder 
     138python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_t${oce}_to_t${atm}_1storder_false 
    138139python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${OCE} mask interpolated to ${ATM}" 
    139140python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${oce_domain_type} 
     
    142143python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${oce_domain_type} 
    143144python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${atm_domain_type} 
    144 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_t${oce}_to_t${atm}_1storder.nc 
     145python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_t${oce}_to_t${atm}_1storder_false.nc 
    145146python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 
    146  
    147 cp iodef.xml iodef_t${oce}_to_t${atm}_1storder.xml 
     147python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false 
     148python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize -v false 
     149 
     150cp iodef.xml iodef_t${oce}_to_t${atm}_1storder_false.xml 
    148151 
    149152time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=no 
     
    160163where (OceFrac <  0.0 )  OceFrac=0.0 ;  
    161164EOF 
    162 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 
    163 ncatted --history -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_1storder.nc 
     165ncap2 --history --overwrite --script-file correction_masque.nco dia_t${oce}_to_t${atm}_1storder_false.nc tmp_dia_t${oce}_to_t${atm}_1storder_false.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder_false.nc dia_t${oce}_to_t${atm}_1storder_false.nc 
     166ncatted --history -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_1storder_false.nc 
    164167 
    165168## 
    166169##  Creates mask on ATM grid 
    167170## =========================================================================== 
    168 cp dia_t${oce}_to_t${atm}_1storder.nc  dia_t${oce}_to_t${atm}_1storder_mask.nc 
    169 ncks --alphabetize --history --overwrite --variable OceFrac dia_t${oce}_to_t${atm}_1storder_mask.nc  ${ATM}_grid_maskFrom_${OCE}.nc 
    170 ncks --alphabetize --history --append    --variable aire    atm_grid.nc                              ${ATM}_grid_maskFrom_${OCE}.nc 
    171 [[ ${atm} = *ico* ]] && ncks --alphabetize --history --append --variable bounds_lon,bounds_lat atm_grid.nc                              ${ATM}_grid_maskFrom_${OCE}.nc 
     171cp dia_t${oce}_to_t${atm}_1storder_false.nc  dia_t${oce}_to_t${atm}_1storder_false_mask.nc 
     172ncks --alphabetize --history --overwrite --variable OceFrac dia_t${oce}_to_t${atm}_1storder_false_mask.nc  ${ATM}_grid_maskFrom_${OCE}.nc 
     173ncks --alphabetize --history --append    --variable aire    atm_grid.nc                                    ${ATM}_grid_maskFrom_${OCE}.nc 
     174[[ ${atm} = *ico* ]] && ncks --alphabetize --history --append --variable bounds_lon,bounds_lat atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc 
    172175 
    173176cat <<EOF > creation_masque.nco 
     
    175178where (OceFrac <= 0.0 )  OceFrac=0 ; 
    176179EOF 
    177 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 
    178 ncrename --history --variable OceFrac,OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc 
    179  
    180 ncks --alphabetize --history --append --variable OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc   ${ATM}_grid_maskFrom_${OCE}.nc 
    181  
    182 ## 
    183 ## Create mask of coastal ATM point 
     180ncap2 --history --overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_1storder_false_mask.nc tmp_dia_t${oce}_to_t${atm}_1storder_false_mask.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder_false_mask.nc dia_t${oce}_to_t${atm}_1storder_false_mask.nc 
     181ncrename --history --variable OceFrac,OceMask dia_t${oce}_to_t${atm}_1storder_false_mask.nc 
     182 
     183ncks --alphabetize --history --append --variable OceMask dia_t${oce}_to_t${atm}_1storder_false_mask.nc   ${ATM}_grid_maskFrom_${OCE}.nc 
     184#rm dia_t${oce}_to_t${atm}_1storder_false_mask.nc 
     185 
     186## 
     187## Creates mask of coastal ATM point 
    184188## =========================================================================== 
    185189cat <<EOF > coastal.nco 
     
    194198## NEMO, other case, towards ATM  
    195199## =========================================================================== 
    196 for order in ${Listorder} ; do 
     200for order in ${ListOrder} ; do 
    197201    case ${order} in 
    198202        ( 1st ) num_order=1 ;; 
    199203        ( 2nd ) num_order=2 ;; 
    200204    esac 
    201      
    202     for OCEGRID in ${ListOCEGRID} ; do 
    203         ocegrid=${OCEGRID~} 
    204  
    205         if [[ !( ${order} = 1st && ${OCEGRID} = T ) ]] ; then 
    206  
    207             echo ${Green}"${OCE} ${OCEGRID} toward ${ATM} - ${order}order"${Norm} 
    208  
    209             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 maskutil_${OCEGRID} 
    210             python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${oce_domain_type} 
    211             python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${atm_domain_type} 
    212             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name  -v maskutil_${OCEGRID} 
    213             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_${ocegrid}${oce}_to_t${atm}_${order}order 
    214             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${OCE} mask interpolated to ${ATM}" 
    215             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${oce_domain_type} 
    216             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${atm_domain_type} 
    217             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t ${num_order} 
    218             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${oce_domain_type} 
    219             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${atm_domain_type} 
    220             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v ${num_order} 
    221             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_${ocegrid}${oce}_to_t${atm}_${order}order.nc 
    222             cp iodef.xml iodef_${ocegrid}${oce}_t${atm}_${order}order.xml 
     205    for normalize in ${ListNormalize} ; do 
     206        for OCEGRID in ${ListOCEGRID} ; do 
     207            ocegrid=${OCEGRID,,} 
    223208             
    224             time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes 
    225         fi 
    226          
     209            if [[ ! -f rmp_${ocegrid}${oce}_to_t${atm}_${order}order_${normalize}.nc ]] ; then 
     210                 
     211                echo ${Green}"${OCE} ${OCEGRID} toward ${ATM} - ${order}order - normalize: ${normalize}"${Norm} 
     212                 
     213                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 maskutil_${OCEGRID} 
     214                python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                     -k type  -v ${oce_domain_type} 
     215                python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                     -k type  -v ${atm_domain_type} 
     216                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]'   -k name  -v maskutil_${OCEGRID} 
     217                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                                 -k name  -v dia_${ocegrid}${oce}_to_t${atm}_${order}order_${normalize} 
     218                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'         -t "${OCE} mask interpolated to ${ATM}" 
     219                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]'   -t ${oce_domain_type} 
     220                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'     -t ${atm_domain_type} 
     221                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'         -t ${num_order} 
     222                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize} 
     223                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                      -k type  -v ${oce_domain_type} 
     224                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                      -k type  -v ${atm_domain_type} 
     225                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k order -v ${num_order} 
     226                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_${ocegrid}${oce}_to_t${atm}_${order}order_${normalize}.nc 
     227                python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize     -v ${normalize} 
     228                 
     229                cp iodef.xml iodef_${ocegrid}${oce}_t${atm}_${order}order_${normalize}.xml 
     230                 
     231                time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes 
     232            fi 
     233             
     234        done 
    227235    done 
    228236done 
     
    241249python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${oce_domain_type} 
    242250             
    243 for order in ${Listorder} ; do 
     251for order in ${ListOrder} ; do 
    244252    case ${order} in 
    245253        ( 1st ) num_order=1 ;; 
    246254        ( 2nd ) num_order=2 ;; 
    247255    esac 
    248     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v ${num_order} 
    249     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t ${num_order}    
     256    for normalize in ${ListNormalize} ; do 
     257        python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k order -v ${num_order} 
     258        python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'         -t ${num_order}    
     259        python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize} 
     260        python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize     -v ${normalize} 
     261         
     262        for OCEGRID in ${ListOCEGRID} ; do 
     263            ocegrid=${OCEGRID,,} 
     264             
     265            echo ${Green}"${ATM} toward ${OCE} ${OCEGRID} - ${order}order - normalize: ${normalize}"${Norm} 
     266            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 mask_${OCEGRID} 
     267            python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="mask_dest"]'   -k name  -v mask_${OCEGRID} 
     268            python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_t${atm}_to_${ocegrid}${oce}_${order}order_${normalize} 
     269            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_t${atm}_to_${ocegrid}${oce}_${order}order_${normalize}.nc 
     270            cp iodef.xml iodef_t${atm}_to_${ocegrid}${oce}_${order}order_${normalize}.xml 
     271             
     272            time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes 
     273             
     274        done 
     275    done 
     276done 
     277 
     278## 
     279## ATM towards NEMO points - runoff 
     280## =========================================================================== 
     281cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml           iodef.xml 
     282for normalize in ${ListNormalize} ; do 
     283    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${atm_domain_type} 
     284    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${oce_domain_type} 
     285    python 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}" 
     286    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${atm_domain_type} 
     287    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${oce_domain_type} 
     288    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${atm_domain_type} 
     289    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${oce_domain_type} 
     290    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 
     291    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t 1 
     292    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize} 
     293    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]'                         -k name  -v ${ATM}_grid_maskFrom_${OCE} 
     294    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 
     295    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} 
     296    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}.nc 
     297    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize     -v ${normalize} 
    250298     
    251     for OCEGRID in ${ListOCEGRID} ; do 
    252         ocegrid=${OCEGRID~} 
    253  
    254         echo ${Green}"${ATM} toward ${OCE} ${OCEGRID} - ${order}order"${Norm} 
    255         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 mask_${OCEGRID} 
    256         python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="mask_dest"]'   -k name  -v mask_${OCEGRID} 
    257         python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_t${atm}_to_${ocegrid}${oce}_${order}order 
    258         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_t${atm}_to_${ocegrid}${oce}_${order}order.nc 
    259         cp iodef.xml iodef_t${atm}_to_${ocegrid}${oce}_${order}order.xml 
    260          
    261         time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes 
    262          
    263     done 
    264 done 
    265  
    266 ## 
    267 ## ATM towards NEMO points - runoff 
    268 ## =========================================================================== 
    269 cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml           iodef.xml 
    270 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${atm_domain_type} 
    271 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${oce_domain_type} 
    272 python 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}" 
    273 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${atm_domain_type} 
    274 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${oce_domain_type} 
    275 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${atm_domain_type} 
    276 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${oce_domain_type} 
    277 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 
    278 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t 1 
    279 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]'                         -k name  -v ${ATM}_grid_maskFrom_${OCE} 
    280 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 
    281 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 
    282 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.nc 
    283  
    284 cp iodef.xml iodef_c${atm}_to_t${oce}_1storder.xml 
    285  
    286 time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes 
    287  
     299    cp iodef.xml iodef_c${atm}_to_t${oce}_1storder_${normalize}.xml 
     300     
     301    time /usr/bin/time ccc_mprun ./interpol.exe --mask_src=yes --mask_dst=yes 
     302done 
    288303## 
    289304## Change all NetCDF files to NetCDF 3 format (needed for OASIS) 
     
    298313## (needed if files need to be read by XIOS) 
    299314## =========================================================================== 
     315#ncatted --history -a coordinates,aire,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc 
     316ncap2 --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 
     317 
    300318if [[ ${atm} = ico ]] ; then 
    301319    cat <<EOF > add_time.nco 
    302 defdim("time_counter",1) ; 
    303 OceFrac [time_counter,cell] = OceFrac (:) ; 
    304 OceMask [time_counter,cell] = OceMask (:) ; 
    305 EOF 
    306     ncap2 --overwrite --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 
    307     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 
     320OceFrac    [time_counter,cell] = OceFrac    (:) ; 
     321OceMask    [time_counter,cell] = OceMask    (:) ; 
     322AtmCoastal [time_counter,cell] = AtmCoastal (:) ; 
     323EOF 
     324    ncap2 --overwrite --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 
    308325    ncatted --history \ 
    309             -a coordinates,OceFrac,c,c,"time_counter cell" \ 
    310             -a coordinates,OceMask,c,c,"time_counter cell" \ 
    311             -a coordinates,aire,c,c,"time_counter cell"    ${ATM}_grid_maskFrom_${OCE}.nc 
     326            -a coordinates,OceFrac,c,c,"time_counter cell"    \ 
     327            -a coordinates,OceMask,c,c,"time_counter cell"    \ 
     328            -a coordinates,AtmCoastal,c,c,"time_counter cell" \ 
     329            -a coordinates,aire,c,c,"cell" \ 
     330            ${ATM}_grid_maskFrom_${OCE}.nc 
    312331fi 
    313332if [[ ${atm} = lmd ]] ; then 
    314333    cat <<EOF > add_time.nco 
    315 defdim("time_counter",1) ; 
    316 OceFrac [time_counter,lat,lon] = OceFrac (:,:) ; 
    317 OceMask [time_counter,lat,lon] = OceMask (:,:) ; 
    318 EOF 
    319     ncap2 --overwrite --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 
    320     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 
     334OceFrac    [time_counter,lat,lon] = OceFrac    (:,:) ; 
     335OceMask    [time_counter,lat,lon] = OceMask    (:,:) ; 
     336AtmCoastal [time_counter,lat,lon] = AtmCoastal (:,:) ; 
     337EOF 
     338    ncap2 --overwrite --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 
    321339    ncatted --history \ 
    322             -a coordinates,OceFrac,c,c,"time_counter lat lon" \ 
    323             -a coordinates,OceMask,c,c,"time_counter lat lon" \ 
    324             -a coordinates,aire,c,c,"time_counter lat lon"    ${ATM}_grid_maskFrom_${OCE}.nc 
     340            -a coordinates,OceFrac,c,c,"time_counter lat lon"    \ 
     341            -a coordinates,OceMask,c,c,"time_counter lat lon"    \ 
     342            -a coordinates,AtmCoastal,c,c,"time_counter lat lon" \ 
     343            -a coordinates,aire,c,c,"lat lon" \ 
     344            ${ATM}_grid_maskFrom_${OCE}.nc 
    325345fi 
    326  
    327 ## 
    328 ## Add some information in file headers 
     346ncks --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 
     347 
     348 
     349## 
     350## Add some metadata in file headers 
    329351## =========================================================================== 
    330352 
     
    378400EOF 
    379401 
    380 for file in rmp_*${oce}_to_*${atm}_*.nc rmp_*${atm}_to_*${oce}_*.nc ; do 
    381     mv ${file} xios_${file} 
    382     ncap2 --fl_fmt=${FL_FMT} --history --script-file add_dim.nco xios_${file} ${file} 
     402for rmpFile in rmp_*.nc ; do 
     403    mv ${rmpFile} xios_${rmpFile} 
     404    ncap2 --fl_fmt=${FL_FMT} --history --script-file add_dim.nco xios_${rmpFile} ${rmpFile} 
    383405     
    384     ncrename --history --dimension n_weight,num_links   ${file} 
    385     ncrename --history --variable  src_idx,src_address  ${file} 
    386     ncrename --history --variable  dst_idx,dst_address  ${file} 
    387     ncrename --history --variable  weight,remap_matrix  ${file} 
    388     case ${file} in 
    389         ( *1storder.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  ${file} ;; 
    390         ( *2ndorder.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 2nd order"  ${file} ;; 
     406    ncrename --history --dimension n_weight,num_links   ${rmpFile} 
     407    ncrename --history --variable  src_idx,src_address  ${rmpFile} 
     408    ncrename --history --variable  dst_idx,dst_address  ${rmpFile} 
     409    ncrename --history --variable  weight,remap_matrix  ${rmpFile} 
     410    case ${rmpFile} in 
     411        ( *_1storder_*.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  ${rmpFile} ;; 
     412        ( *_2ndorder_*.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 2nd order"  ${rmpFile} ;; 
    391413    esac 
    392     ncatted --history --attribute conventions,global,o,c,"SCRIP"   ${file} 
    393     ncatted --history --attribute normalization,global,o,c,"none"  ${file} 
     414    case ${rmpFile} in 
     415        ( *_true.nc  ) ncatted --history --attribute map_method,global,o,c,"Normalization: true"  ${rmpFile} ;; 
     416        ( *_false.nc ) ncatted --history --attribute map_method,global,o,c,"Normalization: false" ${rmpFile} ;; 
     417    esac 
     418    ncatted --history --attribute conventions,global,o,c,"SCRIP"   ${rmpFile} 
     419    ncatted --history --attribute normalization,global,o,c,"none"  ${rmpFile} 
    394420     
    395     case ${file} in 
     421    case ${rmpFile} in 
    396422        ( rmp_*${oce}_to_t${atm}_* ) 
    397423        ncatted --history \ 
     
    399425                --attribute source_grid,global,o,c,"${oce_domain_type}" \ 
    400426                --attribute dest_grid,global,o,c,"${atm_domain_type}"   \ 
    401                 ${file}  
     427                ${rmpFile}       
    402428        ;; 
    403429        ( rmp_*${atm}_to_*${oce}_* ) 
     
    406432                --attribute source_grid,global,o,c,"${atm_domain_type}" \ 
    407433                --attribute dest_grid,global,o,c,"${oce_domain_type}"   \ 
    408                 ${file} 
     434                ${rmpFile} 
    409435        ;; 
    410436    esac 
     
    414440## Add missing variables in rmp files 
    415441## =========================================================================== 
    416 for OGRID in ${ListOCEGRID} ; do 
    417     for AGRID in T C ; do 
    418         for order in ${Listorder} ; do 
    419             ogrid=${OGRID~} 
    420             agrid=${AGRID~} 
     442for rmpFile in rmp_* ; do 
     443    a_to_o=false ; o_to_a=false 
     444    case ${rmpFile} in 
     445        (  rmp_?${oce}_to_?${atm}_*.nc ) o_to_a=true ;; 
     446        (  rmp_?${atm}_to_?${oce}_*.nc ) a_to_o=true ;; 
     447    esac 
     448 
     449    for Grid in t u v c ; do # Identify grids 
     450        case ${rmpFile} in 
     451            (  rmp_${Grid}${oce}_to_?${atm}_*.nc ) ogrid=${Grid} ;; 
     452            (  rmp_?${oce}_to_${Grid}${atm}_*.nc ) agrid=${Grid} ;; 
     453            (  rmp_${Grid}${atm}_to_?${oce}_*.nc ) agrid=${Grid} ;; 
     454            (  rmp_?${atm}_to_${Grid}${oce}_*.nc ) ogrid=${Grid} ;; 
     455        esac 
     456    done 
     457    OGRID=${ogrid^} 
     458    AGRID=${agrid^} 
    421459         
    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 
     460    cat <<EOF >add_varoce.nco 
    426461defdim ("src_grid_size"   , \$x_grid_${OGRID}.size*\$y_grid_${OGRID}.size) ; 
    427462defdim ("src_grid_corners", 4) ; 
     
    448483EOF 
    449484 
    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 
     485    [[ ${o_to_a} = true ]] && ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${rmpFile} 
     486    sed --in-place "s/src_/dst_/g" add_varoce.nco 
     487    [[ ${a_to_o} = true ]] && ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${rmpFile} 
     488                 
     489    if [[ ${atm} = ico ]] ; then 
     490        cat <<EOF >add_varatm.nco 
    456491defdim ("dst_grid_size"   , \$cell.size) ; 
    457492defdim ("dst_grid_corners", 6) ; 
     
    477512dst_grid_area  (:) = aire(:) ; 
    478513EOF 
    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 
     514        if [[ ${o_to_a} = true ]] ; then 
     515            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     516            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 
     517            mv rmp_tmp.nc ${rmpFile} 
     518        fi 
    484519                     
    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 
     520        sed --in-place "s/dst_/src_/g" add_varatm.nco 
     521        if [[ ${a_to_o} = true ]] ; then 
     522            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     523            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 
     524            mv rmp_tmp.nc ${rmpFile} 
     525        fi 
     526    fi 
     527    if [[ ${atm} = lmd ]] ; then 
     528        cat <<EOF >add_varatm.nco 
    494529defdim ("dst_grid_size"   , \$lon.size*\$lat.size) ; 
    495530defdim ("dst_grid_corners", 4) ; 
     
    518553dst_grid_frac (:)  = OceFrac(0,:,:) ; 
    519554EOF 
    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 
    534     done 
     555        if [[ ${o_to_a} = true ]] ; then 
     556            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     557            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 
     558            mv rmp_tmp.nc ${rmpFile} 
     559        fi 
     560         
     561        sed --in-place "s/dst/src/g" add_varatm.nco 
     562        if [[ ${a_to_o} = true ]] ; then 
     563            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     564            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 
     565            mv rmp_tmp.nc ${rmpFile} 
     566        fi 
     567    fi 
    535568done 
    536569 
     
    539572## =========================================================================== 
    540573cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR} 
    541  
    542 cp rmp_c${atm}_to_t${oce}_${order}order.nc ${SUBMIT_DIR}/rmp_c${ATM}_to_t${OCE}_1storder.nc 
    543 cp dia_c${atm}_to_t${oce}_${order}order.nc ${SUBMIT_DIR}/dia_c${ATM}_to_t${OCE}_1storder.nc 
    544  
    545 for order in ${Listorder} 
     574for File in dia_*.nc rmp_*.nc 
    546575do 
    547     cp dia_t${oce}_to_t${atm}_${order}order.nc ${SUBMIT_DIR}/dia_t${OCE}_to_t${ATM}_${order}order.nc 
    548     cp rmp_t${oce}_to_t${atm}_${order}order.nc ${SUBMIT_DIR}/rmp_t${OCE}_to_t${ATM}_${order}order.nc 
    549    
    550     for grid in ${Listocegrid} ; do 
    551         cp rmp_t${atm}_to_${grid}${oce}_${order}order.nc ${SUBMIT_DIR}/rmp_t${ATM}_to_${grid}${OCE}_${order}order.nc 
    552         cp dia_t${atm}_to_${grid}${oce}_${order}order.nc ${SUBMIT_DIR}/dia_t${ATM}_to_${grid}${OCE}_${order}order.nc 
    553     done 
     576    NewFile=$(echo ${File} | sed -e "s/${atm}/${ATM}/" -e "s/${oce}/${OCE}/" ) 
     577    cp ${File} ${SUBMIT_DIR}/${NewFile} 
    554578done 
    555579 
Note: See TracChangeset for help on using the changeset viewer.