source: CPL/oasis3/trunk/src/lib/psmile/src/prism_def_var_proto.F @ 1677

Last change on this file since 1677 was 1677, checked in by aclsce, 12 years ago

Imported oasis3 (tag ipslcm5a) from cvs server to svn server (igcmg project).

File size: 8.5 KB
Line 
1      SUBROUTINE prism_def_var_proto(id_nports, cdport, id_part, 
2     $     id_var_nodims, kinout, id_var_shape, ktype, kinfo)
3c     
4c     **** Def_var ***   PRISM 1.0
5c     
6c     purpose:
7c     --------
8c        define a port
9c
10c     interface:
11c     ----------
12c        id_nports : port number of the field
13c        cdport : symbolic name of the field
14c        id_part : field decomposition 
15c        id_var_nodims(1) : rank of array variable
16c        id_var_nodims(2) : number of bundles
17c        kinout : port status in/out
18c        id_var_shape : description of the local partition in the 
19c                       global index space
20c        ktype  : type of data
21c        kinfo  : output status
22c
23c     lib mp:
24c     -------
25c        mpi-1
26c
27c     author:
28c     -------
29c        Eric Sevault   - METEO FRANCE
30c        Laurent Terray - CERFACS
31c
32c     ----------------------------------------------------------------
33      USE mod_kinds_model
34      USE mod_prism_proto
35      USE mod_comprism_proto
36c     ----------------------------------------------------------------
37      INTEGER (kind=ip_intwp_p)       kinout, ktype, kinfo, id_nports, 
38     $    id_part
39      INTEGER (kind=ip_intwp_p)       id_var_nodims(2), 
40     $    id_var_shape(2*id_var_nodims(1))
41      CHARACTER*(*) cdport
42c     ----------------------------------------------------------------
43c
44c*    0. First Check
45c     --------------
46c
47      IF ( nexit.NE.1 ) THEN
48         kinfo = CLIM_FastExit
49         WRITE(nulprt,FMT='(A)') 'Def_var - should not be called'
50         GO TO 1010
51      ENDIF
52      kinfo = CLIM_Ok
53c
54c*    1. define the port
55c     ------------------
56c
57      WRITE(nulprt,*) 'Def_var - port name, status : ',cdport, kinout
58      WRITE(nulprt,*) 'Def_var - data type: ',ktype
59c
60      IF ( ktype .ne. PRISM_Real ) THEN
61          WRITE(nulprt,FMT='(A,I4)')
62     $        'Def_var - ERROR - Bad data type:',ktype
63          WRITE(nulprt,*)
64     $        'Calling MPI_Abort in prism_def_var'
65          CALL FLUSH(nulprt)
66          CALL MPI_ABORT (mpi_comm, 0, ierror)
67      ENDIF
68c
69      IF ( kinout.EQ.CLIM_InOut ) THEN
70         CALL prism_defport (id_nports, cdport, CLIM_In, ktype, id_part, 
71     $        kinfo )
72         IF (kinfo.EQ.CLIM_Ok) THEN
73            CALL prism_defport (id_nports, cdport, CLIM_Out, ktype, 
74     $           id_part, kinfo )
75         ENDIF
76      ELSE
77         CALL prism_defport ( id_nports,cdport, kinout, ktype, id_part, 
78     $        kinfo )
79      ENDIF
80c
81c     ----------------------------------------------------------------
82c
83 1010 CONTINUE
84      CALL FLUSH(nulprt)
85      RETURN
86      END
87c
88c ====================================================================
89
90      SUBROUTINE prism_defport(id_nports,cdport,kinout,ktype,id_part,
91     $     kinfo)
92c
93c*    *** Define ***   CLIM 2.2
94c
95c     purpose:
96c     --------
97c        define a port
98c
99c     interface:
100c     ----------
101c        id_nports : port number of the field
102c        cdport : symbolic name of the field
103c        kinout : port status in/out
104c        ktype  : type of data
105c        kparal : type of parallel decomposition
106c        kinfo  : output status
107c
108c     lib mp:
109c     -------
110c        mpi-2
111c
112c     author:
113c     -------
114c        Eric Sevault   - METEO FRANCE
115c        Laurent Terray - CERFACS
116c        Jean Latour    - F.S.E.   (mpi-2)
117c
118c     ----------------------------------------------------------------
119      USE mod_kinds_model
120      USE mod_prism_proto
121      USE mod_comprism_proto
122c     ----------------------------------------------------------------
123      INTEGER (kind=ip_intwp_p)       kinout, ktype, kinfo
124      CHARACTER*(*) cdport
125c     ----------------------------------------------------------------
126      INTEGER (kind=ip_intwp_p)    ip, id_nports, id_part, ierror
127      REAL(kind=ip_realwp_p)          rl_testvar
128      REAL(kind=ip_double_p)   dl_testvar
129      CHARACTER*32  cltest
130c     ----------------------------------------------------------------
131c
132      rl_testvar = 0.0_ip_realwp_p
133      dl_testvar = 0.0_ip_double_p
134c
135c*    1. check if this port already exist
136c     -----------------------------------
137c
138      cltest= cdport
139c
140      DO ip=1,nports
141         IF (cltest.EQ.cports(ip).AND.kinout.EQ.myport(1,ip)) THEN
142            kinfo = PRISM_DoubleDef
143            WRITE(nulprt,FMT='(A,A)')
144     $           'Def_var - WARNING - duplicate definition of port ',
145     $           cdport
146            GO TO 1010
147         ENDIF
148      ENDDO
149c     
150c*    2. save arguments as half a link
151c     --------------------------------
152c
153      nports = nports + 1
154      id_nports = nports
155      DO il=1, ig_clim_nfield
156        IF (cltest.EQ.cg_cnaminp(il).or.cltest.eq.cg_cnamout(il)) THEN
157            IF (cltest .EQ. cg_cnaminp(il)) then
158                cga_clim_locator(nports) = cga_clim_locatorbf(il)
159            ELSE IF (cltest .EQ. cg_cnamout(il)) then
160                cga_clim_locator(nports) = cga_clim_locatoraf(il)
161            ENDIF
162            IF (ig_clim_state(il) .eq. ip_exported .or. 
163     $           ig_clim_state(il) .eq. ip_expout .or. 
164     $           ig_clim_state(il) .eq. ip_auxilary) THEN
165               cports(nports) = cltest
166               ig_def_lag(nports)=ig_clim_lag(il)
167!AC
168               IF (cltest.EQ.cg_cnamout(il)) THEN
169                   ig_def_reverse(nports)=ig_clim_reverse(il)
170               ELSEIF  (cltest.EQ.cg_cnaminp(il)) THEN
171                   ig_def_invert(nports)=ig_clim_invert(il)
172               ENDIF
173!AC
174               ig_def_freq(nports)=ig_clim_freq(il)
175               ig_def_seq(nports)=ig_clim_seq(il)
176               cg_def_rstfile(nports)=cg_clim_rstfile(il)
177               ig_def_norstfile(nports)=ig_clim_norstfile(il)
178               ig_def_state(nports)=ig_clim_state(il)
179               ig_def_trans(nports)=ig_clim_trans(il)
180               cg_def_inpfile(nports)=cg_clim_inpfile(il)
181!RV
182               ig_def_numlab(nports)=ig_clim_numlab(il)
183!RV
184            ELSE
185               IF (ig_clim_state(il) .eq. ip_ignout) 
186     $              cg_ignout_field(nports) = cltest
187               cports(nports) = cg_cnamout(il)
188               ig_def_lag(nports)=ig_clim_lag(il)
189!AC
190               IF (cltest.EQ.cg_cnamout(il)) THEN
191                   ig_def_reverse(nports)=ig_clim_reverse(il)
192               ELSEIF  (cltest.EQ.cg_cnaminp(il)) THEN
193                   ig_def_invert(nports)=ig_clim_invert(il)
194               ENDIF
195!AC
196               ig_def_freq(nports)=ig_clim_freq(il)
197               ig_def_seq(nports)=ig_clim_seq(il)
198               cg_def_rstfile(nports)=cg_clim_rstfile(il)
199               ig_def_norstfile(nports)=ig_clim_norstfile(il)
200               ig_def_state(nports)=ig_clim_state(il)
201               ig_def_trans(nports)=ig_clim_trans(il)
202               cg_def_inpfile(nports)=cg_clim_inpfile(il)
203!RV
204               ig_def_numlab(nports)=ig_clim_numlab(il)
205!RV
206            ENDIF
207         ENDIF
208      ENDDO
209c     
210      IF (ig_def_freq(nports) .eq. 0) THEN
211         WRITE(nulprt,FMT=*) 
212     $      'Def_var - WARNING '
213         WRITE(nulprt,FMT=*) 
214     $      'You have a file which is not defined in the namcouple '
215         WRITE(nulprt,FMT=*) 
216     $        'This file will not be exchanged !'
217         GOTO 1010
218      ELSEIF (ig_def_freq(nports) .gt. ig_ntime) THEN
219         WRITE(nulprt,FMT=*) 
220     $        'Def_var - WARNING '
221         WRITE(nulprt,FMT=*) 
222     $        'You have a file defined with a coupling period greater '
223         WRITE(nulprt,FMT=*) 
224     $        'than the time of the simulation. So, this file will not '
225         WRITE(nulprt,FMT=*) 
226     $        'be exchanged !'
227         GOTO 1010 
228      ELSE
229         myport(1,nports) = kinout
230         myport(5,nports) = 0
231c     
232c         IF ( ktype.EQ.CLIM_Integer ) THEN
233c            WRITE(nulprt,FMT=*) 
234c     $ ' Communication with integer as type of data is not supported'
235c            call flush(nulprt)
236c            call MPI_ABORT (mpi_comm, 0, ierror)
237c         ELSEIF ( ktype.EQ.PRISM_Real ) THEN
238         IF ( ktype .EQ. PRISM_Real ) THEN
239            myport(2,nports) = PRISM_Real
240            myport(3,nports) = kind(rl_testvar)
241c         ELSEIF ( ktype.EQ.PRISM_Double ) THEN
242c            myport(2,nports) = PRISM_Double
243c            myport(3,nports) = kind(dl_testvar)
244         ELSE
245            kinfo = CLIM_BadType
246            WRITE(nulprt,FMT='(A,I4)')
247     $           'Def_var - WARNING - Bad data type:',ktype
248         ENDIF
249c     
250         mydist (:,nports) = ig_def_part (:,id_part)
251         myport (4,nports) = ig_length_part (id_part)
252      ENDIF
253c
254c
255c     ----------------------------------------------------------------
256c
257 1010 CONTINUE
258      CALL FLUSH(nulprt)
259      RETURN
260      END 
Note: See TracBrowser for help on using the repository browser.