#!/bin/csh
#
# Data Assimilation Research Testbed -- DART
# Copyright 2004, 2005, Data Assimilation Initiative, University Corporation for Atmospheric Research
# Licensed under the GPL -- www.gpl.org/licenses/gpl.html
#
# <next three lines automatically updated by CVS, do not edit>
# $Id: launch_perfect_model_obs,v 1.4 2005/02/26 06:14:25 thoar Exp $
# $Source: /home/thoar/CVS.REPOS/DART/models/wrf/shell_scripts/launch_perfect_model_obs,v $
# $Name:  $
#
# Shell script to launch the program perfect_model_obs.

set PRES = (1004  993  980 \
             965  945  920 \
             890  853  807 \
             755  696  633 \
             568  504  444 \
             386  335  289 \
             248  212  180 \
             152  127  105 \
              86   70   56 )


# filename for output of observation set_def_list? [set_def.out]

echo 'set_def.out' > set_def.in

# Input the number of unique observation sets you might define

set NSET = 1

echo $NSET >> set_def.in

# Input error variance for this observation definition

set VAR = 1.0

set ISET = 0
# Loop over number of sets

while ($ISET < $NSET )

   @ ISET ++

# How many observations in set

   set BYLEV = 506
   set NLEV = 27

   set NOBS = `expr $BYLEV \* $NLEV`

   echo $NOBS >> set_def.in

   set ILEV = 0
# Loop over levels

   while ($ILEV < $NLEV )

   @ ILEV ++

   set IOBS = 0
# Loop over observations on the level

   while ($IOBS < $BYLEV )

      @ IOBS ++

      echo $VAR >> set_def.in

# Input an integer index if this is identity observation, else -1

      echo '-1' >> set_def.in

# Vertical co-ordinate options
# -1 -> surface pressure, 1 -> model level, 2 -> pressure, 3 -> height

      echo '2' >> set_def.in

# Vertical co-ordinate Pressure (in hPa)

      echo $PRES[$ILEV] >> set_def.in

# Input longitude for this obs: value 0 to 360.0 or a negative number for 
# Uniformly distributed random location in the horizontal

      set loc = `head -n ${IOBS} lon-lat-fix.dat | tail -n 1`
      set lon = $loc[1]
      set lat = $loc[2]

      echo $lon >> set_def.in

# Input latitude for this obs: value -90.0 to 90.0

      echo $lat >> set_def.in

# input obs kind: u = 1, v = 2, ps = 3, t = 4, qv = 5

      echo '4' >> set_def.in

   end

   end

end

create_obs_set_def < set_def.in

echo 'set_def.out' > create_obs_sequence.in

# To input a regularly repeating time sequence enter 1
# To enter an irregular list of times enter 2

set TIME_SEQ = 1

echo $TIME_SEQ >> create_obs_sequence.in

set NCYCLE = 41

echo $NCYCLE >> create_obs_sequence.in

# Input time of initial ob in sequence in days and seconds

set IDAY = 0
set ISEC = 0

echo "${IDAY},${ISEC}" >> create_obs_sequence.in

# Input period of obs in days and seconds

set PDAY = 0
set PSEC = 21600

echo "${PDAY},${PSEC}" >> create_obs_sequence.in

echo 'obs_seq.in' >> create_obs_sequence.in

create_obs_sequence < create_obs_sequence.in

#async_filter.csh | perfect_model_obs
perfect_model_obs
