diff --git a/nccf_atm_monthly.sh b/nccf_atm_monthly.sh index 50477803fbd8a42f8493ec0f3b90ca1dff1c623d..4246f9df2fc12cea6e064f098c8a04d2b3aee9d0 100755 --- a/nccf_atm_monthly.sh +++ b/nccf_atm_monthly.sh @@ -46,15 +46,14 @@ function get_leadtime(){ NMONTH=9999999 for DIR in $MEM_LST do - cd ${DATADIR}/${EXPID}/${SDATE}/${DIR}/outputs + cd ${DATADIR}/${EXPID}/original_files/${SDATE}/${DIR}/outputs NFILE=0 for file in $( find . -maxdepth 1 -name "MMA*" ) do [[ $( echo $file | cut -f5 -d"_" | cut -f1 -d"-" ) -ge ${LEAD_LIST[0]}${LEAD_LIST[1]}01 ]] && [[ $( echo $file | cut -f5 -d"_" | cut -f1 -d"-" ) -le ${LEAD_LIST[2]}${LEAD_LIST[3]}01 ]] && NFILE=$(( NFILE + 1 )) done -# NFILE="$( find . -maxdepth 1 -name "MMA*" | wc -l )" - for TMPFILE in $( find . -maxdepth 1 -name "MMA*" | sed -e 's/\.\///g' ) +for TMPFILE in $( find . -maxdepth 1 -name "MMA*" | sed -e 's/\.\///g' ) do # if [[ $( echo $TMPFILE | cut -f5 -d"_" | cut -f1 -d"-" ) -ge ${LEAD_LIST[0]}${LEAD_LIST[1]}01 ]]; then NMONTHS_LOC=$(tar tvf $TMPFILE | grep GG | wc -l) @@ -98,9 +97,6 @@ function header(){ function rtime(){ DATE1=$1 DATE2=$2 -# FACTOR=day # h for hour, d for days -# echo "NFRP:",$NFRP -# FACTOR=day # h for hour, d for days YEAR1=$(echo $DATE1|cut -c1-4) MONTH1=$(echo $DATE1|cut -c5-6) DAY1=$(echo $DATE1|cut -c7-8) @@ -109,14 +105,6 @@ function rtime(){ DAY2=$(echo $DATE2|cut -c7-8) SEC1=$(date --utc --date "${YEAR1}-${MONTH1}-${DAY1}" +%s) SEC2=$(date --utc --date "${YEAR2}-${MONTH2}-${DAY2}" +%s) -# case $FACTOR in -# hour) -# FACTOR=3600 # 60*60 -# ;; -# day) -# FACTOR=86400 # 60*60*24 -# ;; -# esac REFTIME_VALUE=$(((SEC2-SEC1)/FACTOR)) } @@ -156,17 +144,11 @@ function get_hours(){ function extract(){ -#typeset var jt -#typeset var YEAR0 -#typeset var YEARF -#typeset var MON0 -#typeset var MONF - for MEM in ${MEM_LST[@]}; do # untar and unzip MMA SH files and GG files if [ -z $( echo ${LEAD_LIST[@]} ) ];then - PATH_TO_SEARCH=${DATADIR}/${EXPID}/${SDATE}/$MEM + PATH_TO_SEARCH=${DATADIR}/${EXPID}/original_files/${SDATE}/$MEM FILE_LIST=$(find $PATH_TO_SEARCH -type f -iname "MMA*" 2> /dev/null) else export YEAR0=${LEAD_LIST[0]} @@ -179,9 +161,9 @@ else export LTIME0=1 export LTIMEF=$(( ( ($YEARF - $YEAR0) * 12 + 10#$MONF - 10#$MON0+1 )/$CHUNK_SIZE )) jt=$LTIME0 + FILE_LIST="" while [ $jt -le $((LTIMEF)) ] do - FILE_LIST="" YEAR1=$(( $YEAR0 +(10#$MON0+($jt-1)*$CHUNK_SIZE - 1 )/ 12 )) MON1=$(( ( 10#$MON0 + ( $jt - 1 ) * ($CHUNK_SIZE) ) % 12)) MON1=$(echo $(printf "%02d" $(( 10#$MON1))) ) @@ -192,9 +174,9 @@ else [[ 10#$MON2 -eq 0 ]] && MON2=12 [[ 10#$MON2 -eq 12 ]] && YEAR2=$(( $YEAR2 - 1 )) jt=$(($jt+1)) - FILE="$( find ${DATADIR}/${EXPID}/${SDATE}/*/outputs/ -maxdepth 1 -name "MMA_${EXPID}_${SDATE}_${MEM}_${YEAR1}"$(printf "%02d" $((10#$MON1)))"01-${YEAR2}"$(printf "%02d" $((10#$MON2)))"*.tar" )" + FILE="$( find ${DATADIR}/${EXPID}/original_files/${SDATE}/*/outputs/ -maxdepth 1 -name "MMA_${EXPID}_${SDATE}_${MEM}_${YEAR1}"$(printf "%02d" $((10#$MON1)))"01-${YEAR2}"$(printf "%02d" $((10#$MON2)))"*.tar" )" if [[ -z ${FILE} ]]; then - echo "Expected file ${DATADIR}/${EXPID}/${SDATE}/${MEM}/outputs/MMA_${EXPID}_${SDATE}_${MEM}_${YEAR1}${MON1}01-${YEAR2}${MON2}*.tar not found, check your Namelist parameters" + echo "Expected file ${DATADIR}/${EXPID}/original_files/${SDATE}/${MEM}/outputs/MMA_${EXPID}_${SDATE}_${MEM}_${YEAR1}${MON1}01-${YEAR2}${MON2}*.tar not found, check your Namelist parameters" exit fi FILE_LIST="$FILE_LIST ${FILE}" @@ -211,15 +193,7 @@ fi tar xvf ${f} ${FILE} ;gunzip -q ${FILE}; mv ${FILE%???} ${FILE%???}.$MEM done done -echo "jt ltimef " $jt $((LTIMEF)) -if [ $jt -le $((LTIMEF)) ]; then - echo le -else - echo gt -fi -echo "sortie de extract" $MEM -- ${MEM_LST[@]} done -echo "sortie de extract" } function read_vars(){ @@ -268,7 +242,7 @@ for MEM in ${MEM_LST[@]}; do nb_months_asked=$(( ( ($YEARF - $YEAR0) * 12 + 10#$MONF - 10#$MON0+1 ) )) if [[ $NLT -ne $nb_months_asked ]];then - echo "Warning, the number of months in MMA ($nb_files) is different from the number of months you required according to the LEADLIST",$(( ( ($YEARF - $YEAR0) * 12 + $MONF - $MON0+1 )))," check your configfile!" + echo "Warning, the number of months in MMA ($nb_files) is different from the number of months you required according to the LEADLIST",$(( ( ($YEARF - $YEAR0) * 12 + 10#$MONF - $MON0+1 )))," check your configfile!" exit fi #### process each variable #### @@ -365,7 +339,6 @@ fi esac done # loop for VAR done # loop for members -echo "after loop on members in surface" # finish selecting the variables @@ -373,13 +346,11 @@ echo "after loop on members in surface" for VAR in ${VAR_LST_2D[@]}; do new_name $VAR pathout=${SAVEDIR}/${EXPID}/monthly_mean/${varnew}_f${NFRP}h - pathout=${SAVEDIR}/${EXPID}/monthly_mean/${varnew}_f${NFRP}h mkdir -m ug+w -m o-w -p $pathout LSMBSH="${LISTMEMB[0]}-${LISTMEMB[${#LISTMEMB[@]}-1]}" # PREVIOUS_FILE="$(ls -tr ${SAVEDIR}/${EXPID}/monthly_mean/${varnew}_${NFRP}hourly/${varnew}_${SDATE}_*.nc | tail -1)" (if left like this, we have the "no such file" pb. but if we chose the "find" option, we can sort the files and get hte last one edited => have to make a find to be sure there are some previous_files and then, if so, get the actual previous_file with the ls command. #savedir PREVIOUS_FILE="$( find ${pathout} -maxdepth 1 -name "${varnew}_${SDATE}_*.nc" )" -echo okkkk if [ ! -z $( ls $PREVIOUS_FILE ) ] ; then PREVIOUS_FILE="$(ls -tr ${pathout}/${varnew}_${SDATE}_*.nc | tail -1)" cd ${pathout} @@ -403,11 +374,7 @@ echo okkkk else echo "Some members are going to be treated twice! If you are not adding new lead_times, revise the consistency between your member list and the previously processed files" fi -echo ok2 fi -echo ok3 -pwd -ls YRSO=${YEAR0}$(printf "%02d" $(( 10#$MON0)))_${YEARF}$(printf "%02d" $(( 10#$MONF))) gather_memb tmp_${varnew}_$SDATE ${varnew}_${SDATE}_fc${LSMBSH}_${YRSO}.nc $varnew $VAR @@ -434,21 +401,17 @@ output=${varnew}_${SDATE}_fc${LSMBSH}_${YRSO}.nc # #if [[ $idx -ne 40 ]]; then for att in units valid_range actual_range code table GRID_TYPE ; do - ncatted -O -h -a ${att},${varnew},d,c, ${output} + ncatted -O -h -a ${att},${varnew},d,c, ${output} done # -# Adding and modifying the {varnew}iable attributes +# Adding and modifying the variable attributes # ncatted -O -h -a _FillValue,${varnew},a,f,1.e+12 ${output} - ncatted -O -h -a standard_name,${varnew},o,c,"$cfustandard_name" ${output} # {varnew}iable standard name - ncatted -O -h -a long_name,${varnew},o,c,"$cfulong_name" ${output} # {varnew}iable long name - ncatted -O -h -a cell_methods,${varnew},o,c,"$cfucell_methods" ${output} # {varnew}iable cell methods - ncatted -O -h -a unit_long,${varnew},o,c,"$cfuunit_long" ${output} # {varnew}iable long unit name - ncatted -O -h -a units,${varnew},o,c,"$cfuunit" ${output} # {varnew}iable units -#fi -# ncatted -O -h -a data_type,level_${varnew},o,c,"$cfulevel_type" ${output} # {varnew}iable level type -# ncatted -O -h -a units,level_${varnew},o,c,"$cfulevel_units" ${output} # {varnew}iable level units -# ncatted -O -h -a coordinates,${varnew},o,c,"longitude latitude reftime leadtime time_bnd experiment_id source realization institution level_${varnew}" ${output} # variable coordinates + ncatted -O -h -a standard_name,${varnew},o,c,"$cfustandard_name" ${output} # variable standard name + ncatted -O -h -a long_name,${varnew},o,c,"$cfulong_name" ${output} # variable long name + ncatted -O -h -a cell_methods,${varnew},o,c,"$cfucell_methods" ${output} # variable cell methods + ncatted -O -h -a unit_long,${varnew},o,c,"$cfuunit_long" ${output} # variable long unit name + ncatted -O -h -a units,${varnew},o,c,"$cfuunit" ${output} # variable units ncatted -O -h -a coordinates,${varnew},o,c,"longitude latitude reftime leadtime time_bnd experiment_id source realization institution " ${output} # variable coordinates # # If the NetCDF file had a horizontal axis name different from longitude @@ -456,7 +419,6 @@ output=${varnew}_${SDATE}_fc${LSMBSH}_${YRSO}.nc ncrename -h -d lon,longitude -v lon,longitude ${output} [[ ! -z $( ncdump -h ${output} | grep record ) ]] && ncrename -h -d record,ensemble ${output} -# [[ ! -z $( ncdump -h ${output} | grep ensemble ) ]] && ncrename -h -d record,ensemble ${output} # # If the NetCDF file had a vertical axis name different from latitude # @@ -466,25 +428,13 @@ output=${varnew}_${SDATE}_fc${LSMBSH}_${YRSO}.nc # ncatted -O -h -a axis,longitude,o,c,"X" ${output} # variable longitude axis ncatted -O -h -a axis,latitude,o,c,"Y" ${output} # variable latitude axis -#[[ $idx -ne 40 ]] && -# ncatted -O -h -a axis,level_${varnew},o,c,"Z" ${output} # variable level axis # modify level information # reshape the dimension and make time unlimited -# [[ ! -z $( ncdump -h ${output} | grep record ) ]] && ncpdq -O -h -a time,ensemble ${output} ${output} [[ ! -z $( ncdump -h ${output} | grep ensemble ) ]] && ncpdq -O -h -a time,ensemble ${output} ${output} cp ${output} hhh.nc ncks -h -A header.nc ${output} -#if [[ $idx -ne 40 ]]; then nt=$(cdo ntime ${output}) -# ncatted -O -h -a standard_name,level_${varnew},c,c,"height" ${output} # standard name -# ncatted -O -h -a long_name,level_${varnew},c,c,"reference height" ${output} # long name -# ncatted -O -h -a data_type,level_${varnew},c,c,"float" ${output} # data type -# ncatted -O -h -a units,level_${varnew},c,c,"m" ${output} # units -# ncatted -O -h -a axis,level_${varnew},c,c,"Z" ${output} # axis -# ncatted -O -h -a positive,level_${varnew},c,c,"up" ${output} -# ncap2 -O -h -s "level_${varnew}=float(${cfulevel_number})" $output $output -#fi # delete history ncatted -h -a history,global,d,, $output # change institution name @@ -545,8 +495,6 @@ function new_name(){ #to be rethought: make a match between var_name and xml ta idx=28 ;; "SSTK") -# "SST") -#weird... VAR=SSTK varnew=tos idx=10 ;; @@ -654,7 +602,6 @@ function new_name(){ #to be rethought: make a match between var_name and xml ta varnew=cl idx=35 ;; -#pab!!!! new variables to be added when variable list read directly in outputs, some are missing "var78") varnew=tclw idx=38 @@ -700,8 +647,6 @@ function gather_memb() { # Created in May 2012 Author : vguemas@ic3.cat # Adapted for atmospherical outputs January 2013 pierre-antoine.bretonniere@ic3.cat -# OLD_FILE=$(ls ${1}_* || echo "") -# NEW_FILES=$(ls "${1}".*) OLD_FILE="$( find . -maxdepth 1 -name "${1}_*" | sed -e 's/\.\///g' | sort -u )" NEW_FILES="$( find . -maxdepth 1 -name "${1}.*" | sed -e 's/\.\///g'| sort -u )" VAR_LOC=$3 @@ -714,20 +659,16 @@ if [[ $( echo $NEW_FILES | wc -w ) -gt 1 ]]; then ncecat -O -h tmp_cat.nc tmp_cat2.nc ncpdq -O -h -a ensemble,record tmp_cat2.nc tmp_cat2.nc ncwa -O -h -a record tmp_cat2.nc tmp_cat2.nc - mv tmp_cat2.nc tmp_cat.nc #new + mv tmp_cat2.nc tmp_cat.nc else mv ${NEW_FILES} tmp_cat.nc fi for var_check in $VAR_LST_3D_GG do - if [ $VAR_OLD == $var_check ];then - ncks -O -h -a -v lon,lat,$VAR_LOC tmp_cat.nc tmp_cat.nc -# ncks -O -h -a -v lon,lat,$VAR_LOC tmp_cat2.nc tmp_cat3.nc -# mv tmp_cat3.nc tmp_cat.nc -# else -# mv tmp_cat2.nc tmp_cat.nc - fi + if [ $VAR_OLD == $var_check ];then + ncks -O -h -a -v lon,lat,$VAR_LOC tmp_cat.nc tmp_cat.nc + fi done if [ ! -z $OLD_FILE ] ; then ncks -C -O -v longitude,latitude,$VAR_LOC $OLD_FILE tmp_0_${OLD_FILE} @@ -760,7 +701,6 @@ function save_final_output(){ # Select variables and levels function combine_3d(){ for MEM in ${MEM_LST[@]}; do -# FILES=$(ls MMA*SH*.nc.$MEM) FILES="$(find . -maxdepth 1 -name "MMA*SH*.nc.$MEM" | sed -e 's/\.\///g' )" echo $FILES for f in ${FILES}; do @@ -771,18 +711,17 @@ for MEM in ${MEM_LST[@]}; do done rm -f ${f} done -# FILES=$(ls MMA*GG*.nc.$MEM) FILES=$(find . -maxdepth 1 -name "MMA*GG*.nc.$MEM" | sed -e 's/\.\///g' ) for f in ${FILES}; do for var in ${VAR_LST_3D_GG[@]}; do new_name $var TMP_OUT=tmp_${varnew}_$f - case $var in #pab + case $var in Q) - cdo selname,${var} -sellevel,${LEVEL_LST} ${f} ${TMP_OUT} # + cdo selname,${var} -sellevel,${LEVEL_LST} ${f} ${TMP_OUT} ;; *) - cdo selname,${var} ${f} ${TMP_OUT} #pab + cdo selname,${var} ${f} ${TMP_OUT} ;; esac done @@ -814,7 +753,6 @@ function regrid2x2(){ done for var in ${VAR_LST_3D_GG[@]}; do new_name $var -# FILES="$(ls ${varnew}_$SDATE.*.nc)" FILES=$(find . -maxdepth 1 -name "${varnew}_$SDATE.*.nc" | sed -e 's/\.\///g' ) for f in ${FILES}; do @@ -826,51 +764,42 @@ function regrid2x2(){ function upper(){ for var in ${VAR_LST_3D[@]}; do - new_name $var - - echo ${LISTMEMB[0]} -- ${#LISTMEMB[@]} -- ${LISTMEMB[${#LISTMEMB[@]}-1]} - LSMBSH="${LISTMEMB[0]}-${LISTMEMB[${#LISTMEMB[@]}-1]}" -# PREVIOUS_FILE="$(ls ${SAVEDIR}/${EXPID}/monthly_mean/${varnew}_${NFRP}hourly/${varnew}_${SDATE}_*.nc | tail -1)" -# PREVIOUS_FILE="$( find . -maxdepth 1 -name "${SAVEDIR}/${EXPID}/monthly_mean/${varnew}_${NFRP}hourly/${varnew}_${SDATE}_*.nc" | tail -1 | sed -e 's/\.\///g' )" -#savedir -# PREVIOUS_FILE="$( find ${SAVEDIR}/${EXPID}/monthly_mean/${varnew}_${NFRP}hourly -maxdepth -name "${varnew}_${SDATE}_*.nc" | tail -1 | sed -e 's/\.\///g' )" - PREVIOUS_FILE="$( find ${SAVEDIR}/${EXPID}/monthly_mean/${varnew}_f${NFRP}h -maxdepth -name "${varnew}_${SDATE}_*.nc" | tail -1 | sed -e 's/\.\///g' )" - if [ ! -z $PREVIOUS_FILE ] ; then -# cd ${SAVEDIR}/${EXPID}/monthly_mean/${varnew}_${NFRP}hourly/; - cd ${SAVEDIR}/${EXPID}/monthly_mean/${varnew}_f${NFRP}h/; - FILE_NAME_PREVIOUS="$( find . -maxdepth 1 -name "${varnew}_${SDATE}_*.nc" | tail -1 | sed -e 's/\.\///g' )"; cd - - IDX_1ST=$(echo ${varnew}_${SDATE}_ | wc -m ) - FIRST_MEMBER_PREVIOUS=$(echo $FILE_NAME_PREVIOUS | cut -b$IDX_1ST ) - IDX_LST=$( expr $IDX_1ST + 2 ) - LAST_MEMBER_PREVIOUS=$(echo $FILE_NAME_PREVIOUS | cut -b$IDX_LST ) + new_name $var + LSMBSH="${LISTMEMB[0]}-${LISTMEMB[${#LISTMEMB[@]}-1]}" + PREVIOUS_FILE="$( find ${SAVEDIR}/${EXPID}/monthly_mean/${varnew}_f${NFRP}h -maxdepth -name "${varnew}_${SDATE}_*.nc" | tail -1 | sed -e 's/\.\///g' )" + if [ ! -z $PREVIOUS_FILE ] ; then + cd ${SAVEDIR}/${EXPID}/monthly_mean/${varnew}_f${NFRP}h/; + FILE_NAME_PREVIOUS="$( find . -maxdepth 1 -name "${varnew}_${SDATE}_*.nc" | tail -1 | sed -e 's/\.\///g' )"; cd - + IDX_1ST=$(echo ${varnew}_${SDATE}_ | wc -m ) + FIRST_MEMBER_PREVIOUS=$(echo $FILE_NAME_PREVIOUS | cut -b$IDX_1ST ) + IDX_LST=$( expr $IDX_1ST + 2 ) + LAST_MEMBER_PREVIOUS=$(echo $FILE_NAME_PREVIOUS | cut -b$IDX_LST ) #security check: - if [ $LAST_MEMBER_PREVIOUS -le $(expr ${LISTMEMB[0]} - 1 ) ] ; then - cp $PREVIOUS_FILE rg_$FILE_NAME_PREVIOUS - if [ $LAST_MEMBER_PREVIOUS -eq $(expr ${LISTMEMB[0]} - 1 ) ] ; then - LSMBSH=${FIRST_MEMBER_PREVIOUS}-${LISTMEMB[${#LISTMEMB[@]}-1]} + if [ $LAST_MEMBER_PREVIOUS -le $(expr ${LISTMEMB[0]} - 1 ) ] ; then + cp $PREVIOUS_FILE rg_$FILE_NAME_PREVIOUS + if [ $LAST_MEMBER_PREVIOUS -eq $(expr ${LISTMEMB[0]} - 1 ) ] ; then + LSMBSH=${FIRST_MEMBER_PREVIOUS}-${LISTMEMB[${#LISTMEMB[@]}-1]} + else + echo "Actual list of members does not follow directly the ones already post-processed! Check you did not forget any members at the beginning of your list" + MISSING_FIRST=$(expr ${LAST_MEMBER_PREVIOUS} + 1 ) + MISSING_LAST=$(expr ${LISTMEMB[0]} - 1 ) + LSMBSH=${FIRST_MEMBER_PREVIOUS}_${LISTMEMB[${#LISTMEMB[@]}-1]}-${MISSING_FIRST}_${MISSING_LAST} + fi else - echo "Actual list of members does not follow directly the ones already post-processed! Check you did not forget any members at the beginning of your list" - MISSING_FIRST=$(expr ${LAST_MEMBER_PREVIOUS} + 1 ) - MISSING_LAST=$(expr ${LISTMEMB[0]} - 1 ) - LSMBSH=${FIRST_MEMBER_PREVIOUS}_${LISTMEMB[${#LISTMEMB[@]}-1]}-${MISSING_FIRST}_${MISSING_LAST} - fi - else - echo "Some members are going to be treated twice! Revise the consistency between your member list and the previously processed files" - fi + echo "Some members are going to be treated twice! Revise the consistency between your member list and the previously processed files" + fi fi YRSO=${YEAR0}$(printf "%02d" $(( 10#$MON0)))_${YEARF}$(printf "%02d" $((10#$MONF))).nc [[ 10#${MONF} -le 9 ]] && [[ $( echo $MONF | wc -c) -eq 2 ]] && YRSO=${YEAR0}${MON0}_${YEARF}$(printf "%02d" ${MONF}).nc gather_memb rg_${varnew}_$SDATE ${varnew}_${SDATE}_fc${LSMBSH}_${YRSO}.nc $varnew $VAR output=${varnew}_${SDATE}_fc${LSMBSH}_${YRSO}.nc -# gather_memb rg_${varnew}_$SDATE ${varnew}_${SDATE}_${LSMBSH}.nc $varnew $VAR -# output=${varnew}_${SDATE}_${LSMBSH}.nc - rm -f ${FILES} - for CHECK_VAR in $VAR_LST_3D_SH + rm -f ${FILES} + for CHECK_VAR in $VAR_LST_3D_SH do - if [ $CHECK_VAR == $var ];then + if [ $CHECK_VAR == $var ];then ncrename -h -d lon,longitude -d lat,latitude -d lev,level ${output} ncrename -h -v lon,longitude -v lat,latitude -v lev,level ${output} - fi + fi done for CHECK_VAR in $VAR_LST_3D_GG do @@ -879,8 +808,7 @@ function upper(){ [[ ! -z $( ncdump -h ${output} | grep "mlev =" ) ]] && ncrename -h -d mlev,level -v mlev,level ${output} [[ ! -z $( ncdump -h ${output} | grep "lev =" ) ]] && ncrename -h -d lev,level -v lev,level ${output} if [[ ! -z $( ncdump -h ${output} | grep "depth =" ) ]]; then - ncrename -h -d depth,level ${output} - ncrename -h -v depth,level ${output} + ncrename -h -d .depth,level -v .depth,level ${output} fi ncrename -h -v lon,longitude -v lat,latitude ${output} fi @@ -975,15 +903,11 @@ function upper(){ ncrename -h -O -d record,ensemble $output $output fi ncpdq -O -h -a time,ensemble ${output} ${output} # reshape the dimension and make time unlimited - # ncks -h -A $HEAD_DIR/${SDATE}.nc ${output} ncks -h -A header.nc ${output} ncrename -O -h -v time,kaka $output # delete time variable ncks -O -h -x -v kaka $output $output # delete time variable ncatted -h -a history,global,d,, $output #delete history ncatted -h -a institution,global,m,c,"IC3" $output ## change institution name in global attributes -#pwd -#ls -#exit # create a script to change the EXPID, insitutution, ensember, source and realiazation i=0 # index @@ -997,7 +921,6 @@ EOF i=$((i+1)) done ## -# rm -f ${files}* save_final_output $varnew $output done # loop over variables } @@ -1008,7 +931,6 @@ EOF function maxmin(){ for VAR in ${VAR_LST_MXMN[@]}; do new_name $VAR - echo "llll" $SDATE output=${VAR}_${SDATE}.nc cp $DATADIR/${EXPID}/daily/$VAR/${VAR}_${SDATE}_*.nc.gz . gunzip ${VAR}_${SDATE}_*.nc.gz @@ -1048,13 +970,13 @@ for att in GRID_TYPE ; do ncatted -O -h -a ${att},${varnew},d,c, ${output} done # -# Adding and modifying the {varnew}iable attributes +# Adding and modifying the variable attributes # -ncatted -O -h -a standard_name,${varnew},o,c,"$cfustandard_name" ${output} # {varnew}iable standard name -ncatted -O -h -a long_name,${varnew},o,c,"$cfulong_name" ${output} # {varnew}iable long name -ncatted -O -h -a cell_methods,${varnew},o,c,"$cfucell_methods" ${output} # {varnew}iable cell methods -ncatted -O -h -a data_type,level_${varnew},o,c,"$cfulevel_type" ${output} # {varnew}iable level type -ncatted -O -h -a units,level_${varnew},o,c,"$cfulevel_units" ${output} # {varnew}iable level units +ncatted -O -h -a standard_name,${varnew},o,c,"$cfustandard_name" ${output} # variable standard name +ncatted -O -h -a long_name,${varnew},o,c,"$cfulong_name" ${output} # variable long name +ncatted -O -h -a cell_methods,${varnew},o,c,"$cfucell_methods" ${output} # variable cell methods +ncatted -O -h -a data_type,level_${varnew},o,c,"$cfulevel_type" ${output} # variable level type +ncatted -O -h -a units,level_${varnew},o,c,"$cfulevel_units" ${output} # variable level units ncatted -O -h -a coordinates,${varnew},o,c,"longitude latitude reftime leadtime time_bnd experiment_id source realization institution level_${varnew}" ${output} # # Adding variable axis @@ -1107,16 +1029,11 @@ export WORKDIR FACTOR=$((NFRP*3600)) ENSEMBLE=${#MEM_LST[@]} if [[ $ENSEMBLE -eq 0 ]]; then - MEM_LST=( $( ls ${DATADIR}/${EXPID}/${SDATE} ) ) + MEM_LST=( $( ls ${DATADIR}/${EXPID}/original_files/${SDATE} ) ) ENSEMBLE=${#MEM_LST[@]} echo "Warning: you passed an empty member list. By default, it will treat all the available members: " ${MEM_LST[@]} fi LISTMEMB=( $(echo ${MEM_LST[@]} | sed -e 's/fc//g') ) #member list without "fc" -echo ${MEM_LST[0]} -echo $LISTMEMB -echo ${LISTMEMB[0]} -echo ${LISTMEMB[${#LISTMEMB[@]}-1]} -echo ${#LISTMEMB[@]} rm -rf ${WORKDIR} mkdir -p ${WORKDIR} @@ -1126,23 +1043,22 @@ fi cd ${WORKDIR} -if [[ ! -d ${DATADIR}/${EXPID} ]]; then - [[ -d /esarchive/exp/ecearth/${EXPID} ]] && DATADIR=/esarchive/exp/ecearth +if [[ -d /esarchive/exp/ecearth/${EXPID} ]]; then + DATADIR=/esarchive/exp/ecearth +else + DATADIR=/esnas/exp/ecearth fi -base_path=${DATADIR}/${EXPID}/${SDATE} -mkdir -p ${SAVEDIR}/${EXPID}; # chmod -R 775 $SAVEDIR/${EXPID} +base_path=${DATADIR}/${EXPID}/original_files/${SDATE} +mkdir -p ${SAVEDIR}/${EXPID}; chmod -R 775 $SAVEDIR/${EXPID} -#exit stop get_leadtime header $SDATE extract echo "after extract" if [ -z ${VAR_LST_2D[@]} ]; then -# GG=$(ls *GG* | head -1) GG="$(find . -maxdepth 1 -name "*GG*" | head -1 | sed -e 's/\.\///g' )" read_vars $GG GG -# SH=$(ls *SH* | head -1) SH="$(find . -maxdepth 1 -name "*SH*" | head -1 | sed -e 's/\.\///g' )" read_vars $SH SH rm -f /scratch/Earth/${USER}/pp/VAR_LST_2D.txt @@ -1188,8 +1104,6 @@ upper if [[ ${#VAR_LST_MXMN[@]} > 0 ]]; then maxmin -#else -# echo "" #empty line to avoid trap issue fi cd ~/; rm -rf $WORKDIR # clean up