source: codes/icosagcm/devel/src/initial/etat0.f90 @ 906

Last change on this file since 906 was 906, checked in by dubos, 5 years ago

devel : compute_rhodz for unstructured mesh

File size: 7.0 KB
Line 
1MODULE etat0_mod
2  USE icosa
3  USE etat0_collocated_mod
4  IMPLICIT NONE         
5  PRIVATE
6
7  PUBLIC :: etat0, init_etat0
8
9! Important notes for OpenMP
10! When etat0 is called, vertical OpenMP parallelism is deactivated.
11! Therefore only the omp_level_master thread must work, i.e. :
12!   !$OMP BARRIER
13!    DO ind=1,ndomain
14!      IF (.NOT. assigned_domain(ind) .OR. .NOT. is_omp_level_master) CYCLE
15!      ...
16!    END DO
17!   !$OMP BARRIER
18! There MUST be NO OMP BARRIER inside the DO-LOOP or any routine it calls.
19
20CONTAINS
21 
22  SUBROUTINE init_etat0
23    USE etat0_database_mod, ONLY: init_etat0_database => init_etat0 
24    USE etat0_start_file_mod, ONLY: init_etat0_start_file => init_etat0 
25    USE etat0_heldsz_mod, ONLY: init_etat0_held_suarez => init_etat0 
26   
27    CALL getin("etat0",etat0_type)
28
29    SELECT CASE (TRIM(etat0_type))
30      CASE ('isothermal')
31      CASE ('temperature_profile')
32      CASE ('jablonowsky06')
33      CASE ('dcmip5')
34      CASE ('williamson91.6')
35      CASE ('start_file')
36        CALL init_etat0_start_file
37      CASE ('database')
38        CALL init_etat0_database
39      CASE ('academic')
40      CASE ('held_suarez')
41         CALL init_etat0_held_suarez
42      CASE ('venus')
43      CASE ('dcmip1')
44      CASE ('dcmip2_mountain','dcmip2_schaer_noshear','dcmip2_schaer_shear')
45      CASE ('dcmip3')
46      CASE ('dcmip4')
47      CASE ('dcmip2016_baroclinic_wave')
48      CASE ('dcmip2016_cyclone')
49      CASE ('dcmip2016_supercell')
50      CASE ('bubble')
51      CASE DEFAULT
52         PRINT*, 'Bad selector for variable etat0 <',TRIM(etat0_type),'>'// &
53            ' options are  <isothermal>, <temperature_profile>, <jablonowsky06>, <dcmip5>, <williamson91.6>,'& 
54                         //' <start_file>, <database>, <academic>, <held_suarez>, <venus>, <dcmip1>,'         &
55                         //' <dcmip2_mountain,dcmip2_schaer_noshear,dcmip2_schaer_shear>, <dcmip3>, <dcmip4>,'&
56                         //' <dcmip2016_baroclinic_wave>, <dcmip2016_cyclone>, <dcmip2016_supercell>', 'bubble'
57         STOP
58    END SELECT
59
60  END SUBROUTINE init_etat0
61
62  SUBROUTINE etat0(f_ps,f_mass,f_phis,f_theta_rhodz,f_u, f_geopot,f_w, f_q)
63    USE omp_para, ONLY : is_omp_level_master
64    USE mpipara, ONLY : is_mpi_root
65    USE disvert_mod, ONLY : caldyn_eta, eta_lag
66    USE compute_diagnostics_mod, ONLY : compute_rhodz
67    ! Generic interface
68    USE etat0_isothermal_mod, ONLY : getin_etat0_isothermal=>getin_etat0
69    USE etat0_dcmip1_mod, ONLY : getin_etat0_dcmip1=>getin_etat0
70    USE etat0_dcmip2_mod, ONLY : getin_etat0_dcmip2=>getin_etat0
71    USE etat0_dcmip4_mod, ONLY : getin_etat0_dcmip4=>getin_etat0
72    USE etat0_dcmip5_mod, ONLY : getin_etat0_dcmip5=>getin_etat0
73    USE etat0_bubble_mod, ONLY : getin_etat0_bubble=>getin_etat0
74    USE etat0_williamson_mod, ONLY : getin_etat0_williamson=>getin_etat0
75    USE etat0_temperature_mod, ONLY: getin_etat0_temperature=>getin_etat0
76    USE etat0_dcmip2016_baroclinic_wave_mod, ONLY : getin_etat0_dcmip2016_baroclinic_wave=>getin_etat0
77    USE etat0_dcmip2016_cyclone_mod, ONLY : getin_etat0_dcmip2016_cyclone=>getin_etat0
78    USE etat0_dcmip2016_supercell_mod, ONLY : getin_etat0_dcmip2016_supercell=>getin_etat0
79    ! Ad hoc interfaces
80    USE etat0_academic_mod, ONLY : etat0_academic=>etat0
81    USE etat0_heldsz_mod, ONLY : etat0_heldsz=>etat0
82    USE etat0_venus_mod,  ONLY : etat0_venus=>etat0
83    USE etat0_database_mod, ONLY : etat0_database=>etat0
84    USE etat0_start_file_mod, ONLY : etat0_start_file=>etat0 
85
86    TYPE(t_field),POINTER :: f_ps(:)
87    TYPE(t_field),POINTER :: f_mass(:)
88    TYPE(t_field),POINTER :: f_phis(:)
89    TYPE(t_field),POINTER :: f_theta_rhodz(:)
90    TYPE(t_field),POINTER :: f_u(:)
91    TYPE(t_field),POINTER :: f_geopot(:)
92    TYPE(t_field),POINTER :: f_w(:)
93    TYPE(t_field),POINTER :: f_q(:)
94   
95    REAL(rstd),POINTER :: ps(:), mass(:,:)
96    LOGICAL :: autoinit_mass, autoinit_geopot, collocated
97    INTEGER :: ind,i,j,ij,l
98
99    ! most etat0 routines set ps and not mass
100    ! in that case and if caldyn_eta == eta_lag
101    ! the initial distribution of mass is taken to be the same
102    ! as what the mass coordinate would dictate
103    ! however if etat0_XXX defines mass then the flag autoinit_mass must be set to .FALSE.
104    ! otherwise mass will be overwritten
105    autoinit_mass = (caldyn_eta == eta_lag)
106
107    etat0_type='jablonowsky06'
108    CALL getin("etat0",etat0_type)
109   
110    !------------------- Generic interface ---------------------
111    collocated=.TRUE.
112    SELECT CASE (TRIM(etat0_type))
113    CASE ('isothermal')
114       CALL getin_etat0_isothermal
115    CASE ('temperature_profile')
116       CALL getin_etat0_temperature
117    CASE ('jablonowsky06')
118    CASE ('dcmip1')
119        CALL getin_etat0_dcmip1
120    CASE ('dcmip2_mountain','dcmip2_schaer_noshear','dcmip2_schaer_shear')
121       CALL getin_etat0_dcmip2
122    CASE ('dcmip3')
123    CASE ('dcmip4')
124        CALL getin_etat0_dcmip4
125    CASE ('dcmip5')
126        CALL getin_etat0_dcmip5
127    CASE ('bubble')
128        CALL getin_etat0_bubble
129    CASE ('williamson91.6')
130       autoinit_mass=.FALSE.
131       CALL getin_etat0_williamson
132    CASE ('dcmip2016_baroclinic_wave')
133        CALL getin_etat0_dcmip2016_baroclinic_wave
134    CASE ('dcmip2016_cyclone')
135        CALL getin_etat0_dcmip2016_cyclone
136    CASE ('dcmip2016_supercell')
137        CALL getin_etat0_dcmip2016_supercell
138    CASE DEFAULT
139       collocated=.FALSE.
140       autoinit_mass = .FALSE.
141    END SELECT
142
143    !------------------- Ad hoc interfaces --------------------
144    SELECT CASE (TRIM(etat0_type))
145     CASE ('database')
146        CALL etat0_database(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
147    CASE ('start_file')
148       CALL etat0_start_file(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
149    CASE ('academic')
150       CALL etat0_academic(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
151    CASE ('held_suarez')
152       PRINT *,"Held & Suarez (1994) test case"
153       CALL etat0_heldsz(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
154    CASE ('venus')
155       CALL etat0_venus(f_ps, f_phis, f_theta_rhodz, f_u, f_q)
156       PRINT *, "Venus (Lebonnois et al., 2012) test case"
157   CASE DEFAULT
158      IF(collocated) THEN
159         CALL etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_geopot,f_W, f_q)
160      ELSE
161         PRINT*, 'Bad selector for variable etat0 <',TRIM(etat0_type),'>'// &
162            ' options are  <isothermal>, <temperature_profile>, <jablonowsky06>, <dcmip5>, <williamson91.6>,'& 
163                         //' <start_file>, <database>, <academic>, <held_suarez>, <venus>, <dcmip1>,'         &
164                         //' <dcmip2_mountain,dcmip2_schaer_noshear,dcmip2_schaer_shear>, <dcmip3>, <dcmip4>,'&
165                         //' <dcmip2016_baroclinic_wave>, <dcmip2016_cyclone>, <dcmip2016_supercell>'
166         STOP
167      END IF
168    END SELECT
169
170    IF(autoinit_mass) THEN
171       DO ind=1,ndomain
172          IF (.NOT. assigned_domain(ind) .OR. .NOT. is_omp_level_master) CYCLE
173          CALL swap_dimensions(ind)
174          CALL swap_geometry(ind)
175          mass=f_mass(ind); ps=f_ps(ind)
176          CALL compute_rhodz(.TRUE., ps, mass) ! initialize mass distribution using ps
177       END DO
178    END IF
179 
180  END SUBROUTINE etat0
181
182END MODULE etat0_mod
Note: See TracBrowser for help on using the repository browser.