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

Contents of /MITgcm/pkg/mdsio/mdsio_readvector.F

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


Revision 1.1 - (show 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, checkpoint46f_post, checkpoint48e_post, checkpoint46b_post, checkpoint43a-release1mods, checkpoint44g_post, checkpoint48c_post, release1_p13, checkpoint40pre3, checkpoint40pre1, checkpoint40pre7, checkpoint40pre6, checkpoint48i_post, checkpoint40pre9, checkpoint40pre8, checkpoint46l_pre, chkpt44d_post, release1_p8, release1_p9, release1_p1, release1_p2, release1_p3, release1_p4, release1_p5, release1_p6, release1_p7, checkpoint44e_pre, release1_b1, checkpoint48b_post, 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, checkpoint46a_post, checkpoint47g_post, checkpoint46j_post, checkpoint46k_post, checkpoint46b_pre, chkpt44c_pre, checkpoint45a_post, 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, branch-exfmods-tag, checkpoint46e_pre, checkpoint45b_post, release1-branch-end, c37_adj, release1_final_v1, release1_p12_pre, checkpoint46c_pre, checkpoint46, checkpoint44f_post, checkpoint47b_post, checkpoint44b_post, checkpoint46h_pre, checkpoint46m_post, checkpoint46a_pre, checkpoint45c_post, ecco_ice2, ecco_ice1, checkpoint44h_post, pre38-close, checkpoint46g_post, checkpoint39, checkpoint37, ecco_c44_e22, ecco_c44_e25, checkpoint48a_post, checkpoint47j_post, checkpoint40pre5, checkpoint47f_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, chkpt44c_post, checkpoint47h_post, checkpoint44f_pre, checkpoint46d_post, release1-branch_branchpoint, 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 C $Header: $
2 C $Name: $
3
4 #include "MDSIO_OPTIONS.h"
5
6 SUBROUTINE MDSREADVECTOR(
7 I fName,
8 I filePrec,
9 I arrType,
10 I narr,
11 O arr,
12 I bi,
13 I bj,
14 I irecord,
15 I myThid )
16 C
17 C Arguments:
18 C
19 C fName string base name for file to read
20 C filePrec integer number of bits per word in file (32 or 64)
21 C arrType char(2) declaration of "arr": either "RS" or "RL"
22 C narr integer size of third dimension: normally either 1 or Nr
23 C arr RS/RL array to read into, arr(narr)
24 ce bi integer x tile index
25 ce bj integer y tile index
26 C irecord integer record number to read
27 C myThid integer thread identifier
28 C
29 C Created: 03/26/99 eckert@mit.edu
30 C Modified: 03/29/99 adcroft@mit.edu + eckert@mit.edu
31 C Fixed to work work with _RS and _RL declarations
32 C Modified: 07/27/99 eckert@mit.edu
33 C Customized for state estimation (--> active_file_control.F)
34
35 implicit none
36 C Global variables / common blocks
37 #include "SIZE.h"
38 #include "EEPARAMS.h"
39 #include "PARAMS.h"
40
41 C Routine arguments
42 character*(*) fName
43 integer filePrec
44 character*(2) arrType
45 integer narr
46 Real arr(narr)
47 integer irecord
48 integer myThid
49 ce
50 integer bi,bj
51 ce
52
53 C Functions
54 integer ILNBLNK
55 integer MDS_RECLEN
56 C Local variables
57 character*(80) dataFName
58 integer iG,jG,irec,dUnit,IL
59 logical exst
60 logical globalFile,fileIsOpen
61 integer length_of_rec
62 character*(max_len_mbuf) msgbuf
63 C ------------------------------------------------------------------
64
65 C Only do I/O if I am the master thread
66 _BEGIN_MASTER( myThid )
67
68 C Record number must be >= 1
69 if (irecord .LT. 1) then
70 write(msgbuf,'(a,i9.8)')
71 & ' MDSREADVECTOR: argument irecord = ',irecord
72 call print_message( msgbuf, standardmessageunit,
73 & SQUEEZE_RIGHT , mythid)
74 write(msgbuf,'(a)')
75 & ' MDSREADVECTOR: invalid value for irecord'
76 call print_error( msgbuf, mythid )
77 stop 'ABNORMAL END: S/R MDSREADVECTOR'
78 endif
79
80 C Assume nothing
81 globalFile = .FALSE.
82 fileIsOpen = .FALSE.
83 IL=ILNBLNK( fName )
84
85 C Assign a free unit number as the I/O channel for this routine
86 call MDSFINDUNIT( dUnit, mythid )
87
88 C Check first for global file with simple name (ie. fName)
89 dataFName = fName
90 inquire( file=dataFname, exist=exst )
91 if (exst) then
92 write(msgbuf,'(a,a)')
93 & ' MDSREADVECTOR: opening global file: ',dataFName
94 call print_message( msgbuf, standardmessageunit,
95 & SQUEEZE_RIGHT , mythid)
96 globalFile = .TRUE.
97 endif
98
99 C If negative check for global file with MDS name (ie. fName.data)
100 if (.NOT. globalFile) then
101 write(dataFname(1:80),'(2a)') fName(1:IL),'.data'
102 inquire( file=dataFname, exist=exst )
103 if (exst) then
104 write(msgbuf,'(a,a)')
105 & ' MDSREADVECTOR: opening global file: ',dataFName
106 call print_message( msgbuf, standardmessageunit,
107 & SQUEEZE_RIGHT , mythid)
108 globalFile = .TRUE.
109 endif
110 endif
111
112 C If we are reading from a global file then we open it here
113 if (globalFile) then
114 length_of_rec=MDS_RECLEN( filePrec, narr, mythid )
115 open( dUnit, file=dataFName, status='old',
116 & access='direct', recl=length_of_rec )
117 fileIsOpen=.TRUE.
118 endif
119
120 C Loop over all tiles
121 ce do bj=1,nSy
122 ce do bi=1,nSx
123 C If we are reading from a tiled MDS file then we open each one here
124 if (.NOT. globalFile) then
125 iG=bi+(myXGlobalLo-1)/sNx ! Kludge until unstructered tiles
126 jG=bj+(myYGlobalLo-1)/sNy ! Kludge until unstructered tiles
127 write(dataFname(1:80),'(2a,i3.3,a,i3.3,a)')
128 & fName(1:IL),'.',iG,'.',jG,'.data'
129 inquire( file=dataFname, exist=exst )
130 C Of course, we only open the file if the tile is "active"
131 C (This is a place-holder for the active/passive mechanism)
132 if (exst) then
133 write(msgbuf,'(a,a)')
134 & ' MDSREADVECTOR: opening file: ',dataFName
135 call print_message( msgbuf, standardmessageunit,
136 & SQUEEZE_RIGHT , mythid)
137 length_of_rec=MDS_RECLEN( filePrec, narr, mythid )
138 open( dUnit, file=dataFName, status='old',
139 & access='direct', recl=length_of_rec )
140 fileIsOpen=.TRUE.
141 else
142 fileIsOpen=.FALSE.
143 write(msgbuf,'(a)')
144 & ' MDSREADVECTOR: un-active tiles not implemented yet'
145 call print_error( msgbuf, mythid )
146 stop 'ABNORMAL END: S/R MDSREADVECTOR'
147 endif
148 endif
149 if (fileIsOpen) then
150 if (globalFile) then
151 iG = myXGlobalLo-1+(bi-1)*sNx
152 jG = myYGlobalLo-1+(bj-1)*sNy
153 irec = 1 + int(iG/sNx) + (jG/sNy)*nSx*nPx +
154 & (irecord-1)*nSx*nPx*nSy*nPy
155 else
156 iG = 0
157 jG = 0
158 irec = irecord
159 endif
160 if (filePrec .eq. precFloat32) then
161 call MDS_READ_RS_VEC( dUnit, irec, narr, arr, myThid )
162 elseif (filePrec .eq. precFloat64) then
163 call MDS_READ_RL_VEC( dUnit, irec, narr, arr, myThid )
164 else
165 write(msgbuf,'(a)')
166 & ' MDSREADVECTOR: illegal value for filePrec'
167 call print_error( msgbuf, mythid )
168 stop 'ABNORMAL END: S/R MDSREADVECTOR'
169 endif
170 if (.NOT. globalFile) then
171 close( dUnit )
172 fileIsOpen = .FALSE.
173 endif
174 endif
175 C End of bi,bj loops
176 ce enddo
177 ce enddo
178
179 C If global file was opened then close it
180 if (fileIsOpen .AND. globalFile) then
181 close( dUnit )
182 fileIsOpen = .FALSE.
183 endif
184
185 _END_MASTER( myThid )
186
187 C ------------------------------------------------------------------
188 return
189 end

  ViewVC Help
Powered by ViewVC 1.1.22