Subversion Repositories lagranto.ecmwf

Rev

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

Rev 15 Rev 39
Line 4... Line 4...
4
c     * identifier <fid>. Different modes <mode> are supported:      *
4
c     * identifier <fid>. Different modes <mode> are supported:      *
5
c     *     mode=1: ascii, sorted by trajectory;                     *
5
c     *     mode=1: ascii, sorted by trajectory;                     *
6
c     *     mode=2: ascii, sorted by time;                           *
6
c     *     mode=2: ascii, sorted by time;                           *
7
c     *     mode=3: fortran (unformatted)                            * 
7
c     *     mode=3: fortran (unformatted)                            * 
8
c     *     mode=4: IVE netcdf (for compatibiltzy reasons)           *
8
c     *     mode=4: IVE netcdf (for compatibiltzy reasons)           *
-
 
9
c     *     mode=5: KML                                              *
-
 
10
c     *     mode=6: as mode 1, but with pressure as realk number     *
9
c     * A trajectory set is given as 3d array <tra(ntra,ntim,ncol)>  *
11
c     * A trajectory set is given as 3d array <tra(ntra,ntim,ncol)>  *
10
c     * where <ntra> is the number of trajectories, <ntim> the       *
12
c     * where <ntra> is the number of trajectories, <ntim> the       *
11
c     * number of times of each trajectory and <ncol> the number of  *
13
c     * number of times of each trajectory and <ncol> the number of  *
12
c     * columns of the trajectory. The first 4 columns are: time,    *
14
c     * columns of the trajectory. The first 4 columns are: time,    *
13
c     * longitude, latitude, pressure. The other columns are traced  *
15
c     * longitude, latitude, pressure. The other columns are traced  *
Line 56... Line 58...
56
      elseif (mode.eq.4) then
58
      elseif (mode.eq.4) then
57
         call cdfopn(filename,fid,ierr)
59
         call cdfopn(filename,fid,ierr)
58
      elseif (mode.eq.5) then
60
      elseif (mode.eq.5) then
59
         print*,' ERROR: Reading KML not supported'
61
         print*,' ERROR: Reading KML not supported'
60
         stop
62
         stop
-
 
63
      elseif (mode.eq.6) then
-
 
64
         fid = 10
-
 
65
         open(fid,file=filename)   
61
      endif
66
      endif
62
 
67
 
63
c     Read header information
68
c     Read header information
64
      call read_hea(fid,time,vars,ntra,ntim,ncol,mode)
69
      call read_hea(fid,time,vars,ntra,ntim,ncol,mode)
65
 
70
 
Line 110... Line 115...
110
         mdv      =-999.98999
115
         mdv      =-999.98999
111
         call crecdf(filename,fid,varmin,varmax,3,cfn,ierr)
116
         call crecdf(filename,fid,varmin,varmax,3,cfn,ierr)
112
      elseif (mode.eq.5) then
117
      elseif (mode.eq.5) then
113
         fid = 10
118
         fid = 10
114
         open(fid,file=filename)
119
         open(fid,file=filename)
-
 
120
      elseif (mode.eq.6) then
-
 
121
         fid = 10
-
 
122
         open(fid,file=filename)
115
      endif
123
      endif
116
 
124
 
117
c     Write header information
125
c     Write header information
118
      call write_hea(fid,time,vars,ntra,ntim,ncol,mode)
126
      call write_hea(fid,time,vars,ntra,ntim,ncol,mode)
119
 
127
 
Line 183... Line 191...
183
                      tra(n,i,j)=arr(n)
191
                      tra(n,i,j)=arr(n)
184
                   enddo
192
                   enddo
185
                endif
193
                endif
186
            enddo
194
            enddo
187
         enddo
195
         enddo
-
 
196
         
-
 
197
c     Read ascii trajectory with pressure as real         
-
 
198
      elseif (mode.eq.6) then
-
 
199
         read(fid,*,end=100)
-
 
200
         do n=1,ntra
-
 
201
            do i=1,ntim
-
 
202
               read(fid,*,end=110) (tra(n,i,j),j=1,ncol)
-
 
203
            enddo
-
 
204
         enddo
188
 
205
 
189
      endif
206
      endif
190
 
207
 
191
      return
208
      return
192
 
209
 
Line 334... Line 351...
334
 
351
 
335
           write(fid,*) '</coordinates>'
352
           write(fid,*) '</coordinates>'
336
           write(fid,*) '</LineString>'
353
           write(fid,*) '</LineString>'
337
           write(fid,*) '</Placemark>'
354
           write(fid,*) '</Placemark>'
338
         enddo
355
         enddo
-
 
356
         
-
 
357
c     Write ASCII trajectory with pressure as real         
-
 
358
      elseif (mode.eq.6) then
-
 
359
         do n=1,ntra
-
 
360
            write(fid,*)
-
 
361
            do i=1,ntim
339
 
362
 
-
 
363
c              Avoid ugly *s or missing space in output
-
 
364
               do j=5,ncol
-
 
365
                  if ( abs(tra(n,i,j)).gt.9999.) then                     
-
 
366
                     print*,'Format problem : ',tra(n,i,j),' -> -999.99'
-
 
367
                     tra(n,i,j) = -999.99
-
 
368
                  endif
-
 
369
               enddo
-
 
370
 
-
 
371
               write(fid,'(1f7.2,f9.2,f8.2,f8.2,100f10.3)') 
-
 
372
     >               (tra(n,i,j),j=1,3),             ! time, lon, lat
-
 
373
     >               tra(n,i,4),                     ! p
-
 
374
     >               (tra(n,i,j),j=5,ncol)           ! fields
-
 
375
            enddo
-
 
376
         enddo
340
      endif
377
      endif
341
 
378
 
342
      end
379
      end
343
 
380
 
344
 
381
 
Line 372... Line 409...
372
      character*13  str3
409
      character*13  str3
373
      character*4   str4
410
      character*4   str4
374
      character*80  linestr
411
      character*80  linestr
375
      integer       itmp1,itmp2
412
      integer       itmp1,itmp2
376
 
413
 
377
c     Read ascii format (mode=1,2)
414
c     Read ascii format (mode=1,2,6)
378
      if ( (mode.eq.1).or.(mode.eq.2) ) then
415
      if ( (mode.eq.1).or.(mode.eq.2).or.(mode.eq.6) ) then
379
 
416
 
380
c        Read the time specification (old and new format)
417
c        Read the time specification (old and new format)
381
         read(fid,'(a80)') linestr
418
         read(fid,'(a80)') linestr
382
         
419
         
383
         if ( linestr(1:14).eq.'Reference date' ) then
420
         if ( linestr(1:14).eq.'Reference date' ) then
Line 556... Line 593...
556
      write(fid,"(A)") '</LineStyle>'
593
      write(fid,"(A)") '</LineStyle>'
557
      write(fid,"(A)") '<PolyStyle>'
594
      write(fid,"(A)") '<PolyStyle>'
558
      write(fid,"(A)") '<color>7f00ff00</color>'
595
      write(fid,"(A)") '<color>7f00ff00</color>'
559
      write(fid,"(A)") '</PolyStyle>'
596
      write(fid,"(A)") '</PolyStyle>'
560
      write(fid,"(A)") '</Style>'
597
      write(fid,"(A)") '</Style>'
-
 
598
      
-
 
599
c     Write header for ASCII mode iwth real pressure      
-
 
600
      elseif ( mode.eq.6 ) then
-
 
601
 
-
 
602
c        Get the strings for output
-
 
603
         write(str1,'(i4)') time(1)
-
 
604
         write(str2,'(i2)') time(2)
-
 
605
         write(str3,'(i2)') time(3)
-
 
606
         write(str4,'(i2)') time(4)
-
 
607
         write(str5,'(i2)') time(5)
-
 
608
         if (time(2).eq. 0) str2(1:1)='0'
-
 
609
         if (time(3).eq. 0) str3(1:1)='0'
-
 
610
         if (time(4).eq. 0) str4(1:1)='0'
-
 
611
         if (time(5).eq. 0) str5(1:1)='0'
-
 
612
         if (time(2).lt.10) str2(1:1)='0'
-
 
613
         if (time(3).lt.10) str3(1:1)='0'
-
 
614
         if (time(4).lt.10) str4(1:1)='0'
-
 
615
         if (time(5).lt.10) str5(1:1)='0'
-
 
616
 
-
 
617
c        Write the time specification
-
 
618
         write(fid,'(a15,a4,a2,a2,a1,a2,a2,a13,i8,a4)') 
-
 
619
     >          'Reference date ',
-
 
620
     >           str1,str2,str3,'_',str4,str5,
-
 
621
     >          ' / Time range',time(6), ' min'
-
 
622
         write(fid,*)
-
 
623
 
-
 
624
c        Write variable names
-
 
625
         str=''
-
 
626
         do i=1,ncol
-
 
627
            varname = vars(i)
-
 
628
            vars(i) = varname(1:9)
-
 
629
            str     = trim(str)//trim(vars(i))
-
 
630
         enddo
-
 
631
         write(fid,'(a6,a9,a8,a8,100a10)') (trim(vars(i)),i=1,ncol)
-
 
632
         write(fid,'(a6,a9,a8,a8,100a10)') 
-
 
633
     >              '------','---------','--------','--------',
-
 
634
     >              ('----------',i=5,ncol)
561
 
635
 
562
      endif
636
      endif
563
 
637
 
564
      end
638
      end
565
      
639
      
Line 594... Line 668...
594
 
668
 
595
      elseif (mode.eq.5) then
669
      elseif (mode.eq.5) then
596
          write(fid,"(A)") '</Document>'
670
          write(fid,"(A)") '</Document>'
597
          write(fid,"(A)") '</kml>'
671
          write(fid,"(A)") '</kml>'
598
         close(abs(fid))
672
         close(abs(fid))
-
 
673
         
-
 
674
      elseif (mode.eq.6) then
-
 
675
         close(abs(fid))
-
 
676
         
599
      endif
677
      endif
600
 
678
 
601
      end
679
      end
602
      
680
      
603
 
681
 
Line 629... Line 707...
629
      if ( (char0.eq.'.').and.(char1.eq.'1') ) mode=1
707
      if ( (char0.eq.'.').and.(char1.eq.'1') ) mode=1
630
      if ( (char0.eq.'.').and.(char1.eq.'2') ) mode=2
708
      if ( (char0.eq.'.').and.(char1.eq.'2') ) mode=2
631
      if ( (char0.eq.'.').and.(char1.eq.'3') ) mode=3
709
      if ( (char0.eq.'.').and.(char1.eq.'3') ) mode=3
632
      if ( (char0.eq.'.').and.(char1.eq.'4') ) mode=4
710
      if ( (char0.eq.'.').and.(char1.eq.'4') ) mode=4
633
      if ( (char0.eq.'.').and.(char1.eq.'5') ) mode=5
711
      if ( (char0.eq.'.').and.(char1.eq.'5') ) mode=5
-
 
712
      if ( (char0.eq.'.').and.(char1.eq.'6') ) mode=6
634
 
713
 
635
      if ( mode.gt.0 ) return
714
      if ( mode.gt.0 ) return
636
 
715
 
637
c     Mode specified by appendix
716
c     Mode specified by appendix
638
      char0 = filename((len-3):(len-3))
717
      char0 = filename((len-3):(len-3))
Line 646... Line 725...
646
 
725
 
647
      if ( (char0.eq.'.').and.(char1.eq.'k').and.
726
      if ( (char0.eq.'.').and.(char1.eq.'k').and.
648
     >                        (char2.eq.'m').and.
727
     >                        (char2.eq.'m').and.
649
     >                        (char3.eq.'l') ) mode = 5
728
     >                        (char3.eq.'l') ) mode = 5
650
 
729
 
-
 
730
      if ( (char1.eq.'.').and.(char2.eq.'r').and.(char3.eq.'p') ) mode=6
-
 
731
 
651
      end
732
      end
652
 
733
 
653
 
734
 
654
c     ----------------------------------------------------------------
735
c     ----------------------------------------------------------------
655
c     Get dimension of a trajectory file
736
c     Get dimension of a trajectory file
Line 692... Line 773...
692
      elseif (mode.eq.3) then
773
      elseif (mode.eq.3) then
693
         fid=10
774
         fid=10
694
         open(fid,file=filename,form='unformatted')
775
         open(fid,file=filename,form='unformatted')
695
      elseif (mode.eq.4) then
776
      elseif (mode.eq.4) then
696
         call cdfopn(filename,fid,ierr)
777
         call cdfopn(filename,fid,ierr)
-
 
778
      elseif (mode.eq.6) then
-
 
779
         fid=10
-
 
780
         open(fid,file=filename)
697
      endif
781
      endif
698
 
782
 
699
c     Get dimension information
783
c     Get dimension information
700
      if ( (mode.eq.1).or.(mode.eq.2) ) then
784
      if ( (mode.eq.1).or.(mode.eq.2).or.(mode.eq.6) ) then
701
         read(fid,*)
785
         read(fid,*)
702
         read(fid,*)
786
         read(fid,*)
703
         read(fid,'(a500)') str
787
         read(fid,'(a500)') str
704
         read(fid,*)
788
         read(fid,*)
705
 
789