source: LMDZ6/trunk/libf/dynphy_lonlat/phylmd/ce0l.F90 @ 4582

Last change on this file since 4582 was 4389, checked in by dcugnet, 2 years ago
  • revert to original "type_trac" management:
    • 4 characters keyword (lmdz, Inca, repr, co2i, into, aeNP, coag
    • no longer a list of component with "|" separator
    • the parsed (with "|" separator) version "types_trac" is no longer used
    • the sole routine using a list of component is readTracFiles
  • fix for INCA and CO2Aer modes: setGeneration is now a function, index corrections for had/vadv.
  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.6 KB
Line 
1PROGRAM 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#ifdef CPP_XIOS
39  USE xios, only: xios_finalize
40#endif
41#endif
42
43  USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, kappa, omeg, r, rad, &
44                          pi, jmp1
45  USE logic_mod, ONLY: iflag_phys, ok_etat0, ok_limit
46  USE comvert_mod, ONLY: pa, preff, pressure_exner
47  USE temps_mod, ONLY: calend, day_ini, dt
48
49  IMPLICIT NONE
50
51!-------------------------------------------------------------------------------
52! Local variables:
53  include "dimensions.h"
54  include "paramet.h"
55  include "comgeom2.h"
56  include "iniprint.h"
57#ifdef CPP_MPI
58  include 'mpif.h'
59#endif
60 
61  REAL               :: masque(iip1,jjp1)             !--- CONTINENTAL MASK
62  REAL               :: phis  (iip1,jjp1)             !--- GROUND GEOPOTENTIAL
63  CHARACTER(LEN=256) :: modname, fmt, calnd           !--- CALENDAR TYPE
64  LOGICAL            :: use_filtre_fft
65  LOGICAL, PARAMETER :: extrap=.FALSE.
66
67!--- Local variables for ocean mask reading:
68  INTEGER            :: nid_o2a, iml_omask, jml_omask, j
69  INTEGER            :: fid, iret, llm_tmp, ttm_tmp, itaul(1)
70  REAL, ALLOCATABLE  :: lon_omask(:,:), dlon_omask(:), ocemask(:,:)
71  REAL, ALLOCATABLE  :: lat_omask(:,:), dlat_omask(:), ocetmp (:,:)
72  REAL               :: date, lev(1)
73
74!--- Local variables for land mask from startphy0 file reading
75  INTEGER            :: nid_sta, nid_nph, nid_msk, nphys
76  REAL, ALLOCATABLE  :: masktmp(:)
77
78#ifdef CPP_PARA
79  integer ierr
80#else
81! for iniphysiq in serial mode
82  INTEGER,PARAMETER :: mpi_rank=0
83  INTEGER :: distrib_phys(mpi_rank:mpi_rank)=(jjm-1)*iim+2
84#endif
85!-------------------------------------------------------------------------------
86  modname="ce0l"
87
88!--- Constants
89  pi     = 4. * ATAN(1.)
90  rad    = 6371229.
91  daysec = 86400.
92  omeg   = 2.*pi/daysec
93  g      = 9.8
94  kappa  = 0.2857143
95  cpp    = 1004.70885
96  jmp1   = jjm + 1
97  preff   = 101325.
98  pa      = 50000.
99
100  CALL conf_gcm( 99, .TRUE. )
101  dtvr = daysec/REAL(day_step)
102  WRITE(lunout,*)'dtvr',dtvr
103  CALL iniconst()
104  CALL inigeom()
105
106!--- Calendar choice
107#ifdef CPP_IOIPSL
108  calnd='gregorian'
109  SELECT CASE(calend)
110    CASE('earth_360d');CALL ioconf_calendar('360_day');   calnd='with 360 days/year'
111    CASE('earth_365d');CALL ioconf_calendar('noleap'); calnd='with no leap year'
112    CASE('earth_366d');CALL ioconf_calendar('366d');   calnd='with leap years only'
113    CASE('gregorian'); CALL ioconf_calendar('gregorian')
114    CASE('standard');  CALL ioconf_calendar('gregorian')
115    CASE('julian');    CALL ioconf_calendar('julian'); calnd='julian'
116    CASE('proleptic_gregorian'); CALL ioconf_calendar('gregorian')
117  !--- DC Bof...  => IOIPSL a mettre a jour: proleptic_gregorian /= gregorian
118    CASE DEFAULT
119      CALL abort_gcm('ce0l','Bad choice for calendar',1)
120  END SELECT
121  WRITE(lunout,*)'CHOSEN CALENDAR: Earth '//TRIM(calnd)
122#endif
123
124#ifdef CPP_PARA
125!--- Physical grid + parallel initializations
126  CALL init_const_mpi()
127  CALL init_parallel()
128  CALL read_distrib()
129  CALL init_mod_hallo()
130#endif
131  WRITE(lunout,*)'---> klon=',klon
132
133!--- Tracers initializations
134  CALL init_infotrac()
135
136  CALL inifilr()
137  CALL iniphysiq(iim,jjm,llm, &
138                 distrib_phys(mpi_rank),comm_lmdz, &
139                 daysec,day_ini,dtphys/nsplit_phys, &
140                 rlatu,rlatv,rlonu,rlonv,aire,cu,cv,rad,g,r,cpp,iflag_phys)
141  IF(pressure_exner) CALL test_disvert
142
143#ifdef CPP_PARA
144  IF (mpi_rank==0.AND.omp_rank==0) THEN
145#endif
146  use_filtre_fft=.FALSE.
147  CALL getin('use_filtre_fft',use_filtre_fft)
148  IF(use_filtre_fft) THEN
149     WRITE(lunout,*)"FFT filter not available for sequential dynamics."
150     WRITE(lunout,*)"Your setting of variable use_filtre_fft is not used."
151  ENDIF
152
153!--- LAND MASK. THREE CASES:
154!   1) read from ocean model    file "o2a.nc"    (coupled runs)
155!   2) read from previous run   file="startphy0.nc"
156!   3) computed from topography file "Relief.nc" (masque(:,:)=-99999.)
157! In the first case, the mask from the ocean model is used compute the
158! weights to ensure ocean fractions are the same for atmosphere and ocean.
159!*******************************************************************************
160  IF(NF90_OPEN("o2a.nc", NF90_NOWRITE, nid_o2a)==NF90_NOERR) THEN
161    iret=NF90_CLOSE(nid_o2a)
162    WRITE(lunout,*)'BEWARE !! Ocean mask "o2a.nc" file found'
163    WRITE(lunout,*)'Coupled run.'
164    CALL flininfo("o2a.nc", iml_omask, jml_omask, llm_tmp, ttm_tmp, nid_o2a)
165    IF(iml_omask/=iim .OR.jml_omask/=jjp1) THEN
166      WRITE(lunout,*)'Mismatching dimensions for ocean mask'
167      WRITE(lunout,*)'iim  = ',iim ,' iml_omask = ',iml_omask
168      WRITE(lunout,*)'jjp1 = ',jjp1,' jml_omask = ',jml_omask
169      CALL abort_gcm(modname,'',1)
170    END IF
171    ALLOCATE(ocemask(iim,jjp1),lon_omask(iim,jjp1),dlon_omask(iim ))
172    ALLOCATE(ocetmp (iim,jjp1),lat_omask(iim,jjp1),dlat_omask(jjp1))
173    CALL flinopen("o2a.nc", .FALSE.,iml_omask,jml_omask,llm_tmp,               &
174                  lon_omask,lat_omask,lev,ttm_tmp,itaul,date,dt,fid)
175    CALL flinget(fid, "OceMask",    iim,jjp1,llm_tmp,ttm_tmp,1,1,ocetmp)
176    CALL flinclo(fid)
177    dlon_omask(1:iim ) = lon_omask(1:iim,1)
178    dlat_omask(1:jjp1) = lat_omask(1,1:jjp1)
179    ocemask = ocetmp
180    IF(dlat_omask(1)<dlat_omask(jml_omask)) THEN
181       DO j=1,jjp1
182          ocemask(:,j) = ocetmp(:,jjp1-j+1)
183       END DO
184    END IF
185    DEALLOCATE(ocetmp,lon_omask,lat_omask,dlon_omask,dlat_omask)
186    IF(prt_level>=1) THEN
187      WRITE(fmt,"(i4,'i1)')")iim ; fmt='('//ADJUSTL(fmt)
188      WRITE(lunout,*)'OCEAN MASK :'
189      WRITE(lunout,fmt) NINT(ocemask)
190    END IF
191    masque(1:iim,:)=1.-ocemask(:,:)
192    masque(iip1 ,:)=masque(1,:)
193    DEALLOCATE(ocemask)
194  ELSE IF(NF90_OPEN("startphy0.nc", NF90_NOWRITE, nid_sta)==NF90_NOERR) THEN
195    WRITE(lunout,*)'BEWARE !! File "startphy0.nc" found.'
196    WRITE(lunout,*)'Getting the land mask from a previous run.'
197    iret=NF90_INQ_DIMID(nid_sta,'points_physiques',nid_nph)
198    iret=NF90_INQUIRE_DIMENSION(nid_sta,nid_nph,len=nphys)
199    IF(nphys/=klon) THEN
200      WRITE(lunout,*)'Mismatching dimensions for land mask'
201      WRITE(lunout,*)'nphys  = ',nphys ,' klon = ',klon
202      iret=NF90_CLOSE(nid_sta)
203      CALL abort_gcm(modname,'',1)
204    END IF
205    ALLOCATE(masktmp(klon))
206    iret=NF90_INQ_VARID(nid_sta,'masque',nid_msk)
207    iret=NF90_GET_VAR(nid_sta,nid_msk,masktmp)
208    iret=NF90_CLOSE(nid_sta)
209    CALL gr_fi_dyn(1,klon,iip1,jjp1,masktmp,masque)
210    IF(prt_level>=1) THEN
211      WRITE(fmt,"(i4,'i1)')")iip1 ; fmt='('//ADJUSTL(fmt)
212      WRITE(lunout,*)'LAND MASK :'
213      WRITE(lunout,fmt) NINT(masque)
214    END IF
215    DEALLOCATE(masktmp)
216  ELSE
217    WRITE(lunout,*)'BEWARE !! No ocean mask "o2a.nc" file or "startphy0.nc" file found'
218    WRITE(lunout,*)'Land mask will be built from the topography file.'
219    masque(:,:)=-99999.
220  END IF
221  phis(:,:)=-99999.
222
223  IF(ok_etat0) THEN
224    WRITE(lunout,'(//)')
225    WRITE(lunout,*) '  ************************  '
226    WRITE(lunout,*) '  ***  etat0phy_netcdf ***  '
227    WRITE(lunout,*) '  ************************  '
228    CALL etat0phys_netcdf(masque,phis)
229    WRITE(lunout,'(//)')
230    WRITE(lunout,*) '  ************************  '
231    WRITE(lunout,*) '  ***  etat0dyn_netcdf ***  '
232    WRITE(lunout,*) '  ************************  '
233    CALL etat0dyn_netcdf(masque,phis)
234  END IF
235
236  IF(ok_limit) THEN
237    WRITE(lunout,'(//)')
238    WRITE(lunout,*) '  *********************  '
239    WRITE(lunout,*) '  ***  Limit_netcdf ***  '
240    WRITE(lunout,*) '  *********************  '
241    WRITE(lunout,'(//)')
242    CALL limit_netcdf(masque,phis,extrap)
243  END IF
244
245  WRITE(lunout,'(//)')
246  WRITE(lunout,*) '  ***************************  '
247  WRITE(lunout,*) '  ***  grilles_gcm_netcdf ***  '
248  WRITE(lunout,*) '  ***************************  '
249  WRITE(lunout,'(//)')
250  CALL grilles_gcm_netcdf_sub(masque,phis)
251
252#ifdef CPP_PARA
253  END IF
254#ifdef CPP_XIOS
255  CALL xios_finalize
256#endif
257#ifdef CPP_MPI
258  IF (using_mpi) call MPI_FINALIZE(ierr)
259#endif
260#endif
261
262END PROGRAM ce0l
263!
264!-------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.