source: LMDZ5/branches/testing/libf/dynphy_lonlat/phylmd/ce0l.F90 @ 2542

Last change on this file since 2542 was 2471, checked in by Laurent Fairhead, 9 years ago

Merged trunk changes r2434:2457 into testing branch

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