------------------------------
List of the following files:
------------------------------
nagasaki.maru.meteo.UTC.run.sh
nagasaki.maru.meteo.UTC.f90
TBL101_to_txt.run.sh
TBL101_to_txt.f90
cat.raw.UTC.txt.sh
edit.meteo.humid.sh
paste.meteo.humid.sh
makefile
------------------------------
Machine info
------------------------------
aofd165.bio.mie-u.ac.jp
/work2/am/2017.ECS.Mesolow.2012Leg2/In_Situ_FLUX.CHECK
Tue Sep 12 14:56:19 JST 2017
======================
nagasaki.maru.meteo.UTC.run.sh
======================
#!/bin/sh
exe=$(basename $0 .run.sh)
namelist=namelist.${exe}
indir=/work2/am/2017.ECS.Mesolow.2012Leg2/In_Situ_FLUX.CHECK/Basedata.Check
in=20120525.dat
out=$(basename $in .DAT).raw.UTC.txt
cat <<EOF > $namelist
¶
infle="${indir}/${in}" ! input file
&end
EOF
echo Input: ${indir}/${in}
echo Output: ${out}
$exe < $namelist > $out
exit 0
----------------------
End of nagasaki.maru.meteo.UTC.run.sh
----------------------
======================
nagasaki.maru.meteo.UTC.f90
======================
program meteo
! Description: Read Nagasaki-Maru's Meteorol. data
! 列 データの種類 変数の名前
! 1 日付 yy,mm,dd
! 2 時刻 hh,mm
! 3 緯度 lat(dd,mm.mmm)
! 4 経度 lon(ddd,mm.mmm)
! 5 波高 wh(m)
! 6 周期 wp(s)
! 7 真風向 wd(deg)
! 8 風速(knot) ws(knot) 1 knot=0.514 m/s
! 9 気温 ta(deg)
!10 水温 ts(deg)
!11 気圧 pr(hPa)
!12 ジャイロ方位 gyr(deg)
!13 速力 ss(knots)
! 真風向の定義:北=0度、時計回りにはかる。北より(南向き)の風=0度、東より(西向き)の風=90度
!
! Author: aym
!
! Host: aofd30
! Directory: /work1/aym/11.Work10/03.ECS/01.Obs_Amami/21.check_raw
!
! Revision history:
! 2011-01-14 16:55
! Initial Version
! use
! implicit none
character(len=500)::infle
character strm*500,ymd*12,hms*10,lat*14,lon*15
integer yr,mo,dy,hr,mi,sc,latd,lond
integer uyr, umo, udy, uhr !UTC
real latm,lonm
namelist /para/infle
read(*,nml=para)
print '(A)','# date(yyyy,mm,dd) time_UTC(hh,mm) lat(dd,mm.mmm) lon(ddd,mm.mmm) wh(m) wp(s) wd(deg) ws(knot) ta(degC) ts(degC) p(hPa) gyr ss'
open(10,file=infle,action="read")
10 continue
read(10,'(A)',end=20)strm
if(strm(1:1)=="#")goto 10
read(strm(1:54),'(A,1x,A,1x,A,1x,A)')ymd,hms,lat,lon
read(strm(56:),*)wvh,wvp,wid,wis,ta,tw,pr,gyd,shs
read(ymd(2:5),*)yr
read(ymd(7:9),*)mo
read(ymd(10:11),*)dy
read(hms(2:3),*)hr
read(hms(5:6),*)mi
read(hms(8:9),*)sc
read(lat(2:3),*)latd
read(lat(6:11),*)latm
read(lon(2:4),*)lond
read(lon(7:12),*)lonm
call lst2utc(yr,mo,dy,hr, uyr, umo, udy, uhr, +9)
print '(i5.4,2i3.2,3i3.2, i3,f7.3, i4,f7.3, f7.1,f7.1,f10.3,f8.1,f7.2,f7.1,f7.1,2f8.1)',&
uyr,umo,udy,uhr,mi,sc, latd,latm,lond,lonm ,wvh,wvp,wid,wis,ta,tw,pr,gyd,shs
goto 10
20 continue
write(*,*)
end program meteo
subroutine lst2utc(lyr,lmo,ldy, lhr, uyr, umo, udy, uhr, tdh)
! Description:
!
! Author: am
!
! Host: aofd165.fish.nagasaki-u.ac.jp
! Directory: /work2/kunoki/to_manda_sensei/Tools/MGDSST.AlongTrack
!
! Revision history:
! This file is created by /usr/local/mybin/nff.sh at 09:19 on 09-12-2014.
! Reference
! 1行で書けるうるう年判別法
! http://d.hatena.ne.jp/Kappuccino/20081025/1224906495
!
implicit none
integer,intent(in):: lyr,lmo,ldy, lhr
integer,intent(inout)::uyr,umo,udy, uhr
integer,intent(in):: tdh
integer y
integer,dimension(12)::last_day
data last_day/31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31/
uyr=lyr
umo=lmo
udy=ldy
uhr=lhr
uhr=lhr-tdh
if(uhr<0)then
uhr=uhr+24
udy=udy-1
endif
if(udy<=0)then
umo=umo-1
udy=last_day(umo)
if(umo == 2)then
y=uyr
udy = 28 + (1 / (y - y / 4 * 4 + 1)) * &
& (1 - 1 / (y - y / 100 * 100 + 1)) &
& + (1 / (y - y / 400 * 400 + 1));
endif
endif
if(umo<=0)then
umo=1
uyr=uyr-1
endif
end subroutine lst2utc
----------------------
End of nagasaki.maru.meteo.UTC.f90
----------------------
======================
TBL101_to_txt.run.sh
======================
#!/bin/sh
exe=TBL101_to_txt
namelist=namelist.${exe}
indir=/work2/am/2017.ECS.Mesolow.2012Leg2/In_Situ_FLUX.CHECK/Basedata.Check
in=CR800Series_TBL101.dat
out=$(basename $in .dat).txt
cat <<EOF > $namelist
¶
infle="${indir}/${in}" ! input file
ofle="$out"
&end
EOF
if [ ! -f ${indir}/${in} ]; then
Error in $: No such file, ${indir}/${in}
exit 1
fi
echo Input: ${indir}/${in}
echo Output: ${out}
$exe < $namelist
exit 0
----------------------
End of TBL101_to_txt.run.sh
----------------------
======================
TBL101_to_txt.f90
======================
!
! Change format of the humidity and rain rate data measured by
! Vaisalla CR800 TBL101.dat
!
program TBL101_to_txt
character(len=500)::infle,ofle
character(len=2000)::strm
character datetime*19
integer record
real ta, rh, prec_mm_tot
namelist /para/infle,ofle
read(5,nml=para)
print '(A,A)','Input: ',trim(infle)
print '(A,A)','Output: ',trim(ofle)
open(11,file=infle,action="read")
open(21,file=ofle)
write(21,'(A,A)')'# Input: ',trim(infle)
write(21,'(A)')'# datetime,record,ta,rh,prec_mm_tot'
1 read(11,'(A)',end=9)strm
if(index(strm,"TOA5")/=0)goto 1
if(index(strm,"TIMESTAMP")/=0)goto 1
if(index(strm,"RN")/=0)goto 1
if(index(strm,"Smp")/=0)goto 1
read(strm(2:20),'(a)') datetime
read(strm(23:),*) record,ta,rh,prec_mm_tot
write(21,'(a19,2x,i6.6,f7.2,1x,f7.2,f12.3)')&
datetime,record,ta,rh,prec_mm_tot
goto 1
9 continue
close(21)
close(11)
end program TBL101_to_txt
----------------------
End of TBL101_to_txt.f90
----------------------
======================
cat.raw.UTC.txt.sh
======================
#!/bin/sh
inlist="\
20120525.dat.raw.UTC.txt \
20120526.dat.raw.UTC.txt \
20120527.dat.raw.UTC.txt \
20120528.dat.raw.UTC.txt \
"
out=ECS2012Leg2.Meteo.raw.UTC.txt
n=1
for input in $inlist; do
if [ $n -eq 1 ]; then
awk '{if ($1=="#")print $0}' $input > $out
fi
n=$(expr $n + 1)
done
for input in $inlist; do
awk '{if ($1!="#") print $0}' $input >> $out
done
for input in $inlist; do
echo "Input: $input"
done
echo
echo "Output: $out"
echo
exit 0
----------------------
End of cat.raw.UTC.txt.sh
----------------------
======================
edit.meteo.humid.sh
======================
in1=ECS2012Leg2.Meteo.raw.UTC.txt
in2=CR800Series_TBL101.UTC.txt
inlist="\
$in1 \
$in2 \
"
for input in $inlist; do
if [ ! -f $input ];then
echo
echo Error in $0: No such file, $input
echo
fi
done
out1=$(basename $in1 .txt)_edit.txt
out2=$(basename $in2 .txt)_edit.txt
outlist="\
$out1 \
$out2 \
"
sed -n 662,4322p $in1 >$out1
sed -n 5855,9515p $in2 >$out2
echo
for input in $inlist; do
echo "Input: $input"
done
echo
for output in $outlist; do
echo "Output: $output"
wc $output | awk '{print $1,$4}'
awk '{if (NR==1) print $1,$2,$3,$4,$5}' $output
tail -1 $output|awk '{print $1,$2,$3,$4,$5}'
echo
done
echo
exit 0
----------------------
End of edit.meteo.humid.sh
----------------------
======================
paste.meteo.humid.sh
======================
#!/bin/bash
in1=ECS2012Leg2.Meteo.raw.UTC_edit.txt
in2=CR800Series_TBL101.UTC_edit.txt
inlist="\
$in1 \
$in2 \
"
for input in $inlist; do
if [ ! -f $input ];then
echo
echo Error in $0: No such file, $input
echo
fi
done
out="ECS2012Leg2_raw.UTC_Meteo.Humid.txt"
temp1=temp_$(basename $in1 .txt).txt
temp2=temp_$(basename $in2 .txt).txt
awk '{if ($1!="#")print $1,$2,$3,$4,$5, $7,$8,$9,$10,$13,$14,$15,$16,$17}' \
$in1>$temp1
awk '{if ($1!="#")print $9, $8, $1,$2,$3,$4,$5}' \
$in2>$temp2
cat <<EOF>$out
# date(yyyy,mm,dd) time_UTC(hh,mm) lat(dd,mm.mmm) lon(ddd,mm.mmm) wd(deg) ws(knot) ta(degC) ts(degC) p(hPa) RH(%) ta(degC)
EOF
paste $temp1 $temp2 >>$out
rm -vf $temp1 $temp2
echo
for input in $inlist; do
echo "Input: $input"
done
echo
echo "Output: $out"
echo
exit 0
----------------------
End of paste.meteo.humid.sh
----------------------
======================
makefile
======================
#j 参考文献
#j makefile の書き方
#j http://www.eis.osakafu-u.ac.jp/~yabu/soft/makefile.html
#j Makefile小技と新バージョンのDelFEM(FEMとUIの日記@New York)
#j http://d.hatena.ne.jp/etopirika5/20091207/1260207955
#
#-----------------------------------------
#j マクロの定義
#-----------------------------------------
#j コンパイラの指定
FC=ifort
#FC=gfortran
#FC=g77
#FC=f77
#j OBJDIR (オブジェクトファイルをおくディレクトリ)
OBJDIR=../obj
#-----------------------------------------
#j コンパイルオプション(ifort)
#-----------------------------------------
#j デバッグ用オプション(はじめて実行するときには必ずこのオプションをつけてコンパイルする)
FDFLAGS= -CB -traceback -fpe0
#j コンパイルオプション
FFLAGS=-module ${OBJDIR}
#j -module : モジュールファイル(.mod)を置く場所を指定する
#j 最適化用(他にも何種類かある. ifort -helpかマニュアルを見て調べる)
#FFLAGS = -O3 -module ${OBJDIR}
#j 倍精度
#FFLAGS = -r8 -module ${OBJDIR}
#j 入力データのバイト・スワップ(大型計算機のバイナリデータを読む時などにつかう)
#FFLAGS = #-convert big_endian -module ${OBJDIR}
#-----------------------------------------
#j リンク用のオプション
#-----------------------------------------
LDFLAGS=-module ${OBJDIR}
#j ターゲット名(最終的に作りたい実行ファイル名)
TARGET1=nagasaki.maru.meteo.UTC
TARGET2=TBL101_to_txt.UTC
TARGET3=Flux.Kondo1975
TARGETS=$(TARGET1) $(TARGET2) $(TARGET3)
#j MOD (Fortran90以降のモジュールファイル)
MOD=
#j SRC7 (Fortran77のソースファイル)
SRC7=
#j SRC9 (Fortran90のソースファイル)
SRC9=nagasaki.maru.meteo.UTC.f90
#j OBJ1 (ターゲットを作るのに必要なオブジェクトファイル名)
OBJM=$(MOD:.f90=.o)
OBJ7=$(SRC7:.f=.o)
OBJ9=$(SRC9:.f90=.o)
OBJTMP=$(OBJM) $(OBJ7) $(OBJ9)
OBJ1=$(OBJTMP:%=${OBJDIR}/%)
MOD2=
#j SRC7 (Fortran77のソースファイル)
SRC72=
#j SRC9 (Fortran90のソースファイル)
SRC92=TBL101_to_txt.UTC.f90
#j OBJ (ターゲットを作るのに必要なオブジェクトファイル名)
OBJM2=$(MOD2:.f90=.o)
OBJ72=$(SRC72:.f=.o)
OBJ92=$(SRC92:.f90=.o)
OBJTMP2=$(OBJM2) $(OBJ72) $(OBJ92)
OBJ2=$(OBJTMP2:%=${OBJDIR}/%)
MOD3=
#j SRC7 (Fortran77のソースファイル)
SRC73=
#j SRC9 (Fortran90のソースファイル)
SRC93=Flux.Kondo1975.f90
#j OBJ (ターゲットを作るのに必要なオブジェクトファイル名)
OBJM3=$(MOD3:.f90=.o)
OBJ73=$(SRC73:.f=.o)
OBJ93=$(SRC93:.f90=.o)
OBJTMP3=$(OBJM3) $(OBJ73) $(OBJ93)
OBJ3=$(OBJTMP3:%=${OBJDIR}/%)
OBJ=$(OBJ1) $(OBJ2) $(OBJ3)
#-----------------------------------------
#j ここからコンパイルのルールの記述
#-----------------------------------------
all: mkobjd $(TARGETS)
$(TARGET1): $(OBJ1)
$(FC) -o $@ $(OBJ1) ${LDFLAGS}
$(TARGET2): $(OBJ2)
$(FC) -o $@ $(OBJ2) ${LDFLAGS}
$(TARGET3): $(OBJ3)
$(FC) -o $@ $(OBJ3) ${LDFLAGS}
#j 暗黙のサフィックスルールを無効にする
.SUFFIXES:
#j サフィックスの追加
.SUFFIXES: .o .f .f90
#j f77のソースファイルのコンパイル(.f用のサフィックスルール)
${OBJDIR}/%.o : %.f
$(FC) -c ${FDFLAGS} ${FFLAGS} -c -o $@ $<
#j f90のソースファイルのコンパイル(.f90用のサフィックスルール)
${OBJDIR}/%.o : %.f90
$(FC) -c ${FDFLAGS} ${FFLAGS} -c -o $@ $<
#j オブジェクトファイルを削除
clean:
rm -rf $(OBJ) ${OBJDIR}/*.mod
#j オブジェクトファイルと実行ファイルを削除
distclean:
rm -rf $(OBJ) ${OBJDIR}/*.mod $(TARGETS) \
rm -rf ${OBJDIR}
#j オブジェクトファイルを置くディレクトリを作成
mkobjd:
if [ ! -d ${OBJDIR} ]; then \
mkdir -p ${OBJDIR} ; \
fi
#j tarファイルを作る
tar:
tar cvf $(TARGET1).tar ./*.f90 ./*.f ./*.c ./*.h ./*.txt makefile
----------------------
End of makefile
----------------------
------------------------------
List of the following files:
------------------------------
Flux.Kondo1975.run.sh
Flux.Kondo1975.f90
------------------------------
Machine info
------------------------------
aofd165.bio.mie-u.ac.jp
/work2/am/2017.ECS.Mesolow.2012Leg2/In_Situ_FLUX.CHECK
Tue Sep 12 14:55:58 JST 2017
======================
Flux.Kondo1975.run.sh
======================
#!/bin/sh
exe=$(basename $0 .run.sh)
namelist=namelist.${exe}
indir=.
in=ECS2012Leg2_raw.UTC_Meteo.Humid.txt
out=$(basename $0 .run.sh)_$in
cat <<EOF > $namelist
¶
infle="${indir}/${in}" ! input file
ofle="$out"
&end
EOF
if [ ! -f ${indir}/${in} ]; then
Error in $: No such file, ${indir}/${in}
exit 1
fi
$exe < $namelist
if [ $? -eq 0 ]; then
echo
echo Input: ${indir}/${in}
echo
echo Output: ${out}
echo
fi
exit 0
----------------------
End of Flux.Kondo1975.run.sh
----------------------
======================
Flux.Kondo1975.f90
======================
program Flux_Kondo1975
character(len=2000)::infle, ofle
namelist /para/infle,ofle
integer yy,mm,dd,hh,mi,latd,lond
real latm,lonm,wd,wsknot, ws, ta, ts, p, rh
character(len=5000):: strm
character(len=19):: datetime
read(*,nml=para)
open(11,file=infle,action="read")
open(21,file=ofle)
write(21,'(A)')'# datetime, qe[W/m2], qh[W/m2], qs[g/kg], q [g/kg], ev[mm/h] &
wd, ws, ta, ts, p, rh, latd, latm, lond, lonm'
n=0
skip_comment: do
read(11,'(A)',iostat=ios)strm
if(ios<0)exit
if(strm(1:1) == "#")then
cycle
else
n=n+1
read(strm,*)yy,mm,dd,hh,mi, latd, latm, lond, lonm, wd, wsknot, ta, ts, p, rh
ws=wsknot*0.514 ! 1 knot=0.514 m/s
! dir=270.0 - wd ! azimuth -> direction
sstk=ts+273.15 !degC -> K
satk=ta+273.15 !degC -> K
prs=p*100.0 !hPa -> Pa
call flux_kondo(prs, satk, rh, ws, sstk, qh, qe, qs, q, ev)
! GMT date/time format
write(datetime(1:4),'(i4.4)')yy
write(datetime(5:5),'(A)')'-'
write(datetime(6:7),'(i2.2)')mm
write(datetime(8:8),'(A)')'-'
write(datetime(9:10),'(i2.2)')dd
write(datetime(11:11),'(A)')'T'
write(datetime(12:13),'(i2.2)')hh
write(datetime(14:14),'(A)')':'
write(datetime(15:16),'(i2.2)')mi
write(datetime(17:17),'(A)')':'
write(datetime(18:19),'(i2.2)')0
qsg=qs*1000.0 !kg/kg -> g/kg
qg = q*1000.0 !kg/kg -> g/kg
write(21,'(&
A,f7.1,f7.1, f8.2,f8.2, f7.3, f9.3, f7.1, f8.2, f8.2, f8.1, f7.2, i3, f8.4, i4, f9.4)')&
datetime, qe, qh, qsg, qg, ev, &
wd, ws, ta, ts, p, rh, latd, latm, lond, lonm
endif
enddo skip_comment
end program Flux_Kondo1975
subroutine flux_kondo(prs, sat, rh, ws, sstk, qh, qe, qs, q, ev)
!
! Description: Surface heat flux by Kondo
!
! Author: am
!
! Host: aofd165.fish.nagasaki-u.ac.jp
! Directory: /work1/am/Sato.Kodama.Manda2015/MSM.MGDSST.FLUX.Trajectory
!
real,intent(in):: prs, sat, rh, ws, sstk
real,intent(out)::qh, qe, ev, qs, q
! slp [Pa]
! sstk [K]
! sat [K]
! rh [%]
! ws [m/s]
! qh SHF [W/m2]
! qe: LHF [W/m2]
! ev: Evapolation [mm/h]
! q specific humidity [kg/kg]
! qs saturated specific humidity [kg/kg]
real ae(5)/0., 0.969, 1.18, 1.196, 1.68/
real ah(5)/0., 0.927, 1.15, 1.17, 1.652/
real be(5)/1.23, 0.0521, 0.01, 0.008, -0.016/
real bh(5)/1.185, 0.0546, 0.01, 0.0075, -0.017/
real ce(5)/0., 0, 0, -0.0004, 0./
real ch(5)/0., 0, 0, -0.00045, 0./
real pe(5)/-0.16, 1., 1., 1., 1./
real ph(5)/-0.157, 1., 1., 1., 1./
real es,essea,dens
real chn,cln,chg,clg,s0,s
real,parameter::LH=2500.0,cp=1004.0
slp=prs/100.0 !Pa -> hPa
sst=sstk-273.15 !K -> degC
t=sat-273.15
v=ws !sqrt(u10**2+v10**2)
if (v.le.2.2) l=1
if (v.gt.2.2 .and. v.le.5.0) l=2
if (v.gt.5.0 .and. v.le.8.0) l=3
if (v.gt.8.0 .and. v.le.25.0) l=4
if (v.gt.25.0 .and. v.le.50.0) l=5
chn=0.001*(ah(l) + bh(l)*v**ph(l) + ch(l)*(v-8)**2)
cln=0.001*(ae(l) + be(l)*v**pe(l) + ce(l)*(v-8)**2)
s0=(sst-t)/(v**2)
s=s0*abs(s0)/(abs(s0)+0.01)
if(s.lt. -3.3) then
chg=0.0
clg=0.0
else if(s .lt. 0.0) then
chg=chn*(0.1+0.03*s+0.9*exp(4.8*s))
clg=cln*(0.1+0.03*s+0.9*exp(4.8*s))
else
chg=chn*(1.0+0.63*sqrt(s))
clg=cln*(1.0+0.63*sqrt(s))
endif
es=6.11*exp((LH/0.4615)*(1.0/273.2-1.0/(t+273.15)))
essea=6.11*exp((LH/0.4615)*(1.0/273.2-1.0/(sst+273.15)))*100/rh
q=0.622*es/slp
qs=0.622*essea/slp
dens=slp/(2.87*(1+0.61*q)*(t+273.15))
! write(6,*) 'dens,s,chg,clg,es,essea,q,qs'
! write(6,*) dens,q,qs
qh=dens*cp*chg*v*(sst-t)
qe=dens*LH*1000*clg*v*(qs-q)
ev=qe/(LH*1000.0)*3600.0 !mm/h
end subroutine
----------------------
End of Flux.Kondo1975.f90
----------------------