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

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

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


Revision 1.3 - (hide annotations) (download)
Wed Nov 9 17:22:08 2005 UTC (18 years, 7 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint58e_post, checkpoint57y_post, checkpoint58h_post, checkpoint57y_pre, checkpoint58j_post, checkpoint58, checkpoint58f_post, checkpoint57x_post, checkpoint58d_post, checkpoint58c_post, checkpoint58a_post, checkpoint58i_post, checkpoint58g_post, checkpoint57z_post, checkpoint58b_post
Changes since 1.2: +44 -11 lines
1 - Tidying up multi-threaded stuff to get rid and automate some CPP junk.
2 - Putting in CPP optional mode for exf_interp_read.F that allows it to work
    multi-threaded with an F90 compiler (this mode wont work with g77).

1 heimbach 1.1 #include "EXF_OPTIONS.h"
2     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
3     C Flux Coupler using C
4     C Bilinear interpolation of forcing fields C
5     C C
6     C B. Cheng (12/2002) C
7     C C
8     C added Bicubic (bnc 1/2003) C
9     C C
10     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
11    
12     SUBROUTINE exf_interp_read(
13     I infile,
14     I filePrec,
15     O arrayin,
16     I irecord, xG, yG,
17     I lon_0, lon_inc,
18     I lat_0, lat_inc,
19     I nx_in, ny_in, method, mythid)
20    
21     implicit none
22    
23     C infile = name of the input file (direct access binary)
24     C filePrec = file precicision (currently not used, assumes real*4)
25     C arrout = output arrays (different for each processor)
26     C irecord = record number in global file
27     C xG,yG = coordinates for output grid
28     C lon_0, lat_0 = lon and lat of sw corner of global input grid
29     C lon_inc = scalar x-grid increment
30     C lat_inc = vector y-grid increments
31     C nx_in, ny_in = input x-grid and y-grid size
32     C method = 1 for bilinear 2 for bicubic
33     C mythid = thread id
34     C
35    
36     #include "SIZE.h"
37     #include "EEPARAMS.h"
38     #ifdef ALLOW_USE_MPI
39     # include "EESUPPORT.h"
40     #endif /* ALLOW_USE_MPI */
41     #include "PARAMS.h"
42    
43 cnh 1.3 #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 heimbach 1.1 C subroutine variables
54     character*(*) infile
55     integer filePrec, irecord, nx_in, ny_in
56     real*4 arrayin(-1:nx_in+2 , -1:ny_in+2)
57     _RS xG (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
58     _RS yG (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
59     _RL lon_0, lon_inc
60     _RL lat_0, lat_inc(ny_in-1)
61     integer method, mythid
62    
63     C Functions
64     integer MDS_RECLEN
65    
66     C local variables
67     integer ierr, length_of_rec
68     real*8 ne_fac,nw_fac,se_fac,sw_fac
69     integer e_ind(snx,sny),w_ind(snx,sny)
70     integer n_ind(snx,sny),s_ind(snx,sny)
71     real*8 px_ind(4), py_ind(4), ew_val(4)
72     external lagran
73     real*8 lagran
74     integer i, j, k, l, js, bi, bj, sp, interp_unit
75 cnh 1.3 #ifdef EXF_IREAD_USE_GLOBAL_POINTER
76     real*4, target :: global(nx_in,ny_in)
77     #else
78 heimbach 1.1 real*4 global(nx_in,ny_in)
79 cnh 1.3 #endif
80 heimbach 1.1
81 cnh 1.3 _BEGIN_MASTER( myThid )
82 heimbach 1.1
83 cnh 1.3 #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 heimbach 1.1 C check input arguments
92     if ( .NOT. (filePrec .EQ. 32) )
93     & stop 'stop in exf_interp.F: value of filePrec not allowed'
94    
95     C read in input data
96     #ifdef ALLOW_USE_MPI
97 cnh 1.3 C if (useSingleCPUIO) then
98     if (.FALSE.) then
99 heimbach 1.1
100     C master thread of process 0, only, opens a global file
101     IF( mpiMyId .EQ. 0 ) THEN
102     call mdsfindunit( interp_unit, mythid)
103     length_of_rec=MDS_RECLEN( filePrec, nx_in*ny_in, mythid )
104     open(interp_unit,file=infile,status='old',access='direct',
105     & recl=length_of_rec)
106     read(interp_unit,rec=irecord)
107     & ((global(i,j),i=1,nx_in),j=1,ny_in)
108     close(interp_unit)
109     ENDIF
110    
111     C broadcast to all processes
112     call MPI_BCAST(global,nx_in*ny_in,MPI_REAL,
113     & 0,MPI_COMM_MODEL,ierr)
114     else
115     #endif /* ALLOW_USE_MPI */
116    
117     call mdsfindunit( interp_unit, mythid)
118     length_of_rec=MDS_RECLEN( filePrec, nx_in*ny_in, mythid )
119     open(interp_unit,file=infile,status='old',access='direct',
120     & recl=length_of_rec)
121 cnh 1.3 read(interp_unit,rec=irecord) global
122 heimbach 1.1 close(interp_unit)
123    
124     #ifdef ALLOW_USE_MPI
125     endif
126     #endif /* ALLOW_USE_MPI */
127 cnh 1.3 #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 heimbach 1.1
146     #ifdef _BYTESWAPIO
147     call MDS_BYTESWAPR4((nx_in+4)*(ny_in+4), arrayin )
148     #endif /* _BYTESWAPIO */
149    
150    
151     END

  ViewVC Help
Powered by ViewVC 1.1.22