New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 4124 – NEMO

Changeset 4124


Ignore:
Timestamp:
2013-10-24T18:00:53+02:00 (11 years ago)
Author:
andrewryan
Message:

changed c4comb.F90 to have the same API as fbcomb.exe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2013/dev_r3987_UKMO4_OBS/NEMOGCM/TOOLS/OBSTOOLS/src/c4comb.F90

    r4112 r4124  
    1111   !! 
    1212   !!   Usage: 
    13    !!     c4comb.exe filebase nprocs 
     13   !!     c4comb.exe outputfile inputfile1 inputfile2 ... 
    1414   !! 
    1515   !!   History : 
     
    2525   INTEGER,EXTERNAL :: iargc 
    2626#endif 
    27    INTEGER :: nargs 
     27   INTEGER :: nargs,    & !: number of command line arguments 
     28            & ia,       & !: argument loop index 
     29            & ninfiles    !: number of input files 
    2830   !! Routine arguments 
    29    CHARACTER(len=80) :: cdfilebase, &  
    30                       & cdnprocs 
    31    INTEGER           :: nprocs      !: number of processors 
     31   CHARACTER(len=256) :: cdoutfile 
     32   CHARACTER(len=256),ALLOCATABLE :: cdinfile(:) 
    3233   !! Routine variables 
    33    CHARACTER(len=4)  :: iproc_str 
    34    CHARACTER(len=80) :: cdfilename, cpname, cfname 
     34   CHARACTER(len=80) :: cpname 
    3535   INTEGER,PARAMETER :: nstr=8, n128=128 
    3636   INTEGER           ::    ncid,   & !: netcdf file id 
     
    7070                        &  u_dex 
    7171 
    72    INTEGER                   :: iob, idep, iproc, istat 
     72   INTEGER                   :: iob, idep, istat 
    7373   INTEGER, DIMENSION(2)     :: dim2a, dim2b, dim2c, dim2d 
    7474   INTEGER, DIMENSION(3)     :: dim3a 
     
    156156   nargs = IARGC() 
    157157   IF (nargs /= 2) THEN 
    158       WRITE(*, *) "Usage: c4comb.exe filebase nprocs" 
     158      WRITE(*, *) "Usage: c4comb.exe outputfile inputfile1 inputfile2 ..." 
     159      CALL abort() 
    159160   END IF 
    160    CALL GETARG(1, cdfilebase) 
    161    CALL GETARG(2, cdnprocs) 
    162    READ(cdnprocs, '(I4)') nprocs 
    163    WRITE(*,*) "Processing filebase : ", TRIM(cdfilebase) 
    164    WRITE(*,*) "# processors : ", nprocs 
     161   CALL GETARG(1, cdoutfile) 
    165162 
    166163   !! Process input files 
     
    177174   nobs = 0 
    178175   ndeps= 0 
    179    DO iproc = 1, nprocs 
    180       WRITE( iproc_str,'(I4.4)') iproc - 1 
    181       cdfilename=trim(cdfilebase)//'_'//trim(iproc_str)//'.nc' 
    182       WRITE(*,*) "Opening : ", TRIM(cdfilename) 
     176   ALLOCATE( cdinfile( nargs - 1 ) ) 
     177   ninfiles = nargs - 1 
     178   DO ia = 1, ninfiles 
     179      CALL GETARG(ia+1, cdinfile(ia)) 
     180      WRITE(*,*) "Opening : ", TRIM(cdinfile(ia)) 
    183181      !! Open Netcdf file 
    184       istat = nf90_open(trim(cdfilename),nf90_nowrite,ncid) 
     182      istat = nf90_open(TRIM(cdinfile(ia)),nf90_nowrite,ncid) 
    185183      IF (istat == nf90_noerr) THEN 
    186184         !! Turn output file creation on 
     
    197195         !! Close Netcdf file 
    198196         CALL chkerr( nf90_close(ncid), cpname, __LINE__ ) 
     197         !! Report on file contents 
     198         WRITE(*,'(2A)')'File = ', TRIM(cdinfile(ia)) 
     199         WRITE(*,'(A,I9,A)')'has', sobs, ' observations' 
    199200         !! Increment size 
    200201         nobs  = nobs + sobs       !: Accumulate number of profiles 
     
    267268   qc_flag_meaning  = '' 
    268269 
    269    DO iproc = 1,nprocs 
    270    
    271       WRITE( iproc_str,'(I4.4)') iproc - 1 
    272       cdfilename=trim(cdfilebase)//'_'//trim(iproc_str)//'.nc' 
    273       WRITE(*,*) "Opening : ", TRIM(cdfilename) 
     270   DO ia = 1, ninfiles 
     271      WRITE(*,*) "Opening : ", TRIM(cdinfile(ia)) 
    274272      !! Open Netcdf file 
    275       istat = nf90_open(trim(cdfilename),nf90_nowrite,ncid) 
     273      istat = nf90_open(TRIM(cdinfile(ia)),nf90_nowrite,ncid) 
    276274      IF (istat == nf90_noerr) THEN 
    277275         !! Get Global Attributes 
     
    294292         CALL chkerr( nf90_inquire_dimension(ncid,    dimid, len=sobs  ),  cpname, __LINE__ ) 
    295293         !! Check for Optional variables in first file 
    296          IF (iproc == 1) THEN 
     294         IF (ia == 1) THEN 
    297295            !! Best estimate 
    298296            istat = nf90_inq_varid(ncid,'best_estimate',dm2id) 
     
    316314            ENDIF  
    317315         END IF 
    318          WRITE(*,*) TRIM(cdfilename), " contains ", sobs, " observations" 
    319          WRITE(*,*) TRIM(cdfilename), " contains ", sdeps, " depths" 
    320          WRITE(*,*) TRIM(cdfilename), " contains ", nfcst, " forecasts" 
    321          WRITE(*,*) TRIM(cdfilename), " contains ", nvars, " vars" 
     316         WRITE(*,*) TRIM(cdinfile(ia)), " contains ", sobs, " observations" 
     317         WRITE(*,*) TRIM(cdinfile(ia)), " contains ", sdeps, " depths" 
     318         WRITE(*,*) TRIM(cdinfile(ia)), " contains ", nfcst, " forecasts" 
     319         WRITE(*,*) TRIM(cdinfile(ia)), " contains ", nvars, " vars" 
    322320         !! Read Variables 
    323321         IF (sobs /= 0) THEN 
     
    454452   !! Create Output file 
    455453   IF (ln_cre) THEN 
    456       cfname=trim(cdfilebase)//'.nc' 
    457       WRITE(*,*) 'Create the output file, ',trim(cfname) 
    458       CALL chkerr( nf90_create(trim(cfname),nf90_clobber,ncid),      cpname, __LINE__ ) 
     454      WRITE(*,*) 'Create the output file, ',trim(cdoutfile) 
     455      CALL chkerr( nf90_create(trim(cdoutfile),nf90_clobber,ncid),      cpname, __LINE__ ) 
    459456      !! Put Global Attributes 
    460457      CALL date_format(dat_str)  
     
    607604      CALL chkerr( nf90_close(ncid) ,cpname, __LINE__ )   
    608605      !! Fill in the variables 
    609       CALL chkerr( nf90_open(trim(cfname),nf90_write,ncid),                   cpname, __LINE__ ) 
    610       WRITE(*,*) 'Create the variables ',trim(cfname) 
     606      CALL chkerr( nf90_open(trim(cdoutfile),nf90_write,ncid),                   cpname, __LINE__ ) 
     607      WRITE(*,*) 'Create the variables ',trim(cdoutfile) 
    611608      !  Forecast day 
    612609      CALL chkerr( nf90_inq_varid(ncid, 'leadtime', fdvid)                ,cpname, __LINE__ ) 
     
    700697   DEALLOCATE( fcday, modjd ) 
    701698 
     699   !! Deallocate input argument list 
     700   DEALLOCATE(cdinfile) 
    702701END PROGRAM c4comb 
Note: See TracChangeset for help on using the changeset viewer.