source: LMDZ4/trunk/libf/phylmd/surf_land_orchidee_mod.F90 @ 1176

Last change on this file since 1176 was 1146, checked in by Laurent Fairhead, 15 years ago

Réintegration dans le tronc des modifications issues de la branche LMDZ-dev
comprises entre la révision 1074 et 1145
Validation: une simulation de 1 jour en séquentiel sur PC donne les mêmes
résultats entre la trunk et la dev
LF

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 21.3 KB
RevLine 
[781]1!
2MODULE surf_land_orchidee_mod
[1146]3#ifndef ORCHIDEE_NOOPENMP
[781]4!
5! This module controles the interface towards the model ORCHIDEE
6!
7! Subroutines in this module : surf_land_orchidee
8!                              Init_orchidee_index
9!                              Get_orchidee_communicator
10!                              Init_neighbours
11
12  USE dimphy
[1067]13#ifdef CPP_VEGET
[781]14  USE intersurf     ! module d'ORCHIDEE
[1067]15#endif
[781]16  USE cpl_mod,      ONLY : cpl_send_land_fields
[996]17  USE surface_data, ONLY : type_ocean
[781]18  USE comgeomphy,   ONLY : cuphy, cvphy
19  USE mod_grid_phy_lmdz
[987]20  USE mod_phys_lmdz_para, mpi_root_rank=>mpi_root
[781]21
22  IMPLICIT NONE
23
24  PRIVATE
25  PUBLIC  :: surf_land_orchidee
26
[987]27  LOGICAL, ALLOCATABLE, SAVE :: flag_omp(:)
[781]28CONTAINS
29!
30!****************************************************************************************
31
32  SUBROUTINE surf_land_orchidee(itime, dtime, date0, knon, &
33       knindex, rlon, rlat, pctsrf, &
34       debut, lafin, &
35       plev,  u1_lay, v1_lay, temp_air, spechum, epot_air, ccanopy, &
36       tq_cdrag, petAcoef, peqAcoef, petBcoef, peqBcoef, &
37       precip_rain, precip_snow, lwdown, swnet, swdown, &
[1146]38       ps, q2m, t2m, &
[781]39       evap, fluxsens, fluxlat, &             
[888]40       tsol_rad, tsurf_new, alb1_new, alb2_new, &
[781]41       emis_new, z0_new, qsurf)
[987]42   USE mod_surf_para
43   USE mod_synchro_omp
44   
[781]45!   
46! Cette routine sert d'interface entre le modele atmospherique et le
47! modele de sol continental. Appel a sechiba
48!
49! L. Fairhead 02/2000
50!
51! input:
52!   itime        numero du pas de temps
53!   dtime        pas de temps de la physique (en s)
54!   nisurf       index de la surface a traiter (1 = sol continental)
55!   knon         nombre de points de la surface a traiter
56!   knindex      index des points de la surface a traiter
57!   rlon         longitudes de la grille entiere
58!   rlat         latitudes de la grille entiere
59!   pctsrf       tableau des fractions de surface de chaque maille
60!   debut        logical: 1er appel a la physique (lire les restart)
61!   lafin        logical: dernier appel a la physique (ecrire les restart)
62!                     (si false calcul simplifie des fluxs sur les continents)
63!   plev         hauteur de la premiere couche (Pa)     
64!   u1_lay       vitesse u 1ere couche
65!   v1_lay       vitesse v 1ere couche
66!   temp_air     temperature de l'air 1ere couche
67!   spechum      humidite specifique 1ere couche
68!   epot_air     temp pot de l'air
69!   ccanopy      concentration CO2 canopee
70!   tq_cdrag     cdrag
71!   petAcoef     coeff. A de la resolution de la CL pour t
72!   peqAcoef     coeff. A de la resolution de la CL pour q
73!   petBcoef     coeff. B de la resolution de la CL pour t
74!   peqBcoef     coeff. B de la resolution de la CL pour q
75!   precip_rain  precipitation liquide
76!   precip_snow  precipitation solide
77!   lwdown       flux IR descendant a la surface
78!   swnet        flux solaire net
79!   swdown       flux solaire entrant a la surface
80!   ps           pression au sol
81!   radsol       rayonnement net aus sol (LW + SW)
82!   
83!
84! output:
85!   evap         evaporation totale
86!   fluxsens     flux de chaleur sensible
87!   fluxlat      flux de chaleur latente
88!   tsol_rad     
89!   tsurf_new    temperature au sol
[888]90!   alb1_new     albedo in visible SW interval
91!   alb2_new     albedo in near IR interval
[781]92!   emis_new     emissivite
93!   z0_new       surface roughness
94!   qsurf        air moisture at surface
95!
96    INCLUDE "indicesol.h"
[793]97    INCLUDE "temps.h"
98    INCLUDE "YOMCST.h"
[781]99    INCLUDE "iniprint.h"
[793]100    INCLUDE "dimensions.h"
[781]101 
102!
103! Parametres d'entree
104!****************************************************************************************
105    INTEGER, INTENT(IN)                       :: itime
106    REAL, INTENT(IN)                          :: dtime
107    REAL, INTENT(IN)                          :: date0
108    INTEGER, INTENT(IN)                       :: knon
109    INTEGER, DIMENSION(klon), INTENT(IN)      :: knindex
110    LOGICAL, INTENT(IN)                       :: debut, lafin
111    REAL, DIMENSION(klon,nbsrf), INTENT(IN)   :: pctsrf
112    REAL, DIMENSION(klon), INTENT(IN)         :: rlon, rlat
113    REAL, DIMENSION(klon), INTENT(IN)         :: plev
114    REAL, DIMENSION(klon), INTENT(IN)         :: u1_lay, v1_lay
115    REAL, DIMENSION(klon), INTENT(IN)         :: temp_air, spechum
116    REAL, DIMENSION(klon), INTENT(IN)         :: epot_air, ccanopy
117    REAL, DIMENSION(klon), INTENT(IN)         :: tq_cdrag
118    REAL, DIMENSION(klon), INTENT(IN)         :: petAcoef, peqAcoef
119    REAL, DIMENSION(klon), INTENT(IN)         :: petBcoef, peqBcoef
120    REAL, DIMENSION(klon), INTENT(IN)         :: precip_rain, precip_snow
121    REAL, DIMENSION(klon), INTENT(IN)         :: lwdown, swnet, swdown, ps
[1146]122    REAL, DIMENSION(klon), INTENT(IN)         :: q2m, t2m
[781]123
124! Parametres de sortie
125!****************************************************************************************
126    REAL, DIMENSION(klon), INTENT(OUT)        :: evap, fluxsens, fluxlat, qsurf
[888]127    REAL, DIMENSION(klon), INTENT(OUT)        :: tsol_rad, tsurf_new
128    REAL, DIMENSION(klon), INTENT(OUT)        :: alb1_new, alb2_new
[781]129    REAL, DIMENSION(klon), INTENT(OUT)        :: emis_new, z0_new
130
131! Local
132!****************************************************************************************
133    INTEGER                                   :: ij, jj, igrid, ireal, index
134    INTEGER                                   :: error
[1146]135    REAL, DIMENSION(klon)                     :: swdown_vrai
[781]136    CHARACTER (len = 20)                      :: modname = 'surf_land_orchidee'
137    CHARACTER (len = 80)                      :: abort_message
138    LOGICAL,SAVE                              :: check = .FALSE.
139    !$OMP THREADPRIVATE(check)
140
141! type de couplage dans sechiba
142!  character (len=10)   :: coupling = 'implicit'
143! drapeaux controlant les appels dans SECHIBA
144!  type(control_type), save   :: control_in
145! Preserved albedo
146    REAL, ALLOCATABLE, DIMENSION(:), SAVE     :: albedo_keep, zlev
147    !$OMP THREADPRIVATE(albedo_keep,zlev)
148! coordonnees geographiques
149    REAL, ALLOCATABLE, DIMENSION(:,:), SAVE   :: lalo
150    !$OMP THREADPRIVATE(lalo)
151! pts voisins
152    INTEGER,ALLOCATABLE, DIMENSION(:,:), SAVE :: neighbours
153    !$OMP THREADPRIVATE(neighbours)
154! fractions continents
155    REAL,ALLOCATABLE, DIMENSION(:), SAVE      :: contfrac
156    !$OMP THREADPRIVATE(contfrac)
157! resolution de la grille
158    REAL, ALLOCATABLE, DIMENSION (:,:), SAVE  :: resolution
159    !$OMP THREADPRIVATE(resolution)
160
161    REAL, ALLOCATABLE, DIMENSION (:,:), SAVE  :: lon_scat, lat_scat 
162    !$OMP THREADPRIVATE(lon_scat,lat_scat)
163
164    LOGICAL, SAVE                             :: lrestart_read = .TRUE.
165    !$OMP THREADPRIVATE(lrestart_read)
166    LOGICAL, SAVE                             :: lrestart_write = .FALSE.
167    !$OMP THREADPRIVATE(lrestart_write)
168
169    REAL, DIMENSION(knon,2)                   :: albedo_out
170
171! Pb de nomenclature
172    REAL, DIMENSION(klon)                     :: petA_orc, peqA_orc
173    REAL, DIMENSION(klon)                     :: petB_orc, peqB_orc
174! Pb de correspondances de grilles
175    INTEGER, DIMENSION(:), SAVE, ALLOCATABLE  :: ig, jg
176    !$OMP THREADPRIVATE(ig,jg)
177    INTEGER :: indi, indj
178    INTEGER, SAVE, ALLOCATABLE,DIMENSION(:)   :: ktindex
179    !$OMP THREADPRIVATE(ktindex)
180
181! Essai cdrag
182    REAL, DIMENSION(klon)                     :: cdrag
183    INTEGER,SAVE                              :: offset
184    !$OMP THREADPRIVATE(offset)
185
186    REAL, DIMENSION(klon_glo)                 :: rlon_g,rlat_g
187    INTEGER, SAVE                             :: orch_comm
188    !$OMP THREADPRIVATE(orch_comm)
189
190    REAL, ALLOCATABLE, DIMENSION(:), SAVE     :: coastalflow
191    !$OMP THREADPRIVATE(coastalflow)
192    REAL, ALLOCATABLE, DIMENSION(:), SAVE     :: riverflow
193    !$OMP THREADPRIVATE(riverflow)
[987]194   
195    INTEGER :: orch_omp_rank
196    INTEGER :: orch_omp_size
[781]197!
198! Fin definition
199!****************************************************************************************
200
201    IF (check) WRITE(lunout,*)'Entree ', modname
202 
203! Initialisation
204 
205    IF (debut) THEN
[1067]206! Test of coherence between variable ok_veget and cpp key CPP_VEGET
207#ifndef CPP_VEGET
208       abort_message='Pb de coherence: ok_veget = .true. mais CPP_VEGET = .false.'
209       CALL abort_gcm(modname,abort_message,1)
210#endif
211
[987]212       CALL Init_surf_para(knon)
[781]213       ALLOCATE(ktindex(knon))
214       IF ( .NOT. ALLOCATED(albedo_keep)) THEN
[987]215!ym          ALLOCATE(albedo_keep(klon))
216!ym bizarre que non alloué en knon precedement
217          ALLOCATE(albedo_keep(knon))
[781]218          ALLOCATE(zlev(knon))
219       ENDIF
220! Pb de correspondances de grilles
221       ALLOCATE(ig(klon))
222       ALLOCATE(jg(klon))
223       ig(1) = 1
224       jg(1) = 1
225       indi = 0
226       indj = 2
227       DO igrid = 2, klon - 1
228          indi = indi + 1
229          IF ( indi > iim) THEN
230             indi = 1
231             indj = indj + 1
232          ENDIF
233          ig(igrid) = indi
234          jg(igrid) = indj
235       ENDDO
236       ig(klon) = 1
237       jg(klon) = jjm + 1
238
239       IF ((.NOT. ALLOCATED(lalo))) THEN
240          ALLOCATE(lalo(knon,2), stat = error)
241          IF (error /= 0) THEN
242             abort_message='Pb allocation lalo'
243             CALL abort_gcm(modname,abort_message,1)
244          ENDIF
245       ENDIF
246       IF ((.NOT. ALLOCATED(lon_scat))) THEN
247          ALLOCATE(lon_scat(iim,jjm+1), stat = error)
248          IF (error /= 0) THEN
249             abort_message='Pb allocation lon_scat'
250             CALL abort_gcm(modname,abort_message,1)
251          ENDIF
252       ENDIF
253       IF ((.NOT. ALLOCATED(lat_scat))) THEN
254          ALLOCATE(lat_scat(iim,jjm+1), stat = error)
255          IF (error /= 0) THEN
256             abort_message='Pb allocation lat_scat'
257             CALL abort_gcm(modname,abort_message,1)
258          ENDIF
259       ENDIF
260       lon_scat = 0.
261       lat_scat = 0.
262       DO igrid = 1, knon
263          index = knindex(igrid)
264          lalo(igrid,2) = rlon(index)
265          lalo(igrid,1) = rlat(index)
266       ENDDO
267
268       
269       
270       CALL Gather(rlon,rlon_g)
271       CALL Gather(rlat,rlat_g)
272
273       IF (is_mpi_root) THEN
274          index = 1
275          DO jj = 2, jjm
276             DO ij = 1, iim
277                index = index + 1
278                lon_scat(ij,jj) = rlon_g(index)
279                lat_scat(ij,jj) = rlat_g(index)
280             ENDDO
281          ENDDO
282          lon_scat(:,1) = lon_scat(:,2)
283          lat_scat(:,1) = rlat_g(1)
284          lon_scat(:,jjm+1) = lon_scat(:,2)
285          lat_scat(:,jjm+1) = rlat_g(klon_glo)
286       ENDIF
287   
[1023]288       CALL bcast(lon_scat)
289       CALL bcast(lat_scat)
[781]290!
291! Allouer et initialiser le tableau des voisins et des fraction de continents
292!
293       IF ( (.NOT.ALLOCATED(neighbours))) THEN
294          ALLOCATE(neighbours(knon,8), stat = error)
295          IF (error /= 0) THEN
296             abort_message='Pb allocation neighbours'
297             CALL abort_gcm(modname,abort_message,1)
298          ENDIF
299       ENDIF
300       neighbours = -1.
301       IF (( .NOT. ALLOCATED(contfrac))) THEN
302          ALLOCATE(contfrac(knon), stat = error)
303          IF (error /= 0) THEN
304             abort_message='Pb allocation contfrac'
305             CALL abort_gcm(modname,abort_message,1)
306          ENDIF
307       ENDIF
308
309       DO igrid = 1, knon
310          ireal = knindex(igrid)
311          contfrac(igrid) = pctsrf(ireal,is_ter)
312       ENDDO
313
314
315       CALL Init_neighbours(knon,neighbours,knindex,pctsrf(:,is_ter))
316
317!
318!  Allocation et calcul resolutions
319       IF ( (.NOT.ALLOCATED(resolution))) THEN
320          ALLOCATE(resolution(knon,2), stat = error)
321          IF (error /= 0) THEN
322             abort_message='Pb allocation resolution'
323             CALL abort_gcm(modname,abort_message,1)
324          ENDIF
325       ENDIF
326       DO igrid = 1, knon
327          ij = knindex(igrid)
328          resolution(igrid,1) = cuphy(ij)
329          resolution(igrid,2) = cvphy(ij)
330       ENDDO
331     
332       ALLOCATE(coastalflow(klon), stat = error)
333       IF (error /= 0) THEN
334          abort_message='Pb allocation coastalflow'
335          CALL abort_gcm(modname,abort_message,1)
336       ENDIF
337       
338       ALLOCATE(riverflow(klon), stat = error)
339       IF (error /= 0) THEN
340          abort_message='Pb allocation riverflow'
341          CALL abort_gcm(modname,abort_message,1)
342       ENDIF
343
344    ENDIF                          ! (fin debut)
345
346!
347! Appel a la routine sols continentaux
348!
349    IF (lafin) lrestart_write = .TRUE.
350    IF (check) WRITE(lunout,*)'lafin ',lafin,lrestart_write
[987]351     
[781]352    petA_orc(1:knon) = petBcoef(1:knon) * dtime
353    petB_orc(1:knon) = petAcoef(1:knon)
354    peqA_orc(1:knon) = peqBcoef(1:knon) * dtime
355    peqB_orc(1:knon) = peqAcoef(1:knon)
356
357    cdrag = 0.
358    cdrag(1:knon) = tq_cdrag(1:knon)
359
360! zlev(1:knon) = (100.*plev(1:knon))/((ps(1:knon)/287.05*temp_air(1:knon))*9.80665)
361    zlev(1:knon) = (100.*plev(1:knon))/((ps(1:knon)/RD*temp_air(1:knon))*RG)
362
363
364! PF et PASB
365!   where(cdrag > 0.01)
366!     cdrag = 0.01
367!   endwhere
368!  write(*,*)'Cdrag = ',minval(cdrag),maxval(cdrag)
369
370 
371    IF (debut) THEN
[987]372       CALL Init_orchidee_index(knon,knindex,offset,ktindex)
373       CALL Get_orchidee_communicator(orch_comm,orch_omp_size,orch_omp_rank)
374       CALL Init_synchro_omp
375       
[1023]376       IF (knon > 0) THEN
[1067]377#ifdef CPP_VEGET
[987]378         CALL Init_intersurf(nbp_lon,nbp_lat,knon,ktindex,offset,orch_omp_size,orch_omp_rank,orch_comm)
[1067]379#endif
[987]380       ENDIF
[802]381
[987]382       
383       IF (knon > 0) THEN
384
[1067]385#ifdef CPP_VEGET
[802]386          CALL intersurf_main (itime+itau_phy-1, iim, jjm+1, knon, ktindex, dtime, &
387               lrestart_read, lrestart_write, lalo, &
388               contfrac, neighbours, resolution, date0, &
389               zlev,  u1_lay, v1_lay, spechum, temp_air, epot_air, ccanopy, &
390               cdrag, petA_orc, peqA_orc, petB_orc, peqB_orc, &
391               precip_rain, precip_snow, lwdown, swnet, swdown, ps, &
392               evap, fluxsens, fluxlat, coastalflow, riverflow, &
393               tsol_rad, tsurf_new, qsurf, albedo_out, emis_new, z0_new, &
[1146]394               lon_scat, lat_scat, q2m, t2m)
[1067]395#endif         
[781]396       ENDIF
397
[987]398       CALL Synchro_omp
399
[781]400       albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2.
401
402    ENDIF
403
[987]404   
[781]405!  swdown_vrai(1:knon) = swnet(1:knon)/(1. - albedo_keep(1:knon))
406    swdown_vrai(1:knon) = swdown(1:knon)
407
[987]408    IF (knon > 0) THEN
[1067]409#ifdef CPP_VEGET   
[987]410       CALL intersurf_main (itime+itau_phy, iim, jjm+1, knon, ktindex, dtime,  &
[802]411            lrestart_read, lrestart_write, lalo, &
412            contfrac, neighbours, resolution, date0, &
[781]413            zlev,  u1_lay(1:knon), v1_lay(1:knon), spechum(1:knon), temp_air(1:knon), epot_air(1:knon), ccanopy(1:knon), &
414            cdrag(1:knon), petA_orc(1:knon), peqA_orc(1:knon), petB_orc(1:knon), peqB_orc(1:knon), &
415            precip_rain(1:knon), precip_snow(1:knon), lwdown(1:knon), swnet(1:knon), swdown_vrai(1:knon), ps(1:knon), &
416            evap(1:knon), fluxsens(1:knon), fluxlat(1:knon), coastalflow(1:knon), riverflow(1:knon), &
417            tsol_rad(1:knon), tsurf_new(1:knon), qsurf(1:knon), albedo_out(1:knon,:), emis_new(1:knon), z0_new(1:knon), &
[1146]418            lon_scat, lat_scat, q2m, t2m)
[1067]419#endif       
[781]420    ENDIF
421
[987]422    CALL Synchro_omp
423   
[781]424    albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2.
425
426!* Send to coupler
427!
[996]428    IF (type_ocean=='couple') THEN
[781]429       CALL cpl_send_land_fields(itime, knon, knindex, &
430            riverflow, coastalflow)
431    ENDIF
432
[888]433    alb1_new(1:knon) = albedo_out(1:knon,1)
434    alb2_new(1:knon) = albedo_out(1:knon,2)
[781]435
436! Convention orchidee: positif vers le haut
437    fluxsens(1:knon) = -1. * fluxsens(1:knon)
438    fluxlat(1:knon)  = -1. * fluxlat(1:knon)
439   
440!  evap     = -1. * evap
441
442    IF (debut) lrestart_read = .FALSE.
443   
[987]444    IF (debut) CALL Finalize_surf_para
445   
[781]446  END SUBROUTINE surf_land_orchidee
447!
448!****************************************************************************************
449!
[987]450  SUBROUTINE Init_orchidee_index(knon,knindex,offset,ktindex)
451  USE mod_surf_para
452  USE mod_grid_phy_lmdz
453 
454    INTEGER,INTENT(IN)    :: knon
455    INTEGER,INTENT(IN)    :: knindex(klon)   
456    INTEGER,INTENT(OUT)   :: offset
457    INTEGER,INTENT(OUT)   :: ktindex(klon)
[781]458   
[987]459    INTEGER               :: ktindex_glo(knon_glo)
460    INTEGER               :: offset_para(0:omp_size*mpi_size-1)
461    INTEGER               :: LastPoint
462    INTEGER               :: task
[781]463   
[987]464    ktindex(1:knon)=knindex(1:knon)+(klon_mpi_begin-1)+(klon_omp_begin-1)+nbp_lon-1
[781]465   
[987]466    CALL gather_surf(ktindex(1:knon),ktindex_glo)
467   
468    IF (is_mpi_root .AND. is_omp_root) THEN
469      LastPoint=0
470      DO Task=0,mpi_size*omp_size-1
471        IF (knon_glo_para(Task)>0) THEN
472           offset_para(task)= LastPoint-MOD(LastPoint,nbp_lon)
473           LastPoint=ktindex_glo(knon_glo_end_para(task))
474        ENDIF
475      ENDDO
[781]476    ENDIF
477   
[987]478    CALL bcast(offset_para)
[781]479   
[987]480    offset=offset_para(omp_size*mpi_rank+omp_rank)
481   
482    ktindex(1:knon)=ktindex(1:knon)-offset
[781]483
[987]484  END SUBROUTINE Init_orchidee_index
485
[781]486!
[987]487!************************* ***************************************************************
[781]488!
[987]489
490  SUBROUTINE Get_orchidee_communicator(orch_comm,orch_omp_size,orch_omp_rank)
491  USE  mod_surf_para
492     
[1001]493#ifdef CPP_MPI
[781]494    INCLUDE 'mpif.h'
495#endif   
496
497    INTEGER,INTENT(OUT) :: orch_comm
[987]498    INTEGER,INTENT(OUT) :: orch_omp_size
499    INTEGER,INTENT(OUT) :: orch_omp_rank
[781]500    INTEGER             :: color
[987]501    INTEGER             :: i,ierr
[802]502!
503! End definition
504!****************************************************************************************
[781]505   
[987]506   
507    IF (is_omp_root) THEN         
508     
509      IF (knon_mpi==0) THEN
510         color = 0
511      ELSE
512         color = 1
513      ENDIF
514   
[1001]515#ifdef CPP_MPI   
[987]516      CALL MPI_COMM_SPLIT(COMM_LMDZ_PHY,color,mpi_rank,orch_comm,ierr)
[781]517#endif
[1023]518   
519    ENDIF
520    CALL bcast_omp(orch_comm)
521   
522    IF (knon_mpi /= 0) THEN
523      orch_omp_size=0
524      DO i=0,omp_size-1
525        IF (knon_omp_para(i) /=0) THEN
526          orch_omp_size=orch_omp_size+1
527          IF (i==omp_rank) orch_omp_rank=orch_omp_size-1
528        ENDIF
529      ENDDO
530    ENDIF
[987]531   
[781]532   
533  END SUBROUTINE Get_orchidee_communicator
534!
535!****************************************************************************************
536
[987]537
538  SUBROUTINE Init_neighbours(knon,neighbours,knindex,pctsrf)
539    USE mod_grid_phy_lmdz
540    USE mod_surf_para   
[781]541    INCLUDE "indicesol.h"
[987]542
[1001]543#ifdef CPP_MPI
[781]544    INCLUDE 'mpif.h'
545#endif   
546
[802]547! Input arguments
548!****************************************************************************************
[781]549    INTEGER, INTENT(IN)                     :: knon
[987]550    INTEGER, DIMENSION(klon), INTENT(IN)    :: knindex
[781]551    REAL, DIMENSION(klon), INTENT(IN)       :: pctsrf
552   
[802]553! Output arguments
554!****************************************************************************************
555    INTEGER, DIMENSION(knon,8), INTENT(OUT) :: neighbours
556
557! Local variables
558!****************************************************************************************
559    INTEGER                              :: i, igrid, jj, ij, iglob
560    INTEGER                              :: ierr, ireal, index
561    INTEGER, DIMENSION(8,3)              :: off_ini
562    INTEGER, DIMENSION(8)                :: offset 
[987]563    INTEGER, DIMENSION(nbp_lon,nbp_lat)  :: correspond
564    INTEGER, DIMENSION(knon_glo)         :: ktindex_glo
565    INTEGER, DIMENSION(knon_glo,8)       :: neighbours_glo
566    REAL, DIMENSION(klon_glo)            :: pctsrf_glo
567    INTEGER                              :: ktindex(klon)
[802]568!
569! End definition
570!****************************************************************************************
571
[987]572    ktindex(1:knon)=knindex(1:knon)+(klon_mpi_begin-1)+(klon_omp_begin-1)+nbp_lon-1
[781]573   
[987]574    CALL gather_surf(ktindex(1:knon),ktindex_glo)
575    CALL gather(pctsrf,pctsrf_glo)
[781]576   
[987]577    IF (is_mpi_root .AND. is_omp_root) THEN
578      neighbours_glo(:,:)=-1
[781]579!  Initialisation des offset   
580!
581! offset bord ouest
[987]582       off_ini(1,1) = - nbp_lon   ; off_ini(2,1) = - nbp_lon + 1     ; off_ini(3,1) = 1
583       off_ini(4,1) = nbp_lon + 1 ; off_ini(5,1) = nbp_lon           ; off_ini(6,1) = 2 * nbp_lon - 1
584       off_ini(7,1) = nbp_lon -1  ; off_ini(8,1) = - 1
[781]585! offset point normal
[987]586       off_ini(1,2) = - nbp_lon   ; off_ini(2,2) = - nbp_lon + 1     ; off_ini(3,2) = 1
587       off_ini(4,2) = nbp_lon + 1 ; off_ini(5,2) = nbp_lon           ; off_ini(6,2) = nbp_lon - 1
588       off_ini(7,2) = -1          ; off_ini(8,2) = - nbp_lon - 1
[781]589! offset bord   est
[987]590       off_ini(1,3) = - nbp_lon   ; off_ini(2,3) = - 2 * nbp_lon + 1 ; off_ini(3,3) = - nbp_lon + 1
591       off_ini(4,3) =  1          ; off_ini(5,3) = nbp_lon           ; off_ini(6,3) = nbp_lon - 1
592       off_ini(7,3) = -1          ; off_ini(8,3) = - nbp_lon - 1
[781]593!
594!
595! Attention aux poles
596!
[987]597       DO igrid = 1, knon_glo
598          index = ktindex_glo(igrid)
599          jj = INT((index - 1)/nbp_lon) + 1
600          ij = index - (jj - 1) * nbp_lon
[781]601          correspond(ij,jj) = igrid
602       ENDDO
603       
[987]604       DO igrid = 1, knon_glo
605          iglob = ktindex_glo(igrid)
606         
607          IF (MOD(iglob, nbp_lon) == 1) THEN
[781]608             offset = off_ini(:,1)
[987]609          ELSE IF(MOD(iglob, nbp_lon) == 0) THEN
[781]610             offset = off_ini(:,3)
611          ELSE
612             offset = off_ini(:,2)
613          ENDIF
[987]614         
[781]615          DO i = 1, 8
616             index = iglob + offset(i)
[987]617             ireal = (MIN(MAX(1, index - nbp_lon + 1), klon_glo))
618             IF (pctsrf_glo(ireal) > EPSFRA) THEN
619                jj = INT((index - 1)/nbp_lon) + 1
620                ij = index - (jj - 1) * nbp_lon
621                neighbours_glo(igrid, i) = correspond(ij, jj)
[781]622             ENDIF
623          ENDDO
624       ENDDO
625
626    ENDIF
627   
[987]628    DO i = 1, 8
629      CALL scatter_surf(neighbours_glo(:,i),neighbours(1:knon,i))
[781]630    ENDDO
631  END SUBROUTINE Init_neighbours
[987]632
[781]633!
634!****************************************************************************************
635!
[1146]636#endif
[781]637END MODULE surf_land_orchidee_mod
Note: See TracBrowser for help on using the repository browser.