1 |
jmc |
1.5 |
C $Header: $ |
2 |
|
|
C $Name: $ |
3 |
|
|
|
4 |
heimbach |
1.1 |
#include "EXF_OPTIONS.h" |
5 |
|
|
|
6 |
|
|
SUBROUTINE exf_interp_read( |
7 |
dimitri |
1.4 |
I infile, filePrec, |
8 |
heimbach |
1.1 |
O arrayin, |
9 |
dimitri |
1.4 |
I irecord, nx_in, ny_in, mythid) |
10 |
heimbach |
1.1 |
|
11 |
|
|
implicit none |
12 |
|
|
|
13 |
|
|
C infile = name of the input file (direct access binary) |
14 |
|
|
C filePrec = file precicision (currently not used, assumes real*4) |
15 |
|
|
C arrout = output arrays (different for each processor) |
16 |
|
|
C irecord = record number in global file |
17 |
|
|
C nx_in, ny_in = input x-grid and y-grid size |
18 |
|
|
C mythid = thread id |
19 |
|
|
|
20 |
|
|
#include "SIZE.h" |
21 |
|
|
#include "EEPARAMS.h" |
22 |
|
|
#ifdef ALLOW_USE_MPI |
23 |
|
|
# include "EESUPPORT.h" |
24 |
|
|
#endif /* ALLOW_USE_MPI */ |
25 |
|
|
#include "PARAMS.h" |
26 |
|
|
|
27 |
cnh |
1.3 |
#ifdef EXF_IREAD_USE_GLOBAL_POINTER |
28 |
|
|
C When using threads the address of the local automatic array |
29 |
|
|
C "global" is not visible to the other threads. So we create |
30 |
|
|
C a pointer to share that address here. This is presently |
31 |
|
|
C in an ifdef because it won't go through g77 and I'm not |
32 |
|
|
C currently sure what TAF would do with this. |
33 |
|
|
COMMON /EXF_IOPTR/ glPtr |
34 |
|
|
REAL*4, POINTER :: glPtr(:,:) |
35 |
|
|
#endif |
36 |
|
|
|
37 |
heimbach |
1.1 |
C subroutine variables |
38 |
|
|
character*(*) infile |
39 |
|
|
integer filePrec, irecord, nx_in, ny_in |
40 |
|
|
real*4 arrayin(-1:nx_in+2 , -1:ny_in+2) |
41 |
dimitri |
1.4 |
integer mythid |
42 |
heimbach |
1.1 |
|
43 |
|
|
C Functions |
44 |
|
|
integer MDS_RECLEN |
45 |
|
|
|
46 |
|
|
C local variables |
47 |
|
|
integer ierr, length_of_rec |
48 |
|
|
real*8 ne_fac,nw_fac,se_fac,sw_fac |
49 |
|
|
integer e_ind(snx,sny),w_ind(snx,sny) |
50 |
|
|
integer n_ind(snx,sny),s_ind(snx,sny) |
51 |
|
|
real*8 px_ind(4), py_ind(4), ew_val(4) |
52 |
|
|
external lagran |
53 |
|
|
real*8 lagran |
54 |
|
|
integer i, j, k, l, js, bi, bj, sp, interp_unit |
55 |
cnh |
1.3 |
#ifdef EXF_IREAD_USE_GLOBAL_POINTER |
56 |
|
|
real*4, target :: global(nx_in,ny_in) |
57 |
|
|
#else |
58 |
heimbach |
1.1 |
real*4 global(nx_in,ny_in) |
59 |
cnh |
1.3 |
#endif |
60 |
heimbach |
1.1 |
|
61 |
jmc |
1.5 |
_BARRIER |
62 |
cnh |
1.3 |
_BEGIN_MASTER( myThid ) |
63 |
heimbach |
1.1 |
|
64 |
cnh |
1.3 |
#ifndef EXF_IREAD_USE_GLOBAL_POINTER |
65 |
|
|
C The CPP symbol EXF_IREAD_USE_GLOBAL_POINTER must be defined for the |
66 |
|
|
C case of nThreads > 1. Stop if it isnt. |
67 |
|
|
IF ( nThreads .GT. 1 ) THEN |
68 |
|
|
STOP |
69 |
|
|
&'EXF_INTERP_READ: nThreads > 1 needs EXF_IREAD_USE_GLOBAL_POINTER' |
70 |
|
|
ENDIF |
71 |
|
|
#endif |
72 |
heimbach |
1.1 |
C check input arguments |
73 |
|
|
if ( .NOT. (filePrec .EQ. 32) ) |
74 |
|
|
& stop 'stop in exf_interp.F: value of filePrec not allowed' |
75 |
|
|
|
76 |
|
|
C read in input data |
77 |
|
|
#ifdef ALLOW_USE_MPI |
78 |
cnh |
1.3 |
C if (useSingleCPUIO) then |
79 |
|
|
if (.FALSE.) then |
80 |
heimbach |
1.1 |
|
81 |
|
|
C master thread of process 0, only, opens a global file |
82 |
|
|
IF( mpiMyId .EQ. 0 ) THEN |
83 |
|
|
call mdsfindunit( interp_unit, mythid) |
84 |
|
|
length_of_rec=MDS_RECLEN( filePrec, nx_in*ny_in, mythid ) |
85 |
|
|
open(interp_unit,file=infile,status='old',access='direct', |
86 |
|
|
& recl=length_of_rec) |
87 |
|
|
read(interp_unit,rec=irecord) |
88 |
|
|
& ((global(i,j),i=1,nx_in),j=1,ny_in) |
89 |
|
|
close(interp_unit) |
90 |
|
|
ENDIF |
91 |
|
|
|
92 |
|
|
C broadcast to all processes |
93 |
|
|
call MPI_BCAST(global,nx_in*ny_in,MPI_REAL, |
94 |
|
|
& 0,MPI_COMM_MODEL,ierr) |
95 |
|
|
else |
96 |
|
|
#endif /* ALLOW_USE_MPI */ |
97 |
|
|
|
98 |
|
|
call mdsfindunit( interp_unit, mythid) |
99 |
|
|
length_of_rec=MDS_RECLEN( filePrec, nx_in*ny_in, mythid ) |
100 |
|
|
open(interp_unit,file=infile,status='old',access='direct', |
101 |
|
|
& recl=length_of_rec) |
102 |
cnh |
1.3 |
read(interp_unit,rec=irecord) global |
103 |
heimbach |
1.1 |
close(interp_unit) |
104 |
|
|
|
105 |
|
|
#ifdef ALLOW_USE_MPI |
106 |
|
|
endif |
107 |
|
|
#endif /* ALLOW_USE_MPI */ |
108 |
cnh |
1.3 |
#ifdef EXF_IREAD_USE_GLOBAL_POINTER |
109 |
|
|
glPtr => global |
110 |
|
|
#endif |
111 |
|
|
_END_MASTER( myThid ) |
112 |
|
|
_BARRIER |
113 |
|
|
#ifdef EXF_IREAD_USE_GLOBAL_POINTER |
114 |
|
|
do j=1,ny_in |
115 |
|
|
do i=1,nx_in |
116 |
|
|
arrayin(i,j)=glPtr(i,j) |
117 |
|
|
enddo |
118 |
|
|
enddo |
119 |
|
|
#else |
120 |
|
|
do j=1,ny_in |
121 |
|
|
do i=1,nx_in |
122 |
|
|
arrayin(i,j)=global(i,j) |
123 |
|
|
enddo |
124 |
|
|
enddo |
125 |
|
|
#endif |
126 |
heimbach |
1.1 |
|
127 |
|
|
#ifdef _BYTESWAPIO |
128 |
|
|
call MDS_BYTESWAPR4((nx_in+4)*(ny_in+4), arrayin ) |
129 |
|
|
#endif /* _BYTESWAPIO */ |
130 |
|
|
|
131 |
jmc |
1.5 |
RETURN |
132 |
heimbach |
1.1 |
END |