[1523] | 1 | MODULE iniphysiq_mod |
---|
| 2 | |
---|
| 3 | CONTAINS |
---|
| 4 | |
---|
[1395] | 5 | subroutine iniphysiq(ii,jj,nlayer,punjours, pdayref,ptimestep, & |
---|
[1523] | 6 | rlatu,rlatv,rlonu,rlonv,aire,cu,cv, & |
---|
[1216] | 7 | prad,pg,pr,pcpp,iflag_phys) |
---|
| 8 | |
---|
| 9 | use dimphy, only : klev ! number of atmospheric levels |
---|
| 10 | use mod_grid_phy_lmdz, only : klon_glo ! number of atmospheric columns |
---|
| 11 | ! (on full grid) |
---|
| 12 | use mod_phys_lmdz_para, only : klon_omp, & ! number of columns (on local omp grid) |
---|
| 13 | klon_omp_begin, & ! start index of local omp subgrid |
---|
| 14 | klon_omp_end, & ! end index of local omp subgrid |
---|
| 15 | klon_mpi_begin ! start indes of columns (on local mpi grid) |
---|
[1395] | 16 | |
---|
| 17 | use comgeomphy, only : initcomgeomphy, & |
---|
| 18 | airephy, & ! physics grid area (m2) |
---|
[1216] | 19 | cuphy, & ! cu coeff. (u_covariant = cu * u) |
---|
| 20 | cvphy, & ! cv coeff. (v_covariant = cv * v) |
---|
| 21 | rlond, & ! longitudes |
---|
| 22 | rlatd ! latitudes |
---|
| 23 | use infotrac, only : nqtot ! number of advected tracers |
---|
[1308] | 24 | use planete_mod, only: ini_planete_mod |
---|
[1422] | 25 | USE comvert_mod, ONLY: ap,bp,preff |
---|
[1523] | 26 | use regular_lonlat_mod, only: init_regular_lonlat, & |
---|
| 27 | east, west, north, south, & |
---|
| 28 | north_east, north_west, & |
---|
| 29 | south_west, south_east |
---|
[1216] | 30 | |
---|
| 31 | implicit none |
---|
[1308] | 32 | include "dimensions.h" |
---|
[1395] | 33 | include "iniprint.h" |
---|
[1216] | 34 | |
---|
| 35 | real,intent(in) :: prad ! radius of the planet (m) |
---|
| 36 | real,intent(in) :: pg ! gravitational acceleration (m/s2) |
---|
| 37 | real,intent(in) :: pr ! ! reduced gas constant R/mu |
---|
| 38 | real,intent(in) :: pcpp ! specific heat Cp |
---|
| 39 | real,intent(in) :: punjours ! length (in s) of a standard day |
---|
[1395] | 40 | !integer,intent(in) :: ngrid ! number of horizontal grid points in the physics (full grid) |
---|
[1216] | 41 | integer,intent(in) :: nlayer ! number of atmospheric layers |
---|
[1395] | 42 | integer,intent(in) :: ii ! number of atmospheric coulumns along longitudes |
---|
| 43 | integer,intent(in) :: jj ! number of atompsheric columns along latitudes |
---|
[1523] | 44 | real,intent(in) :: rlatu(jj+1) ! latitudes of the physics grid |
---|
| 45 | real,intent(in) :: rlatv(jj) ! latitude boundaries of the physics grid |
---|
| 46 | real,intent(in) :: rlonv(ii+1) ! longitudes of the physics grid |
---|
| 47 | real,intent(in) :: rlonu(ii+1) ! longitude boundaries of the physics grid |
---|
[1395] | 48 | real,intent(in) :: aire(ii+1,jj+1) ! area of the dynamics grid (m2) |
---|
| 49 | real,intent(in) :: cu((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u) |
---|
| 50 | real,intent(in) :: cv((ii+1)*jj) ! cv coeff. (v_covariant = cv * v) |
---|
[1216] | 51 | integer,intent(in) :: pdayref ! reference day of for the simulation |
---|
| 52 | real,intent(in) :: ptimestep !physics time step (s) |
---|
| 53 | integer,intent(in) :: iflag_phys ! type of physics to be called |
---|
| 54 | |
---|
| 55 | integer :: ibegin,iend,offset |
---|
[1395] | 56 | integer :: i,j |
---|
[1216] | 57 | character(len=20) :: modname='iniphysiq' |
---|
| 58 | character(len=80) :: abort_message |
---|
[1395] | 59 | real :: total_area_phy, total_area_dyn |
---|
[1523] | 60 | real :: pi |
---|
[1216] | 61 | |
---|
[1523] | 62 | ! boundaries, on global grid |
---|
| 63 | real,allocatable :: boundslon_reg(:,:) |
---|
| 64 | real,allocatable :: boundslat_reg(:,:) |
---|
[1395] | 65 | |
---|
| 66 | ! global array, on full physics grid: |
---|
| 67 | real,allocatable :: latfi(:) |
---|
| 68 | real,allocatable :: lonfi(:) |
---|
| 69 | real,allocatable :: cufi(:) |
---|
| 70 | real,allocatable :: cvfi(:) |
---|
| 71 | real,allocatable :: airefi(:) |
---|
| 72 | |
---|
[1523] | 73 | pi=2.*asin(1.0) |
---|
| 74 | |
---|
[1216] | 75 | IF (nlayer.NE.klev) THEN |
---|
| 76 | write(*,*) 'STOP in ',trim(modname) |
---|
| 77 | write(*,*) 'Problem with dimensions :' |
---|
| 78 | write(*,*) 'nlayer = ',nlayer |
---|
| 79 | write(*,*) 'klev = ',klev |
---|
| 80 | abort_message = '' |
---|
| 81 | CALL abort_gcm (modname,abort_message,1) |
---|
| 82 | ENDIF |
---|
| 83 | |
---|
[1395] | 84 | !IF (ngrid.NE.klon_glo) THEN |
---|
| 85 | ! write(*,*) 'STOP in ',trim(modname) |
---|
| 86 | ! write(*,*) 'Problem with dimensions :' |
---|
| 87 | ! write(*,*) 'ngrid = ',ngrid |
---|
| 88 | ! write(*,*) 'klon = ',klon_glo |
---|
| 89 | ! abort_message = '' |
---|
| 90 | ! CALL abort_gcm (modname,abort_message,1) |
---|
| 91 | !ENDIF |
---|
| 92 | |
---|
| 93 | !call init_phys_lmdz(iim,jjm+1,llm,1,(/(jjm-1)*iim+2/)) |
---|
| 94 | |
---|
[1523] | 95 | ! init regular global longitude-latitude grid points and boundaries |
---|
| 96 | ALLOCATE(boundslon_reg(ii,2)) |
---|
| 97 | ALLOCATE(boundslat_reg(jj+1,2)) |
---|
| 98 | |
---|
| 99 | DO i=1,ii |
---|
| 100 | boundslon_reg(i,east)=rlonu(i) |
---|
| 101 | boundslon_reg(i,west)=rlonu(i+1) |
---|
| 102 | ENDDO |
---|
| 103 | |
---|
| 104 | boundslat_reg(1,north)= PI/2 |
---|
| 105 | boundslat_reg(1,south)= rlatv(1) |
---|
| 106 | DO j=2,jj |
---|
| 107 | boundslat_reg(j,north)=rlatv(j-1) |
---|
| 108 | boundslat_reg(j,south)=rlatv(j) |
---|
| 109 | ENDDO |
---|
| 110 | boundslat_reg(jj+1,north)= rlatv(jj) |
---|
| 111 | boundslat_reg(jj+1,south)= -PI/2 |
---|
| 112 | |
---|
| 113 | ! Write values in module regular_lonlat_mod |
---|
| 114 | CALL init_regular_lonlat(ii,jj+1, rlonv(1:ii), rlatu, & |
---|
| 115 | boundslon_reg, boundslat_reg) |
---|
| 116 | |
---|
[1395] | 117 | ! Generate global arrays on full physics grid |
---|
| 118 | allocate(latfi(klon_glo),lonfi(klon_glo),cufi(klon_glo),cvfi(klon_glo)) |
---|
| 119 | latfi(1)=rlatu(1) |
---|
| 120 | lonfi(1)=0. |
---|
| 121 | cufi(1) = cu(1) |
---|
| 122 | cvfi(1) = cv(1) |
---|
| 123 | DO j=2,jj |
---|
| 124 | DO i=1,ii |
---|
| 125 | latfi((j-2)*ii+1+i)= rlatu(j) |
---|
| 126 | lonfi((j-2)*ii+1+i)= rlonv(i) |
---|
[1428] | 127 | cufi((j-2)*ii+1+i) = cu((j-1)*(ii+1)+i) |
---|
| 128 | cvfi((j-2)*ii+1+i) = cv((j-1)*(ii+1)+i) |
---|
[1395] | 129 | ENDDO |
---|
| 130 | ENDDO |
---|
| 131 | latfi(klon_glo)= rlatu(jj+1) |
---|
| 132 | lonfi(klon_glo)= 0. |
---|
| 133 | cufi(klon_glo) = cu((ii+1)*jj+1) |
---|
| 134 | cvfi(klon_glo) = cv((ii+1)*jj-ii) |
---|
| 135 | |
---|
| 136 | ! build airefi(), mesh area on physics grid |
---|
| 137 | allocate(airefi(klon_glo)) |
---|
| 138 | CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,aire,airefi) |
---|
| 139 | ! Poles are single points on physics grid |
---|
| 140 | airefi(1)=sum(aire(1:ii,1)) |
---|
| 141 | airefi(klon_glo)=sum(aire(1:ii,jj+1)) |
---|
| 142 | |
---|
| 143 | ! Sanity check: do total planet area match between physics and dynamics? |
---|
| 144 | total_area_dyn=sum(aire(1:ii,1:jj+1)) |
---|
| 145 | total_area_phy=sum(airefi(1:klon_glo)) |
---|
| 146 | IF (total_area_dyn/=total_area_phy) THEN |
---|
| 147 | WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!' |
---|
| 148 | WRITE (lunout, *) ' in the dynamics total_area_dyn=', total_area_dyn |
---|
| 149 | WRITE (lunout, *) ' but in the physics total_area_phy=', total_area_phy |
---|
| 150 | IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN |
---|
| 151 | ! stop here if the relative difference is more than 0.001% |
---|
| 152 | abort_message = 'planet total surface discrepancy' |
---|
| 153 | CALL abort_gcm(modname, abort_message, 1) |
---|
| 154 | ENDIF |
---|
[1216] | 155 | ENDIF |
---|
| 156 | |
---|
[1395] | 157 | |
---|
| 158 | !$OMP PARALLEL |
---|
| 159 | ! Now generate local lon/lat/cu/cv/area arrays |
---|
| 160 | call initcomgeomphy |
---|
| 161 | |
---|
| 162 | !!!!$OMP PARALLEL PRIVATE(ibegin,iend) & |
---|
| 163 | !!! !$OMP SHARED(airefi,cufi,cvfi,lonfi,latfi) |
---|
| 164 | |
---|
[1216] | 165 | offset=klon_mpi_begin-1 |
---|
[1395] | 166 | airephy(1:klon_omp)=airefi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
| 167 | cuphy(1:klon_omp)=cufi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
| 168 | cvphy(1:klon_omp)=cvfi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
| 169 | rlond(1:klon_omp)=lonfi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
| 170 | rlatd(1:klon_omp)=latfi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
[1216] | 171 | |
---|
[1308] | 172 | ! copy over preff , ap() and bp() |
---|
| 173 | call ini_planete_mod(nlayer,preff,ap,bp) |
---|
| 174 | |
---|
[1216] | 175 | ! copy some fundamental parameters to physics |
---|
| 176 | ! and do some initializations |
---|
| 177 | call inifis(klon_omp,nlayer,nqtot,pdayref,punjours,ptimestep, & |
---|
| 178 | rlatd,rlond,airephy,prad,pg,pr,pcpp) |
---|
| 179 | |
---|
| 180 | !$OMP END PARALLEL |
---|
| 181 | |
---|
| 182 | |
---|
| 183 | end subroutine iniphysiq |
---|
[1523] | 184 | |
---|
| 185 | |
---|
| 186 | END MODULE iniphysiq_mod |
---|