source: LMDZ6/branches/Amaury_dev/libf/phylmd/create_etat0_unstruct_mod.F90 @ 5441

Last change on this file since 5441 was 5224, checked in by abarral, 3 months ago

Merge r5204 r5205
Light lint
Correct missing IOIPSL includes

File size: 10.1 KB
Line 
1MODULE create_etat0_unstruct_mod
2
3  REAL, SAVE, ALLOCATABLE :: zmea_gw(:)
4  !$OMP THREADPRIVATE(zmea_gw)
5  REAL, SAVE, ALLOCATABLE :: zpic_gw(:)
6  !$OMP THREADPRIVATE(zpic_gw)
7  REAL, SAVE, ALLOCATABLE :: zval_gw(:)
8  !$OMP THREADPRIVATE(zval_gw)
9  REAL, SAVE, ALLOCATABLE :: zstd_gw(:)
10  !$OMP THREADPRIVATE(zstd_gw)
11  REAL, SAVE, ALLOCATABLE :: zsig_gw(:)
12  !$OMP THREADPRIVATE(zsig_gw)
13  REAL, SAVE, ALLOCATABLE :: zgam_gw(:)
14  !$OMP THREADPRIVATE(zgam_gw)
15  REAL, SAVE, ALLOCATABLE :: zthe_gw(:)
16  !$OMP THREADPRIVATE(zthe_gw)
17
18  PRIVATE zmea_gw, zpic_gw, zval_gw, zstd_gw, zsig_gw, zgam_gw, zthe_gw
19
20
21CONTAINS
22 
23  SUBROUTINE init_create_etat0_unstruct
24  USE lmdz_xios
25  USE netcdf, ONLY: nf90_nowrite,nf90_close,nf90_noerr,nf90_open
26  USE lmdz_phys_para
27  IMPLICIT NONE
28  INTEGER :: file_id, iret
29 
30   ! for coupling activate ocean fraction reading from file "ocean_fraction.nc"
31    IF (is_omp_master) THEN
32
33      IF (nf90_open("ocean_fraction.nc", nf90_nowrite, file_id)==nf90_noerr) THEN
34        CALL xios_set_file_attr("frac_ocean",enabled=.TRUE.)
35        CALL xios_set_field_attr("mask",field_ref="frac_ocean_read")
36        iret=nf90_close(file_id)
37      ELSE IF (nf90_open("land_water_0.05.nc", nf90_nowrite, file_id)==nf90_noerr) THEN
38        CALL xios_set_file_attr("land_water",name="land_water_0.05",enabled=.TRUE.)
39        CALL xios_set_field_attr("mask",field_ref="land_water")
40        iret=nf90_close(file_id)
41      ELSE IF (nf90_open("land_water_0.25.nc", nf90_nowrite, file_id)==nf90_noerr) THEN
42        CALL xios_set_file_attr("land_water",name="land_water_0.25",enabled=.TRUE.)
43        CALL xios_set_field_attr("mask",field_ref="land_water")
44        iret=nf90_close(file_id)
45      ELSE IF (nf90_open("land_water_0.50.nc", nf90_nowrite, file_id)==nf90_noerr) THEN
46        CALL xios_set_file_attr("land_water",name="land_water_0.50",enabled=.TRUE.)
47        CALL xios_set_field_attr("mask",field_ref="land_water")
48        iret=nf90_close(file_id)
49      ENDIF
50
51    ENDIF
52
53  END SUBROUTINE init_create_etat0_unstruct
54 
55 
56  SUBROUTINE init_param_gw(zmea, zpic, zval, zstd, zsig, zgam, zthe)
57  USE dimphy
58    REAL, INTENT(IN) :: zmea(klon) 
59    REAL, INTENT(IN) :: zpic(klon)
60    REAL, INTENT(IN) :: zval(klon)
61    REAL, INTENT(IN) :: zstd(klon)
62    REAL, INTENT(IN) :: zsig(klon)
63    REAL, INTENT(IN) :: zgam(klon)
64    REAL, INTENT(IN) :: zthe(klon)
65
66    ALLOCATE(zmea_gw(klon), zpic_gw(klon), zval_gw(klon), zstd_gw(klon), zsig_gw(klon), zgam_gw(klon), zthe_gw(klon))
67   
68    zmea_gw(:)=zmea(:)
69    zpic_gw(:)=zpic(:)
70    zval_gw(:)=zval(:)
71    zstd_gw(:)=zstd(:)
72    zsig_gw(:)=zsig(:)
73    zgam_gw(:)=zgam(:)
74    zthe_gw(:)=zthe(:)
75
76  END SUBROUTINE init_param_gw
77
78
79
80
81  SUBROUTINE create_etat0_unstruct
82  USE dimphy
83  USE lmdz_xios
84  USE infotrac_phy
85  USE fonte_neige_mod
86  USE pbl_surface_mod
87  USE phys_state_var_mod
88  USE indice_sol_mod
89  USE surface_data,      ONLY: landice_opt
90  USE lmdz_phys_para
91  USE lmdz_print_control, ONLY: lunout
92  USE lmdz_geometry
93  USE lmdz_ioipsl_getin_p, ONLY: getin_p
94  USE lmdz_alpale
95  USE lmdz_clesphys
96  USE lmdz_compbl, ONLY: iflag_pbl, iflag_pbl_split, iflag_order2_sollw, ifl_pbltree
97
98  IMPLICIT NONE
99  INCLUDE 'dimsoil.h'
100
101    LOGICAL :: no_ter_antartique   ! If true, no land points are allowed at Antartic
102    REAL,    DIMENSION(klon)                 :: tsol
103    REAL,    DIMENSION(klon)                 :: sn
104    REAL,    DIMENSION(klon)                 :: rugmer
105    REAL,    DIMENSION(klon)                 :: run_off_lic_0
106    REAL,    DIMENSION(klon)                 :: lic
107    REAL,    DIMENSION(klon)                 :: fder
108
109    REAL,    DIMENSION(klon,nbsrf)           :: qsurf, snsrf
110    REAL,    DIMENSION(klon,nsoilmx,nbsrf)   :: tsoil
111   
112    REAL,    DIMENSION(klon_mpi)             :: tsol_mpi, qsol_mpi, zmasq_mpi, lic_mpi
113    REAL,    DIMENSION(klon_mpi)             :: zmea_mpi, zstd_mpi, zsig_mpi, zgam_mpi, zthe_mpi
114    REAL,    DIMENSION(klon_mpi)             :: cell_area_mpi
115    REAL,    DIMENSION(klon_mpi,nbsrf)       :: pctsrf_mpi
116
117    INTEGER :: ji,j,i
118 
119
120!--- Initial atmospheric CO2 conc. from .def file
121    co2_ppm0 = co2_ppm
122
123    IF (is_omp_master) THEN
124      CALL xios_recv_field("ts",tsol_mpi)
125      CALL xios_recv_field("qs",qsol_mpi)
126      CALL xios_recv_field("mask",zmasq_mpi)
127      IF (landice_opt < 2) CALL xios_recv_field("landice",lic_mpi)
128    ENDIF
129    CALL scatter_omp(tsol_mpi,tsol)
130    CALL scatter_omp(qsol_mpi,qsol)
131    CALL scatter_omp(zmasq_mpi,zmasq)
132    IF (landice_opt < 2) CALL scatter_omp(lic_mpi,lic)
133
134    radsol(:)   = 0.0
135    rugmer(:) = 0.001
136    sn(:)     = 0
137
138    WHERE(qsol(:)<0) qsol(:)=0
139       
140    WHERE(   zmasq(:)<EPSFRA) zmasq(:)=0.
141    WHERE(1.-zmasq(:)<EPSFRA) zmasq(:)=1.
142
143    pctsrf(:,:) = 0
144    IF (landice_opt < 2) THEN
145       pctsrf(:,is_lic)=lic
146       WHERE(pctsrf(:,is_lic)<EPSFRA) pctsrf(:,is_lic)=0.
147       WHERE(zmasq(:)<EPSFRA)         pctsrf(:,is_lic)=0.
148
149       pctsrf(:,is_ter)=zmasq(:)
150       
151       !--- Adequation with soil/sea mask
152       DO ji=1,klon
153          IF(zmasq(ji)>EPSFRA) THEN
154             IF(pctsrf(ji,is_lic)>=zmasq(ji)) THEN
155                pctsrf(ji,is_lic)=zmasq(ji)
156                pctsrf(ji,is_ter)=0.
157             ELSE
158                pctsrf(ji,is_ter)=zmasq(ji)-pctsrf(ji,is_lic)
159                IF(pctsrf(ji,is_ter)<EPSFRA) THEN
160                   pctsrf(ji,is_ter)=0.
161                   pctsrf(ji,is_lic)=zmasq(ji)
162                END IF
163             END IF
164          END IF
165       END DO
166   
167    ELSE
168       ! landice_opt=>2 : no land ice
169       pctsrf(:,is_lic)=0.0
170       pctsrf(:,is_ter)=zmasq(:)
171    END IF
172
173
174
175
176
177  !--- Option no_ter_antartique removes all land fractions souther than 60S.
178  !--- Land ice is set instead of the land fractions on these latitudes.
179  !--- The ocean and sea-ice fractions are not changed.
180  !--- This option is only available if landice_opt<2.   
181  IF (landice_opt < 2) THEN
182     no_ter_antartique=.FALSE.
183     CALL getin_p('no_ter_antartique',no_ter_antartique)
184     WRITE(lunout,*)"no_ter_antartique=",no_ter_antartique
185     IF (no_ter_antartique) THEN
186        ! Remove all land fractions souther than 60S and set land-ice instead
187        WRITE(lunout,*) "Remove land fractions souther than 60deg south by increasing"
188        WRITE(lunout,*) "the continental ice fractions. No land can now be found at Antartic."
189        DO ji=1, klon
190           IF (latitude_deg(ji)<-60.0) THEN
191              pctsrf(ji,is_lic) = pctsrf(ji,is_lic) + pctsrf(ji,is_ter)
192              pctsrf(ji,is_ter) = 0
193           END IF
194        END DO
195     END IF
196  END IF
197   
198! sub-surface ocean and sea ice (sea ice set to zero for start)
199!*******************************************************************************
200    pctsrf(:,is_oce)=(1.-zmasq(:))
201    WHERE(pctsrf(:,is_oce)<EPSFRA) pctsrf(:,is_oce)=0.
202   
203!    zval(:)=max(0.,zmea-2*zstd(:))
204!    zpic(:)=zmea+2*zstd(:)
205   
206!! WARNING    DON'T FORGET FOR LATER
207!!ym  IF(couple) pctsrf(:,is_oce)=ocemask_fi(:)
208!!
209   
210! Init: tsol, qsol, sn, evap, tsoil, rain_fall, snow_fall, solsw, sollw, frugs
211!*******************************************************************************
212    DO i=1,nbsrf
213     ftsol(:,i) = tsol
214    END DO
215 
216    DO i=1,nbsrf
217     snsrf(:,i) = sn
218    END DO
219!albedo SB >>>
220!ym error : the sub surface dimension is the third not second
221!    falb_dir(:,is_ter,:)=0.08; falb_dir(:,is_lic,:)=0.6
222!    falb_dir(:,is_oce,:)=0.5;  falb_dir(:,is_sic,:)=0.6
223    falb_dir(:,:,is_ter)=0.08; falb_dir(:,:,is_lic)=0.6
224    falb_dir(:,:,is_oce)=0.5;  falb_dir(:,:,is_sic)=0.6
225
226!ym falb_dif has been forgotten, initialize with defaukt value found in phyetat0 or 0 ?
227!ym probably the uninitialized value was 0 for standard (regular grid) case
228    falb_dif(:,:,:)=0
229    u10m(:,:)=0 
230    v10m(:,:)=0 
231    treedrg(:,:,:)=0
232!albedo SB <<<
233    fevap(:,:) = 0.
234    qsurf = 0.
235   
236    DO i=1,nbsrf
237      DO j=1,nsoilmx
238        tsoil(:,j,i) = tsol
239      END DO
240    END DO
241 
242    rain_fall = 0.; snow_fall = 0.
243    solsw = 165.;   sollw = -53.
244    solswfdiff = 1.
245!ym warning missing init for sollwdown => set to 0
246  sollwdown  = 0.
247   
248   
249    t_ancien = 273.15
250    u_ancien=0
251    v_ancien=0
252    q_ancien = 0.
253    ql_ancien = 0.
254    qs_ancien = 0.
255    prlw_ancien = 0.
256    prsw_ancien = 0.
257    prw_ancien = 0.
258    agesno = 0.
259   
260    ! LSCP condensation and ice supersaturation
261    cf_ancien = 0.
262    rvc_ancien = 0.
263
264    wake_delta_pbl_TKE(:,:,:)=0
265    wake_dens(:)=0
266    awake_dens = 0.
267    cv_gen = 0.
268    ale_bl = 0.
269    ale_bl_trig =0.
270    alp_bl=0.
271    ale_wake=0.
272    ale_bl_stat=0.
273   
274    z0m(:,:)=0 ! ym missing 5th subsurface initialization
275    z0m(:,is_oce) = rugmer(:)
276    z0m(:,is_ter) = 0.01 ! MAX(1.0e-05,zstd(:)*zsig(:)/2.0)
277    z0m(:,is_lic) = 0.001 !MAX(1.0e-05,zstd(:)*zsig(:)/2.0)
278    z0m(:,is_sic) = 0.001
279    z0h(:,:)=z0m(:,:)
280
281    fder = 0.0
282    clwcon = 0.0
283    rnebcon = 0.0
284    ratqs = 0.0
285    run_off_lic_0 = 0.0
286    rugoro = 0.0
287
288! Before phyredem calling, surface modules and values to be saved in startphy.nc
289! are initialized
290!*******************************************************************************
291    pbl_tke(:,:,:) = 1.e-8
292    zmax0(:) = 40.
293    f0(:) = 1.e-5
294    sig1(:,:) = 0.
295    w01(:,:) = 0.
296    wake_deltat(:,:) = 0.
297    wake_deltaq(:,:) = 0.
298    wake_s(:) = 0.
299    wake_cstar(:) = 0.
300    wake_fip(:) = 0.
301    wake_pe = 0.
302    fm_therm = 0.
303    entr_therm = 0.
304    detr_therm = 0.
305    awake_s = 0.
306
307    CALL fonte_neige_init(run_off_lic_0)
308    CALL pbl_surface_init( fder, snsrf, qsurf, tsoil )
309
310    IF (iflag_pbl>1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1) THEN
311     delta_tsurf = 0.
312     beta_aridity = 0.
313    END IF
314    ratqs_inter_ = 0.002
315
316    CALL gather_omp(cell_area,cell_area_mpi)
317    CALL gather_omp(pctsrf,pctsrf_mpi)
318    IF (is_omp_master) THEN
319      CALL xios_send_field("area_ce0l",cell_area_mpi)
320      CALL xios_send_field("fract_oce_ce0l",pctsrf_mpi(:,is_oce))
321      CALL xios_send_field("fract_sic_ce0l",pctsrf_mpi(:,is_sic))
322    ENDIF
323   
324    zmea(:) = zmea_gw(:)
325    zpic(:) = zpic_gw(:)
326    zval(:) = zval_gw(:)
327    zstd(:) = zstd_gw(:)
328    zsig(:) = zsig_gw(:)
329    zgam(:) = zgam_gw(:)
330    zthe(:) = zthe_gw(:)
331    DEALLOCATE(zmea_gw, zpic_gw, zval_gw, zstd_gw, zsig_gw, zgam_gw, zthe_gw)
332
333    CALL phyredem( "startphy.nc" )
334
335  END SUBROUTINE create_etat0_unstruct
336
337
338END MODULE create_etat0_unstruct_mod
Note: See TracBrowser for help on using the repository browser.