#!/bin/bash                                                                                                                                                                            
pgm="/home/karolina/bin/gNut-Anubis-Pro.2021-08-09"                                                                                                                                    
                                                                                                                                                                                       
                                                                                                                                                                                       
outdir="/home/karolina/CADM/QC"                                                                                                                                                        
                                                                                                                                                                                       
beg=${01:?"par1: beg - gps_date format"} # begin date                                                                                                                                 $
end=${2:?"par2: end - gps_date fotmat"} # end daTE                                                                                                                                     
                                                                                                                                                                                       
                                                                                                                                                                                       
mjdBeg=$(gps_date $beg -o "%J")                                                                                                                                                        
mjdEnd=$(gps_date $end -o "%J")                                                                                                                                                        
mjd=$mjdBeg                                                                                                                                                                            
                                                                                                                                                                                       
                                                                                                                                                                                       
while [ $[${mjd/./}] -le $[${mjdEnd/./}] ]                                                                                                                                             
do                                                                                                                                                                                     
                                                                                                                                                                                       
  

year=$( gps_date "-mjd $mjd" -o "%Y")                                                                                                                                                
   doy=$( gps_date "-mjd $mjd" -o "%j")                                                                                                                                                
                                                                                                                                                                                       
rinexn="/home/karolina/ldc/orbits_brd/gop3/${year}/BRDC00GOP_R_${year}${doy}0000_01D_MN.rnx.gz"                                                                                        
rinexo="/home/karolina/CADM/OBS/${year}/${doy}/CADM00CZE_R_${year}${doy}0000_01D_30S_MO.crx.gz"                                                                                        
                                                                                                                                                                                       
# rinexn not exit ->                                                                                                                                                                   
# if not exist(                                                                                                                                                                        
#   mjd=$(echo $mjd + 1 | bc -l)                                                                                                                                                       
#   continue;                                                                                                                                                                          
# fi                                                                                                                                                                                   
                                                                                                                                                                                       
$pgm --full \                                                                                                                                                                          
\                                                                                                                                                                                      
:inp:rinexo "$rinexo" \                                                                                                                                                                
:inp:rinexn "$rinexn" \                                                                                                                                                                
:out:xtr "$outdir/${year}/CADM${year}${doy}.xtr.gz" \                                                                                                                                  
:out:xml "$outdir/${year}/CADM${year}${doy}.xml.gz" \                                                                                                                                  
:out:log "$outdir/${year}/CADM${year}${doy}.log.gz" \                                                                                                                                  
:out:verb=1                                                                                                                                                                            
                                                                                                                                                                                       
#elev cutoff = 15                                                                                                                                                                      
  mjd=$(echo $mjd + 1 | bc -l)                                                                                                                                                         
done                                                                                                                                                                                   
                                                                                                                                                                                       
                                                                                                                                                                                       
                                                                                                                                                                                       
                                                                                                                                                                                       
                                                                                                                                                                                       
                                                                                                                                                                                       
                                                                                                                                                                                       
#for i in {1..010}                                                                                                                                                                     
#do                                                                                                                                                                                    
                                                                                                                                                                                       
                                                                                                                                                                                       
                                                                                                                                                                                       
#done 