source: src/compute_metrics_csv.sh @ 193

Last change on this file since 193 was 193, checked in by htune, 6 years ago

Introducing a env.sh file to allow activating particular environment.
Needed on the jean-zay supercomputer.
Fredho

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/bin/bash
2
3. env.sh
4
5##############################################################################
6# Computing metrics from LES and SCM
7# Result in csv format
8# Auteur: F Couvreux, R Honnert, F Hourdin, N Villefranque, C Rio, n'co
9##############################################################################
10#
11# metrics are specified in list_case
12# metrics names follow the syntax
13#
14# CASE_SUBCASE_METRICS_T1_T2
15# T1 and T2 are initial and final time step for time averages
16#
17# available METRICS :
18# ===================
19#
20# 1/ zav-400-600-var  -> variable "var" averaged between 400 and 600 m
21#
22# 2/ Ay-var -> integral ( min ( var -var(t=1) ) dz ) / integral ( dz )
23#           integral taken from 0 to  zmax
24#
25# 3/ nebzave, neb2zave, neb4zave : Effective cloud height
26#           = int ( neb^p z dz ) / int ( neb^p dz ) with  p=1, 2 or 4
27#
28# 4/ nebmax : maximum cloud fraction on the column
29#
30# 5/ nebzmin, nebzmax : minimum/maximum cloud height
31#
32# 6/ lwp : liquid water path
33#
34# TBD :
35# =====
36# 1/ integrals are computed assuming rho=1 because rho is not systematically avalble
37# 2/ the time average is coded for zav metrics only
38#
39##############################################################################
40
41nWAVE=1
42
43
44list_case=""
45while (($# > 0)) ; do
46  case $1 in
47    -wave) nWAVE=$2 ; echo WAVE $nWAVE ;  shift ; shift ; echo OPTION $* ;;
48    -help|-h) echo Usage "$0 [-wave N] [metrics1] [metrics2] ..." ; exit ;;
49    *) list_case=( ${list_case[*]} $1 ) ; shift ;;
50  esac
51done
52
53# Default metrics
54if [ $list_case = "" ] ; then list_case=( ARMCU_REF_zav-400-600-theta_9_9 ) ; fi
55       
56wavedir=WAVE$nWAVE
57wave=$nWAVE
58starting=1
59
60# Remove old files
61rm -f metrics_$wave.csv metrics_LES_$wave.csv
62
63for name in ${list_case[@]};do
64  # Where are the reference (target) nc files?
65  if [ ${name:0:3} == RAD ] ; then 
66    REF=RAD
67  else 
68    REF=LES
69  fi
70  for dir in $REF ${wavedir} ; do
71    echo ./extract_onemetric_csv.sh $name $dir
72    ./extract_onemetric_csv.sh $name $dir
73    #========================
74    # Concatenation
75    #========================
76    if [ $dir = $REF ] ; then dirname=REF
77    else dirname=$dir ; fi
78    if [ $starting == 1 ];then
79      cp -f ${dir}_$name.csv metrics_${dirname}_$wave.csv
80    else
81      cut -d, -f2 ${dir}_$name.csv | paste -d, metrics_${dirname}_$wave.csv - > temp
82      mv temp metrics_${dirname}_$wave.csv
83    fi
84  done
85  starting=0
86done # end loop $name
87
88Rscript --vanilla htune_csv2Rdata.R $wave
Note: See TracBrowser for help on using the repository browser.