/[MITgcm]/MITgcm/pkg/mdsio/mdsio_writevector.F
ViewVC logotype

Annotation of /MITgcm/pkg/mdsio/mdsio_writevector.F

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


Revision 1.1 - (hide annotations) (download)
Tue Mar 6 15:28:54 2001 UTC (23 years, 2 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint47e_post, checkpoint44e_post, checkpoint46l_post, checkpoint46g_pre, checkpoint47c_post, release1_p13_pre, checkpoint50c_post, checkpoint46f_post, checkpoint48e_post, checkpoint50g_post, checkpoint46b_post, checkpoint43a-release1mods, checkpoint44g_post, checkpoint48c_post, ecco_c50_e32, ecco_c50_e33, ecco_c50_e30, ecco_c50_e31, release1_p13, checkpoint40pre3, checkpoint40pre1, checkpoint40pre7, checkpoint40pre6, checkpoint48i_post, checkpoint40pre9, checkpoint40pre8, checkpoint46l_pre, checkpoint50d_pre, chkpt44d_post, checkpoint51, release1_p8, release1_p9, checkpoint50d_post, release1_p1, release1_p2, release1_p3, release1_p4, release1_p5, release1_p6, release1_p7, checkpoint50b_pre, checkpoint44e_pre, release1_b1, checkpoint48b_post, ecco_c51_e34a, ecco_c51_e34b, checkpoint43, checkpoint48c_pre, checkpoint47d_pre, checkpoint38, release1_chkpt44d_post, checkpoint47a_post, checkpoint48d_pre, checkpoint47i_post, release1_p11, checkpoint47d_post, icebear5, icebear4, icebear3, icebear2, checkpoint46d_pre, checkpoint40pre2, checkpoint48d_post, release1-branch_tutorials, checkpoint48f_post, checkpoint45d_post, checkpoint46j_pre, chkpt44a_post, checkpoint44h_pre, checkpoint48h_post, checkpoint40pre4, ecco_c50_e29, ecco_c50_e28, checkpoint51b_pre, checkpoint46a_post, checkpoint47g_post, checkpoint46j_post, checkpoint46k_post, checkpoint46b_pre, chkpt44c_pre, checkpoint45a_post, checkpoint50f_post, checkpoint50a_post, checkpoint50f_pre, ecco_c44_e19, ecco_c44_e18, ecco_c44_e17, ecco_c44_e16, release1_p12, release1_p10, release1_p16, release1_p17, release1_p14, release1_p15, pre38tag1, ecco_c50_e33a, branch-exfmods-tag, checkpoint46e_pre, checkpoint45b_post, release1-branch-end, c37_adj, release1_final_v1, checkpoint51b_post, release1_p12_pre, checkpoint46c_pre, checkpoint46, checkpoint44f_post, checkpoint47b_post, checkpoint44b_post, ecco_c51_e34, checkpoint46h_pre, checkpoint46m_post, checkpoint46a_pre, checkpoint50c_pre, checkpoint45c_post, ecco_ice2, ecco_ice1, checkpoint44h_post, pre38-close, checkpoint46g_post, checkpoint39, checkpoint37, ecco_c44_e22, checkpoint50h_post, checkpoint50e_pre, checkpoint50i_post, ecco_c44_e25, checkpoint48a_post, checkpoint47j_post, checkpoint40pre5, checkpoint47f_post, checkpoint50e_post, chkpt44a_pre, checkpoint46i_post, ecco_c44_e23, ecco_c44_e20, ecco_c44_e21, ecco_c44_e26, ecco_c44_e27, ecco_c44_e24, checkpoint46c_post, ecco-branch-mod1, ecco-branch-mod2, ecco-branch-mod3, ecco-branch-mod4, ecco-branch-mod5, checkpoint46e_post, release1_beta1, checkpoint44b_pre, checkpoint42, checkpoint40, checkpoint41, checkpoint47, checkpoint44, checkpoint45, checkpoint48, checkpoint49, checkpoint46h_post, checkpoint50, chkpt44c_post, checkpoint47h_post, checkpoint44f_pre, checkpoint46d_post, checkpoint50b_post, release1-branch_branchpoint, checkpoint51a_post, checkpoint48g_post
Branch point for: c24_e25_ice, branch-exfmods-curt, release1_coupled, release1_final, release1-branch, release1, ecco-branch, release1_50yr, icebear, pre38
Packaged mdsio.

Note: using a "feature" of genmake to keep original mdsio.F and mdsio_gl.F
in place during testing of mdsio package. To use original code simply
use genmake -disable=mdsio.
                                             Enjoy.

1 adcroft 1.1 C $Header: $
2     C $Name: $
3    
4     #include "MDSIO_OPTIONS.h"
5    
6     SUBROUTINE MDSWRITEVECTOR(
7     I fName,
8     I filePrec,
9     I globalfile,
10     I arrType,
11     I narr,
12     I arr,
13     I bi,
14     I bj,
15     I irecord,
16     I myIter,
17     I myThid )
18     C Arguments:
19     C
20     C fName string base name for file to written
21     C filePrec integer number of bits per word in file (32 or 64)
22     C globalFile logical selects between writing a global or tiled file
23     C arrType char(2) declaration of "arr": either "RS" or "RL"
24     C narr integer size of third dimension: normally either 1 or Nr
25     C arr RS/RL array to write, arr(narr)
26     ce bi integer x tile index
27     ce bj integer y tile index
28     C irecord integer record number to read
29     C myIter integer time step number
30     C myThid integer thread identifier
31     C
32     C Created: 03/26/99 eckert@mit.edu
33     C Modified: 03/29/99 adcroft@mit.edu + eckert@mit.edu
34     C Fixed to work work with _RS and _RL declarations
35     C Modified: 07/27/99 eckert@mit.edu
36     C Customized for state estimation (--> active_file_control.F)
37     C Changed: 05/31/00 heimbach@mit.edu
38     C open(dUnit, ..., status='old', ... -> status='unknown'
39    
40     implicit none
41     C Global variables / common blocks
42     #include "SIZE.h"
43     #include "EEPARAMS.h"
44     #include "PARAMS.h"
45    
46     C Routine arguments
47     character*(*) fName
48     integer filePrec
49     logical globalfile
50     character*(2) arrType
51     integer narr
52     Real arr(narr)
53     integer irecord
54     integer myIter
55     integer myThid
56     ce
57     integer bi,bj
58     ce
59    
60     C Functions
61     integer ILNBLNK
62     integer MDS_RECLEN
63     C Local variables
64     character*(80) dataFName,metaFName
65     integer iG,jG,irec,dUnit,IL
66     logical fileIsOpen
67     integer dimList(3,3),ndims
68     integer length_of_rec
69     character*(max_len_mbuf) msgbuf
70     C ------------------------------------------------------------------
71    
72     C Only do I/O if I am the master thread
73     _BEGIN_MASTER( myThid )
74    
75     C Record number must be >= 1
76     if (irecord .LT. 1) then
77     write(msgbuf,'(a,i9.8)')
78     & ' MDSWRITEVECTOR: argument irecord = ',irecord
79     call print_message( msgbuf, standardmessageunit,
80     & SQUEEZE_RIGHT , mythid)
81     write(msgbuf,'(a)')
82     & ' MDSWRITEVECTOR: invalid value for irecord'
83     call print_error( msgbuf, mythid )
84     stop 'ABNORMAL END: S/R MDSWRITEVECTOR'
85     endif
86    
87     C Assume nothing
88     fileIsOpen = .FALSE.
89     IL=ILNBLNK( fName )
90    
91     C Assign a free unit number as the I/O channel for this routine
92     call MDSFINDUNIT( dUnit, mythid )
93    
94     C If we are writing to a global file then we open it here
95     if (globalFile) then
96     write(dataFname(1:80),'(2a)') fName(1:IL),'.data'
97     if (irecord .EQ. 1) then
98     length_of_rec = MDS_RECLEN( filePrec, narr, mythid )
99     open( dUnit, file=dataFName, status=_NEW_STATUS,
100     & access='direct', recl=length_of_rec )
101     fileIsOpen=.TRUE.
102     else
103     length_of_rec = MDS_RECLEN( filePrec, narr, mythid )
104     open( dUnit, file=dataFName, status=_OLD_STATUS,
105     & access='direct', recl=length_of_rec )
106     fileIsOpen=.TRUE.
107     endif
108     endif
109    
110     C Loop over all tiles
111     ce do bj=1,nSy
112     ce do bi=1,nSx
113     C If we are writing to a tiled MDS file then we open each one here
114     if (.NOT. globalFile) then
115     iG=bi+(myXGlobalLo-1)/sNx ! Kludge until unstructered tiles
116     jG=bj+(myYGlobalLo-1)/sNy ! Kludge until unstructered tiles
117     write(dataFname(1:80),'(2a,i3.3,a,i3.3,a)')
118     & fName(1:IL),'.',iG,'.',jG,'.data'
119     if (irecord .EQ. 1) then
120     length_of_rec = MDS_RECLEN( filePrec, narr, mythid )
121     open( dUnit, file=dataFName, status=_NEW_STATUS,
122     & access='direct', recl=length_of_rec )
123     fileIsOpen=.TRUE.
124     else
125     length_of_rec = MDS_RECLEN( filePrec, narr, mythid )
126     open( dUnit, file=dataFName, status=_OLD_STATUS,
127     & access='direct', recl=length_of_rec )
128     fileIsOpen=.TRUE.
129     endif
130     endif
131     if (fileIsOpen) then
132     if (globalFile) then
133     iG = myXGlobalLo-1+(bi-1)*sNx
134     jG = myYGlobalLo-1+(bj-1)*sNy
135     irec = 1 + int(iG/sNx) + (jG/sNy)*nSx*nPx +
136     & (irecord-1)*nSx*nPx*nSy*nPy
137     else
138     iG = 0
139     jG = 0
140     irec = irecord
141     endif
142     if (filePrec .eq. precFloat32) then
143     call MDS_WRITE_RS_VEC( dUnit, irec, narr, arr, myThid )
144     elseif (filePrec .eq. precFloat64) then
145     call MDS_WRITE_RL_VEC( dUnit, irec, narr, arr, myThid )
146     else
147     write(msgbuf,'(a)')
148     & ' MDSWRITEVECTOR: illegal value for filePrec'
149     call print_error( msgbuf, mythid )
150     stop 'ABNORMAL END: S/R MDSWRITEVECTOR'
151     endif
152     else
153     write(msgbuf,'(a)')
154     & ' MDSWRITEVECTOR: I should never get to this point'
155     call print_error( msgbuf, mythid )
156     stop 'ABNORMAL END: S/R MDSWRITEVECTOR'
157     endif
158     C If we were writing to a tiled MDS file then we close it here
159     if (fileIsOpen .AND. (.NOT. globalFile)) then
160     close( dUnit )
161     fileIsOpen = .FALSE.
162     endif
163     C Create meta-file for each tile file
164     if (.NOT. globalFile) then
165     iG=bi+(myXGlobalLo-1)/sNx ! Kludge until unstructered tiles
166     jG=bj+(myYGlobalLo-1)/sNy ! Kludge until unstructered tiles
167     write(metaFname(1:80),'(2a,i3.3,a,i3.3,a)')
168     & fName(1:IL),'.',iG,'.',jG,'.meta'
169     dimList(1,1) = nPx*nSx*narr
170     dimList(2,1) = ((myXGlobalLo-1)/sNx + (bi-1))*narr + 1
171     dimList(3,1) = ((myXGlobalLo-1)/sNx + bi )*narr
172     dimList(1,2) = nPy*nSy
173     dimList(2,2) = (myYGlobalLo-1)/sNy + bj
174     dimList(3,2) = (myYGlobalLo-1)/sNy + bj
175     dimList(1,3) = 1
176     dimList(2,3) = 1
177     dimList(3,3) = 1
178     ndims=1
179     call MDSWRITEMETA( metaFName, dataFName,
180     & filePrec, ndims, dimList, irecord, myIter, mythid )
181     endif
182     C End of bi,bj loops
183     ce enddo
184     ce enddo
185    
186     C If global file was opened then close it
187     if (fileIsOpen .AND. globalFile) then
188     close( dUnit )
189     fileIsOpen = .FALSE.
190     endif
191    
192     C Create meta-file for global file
193     if (globalFile) then
194     write(metaFName(1:80),'(2a)') fName(1:IL),'.meta'
195     dimList(1,1) = nPx*nSx*narr
196     dimList(2,1) = 1
197     dimList(3,1) = nPx*nSx*narr
198     dimList(1,2) = nPy*nSy
199     dimList(2,2) = 1
200     dimList(3,2) = nPy*nSy
201     dimList(1,3) = 1
202     dimList(2,3) = 1
203     dimList(3,3) = 1
204     ndims=1
205     call MDSWRITEMETA( metaFName, dataFName,
206     & filePrec, ndims, dimList, irecord, myIter, mythid )
207     endif
208    
209     _END_MASTER( myThid )
210     C ------------------------------------------------------------------
211     return
212     end

  ViewVC Help
Powered by ViewVC 1.1.22