source: LMDZ5/branches/AI-cosp/libf/dynphy_lonlat/phylmd/init_ssrf_m.F90 @ 4395

Last change on this file since 4395 was 2399, checked in by Ehouarn Millour, 9 years ago

Follow-up from commit 2395: get rid of rlon and rlat, longitude_deg and latitude_deg (from module geometry_mod) should be used instead. Longitudes and latitudes are no longer loaded from startphy.nc but inherited from dynamics (and compatibility with values in startphy.nc is checked). This will change bench results because of roundoffs differences between the two.
EM

File size: 4.5 KB
Line 
1MODULE init_ssrf_m
2!
3!*******************************************************************************
4
5  USE indice_sol_mod, ONLY: is_ter, is_oce, is_oce, is_lic, epsfra
6  USE dimphy,             ONLY: klon, zmasq
7  USE phys_state_var_mod, ONLY: pctsrf
8  USE geometry_mod, ONLY : longitude_deg, latitude_deg
9  USE grid_atob_m,        ONLY: grille_m
10  USE ioipsl,             ONLY: flininfo, flinopen, flinget, flinclo
11
12  CHARACTER(LEN=256), PARAMETER :: icefname="landiceref.nc", icevar="landice"
13  PRIVATE
14  PUBLIC :: start_init_subsurf
15  include "iniprint.h"
16  include "dimensions.h"
17  include "paramet.h"
18  include "comgeom2.h"
19  include "comconst.h"
20
21CONTAINS
22
23!-------------------------------------------------------------------------------
24!
25SUBROUTINE start_init_subsurf(known_mask)
26!
27!-------------------------------------------------------------------------------
28! Purpose: Subsurfaces initialization.
29!-------------------------------------------------------------------------------
30! Comment: Called by etat0phys_netcdf ; also called by limit_netcdf in case
31!          no starting states are required (ok_etat0==.FALSE.).
32!-------------------------------------------------------------------------------
33  IMPLICIT NONE
34!-------------------------------------------------------------------------------
35! Arguments:
36  LOGICAL, INTENT(IN) :: known_mask
37!-------------------------------------------------------------------------------
38! Local variables:
39  INTEGER           :: iml_lic, jml_lic
40  INTEGER           :: fid, llm_tmp, ttm_tmp, itaul(1), ji, j
41  REAL, ALLOCATABLE :: dlon_lic(:), lon_lic(:,:), fraclic (:,:)
42  REAL, ALLOCATABLE :: dlat_lic(:), lat_lic(:,:), flic_tmp(:,:), vtmp(:,:)
43  REAL              :: date, lev(1), dt, deg2rad
44!-------------------------------------------------------------------------------
45  deg2rad= pi/180.0
46
47!--- Physical grid points coordinates
48  DO j=2,jjm; latitude_deg((j-2)*iim+2:(j-1)*iim+1)=rlatu(j);    END DO
49  DO j=2,jjm; longitude_deg((j-2)*iim+2:(j-1)*iim+1)=rlonv(1:im); END DO
50  latitude_deg(1) = pi/2.; latitude_deg(klon) = - pi/2.
51  latitude_deg(:)=latitude_deg(:)/deg2rad
52  longitude_deg(1) = 0.0;   longitude_deg(klon) = 0.0;
53  longitude_deg(:)=longitude_deg(:)/deg2rad
54
55! Compute ground geopotential, sub-cells quantities and possibly the mask.
56! Sub-surfaces initialization
57!*******************************************************************************
58!--- Read and interpolate on model T-grid soil fraction and soil ice fraction.
59  CALL flininfo(icefname, iml_lic, jml_lic, llm_tmp, ttm_tmp, fid)
60  ALLOCATE(lat_lic(iml_lic,jml_lic),lon_lic(iml_lic,jml_lic))
61  ALLOCATE(fraclic(iml_lic,jml_lic))
62  CALL flinopen(icefname, .FALSE., iml_lic, jml_lic, llm_tmp,  &
63 &               lon_lic, lat_lic, lev, ttm_tmp, itaul, date, dt, fid)
64  CALL flinget(fid, icevar, iml_lic, jml_lic, llm_tmp, ttm_tmp, 1,1, fraclic)
65  CALL flinclo(fid)
66  WRITE(lunout,*)'landice dimensions: iml_lic, jml_lic : ',iml_lic,jml_lic
67
68  ALLOCATE(dlon_lic(iml_lic),dlat_lic(jml_lic))
69  dlon_lic(:)=lon_lic(:,1); IF(MAXVAL(dlon_lic)>pi) dlon_lic=dlon_lic*pi/180.
70  dlat_lic(:)=lat_lic(1,:); IF(MAXVAL(dlat_lic)>pi) dlat_lic=dlat_lic*pi/180.
71  DEALLOCATE(lon_lic,lat_lic); ALLOCATE(flic_tmp(iip1,jjp1))
72  CALL grille_m(dlon_lic,dlat_lic,fraclic,rlonv(1:iim),rlatu,flic_tmp(1:iim,:))
73  flic_tmp(iip1,:)=flic_tmp(1,:)
74
75!--- To the physical grid
76  pctsrf(:,:) = 0.
77  CALL gr_dyn_fi(1, iip1, jjp1, klon, flic_tmp, pctsrf(:,is_lic))
78  DEALLOCATE(flic_tmp)
79
80!--- Adequation with soil/sea mask
81  WHERE(pctsrf(:,is_lic)<EPSFRA) pctsrf(:,is_lic)=0.
82  WHERE(zmasq(:)<EPSFRA)         pctsrf(:,is_lic)=0.
83  pctsrf(:,is_ter)=zmasq(:)
84  DO ji=1,klon
85    IF(zmasq(ji)>EPSFRA) THEN
86      IF(pctsrf(ji,is_lic)>=zmasq(ji)) THEN
87        pctsrf(ji,is_lic)=zmasq(ji)
88        pctsrf(ji,is_ter)=0.
89      ELSE
90        pctsrf(ji,is_ter)=zmasq(ji)-pctsrf(ji,is_lic)
91        IF(pctsrf(ji,is_ter)<EPSFRA) THEN
92          pctsrf(ji,is_ter)=0.
93          pctsrf(ji,is_lic)=zmasq(ji)
94        END IF
95      END IF
96    END IF
97  END DO
98
99!--- Sub-surface ocean and sea ice (sea ice set to zero for start).
100  pctsrf(:,is_oce)=(1.-zmasq(:))
101  WHERE(pctsrf(:,is_oce)<EPSFRA) pctsrf(:,is_oce)=0.
102  IF(known_mask) pctsrf(:,is_oce)=1-zmasq(:)
103
104!--- It is checked that the sub-surfaces sum is equal to 1.
105  ji=COUNT((ABS(SUM(pctsrf(:,:),dim=2))-1.0)>EPSFRA)
106  IF(ji/=0) WRITE(lunout,*) 'Sub-cell distribution problem for ',ji,' points'
107
108END SUBROUTINE start_init_subsurf
109!
110!-------------------------------------------------------------------------------
111
112END MODULE init_ssrf_m
113!
114!*******************************************************************************
Note: See TracBrowser for help on using the repository browser.