1 |
C $Header$ |
C $Header$ |
2 |
|
C $Name$ |
3 |
|
|
4 |
#include "MDSIO_OPTIONS.h" |
#include "MDSIO_OPTIONS.h" |
5 |
|
|
83 |
integer ILNBLNK |
integer ILNBLNK |
84 |
integer MDS_RECLEN |
integer MDS_RECLEN |
85 |
C Local variables |
C Local variables |
86 |
character*(80) dataFName |
character*(MAX_LEN_FNAM) dataFName |
87 |
integer ip,jp,iG,jG,irec,bi,bj,ii,j,k,dUnit,IL |
integer ip,jp,iG,jG,irec,bi,bj,i,j,k,dUnit,IL |
88 |
logical exst |
logical exst |
89 |
_RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,Nr,nSx,nSy) |
_RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,Nr,nSx,nSy) |
90 |
Real*4 r4seg(sNx) |
Real*4 r4seg(sNx) |
92 |
logical globalFile,fileIsOpen |
logical globalFile,fileIsOpen |
93 |
integer length_of_rec |
integer length_of_rec |
94 |
character*(max_len_mbuf) msgbuf |
character*(max_len_mbuf) msgbuf |
95 |
|
cph-usesingle( |
96 |
|
integer ii,jj |
97 |
|
c integer iG_IO,jG_IO,npe |
98 |
|
integer x_size,y_size |
99 |
|
PARAMETER ( x_size = Nx ) |
100 |
|
PARAMETER ( y_size = Ny ) |
101 |
|
Real*4 xy_buffer_r4(x_size,y_size) |
102 |
|
Real*8 xy_buffer_r8(x_size,y_size) |
103 |
|
Real*8 global(Nx,Ny) |
104 |
|
c _RL local(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
105 |
|
cph-usesingle) |
106 |
|
CMM( |
107 |
|
integer pIL |
108 |
|
CMM) |
109 |
|
|
110 |
C ------------------------------------------------------------------ |
C ------------------------------------------------------------------ |
111 |
|
|
112 |
C Only do I/O if I am the master thread |
C Only do I/O if I am the master thread |
128 |
globalFile = .FALSE. |
globalFile = .FALSE. |
129 |
fileIsOpen = .FALSE. |
fileIsOpen = .FALSE. |
130 |
IL=ILNBLNK( fName ) |
IL=ILNBLNK( fName ) |
131 |
|
CMM( |
132 |
|
pIL = ILNBLNK( mdsioLocalDir ) |
133 |
|
CMM) |
134 |
|
CMM( |
135 |
|
C Assign special directory |
136 |
|
if ( pIL.NE.0 ) then |
137 |
|
write(fName,'(2a)') mdsioLocalDir(1:pIL), fName(1:IL) |
138 |
|
endif |
139 |
|
CMM) |
140 |
|
|
141 |
C Assign a free unit number as the I/O channel for this routine |
C Assign a free unit number as the I/O channel for this routine |
142 |
call MDSFINDUNIT( dUnit, mythid ) |
call MDSFINDUNIT( dUnit, mythid ) |
143 |
|
|
144 |
|
if ( useSingleCPUIO ) then |
145 |
|
|
146 |
|
#ifdef ALLOW_USE_MPI |
147 |
|
IF( mpiMyId .EQ. 0 ) THEN |
148 |
|
#else |
149 |
|
IF ( .TRUE. ) THEN |
150 |
|
#endif /* ALLOW_USE_MPI */ |
151 |
|
|
152 |
C Check first for global file with simple name (ie. fName) |
C Check first for global file with simple name (ie. fName) |
153 |
dataFName = fName |
dataFName = fName |
154 |
inquire( file=dataFname, exist=exst ) |
inquire( file=dataFname, exist=exst ) |
155 |
if (exst) then |
if (exst) globalFile = .TRUE. |
|
write(msgbuf,'(a,a)') |
|
|
& ' MDSREADFIELD: opening global file: ',dataFName |
|
|
call print_message( msgbuf, standardmessageunit, |
|
|
& SQUEEZE_RIGHT , mythid) |
|
|
endif |
|
156 |
|
|
157 |
C If negative check for global file with MDS name (ie. fName.data) |
C If negative check for global file with MDS name (ie. fName.data) |
158 |
if (.NOT. globalFile) then |
if (.NOT. globalFile) then |
159 |
write(dataFname(1:80),'(2a)') fName(1:IL),'.data' |
write(dataFname,'(2a)') fName(1:IL),'.data' |
160 |
|
inquire( file=dataFname, exist=exst ) |
161 |
|
if (exst) globalFile = .TRUE. |
162 |
|
endif |
163 |
|
|
164 |
|
C If global file is visible to process 0, then open it here. |
165 |
|
C Otherwise stop program. |
166 |
|
if ( globalFile) then |
167 |
|
length_of_rec=MDS_RECLEN( filePrec, x_size*y_size, mythid ) |
168 |
|
open( dUnit, file=dataFName, status='old', |
169 |
|
& access='direct', recl=length_of_rec ) |
170 |
|
else |
171 |
|
write(msgbuf,'(2a)') |
172 |
|
& ' MDSREADFIELD: filename: ',dataFName(1:IL) |
173 |
|
call print_message( msgbuf, standardmessageunit, |
174 |
|
& SQUEEZE_RIGHT , mythid) |
175 |
|
call print_error( msgbuf, mythid ) |
176 |
|
write(msgbuf,'(a)') |
177 |
|
& ' MDSREADFIELD: File does not exist' |
178 |
|
call print_message( msgbuf, standardmessageunit, |
179 |
|
& SQUEEZE_RIGHT , mythid) |
180 |
|
call print_error( msgbuf, mythid ) |
181 |
|
stop 'ABNORMAL END: S/R MDSREADFIELD' |
182 |
|
endif |
183 |
|
|
184 |
|
ENDIF |
185 |
|
|
186 |
|
c-- useSingleCpuIO |
187 |
|
else |
188 |
|
C Only do I/O if I am the master thread |
189 |
|
|
190 |
|
C Check first for global file with simple name (ie. fName) |
191 |
|
dataFName = fName |
192 |
inquire( file=dataFname, exist=exst ) |
inquire( file=dataFname, exist=exst ) |
193 |
if (exst) then |
if (exst) then |
194 |
write(msgbuf,'(a,a)') |
write(msgbuf,'(a,a)') |
195 |
& ' MDSREADFIELD_GL: opening global file: ',dataFName |
& ' MDSREADFIELD: opening global file: ',dataFName(1:IL) |
196 |
call print_message( msgbuf, standardmessageunit, |
call print_message( msgbuf, standardmessageunit, |
197 |
& SQUEEZE_RIGHT , mythid) |
& SQUEEZE_RIGHT , mythid) |
|
globalFile = .TRUE. |
|
198 |
endif |
endif |
199 |
|
|
200 |
|
C If negative check for global file with MDS name (ie. fName.data) |
201 |
|
if (.NOT. globalFile) then |
202 |
|
write(dataFname,'(2a)') fName(1:IL),'.data' |
203 |
|
inquire( file=dataFname, exist=exst ) |
204 |
|
if (exst) then |
205 |
|
write(msgbuf,'(a,a)') |
206 |
|
& ' MDSREADFIELD_GL: opening global file: ',dataFName(1:IL+5) |
207 |
|
call print_message( msgbuf, standardmessageunit, |
208 |
|
& SQUEEZE_RIGHT , mythid) |
209 |
|
globalFile = .TRUE. |
210 |
|
endif |
211 |
|
endif |
212 |
|
|
213 |
|
c-- useSingleCpuIO |
214 |
endif |
endif |
215 |
|
|
216 |
if ( .not. ( globalFile .and. useSingleCPUIO ) ) then |
if ( .not. useSingleCpuIO ) then |
217 |
|
cph if ( .not. ( globalFile .and. useSingleCPUIO ) ) then |
218 |
|
if ( .not. ( globalFile ) ) then |
219 |
|
|
220 |
C If we are reading from a global file then we open it here |
C If we are reading from a global file then we open it here |
221 |
if (globalFile) then |
if (globalFile) then |
235 |
if (.NOT. globalFile) then |
if (.NOT. globalFile) then |
236 |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
237 |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
238 |
write(dataFname(1:80),'(2a,i3.3,a,i3.3,a)') |
write(dataFname,'(2a,i3.3,a,i3.3,a)') |
239 |
& fName(1:IL),'.',iG,'.',jG,'.data' |
& fName(1:IL),'.',iG,'.',jG,'.data' |
240 |
inquire( file=dataFname, exist=exst ) |
inquire( file=dataFname, exist=exst ) |
241 |
C Of course, we only open the file if the tile is "active" |
C Of course, we only open the file if the tile is "active" |
243 |
if (exst) then |
if (exst) then |
244 |
if ( debugLevel .GE. debLevA ) then |
if ( debugLevel .GE. debLevA ) then |
245 |
write(msgbuf,'(a,a)') |
write(msgbuf,'(a,a)') |
246 |
& ' MDSREADFIELD_GL: opening file: ',dataFName |
& ' MDSREADFIELD_GL: opening file: ',dataFName(1:IL+13) |
247 |
call print_message( msgbuf, standardmessageunit, |
call print_message( msgbuf, standardmessageunit, |
248 |
& SQUEEZE_RIGHT , mythid) |
& SQUEEZE_RIGHT , mythid) |
249 |
endif |
endif |
254 |
else |
else |
255 |
fileIsOpen=.FALSE. |
fileIsOpen=.FALSE. |
256 |
write(msgbuf,'(a,a)') |
write(msgbuf,'(a,a)') |
257 |
& ' MDSREADFIELD_GL: filename: ',dataFName |
& ' MDSREADFIELD_GL: filename: ',dataFName(1:IL+13) |
258 |
call print_message( msgbuf, standardmessageunit, |
call print_message( msgbuf, standardmessageunit, |
259 |
& SQUEEZE_RIGHT , mythid) |
& SQUEEZE_RIGHT , mythid) |
260 |
call print_error( msgbuf, mythid ) |
call print_error( msgbuf, mythid ) |
342 |
fileIsOpen = .FALSE. |
fileIsOpen = .FALSE. |
343 |
endif |
endif |
344 |
|
|
345 |
|
c end of if ( .not. ( globalFile ) ) then |
346 |
|
endif |
347 |
|
|
348 |
|
c else of if ( .not. ( globalFile .and. useSingleCPUIO ) ) then |
349 |
|
else |
350 |
|
|
351 |
|
DO k=1,nNz |
352 |
|
|
353 |
|
#ifdef ALLOW_USE_MPI |
354 |
|
IF( mpiMyId .EQ. 0 ) THEN |
355 |
|
#else |
356 |
|
IF ( .TRUE. ) THEN |
357 |
|
#endif /* ALLOW_USE_MPI */ |
358 |
|
irec = k+nNz*(irecord-1) |
359 |
|
if (filePrec .eq. precFloat32) then |
360 |
|
read(dUnit,rec=irec) xy_buffer_r4 |
361 |
|
#ifdef _BYTESWAPIO |
362 |
|
call MDS_BYTESWAPR4( x_size*y_size, xy_buffer_r4 ) |
363 |
|
#endif |
364 |
|
DO J=1,Ny |
365 |
|
DO I=1,Nx |
366 |
|
global(I,J) = xy_buffer_r4(I,J) |
367 |
|
ENDDO |
368 |
|
ENDDO |
369 |
|
elseif (filePrec .eq. precFloat64) then |
370 |
|
read(dUnit,rec=irec) xy_buffer_r8 |
371 |
|
#ifdef _BYTESWAPIO |
372 |
|
call MDS_BYTESWAPR8( x_size*y_size, xy_buffer_r8 ) |
373 |
|
#endif |
374 |
|
DO J=1,Ny |
375 |
|
DO I=1,Nx |
376 |
|
global(I,J) = xy_buffer_r8(I,J) |
377 |
|
ENDDO |
378 |
|
ENDDO |
379 |
|
else |
380 |
|
write(msgbuf,'(a)') |
381 |
|
& ' MDSREADFIELD: illegal value for filePrec' |
382 |
|
call print_error( msgbuf, mythid ) |
383 |
|
stop 'ABNORMAL END: S/R MDSREADFIELD' |
384 |
|
endif |
385 |
|
ENDIF |
386 |
|
DO jp=1,nPy |
387 |
|
DO ip=1,nPx |
388 |
|
DO bj = myByLo(myThid), myByHi(myThid) |
389 |
|
DO bi = myBxLo(myThid), myBxHi(myThid) |
390 |
|
DO J=1,sNy |
391 |
|
JJ=((jp-1)*nSy+(bj-1))*sNy+J |
392 |
|
DO I=1,sNx |
393 |
|
II=((ip-1)*nSx+(bi-1))*sNx+I |
394 |
|
arr_gl(i,bi,ip,j,bj,jp,k) = global(II,JJ) |
395 |
|
ENDDO |
396 |
|
ENDDO |
397 |
|
ENDDO |
398 |
|
ENDDO |
399 |
|
ENDDO |
400 |
|
ENDDO |
401 |
|
|
402 |
|
ENDDO |
403 |
|
c ENDDO k=1,nNz |
404 |
|
|
405 |
|
close( dUnit ) |
406 |
|
|
407 |
endif |
endif |
408 |
c end of if ( .not. ( globalFile .and. useSingleCPUIO ) ) then |
c end of if ( .not. ( globalFile .and. useSingleCPUIO ) ) then |
409 |
|
|
484 |
integer ILNBLNK |
integer ILNBLNK |
485 |
integer MDS_RECLEN |
integer MDS_RECLEN |
486 |
C Local variables |
C Local variables |
487 |
character*(80) dataFName,metaFName |
character*(MAX_LEN_FNAM) dataFName,metaFName |
488 |
integer ip,jp,iG,jG,irec,bi,bj,i,j,k,dUnit,IL |
integer ip,jp,iG,jG,irec,bi,bj,i,j,k,dUnit,IL |
489 |
Real*4 r4seg(sNx) |
Real*4 r4seg(sNx) |
490 |
Real*8 r8seg(sNx) |
Real*8 r8seg(sNx) |
494 |
logical fileIsOpen |
logical fileIsOpen |
495 |
character*(max_len_mbuf) msgbuf |
character*(max_len_mbuf) msgbuf |
496 |
cph-usesingle( |
cph-usesingle( |
497 |
|
#ifdef ALLOW_USE_MPI |
498 |
integer ii,jj |
integer ii,jj |
499 |
integer x_size,y_size,iG_IO,jG_IO,npe |
c integer iG_IO,jG_IO,npe |
500 |
|
integer x_size,y_size |
501 |
PARAMETER ( x_size = Nx ) |
PARAMETER ( x_size = Nx ) |
502 |
PARAMETER ( y_size = Ny ) |
PARAMETER ( y_size = Ny ) |
503 |
Real*4 xy_buffer_r4(x_size,y_size) |
Real*4 xy_buffer_r4(x_size,y_size) |
504 |
Real*8 xy_buffer_r8(x_size,y_size) |
Real*8 xy_buffer_r8(x_size,y_size) |
505 |
Real*8 global(Nx,Ny) |
Real*8 global(Nx,Ny) |
506 |
|
#endif |
507 |
cph-usesingle) |
cph-usesingle) |
508 |
|
CMM( |
509 |
|
integer pIL |
510 |
|
CMM) |
511 |
|
|
512 |
C ------------------------------------------------------------------ |
C ------------------------------------------------------------------ |
513 |
|
|
529 |
C Assume nothing |
C Assume nothing |
530 |
fileIsOpen=.FALSE. |
fileIsOpen=.FALSE. |
531 |
IL=ILNBLNK( fName ) |
IL=ILNBLNK( fName ) |
532 |
|
CMM( |
533 |
|
pIL = ILNBLNK( mdsioLocalDir ) |
534 |
|
CMM) |
535 |
|
CMM( |
536 |
|
C Assign special directory |
537 |
|
if ( pIL.NE.0 ) then |
538 |
|
write(fName,'(2a)') mdsioLocalDir(1:pIL), fName(1:IL) |
539 |
|
endif |
540 |
|
CMM) |
541 |
|
|
542 |
C Assign a free unit number as the I/O channel for this routine |
C Assign a free unit number as the I/O channel for this routine |
543 |
call MDSFINDUNIT( dUnit, mythid ) |
call MDSFINDUNIT( dUnit, mythid ) |
552 |
C Master thread of process 0, only, opens a global file |
C Master thread of process 0, only, opens a global file |
553 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
554 |
IF( mpiMyId .EQ. 0 ) THEN |
IF( mpiMyId .EQ. 0 ) THEN |
555 |
write(dataFname(1:80),'(2a)') fName(1:IL),'.data' |
write(dataFname,'(2a)') fName(1:IL),'.data' |
556 |
length_of_rec=MDS_RECLEN(filePrec,x_size*y_size,mythid) |
length_of_rec=MDS_RECLEN(filePrec,x_size*y_size,mythid) |
557 |
if (irecord .EQ. 1) then |
if (irecord .EQ. 1) then |
558 |
open( dUnit, file=dataFName, status=_NEW_STATUS, |
open( dUnit, file=dataFName, status=_NEW_STATUS, |
619 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
620 |
IF( mpiMyId .EQ. 0 ) THEN |
IF( mpiMyId .EQ. 0 ) THEN |
621 |
close( dUnit ) |
close( dUnit ) |
622 |
write(metaFName(1:80),'(2a)') fName(1:IL),'.meta' |
write(metaFName,'(2a)') fName(1:IL),'.meta' |
623 |
dimList(1,1)=Nx |
dimList(1,1)=Nx |
624 |
dimList(2,1)=1 |
dimList(2,1)=1 |
625 |
dimList(3,1)=Nx |
dimList(3,1)=Nx |
652 |
C If we are writing to a tiled MDS file then we open each one here |
C If we are writing to a tiled MDS file then we open each one here |
653 |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
654 |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
655 |
write(dataFname(1:80),'(2a,i3.3,a,i3.3,a)') |
write(dataFname,'(2a,i3.3,a,i3.3,a)') |
656 |
& fName(1:IL),'.',iG,'.',jG,'.data' |
& fName(1:IL),'.',iG,'.',jG,'.data' |
657 |
if (irecord .EQ. 1) then |
if (irecord .EQ. 1) then |
658 |
length_of_rec=MDS_RECLEN( filePrec, sNx, mythid ) |
length_of_rec=MDS_RECLEN( filePrec, sNx, mythid ) |
668 |
if (fileIsOpen) then |
if (fileIsOpen) then |
669 |
do k=1,Nr |
do k=1,Nr |
670 |
do j=1,sNy |
do j=1,sNy |
671 |
do ii=1,sNx |
do i=1,sNx |
672 |
arr(ii,j,k,bi,bj)=arr_gl(ii,bi,ip,j,bj,jp,k) |
arr(i,j,k,bi,bj)=arr_gl(i,bi,ip,j,bj,jp,k) |
673 |
enddo |
enddo |
674 |
iG = 0 |
iG = 0 |
675 |
jG = 0 |
jG = 0 |
728 |
C Create meta-file for each tile if we are tiling |
C Create meta-file for each tile if we are tiling |
729 |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
730 |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
731 |
write(metaFname(1:80),'(2a,i3.3,a,i3.3,a)') |
write(metaFname,'(2a,i3.3,a,i3.3,a)') |
732 |
& fName(1:IL),'.',iG,'.',jG,'.meta' |
& fName(1:IL),'.',iG,'.',jG,'.meta' |
733 |
dimList(1,1)=Nx |
dimList(1,1)=Nx |
734 |
dimList(2,1)=((ip-1)*nSx+(bi-1))*sNx+1 |
dimList(2,1)=((ip-1)*nSx+(bi-1))*sNx+1 |
821 |
integer ILNBLNK |
integer ILNBLNK |
822 |
integer MDS_RECLEN |
integer MDS_RECLEN |
823 |
C Local variables |
C Local variables |
824 |
character*(80) dataFName |
character*(MAX_LEN_FNAM) dataFName |
825 |
integer ip,jp,iG,jG,irec,bi,bj,ii,j,k,dUnit,IL |
integer ip,jp,iG,jG,irec,bi,bj,i,j,k,dUnit,IL |
826 |
logical exst |
logical exst |
827 |
_RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,nLocz,nSx,nSy) |
_RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,nLocz,nSx,nSy) |
828 |
Real*4 r4seg(sNx) |
Real*4 r4seg(sNx) |
830 |
logical globalFile,fileIsOpen |
logical globalFile,fileIsOpen |
831 |
integer length_of_rec |
integer length_of_rec |
832 |
character*(max_len_mbuf) msgbuf |
character*(max_len_mbuf) msgbuf |
833 |
|
cph-usesingle( |
834 |
|
integer ii,jj |
835 |
|
c integer iG_IO,jG_IO,npe |
836 |
|
integer x_size,y_size |
837 |
|
PARAMETER ( x_size = Nx ) |
838 |
|
PARAMETER ( y_size = Ny ) |
839 |
|
Real*4 xy_buffer_r4(x_size,y_size) |
840 |
|
Real*8 xy_buffer_r8(x_size,y_size) |
841 |
|
Real*8 global(Nx,Ny) |
842 |
|
c _RL local(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
843 |
|
cph-usesingle) |
844 |
|
CMM( |
845 |
|
integer pIL |
846 |
|
CMM) |
847 |
|
|
848 |
C ------------------------------------------------------------------ |
C ------------------------------------------------------------------ |
849 |
|
|
850 |
C Only do I/O if I am the master thread |
C Only do I/O if I am the master thread |
866 |
globalFile = .FALSE. |
globalFile = .FALSE. |
867 |
fileIsOpen = .FALSE. |
fileIsOpen = .FALSE. |
868 |
IL=ILNBLNK( fName ) |
IL=ILNBLNK( fName ) |
869 |
|
CMM( |
870 |
|
pIL = ILNBLNK( mdsioLocalDir ) |
871 |
|
CMM) |
872 |
|
CMM( |
873 |
|
C Assign special directory |
874 |
|
if ( pIL.NE.0 ) then |
875 |
|
write(fName,'(2a)') mdsioLocalDir(1:pIL), fName(1:IL) |
876 |
|
endif |
877 |
|
CMM) |
878 |
|
|
879 |
C Assign a free unit number as the I/O channel for this routine |
C Assign a free unit number as the I/O channel for this routine |
880 |
call MDSFINDUNIT( dUnit, mythid ) |
call MDSFINDUNIT( dUnit, mythid ) |
881 |
|
|
882 |
|
if ( useSingleCPUIO ) then |
883 |
|
|
884 |
|
C master thread of process 0, only, opens a global file |
885 |
|
#ifdef ALLOW_USE_MPI |
886 |
|
IF( mpiMyId .EQ. 0 ) THEN |
887 |
|
#else |
888 |
|
IF ( .TRUE. ) THEN |
889 |
|
#endif /* ALLOW_USE_MPI */ |
890 |
|
|
891 |
C Check first for global file with simple name (ie. fName) |
C Check first for global file with simple name (ie. fName) |
892 |
dataFName = fName |
dataFName = fName |
893 |
inquire( file=dataFname, exist=exst ) |
inquire( file=dataFname, exist=exst ) |
894 |
if (exst) then |
if (exst) globalFile = .TRUE. |
|
write(msgbuf,'(a,a)') |
|
|
& ' MDSREADFIELD: opening global file: ',dataFName |
|
|
call print_message( msgbuf, standardmessageunit, |
|
|
& SQUEEZE_RIGHT , mythid) |
|
|
endif |
|
895 |
|
|
896 |
C If negative check for global file with MDS name (ie. fName.data) |
C If negative check for global file with MDS name (ie. fName.data) |
897 |
if (.NOT. globalFile) then |
if (.NOT. globalFile) then |
898 |
write(dataFname(1:80),'(2a)') fName(1:IL),'.data' |
write(dataFname,'(2a)') fName(1:IL),'.data' |
899 |
|
inquire( file=dataFname, exist=exst ) |
900 |
|
if (exst) globalFile = .TRUE. |
901 |
|
endif |
902 |
|
|
903 |
|
C If global file is visible to process 0, then open it here. |
904 |
|
C Otherwise stop program. |
905 |
|
if ( globalFile) then |
906 |
|
length_of_rec=MDS_RECLEN( filePrec, x_size*y_size, mythid ) |
907 |
|
open( dUnit, file=dataFName, status='old', |
908 |
|
& access='direct', recl=length_of_rec ) |
909 |
|
else |
910 |
|
write(msgbuf,'(2a)') |
911 |
|
& ' MDSREADFIELD: filename: ',dataFName(1:IL) |
912 |
|
call print_message( msgbuf, standardmessageunit, |
913 |
|
& SQUEEZE_RIGHT , mythid) |
914 |
|
call print_error( msgbuf, mythid ) |
915 |
|
write(msgbuf,'(a)') |
916 |
|
& ' MDSREADFIELD: File does not exist' |
917 |
|
call print_message( msgbuf, standardmessageunit, |
918 |
|
& SQUEEZE_RIGHT , mythid) |
919 |
|
call print_error( msgbuf, mythid ) |
920 |
|
stop 'ABNORMAL END: S/R MDSREADFIELD' |
921 |
|
endif |
922 |
|
|
923 |
|
ENDIF |
924 |
|
|
925 |
|
c-- useSingleCpuIO |
926 |
|
else |
927 |
|
|
928 |
|
C Check first for global file with simple name (ie. fName) |
929 |
|
dataFName = fName |
930 |
inquire( file=dataFname, exist=exst ) |
inquire( file=dataFname, exist=exst ) |
931 |
if (exst) then |
if (exst) then |
932 |
write(msgbuf,'(a,a)') |
write(msgbuf,'(a,a)') |
933 |
& ' MDSREADFIELD_GL: opening global file: ',dataFName |
& ' MDSREADFIELD: opening global file: ',dataFName(1:IL) |
934 |
call print_message( msgbuf, standardmessageunit, |
call print_message( msgbuf, standardmessageunit, |
935 |
& SQUEEZE_RIGHT , mythid) |
& SQUEEZE_RIGHT , mythid) |
|
globalFile = .TRUE. |
|
936 |
endif |
endif |
937 |
|
|
938 |
|
C If negative check for global file with MDS name (ie. fName.data) |
939 |
|
if (.NOT. globalFile) then |
940 |
|
write(dataFname,'(2a)') fName(1:IL),'.data' |
941 |
|
inquire( file=dataFname, exist=exst ) |
942 |
|
if (exst) then |
943 |
|
write(msgbuf,'(a,a)') |
944 |
|
& ' MDSREADFIELD_GL: opening global file: ',dataFName(1:IL+5) |
945 |
|
call print_message( msgbuf, standardmessageunit, |
946 |
|
& SQUEEZE_RIGHT , mythid) |
947 |
|
globalFile = .TRUE. |
948 |
|
endif |
949 |
|
endif |
950 |
|
|
951 |
|
c-- useSingleCpuIO |
952 |
endif |
endif |
953 |
|
|
954 |
if ( .not. ( globalFile .and. useSingleCPUIO ) ) then |
if ( .not. useSingleCpuIO ) then |
955 |
|
cph if ( .not. ( globalFile .and. useSingleCPUIO ) ) then |
956 |
|
if ( .not. ( globalFile ) ) then |
957 |
|
|
958 |
C If we are reading from a global file then we open it here |
C If we are reading from a global file then we open it here |
959 |
if (globalFile) then |
if (globalFile) then |
973 |
if (.NOT. globalFile) then |
if (.NOT. globalFile) then |
974 |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
975 |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
976 |
write(dataFname(1:80),'(2a,i3.3,a,i3.3,a)') |
write(dataFname,'(2a,i3.3,a,i3.3,a)') |
977 |
& fName(1:IL),'.',iG,'.',jG,'.data' |
& fName(1:IL),'.',iG,'.',jG,'.data' |
978 |
inquire( file=dataFname, exist=exst ) |
inquire( file=dataFname, exist=exst ) |
979 |
C Of course, we only open the file if the tile is "active" |
C Of course, we only open the file if the tile is "active" |
981 |
if (exst) then |
if (exst) then |
982 |
if ( debugLevel .GE. debLevA ) then |
if ( debugLevel .GE. debLevA ) then |
983 |
write(msgbuf,'(a,a)') |
write(msgbuf,'(a,a)') |
984 |
& ' MDSREADFIELD_GL: opening file: ',dataFName |
& ' MDSREADFIELD_GL: opening file: ',dataFName(1:IL+13) |
985 |
call print_message( msgbuf, standardmessageunit, |
call print_message( msgbuf, standardmessageunit, |
986 |
& SQUEEZE_RIGHT , mythid) |
& SQUEEZE_RIGHT , mythid) |
987 |
endif |
endif |
992 |
else |
else |
993 |
fileIsOpen=.FALSE. |
fileIsOpen=.FALSE. |
994 |
write(msgbuf,'(a,a)') |
write(msgbuf,'(a,a)') |
995 |
& ' MDSREADFIELD_GL: filename: ',dataFName |
& ' MDSREADFIELD_GL: filename: ',dataFName(1:IL+13) |
996 |
call print_message( msgbuf, standardmessageunit, |
call print_message( msgbuf, standardmessageunit, |
997 |
& SQUEEZE_RIGHT , mythid) |
& SQUEEZE_RIGHT , mythid) |
998 |
call print_error( msgbuf, mythid ) |
call print_error( msgbuf, mythid ) |
1080 |
fileIsOpen = .FALSE. |
fileIsOpen = .FALSE. |
1081 |
endif |
endif |
1082 |
|
|
1083 |
|
c end of if ( .not. ( globalFile ) ) then |
1084 |
|
endif |
1085 |
|
|
1086 |
|
c else of if ( .not. ( globalFile .and. useSingleCPUIO ) ) then |
1087 |
|
else |
1088 |
|
|
1089 |
|
DO k=1,nLocz |
1090 |
|
|
1091 |
|
#ifdef ALLOW_USE_MPI |
1092 |
|
IF( mpiMyId .EQ. 0 ) THEN |
1093 |
|
#else |
1094 |
|
IF ( .TRUE. ) THEN |
1095 |
|
#endif /* ALLOW_USE_MPI */ |
1096 |
|
irec = k+nNz*(irecord-1) |
1097 |
|
if (filePrec .eq. precFloat32) then |
1098 |
|
read(dUnit,rec=irec) xy_buffer_r4 |
1099 |
|
#ifdef _BYTESWAPIO |
1100 |
|
call MDS_BYTESWAPR4( x_size*y_size, xy_buffer_r4 ) |
1101 |
|
#endif |
1102 |
|
DO J=1,Ny |
1103 |
|
DO I=1,Nx |
1104 |
|
global(I,J) = xy_buffer_r4(I,J) |
1105 |
|
ENDDO |
1106 |
|
ENDDO |
1107 |
|
elseif (filePrec .eq. precFloat64) then |
1108 |
|
read(dUnit,rec=irec) xy_buffer_r8 |
1109 |
|
#ifdef _BYTESWAPIO |
1110 |
|
call MDS_BYTESWAPR8( x_size*y_size, xy_buffer_r8 ) |
1111 |
|
#endif |
1112 |
|
DO J=1,Ny |
1113 |
|
DO I=1,Nx |
1114 |
|
global(I,J) = xy_buffer_r8(I,J) |
1115 |
|
ENDDO |
1116 |
|
ENDDO |
1117 |
|
else |
1118 |
|
write(msgbuf,'(a)') |
1119 |
|
& ' MDSREADFIELD: illegal value for filePrec' |
1120 |
|
call print_error( msgbuf, mythid ) |
1121 |
|
stop 'ABNORMAL END: S/R MDSREADFIELD' |
1122 |
|
endif |
1123 |
|
ENDIF |
1124 |
|
DO jp=1,nPy |
1125 |
|
DO ip=1,nPx |
1126 |
|
DO bj = myByLo(myThid), myByHi(myThid) |
1127 |
|
DO bi = myBxLo(myThid), myBxHi(myThid) |
1128 |
|
DO J=1,sNy |
1129 |
|
JJ=((jp-1)*nSy+(bj-1))*sNy+J |
1130 |
|
DO I=1,sNx |
1131 |
|
II=((ip-1)*nSx+(bi-1))*sNx+I |
1132 |
|
arr_gl(i,bi,ip,j,bj,jp,k) = global(II,JJ) |
1133 |
|
ENDDO |
1134 |
|
ENDDO |
1135 |
|
ENDDO |
1136 |
|
ENDDO |
1137 |
|
ENDDO |
1138 |
|
ENDDO |
1139 |
|
|
1140 |
|
ENDDO |
1141 |
|
c ENDDO k=1,nNz |
1142 |
|
|
1143 |
|
close( dUnit ) |
1144 |
|
|
1145 |
endif |
endif |
1146 |
c end of if ( .not. ( globalFile .and. useSingleCPUIO ) ) then |
c end of if ( .not. ( globalFile .and. useSingleCPUIO ) ) then |
1147 |
|
|
1223 |
integer ILNBLNK |
integer ILNBLNK |
1224 |
integer MDS_RECLEN |
integer MDS_RECLEN |
1225 |
C Local variables |
C Local variables |
1226 |
character*(80) dataFName,metaFName |
character*(MAX_LEN_FNAM) dataFName,metaFName |
1227 |
integer ip,jp,iG,jG,irec,bi,bj,i,j,k,dUnit,IL |
integer ip,jp,iG,jG,irec,bi,bj,i,j,k,dUnit,IL |
1228 |
Real*4 r4seg(sNx) |
Real*4 r4seg(sNx) |
1229 |
Real*8 r8seg(sNx) |
Real*8 r8seg(sNx) |
1233 |
logical fileIsOpen |
logical fileIsOpen |
1234 |
character*(max_len_mbuf) msgbuf |
character*(max_len_mbuf) msgbuf |
1235 |
cph-usesingle( |
cph-usesingle( |
1236 |
|
#ifdef ALLOW_USE_MPI |
1237 |
integer ii,jj |
integer ii,jj |
1238 |
integer x_size,y_size,iG_IO,jG_IO,npe |
c integer iG_IO,jG_IO,npe |
1239 |
|
integer x_size,y_size |
1240 |
PARAMETER ( x_size = Nx ) |
PARAMETER ( x_size = Nx ) |
1241 |
PARAMETER ( y_size = Ny ) |
PARAMETER ( y_size = Ny ) |
1242 |
Real*4 xy_buffer_r4(x_size,y_size) |
Real*4 xy_buffer_r4(x_size,y_size) |
1243 |
Real*8 xy_buffer_r8(x_size,y_size) |
Real*8 xy_buffer_r8(x_size,y_size) |
1244 |
Real*8 global(Nx,Ny) |
Real*8 global(Nx,Ny) |
1245 |
|
#endif |
1246 |
cph-usesingle) |
cph-usesingle) |
1247 |
|
CMM( |
1248 |
|
integer pIL |
1249 |
|
CMM) |
1250 |
|
|
1251 |
C ------------------------------------------------------------------ |
C ------------------------------------------------------------------ |
1252 |
|
|
1268 |
C Assume nothing |
C Assume nothing |
1269 |
fileIsOpen=.FALSE. |
fileIsOpen=.FALSE. |
1270 |
IL=ILNBLNK( fName ) |
IL=ILNBLNK( fName ) |
1271 |
|
CMM( |
1272 |
|
pIL = ILNBLNK( mdsioLocalDir ) |
1273 |
|
CMM) |
1274 |
|
CMM( |
1275 |
|
C Assign special directory |
1276 |
|
if ( pIL.NE.0 ) then |
1277 |
|
write(fName,'(2a)') mdsioLocalDir(1:pIL), fName(1:IL) |
1278 |
|
endif |
1279 |
|
CMM) |
1280 |
|
|
1281 |
C Assign a free unit number as the I/O channel for this routine |
C Assign a free unit number as the I/O channel for this routine |
1282 |
call MDSFINDUNIT( dUnit, mythid ) |
call MDSFINDUNIT( dUnit, mythid ) |
1292 |
C Master thread of process 0, only, opens a global file |
C Master thread of process 0, only, opens a global file |
1293 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
1294 |
IF( mpiMyId .EQ. 0 ) THEN |
IF( mpiMyId .EQ. 0 ) THEN |
1295 |
write(dataFname(1:80),'(2a)') fName(1:IL),'.data' |
write(dataFname,'(2a)') fName(1:IL),'.data' |
1296 |
length_of_rec=MDS_RECLEN(filePrec,x_size*y_size,mythid) |
length_of_rec=MDS_RECLEN(filePrec,x_size*y_size,mythid) |
1297 |
if (irecord .EQ. 1) then |
if (irecord .EQ. 1) then |
1298 |
open( dUnit, file=dataFName, status=_NEW_STATUS, |
open( dUnit, file=dataFName, status=_NEW_STATUS, |
1359 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
1360 |
IF( mpiMyId .EQ. 0 ) THEN |
IF( mpiMyId .EQ. 0 ) THEN |
1361 |
close( dUnit ) |
close( dUnit ) |
1362 |
write(metaFName(1:80),'(2a)') fName(1:IL),'.meta' |
write(metaFName,'(2a)') fName(1:IL),'.meta' |
1363 |
dimList(1,1)=Nx |
dimList(1,1)=Nx |
1364 |
dimList(2,1)=1 |
dimList(2,1)=1 |
1365 |
dimList(3,1)=Nx |
dimList(3,1)=Nx |
1392 |
C If we are writing to a tiled MDS file then we open each one here |
C If we are writing to a tiled MDS file then we open each one here |
1393 |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
1394 |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
1395 |
write(dataFname(1:80),'(2a,i3.3,a,i3.3,a)') |
write(dataFname,'(2a,i3.3,a,i3.3,a)') |
1396 |
& fName(1:IL),'.',iG,'.',jG,'.data' |
& fName(1:IL),'.',iG,'.',jG,'.data' |
1397 |
if (irecord .EQ. 1) then |
if (irecord .EQ. 1) then |
1398 |
length_of_rec=MDS_RECLEN( filePrec, sNx, mythid ) |
length_of_rec=MDS_RECLEN( filePrec, sNx, mythid ) |
1408 |
if (fileIsOpen) then |
if (fileIsOpen) then |
1409 |
do k=1,nLocz |
do k=1,nLocz |
1410 |
do j=1,sNy |
do j=1,sNy |
1411 |
do ii=1,sNx |
do i=1,sNx |
1412 |
arr(ii,j,k,bi,bj)=arr_gl(ii,bi,ip,j,bj,jp,k) |
arr(i,j,k,bi,bj)=arr_gl(i,bi,ip,j,bj,jp,k) |
1413 |
enddo |
enddo |
1414 |
iG = 0 |
iG = 0 |
1415 |
jG = 0 |
jG = 0 |
1468 |
C Create meta-file for each tile if we are tiling |
C Create meta-file for each tile if we are tiling |
1469 |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles |
1470 |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles |
1471 |
write(metaFname(1:80),'(2a,i3.3,a,i3.3,a)') |
write(metaFname,'(2a,i3.3,a,i3.3,a)') |
1472 |
& fName(1:IL),'.',iG,'.',jG,'.meta' |
& fName(1:IL),'.',iG,'.',jG,'.meta' |
1473 |
dimList(1,1)=Nx |
dimList(1,1)=Nx |
1474 |
dimList(2,1)=((ip-1)*nSx+(bi-1))*sNx+1 |
dimList(2,1)=((ip-1)*nSx+(bi-1))*sNx+1 |