Subversion Repositories lagranto.icon

Rev

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

Rev 3 Rev 8
Line 100... Line 100...
100
      integer      dimids(100)
100
      integer      dimids(100)
101
      character*80 dimname(100)   
101
      character*80 dimname(100)   
102
      integer      ndim
102
      integer      ndim
103
      integer      i,j,k
103
      integer      i,j,k
104
      real         tmp3(nx,ny,nz)
104
      real         tmp3(nx,ny,nz)
-
 
105
      real         stag3(nx,ny,nz+1)
105
      integer      cdfid 
106
      integer      cdfid 
106
       
107
       
107
c     fid can be negative, take its absolute value
108
c     fid can be negative, take its absolute value
108
      cdfid = abs(fid)
109
      cdfid = abs(fid)
109
       
110
       
Line 160... Line 161...
160
 
161
 
161
c     Get number of vertical levels
162
c     Get number of vertical levels
162
      ierr = nf90_inquire_dimension(cdfid, dimids(3), len = nz)
163
      ierr = nf90_inquire_dimension(cdfid, dimids(3), len = nz)
163
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
164
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
164
 
165
 
-
 
166
c     Handling of vertical staggering 
-
 
167
      nz = nz -1
-
 
168
 
165
c     Set parameters
169
c     Set parameters
166
      pollon = 0.
170
      pollon = 0.
167
      pollat = 90.
171
      pollat = 90.
168
      polgam = 0.
172
      polgam = 0.
169
      xmin   = lon(1)
173
      xmin   = lon(1)
Line 191... Line 195...
191
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr) 
195
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr) 
192
 
196
 
193
c     Read 3D height field
197
c     Read 3D height field
194
      ierr = NF90_INQ_VARID(cdfid,'z_mc',varid)
198
      ierr = NF90_INQ_VARID(cdfid,'z_mc',varid)
195
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
199
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
196
      ierr = NF90_GET_VAR(cdfid,varid,tmp3)
200
      ierr = NF90_GET_VAR(cdfid,varid,stag3)
197
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr) 
201
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr) 
198
 
202
 
-
 
203
c     Handling of vertical staggering - destagger
-
 
204
      do i=1,nx
-
 
205
         do j=1,ny
-
 
206
         	do k=1,nz
-
 
207
         	   tmp3(i,j,k) = 0.5 * ( stag3(i,j,k) + stag3(i,j,k+1) )
-
 
208
         	enddo
-
 
209
         enddo
-
 
210
      enddo   	
-
 
211
 
199
c     Check whether vertical axis is descending - vertical flip
212
c     Check whether vertical axis is descending - vertical flip
200
      if ( tmp3(1,1,1).lt.tmp3(1,1,nz) ) then
213
      if ( tmp3(1,1,1).lt.tmp3(1,1,nz) ) then
201
        print*,' ERROR: vertical axis must be descending... Stop'
214
        print*,' ERROR: vertical axis must be descending... Stop'
202
        stop
215
        stop
203
      endif
216
      endif
Line 251... Line 264...
251
c     Auxiliary variables
264
c     Auxiliary variables
252
      integer      i,j,k
265
      integer      i,j,k
253
      integer      nlon,nlat,nlev
266
      integer      nlon,nlat,nlev
254
      real         tmp2(nx,ny)
267
      real         tmp2(nx,ny)
255
      real         tmp3(nx,ny,nz)
268
      real         tmp3(nx,ny,nz)
-
 
269
      real         stag3(nx,ny,nz+1)
256
      integer      ierr
270
      integer      ierr
257
      integer      varid
271
      integer      varid
258
      integer      dimid
272
      integer      dimid
259
      integer      dimids(100)
273
      integer      dimids(100)
260
      character*80 dimname(100)   
274
      character*80 dimname(100)   
Line 306... Line 320...
306
      ierr = nf90_inq_dimid(fid,dimname(3), dimid)
320
      ierr = nf90_inq_dimid(fid,dimname(3), dimid)
307
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
321
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
308
      ierr = nf90_inquire_dimension(fid, dimid, len = nlev)
322
      ierr = nf90_inquire_dimension(fid, dimid, len = nlev)
309
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
323
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
310
      if ( (nlon.ne.nx).or.(nlat.ne.ny).or.
324
      if ( (nlon.ne.nx).or.(nlat.ne.ny).or.
311
     >     (nlev.ne.nz).and.(nlev.ne.1) )
325
     >  (nlev.ne.nz).and.(nlev.ne.1).and.(nlev.ne.(nz+1)) )
312
     >then
326
     >then
313
         print*,' ERROR: grid mismatch between ICONCOSNT and P file'
327
         print*,' ERROR: grid mismatch between ICONCONST and P file'
314
         stop
328
         stop
315
      endif
329
      endif
316
 
330
 
317
c     Read the field
331
c     Get varid
318
      ierr = NF90_INQ_VARID(fid,fieldname,varid)
332
      ierr = NF90_INQ_VARID(fid,fieldname,varid)
319
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
333
      IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr)
-
 
334
 
-
 
335
c     Read 2D variable
320
      if ( nlev.eq.2 ) then
336
      if ( nlev.eq.1 ) then
321
        ierr = NF90_GET_VAR(fid,varid,tmp2)
337
        ierr = NF90_GET_VAR(fid,varid,tmp2)
322
        IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr) 
338
        IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr) 
323
        do i=1,nx
339
        do i=1,nx
324
            do j=1,ny
340
            do j=1,ny
325
               do k=1,nz
341
               do k=1,nz
326
                  tmp3(i,j,k) = tmp2(i,j)
342
                  tmp3(i,j,k) = tmp2(i,j)
327
               enddo
343
               enddo
328
            enddo
344
            enddo
329
         enddo
345
         enddo
330
      else
346
      endif
-
 
347
      
-
 
348
c     Read 3D variable, destagger if necessary      
-
 
349
      if ( nlev.eq.nz ) then
331
        ierr = NF90_GET_VAR(fid,varid,tmp3)
350
        ierr = NF90_GET_VAR(fid,varid,tmp3)
332
        IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr) 
351
        IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr) 
-
 
352
      elseif ( nlev.eq.(nz+1) ) then  
-
 
353
        ierr = NF90_GET_VAR(fid,varid,stag3)
-
 
354
        IF ( ierr /= nf90_NoErr) PRINT *,NF90_STRERROR(ierr) 
-
 
355
        do i=1,nx
-
 
356
          do j=1,ny
-
 
357
             do k=1,nz
-
 
358
                tmp3(i,j,k) = 0.5 * ( stag3(i,j,k) + stag3(i,j,k+1) )
-
 
359
             enddo
-
 
360
          enddo
-
 
361
        enddo  
333
      endif
362
      endif
334
     
363
     
335
c     Flip vertically 
364
c     Flip vertically 
336
      do i=1,nx
365
      do i=1,nx
337
        do j=1,ny
366
        do j=1,ny