C $Header: /home/ubuntu/mnt/e9_copy/MITgcm/pkg/flt/flt_traj.F,v 1.6 2009/02/05 01:01:48 jmc Exp $ C $Name: $ #include "FLT_OPTIONS.h" SUBROUTINE FLT_TRAJ ( I myTime, myIter, myThid ) C ================================================================== C SUBROUTINE FLT_TRAJ C ================================================================== C o This routine samples the model state at float position every C flt_int_traj time steps and writes output. C ================================================================== C !USES: IMPLICIT NONE C == global variables == #include "SIZE.h" #include "EEPARAMS.h" #include "PARAMS.h" #include "GRID.h" #include "DYNVARS.h" #include "FLT.h" C == routine arguments == _RL myTime INTEGER myIter, myThid C === Functions == INTEGER ILNBLNK _RL global2local_i _RL global2local_j _RL FLT_MAP_K2R EXTERNAL ILNBLNK EXTERNAL FLT_MAP_K2R C == local variables == INTEGER bi, bj, imax PARAMETER (imax=13) INTEGER ip, kp, ii _RL ix, jy, i0x, j0y, zz _RL uu, vv, tt, ss, pp INTEGER ioUnit, irecord _RL tmp(imax) _RL npart_read,npart_times CHARACTER*(MAX_LEN_FNAM) fn CHARACTER*(MAX_LEN_MBUF) msgBuf CHARACTER*(80) dataFName INTEGER iG,jG,IL LOGICAL exst LOGICAL globalFile C == end of interface == fn = 'float_trajectories' DO bj=myByLo(myThid),myByHi(myThid) DO bi=myBxLo(myThid),myBxHi(myThid) C (1) read actual number floats from file (if exists) IL=ILNBLNK( fn ) iG=bi+(myXGlobalLo-1)/sNx ! Kludge until unstructered tiles jG=bj+(myYGlobalLo-1)/sNy ! Kludge until unstructered tiles WRITE(dataFname(1:80),'(2a,i3.3,a,i3.3,a)') & fn(1:IL),'.',iG,'.',jG,'.data' INQUIRE( file=dataFname, exist=exst ) IF (exst) THEN CALL FLT_MDSREADVECTOR(fn,globalFile,precFloat64,'RL', & imax,tmp,bi,bj,1,myThid) npart_read = tmp(1) npart_times = tmp(5) ELSE npart_read = 0. npart_times = 0. tmp(2) = myTime ENDIF C the standard routine mds_writevec_loc can be used here C (2) WRITE new actual number floats and time axis into file C C total number of records in this file tmp(1) = DBLE(npart_tile(bi,bj))+npart_read C first time of writing floats (do not change when written) c tmp(2) = tmp(2) C current time tmp(3) = myTime C timestep tmp(4) = flt_int_traj C total number of timesteps tmp(5) = npart_times + 1. C total number of floats tmp(6) = max_npart DO ii=7,imax tmp(ii) = 0. ENDDO ioUnit = -1 CALL MDS_WRITEVEC_LOC( fn, precFloat64, ioUnit, & 'RL', imax, tmp, & bi,bj,-1, myIter, myThid ) i0x = DFLOAT( myXGlobalLo-1 + (bi-1)*sNx ) j0y = DFLOAT( myYGlobalLo-1 + (bj-1)*sNy ) DO ip=1,npart_tile(bi,bj) ix=global2local_i(xpart(ip,bi,bj),bi,bj,myThid) jy=global2local_j(ypart(ip,bi,bj),bi,bj,myThid) zz = FLT_MAP_K2R( kpart(ip,bi,bj),bi,bj,myThid) kp = NINT(kpart(ip,bi,bj)) tmp(1) = npart(ip,bi,bj) tmp(2) = myTime tmp(3) = xpart(ip,bi,bj) tmp(4) = ypart(ip,bi,bj) tmp(5) = zz tmp(6) = ix + i0x tmp(7) = jy + j0y tmp(8) = kpart(ip,bi,bj) IF ( ( myTime.GE.tstart(ip,bi,bj)) .AND. & ( tend(ip,bi,bj).EQ.-1. .OR. myTime.LE.tend(ip,bi,bj)) & ) THEN IF ( kp.LT.1 .OR. kp.GT.Nr ) THEN WRITE(msgBuf,'(2A,I8)') '** WARNING ** FLT_TRAJ: ', & ' illegal value for kp=',kp CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, & SQUEEZE_RIGHT, myThid ) WRITE(msgBuf,'(A,1P5E20.13)') & ' FLT_TRAJ: ', (tmp(ii),ii=1,5) CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, & SQUEEZE_RIGHT, myThid ) c CALL PRINT_ERROR( msgBuf, myThid ) c STOP 'ABNORMAL END: S/R FLT_TRAJ' C-- jmc: not sure if this is right but added to avoid Pb in FLT_BILINEAR: kp = MIN( MAX(kp,1), Nr) ENDIF CALL FLT_BILINEAR (ix,jy,uu,uVel, kp,1,bi,bj,myThid) CALL FLT_BILINEAR (ix,jy,vv,vVel, kp,2,bi,bj,myThid) CALL FLT_BILINEAR2D(ix,jy,pp,etaN, 0,bi,bj,myThid) CALL FLT_BILINEAR (ix,jy,tt,theta, kp,0,bi,bj,myThid) CALL FLT_BILINEAR (ix,jy,ss,salt, kp,0,bi,bj,myThid) tmp( 9) = pp tmp(10) = uu tmp(11) = vv tmp(12) = tt tmp(13) = ss ELSE tmp( 9) = flt_nan tmp(10) = flt_nan tmp(11) = flt_nan tmp(12) = flt_nan tmp(13) = flt_nan ENDIF C (3) WRITE float positions into file irecord = npart_read+ip+1 IF ( ip.NE.npart_tile(bi,bj) ) irecord = -irecord CALL MDS_WRITEVEC_LOC( fn, precFloat64, ioUnit, & 'RL', imax, tmp, & bi,bj,irecord, myIter, myThid ) ENDDO CLOSE( ioUnit ) ENDDO ENDDO RETURN END