1 | PROGRAM ce0l |
---|
2 | ! |
---|
3 | !------------------------------------------------------------------------------- |
---|
4 | ! Purpose: Initial states and boundary conditions files creation: |
---|
5 | ! * start.nc for dynamics (using etat0dyn routine) |
---|
6 | ! * startphy.nc for physics (using etat0phys routine) |
---|
7 | ! * limit.nc for forced runs (using limit_netcdf routine) |
---|
8 | !------------------------------------------------------------------------------- |
---|
9 | ! Notes: |
---|
10 | ! * extrap=.T. (default) for data extrapolation, like for the SSTs when file |
---|
11 | ! does contain ocean points only. |
---|
12 | ! * "masque" can be: |
---|
13 | ! - read from file "o2a.nc" (for coupled runs). |
---|
14 | ! - read from file "startphy0.nc" (from a previous run). |
---|
15 | ! - created in etat0phys or etat0dyn (for forced runs). |
---|
16 | ! It is then passed to limit_netcdf to ensure consistancy. |
---|
17 | !------------------------------------------------------------------------------- |
---|
18 | USE ioipsl, ONLY: ioconf_calendar, getin, flininfo, flinopen, flinget, flinclo |
---|
19 | USE control_mod, ONLY: day_step, dayref, nsplit_phys |
---|
20 | USE etat0dyn, ONLY: etat0dyn_netcdf |
---|
21 | USE etat0phys, ONLY: etat0phys_netcdf |
---|
22 | USE limit, ONLY: limit_netcdf |
---|
23 | USE netcdf, ONLY: NF90_OPEN, NF90_NOWRITE, NF90_CLOSE, NF90_NOERR, & |
---|
24 | NF90_INQUIRE_DIMENSION, NF90_INQ_DIMID, NF90_INQ_VARID, NF90_GET_VAR |
---|
25 | USE infotrac, ONLY: init_infotrac |
---|
26 | USE dimphy, ONLY: klon |
---|
27 | USE test_disvert_m, ONLY: test_disvert |
---|
28 | USE filtreg_mod, ONLY: inifilr |
---|
29 | USE iniphysiq_mod, ONLY: iniphysiq |
---|
30 | USE mod_const_mpi, ONLY: comm_lmdz |
---|
31 | |
---|
32 | #ifdef CPP_PARA |
---|
33 | USE mod_const_mpi, ONLY: init_const_mpi |
---|
34 | USE parallel_lmdz, ONLY: init_parallel, mpi_rank, omp_rank, using_mpi |
---|
35 | USE bands, ONLY: read_distrib, distrib_phys |
---|
36 | USE mod_hallo, ONLY: init_mod_hallo |
---|
37 | USE mod_interface_dyn_phys, ONLY: init_interface_dyn_phys |
---|
38 | USE lmdz_xios, only: using_xios, xios_finalize |
---|
39 | #endif |
---|
40 | |
---|
41 | USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, kappa, omeg, r, rad, & |
---|
42 | pi, jmp1 |
---|
43 | USE logic_mod, ONLY: iflag_phys, ok_etat0, ok_limit |
---|
44 | USE comvert_mod, ONLY: pa, preff, pressure_exner |
---|
45 | USE temps_mod, ONLY: calend, day_ini, dt |
---|
46 | USE lmdz_mpi |
---|
47 | |
---|
48 | USE dimensions_mod, ONLY: iim, jjm, llm, ndm |
---|
49 | USE paramet_mod_h, ONLY: iip1, iip2, iip3, jjp1, llmp1, llmp2, llmm1, kftd, ip1jm, ip1jmp1, & |
---|
50 | ip1jmi1, ijp1llm, ijmllm, mvar, jcfil, jcfllm |
---|
51 | IMPLICIT NONE |
---|
52 | |
---|
53 | !------------------------------------------------------------------------------- |
---|
54 | ! Local variables: |
---|
55 | |
---|
56 | |
---|
57 | include "comgeom2.h" |
---|
58 | include "iniprint.h" |
---|
59 | |
---|
60 | REAL :: masque(iip1,jjp1) !--- CONTINENTAL MASK |
---|
61 | REAL :: phis (iip1,jjp1) !--- GROUND GEOPOTENTIAL |
---|
62 | CHARACTER(LEN=256) :: modname, fmt, calnd !--- CALENDAR TYPE |
---|
63 | LOGICAL :: use_filtre_fft |
---|
64 | LOGICAL, PARAMETER :: extrap=.FALSE. |
---|
65 | |
---|
66 | !--- Local variables for ocean mask reading: |
---|
67 | INTEGER :: nid_o2a, iml_omask, jml_omask, j |
---|
68 | INTEGER :: fid, iret, llm_tmp, ttm_tmp, itaul(1) |
---|
69 | REAL, ALLOCATABLE :: lon_omask(:,:), dlon_omask(:), ocemask(:,:) |
---|
70 | REAL, ALLOCATABLE :: lat_omask(:,:), dlat_omask(:), ocetmp (:,:) |
---|
71 | REAL :: date, lev(1) |
---|
72 | |
---|
73 | !--- Local variables for land mask from startphy0 file reading |
---|
74 | INTEGER :: nid_sta, nid_nph, nid_msk, nphys |
---|
75 | REAL, ALLOCATABLE :: masktmp(:) |
---|
76 | |
---|
77 | #ifdef CPP_PARA |
---|
78 | integer ierr |
---|
79 | #else |
---|
80 | ! for iniphysiq in serial mode |
---|
81 | INTEGER,PARAMETER :: mpi_rank=0 |
---|
82 | INTEGER :: distrib_phys(mpi_rank:mpi_rank)=(jjm-1)*iim+2 |
---|
83 | #endif |
---|
84 | !------------------------------------------------------------------------------- |
---|
85 | modname="ce0l" |
---|
86 | |
---|
87 | !--- Constants |
---|
88 | pi = 4. * ATAN(1.) |
---|
89 | rad = 6371229. |
---|
90 | daysec = 86400. |
---|
91 | omeg = 2.*pi/daysec |
---|
92 | g = 9.8 |
---|
93 | kappa = 0.2857143 |
---|
94 | cpp = 1004.70885 |
---|
95 | jmp1 = jjm + 1 |
---|
96 | preff = 101325. |
---|
97 | pa = 50000. |
---|
98 | |
---|
99 | CALL conf_gcm( 99, .TRUE. ) |
---|
100 | dtvr = daysec/REAL(day_step) |
---|
101 | WRITE(lunout,*)'dtvr',dtvr |
---|
102 | CALL iniconst() |
---|
103 | CALL inigeom() |
---|
104 | |
---|
105 | !--- Calendar choice |
---|
106 | calnd='gregorian' |
---|
107 | SELECT CASE(calend) |
---|
108 | CASE('earth_360d');CALL ioconf_calendar('360_day'); calnd='with 360 days/year' |
---|
109 | CASE('earth_365d');CALL ioconf_calendar('noleap'); calnd='with no leap year' |
---|
110 | CASE('earth_366d');CALL ioconf_calendar('366d'); calnd='with leap years only' |
---|
111 | CASE('gregorian'); CALL ioconf_calendar('gregorian') |
---|
112 | CASE('standard'); CALL ioconf_calendar('gregorian') |
---|
113 | CASE('julian'); CALL ioconf_calendar('julian'); calnd='julian' |
---|
114 | CASE('proleptic_gregorian'); CALL ioconf_calendar('gregorian') |
---|
115 | !--- DC Bof... => IOIPSL a mettre a jour: proleptic_gregorian /= gregorian |
---|
116 | CASE DEFAULT |
---|
117 | CALL abort_gcm('ce0l','Bad choice for calendar',1) |
---|
118 | END SELECT |
---|
119 | WRITE(lunout,*)'CHOSEN CALENDAR: Earth '//TRIM(calnd) |
---|
120 | |
---|
121 | |
---|
122 | #ifdef CPP_PARA |
---|
123 | !--- Physical grid + parallel initializations |
---|
124 | CALL init_const_mpi() |
---|
125 | CALL init_parallel() |
---|
126 | CALL read_distrib() |
---|
127 | CALL init_mod_hallo() |
---|
128 | #endif |
---|
129 | WRITE(lunout,*)'---> klon=',klon |
---|
130 | |
---|
131 | !--- Tracers initializations |
---|
132 | CALL init_infotrac() |
---|
133 | |
---|
134 | CALL inifilr() |
---|
135 | CALL iniphysiq(iim,jjm,llm, & |
---|
136 | distrib_phys(mpi_rank),comm_lmdz, & |
---|
137 | daysec,day_ini,dtphys/nsplit_phys, & |
---|
138 | rlatu,rlatv,rlonu,rlonv,aire,cu,cv,rad,g,r,cpp,iflag_phys) |
---|
139 | IF(pressure_exner) CALL test_disvert |
---|
140 | |
---|
141 | #ifdef CPP_PARA |
---|
142 | IF (mpi_rank==0.AND.omp_rank==0) THEN |
---|
143 | #endif |
---|
144 | use_filtre_fft=.FALSE. |
---|
145 | CALL getin('use_filtre_fft',use_filtre_fft) |
---|
146 | IF(use_filtre_fft) THEN |
---|
147 | WRITE(lunout,*)"FFT filter not available for sequential dynamics." |
---|
148 | WRITE(lunout,*)"Your setting of variable use_filtre_fft is not used." |
---|
149 | ENDIF |
---|
150 | |
---|
151 | !--- LAND MASK. THREE CASES: |
---|
152 | ! 1) read from ocean model file "o2a.nc" (coupled runs) |
---|
153 | ! 2) read from previous run file="startphy0.nc" |
---|
154 | ! 3) computed from topography file "Relief.nc" (masque(:,:)=-99999.) |
---|
155 | ! In the first case, the mask from the ocean model is used compute the |
---|
156 | ! weights to ensure ocean fractions are the same for atmosphere and ocean. |
---|
157 | !******************************************************************************* |
---|
158 | IF(NF90_OPEN("o2a.nc", NF90_NOWRITE, nid_o2a)==NF90_NOERR) THEN |
---|
159 | iret=NF90_CLOSE(nid_o2a) |
---|
160 | WRITE(lunout,*)'BEWARE !! Ocean mask "o2a.nc" file found' |
---|
161 | WRITE(lunout,*)'Coupled run.' |
---|
162 | CALL flininfo("o2a.nc", iml_omask, jml_omask, llm_tmp, ttm_tmp, nid_o2a) |
---|
163 | IF(iml_omask/=iim .OR.jml_omask/=jjp1) THEN |
---|
164 | WRITE(lunout,*)'Mismatching dimensions for ocean mask' |
---|
165 | WRITE(lunout,*)'iim = ',iim ,' iml_omask = ',iml_omask |
---|
166 | WRITE(lunout,*)'jjp1 = ',jjp1,' jml_omask = ',jml_omask |
---|
167 | CALL abort_gcm(modname,'',1) |
---|
168 | END IF |
---|
169 | ALLOCATE(ocemask(iim,jjp1),lon_omask(iim,jjp1),dlon_omask(iim )) |
---|
170 | ALLOCATE(ocetmp (iim,jjp1),lat_omask(iim,jjp1),dlat_omask(jjp1)) |
---|
171 | CALL flinopen("o2a.nc", .FALSE.,iml_omask,jml_omask,llm_tmp, & |
---|
172 | lon_omask,lat_omask,lev,ttm_tmp,itaul,date,dt,fid) |
---|
173 | CALL flinget(fid, "OceMask", iim,jjp1,llm_tmp,ttm_tmp,1,1,ocetmp) |
---|
174 | CALL flinclo(fid) |
---|
175 | dlon_omask(1:iim ) = lon_omask(1:iim,1) |
---|
176 | dlat_omask(1:jjp1) = lat_omask(1,1:jjp1) |
---|
177 | ocemask = ocetmp |
---|
178 | IF(dlat_omask(1)<dlat_omask(jml_omask)) THEN |
---|
179 | DO j=1,jjp1 |
---|
180 | ocemask(:,j) = ocetmp(:,jjp1-j+1) |
---|
181 | END DO |
---|
182 | END IF |
---|
183 | DEALLOCATE(ocetmp,lon_omask,lat_omask,dlon_omask,dlat_omask) |
---|
184 | IF(prt_level>=1) THEN |
---|
185 | WRITE(fmt,"(i4,'i1)')")iim ; fmt='('//ADJUSTL(fmt) |
---|
186 | WRITE(lunout,*)'OCEAN MASK :' |
---|
187 | WRITE(lunout,fmt) NINT(ocemask) |
---|
188 | END IF |
---|
189 | masque(1:iim,:)=1.-ocemask(:,:) |
---|
190 | masque(iip1 ,:)=masque(1,:) |
---|
191 | DEALLOCATE(ocemask) |
---|
192 | ELSE IF(NF90_OPEN("startphy0.nc", NF90_NOWRITE, nid_sta)==NF90_NOERR) THEN |
---|
193 | WRITE(lunout,*)'BEWARE !! File "startphy0.nc" found.' |
---|
194 | WRITE(lunout,*)'Getting the land mask from a previous run.' |
---|
195 | iret=NF90_INQ_DIMID(nid_sta,'points_physiques',nid_nph) |
---|
196 | iret=NF90_INQUIRE_DIMENSION(nid_sta,nid_nph,len=nphys) |
---|
197 | IF(nphys/=klon) THEN |
---|
198 | WRITE(lunout,*)'Mismatching dimensions for land mask' |
---|
199 | WRITE(lunout,*)'nphys = ',nphys ,' klon = ',klon |
---|
200 | iret=NF90_CLOSE(nid_sta) |
---|
201 | CALL abort_gcm(modname,'',1) |
---|
202 | END IF |
---|
203 | ALLOCATE(masktmp(klon)) |
---|
204 | iret=NF90_INQ_VARID(nid_sta,'masque',nid_msk) |
---|
205 | iret=NF90_GET_VAR(nid_sta,nid_msk,masktmp) |
---|
206 | iret=NF90_CLOSE(nid_sta) |
---|
207 | CALL gr_fi_dyn(1,klon,iip1,jjp1,masktmp,masque) |
---|
208 | IF(prt_level>=1) THEN |
---|
209 | WRITE(fmt,"(i4,'i1)')")iip1 ; fmt='('//ADJUSTL(fmt) |
---|
210 | WRITE(lunout,*)'LAND MASK :' |
---|
211 | WRITE(lunout,fmt) NINT(masque) |
---|
212 | END IF |
---|
213 | DEALLOCATE(masktmp) |
---|
214 | ELSE |
---|
215 | WRITE(lunout,*)'BEWARE !! No ocean mask "o2a.nc" file or "startphy0.nc" file found' |
---|
216 | WRITE(lunout,*)'Land mask will be built from the topography file.' |
---|
217 | masque(:,:)=-99999. |
---|
218 | END IF |
---|
219 | phis(:,:)=-99999. |
---|
220 | |
---|
221 | IF(ok_etat0) THEN |
---|
222 | WRITE(lunout,'(//)') |
---|
223 | WRITE(lunout,*) ' ************************ ' |
---|
224 | WRITE(lunout,*) ' *** etat0phy_netcdf *** ' |
---|
225 | WRITE(lunout,*) ' ************************ ' |
---|
226 | CALL etat0phys_netcdf(masque,phis) |
---|
227 | WRITE(lunout,'(//)') |
---|
228 | WRITE(lunout,*) ' ************************ ' |
---|
229 | WRITE(lunout,*) ' *** etat0dyn_netcdf *** ' |
---|
230 | WRITE(lunout,*) ' ************************ ' |
---|
231 | CALL etat0dyn_netcdf(masque,phis) |
---|
232 | END IF |
---|
233 | |
---|
234 | IF(ok_limit) THEN |
---|
235 | WRITE(lunout,'(//)') |
---|
236 | WRITE(lunout,*) ' ********************* ' |
---|
237 | WRITE(lunout,*) ' *** Limit_netcdf *** ' |
---|
238 | WRITE(lunout,*) ' ********************* ' |
---|
239 | WRITE(lunout,'(//)') |
---|
240 | CALL limit_netcdf(masque,phis,extrap) |
---|
241 | END IF |
---|
242 | |
---|
243 | WRITE(lunout,'(//)') |
---|
244 | WRITE(lunout,*) ' *************************** ' |
---|
245 | WRITE(lunout,*) ' *** grilles_gcm_netcdf *** ' |
---|
246 | WRITE(lunout,*) ' *************************** ' |
---|
247 | WRITE(lunout,'(//)') |
---|
248 | CALL grilles_gcm_netcdf_sub(masque,phis) |
---|
249 | |
---|
250 | #ifdef CPP_PARA |
---|
251 | END IF |
---|
252 | IF (using_xios) CALL xios_finalize |
---|
253 | IF (using_mpi) call MPI_FINALIZE(ierr) |
---|
254 | #endif |
---|
255 | |
---|
256 | END PROGRAM ce0l |
---|
257 | ! |
---|
258 | !------------------------------------------------------------------------------- |
---|