- Timestamp:
- 2013-10-24T18:00:53+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2013/dev_r3987_UKMO4_OBS/NEMOGCM/TOOLS/OBSTOOLS/src/c4comb.F90
r4112 r4124 11 11 !! 12 12 !! Usage: 13 !! c4comb.exe filebase nprocs13 !! c4comb.exe outputfile inputfile1 inputfile2 ... 14 14 !! 15 15 !! History : … … 25 25 INTEGER,EXTERNAL :: iargc 26 26 #endif 27 INTEGER :: nargs 27 INTEGER :: nargs, & !: number of command line arguments 28 & ia, & !: argument loop index 29 & ninfiles !: number of input files 28 30 !! 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(:) 32 33 !! Routine variables 33 CHARACTER(len=4) :: iproc_str 34 CHARACTER(len=80) :: cdfilename, cpname, cfname 34 CHARACTER(len=80) :: cpname 35 35 INTEGER,PARAMETER :: nstr=8, n128=128 36 36 INTEGER :: ncid, & !: netcdf file id … … 70 70 & u_dex 71 71 72 INTEGER :: iob, idep, i proc, istat72 INTEGER :: iob, idep, istat 73 73 INTEGER, DIMENSION(2) :: dim2a, dim2b, dim2c, dim2d 74 74 INTEGER, DIMENSION(3) :: dim3a … … 156 156 nargs = IARGC() 157 157 IF (nargs /= 2) THEN 158 WRITE(*, *) "Usage: c4comb.exe filebase nprocs" 158 WRITE(*, *) "Usage: c4comb.exe outputfile inputfile1 inputfile2 ..." 159 CALL abort() 159 160 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) 165 162 166 163 !! Process input files … … 177 174 nobs = 0 178 175 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)) 183 181 !! Open Netcdf file 184 istat = nf90_open( trim(cdfilename),nf90_nowrite,ncid)182 istat = nf90_open(TRIM(cdinfile(ia)),nf90_nowrite,ncid) 185 183 IF (istat == nf90_noerr) THEN 186 184 !! Turn output file creation on … … 197 195 !! Close Netcdf file 198 196 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' 199 200 !! Increment size 200 201 nobs = nobs + sobs !: Accumulate number of profiles … … 267 268 qc_flag_meaning = '' 268 269 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)) 274 272 !! Open Netcdf file 275 istat = nf90_open( trim(cdfilename),nf90_nowrite,ncid)273 istat = nf90_open(TRIM(cdinfile(ia)),nf90_nowrite,ncid) 276 274 IF (istat == nf90_noerr) THEN 277 275 !! Get Global Attributes … … 294 292 CALL chkerr( nf90_inquire_dimension(ncid, dimid, len=sobs ), cpname, __LINE__ ) 295 293 !! Check for Optional variables in first file 296 IF (i proc== 1) THEN294 IF (ia == 1) THEN 297 295 !! Best estimate 298 296 istat = nf90_inq_varid(ncid,'best_estimate',dm2id) … … 316 314 ENDIF 317 315 END IF 318 WRITE(*,*) TRIM(cd filename), " contains ", sobs, " observations"319 WRITE(*,*) TRIM(cd filename), " contains ", sdeps, " depths"320 WRITE(*,*) TRIM(cd filename), " contains ", nfcst, " forecasts"321 WRITE(*,*) TRIM(cd filename), " 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" 322 320 !! Read Variables 323 321 IF (sobs /= 0) THEN … … 454 452 !! Create Output file 455 453 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__ ) 459 456 !! Put Global Attributes 460 457 CALL date_format(dat_str) … … 607 604 CALL chkerr( nf90_close(ncid) ,cpname, __LINE__ ) 608 605 !! Fill in the variables 609 CALL chkerr( nf90_open(trim(c fname),nf90_write,ncid), cpname, __LINE__ )610 WRITE(*,*) 'Create the variables ',trim(c fname)606 CALL chkerr( nf90_open(trim(cdoutfile),nf90_write,ncid), cpname, __LINE__ ) 607 WRITE(*,*) 'Create the variables ',trim(cdoutfile) 611 608 ! Forecast day 612 609 CALL chkerr( nf90_inq_varid(ncid, 'leadtime', fdvid) ,cpname, __LINE__ ) … … 700 697 DEALLOCATE( fcday, modjd ) 701 698 699 !! Deallocate input argument list 700 DEALLOCATE(cdinfile) 702 701 END PROGRAM c4comb
Note: See TracChangeset
for help on using the changeset viewer.