SURFEX v8.1
General documentation of Surfex
trip_oasis_define.F90
Go to the documentation of this file.
1 !#########
2 SUBROUTINE trip_oasis_define(KLISTING,KLON,KLAT)
3 !###############################################
4 !
5 !!**** *TRIP_OASIS_DEFINE* - Definitions for exchange of coupling fields
6 !!
7 !! PURPOSE
8 !! -------
9 !!
10 !!** METHOD
11 !! ------
12 !!
13 !! EXTERNAL
14 !! --------
15 !!
16 !!
17 !! IMPLICIT ARGUMENTS
18 !! ------------------
19 !!
20 !! REFERENCE
21 !! ---------
22 !!
23 !!
24 !! AUTHOR
25 !! ------
26 !! B. Decharme *Meteo France*
27 !!
28 !! MODIFICATIONS
29 !! -------------
30 !! Original 10/2013
31 !! B. Decharme 10/2016 bug surface/groundwater coupling
32 !-------------------------------------------------------------------------------
33 !
34 !* 0. DECLARATIONS
35 ! ------------
36 !
37 !
40 !
41 USE modd_trip_par, ONLY : nundef
42 !
44 !
46 !
47 USE modi_abort_trip
48 USE modi_get_lonlat_trip
49 !
50 USE yomhook ,ONLY : lhook, dr_hook
51 USE parkind1 ,ONLY : jprb
52 !
53 #ifdef CPLOASIS
54 USE mod_oasis
55 #endif
56 !
57 IMPLICIT NONE
58 !
59 !* 0.1 Declarations of arguments
60 ! -------------------------
61 !
62 INTEGER, INTENT(IN) :: KLISTING
63 INTEGER, INTENT(IN) :: KLON
64 INTEGER, INTENT(IN) :: KLAT
65 !
66 !* 0.2 Declarations of local parameter
67 ! -------------------------------
68 !
69 INTEGER, PARAMETER :: IG_PARSIZE = 3 ! Size of array decomposition
70 INTEGER, DIMENSION(2), PARAMETER :: IVAR_NODIMS = (/2,1/) ! rank and number of bundles in coupling field
71 !
72 !* 0.3 Declarations of local variables
73 ! -------------------------------
74 !
75 INTEGER, DIMENSION(IG_PARSIZE) :: IPARAL ! Decomposition for each proc
76 INTEGER, DIMENSION(2,2) :: IVAR_SHAPE ! indexes for the coupling field local dimension
77 !
78 INTEGER :: IPART_ID ! Local partition ID
79 INTEGER :: IERR ! Error info
80 !
81 LOGICAL :: GFOUND ! Return code when searching namelist
82 INTEGER :: INAM ! logical unit of namelist file
83 !
84 INTEGER :: JLON, JLAT, JC, IFLAG
85 !
86 REAL(KIND=JPRB) :: ZHOOK_HANDLE
87 !
88 !-------------------------------------------------------------------------------
89 !
90 IF (lhook) CALL dr_hook('TRIP_OASIS_DEFINE',0,zhook_handle)
91 !
92 !-------------------------------------------------------------------------------
93 #ifdef CPLOASIS
94 !-------------------------------------------------------------------------------
95 !
96 !* 1. Define parallel partitions:
97 ! ---------------------------
98 !
99 ! TRIP is for now a monoprocess model: the entire field will be exchanged by the process.
100 !
101 iparal(clim_strategy) = clim_serial
102 iparal(clim_offset ) = 0
103 iparal(clim_length ) = klon*klat
104 !
105  CALL oasis_def_partition(ipart_id,iparal(:),ierr)
106 !
107 IF(ierr/=oasis_ok)THEN
108  WRITE(klisting,*)'TRIP_OASIS_DEFINE: OASIS def partition problem, err = ',ierr
109  CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def partition problem')
110 ENDIF
111 !
112 !-------------------------------------------------------------------------------
113 !
114 !* 2. Coupling fields shape :
115 ! -----------------------
116 !
117 ivar_shape(1,1)= 1
118 ivar_shape(1,2)= klon
119 ivar_shape(2,1)= 1
120 ivar_shape(2,2)= klat
121 !
122 !
123 !-------------------------------------------------------------------------------
124 !
125 !* 3. Sea variables for Trip - Oasis coupling :
126 ! -----------------------------------------
127 !
128 IF(lcpl_sea)THEN
129 !
130 ! Output river discharge to ocean
131  CALL oasis_def_var(nrivdis_id,crivdis,ipart_id,ivar_nodims,oasis_out,ivar_shape,oasis_double,ierr)
132  IF(ierr/=oasis_ok) CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def var problem for River discharge to ocean')
133 !
134 ! Particular case for Calving fluxes
135 !
136  IF(lcpl_calvsea)THEN
137 !
138 ! Output calving flux over Greenland
139  CALL oasis_def_var(ncalvgre_id,ccalvgre,ipart_id,ivar_nodims,oasis_out,ivar_shape,oasis_double,ierr)
140  IF(ierr/=oasis_ok) CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def var problem for Calving flux over Greenland')
141 !
142 ! Output calving flux over Antarctica
143  CALL oasis_def_var(ncalvant_id,ccalvant,ipart_id,ivar_nodims,oasis_out,ivar_shape,oasis_double,ierr)
144  IF(ierr/=oasis_ok) CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def var problem for Calving flux over Antarctica')
145 !
146  ENDIF
147 !
148 ENDIF
149 !
150 !-------------------------------------------------------------------------------
151 !
152 !* 4. Land surface variables for trip - Oasis coupling :
153 ! ----------------------------------------------------
154 !
155 !
156 IF(lcpl_land)THEN
157 !
158 ! Input surface runoff
159  CALL oasis_def_var(nrunoff_id,crunoff,ipart_id,ivar_nodims,oasis_in,ivar_shape,oasis_double,ierr)
160  IF(ierr/=oasis_ok) CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def var problem for Surface runoff')
161 !
162 ! Input calving flux
163 !
164  IF(lcpl_calving)THEN
165  CALL oasis_def_var(ncalving_id,ccalving,ipart_id,ivar_nodims,oasis_in,ivar_shape,oasis_double,ierr)
166  IF(ierr/=oasis_ok) CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def var problem for calvin flux')
167  ENDIF
168 !
169 ! Inputd deep drainage
170  CALL oasis_def_var(ndrain_id,cdrain,ipart_id,ivar_nodims,oasis_in,ivar_shape,oasis_double,ierr)
171  IF(ierr/=oasis_ok) CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def var problem for Deep drainage')
172 !
173 ! Particular case due to water table depth / surface coupling
174 !
175  IF(lcpl_gw)THEN
176 !
177 ! Output Water table depth
178  CALL oasis_def_var(nwtd_id,cwtd,ipart_id,ivar_nodims,oasis_out,ivar_shape,oasis_double,ierr)
179  IF(ierr/=oasis_ok) CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def var problem for Water table depth')
180 !
181 ! Output grid-cell fraction of WTD to rise
182  CALL oasis_def_var(nfwtd_id,cfwtd,ipart_id,ivar_nodims,oasis_out,ivar_shape,oasis_double,ierr)
183  IF(ierr/=oasis_ok) CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def var problem for fraction of WTD to rise')
184 !
185  ENDIF
186 !
187 ! Particular case due to floodplains coupling
188 !
189  IF(lcpl_flood)THEN
190 !
191 ! Iutput Flood freshwater flux
192  CALL oasis_def_var(nsrcflood_id,csrcflood,ipart_id,ivar_nodims,oasis_in,ivar_shape,oasis_double,ierr)
193  IF(ierr/=oasis_ok) CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def var problem for Flood precip interception')
194 !
195 ! Output floodplains fraction
196  CALL oasis_def_var(nfflood_id,cfflood,ipart_id,ivar_nodims,oasis_out,ivar_shape,oasis_double,ierr)
197  IF(ierr/=oasis_ok) CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def var problem for Floodplains fraction')
198 !
199 ! Output floodplains potential infiltration
200  CALL oasis_def_var(npiflood_id,cpiflood,ipart_id,ivar_nodims,oasis_out,ivar_shape,oasis_double,ierr)
201  IF(ierr/=oasis_ok) CALL abort_trip('TRIP_OASIS_DEFINE: OASIS def var problem for Floodplains potential infiltration')
202 !
203  ENDIF
204 !
205 ENDIF
206 !
207 !-------------------------------------------------------------------------------
208 !
209 !* 5. End of declaration phase:
210 ! --------------
211 !
212  CALL oasis_enddef(ierr)
213 !
214 IF(ierr/=oasis_ok)THEN
215  WRITE(klisting,*)'TRIP_OASIS_DEFINE: OASIS enddef problem, err = ',ierr
216  CALL abort_trip('TRIP_OASIS_DEFINE: OASIS enddef problem')
217 ENDIF
218 !
219 !-------------------------------------------------------------------------------
220 #endif
221 !-------------------------------------------------------------------------------
222 !
223 IF (lhook) CALL dr_hook('TRIP_OASIS_DEFINE',1,zhook_handle)
224 !
225 !-------------------------------------------------------------------------------
226 !
227 END SUBROUTINE trip_oasis_define
integer, save nundef
character(len=8) cwtd
subroutine trip_oasis_define(KLISTING, KLON, KLAT)
character(len=8) crivdis
character(len=8) cdrain
integer, parameter jprb
Definition: parkind1.F90:32
character(len=8) ccalvant
character(len=8) crunoff
character(len=8) cpiflood
logical lhook
Definition: yomhook.F90:15
character(len=8) ccalvgre
character(len=8) ccalving
subroutine abort_trip(YTEXT)
Definition: abort_trip.F90:3
character(len=8) csrcflood
character(len=8) cfwtd
character(len=8) cfflood