31 logical,
intent(in) :: Lwrite
33 integer,
intent(in) :: model, inp, out
38 integer :: i, j, igrid, mc, nc, ng, status
40 integer,
dimension(Ngrids) :: ncount, nentry
42 integer,
allocatable :: Fcoor(:,:), Fcount(:,:), Ftype(:,:)
44 real(r8) :: xfloat, yfloat, zfloat
46 real(dp),
dimension(nRval) :: Rval
48 real(r8),
allocatable :: Ft0(:,:), Fx0(:,:), Fy0(:,:), Fz0(:,:)
49 real(r8),
allocatable :: Fdt(:,:), Fdx(:,:), Fdy(:,:), Fdz(:,:)
51 character (len=1 ),
parameter :: blank =
' '
53 character (len=35 ) :: frmt
54 character (len=40 ) :: KeyWord
55 character (len=256) :: fname, line
56 character (len=256),
dimension(nCval) :: Cval
58 character (len=*),
parameter :: MyFile = &
75 READ (inp,
'(a)',
err=20,
END=30) line
76 status=decode_line(line, keyword, nval, cval, rval)
78 SELECT CASE (trim(keyword))
80 npts=load_l(nval, cval, ngrids, lfloats)
82 npts=load_l(nval, cval, ngrids, fprint)
84 npts=load_i(nval, rval, ngrids, frrec)
89 fbionam=trim(adjustl(cval(nval)))
91 npts=load_i(nval, rval, ngrids, nfloats)
94 IF (ngrids.gt.1) npts=maxval(nfloats)+1
95 IF (.not.
allocated(fcoor))
THEN
96 allocate ( fcoor(npts,ngrids) )
97 dmem(1)=dmem(1)+real(npts*ngrids,r8)
99 IF (.not.
allocated(fcount))
THEN
100 allocate ( fcount(npts,ngrids) )
101 dmem(1)=dmem(1)+real(npts*ngrids,r8)
103 IF (.not.
allocated(ftype))
THEN
104 allocate ( ftype(npts,ngrids) )
105 dmem(1)=dmem(1)+real(npts*ngrids,r8)
107 IF (.not.
allocated(ft0))
THEN
108 allocate ( ft0(npts,ngrids) )
109 dmem(1)=dmem(1)+real(npts*ngrids,r8)
111 IF (.not.
allocated(fx0))
THEN
112 allocate ( fx0(npts,ngrids) )
113 dmem(1)=dmem(1)+real(npts*ngrids,r8)
115 IF (.not.
allocated(fy0))
THEN
116 allocate ( fy0(npts,ngrids) )
117 dmem(1)=dmem(1)+real(npts*ngrids,r8)
119 IF (.not.
allocated(fz0))
THEN
120 allocate ( fz0(npts,ngrids) )
121 dmem(1)=dmem(1)+real(npts*ngrids,r8)
123 IF (.not.
allocated(fdt))
THEN
124 allocate ( fdt(npts,ngrids) )
125 dmem(1)=dmem(1)+real(npts*ngrids,r8)
127 IF (.not.
allocated(fdx))
THEN
128 allocate ( fdx(npts,ngrids) )
129 dmem(1)=dmem(1)+real(npts*ngrids,r8)
131 IF (.not.
allocated(fdy))
THEN
132 allocate ( fdy(npts,ngrids) )
133 dmem(1)=dmem(1)+real(npts*ngrids,r8)
135 IF (.not.
allocated(fdz))
THEN
136 allocate ( fdz(npts,ngrids) )
137 dmem(1)=dmem(1)+real(npts*ngrids,r8)
139 CALL allocate_floats (.true.)
143 READ (inp,*,err=30,
END=30) igrid, &
144 & fcoor(nentry(igrid)+1,igrid), &
145 & ftype(nentry(igrid)+1,igrid), &
146 & fcount(nentry(igrid)+1,igrid), &
147 & ft0(nentry(igrid)+1,igrid), &
148 & fx0(nentry(igrid)+1,igrid), &
149 & fy0(nentry(igrid)+1,igrid), &
150 & fz0(nentry(igrid)+1,igrid), &
151 & fdt(nentry(igrid)+1,igrid), &
152 & fdx(nentry(igrid)+1,igrid), &
153 & fdy(nentry(igrid)+1,igrid), &
154 & fdz(nentry(igrid)+1,igrid)
155 IF (igrid.gt.ngrids)
THEN
156 IF (master)
WRITE (out,60) fposnam
160 ncount(igrid)=ncount(igrid)+ &
161 & fcount(nentry(igrid)+1,igrid)
162 nentry(igrid)=nentry(igrid)+1
167 20
IF (master)
WRITE (out,70) line
177 IF (.not.ldefflt(ng).and.lfloats(ng))
THEN
186 IF (master.and.lwrite)
THEN
188 IF (lfloats(ng).and.fprint(ng))
THEN
189 IF (ncount(ng).ne.nfloats(ng))
THEN
190 WRITE (stdout,80) ncount(ng), nfloats(ng)
196 IF (.not.spherical.and.(fcoor(i,ng).eq.0))
THEN
197 frmt=
'(i1,i2,i5,f10.4,2f8.2,f8.2,4f9.3)'
199 frmt=
'(i1,i2,i5,f10.4,3f8.2,4f9.3)'
201 WRITE (out,frmt) fcoor(i,ng), ftype(i,ng), fcount(i,ng), &
202 & ft0(i,ng), fx0(i,ng), fy0(i,ng), &
203 & fz0(i,ng), fdt(i,ng), fdx(i,ng), &
204 & fdy(i,ng), fdz(i,ng)
206 WRITE (out,100) nfloats(ng), &
208 &
'Number of float trajectories to compute.'
215 IF (.not.find_file(1, out, fname,
'FBIONAM'))
THEN
216 IF (founderror(exit_flag, noerror, __line__, myfile))
RETURN
218 IF (master.and.lwrite)
THEN
219 WRITE (out,120)
'biological floats behavior File: ', &
236 IF (lfloats(ng))
THEN
238 IF (fcount(i,ng).eq.1)
THEN
240 drifter(ng)%Tinfo(itstr,nc)=(dstart+ft0(i,ng))*day2sec
241 drifter(ng)%Tinfo(izgrd,nc)=fz0(i,ng)
242 drifter(ng)%Ftype(nc)=ftype(i,ng)
243 IF (fcoor(i,ng).eq.0)
THEN
244 drifter(ng)%Tinfo(ixgrd,nc)=fx0(i,ng)
245 drifter(ng)%Tinfo(iygrd,nc)=fy0(i,ng)
248 drifter(ng)%Flon(mc)=fx0(i,ng)
249 drifter(ng)%Flat(mc)=fy0(i,ng)
250 drifter(ng)%Findex(mc)=nc
252 ELSE IF (fcount(i,ng).gt.1)
THEN
255 IF (fdt(i,ng).gt.0.0_r8)
THEN
256 drifter(ng)%Tinfo(itstr,nc)=(dstart+ft0(i,ng)+ &
257 & real(j-1,r8)*fdt(i,ng))* &
259 drifter(ng)%Tinfo(izgrd,nc)=fz0(i,ng)
260 drifter(ng)%Ftype(nc)=ftype(i,ng)
261 IF (fcoor(i,ng).eq.0)
THEN
262 drifter(ng)%Tinfo(ixgrd,nc)=fx0(i,ng)
263 drifter(ng)%Tinfo(iygrd,nc)=fy0(i,ng)
266 drifter(ng)%Flon(mc)=fx0(i,ng)
267 drifter(ng)%Flat(mc)=fy0(i,ng)
268 drifter(ng)%Findex(mc)=nc
271 drifter(ng)%Tinfo(itstr,nc)=(dstart+ft0(i,ng))*day2sec
272 IF (fdz(i,ng).eq.0.0_r8)
THEN
273 drifter(ng)%Tinfo(izgrd,nc)=fz0(i,ng)
275 IF (fz0(i,ng).gt.0.0_r8)
THEN
276 zfloat=fz0(i,ng)+real(j-1,r8)*fdz(i,ng)
277 drifter(ng)%Tinfo(izgrd,nc)=min(max(0.0_r8, &
281 drifter(ng)%Tinfo(izgrd,nc)=fz0(i,ng)+ &
282 & real(j-1,r8)*fdz(i,ng)
285 drifter(ng)%Ftype(nc)=ftype(i,ng)
286 IF (fcoor(i,ng).eq.0)
THEN
287 xfloat=fx0(i,ng)+real(j-1,r8)*fdx(i,ng)
288 yfloat=fy0(i,ng)+real(j-1,r8)*fdy(i,ng)
289 drifter(ng)%Tinfo(ixgrd,nc)=xfloat
290 drifter(ng)%Tinfo(iygrd,nc)=yfloat
293 drifter(ng)%Flon(mc)=fx0(i,ng)+ &
294 & real(j-1,r8)*fdx(i,ng)
295 drifter(ng)%Flat(mc)=fy0(i,ng)+ &
296 & real(j-1,r8)*fdy(i,ng)
297 drifter(ng)%Findex(mc)=nc
303 drifter(ng)%Findex(0)=mc
309 IF (
allocated(fcoor))
deallocate ( fcoor )
310 IF (
allocated(fcount))
deallocate ( fcount )
311 IF (
allocated(ftype))
deallocate ( ftype )
312 IF (
allocated(ft0))
deallocate ( ft0 )
313 IF (
allocated(fx0))
deallocate ( fx0 )
314 IF (
allocated(fy0))
deallocate ( fy0 )
315 IF (
allocated(fz0))
deallocate ( fz0 )
316 IF (
allocated(fdt))
deallocate ( fdt )
317 IF (
allocated(fdx))
deallocate ( fdx )
318 IF (
allocated(fdy))
deallocate ( fdy )
319 IF (
allocated(fdz))
deallocate ( fdz )
321 60
FORMAT (/,
' READ_FltPar - Error while reading floats', &
322 &
' locations in input script: ',a)
323 70
FORMAT (/,
' READ_FltPar - Error while processing line: ',/,a)
324 80
FORMAT (/,
' READ_FltPar - Inconsistent number of floats to', &
325 &
' process: ', 2i6,/,18x,
'change input script.')
326 90
FORMAT (/,/,
' Floats Initial Locations, Grid: ',i2.2, &
327 & /,
' ==================================',/,/, &
328 & 15x,
'Ft0',5x,
'Fx0',5x,
'Fy0',5x,
'Fz0', &
329 & 6x,
'Fdt',6x,
'Fdx',6x,
'Fdy',6x,
'Fdz',/)
330 100
FORMAT (/,1x,i10,2x,a,t30,a)
331 110
FORMAT (/,
' READ_FltPar - Grid ', i2.2, &
332 &
', could not find input file: ', a)
333 120
FORMAT (/,2x,a,a)