40 |
#endif /* ALLOW_USE_MPI */ |
#endif /* ALLOW_USE_MPI */ |
41 |
#include "PARAMS.h" |
#include "PARAMS.h" |
42 |
|
|
43 |
|
#ifdef EXF_IREAD_USE_GLOBAL_POINTER |
44 |
|
C When using threads the address of the local automatic array |
45 |
|
C "global" is not visible to the other threads. So we create |
46 |
|
C a pointer to share that address here. This is presently |
47 |
|
C in an ifdef because it won't go through g77 and I'm not |
48 |
|
C currently sure what TAF would do with this. |
49 |
|
COMMON /EXF_IOPTR/ glPtr |
50 |
|
REAL*4, POINTER :: glPtr(:,:) |
51 |
|
#endif |
52 |
|
|
53 |
C subroutine variables |
C subroutine variables |
54 |
character*(*) infile |
character*(*) infile |
55 |
integer filePrec, irecord, nx_in, ny_in |
integer filePrec, irecord, nx_in, ny_in |
72 |
external lagran |
external lagran |
73 |
real*8 lagran |
real*8 lagran |
74 |
integer i, j, k, l, js, bi, bj, sp, interp_unit |
integer i, j, k, l, js, bi, bj, sp, interp_unit |
75 |
|
#ifdef EXF_IREAD_USE_GLOBAL_POINTER |
76 |
|
real*4, target :: global(nx_in,ny_in) |
77 |
|
#else |
78 |
real*4 global(nx_in,ny_in) |
real*4 global(nx_in,ny_in) |
79 |
|
#endif |
80 |
|
|
81 |
C _BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
82 |
|
|
83 |
|
#ifndef EXF_IREAD_USE_GLOBAL_POINTER |
84 |
|
C The CPP symbol EXF_IREAD_USE_GLOBAL_POINTER must be defined for the |
85 |
|
C case of nThreads > 1. Stop if it isnt. |
86 |
|
IF ( nThreads .GT. 1 ) THEN |
87 |
|
STOP |
88 |
|
&'EXF_INTERP_READ: nThreads > 1 needs EXF_IREAD_USE_GLOBAL_POINTER' |
89 |
|
ENDIF |
90 |
|
#endif |
91 |
C check input arguments |
C check input arguments |
92 |
if ( .NOT. (filePrec .EQ. 32) ) |
if ( .NOT. (filePrec .EQ. 32) ) |
93 |
& stop 'stop in exf_interp.F: value of filePrec not allowed' |
& stop 'stop in exf_interp.F: value of filePrec not allowed' |
94 |
|
|
95 |
C read in input data |
C read in input data |
96 |
#ifdef ALLOW_USE_MPI |
#ifdef ALLOW_USE_MPI |
97 |
if (useSingleCPUIO) then |
C if (useSingleCPUIO) then |
98 |
|
if (.FALSE.) then |
99 |
|
|
100 |
C master thread of process 0, only, opens a global file |
C master thread of process 0, only, opens a global file |
101 |
IF( mpiMyId .EQ. 0 ) THEN |
IF( mpiMyId .EQ. 0 ) THEN |
111 |
C broadcast to all processes |
C broadcast to all processes |
112 |
call MPI_BCAST(global,nx_in*ny_in,MPI_REAL, |
call MPI_BCAST(global,nx_in*ny_in,MPI_REAL, |
113 |
& 0,MPI_COMM_MODEL,ierr) |
& 0,MPI_COMM_MODEL,ierr) |
|
do j=1,ny_in |
|
|
do i=1,nx_in |
|
|
arrayin(i,j)=global(i,j) |
|
|
enddo |
|
|
enddo |
|
|
|
|
114 |
else |
else |
115 |
#endif /* ALLOW_USE_MPI */ |
#endif /* ALLOW_USE_MPI */ |
116 |
|
|
118 |
length_of_rec=MDS_RECLEN( filePrec, nx_in*ny_in, mythid ) |
length_of_rec=MDS_RECLEN( filePrec, nx_in*ny_in, mythid ) |
119 |
open(interp_unit,file=infile,status='old',access='direct', |
open(interp_unit,file=infile,status='old',access='direct', |
120 |
& recl=length_of_rec) |
& recl=length_of_rec) |
121 |
read(interp_unit,rec=irecord) |
read(interp_unit,rec=irecord) global |
|
& ((arrayin(i,j),i=1,nx_in),j=1,ny_in) |
|
122 |
close(interp_unit) |
close(interp_unit) |
123 |
|
|
124 |
#ifdef ALLOW_USE_MPI |
#ifdef ALLOW_USE_MPI |
125 |
endif |
endif |
126 |
#endif /* ALLOW_USE_MPI */ |
#endif /* ALLOW_USE_MPI */ |
127 |
|
#ifdef EXF_IREAD_USE_GLOBAL_POINTER |
128 |
|
glPtr => global |
129 |
|
#endif |
130 |
|
_END_MASTER( myThid ) |
131 |
|
_BARRIER |
132 |
|
#ifdef EXF_IREAD_USE_GLOBAL_POINTER |
133 |
|
do j=1,ny_in |
134 |
|
do i=1,nx_in |
135 |
|
arrayin(i,j)=glPtr(i,j) |
136 |
|
enddo |
137 |
|
enddo |
138 |
|
#else |
139 |
|
do j=1,ny_in |
140 |
|
do i=1,nx_in |
141 |
|
arrayin(i,j)=global(i,j) |
142 |
|
enddo |
143 |
|
enddo |
144 |
|
#endif |
145 |
|
|
146 |
#ifdef _BYTESWAPIO |
#ifdef _BYTESWAPIO |
147 |
call MDS_BYTESWAPR4((nx_in+4)*(ny_in+4), arrayin ) |
call MDS_BYTESWAPR4((nx_in+4)*(ny_in+4), arrayin ) |
148 |
#endif /* _BYTESWAPIO */ |
#endif /* _BYTESWAPIO */ |
149 |
|
|
|
C _END_MASTER( myThid ) |
|
150 |
|
|
151 |
END |
END |