Changeset 6072 for trunk/TOOLS


Ignore:
Timestamp:
2019-06-27T16:33:04+02:00 (5 years ago)
Author:
josefine.ghattas
Message:

Add script to create soil moisture nudging files for running mean to be used for LS3MIP (CMIP6).

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/TOOLS/NUDGING_FILE/Job_moistc_runningmedian.sh

    r6029 r6072  
    1 #MSUB -r moistcr1 
    2 #MSUB -o moistc.out_%I 
    3 #MSUB -e moistc.out_%I 
     1#MSUB -r moistc_rmssp126 
     2#MSUB -o moistc_rmssp126.out_%I 
     3#MSUB -e moistc_rmssp126.out_%I 
    44#MSUB -n 1 
    55#MSUB -T 36000 
     
    1010#MSUB -m store,work,scratch 
    1111##MSUB -A ls3cmip6  
    12 set +vx 
     12set -vx 
     13#!/bin/bash 
    1314 
    14 # Script to create nudging file for soil moisture.  
    15 # This creates a climatology of the soil moisture over 1980-2014 with daily frequency. 
     15# Script to create nudging files for soil moisture climatology derived from 30 year running mean 
     16# This creates running mean climatology of the soil moisture with daily frequency, starting with  
     17# the historical siumlation and then using one scenario. 
    1618# 
    17 # 1. Daily output for the years 1980-2014 from the simulation CM61-LR-hist-03.1910 are used. 
     19# 1. Daily output for the years 1980-2014 from the simulation CM61-LR-hist-03.1910 and for the years 
     20#    2015-210O from sceanario simulation CM61-LR-scen-ssp126 or CM61-LR-scen-585 are used 
    1821# 2. The variable moistc is first splitted into moistc_1, moistc_2, moistc_3 to remove the axes on soiltiles. 
    1922# 3. For years with 366 days, the 31 of decembre is removed to enable making the median over all years. 
    20 # 4. The median is calculated over the whole period 1980-2014 to obtain one year climatologie file with daily frequency. 
    21 # 5. The last day is duplicated to have 366 days in the file.  
     23# 4. For each year in the intervall 1994-2085, the median is calculated using 30years in total with the current year in the middle.  
     24#    For the first 15 years 1980-1995: the median for the first 30years will be used => running median for year 1994 
     25#    For the last 15 years 2085-2100: the median for the last 30years will be used => running meadian for year 2085 
     26# 5. For each year, the last day is duplicated to have 366 days in each file.  
    2227# 
    2328# $HeadURL$ 
     
    2732date 
    2833JobName=CM61-LR-hist-03.1910 
    29 mkdir run_moistc_${JobName} 
    30 cd run_moistc_${JobName} 
     34ssp=ssp126 
     35#ssp=ssp585 
     36JobNameScen=CM61-LR-scen-${ssp} 
     37mkdir run_moistc_rm_${JobName}_${JobNameScen} 
     38cd run_moistc_rm_${JobName}_${JobNameScen} 
    3139 
    3240echo Start 
    3341# 1. historical r1: CM61-LR-hist-03.1910 
    34 simulpath=/ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM6/PROD/historical/CM61-LR-hist-03.1910/SRF/Output/DA 
    35 allpack=" 19800101_19891231 19900101_19991231 20000101_20091231 20100101_20141231 " 
     42simulpathHist=/ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/IPSLCM6/PROD/historical/CM61-LR-hist-03.1910/SRF/Output/DA 
     43simulpathScen=/ccc/store/cont003/gencmip6/oboucher/IGCM_OUT/IPSLCM6/PROD/${ssp}/${JobNameScen}/SRF/Output/DA 
     44 
     45allpackHist=" 19800101_19891231 19900101_19991231 20000101_20091231 20100101_20141231 " 
     46allpackScen=" 20150101_20241231 20250101_20341231 20350101_20441231 20450101_20541231 20550101_20641231 20650101_20741231 20750101_20841231 20850101_20941231 20950101_21001231 " 
    3647 
    3748# 2. Extract moistc 
    38 echo Extract variable moistc from pack files 
     49#    First from historical simulation and then also from scenario simulation 
     50echo Extract variable moistc from packed files 
    3951# float moistc(time_counter, soiltyp, solay, lat, lon) 
    4052 
    41 for pack in ${allpack} ; do 
    42   echo Treat file ${simulpath}/${JobName}_${pack}_DA_sechiba_out_2.nc 
    43   ncks -v moistc ${simulpath}/${JobName}_${pack}_DA_sechiba_out_2.nc moistc_${pack}_DA_sechiba_out_2.nc 
     53for pack in ${allpackHist} ; do 
     54  echo Treat file ${simulpathHist}/${JobName}_${pack}_DA_sechiba_out_2.nc 
     55  ncks -v moistc ${simulpathHist}/${JobName}_${pack}_DA_sechiba_out_2.nc moistc_${pack}_DA_sechiba_out_2.nc 
    4456done 
    4557 
    46 echo Separate into variables per soiltile 
    47 for pack in ${allpack} ; do 
     58for pack in ${allpackScen} ; do 
     59  echo Treat file ${simulpathScen}/${JobNameScen}_${pack}_DA_sechiba_out_2.nc 
     60  ncks -v moistc ${simulpathScen}/${JobNameScen}_${pack}_DA_sechiba_out_2.nc moistc_${pack}_DA_sechiba_out_2.nc 
     61done 
     62 
     63 
     64echo Separate into variables per soiltile, for historical and scenario 
     65for pack in ${allpackHist} ${allpackScen} ; do 
    4866  ncks -d soiltyp,0,0 moistc_${pack}_DA_sechiba_out_2.nc moistc1_${pack}_DA_sechiba_out_2.nc 
    4967  ncks -d soiltyp,1,1 moistc_${pack}_DA_sechiba_out_2.nc moistc2_${pack}_DA_sechiba_out_2.nc 
     
    5573done 
    5674 
    57 echo Remove dimension soiltyp (which is now 1) by averaging over the dimension. Put all variables in the same file. 
    58 for pack in ${allpack} ; do 
     75 
     76echo "Remove dimension soiltyp (which is now 1) by averaging over the dimension. Put all variables in the same file." 
     77 
     78for pack in ${allpackHist} ${allpackScen} ; do 
    5979  for soiltyp in 1 2 3 ; do 
    6080    ncwa -A -a soiltyp  moistc${soiltyp}_${pack}_DA_sechiba_out_2.nc moistc_allsoil_${pack}_DA_sechiba_out_2.nc  
     
    6686 
    6787echo Separate per year 
    68 for pack in ${allpack} ; do 
     88for pack in ${allpackHist} ${allpackScen} ; do 
    6989  cdo splityear moistc_allsoil_${pack}_DA_sechiba_out_2.nc moistc_ 
    7090done 
    7191 
    7292# 3. Remove one time step in leap years 
    73 echo Remove last time step 31 of december from leap years 
     93echo Remove last time step (31 of december) from leap years 
    7494allleap=" 1980 1984 1988 1992 1996 2000 2004 2008 2012 " 
    75 for year in $allleap ; do 
     95allleapScen=" 2016 2020 2024 2028 2032 2036 2040 2044 2048 2052 2056 2060 2064 2068 2072 2076 2080 2084 2088 2092 2096 " 
     96for year in $allleap ${allleapScen} ; do 
    7697  mv moistc_${year}.nc moistc_${year}.leap.nc  
    7798  ncks -d time_counter,0,364 moistc_${year}.leap.nc moistc_${year}.365.nc  
     
    79100done 
    80101 
    81 # 4. Calculate the median 
     102# 4. Calculate running median over 30 years  
    82103echo Calculate median 
    83 cdo enspctl,50 moistc_????.nc moistc_clim_1980_2014.nc 
    84104 
    85 # 5. Duplicate last day to make a file with 366days 
    86 echo Duplicate last day to make a file with 366days 
    87 # Extract last day 
    88 cdo seltimestep,365 moistc_clim_1980_2014.nc moistc_clim_365.nc 
    89 # Switch time axis one day ahead 
    90 ncatted -O -a units,time_counter,m,c,"seconds since 1850-01-02 00:00:00"  moistc_clim_365.nc  
    91 # Merge with clim file 
    92 ncrcat moistc_clim_1980_2014.nc moistc_clim_365.nc moistc_clim_1980_2014_366d.nc  
     105# For the first 15 years 1980-1995: take median for the first 30years => running median for year 1994 
     106# For the last 15 years 2085-2100: take median for the last 30years => running meadian for year 2085 
     107# For the years in between, take the median using 14 years before, the current year and 15 years after 
     108 
     109# Calculate here the running median for the years 1994-2085 
     110year=1994 
     111lastyear=2085 
     112while [ ${year} -le ${lastyear} ] ; do 
     113  echo year=${year} 
     114  # Determine the list of files for 14 years before, the current year and 15 years after current year 
     115  y1=$(( ${year} - 15 )) 
     116  y2=$(( ${year} + 15 )) 
     117  filelist="" 
     118  while [ ${y1} -le ${y2} ] ; do 
     119    filelist="$filelist moistc_${y1}.nc " 
     120    let y1=${y1}+1 
     121  done 
     122  echo for year=$year filelist= $filelist 
     123 
     124  echo "Calculate median for year=$year using files: $filelist " 
     125  cdo enspctl,50 $filelist moistc_30yrm_${year}.nc  
     126 
     127 
     128  # 5. Duplicate last day to make a file with 366days 
     129  echo Duplicate last day to make a file with 366days 
     130  # Extract last day 
     131  cdo seltimestep,365 moistc_30yrm_${year}.nc moistc_clim_365.nc 
     132  # Switch time axis one day ahead 
     133  ncatted -O -a units,time_counter,m,c,"seconds since 1850-01-02 00:00:00"  moistc_clim_365.nc  
     134  # Merge with clim file 
     135  ncrcat moistc_30yrm_${year}.nc moistc_clim_365.nc moistc_30yrm_${year}.nc  
     136 
     137  let year=${year}+1 
     138done 
     139 
    93140 
    94141echo End 
Note: See TracChangeset for help on using the changeset viewer.