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

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

More on physics/dynamics separation and cleanup:

  • Set things up so that all physics-related initializations are done via iniphysiq.
  • Created a "geometry_mod.F90" module in phy_common to store information on the loacl grid (i.e. replaces comgeomphy) and moreover give these variables more obvious names (e.g.: rlond => longitude, rlatd => latitude, airephy => cell_area).
  • removed obsolete comgeomphy.h and comgeomphy.F90

EM

  • 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.2 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  USE iniphysiq_mod,  ONLY: iniphysiq
28  USE mod_const_mpi,  ONLY: comm_lmdz
29#ifdef inca
30  USE indice_sol_mod, ONLY: nbsrf, is_oce, is_sic, is_ter, is_lic
31#endif
32#ifdef CPP_PARA
33  USE mod_const_mpi,  ONLY: init_const_mpi
34  USE parallel_lmdz,  ONLY: init_parallel, mpi_rank, omp_rank, mpi_size
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#endif
39
40  IMPLICIT NONE
41
42!-------------------------------------------------------------------------------
43! Local variables:
44  include "dimensions.h"
45  include "paramet.h"
46  include "comgeom2.h"
47  include "comconst.h"
48  include "comvert.h"
49  include "iniprint.h"
50  include "temps.h"
51  include "logic.h"
52  REAL               :: masque(iip1,jjp1)             !--- CONTINENTAL MASK
53  REAL               :: phis  (iip1,jjp1)             !--- GROUND GEOPOTENTIAL
54  CHARACTER(LEN=256) :: modname, fmt, calnd           !--- CALENDAR TYPE
55  LOGICAL            :: use_filtre_fft
56  LOGICAL, PARAMETER :: extrap=.FALSE.
57
58!--- Local variables for ocean mask reading:
59  INTEGER            :: nid_o2a, iml_omask, jml_omask, j
60  INTEGER            :: fid, iret, llm_tmp, ttm_tmp, itaul(1)
61  REAL, ALLOCATABLE  :: lon_omask(:,:), dlon_omask(:), ocemask(:,:)
62  REAL, ALLOCATABLE  :: lat_omask(:,:), dlat_omask(:), ocetmp (:,:)
63  REAL               :: date, lev(1)
64!-------------------------------------------------------------------------------
65  modname="ce0l"
66
67!--- Constants
68  pi     = 4. * ATAN(1.)
69  rad    = 6371229.
70  daysec = 86400.
71  omeg   = 2.*pi/daysec
72  g      = 9.8
73  kappa  = 0.2857143
74  cpp    = 1004.70885
75  jmp1   = jjm + 1
76  preff   = 101325.
77  pa      = 50000.
78
79  CALL conf_gcm( 99, .TRUE. )
80  dtvr = daysec/REAL(day_step)
81  WRITE(lunout,*)'dtvr',dtvr
82  CALL iniconst()
83  CALL inigeom()
84
85!--- Calendar choice
86#ifdef CPP_IOIPSL
87  calnd='gregorian'
88  SELECT CASE(calend)
89    CASE('earth_360d');CALL ioconf_calendar('360d');   calnd='with 360 days/year'
90    CASE('earth_365d');CALL ioconf_calendar('noleap'); calnd='with no leap year'
91    CASE('earth_366d');CALL ioconf_calendar('366d');   calnd='with leap years only'
92    CASE('gregorian'); CALL ioconf_calendar('gregorian')
93    CASE('standard');  CALL ioconf_calendar('gregorian')
94    CASE('julian');    CALL ioconf_calendar('julian'); calnd='julian'
95    CASE('proleptic_gregorian'); CALL ioconf_calendar('gregorian')
96  !--- DC Bof...  => IOIPSL a mettre a jour: proleptic_gregorian /= gregorian
97    CASE DEFAULT
98      CALL abort_gcm('ce0l','Bad choice for calendar',1)
99  END SELECT
100  WRITE(lunout,*)'CHOSEN CALENDAR: Earth '//TRIM(calnd)
101#endif
102
103#ifdef CPP_PARA
104!--- Physical grid + parallel initializations
105  CALL init_const_mpi()
106  CALL init_parallel()
107  CALL read_distrib()
108  CALL init_mod_hallo()
109#endif
110  WRITE(lunout,*)'---> klon=',klon
111
112!--- Tracers initializations
113  IF (type_trac == 'inca') THEN
114#ifdef INCA
115    CALL init_const_lmdz(nbtr,anneeref,dayref,iphysiq,day_step,nday,&
116                         nbsrf,is_oce,is_sic,is_ter,is_lic,calend)
117    CALL init_inca_para(iim,jjp1,llm,klon_glo,mpi_size,distrib_phys,&
118                        COMM_LMDZ)
119    WRITE(lunout,*)'nbtr =' , nbtr
120#endif
121  END IF
122  CALL infotrac_init()
123
124  CALL inifilr()
125  CALL iniphysiq(iim,jjm,llm, &
126                 distrib_phys(mpi_rank),comm_lmdz, &
127                 daysec,day_ini,dtphys/nsplit_phys, &
128                 rlatu,rlatv,rlonu,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.