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/phydev/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 infotrac, ONLY: nqtot, type_trac
    2522  USE infotrac_phy, ONLY: init_infotrac_phy
     
    3027  USE inifis_mod, ONLY: inifis
    3128  USE phyaqua_mod, ONLY: iniaqua
     29  USE physics_distribution_mod, ONLY : init_physics_distribution
    3230  USE regular_lonlat_mod, ONLY : init_regular_lonlat, &
    3331                                 east, west, north, south, &
    3432                                 north_east, north_west, &
    3533                                 south_west, south_east
     34  USE mod_interface_dyn_phys, ONLY :  init_interface_dyn_phys
    3635  USE nrtype, ONLY: pi
    3736  IMPLICIT NONE
     
    5352  INTEGER, INTENT (IN) :: iim ! number of atmospheric coulumns along longitudes
    5453  INTEGER, INTENT (IN) :: jjm  ! number of atompsheric columns along latitudes
     54  INTEGER, INTENT(IN) :: nbp ! number of physics columns for this MPI process
     55  INTEGER, INTENT(IN) :: communicator ! MPI communicator
    5556  REAL, INTENT (IN) :: rlatu(jjm+1) ! latitudes of the physics grid
    5657  REAL, INTENT (IN) :: rlatv(jjm) ! latitude boundaries of the physics grid
     
    6566
    6667  INTEGER :: ibegin,iend,offset
    67   INTEGER :: i,j
     68  INTEGER :: i,j,k
    6869  CHARACTER (LEN=20) :: modname='iniphysiq'
    6970  CHARACTER (LEN=80) :: abort_message
     
    7576
    7677  ! global array, on full physics grid:
    77   REAL,ALLOCATABLE :: latfi(:)
    78   REAL,ALLOCATABLE :: lonfi(:)
    79   REAL,ALLOCATABLE :: cufi(:)
    80   REAL,ALLOCATABLE :: cvfi(:)
    81   REAL,ALLOCATABLE :: airefi(:)
    82 
    83   IF (nlayer.NE.klev) THEN
    84     WRITE(lunout,*) 'STOP in ',trim(modname)
    85     WRITE(lunout,*) 'Problem with dimensions :'
    86     WRITE(lunout,*) 'nlayer     = ',nlayer
    87     WRITE(lunout,*) 'klev   = ',klev
    88     abort_message = ''
    89     CALL abort_gcm (modname,abort_message,1)
    90   ENDIF
    91 
    92   !call init_phys_lmdz(iim,jjm+1,llm,1,(/(jjm-1)*iim+2/))
     78  REAL,ALLOCATABLE :: latfi_glo(:)
     79  REAL,ALLOCATABLE :: lonfi_glo(:)
     80  REAL,ALLOCATABLE :: cufi_glo(:)
     81  REAL,ALLOCATABLE :: cvfi_glo(:)
     82  REAL,ALLOCATABLE :: airefi_glo(:)
     83  REAL,ALLOCATABLE :: boundslonfi_glo(:,:)
     84  REAL,ALLOCATABLE :: boundslatfi_glo(:,:)
     85
     86  ! local arrays, on given MPI/OpenMP domain:
     87  REAL,ALLOCATABLE,SAVE :: latfi(:)
     88  REAL,ALLOCATABLE,SAVE :: lonfi(:)
     89  REAL,ALLOCATABLE,SAVE :: cufi(:)
     90  REAL,ALLOCATABLE,SAVE :: cvfi(:)
     91  REAL,ALLOCATABLE,SAVE :: airefi(:)
     92  REAL,ALLOCATABLE,SAVE :: boundslonfi(:,:)
     93  REAL,ALLOCATABLE,SAVE :: boundslatfi(:,:)
     94!$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi)
     95
     96  ! Initialize Physics distibution and parameters and interface with dynamics
     97  CALL init_physics_distribution(regular_lonlat,4, &
     98                                 nbp,iim,jjm+1,nlayer,communicator)
     99  CALL init_interface_dyn_phys
    93100 
    94101  ! init regular global longitude-latitude grid points and boundaries
     
    115122
    116123  ! Generate global arrays on full physics grid
    117   ALLOCATE(latfi(klon_glo),lonfi(klon_glo),cufi(klon_glo),cvfi(klon_glo))
    118   ALLOCATE(airefi(klon_glo))
     124  ALLOCATE(latfi_glo(klon_glo),lonfi_glo(klon_glo))
     125  ALLOCATE(cufi_glo(klon_glo),cvfi_glo(klon_glo))
     126  ALLOCATE(airefi_glo(klon_glo))
     127  ALLOCATE(boundslonfi_glo(klon_glo,4))
     128  ALLOCATE(boundslatfi_glo(klon_glo,4))
    119129
    120130    ! North pole
    121     latfi(1)=rlatu(1)
    122     lonfi(1)=0.
    123     cufi(1) = cu(1)
    124     cvfi(1) = cv(1)
     131    latfi_glo(1)=rlatu(1)
     132    lonfi_glo(1)=0.
     133    cufi_glo(1) = cu(1)
     134    cvfi_glo(1) = cv(1)
     135    boundslonfi_glo(1,north_east)=0
     136    boundslatfi_glo(1,north_east)=PI/2
     137    boundslonfi_glo(1,north_west)=2*PI
     138    boundslatfi_glo(1,north_west)=PI/2
     139    boundslonfi_glo(1,south_west)=2*PI
     140    boundslatfi_glo(1,south_west)=rlatv(1)
     141    boundslonfi_glo(1,south_east)=0
     142    boundslatfi_glo(1,south_east)=rlatv(1)
    125143    DO j=2,jjm
    126144      DO i=1,iim
    127         latfi((j-2)*iim+1+i)= rlatu(j)
    128         lonfi((j-2)*iim+1+i)= rlonv(i)
    129         cufi((j-2)*iim+1+i) = cu((j-1)*iim+1+i)
    130         cvfi((j-2)*iim+1+i) = cv((j-1)*iim+1+i)
     145        k=(j-2)*iim+1+i
     146        latfi_glo(k)= rlatu(j)
     147        lonfi_glo(k)= rlonv(i)
     148        cufi_glo(k) = cu((j-1)*iim+1+i)
     149        cvfi_glo(k) = cv((j-1)*iim+1+i)
     150        boundslonfi_glo(k,north_east)=rlonu(i)
     151        boundslatfi_glo(k,north_east)=rlatv(j-1)
     152        boundslonfi_glo(k,north_west)=rlonu(i+1)
     153        boundslatfi_glo(k,north_west)=rlatv(j-1)
     154        boundslonfi_glo(k,south_west)=rlonu(i+1)
     155        boundslatfi_glo(k,south_west)=rlatv(j)
     156        boundslonfi_glo(k,south_east)=rlonu(i)
     157        boundslatfi_glo(k,south_east)=rlatv(j)
    131158      ENDDO
    132159    ENDDO
    133160    ! South pole
    134     latfi(klon_glo)= rlatu(jjm+1)
    135     lonfi(klon_glo)= 0.
    136     cufi(klon_glo) = cu((iim+1)*jjm+1)
    137     cvfi(klon_glo) = cv((iim+1)*jjm-iim)
     161    latfi_glo(klon_glo)= rlatu(jjm+1)
     162    lonfi_glo(klon_glo)= 0.
     163    cufi_glo(klon_glo) = cu((iim+1)*jjm+1)
     164    cvfi_glo(klon_glo) = cv((iim+1)*jjm-iim)
     165    boundslonfi_glo(klon_glo,north_east)= 0
     166    boundslatfi_glo(klon_glo,north_east)= rlatv(jjm)
     167    boundslonfi_glo(klon_glo,north_west)= 2*PI
     168    boundslatfi_glo(klon_glo,north_west)= rlatv(jjm)
     169    boundslonfi_glo(klon_glo,south_west)= 2*PI
     170    boundslatfi_glo(klon_glo,south_west)= -PI/2
     171    boundslonfi_glo(klon_glo,south_east)= 0
     172    boundslatfi_glo(klon_glo,south_east)= -Pi/2
    138173
    139174    ! build airefi(), mesh area on physics grid
    140     CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,airefi)
     175    CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,airefi_glo)
    141176    ! Poles are single points on physics grid
    142     airefi(1)=sum(aire(1:iim,1))
    143     airefi(klon_glo)=sum(aire(1:iim,jjm+1))
     177    airefi_glo(1)=sum(aire(1:iim,1))
     178    airefi_glo(klon_glo)=sum(aire(1:iim,jjm+1))
    144179
    145180    ! Sanity check: do total planet area match between physics and dynamics?
    146181    total_area_dyn=sum(aire(1:iim,1:jjm+1))
    147     total_area_phy=sum(airefi(1:klon_glo))
     182    total_area_phy=sum(airefi_glo(1:klon_glo))
    148183    IF (total_area_dyn/=total_area_phy) THEN
    149184      WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
     
    158193
    159194!$OMP PARALLEL
     195  ! Now generate local lon/lat/cu/cv/area/bounds arrays
     196  ALLOCATE(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp))
     197  ALLOCATE(airefi(klon_omp))
     198  ALLOCATE(boundslonfi(klon_omp,4))
     199  ALLOCATE(boundslatfi(klon_omp,4))
     200
     201
     202  offset = klon_mpi_begin - 1
     203  airefi(1:klon_omp) = airefi_glo(offset+klon_omp_begin:offset+klon_omp_end)
     204  cufi(1:klon_omp) = cufi_glo(offset+klon_omp_begin:offset+klon_omp_end)
     205  cvfi(1:klon_omp) = cvfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
     206  lonfi(1:klon_omp) = lonfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
     207  latfi(1:klon_omp) = latfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
     208  boundslonfi(1:klon_omp,:) = boundslonfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
     209  boundslatfi(1:klon_omp,:) = boundslatfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
     210
     211  ! copy over local grid longitudes and latitudes
     212  CALL init_geometry(klon_omp,lonfi,latfi,boundslonfi,boundslatfi, &
     213                     airefi,cufi,cvfi)
     214
    160215  ! Initialize physical constants in physics:
    161216  CALL inifis(prad,pg,pr,pcpp)
     
    164219  CALL init_infotrac_phy(nqtot,type_trac)
    165220
    166   ! Now generate local lon/lat/cu/cv/area arrays
    167   CALL initcomgeomphy
    168 
    169   offset = klon_mpi_begin - 1
    170   airephy(1:klon_omp) = airefi(offset+klon_omp_begin:offset+klon_omp_end)
    171   cuphy(1:klon_omp) = cufi(offset+klon_omp_begin:offset+klon_omp_end)
    172   cvphy(1:klon_omp) = cvfi(offset+klon_omp_begin:offset+klon_omp_end)
    173   rlond(1:klon_omp) = lonfi(offset+klon_omp_begin:offset+klon_omp_end)
    174   rlatd(1:klon_omp) = latfi(offset+klon_omp_begin:offset+klon_omp_end)
    175 
    176221  ! Additional initializations for aquaplanets
    177222  IF (iflag_phys>=100) THEN
    178     CALL iniaqua(klon_omp,rlatd,rlond,iflag_phys)
     223    CALL iniaqua(klon_omp,iflag_phys)
    179224  ENDIF
    180225!$OMP END PARALLEL
Note: See TracChangeset for help on using the changeset viewer.