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