source: codes/icosagcm/trunk/src/etat0_dcmip2.f90 @ 78

Last change on this file since 78 was 71, checked in by dubos, 12 years ago

Minor change in etat0_dcmip2.f90

File size: 4.1 KB
Line 
1MODULE etat0_dcmip2_mod
2
3! test cases DCMIP 2012, category 2 : Orographic gravity waves
4
5  USE genmod
6
7  PRIVATE
8
9  PUBLIC  etat0
10
11CONTAINS
12
13
14  SUBROUTINE etat0(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
15  USE icosa
16  IMPLICIT NONE
17    TYPE(t_field),POINTER :: f_ps(:)
18    TYPE(t_field),POINTER :: f_phis(:)
19    TYPE(t_field),POINTER :: f_theta_rhodz(:)
20    TYPE(t_field),POINTER :: f_u(:)
21    TYPE(t_field),POINTER :: f_q(:)
22   
23    REAL(rstd),POINTER :: ps(:)
24    REAL(rstd),POINTER :: phis(:)
25    REAL(rstd),POINTER :: u(:,:)
26    REAL(rstd),POINTER :: theta_rhodz(:,:)
27    REAL(rstd),POINTER :: q(:,:,:)
28
29    INTEGER :: ind, icase
30    CHARACTER(len=255) :: etat0_type
31    etat0_type='jablonowsky06'
32    CALL getin("etat0",etat0_type)
33
34    SELECT CASE (TRIM(etat0_type))
35    CASE('dcmip2_mountain')
36       icase=0
37    CASE('dcmip2_schaer_noshear')
38       icase=1
39    CASE('dcmip2_schaer_shear')
40       icase=2
41    CASE DEFAULT
42       PRINT *, 'This should not happen : etat0_type =', TRIM(etat0_type), ' in etat0_dcmip2.f90/etat0'
43       STOP
44    END SELECT
45    PRINT *, 'Orographic gravity-wave test case :', TRIM(etat0_type)
46
47    DO ind=1,ndomain
48      CALL swap_dimensions(ind)
49      CALL swap_geometry(ind)
50
51      ps=f_ps(ind)
52      phis=f_phis(ind)
53      u=f_u(ind)
54      theta_rhodz=f_theta_rhodz(ind)
55      q=f_q(ind)
56      CALL compute_etat0_DCMIP2(icase,ps,phis,u,theta_rhodz,q)
57    ENDDO
58           
59  END SUBROUTINE etat0
60 
61  SUBROUTINE compute_etat0_DCMIP2(icase, ps, phis, u, theta_rhodz,q)
62    USE icosa
63    USE disvert_ncar_mod, ONLY : ap,bp
64    USE pression_mod
65    USE theta2theta_rhodz_mod
66    USE wind_mod
67    IMPLICIT NONE
68    INTEGER, INTENT(IN) :: icase
69    REAL(rstd), INTENT(OUT) :: ps(iim*jjm)
70    REAL(rstd), INTENT(OUT) :: phis(iim*jjm)
71    REAL(rstd), INTENT(OUT) :: u(3*iim*jjm,llm)
72    REAL(rstd), INTENT(OUT) :: theta_rhodz(iim*jjm,llm)
73    REAL(rstd), INTENT(OUT) :: q(iim*jjm)
74    REAL(rstd) :: ulon(3*iim*jjm,llm), ulat(3*iim*jjm,llm), temp(iim*jjm,llm)
75   
76    INTEGER :: i,j,l,ij
77    REAL(rstd) :: hyam, hybm, pp, dummy1, dummy2, dummy3 
78   
79    ! Hexagons : ps,phis,temp
80    DO l=1,llm
81       ! The surface pressure is not set yet so we provide the hybrid coefficients
82       hyam = .5*(ap(l)+ap(l+1))/preff
83       hybm = .5*(bp(l)+bp(l+1))
84       DO j=jj_begin,jj_end
85          DO i=ii_begin,ii_end
86             ij=(j-1)*iim+i
87             CALL comp_all(xyz_i(ij,:), ps(ij),phis(ij),temp(ij,l), dummy1,dummy2)
88          END DO
89       END DO
90    END DO
91    CALL compute_temperature2theta_rhodz(ps,temp,theta_rhodz,1)
92   
93    ! Edges : ulon,ulat
94    DO l=1,llm
95       ! The surface pressure is not set yet so we provide the hybrid coefficients
96       hyam = .5*(ap(l)+ap(l+1))/preff
97       hybm = .5*(bp(l)+bp(l+1))
98       DO j=jj_begin,jj_end
99          DO i=ii_begin,ii_end
100             ij=(j-1)*iim+i
101             CALL comp_all(xyz_e(ij+u_right,:), dummy1,dummy2,dummy3, ulon(ij+u_right,l),ulat(ij+u_right,l))
102             CALL comp_all(xyz_e(ij+u_lup,:), dummy1,dummy2,dummy3, ulon(ij+u_lup,l),ulat(ij+u_lup,l))
103             CALL comp_all(xyz_e(ij+u_ldown,:), dummy1,dummy2,dummy3, ulon(ij+u_ldown,l),ulat(ij+u_ldown,l))
104          END DO
105       END DO
106    END DO
107    CALL compute_wind_perp_from_lonlat_compound(ulon,ulat,u)
108
109    CONTAINS
110     
111      SUBROUTINE comp_all(xyz, psj,phisj,tempj, ulonj,ulatj)
112        USE dcmip_initial_conditions_test_1_2_3
113        REAL(rstd), INTENT(IN) :: xyz(3)
114        REAL(rstd), INTENT(OUT) :: psj,phisj,tempj,ulonj,ulatj
115        REAL :: lon,lat, dummy
116        dummy=0.
117        CALL xyz2lonlat(xyz,lon,lat)
118        SELECT CASE (icase)
119        CASE(0)
120           CALL test2_steady_state_mountain(lon,lat,dummy,dummy,0,.TRUE.,hyam,hybm, &
121                ulonj,ulatj,dummy,tempj,phisj,psj,dummy,dummy)
122        CASE(1)
123           CALL test2_schaer_mountain(lon,lat,dummy,dummy,0,.TRUE.,hyam,hybm,0,&
124                ulonj,ulatj,dummy,tempj,phisj,psj,dummy,dummy)
125        CASE(2)
126           CALL test2_schaer_mountain(lon,lat,dummy,dummy,0,.TRUE.,hyam,hybm,1, &
127                ulonj,ulatj,dummy,tempj,phisj,psj,dummy,dummy)
128        END SELECT
129      END SUBROUTINE comp_all
130
131  END SUBROUTINE compute_etat0_DCMIP2
132
133
134END MODULE etat0_dcmip2_mod
Note: See TracBrowser for help on using the repository browser.