2013年8月18日日曜日

perl goto

引用



goto文は次の書式となります。

goto ラベル1
ラベル1 : gotoにより呼び出されるブロックのラベル
(例)
goto TEST1;

TEST2:
{
    print "test2\n";             # ここが2番目に表示される
    die "end\n";
}

TEST1:
{
    print "test1\n";
    goto TEST2;
}
実行結果
test1
test2
end





2013年7月30日火曜日

wgrib チェック

set file = ( /mnt/locals60/data1/gsm/c0210/c02100709.gsm024  )


wgrib $file | grep MSL | grep MSL
#| wgrib $file -i -text -o 08.txt
#wgrib $file | grep PRM | wgrib $file -i -text -o 08.txt
#cat 07.text

2012年8月19日日曜日

fortran 仕事用


open (unit=31, file='${ofname1}.txt', position='append', form='FORMATTED')
write(*,*) ${time_step}, pn, plonn,
write(31,*) ${time_step}, pn, plonn
close(31)

2012年7月3日火曜日

mkpdf.gs


*'make .ps'
'enable print pspdf.gmf'
'print'
'disable print'
'!gxps -c -i pspdf.gmf -o pspdf.ps'
'!rm pspdf.gmf'

'!ps2pdf pspdf.ps pspdf.pdf'

gnuplot ぐにゅ


#! /bin/tcsh -f
################################################
################################################
read_file1=output__find_i_n_v_pmin.txt
read_file2=output__find_i_s_v_pmin.txt
################################################
plot_file1=angelina_pmin
plot_file2=angelina_vmax
plot_file3=brad_pmin
plot_file4=brad_vmax
################################################
plot_filename11=twc_pmin
plot_filename12=twc_vmax
################################################
################################################
gnuplot <<EOF
################################################
### double plot#################################
################################################
#pmin
set yrange [950:1020]
plot "${read_file1}" using 1:2 axis x1y1 with lines title "${plot_file1}" linetype 1 linecolor rgbcolor "red" linewidth 3,\
"${read_file2}" using 1:2  axis x1y1 with line title "${plot_file3}" linetype 1 linecolor rgbcolor "blue" linewidth 3
set xlabel "time step [h]"
set ylabel "[hPa]"
set title "${plot_filename11}"
set term postscript
set output "${plot_filename11}.ps"
replot
################################################
set yrange [0:70]
plot "${read_file1}" using 1:7 axis x1y1 with lines title "${plot_file2}" linetype 1 linecolor rgbcolor "red" linewidth 3,\
"${read_file2}" using 1:7  axis x1y1 with line title "${plot_file4}" linetype 1 linecolor rgbcolor "blue" linewidth 3
set xlabel "time step [h]"
set ylabel "[m/s]"
set title "${plot_filename12}"
set term postscript
set output "${plot_filename12}.ps"
replot
################################################
################################################
EOF

################################################
################################################
################################################
### make pdf ###################################
################################################
################################################
################################################

ps2pdf ${plot_filename11}.ps 2_${plot_filename11}.pdf
rm ${plot_filename11}.ps
ps2pdf ${plot_filename12}.ps 2_${plot_filename12}.pdf
rm ${plot_filename12}.ps

気圧の書き出し mk_i_p.sh


#! /bin/tcsh -f

#type yyyymmddhhhh start and end time
: ${start:=200103131200}
: ${end:=200103280000}
#: ${end:=200001051200}
year=`echo ${start} | cut -c 1-4`
month=`echo ${start} | cut -c 5-6`
day=`echo ${start} | cut -c 7-8`
hour=`echo ${start} |cut -c 9-10`
h=00

echo start time ${year} ${month} ${day} ${hour} ${h}
echo end   time ${end}

: ${time:=${start}}
: ${start:=${start}}
: ${time_step=0}
timestep=12 #timestep of output file

title1=large
folder=result_press_12hby
mkdir ${folder}


cp ~/tool/color.gs .


i=0
while [ ${time} -le ${end} ]
do
time_step=`expr ${timestep} \* ${i}`
echo time_step ${time_step}

##decide m
if [ ${month} -eq 01 ]; then
    m=JAN
elif  [ ${month} -eq 02 ]; then
    m=FEB
elif  [ ${month} -eq 03 ]; then
    m=MAR
elif  [ ${month} -eq 04 ]; then
    m=APR
elif  [ ${month} -eq 05 ]; then
    m=MAY
elif  [ ${month} -eq 06 ]; then
    m=JUN
elif  [ ${month} -eq 07 ]; then
    m=JUL
elif  [ ${month} -eq 08 ]; then
    m=AUG
elif  [ ${month} -eq 09 ]; then
    m=SEP
elif  [ ${month} -eq 10 ]; then
    m=OCT
elif  [ ${month} -eq 11 ]; then
    m=NOV
elif  [ ${month} -eq 12 ]; then
    m=DEM
fi
#tim=${hour}z${day}${m}${year}
echo tim $tim
#make press wind, rv700, rvsrf image
    cat > ci.gs <<EOF 
'reinit'
'open _NHMMRPPFCSVSTD1_${time}.ctl'


'set lon -50 50'
'set lat -30 30'
'set mproj off'

*'set gxout shaded'
'set ccolor 4'
'd psea'
*'color '
*'cbarn'
'd skip (Usrf,10,10);Vsrf' 


'draw title ${title1} Press wind timestep=${time_step}[hour]'

'enable print t=${time_step}.gmf'
'print'
'disable print'
'!gxps -c -i t=${time_step}.gmf -o Press_wind_t=${time_step}.ps'
'!rm t='${time_step}'.gmf'

'!ps2pdf Press_wind_t=${time_step}.ps aPress_wind_t='${time_step}'.pdf'
'!rm Press_wind_t=${time_step}.ps'
'c'

'quit'

#157
EOF
    grads -blc ci.gs
#echo "yoshiyoshi"
i=`expr $i + 1`
#echo $i

############################################################
############################################################
cd ${folder}
cp ../aPress_wind_t=${time_step}.pdf .
cd ..
rm aPress_wind_t=${time_step}.pdf
############################################################
############################################################

#### next time step
#hour=`expr $hour + 1`
hour=`expr $hour + $timestep`
hour=`echo ${hour} | awk '{printf("%02d",$1)}'`


if [ $hour -eq 24 ]; then
    hour=00
#    day=`expr $day + 1`
        day=`echo ${day} | awk '{printf("%02d",$1+1)}'`
    
    if [ $day -ge 32 ];then
        day=01
#        month=`expr $month + 1`
        month=`echo ${month} | awk '{printf("%02d",$1+1)}'`
    
        if [ $month -ge 13 ];then
            month=01
            year=`expr $year + 1`

        fi    
    fi    
fi

time=${year}${month}${day}${hour}${h}

done

コントロールファイルの作成


#! /bin/tcsh -f

#type yyyymmddhhhh start and end time
: ${start:=200103131200}
: ${end:=200103280000}
#: ${end:=200001051200}
year=`echo ${start} | cut -c 1-4`
month=`echo ${start} | cut -c 5-6`
day=`echo ${start} | cut -c 7-8`
hour=`echo ${start} |cut -c 9-10`
h=00

echo start time ${year} ${month} ${day} ${hour} ${h}
echo end   time ${end}

: ${time:=${start}}

#timestep
timestep=6

#para
: ${xgrid:=557} 
: ${ygrid:=335} 
: ${slon:=-50}   
: ${slat:=-30.06}   

i=0
while [ ${time} -le ${end} ]
do

##decide m
if [ ${month} -eq 01 ]; then
    m=JAN
elif  [ ${month} -eq 02 ]; then
    m=FEB
elif  [ ${month} -eq 03 ]; then
    m=MAR
elif  [ ${month} -eq 04 ]; then
    m=APR
elif  [ ${month} -eq 05 ]; then
    m=MAY
elif  [ ${month} -eq 06 ]; then
    m=JUN
elif  [ ${month} -eq 07 ]; then
    m=JUL
elif  [ ${month} -eq 08 ]; then
    m=AUG
elif  [ ${month} -eq 09 ]; then
    m=SEP
elif  [ ${month} -eq 10 ]; then
    m=OCT
elif  [ ${month} -eq 11 ]; then
    m=NOV
elif  [ ${month} -eq 12 ]; then
    m=DEC
fi

##decide m

#echo $hour
time=${year}${month}${day}${hour}${h}
#echo yoshiyoshi
echo time $time
echo month $m
##mk_ctl
~/Nhm/NHM1.2/Tools/nus2grads/nus2grads fcst_p.nus/PPSTD1/${time}

# Write ctl file
cat <<EOF > _NHMMRPPFCSVSTD1_${time}.ctl
***output grads ctl file ***
dset _NHMMRPPFCSVSTD1_${time}.dat
title convert from NuSDaS
OPTIONS big_endian sequential yrev
undef 9.990000e+20
xdef  ${xgrid} linear ${slon} 0.18
ydef  ${ygrid} linear ${slat} 0.18
zdef  18 levels 1000  975  950  925  900  850  800  700  600  500  400  300  250  200  150  100   75   50 
tdef  1  linear  ${hour}z${day}${m}${year} 1mn
vars  21
Usrf          0 99 Usrf      
U            18 99 U         
Vsrf          0 99 Vsrf      
V            18 99 V         
Tsrf          0 99 Tsrf      
T            18 99 T         
TTDsrf        0 99 TTDsrf    
TTD          18 99 TTD       
Z            18 99 Z         
W            18 99 W         
OMG          18 99 OMG       
VOR          18 99 VOR       
CVR          18 99 CVR       
CWC          18 99 CWC       
PSEA          0 99 PSEA      
P             0 99 P         
RAIN          0 99 RAIN      
SMQR          0 99 SMQR      
SMQS          0 99 SMQS      
SMQG          0 99 SMQG      
SMQH          0 99 SMQH      

endvars

EOF

echo "GrADS files,  _NHMMRPPFCSVSTD1_${time}.ctl  are created."






#echo "yoshiyoshi"
i=`expr $i + 1`
#echo $i

#### next time step
#hour=`expr $hour + 1`
hour=`expr $hour + $timestep`
hour=`echo ${hour} | awk '{printf("%02d",$1)}'`


if [ $hour -eq 24 ]; then
    hour=00
#    day=`expr $day + 1`
        day=`echo ${day} | awk '{printf("%02d",$1+1)}'`
    
    if [ $day -ge 32 ];then
        day=01
#        month=`expr $month + 1`
        month=`echo ${month} | awk '{printf("%02d",$1+1)}'`
    
        if [ $month -ge 13 ];then
            month=01
            year=`expr $year + 1`

        fi    
    fi    
fi

time=${year}${month}${day}${hour}${h}

done