Since the data format of MSM data has been changed since March 2006, the Fortran programs are modified.
Known problems on the MSM data
You should carefully read the following website before modifying the scripts and programs:
http://database.rish.kyoto-u.ac.jp/arch/jmadata/gpv-netcdf.html
Be careful of character encoding on the web pages above. One page uses shit-jis, but another page uses EUC.
Do not run the following scripts and programs on 133.45.210.31 for a long period of time. Disk space is very limited.
Download netcdf files
[Fri Apr 24 13:40:07 JST 2015]
[~/NetCDF2txt_MSM_2006]
[elham@aofd31]
$ cat getmsm.sh
#!/bin/bash
#==============================================================================
# Note:
# - Known problems on MSM data
# http://database.rish.kyoto-u.ac.jp/arch/jmadata/gpv-netcdf.html
# - Missing data list
# http://database.rish.kyoto-u.ac.jp/arch/jmadata/data/gpv/netcdf/MISSING_DATA_LIST
# - Contents of the netCDF file have been changed since March 2006.
# http://database.rish.kyoto-u.ac.jp/arch/jmadata/data/gpv/netcdf/README
#==============================================================================
#
# Input parameters
#
yyyymmdd1=20030301
yyyymmdd2=20030301
dir_p="./DATA/MSM-P" #Pressure level data
dir_s="./DATA/MSM-S" #Surface data
exe=wget
url=http://database.rish.kyoto-u.ac.jp/arch/jmadata/data/gpv/netcdf
opt=-N #-nc
# N: Overwrite if a remote file is newer than a local file.
# nc: Do not overwrite
#
#
#
yyyy1=${yyyymmdd1:0:4}
mm1=${yyyymmdd1:4:2}
dd1=${yyyymmdd1:6:2}
yyyy2=${yyyymmdd2:0:4}
mm2=${yyyymmdd2:4:2}
dd2=${yyyymmdd2:6:2}
start=${yyyy1}/${mm1}/${dd1}
end=${yyyy2}/${mm2}/${dd2}
jsstart=$(date -d${start} +%s)
jsend=$(date -d${end} +%s)
jdstart=$(expr $jsstart / 86400)
jdend=$(expr $jsend / 86400)
nday=$( expr $jdend - $jdstart)
i=0
while [ $i -le $nday ]; do
date_out=$(date -d"${yyyy1}/${mm1}/${dd1} ${i}day" +%Y%m%d)
yyyy=${date_out:0:4}
mm=${date_out:4:2}
dd=${date_out:6:2}
olddir=$(pwd)
mkdir -p $dir_p/${yyyy}
mkdir -p $dir_s/${yyyy}
dataset=MSM-P
cd $dir_p/${yyyy}
mkdir -p $yyyy
fname=${url}/${dataset}/${yyyy}/${mm}${dd}.nc
${exe} ${opt} $fname
cd $olddir
dataset=MSM-S
cd $dir_s/${yyyy}
mkdir -p $yyyy
fname=${url}/${dataset}/${yyyy}/${mm}${dd}.nc
${exe} ${opt} $fname
cd $olddir
i=$(expr $i + 1)
done
exit 0
$ ./getmsm.sh
$ tree DATA
DATA
|-- MSM-P
| `-- 2003
| |-- 0101.nc
| |-- 0101_format.txt
| `-- 2003
`-- MSM-S
`-- 2003
|-- 0101.nc
|-- 0101_format.txt
`-- 2003
Format of the netCDF file
You can obtain the following information using ncdump command with -h option.
Pressure level data
Before March 2006
$ ncdump -h DATA/MSM-P/2003/0101.nc
netcdf 0101 {
dimensions:
lon = 120 ;
lat = 126 ;
p = 14 ;
time = 8 ;
ref_time = 4 ;
variables:
float lon(lon) ;
lon:long_name = "longitude" ;
lon:standard_name = "longitude" ;
lon:units = "degrees_east" ;
float lat(lat) ;
lat:long_name = "latitude" ;
lat:standard_name = "latitude" ;
lat:units = "degrees_north" ;
float p(p) ;
p:long_name = "pressure level" ;
p:standard_name = "air_pressure" ;
p:units = "hPa" ;
float time(time) ;
time:long_name = "time" ;
time:standard_name = "time" ;
time:units = "hours since 2003-01-01 00:00:00+00:00" ;
float ref_time(ref_time) ;
ref_time:long_name = "forecaset reference time" ;
ref_time:standard_name = "forecaset_reference_time" ;
ref_time:units = "hours since 2003-01-01 00:00:00+00:00" ;
float z(time, p, lat, lon) ;
z:long_name = "geopotential height" ;
z:units = "m" ;
z:standard_name = "geopotential_height" ;
short u(time, p, lat, lon) ;
u:scale_factor = 0.006116208f ;
u:add_offset = 0.f ;
u:long_name = "eastward component of wind" ;
u:units = "m/s" ;
u:standard_name = "eastward_wind" ;
short v(time, p, lat, lon) ;
v:scale_factor = 0.006116208f ;
v:add_offset = 0.f ;
v:long_name = "northward component of wind" ;
v:units = "m/s" ;
v:standard_name = "northward_wind" ;
short temp(time, p, lat, lon) ;
temp:scale_factor = 0.00382263f ;
temp:add_offset = -25.f ;
temp:long_name = "temperature" ;
temp:units = "celcius" ;
temp:standard_name = "air_temperature" ;
short rh(time, p, lat, lon) ;
rh:scale_factor = 0.002293578f ;
rh:add_offset = 75.f ;
rh:long_name = "relative humidity" ;
rh:units = "%" ;
rh:standard_name = "relative_humidity" ;
float omega(time, p, lat, lon) ;
omega:long_name = "vertical velocity in p" ;
omega:units = "hPa/h" ;
omega:standard_name = "lagrangian_tendency_of_air_pressure" ;
// global attributes:
:Conventions = "CF-1.0" ;
:source = "Mesoscale Model MSM" ;
:institution = "JMA" ;
:history = "2005-07-19: gpv2nc -o /raid/raid1/jmadata/gpv/netcdf/MSM-P/2003/0101.nc -r u,v,-200..200:temp,-150..100:rh,0..150:r1h,0..400:psea,800..1100 -s 0 -e 5 MSM00PLM018_1 MSM00PLM018_2 MSM00PMH018 MSM06PLM018_1 MSM06PLM018_2 MSM06PMH018 MSM12PLM018_1 MSM12PLM018_2 MSM12PMH018 MSM18PLM018_1 MSM18PLM018_2 MSM18PMH018" ;
}
As of March 2006
netcdf 0502 {
dimensions:
lon = 241 ;
lat = 253 ;
p = 16 ;
time = 8 ;
variables:
float lon(lon) ;
lon:long_name = "longitude" ;
lon:units = "degrees_east" ;
lon:standard_name = "longitude" ;
float lat(lat) ;
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
lat:standard_name = "latitude" ;
float p(p) ;
p:long_name = "pressure level" ;
p:standard_name = "air_pressure" ;
p:units = "hPa" ;
float time(time) ;
time:long_name = "time" ;
time:standard_name = "time" ;
time:units = "hours since 2006-05-02 00:00:00+00:00" ;
double z(time, p, lat, lon) ;
z:long_name = "geopotential height" ;
z:units = "m" ;
z:standard_name = "geopotential_height" ;
double w(time, p, lat, lon) ;
w:long_name = "vertical velocity in p" ;
w:units = "Pa/s" ;
w:standard_name = "lagrangian_tendency_of_air_pressure" ;
short u(time, p, lat, lon) ;
u:scale_factor = 0.006116208155 ;
u:add_offset = 0. ;
u:long_name = "eastward component of wind" ;
u:units = "m/s" ;
u:standard_name = "eastward_wind" ;
short v(time, p, lat, lon) ;
v:scale_factor = 0.006116208155 ;
v:add_offset = 0. ;
v:long_name = "northward component of wind" ;
v:units = "m/s" ;
v:standard_name = "northward_wind" ;
short temp(time, p, lat, lon) ;
temp:scale_factor = 0.002613491379 ;
temp:add_offset = 255.4004974 ;
temp:long_name = "temperature" ;
temp:units = "K" ;
temp:standard_name = "air_temperature" ;
short rh(time, p, lat, lon) ;
rh:scale_factor = 0.002293577883 ;
rh:add_offset = 75. ;
rh:long_name = "relative humidity" ;
rh:units = "%" ;
rh:standard_name = "relative_humidity" ;
// global attributes:
:Conventions = "CF-1.0" ;
:history = "created by ./driver_grib2_2_nc_MSMP.rb 2006-08-13" ;
}
Surface data
[~/NetCDF2txt_MSM]
[elham@aofd31]
$ ncdump -h DATA/MSM-S/2003/0101.nc
Before March 2006
netcdf 0101 {
dimensions:
lon = 240 ;
lat = 252 ;
time = 24 ;
ref_time = 4 ;
variables:
float lon(lon) ;
lon:long_name = "longitude" ;
lon:standard_name = "longitude" ;
lon:units = "degrees_east" ;
float lat(lat) ;
lat:long_name = "latitude" ;
lat:standard_name = "latitude" ;
lat:units = "degrees_north" ;
float time(time) ;
time:long_name = "time" ;
time:standard_name = "time" ;
time:units = "hours since 2003-01-01 00:00:00+00:00" ;
float ref_time(ref_time) ;
ref_time:long_name = "forecaset reference time" ;
ref_time:standard_name = "forecaset_reference_time" ;
ref_time:units = "hours since 2003-01-01 00:00:00+00:00" ;
short psea(time, lat, lon) ;
psea:scale_factor = 0.004587156f ;
psea:add_offset = 950.f ;
psea:long_name = "sea level pressure" ;
psea:units = "hPa" ;
psea:standard_name = "air_pressure" ;
short u(time, lat, lon) ;
u:scale_factor = 0.006116208f ;
u:add_offset = 0.f ;
u:long_name = "eastward component of wind" ;
u:units = "m/s" ;
u:standard_name = "eastward_wind" ;
short v(time, lat, lon) ;
v:scale_factor = 0.006116208f ;
v:add_offset = 0.f ;
v:long_name = "northward component of wind" ;
v:units = "m/s" ;
v:standard_name = "northward_wind" ;
short temp(time, lat, lon) ;
temp:scale_factor = 0.00382263f ;
temp:add_offset = -25.f ;
temp:long_name = "temperature" ;
temp:units = "celcius" ;
temp:standard_name = "air_temperature" ;
short rh(time, lat, lon) ;
rh:scale_factor = 0.002293578f ;
rh:add_offset = 75.f ;
rh:long_name = "relative humidity" ;
rh:units = "%" ;
rh:standard_name = "relative_humidity" ;
short r1h(time, lat, lon) ;
r1h:scale_factor = 0.006116208f ;
r1h:add_offset = 200.f ;
r1h:long_name = "rainfall in 1 hour" ;
r1h:units = "mm/h" ;
r1h:standard_name = "rainfall_rate" ;
byte ncld_upper(time, lat, lon) ;
ncld_upper:long_name = "upper-level cloudiness" ;
ncld_upper:units = "1" ;
ncld_upper:comment = "9 represents 9 or 10 (full cloud coverage)" ;
byte ncld_mid(time, lat, lon) ;
ncld_mid:long_name = "mid-level cloudiness" ;
ncld_mid:units = "1" ;
ncld_mid:comment = "9 represents 9 or 10 (full cloud coverage)" ;
byte ncld_low(time, lat, lon) ;
ncld_low:long_name = "low-level cloudiness" ;
ncld_low:units = "1" ;
ncld_low:comment = "9 represents 9 or 10 (full cloud coverage)" ;
// global attributes:
:Conventions = "CF-1.0" ;
:source = "Mesoscale Model MSM" ;
:institution = "JMA" ;
:history = "2005-07-19: gpv2nc -o /raid/raid1/jmadata/gpv/netcdf/MSM-S/2003/0101.nc -r u,v,-200..200:temp,-150..100:rh,0..150:r1h,0..400:psea,800..1100 -s 0 -e 5 MSM00SFC018_1 MSM00SFC018_2 MSM06SFC018_1 MSM06SFC018_2 MSM12SFC018_1 MSM12SFC018_2 MSM18SFC018_1 MSM18SFC018_2" ;
}
As of March 2006
netcdf 0502 {
dimensions:
lon = 481 ;
lat = 505 ;
time = 24 ;
ref_time = 8 ;
variables:
float lon(lon) ;
lon:long_name = "longitude" ;
lon:units = "degrees_east" ;
lon:standard_name = "longitude" ;
float lat(lat) ;
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
lat:standard_name = "latitude" ;
float time(time) ;
time:long_name = "time" ;
time:standard_name = "time" ;
time:units = "hours since 2006-05-02 00:00:00+00:00" ;
float ref_time(ref_time) ;
ref_time:long_name = "forecaset reference time" ;
ref_time:standard_name = "forecaset_reference_time" ;
ref_time:units = "hours since 2006-05-02 00:00:00+00:00" ;
short psea(time, lat, lon) ;
psea:scale_factor = 0.4587155879 ;
psea:add_offset = 95000. ;
psea:long_name = "sea level pressure" ;
psea:units = "Pa" ;
psea:standard_name = "air_pressure" ;
short sp(time, lat, lon) ;
sp:scale_factor = 0.4587155879 ;
sp:add_offset = 95000. ;
sp:long_name = "surface air pressure" ;
sp:units = "Pa" ;
sp:standard_name = "surface_air_pressure" ;
short u(time, lat, lon) ;
u:scale_factor = 0.006116208155 ;
u:add_offset = 0. ;
u:long_name = "eastward component of wind" ;
u:units = "m/s" ;
u:standard_name = "eastward_wind" ;
short v(time, lat, lon) ;
v:scale_factor = 0.006116208155 ;
v:add_offset = 0. ;
v:long_name = "northward component of wind" ;
v:units = "m/s" ;
v:standard_name = "northward_wind" ;
short temp(time, lat, lon) ;
temp:scale_factor = 0.002613491379 ;
temp:add_offset = 255.4004974 ;
temp:long_name = "temperature" ;
temp:units = "K" ;
temp:standard_name = "air_temperature" ;
short rh(time, lat, lon) ;
rh:scale_factor = 0.002293577883 ;
rh:add_offset = 75. ;
rh:long_name = "relative humidity" ;
rh:units = "%" ;
rh:standard_name = "relative_humidity" ;
short r1h(time, lat, lon) ;
r1h:scale_factor = 0.006116208155 ;
r1h:add_offset = 200. ;
r1h:long_name = "rainfall in 1 hour" ;
r1h:units = "mm/h" ;
r1h:standard_name = "rainfall_rate" ;
short ncld_mid(time, lat, lon) ;
ncld_mid:scale_factor = 0.001666666591 ;
ncld_mid:add_offset = 50. ;
ncld_mid:long_name = "mid-level cloudiness" ;
ncld_mid:units = "%" ;
short ncld_low(time, lat, lon) ;
ncld_low:scale_factor = 0.001666666591 ;
ncld_low:add_offset = 50. ;
ncld_low:long_name = "low-level cloudiness" ;
ncld_low:units = "%" ;
short ncld(time, lat, lon) ;
ncld:scale_factor = 0.001666666591 ;
ncld:add_offset = 50. ;
ncld:long_name = "cloud amount" ;
ncld:units = "%" ;
ncld:standard_name = "cloud_area_fraction" ;
short ncld_upper(time, lat, lon) ;
ncld_upper:scale_factor = 0.001666666591 ;
ncld_upper:add_offset = 50. ;
ncld_upper:long_name = "upper-level cloudiness" ;
ncld_upper:units = "%" ;
// global attributes:
:Conventions = "CF-1.0" ;
:history = "created by ./driver_grib2_2_nc_MSMS.rb 2006-08-12" ;
}
Compile fortran program
$ make clean ; make
rm -rf ./obj/module_msms_var.o ./obj/module_msmp_var.o ./obj/netcdf2txt.o ./obj/read_msms.o ./obj/read_msmp.o ./obj/write_msms.o ./obj/write_msmp.o ./obj/*.mod
if [ ! -d ./obj ]; then \
mkdir -p ./obj ; \
fi
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/module_msms_var.o module_msms_var.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/module_msmp_var.o module_msmp_var.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/netcdf2txt.o netcdf2txt.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/read_msms.o read_msms.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/read_msmp.o read_msmp.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/write_msms.o write_msms.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/write_msmp.o write_msmp.f90
ifort -o netcdf2txt ./obj/module_msms_var.o ./obj/module_msmp_var.o ./obj/netcdf2txt.o ./obj/read_msms.o ./obj/read_msmp.o ./obj/write_msms.o ./obj/write_msmp.o -module ./obj -L/usr/local/lib -lnetcdf
Edit shell script
$ cat netcdf2txt_run.sh
#!/bin/bash
#
# Input parameters
#
indir_p="./DATA/MSM-P" #Pressure level data
indir_s="./DATA/MSM-S" #Surface data
yyyymmdd1=20030101
yyyymmdd2=20030101
plev=850 #Pressure level in hPa
hr1=06 #UTC
hr2=18 #UTC
outdir="output"
#
#
#
mkdir -p $outdir
exe=netcdf2txt
namelist=${exe}.namelist.txt
yyyy1=${yyyymmdd1:0:4}
mm1=${yyyymmdd1:4:2}
dd1=${yyyymmdd1:6:2}
yyyy2=${yyyymmdd2:0:4}
mm2=${yyyymmdd2:4:2}
dd2=${yyyymmdd2:6:2}
start=${yyyy1}/${mm1}/${dd1}
end=${yyyy2}/${mm2}/${dd2}
jsstart=$(date -d${start} +%s)
jsend=$(date -d${end} +%s)
jdstart=$(expr $jsstart / 86400)
jdend=$(expr $jsend / 86400)
nday=$( expr $jdend - $jdstart)
i=0
while [ $i -le $nday ]; do
date_out=$(date -d"${yyyy1}/${mm1}/${dd1} ${i}day" +%Y%m%d)
yyyy=${date_out:0:4}
mm=${date_out:4:2}
dd=${date_out:6:2}
cat <<EOF>$namelist
¶
in_msmp="${indir_p}/${yyyy}/${mm}${dd}.nc"
in_msms="${indir_s}/${yyyy}/${mm}${dd}.nc"
yyyy=${yyyy}
mm=${mm}
dd=${dd}
plev=${plev}
hr1=${hr1}
hr2=${hr2}
outdir="${outdir}"
&end
EOF
./${exe} < $namelist
i=$(expr $i + 1)
done
exit 0
Run the shell script
$ ./netcdf2txt_run.sh
Open : ./DATA/MSM-S/2006/0502.nc
Read lon
Read lat
Read time
Read psea
Read sp
Read u
Read v
Read rh
Read r1h
Read ncld_upper
Read ncld_mid
Read ncld_low
Read ncld
Output: output/MSMS20060502_06.txt
Output: output/MSMS20060502_09.txt
Output: output/MSMS20060502_12.txt
Output: output/MSMS20060502_15.txt
Output: output/MSMS20060502_18.txt
Open : ./DATA/MSM-P/2006/0502.nc
Read lon
Read lat
Read p
Read time
Read temp
Read z
Read w
Read u
Read v
Read rh
Output: output/MSMP0850_20060502_06.txt
Output: output/MSMP0850_20060502_09.txt
Output: output/MSMP0850_20060502_12.txt
Output: output/MSMP0850_20060502_15.txt
Output: output/MSMP0850_20060502_18.txt
Plot results
$ ./pl.msmp.sh output/MSMP0850_20030101_06.txt
Bash script ./pl.msmp.sh starts.
Input : output/MSMP0850_20030101_06.txt
Output : ./fig/MSMP0850_20030101_06.ps
$ ./pl.msms.sh output/MSMS20030101_06.txt
Bash script ./pl.msms.sh starts.
Input : output/MSMS20030101_06.txt
Output : ./fig/MSMS20030101_06.ps
Source codes
$ cat makefile
#
# References
#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 Definition of macro
#-----------------------------------------
# Compiler
FC=ifort
#FC=gfortran
#FC=g77
#FC=f77
# Directory for object files
OBJDIR=./obj
#-----------------------------------------
# Compiler options for intel fortran (ifort)
#-----------------------------------------
# Debugging
FDFLAGS= -CB -traceback -fpe0
#
FFLAGS=-module ${OBJDIR}
#j -module : モジュールファイル(.mod)を置く場所を指定する
# For optimization
#FFLAGS = -O3 -module ${OBJDIR}
# For double precision computation
#FFLAGS = -r8 -module ${OBJDIR}
# Byte swap
#FFLAGS = #-convert big_endian -module ${OBJDIR}
#-----------------------------------------
# For linking
#-----------------------------------------
LDFLAGS=-module ${OBJDIR} -L/usr/local/lib -lnetcdf
# Target file name
TARGET1=./netcdf2txt
TARGET2=
TARGETS=$(TARGET1) $(TARGET2)
# Fortran 90 module files
MOD=module_msms_var.f90 module_msmp_var.f90
#j Fortran 77 source file
SRC7=
#j Fortran 90 source file
SRC9=netcdf2txt.f90 read_msms.f90 read_msmp.f90 \
write_msms.f90 write_msmp.f90
# Object file
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=
#j OBJ (ターゲットを作るのに必要なオブジェクトファイル名)
OBJM2=$(MOD2:.f90=.o)
OBJ72=$(SRC72:.f=.o)
OBJ92=$(SRC92:.f90=.o)
OBJTMP2=$(OBJM2) $(OBJ72) $(OBJ92)
OBJ2=$(OBJTMP2:%=${OBJDIR}/%)
OBJ=$(OBJ1) $(OBJ2)
#-----------------------------------------
# Compile rule
#-----------------------------------------
all: mkobjd $(TARGETS)
$(TARGET1): $(OBJ1)
$(FC) -o $@ $(OBJ1) ${LDFLAGS}
$(TARGET2): $(OBJ2)
$(FC) -o $@ $(OBJ2) ${LDFLAGS}
# Disable default suffix rule
.SUFFIXES:
# Add suffix
.SUFFIXES: .o .f .f90
# Compile command for fortran 77
${OBJDIR}/%.o : %.f
$(FC) -c ${FDFLAGS} ${FFLAGS} -c -o $@ $<
# Compile command for fortran 90
${OBJDIR}/%.o : %.f90
$(FC) -c ${FDFLAGS} ${FFLAGS} -c -o $@ $<
#j Remove object files
clean:
rm -rf $(OBJ) ${OBJDIR}/*.mod
#j Remove object and executable files
distclean:
rm -rf $(OBJ) ${OBJDIR}/*.mod $(TARGETS) \
rm -rf ${OBJDIR}
# Create directory for object files
mkobjd:
if [ ! -d ${OBJDIR} ]; then \
mkdir -p ${OBJDIR} ; \
fi
run:
cd .. ; \
./run.sh 2>&1 > log.txt ; \
cd src
# Create compressed arhive file
tar:
tar cvf $(TARGET1).tar ./*.f90 ./*.f ./*.c ./*.h ./*.txt makefile
$ cat netcdf2txt_run.sh
#!/bin/bash
#
# Input parameters
#
indir_p="./DATA/MSM-P" #Pressure level data
indir_s="./DATA/MSM-S" #Surface data
yyyymmdd1=20030101
yyyymmdd2=20030101
plev=850 #Pressure level in hPa
hr1=03 #UTC
hr2=24 #UTC
outdir="output"
#
#
#
mkdir -p $outdir
exe=netcdf2txt
namelist=${exe}.namelist.txt
yyyy1=${yyyymmdd1:0:4}
mm1=${yyyymmdd1:4:2}
dd1=${yyyymmdd1:6:2}
yyyy2=${yyyymmdd2:0:4}
mm2=${yyyymmdd2:4:2}
dd2=${yyyymmdd2:6:2}
start=${yyyy1}/${mm1}/${dd1}
end=${yyyy2}/${mm2}/${dd2}
jsstart=$(date -d${start} +%s)
jsend=$(date -d${end} +%s)
jdstart=$(expr $jsstart / 86400)
jdend=$(expr $jsend / 86400)
nday=$( expr $jdend - $jdstart)
i=0
while [ $i -le $nday ]; do
date_out=$(date -d"${yyyy1}/${mm1}/${dd1} ${i}day" +%Y%m%d)
yyyy=${date_out:0:4}
mm=${date_out:4:2}
dd=${date_out:6:2}
cat <<EOF>$namelist
¶
in_msmp="${indir_p}/${yyyy}/${mm}${dd}.nc"
in_msms="${indir_s}/${yyyy}/${mm}${dd}.nc"
yyyy=${yyyy}
mm=${mm}
dd=${dd}
plev=${plev}
hr1=${hr1}
hr2=${hr2}
outdir="${outdir}"
&end
EOF
./${exe} < $namelist
i=$(expr $i + 1)
done
exit 0
::::::::::::::
netcdf2txt.f90
::::::::::::::
program netcdf2txt
! Description:
!
! Author: AM
!
! Host: aofd31.fish.nagasaki-u.ac.jp
! Directory: /home/share/Data/121012_Jikken4/MSM/src
!
! Revision history:
! This file is created by /usr/local/mybin/nff.sh at 20:44 on 12-04-2012.
use module_msms_var
use module_msmp_var
include '/usr/local/include/netcdf.inc'
type(msms)::s
type(msmp)::p
! implicit none
integer yyyy,mm,dd
real plev, hr1, hr2
character(len=150):: in_msms, in_msmp, outdir
namelist/para/in_msmp,in_msms,yyyy,mm,dd,plev,hr1,hr2,outdir
read(*,nml=para)
call read_msms(in_msms, s)
call write_msms(yyyy,mm,dd, hr1, hr2, outdir, s)
call read_msmp(in_msmp, p)
call write_msmp(yyyy,mm,dd, plev, hr1, hr2, outdir, p)
end program netcdf2txt
::::::::::::::
module_msmp_var.f90
::::::::::::::
module module_msmp_var
! Description:
!
! Author: AM
!
! Host: aofd31.fish.nagasaki-u.ac.jp
! Directory: /home/share/Data/121012_Jikken4/MSM
!
! Revision history:
! This file is created by /usr/local/mybin/nff.sh at 21:36 on 12-04-2012.
! use
! implicit none
! write(*,'(a)')'Module: module_msmp_var'
! write(*,*)''
! private
! ncid:ファイルのID番号、 varid: 変 数のID番号
integer,public :: ncid,varid
integer,public :: stat
! Before March 2006
integer,public,parameter :: plon=120, plat=126, ptime=8, ppres=14
! integer,public,parameter :: plon=241, plat=253, ptime=8, ppres=16
integer,public::iyyyy,imm,idd
type, public :: msmp
character(len=50):: var
real,dimension (plon) :: lon
real,dimension (plat) :: lat
real,dimension (ppres) :: p
real,dimension (ptime) :: time
real,dimension(plon, plat, ppres, ptime) :: z, w, u, v, temp, &
& rh
! year,month,day on initial date (i.e., origin of time)
end type msmp
contains
subroutine read_msmp_vars(varname, varout)
include '/usr/local/include/netcdf.inc'
character(len=*),intent(in)::varname
real,dimension(:,:,:,:),intent(inout)::varout
integer(2),dimension(plon,plat,ppres,ptime)::varout_int
real(8),dimension(plon,plat,ppres,ptime)::varout_dbl
integer,allocatable :: dimids(:),nshape(:)
character(len=70) :: err_message
character(len=100) :: dimname !dimnameは各次元の名前。
! print '(A)',varname(1:lnblnk(varname))
! ファイルID(ncid)からs%varで設定した変数のID(varid)を得る。
stat = nf_inq_varid(ncid,varname,varid)
! print *,'ncid=', ncid
! print *,'varid=', varid
! print *,'stat= ', stat
! print *
! スケールファクターを得る。(*1)
stat = nf_get_att_real(ncid,varid,'scale_factor',scale)
! print *,'scale= ',scale
! print *,'stat= ',stat
! print *
! オフセットの 値を得る(*2)
stat = nf_get_att_real(ncid,varid,'add_offset',offset)
! print *,'offset=', offset
! print *,'stat= ',stat
! print *
! varidからndimsを得る。ndimsとは次元の数。二次元データなら2
stat = nf_inq_varndims(ncid, varid, ndims)
! print *,'stat=',stat
! print *,'ndims= ', ndims
! print *
! varidからdimidsを得る。dimidsとはそれぞれの次元に対するID
allocate(dimids(ndims))
stat = nf_inq_vardimid(ncid, varid, dimids)
! print *,'stat= ',stat
! print *,'ndims= ', ndims
! print *,dimids
! do i=1,ndims
! write(6,'("dimids(",i3,")=",i9 )') i,dimids(i)
! enddo
! print *
allocate(nshape(ndims))
do i=1,ndims
! dimidsからnshapeを得る。
! nshapeとはそれぞれの次元に対する最大データ数 (格子数)
stat = nf_inq_dimlen(ncid, dimids(i), nshape(i))
! print *,'stat=',stat
! print *,nshape
! write(6,'("nshape(",i3,")=",i9 )') i,nshape(i)
enddo !i
! print *
do i=1,ndims
stat = nf_inq_dimname(ncid, dimids(i), dimname)
! print *,'stat=',stat
! print *,'dimname=',dimname
! write(6,'("dimname(",i3,")=",1x,a23)') i,dimname
enddo
! print *
print *,'Read ',varname(1:lnblnk(varname))
if(varname == 'u' .or. varname == 'v' .or. varname == 'temp' &
.or. varname == 'rh')then
stat = nf_get_var_int2(ncid, varid, varout_int)
else if (varname == 'z' .or. varname == 'w')then
stat = nf_get_var_real(ncid, varid, varout)
! stat = nf_get_var_double(ncid, varid, varout_dbl)
endif
if(stat /= 0)then
print *,'stat= ',stat
print *,"Terminated."
print *
stop
endif
if(varname == 'u' .or. varname == 'v' .or. varname == 'temp' &
.or. varname == 'rh')then
varout(:,:,:,:)=float(varout_int(:,:,:,:))*scale + offset
! else if (varname == 'z' .or. varname == 'w')then
! varout(:,:,:,:)=sngl(varout_dbl(:,:,:,:))
endif
deallocate(dimids,nshape)
end subroutine read_msmp_vars
end module module_msmp_var
::::::::::::::
module_msms_var.f90
::::::::::::::
module module_msms_var
! Description:
!
! Author: AM
!
! Host: aofd31.fish.nagasaki-u.ac.jp
! Directory: /home/share/Data/121012_Jikken4/MSM
!
! Revision history:
! This file is created by /usr/local/mybin/nff.sh at 21:36 on 12-04-2012.
! use
! implicit none
! write(*,'(a)')'Module: module_msms_var'
! write(*,*)''
! private
! ncid:ファイルのID番号、 varid: 変 数のID番号
integer,public :: ncid,varid
integer,public :: stat
! Before March 2006
integer,public,parameter :: slon=240, slat=252, stime=24
! integer,public,parameter :: slon=481, slat=505, stime=24
type, public :: msms
character(len=50):: var
real,dimension (slon) :: lon
real,dimension (slat) :: lat
real,dimension (stime) :: time
real,dimension(slon,slat,stime) :: psea, sp, u, v, temp, &
& rh, r1h, ncld_upper, ncld_mid, ncld_low, ncld
end type msms
contains
subroutine read_msms_vars(varname, varout)
include '/usr/local/include/netcdf.inc'
character(len=*),intent(in)::varname
real,dimension(:,:,:),intent(inout)::varout
integer(2),dimension(slon,slat,stime)::varout_int
integer,allocatable :: dimids(:),nshape(:)
character(len=70):: err_message
character(len=100) :: dimname !dimnameは各次元の名前。
! print '(A)',varname(1:lnblnk(varname))
! ファイルID(ncid)からs%varで設定した変数のID(varid)を得る。
sta = nf_inq_varid(ncid,varname,varid)
! print *,'varid=', varid
! print *,'sta= ', sta
! print *
! スケールファクターを得る。(*1)
sta = nf_get_att_real(ncid,varid,'scale_factor',scale)
! print *,'scale= ',scale
! print *,'sta= ',sta
! print *
! オフセットの 値を得る(*2)
sta = nf_get_att_real(ncid,varid,'add_offset',offset)
! print *,'offset=', offset
! print *,'sta= ',sta
! print *
! varidからndimsを得る。ndimsとは次元の数。二次元データなら2
stat = nf_inq_varndims(ncid, varid, ndims)
! print *,'ndims= ', ndims
! print *
! varidからdimidsを得る。dimidsとはそれぞれの次元に対するID
allocate(dimids(ndims))
stat = nf_inq_vardimid(ncid, varid, dimids)
! do i=1,ndims
! write(6,'("dimids(",i2,")=",i9 )') i,dimids(i)
! enddo
! print *
allocate(nshape(ndims))
do i=1,ndims
! dimidsからnshapeを得る。
! nshapeとはそれぞれの次元に対する最大データ数 (格子数)
stat = nf_inq_dimlen(ncid, dimids(i), nshape(i))
! write(6,'("nshape(",i2,")=",i9 )') i,nshape(i)
enddo !i
! print *
do i=1,ndims
stat = nf_inq_dimname(ncid, dimids(i), dimname)
! write(6,'("dimname(",i2,")=",1x,a23)') i,dimname
enddo
! print *
print *,'Read ',varname(1:lnblnk(varname))
stat = nf_get_var_int2(ncid, varid, varout_int)
if(stat /= 0)then
print *,'stat= ',stat
print *,"Terminated."
print *
stop
endif
deallocate(dimids,nshape)
varout(:,:,:)=float(varout_int(:,:,:))*scale + offset
end subroutine read_msms_vars
end module module_msms_var
::::::::::::::
read_msmp.f90
::::::::::::::
subroutine read_msmp(in_msmp, p)
! Description:
!
! Author: AM
!
! Host: aofd31.fish.nagasaki-u.ac.jp
! Directory: /home/share/Data/121012_Jikken4/MSM/src
!
! Revision history:
! This file is created by /usr/local/mybin/nff.sh at 21:57 on 12-04-2012.
use module_msmp_var
include '/usr/local/include/netcdf.inc'
character(len=*),intent(in) :: in_msmp
type(msmp),intent(inout)::p
! write(*,'(a)')'Subroutine: read_msmp'
! write(*,*)''
print *
stat = nf_open(in_msmp, nf_nowrite, ncid) ! ファイルのopenとNetCDF ID(ncid)の取得
! print *,'ncid= ',ncid
if(stat == 0)then
print '(A,A)','Open : ',in_msmp(1:lnblnk(in_msmp))
else
print '(A,A)','Error while opening ',in_msmp(1:lnblnk(in_msmp))
print *,'status= ',stat
stop
endif
!==================
p%var='lon'
!==================
! ファイルID(ncid)からvarで設定した変数のID(varid)を得る。
stat = nf_inq_varid(ncid,p%var,varid)
! print *,'varid=', varid
! print *,'sta= ', sta
print *,'Read ',p%var(1:lnblnk(p%var))
stat = nf_get_var_real(ncid, varid, p%lon)
! print *,'stat= ',stat
!==================
p%var='lat'
!==================
! ファイルID(ncid)からvarで設定した変数のID(varid)を得る。
stat = nf_inq_varid(ncid,p%var,varid)
! print *,'varid=', varid
! print *,'sta= ', sta
print *,'Read ',p%var(1:lnblnk(p%var))
stat = nf_get_var_real(ncid, varid, p%lat)
! print *,'stat= ',stat
! print *
!==================
p%var='p'
!==================
! ファイルID(ncid)からvarで設定した変数のID(varid)を得る。
stat = nf_inq_varid(ncid,p%var,varid)
! print *,'varid=', varid
! print *,'sta= ', sta
print *,'Read ',p%var(1:lnblnk(p%var))
stat = nf_get_var_real(ncid, varid, p%p)
!==================
p%var='time'
!==================
! ファイルID(ncid)からvarで設定した変数のID(varid)を得る。
stat = nf_inq_varid(ncid,p%var,varid)
! print *,'varid=', varid
! print *,'sta= ', sta
print *,'Read ',p%var(1:lnblnk(p%var))
stat = nf_get_var_real(ncid, varid, p%time)
! print *,'stat= ',stat
! print *
call read_msmp_vars('temp',p%temp)
call read_msmp_vars('z',p%z)
call read_msmp_vars('omega',p%w)
call read_msmp_vars('u',p%u)
call read_msmp_vars('v',p%v)
call read_msmp_vars('rh',p%rh)
end subroutine read_msmp
::::::::::::::
read_msms.f90
::::::::::::::
subroutine read_msms(in_msms, s)
! Description:
!
! Author: AM
!
! Host: aofd31.fish.nagasaki-u.ac.jp
! Directory: /home/share/Data/121012_Jikken4/MSM/src
!
! Revision history:
! This file is created by /usr/local/mybin/nff.sh at 21:57 on 12-04-2012.
use module_msms_var
include '/usr/local/include/netcdf.inc'
character(len=*),intent(in) :: in_msms
type(msms),intent(inout)::s
! write(*,'(a)')'Subroutine: read_msms'
! write(*,*)''
print *
stat = nf_open(in_msms, nf_nowrite, ncid) ! ファイルのopenとNetCDF ID(ncid)の取得
if(stat == 0)then
print '(A,A)','Open : ',in_msms(1:lnblnk(in_msms))
else
print '(A,A)','Error while opening ',in_msms(1:lnblnk(in_msms))
print *,'status= ',stat
stop
endif
!==================
s%var='lon'
!==================
! ファイルID(ncid)からvarで設定した変数のID(varid)を得る。
stat = nf_inq_varid(ncid,s%var,varid)
! print *,'varid=', varid
! print *,'sta= ', sta
print *,'Read ',s%var(1:lnblnk(s%var))
stat = nf_get_var_real(ncid, varid, s%lon)
! print *,'stat= ',stat
!==================
s%var='lat'
!==================
! ファイルID(ncid)からvarで設定した変数のID(varid)を得る。
stat = nf_inq_varid(ncid,s%var,varid)
! print *,'varid=', varid
! print *,'sta= ', sta
print *,'Read ',s%var(1:lnblnk(s%var))
stat = nf_get_var_real(ncid, varid, s%lat)
! print *,'stat= ',stat
! print *
!==================
s%var='time'
!==================
! ファイルID(ncid)からvarで設定した変数のID(varid)を得る。
stat = nf_inq_varid(ncid,s%var,varid)
! print *,'varid=', varid
! print *,'sta= ', sta
print *,'Read ',s%var(1:lnblnk(s%var))
stat = nf_get_var_real(ncid, varid, s%time)
! print *,'stat= ',stat
! print *
call read_msms_vars('psea',s%psea)
call read_msms_vars('sp', s%sp)
call read_msms_vars('u', s%u)
call read_msms_vars('v', s%v)
call read_msms_vars('rh', s%rh)
call read_msms_vars('r1h',s%r1h)
call read_msms_vars('ncld_upper',s%ncld_upper)
call read_msms_vars('ncld_mid',s%ncld_mid)
call read_msms_vars('ncld_low',s%ncld_low)
call read_msms_vars('ncld',s%ncld)
end subroutine read_msms
::::::::::::::
write_msmp.f90
::::::::::::::
subroutine write_msmp(yyyy,mm,dd, plev, hr1, hr2, outdir, p)
! Description:
!
! Author: AM
!
! Host: aofd31.fish.nagasaki-u.ac.jp
! Directory: /home/share/Data/121012_Jikken4/MSM
!
! Revision history:
! This file is created by /usr/local/mybin/nff.sh at 17:05 on 12-05-2012.
! use
! implicit none
use module_msmp_var
integer,intent(in)::yyyy,mm,dd
real,intent(in)::plev, hr1, hr2
character(len=*),intent(in):: outdir
type(msmp),intent(in)::p
character month*3, dat_msmp*500, ctl_msmp*500
integer hh
l1=hr1/3
l2=hr2/3
do k=1,ppres
if(plev == p%p(k)) then
kout=k
endif
enddo
!print *, p%p(kout)
time: do l=l1, l2
hh=3*l
is=1
ie=lnblnk(outdir)
write(dat_msmp(is:ie),'(A,A)')outdir(is:ie)
is=ie+1
ie=is
write(dat_msmp(is:ie),'(A,A)')'/'
is=ie+1
write(dat_msmp(is:),'(A,i4.4,A,i4.4,i2.2,i2.2,A,i2.2,A)') &
& 'MSMP',int(plev),'_',yyyy,mm,dd,'_',hh,'.txt'
print '(A,A)','Output: ',trim(dat_msmp)
k=kout
open(20,file=dat_msmp)
write(20,'(A)')'# lon lat u[m/s] v[m/s], omega[hPa/h], yyyy,mm,dd,hh'
do j=1,plat
do i=1,plon
write(20,'(f11.5,f10.5,f10.1,f10.1,f12.6, &
& 1x,i4.4,1x,i2.2,1x,i2.2,1x,i2.2)') &
& p%lon(i),p%lat(j), &
& p%u(i,j,k,l),p%v(i,j,k,l),p%w(i,j,k,l),yyyy,mm,dd,hh
enddo
enddo
close(20)
enddo time
end subroutine write_msmp
::::::::::::::
write_msms.f90
::::::::::::::
subroutine write_msms(yyyy,mm,dd, hr1, hr2, outdir, s)
! Description:
!
! Author: AM
!
! Host: aofd31.fish.nagasaki-u.ac.jp
! Directory: /home/share/Data/121012_Jikken4/MSM
!
! Revision history:
! This file is created by /usr/local/mybin/nff.sh at 17:05 on 12-05-2012.
! use
! implicit none
use module_msms_var
integer,intent(in)::yyyy,mm,dd
real,intent(in)::hr1,hr2
character(len=*),intent(in):: outdir
type(msms),intent(in)::s
integer hh
character month*3, dat_msms*500, ctl_msms*500
l1=hr1
l2=hr2
time: do l=l1,l2,3
hh=l
is=1
ie=lnblnk(outdir)
write(dat_msms(is:ie),'(A,A)')outdir(is:ie)
is=ie+1
ie=is
write(dat_msms(is:ie),'(A,A)')'/'
is=ie+1
write(dat_msms(is:),'(A,i4.4,i2.2,i2.2,A,i2.2,A)')&
& 'MSMS',yyyy,mm,dd,'_',hh,'.txt'
print '(A,A)','Output: ',trim(dat_msms)
open(20,file=dat_msms)
write(20,'(A)')'# lon lat hourly precip.[mm] relative hum[%], yyyy,mm,dd,hh'
do j=1,slat,2
do i=1,slon,2
write(20,'(f11.5,f10.5,f10.1,f10.1, 1x,i4.4,1x,i2.2,1x,i2.2,1x,i2.2)') &
& s%lon(i),s%lat(j),s%r1h(i,j,l),s%rh(i,j,l),&
& yyyy,mm,dd,hh
enddo !i
enddo !j
enddo time
close(20)
! s%psea(i,j,l) !"sea level pressure ","Pa"
! s%sp(i,j,l) !"surface air pressure ","Pa"
! s%u(i,j,l) !"eastward component of wind ", "m/s"
! s%v(i,j,l) !"northward component of wind ","m/s"
! s%temp(i,j,l) !"air_temperature " ,"K"
! s%rh(i,j,l) !"relative_humidity ","%"
! s%r1h(i,j,l) !"rainfall in 1 hour ","mm/h"
! s%ncld_upper(i,j,l) !"upper-level cloudiness ","%"
! s%ncld_mid(i,j,l) !"mid-level cloudiness ","%"
! s%ncld_low(i,j,l) !"rlow-level cloudiness ","%"
! s%ncld(i,j,l) !"cloud_area_fraction ","%"
end subroutine write_msms
$ cat pl.msmp.sh
#!/bin/bash
# Description:
#
# Author: AM
#
# Host: aofd31.fish.nagasaki-u.ac.jp
# Directory: /home/elham/NetCDF2txt_MSM
#
# Revision history:
# This file is created by /usr/local/mybin/ngmt.sh at 15:56 on 04-11-2015.
. ./gmtpar.sh
echo "Bash script $0 starts."
range=120/150/22/47
size=5
xanot=a10f5
yanot=a5f5
anot=${xanot}/${yanot}WSne
in=$1
if [ ! -f $in ]; then
echo Error in $0 : No such file, $in
exit 1
fi
psdir="./fig/"
if [ ! -d ${psdir} ];then
mkdir -p $psdir
fi
out=${psdir}$(basename $in .txt).ps
echo Input : $in
echo Output : $out
cpt=$(basename $0).omega.cpt
makecpt -Cpolar -I -T-7/7/1 > $cpt
grd=$(basename $0).omega.grd
awk '{if($1!="#")print $1, $2, $5/100*3600}' $in |
surface -R$range -T0.5 -I0.1/0.1 -G$grd
grdimage $grd -R$range -JM$size -C$cpt -K1.5 -Y1.5 -P > $out
psscale -D5.5/2.5/2/0.1 -C$cpt -Ba5f1:"@~w@~${sp}[Pa/s]": -O -K >> $out
PI=3.1415926535
# 20 m/s => 0.15 inch
scl=0.15
legmag=20
fac=$(echo "scale=5; $scl/$legmag" | bc)
# column 1=x, column 2=y, column 3=u, column 4=v
awk -v f=$fac -v pi=${PI} '{if($1!="#" && ($1%0.5)==0 && ($2%0.5)==0) \
printf "%12.6f %12.6f %12.6f %12.6f\n", \
$1,$2,(180.0/pi)*atan2($4,$3),sqrt($3*$3+$4*$4)*f}' $in| \
psxy -R$range -JM$size -Sv0.01/0.1/0.05n0.2 -G0 \
-O -K >> $out
pscoast -R$range -JM -W5/${brown} -O -K >>$out
psbasemap -R$range -B$anot -JM -O -K >> $out
legend=legend.txt
cat <<EOF> $legend
0.5 0.5 ${legmag} 0
EOF
awk -v f=$fac -v pi=${PI} '{if($1!="#") \
printf "%12.6f %12.6f %12.6f %12.6f\n", \
$1,$2,(180.0/pi)*atan2($4,$3),sqrt($3*$3+$4*$4)*f}' $legend |\
psxy -R0/1/0/1 -JX${size}/1 -Sv0.01/0.1/0.05n0.2 -G0 -O -K -Y-1.5 >>$out
pstext -R -JX <<EOF -O -K >>$out
0.55 0.5 16 0 0 LM ${legmag} m/s
EOF
xoffset=
yoffset=7
comment=
. ./note.sh
rm -f $legend $cpt $grd
$ cat ./pl.msms.sh
#!/bin/bash
# Description:
#
# Author: AM
#
# Host: aofd31.fish.nagasaki-u.ac.jp
# Directory: /home/elham/NetCDF2txt_MSM
#
# Revision history:
# This file is created by /usr/local/mybin/ngmt.sh at 15:56 on 04-11-2015.
. ./gmtpar.sh
echo "Bash script $0 starts."
range=120/150/22/47
size=5
xanot=a10f5
yanot=a5f5
anot=${xanot}/${yanot}WSne
in=$1
if [ ! -f $in ]; then
echo Error in $0 : No such file, $in
exit 1
fi
psdir="./fig/"
if [ ! -d ${psdir} ];then
mkdir -p $psdir
fi
out=${psdir}$(basename $in .txt).ps
echo Input : $in
echo Output : $out
cpt=$(basename $0).RH.cpt
makecpt -Ctopo -I -T50/100/5 > $cpt
grd=$(basename $0).RH.grd
awk '{if($1!="#")print $1, $2, $4}' $in |
surface -R$range -T0.5 -I0.1/0.1 -G$grd
grdimage $grd -R$range -JM$size -C$cpt -K1.5 -Y1.5 -P > $out
psscale -D5.5/2.5/2/0.1 -C$cpt -Ba10f10:"RH": -O -K >> $out
PI=3.1415926535
# 20 m/s => 0.15 inch
##scl=0.15
##legmag=20
##fac=$(echo "scale=5; $scl/$legmag" | bc)
## column 1=x, column 2=y, column 3=u, column 4=v
#awk -v f=$fac -v pi=${PI} '{if($1!="#" && ($1%0.5)==0 && ($2%0.5)==0) \
#printf "%12.6f %12.6f %12.6f %12.6f\n", \
#$1,$2,(180.0/pi)*atan2($4,$3),sqrt($3*$3+$4*$4)*f}' $in| \
#psxy -R$range -JM$size -Sv0.01/0.1/0.05n0.2 -G0 \
# -O -K >> $out
pscoast -R$range -JM -W5/${brown} -O -K >>$out
psbasemap -R$range -B$anot -JM -O -K >> $out
#legend=legend.txt
#cat <<EOF> $legend
#0.5 0.5 ${legmag} 0
#EOF
#awk -v f=$fac -v pi=${PI} '{if($1!="#") \
#printf "%12.6f %12.6f %12.6f %12.6f\n", \
#$1,$2,(180.0/pi)*atan2($4,$3),sqrt($3*$3+$4*$4)*f}' $legend |\
#psxy -R0/1/0/1 -JX${size}/1 -Sv0.01/0.1/0.05n0.2 -G0 -O -K -Y-1.5 >>$out
#
#pstext -R -JX <<EOF -O -K >>$out
#0.55 0.5 16 0 0 LM ${legmag} m/s
#EOF
xoffset=
yoffset=7
comment=
. ./note.sh
rm -f $legend $cpt $grd
echo "Done $0"