Commit a09d118a authored by Paulo V C Medeiros's avatar Paulo V C Medeiros
Browse files

Initial commit

Added files from Per Dahlgren, originally located at

/home/ms/no/fasg/CARRA/local_obs/
parents
FC=gfortran
LD=gfortran
FC_FLAGS=-fdefault-real-8
LD_FLAGS=
OBJ=carra_obsoul.main.o ext_lam_synop.o
carra_obsoul.main.x: $(OBJ)
$(LD) $(LD_FLAGS) -o carra_obsoul.main.x $(OBJ)
%.o: %.f90
$(FC) $(FC_FLAGS) -c $<
FC=gfortran
LD=gfortran
FC_FLAGS=-fdefault-real-8
LD_FLAGS=
yearmonday hour
Processed dates new obsoul created merged
19980101 to 19980731 yes yes
#!/bin/ksh
GCDIR=/scratch/ms/no/fasg/CARRA/local_obs_wrk/GCnet
OBDIR=/scratch/ms/no/fasg/CARRA/local_obs_wrk/obsoul_out
cd $GCDIR
GCYMLIST=$(ls -1 GCnet201* | cut -c6-11)
for GCYM in $GCYMLIST;do
tar xf GCnet${GCYM}.tar
SY=$(echo $GCYM | cut -c3-4)
DTGLIST=$(ls -1 gcnet${SY}* | awk '{print "20"substr($1,6,2)substr($1,8,6)}')
for DTG in $DTGLIST;do
SDTG=$(echo $DTG | cut -c3-10)
GCFILE=gcnet${SDTG}.obsoul
YY=$(echo $DTG | cut -c1-4)
MM=$(echo $DTG | cut -c5-6)
OBSOUL=../obsoul_out/$YY/$MM/obsoul$DTG
echo "cat $OBSOUL $GCFILE"
if [[ ! -e $OBSOUL ]];then
echo $OBSOUL does not exist
[[ -d ../obsoul_out/$YY ]] || mkdir ../obsoul_out/$YY
[[ -d ../obsoul_out/$YY/$MM ]] || mkdir ../obsoul_out/$YY/$MM
YMD=$(echo $DTG | cut -c1-8)
HH=$(echo $DTG | cut -c9-10)
sed s/yearmonday/$YMD/g ../OBSOULFILE_template | sed s/hour/$HH/g > $OBSOUL
fi
cat $OBSOUL $GCFILE > ttt
/bin/mv ttt $OBSOUL
done
/bin/rm gcnet${SY}*
done
#!/bin/ksh
GCDIR=/scratch/ms/no/fasg/CARRA/local_obs_wrk/GCnet
OBDIR=/scratch/ms/no/fasg/CARRA/local_obs_wrk/obsoul_out
cd $GCDIR
GCYMLIST=$(ls -1 GCnet2018* | cut -c6-11)
for GCYM in $GCYMLIST;do
# tar xf GCnet${GCYM}.tar
SY=$(echo $GCYM | cut -c3-4)
DTGLIST=$(ls -1 gcnet${SY}* | awk '{print "20"substr($1,6,2)substr($1,8,6)}')
for DTG in $DTGLIST;do
SDTG=$(echo $DTG | cut -c3-10)
GCFILE=gcnet${SDTG}.obsoul
YY=$(echo $DTG | cut -c1-4)
MM=$(echo $DTG | cut -c5-6)
OBSOUL=../obsoul_out/$YY/$MM/obsoul$DTG
echo "cat $OBSOUL $GCFILE"
if [[ -e $OBSOUL ]];then
echo $OBSOUL does not exist
fi
done
exit
done
program carra_obsoul
implicit none
integer, parameter :: npar=13
real, parameter :: rmissval=-9.
integer :: ipar,i_block,i_stn,icount_stn
integer :: istat,ios,narg,iarg
real :: rval_block,rval_station
real :: rval_lat,rval_lon,rval_hei,rval_baro
real, dimension(npar) :: rval
character(len=2) :: country,cval_hour
character(len=3) :: win
character(len=4) :: subset
character(len=8) :: indic
character(len=10) :: cval_date,date
character(len=90) :: line
character(len=256) :: ifile,ofile,carg(5)
!-----------------------------------------------------------------------
! INPUT PARAMETERS
!-----------------------------------------------------------------------
narg=IARGC()
if (narg<5) then
PRINT*,'USAGE: exe file country subset date'
STOP
endif
do iarg=1,narg
CALL GETARG(iarg,carg(iarg))
enddo
ifile=TRIM(carg(1))
ofile='obsoul.txt'
country=TRIM(carg(2))
subset=TRIM(carg(3))
date=TRIM(carg(4))
win=TRIM(carg(5))
write(*,*) 'ifile = ',TRIM(ifile)
write(*,*) 'country = ',country
write(*,*) 'subset = ',subset
write(*,*) 'date = ',date
write(*,*) 'win = ',win
!-----------------------------------------------------------------------
! OPEN FILES
!-----------------------------------------------------------------------
open(unit=21,file=ifile,status='old',action='read',form='formatted',iostat=istat)
if (istat.ne.0) stop 'OPEN FAILED ON INPUT FILE [unit=21]'
open(unit=61,file=ofile,status='new',action='write',form='formatted',iostat=ios)
if (ios.ne.0) stop 'OPEN FAILED ON OUTPUT FILE [unit=61]'
!-----------------------------------------------------------------------
! READ LEADING LINE IN NORWEGIAN DATA
!-----------------------------------------------------------------------
if ( country == 'NO' ) READ(21,'(a)') line
!***********************************************************************
! READ ALL AVAILABLE STNDATA FROM INPUT DATA FILE FOR SPECIFIED
! country , subset , date
icount_stn = 0
do
!***********************************************************************
do ipar=1,npar
rval(ipar)=rmissval
enddo
SELECT CASE (country)
CASE ('DK','FI','SE')
read(21,*,iostat=istat) cval_date,rval_block,rval_station, &
rval_lat,rval_lon,rval_hei,rval_baro, &
(rval(ipar),ipar=1,13)
if (istat < 0) exit
CASE ('IS')
if ( subset == 'None' ) then
read(21,*,iostat=istat) cval_date,rval_block,rval_station, &
rval_lat,rval_lon,rval_hei,rval_baro, &
(rval(ipar),ipar=1,13)
if (istat < 0) exit
rval(4)=-9.
endif
if ( subset == 'SNOW' ) then
read(21,*,iostat=istat) cval_date,rval_block,rval_station, &
rval_lat,rval_lon,rval_hei,rval_baro, &
(rval(ipar),ipar=1,13)
if (istat < 0) exit
cval_hour=cval_date(9:10)
if ( cval_hour == '09' ) then
cval_date(9:10)='06'
do ipar=1,3
rval(ipar)=-9.
enddo
do ipar=5,npar
rval(ipar)=-9.
enddo
else
cval_date='2100010100'
endif
endif
CASE ('NO')
if ( subset == 'None' ) then
read(21,*,iostat=istat) cval_date,rval_station, &
rval_lat,rval_lon,rval_hei,rval_baro, &
(rval(ipar),ipar=1,3), &
rval(6),rval(5),(rval(ipar),ipar=7,8), &
(rval(ipar),ipar=10,13)
if (istat < 0) exit
endif
if ( subset == 'CLIM' ) then
read(21,*,iostat=istat) cval_date,rval_station, &
rval_lat,rval_lon,rval_hei, &
rval(4),rval(9)
if (istat < 0) exit
endif
CASE default
write(*,*) country,' not allowed'
stop
END SELECT
!***********************************************************************
! IF DATE IS CORRECT - WRITE TO TEMPORARY OUTPUT DATA FILE
if ((cval_date.eq.date).and.(istat.eq.0)) then
icount_stn = icount_stn + 1
!***********************************************************************
indic=' '
SELECT CASE (country)
CASE ('DK')
if (rval_station.lt.1000.) then
write(indic(1:2),'(i2.2)') INT(rval_block)
write(indic(3:5),'(i3.3)') INT(rval_station)
else if (rval_station.lt.10000.) then
indic='420 '
write(indic(4:7),'(i4.4)') INT(rval_station)
else
write(*,*) 'ERROR : Something wrong with DK stn nr = ',INT(rval_station)
endif
CASE ('FI')
if (rval_station.lt.1000.) then
write(indic(1:2),'(i2.2)') INT(rval_block)
write(indic(3:5),'(i3.3)') INT(rval_station)
else if ((rval_station.ge.2000.).and.(rval_station.lt.3000.)) then
i_stn=INT(rval_station)
i_stn=i_stn-2000
write(indic(1:2),'(i2.2)') INT(rval_block)
write(indic(3:5),'(i3.3)') i_stn
else if (rval_station.ge.700000.) then
indic='2 '
write(indic(2:7),'(i6.6)') INT(rval_station)
else
write(*,*) 'ERROR : Something wrong with FI stn nr = ',INT(rval_station)
endif
CASE ('IS')
if (rval_station.lt.5000.) then
write(indic(1:5),'(i5.5)') INT(rval_station)
else if (rval_station.ge.4000000.) then
write(indic(1:7),'(i7.7)') INT(rval_station)
else
write(*,*) 'ERROR : Something wrong with IS stn nr = ',INT(rval_station)
endif
CASE ('NO')
if (rval_station.lt.2000.) then
write(indic(1:5),'(i5.5)') INT(rval_station)
else if (rval_station.ge.100000.) then
write(indic(1:6),'(i6.6)') INT(rval_station)
else
write(*,*) 'ERROR : Something wrong with NO stn nr = ',INT(rval_station)
endif
CASE ('SE')
if (rval_station.lt.1000.) then
write(indic(1:2),'(i2.2)') INT(rval_block)
write(indic(3:5),'(i3.3)') INT(rval_station)
else if (rval_station.ge.50000.) then
indic='2 '
write(indic(2:7),'(i6.6)') INT(rval_station)
else
write(*,*) 'ERROR : Something wrong with SE stn nr = ',INT(rval_station)
endif
END SELECT
!-----------------------------------------------------------------------
! ASSIGN SPECIAL VALUE TO MISSING DATA
!-----------------------------------------------------------------------
if (rval_hei.lt.0.) rval_hei = rmissval
do ipar=1,npar
if (rval(ipar).lt.0.) then
rval(ipar)=rmissval
endif
enddo
!-----------------------------------------------------------------------
! FORCE VARIABLES 1-4,7-13 TO BE MISSING FOR win='OFF'
!-----------------------------------------------------------------------
if ( win == 'OFF' ) then
do ipar=1,4
rval(ipar)=rmissval
enddo
do ipar=7,13
rval(ipar)=rmissval
enddo
endif
!-----------------------------------------------------------------------
! WRITE OUT DATA TO OBSOUL FILE
!-----------------------------------------------------------------------
call EXT_LAM_SYNOP(date,indic,rval_lat,rval_lon,rval_hei,rval)
!***********************************************************************
endif
! END IF DATE IS CORRECT - WRITE TO TEMPORARY OUTPUT DATA FILE
!***********************************************************************
!***********************************************************************
enddo
! END READ ALL AVAILABLE DATA FROM INPUT DATA FILE
!***********************************************************************
close(21)
close(61)
write(*,*) icount_stn,' ',country,' ',subset,' stations at ',date
end program carra_obsoul
#!/bin/ksh
#SBATCH --qos=normal
#SBATCH --job-name=carra_obsoul
#SBATCH --output=/scratch/ms/no/fasg/CARRA/local_obs_wrk/obsoul_out/carra_obsoul.out
#SBATCH --error=/scratch/ms/no/fasg/CARRA/local_obs_wrk/obsoul_out/carra_obsoul.err
set -a
print "\n\t CARRA_OBSOUL_PROD.KSH starts at $(date)"
ulimit -c 0
integer datornr
integer iw
dator=ECGATE
hdir=/scratch/ms/no/fasg/CARRA/local_obs_wrk/obsoul_out
ddir=/scratch/ms/no/fasg/CARRA/local_obs_wrk
odir=/scratch/ms/no/fasg/CARRA/local_obs_wrk
cd $hdir
print "\n\t Working directory on $dator is \t $(pwd)"
print "\t Input data is stored in directory \t $ddir"
print "\t Output data is stored in directory \t $odir"
#-----------------------------------------------------------------------
# Specify Times of Initial Conditions
#-----------------------------------------------------------------------
years=2005 ; mons=05 ; days=01 ; hours=00 ; dhour=03
yeare=2005 ; mone=07 ; daye=31 ; houre=21
print "\n\t years = $years \t mons = $mons \t days = $days \t hours = $hours \t dhour = $dhour"
print "\t yeare = $yeare \t mone = $mone \t daye = $daye \t houre = $houre"
SDATE=$years$mons$days$hours
EDATE=$yeare$mone$daye$houre
print "\t SDATE = $SDATE \t EDATE = $EDATE \t DHOUR = $dhour"
#-----------------------------------------------------------------------
# CREATE DIRECTORIES IF THEY DO NOT EXIST
#-----------------------------------------------------------------------
########################################################################
# Loop over Initial Condition Times ITO
########################################################################
date=$SDATE
until (( date > EDATE )) ; do
YYYY=$(echo $date | cut -c1-4)
MM=$(echo $date | cut -c5-6)
DD=$(echo $date | cut -c7-8)
HH=$(echo $date | cut -c9-10)
ITO=${YYYY}${MM}${DD}${HH} ; print "\n\n\t ITO = $ITO"
# Check directory
[[ -d $hdir/$YYYY/$MM ]] || mkdir -p $hdir/$YYYY/$MM
cd $hdir/$YYYY/$MM
ofile=obsoul$date
sed "s/year/${YYYY}/" $ddir/OBSOULFILE_template > OBSOULFILE_template.1
sed "s/mon/${MM}/" OBSOULFILE_template.1 > OBSOULFILE_template.2
sed "s/day/${DD}/" OBSOULFILE_template.2 > OBSOULFILE_template.3
sed "s/hour/${HH}/" OBSOULFILE_template.3 > OBSOULFILE
mv OBSOULFILE $ofile
#-------------------------------------------------------------------------------
# HOUSEKEEPING
#-------------------------------------------------------------------------------
/bin/rm OBSOULFILE_template.1
/bin/rm OBSOULFILE_template.2
/bin/rm OBSOULFILE_template.3
########################################################################
# Loop over 3 time points centered at date ITO ITO_W
########################################################################
for iw in -1 0 1 ; do
date_w=$(dateincr -h $date $iw)
YYYY_W=$(echo $date_w | cut -c1-4)
MM_W=$(echo $date_w | cut -c5-6)
DD_W=$(echo $date_w | cut -c7-8)
HH_W=$(echo $date_w | cut -c9-10)
ITO_W=${YYYY_W}${MM_W}${DD_W}${HH_W}
WIN='OFF'
(( iw == 0 )) && WIN='CEN'
#----- FI DIRECTORY AT FIRST TIME POINT IN MONTH -----------------------
if { (( DD_W == 01 )) && (( HH_W == 00 )) } ; then
date_w_FI=$(dateincr -h $date_w -1)
YYYY_W_FI=$(echo $date_w_FI | cut -c1-4)
MM_W_FI=$(echo $date_w_FI | cut -c5-6)
DD_W_FI=$(echo $date_w_FI | cut -c7-8)
HH_W_FI=$(echo $date_w_FI | cut -c9-10)
ITO_W_FI=${YYYY_W_FI}${MM_W_FI}${DD_W_FI}${HH_W_FI}
print "\n\t ITO_W = $ITO_W \t WIN = $WIN \t ITO_W_FI = $ITO_W_FI"
else
YYYY_W_FI=$(echo $date_w | cut -c1-4)
MM_W_FI=$(echo $date_w | cut -c5-6)
DD_W_FI=$(echo $date_w | cut -c7-8)
HH_W_FI=$(echo $date_w | cut -c9-10)
ITO_W_FI=${YYYY_W_FI}${MM_W_FI}${DD_W_FI}${HH_W_FI}
print "\n\t ITO_W = $ITO_W \t WIN = $WIN \t ITO_W_FI = $ITO_W_FI"
fi
#----- FI DIRECTORY AT FIRST POINT IN MONTH ----------------------------
########################################################################
# Loop over dataset dataset
########################################################################
for dataset in 1 2 ; do
case $dataset in
1) dfile="$ddir/${YYYY_W}/Asiaq_${YYYY_W}${MM_W}.txt"
land=DK
subset=None ;;
2) dfile="$ddir/${YYYY_W}/synop_${YYYY_W}${MM_W}${DD_W}.txt"
land=DK
subset=None ;;
*) exit ;;
esac
if [[ -f $dfile && -s $dfile ]] ; then
print "\n\t dfile = $dfile \t Exist"
print $dfile $land $subset $ITO_W $WIN
$ddir/carra_obsoul.main.x $dfile $land $subset $ITO_W $WIN
cat obsoul.txt >> $ofile
/bin/rm obsoul.txt
# if (( $dataset == 1 ));then
# /bin/mv obsoul.txt obsoul_Asiaq_${date_w}.txt
# elif (( $dataset == 2 ));then
# /bin/mv obsoul.txt obsoul_synop_${date_w}.txt
# fi
else
print "\n\t dfile = $dfile \t Does not exist"
fi
########################################################################
done
# END Loop over dataset dataset
########################################################################
########################################################################
done
# END Loop over 3 time points centered at date ITO ITO_W
########################################################################
########################################################################
date=$(dateincr -h $date +$dhour)
done
# END Loop over Initial Condition Times ITO
########################################################################
print "\n\t CARRA_OBSOUL_PROD.KSH ends at $(date)"
#!/bin/ksh
#SBATCH --qos=normal
#SBATCH --job-name=carra_obsoul
#SBATCH --output=/scratch/ms/no/fasg/CARRA/local_obs_wrk/obsoul_out/carra_obsoul.out
#SBATCH --error=/scratch/ms/no/fasg/CARRA/local_obs_wrk/obsoul_out/carra_obsoul.err
set -a
print "\n\t CARRA_OBSOUL_PROD.KSH starts at $(date)"
ulimit -c 0
integer datornr
integer iw
dator=ECGATE
hdir=/scratch/ms/no/fasg/CARRA/local_obs_wrk/obsoul_out
ddir=/scratch/ms/no/fasg/CARRA/local_obs_wrk
odir=/scratch/ms/no/fasg/CARRA/local_obs_wrk
cd $hdir
print "\n\t Working directory on $dator is \t $(pwd)"
print "\t Input data is stored in directory \t $ddir"
print "\t Output data is stored in directory \t $odir"
#-----------------------------------------------------------------------
# Specify Times of Initial Conditions
#-----------------------------------------------------------------------
years=2005 ; mons=03 ; days=01 ; hours=00 ; dhour=03
yeare=2005 ; mone=04 ; daye=30 ; houre=21
print "\n\t years = $years \t mons = $mons \t days = $days \t hours = $hours \t dhour = $dhour"
print "\t yeare = $yeare \t mone = $mone \t daye = $daye \t houre = $houre"
SDATE=$years$mons$days$hours
EDATE=$yeare$mone$daye$houre
print "\t SDATE = $SDATE \t EDATE = $EDATE \t DHOUR = $dhour"
#-----------------------------------------------------------------------