Print 
Observations

Use ERA-40 observation archive which starts in 1957 and until 2001:

Until 2001 obtype=ai, class=e4 and then on obtype=ob, class=od.

All conventional observations that had been used in era40 had been 'wrapped' up into mars using

retrieve,
type=ai,date=$yyyymmdd,time=$hh,class=e4,
obstype=bufr,expver=0001,target="$wdir/bufr".

They have been stored as type=ai, so not type=ob.
One only has to specify date and time to get all data in a 6-hourly batch.

For type=ob, which in general contains data that arrived too late for the
analysis input,
one has to specify start and end time, such as: retrieve,
type=ob,date=${start_date},
time=${start_hour}01/to/${end_hour1}00,
obstype=hr,
target="$wdir/tovh".

The analysis input can then be filtered, see

https://software.ecmwf.int/wiki/display/UDOC/MARS+FAQ#MARSFAQ-HowcanIfilterAnalysisInputobservations?

e.g. first retrieve everything to a file and then loop over your obstypes
filtering out to individual files with something like

for obstype in s sa metar ss sas dsu ; do
mars <<EOF
retrieve,
type=ob,
obstype =${obstype},
date = 19780615,
time = 12,
range = 1800,
source=19780615.12Z.all,
target=19780615.12Z.${obstype}

EOF

done