Subversion Repositories lagranto.um

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 michaesp 1
      program pp2cdf
2
      implicit none
3
C
4
C     Purpose.
5
C     --------
6
C
7
C       Reads UKMO MM pressure data and writes the data to a NetCDF-file.
8
C       It works on 20 pressure levels, and uses stashcodes 90003 and 90004 
9
C       (u and v wrt model grid).
10
C
11
C     Interface.
12
C     ----------
13
C
14
C       File with MM data attached as unit 8.
15
C       File with NetCDF filename and missing data flag is unit 15.
16
C       Varfile (variable informations) attached as unit 12.
17
C
18
C     Reference.
19
C     ----------
20
C
21
C       None.
22
C
23
C     Author.
24
C     -------
25
C
26
C
27
C     Modifications.
28
C     --------------
29
C
30
C       None.
31
C
32
C     -----------------------------------------------------------------
33
C
34
 
35
CCC   Include your netcdf.inc
36
      include 'netcdf.inc'
37
 
38
C     ===  definitions of routinespecific variables  =======================
39
 
40
CCC   maximum array dimensions (change them for your purpose)
41
      integer   nxmax,nymax,nxi,nyi,nlevmax,nwet
42
      real      pmin,pmax,pdiff
43
      parameter(nxmax=270,nymax=270,nlevmax=20,nwet=20)
44
      parameter(nxi=nxmax-2,nyi=nymax-2)
45
 
46
      real      fld(nxmax,nymax)
47
      real	field(nxi*nyi)
48
      real	pstar(nxmax,nymax)
49
      real	data(nxi,nyi)
50
      real      varmin(3), varmax(3), stag(3)
51
      integer   vardim(4)
52
      real      mdv
53
      integer	datar(14),idate(5),stdate(5),cstid
54
      integer	lev,cdfid
55
      real	tstep
56
      real	aklev(nlevmax),bklev(nlevmax),aklay(nlevmax),bklay(nlevmax)
57
      real	latn,lats,lonw,lone,dx,dy,pole_lon,pole_lat
58
      real      p1,p2,pex1,pex2,exner,pres,plevs(nlevmax)
59
      integer	nx,ny,nlev,nvars,ntimes,tcode,qcode,pcode
60
      integer	i,j,ierr,iform,ieee,stash_code,iend,ilev
61
      integer	dyear,dmonth,dday,dhour,dmins
62
      logical	opnfile
63
      integer	strend,saveplevs,tind,irec
64
      integer	done_u,done_v,done_t,done_q,done_o,done_p
65
      character*80 cfn,wrcstflag,cdfname,varname
66
      logical    NewDyn
67
 
68
c     include 'ABmeso31.f'     ! define Hybrid coord. coefficients
69
 
70
C R IS GAS CONSTANT FOR DRY AIR
71
C CP IS SPECIFIC HEAT OF DRY AIR AT CONSTANT PRESSURE
72
C PREF IS REFERENCE SURFACE PRESSURE
73
      REAL R,CP,KAPPA,PREF  ! PREFTOKI
74
      PARAMETER(R=287.05,CP=1005.0,KAPPA=R/CP,PREF=100000.0)
75
!     PARAMETER(pmin=1000.0,pmax=200.0,pdiff=25.0,pcode=409)
76
 
77
      character*100 infile
78
      character*60 cdf_file,ctime*2,char1*1,ext1*2,ext2*2,date_str*2
79
 
80
      write(*,*)'===  start of program pp2cdf_p20 ===  (+++)'
81
      write(*,*)'===  This Program works on UKMM pressure level data'
82
 
83
C     Read parameters from input-file fort.15
84
 
85
      read(15,'(a)') infile		! name of PP Format input file
86
      read(15,'(a)') cdfname	! name of NetCDF file
87
      read(15,'(a)') wrcstflag	! write-cst-file flag
88
      read(15,'(a)') cfn           ! name of constants file
89
      read(15,*) mdv			! missing data value
90
      read(15,*) tcode             ! stash code of T/Theta field
91
      read(15,*) qcode             ! stash code of Q field
92
      read(15,*) pcode             ! stash code of PS field
93
      read(15,*) pmin              ! min value of PS field
94
      read(15,*) pmax              ! max. value of PS field
95
      read(15,*) pdiff             ! level difference of PS field
96
      read(15,*) NewDyn            ! New Dynamics (version 5 onwards)
97
C      write(*,*) NewDyn
98
C     write(*,*)pmin, pmax, pdiff 
99
C     Define constants file name
100
 
101
      if (cfn.eq.'default') then
102
        cfn=cdfname(1:strend(cdfname))//'_cst'
103
      endif
104
      opnfile=.false.
105
      nvars=0
106
      ntimes=1
107
 
108
C     ======================================================
109
C     Start of loop to write specified fields on NetCDF file
110
C     loop 30 --> goto 30
111
C     ======================================================
112
 
113
      iform=0
114
      ieee=1
115
      irec=0
116
      done_u=0
117
      done_v=0
118
      done_t=0
119
      done_q=0
120
      done_o=0
121
      done_p=0
122
      saveplevs=0
123
      nlev=pmax  !50.0
124
      call open_ppf(infile,iform,ieee)  ! open PP Format input file
125
 
126
   30 continue
127
 
128
CCC   call here a subroutine that reads 1 variable on 1 level from
129
CCC   a data file
130
CCC   call another subroutine or do everything in one, as you like,
131
CCC   that gets some general information about the data
132
CCC   anyhow, what you do here should define the following parameters:
133
 
134
C     dyear	integer		year of date valid for current field
135
C     dmonth	integer		month of date valid for current field
136
C     dday	integer		day of date valid for current field
137
C     dhour	integer		hour of date valid for current field
138
C     dmins	integer		minute of date valid for current field
139
 
140
C     lonw	real		coordinates of data domain (in deg):
141
C     lone	real		      latn
142
C     lats	real       	 lonw --|-- lone
143
C     late	real		      lats
144
C     dx	real		grid size in W-E direction (in deg)
145
C     dy	real		grid size in S-N direction (in deg)
146
C     nx	integer	number of data points in W-E direction
147
C     ny	integer	number of data points in S-N direction
148
C     nlev	integer	number of data levels
149
 
150
C     stash_code	integer	your field code
151
C     lev	integer	number of the level for the current field
152
C     fld 	real		2-dim array with dimensions (nx,ny),
153
C				contains the field values
154
 
155
CCC   ... call here your subroutine(s)...
156
      call read_field(iform,nx,ny,fld,stash_code,lev,
157
     &     dx,dy,dyear,dmonth,dday,dhour,dmins,iend,
158
     &     lonw,lone,latn,lats,pole_lon,pole_lat,pres,nxmax,nymax,
159
     &     NewDyn)
160
c      write(*,*)'stash and level',stash_code,lev,iend,pres
161
      if(iend.eq.1) goto 999
162
 
163
CCC   Determine the name of the variable from the field code 'num'
164
CCC   If a variable is not in the list, it is not written to the NetCDF file
165
      if (stash_code.eq.90003) then
166
        varname='U'			! zonal velocity
167
        if(lev.eq.nlev) done_u=1
168
c       if(saveplevs.lt.nlevmax+1) then
169
c         if(saveplevs.eq.0) tind=1
170
c         plevs(tind)=pres
171
c         tind=tind+1
172
c       endif
173
      else if (stash_code.eq.90004) then
174
        varname='V'			! meridional velocity
175
        if(lev.eq.nlev) done_v=1
176
      else if (stash_code.eq.90087) then
177
        varname='OMEGA'			! vertical velocity
178
        if(lev.eq.nlev) done_o=1
179
      else if (stash_code.eq.tcode) then
180
        varname='T'			! temperature
181
        if(lev.eq.nlev) done_t=1
182
c if Theta supplied then convert to Temp
183
        if(tcode.eq.90006) then
184
          do j = 1,ny
185
            do i = 1,nx
186
c     form Temp. at full levels from Theta
187
              exner=(pres/pref)**kappa
188
              fld(i,j)=fld(i,j)*exner
189
            enddo
190
          enddo
191
        endif
192
      else if (stash_code.eq.pcode ) then
193
        varname='PS'			! surface pressure
194
cwang   nlev=1
195
cwang   lev=1        ! reset lev to 1 from 9999
196
        done_p=1
197
        do j = 1,ny
198
          do i = 1,nx
199
            pstar(i,j)=fld(i,j)
200
            fld(i,j)=fld(i,j)/100.0    ! Pstar needed in hPa
201
          enddo
202
        enddo
203
      else if (stash_code.eq.qcode) then
204
        varname='Q'			! specific humidity
205
        if(lev.eq.nlev) done_q=1
206
      else
207
        goto 30				! don't put fld on NetCDF file
208
      endif
209
 
210
      irec=irec+1
211
c     N.B. U, V and Omega are all on P-Grid
212
        do i=1,nxi
213
          do j=1,nyi
214
            data(i,j)=fld(i+1,j+1)
215
          enddo
216
        enddo
217
 
218
C     Define staggering coefficients
219
CCC   change the ??? to your num-value for vertical velocity
220
 
221
      stag(1)=0.0
222
      stag(2)=0.0
223
      stag(3)=0.0
224
c     if (stash_code.eq.???) then	! no staggering for vertical velocity
225
c       stag(3)=0.0
226
c     else
227
c       stag(3)=-0.5		! vertical staggering for all other variables
228
c     endif
229
 
230
C     Define data region
231
 
232
      varmin(1)=lonw
233
      varmin(2)=lats
234
      varmax(1)=lone
235
      varmax(2)=latn
236
C     varmin/max(3) changed to take into account reverse order of data
237
      varmin(3)=pmin   ! Not used
238
      varmax(3)=pmax  !50.0
239
      write(*,*) 'lonw,lats,lone,latn',lonw,lats,lone,latn
240
      write(*,*) 'pmax, pmin',pmax, pmin 
241
 
242
C     Define dimensions
243
 
244
      vardim(1)=nxi
245
      vardim(2)=nyi
246
CCC   Distinction between 2dim and 3dim fields
247
CCC   Insert num-values for 2dim fields
248
      if (stash_code.eq.pcode) then
249
        vardim(3)=1
250
      else
251
        vardim(3)=nlevmax
252
      endif
253
      vardim(4)=1
254
 
255
C     Define the date array
256
 
257
      idate(1)=dyear
258
      idate(2)=dmonth
259
      idate(3)=dday
260
      idate(4)=dhour
261
      idate(5)=dmins
262
 
263
C     set stdate on first read of PP record from file
264
 
265
c     if (irec.eq.1) then
266
c     endif
267
      if (wrcstflag.eq.'yes') then
268
 
269
C       stdate is the simulation start time
270
        stdate(1)=dyear
271
        stdate(2)=dmonth
272
        stdate(3)=dday
273
        stdate(4)=dhour
274
        stdate(5)=dmins
275
C       Define the datar array (used to define constants file)
276
 
277
        datar(1)=nxi
278
        datar(2)=nyi
279
        datar(3)=nint(1000.0*latn) ! I agree this is not nice
280
        datar(4)=nint(1000.0*lonw) ! but for historical reasons
281
        datar(5)=nint(1000.0*lats) ! subroutine wricst contains
282
        datar(6)=nint(1000.0*lone) ! this factor 1000. things
283
        datar(7)=nint(1000.0*dx)
284
        datar(8)=nint(1000.0*dy)
285
        datar(9)=nlevmax  ! just in case Pstar first in file
286
        datar(10)=0         ! not used
287
        datar(11)=0         ! not used
288
        datar(12)=0         ! not used
289
        datar(13)=nint(1000.0*pole_lon)
290
        datar(14)=nint(1000.0*pole_lat)
291
 
292
C       Get the 4 levels/layers arrays
293
 
294
        call modlevs(aklev,bklev,aklay,bklay,plevs,nlevmax,pmin,pdiff)
295
 
296
C       Write the constants file
297
 
298
        call wricst(cfn,datar,aklev,bklev,aklay,bklay,stdate)
299
        write(*,*)
300
        write(*,*)'*** constants-file ',cfn(1:strend(cfn)),' created'
301
        wrcstflag='no'
302
      else           ! assume that the constants-file already exists
303
C       Inquire start time
304
        call cdfopn(cfn,cstid,ierr)              ! open constants file
305
        call getstart(cstid,stdate,ierr)
306
        call ncclos(cstid,ierr)                  ! close constants file
307
      endif
308
 
309
C     Create the NetCDF file (only once)
310
 
311
      if (.not.opnfile) then
312
c    Code to derive Index No. for filenames
313
c       if(ntimes.lt.10) then
314
c         write(char1,'(i1)') ntimes
315
c         ctime='0'//char1
316
c       else
317
c         write(ctime,'(i2)') ntimes
318
c       endif
319
c       cdf_file=cdfname(1:strend(cdfname))//ctime
320
c    Code to derive timestamp for filenames
321
c       dhour=dhour-stdate(4)  ! subtract start time so always atart at 0
322
        if(dhour.eq.0) then
323
          ext1='00'
324
        elseif(dhour.lt.10) then
325
          write(char1,'(i1)') dhour
326
          ext1='0'//char1
327
        else
328
          write(ext1,'(i2)') dhour
329
        endif
330
        if(dmins.eq.0) then
331
          ext2='00'
332
        else
333
          write(ext2,'(i2)') dmins
334
        endif
335
c       n.b if data runs into next day then can't use root of first
336
c       filename for rest, so form filename manually
337
c       cdf_file=cdfname(1:strend(cdfname))//ext1//ext2
338
c       below assumes year and month are constant
339
        if(dday.lt.10) then
340
          write(char1,'(i1)') dday
341
          date_str='0'//char1
342
        else
343
          write(date_str,'(i2)') dday
344
        endif
345
        cdf_file=cdfname(1:5)//date_str//'_'//ext1//ext2
346
        call crecdf(cdf_file,cdfid,varmin,varmax,
347
     &              3,cfn(1:strend(cfn)),ierr)
348
        if (ierr.ne.0) goto 996
349
        write(*,*)
350
c       write(*,*)'*** NetCDF file ',cdfname(1:strend(cdfname)),' create
351
        write(*,*)'*** NetCDF file ',cdf_file,' created'
352
        opnfile=.true.
353
      endif
354
 
355
C     Put 2dim array in 1dim array
356
 
357
      do i=1,nxi
358
        do j=1,nyi
359
          field(i+(j-1)*nxi)=data(i,j)
360
        enddo
361
      enddo
362
 
363
C     Calculate tstep for actual date (relative to first time of
364
c     simulation) and convert to minutes
365
 
366
      call timediff(idate,stdate,tstep)
367
c     tstep=tstep*100.0
368
c     tstep=float(nint(tstep*100.0))
369
      write(6,*)"idate,stdate,tstep:",idate,stdate,tstep
370
      i=ifix(tstep)  ! round down to nearest hour
371
      tstep=float(i*60+nint(100.0*tstep)-100*i)
372
cwang     ilev=1+((1000-lev)/50) this should be changed to /25     
373
cwang     change ilev=1+((1000-lev)/50) statement when pdiff read in
374
      write(6,*)"tstep:",tstep
375
      ilev=1+((pmin-lev)/pdiff)
376
      if(stash_code.eq.pcode) ilev=1
377
 
378
      if (ilev.eq.1) then
379
        call putdef(cdfid,varname(1:strend(varname)),4,mdv,vardim,
380
     &              varmin,varmax,stag,ierr)
381
        if (ierr.ne.0) goto 996
382
        write(*,*)
383
        write(*,*)'*** variable ',varname(1:strend(varname)),' created'
384
        nvars=nvars+1
385
      endif
386
 
387
C     Put data on file
388
 
389
c     Convert units of Temp to Degrees C
390
      if (stash_code.eq.90002.or.stash_code.eq.90006) then
391
        do i=1,nxi*nyi
392
          field(i)=field(i)-273.15
393
        enddo
394
      endif
395
 
396
      write(*,*)
397
      write(*,'(a,a,a,f7.1,a,i4,a)')'*** var ',
398
     &  varname(1:strend(varname)),' at time ',
399
     &  tstep,' on level ',lev,' written on cdffile'
400
      call putdat(cdfid,varname(1:strend(varname)),tstep,ilev,
401
     &  field,ierr)
402
      if (ierr.ne.0) goto 996
403
      write(*,*)'cdfid',cdfid
404
c     if(nvars.eq.6.and.lev.eq.nlev) then   ! required variables written
405
      write(*,*)done_u,done_v,done_t,done_q,done_o,done_p
406
      if(done_u+done_v+done_t+done_q+done_o+done_p.eq.6) then
407
        opnfile=.false.
408
        ntimes=ntimes+1
409
        nvars=0
410
C     Close NetCDF file
411
 
412
        call ncclos(cdfid,ierr)
413
        if (ierr.ne.0) stop 'error when closing NetCDF file'
414
c       if(ntimes.eq.2) stop
415
        done_u=0
416
        done_v=0
417
        done_t=0
418
        done_q=0
419
        done_o=0
420
        done_p=0
421
      endif
422
      goto 30
423
 
424
  996 stop 'error: could not create NetCDF file'
425
  999 continue
426
      write(*,*)lev,nlev,ierr
427
      if(lev.gt.nlev.or.ierr.ne.0) then
428
        write(*,*)'===  Error: NetCDF file: ',cdf_file,' incomplete'
429
        write(*,*)'See fort.12 for list of data processed'
430
        stop
431
      endif
432
 
433
      write(*,*)'===  end of program pp2cdf_p20: status normal  ==='
434
 
435
      stop
436
      end
437
 
438
      subroutine open_ppf(infile,iform,ieee)
439
C    I/O STREAMS ARE AS FOLLOWS
440
C     1) 6   STANDARD OUTPUT
441
C     2) 8   PPUNIT - READ UNIT FOR PP FILE
442
      IMPLICIT NONE
443
      INTEGER ierr,IFORM,IEEE
444
      CHARACTER INFILE*100
445
c
446
      IF(IFORM.EQ.1) THEN
447
        OPEN(UNIT=8,FILE=INFILE,FORM='FORMATTED')
448
      ELSE
449
        IF(IEEE.EQ.1) THEN
450
c     2 lines below are Cray specific calls to identify IEEE file
451
c     n.b 'newlocal' refers to assign environment, not file
452
c         call asnctl('newlocal',1,ierr)
453
c         write(*,*) 'ierr from asnctl ',ierr
454
c         call asnunit(8,'-F f77 -N ieee',ierr)
455
c         write(*,*) 'ierr from asnunit ',ierr
456
        ENDIF
457
        OPEN(UNIT=8,FILE=INFILE,FORM='UNFORMATTED')
458
      ENDIF
459
      return
460
      END
461
c********************************************************
462
      subroutine read_field(iform,nx,ny,data,stash_code,level,
463
     &     dxdeg,dydeg,dyear,dmonth,dday,dhour,dmins,iend,
464
     &     lonw,lone,latn,lats,pole_lon,pole_lat,pres,nxmax,nymax,
465
     &      NewDyn)
466
C    I/O STREAMS ARE AS FOLLOWS
467
C     1) 6   STANDARD OUTPUT
468
C     2) 8   PPUNIT - READ UNIT FOR PP FILE
469
C     3) 12  HEADER INFORMATION STREAM
470
      IMPLICIT NONE
471
c     
472
      REAL ROOK(19), FIELD(72900),data(270,270)
473
      INTEGER LOOK(45),I,J,K,N,NUM_VALUES,NX,NY,IFORM,nxmax,nymax,
474
     &     nf,stash_code,level,dyear,dmonth,dday,dhour,dmins,iend
475
      real LONG1,LAT1,dxdeg,dydeg,long_nw,lat_nw,
476
     &     fac,lonw,lone,latn,lats,pole_lon,pole_lat,pres
477
      logical NewDyn
478
      data nf/0/
479
      save nf
480
      nf=nf+1
481
c
482
      IF(IFORM.EQ.1) THEN
483
        READ(8,12,END=99) LOOK
484
        READ(8,13) ROOK
485
      ELSE
486
        READ(8,END=99) LOOK,ROOK
487
      ENDIF
488
      NX=LOOK(19)
489
      NY=LOOK(18)
490
      NUM_VALUES=NX*NY
491
C     WRITE OUT CONTENTS OF INFILE FOR INFORMATION
492
      WRITE(12,106) LOOK(33),LOOK(14),nf,
493
     &      NUM_VALUES,LOOK(42),LOOK(18),LOOK(19)
494
      IF(IFORM.EQ.1) THEN
495
        READ(8,13) (FIELD(I),I=1,NUM_VALUES)
496
      ELSE
497
      write(*,*) '1'
498
        READ(8) (FIELD(I),I=1,NUM_VALUES)
499
      ENDIF
500
      write(*,*) '2'
501
      LEVEL=LOOK(33)
502
      stash_code=LOOK(42)
503
c     Assign exact time of field from "Validity time"
504
      dyear=look(1)
505
      if(dyear.gt.1900) dyear=dyear-1900   ! wants only year as 9?
506
      dmonth=look(2)
507
      dday=look(3)
508
      dhour=look(4)
509
      dmins=look(5)
510
      LONG1=ROOK(61-45)
511
      if(LONG1 .lt. 0.0 ) then 
512
        LONG1=LONG1+360.0
513
      endif
514
      LAT1=ROOK(59-45)
515
      dxdeg=abs(ROOK(62-45))
516
      dydeg=abs(ROOK(60-45))
517
cwang      write(*,*)'dxdy',ROOK(62-45),ROOK(60-45)
518
cwang      write(*,*)'LONG1Lat1',ROOK(61-45),ROOK(59-45)
519
      fac=0.0
520
c     if(stash_code.eq.2.or.stash_code.eq.3.or.stash_code.eq.12201)
521
c    &      fac=0.5
522
C PAC Verified 
523
      long_nw=LONG1+dxdeg-fac*dxdeg
524
cwang      lat_nw=Lat1-dydeg+fac*dydeg
525
c     define limits of inner 2:nxmax-1 X 2:nymax-1 grid
526
      lonw=long_nw+dxdeg
527
      lone=lonw+float(nxmax-3)*dxdeg
528
cwang change statements to calculate latn and lats
529
cwang to next if loop so that it counts for dy for positive condition
530
      if (NewDyn .eq. .false.) then 
531
        lat_nw=Lat1-dydeg+fac*dydeg
532
        latn=lat_nw-dydeg
533
        lats=latn-float(nymax-3)*dydeg
534
      else
535
C PAC Verified
536
        lat_nw=Lat1+dydeg-fac*dydeg
537
        lats=lat_nw+dydeg
538
        latn=lats+float(nymax-3)*dydeg
539
      endif
540
      pole_lon=ROOK(57-45)
541
      pole_lat=ROOK(56-45)
542
      pres=100.0*rook(52-45)  ! in Pa
543
C-------------------------------------------------------------------
544
 12   FORMAT(12I10)
545
 13   FORMAT(10E12.5)
546
  106 FORMAT(' LEVEL=',I5,' FCST=',I6,' FIELD NO',I4,' NVALS='
547
     &    ,I5,' STASH CODE=',I5,' NO.ROWS=',I3,' NO.COLUMNS=',I3)
548
  100 FORMAT('  THE NUMBER OF FIELDS IN THE INPUT FILE IS   ',I8)
549
C-----------------------Process Data--------------------------------
550
C     Data WRITTEN STARTING AT N-W CORNER, FOLLOWING LOOPS
551
C     ASSIGN DATA FROM S-W CORNER AND THEN WRITE OUT
552
      if (NewDyn .eq. .false.) then 
553
        write(*,*)'data read starting at N-W'
554
        DO J=NY-1,0,-1 !LOOP SOUTH-NORTH (ROWS)
555
          I=J*NX       !FIELD RUNS OPPOSITE
556
          DO N=1,NX
557
            DATA(N,NY-J)=FIELD(N+I)
558
          END DO
559
        END DO
560
      else
561
C PAC Verified
562
         write(*,*)'data read dstarting at S-W'
563
        DO J=1,NY
564
          DO N=1,NX
565
            DATA(N,J)=FIELD((J-1)*NX+N)
566
          END DO
567
        END DO
568
      endif
569
C     CODE TO PREVENT UNDERFLOWS ON CONVERSION TO IEEE
570
      DO J = 1,NY
571
        DO I = 1,NX
572
           IF(ABS(DATA(I,J)).LT.1.0E-30.AND.DATA(I,J).NE.0.0) THEN
573
c            WRITE(6,*) 'UNDERFLOW AT: ',I,J,DATA(I,J)
574
             DATA(I,J) = 0.0
575
           ENDIF
576
        END DO
577
      END DO
578
      iend=0
579
      return
580
 99   continue
581
      iend=1
582
      write(*,*) 'End of file reached'
583
      return
584
      END
585
      subroutine modlevs(aklev,bklev,aklay,bklay,plevs,nlevmax,pm,pd)
586
C------------------------------------------------------------------------
587
C
588
C     Defines the level- and layer-arrays given the number of levels nlev.
589
C
590
C     nlev    int    input  number of levels/layers
591
C     aklev   real   output array contains ak values for levels
592
C     bklev     real    output  array contains bk values for levels
593
C     aklay     real    output  array contains ak values for layers
594
C     bklay     real    output  array contains bk values for layers
595
C------------------------------------------------------------------------
596
 
597
      integer   nlev,k
598
 
599
      real      aklev(nlevmax),bklev(nlevmax),    ! level coefficients
600
     &          aklay(nlevmax),bklay(nlevmax)     ! layer coefficients
601
     &         ,plevs(nlevmax)
602
 
603
      do k=1,nlevmax
604
        aklay(k)=0.0
605
        bklay(k)=0.0
606
c       aklev(k)=plevs(k)/100.0    ! P needed in hPa
607
        aklev(k)=(pm-(k-1)*pd)    ! P needed in hPa
608
        bklev(k)=0.0
609
      enddo
610
      return
611
      end