Subversion Repositories lagranto.icon

Rev

Rev 8 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8 Rev 9
Line 271... Line 271...
271
      integer      varid
271
      integer      varid
272
      integer      dimid
272
      integer      dimid
273
      integer      dimids(100)
273
      integer      dimids(100)
274
      character*80 dimname(100)   
274
      character*80 dimname(100)   
275
      integer      ndim
275
      integer      ndim
-
 
276
 
-
 
277
c     ----- Get dimension and check whether OK --------------------------------- 
276
     
278
     
277
c     Get <ndim>, <dimids> and <dimname>
279
c     Get <ndim>, <dimids> and <dimname>
278
      ierr = NF90_INQ_VARID(fid,fieldname,varid)
280
      ierr = NF90_INQ_VARID(fid,fieldname,varid)
279
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
281
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
280
      ierr = nf90_inquire_variable(fid, varid, ndims  = ndim)
282
      ierr = nf90_inquire_variable(fid, varid, ndims  = ndim)
Line 284... Line 286...
284
      do i=1,ndim
286
      do i=1,ndim
285
         ierr = nf90_inquire_dimension(fid, dimids(i), 
287
         ierr = nf90_inquire_dimension(fid, dimids(i), 
286
     >                               name = dimname(i) )
288
     >                               name = dimname(i) )
287
         IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
289
         IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
288
      enddo
290
      enddo
289
      
291
 
290
c     Check that dimensions are OK
-
 
291
      if ( ndim.ne.4 ) then
292
      if ( (ndim.ne.3).and.(ndim.ne.4) ) then
292
        print*,' ERROR: ',trim(fieldname),' must be 4D'
293
        print*,' Data must be either 3D or 4D'
293
        stop
294
        stop
294
      endif
295
      endif
-
 
296
      
-
 
297
c     ----- Read 4D data ------------------------------------------------------ 
-
 
298
 
-
 
299
      if ( ndim.ne.4 ) goto 100
-
 
300
 
-
 
301
c     Check that dimensions are OK
295
      if ( dimname(4).ne.'time' ) then
302
      if ( dimname(4).ne.'time' ) then
296
        print*,' ERROR: dimname(4) must be time '
303
        print*,' ERROR: dimname(4) must be time '
297
        print*,trim(fieldname),' / ',trim(dimname(4))
304
        print*,trim(fieldname),' / ',trim(dimname(4))
298
        stop
305
        stop
299
      endif
306
      endif
Line 368... Line 375...
368
              field(i,j,k) = tmp3(i,j,nz-k+1)
375
              field(i,j,k) = tmp3(i,j,nz-k+1)
369
           enddo
376
           enddo
370
        enddo
377
        enddo
371
      enddo
378
      enddo
372
 
379
 
-
 
380
c     Exit point for reading 4D data
-
 
381
 100  continue
-
 
382
 
-
 
383
c     ----- Read 3D data ------------------------------------------------------ 
-
 
384
 
-
 
385
      if ( ndim.ne.3 ) goto 200
-
 
386
 
-
 
387
c     Check that dimensions are OK
-
 
388
      if ( dimname(3).ne.'time' ) then
-
 
389
        print*,' ERROR: dimname(3) must be time '
-
 
390
        print*,trim(fieldname),' / ',trim(dimname(3))
-
 
391
        stop
-
 
392
      endif
-
 
393
      if ( dimname(2).ne.'lat' ) then
-
 
394
        print*,' ERROR: dimname(2) must be lat ' 
-
 
395
        print*,trim(fieldname),' / ',trim(dimname(2))
-
 
396
        stop
-
 
397
      endif    
-
 
398
      if ( dimname(1).ne.'lon' ) then
-
 
399
        print*,' ERROR: dimname(1) must be lon ' 
-
 
400
        print*,trim(fieldname),' / ',trim(dimname(2))
-
 
401
        stop
-
 
402
      endif   
-
 
403
      
-
 
404
c     Check grid dimensions       
-
 
405
      ierr = nf90_inq_dimid(fid,dimname(1), dimid)
-
 
406
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
-
 
407
      ierr = nf90_inquire_dimension(fid, dimid, len = nlon)
-
 
408
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
-
 
409
      ierr = nf90_inq_dimid(fid,dimname(2), dimid)
-
 
410
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
-
 
411
      ierr = nf90_inquire_dimension(fid, dimid, len = nlat)
-
 
412
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
-
 
413
      if ( (nlon.ne.nx).or.(nlat.ne.ny) ) then
-
 
414
         print*,' ERROR: grid mismatch between ICONCONST and P file'
-
 
415
         stop
-
 
416
      endif
-
 
417
 
-
 
418
c     Get varid
-
 
419
      ierr = NF90_INQ_VARID(fid,fieldname,varid)
-
 
420
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
-
 
421
 
-
 
422
c     Read 2D variable
-
 
423
      ierr = NF90_GET_VAR(fid,varid,tmp2)
-
 
424
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr) 
-
 
425
      do i=1,nx
-
 
426
          do j=1,ny
-
 
427
             do k=1,nz
-
 
428
                field(i,j,k) = tmp2(i,j)
-
 
429
             enddo
-
 
430
          enddo
-
 
431
      enddo
-
 
432
 
-
 
433
c     Exit point for reading 4D data
-
 
434
 200  continue
373
     
435
     
374
      end
436
      end
375
 
437
 
376
c     ------------------------------------------------------------
438
c     ------------------------------------------------------------
377
c     Close input file
439
c     Close input file