Subversion Repositories lagranto.icon

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 michaesp 1
      PROGRAM extract
2
 
3
c     ***********************************************************************
4
c     * Extract columns of a trajectory file                                *
5
c     * Michael Sprenger / Spring, summer 2010                              *
6
c     ***********************************************************************
7
 
8
      implicit none
9
 
10
c     ----------------------------------------------------------------------
11
c     Declaration of parameters
12
c     ----------------------------------------------------------------------
13
 
14
c     Numerical epsilon
15
      real      eps
16
      parameter (eps=0.0001)
17
 
18
c     ----------------------------------------------------------------------
19
c     Declaration of variables
20
c     ----------------------------------------------------------------------
21
 
22
c     Extraction mode
23
      character*80                           mode                             
24
 
25
c     Input and output format for trajectories (see iotra.f)
26
      character*80                           inpfile       ! Input filename
27
      character*80                           outfile       ! Output filename
28
 
29
c     Trajectories
30
      integer                                ntra_inp      ! Number of trajectories
31
      integer                                ntim_inp      ! Number of times
32
      integer                                ncol_inp      ! Number of columns
33
      real,allocatable, dimension (:,:,:) :: tra_inp       ! Trajectories (ntra,ntim,ncol)
34
      character*80                           vars_inp(100) ! Variable names
35
 
36
      integer                                ntra_out      ! Number of trajectories
37
      integer                                ntim_out      ! Number of times
38
      integer                                ncol_out      ! Number of columns
39
      real,allocatable, dimension (:,:,:) :: tra_out       ! Trajectories (ntra,ntim,ncol)
40
      integer,allocatable, dimension (:)  :: ind           ! Index for selection
41
      integer,allocatable, dimension (:)  :: isok          ! Index for selection
42
      character*80                           vars_out(100) ! Variable names
43
 
44
      real                                   time_inp(5000) ! Times of input trajectory
45
      real                                   time_out(5000) ! Times of output trajectory
46
      integer                                refdate(6)    ! Reference date
47
      integer                                ind_time(500) ! Index for time selection
48
 
49
c     Auxiliary variables
50
      integer                                inpmode
51
      integer                                outmode
52
      integer                                stat
53
      integer                                fid
54
      integer                                i,j,k,n,j0,j1
55
      character*80                           str
56
      character*80                           split_str(100)
57
      integer                                split_n
58
      integer                                isstr,nvars,ileft,iright
59
      character*80                           vars(100)
60
      character                              ch
61
      real                                   tmp0,tmp1
62
      integer                                ind1
63
      character*2000                         linestr
64
      integer                                istr(100)
65
      integer                                nstr
66
      character*80                           strsplit(100)
67
      integer                                flag
68
 
69
c     ----------------------------------------------------------------------
70
c     Read and handle parameters
71
c     ----------------------------------------------------------------------
72
 
73
c     Read parameters
74
      open(10,file='extract.param')
75
       read(10,*) inpfile
76
       read(10,*) outfile
77
       read(10,*) mode
78
       read(10,*) ntra_inp,ntim_inp,ncol_inp
79
       read(10,*) str
80
      close(10)
81
 
82
c     Split the input string
83
      isstr   = 0
84
      split_n = 0
85
      do i=1,80
86
         ch = str(i:i)
87
         if ( (isstr.eq.0).and.(ch.ne.' ') ) then
88
            isstr=1
89
            ileft=i
90
         elseif ( (isstr.eq.1).and.(ch.eq.' ') ) then
91
            isstr              = 0
92
            iright             = i-1
93
            split_n            = split_n+1
94
            split_str(split_n) = str(ileft:iright)
95
         endif
96
      enddo
97
 
98
c     Determine the formats
99
      call mode_tra(inpmode,inpfile)
100
      if (inpmode.eq.-1) inpmode=1
101
      call mode_tra(outmode,outfile)
102
      if ( (mode.ne.'-startf').and.(outmode.eq.-1) ) then
103
         outmode=1
104
      endif
105
 
106
c     ----------------------------------------------------------------------
107
c     Read input trajectories
108
c     ----------------------------------------------------------------------
109
 
110
c     Allocate memory
111
      allocate(tra_inp(ntra_inp,ntim_inp,ncol_inp),stat=stat)
112
      if (stat.ne.0) print*,'*** error allocating array tra_inp    ***' 
113
      allocate(ind(ntra_inp),stat=stat)
114
      if (stat.ne.0) print*,'*** error allocating array ind        ***' 
115
      allocate(isok(ntra_inp),stat=stat)
116
      if (stat.ne.0) print*,'*** error allocating array isok       ***'
117
 
118
 
119
c     Read inpufile
120
      fid = 10
121
      call ropen_tra(fid,inpfile,ntra_inp,ntim_inp,ncol_inp,
122
     >               refdate,vars_inp,inpmode)
123
      call read_tra (fid,tra_inp,ntra_inp,ntim_inp,ncol_inp,inpmode)
124
      call close_tra(fid,inpmode)
125
 
126
c     Check format 
127
      if (  vars_inp(1).ne.'time') goto 990
128
      if ( (vars_inp(2).ne.'lon').and.(vars_inp(2).ne.'xpos') ) goto 990
129
      if ( (vars_inp(3).ne.'lat').and.(vars_inp(3).ne.'ypos') ) goto 990
130
      if ( (vars_inp(4).ne.'z'  ).and.(vars_inp(4).ne.'ppos') ) goto 990
131
 
132
c     ----------------------------------------------------------------------
133
c     Option -vars : Extract columns of variables
134
c     ----------------------------------------------------------------------
135
 
136
      if ( mode.ne.'-var' ) goto 100
137
 
138
c     Set the first for columns of the output
139
      ncol_out   = 4
140
      vars_out(1)='time'
141
      vars_out(2)='lon'
142
      vars_out(3)='lat'
143
      vars_out(4)='p'
144
      ind(1)     =1
145
      ind(2)     =2
146
      ind(3)     =3
147
      ind(4)     =4
148
 
149
c     Get final list of extraction columns (set number of columns)
150
      do i=1,split_n
151
 
152
         if (split_str(i).eq.'to') then
153
            do j=1,ncol_inp
154
               if ( vars_inp(j).eq.split_str(i-1) ) j0 = j + 1
155
            enddo
156
            do j=1,ncol_inp
157
               if ( vars_inp(j).eq.split_str(i+1) ) j1 = j - 1
158
            enddo
159
            do j=j0,j1
160
               ncol_out           = ncol_out + 1
161
               vars_out(ncol_out) = vars_inp(j)
162
            enddo
163
         else
164
            ncol_out           = ncol_out + 1
165
            vars_out(ncol_out) = split_str(i)
166
         endif
167
 
168
      enddo
169
 
170
c     Set the dimensions of the output trajectory
171
      ntra_out = ntra_inp
172
      ntim_out = ntim_inp
173
 
174
c     Allocate memory for output trajectory
175
      allocate(tra_out(ntra_out,ntim_out,ncol_out),stat=stat)
176
      if (stat.ne.0) print*,'*** error allocating array tra_out    ***' 
177
 
178
c     Extract <time,lon,lat,p> columns
179
      do i=1,ntra_out
180
         do j=1,ntim_out
181
            tra_out(i,j,1) = tra_inp(i,j,1)
182
            tra_out(i,j,2) = tra_inp(i,j,2)
183
            tra_out(i,j,3) = tra_inp(i,j,3)
184
            tra_out(i,j,4) = tra_inp(i,j,4)
185
         enddo
186
      enddo
187
 
188
c     Get indices for new columns (1..4 are already ok)
189
      do i=5,ncol_out
190
         ind(i)=0
191
      enddo
192
      do i=5,ncol_out
193
         do j=1,ncol_inp
194
            if ( vars_inp(j).eq.vars_out(i) ) ind(i) = j
195
         enddo
196
      enddo
197
 
198
c     Check if all selected columns are available
199
      do i=1,ncol_out
200
         if ( ind(i).eq.0 ) then
201
            print*,'Invalid column in ',trim(str)
202
            stop
203
         endif
204
      enddo
205
 
206
c     Extract the column
207
      do i=1,ntra_out
208
         do j=1,ntim_out
209
            do k=1,ncol_out
210
               tra_out(i,j,k) = tra_inp(i,j,ind(k))
211
            enddo
212
         enddo
213
      enddo
214
 
215
 100  continue
216
 
217
c     ----------------------------------------------------------------------
218
c     Option -times : Extract times of trajectories
219
c     ----------------------------------------------------------------------
220
 
221
      if ( mode.ne.'-time' ) goto 110
222
 
223
c     Set the dimension of the output trajectory
224
      ntim_out = 0
225
 
226
c     Get the list of times for the input trajectory
227
      do i=1,ntim_inp
228
         time_inp(i) = tra_inp(1,i,1)
229
      enddo
230
 
231
c     Get final list of extraction times (set number of times)
232
      do i=1,split_n
233
 
234
         if (split_str(i).eq.'to') then
235
            read(split_str(i-1),*) tmp0
236
            do j=1,ntim_inp
237
               if ( time_inp(j).eq.tmp0 ) j0 = j + 1
238
            enddo
239
            read(split_str(i+1),*) tmp0
240
            do j=1,ntim_inp
241
               if ( time_inp(j).eq.tmp0 ) j1 = j - 1
242
            enddo
243
            do j=j0,j1
244
               ntim_out           = ntim_out + 1
245
               time_out(ntim_out) = time_inp(j)
246
            enddo
247
         elseif (split_str(i).eq.'first') then
248
            ntim_out           = ntim_out + 1
249
            time_out(ntim_out) = time_inp(1)
250
         elseif (split_str(i).eq.'last') then
251
            ntim_out           = ntim_out + 1
252
            time_out(ntim_out) = time_inp(ntim_inp)
253
         else
254
            ntim_out           = ntim_out + 1
255
            read(split_str(i),*) tmp0
256
            time_out(ntim_out) = tmp0
257
         endif
258
 
259
      enddo
260
 
261
c     Get the indices of the selected times
262
      do i=1,ntim_out
263
         ind_time(i) = 0
264
      enddo
265
      do i=1,ntim_out
266
         do j=1,ntim_inp
267
            if ( abs(time_out(i)-time_inp(j)).lt.eps) ind_time(i) = j
268
         enddo
269
      enddo
270
      do i=1,ntim_out
271
         if ( ind_time(i).eq.0) then
272
            print*,' Invalid time ',time_out(i)
273
            stop
274
         endif
275
      enddo
276
 
277
c     Set dimensions of output trajectory
278
      ntra_out = ntra_inp
279
      ncol_out = ncol_inp
280
 
281
c     Allocate memory for output trajectory
282
      allocate(tra_out(ntra_out,ntim_out,ncol_out),stat=stat)
283
      if (stat.ne.0) print*,'*** error allocating array tra_out    ***' 
284
 
285
c     Copy the selected times to the output trajectory
286
      do i=1,ntra_out
287
         do j=1,ntim_out
288
            do k=1,ncol_out
289
               tra_out(i,j,k) = tra_inp(i,ind_time(j),k)
290
            enddo
291
         enddo
292
      enddo
293
 
294
c     Copy meta information
295
      do i=1,ncol_out
296
         vars_out(i) = vars_inp(i)
297
      enddo
298
 
299
 110  continue
300
 
301
c     ----------------------------------------------------------------------
302
c     Option -tra : Extract trajectories by number
303
c     ----------------------------------------------------------------------
304
 
305
      if ( mode.ne.'-tra' ) goto 120
306
 
307
c     Set the dimension of the output trajectory
308
      ntra_out = 0
309
 
310
c     Get final list of extraction times (set number of times)
311
      do i=1,split_n
312
 
313
         if (split_str(i).eq.'to') then
314
            read(split_str(i-1),*) tmp0
315
            read(split_str(i+1),*) tmp1
316
            do j=nint(tmp0)+1,nint(tmp1)-1
317
               ntra_out        = ntra_out + 1
318
               ind(ntra_out)   = j   
319
            enddo
320
         elseif (split_str(i).eq.'first') then
321
            ntra_out           = ntra_out + 1
322
            ind(ntra_out)      = 1
323
         elseif (split_str(i).eq.'last') then
324
            ntra_out           = ntra_out + 1
325
            ind(ntra_out)      = ntra_inp
326
         else
327
            ntra_out           = ntra_out + 1
328
            read(split_str(i),*) tmp0
329
            ind(ntra_out)      = nint(tmp0) 
330
         endif
331
 
332
      enddo
333
 
334
c     Check whether selected trajectories are ok
335
      do i=1,ntra_out
336
         if ( (ind(i).lt.1).or.(ind(i).gt.ntra_inp) ) then
337
            print*,'Invalid trajectory selected ',ind(i)
338
            stop
339
         endif
340
      enddo
341
 
342
c     Set dimensions of output trajectory
343
      ntim_out = ntim_inp
344
      ncol_out = ncol_inp
345
 
346
c     Allocate memory for output trajectory
347
      allocate(tra_out(ntra_out,ntim_out,ncol_out),stat=stat)
348
      if (stat.ne.0) print*,'*** error allocating array tra_out    ***' 
349
 
350
c     Copy the selected times to the output trajectory
351
      do i=1,ntra_out
352
         do j=1,ntim_out
353
            do k=1,ncol_out
354
               tra_out(i,j,k) = tra_inp(ind(i),j,k)
355
            enddo
356
         enddo
357
      enddo
358
 
359
c     Copy meta information
360
      do i=1,ncol_out
361
         vars_out(i) = vars_inp(i)
362
      enddo
363
 
364
 120  continue
365
 
366
c     ----------------------------------------------------------------------
367
c     Option -startf : Extract starting positions for the trajectory file
368
c     ----------------------------------------------------------------------
369
 
370
      if ( mode.ne.'-startf' ) goto 130
371
 
372
c     Set the first for columns of the output
373
      ncol_out   = 4
374
      vars_out(1)='time'
375
      vars_out(2)='lon'
376
      vars_out(3)='lat'
377
      vars_out(4)='p'
378
      ind(1)     =1
379
      ind(2)     =2
380
      ind(3)     =3
381
      ind(4)     =4
382
 
383
c     Set dimensions of output trajectory
384
      ntim_out = 1
385
      ntra_out = ntra_inp
386
 
387
c     Allocate memory for output trajectory
388
      allocate(tra_out(ntra_out,ntim_out,ncol_out),stat=stat)
389
      if (stat.ne.0) print*,'*** error allocating array tra_out    ***' 
390
 
391
c     Copy the selected times to the output trajectory
392
      do i=1,ntra_out
393
         do k=1,ncol_out
394
            tra_out(i,1,k) = tra_inp(i,1,k)
395
         enddo
396
      enddo
397
 
398
c     Copy meta information
399
      do i=1,ncol_out
400
         vars_out(i) = vars_inp(i)
401
      enddo
402
 
403
 130  continue
404
 
405
c     ----------------------------------------------------------------------
406
c     Option -index : Extract trajectories by index file
407
c     ----------------------------------------------------------------------
408
 
409
      if ( mode.ne.'-index' ) goto 140
410
 
411
c     Read the index file
412
      open(10,file=str)
413
 
414
        ntra_out = 1
415
 142    read(10,*,end=141) ind(ntra_out)
416
        ntra_out = ntra_out + 1
417
        goto 142 
418
 141    continue
419
        ntra_out = ntra_out - 1
420
 
421
      close(10)
422
 
423
c     Check whether selected trajectories are ok
424
      do i=1,ntra_out
425
         if ( (ind(i).lt.1).or.(ind(i).gt.ntra_inp) ) then
426
            print*,'Invalid trajectory selected ',ind(i)
427
            stop
428
         endif
429
      enddo
430
 
431
c     Set dimensions of output trajectory
432
      ntim_out = ntim_inp
433
      ncol_out = ncol_inp
434
 
435
c     Allocate memory for output trajectory
436
      allocate(tra_out(ntra_out,ntim_out,ncol_out),stat=stat)
437
      if (stat.ne.0) print*,'*** error allocating array tra_out    ***' 
438
 
439
c     Copy the selected times to the output trajectory
440
      do i=1,ntra_out
441
         do j=1,ntim_out
442
            do k=1,ncol_out
443
               tra_out(i,j,k) = tra_inp(ind(i),j,k)
444
            enddo
445
         enddo
446
      enddo
447
 
448
c     Copy meta information
449
      do i=1,ncol_out
450
         vars_out(i) = vars_inp(i)
451
      enddo
452
 
453
 140  continue
454
 
455
c     ----------------------------------------------------------------------
456
c     Option -boolean : Extract trajectories by boolean file
457
c     ----------------------------------------------------------------------
458
 
459
      if ( mode.ne.'-boolean' ) goto 150
460
 
461
c     Read the index file
462
      open(10,file=str)
463
        ntra_out = 0
464
        do i=1,ntra_inp
465
           read(10,*) ind1
466
           if ( ind1.eq.1 ) then
467
              ntra_out      = ntra_out + 1
468
              ind(ntra_out) = i
469
           endif
470
        enddo
471
      close(10)
472
 
473
c     Check whether selected trajectories are ok
474
      do i=1,ntra_out
475
         if ( (ind(i).lt.1).or.(ind(i).gt.ntra_inp) ) then
476
            print*,'Invalid trajectory selected ',ind(i)
477
            stop
478
         endif
479
      enddo
480
 
481
c     Set dimensions of output trajectory
482
      ntim_out = ntim_inp
483
      ncol_out = ncol_inp
484
 
485
c     Allocate memory for output trajectory
486
      allocate(tra_out(ntra_out,ntim_out,ncol_out),stat=stat)
487
      if (stat.ne.0) print*,'*** error allocating array tra_out    ***' 
488
 
489
c     Copy the selected times to the output trajectory
490
      do i=1,ntra_out
491
         do j=1,ntim_out
492
            do k=1,ncol_out
493
               tra_out(i,j,k) = tra_inp(ind(i),j,k)
494
            enddo
495
         enddo
496
      enddo
497
 
498
c     Copy meta information
499
      do i=1,ncol_out
500
         vars_out(i) = vars_inp(i)
501
      enddo
502
 
503
 150  continue
504
 
505
c     ----------------------------------------------------------------------
506
c     Option -pattern : Extract trajectories which match a regular expression
507
c     ----------------------------------------------------------------------
508
 
509
      if ( mode.ne.'-pattern' ) goto 160
510
 
511
c     All times and columns are extracted
512
      ncol_out = ncol_inp
513
      ntim_out = ntim_inp
514
      ntra_out = 0
515
 
516
c     Split the search string
517
      nstr   = 0
518
      ileft  = 0
519
      iright = 0
520
      do i=1,len_trim(str)
521
        if ( (str(i:i).eq.' ').and.(ileft.eq.0) ) then
522
           ileft = ileft + 1
523
        elseif ( (str(i:i).ne.' ').and.(ileft.eq.0) ) then
524
           ileft  = i
525
           iright = 0
526
        elseif ( (str(i:i).ne.' ').and.(ileft.ne.0) ) then
527
           iright = i
528
        elseif ( (str(i:i).eq.' ').and.(ileft.ne.0) ) then
529
           nstr           = nstr + 1
530
           strsplit(nstr) = str(ileft:iright)
531
           ileft          = 0
532
           iright         = 0
533
        endif
534
      enddo
535
      if ( (ileft.ne.0).and.(iright.ne.0) ) then
536
           nstr           = nstr + 1
537
           strsplit(nstr) = str(ileft:iright)
538
           ileft          = 0
539
      endif
540
 
541
c     Loop over the trajectories - check for matching pattern
542
      do n=1,ntra_inp
543
 
544
        ind(n) = 0
545
        do i=1,ntim_inp
546
 
547
           write(linestr,'(1f7.2,f9.2,f8.2,i6,100f10.3)')
548
     >                   (tra_inp(n,i,j),j=1,3),             ! time, lon, lat
549
     >                   nint(tra_inp(n,i,4)),               ! p
550
     >                   (tra_inp(n,i,j),j=5,ncol_inp)       ! fields
551
 
552
           flag = 1
553
           do k=1,nstr
554
             istr(k) = index(trim(linestr),trim(strsplit(k)))
555
             if ( istr(k).eq.0 ) flag = 0
556
           enddo
557
           if ( flag.eq.1 ) ind(n) = 1
558
 
559
        enddo
560
        if ( ind(n).eq.1 ) ntra_out = ntra_out + 1
561
 
562
      enddo
563
 
564
c     Allocate memory for output trajectory
565
      allocate(tra_out(ntra_out,ntim_out,ncol_out),stat=stat)
566
      if (stat.ne.0) print*,'*** error allocating array tra_out    ***'
567
 
568
c     Copy the selected times to the output trajectory
569
      ntra_out = 0
570
      do i=1,ntra_inp
571
        if (ind(i).eq.1) then
572
            ntra_out = ntra_out + 1
573
            do j=1,ntim_out
574
                do k=1,ncol_out
575
                    tra_out(ntra_out,j,k) = tra_inp(i,j,k)
576
                enddo
577
            enddo
578
         endif
579
      enddo
580
 
581
c     Copy meta information
582
      do i=1,ncol_out
583
         vars_out(i) = vars_inp(i)
584
      enddo
585
 
586
 160  continue
587
 
588
c     ----------------------------------------------------------------------
589
c     Option -leaving : Extract all trajectories which leave domain
590
c     ----------------------------------------------------------------------
591
 
592
      if ( mode.ne.'-leaving' ) goto 170
593
 
594
c     Set dimensions of output trajectory
595
      ntim_out = ntim_inp
596
      ncol_out = ncol_inp
597
 
598
c     Copy the meta data
599
      do i=1,ncol_out
600
         vars_out(i) = vars_inp(i)
601
      enddo
602
 
603
c     Determine the number of trajectories leaving domain
604
      do i=1,ntra_inp
605
         isok(i) = 1
606
         do j=1,ntim_inp
607
            if ( tra_inp(i,j,4).lt.0. ) isok(i) = 0
608
         enddo
609
         if ( isok(i).eq.0 ) then
610
            ntra_out = ntra_out + 1
611
         endif
612
      enddo
613
 
614
c     Allocate memory for output trajectory
615
      allocate(tra_out(ntra_out,ntim_out,ncol_out),stat=stat)
616
      if (stat.ne.0) print*,'*** error allocating array tra_out    ***'
617
 
618
c     Copy the selected trajectories to the output trajectory
619
      ntra_out = 0
620
      do i=1,ntra_inp
621
         if ( isok(i).eq.0 ) then
622
            ntra_out = ntra_out + 1
623
            do j=1,ntim_inp
624
               do k=1,ncol_out
625
                  tra_out(ntra_out,j,k) = tra_inp(i,j,k)
626
               enddo
627
            enddo
628
         endif
629
      enddo
630
 
631
c     Copy meta information
632
 
633
 170  continue
634
 
635
c     ----------------------------------------------------------------------
636
c     Option -staying : Extract all trajectories which stay in domain
637
c     ----------------------------------------------------------------------
638
 
639
      if ( mode.ne.'-staying' ) goto 180
640
 
641
c     Set dimensions of output trajectory
642
      ntim_out = ntim_inp
643
      ncol_out = ncol_inp
644
 
645
c     Copy the meta data
646
      do i=1,ncol_out
647
         vars_out(i) = vars_inp(i)
648
      enddo
649
 
650
c     Determine the number of trajectories staying in domain
651
      do i=1,ntra_inp
652
         isok(i) = 1
653
         do j=1,ntim_inp
654
            if ( tra_inp(i,j,4).lt.0. ) isok(i) = 0
655
         enddo
656
         if ( isok(i).eq.1 ) then
657
            ntra_out = ntra_out + 1
658
         endif
659
      enddo
660
 
661
c     Allocate memory for output trajectory
662
      allocate(tra_out(ntra_out,ntim_out,ncol_out),stat=stat)
663
      if (stat.ne.0) print*,'*** error allocating array tra_out    ***'
664
 
665
c     Copy the selected trajectories to the output trajectory
666
      ntra_out = 0
667
      do i=1,ntra_inp
668
         if ( isok(i).eq.1 ) then
669
            ntra_out = ntra_out + 1
670
            do j=1,ntim_inp
671
               do k=1,ncol_out
672
                  tra_out(ntra_out,j,k) = tra_inp(i,j,k)
673
               enddo
674
            enddo
675
         endif
676
      enddo
677
 
678
c     Copy meta information
679
 
680
 180  continue
681
 
682
 
683
c     ----------------------------------------------------------------------
684
c     Write output trajectories
685
c     ----------------------------------------------------------------------
686
 
687
c     Write output as trajectory file
688
      if (outmode.ge.1) then
689
 
690
         call wopen_tra(fid,outfile,ntra_out,ntim_out,ncol_out,
691
     >                  refdate,vars_out,outmode)
692
         call write_tra(fid,tra_out,ntra_out,ntim_out,ncol_out,outmode)
693
         call close_tra(fid,outmode)
694
 
695
c     Write output as (lon, lat, p)-list
696
      else
697
 
698
         open(10,file=outfile)
699
         do i=1,ntra_out
700
            write(10,'(3f10.2)') tra_out(i,1,2),    ! lon
701
     >                           tra_out(i,1,3),    ! lat
702
     >                           tra_out(i,1,4)     ! p
703
         enddo
704
         close(10)
705
 
706
      endif
707
 
708
c     ----------------------------------------------------------------------
709
c     Error handling
710
c     ----------------------------------------------------------------------
711
 
712
      stop
713
 
714
 990  print*,'First columns must be <time,lon,lat,p>... Stop'
715
      stop
716
 
717
 
718
      end
719
 
720
 
721
 
722