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

Last change on this file since 5272 was 5272, checked in by abarral, 8 weeks ago

Turn paramet.h into a module

  • 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.7 KB
RevLine 
[2293]1PROGRAM ce0l
[2336]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).
[2665]14!       - read from file "startphy0.nc"    (from a previous run).
[2336]15!       - created in etat0phys or etat0dyn (for forced  runs).
16!     It is then passed to limit_netcdf to ensure consistancy.
17!-------------------------------------------------------------------------------
[2293]18  USE ioipsl, ONLY: ioconf_calendar, getin, flininfo, flinopen, flinget, flinclo
[2336]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
[5084]23  USE netcdf,         ONLY: NF90_OPEN, NF90_NOWRITE, NF90_CLOSE, NF90_NOERR,    &
[2665]24         NF90_INQUIRE_DIMENSION, NF90_INQ_DIMID, NF90_INQ_VARID, NF90_GET_VAR
[4389]25  USE infotrac,       ONLY: init_infotrac
[2336]26  USE dimphy,         ONLY: klon
[2293]27  USE test_disvert_m, ONLY: test_disvert
[2336]28  USE filtreg_mod,    ONLY: inifilr
[2349]29  USE iniphysiq_mod,  ONLY: iniphysiq
[2351]30  USE mod_const_mpi,  ONLY: comm_lmdz
[3815]31
[2336]32#ifdef CPP_PARA
33  USE mod_const_mpi,  ONLY: init_const_mpi
[3815]34  USE parallel_lmdz,  ONLY: init_parallel, mpi_rank, omp_rank, using_mpi
[2336]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
[4689]38  USE lmdz_xios, only: using_xios, xios_finalize
[2336]39#endif
[3815]40
[2597]41  USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, kappa, omeg, r, rad, &
42                          pi, jmp1
[2603]43  USE logic_mod, ONLY: iflag_phys, ok_etat0, ok_limit
[2600]44  USE comvert_mod, ONLY: pa, preff, pressure_exner
[2601]45  USE temps_mod, ONLY: calend, day_ini, dt
[4600]46  USE lmdz_mpi
[524]47
[5271]48  USE dimensions_mod, ONLY: iim, jjm, llm, ndm
[5272]49USE paramet_mod_h, ONLY: iip1, iip2, iip3, jjp1, llmp1, llmp2, llmm1, kftd, ip1jm, ip1jmp1, &
50          ip1jmi1, ijp1llm, ijmllm, mvar, jcfil, jcfllm
[5271]51IMPLICIT NONE
[2293]52
[2336]53!-------------------------------------------------------------------------------
54! Local variables:
[5271]55
[5272]56
[2336]57  include "comgeom2.h"
[2293]58  include "iniprint.h"
[3815]59 
[2336]60  REAL               :: masque(iip1,jjp1)             !--- CONTINENTAL MASK
61  REAL               :: phis  (iip1,jjp1)             !--- GROUND GEOPOTENTIAL
[2293]62  CHARACTER(LEN=256) :: modname, fmt, calnd           !--- CALENDAR TYPE
63  LOGICAL            :: use_filtre_fft
[2336]64  LOGICAL, PARAMETER :: extrap=.FALSE.
[2293]65
[2336]66!--- Local variables for ocean mask reading:
[2293]67  INTEGER            :: nid_o2a, iml_omask, jml_omask, j
68  INTEGER            :: fid, iret, llm_tmp, ttm_tmp, itaul(1)
[2336]69  REAL, ALLOCATABLE  :: lon_omask(:,:), dlon_omask(:), ocemask(:,:)
70  REAL, ALLOCATABLE  :: lat_omask(:,:), dlat_omask(:), ocetmp (:,:)
[2293]71  REAL               :: date, lev(1)
[2665]72
73!--- Local variables for land mask from startphy0 file reading
74  INTEGER            :: nid_sta, nid_nph, nid_msk, nphys
75  REAL, ALLOCATABLE  :: masktmp(:)
76
[3815]77#ifdef CPP_PARA
78  integer ierr
79#else
[2353]80! for iniphysiq in serial mode
81  INTEGER,PARAMETER :: mpi_rank=0
82  INTEGER :: distrib_phys(mpi_rank:mpi_rank)=(jjm-1)*iim+2
83#endif
[2336]84!-------------------------------------------------------------------------------
[2293]85  modname="ce0l"
86
[2336]87!--- Constants
[2293]88  pi     = 4. * ATAN(1.)
89  rad    = 6371229.
90  daysec = 86400.
91  omeg   = 2.*pi/daysec
92  g      = 9.8
93  kappa  = 0.2857143
94  cpp    = 1004.70885
95  jmp1   = jjm + 1
96  preff   = 101325.
97  pa      = 50000.
98
[2221]99  CALL conf_gcm( 99, .TRUE. )
[2331]100  dtvr = daysec/REAL(day_step)
[2336]101  WRITE(lunout,*)'dtvr',dtvr
[2293]102  CALL iniconst()
103  CALL inigeom()
[822]104
[2336]105!--- Calendar choice
[2293]106  calnd='gregorian'
[1319]107  SELECT CASE(calend)
[4361]108    CASE('earth_360d');CALL ioconf_calendar('360_day');   calnd='with 360 days/year'
[2336]109    CASE('earth_365d');CALL ioconf_calendar('noleap'); calnd='with no leap year'
110    CASE('earth_366d');CALL ioconf_calendar('366d');   calnd='with leap years only'
111    CASE('gregorian'); CALL ioconf_calendar('gregorian')
112    CASE('standard');  CALL ioconf_calendar('gregorian')
113    CASE('julian');    CALL ioconf_calendar('julian'); calnd='julian'
114    CASE('proleptic_gregorian'); CALL ioconf_calendar('gregorian')
115  !--- DC Bof...  => IOIPSL a mettre a jour: proleptic_gregorian /= gregorian
116    CASE DEFAULT
117      CALL abort_gcm('ce0l','Bad choice for calendar',1)
[1319]118  END SELECT
[2336]119  WRITE(lunout,*)'CHOSEN CALENDAR: Earth '//TRIM(calnd)
[1279]120
[5267]121
[2336]122#ifdef CPP_PARA
123!--- Physical grid + parallel initializations
124  CALL init_const_mpi()
125  CALL init_parallel()
126  CALL read_distrib()
127  CALL init_mod_hallo()
128#endif
129  WRITE(lunout,*)'---> klon=',klon
130
131!--- Tracers initializations
[4325]132  CALL init_infotrac()
[2336]133
134  CALL inifilr()
[2351]135  CALL iniphysiq(iim,jjm,llm, &
136                 distrib_phys(mpi_rank),comm_lmdz, &
137                 daysec,day_ini,dtphys/nsplit_phys, &
[2349]138                 rlatu,rlatv,rlonu,rlonv,aire,cu,cv,rad,g,r,cpp,iflag_phys)
[2336]139  IF(pressure_exner) CALL test_disvert
140
141#ifdef CPP_PARA
142  IF (mpi_rank==0.AND.omp_rank==0) THEN
143#endif
[2293]144  use_filtre_fft=.FALSE.
[2336]145  CALL getin('use_filtre_fft',use_filtre_fft)
[2293]146  IF(use_filtre_fft) THEN
[2336]147     WRITE(lunout,*)"FFT filter not available for sequential dynamics."
148     WRITE(lunout,*)"Your setting of variable use_filtre_fft is not used."
[2293]149  ENDIF
150
[2665]151!--- LAND MASK. THREE CASES:
[2336]152!   1) read from ocean model    file "o2a.nc"    (coupled runs)
[2665]153!   2) read from previous run   file="startphy0.nc"
154!   3) computed from topography file "Relief.nc" (masque(:,:)=-99999.)
155! In the first case, the mask from the ocean model is used compute the
[2336]156! weights to ensure ocean fractions are the same for atmosphere and ocean.
157!*******************************************************************************
[2665]158  IF(NF90_OPEN("o2a.nc", NF90_NOWRITE, nid_o2a)==NF90_NOERR) THEN
[2336]159    iret=NF90_CLOSE(nid_o2a)
160    WRITE(lunout,*)'BEWARE !! Ocean mask "o2a.nc" file found'
161    WRITE(lunout,*)'Coupled run.'
162    CALL flininfo("o2a.nc", iml_omask, jml_omask, llm_tmp, ttm_tmp, nid_o2a)
163    IF(iml_omask/=iim .OR.jml_omask/=jjp1) THEN
164      WRITE(lunout,*)'Mismatching dimensions for ocean mask'
165      WRITE(lunout,*)'iim  = ',iim ,' iml_omask = ',iml_omask
166      WRITE(lunout,*)'jjp1 = ',jjp1,' jml_omask = ',jml_omask
167      CALL abort_gcm(modname,'',1)
168    END IF
169    ALLOCATE(ocemask(iim,jjp1),lon_omask(iim,jjp1),dlon_omask(iim ))
170    ALLOCATE(ocetmp (iim,jjp1),lat_omask(iim,jjp1),dlat_omask(jjp1))
[2338]171    CALL flinopen("o2a.nc", .FALSE.,iml_omask,jml_omask,llm_tmp,               &
172                  lon_omask,lat_omask,lev,ttm_tmp,itaul,date,dt,fid)
[2336]173    CALL flinget(fid, "OceMask",    iim,jjp1,llm_tmp,ttm_tmp,1,1,ocetmp)
174    CALL flinclo(fid)
175    dlon_omask(1:iim ) = lon_omask(1:iim,1)
176    dlat_omask(1:jjp1) = lat_omask(1,1:jjp1)
177    ocemask = ocetmp
178    IF(dlat_omask(1)<dlat_omask(jml_omask)) THEN
[3815]179       DO j=1,jjp1
180          ocemask(:,j) = ocetmp(:,jjp1-j+1)
181       END DO
[2336]182    END IF
183    DEALLOCATE(ocetmp,lon_omask,lat_omask,dlon_omask,dlat_omask)
184    IF(prt_level>=1) THEN
185      WRITE(fmt,"(i4,'i1)')")iim ; fmt='('//ADJUSTL(fmt)
186      WRITE(lunout,*)'OCEAN MASK :'
187      WRITE(lunout,fmt) NINT(ocemask)
188    END IF
189    masque(1:iim,:)=1.-ocemask(:,:)
190    masque(iip1 ,:)=masque(1,:)
191    DEALLOCATE(ocemask)
[2665]192  ELSE IF(NF90_OPEN("startphy0.nc", NF90_NOWRITE, nid_sta)==NF90_NOERR) THEN
193    WRITE(lunout,*)'BEWARE !! File "startphy0.nc" found.'
194    WRITE(lunout,*)'Getting the land mask from a previous run.'
195    iret=NF90_INQ_DIMID(nid_sta,'points_physiques',nid_nph)
196    iret=NF90_INQUIRE_DIMENSION(nid_sta,nid_nph,len=nphys)
197    IF(nphys/=klon) THEN
198      WRITE(lunout,*)'Mismatching dimensions for land mask'
199      WRITE(lunout,*)'nphys  = ',nphys ,' klon = ',klon
200      iret=NF90_CLOSE(nid_sta)
201      CALL abort_gcm(modname,'',1)
202    END IF
203    ALLOCATE(masktmp(klon))
204    iret=NF90_INQ_VARID(nid_sta,'masque',nid_msk)
205    iret=NF90_GET_VAR(nid_sta,nid_msk,masktmp)
206    iret=NF90_CLOSE(nid_sta)
207    CALL gr_fi_dyn(1,klon,iip1,jjp1,masktmp,masque)
208    IF(prt_level>=1) THEN
209      WRITE(fmt,"(i4,'i1)')")iip1 ; fmt='('//ADJUSTL(fmt)
210      WRITE(lunout,*)'LAND MASK :'
211      WRITE(lunout,fmt) NINT(masque)
212    END IF
213    DEALLOCATE(masktmp)
214  ELSE
215    WRITE(lunout,*)'BEWARE !! No ocean mask "o2a.nc" file or "startphy0.nc" file found'
216    WRITE(lunout,*)'Land mask will be built from the topography file.'
217    masque(:,:)=-99999.
[2293]218  END IF
[2336]219  phis(:,:)=-99999.
[2293]220
221  IF(ok_etat0) THEN
[2336]222    WRITE(lunout,'(//)')
223    WRITE(lunout,*) '  ************************  '
224    WRITE(lunout,*) '  ***  etat0phy_netcdf ***  '
225    WRITE(lunout,*) '  ************************  '
226    CALL etat0phys_netcdf(masque,phis)
227    WRITE(lunout,'(//)')
228    WRITE(lunout,*) '  ************************  '
229    WRITE(lunout,*) '  ***  etat0dyn_netcdf ***  '
230    WRITE(lunout,*) '  ************************  '
231    CALL etat0dyn_netcdf(masque,phis)
[2293]232  END IF
[524]233
[2336]234  IF(ok_limit) THEN
235    WRITE(lunout,'(//)')
236    WRITE(lunout,*) '  *********************  '
237    WRITE(lunout,*) '  ***  Limit_netcdf ***  '
238    WRITE(lunout,*) '  *********************  '
239    WRITE(lunout,'(//)')
240    CALL limit_netcdf(masque,phis,extrap)
[2293]241  END IF
[524]242
[2336]243  WRITE(lunout,'(//)')
244  WRITE(lunout,*) '  ***************************  '
245  WRITE(lunout,*) '  ***  grilles_gcm_netcdf ***  '
246  WRITE(lunout,*) '  ***************************  '
247  WRITE(lunout,'(//)')
248  CALL grilles_gcm_netcdf_sub(masque,phis)
249
250#ifdef CPP_PARA
[1319]251  END IF
[4619]252  IF (using_xios) CALL xios_finalize
[3815]253  IF (using_mpi) call MPI_FINALIZE(ierr)
254#endif
[1319]255
256END PROGRAM ce0l
[2336]257!
258!-------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.