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

Remove backup (*~) files

parent b6dcf6d2
FC=gfortran
LD=gfortran
FC_FLAGS=-fdefault-real-8
LD_FLAGS=
#!/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
#!/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"
#-----------------------------------------------------------------------
# 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
# PD: This script is designed to cat Asiaq and Promice OBSOUL files
# into the final OBSOUL file. synop data are processed via the fortran code.
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=2017 ; mons=01 ; days=01 ; hours=00 ; dhour=03
yeare=2018 ; mone=06 ; 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"
#-----------------------------------------------------------------------
# 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
tar xf $ddir/Asiaq/Asiaq${YYYY_W}${MM_W}.tar
tar xf $ddir/Promice/Geus${YYYY_W}${MM_W}.tar
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 3 ; do
case $dataset in
1) YYYY_W_2D=$(echo ${YYYY_W} | cut -c3-4)
dfile="$ddir/Asiaq/Asiaq${YYYY_W_2D}${MM_W}${DD_W}${HH_W}.obsoul";;
2) dfile="$ddir/${YYYY_W}/synop_${YYYY_W}${MM_W}${DD_W}.txt"
land=DK
subset=None ;;
3) dfile="$ddir/Promice/geus${YYYY_W}${MM_W}${DD_W}${HH_W}.obsoul";;
*) exit ;;
esac
if [[ -f $dfile && -s $dfile ]] ; then
print "\n\t dfile = $dfile \t Exist"
print $dfile $land $subset $ITO_W $WIN
if [[ $dataset == 2 ]];then
$ddir/carra_obsoul.main.x $dfile $land $subset $ITO_W $WIN
cat obsoul.txt >> $ofile
/bin/rm obsoul.txt
else
cat $dfile >> $ofile
/bin/rm $dfile
fi
# 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)"
subroutine EXT_LAM_SYNOP(CLDATE,CINDIC,ZLATA,ZLONA,ZALTA,rval)
!-----------------------------------------------------------------------
! SUBROUTINE EXT_LAM_SYNOP(CLDATE,CINDIC,ZLATA,ZLONA,ZALTA,
! ZPMERA,ZPSTAA,ZT2M,ZDEW2M,ZDIR,ZWSP,ZRH,ZPRE,ZSNOW)
! 6 5 1 3 8 7 2 9 4
! call EXT_LAM_SYNOP(cval_date,INDIC,rval_lat,rval_lon,rval_hei,rval)
!-----------------------------------------------------------------------
implicit none
integer, parameter :: npar=13,nvar=15,NABSI=999999
real, parameter :: RG=9.80665,ZALTSY=500.,RABSI=1.70E+38,undef=999999.
integer :: IDAT,IDATE,IETM,INBP,INLV,IOCH,IOTP,IPRESCD,IRFL,IRLN,ISTD,ivar,NABSO
integer, dimension(nvar) :: IVNM,IFLG
real :: ew
real :: ZLATA,ZLONA,ZALTA,ZLAT,ZLON,ZALT
real :: ZPMERA,ZPSTAA,ZT2M,ZDEW2M,ZDIR,ZWSP,ZRH,ZSNOW
real :: ZPMER,ZPSTA,ZT,ZTD,ZHU
real :: RABSO
real,dimension(npar) :: rval
real,dimension(nvar) :: ZPOB,ZPRL,ZVAR
character(len=8) :: CINDIC
character(len=10) :: CLDATE
character(len=11) :: CLINDIC
character(len=12) :: CLLAT,CLLON
REAL FUNCTION EW(T)
IMPLICIT NONE
REAL :: T
EW(T) = EXP( 60.22274788372 - &
& 27.60156807553*AMAX1(0.,SIGN(1.,273.16-T)) - &
& ( 6822.400210096 - &
& 526.9788711908*AMAX1(0.,SIGN(1.,273.16-T)) )/T - &
& ALOG(T)*( 5.139266694451 - &
& 4.576133536908*AMAX1(0.,SIGN(1.,273.16-T)) ) )
RETURN
END FUNCTION EW
NABSO = NABSI
RABSO = RABSI
IDAT = NABSO
IETM = NABSO
INLV = NABSO
IRLN = NABSO
DO ivar=1,nvar
IVNM(ivar) = NABSO
ZPOB(ivar) = RABSO
ZPRL(ivar) = RABSO
ZVAR(ivar) = RABSO
IFLG(ivar) = NABSO
ENDDO
!-----------------------------------------------------------------------
! PARAMETERS - Set to a fixed value which is never changed
!-----------------------------------------------------------------------
IOTP = 1 ! OBSTYPE : 1 = Land SYNOP and SHIP reports
IOCH = 14 ! Code type for SYNOP : 14 = SYNOP land manual
IRFL = 1111 ! Observation quality flag [Assigned by program OULAN]
!-----------------------------------------------------------------------
! DATE
!-----------------------------------------------------------------------
READ(CLDATE,'(I10)') IDATE
IDAT = IDATE/100 ! YYYYMMDD
IETM = (IDATE - IDAT*100)*10000 ! hhmmss [without leading zeros in hh]
!-----------------------------------------------------------------------
! STN ID
!-----------------------------------------------------------------------
CLINDIC = " ' '"
CLINDIC(3:10)=CINDIC
!-----------------------------------------------------------------------
! GEOGRAPHICAL POSITION (X,Y,Z)
!-----------------------------------------------------------------------
CLLAT = ' '
CLLON = ' '
ZLAT = ZLATA ; WRITE (CLLAT(2:11),'(F10.5)') ZLAT
ZLON = ZLONA ; WRITE (CLLON(2:11),'(F10.5)') ZLON
ZALT = RABSO ; IF (ZALTA.ge.0.) ZALT=ZALTA
!-----------------------------------------------------------------------
! OBSERVED DATA
! VAR IPAR IVNM
!-----------------------------------------------------------------------
ZT2M = rval(1) ! 39
ZRH = rval(2) ! 58
ZDEW2M = rval(3) !
ZSNOW = rval(4) ! 92
ZPSTAA = rval(5) ! 1
ZPMERA = rval(6) ! 1
!-----------------------------------------------------------------------
! ASSIGN VALUES FOR THE DIFFERENT VARIABLES IF THEY EXIST INBP
!-----------------------------------------------------------------------
INBP = 0 ! Count of number of variables with observed data
!-----------------------------------------------------------------------
! ZPSTA ZPMER ps=5 pmsl=6 IVNM = 1
!-----------------------------------------------------------------------
ZPSTA=undef ; IF (ZPSTAA.ge.0.) ZPSTA = ZPSTAA
ZPMER=RABSO ; IF (ZPMERA.ge.0.) ZPMER = ZPMERA
IPRESCD=5
IF ( ZPSTA < undef ) THEN
IPRESCD=1
ELSE IF ( ZPMER < RABSO ) THEN
IPRESCD=0
ENDIF
IPRESCD=1
ISTD = IPRESCD*100000
IF ( ZPMER < RABSO .AND. ZALT < ZALTSY ) THEN
INBP = INBP + 1
IVNM(INBP) = 1
ZPOB(INBP) = - ZPMER
ZVAR(INBP) = 0.
IFLG(INBP) = 2064
ELSE IF ( ZPSTA < undef ) THEN
INBP = INBP + 1
IVNM(INBP) = 1
ZPOB(INBP) = ZPSTA
ZVAR(INBP) = ZALT * RG
IFLG(INBP) = 2064
ENDIF
!-----------------------------------------------------------------------
! ZT2M temp=1 IVNM = 39
!-----------------------------------------------------------------------
IF (ZT2M.ge.0.) THEN
INBP = INBP + 1
IVNM(INBP) = 39
ZPOB(INBP) = ZPSTA
ZVAR(INBP) = ZT2M
IFLG(INBP) = 2048
ENDIF
!-----------------------------------------------------------------------
! ZRH rh=2 IVNM = 58
!-----------------------------------------------------------------------
ZT = RABSI
ZTD = RABSI
ZHU = RABSI
IF (ZRH.ge.0.) THEN
INBP = INBP + 1
IVNM(INBP) = 58
ZPOB(INBP) = ZPSTA
ZVAR(INBP) = ZRH
IFLG(INBP) = 2048
ELSE
IF ((ZT2M.ge.0.).AND.(ZDEW2M.ge.0.)) THEN
ZT = ZT2M
ZTD = ZDEW2M
INBP = INBP + 1
IVNM(INBP) = 58
ZPOB(INBP) = ZPSTA
ZVAR(INBP) = NINT( 100. * ( EW(ZTD) / EW(ZT) ) )
ZHU = ZVAR(INBP) / 100.
IFLG(INBP) = 2048
ENDIF
ENDIF
!-----------------------------------------------------------------------
! ZSNOW snow=4 IVNM = 92
!-----------------------------------------------------------------------
IF (ZSNOW.ge.0.) THEN
INBP = INBP + 1
IVNM(INBP) = 92
ZPOB(INBP) = ZPSTA
ZVAR(INBP) = ZSNOW
IFLG(INBP) = 2048
ENDIF
!-----------------------------------------------------------------------
! Write out to file
!-----------------------------------------------------------------------
IF ( INBP.GT.0 ) THEN
INLV = INBP ! Number of variables with data in this post
IRLN = 12 + INLV*5 ! Total number of data in this record - including even this
WRITE (61,*) IRLN,IOTP,IOCH,CLLAT,CLLON,CLINDIC
WRITE (61,*) IDAT,IETM,ZALT,INLV,IRFL,ISTD
DO ivar=1,INBP
WRITE (61,*) IVNM(ivar),ZPOB(ivar),ZPRL(ivar),ZVAR(ivar),IFLG(ivar)
END DO
ENDIF
end subroutine EXT_LAM_SYNOP