/[MITgcm]/MITgcm/pkg/exf/exf_interp_read.F
ViewVC logotype

Contents of /MITgcm/pkg/exf/exf_interp_read.F

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


Revision 1.7 - (show annotations) (download)
Wed Dec 13 18:37:21 2006 UTC (17 years, 6 months ago) by dimitri
Branch: MAIN
Changes since 1.6: +1 -4 lines
exf_iprec is no longer tied to 32: stop statement removed

1 C $Header: /u/gcmpack/MITgcm/pkg/exf/exf_interp_read.F,v 1.6 2006/10/15 14:08:10 dimitri Exp $
2 C $Name: $
3
4 #include "EXF_OPTIONS.h"
5
6 SUBROUTINE exf_interp_read(
7 I infile, filePrec,
8 O arrayin,
9 I irecord, nx_in, ny_in, mythid)
10
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 #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 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 integer mythid
42
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 #ifdef EXF_IREAD_USE_GLOBAL_POINTER
56 real*4, target :: global(nx_in,ny_in)
57 #else
58 real*4 global(nx_in,ny_in)
59 #endif
60
61 _BARRIER
62 _BEGIN_MASTER( myThid )
63
64 #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
73 C read in input data
74 #ifdef ALLOW_USE_MPI
75 #ifdef EXF_IREAD_USE_GLOBAL_POINTER
76 if (.FALSE.) then
77 #else
78 if (useSingleCPUIO) then
79 #endif
80
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 read(interp_unit,rec=irecord) global
103 close(interp_unit)
104
105 #ifdef ALLOW_USE_MPI
106 endif
107 #endif /* ALLOW_USE_MPI */
108 #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
127 #ifdef _BYTESWAPIO
128 call MDS_BYTESWAPR4((nx_in+4)*(ny_in+4), arrayin )
129 #endif /* _BYTESWAPIO */
130
131 RETURN
132 END

  ViewVC Help
Powered by ViewVC 1.1.22