source: codes/icosagcm/trunk/src/geopotential_mod.f90 @ 19

Last change on this file since 19 was 19, checked in by ymipsl, 12 years ago

Simplify the management of the module.

YM

File size: 1.8 KB
Line 
1MODULE geopotential_mod
2
3CONTAINS
4
5  SUBROUTINE geopotential(f_phis,f_pks,f_pk,f_theta,f_phi)
6  USE icosa
7  IMPLICIT NONE
8    TYPE(t_field), POINTER :: f_phis(:)
9    TYPE(t_field), POINTER :: f_pks(:)
10    TYPE(t_field), POINTER :: f_pk(:)
11    TYPE(t_field), POINTER :: f_theta(:)
12    TYPE(t_field), POINTER :: f_phi(:)
13 
14    REAL(rstd), POINTER :: phis(:)
15    REAL(rstd), POINTER :: pks(:)
16    REAL(rstd), POINTER :: pk(:,:)
17    REAL(rstd), POINTER :: theta(:,:)
18    REAL(rstd), POINTER :: phi(:,:)
19    INTEGER :: ind
20
21    DO ind=1,ndomain
22      CALL swap_dimensions(ind)
23      CALL swap_geometry(ind)
24      phis=f_phis(ind)
25      pks=f_pks(ind)
26      pk=f_pk(ind)
27      theta=f_theta(ind)
28      phi=f_phi(ind)
29      CALL compute_geopotential(phis,pks,pk,theta,phi,0)
30    ENDDO
31 
32  END SUBROUTINE geopotential
33 
34  SUBROUTINE compute_geopotential(phis,pks,pk,theta,phi,offset)
35  USE icosa
36  IMPLICIT NONE
37    REAL(rstd),INTENT(IN) :: phis(iim*jjm)
38    REAL(rstd),INTENT(IN) :: pks(iim*jjm)
39    REAL(rstd),INTENT(IN) :: pk(iim*jjm,llm)
40    REAL(rstd),INTENT(IN) :: theta(iim*jjm,llm)
41    REAL(rstd),INTENT(OUT) :: phi(iim*jjm,llm)
42    INTEGER,INTENT(IN) :: offset
43    INTEGER :: i,j,ij,l
44
45!!! Compute geopotential
46
47  ! for first layer
48   DO j=jj_begin-offset,jj_end+offset
49     DO i=ii_begin-offset,ii_end+offset
50       ij=(j-1)*iim+i
51       phi( ij,1 ) = phis( ij ) + theta(ij,1) * ( pks(ij) - pk(ij,1) )
52     ENDDO
53   ENDDO
54         
55  ! for other layers
56   DO l = 2, llm
57     DO j=jj_begin-offset,jj_end+offset
58       DO i=ii_begin-offset,ii_end+offset
59         ij=(j-1)*iim+i
60         phi(ij,l) = phi(ij,l-1) + 0.5 * ( theta(ij,l)  + theta(ij,l-1) )  & 
61                                       * (  pk(ij,l-1) -  pk(ij,l)    )
62       ENDDO
63     ENDDO
64   ENDDO
65   
66  END SUBROUTINE compute_geopotential
67
68END MODULE geopotential_mod
Note: See TracBrowser for help on using the repository browser.