File: readpoints.f

package info (click to toggle)
flextra 5.0-2.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 860 kB
  • ctags: 402
  • sloc: fortran: 6,987; makefile: 55; sh: 17
file content (183 lines) | stat: -rw-r--r-- 7,513 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
      subroutine readpoints(error)
***********************************************************************
*                                                                     * 
*             TRAJECTORY MODEL SUBROUTINE READPOINTS                  *
*                                                                     *
***********************************************************************
*                                                                     * 
*             AUTHOR:      G. WOTAWA                                  *
*             DATE:        1994-02-03                                 *
*             LAST UPDATE: 1996-06-21 A. Stohl                        *
*                                                                     * 
* Update: Vertical coordinate can now be given in meters above sea    * 
* level, meters above ground, and in hPa.                             * 
*                                                                     * 
*     10 January 1999  Update to facilitate free formatted input      *
*     (P. Seibert + A. Stohl)                                         *
*                                                                     * 
***********************************************************************
*                                                                     *
* DESCRIPTION:                                                        *
*                                                                     *
* READING OF TRAJECTORY STARTING/ENDING POINTS FROM DATA FILE         *
*                                                                     * 
* LINE                  a line of text                                * 
* NUMPOINT              number of trajectory starting/ending points   *
* XPOINT(maxpoint)      x-coordinates of starting/ending points       *
* YPOINT(maxpoint)      y-coordinates of starting/ending points       *
* ZPOINT(maxpoint)      z-coordinates of starting/ending points       *
* KINDZ(maxpoint)       kind of z coordinate (1:masl, 2:magl, 3:hPa)  *
* KIND(maxpoint)        kind of trajectory                            *
* COMPOINT(maxpoint)    comment for trajectory output                 *
*                                                                     *
***********************************************************************
*
      include 'includepar'
      include 'includecom'

      integer isum
      logical error,old
      integer kindhelp,kindzhelp
      real xhelp,yhelp,zhelp
      character*45 comhelp,line

      error=.false.
*
* OPENING OF FILE 'STARTPOINTS'
*

      open(unitpoin,file=path(1)(1:len(1))//'STARTPOINTS',
     &     status='old',err=999)

C Check the format of the STARTPOINTS file (either in free format,
C or using formatted mask)
C Use of formatted mask is assumed if line 28 contains the word '____'
**********************************************************************

      call skplin(27,unitpoin)
      read (unitpoin,901) line
901   format (a)
      if (index(line,'____') .eq. 0) then
        old = .false.
      else
        old = .true.
      endif
      rewind(unitpoin)

*
* READING OF STARTING/ENDING POINTS OF TRAJECTORIES
*
      call skplin(26,unitpoin)

10    continue
      isum=0
100   read(unitpoin,*,err=998,end=25) xhelp
      if (old) call skplin(2,unitpoin)
      read(unitpoin,*,err=998,end=25) yhelp
      if (old) call skplin(2,unitpoin)
      read(unitpoin,*,err=998,end=25) kindhelp
      if (old) call skplin(2,unitpoin)
      read(unitpoin,*,err=998,end=25) kindzhelp
      if (old) call skplin(2,unitpoin)
      read(unitpoin,*,err=998,end=25) zhelp
      if (old) call skplin(2,unitpoin)
      if (old) then
        read(unitpoin,'(a40)',err=998,end=25) comhelp(1:40)
      else
        read(unitpoin,*,err=998,end=25) comhelp(1:40)
      endif
      if (old) call skplin(1,unitpoin)
      call skplin(1,unitpoin)

      if((xhelp.eq.0.).and.(yhelp.eq.0.).and.
     &   (zhelp.eq.0.).and.(comhelp(1:8).eq.' '))
     &   goto 25


      if ((kindhelp.eq.3).and.(kindzhelp.ne.2)) then
        write(*,*) ' #### FLEXTRA MODEL ERROR! FOR MIXING LAYER   #### '
        write(*,*) ' #### TRAJECTORIES, THE Z COORDINATE MUST BE  #### '
        write(*,*) ' #### GIVEN IN METERS ABOVE GROUND.           #### '
        error=.true.
        return
      endif
  

      isum=isum+1
      if(isum.gt.maxpoint.or.isum*(numbunc+1).gt.maxpoint) then
         error=.true.
         write(*,*) '#### TRAJECTORY MODEL SUBROUTINE READPOINTS: '//
     &              '#### '
         write(*,*) '#### ERROR - TOO MANY STARTING POINTS        '//
     &              '#### '
         write(*,*) '#### REDUCE NUMBER OF STARTING POINTS OR     '//
     &              '#### '
         write(*,*) '#### CHANGE PARAMETERIZATION OF TRAJECTORY   '//
     &              '#### '
         write(*,*) '#### MODEL !!!                               '//
     &              '#### '
         goto 25
      endif
      xpoint(isum)=xhelp
      ypoint(isum)=yhelp
      kind(isum)=kindhelp
      kindz(isum)=kindzhelp
      zpoint(isum)=zhelp
C Conversion from hPa to Pa, if z coordinate is given in pressure units
      if (kindz(isum).eq.3) zpoint(isum)=zpoint(isum)*100. 
      compoint(isum)(1:40)=comhelp(1:40)
      goto 100
1     format(1x,a17,i6,a28)
25    close(unitpoin)
      numpoint=isum

      if ((numpoint*(numbunc+1)*(abs(lentra)/interv+1)).gt.maxtra) then
        write(*,*) ' #### TRAJECTORY MODEL ERROR! MODEL CAN NOT   #### ' 
        write(*,*) ' #### KEEP SO MANY TRAJECTORIES IN MEMORY.    #### '
        write(*,1) ' #### MAXIMUM:   ',maxtra,'                     ####
     + '
        write(*,1) ' #### CURRENTLY: ',numpoint*(numbunc+1)*(abs(lentra)
     +  /interv+1),'                      #### '
        write(*,*) ' #### YOU HAVE 3 POSSIBILITIES:               #### '
        write(*,*) ' #### 1) REDUCE NUMBER OF STARTING POINTS     #### '
        write(*,*) ' ####    (FILE "STARTPOINTS").                #### '
        write(*,*) ' #### 2) REDUCE THE LENGTH OF AN INDIVIDUAL   #### '
        write(*,*) ' ####    TRAJECTORY (FILE "COMMAND").         #### '
        write(*,*) ' #### 3) INCREASE THE TIME INTERVAL BETWEEN   #### '
        write(*,*) ' ####    TRAJECTORY STARTING TIMES (FILE      #### '
        write(*,*) ' ####    "COMMAND").                          #### '
        error=.true.
      endif


      return

998   error=.true.
         write(*,*) '#### TRAJECTORY MODEL SUBROUTINE READPOINTS: '//
     &              '#### '
         write(*,*) '#### FATAL ERROR - FILE "STARTPOINTS" IS     '//
     &              '#### '
         write(*,*) '#### CORRUPT. PLEASE CHECK YOUR INPUTS FOR   '//
     &              '#### '
         write(*,*) '#### MISTAKES OR GET A NEW "STARTPOINTS"-    '//
     &              '#### '
         write(*,*) '#### FILE ...                                '//
     &              '#### '
      return

999   error=.true.
      write(*,*)  
      write(*,*) ' ###########################################'//
     &           '###### '
      write(*,*) '    TRAJECTORY MODEL SUBROUTINE READPOINTS: '
      write(*,*)
      write(*,*) ' FATAL ERROR - FILE CONTAINING TRAJECTORY ST'//
     &           'ARTING '
      write(*,*) ' AND ENDING POINTS IS NOT AVAILABLE OR YOU A'//
     &           'RE NOT'
      write(*,*) ' PERMITTED FOR ANY ACCESS                   '
      write(*,*) ' ###########################################'//
     &           '###### '

      return
      end