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

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

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


Revision 1.12 - (show annotations) (download)
Mon Dec 27 19:21:23 2010 UTC (13 years, 4 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62w, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint63, checkpoint63a, checkpoint63b
Changes since 1.11: +12 -19 lines
- use (recent) mdsio S/R MDS_READVEC_LOC instead of local FLT_MDSREADVECTOR
- precision of input and output files set according to readBinaryPrec
  and writeBinaryPrec (previously always 64.b), pickup remains at 64 bits.
- initial float position from tiled file was not converted to index space
  (looks like a bug): fixed to make it similar to initial pos. global file.

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

  ViewVC Help
Powered by ViewVC 1.1.22