source: LMDZ5/branches/IPSLCM5A2.1/libf/dynphy_lonlat/phylmd/ce0l.F90 @ 5360

Last change on this file since 5360 was 2603, checked in by Ehouarn Millour, 8 years ago

Cleanup in the dynamics: turn logic.h into module logic_mod.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.0 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 CPP_PARA
30  USE mod_const_mpi,  ONLY: init_const_mpi
31  USE parallel_lmdz,  ONLY: init_parallel, mpi_rank, omp_rank
32  USE bands,          ONLY: read_distrib, distrib_phys
33  USE mod_hallo,      ONLY: init_mod_hallo
34  USE mod_interface_dyn_phys, ONLY: init_interface_dyn_phys
35#endif
36  USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, kappa, omeg, r, rad, &
37                          pi, jmp1
38  USE logic_mod, ONLY: iflag_phys, ok_etat0, ok_limit
39  USE comvert_mod, ONLY: pa, preff, pressure_exner
40  USE temps_mod, ONLY: calend, day_ini, dt
41
42  IMPLICIT NONE
43
44!-------------------------------------------------------------------------------
45! Local variables:
46  include "dimensions.h"
47  include "paramet.h"
48  include "comgeom2.h"
49  include "iniprint.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#ifndef CPP_PARA
63! for iniphysiq in serial mode
64  INTEGER,PARAMETER :: mpi_rank=0
65  INTEGER :: distrib_phys(mpi_rank:mpi_rank)=(jjm-1)*iim+2
66#endif
67!-------------------------------------------------------------------------------
68  modname="ce0l"
69
70!--- Constants
71  pi     = 4. * ATAN(1.)
72  rad    = 6371229.
73  daysec = 86400.
74  omeg   = 2.*pi/daysec
75  g      = 9.8
76  kappa  = 0.2857143
77  cpp    = 1004.70885
78  jmp1   = jjm + 1
79  preff   = 101325.
80  pa      = 50000.
81
82  CALL conf_gcm( 99, .TRUE. )
83  dtvr = daysec/REAL(day_step)
84  WRITE(lunout,*)'dtvr',dtvr
85  CALL iniconst()
86  CALL inigeom()
87
88!--- Calendar choice
89#ifdef CPP_IOIPSL
90  calnd='gregorian'
91  SELECT CASE(calend)
92    CASE('earth_360d');CALL ioconf_calendar('360d');   calnd='with 360 days/year'
93    CASE('earth_365d');CALL ioconf_calendar('noleap'); calnd='with no leap year'
94    CASE('earth_366d');CALL ioconf_calendar('366d');   calnd='with leap years only'
95    CASE('gregorian'); CALL ioconf_calendar('gregorian')
96    CASE('standard');  CALL ioconf_calendar('gregorian')
97    CASE('julian');    CALL ioconf_calendar('julian'); calnd='julian'
98    CASE('proleptic_gregorian'); CALL ioconf_calendar('gregorian')
99  !--- DC Bof...  => IOIPSL a mettre a jour: proleptic_gregorian /= gregorian
100    CASE DEFAULT
101      CALL abort_gcm('ce0l','Bad choice for calendar',1)
102  END SELECT
103  WRITE(lunout,*)'CHOSEN CALENDAR: Earth '//TRIM(calnd)
104#endif
105
106#ifdef CPP_PARA
107!--- Physical grid + parallel initializations
108  CALL init_const_mpi()
109  CALL init_parallel()
110  CALL read_distrib()
111  CALL init_mod_hallo()
112#endif
113  WRITE(lunout,*)'---> klon=',klon
114
115!--- Tracers initializations
116  CALL infotrac_init()
117
118  CALL inifilr()
119  CALL iniphysiq(iim,jjm,llm, &
120                 distrib_phys(mpi_rank),comm_lmdz, &
121                 daysec,day_ini,dtphys/nsplit_phys, &
122                 rlatu,rlatv,rlonu,rlonv,aire,cu,cv,rad,g,r,cpp,iflag_phys)
123  IF(pressure_exner) CALL test_disvert
124
125#ifdef CPP_PARA
126  IF (mpi_rank==0.AND.omp_rank==0) THEN
127#endif
128  use_filtre_fft=.FALSE.
129  CALL getin('use_filtre_fft',use_filtre_fft)
130  IF(use_filtre_fft) THEN
131     WRITE(lunout,*)"FFT filter not available for sequential dynamics."
132     WRITE(lunout,*)"Your setting of variable use_filtre_fft is not used."
133  ENDIF
134
135!--- LAND MASK. TWO CASES:
136!   1) read from ocean model    file "o2a.nc"    (coupled runs)
137!   2) computed from topography file "Relief.nc" (masque(:,:)=-99999.)
138! Coupled simulations (case 1) use the ocean model mask to compute the
139! weights to ensure ocean fractions are the same for atmosphere and ocean.
140!*******************************************************************************
141  IF(NF90_OPEN("o2a.nc", NF90_NOWRITE, nid_o2a)/=NF90_NOERR) THEN
142    WRITE(lunout,*)'BEWARE !! No ocean mask "o2a.nc" file found'
143    WRITE(lunout,*)'Forced run.'
144    masque(:,:)=-99999.
145  ELSE
146    iret=NF90_CLOSE(nid_o2a)
147    WRITE(lunout,*)'BEWARE !! Ocean mask "o2a.nc" file found'
148    WRITE(lunout,*)'Coupled run.'
149    CALL flininfo("o2a.nc", iml_omask, jml_omask, llm_tmp, ttm_tmp, nid_o2a)
150    IF(iml_omask/=iim .OR.jml_omask/=jjp1) THEN
151      WRITE(lunout,*)'Mismatching dimensions for ocean mask'
152      WRITE(lunout,*)'iim  = ',iim ,' iml_omask = ',iml_omask
153      WRITE(lunout,*)'jjp1 = ',jjp1,' jml_omask = ',jml_omask
154      CALL abort_gcm(modname,'',1)
155    END IF
156    ALLOCATE(ocemask(iim,jjp1),lon_omask(iim,jjp1),dlon_omask(iim ))
157    ALLOCATE(ocetmp (iim,jjp1),lat_omask(iim,jjp1),dlat_omask(jjp1))
158    CALL flinopen("o2a.nc", .FALSE.,iml_omask,jml_omask,llm_tmp,               &
159                  lon_omask,lat_omask,lev,ttm_tmp,itaul,date,dt,fid)
160    CALL flinget(fid, "OceMask",    iim,jjp1,llm_tmp,ttm_tmp,1,1,ocetmp)
161    CALL flinclo(fid)
162    dlon_omask(1:iim ) = lon_omask(1:iim,1)
163    dlat_omask(1:jjp1) = lat_omask(1,1:jjp1)
164    ocemask = ocetmp
165    IF(dlat_omask(1)<dlat_omask(jml_omask)) THEN
166      DO j=1,jjp1; ocemask(:,j) = ocetmp(:,jjp1-j+1); END DO
167    END IF
168    DEALLOCATE(ocetmp,lon_omask,lat_omask,dlon_omask,dlat_omask)
169    IF(prt_level>=1) THEN
170      WRITE(fmt,"(i4,'i1)')")iim ; fmt='('//ADJUSTL(fmt)
171      WRITE(lunout,*)'OCEAN MASK :'
172      WRITE(lunout,fmt) NINT(ocemask)
173    END IF
174    masque(1:iim,:)=1.-ocemask(:,:)
175    masque(iip1 ,:)=masque(1,:)
176    DEALLOCATE(ocemask)
177  END IF
178  phis(:,:)=-99999.
179
180  IF(ok_etat0) THEN
181    WRITE(lunout,'(//)')
182    WRITE(lunout,*) '  ************************  '
183    WRITE(lunout,*) '  ***  etat0phy_netcdf ***  '
184    WRITE(lunout,*) '  ************************  '
185    CALL etat0phys_netcdf(masque,phis)
186    WRITE(lunout,'(//)')
187    WRITE(lunout,*) '  ************************  '
188    WRITE(lunout,*) '  ***  etat0dyn_netcdf ***  '
189    WRITE(lunout,*) '  ************************  '
190    CALL etat0dyn_netcdf(masque,phis)
191  END IF
192
193  IF(ok_limit) THEN
194    WRITE(lunout,'(//)')
195    WRITE(lunout,*) '  *********************  '
196    WRITE(lunout,*) '  ***  Limit_netcdf ***  '
197    WRITE(lunout,*) '  *********************  '
198    WRITE(lunout,'(//)')
199    CALL limit_netcdf(masque,phis,extrap)
200  END IF
201
202  WRITE(lunout,'(//)')
203  WRITE(lunout,*) '  ***************************  '
204  WRITE(lunout,*) '  ***  grilles_gcm_netcdf ***  '
205  WRITE(lunout,*) '  ***************************  '
206  WRITE(lunout,'(//)')
207  CALL grilles_gcm_netcdf_sub(masque,phis)
208
209#ifdef CPP_PARA
210  END IF
211#endif
212
213END PROGRAM ce0l
214!
215!-------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.