[2347] | 1 | ! |
---|
[1403] | 2 | ! $Id: iniphysiq_mod.F90 2347 2015-08-24 07:26:48Z emillour $ |
---|
[2347] | 3 | ! |
---|
| 4 | MODULE iniphysiq_mod |
---|
[1671] | 5 | |
---|
[2347] | 6 | CONTAINS |
---|
[1671] | 7 | |
---|
[2346] | 8 | SUBROUTINE iniphysiq(ii,jj,nlayer,punjours, pdayref,ptimestep, & |
---|
| 9 | rlatu,rlatv,rlonu,rlonv,aire,cu,cv, & |
---|
[2225] | 10 | prad,pg,pr,pcpp,iflag_phys) |
---|
| 11 | USE dimphy, ONLY: klev ! number of atmospheric levels |
---|
| 12 | USE mod_grid_phy_lmdz, ONLY: klon_glo ! number of atmospheric columns |
---|
| 13 | ! (on full grid) |
---|
| 14 | USE mod_phys_lmdz_para, ONLY: klon_omp, & ! number of columns (on local omp grid) |
---|
| 15 | klon_omp_begin, & ! start index of local omp subgrid |
---|
| 16 | klon_omp_end, & ! end index of local omp subgrid |
---|
| 17 | klon_mpi_begin ! start indes of columns (on local mpi grid) |
---|
[2315] | 18 | USE vertical_layers_mod, ONLY : init_vertical_layers |
---|
[2320] | 19 | USE infotrac, ONLY: nqtot,nqo,nbtr,tname,ttext,type_trac,& |
---|
| 20 | niadv,conv_flg,pbl_flg,solsym,& |
---|
| 21 | nqfils,nqdesc,nqdesc_tot,iqfils,iqpere,& |
---|
| 22 | ok_isotopes,ok_iso_verif,ok_isotrac,& |
---|
| 23 | ok_init_iso,niso_possibles,tnat,& |
---|
| 24 | alpha_ideal,use_iso,iqiso,iso_num,& |
---|
| 25 | iso_indnum,zone_num,phase_num,& |
---|
| 26 | indnum_fn_num,index_trac,& |
---|
| 27 | niso,ntraceurs_zone,ntraciso |
---|
[2343] | 28 | USE control_mod, ONLY: dayref,anneeref,day_step,nday,offline |
---|
[2225] | 29 | USE comgeomphy, ONLY: initcomgeomphy, & |
---|
| 30 | airephy, & ! physics grid area (m2) |
---|
| 31 | cuphy, & ! cu coeff. (u_covariant = cu * u) |
---|
| 32 | cvphy, & ! cv coeff. (v_covariant = cv * v) |
---|
| 33 | rlond, & ! longitudes |
---|
| 34 | rlatd ! latitudes |
---|
[2311] | 35 | USE inifis_mod, ONLY: inifis |
---|
[2343] | 36 | USE time_phylmdz_mod, ONLY: init_time |
---|
[2320] | 37 | USE infotrac_phy, ONLY: init_infotrac_phy |
---|
[2343] | 38 | USE phystokenc_mod, ONLY: init_phystokenc |
---|
[1992] | 39 | USE phyaqua_mod, ONLY: iniaqua |
---|
[2346] | 40 | USE regular_lonlat_mod, ONLY : init_regular_lonlat, & |
---|
| 41 | east, west, north, south, & |
---|
| 42 | north_east, north_west, & |
---|
| 43 | south_west, south_east |
---|
[1992] | 44 | IMPLICIT NONE |
---|
[1671] | 45 | |
---|
[1992] | 46 | ! ======================================================================= |
---|
| 47 | ! Initialisation of the physical constants and some positional and |
---|
| 48 | ! geometrical arrays for the physics |
---|
| 49 | ! ======================================================================= |
---|
[1403] | 50 | |
---|
[2315] | 51 | include "dimensions.h" |
---|
| 52 | include "comvert.h" |
---|
[2346] | 53 | include "comconst.h" |
---|
[1992] | 54 | include "iniprint.h" |
---|
[2343] | 55 | include "temps.h" |
---|
| 56 | include "tracstoke.h" |
---|
[1992] | 57 | |
---|
| 58 | REAL, INTENT (IN) :: prad ! radius of the planet (m) |
---|
| 59 | REAL, INTENT (IN) :: pg ! gravitational acceleration (m/s2) |
---|
| 60 | REAL, INTENT (IN) :: pr ! ! reduced gas constant R/mu |
---|
| 61 | REAL, INTENT (IN) :: pcpp ! specific heat Cp |
---|
| 62 | REAL, INTENT (IN) :: punjours ! length (in s) of a standard day |
---|
| 63 | INTEGER, INTENT (IN) :: nlayer ! number of atmospheric layers |
---|
[2315] | 64 | INTEGER, INTENT (IN) :: ii ! number of atmospheric columns along longitudes |
---|
| 65 | INTEGER, INTENT (IN) :: jj ! number of atompsheric columns along latitudes |
---|
| 66 | REAL, INTENT (IN) :: rlatu(jj+1) ! latitudes of the physics grid |
---|
[2346] | 67 | REAL, INTENT (IN) :: rlatv(jj) ! latitude boundaries of the physics grid |
---|
[2315] | 68 | REAL, INTENT (IN) :: rlonv(ii+1) ! longitudes of the physics grid |
---|
[2346] | 69 | REAL, INTENT (IN) :: rlonu(ii+1) ! longitude boundaries of the physics grid |
---|
[2315] | 70 | REAL, INTENT (IN) :: aire(ii+1,jj+1) ! area of the dynamics grid (m2) |
---|
| 71 | REAL, INTENT (IN) :: cu((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u) |
---|
| 72 | REAL, INTENT (IN) :: cv((ii+1)*jj) ! cv coeff. (v_covariant = cv * v) |
---|
[1992] | 73 | INTEGER, INTENT (IN) :: pdayref ! reference day of for the simulation |
---|
| 74 | REAL, INTENT (IN) :: ptimestep !physics time step (s) |
---|
| 75 | INTEGER, INTENT (IN) :: iflag_phys ! type of physics to be called |
---|
| 76 | |
---|
| 77 | INTEGER :: ibegin, iend, offset |
---|
[2225] | 78 | INTEGER :: i,j |
---|
[1992] | 79 | CHARACTER (LEN=20) :: modname = 'iniphysiq' |
---|
| 80 | CHARACTER (LEN=80) :: abort_message |
---|
[2225] | 81 | REAL :: total_area_phy, total_area_dyn |
---|
[1992] | 82 | |
---|
[2346] | 83 | ! boundaries, on global grid |
---|
| 84 | REAL,ALLOCATABLE :: boundslon_reg(:,:) |
---|
| 85 | REAL,ALLOCATABLE :: boundslat_reg(:,:) |
---|
[2225] | 86 | |
---|
| 87 | ! global array, on full physics grid: |
---|
| 88 | REAL,ALLOCATABLE :: latfi(:) |
---|
| 89 | REAL,ALLOCATABLE :: lonfi(:) |
---|
| 90 | REAL,ALLOCATABLE :: cufi(:) |
---|
| 91 | REAL,ALLOCATABLE :: cvfi(:) |
---|
| 92 | REAL,ALLOCATABLE :: airefi(:) |
---|
| 93 | |
---|
[1992] | 94 | IF (nlayer/=klev) THEN |
---|
| 95 | WRITE (lunout, *) 'nlayer = ', nlayer |
---|
| 96 | WRITE (lunout, *) 'klev = ', klev |
---|
[2331] | 97 | CALL abort_gcm(modname, 'Problem with dimensions', 1) |
---|
[1992] | 98 | END IF |
---|
| 99 | |
---|
[2315] | 100 | !call init_phys_lmdz(ii,jj+1,llm,1,(/(jj-1)*ii+2/)) |
---|
[2225] | 101 | |
---|
[2346] | 102 | ! init regular global longitude-latitude grid points and boundaries |
---|
| 103 | ALLOCATE(boundslon_reg(ii,2)) |
---|
| 104 | ALLOCATE(boundslat_reg(jj+1,2)) |
---|
| 105 | |
---|
| 106 | DO i=1,ii |
---|
| 107 | boundslon_reg(i,east)=rlonu(i) |
---|
| 108 | boundslon_reg(i,west)=rlonu(i+1) |
---|
| 109 | ENDDO |
---|
| 110 | |
---|
| 111 | boundslat_reg(1,north)= PI/2 |
---|
| 112 | boundslat_reg(1,south)= rlatv(1) |
---|
| 113 | DO j=2,jj |
---|
| 114 | boundslat_reg(j,north)=rlatv(j-1) |
---|
| 115 | boundslat_reg(j,south)=rlatv(j) |
---|
| 116 | ENDDO |
---|
| 117 | boundslat_reg(jj+1,north)= rlatv(jj) |
---|
| 118 | boundslat_reg(jj+1,south)= -PI/2 |
---|
| 119 | |
---|
| 120 | ! Write values in module regular_lonlat_mod |
---|
| 121 | CALL init_regular_lonlat(ii,jj+1, rlonv(1:ii), rlatu, & |
---|
| 122 | boundslon_reg, boundslat_reg) |
---|
| 123 | |
---|
[2225] | 124 | ! Generate global arrays on full physics grid |
---|
| 125 | ALLOCATE(latfi(klon_glo),lonfi(klon_glo),cufi(klon_glo),cvfi(klon_glo)) |
---|
| 126 | ALLOCATE(airefi(klon_glo)) |
---|
[1992] | 127 | |
---|
[2225] | 128 | IF (klon_glo>1) THEN ! general case |
---|
| 129 | ! North pole |
---|
| 130 | latfi(1)=rlatu(1) |
---|
| 131 | lonfi(1)=0. |
---|
| 132 | cufi(1) = cu(1) |
---|
| 133 | cvfi(1) = cv(1) |
---|
[2315] | 134 | DO j=2,jj |
---|
| 135 | DO i=1,ii |
---|
| 136 | latfi((j-2)*ii+1+i)= rlatu(j) |
---|
| 137 | lonfi((j-2)*ii+1+i)= rlonv(i) |
---|
| 138 | cufi((j-2)*ii+1+i) = cu((j-1)*(ii+1)+i) |
---|
| 139 | cvfi((j-2)*ii+1+i) = cv((j-1)*(ii+1)+i) |
---|
[2225] | 140 | ENDDO |
---|
| 141 | ENDDO |
---|
| 142 | ! South pole |
---|
[2315] | 143 | latfi(klon_glo)= rlatu(jj+1) |
---|
[2225] | 144 | lonfi(klon_glo)= 0. |
---|
[2315] | 145 | cufi(klon_glo) = cu((ii+1)*jj+1) |
---|
| 146 | cvfi(klon_glo) = cv((ii+1)*jj-ii) |
---|
[1992] | 147 | |
---|
[2225] | 148 | ! build airefi(), mesh area on physics grid |
---|
[2315] | 149 | CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,aire,airefi) |
---|
[2225] | 150 | ! Poles are single points on physics grid |
---|
[2315] | 151 | airefi(1)=sum(aire(1:ii,1)) |
---|
| 152 | airefi(klon_glo)=sum(aire(1:ii,jj+1)) |
---|
[2225] | 153 | |
---|
| 154 | ! Sanity check: do total planet area match between physics and dynamics? |
---|
[2315] | 155 | total_area_dyn=sum(aire(1:ii,1:jj+1)) |
---|
[2225] | 156 | total_area_phy=sum(airefi(1:klon_glo)) |
---|
| 157 | IF (total_area_dyn/=total_area_phy) THEN |
---|
| 158 | WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!' |
---|
| 159 | WRITE (lunout, *) ' in the dynamics total_area_dyn=', total_area_dyn |
---|
| 160 | WRITE (lunout, *) ' but in the physics total_area_phy=', total_area_phy |
---|
| 161 | IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN |
---|
| 162 | ! stop here if the relative difference is more than 0.001% |
---|
| 163 | abort_message = 'planet total surface discrepancy' |
---|
| 164 | CALL abort_gcm(modname, abort_message, 1) |
---|
| 165 | ENDIF |
---|
| 166 | ENDIF |
---|
| 167 | ELSE ! klon_glo==1, running the 1D model |
---|
| 168 | ! just copy over input values |
---|
| 169 | latfi(1)=rlatu(1) |
---|
| 170 | lonfi(1)=rlonv(1) |
---|
| 171 | cufi(1)=cu(1) |
---|
| 172 | cvfi(1)=cv(1) |
---|
| 173 | airefi(1)=aire(1,1) |
---|
| 174 | ENDIF ! of IF (klon_glo>1) |
---|
| 175 | |
---|
[2343] | 176 | !$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/) |
---|
[2311] | 177 | ! Initialize physical constants in physics: |
---|
| 178 | CALL inifis(punjours,prad,pg,pr,pcpp) |
---|
[2343] | 179 | CALL init_time(annee_ref,day_ref,day_ini,start_time,nday,ptimestep) |
---|
| 180 | |
---|
| 181 | ! Copy over "offline" settings |
---|
| 182 | CALL init_phystokenc(offline,istphy) |
---|
| 183 | |
---|
[2315] | 184 | ! copy over preff , ap(), bp(), etc |
---|
| 185 | CALL init_vertical_layers(nlayer,preff,scaleheight, & |
---|
| 186 | ap,bp,presnivs,pseudoalt) |
---|
| 187 | |
---|
[2320] | 188 | ! Initialize tracer names, numbers, etc. for physics |
---|
| 189 | CALL init_infotrac_phy(nqtot,nqo,nbtr,tname,ttext,type_trac,& |
---|
| 190 | niadv,conv_flg,pbl_flg,solsym,& |
---|
| 191 | nqfils,nqdesc,nqdesc_tot,iqfils,iqpere,& |
---|
| 192 | ok_isotopes,ok_iso_verif,ok_isotrac,& |
---|
| 193 | ok_init_iso,niso_possibles,tnat,& |
---|
| 194 | alpha_ideal,use_iso,iqiso,iso_num,& |
---|
| 195 | iso_indnum,zone_num,phase_num,& |
---|
| 196 | indnum_fn_num,index_trac,& |
---|
| 197 | niso,ntraceurs_zone,ntraciso) |
---|
| 198 | |
---|
[2225] | 199 | ! Now generate local lon/lat/cu/cv/area arrays |
---|
| 200 | CALL initcomgeomphy |
---|
| 201 | |
---|
[1992] | 202 | offset = klon_mpi_begin - 1 |
---|
[2225] | 203 | airephy(1:klon_omp) = airefi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
| 204 | cuphy(1:klon_omp) = cufi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
| 205 | cvphy(1:klon_omp) = cvfi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
| 206 | rlond(1:klon_omp) = lonfi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
| 207 | rlatd(1:klon_omp) = latfi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
[1992] | 208 | |
---|
[2311] | 209 | ! Additional initializations for aquaplanets |
---|
[1992] | 210 | IF (iflag_phys>=100) THEN |
---|
| 211 | CALL iniaqua(klon_omp, rlatd, rlond, iflag_phys) |
---|
| 212 | END IF |
---|
[2225] | 213 | !$OMP END PARALLEL |
---|
[1992] | 214 | |
---|
| 215 | END SUBROUTINE iniphysiq |
---|
[2347] | 216 | |
---|
| 217 | END MODULE iniphysiq_mod |
---|