Index: branches/2013/dev_r3987_UKMO4_OBS/NEMOGCM/TOOLS/OBSTOOLS/src/c4comb.F90
===================================================================
--- branches/2013/dev_r3987_UKMO4_OBS/NEMOGCM/TOOLS/OBSTOOLS/src/c4comb.F90	(revision 4123)
+++ branches/2013/dev_r3987_UKMO4_OBS/NEMOGCM/TOOLS/OBSTOOLS/src/c4comb.F90	(revision 4124)
@@ -11,5 +11,5 @@
    !!
    !!   Usage:
-   !!     c4comb.exe filebase nprocs
+   !!     c4comb.exe outputfile inputfile1 inputfile2 ...
    !!
    !!   History :
@@ -25,12 +25,12 @@
    INTEGER,EXTERNAL :: iargc
 #endif
-   INTEGER :: nargs
+   INTEGER :: nargs,    & !: number of command line arguments
+            & ia,       & !: argument loop index
+            & ninfiles    !: number of input files
    !! Routine arguments
-   CHARACTER(len=80) :: cdfilebase, & 
-                      & cdnprocs
-   INTEGER           :: nprocs      !: number of processors
+   CHARACTER(len=256) :: cdoutfile
+   CHARACTER(len=256),ALLOCATABLE :: cdinfile(:)
    !! Routine variables
-   CHARACTER(len=4)  :: iproc_str
-   CHARACTER(len=80) :: cdfilename, cpname, cfname
+   CHARACTER(len=80) :: cpname
    INTEGER,PARAMETER :: nstr=8, n128=128
    INTEGER           ::    ncid,   & !: netcdf file id
@@ -70,5 +70,5 @@
                         &  u_dex
 
-   INTEGER                   :: iob, idep, iproc, istat
+   INTEGER                   :: iob, idep, istat
    INTEGER, DIMENSION(2)     :: dim2a, dim2b, dim2c, dim2d
    INTEGER, DIMENSION(3)     :: dim3a
@@ -156,11 +156,8 @@
    nargs = IARGC()
    IF (nargs /= 2) THEN
-      WRITE(*, *) "Usage: c4comb.exe filebase nprocs"
+      WRITE(*, *) "Usage: c4comb.exe outputfile inputfile1 inputfile2 ..."
+      CALL abort()
    END IF
-   CALL GETARG(1, cdfilebase)
-   CALL GETARG(2, cdnprocs)
-   READ(cdnprocs, '(I4)') nprocs
-   WRITE(*,*) "Processing filebase : ", TRIM(cdfilebase)
-   WRITE(*,*) "# processors : ", nprocs
+   CALL GETARG(1, cdoutfile)
 
    !! Process input files
@@ -177,10 +174,11 @@
    nobs = 0
    ndeps= 0
-   DO iproc = 1, nprocs
-      WRITE( iproc_str,'(I4.4)') iproc - 1
-      cdfilename=trim(cdfilebase)//'_'//trim(iproc_str)//'.nc'
-      WRITE(*,*) "Opening : ", TRIM(cdfilename)
+   ALLOCATE( cdinfile( nargs - 1 ) )
+   ninfiles = nargs - 1
+   DO ia = 1, ninfiles
+      CALL GETARG(ia+1, cdinfile(ia))
+      WRITE(*,*) "Opening : ", TRIM(cdinfile(ia))
       !! Open Netcdf file
-      istat = nf90_open(trim(cdfilename),nf90_nowrite,ncid)
+      istat = nf90_open(TRIM(cdinfile(ia)),nf90_nowrite,ncid)
       IF (istat == nf90_noerr) THEN
          !! Turn output file creation on
@@ -197,4 +195,7 @@
          !! Close Netcdf file
          CALL chkerr( nf90_close(ncid), cpname, __LINE__ )
+         !! Report on file contents
+         WRITE(*,'(2A)')'File = ', TRIM(cdinfile(ia))
+         WRITE(*,'(A,I9,A)')'has', sobs, ' observations'
          !! Increment size
          nobs  = nobs + sobs       !: Accumulate number of profiles
@@ -267,11 +268,8 @@
    qc_flag_meaning  = ''
 
-   DO iproc = 1,nprocs
-  
-      WRITE( iproc_str,'(I4.4)') iproc - 1
-      cdfilename=trim(cdfilebase)//'_'//trim(iproc_str)//'.nc'
-      WRITE(*,*) "Opening : ", TRIM(cdfilename)
+   DO ia = 1, ninfiles
+      WRITE(*,*) "Opening : ", TRIM(cdinfile(ia))
       !! Open Netcdf file
-      istat = nf90_open(trim(cdfilename),nf90_nowrite,ncid)
+      istat = nf90_open(TRIM(cdinfile(ia)),nf90_nowrite,ncid)
       IF (istat == nf90_noerr) THEN
          !! Get Global Attributes
@@ -294,5 +292,5 @@
          CALL chkerr( nf90_inquire_dimension(ncid,    dimid, len=sobs  ),  cpname, __LINE__ )
          !! Check for Optional variables in first file
-         IF (iproc == 1) THEN
+         IF (ia == 1) THEN
             !! Best estimate
             istat = nf90_inq_varid(ncid,'best_estimate',dm2id)
@@ -316,8 +314,8 @@
             ENDIF 
          END IF
-         WRITE(*,*) TRIM(cdfilename), " contains ", sobs, " observations"
-         WRITE(*,*) TRIM(cdfilename), " contains ", sdeps, " depths"
-         WRITE(*,*) TRIM(cdfilename), " contains ", nfcst, " forecasts"
-         WRITE(*,*) TRIM(cdfilename), " contains ", nvars, " vars"
+         WRITE(*,*) TRIM(cdinfile(ia)), " contains ", sobs, " observations"
+         WRITE(*,*) TRIM(cdinfile(ia)), " contains ", sdeps, " depths"
+         WRITE(*,*) TRIM(cdinfile(ia)), " contains ", nfcst, " forecasts"
+         WRITE(*,*) TRIM(cdinfile(ia)), " contains ", nvars, " vars"
          !! Read Variables
          IF (sobs /= 0) THEN
@@ -454,7 +452,6 @@
    !! Create Output file
    IF (ln_cre) THEN
-      cfname=trim(cdfilebase)//'.nc'
-      WRITE(*,*) 'Create the output file, ',trim(cfname)
-      CALL chkerr( nf90_create(trim(cfname),nf90_clobber,ncid),      cpname, __LINE__ )
+      WRITE(*,*) 'Create the output file, ',trim(cdoutfile)
+      CALL chkerr( nf90_create(trim(cdoutfile),nf90_clobber,ncid),      cpname, __LINE__ )
       !! Put Global Attributes
       CALL date_format(dat_str) 
@@ -607,6 +604,6 @@
       CALL chkerr( nf90_close(ncid) ,cpname, __LINE__ )  
       !! Fill in the variables
-      CALL chkerr( nf90_open(trim(cfname),nf90_write,ncid),                   cpname, __LINE__ )
-      WRITE(*,*) 'Create the variables ',trim(cfname)
+      CALL chkerr( nf90_open(trim(cdoutfile),nf90_write,ncid),                   cpname, __LINE__ )
+      WRITE(*,*) 'Create the variables ',trim(cdoutfile)
       !  Forecast day
       CALL chkerr( nf90_inq_varid(ncid, 'leadtime', fdvid)                ,cpname, __LINE__ )
@@ -700,3 +697,5 @@
    DEALLOCATE( fcday, modjd )
 
+   !! Deallocate input argument list
+   DEALLOCATE(cdinfile)
 END PROGRAM c4comb
