/[MITgcm]/MITgcm/pkg/sbo/sbo_writevector.F
ViewVC logotype

Diff of /MITgcm/pkg/sbo/sbo_writevector.F

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

revision 1.1 by dimitri, Fri Jan 31 04:42:16 2003 UTC revision 1.2 by dimitri, Tue Feb 18 05:33:55 2003 UTC
# Line 0  Line 1 
1    C
2    
3    #include "SBO_OPTIONS.h"
4    
5    #undef  SAFE_IO
6    
7    #ifdef SAFE_IO
8    #define _NEW_STATUS 'new'
9    #else
10    #define _NEW_STATUS 'unknown'
11    #endif
12    
13    #ifdef ALLOW_AUTODIFF_TAMC
14    #define _OLD_STATUS 'unknown'
15    #else
16    #define _OLD_STATUS 'old'
17    #endif
18    
19          SUBROUTINE SBO_WRITEVECTOR(
20         I   fName,
21         I   narr,
22         I   arr,
23         I   irecord,
24         I   myIter,
25         I   myThid )
26    C     /==========================================================\
27    C     | SUBROUTINE SBO_WRITEVECTOR                               |
28    C     | o Routine to write a vector to a direct access file.     |
29    C     |==========================================================|
30    C     | This is a rewrite of MDSWRITEVECTOR that outputs a       |
31    C     | single Real*8 vector from the master process and thread. |
32    C     \==========================================================/
33          IMPLICIT NONE
34    
35    C     === Global variables ===
36    #include "SIZE.h"
37    #include "EEPARAMS.h"
38    #include "PARAMS.h"
39    
40    C     == Routine arguments ==
41    C
42    C fName         string  base name for file to written
43    C narr          integer size of vector dimension
44    C arr           Real array to write, arr(narr)
45    C irecord       integer record number to read
46    C myIter        integer time step number
47    C myThid        integer thread identifier
48    
49    C Routine arguments
50          character*(*) fName
51          integer narr
52          Real*8  arr(narr)
53          integer irecord
54          integer myIter
55          integer myThid
56    
57    #ifdef ALLOW_SBO
58    
59    C Functions
60          integer ILNBLNK
61          integer MDS_RECLEN
62    
63    C Local variables
64    C filePrec      integer number of bits per word in file (64)
65          integer filePrec / 64 /
66          character*(80) dataFName,metaFName
67          integer dUnit,IL
68          logical fileIsOpen
69          integer dimList(3,3),ndims
70          integer length_of_rec
71          character*(max_len_mbuf) msgbuf
72    
73    C Only do I/O if I am the master process
74          IF( myProcId .EQ. 0 ) THEN
75    
76    C Only do I/O if I am the master thread
77             _BEGIN_MASTER( myThid )
78    
79    C Record number must be >= 1
80             if (irecord .LT. 1) then
81                write(msgbuf,'(a,i9.8)')
82         &           ' SBO_WRITEVECTOR: argument irecord = ',irecord
83                call print_message( msgbuf, standardmessageunit,
84         &           SQUEEZE_RIGHT , mythid)
85                write(msgbuf,'(a)')
86         &           ' SBO_WRITEVECTOR: invalid value for irecord'
87                call print_error( msgbuf, mythid )
88                stop 'ABNORMAL END: S/R SBO_WRITEVECTOR'
89             endif
90    
91    C Assume nothing
92             fileIsOpen = .FALSE.
93             IL=ILNBLNK( fName )
94    
95    C Assign a free unit number as the I/O channel for this routine
96             call MDSFINDUNIT( dUnit, mythid )
97    
98    C Open file
99             write(dataFname(1:80),'(2a)') fName(1:IL),'.data'
100             if (irecord .EQ. 1) then
101                length_of_rec = MDS_RECLEN( filePrec, narr, mythid )
102                open( dUnit, file=dataFName, status=_NEW_STATUS,
103         &           access='direct', recl=length_of_rec )
104                fileIsOpen=.TRUE.
105             else
106                length_of_rec = MDS_RECLEN( filePrec, narr, mythid )
107                open( dUnit, file=dataFName, status=_OLD_STATUS,
108         &           access='direct', recl=length_of_rec )
109                fileIsOpen=.TRUE.
110             endif
111    
112    C Write record
113             if (fileIsOpen) then
114                write(msgbuf,'(a,i9.8,2x,i9.8)')
115         &           ' SBO_WRITEVECTOR: irec = ',irecord,narr
116                call print_message( msgbuf, standardmessageunit,
117         &           SQUEEZE_RIGHT , mythid)
118                write(dUnit,rec=irecord) arr
119             else
120                write(msgbuf,'(a)')
121         &           ' SBO_WRITEVECTOR: I should never get to this point'
122                call print_error( msgbuf, mythid )
123                stop 'ABNORMAL END: S/R SBO_WRITEVECTOR'
124             endif
125    
126    C Close file
127             if (fileIsOpen) then
128                close( dUnit )
129                fileIsOpen = .FALSE.
130             endif
131    
132    C Create meta-file
133             write(metaFName(1:80),'(2a)') fName(1:IL),'.meta'
134             dimList(1,1) = narr
135             dimList(2,1) = 1
136             dimList(3,1) = narr
137             dimList(1,2) = 1
138             dimList(2,2) = 1
139             dimList(3,2) = 1
140             dimList(1,3) = 1
141             dimList(2,3) = 1
142             dimList(3,3) = 1
143             ndims=1
144             call MDSWRITEMETA( metaFName, dataFName,
145         &        filePrec, ndims, dimList, irecord, myIter, mythid )
146    
147             _END_MASTER( myThid )
148    
149          ENDIF
150    
151    #endif ALLOW_SBO
152    
153          return
154          end

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.22