source: LMDZ5/trunk/libf/dynlonlat_phylonlat/phylmd/ce0l.F90 @ 2342

Last change on this file since 2342 was 2338, checked in by dcugnet, 9 years ago
  • 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: 8.1 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!       - created in etat0phys or etat0dyn (for forced  runs).
15!     It is then passed to limit_netcdf to ensure consistancy.
16!-------------------------------------------------------------------------------
17  USE ioipsl, ONLY: ioconf_calendar, getin, flininfo, flinopen, flinget, flinclo
18  USE control_mod,    ONLY: day_step, dayref, nsplit_phys
19  USE etat0dyn,       ONLY: etat0dyn_netcdf
20  USE etat0phys,      ONLY: etat0phys_netcdf
21  USE limit,          ONLY: limit_netcdf
22  USE netcdf,         ONLY: NF90_OPEN, NF90_NOWRITE, NF90_CLOSE, NF90_NOERR
23  USE infotrac,       ONLY: type_trac, infotrac_init
24  USE dimphy,         ONLY: klon
25  USE test_disvert_m, ONLY: test_disvert
26  USE filtreg_mod,    ONLY: inifilr
27#ifdef inca
28  USE indice_sol_mod, ONLY: nbsrf, is_oce, is_sic, is_ter, is_lic
29#endif
30#ifdef CPP_PARA
31  USE mod_const_mpi,  ONLY: init_const_mpi
32  USE parallel_lmdz,  ONLY: init_parallel, mpi_rank, omp_rank, mpi_size
33  USE bands,          ONLY: read_distrib, distrib_phys
34  USE mod_hallo,      ONLY: init_mod_hallo
35  USE mod_interface_dyn_phys, ONLY: init_interface_dyn_phys
36#endif
37
38  IMPLICIT NONE
39
40!-------------------------------------------------------------------------------
41! Local variables:
42  include "dimensions.h"
43  include "paramet.h"
44  include "comgeom2.h"
45  include "comconst.h"
46  include "comvert.h"
47  include "iniprint.h"
48  include "temps.h"
49  include "logic.h"
50  REAL               :: masque(iip1,jjp1)             !--- CONTINENTAL MASK
51  REAL               :: phis  (iip1,jjp1)             !--- GROUND GEOPOTENTIAL
52  CHARACTER(LEN=256) :: modname, fmt, calnd           !--- CALENDAR TYPE
53  LOGICAL            :: use_filtre_fft
54  LOGICAL, PARAMETER :: extrap=.FALSE.
55
56!--- Local variables for ocean mask reading:
57  INTEGER            :: nid_o2a, iml_omask, jml_omask, j
58  INTEGER            :: fid, iret, llm_tmp, ttm_tmp, itaul(1)
59  REAL, ALLOCATABLE  :: lon_omask(:,:), dlon_omask(:), ocemask(:,:)
60  REAL, ALLOCATABLE  :: lat_omask(:,:), dlat_omask(:), ocetmp (:,:)
61  REAL               :: date, lev(1)
62!-------------------------------------------------------------------------------
63  modname="ce0l"
64
65!--- Constants
66  pi     = 4. * ATAN(1.)
67  rad    = 6371229.
68  daysec = 86400.
69  omeg   = 2.*pi/daysec
70  g      = 9.8
71  kappa  = 0.2857143
72  cpp    = 1004.70885
73  jmp1   = jjm + 1
74  preff   = 101325.
75  pa      = 50000.
76
77  CALL conf_gcm( 99, .TRUE. )
78  dtvr = daysec/REAL(day_step)
79  WRITE(lunout,*)'dtvr',dtvr
80  CALL iniconst()
81  CALL inigeom()
82
83!--- Calendar choice
84#ifdef CPP_IOIPSL
85  calnd='gregorian'
86  SELECT CASE(calend)
87    CASE('earth_360d');CALL ioconf_calendar('360d');   calnd='with 360 days/year'
88    CASE('earth_365d');CALL ioconf_calendar('noleap'); calnd='with no leap year'
89    CASE('earth_366d');CALL ioconf_calendar('366d');   calnd='with leap years only'
90    CASE('gregorian'); CALL ioconf_calendar('gregorian')
91    CASE('standard');  CALL ioconf_calendar('gregorian')
92    CASE('julian');    CALL ioconf_calendar('julian'); calnd='julian'
93    CASE('proleptic_gregorian'); CALL ioconf_calendar('gregorian')
94  !--- DC Bof...  => IOIPSL a mettre a jour: proleptic_gregorian /= gregorian
95    CASE DEFAULT
96      CALL abort_gcm('ce0l','Bad choice for calendar',1)
97  END SELECT
98  WRITE(lunout,*)'CHOSEN CALENDAR: Earth '//TRIM(calnd)
99#endif
100
101#ifdef CPP_PARA
102!--- Physical grid + parallel initializations
103  CALL init_const_mpi()
104  CALL init_parallel()
105  CALL read_distrib()
106  CALL init_mod_hallo()
107  CALL Init_Phys_lmdz(iim,jjp1,llm,mpi_size,distrib_phys)
108  CALL init_interface_dyn_phys()
109#else
110  CALL Init_Phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/))
111#endif
112  WRITE(lunout,*)'---> klon=',klon
113
114!--- Tracers initializations
115  IF (type_trac == 'inca') THEN
116#ifdef INCA
117    CALL init_const_lmdz(nbtr,anneeref,dayref,iphysiq,day_step,nday,&
118                         nbsrf,is_oce,is_sic,is_ter,is_lic,calend)
119    CALL init_inca_para(iim,jjp1,llm,klon_glo,mpi_size,distrib_phys,&
120                        COMM_LMDZ)
121    WRITE(lunout,*)'nbtr =' , nbtr
122#endif
123  END IF
124  CALL infotrac_init()
125
126  CALL inifilr()
127  CALL iniphysiq(iim,jjm,llm,daysec,day_ini,dtphys/nsplit_phys, &
128                 rlatu,rlonv,aire,cu,cv,rad,g,r,cpp,iflag_phys)
129  IF(pressure_exner) CALL test_disvert
130
131#ifdef CPP_PARA
132  IF (mpi_rank==0.AND.omp_rank==0) THEN
133#endif
134  use_filtre_fft=.FALSE.
135  CALL getin('use_filtre_fft',use_filtre_fft)
136  IF(use_filtre_fft) THEN
137     WRITE(lunout,*)"FFT filter not available for sequential dynamics."
138     WRITE(lunout,*)"Your setting of variable use_filtre_fft is not used."
139  ENDIF
140
141!--- LAND MASK. TWO CASES:
142!   1) read from ocean model    file "o2a.nc"    (coupled runs)
143!   2) computed from topography file "Relief.nc" (masque(:,:)=-99999.)
144! Coupled simulations (case 1) use the ocean model mask to compute the
145! weights to ensure ocean fractions are the same for atmosphere and ocean.
146!*******************************************************************************
147  IF(NF90_OPEN("o2a.nc", NF90_NOWRITE, nid_o2a)/=NF90_NOERR) THEN
148    WRITE(lunout,*)'BEWARE !! No ocean mask "o2a.nc" file found'
149    WRITE(lunout,*)'Forced run.'
150    masque(:,:)=-99999.
151  ELSE
152    iret=NF90_CLOSE(nid_o2a)
153    WRITE(lunout,*)'BEWARE !! Ocean mask "o2a.nc" file found'
154    WRITE(lunout,*)'Coupled run.'
155    CALL flininfo("o2a.nc", iml_omask, jml_omask, llm_tmp, ttm_tmp, nid_o2a)
156    IF(iml_omask/=iim .OR.jml_omask/=jjp1) THEN
157      WRITE(lunout,*)'Mismatching dimensions for ocean mask'
158      WRITE(lunout,*)'iim  = ',iim ,' iml_omask = ',iml_omask
159      WRITE(lunout,*)'jjp1 = ',jjp1,' jml_omask = ',jml_omask
160      CALL abort_gcm(modname,'',1)
161    END IF
162    ALLOCATE(ocemask(iim,jjp1),lon_omask(iim,jjp1),dlon_omask(iim ))
163    ALLOCATE(ocetmp (iim,jjp1),lat_omask(iim,jjp1),dlat_omask(jjp1))
164    CALL flinopen("o2a.nc", .FALSE.,iml_omask,jml_omask,llm_tmp,               &
165                  lon_omask,lat_omask,lev,ttm_tmp,itaul,date,dt,fid)
166    CALL flinget(fid, "OceMask",    iim,jjp1,llm_tmp,ttm_tmp,1,1,ocetmp)
167    CALL flinclo(fid)
168    dlon_omask(1:iim ) = lon_omask(1:iim,1)
169    dlat_omask(1:jjp1) = lat_omask(1,1:jjp1)
170    ocemask = ocetmp
171    IF(dlat_omask(1)<dlat_omask(jml_omask)) THEN
172      DO j=1,jjp1; ocemask(:,j) = ocetmp(:,jjp1-j+1); END DO
173    END IF
174    DEALLOCATE(ocetmp,lon_omask,lat_omask,dlon_omask,dlat_omask)
175    IF(prt_level>=1) THEN
176      WRITE(fmt,"(i4,'i1)')")iim ; fmt='('//ADJUSTL(fmt)
177      WRITE(lunout,*)'OCEAN MASK :'
178      WRITE(lunout,fmt) NINT(ocemask)
179    END IF
180    masque(1:iim,:)=1.-ocemask(:,:)
181    masque(iip1 ,:)=masque(1,:)
182    DEALLOCATE(ocemask)
183  END IF
184  phis(:,:)=-99999.
185
186  IF(ok_etat0) THEN
187    WRITE(lunout,'(//)')
188    WRITE(lunout,*) '  ************************  '
189    WRITE(lunout,*) '  ***  etat0phy_netcdf ***  '
190    WRITE(lunout,*) '  ************************  '
191    CALL etat0phys_netcdf(masque,phis)
192    WRITE(lunout,'(//)')
193    WRITE(lunout,*) '  ************************  '
194    WRITE(lunout,*) '  ***  etat0dyn_netcdf ***  '
195    WRITE(lunout,*) '  ************************  '
196    CALL etat0dyn_netcdf(masque,phis)
197  END IF
198
199  IF(ok_limit) THEN
200    WRITE(lunout,'(//)')
201    WRITE(lunout,*) '  *********************  '
202    WRITE(lunout,*) '  ***  Limit_netcdf ***  '
203    WRITE(lunout,*) '  *********************  '
204    WRITE(lunout,'(//)')
205    CALL limit_netcdf(masque,phis,extrap)
206  END IF
207
208  WRITE(lunout,'(//)')
209  WRITE(lunout,*) '  ***************************  '
210  WRITE(lunout,*) '  ***  grilles_gcm_netcdf ***  '
211  WRITE(lunout,*) '  ***************************  '
212  WRITE(lunout,'(//)')
213  CALL grilles_gcm_netcdf_sub(masque,phis)
214
215#ifdef CPP_PARA
216  END IF
217#endif
218
219END PROGRAM ce0l
220!
221!-------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.