Changeset 4289 for TOOLS


Ignore:
Timestamp:
02/22/19 14:16:18 (5 years ago)
Author:
omamce
Message:

O.M. : CPLRESTART

  • Add filling of ocean variable on continents
  • Add more parameters to increase versability
Location:
TOOLS/CPLRESTART
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/CPLRESTART/CreateRestartAtm4Oasis.bash

    r3707 r4289  
    156156    mv tmp_flxat_fields_notime.nc flxat_fields_notime.nc 
    157157    (( dim_lat = dim_lat - 1 )) 
    158     #ATM=lmdz${dim_lon}x${dim_lat} 
    159158    ATM=LMD${dim_lon}${dim_lat} 
    160     (( n_lat = dim_lat-1 )) 
     159    (( n_lat = dim_lat - 1 )) 
    161160cat<<EOF > lonlat2xyz.nco 
    162161// Value at North Pole for LMDZ lon/lat grid 
  • TOOLS/CPLRESTART/CreateRestartOce4Oasis.bash

    r4249 r4289  
    2626#  $HeadURL$ 
    2727 
    28 # Usage exemples : 
    29 # CreateRestartOce4Oasis.bash /ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/OCE/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_grid_T.nc/ccc/store/c# CreateRestartOce4Oasis.bash /ccc/store/cont003/gencmip6/p86mart/IGCM_OUT/IPSLCM6/DEVT/pdControl/CM6010.2.rivgeo-LR-pdCtrl/OCE/Output/MO/CM6010.2.rivgeo-LR-pdCtrl_22400101_22491231_1M_grid_T.nc 
     28## Usage exemples : 
     29# 
     30# CreateRestartOce4Oasis.bash --ocefile /ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/OCE/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_grid_T.nc --icefile /ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/ICE/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_icemod.nc --icefrc ice_pres --icetem tsice --icealb ialb 
     31# 
     32# CreateRestartOce4Oasis.bash --ocefile /ccc/store/cont003/gencmip6/p86mart/IGCM_OUT/IPSLCM6/DEVT/pdControl/CM6010.2.rivgeo-LR-pdCtrl/OCE/Output/MO/CM6010.2.rivgeo-LR-pdCtrl_22400101_22491231_1M_grid_T.nc --icefrc siconc 
     33 
     34# CreateRestartOce4Oasis.bash --ocefile /ccc/store/cont003/gen7451/personr/IGCM_OUT/ORCA025_LIM3_PISCES/DEVT/ORCA025ia/eOR025L3P-IA-REF07-MUSCL/OCE/Output/MO/eOR025L3P-IA-REF07-MUSCL_20090101_20091231_1M_grid_T.nc 
     35# 
     36# CreateRestartOce4Oasis.bash --ocefile /ccc/work/cont003/gencmip6/p48ethe/ICMC-TOOLS/DATA/eOR025L3P-IA-REF07-MUSCL_20090101_20091231_1M_grid_T.nc --icefile /ccc/work/cont003/gencmip6/p48ethe/ICMC-TOOLS/DATA/eOR025L3P-IA-REF07-MUSCL_20090101_20091231_1M_icemod.nc --icefrc siconc/oce --icetem sistem 
     37#  
     38#  
    3039## =========================================================================== 
    3140## 
     
    3948# Default values 
    4049Comment="Preliminary attempt - Do not trust !" 
    41 ##IceVar=ice_pres # siconc #> Variable containing sea ice fraction [0-1] 
    42 IceVar=siconc #> Variable containing sea ice fraction [0-1] 
     50# 
     51# --ocefile : file in which sea surface temperature is read 
     52# --icefile : file in which sea ice fraction, albedo and surface temperature are read. 
     53#             if not specified, these variables are readed in the ocean file 
     54# 
     55## Variable in ocean file : 
     56OceSst=tos      #> Variable containing sea surface temperature (°C) : --ocesst tos 
     57## Variables in ice file 
     58IceFrc=ice_pres #> Variable containing sea ice fraction [0-1]       : --icefrc ice_pres 
     59IceAlb=none     #> Variable containing sea ice albedo [0-1]. If 'none', set to 0.65         : --icealb ialb 
     60IceTem=none     #> Variable containing sea ice surface temperature (°C). If 'none', set to -20°C : --icetem tsice 
     61 
     62# Complementary syntaxes for variables names 
     63# --icefrc siconc/oce means that siconc variable should be taken in the ocean file ... 
     64# --icealb ialb/oce 
     65# --icetem tsice/oce 
     66 
     67## Filling 
     68# If the ocean in the coupled model has a different geometry that the one in the files. 
     69# In general, the forced ocean does run with no closed sea, when the coupled model does. 
     70# This step is he mandatory 
     71Fill=yes # If yes, fill the continents. --fill / --nofill 
     72 
     73# nperio parameter for ORCA. Normally guess from name or dimensions. For ORCA2, set to nperio=4, but should be set to nperio=6 for some paleo configs 
     74# --nperio 4 
     75 
     76DefaultIceAlb=0.65 
     77DefaultIceTem=-20.0 
     78 
     79#OceFile=/ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/OCE/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_grid_T.nc 
     80#OceFile=/ccc/store/cont003/gencmip6/p86mart/IGCM_OUT/IPSLCM6/DEVT/pdControl/CM6010.2.rivgeo-LR-pdCtrl/OCE/Output/MO/CM6010.2.rivgeo-LR-pdCtrl_22400101_22491231_1M_grid_T.nc 
     81# 
    4382 
    4483# 
    4584# Defines computer 
    4685# ================ 
    47 if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi 
    4886if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi 
    4987 
    5088case ${arch} in 
    51     ( curie | irene ) 
     89    ( irene ) 
    5290    set +vx 
    5391    module unload cdo nco ferret 
    5492    module unload netcdf hdf5 
    5593    module load python # /2.7.12 
    56     module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS 
     94    #module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS 
    5795    module load nco 
     96    module load python3 
    5897    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM 
    5998    TMPDIR=${SCRATCHDIR}/TMP 
     
    68107set -e 
    69108 
     109Nperio="" 
     110 
    70111while [[ ${1} = -* ]] ; do 
    71112    case ${1} in 
    72113        ( -- ) shift ; break ;; 
    73         ( -c   | --comment  ) shift ; Comment=${1} ;; 
    74         ( -i   | --ice      ) shift ; IceVar=${1}  ;; 
    75         ( -a   | --alb      ) shift ; AlbVar=${1}  ;; 
     114        ( -c   | --comment  ) shift ; Comment=${1}  ;; 
     115        ( --ocefile         ) shift ; OceFile=${1}  ;; 
     116        ( --icefile         ) shift ; IceFile=${1}  ;; 
     117        ( --ocesst          ) shift ; OceSst=${1}   ;; 
     118        ( --icefrc          ) shift ; IceFrc=${1}   ;; 
     119        ( --icetem          ) shift ; IceTem=${1}   ;; 
     120        ( --icealb          ) shift ; IceAlb=${1}   ;; 
     121        ( --fill            ) Fill="yes" ;; 
     122        ( --nofill          ) Fill="no"  ;; 
     123        ( --nperio          ) shift ; Nperio="--nperio ${1}" ;; 
    76124        ( -v | --verbose    ) set -o verbose   ;; 
    77125        ( -x | --xtrace     ) set -o xtrace    ;; 
     
    82130        ( -XV | -VX         ) set +o xtrace verbose    ;; 
    83131        ( -E                ) set +e           ;; 
    84         ( -* ) echo ${Bold}"Unknown option : ${1}"${Norm} ; return 1 ;; 
     132        ( -* ) echo ${Bold}"Unknown option : ${1}"${Norm} ; exit 1 ;; 
    85133    esac 
    86134    shift 
    87135done 
    88136 
    89 OceFile=${1:-/ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/OCE/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_grid_T.nc} 
    90  
    91 #OceFile=${1:-/ccc/store/cont003/gencmip6/p86mart/IGCM_OUT/IPSLCM6/DEVT/pdControl/CM6010.2.rivgeo-LR-pdCtrl/OCE/Output/MO/CM6010.2.rivgeo-LR-pdCtrl_22400101_22491231_1M_grid_T.nc} 
    92 # 
    93  
    94137# 
    95138# Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits 
     
    100143## Defines associated sea ice file 
    101144## =========================================================================== 
    102 ###IceFile=$(echo ${OceFile} | sed 's=/OCE/=/ICE/=' | sed 's=grid_T=icemod=') 
    103 IceFile=${OceFile} 
     145if [[ -z ${IceFile} ]] ; then IceFile=${OceFile} ; fi 
     146IceFrcFile=${IceFile} 
     147IceTemFile=${IceFile} 
     148IceAlbFile=${IceFile} 
     149 
     150## Select file for each variable 
     151OceSstFile=${OceFile} 
     152if [[ ${OceSst} = */ice ]] ; then 
     153    OceSstFile=${IceFile} 
     154    OceSst=${OceSst%%/*} 
     155fi 
     156 
     157 
     158if [[ ${IceAlb} = */oce ]] ; then 
     159    IceAlbFile=${OceFile} 
     160    IceAlb=${IceFrc%%/*} 
     161fi 
     162if [[ ${IceFrc} = */oce ]] ; then 
     163    IceFrcFile=${OceFile} 
     164    IceFrc=${IceFrc%%/*} 
     165fi 
     166if [[ ${IceTem} = */oce ]] ; then 
     167    IceTemFile=${OceFile} 
     168    IceTem=${IceTem%%/*} 
     169fi 
     170 
     171 
     172echo "Oce sst         - Variable ${OceSst} - File ${OceSstFile}" 
     173echo "Ice fraction    - Variable ${IceFrc} - File ${IceFrcFile}" 
     174echo "Ice albedo      - Variable ${IceAlb} - File ${IceAlbFile}" 
     175echo "Ice temperature - Variable ${IceTem} - File ${IcetemFile}" 
     176 
    104177 
    105178## 
    106179## Extract variables 
    107180## =========================================================================== 
    108 ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${IceVar} ${IceFile} sstoce_fields.nc 
    109 ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable tos       ${OceFile} oce_fields.nc 
    110 ncks --append --fl_fmt=${FL_FMT} --history oce_fields.nc   sstoce_fields.nc 
     181ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${IceFrc} ${IceFrcFile} sstoce_fields.nc 
     182ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${OceSst} ${OceSstFile} oce_sst.nc 
     183 
     184ncks --append    --fl_fmt=${FL_FMT} --history oce_sst.nc   sstoce_fields.nc 
     185if [[ "X${IceAlb}" != "Xnone" ]] ; then 
     186    ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${IceAlb} ${IceAlbFile} ice_alb.nc 
     187    ncks --append    --fl_fmt=${FL_FMT} --history ice_alb.nc   sstoce_fields.nc 
     188fi 
     189if [[ "X${IceTem}" != "Xnone" ]] ; then 
     190    ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${IceTem} ${IceTemFile} ice_tem.nc 
     191    ncks --append    --fl_fmt=${FL_FMT} --history ice_tem.nc   sstoce_fields.nc 
     192fi 
    111193ncwa --overwrite --fl_fmt=${FL_FMT} --history --average time_counter sstoce_fields.nc sstoce_fields_notime.nc # Remove time dimension 
    112194ncatted --history --attribute history,global,d,c,""  sstoce_fields_notime.nc           # Clean attributes 
     
    115197## Find ocean name 
    116198## =========================================================================== 
    117 dim_y=$(ncdump -h sstoce_fields_notime.nc | grep "y *=" | awk '{print $3}' ) 
     199dim_y=$(ncdump -h sstoce_fields_notime.nc | grep "y *=" | grep -v "nvertex" | awk '{print $3}' ) 
    118200dim_x=$(ncdump -h sstoce_fields_notime.nc | grep "x *=" | grep -v "nvertex" | awk '{print $3}' ) 
    119201echo ${dim_x} ${dim_y} 
    120202 
    121 [[ ${dim_x} = 182 && ${dim_y} = 149 ]] && OCE=ORCA2.3 
    122 [[ ${dim_x} = 362 && ${dim_y} = 332 ]] && OCE=eORCA2.1 
     203[[ ${dim_x} =  182 && ${dim_y} = 149 ]] && OCE=ORCA2.3 
     204[[ ${dim_x} =  362 && ${dim_y} =  332 ]] && OCE=eORCA1.2 
    123205[[ ${dim_x} = 1442 && ${dim_y} = 1207 ]] && OCE=eORCA025.1 
    124206 
    125  
    126207## 
    127208## Creates sstoce file 
    128209## =========================================================================== 
    129  
    130210cat <<EOF > create_sstoce.nco 
    131 OIceFrc[y,x]   = double ( ${IceVar}(:,:) ) ;  
    132 //tos.simple_fill_miss(tos)               ; 
    133 O_SSTSST[y,x]  = double ( (tos   (:,:) + 273.15d) * (1.0d-OIceFrc(:,:)) ) ; 
    134 //O_AlbIce[y,x]  = double ( ialb   (:,:)            * OIceFrc(:,:)   ) ; 
    135 //O_TepIce[y,x]  = double ( (tsice (:,:) + 273.15d) * OIceFrc(:,:)   ) ; 
    136 O_AlbIce[y,x]  = double (   0.65d            * OIceFrc(:,:)   ) ; 
    137 O_TepIce[y,x]  = double ( (-20.0d + 273.15d) * OIceFrc(:,:)   ) ; 
     211*OceSst[y,x]    = double ( ${OceSst}(:,:) + 273.15d ) ; 
     212OIceFrc[y,x]   = double ( ${IceFrc}(:,:) ) ;  
     213// 
     214EOF 
     215 
     216if [[ "X${IceAlb}" != "Xnone" ]] ; then 
     217    cat <<EOF >> create_sstoce.nco 
     218*IceAlb[y,x]  = double ( ${IceAlb}(:,:) ) ; 
     219// 
     220EOF 
     221else 
     222     cat <<EOF >> create_sstoce.nco 
     223*IceAlb[y,x] = double ( ${DefaultIceAlb}d ) ; 
     224// 
     225EOF 
     226fi 
     227 
     228if [[ "X${IceTem}" != "Xnone" ]] ; then 
     229    cat <<EOF >> create_sstoce.nco 
     230*IceTem[y,x] = double ( ${IceTem}(:,:) + 273.15d ) ; 
     231// 
     232EOF 
     233else 
     234     cat <<EOF >> create_sstoce.nco 
     235*IceTem[y,x] = double ( ${DefaultIceTem}d + 273.15d ) ; 
     236// 
     237EOF 
     238fi 
     239 
     240cat <<EOF >>  create_sstoce.nco 
     241O_SSTSST[y,x]  = OceSst (:,:) * (1.0d-OIceFrc(:,:)) ; 
     242O_AlbIce[y,x]  = IceAlb (:,:)       * OIceFrc(:,:)  ; 
     243O_TepIce[y,x]  = IceTem (:,:)       * OIceFrc(:,:)  ; 
    138244O_OCurx1[y,x]  = 0.0d ; 
    139245O_OCury1[y,x]  = 0.0d ; 
     
    143249ncap2 --overwrite --fl_fmt=${FL_FMT} --history --script-file create_sstoce.nco sstoce_fields_notime.nc tmp_sstoc.nc 
    144250ncks --fl_fmt=${FL_FMT} --overwrite --history --variable OIceFrc,O_SSTSST,O_AlbIce,O_TepIce,O_OCurx1,O_OCury1,O_OCurz1 tmp_sstoc.nc sstoc.nc 
    145 ncatted --history --attribute comment,O_SSTSST,o,c,"SST weighted by fraction of open ocean"          sstoc.nc 
    146 ncatted --history --attribute comment,O_AlbIce,o,c,"Albedo weighted by fraction of sea ice"          sstoc.nc 
    147 ncatted --history --attribute comment,O_TepIce,o,c,"Ice temperature weighted by fraction of sea ice" sstoc.nc 
    148  
    149 ## 
    150 ## Add some information in file headers 
     251ncatted --history --attribute long_name,O_SSTSST,o,c,"SST weighted by fraction of open ocean"          sstoc.nc 
     252ncatted --history --attribute long_name,O_AlbIce,o,c,"Albedo weighted by fraction of sea ice"          sstoc.nc 
     253ncatted --history --attribute long_name,O_TepIce,o,c,"Ice temperature weighted by fraction of sea ice" sstoc.nc 
     254 
     255ncatted --history --attribute comment,O_SSTSST,o,c,"Variable ${OceSst} taken in ${OceSstFile}"  sstoc.nc 
     256ncatted --history --attribute comment,OIceFrc,o,c,"Variable ${IceFrc} taken in ${IceFrcFile}"   sstoc.nc 
     257 
     258if [[ ${IceAlb} = none ]] ; then  ncatted --history --attribute comment,O_AlbIce,o,c,"Set to ${DefaultIceAlb}"  sstoc.nc 
     259else                              ncatted --history --attribute comment,O_AlbIce,o,c,"Variable ${IceAlb} taken in ${IceAlbFile}"  sstoc.nc 
     260fi 
     261if [[ ${IceTem} = none ]] ; then  ncatted --history --attribute comment,O_TepIce,o,c,"Set to ${DefaultIceTem}"  sstoc.nc 
     262else                              ncatted --history --attribute comment,O_TepIce,o,c,"Variable ${IceTem} taken in ${IceTemFile}"  sstoc.nc 
     263fi 
     264 
     265## 
     266## Filling the fields 
     267## =========================================================================== 
     268if [[ ${Fill} = yes ]] ; then 
     269    mv sstoc.nc sstoc_nofilled.nc 
     270    python3 FillOceRestart.py --input sstoc_nofilled.nc --output sstoc.nc ${Nperio} 
     271fi 
     272 
     273## 
     274## Add some information in file header 
    151275## =========================================================================== 
    152276 
     
    183307## Cleaning 
    184308## =========================================================================== 
    185 rm -f sstoce_fields.nc sstoce_fields_notime.nc tmp_flxat.nc oce_fields.nc 
     309#rm -f sstoce_fields.nc sstoce_fields_notime.nc tmp_sstoce.nc oce_fields.nc 
    186310 
    187311mv sstoc.nc sstoc_${OCE}.nc 
  • TOOLS/CPLRESTART/FillOceRestart.py

    r4249 r4289  
    5050 -o <file>    | --output=<file>        : output file (default : build a name form input file) 
    5151 -r           | --replace              : replace input file by new file with filled variables 
    52  -v <varlist> | --variable=<variables> : list of variable to fill (defautlt: all variable in file) 
     52 -v <varlist> | --variable=<variables> : list of variable to fill (default: all variable in file) 
    5353 -x           | --exclude              : fills all variable in files, except those given in -v|--variable 
    5454 -n <perio>   | --perio=<perio> : periodicity type (default: try to guess) 
     
    9292            sys.exit(1) 
    9393        else : 
    94             if Debug : print ("Out file set to "+OuFile) 
    9594            OuFile   = myval ; 
     95            if Debug : print ("Out file set to " + OuFile) 
    9696    elif myopt in [ '-r', '--replace' ] : 
    9797        if OuFile != None : 
     
    111111            ListExclude = ListVarName 
    112112            ListVarName  = None 
    113   
     113 
    114114if OuFile == None : 
     115    print ( 'Definition OuFile' ) 
    115116    OuFile = InFile.replace ( ".nc", "_filled.nc" ) 
    116     print ("Creates output file name: "+OuFile) 
     117    print ("Creates output file name: " + OuFile) 
    117118 
    118119# Copy the input file if needed 
     
    131132    print ("Grid dimensions: ("+str(jpoj)+", "+str(jpoi)+")") 
    132133    if   'ORCA2' in InFile : 
     134        nperio=4 
    133135        print ("ORCA 2 grid found from file name: nperio may vary for this configuration") 
    134         print ("Choosen nperio=4") 
     136        print ("Choosen nperio=" + str(nperio) ) 
    135137    elif 'ORCA1' in InFile : 
    136         if 'eORCA1' in InFile :  
    137             print ("eORCA 1 grid found from file name, nperio=6") 
     138        if 'eORCA1' in InFile : 
     139            nperio=6 
     140            print ("eORCA 1 grid found from file name, nperio=" + str(nperio)) 
    138141        else : 
    139             print ("ORCA 1 grid found from file name, nperio=6") 
     142            nperio=6 
     143            print ("ORCA 1 grid found from file name, nperio=" + str(nperio)) 
    140144    elif (jpoj, jpoi) == (149, 182) : 
     145        nperio = 4 
    141146        print ("ORCA 2 grid found from dimension: nperio may vary for this configuration") 
    142         print ("Choosen nperio=4") 
    143         nperio = 4 
     147        print ("Choosen nperio=" + str(nperio)) 
    144148    elif (jpoj, jpoi) == (332, 292) : 
    145149        nperio = 6 
    146         print ("ORCA1 grid found from dimensions, nperio=6" ) 
     150        print ("ORCA1 grid found from dimensions, nperio" + str(nperio) ) 
    147151    elif (jpoj, jpoi) == (332, 362) : 
    148152        nperio = 6 
    149         print ("eORCA1 grid found from dimensions, nperio=6" ) 
     153        print ("eORCA1 grid found from dimensions, nperio" + str(nperio) ) 
    150154    elif (jpoj, jpoi) == (1021, 1442) : 
    151         nperio = 4 
    152         print ("ORCA025 grid found from dimensions, nperio=6" ) 
     155        nperio = 6 
     156        print ("ORCA025 grid found from dimensions, nperio" + str(nperio) ) 
    153157    elif (jpoj, jpoi) == (1207, 1442) : 
    154         nperio = 4 
    155         print ("eORCA025 grid found from dimensions, nperio=6" ) 
     158        nperio = 6 
     159        print ("eORCA025 grid found from dimensions, nperio=" + str(nperio) ) 
    156160         
    157161if nperio == None : 
Note: See TracChangeset for help on using the changeset viewer.