/[MITgcm]/MITgcm/pkg/flt/flt_traj.F
ViewVC logotype

Annotation of /MITgcm/pkg/flt/flt_traj.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (hide annotations) (download)
Tue Feb 10 21:30:21 2009 UTC (15 years, 3 months ago) by jmc
Branch: MAIN
Changes since 1.6: +9 -9 lines
replace horizontal coord. x,y by horizontal (decimal) indices i,j :
 - a step towards floats on curvilinear grid.
 - use mapping functions from file flt_mapping.F (remove flt_functions.F).
 - delX,delY no longer used.

1 jmc 1.7 C $Header: /u/gcmpack/MITgcm/pkg/flt/flt_traj.F,v 1.6 2009/02/05 01:01:48 jmc Exp $
2 jmc 1.2 C $Name: $
3 adcroft 1.1
4 jmc 1.2 #include "FLT_OPTIONS.h"
5 adcroft 1.1
6    
7 jmc 1.2 SUBROUTINE FLT_TRAJ (
8 jmc 1.3 I myTime, myIter, myThid )
9 adcroft 1.1
10 jmc 1.2 C ==================================================================
11     C SUBROUTINE FLT_TRAJ
12     C ==================================================================
13     C o This routine samples the model state at float position every
14     C flt_int_traj time steps and writes output.
15     C ==================================================================
16 jmc 1.4
17     C !USES:
18     IMPLICIT NONE
19 adcroft 1.1
20 jmc 1.2 C == global variables ==
21     #include "SIZE.h"
22 adcroft 1.1 #include "EEPARAMS.h"
23 jmc 1.2 #include "PARAMS.h"
24     #include "GRID.h"
25 adcroft 1.1 #include "DYNVARS.h"
26     #include "FLT.h"
27    
28 jmc 1.2 C == routine arguments ==
29 jmc 1.3 _RL myTime
30 jmc 1.2 INTEGER myIter, myThid
31 jmc 1.3
32 jmc 1.4 C === Functions ==
33     INTEGER ILNBLNK
34 jmc 1.6 _RL FLT_MAP_K2R
35     EXTERNAL ILNBLNK
36     EXTERNAL FLT_MAP_K2R
37 jmc 1.4
38 jmc 1.3 C == local variables ==
39 adcroft 1.1 INTEGER bi, bj, imax
40 jmc 1.6 PARAMETER (imax=13)
41 jmc 1.2 INTEGER ip, kp, ii
42 jmc 1.7 _RL ix, jy, i0x, j0y, xx, yy, zz
43 jmc 1.6 _RL uu, vv, tt, ss, pp
44 jmc 1.2
45 jmc 1.5 INTEGER ioUnit, irecord
46 adcroft 1.1 _RL tmp(imax)
47     _RL npart_read,npart_times
48     CHARACTER*(MAX_LEN_FNAM) fn
49 jmc 1.2 CHARACTER*(MAX_LEN_MBUF) msgBuf
50     CHARACTER*(80) dataFName
51     INTEGER iG,jG,IL
52     LOGICAL exst
53     LOGICAL globalFile
54 adcroft 1.1
55 jmc 1.2 C == end of interface ==
56 adcroft 1.1
57     fn = 'float_trajectories'
58    
59     DO bj=myByLo(myThid),myByHi(myThid)
60 jmc 1.4 DO bi=myBxLo(myThid),myBxHi(myThid)
61 adcroft 1.1
62 jmc 1.2 C (1) read actual number floats from file (if exists)
63 adcroft 1.1 IL=ILNBLNK( fn )
64     iG=bi+(myXGlobalLo-1)/sNx ! Kludge until unstructered tiles
65     jG=bj+(myYGlobalLo-1)/sNy ! Kludge until unstructered tiles
66 jmc 1.2 WRITE(dataFname(1:80),'(2a,i3.3,a,i3.3,a)')
67 adcroft 1.1 & fn(1:IL),'.',iG,'.',jG,'.data'
68 jmc 1.2 INQUIRE( file=dataFname, exist=exst )
69     IF (exst) THEN
70 jmc 1.5 CALL FLT_MDSREADVECTOR(fn,globalFile,precFloat64,'RL',
71 jmc 1.2 & imax,tmp,bi,bj,1,myThid)
72 adcroft 1.1 npart_read = tmp(1)
73     npart_times = tmp(5)
74 jmc 1.2 ELSE
75 adcroft 1.1 npart_read = 0.
76     npart_times = 0.
77 jmc 1.2 tmp(2) = myTime
78     ENDIF
79 adcroft 1.1
80 jmc 1.5 C the standard routine mds_writevec_loc can be used here
81 jmc 1.2 C (2) WRITE new actual number floats and time axis into file
82     C
83     C total number of records in this file
84 adcroft 1.1 tmp(1) = DBLE(npart_tile(bi,bj))+npart_read
85 jmc 1.2 C first time of writing floats (do not change when written)
86 adcroft 1.1 c tmp(2) = tmp(2)
87 jmc 1.2 C current time
88     tmp(3) = myTime
89     C timestep
90 adcroft 1.1 tmp(4) = flt_int_traj
91 jmc 1.2 C total number of timesteps
92 adcroft 1.1 tmp(5) = npart_times + 1.
93 jmc 1.2 C total number of floats
94 adcroft 1.1 tmp(6) = max_npart
95 jmc 1.6 DO ii=7,imax
96     tmp(ii) = 0.
97 jmc 1.2 ENDDO
98 adcroft 1.1
99 jmc 1.5 ioUnit = -1
100     CALL MDS_WRITEVEC_LOC( fn, precFloat64, ioUnit,
101     & 'RL', imax, tmp,
102     & bi,bj,-1, myIter, myThid )
103 adcroft 1.1
104 jmc 1.6 i0x = DFLOAT( myXGlobalLo-1 + (bi-1)*sNx )
105     j0y = DFLOAT( myYGlobalLo-1 + (bj-1)*sNy )
106 jmc 1.2 DO ip=1,npart_tile(bi,bj)
107 adcroft 1.1
108 jmc 1.7 ix = ipart(ip,bi,bj)
109     jy = jpart(ip,bi,bj)
110     CALL FLT_MAP_IJLOCAL2XY( xx, yy,
111     I ix, jy, bi,bj, myThid )
112     zz = FLT_MAP_K2R( kpart(ip,bi,bj),bi,bj,myThid )
113 jmc 1.4 kp = NINT(kpart(ip,bi,bj))
114 adcroft 1.1 tmp(1) = npart(ip,bi,bj)
115 jmc 1.2 tmp(2) = myTime
116 jmc 1.7 tmp(3) = xx
117     tmp(4) = yy
118 jmc 1.6 tmp(5) = zz
119     tmp(6) = ix + i0x
120     tmp(7) = jy + j0y
121     tmp(8) = kpart(ip,bi,bj)
122 adcroft 1.1
123 jmc 1.4 IF ( ( myTime.GE.tstart(ip,bi,bj)) .AND.
124 jmc 1.2 & ( tend(ip,bi,bj).EQ.-1. .OR. myTime.LE.tend(ip,bi,bj))
125     & ) THEN
126    
127     IF ( kp.LT.1 .OR. kp.GT.Nr ) THEN
128     WRITE(msgBuf,'(2A,I8)') '** WARNING ** FLT_TRAJ: ',
129     & ' illegal value for kp=',kp
130     CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
131     & SQUEEZE_RIGHT, myThid )
132     WRITE(msgBuf,'(A,1P5E20.13)')
133     & ' FLT_TRAJ: ', (tmp(ii),ii=1,5)
134     CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
135     & SQUEEZE_RIGHT, myThid )
136     c CALL PRINT_ERROR( msgBuf, myThid )
137     c STOP 'ABNORMAL END: S/R FLT_TRAJ'
138 jmc 1.4 C-- jmc: not sure if this is right but added to avoid Pb in FLT_BILINEAR:
139     kp = MIN( MAX(kp,1), Nr)
140 jmc 1.2 ENDIF
141    
142 jmc 1.6 CALL FLT_BILINEAR (ix,jy,uu,uVel, kp,1,bi,bj,myThid)
143     CALL FLT_BILINEAR (ix,jy,vv,vVel, kp,2,bi,bj,myThid)
144     CALL FLT_BILINEAR2D(ix,jy,pp,etaN, 0,bi,bj,myThid)
145     CALL FLT_BILINEAR (ix,jy,tt,theta, kp,0,bi,bj,myThid)
146     CALL FLT_BILINEAR (ix,jy,ss,salt, kp,0,bi,bj,myThid)
147    
148     tmp( 9) = pp
149     tmp(10) = uu
150     tmp(11) = vv
151     tmp(12) = tt
152     tmp(13) = ss
153 jmc 1.2 ELSE
154 jmc 1.6 tmp( 9) = flt_nan
155     tmp(10) = flt_nan
156     tmp(11) = flt_nan
157     tmp(12) = flt_nan
158     tmp(13) = flt_nan
159 jmc 1.2 ENDIF
160    
161     C (3) WRITE float positions into file
162 jmc 1.5 irecord = npart_read+ip+1
163     IF ( ip.NE.npart_tile(bi,bj) ) irecord = -irecord
164     CALL MDS_WRITEVEC_LOC( fn, precFloat64, ioUnit,
165     & 'RL', imax, tmp,
166     & bi,bj,irecord, myIter, myThid )
167 adcroft 1.1
168 jmc 1.2 ENDDO
169 jmc 1.5 CLOSE( ioUnit )
170 adcroft 1.1
171     ENDDO
172 jmc 1.4 ENDDO
173 adcroft 1.1
174 jmc 1.2 RETURN
175     END

  ViewVC Help
Powered by ViewVC 1.1.22