Changeset 4153


Ignore:
Timestamp:
11/27/18 17:08:31 (3 years ago)
Author:
omamce
Message:

O.M. : include areas correction

Location:
TOOLS/MOSAIX
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/CreateWeightsMask.bash

    r4146 r4153  
    5353# Defines models 
    5454# ============== 
    55 OCE=ORCA2.3 
    56 #OCE=eORCA1.2 
     55#OCE=ORCA2.3 
     56OCE=eORCA1.2 
    5757#OCE=ORCA025 
    5858 
     
    6060#ATM=ICO40 
    6161#ATM=ICO450 
    62 ATM=LMD9695 
    63 #ATM=LMD144X142 
    64  
    65 # 
    66 # Defines OCE grids to handle 
    67 # =========================== 
    68 ListOCEGRID="T" # U V 
    69 ListOrder="1st" # 2nd 
    70 ListNormalize="false true" 
    71 ListQuantity="false true" 
     62#ATM=LMD9695 
     63ATM=LMD144142 
     64 
     65# Default values, used to create ocean fraction on atmospheric grid  
     66DefaultValues=( Direction=o2a,ocegrid=t,atmgrid=t,Order=1st,Quantity=false,Renormalize=false,useArea=false,maskSrc=true,maskDst=false ) 
     67 
     68# List of weights to build 
     69CommandList=( \ 
     70    Direction=o2a,Order=1st,Quantity=false,Renormalize=true,ocegrid=t,atmgrid=t,useArea=false,maskSrc=true,maskDst=true  \ 
     71    Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmgrid=t,ocegrid=t,useArea=true,maskSrc=true,maskDst=true  \ 
     72    Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmgrid=t,ocegrid=u,useArea=true,maskSrc=true,maskDst=true  \ 
     73    Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmgrid=t,ocegrid=v,useArea=true,maskSrc=true,maskDst=true  \ 
     74    Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmgrid=c,ocegrid=t,useArea=true,maskSrc=true,maskDst=true   \ 
     75   ) 
    7276 
    7377## =========================================================================== 
     
    7781## =========================================================================== 
    7882SUBMIT_DIR=$(pwd) 
    79  
     83# Function to handle command parameters 
     84function read_Command { 
     85    # Decipher the command line to set bash variables  
     86    local l_Debug="no" l_Element 
     87    while [[ ${1} = -* ]] ; do 
     88        case ${1} in 
     89            ( -- ) shift ; break ;; 
     90            ( -d | --debug ) l_Debug="true" ; shift ;; 
     91        esac 
     92    done 
     93    local l_Command=${1} 
     94    for l_Element in $(echo ${l_Command} | tr "," "\n" ) 
     95    do 
     96        [[ "X${l_Debug}" = "Xtrue" ]] && echo ${l_Element} 
     97        eval export ${l_Element} 
     98    done 
     99} 
     100 
     101function setValues { 
     102    # 
     103    ocegrid=${ocegrid,,} 
     104    atmgrid=${atmgrid,,} 
     105    OCEGRID=${ocegrid^^} 
     106    ATMGRID=${atmgrid^^} 
     107 
     108    case ${Order} in 
     109        ( 1st ) numOrder=1 ;; 
     110        ( 2nd ) numOrder=2 ;; 
     111    esac 
     112    case ${Renormalize} in 
     113        ( true )  NormName=Normalized   ;; 
     114        ( false ) NormName=UnNormalized ;; 
     115    esac 
     116    case ${Quantity} in 
     117        ( true )  QuantName=Integrated ;; 
     118        ( false ) QuantName=Surfacic   ;; 
     119    esac 
     120    case ${useArea} in 
     121        ( true )  AreaName=Area   ;; 
     122        ( false ) AreaName=NoArea ;; 
     123    esac 
     124     
     125    Suffix=${Order}Order_${NormName}_${QuantName}_${AreaName} 
     126 
     127    case ${Direction} in 
     128        ( o2a ) 
     129        src=${oce} ; SRC=${OCE} ; srcGrid=${ocegrid} ; srcDomainType=${oceDomainType} ; SRCGRID=${OCEGRID} ; srcArea=area_grid_${OCEGRID} 
     130        dst=${atm} ; DST=${ATM} ; dstGrid=${atmgrid} ; dstDomainType=${atmDomainType} ; DSTGRID=${ATMGRID} ; dstArea=aire 
     131        ;;  
     132        ( a2o ) 
     133        src=${atm} ; SRC=${ATM} ; srcGrid=${atmgrid} ; srcDomainType=${atmDomainType} ; SRCGRID=${ATMGRID} ; srcArea=aire 
     134        dst=${oce} ; DST=${OCE} ; dstGrid=${ocegrid} ; dstDomainType=${oceDomainType} ; DSTGRID=${OCEGRID} ; dstArea=area_grid_${OCEGRID} 
     135        ;; 
     136    esac 
     137    echo ${Green}"${SRC} ${SRCGRID} toward ${DST} ${DSTGRID} - ${Order} Order - Normalize: ${Renormalize} - Quantity: ${QuantName} - Area: ${AreaName}  "${Norm}              
     138} 
     139     
    80140# 
    81141# Defines computer 
    82142# ================ 
    83 if [[ $(hostname) = curie*    ]] ; then arch=curie ; center=tgcc ; fi 
    84143if [[ $(hostname) = irene*    ]] ; then arch=irene ; center=tgcc ; fi 
    85 if [[ $(hostname) = lsce3005* ]] ; then arch=spip  ; center=spip ; fi 
     144if [[ $(hostname) = lsce*    ]] ; then arch=spip  ; center=spip ; fi 
    86145 
    87146PROGRAM=$(basename ${0}) 
    88147 
    89148case ${arch} in 
    90      ( irene ) 
     149    ( irene ) 
    91150    set +vx 
    92     module purge 
    93     source $(ccc_home -u igcmg)/MachineEnvironment/irene/env_irene 
    94     module load python/2.7.8 
    95     module load datadir/igcmg 
    96151    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM 
    97152    TMPDIR=${CCCWORKDIR}/TMP 
     
    99154    PROGRAM=${BRIDGE_MSUB_REQNAME} 
    100155    MPIRUN=ccc_mprun 
     156    source ${SUBMIT_DIR}/arch.env 
     157    module load nco 
     158    module load cdo 
     159    #source $(ccc_home -u igcmg)/MachineEnvironment/irene/env_irene 
     160    module load python/2.7.8 
     161    module load datadir/igcmg 
    101162    module list 
    102163    ;; 
     
    119180# Suffixes 
    120181# --------------------------------------------------------------------------- 
    121 Listocegrid=${ListOCEGRID,,} 
    122182 
    123183case ${OCE} in 
    124     ( *ORC* )         oce=orc ; oce_domain_type=curvilinear   ;; 
     184    ( *ORC* )         oce=orc ; oceDomainType=curvilinear   ;; 
    125185esac 
    126186case ${ATM} in 
    127     ( *dynamico*    ) atm=ico ; atm_domain_type=unstructured  ;; 
    128     ( *ICO*         ) atm=ico ; atm_domain_type=unstructured  ;; 
    129     ( *lmd* | *LMD* ) atm=lmd ; atm_domain_type=rectilinear   ;; 
     187    ( *dynamico*    ) atm=ico ; atmDomainType=unstructured  ;; 
     188    ( *ICO*         ) atm=ico ; atmDomainType=unstructured  ;; 
     189    ( *lmd* | *LMD* ) atm=lmd ; atmDomainType=rectilinear   ;; 
    130190esac 
    131191 
     
    143203cp ${SUBMIT_DIR}/bin/interpol.exe    . 
    144204cp ${SUBMIT_DIR}/*.py                . 
     205cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml   . 
     206cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml   . 
    145207 
    146208cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc  . 
     
    181243## NEMO T point towards ATM - 1st order 
    182244## =========================================================================== 
    183 echo ${Green}"Initial case - ${OCE} T toward ${ATM} - 1stOrder - UnNormalized - Surfacic"${Norm} 
    184 cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml   iodef.xml 
    185 Suffix=1stOrder_UnNormalized_Surfacic 
     245echo "Command parameters : ${Command}" 
     246read_Command ${DefaultValues} 
     247read_Command ${Command} 
     248setValues 
     249 
     250cp iodef_oce_to_atm.xml   iodef.xml 
    186251 
    187252python 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_T 
    188 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${oce_domain_type} 
    189 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${atm_domain_type} 
     253python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="area_src"]'   -k name  -v area_grid_T 
     254python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${srcDomainType} 
     255python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${dstDomainType} 
     256python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 
     257python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity    -v false 
     258python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v false 
     259python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k use_area -v false 
    190260python 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 
    191 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}_${Suffix} 
    192 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}" 
    193 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} 
    194 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} 
     261python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="area_source"]' -k name  -v area_grid_T 
     262python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix} 
     263python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${SRC} mask interpolated to ${DST}" 
     264python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${srcDomainType} 
     265python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'   -t ${dstDomainType} 
    195266python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t 1 
    196 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${oce_domain_type} 
    197 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${atm_domain_type} 
    198 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}_${Suffix}.nc 
    199 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 
     267python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${srcDomainType} 
     268python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${dstDomainType} 
     269python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.nc 
     270python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k order -v 1 
    200271python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false 
    201272python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t false 
     273python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]'      -t false 
    202274python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize -v false 
    203275python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k quantity    -v false 
    204  
    205 cp iodef.xml iodef_t${oce}_to_t${atm}_${Suffix}.xml 
     276python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k use_area    -v false 
     277 
     278cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.xml 
    206279ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc 
    207280ln -fs ${ATM}_grid.nc              atm_grid.nc 
    208281 
    209 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=no 
     282time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} 
    210283## 
    211284## Correct spurious values (extremes) 
     
    266339[[ ${atm} = *ico* ]] && ncks --alphabetize --history --append --variable bounds_lon,bounds_lat atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc 
    267340 
    268  
    269 ## 
    270 ## NEMO, other case, towards ATM  
    271 ## =========================================================================== 
    272 for order in ${ListOrder} ; do 
    273     case ${order} in 
    274         ( 1st ) num_order=1 ;; 
    275         ( 2nd ) num_order=2 ;; 
    276     esac 
    277     for normalize in ${ListNormalize} ; do 
    278         for quantity in ${ListQuantity} ; do 
    279             for OCEGRID in ${ListOCEGRID} ; do 
    280                 ocegrid=${OCEGRID,,} 
    281                  
    282                 case ${normalize} in 
    283                     ( true )  NormName=Normalized  ;; 
    284                     ( false ) NormName=UnNormalized ;; 
    285                 esac 
    286                 case ${quantity} in 
    287                     ( true )  QuantName=Integrated ;; 
    288                     ( false ) QuantName=Surfacic ;; 
    289                 esac 
    290                  
    291                 Suffix=${order}Order_${NormName}_${QuantName} 
    292                  
    293                 if [[ ! -f rmp_${ocegrid}${oce}_to_t${atm}_${Suffix}.nc ]] ; then 
    294                      
    295                     echo ${Green}"${OCE} ${OCEGRID} toward ${ATM} - ${order}Order - normalize: ${normalize} - quantity: ${quantity}"${Norm} 
    296                      
    297                     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} 
    298                     python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                     -k type  -v ${oce_domain_type} 
    299                     python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                     -k type  -v ${atm_domain_type} 
    300                     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} 
    301                     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}_${Suffix} 
    302                     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}" 
    303                     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} 
    304                     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} 
    305                     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'         -t ${num_order} 
    306                     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize} 
    307                     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t ${quantity} 
    308                     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                      -k type  -v ${oce_domain_type} 
    309                     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                      -k type  -v ${atm_domain_type} 
    310                     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} 
    311                     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}_${Suffix}.nc 
    312                     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize     -v ${normalize} 
    313                     python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity        -v ${quantity} 
    314                      
    315                     cp iodef.xml iodef_${ocegrid}${oce}_t${atm}_${Suffix}.xml 
    316                      
    317                     ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc 
    318                     ln -fs ${ATM}_grid.nc              atm_grid.nc 
    319                     time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 
    320                 fi 
    321                  
    322             done 
    323         done 
    324     done 
    325 done 
    326 ## 
    327 ## ATM towards NEMO points 
    328 ## =========================================================================== 
    329 cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml           iodef.xml 
    330  
    331 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${atm_domain_type} 
    332 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${oce_domain_type} 
    333 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'       -t "${ATM} mask interpolated to ${OCE}" 
    334 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} 
    335 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} 
    336 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${atm_domain_type} 
    337 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${oce_domain_type} 
    338              
    339 for order in ${ListOrder} ; do 
    340     case ${order} in 
    341         ( 1st ) num_order=1 ;; 
    342         ( 2nd ) num_order=2 ;; 
    343     esac 
    344     for normalize in ${ListNormalize} ; do 
    345         for quantity in ${ListQuantity} ; do 
    346             case ${normalize} in 
    347                 ( true )  NormName=Normalized  ;; 
    348                 ( false ) NormName=UnNormalized ;; 
    349             esac 
    350             case ${quantity} in 
    351                 ( true )  QuantName=Integrated ;; 
    352                 ( false ) QuantName=Surfacic ;; 
    353             esac 
    354              
    355             Suffix=${order}Order_${NormName}_${QuantName} 
    356              
    357             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} 
    358             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'         -t ${num_order}    
    359             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize} 
    360             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t ${quantity} 
    361             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize     -v ${normalize} 
    362             python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k quantity        -v ${quantity} 
    363              
    364             for OCEGRID in ${ListOCEGRID} ; do 
    365                 ocegrid=${OCEGRID,,} 
    366                  
    367                 echo ${Green}"${ATM} toward ${OCE} ${OCEGRID} - ${order}Order - normalize: ${normalize} - quantity: ${quantity}"${Norm} 
    368                 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} 
    369                 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} 
    370                 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}_${Suffix} 
    371                 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}_${Suffix}.nc 
    372                 cp iodef.xml iodef_t${atm}_to_${ocegrid}${oce}_${Suffix}.xml 
    373                  
    374                 ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc 
    375                 ln -fs ${ATM}_grid.nc              atm_grid.nc 
    376                 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 
    377                  
    378             done 
    379         done 
    380     done 
    381 done 
    382341## 
    383342## Creates mask of coastal OCE points 
     
    396355ncks --alphabetize --history --overwrite --fl_fmt=${FMT_OASIS} ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 
    397356 
    398 ## 
    399 ## ATM towards NEMO points - runoff 
    400 ## =========================================================================== 
    401 cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml           iodef.xml 
    402 for normalize in ${ListNormalize} ; do 
    403     for quantity in ${ListQuantity} ; do 
    404         case ${normalize} in 
    405             ( true )  NormName=Normalized  ;; 
    406             ( false ) NormName=UnNormalized ;; 
    407         esac 
    408         case ${quantity} in 
    409             ( true )  QuantName=Integrated ;; 
    410             ( false ) QuantName=Surfacic ;; 
    411         esac 
     357 
     358## 
     359## Other weigths files 
     360## =========================================================================== 
     361# Loop on commands 
     362for Command in ${CommandList[@]} 
     363do 
     364    echo "Command parameters : ${Command}" 
     365    read_Command ${DefaultValues} 
     366    read_Command ${Command} 
     367    setValues 
     368     
     369    ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc 
     370    ln -fs ${ATM}_grid.nc              atm_grid.nc 
     371     
     372    case ${Direction} in 
     373        ( o2a ) 
     374        cp iodef_oce_to_atm.xml iodef.xml 
    412375         
    413         Suffix=${order}Order_${NormName}_${QuantName} 
     376        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 mask_${DSTGRID}  
     377        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 OceMask 
    414378         
    415         python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                   -k type  -v ${atm_domain_type} 
    416         python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                   -k type  -v ${oce_domain_type} 
    417         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}" 
    418         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} 
    419         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} 
    420         python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${atm_domain_type} 
    421         python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${oce_domain_type} 
    422         python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 
    423         python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'       -t 1 
    424         python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${normalize} 
    425         python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'    -t ${quantity} 
    426         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} 
    427         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 
    428         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 
    429         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}_${Suffix} 
    430         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}_${Suffix}.nc 
    431         python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize     -v ${normalize} 
    432         python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity        -v ${quantity} 
     379        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_${SRCGRID} 
     380        python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="area_source"]' -k name -v area_grid_${SRCGRID} 
     381        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 OceMask 
     382        python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="area_dest"]'   -k name -v aire 
     383        ;; 
     384        ( a2o ) 
     385        cp iodef_atm_to_oce.xml iodef.xml 
    433386         
    434         cp iodef.xml iodef_o${atm}_to_c${oce}_${Suffix}.xml 
     387        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 OceMask 
     388        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_${DSTGRID} 
    435389         
    436         ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc 
    437         ln -fs ${ATM}_grid.nc              atm_grid.nc 
    438         time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=yes --mask_dst=yes 
    439          
    440         # Now we should divide weight par source (atm) grid area : run-off is a quantity/s integrated on the grid mox, not a flux  
    441     done 
     390        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 OceMask 
     391        python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="area_source"]' -k name  -v aire 
     392        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_${DSTGRID} 
     393        python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="area_dest"]'   -k name  -v area_grid_${DSTGRID} 
     394        ;; 
     395    esac 
     396     
     397    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                     -k type  -v ${dstDomainType} 
     398    python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]'                     -k type  -v ${srcDomainType} 
     399     
     400    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                      -k type  -v ${srcDomainType} 
     401    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                      -k type  -v ${dstDomainType} 
     402     
     403    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_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.nc 
     404    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k order       -v ${numOrder} 
     405    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k quantity    -v ${Quantity} 
     406    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k renormalize -v ${Renormalize} 
     407    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k use_area    -v ${useArea} 
     408     
     409    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                                 -k name -v dia_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix} 
     410    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]'         -t "${SRC} mask interpolated to ${DST}" 
     411    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'     -t ${dstDomainType} 
     412    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]'   -t ${srcDomainType} 
     413    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${Renormalize} 
     414    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]'         -t ${numOrder}    
     415    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]'      -t ${Quantity} 
     416    python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]'      -t ${useArea} 
     417     
     418    cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.xml 
     419    time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} 
    442420done 
    443     ## 
     421 
     422## 
    444423## Copy all NetCDF files to NetCDF 3 format (needed for OASIS) 
    445424## =========================================================================== 
    446425for InFile in *.nc ; do 
    447426    OuFile=$(basename ${InFile} .nc)_${FMT_OASIS}.nc 
    448     if [[ ! -f ${OuFile} ]] ; then 
    449         ncks --alphabetize --history --fl_fmt=${FMT_OASIS} ${InFile} ${OuFile} 
    450     fi 
     427    [[ ! -f ${OuFile} ]] && ncks --alphabetize --history --fl_fmt=${FMT_OASIS} ${InFile} ${OuFile} 
    451428done 
    452429 
     
    573550        ncatted --history \ 
    574551                --attribute title,global,o,c,"Weights ${OCE} to ${ATM}" \ 
    575                 --attribute source_grid,global,o,c,"${oce_domain_type}" \ 
    576                 --attribute dest_grid,global,o,c,"${atm_domain_type}"   \ 
     552                --attribute source_grid,global,o,c,"${oceDomainType}" \ 
     553                --attribute dest_grid,global,o,c,"${atmDomainType}"   \ 
    577554                ${rmpFile}       
    578555        ;; 
     
    580557        ncatted --history \ 
    581558                --attribute title,global,o,c,"Weights ${ATM} to ${OCE}" \ 
    582                 --attribute source_grid,global,o,c,"${atm_domain_type}" \ 
    583                 --attribute dest_grid,global,o,c,"${oce_domain_type}"   \ 
     559                --attribute source_grid,global,o,c,"${atmDomainType}" \ 
     560                --attribute dest_grid,global,o,c,"${oceDomainType}"   \ 
    584561                ${rmpFile} 
    585562        ;; 
  • TOOLS/MOSAIX/check_conserv.py

    r4089 r4153  
    1414##  personal. 
    1515## 
     16# 
     17# python3 -i check_conserv.py --file dia_tORCA2.3_to_tLMD9695_1stOrder_Normalized_Surfacic_NoArea.nc --grids grids_ORCA2.3xLMD9695.nc --areas areas_ORCA2.3xLMD9695.nc --masks masks_ORCA2.3xLMD9695.nc --frac LMD9695_grid_maskFrom_ORCA2.3.nc 
     18# 
    1619## SVN information 
    1720__Author__   = "$Author$" 
     
    2124__HeadURL    = "$HeadURL$" 
    2225 
    23 import cdms2 
     26import netCDF4 
    2427import numpy as np 
    2528import glob 
    2629import sys, argparse, textwrap 
    2730import nemo 
     31import os 
    2832 
    2933# Creating a parser 
     
    5054name_input = myargs.file 
    5155 
    52 # Determination des modeles 
    53 Elements = myargs.file.split('_') 
    54  
    55 # 
     56# Get dir and file 
     57InDir  =  os.path.dirname  (os.path.abspath(myargs.file)) 
     58InFile =  os.path.basename (os.path.abspath(myargs.file)) 
     59 
     60print ('InDir  : ' + InDir ) 
     61print ('InFile : ' + InFile ) 
     62 
     63Elements = InFile.split('_') 
     64 
     65# Get models 
    5666Name_src = Elements[1][1:] ; Name_dst = Elements[3][1:] 
    5767grid_src = Elements[1][0]  ; grid_dst = Elements[3][0] 
     
    8494if Name_dst.count('ORC') : CplModel = Name_dst + 'x' + Name_src 
    8595 
    86 print ('CplModel : ' + CplModel ) 
    87 print ('Input file: ' + name_input ) 
     96print ('CplModel   : ' + CplModel ) 
     97print ('Input file : ' + name_input ) 
    8898      
    8999# Coordonnees et masques 
    90100if myargs.fracs == None : 
    91     if Name_src.count('ORC') : name_frc = Name_dst + '_grid_maskFrom_' + Name_src + '.nc' 
    92     if Name_dst.count('ORC') : name_frc = Name_src + '_grid_maskFrom_' + Name_dst + '.nc' 
     101    if Name_src.count('ORC') : name_frc = InDir + '/' + Name_dst + '_grid_maskFrom_' + Name_src + '.nc' 
     102    if Name_dst.count('ORC') : name_frc = InDir + '/' + Name_src + '_grid_maskFrom_' + Name_dst + '.nc' 
    93103else: 
    94104    name_frc = myargs.fracs 
    95105 
    96106if myargs.guess : 
    97     n_grids =  'grids_' + CplModel + '.nc' 
    98     n_masks =  'masks_' + CplModel + '.nc' 
    99     n_areas =  'areas_' + CplModel + '.nc' 
     107    n_grids =  InDir + '/grids_' + CplModel + '.nc' 
     108    n_masks =  InDir + '/masks_' + CplModel + '.nc' 
     109    n_areas =  InDir + '/areas_' + CplModel + '.nc' 
    100110else : 
    101111    n_grids = myargs.grids 
     
    104114 
    105115print ('Opening grids file: ' + n_grids ) 
    106 f_grids = cdms2.open ( n_grids ) 
     116f_grids = netCDF4.Dataset ( n_grids ) 
    107117print ('Opening masks file: ' + n_masks ) 
    108 f_masks = cdms2.open ( n_masks ) 
     118f_masks = netCDF4.Dataset ( n_masks ) 
    109119print ('Opening areas file: ' + n_areas ) 
    110 f_areas = cdms2.open ( n_areas ) 
     120f_areas = netCDF4.Dataset ( n_areas ) 
    111121print ('Opening fracs file: ' + name_frc )    
    112 f_frac  = cdms2.open ( name_frc     ) 
    113  
    114 # 
    115 msk_src = np.float64(1.0) - f_masks ( grid_src + name_src + '.msk', squeeze=True ) 
    116 lon_src = f_grids ( grid_src + name_src + '.lon', squeeze=True ) 
    117 lat_src = f_grids ( grid_src + name_src + '.lat', squeeze=True ) 
    118 if myargs.src_int : srf_src = np.ones ( (msk_src.shape), dtype=np.float64 ) 
    119 else              : srf_src = f_areas ( grid_src + name_src + '.srf', squeeze=True ) 
    120  
    121 # 
    122 msk_dst = np.float64(1.0) - f_masks ( grid_dst + name_dst + '.msk', squeeze=True ) 
    123 lon_dst = f_grids ( grid_dst + name_dst + '.lon', squeeze=True ) 
    124 lat_dst = f_grids ( grid_dst + name_dst + '.lat', squeeze=True ) 
    125 if myargs.dst_int : srf_dst = np.ones ( (msk_dst.shape), dtype=np.float64) 
    126 else              : srf_dst = f_areas ( grid_dst + name_dst + '.srf' ) 
     122f_frac  = netCDF4.Dataset ( name_frc     ) 
     123 
     124# 
     125msk_src = np.float64(1.0) - f_masks.variables[ grid_src + name_src + '.msk'][:].squeeze() 
     126lon_src = f_grids.variables [grid_src + name_src + '.lon'][:].squeeze() 
     127lat_src = f_grids.variables [grid_src + name_src + '.lat'][:].squeeze() 
     128if myargs.src_int : srf_src = np.ones ( (msk_src.shape), dtype=np.float64 )[:] 
     129else              : srf_src = f_areas.variables [grid_src + name_src + '.srf'][:].squeeze() 
     130 
     131# 
     132msk_dst = np.float64(1.0) - f_masks.variables[grid_dst + name_dst + '.msk'][:] 
     133lon_dst = f_grids.variables [grid_dst + name_dst + '.lon'][:].squeeze() 
     134lat_dst = f_grids.variables [grid_dst + name_dst + '.lat'][:].squeeze() 
     135if myargs.dst_int : srf_dst = np.ones ( (msk_dst.shape), dtype=np.float64)[:] 
     136else              : srf_dst = f_areas.variables [grid_dst + name_dst + '.srf'][:].squeeze() 
    127137 
    128138# 
    129139if name_src in ( 'ico', 'lmd' ) : 
    130140    if myargs.src_nofrac : frc_src = np.ones ( (msk_src.shape), dtype=np.float64) 
    131     else                 : frc_src = f_frac ( 'OceFrac', squeeze=True ) 
     141    else                 : frc_src = f_frac.variables ['OceFrac'][:].squeeze() 
     142         
    132143if name_src == 'orc'     : frc_src = np.ones ( (msk_src.shape), dtype=np.float64) 
     144     
    133145if name_dst in ( 'ico', 'lmd' ) : 
    134146    if myargs.dst_nofrac : frc_dst = np.ones ( (msk_dst.shape), dtype=np.float64) 
    135     else                 : frc_dst = f_frac ( 'OceFrac', squeeze=True ) 
     147    else                 : frc_dst = f_frac.variables['OceFrac'][:].squeeze() 
     148         
    136149if name_dst == 'orc'     : frc_dst = np.ones ( (msk_dst.shape), dtype=np.float64) 
    137150 
     
    156169 
    157170print ( Name_src ) 
    158 print 'mask: {:12.3} {:12.3} {:12.3}'.format( np.min(msk_src), np.max(msk_src), np.sum(msk_src) ) 
    159 print 'frac: {:12.3} {:12.3} {:12.3}'.format( np.min(frc_src), np.max(frc_src), np.sum(frc_src) ) 
    160 print 'area: {:12.3} {:12.3} {:12.3}'.format( np.min(srf_src), np.max(srf_src), np.sum(srf_src) ) 
     171print ( 'mask: {:12.3} {:12.3} {:12.3}'.format( np.min(msk_src), np.max(msk_src), np.sum(msk_src) ) ) 
     172print ( 'frac: {:12.3} {:12.3} {:12.3}'.format( np.min(frc_src), np.max(frc_src), np.sum(frc_src) ) ) 
     173print ( 'area: {:12.3} {:12.3} {:12.3}'.format( np.min(srf_src), np.max(srf_src), np.sum(srf_src) ) ) 
    161174 
    162175print ( Name_dst ) 
    163 print 'mask: {:12.3} {:12.3} {:12.3}'.format( np.min(msk_dst), np.max(msk_dst), np.sum(msk_dst) ) 
    164 print 'frac: {:12.3} {:12.3} {:12.3}'.format( np.min(frc_dst), np.max(frc_dst), np.sum(frc_dst) ) 
    165 print 'area: {:12.3} {:12.3} {:12.3}'.format( np.min(srf_dst), np.max(srf_dst), np.sum(srf_dst) ) 
     176print ( 'mask: {:12.3} {:12.3} {:12.3}'.format( np.min(msk_dst), np.max(msk_dst), np.sum(msk_dst) ) ) 
     177print ( 'frac: {:12.3} {:12.3} {:12.3}'.format( np.min(frc_dst), np.max(frc_dst), np.sum(frc_dst) ) ) 
     178print ( 'area: {:12.3} {:12.3} {:12.3}'.format( np.min(srf_dst), np.max(srf_dst), np.sum(srf_dst) ) ) 
    166179print (' ') 
    167180print ( "Surfaces   : %14.6e %14.6e %11.3e"%( area_src, area_dst, (area_src-area_dst)/(area_src+area_dst)*0.5 ) ) 
     
    169182 
    170183## 
    171 f_input = cdms2.open ( name_input ) 
     184f_input = netCDF4.Dataset( name_input ) 
    172185# Loop over fields 
    173186for num in np.arange (1, 7) : 
     
    177190 
    178191    # Reading field 
    179     v_src = f_input ( name_src ) 
    180     v_dst = f_input ( name_dst ) 
     192    v_src = f_input [ name_src ][:] 
     193    v_dst = f_input [ name_dst ][:] 
    181194 
    182195    # Compute integrals 
  • TOOLS/MOSAIX/iodef_atm_to_oce.xml

    r4082 r4153  
    11<?xml version="1.0"?> 
     2 
     3<!-- Earth radius NEMO ra = 6371229 --> 
     4<!-- Earth radius LMDZ RA=6371229. --> 
     5 
    26<simulation> 
    37 
     
    913      <file id="file_src" name="atm_grid" mode="read" output_freq="1ts" enabled=".TRUE."> 
    1014        <field id="mask_src" name="OceMask" operation="instant" domain_ref="domain_src" />  
     15        <field id="area_src" name="aire"    operation="instant" domain_ref="domain_src" />  
    1116      </file> 
    1217 
    1318      <file id="file_dst" name="oce_grid" mode="read" output_freq="1ts" enabled=".TRUE."> 
    14         <field id="mask_dst" name="mask_T" operation="instant" domain_ref="domain_dst" />  
     19        <field id="mask_dst" name="mask_T"      operation="instant" domain_ref="domain_dst" />  
     20        <field id="area_dst" name="area_grid_T" operation="instant" domain_ref="domain_dst" />  
    1521      </file> 
    1622       
     
    5965      <file id="file_src" name="atm_grid" mode="read" output_freq="1ts" enabled=".TRUE."> 
    6066        <field id="mask_source"  name="OceMask" operation="instant" domain_ref="domain_src" />  
     67        <field id="area_source"  name="aire"    operation="instant" domain_ref="domain_src" />  
    6168      </file> 
    6269 
    6370      <file id="file_dst" name="oce_grid" mode="read" output_freq="1ts" enabled=".TRUE.">  
    64         <field id="mask_dest"  name="mask_T" operation="instant" domain_ref="domain_dst" /> 
     71        <field id="mask_dest"  name="mask_T"      operation="instant" domain_ref="domain_dst" /> 
     72        <field id="area_dest"  name="area_grid_T" operation="instant" domain_ref="domain_dst" /> 
    6573      </file> 
    6674 
     
    7482        <variable name="normalization" type="string">none</variable> 
    7583        <variable name="quantity"      type="string">none</variable> 
     84        <variable name="use_area"      type="string">none</variable> 
    7685        <variable name="source_grid"   type="string">curvilinear</variable> 
    7786        <variable name="dest_grid"     type="string">unstructured</variable> 
     
    102111 
    103112    <domain_definition> 
    104       <domain id="domain_src" type="unstructured" > 
     113      <domain id="domain_src" type="unstructured" radius="6371229.0" > 
    105114        <generate_rectilinear_domain/> 
    106115      </domain> 
    107116       
    108       <domain id="domain_dst" type="curvilinear" prec="8" > 
     117      <domain id="domain_dst" type="curvilinear" prec="8" radius="6371229.0" > 
    109118        <generate_rectilinear_domain/> 
    110         <interpolate_domain order="1" renormalize="false" quantity="false" write_weight="true" weight_filename="rmp_tatm_to_toce_1storder.nc"/> 
     119        <interpolate_domain order="1" renormalize="false" quantity="false" use_area="false" write_weight="true" weight_filename="rmp_tatm_to_toce.nc" /> 
    111120      </domain> 
    112121    </domain_definition> 
  • TOOLS/MOSAIX/iodef_oce_to_atm.xml

    r4082 r4153  
    88 
    99      <file id="file_src" name="oce_grid" mode="read" output_freq="1ts" enabled=".TRUE."> 
    10         <field id="mask_src"  name="maskutil_T" operation="instant" domain_ref="domain_src" />  
     10        <field id="mask_src"  name="maskutil_T"  operation="instant" domain_ref="domain_src" />  
     11        <field id="area_src"  name="area_grid_T" operation="instant"       domain_ref="domain_src" />  
    1112      </file> 
    1213 
    1314      <file id="file_dst" name="atm_grid" mode="read" output_freq="1ts" enabled=".TRUE."> 
    1415        <field id="mask_dst"  name="OceMask" operation="instant" domain_ref="domain_dst" />  
     16        <field id="area_dst"  name="aire"    operation="instant" domain_ref="domain_dst" />  
    1517      </file> 
    1618       
     
    5860 
    5961      <file id="file_src" name="oce_grid" mode="read" output_freq="1ts" enabled=".TRUE."> 
    60         <field id="mask_source"  name="maskutil_T" operation="instant" domain_ref="domain_src" />  
     62        <field id="mask_source"  name="maskutil_T"  operation="instant" domain_ref="domain_src" />  
     63        <field id="area_source"  name="area_grid_T" operation="instant" domain_ref="domain_src" />  
    6164      </file> 
    6265 
    6366      <file id="file_dst" name="atm_grid" mode="read" output_freq="1ts" enabled=".TRUE.">  
    64         <field id="aire"  name="aire" operation="instant" domain_ref="domain_dst" /> 
     67        <field id="mask_dest"  name="OceMask" operation="instant" domain_ref="domain_dst" /> 
     68        <field id="area_dest"  name="aire"    operation="instant" domain_ref="domain_dst" /> 
    6569      </file> 
    6670 
     
    7478        <variable name="normalization" type="string">none</variable> 
    7579        <variable name="quantity"      type="string">none</variable> 
     80        <variable name="use_area"      type="string">none</variable> 
    7681        <variable name="source_grid"   type="string">curvilinear</variable> 
    7782        <variable name="dest_grid"     type="string">unstructured</variable> 
     
    105110 
    106111    <domain_definition> 
    107       <domain id="domain_src" type="curvilinear" > 
     112      <domain id="domain_src" type="curvilinear" radius="6371229.0" > 
    108113        <generate_rectilinear_domain/> 
    109114      </domain> 
    110115       
    111       <domain id="domain_dst" type="unstructured" prec="8" > 
     116      <domain id="domain_dst" type="unstructured" prec="8" radius="6371229.0" > 
    112117        <generate_rectilinear_domain/> 
    113         <interpolate_domain order="1" renormalize="false" quantity="false" write_weight="true" weight_filename="rmp_toce_to_tatm_1storder.nc"/> 
     118        <interpolate_domain order="1" renormalize="false" quantity="false" use_area="false" write_weight="true" weight_filename="rmp_toce_to_tatm.nc" /> 
    114119      </domain> 
    115120    </domain_definition> 
  • TOOLS/MOSAIX/rangement.bash

    r4092 r4153  
    1717# ============================================================ 
    1818 
    19 for ATM in LMD144X142 LMD9695 ICO30 ICO40 ICO450 dynamico30 dynamico40 dynamico450 
     19for ATM in LMD144142 LMD9695 ICO30 ICO40 ICO450 dynamico30 dynamico40 dynamico450 
    2020do 
    2121    for OCE in ORCA2.3 eORCA1.2 ORCA025 
     
    2727        else 
    2828            echo "${ATM} : ${OCE} : ${Liste}" 
     29            echo "${WORK_MOSAIC}/${OCE}x${ATM}" 
    2930            mkdir -p ${WORK_MOSAIC}/${OCE}x${ATM} 
    3031            mv ${Liste}  ${WORK_MOSAIC}/${OCE}x${ATM} 
  • TOOLS/MOSAIX/src/MOSAIX/interpol.f90

    r3940 r4153  
    1616   INTEGER :: ni_src, nj_src !< Dimensions of the source grid 
    1717   INTEGER :: ni_dst, nj_dst !< Dimensions of the source grid 
    18    REAL (kind=rl), ALLOCATABLE :: imask_src (:,:), imask_dst (:,:) 
     18   REAL (kind=rl), ALLOCATABLE :: imask_src (:,:), imask_dst (:,:), area_src(:,:), area_dst(:,:) 
    1919   REAL (kind=rl), ALLOCATABLE :: lon_src(:,:), lat_src(:,:), field_src(:,:) 
    2020   LOGICAL, ALLOCATABLE :: lmask_src (:,:), lmask_dst (:,:) 
    2121   INTEGER :: nout = 0, jf 
    2222   CHARACTER (LEN=20) :: nchar, type_src, type_dst 
    23    LOGICAL :: l_mask_src = .TRUE. , l_mask_dst = .TRUE. 
     23   LOGICAL :: l_mask_src = .TRUE. , l_mask_dst = .TRUE., l_use_area = .FALSE. 
    2424   ! 
    2525   REAL (kind=rl), PARAMETER :: rpi = ACOS ( -1.0_rl) 
     
    6464      CALL getarg ( ja, cmd_arg ) 
    6565      SELECT CASE ( TRIM (cmd_arg) ) 
    66       CASE ( '--mask_src=yes' ) ; l_mask_src = .TRUE. 
    67       CASE ( '--mask_src=no'  ) ; l_mask_src = .FALSE. 
    68       CASE ( '--mask_dst=yes' ) ; l_mask_dst = .TRUE. 
    69       CASE ( '--mask_dst=no'  ) ; l_mask_dst = .FALSE. 
     66      CASE ( '--mask_src=true'  ) ; l_mask_src = .TRUE. 
     67      CASE ( '--mask_src=false' ) ; l_mask_src = .FALSE. 
     68      CASE ( '--mask_dst=true'  ) ; l_mask_dst = .TRUE. 
     69      CASE ( '--mask_dst=false' ) ; l_mask_dst = .FALSE. 
     70      CASE ( '--use_area=true'  ) ; l_use_area = .TRUE. 
     71      CASE ( '--use_area=no'    ) ; l_use_area = .FALSE. 
    7072      END SELECT 
    7173   END DO 
     
    7375   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- mask_src : ', 1L)" ) rank, l_mask_src 
    7476   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- mask_dst : ', 1L)" ) rank, l_mask_dst 
     77   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- use_area : ', 1L)" ) rank, l_use_area 
    7578 
    7679   !< Context interpol_read : read masks 
    77    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- debut interpol_read')" ) rank 
     80   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Starting interpol_read')" ) rank 
    7881   CALL xios_context_initialize  ("interpol_read", comm) 
    7982   CALL xios_get_handle          ("interpol_read", ctx_hdl) 
    80    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- set current context interpol_read')" ) rank 
     83   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Set current context interpol_read')" ) rank 
    8184   CALL xios_set_current_context (ctx_hdl) 
    82    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- close context definition interpol_read')" ) rank 
     85   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Close context definition interpol_read')" ) rank 
    8386   CALL xios_close_context_definition () 
    8487 
    8588   !< Read characteristics of the source grid 
    86    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture domain_src')" ) rank 
     89   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_src')" ) rank 
    8790   CALL xios_get_domain_attr ("domain_src", ni=ni_src, nj=nj_src) 
    88    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture domain_src ', 6I9)") rank, ni_src, nj_src 
     91   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_src ', 6I9)") rank, ni_src, nj_src 
    8992   ALLOCATE ( lon_src (ni_src, nj_src), lat_src (ni_src, nj_src) ) 
    90    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture lon lat src ', 6I9)") rank, SIZE (lon_src), & 
     93   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src ', 6I9)") rank, SIZE (lon_src), & 
    9194      &        SHAPE (lon_src), SIZE (lat_src), SHAPE (lat_src) 
    9295   !! 
    9396   ! 
    94    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture type src ', 6I9)") rank 
     97   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading type src ', 6I9)") rank 
    9598   CALL xios_get_domain_attr ("domain_src", TYPE=type_src ) 
    9699   SELECT CASE ( TRIM (type_src)) 
    97100   CASE ( "rectilinear" ) 
    98       WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture lon lat src rectilinear', 6I9)") rank 
     101      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src rectilinear', 6I9)") rank 
    99102      CALL xios_get_domain_attr ("domain_src", lonvalue_1d=lon_src(:,1), latvalue_1d=lat_src(1,:) ) 
    100103      lon_src (:,:) = SPREAD ( lon_src(:,1), DIM=2, ncopies=nj_src) 
     
    102105   CASE default 
    103106      IF ( nj_src == 1 .AND. ni_src==1) THEN 
    104          WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture lon lat src 2D ', 6I9)") rank 
     107         WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src 2D ', 6I9)") rank 
    105108         CALL xios_get_domain_attr ("domain_src", lonvalue_2d=lon_src(:,:), latvalue_2d=lat_src(:,:) ) 
    106109      ELSE IF ( nj_src == 1 ) THEN 
    107          WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture lon lat src 1D ', 6I9)") rank 
     110         WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src 1D ', 6I9)") rank 
    108111         CALL xios_get_domain_attr ("domain_src", lonvalue_1d=lon_src(:,1), latvalue_1d=lat_src(:,1) ) 
    109112      ELSE 
    110          WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture lon lat src 2D ', 6I9)") rank 
     113         WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading lon lat src 2D ', 6I9)") rank 
    111114         CALL xios_get_domain_attr ("domain_src", lonvalue_2d=lon_src(:,:), latvalue_2d=lat_src(:,:) ) 
    112115      ENDIF 
    113116   END SELECT 
     117    
    114118   !< Read mask on the source grid 
    115119   ALLOCATE ( imask_src (ni_src, nj_src), lmask_src (ni_src, nj_src) ) 
    116120   IF ( l_mask_src ) THEN  
    117       WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- receive field mask_src')" ) rank 
     121      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Receive field mask_src')" ) rank 
    118122      CALL xios_recv_field ("mask_src", imask_src) 
    119123      lmask_src = .FALSE. 
     
    122126      imask_src (:,:) = 1 ; lmask_src (:,:) = .TRUE. 
    123127   ENDIF 
    124    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- counting mask_src : ', 1I8)" ) rank, COUNT(lmask_src) 
     128   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Counting mask_src : ', 1I8)" ) rank, COUNT(lmask_src) 
     129 
     130   !< Read area on the source grid 
     131   ALLOCATE ( area_src (ni_src, nj_src) ) 
     132   IF ( l_use_area ) THEN 
     133      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Receive field area_src')" ) rank 
     134      CALL xios_recv_field ("area_src", area_src) 
     135   ELSE 
     136      area_src (:,:) = 1 
     137   ENDIF 
     138   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Sum area_src : ', 2E15.3)" ) rank, SUM(area_src) !, SUM(area_src, mask=lmask_src) 
    125139    
    126140   !< Read mask on the destination grid 
    127    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture domain_dst')" ) rank 
     141   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_dst')" ) rank 
    128142   CALL xios_get_domain_attr ("domain_dst", ni=ni_dst, nj=nj_dst) 
    129    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- lecture domain_dst ', 6I7)") rank, ni_dst, nj_dst 
     143   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Reading domain_dst ', 6I7)") rank, ni_dst, nj_dst 
    130144   ALLOCATE ( imask_dst (ni_dst, nj_dst), lmask_dst (ni_dst, nj_dst) ) 
    131145   IF ( l_mask_dst ) THEN 
    132       WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- receive field mask_dst')" ) rank  
     146      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Receive field mask_dst')" ) rank  
    133147      CALL xios_recv_field ("mask_dst", imask_dst) 
    134148      lmask_dst = .FALSE. 
     
    139153   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- counting mask_dst : ', 1I8)" ) rank, COUNT(lmask_dst) 
    140154 
    141    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fin interpol_read (1)')") rank 
     155   !< Read area on the destination grid 
     156   ALLOCATE ( area_dst (ni_dst, nj_dst) ) 
     157   IF ( l_use_area ) THEN 
     158      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- receive field area_dst')" ) rank  
     159      CALL xios_recv_field ("area_dst", area_dst) 
     160   ELSE 
     161      area_dst (:,:) = 1.0 
     162   ENDIF 
     163   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Counting mask_dst : ', 2E15.3)" ) rank, SUM(area_dst) !, SUM(area_dst,mask=lmask_dst) 
     164 
     165   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- End interpol_read (1)')") rank 
    142166   CALL xios_context_finalize () 
    143    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fin interpol_read (2)')") rank 
     167   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- End interpol_read (2)')") rank 
    144168    
    145169   !< Context interpol run : generates weights, interpolate mask from source to destination 
    146    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- debut interpol_run')" ) rank 
     170   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Starting interpol_run')" ) rank 
    147171   CALL xios_context_initialize  ("interpol_run", comm) 
    148172   CALL xios_get_handle          ("interpol_run", ctx_hdl) 
    149    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- set context interpol_run')" ) rank 
     173   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Set context interpol_run')" ) rank 
    150174   CALL xios_set_current_context (ctx_hdl) 
    151175 
    152    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- get attributes domain_src')" ) rank 
     176   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Get attributes domain_src')" ) rank 
    153177   IF ( l_mask_src ) CALL xios_set_domain_attr ("domain_src", mask_2d=lmask_src) 
     178   IF ( l_use_area ) CALL xios_set_domain_attr ("domain_src", area   =area_src ) 
     179   !CALL xios_set_domain_attr ("domain_src", radius= 6371229.0 ) 
    154180   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- get attributes domain_src')" ) rank 
    155181   IF ( l_mask_dst ) CALL xios_set_domain_attr ("domain_dst", mask_2d=lmask_dst) 
    156  
    157    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- close context definition')" ) rank 
     182   IF ( l_use_area ) CALL xios_set_domain_attr ("domain_dst", area   =area_dst ) 
     183   !CALL xios_set_domain_attr ("domain_dst", radius= 6371229.0 ) 
     184    
     185   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Close context definition')" ) rank 
    158186   CALL xios_close_context_definition () 
    159187 
    160188   CALL xios_update_calendar (1) 
    161    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- send field mask_src')" ) rank 
     189   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Send field mask_src')" ) rank 
    162190   CALL xios_send_field ("mask_src", imask_src) 
    163191 
     
    166194 
    167195   DO jf = 1, 6 
    168       WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- working on test case ', 1I2.2)" ) rank, jf 
     196      WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- Working on test case ', 1I2.2)" ) rank, jf 
    169197      SELECT CASE ( jf) 
    170198      CASE ( 1) ; field_src (:,:) = REAL ( imask_src, kind=rl) 
     
    181209   !!< 
    182210    
    183    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fin interpol_run')" ) rank 
     211   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- End interpol_run')" ) rank 
    184212   CALL xios_context_finalize () 
    185213 
     
    193221   CALL MPI_FINALIZE (ierr) 
    194222 
    195    WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- fini')" ) rank 
     223   WRITE (UNIT=nout, FMT="('-- ', 1I4.4, ' -- The end')" ) rank 
    196224 
    197225END PROGRAM interpol 
  • TOOLS/MOSAIX/update_xml.py

    r3671 r4153  
    108108 
    109109if FileOut == None : FileOut = FileIn 
    110      
     110 
     111## Remove white spaces at beginning and end of line 
     112Node = Node.rstrip().lstrip() 
     113 
    111114## Get XML tree from input file 
    112115iodef = xml.etree.ElementTree.parse ( FileIn ) 
Note: See TracChangeset for help on using the changeset viewer.