Index: /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90	(revision 5062)
+++ /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90	(revision 5063)
@@ -21,5 +21,4 @@
    USE par_oce
    USE dom_oce                  ! Ocean space and time domain variables
-   USE obs_fbm, ONLY: ln_cl4    ! Class 4 diagnostic switch
    USE obs_read_prof            ! Reading and allocation of observations (Coriolis)
    USE obs_read_sla             ! Reading and allocation of SLA observations  
@@ -180,5 +179,5 @@
          &            ln_velhradcp, velhradcpfiles,                   &
          &            ln_velfb, velfbfiles, ln_velfb_av,              &
-         &            ln_profb_enatim, ln_ignmis, ln_cl4
+         &            ln_profb_enatim, ln_ignmis
 
       INTEGER :: jprofset
Index: /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/OPA_SRC/OBS/obs_fbm.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/OPA_SRC/OBS/obs_fbm.F90	(revision 5062)
+++ /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/OPA_SRC/OBS/obs_fbm.F90	(revision 5063)
@@ -45,8 +45,4 @@
    INTEGER, PARAMETER    :: fbimdi = -99999   !: Integers
    REAL(fbsp), PARAMETER :: fbrmdi =  99999   !: Reals
-
-   ! Output stream choice
-   LOGICAL               :: ln_cl4 = .FALSE.  !: Logical switch for
-                                              !: class 4 file outputs
  
    ! Main data structure for observation feedback data.
@@ -1030,31 +1026,4 @@
 
    SUBROUTINE write_obfbdata( cdfilename, fbdata )
-      !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE write_obfbdata  ***
-      !!
-      !! ** Purpose :   Write an obfbdata structure into a netCDF file.
-      !!
-      !! ** Method  :   Decides which output wrapper to use. 
-      !!
-      !! ** Action  : 
-      !!
-      !!----------------------------------------------------------------------
-      !! * Arguments
-      CHARACTER(len=*) :: cdfilename ! Output filename
-      TYPE(obfbdata)   :: fbdata     ! obsfbdata structure
-#if defined key_offobsoper
-      IF (ln_cl4) THEN
-          ! Class 4 file output stream
-          CALL write_obfbdata_cl( cdfilename, fbdata )
-      ELSE
-#endif
-          ! Standard feedback file output stream
-          CALL write_obfbdata_fb( cdfilename, fbdata )
-#if defined key_offobsoper
-      ENDIF
-#endif
-   END SUBROUTINE write_obfbdata
-
-   SUBROUTINE write_obfbdata_fb( cdfilename, fbdata )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE write_obfbdata  ***
@@ -1555,237 +1524,5 @@
 
       
-   END SUBROUTINE write_obfbdata_fb
-
-#if defined key_offobsoper
-   SUBROUTINE write_obfbdata_cl(cdfilename, fbdata)
-      !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE write_obfbdata_cl  ***
-      !!
-      !! ** Purpose : Write an obfbdata structure into a class 4 file.
-      !!
-      !! ** Method  : 1. Allocate memory needed by sao_write
-      !!              2. Map obfbdata into allocated memory
-      !!              3. Pass mapped data to sao_write
-      !!              4. Deallocate memory
-      !!----------------------------------------------------------------------
-      USE dom_oce, ONLY: narea
-      USE sao_write
-      USE sao_data
-      !! * Arguments
-      CHARACTER(len=*) :: cdfilename ! Feedback filename
-      TYPE(obfbdata)   :: fbdata     ! obsfbdata structure
-      !! * Local variables
-      CHARACTER(len=17), PARAMETER :: cpname = 'write_obfbdata_cl'
-      CHARACTER(len=64) :: &
-              & cdate, &   !: class 4 file validity date 
-              & cconf, &   !: model configuration
-              & csys, &    !: model system
-              & ccont, &   !: contact email
-              & cinst, &   !: institution
-              & cversion   !: model version
-      CHARACTER(len=8) :: &
-              & ckind      !: observation kind
-      CHARACTER(len=3) :: cfield
-      INTEGER :: kobs, &   !: number of observations
-              &  kvars, &  !: number of physical variables
-              &  kdeps, &  !: number of observed depths
-              &  kfcst, &  !: number of forecasts
-              &  kifcst, & !: current forecast number
-              &  kproc     !: processor number
-      INTEGER, DIMENSION(:, :, :), ALLOCATABLE :: &
-              &  kqc       !: quality control counterpart
-      INTEGER(KIND=2), DIMENSION(:, :, :), ALLOCATABLE :: &
-              &  k2qc       !: quality control counterpart
-      REAL(kind=fbdp) :: &
-              &  pmodjuld  !: model Julian day
-      REAL(kind=fbdp), DIMENSION(:), ALLOCATABLE :: &
-              &  plead, &  !: forecast lead time
-              &  plam, &   !: longitude of observation
-              &  pphi, &   !: latitude of observation
-              &  ptim      !: time of observation
-      REAL(kind=fbdp), DIMENSION(:, :), ALLOCATABLE :: &
-              &  pdep      !: depths of observations
-      REAL(kind=fbdp), DIMENSION(:, :, :), ALLOCATABLE :: &
-              &  pob, &    !: observation counterpart
-              &  pextra    !: extra field counterpart
-      REAL(kind=fbdp), DIMENSION(:, :, :), ALLOCATABLE :: &
-              &  pmod      !: model counterpart
-      CHARACTER(len=128) :: &
-              &  clfilename  !: class 4 file name
-      CHARACTER(len=128), DIMENSION(:), ALLOCATABLE :: &
-              &  ctype       !: Instrument type
-      CHARACTER(len=nf90_max_name) :: &
-              & cdtmp        !: NetCDF variable name
-      CHARACTER(len=8), DIMENSION(:), ALLOCATABLE :: &
-              &  cwmo, &     !: Instrument WMO ID
-              &  cunit, &    !: Instrument WMO ID
-              &  cvarname    !: Instrument WMO ID
-      INTEGER :: &
-              &  idep, &     !: Loop variable
-              &  ivar, &     !: Loop variable
-              &  iobs, &     !: Loop variable
-              &  ii, &       !: Loop variable
-              &  ij, &       !: Loop variable
-              &  ik, &       !: Loop variable
-              &  il          !: Loop variable
-      cconf = TRIM(cl4_cfg)
-      csys = TRIM(cl4_sys)
-      cversion = TRIM(cl4_vn)
-      ccont = TRIM(cl4_contact)
-      cinst = TRIM(cl4_inst)
-      cdate = TRIM(cl4_date)
-      CALL locate_kind(cdfilename, ckind)
-      kproc = narea
-      kfcst = cl4_fcst_len
-      kobs = fbdata%nobs
-      kdeps = fbdata%nlev
-      kvars = fbdata%nvar
-      IF (kobs .GT. 0) THEN
-         ALLOCATE(plam(kobs), &
-               &  pphi(kobs), &
-               &  ptim(kobs), &
-               &  plead(kfcst), &
-               &  pdep(kdeps, kobs), &
-               &  kqc(kdeps, kvars, kobs), &
-               &  k2qc(kdeps, kvars, kobs), &
-               &  pob(kdeps, kvars, kobs), &
-               &  pmod(kdeps, kvars, kobs), &
-               &  pextra(kdeps, kvars, kobs), &
-               &  ctype(kobs), &
-               &  cwmo(kobs), &
-               &  cunit(kvars), &
-               &  cvarname(kvars))
-         plam(:) = fbdata%plam(:)
-         pphi(:) = fbdata%pphi(:)
-         ptim(:) = fbdata%ptim(:)
-         pdep(:, :) = fbdata%pdep(:, :)
-         kqc(:,:,:) = 1.
-         DO ii = 1, kvars
-            cvarname(ii)  = fbdata%cname(ii)
-            cunit(ii)     = fbdata%cobunit(ii)
-         END DO
-
-         ! Quality control algorithm
-         k2qc(:,:,:) = NF90_FILL_SHORT
-         DO idep = 1,kdeps
-            DO ivar = 1, kvars
-               DO iobs = 1, kobs
-                  ! 1 symbolises good for fbdata
-                  ! fbimdi symbolises that qc has not been set
-                  ! Essentially, if any fbdata flag is not an element of {1, fbimdi}
-                  ! then set the class 4 flag to bad.
-                  ! Note: fbdata%ioqc is marked good if zero.
-                  IF (((fbdata%ioqc(iobs) /= 0) .AND. &
-                            & (fbdata%ioqc(iobs) /= fbimdi)) .OR. &
-                    & ((fbdata%ipqc(iobs) /= 1) .AND. &
-                            & (fbdata%ipqc(iobs) /= fbimdi)) .OR. &
-                    & ((fbdata%idqc(idep,iobs) /= 1) .AND. &
-                            & (fbdata%idqc(idep,iobs) /= fbimdi)) .OR. &
-                    & ((fbdata%ivqc(iobs,ivar) /= 1) .AND. &
-                            & (fbdata%ivqc(iobs,ivar) /= fbimdi)) .OR. &
-                    & ((fbdata%ivlqc(idep,iobs,ivar) /= 1) .AND. &
-                            & (fbdata%ivlqc(idep,iobs,ivar) /= fbimdi)) .OR. &
-                    & ((fbdata%itqc(iobs) /= 1) .AND. &
-                            & (fbdata%itqc(iobs) /= fbimdi))) THEN
-                     ! 1 symbolises bad for class 4 file
-                     k2qc(idep, ivar, iobs) = 1
-                  ELSE
-                     ! 0 symbolises good for class 4 file
-                     k2qc(idep, ivar, iobs) = 0
-                  END IF 
-               END DO
-            END DO
-         END DO
-
-         ! Permute observation dimensions
-         pob(:,:,:) = RESHAPE(fbdata%pob, (/kdeps, kvars, kobs/), &
-                            & ORDER=(/1, 3, 2/))
-
-         ! Explicit model counterpart dimension permutation
-         ! 1,2,3,4 --> 1,4,2,3
-         pmod(:,:,:) = fbrmdi
-         ij = cl4_fcst_idx(jimatch)
-         DO ii = 1,kdeps
-            DO ik = 1, kvars
-               DO il = 1, kobs
-                  pmod(ii,ik,il) = fbdata%padd(ii,il,1,ik)
-               END DO
-            END DO
-         END DO
-
-         ! Extra fields set to missing for now
-         pextra(:,:,:) = fbrmdi
-
-         ! Lead time of class 4 file is a global parameter
-         plead = cl4_leadtime(1:cl4_fcst_len)
-
-         ! Model Julian day
-         pmodjuld = cl4_modjuld
-
-         ! Observation types
-         ctype(:) = 'X'
-         DO ii = 1,kobs
-            ctype(ii) = fbdata%cdtyp(ii)
-         END DO
-
-         ! World Meteorology Organisation codes
-         cwmo(:) = fbdata%cdwmo(:)
-
-         ! Initialise class 4 file
-         CALL sao_wri_init(cconf, csys, ckind, cversion, ccont, cinst, cdate, &
-                         & kproc, kobs, kvars, kdeps, kfcst, &
-                         & clfilename)
-
-         ! Write standard variables
-         CALL sao_wri_default(clfilename, kobs, kvars, kfcst, kdeps, &
-                            & ctype, cwmo, cunit, cvarname, &
-                            & plam, pphi, pdep, ptim, pob, plead, &
-                            & k2qc, pmodjuld)
-         !! Write to optional variables
-         cdtmp = cl4_vars(jimatch)
-         IF ( (TRIM(cdtmp) == "forecast") .OR. &
-              (TRIM(cdtmp) == "persistence") ) THEN
-            !! 4D variables
-            CALL sao_wri_extra(clfilename, TRIM(cdtmp), kdeps, kfcst, &
-                            &  kvars, kobs, (/ 1,ij,1,1 /), (/ kdeps,1,kvars,kobs /), pmod)
-         ELSE
-            !! 3D variables
-            CALL sao_wri_extra(clfilename, TRIM(cdtmp), kdeps, &
-                            &  kvars, kobs, (/ 1,1,1 /), (/ kdeps,kvars,kobs /), pmod)
-         ENDIF
-
-         DEALLOCATE(plam, pphi, ptim, pdep, plead, kqc, k2qc, &
-                  & pob, pmod, pextra, ctype, cwmo, &
-                  & cunit, cvarname)
-      END IF
-   END SUBROUTINE write_obfbdata_cl
-#endif
-
-#if defined key_offobsoper
-   SUBROUTINE locate_kind(cdfilename, ckind)
-      !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE locate_kind  ***
-      !!
-      !! ** Purpose : Detect which kind of class 4 file is being produced.
-      !!
-      !! ** Method  : 1. Inspect cdfilename for observation kind.
-      !!----------------------------------------------------------------------
-      CHARACTER(len=*) :: cdfilename ! Feedback filename
-      CHARACTER(len=8) :: ckind
-      IF (cdfilename(1:3) == 'sst') THEN
-         ckind = 'SST'
-      ELSE IF (cdfilename(1:3) == 'sla') THEN
-         ckind = 'SLA'
-      ELSE IF (cdfilename(1:3) == 'pro') THEN
-         ckind = 'profile'
-      ELSE IF (cdfilename(1:3) == 'ena') THEN
-         ckind = 'profile'
-      ELSE IF (cdfilename(1:3) == 'sea') THEN
-         ckind = 'seaice'
-      ELSE
-         ckind = 'unknown'
-      END IF
-   END SUBROUTINE locate_kind
-#endif
+   END SUBROUTINE write_obfbdata
 
    SUBROUTINE putvaratt_obfbdata( idfile, idvar, cdlongname, cdunits, &
Index: /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/nemogcm.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/nemogcm.F90	(revision 5062)
+++ /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/nemogcm.F90	(revision 5063)
@@ -97,21 +97,16 @@
          !!
          !!----------------------------------------------------------------------
-         !! Class 4 output stream switch
-         USE obs_fbm, ONLY: ln_cl4
          !! Initialise NEMO
          CALL nemo_init
          !! Initialise Stand Alone Observation operator data
-         CALL sao_data_init( ln_cl4 )
-         !! Loop over various model counterparts
-         DO jimatch = 1, cl4_match_len
-            !! Initialise obs_oper
-            CALL dia_obs_init
-            !! Interpolate to observation space
-            CALL sao_interp
-            !! Pipe to output files
-            CALL dia_obs_wri
-            !! Reset the obs_oper between
-            CALL dia_obs_dealloc
-         END DO
+         CALL sao_data_init
+         !! Initialise obs_oper
+         CALL dia_obs_init
+         !! Interpolate to observation space
+         CALL sao_interp
+         !! Pipe to output files
+         CALL dia_obs_wri
+         !! Reset the obs_oper between
+         CALL dia_obs_dealloc
          !! Safely stop MPI
          IF(lk_mpp) CALL mppstop  ! end mpp communications
Index: /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao.nml
===================================================================
--- /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao.nml	(revision 5062)
+++ /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao.nml	(revision 5063)
@@ -1,3 +1,2 @@
-
 !----------------------------------------------------------------------
 !       namsao Stand Alone Observation operator namelist
@@ -10,35 +9,2 @@
    nn_sao_idx = 1
 /
-!----------------------------------------------------------------------
-!       namcl4 Class 4 obs_oper namelist
-!----------------------------------------------------------------------
-!   cl4_date      the verfication date of the class 4 file
-!   cl4_vars      the name of the variable in the class 4 file
-!   cl4_sys       the forecast system being used e.g. FOAM
-!   cl4_cfg       the model configuration being used e.g. amm7
-!   cl4_vn        the version number e.g. 12.0
-!   cl4_prefix    prefix which denotes the output file
-!   cl4_contact   email address of file creator
-!   cl4_inst      institution related to the data within the file
-!   cl4_leadtime  lead time axis of class 4 file
-!   cl4_fcst_idx  output file forecast index
-!   cl4_fcst_len  output file forecast dimension length
-!   cl4_match_len number of match types
-!
-&namcl4
-   cl4_leadtime = 12
-   cl4_fcst_idx = 1
-   cl4_fcst_len = 1
-   cl4_match_len = 1
-   cl4_date = '20130101'
-   cl4_vars = 'forecast'
-   cl4_sys = 'FOAM'
-   cl4_cfg = 'amm7'
-   cl4_vn = '12.0'
-   cl4_prefix = 'class4'
-   cl4_contact = ''
-   cl4_inst = 'UK Met Office'
-/
-
-
-
Index: /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_data.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_data.F90	(revision 5062)
+++ /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_data.F90	(revision 5063)
@@ -12,35 +12,13 @@
    INTEGER, PARAMETER :: MaxNumFiles = 1000
 
-   !! Class 4 file settings
-   INTEGER :: &
-           & cl4_fcst_idx(MaxNumFiles), & !: forecast indices
-           & cl4_match_len, &             !: number of match types
-           & cl4_fcst_len                 !: number of forecast days
-   CHARACTER(len=lc) :: &
-           & cl4_vars(MaxNumFiles), &  !: class 4 variables
-           & cl4_sys, &                !: class 4 system
-           & cl4_cfg, &                !: class 4 configuration
-           & cl4_date, &               !: class 4 date
-           & cl4_vn,  &                !: class 4 version
-           & cl4_prefix, &             !: class 4 prefix
-           & cl4_contact, &            !: class 4 contact
-           & cl4_inst                  !: class 4 institute
-   REAL ::   cl4_modjuld               !: model Julian day
-   REAL :: &
-      & cl4_leadtime(MaxNumFiles)      !: Lead time data
-
    !! Stand Alone Observation operator settings
    CHARACTER(len=lc) :: &
       & sao_files(MaxNumFiles)         !: model files
    INTEGER            :: &
-      & jifile, &                      !: current file list index
       & n_files, &                     !: number of files
-      & jimatch, &                     !: current match
       & nn_sao_idx(MaxNumFiles), &     !: time_counter indices
       & nn_sao_freq                    !: read frequency in time steps
-   CHARACTER(len=128) :: &
-      & alt_file                       !: altimeter file
 CONTAINS
-   SUBROUTINE sao_data_init( ld_cl4 )
+   SUBROUTINE sao_data_init()
       !!----------------------------------------------------------------------
       !!                    ***  SUBROUTINE sao_data_init ***
@@ -53,5 +31,4 @@
          & jf                           !: file dummy loop index
       LOGICAL :: lmask(MaxNumFiles)     !: Logical mask used for counting
-      LOGICAL, INTENT(IN) :: ld_cl4     !: Logical class 4 on/off
       INTEGER :: ios
 
@@ -59,30 +36,9 @@
       NAMELIST/namsao/sao_files, nn_sao_idx, nn_sao_freq
 
-      ! Class 4 file specifiers
-      NAMELIST/namcl4/cl4_vars, cl4_sys, cl4_cfg, cl4_date, cl4_vn, &
-         &            cl4_prefix, cl4_contact, cl4_inst, cl4_leadtime, &
-         &            cl4_fcst_idx, cl4_fcst_len, cl4_match_len
-
       ! Standard offline obs_oper initialisation
-      jimatch = 0                   !: match-up iteration variable 
-      jifile = 1                    !: input file iteration variable 
       n_files = 0                   !: number of files to cycle through
       sao_files(:) = ''             !: list of files to read in
       nn_sao_idx(:) = 0             !: list of indices inside each file
       nn_sao_freq = -1              !: input frequency in time steps
-
-      ! Class 4 initialisation
-      cl4_leadtime(:) = 0           !: Lead time axis value for each file
-      cl4_fcst_len = 0              !: Length of the forecast dimension
-      cl4_match_len = 1             !: Number of match types
-      cl4_fcst_idx(:) = 0           !: output file forecast index
-      cl4_vars(:) = ''              !: output file variable names
-      cl4_sys = ''                  !: output file system
-      cl4_cfg = ''                  !: output file configuration
-      cl4_date = ''                 !: output file date string
-      cl4_vn = ''                   !: output file version
-      cl4_prefix = 'class4'         !: output file prefix
-      cl4_contact = ''              !: output file contact details
-      cl4_inst = ''                 !: output file institution
 
       ! Standard offline obs_oper settings
@@ -95,14 +51,4 @@
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsao in configuration namelist', .TRUE. )
 
-      ! Read class 4 output settings
-      IF (ld_cl4) THEN
-         REWIND( numnam_ref )              ! Namelist namctl in reference namelist : Control prints & Benchmark
-         READ  ( numnam_ref, namcl4, IOSTAT = ios, ERR = 903 )
-903      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcl4 in reference namelist', .TRUE. )
-
-         REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist : Control prints & Benchmark
-         READ  ( numnam_cfg, namcl4, IOSTAT = ios, ERR = 904 )
-904      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcl4 in configuration namelist', .TRUE. )
-      ENDIF
 
       ! count input files
@@ -122,5 +68,5 @@
          WRITE(numout,*) 'offline obs_oper : Initialization'
          WRITE(numout,*) '~~~~~~~~~~~~~~~~~'
-         WRITE(numout,*) '   Namelist namsao : set stand alone obs_oper parameters' 
+         WRITE(numout,*) '   Namelist namsao : set stand alone obs_oper parameters'
          DO jf = 1, n_files
             WRITE(numout,'(1X,2A)') '   Input forecast file name          forecastfile = ', &
@@ -128,25 +74,5 @@
             WRITE(numout,*) '   Input forecast file index        forecastindex = ', &
                nn_sao_idx(jf)
-            WRITE(numout,*) '   Output forecast leadtime index   leadtimeindex = ', &
-               cl4_fcst_idx(jf)
-            WRITE(numout,*) '   Output forecast leadtime value   leadtimevalue = ', &
-               cl4_leadtime(jf)
-            WRITE(numout,'(1X,2A)') '   Input class 4 variable       class 4 parameter = ', &
-               TRIM(cl4_vars(jf))
          END DO
-         WRITE(numout, '(1X,2A)') '   Input class 4 system            class 4 system = ', &
-            TRIM(cl4_sys)
-         WRITE(numout, '(1X,2A)') '   Input class 4 config            class 4 config = ', &
-            TRIM(cl4_cfg)
-         WRITE(numout, '(1X,2A)') '   Input class 4 date                class 4 date = ', &
-            TRIM(cl4_date)
-         WRITE(numout, '(1X,2A)') '   Input class 4 version          class 4 version = ', &
-            TRIM(cl4_vn)
-         WRITE(numout, '(1X,2A)') '   Input class 4 prefix            class 4 prefix = ', &
-            TRIM(cl4_prefix)
-         WRITE(numout, '(1X,2A)') '   Input class 4 contact          class 4 contact = ', &
-            TRIM(cl4_contact)
-         WRITE(numout, '(1X,2A)') '   Input class 4 institute      class 4 institute = ', &
-            TRIM(cl4_inst)
       END IF
 
Index: /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_intp.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_intp.F90	(revision 5062)
+++ /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_intp.F90	(revision 5063)
@@ -27,19 +27,19 @@
          !!             2. Call dia_obs at appropriate time steps
          !!----------------------------------------------------------------------
-         INTEGER :: istp ! time step index
-         !! Loop over entire run
+         INTEGER :: &
+            & istp, & ! time step index
+            & ifile   ! file index
          istp = nit000 - 1
          nstop = 0
+         ifile = 1
+         CALL sao_rea_dri(ifile)
          DO WHILE ( istp <= nitend .AND. nstop == 0 )
-            IF (jifile <= n_files + 1) THEN
+            IF (ifile <= n_files + 1) THEN
                IF ( MOD(istp, nn_sao_freq) == nit000 ) THEN
-                  !! Read next model counterpart
-                  CALL sao_rea_dri(jifile)
-                  jifile = jifile + 1
+                  CALL sao_rea_dri(ifile)
+                  ifile = ifile + 1
                ENDIF
-               !! Interpolate single time step
                CALL dia_obs(istp)
             ENDIF
-            !! Increment model step
             istp = istp + 1
          END DO
Index: /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_read.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_read.F90	(revision 5062)
+++ /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_read.F90	(revision 5063)
@@ -1,3 +1,2 @@
-
 MODULE sao_read
    !!==================================================================
@@ -5,5 +4,4 @@
    !! Read routines : I/O for Stand Alone Observation operator
    !!==================================================================
-
    USE mppini
    USE lib_mpp
@@ -28,5 +26,5 @@
       !!
       !! Purpose : To choose appropriate read method
-      !! Method  : 
+      !! Method  :
       !!
       !! Author  : A. Ryan Oct 2013
@@ -36,107 +34,13 @@
               & kfile         !: File number
       CHARACTER(len=lc) :: &
-              & cdfilename, & !: File name
-              & cmatchname    !: Match name
+              & cdfilename    !: File name
       INTEGER :: &
-              & kindex       !: File index to read
- 
-      !! Filename, index and match-up kind
+              & kindex        !: File index to read
+
       cdfilename = TRIM(sao_files(kfile))
-      cmatchname = TRIM(cl4_vars(kfile))
       kindex = nn_sao_idx(kfile)
-
-      !! Update model fields
-      !! Class 4 variables: forecast, persistence,
-      !!                    nrt_analysis, best_estimate
-      !! Feedback variables: empty string
-      IF ( (TRIM(cmatchname) == 'forecast') .OR. &
-         & (TRIM(cmatchname) == 'persistence') .OR. &
-         & (TRIM(cmatchname) == 'nrt_analysis') .OR. &
-         & (TRIM(cmatchname) == 'best_estimate').OR. &
-         & (TRIM(cmatchname) == '') ) THEN
-         CALL sao_read_file(TRIM(cdfilename), kindex)
-         CALL sao_read_juld(TRIM(cdfilename), kindex, cl4_modjuld)
-      ELSE IF (TRIM(cmatchname) == 'climatology') THEN
-         WRITE(numout,*) 'Interpolating climatologies'
-      ELSE IF (TRIM(cmatchname) == 'altimeter') THEN
-         CALL sao_read_altbias(TRIM(cdfilename))
-         CALL sao_read_juld(TRIM(cdfilename), kindex, cl4_modjuld)
-      END IF
+      CALL sao_read_file(TRIM(cdfilename), kindex)
 
    END SUBROUTINE sao_rea_dri
-
-   SUBROUTINE sao_read_altbias(filename)
-      !!------------------------------------------------------------------------
-      !!                      *** sao_read_altbias ***
-      !!
-      !! Purpose : To read altimeter bias and set tn,sn to missing values
-      !! Method  : Use subdomain indices to create start and count matrices
-      !!           for netcdf read.
-      !!
-      !! Author  : A. Ryan Sept 2012
-      !!------------------------------------------------------------------------
-      CHARACTER(len=*), INTENT(IN) :: filename
-      INTEGER                      :: ncid, &
-                                    & varid,&
-                                    & istat,&
-                                    & ntimes,&
-                                    & tdim, &
-                                    & xdim, &
-                                    & ydim, &
-                                    & zdim
-      INTEGER                      :: ii, ij, ik
-      INTEGER, DIMENSION(3)        :: start_s, &
-                                    & count_s
-      REAL(fbdp), DIMENSION(:,:),  ALLOCATABLE :: temp_sshn
-      REAL(fbdp)                     :: fill_val
-
-      IF (TRIM(filename) == 'nofile') THEN
-         tsn(:,:,:,:) = fbrmdi
-         sshn(:,:) = fbrmdi 
-      ELSE
-         ! Open Netcdf file to find dimension id
-         istat = nf90_open(trim(filename),nf90_nowrite,ncid)
-         istat = nf90_inq_dimid(ncid,'x',xdim)
-         istat = nf90_inq_dimid(ncid,'y',ydim)
-         istat = nf90_inq_dimid(ncid,'deptht',zdim)
-         istat = nf90_inq_dimid(ncid,'time',tdim)
-         istat = nf90_inquire_dimension(ncid, tdim, len=ntimes)
-         ! Allocate temporary temperature array
-         ALLOCATE(temp_sshn(nlci,nlcj))
-         ! Create start and count arrays
-         start_s = (/ nimpp, njmpp, 1 /)
-         count_s = (/ nlci,  nlcj,  1 /)
-          
-         ! Altimeter bias
-         istat = nf90_inq_varid(ncid,'altbias',varid)
-         istat = nf90_get_att(ncid, varid, '_FillValue', fill_val)
-         istat = nf90_get_var(ncid, varid, temp_sshn, start_s, count_s)
-         WHERE(temp_sshn(:,:) == fill_val) temp_sshn(:,:) = fbrmdi
-   
-         ! Initialise tsn, sshn to fbrmdi
-         tsn(:,:,:,:) = fbrmdi
-         sshn(:,:) = fbrmdi 
-
-         ! Fill sshn with altimeter bias 
-         sshn(1:nlci,1:nlcj) = temp_sshn(:,:) * tmask(1:nlci,1:nlcj,1)
-
-         ! Remove halo from tmask, sshn to prevent double obs counting
-         IF (jpi > nlci) THEN
-             tmask(nlci+1:,:,:) = 0
-             sshn(nlci+1:,:) = 0
-         END IF
-         IF (jpj > nlcj) THEN
-             tmask(:,nlcj+1:,:) = 0
-             sshn(:,nlcj+1:) = 0
-         END IF
-
-         ! Deallocate arrays
-         DEALLOCATE(temp_sshn)
-
-         ! Close netcdf file
-         istat = nf90_close(ncid)
-      END IF
-   
-   END SUBROUTINE sao_read_altbias
 
    SUBROUTINE sao_read_file(filename, ifcst)
@@ -176,5 +80,5 @@
       IF (TRIM(filename) == 'nofile') THEN
          tsn(:,:,:,:) = fbrmdi
-         sshn(:,:) = fbrmdi 
+         sshn(:,:) = fbrmdi
       ELSE
          WRITE(numout,*) "Opening :", TRIM(filename)
@@ -190,15 +94,15 @@
          istat = nf90_inq_dimid(ncid,'time_counter',tdim)
          istat = nf90_inquire_dimension(ncid, tdim, len=ntimes)
-         IF (ifcst .LE. ntimes) THEN   
+         IF (ifcst .LE. ntimes) THEN
             ! Allocate temporary temperature array
             ALLOCATE(temp_tn(nlci,nlcj,jpk))
             ALLOCATE(temp_sn(nlci,nlcj,jpk))
             ALLOCATE(temp_sshn(nlci,nlcj))
-      
+
             ! Set temp_tn, temp_sn to 0.
             temp_tn(:,:,:) = fbrmdi
             temp_sn(:,:,:) = fbrmdi
             temp_sshn(:,:) = fbrmdi
-      
+
             ! Create start and count arrays
             start_n = (/ nimpp, njmpp, 1,   ifcst /)
@@ -206,5 +110,5 @@
             start_s = (/ nimpp, njmpp, ifcst /)
             count_s = (/ nlci,  nlcj,  1     /)
-             
+
             ! Read information into temporary arrays
             ! retrieve varid and read in temperature
@@ -213,5 +117,5 @@
             istat = nf90_get_var(ncid, varid, temp_tn, start_n, count_n)
             WHERE(temp_tn(:,:,:) == fill_val) temp_tn(:,:,:) = fbrmdi
-      
+
             ! retrieve varid and read in salinity
             istat = nf90_inq_varid(ncid,'vosaline',varid)
@@ -219,5 +123,5 @@
             istat = nf90_get_var(ncid, varid, temp_sn, start_n, count_n)
             WHERE(temp_sn(:,:,:) == fill_val) temp_sn(:,:,:) = fbrmdi
-      
+
             ! retrieve varid and read in SSH
             istat = nf90_inq_varid(ncid,'sossheig',varid)
@@ -226,12 +130,12 @@
                istat = nf90_inq_varid(ncid,'altbias',varid)
             END IF
-      
+
             istat = nf90_get_att(ncid, varid, '_FillValue', fill_val)
             istat = nf90_get_var(ncid, varid, temp_sshn, start_s, count_s)
             WHERE(temp_sshn(:,:) == fill_val) temp_sshn(:,:) = fbrmdi
-   
+
             ! Initialise tsn, sshn to fbrmdi
             tsn(:,:,:,:) = fbrmdi
-            sshn(:,:) = fbrmdi 
+            sshn(:,:) = fbrmdi
 
             ! Mask out missing data index
@@ -256,8 +160,8 @@
             ! Deallocate arrays
             DEALLOCATE(temp_tn, temp_sn, temp_sshn)
-         ELSE   
+         ELSE
             ! Mark all as missing data
             tsn(:,:,:,:) = fbrmdi
-            sshn(:,:) = fbrmdi 
+            sshn(:,:) = fbrmdi
          ENDIF
          ! Close netcdf file
@@ -266,82 +170,3 @@
       END IF
    END SUBROUTINE sao_read_file
-
-   SUBROUTINE sao_read_juld(filename, ifcst, julian)
-      USE calendar
-      !!--------------------------------------------------------------------
-      !!                 *** sao_read_juld ***
-      !!
-      !!   Purpose : To read model julian day information from file
-      !!   Author  : A. Ryan Nov 2010
-      !!--------------------------------------------------------------------
-
-      !! Routine arguments
-      CHARACTER(len=*), INTENT(IN)  :: filename
-      INTEGER,          INTENT(IN)  :: ifcst
-      REAL,             INTENT(OUT) :: julian    !: Julian day
-
-      !! Local variables
-      INTEGER :: year,  &   !: Date information
-               & month, &
-               & day,   &
-               & hour,  &
-               & minute,&
-               & second
-      INTEGER :: istat, &   !: Netcdf variables
-               & ncid,  &
-               & dimid, &
-               & varid, &
-               & ntime      
-      REAL,DIMENSION(:),ALLOCATABLE :: r_sec     !: Remainder seconds
-      CHARACTER(len=120) :: time_str  !: time string
-
-      time_str=''
-      !! Read in time_counter and remainder seconds
-      istat = nf90_open(trim(filename),nf90_nowrite,ncid)
-      istat = nf90_inq_dimid(ncid,'time_counter',dimid)
-      IF (istat /= nf90_noerr) THEN
-          istat = nf90_inq_dimid(ncid,'time',dimid)
-      ENDIF
-      istat = nf90_inquire_dimension(ncid,dimid,len=ntime)
-      istat = nf90_inq_varid(ncid,'time_counter',varid)
-      IF (istat /= nf90_noerr) THEN
-          istat = nf90_inq_dimid(ncid,'time',dimid)
-      ENDIF
-      istat = nf90_get_att(ncid,varid,'units',time_str)
-      ALLOCATE(r_sec(ntime))
-      istat = nf90_get_var(ncid,varid, r_sec)
-      istat = nf90_close(ncid)
-
-      !! Fill yyyy-mm-dd hh:mm:ss
-      !! format(('seconds since ', I4.4,'-',I2.2,'-',I2.2,' ',I2.2,':',I2.2,':',I2.2))
-      100 format((14x, I4.4,1x,I2.2,1x,I2.2,1x,I2.2,1x,I2.2,1x,I2.2))
-      READ( time_str, 100 ) year, month, day, hour, minute, second
-
-      CALL ymds2ju(year, month, day, r_sec(ifcst), julian)
-
-      !! To take a comment from the ymds2ju subroutine
-
-   !- In the case of the Gregorian calendar we have chosen to use
-   !- the Lilian day numbers. This is the day counter which starts
-   !- on the 15th October 1582.
-   !- This is the day at which Pope Gregory XIII introduced the
-   !- Gregorian calendar.
-   !- Compared to the true Julian calendar, which starts some
-   !- 7980 years ago, the Lilian days are smaler and are dealt with
-   !- easily on 32 bit machines. With the true Julian days you can only
-   !- the fraction of the day in the real part to a precision of
-   !- a 1/4 of a day with 32 bits.
-      
-      !! The obs operator routines prefer to calculate Julian days since 
-      !! 01/01/1950 00:00:00
-      !! In order to convert to the 1950 version we must adjust by the number
-      !! of days between 15th October 1582 and 1st Jan 1950
-
-      julian = julian - 134123.
-      
-      DEALLOCATE(r_sec)
-      
-   END SUBROUTINE sao_read_juld
-
-END MODULE sao_read 
-
+END MODULE sao_read
Index: anches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_utils.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_utils.F90	(revision 5062)
+++ 	(revision )
@@ -1,102 +1,0 @@
-MODULE sao_utils
-   !! =================================================================
-   !!                    *** MODULE sao_utils ***
-   !! =================================================================
-   USE par_oce
-
-   IMPLICIT NONE
-
-   ! Define double precision obfillflt
-   REAL(kind=dp), PARAMETER :: obfilldbl=99999.
-
-   CONTAINS
-
-   SUBROUTINE yyyymmdd_to_ref_date(indate, intime, outstring)
-      !----------------------------------------
-      ! Routine to create reference date string
-      !----------------------------------------
-      ! Routine arguments
-      CHARACTER(len=8),  INTENT(IN)  :: indate    ! yyyymmdd
-      CHARACTER(len=6),  INTENT(IN)  :: intime    ! hhmmss
-      CHARACTER(len=23), INTENT(OUT) :: outstring ! yyyy-mm-dd hh:mm:ss utc
-      ! Local variables
-      CHARACTER(len=4)  :: year      ! yyyy
-      CHARACTER(len=2)  :: month     ! mm
-      CHARACTER(len=2)  :: day       ! dd
-      CHARACTER(len=2)  :: hour      ! hh
-      CHARACTER(len=2)  :: minute    ! mm
-      CHARACTER(len=2)  :: second    ! ss
-
-      year   = indate(1:4)
-      month  = indate(5:6)
-      day    = indate(7:8)
-      hour   = intime(1:2)
-      minute = intime(3:4)
-      second = intime(5:6)
-
-      outstring = year//"-"//month//"-"//day//" "//hour//":"//minute//":"//second//" utc"
-      
-   END SUBROUTINE yyyymmdd_to_ref_date
-
-   SUBROUTINE date_format(date_str)
-      !---------------------------------------
-      ! Routine to create creation date string
-      !---------------------------------------
-
-      ! Routine arguments
-      CHARACTER(len=*), INTENT(OUT) :: date_str
-      ! Local variables
-      CHARACTER(8)  :: date
-      CHARACTER(10) :: time
-
-      CHARACTER(10)  :: date_part
-      CHARACTER(8)  :: time_part
-
-      CALL date_and_time(DATE=date)
-      CALL date_and_time(TIME=time)
-      date_part  = date(1:4)//'/'//date(5:6)//'/'//date(7:8)
-      time_part  = time(1:2)//':'//time(3:4)//':'//time(5:6)
-
-      date_str   = date_part//' '//time_part
-
-   END SUBROUTINE date_format
-
-   SUBROUTINE inst_converter(wmo_inst_list, nprofs, obs_names)
-      !---------------------------------------
-      ! Routine to convert WMO_INST_TYPE to
-      ! 'ARGO', 'TESAC', 'XBT', 'BUOYS'
-      !---------------------------------------
-
-      !! Routine arguments
-      INTEGER,                             INTENT(IN) :: nprofs
-      CHARACTER(len=*),DIMENSION(nprofs),  INTENT(IN) :: wmo_inst_list      
-      CHARACTER(len=128),DIMENSION(nprofs),INTENT(OUT):: obs_names
-
-      !! Local variables
-      INTEGER :: inam !: loop over name
-
-      !! Initialise obs_names
-      obs_names(:) = ''
-
-      !! Convert number to text
-      DO inam = 1,nprofs
-         IF (trim(adjustl(wmo_inst_list(inam))) .EQ. '820') THEN
-            obs_names(inam) = 'BUOYS'
-         ELSEIF (trim(adjustl(wmo_inst_list(inam))) .EQ. '401') THEN
-            obs_names(inam) = 'XBT'
-         ELSEIF (trim(adjustl(wmo_inst_list(inam))) .EQ. '741') THEN
-            obs_names(inam) = 'TESAC'
-         ELSEIF (trim(adjustl(wmo_inst_list(inam))) .EQ. '831') THEN
-            obs_names(inam) = 'ARGO'
-         ELSEIF (trim(adjustl(wmo_inst_list(inam))) .EQ. '22') THEN ! Special case for AATSR
-            obs_names(inam) = '22'
-         ELSEIF (trim(adjustl(wmo_inst_list(inam))) .EQ. '') THEN
-            obs_names(inam) = 'UNKNOWN'
-         ELSE 
-            obs_names(inam) = adjustl(wmo_inst_list(inam)) ! For all other cases
-         ENDIF
-      ENDDO
-
-   END SUBROUTINE inst_converter
-
-END MODULE sao_utils
Index: anches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_write.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_write.F90	(revision 5062)
+++ 	(revision )
@@ -1,591 +1,0 @@
-MODULE sao_write
-   !!======================================================================
-   !!                       ***  MODULE sao_write  ***
-   !!======================================================================
-
-   USE in_out_manager
-   USE netcdf
-   USE obs_utils, ONLY: chkerr
-   USE sao_utils, ONLY: date_format, inst_converter, yyyymmdd_to_ref_date
-   USE sao_data
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC sao_wri_init
-   PUBLIC sao_wri_default
-   PUBLIC sao_wri_extra
-
-   ! Type kinds for class 4 data.
-   INTEGER, PARAMETER :: clsp = SELECTED_REAL_KIND( 6, 37) !: single precision
-   INTEGER, PARAMETER :: cldp = SELECTED_REAL_KIND(12,307) !: double precision
-
-   ! Missinge data indicators 
-   INTEGER, PARAMETER    :: climdi = -99999   !: Integers
-   REAL(clsp), PARAMETER :: clrmdi =  99999   !: Reals
-
-   INTERFACE sao_wri_extra
-      MODULE PROCEDURE sao_wri_extra_3d_index, sao_wri_extra_4d, sao_wri_extra_4d_index
-   END INTERFACE
-
-   CONTAINS
-
-      SUBROUTINE sao_wri_extra_3d_index(cdfilename, cdvarname, ndeps, nvars, &
-                               &  nobs, kstart, kcount, pdata)
-         !!----------------------------------------------------------------------
-         !!                    ***  ROUTINE sao_wri_extra_3d  ***
-         !!
-         !! ** Purpose : Write 3d variables to class 4 file.
-         !!
-         !!----------------------------------------------------------------------
-         INTEGER, INTENT(IN) :: &
-                 & nobs, &       !: number of observations/profiles
-                 & nvars, &      !: number of physical parameters
-                 & ndeps         !: number of depths
-         CHARACTER(len=*), INTENT(IN) :: &
-                 & cdfilename, & !: netcdf file name
-                 & cdvarname     !: netcdf variable name
-         INTEGER, DIMENSION(3), INTENT(IN) :: &
-                 & kstart, &     !: start indices
-                 & kcount        !: count indices
-         REAL(KIND=cldp), DIMENSION(ndeps, nvars, nobs), INTENT(IN) :: &
-                 & pdata         !: 3d data
-         INTEGER :: &
-                 & ncid, &       !:
-                 & dimid, &      !:
-                 & varid         !:
-         CHARACTER(len=16), PARAMETER :: cpname = 'sao_wri_extra_3d'
-         ! Open netcdf file
-         CALL chkerr(nf90_open(trim(cdfilename), nf90_write, ncid), cpname, __LINE__ )
-         ! Write data
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cdvarname), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, pdata, kstart, kcount),cpname, __LINE__ )
-         ! Close netcdf file
-         CALL chkerr(nf90_close(ncid), cpname, __LINE__ )
-      END SUBROUTINE sao_wri_extra_3d_index
-
-      SUBROUTINE sao_wri_extra_4d_index(cdfilename, cdvarname, ndeps, nfcst, &
-                               &  nvars, nobs, kstart, kcount, pdata)
-         !!----------------------------------------------------------------------
-         !!                    ***  ROUTINE sao_wri_extra_4d  ***
-         !!
-         !! ** Purpose : Write 4d variables to class 4 file.
-         !!
-         !!----------------------------------------------------------------------
-         INTEGER, INTENT(IN) :: &
-                 & nobs, &       !: number of observations/profiles
-                 & nvars, &      !: number of physical parameters
-                 & ndeps, &      !: number of depths
-                 & nfcst         !: number of forecasts
-         CHARACTER(len=*), INTENT(IN) :: &
-                 & cdfilename, & !: netcdf file name
-                 & cdvarname     !: netcdf variable name
-         INTEGER, DIMENSION(4), INTENT(IN) :: &
-                 & kstart, &     !: start indices
-                 & kcount        !: count indices
-         REAL(KIND=cldp), DIMENSION(ndeps, nvars, nobs), INTENT(IN) :: &
-                 & pdata         !: slice of 4d data
-         INTEGER :: &
-                 & ncid, &       !:
-                 & dimid, &      !:
-                 & varid         !:
-         CHARACTER(len=22), PARAMETER :: cpname = 'sao_wri_extra_4d_index'
-         ! Open netcdf file
-         CALL chkerr(nf90_open(trim(cdfilename), nf90_write, ncid), cpname, __LINE__ )
-         ! Write data
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cdvarname), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, pdata, kstart, kcount),cpname, __LINE__ )
-         ! Close netcdf file
-         CALL chkerr(nf90_close(ncid), cpname, __LINE__ )
-      END SUBROUTINE sao_wri_extra_4d_index
-
-      SUBROUTINE sao_wri_extra_4d(cdfilename, cdvarname, ndeps, nfcst, &
-                               &  nvars, nobs, pdata)
-         !!----------------------------------------------------------------------
-         !!                    ***  ROUTINE sao_wri_extra_4d  ***
-         !!
-         !! ** Purpose : Write 4d variables to class 4 file.
-         !!
-         !!----------------------------------------------------------------------
-         INTEGER, INTENT(IN) :: &
-                 & nobs, &       !: number of observations/profiles
-                 & nvars, &      !: number of physical parameters
-                 & ndeps, &      !: number of depths
-                 & nfcst         !: number of forecasts
-         CHARACTER(len=*), INTENT(IN) :: &
-                 & cdfilename, & !: netcdf file name
-                 & cdvarname     !: netcdf variable name
-         REAL(KIND=cldp), DIMENSION(ndeps, nfcst, nvars, nobs), INTENT(IN) :: &
-                 & pdata         !: 4d data
-         INTEGER :: &
-                 & ncid, &       !:
-                 & dimid, &      !:
-                 & varid         !:
-         CHARACTER(len=16), PARAMETER :: cpname = 'sao_wri_extra_4d'
-         ! Open netcdf file
-         CALL chkerr(nf90_open(trim(cdfilename), nf90_write, ncid), cpname, __LINE__ )
-         ! Write data
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cdvarname), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, pdata),cpname, __LINE__ )
-         ! Close netcdf file
-         CALL chkerr(nf90_close(ncid), cpname, __LINE__ )
-      END SUBROUTINE sao_wri_extra_4d
-
-      SUBROUTINE sao_wri_default(cdfilename, nobs, nvars, nfcst, ndeps, & 
-                             &   cdtyp, cdwmo, cunit, cvnam, &
-                             &   plam, pphi, pdep, ptim, pob, plead, &
-                             &   kqc, pmjuld)
-         !!----------------------------------------------------------------------
-         !!                    ***  ROUTINE sao_wri_default  ***
-         !!
-         !! ** Purpose : Write standard variables to class 4 file.
-         !! ** Method  : Write the following variables;
-         !!                 observation type
-         !!                 observation wmo id
-         !!                 variable units
-         !!                 variable names
-         !!                 observation latitudes
-         !!                 observation longitudes
-         !!                 observation depths
-         !!                 observation times
-         !!                 observation values
-         !!                 observation qc flags
-         !!                 model julian days
-         !!                 
-         !! ** Returns : 
-         !!----------------------------------------------------------------------
-         INTEGER, INTENT(IN) :: &
-                 & nfcst, &      !: number of forecasts
-                 & nobs, &       !: number of observations/profiles
-                 & nvars, &      !: number of physical parameters
-                 & ndeps         !: number of depths
-         CHARACTER(len=*), INTENT(IN) :: &
-                 & cdfilename    !: file name
-         CHARACTER(LEN=128), DIMENSION(nobs), INTENT(IN) :: &
-                 & cdtyp         !: Instrument type
-         CHARACTER(LEN=8), DIMENSION(nobs), INTENT(IN) :: &
-                 & cdwmo         ! WMO number
-         CHARACTER(LEN=128), DIMENSION(nobs) :: &
-                 & cdpad         !: Instrument type (padded)
-         CHARACTER(LEN=8), DIMENSION(nvars), INTENT(IN) :: &
-                 & cunit, &      !: variable units (e.g. psu)
-                 & cvnam         !: variable names (e.g. vosaline)
-         REAL(KIND=cldp), DIMENSION(nfcst), INTENT(IN) :: &
-                 & plead         !: Leadtime
-         REAL(KIND=cldp), DIMENSION(nobs), INTENT(IN) :: &
-                 & pphi, &       !: Latitude
-                 & plam          !: Longitude
-         REAL(KIND=cldp), DIMENSION(ndeps, nobs), INTENT(IN) :: &
-                 & pdep          !: Depth               
-         REAL(KIND=cldp), DIMENSION(ndeps, nvars, nobs), INTENT(IN) :: &
-                 & pob           !: T observation
-         REAL(KIND=cldp), DIMENSION(nobs), INTENT(IN) :: &
-                 & ptim          !: Time
-         INTEGER(KIND=2), DIMENSION(ndeps, nvars, nobs), INTENT(IN) :: &
-                 & kqc           !: Observation QC
-         REAL, INTENT(IN) :: &
-                 & pmjuld        !: Model Julian Day
-         CHARACTER(len=128) :: &
-                 & cvar          !: variable name placeholder
-         INTEGER :: &
-                 & ncid, &  !:
-                 & dimid, & !:
-                 & varid    !:
-         CHARACTER(len=15), PARAMETER :: cpname = 'sao_wri_default'
-         ! Open netcdf file
-         CALL chkerr(nf90_open(trim(cdfilename), nf90_write, ncid), cpname, __LINE__ )
-         ! longitude
-         cvar = 'longitude'
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cvar), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, plam),cpname, __LINE__ )
-         ! latitude
-         cvar = 'latitude'
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cvar), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, pphi),cpname, __LINE__ )
-         ! depth
-         cvar = 'depth'
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cvar), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, pdep),cpname, __LINE__ )
-         ! varname
-         cvar = 'varname'
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cvar), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, cvnam),cpname, __LINE__ )
-         ! unitname
-         cvar = 'unitname'
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cvar), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, cunit),cpname, __LINE__ )
-         ! leadtime
-         cvar = 'leadtime'
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cvar), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, plead),cpname, __LINE__ )
-         ! observation
-         cvar = 'observation'
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cvar), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, pob),cpname, __LINE__ )
-         ! qc
-         cvar = 'qc'
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cvar), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, kqc),cpname, __LINE__ )
-         ! juld
-         cvar = 'juld'
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cvar), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, ptim),cpname, __LINE__ )
-         ! type
-         cvar = 'type'
-         CALL inst_converter(cdtyp,nobs,cdpad)
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cvar), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, cdpad),cpname, __LINE__ )
-         ! id
-         cvar = 'id'
-         CALL chkerr(nf90_inq_varid(ncid,TRIM(cvar), varid),cpname, __LINE__ )
-         CALL chkerr(nf90_put_var(ncid, varid, cdwmo),cpname, __LINE__ )
-         ! Close netcdf file
-         CALL chkerr(nf90_close(ncid), cpname, __LINE__ )
-      END SUBROUTINE sao_wri_default
-
-      SUBROUTINE sao_wri_init(cconf, csys, ckind, cversion, ccont, &
-                            & cinst, cdate, nproc, nobs, nvars, &
-                            & ndeps, nfcst, cdfilename)
-         !!----------------------------------------------------------------------
-         !!                    ***  ROUTINE sao_wri_init  ***
-         !!
-         !! ** Purpose : Initialise a class 4 file.
-         !!
-         !! ** Method  :
-         !! ** Returns : cdfilename
-         !!----------------------------------------------------------------------
-         CHARACTER(len=*), INTENT(IN) :: &
-                 & cconf, &      !: model configuration e.g. orca025
-                 & csys, &       !: model system e.g. FOAM
-                 & ckind, &      !: observation kind e.g. profile
-                 & cversion, &   !: model version e.g. 12.0
-                 & ccont, &      !: contact email
-                 & cinst, &      !: institution description
-                 & cdate         !: e.g. yyyymmdd
-         INTEGER, INTENT(IN) :: &
-                 & nproc, &      !: processor number
-                 & nobs, &       !: number of observations/profiles
-                 & nvars, &      !: number of physical parameters
-                 & ndeps, &      !: number of depths
-                 & nfcst         !: number of forecast days
-         CHARACTER(len=128), INTENT(OUT) :: &
-                 & cdfilename    !: e.g. orca025
-         CHARACTER(len=4) :: &
-                 & cproc         !: character representation of nproc
-         CHARACTER(len=128) :: &
-                 & cattnam, &    !: attribute placeholder
-                 & cattval, &    !: attribute placeholder
-                 & cvar, &       !: variable name placeholder
-                 & cqcdes, &     !: quality control description
-                 & cqcval        !: quality control values
-         INTEGER :: &
-                 & istat, &      !: status of netcdf operation
-                 & ncid, &       !: netcdf file id placeholder
-                 & dimid_d, &    !: netcdf dimension id placeholder
-                 & dimid_f, &    !: netcdf dimension id placeholder
-                 & dimid_o, &    !: netcdf dimension id placeholder
-                 & dimid_v, &    !: netcdf dimension id placeholder
-                 & dimid_s, &    !: netcdf dimension id placeholder
-                 & dimid_l, &    !: netcdf dimension id placeholder
-                 & varid         !: netcdf variable id placeholder
-         INTEGER, DIMENSION(2) :: &
-                 & qc_flags      !: quality control flags
-         CHARACTER(len=23) :: &
-                 & ref_date      !: reference date holder
-         INTEGER, DIMENSION(2) :: &
-                 & dim2a, &      !: 2 dimensional settings
-                 & dim2b, &      !:
-                 & dim2c, &      !:
-                 & dim2d         !:
-         INTEGER, DIMENSION(3) :: &
-                 & dim3a         !: 3 dimensional settings
-         INTEGER, DIMENSION(4) :: &
-                 & dim4a         !: 4 dimensional settings
-         CHARACTER(len=12), PARAMETER :: cpname = 'sao_wri_init'
-         ! Global att variables
-         CHARACTER(len=40) :: date_str
-         CHARACTER(len=6)  :: noon
-
-         WRITE(cproc, FMT="(I4.4)") nproc
-         cdfilename = 'class4'
-         cdfilename = TRIM(cdfilename)//'_'//TRIM(cdate)
-         cdfilename = TRIM(cdfilename)//'_'//TRIM(csys)
-         cdfilename = TRIM(cdfilename)//'_'//TRIM(cconf)
-         cdfilename = TRIM(cdfilename)//'_'//TRIM(cversion)
-         cdfilename = TRIM(cdfilename)//'_'//TRIM(ckind)
-         cdfilename = TRIM(cdfilename)//'_'//TRIM(cproc)
-         cdfilename = TRIM(cdfilename)//'.nc'
-         ! QC attribute string settings
-         IF (ckind .EQ. 'profile') THEN
-            cqcval = '0 - good data. 9 - bad data.'
-            cqcdes = ''
-            qc_flags = (/0, 9/)
-         ELSE IF (ckind .EQ. 'SST') THEN
-            cqcval = '0 - good data. 1 - bad data.'
-            cqcdes = 'In situ qc flag set to 0 if prob. of gross error < 0.5, &
-                     &1 otherwise. AATSR qc flag set to 0 for best_quality, 1 otherwise.'
-            qc_flags = (/0, 1/)
-         ELSE IF (ckind .EQ. 'SLA') THEN
-            cqcval = '0 - good data. 9 - bad data.'
-            cqcdes = ''
-            qc_flags = (/0, 9/)
-         ELSE
-            cqcval = ''
-            cqcdes = ''
-            qc_flags = (/0, 9/)
-         END IF
-         ! Check cdfilename exists
-         istat = nf90_open(TRIM(cdfilename), nf90_nowrite, ncid)
-         IF (istat /= nf90_noerr) THEN
-            IF (lwp) WRITE(numout, *) TRIM(cdfilename), ' opened successfully.'
-            CALL chkerr( nf90_create(TRIM(cdfilename), nf90_clobber, ncid), cpname, __LINE__ )
-            !! Global Dimension section
-            !  Partially hardwired for now
-            CALL date_format(date_str)
-            noon = '120000' ! hhmmss
-            ref_date = ''
-            CALL yyyymmdd_to_ref_date(TRIM(cdate), noon, ref_date)
-
-            CALL chkerr( nf90_put_att(ncid, nf90_global, 'title', &
-               & 'Forecast class 4 file'), cpname, __LINE__ )
-            CALL chkerr( nf90_put_att(ncid, nf90_global, 'version', &
-               & TRIM(cversion)), cpname, __LINE__ )
-            CALL chkerr( nf90_put_att(ncid, nf90_global, 'creation_date', &
-               & TRIM(date_str) ), cpname, __LINE__ )
-            CALL chkerr( nf90_put_att(ncid, nf90_global, 'validity_time', &
-               & TRIM(ref_date) ), cpname, __LINE__ )
-            CALL chkerr( nf90_put_att(ncid, nf90_global, 'contact', &
-               & TRIM(ccont) ), cpname, __LINE__ )
-            CALL chkerr( nf90_put_att(ncid, nf90_global, 'obs_type', &
-               & TRIM(ckind) ), cpname, __LINE__ )
-            CALL chkerr( nf90_put_att(ncid, nf90_global, 'system', &
-               & TRIM(csys)), cpname, __LINE__ )
-            CALL chkerr( nf90_put_att(ncid, nf90_global, 'configuration', &
-               & TRIM(cconf) ), cpname, __LINE__ ) 
-            CALL chkerr( nf90_put_att(ncid, nf90_global, 'institution', &
-               & TRIM(cinst) ), cpname, __LINE__ ) 
-
-            !! Define Dimensions
-            CALL chkerr(nf90_def_dim(ncid, 'numdeps', ndeps, dimid_d), cpname, __LINE__ )
-            CALL chkerr(nf90_def_dim(ncid, 'numfcsts', nfcst, dimid_f), cpname, __LINE__ )
-            CALL chkerr(nf90_def_dim(ncid, 'numvars', nvars, dimid_v), cpname, __LINE__ )
-            CALL chkerr(nf90_def_dim(ncid, 'numobs', nobs, dimid_o), cpname, __LINE__ )
-            CALL chkerr(nf90_def_dim(ncid, 'string_length8', 8, dimid_s), cpname, __LINE__ )
-            CALL chkerr(nf90_def_dim(ncid, 'string_length128', 128, dimid_l), cpname, __LINE__ )
-            !! Define possible dimension permutations
-            ! 2d
-            dim2a(:) = (/ dimid_d, dimid_o /) !: (/ ndeps, nobs  /) 
-            dim2b(:) = (/ dimid_s, dimid_o /) !: (/ 8, nobs  /)
-            dim2c(:) = (/ dimid_s, dimid_v /) !: (/ 8, nvars /)
-            dim2d(:) = (/ dimid_l, dimid_o /) !: (/ 128, nobs  /)
-            ! 3d
-            dim3a(:) = (/ dimid_d, dimid_v, dimid_o/) !: (/ ndeps, nvars, nobs /)
-            ! 4d
-            dim4a(:) = (/ dimid_d, dimid_f, dimid_v, dimid_o /) !: (/ ndeps, nfcst, nvars, nobs /)
-
-            !! Create the variables
-            !  Forecast day
-            cvar = 'leadtime'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dimid_f, varid), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Model forecast day offset'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'units'
-            cattval = 'Hours'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'comment'
-            cattval = 'Hours between forecast production and validity time'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  longitude
-            cvar = 'longitude'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dimid_o, varid), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Longitudes'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'units'
-            cattval = 'Degrees'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  latitude
-            cvar = 'latitude'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dimid_o, varid), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Latitudes'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'units'
-            cattval = 'Degrees'
-
-            !  depth
-            cvar = 'depth'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dim2a, varid), cpname, __LINE__ )
-            CALL chkerr(nf90_put_att(ncid, varid, '_FillValue', clrmdi), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Depths'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'units'
-            cattval = 'metre'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  varname
-            cvar = 'varname'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_char, dim2c, varid), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Variable name'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  unitname
-            cvar = 'unitname'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_char, dim2c, varid), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Unit name'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  observation
-            cvar = 'observation'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dim3a, varid), cpname, __LINE__ )
-            CALL chkerr(nf90_put_att(ncid, varid, '_FillValue', clrmdi), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Observation value'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  forecast
-            cvar = 'forecast'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dim4a, varid), cpname, __LINE__ )
-            CALL chkerr(nf90_put_att(ncid, varid, '_FillValue', clrmdi), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Model forecast counterpart of obs. value'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'comment'
-            cattval = 'Model daily mean valid at noon used for calculation'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  persistence
-            cvar = 'persistence'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dim4a, varid), cpname, __LINE__ )
-            CALL chkerr(nf90_put_att(ncid, varid, '_FillValue', clrmdi), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Model persistence counterpart of obs. value'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'comment'
-            cattval = 'Model daily mean valid at noon used for calculation'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  climatology
-            cvar = 'climatology'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dim3a, varid), cpname, __LINE__ )
-            CALL chkerr(nf90_put_att(ncid, varid, '_FillValue', clrmdi), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Climatological value'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'comment'
-            cattval = 'Levitus monthly fields interpolated to the correct day'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  daym2
-            cvar = 'best_estimate'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dim3a, varid), cpname, __LINE__ )
-            CALL chkerr(nf90_put_att(ncid, varid, '_FillValue', clrmdi), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Best estimate'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'comment'
-            cattval = 'FOAM daym2 field'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  daym1
-            cvar = 'nrt_analysis'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dim3a, varid), cpname, __LINE__ )
-            CALL chkerr(nf90_put_att(ncid, varid, '_FillValue', clrmdi), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Near real time analysis'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'comment'
-            cattval = 'FOAM daym1 field'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-         
-            !  optional fields
-            IF (TRIM(ckind) .EQ. 'SLA') THEN
-               !  mdt
-               cvar = 'mdt_reference'
-               CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dim3a, varid), cpname, __LINE__ )
-               CALL chkerr(nf90_put_att(ncid, varid, '_FillValue', clrmdi), cpname, __LINE__ )
-               cattnam = 'long_name'
-               cattval = 'Mean dynamic topography'
-               CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-               cattnam = 'comment'
-               cattval = 'MDT reference field'
-               CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-               !  altbias
-               cvar = 'altimeter_bias'
-               CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dim3a, varid), cpname, __LINE__ )
-               CALL chkerr(nf90_put_att(ncid, varid, '_FillValue', clrmdi), cpname, __LINE__ )
-               cattnam = 'long_name'
-               cattval = 'Altimeter bias'
-               CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            ENDIF
-         
-            !  qc
-            cvar = 'qc'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_short, dim3a, varid), cpname, __LINE__ )
-            CALL chkerr(nf90_put_att(ncid, varid, '_FillValue', NF90_FILL_SHORT), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Quality flags'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'flag_value'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), qc_flags), cpname, __LINE__ )
-            cattnam = 'flag_meaning'
-            cattval = cqcval
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'comment'
-            cattval = cqcdes
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-!            !  juld
-            cvar = 'juld'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_double, dimid_o, varid), cpname, __LINE__ )
-!            CALL chkerr(nf90_put_att(ncid, varid, '_FillValue', clrmdi), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Observation time in Julian days'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'units'
-            CALL yyyymmdd_to_ref_date('19500101', '000000', ref_date)
-            cattval = 'Days since '//ref_date
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  modeljuld 
-            cvar = 'modeljuld'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_float, dimid_f, varid), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Model field date in Julian days'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-            cattnam = 'units'
-            cattval = 'Days since '//ref_date
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  type
-            cvar = 'type'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_char, dim2d, varid), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Observation type'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            !  id
-            cvar = 'id'
-            CALL chkerr(nf90_def_var(ncid, TRIM(cvar), nf90_char, dim2b, varid), cpname, __LINE__ )
-            cattnam = 'long_name'
-            cattval = 'Observation id'
-            CALL chkerr(nf90_put_att(ncid, varid, TRIM(cattnam), TRIM(cattval)), cpname, __LINE__ )
-
-            ! Close netcdf file
-            CALL chkerr(nf90_close(ncid), cpname, __LINE__ )
-         ELSE
-            IF (lwp) WRITE(numout, *) TRIM(cdfilename), 'already exists.'
-            ! Close netcdf file
-            CALL chkerr(nf90_close(ncid), cpname, __LINE__ )
-         END IF
-      END SUBROUTINE sao_wri_init
-
-
-END MODULE sao_write
