Fix_vobsfiles.ksh 2.58 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
#SBATCH --job-name=vobs
#SBATCH --workdir=/scratch/ms/se/smo/carra/conv
#SBATCH --qos=normal
#SBATCH --time=05:30:00
#
set -x

cd /scratch/ms/se/smo/carra/conv

YYYY=$1

for MM in 01 02 03 04 05 06 07 08 09 10 11 12; do

IMM=`perl -e "printf('%2.2i', '$MM')"`

D1=01

case $MM in
  02) ND=28
      if [ $YYYY = 1984 -o $YYYY = 1988 -o $YYYY = 1992 -o $YYYY = 1980 \
        -o $YYYY = 1976 -o $YYYY = 1972 -o $YYYY = 1968 -o $YYYY = 1964 \
        -o $YYYY = 1960 -o $YYYY = 1956 -o $YYYY = 1996 -o $YYYY = 2000 \
        -o $YYYY = 2004 -o $YYYY = 2008 -o $YYYY = 2012 -o $YYYY = 2016 ]
      then
           ND=29
      fi;;
  04)  ND=30;;
  06)  ND=30;;
  09)  ND=30;;
  11)  ND=30;;
   *)  ND=31;;
esac

DTG1=$YYYY$MM$D1"00"
DTG2=$YYYY$MM$ND"23"

DTGNO1=$YYYY$MM$D1"06"
DTGNO2=$YYYY$MM$ND"06"

DTG=$DTG1

export INPATH=/scratch/ms/se/smo/carra/conv/

./Fix_obsfiles_DK.ksh $DTG1 $DTG2

DTGF=$(/home/ms/se/smo/bin/mandtg.x $DTG1 + -24)

((BB = ${DTGF} / 100))
((YYF = $BB / 10000))
((MMF = ( $BB - $YYF*10000) / 100))
IMF=`perl -e "printf('%2.2i', '$MMF')"`

cd $INPATH/FI/$YYYY
gunzip "synopCARRA_FMI_"$YYYY$MM".txt.gz"

cd $INPATH
./Fix_obsfiles_FI.ksh $DTG1 $DTG2

cd $INPATH/FI/$YYYY
gzip "synopCARRA_FMI_"$YYYY$MM".txt"

cd $INPATH/FI/$YYF
gunzip "synopCARRA_FMI_"$YYF$IMF".txt.gz"
grep $DTG1 "synopCARRA_FMI_"$YYF$IMF".txt" > "../obs_"$DTG1".txt"
gzip "synopCARRA_FMI_"$YYF$IMF".txt"

cd $INPATH

./Fix_obsfiles_IC.ksh $DTG1 $DTG2

./Fix_obsfiles_NO1.ksh $DTG1 $DTG2

./Fix_obsfiles_NO2.ksh $DTGNO1 $DTGNO2

./Fix_obsfiles_SE.ksh $DTG1 $DTG2


while (( $DTG<=$DTG2 ))
do

  ((BB = ${DTG} / 100))
  ((YY = $BB / 10000))
  ((MM = ( $BB - $YY*10000) / 100))
  ((DD = ( $BB - $YY*10000 - $MM*100) ))
  ((HH = (${DTG} - $BB*100) ))

  ((IYY = $YY-2000))
  IY=`perl -e "printf('%2.2i', '$IYY')"`
  IM=`perl -e "printf('%2.2i', '$MM')"`
  ID=`perl -e "printf('%2.2i', '$DD')"`
  IH=`perl -e "printf('%2.2i', '$HH')"`

  /bin/rm vobs.txt

  VOBSFILE=vobs/vobs$DTG

 ./carra2vobs.x $DTG

  if [[ -f vobs.txt && -s vobs.txt ]];then
        cat vobs.txt >> $VOBSFILE
	/bin/rm vobs.txt
  fi

  DTG=$(/home/ms/se/smo/bin/mandtg.x $DTG + 01) 

done

cd $INPATH/vobs


TAR_FILE="vobs_"$YYYY$IMM".tar"

tar cvf $TAR_FILE vobs*
gzip $TAR_FILE

GZIP_FILE="vobs_"$YYYY$IMM".tar.gz"

ecp $GZIP_FILE ec:/smo/harmonie/CARRA/vobs/$YYYY/
echmod 755 ec:/smo/harmonie/CARRA/vobs/$YYYY/*
echgrp hirald ec:/smo/harmonie/CARRA/vobs/$YYYY/*

/bin/rm $GZIP_FILE vobs*

cd $INPATH

/bin/rm $INPATH/DK/obs_*.txt
/bin/rm $INPATH/FI/obs_*.txt
/bin/rm $INPATH/IC/obs_*.txt
/bin/rm $INPATH/NO/carra_Norway*.txt
/bin/rm $INPATH/SE/obs_*.txt

done

exit