Subversion Repositories lagranto.ecmwf

Rev

Rev 25 | Rev 29 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25 Rev 27
Line 198... Line 198...
198
         print*,' ERROR: input netCDF data must be on hybrid-sigma'
198
         print*,' ERROR: input netCDF data must be on hybrid-sigma'
199
         print*,'        or air pressure levels!',trim(leveltype)
199
         print*,'        or air pressure levels!',trim(leveltype)
200
         stop
200
         stop
201
      endif
201
      endif
202
 
202
 
203
c     Check that vardim(3)==#AK,BK for hybrid-sigmal levels
-
 
204
      if ( (leveltype.eq.'hybrid_sigma_pressure').and.
-
 
205
     >     (dimname(3).eq.'lev') )
-
 
206
     >then
-
 
207
        if ( nakbktmp.ne.vardim(3) ) then
-
 
208
           print*,' ERROR: for hybrid-sigma pressure levels, #AK,BK'
-
 
209
           print*,'        must agree with number of vertical levels'
-
 
210
           print*,'        ',vardim(3),nakbktmp
-
 
211
           stop
-
 
212
        endif
-
 
213
      endif
-
 
214
 
-
 
215
c     Allocate memory for reading arrays
203
c     Allocate memory for reading arrays
216
      allocate(tmp2(vardim(1),vardim(2)),stat=stat)
204
      allocate(tmp2(vardim(1),vardim(2)),stat=stat)
217
      if (stat.ne.0) print*,'*** error allocating array tmp2     ***'
205
      if (stat.ne.0) print*,'*** error allocating array tmp2     ***'
218
      allocate(tmp3(vardim(1),vardim(2),vardim(3)),stat=stat)
206
      allocate(tmp3(vardim(1),vardim(2),vardim(3)),stat=stat)
219
      if (stat.ne.0) print*,'*** error allocating array tmp3     ***'
207
      if (stat.ne.0) print*,'*** error allocating array tmp3     ***'
Line 283... Line 271...
283
               lev(k) = 0.01 * lev(k)
271
               lev(k) = 0.01 * lev(k)
284
            enddo
272
            enddo
285
         endif
273
         endif
286
      endif
274
      endif
287
 
275
 
288
c     Decide whether to swap vertical levels
276
c     Decide whether to swap vertical levels - highest pressure at index 1
289
      vertical_swap = 1
277
      vertical_swap = 1
290
      if ( leveltype.eq.'hybrid_sigma_pressure') then
278
      if ( leveltype.eq.'hybrid_sigma_pressure') then
291
        if ( (aktmp(1) + bktmp(1) * 1000.).gt.
279
        if ( (aktmp(1) + bktmp(1) * 1000.).gt.
292
     >       (aktmp(2) + bktmp(2) * 1000.) )
280
     >       (aktmp(2) + bktmp(2) * 1000.) )
293
     >  then
281
     >  then
Line 343... Line 331...
343
         stop
331
         stop
344
      endif
332
      endif
345
 
333
 
346
c     ---- Define output of subroutine --------------------------------
334
c     ---- Define output of subroutine --------------------------------
347
 
335
 
-
 
336
c     If not full list of vertical levels, reduce AK,BK arrays
-
 
337
      if ( (leveltype.eq.'hybrid_sigma_pressure').and.
-
 
338
     >     (nakbktmp.ne.vardim(3) ) )
-
 
339
     >then
-
 
340
         print*,' WARNING: only subset of vertical levels used...'
-
 
341
         do k=1,vardim(3)
-
 
342
            if ( vertical_swap.eq.1 ) then
-
 
343
               aktmp(k) = aktmp( k+nakbktmp-vardim(3) )
-
 
344
               bktmp(k) = bktmp( k+nakbktmp-vardim(3) )
-
 
345
            endif
-
 
346
         enddo
-
 
347
      endif
-
 
348
 
348
c     Set the grid dimensions and constants
349
c     Set the grid dimensions and constants
349
      nx      = vardim(1)
350
      nx      = vardim(1)
350
      ny      = vardim(2)
351
      ny      = vardim(2)
351
      nz      = vardim(3)
352
      nz      = vardim(3)
352
      xmin    = lon(1)
353
      xmin    = lon(1)
Line 562... Line 563...
562
         print*,' ERROR: input netCDF data must be on hybrid-sigma'
563
         print*,' ERROR: input netCDF data must be on hybrid-sigma'
563
         print*,'        or air pressure levels!',trim(leveltype)
564
         print*,'        or air pressure levels!',trim(leveltype)
564
         stop
565
         stop
565
      endif
566
      endif
566
 
567
 
567
c     Check that vardim(3)==#AK,BK for hybrid-sigmal levels
-
 
568
      if ( (leveltype.eq.'hybrid_sigma_pressure').and.
-
 
569
     >     (dimname(3).eq.'lev') )
-
 
570
     >then
-
 
571
        if ( nakbktmp.ne.vardim(3) ) then
-
 
572
           print*,' ERROR: for hybrid-sigma pressure levels, #AK,BK'
-
 
573
           print*,'        must agree with number of vertical levels'
-
 
574
           print*,'        ',vardim(3),nakbktmp
-
 
575
           stop
-
 
576
        endif
-
 
577
      endif
-
 
578
 
-
 
579
c     Allocate memory for reading arrays - depending on <closear>
568
c     Allocate memory for reading arrays - depending on <closear>
580
      allocate(tmp2(vardim(1),vardim(2)),stat=stat)
569
      allocate(tmp2(vardim(1),vardim(2)),stat=stat)
581
      if (stat.ne.0) print*,'*** error allocating array tmp2     ***'
570
      if (stat.ne.0) print*,'*** error allocating array tmp2     ***'
582
      allocate(tmp3(vardim(1),vardim(2),vardim(3)),stat=stat)
571
      allocate(tmp3(vardim(1),vardim(2),vardim(3)),stat=stat)
583
      if (stat.ne.0) print*,'*** error allocating array tmp3     ***'
572
      if (stat.ne.0) print*,'*** error allocating array tmp3     ***'
Line 657... Line 646...
657
        endif
646
        endif
658
      elseif ( leveltype.eq.'air_pressure') then
647
      elseif ( leveltype.eq.'air_pressure') then
659
        if ( lev(1).gt.lev(2) ) then
648
        if ( lev(1).gt.lev(2) ) then
660
          vertical_swap = 0
649
          vertical_swap = 0
661
        endif
650
        endif
662
      endif
651
      endi
663
c      print*,' Vertical SWAP ',trim(fieldname),' -> ', vertical_swap
-
 
664
 
652
 
665
c     Read data 
653
c     Read data 
666
      ierr = NF90_INQ_VARID(fid,fieldname,varid)
654
      ierr = NF90_INQ_VARID(fid,fieldname,varid)
667
      IF(ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
655
      IF(ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
668
      ierr = nf90_get_var(fid,varid,tmp3)
656
      ierr = nf90_get_var(fid,varid,tmp3)