Ignore:
Timestamp:
Aug 25, 2015, 5:14:59 PM (9 years ago)
Author:
Ehouarn Millour
Message:

More on physics/dynamics separation and cleanup:

  • Set things up so that all physics-related initializations are done via iniphysiq.
  • Created a "geometry_mod.F90" module in phy_common to store information on the loacl grid (i.e. replaces comgeomphy) and moreover give these variables more obvious names (e.g.: rlond => longitude, rlatd => latitude, airephy => cell_area).
  • removed obsolete comgeomphy.h and comgeomphy.F90

EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ5/trunk/libf/dynlonlat_phylonlat/phymar/iniphysiq_mod.F90

    r2347 r2351  
    66CONTAINS
    77
    8 SUBROUTINE iniphysiq(iim,jjm,nlayer,punjours, pdayref,ptimestep, &
     8SUBROUTINE iniphysiq(iim,jjm,nlayer,
     9                     nbp, communicator, &
     10                     punjours, pdayref,ptimestep, &
    911                     rlatu,rlatv,rlonu,rlonv,aire,cu,cv,         &
    1012                     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)
     13  USE dimphy, ONLY: init_dimphy
     14  USE mod_grid_phy_lmdz, ONLY: klon_glo,  & ! number of atmospheric columns (on full grid)
     15                               regular_lonlat  ! regular longitude-latitude grid type
    1416  USE mod_phys_lmdz_para, ONLY: klon_omp, & ! number of columns (on local omp grid)
    1517                                klon_omp_begin, & ! start index of local omp subgrid
    1618                                klon_omp_end, & ! end index of local omp subgrid
    1719                                klon_mpi_begin ! start indes of columns (on local mpi grid)
    18   USE comgeomphy, ONLY: initcomgeomphy, &
    19                         airephy, & ! physics grid area (m2)
    20                         cuphy, & ! cu coeff. (u_covariant = cu * u)
    21                         cvphy, & ! cv coeff. (v_covariant = cv * v)
    22                         rlond, & ! longitudes
    23                         rlatd ! latitudes
     20  USE geometry_mod, ONLY : init_geometry
    2421  USE comcstphy, ONLY: rradius, & ! planet radius (m)
    2522                       rr, & ! recuced gas constant: R/molar mass of atm
     
    2724                       rcpp  ! specific heat of the atmosphere
    2825!  USE phyaqua_mod, ONLY: iniaqua
     26  USE physics_distribution_mod, ONLY : init_physics_distribution
    2927  USE regular_lonlat_mod, ONLY : init_regular_lonlat, &
    3028                                 east, west, north, south, &
    3129                                 north_east, north_west, &
    3230                                 south_west, south_east
     31  USE mod_interface_dyn_phys, ONLY :  init_interface_dyn_phys
    3332  USE nrtype, ONLY: pi
    3433  IMPLICIT NONE
     
    5049  INTEGER, INTENT (IN) :: iim ! number of atmospheric coulumns along longitudes
    5150  INTEGER, INTENT (IN) :: jjm  ! number of atompsheric columns along latitudes
     51  INTEGER, INTENT(IN) :: nbp ! number of physics columns for this MPI process
     52  INTEGER, INTENT(IN) :: communicator ! MPI communicator
    5253  REAL, INTENT (IN) :: rlatu(jjm+1) ! latitudes of the physics grid
    5354  REAL, INTENT (IN) :: rlatv(jjm) ! latitude boundaries of the physics grid
     
    6263
    6364  INTEGER :: ibegin,iend,offset
    64   INTEGER :: i,j
     65  INTEGER :: i,j,k
    6566  CHARACTER (LEN=20) :: modname='iniphysiq'
    6667  CHARACTER (LEN=80) :: abort_message
     
    7273
    7374  ! global array, on full physics grid:
    74   REAL,ALLOCATABLE :: latfi(:)
    75   REAL,ALLOCATABLE :: lonfi(:)
    76   REAL,ALLOCATABLE :: cufi(:)
    77   REAL,ALLOCATABLE :: cvfi(:)
    78   REAL,ALLOCATABLE :: airefi(:)
    79  
    80   IF (nlayer.NE.klev) THEN
    81     WRITE(lunout,*) 'STOP in ',trim(modname)
    82     WRITE(lunout,*) 'Problem with dimensions :'
    83     WRITE(lunout,*) 'nlayer     = ',nlayer
    84     WRITE(lunout,*) 'klev   = ',klev
    85     abort_message = ''
    86     CALL abort_gcm (modname,abort_message,1)
    87   ENDIF
    88 
     75  REAL,ALLOCATABLE :: latfi_glo(:)
     76  REAL,ALLOCATABLE :: lonfi_glo(:)
     77  REAL,ALLOCATABLE :: cufi_glo(:)
     78  REAL,ALLOCATABLE :: cvfi_glo(:)
     79  REAL,ALLOCATABLE :: airefi_glo(:)
     80  REAL,ALLOCATABLE :: boundslonfi_glo(:,:)
     81  REAL,ALLOCATABLE :: boundslatfi_glo(:,:)
     82
     83  ! local arrays, on given MPI/OpenMP domain:
     84  REAL,ALLOCATABLE,SAVE :: latfi(:)
     85  REAL,ALLOCATABLE,SAVE :: lonfi(:)
     86  REAL,ALLOCATABLE,SAVE :: cufi(:)
     87  REAL,ALLOCATABLE,SAVE :: cvfi(:)
     88  REAL,ALLOCATABLE,SAVE :: airefi(:)
     89  REAL,ALLOCATABLE,SAVE :: boundslonfi(:,:)
     90  REAL,ALLOCATABLE,SAVE :: boundslatfi(:,:)
     91!$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi)
     92
     93  ! Initialize Physics distibution and parameters and interface with dynamics
     94  CALL init_physics_distribution(regular_lonlat,4, &
     95                                 nbp,ii,jj+1,nlayer,communicator)
     96  CALL init_interface_dyn_phys
     97 
    8998  ! init regular global longitude-latitude grid points and boundaries
    9099  ALLOCATE(boundslon_reg(iim,2))
     
    110119
    111120  ! Generate global arrays on full physics grid
    112   ALLOCATE(latfi(klon_glo),lonfi(klon_glo),cufi(klon_glo),cvfi(klon_glo))
    113   ALLOCATE(airefi(klon_glo))
     121  ALLOCATE(latfi_glo(klon_glo),lonfi_glo(klon_glo))
     122  ALLOCATE(cufi_glo(klon_glo),cvfi_glo(klon_glo))
     123  ALLOCATE(airefi_glo(klon_glo))
     124  ALLOCATE(boundslonfi_glo(klon_glo,4))
     125  ALLOCATE(boundslatfi_glo(klon_glo,4))
    114126
    115127  IF (klon_glo>1) THEN ! general case
    116128    ! North pole
    117     latfi(1)=rlatu(1)
    118     lonfi(1)=0.
    119     cufi(1) = cu(1)
    120     cvfi(1) = cv(1)
     129    latfi_glo(1)=rlatu(1)
     130    lonfi_glo(1)=0.
     131    cufi_glo(1) = cu(1)
     132    cvfi_glo(1) = cv(1)
     133    boundslonfi_glo(1,north_east)=0
     134    boundslatfi_glo(1,north_east)=PI/2
     135    boundslonfi_glo(1,north_west)=2*PI
     136    boundslatfi_glo(1,north_west)=PI/2
     137    boundslonfi_glo(1,south_west)=2*PI
     138    boundslatfi_glo(1,south_west)=rlatv(1)
     139    boundslonfi_glo(1,south_east)=0
     140    boundslatfi_glo(1,south_east)=rlatv(1)
    121141    DO j=2,jjm
    122142      DO i=1,iim
    123         latfi((j-2)*iim+1+i)= rlatu(j)
    124         lonfi((j-2)*iim+1+i)= rlonv(i)
    125         cufi((j-2)*iim+1+i) = cu((j-1)*iim+1+i)
    126         cvfi((j-2)*iim+1+i) = cv((j-1)*iim+1+i)
     143        k=(j-2)*iim+1+i
     144        latfi_glo((j-2)*iim+1+i)= rlatu(j)
     145        lonfi_glo((j-2)*iim+1+i)= rlonv(i)
     146        cufi_glo((j-2)*iim+1+i) = cu((j-1)*iim+1+i)
     147        cvfi_glo((j-2)*iim+1+i) = cv((j-1)*iim+1+i)
     148        boundslonfi_glo(k,north_east)=rlonu(i)
     149        boundslatfi_glo(k,north_east)=rlatv(j-1)
     150        boundslonfi_glo(k,north_west)=rlonu(i+1)
     151        boundslatfi_glo(k,north_west)=rlatv(j-1)
     152        boundslonfi_glo(k,south_west)=rlonu(i+1)
     153        boundslatfi_glo(k,south_west)=rlatv(j)
     154        boundslonfi_glo(k,south_east)=rlonu(i)
     155        boundslatfi_glo(k,south_east)=rlatv(j)
    127156      ENDDO
    128157    ENDDO
    129158    ! South pole
    130     latfi(klon_glo)= rlatu(jjm+1)
    131     lonfi(klon_glo)= 0.
    132     cufi(klon_glo) = cu((iim+1)*jjm+1)
    133     cvfi(klon_glo) = cv((iim+1)*jjm-iim)
     159    latfi_glo(klon_glo)= rlatu(jjm+1)
     160    lonfi_glo(klon_glo)= 0.
     161    cufi_glo(klon_glo) = cu((iim+1)*jjm+1)
     162    cvfi_glo(klon_glo) = cv((iim+1)*jjm-iim)
     163    boundslonfi_glo(klon_glo,north_east)= 0
     164    boundslatfi_glo(klon_glo,north_east)= rlatv(jjm)
     165    boundslonfi_glo(klon_glo,north_west)= 2*PI
     166    boundslatfi_glo(klon_glo,north_west)= rlatv(jjm)
     167    boundslonfi_glo(klon_glo,south_west)= 2*PI
     168    boundslatfi_glo(klon_glo,south_west)= -PI/2
     169    boundslonfi_glo(klon_glo,south_east)= 0
     170    boundslatfi_glo(klon_glo,south_east)= -Pi/2
    134171
    135172    ! build airefi(), mesh area on physics grid
    136     CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,airefi)
     173    CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,airefi_glo)
    137174    ! Poles are single points on physics grid
    138     airefi(1)=sum(aire(1:iim,1))
    139     airefi(klon_glo)=sum(aire(1:iim,jjm+1))
     175    airefi_glo(1)=sum(aire(1:iim,1))
     176    airefi_glo(klon_glo)=sum(aire(1:iim,jjm+1))
    140177
    141178    ! Sanity check: do total planet area match between physics and dynamics?
    142179    total_area_dyn=sum(aire(1:iim,1:jjm+1))
    143     total_area_phy=sum(airefi(1:klon_glo))
     180    total_area_phy=sum(airefi_glo(1:klon_glo))
    144181    IF (total_area_dyn/=total_area_phy) THEN
    145182      WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
     
    154191  ELSE ! klon_glo==1, running the 1D model
    155192    ! just copy over input values
    156     latfi(1)=rlatu(1)
    157     lonfi(1)=rlonv(1)
    158     cufi(1)=cu(1)
    159     cvfi(1)=cv(1)
    160     airefi(1)=aire(1,1)
     193    latfi_glo(1)=rlatu(1)
     194    lonfi_glo(1)=rlonv(1)
     195    cufi_glo(1)=cu(1)
     196    cvfi_glo(1)=cv(1)
     197    airefi_glo(1)=aire(1,1)
     198    boundslonfi_glo(1,north_east)=rlonu(1)
     199    boundslatfi_glo(1,north_east)=PI/2
     200    boundslonfi_glo(1,north_west)=rlonu(2)
     201    boundslatfi_glo(1,north_west)=PI/2
     202    boundslonfi_glo(1,south_west)=rlonu(2)
     203    boundslatfi_glo(1,south_west)=rlatv(1)
     204    boundslonfi_glo(1,south_east)=rlonu(1)
     205    boundslatfi_glo(1,south_east)=rlatv(1)
    161206  ENDIF ! of IF (klon_glo>1)
    162207
    163208!$OMP PARALLEL
    164   ! Now generate local lon/lat/cu/cv/area arrays
    165   CALL initcomgeomphy
    166      
     209  ! Now generate local lon/lat/cu/cv/area/bounds arrays
     210  ALLOCATE(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp))
     211  ALLOCATE(airefi(klon_omp))
     212  ALLOCATE(boundslonfi(klon_omp,4))
     213  ALLOCATE(boundslatfi(klon_omp,4))
     214
     215
    167216  offset = klon_mpi_begin - 1
    168   airephy(1:klon_omp) = airefi(offset+klon_omp_begin:offset+klon_omp_end)
    169   cuphy(1:klon_omp) = cufi(offset+klon_omp_begin:offset+klon_omp_end)
    170   cvphy(1:klon_omp) = cvfi(offset+klon_omp_begin:offset+klon_omp_end)
    171   rlond(1:klon_omp) = lonfi(offset+klon_omp_begin:offset+klon_omp_end)
    172   rlatd(1:klon_omp) = latfi(offset+klon_omp_begin:offset+klon_omp_end)
     217  airefi(1:klon_omp) = airefi_glo(offset+klon_omp_begin:offset+klon_omp_end)
     218  cufi(1:klon_omp) = cufi_glo(offset+klon_omp_begin:offset+klon_omp_end)
     219  cvfi(1:klon_omp) = cvfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
     220  lonfi(1:klon_omp) = lonfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
     221  latfi(1:klon_omp) = latfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
     222  boundslonfi(1:klon_omp,:) = boundslonfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
     223  boundslatfi(1:klon_omp,:) = boundslatfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
     224
     225  ! copy over local grid longitudes and latitudes
     226  CALL init_geometry(klon_omp,lonfi,latfi,boundslonfi,boundslatfi, &
     227                     airefi,cufi,cvfi)
     228
    173229
    174230! copy some fundamental parameters to physics
Note: See TracChangeset for help on using the changeset viewer.