1 | MODULE vertical_remap_mod |
---|
2 | USE icosa |
---|
3 | |
---|
4 | |
---|
5 | CONTAINS |
---|
6 | |
---|
7 | |
---|
8 | SUBROUTINE vertical_remap(pressure_level,field_in,f_ps,field_out) |
---|
9 | USE icosa |
---|
10 | USE pression_mod |
---|
11 | USE omp_para |
---|
12 | IMPLICIT NONE |
---|
13 | REAL(rstd), INTENT(IN) :: pressure_level(:) |
---|
14 | TYPE(t_field),POINTER :: field_in(:) |
---|
15 | TYPE(t_field),POINTER :: f_ps(:) |
---|
16 | TYPE(t_field),POINTER :: field_out(:) |
---|
17 | |
---|
18 | TYPE(t_field),POINTER :: f_p(:) |
---|
19 | REAL(rstd),POINTER :: in(:,:) |
---|
20 | REAL(rstd),POINTER :: out(:,:) |
---|
21 | REAL(rstd),POINTER :: p(:,:) |
---|
22 | |
---|
23 | INTEGER :: ind |
---|
24 | |
---|
25 | CALL allocate_field(f_p,field_t,type_real,llm+1) |
---|
26 | CALL pression(f_ps,f_p) |
---|
27 | |
---|
28 | DO ind=1,ndomain |
---|
29 | IF (.NOT. assigned_domain(ind)) CYCLE |
---|
30 | CALL swap_dimensions(ind) |
---|
31 | CALL swap_geometry(ind) |
---|
32 | p=f_p(ind) |
---|
33 | in=field_in(ind) |
---|
34 | out=field_out(ind) |
---|
35 | CALL compute_vertical_remap(pressure_level,in,p,out) |
---|
36 | ENDDO |
---|
37 | |
---|
38 | END SUBROUTINE vertical_remap |
---|
39 | |
---|
40 | SUBROUTINE compute_vertical_remap(pressure_level,in,p,out) |
---|
41 | USE omp_para |
---|
42 | IMPLICIT NONE |
---|
43 | REAL(rstd),INTENT(IN) :: pressure_level(:) |
---|
44 | REAL(rstd),INTENT(IN) :: in(:,:) |
---|
45 | REAL(rstd),INTENT(IN) :: p(iim*jjm,llm+1) |
---|
46 | REAL(rstd),INTENT(OUT) :: out(iim*jjm,llm) |
---|
47 | REAL(rstd) :: coeff, pmid |
---|
48 | INTEGER :: i,j,ij,l,n,nb_level |
---|
49 | INTEGER :: a |
---|
50 | INTEGER :: b |
---|
51 | LOGICAL :: positive |
---|
52 | |
---|
53 | nb_level=size(pressure_level) |
---|
54 | IF (pressure_level(1)>=pressure_level(nb_level)) THEN |
---|
55 | positive=.FALSE. |
---|
56 | ELSE |
---|
57 | positive=.TRUE. |
---|
58 | ENDIF |
---|
59 | |
---|
60 | !$OMP BARRIER |
---|
61 | IF (is_omp_level_master) THEN |
---|
62 | |
---|
63 | DO l=1,llm |
---|
64 | DO j=jj_begin,jj_end |
---|
65 | DO i=ii_begin,ii_end |
---|
66 | ij=(j-1)*iim+i |
---|
67 | pmid=0.5*(p(ij,l)+p(ij,l+1)) |
---|
68 | IF (positive) THEN |
---|
69 | a=0 |
---|
70 | DO n=1,nb_level-1 |
---|
71 | IF ( (pmid>=pressure_level(n) .AND. pmid<pressure_level(n+1))) THEN |
---|
72 | a=n ; b=n+1 ; EXIT |
---|
73 | ENDIF |
---|
74 | ENDDO |
---|
75 | IF (a==0) THEN |
---|
76 | IF (pmid<=pressure_level(1)) THEN |
---|
77 | a=1 ; b=2 |
---|
78 | ELSE |
---|
79 | a=nb_level-1 ; b=nb_level |
---|
80 | ENDIF |
---|
81 | ENDIF |
---|
82 | ELSE |
---|
83 | a=0 |
---|
84 | DO n=1,nb_level-1 |
---|
85 | IF ( (pmid<=pressure_level(n) .AND. pmid>pressure_level(n+1))) THEN |
---|
86 | a=n ; b=n+1 ; EXIT |
---|
87 | ENDIF |
---|
88 | ENDDO |
---|
89 | |
---|
90 | IF (a==0) THEN |
---|
91 | IF (pmid >= pressure_level(1)) THEN |
---|
92 | a=1 ; b=2 |
---|
93 | ELSE |
---|
94 | a=nb_level-1 ; b=nb_level |
---|
95 | ENDIF |
---|
96 | ENDIF |
---|
97 | ENDIF |
---|
98 | |
---|
99 | coeff=(pmid-pressure_level(a))/(pressure_level(a)-pressure_level(b)) |
---|
100 | out(ij,l)=in(ij,a)+coeff*(in(ij,a)-in(ij,b)) |
---|
101 | ENDDO |
---|
102 | ENDDO |
---|
103 | ENDDO |
---|
104 | |
---|
105 | ENDIF |
---|
106 | !$OMP BARRIER |
---|
107 | |
---|
108 | END SUBROUTINE compute_vertical_remap |
---|
109 | |
---|
110 | END MODULE vertical_remap_mod |
---|