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

Location:
LMDZ5/trunk/libf/phy_common
Files:
1 added
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • LMDZ5/trunk/libf/phy_common/mod_grid_phy_lmdz.F90

    r2326 r2351  
    88             grid2dTo1d_glo_igen, grid2dTo1d_glo_rgen, grid2dTo1d_glo_lgen
    99 
     10  INTEGER,PARAMETER :: unstructured=0
     11  INTEGER,PARAMETER :: regular_lonlat=1
     12
     13  INTEGER,SAVE :: grid_type
     14  INTEGER,SAVE :: nvertex
    1015  INTEGER,SAVE :: nbp_lon  ! == iim
    11   INTEGER,SAVE :: nbp_lat  ! == jjmp1
     16  INTEGER,SAVE :: nbp_lat  ! == jjmp1 (or == 1 if running 1D model)
    1217  INTEGER,SAVE :: nbp_lev  ! == llm
    13   INTEGER,SAVE :: klon_glo
     18  INTEGER,SAVE :: klon_glo ! total number of atmospheric columns
    1419
    1520  INTERFACE grid1dTo2d_glo
     
    3237
    3338
    34   SUBROUTINE Init_grid_phy_lmdz(iim,jjp1,llm)
     39  SUBROUTINE init_grid_phy_lmdz(grid_type_,nvertex_,nbp_lon_,nbp_lat_,nbp_lev_)
    3540  IMPLICIT NONE
    36   INTEGER, INTENT(in) :: iim
    37   INTEGER, INTENT(in) :: jjp1
    38   INTEGER, INTENT(in) :: llm
    39  
    40     nbp_lon=iim
    41     nbp_lat=jjp1
    42     nbp_lev=llm
    43     klon_glo=(iim*jjp1)-2*(iim-1)
    44  
    45   END SUBROUTINE Init_grid_phy_lmdz
     41  INTEGER,INTENT(IN)  :: grid_type_
     42  INTEGER,INTENT(IN)  :: nvertex_
     43  INTEGER, INTENT(IN) :: nbp_lon_
     44  INTEGER, INTENT(IN) :: nbp_lat_
     45  INTEGER, INTENT(IN) :: nbp_lev_
     46 
     47    grid_type = grid_type_
     48    nvertex   = nvertex_
     49    nbp_lon   = nbp_lon_
     50    nbp_lat   = nbp_lat_
     51    nbp_lev   = nbp_lev_
     52   
     53    IF (nbp_lon*nbp_lat==1) THEN
     54      klon_glo=1
     55    ELSE   
     56      klon_glo=(nbp_lon*nbp_lat)-2*(nbp_lon-1)
     57    ENDIF
     58 
     59  END SUBROUTINE init_grid_phy_lmdz
    4660 
    4761 
  • LMDZ5/trunk/libf/phy_common/mod_phys_lmdz_mpi_data.F90

    r2326 r2351  
    33!
    44MODULE mod_phys_lmdz_mpi_data
    5   USE mod_const_mpi
     5!  USE mod_const_mpi
    66 
    77  INTEGER,SAVE :: ii_begin
     
    3535  INTEGER,SAVE :: mpi_rank
    3636  INTEGER,SAVE :: mpi_size
    37   INTEGER,SAVE :: mpi_root
     37  INTEGER,SAVE :: mpi_master
     38!  INTEGER,SAVE :: mpi_root
    3839  LOGICAL,SAVE :: is_mpi_root
    3940  LOGICAL,SAVE :: is_using_mpi
     
    4344  LOGICAL,SAVE :: is_south_pole
    4445  INTEGER,SAVE :: COMM_LMDZ_PHY
     46  INTEGER,SAVE :: MPI_REAL_LMDZ   ! MPI_REAL8
    4547
    4648CONTAINS
    4749 
    48   SUBROUTINE Init_phys_lmdz_mpi_data(iim,jjp1,nb_proc,distrib)
    49   USE mod_const_mpi, ONLY : COMM_LMDZ
     50!  SUBROUTINE Init_phys_lmdz_mpi_data(iim,jjp1,nb_proc,distrib)
     51  SUBROUTINE init_phys_lmdz_mpi_data(nbp, nbp_lon, nbp_lat, communicator)
     52!  USE mod_const_mpi, ONLY : COMM_LMDZ
    5053  IMPLICIT NONE
    51     INTEGER,INTENT(in) :: iim
    52     INTEGER,INTENT(in) :: jjp1
    53     INTEGER,INTENT(in) :: nb_proc
    54     INTEGER,INTENT(in) :: distrib(0:nb_proc-1)
    55    
     54#ifdef CPP_MPI
     55    INCLUDE 'mpif.h'
     56#endif
     57    INTEGER,INTENT(in) :: nbp
     58    INTEGER,INTENT(in) :: nbp_lon
     59    INTEGER,INTENT(in) :: nbp_lat
     60    INTEGER,INTENT(in) :: communicator
     61   
     62    INTEGER,ALLOCATABLE :: distrib(:)
    5663    INTEGER :: ierr
    5764    INTEGER :: klon_glo
     
    6471#endif
    6572   
    66     if (iim.eq.1) then
     73    if ((nbp_lon.eq.1).and.(nbp_lat.eq.1)) then ! running 1D column model
    6774       klon_glo=1
    6875    else
    69        klon_glo=iim*(jjp1-2)+2
     76    ! The usual global physics grid: 1 point for each pole and nbp_lon points
     77    ! for all other latitudes
     78       klon_glo=nbp_lon*(nbp_lat-2)+2
    7079    endif
    7180   
    72     COMM_LMDZ_PHY=COMM_LMDZ
     81    COMM_LMDZ_PHY=communicator
    7382
    7483    IF (is_using_mpi) THEN   
    7584#ifdef CPP_MPI
     85      MPI_REAL_LMDZ=MPI_REAL8
    7686      CALL MPI_COMM_SIZE(COMM_LMDZ_PHY,mpi_size,ierr)   
    7787      CALL MPI_COMM_RANK(COMM_LMDZ_PHY,mpi_rank,ierr)
     
    8292    ENDIF
    8393   
     94    ALLOCATE(distrib(0:mpi_size-1))
     95
     96    IF (is_using_mpi) THEN   
     97#ifdef CPP_MPI
     98    CALL MPI_ALLGATHER(nbp,1,MPI_INTEGER,distrib,1,MPI_INTEGER,COMM_LMDZ_PHY,ierr)
     99#endif
     100    ELSE
     101     distrib(:)=nbp
     102    ENDIF
     103
     104
    84105    IF (mpi_rank == 0) THEN
    85       mpi_root = 0
     106      mpi_master = 0
    86107      is_mpi_root = .true.
    87108    ENDIF
     
    115136 
    116137     
    117     klon_mpi_para_nb(0:mpi_size-1)=distrib(0:nb_proc-1)
     138    klon_mpi_para_nb(0:mpi_size-1)=distrib(0:mpi_size-1)
    118139
    119140    DO i=0,mpi_size-1
     
    132153        ij_para_begin(i) = 1
    133154      ELSE
    134         ij_para_begin(i) = klon_mpi_para_begin(i)+iim-1
     155        ij_para_begin(i) = klon_mpi_para_begin(i)+nbp_lon-1
    135156      ENDIF
    136157
    137       jj_para_begin(i) = (ij_para_begin(i)-1)/iim + 1
    138       ii_para_begin(i) = MOD(ij_para_begin(i)-1,iim) + 1
     158      jj_para_begin(i) = (ij_para_begin(i)-1)/nbp_lon + 1
     159      ii_para_begin(i) = MOD(ij_para_begin(i)-1,nbp_lon) + 1
    139160
    140161     
    141       ij_para_end(i) = klon_mpi_para_end(i)+iim-1
    142       jj_para_end(i) = (ij_para_end(i)-1)/iim + 1
    143       ii_para_end(i) = MOD(ij_para_end(i)-1,iim) + 1
     162      ij_para_end(i) = klon_mpi_para_end(i)+nbp_lon-1
     163      jj_para_end(i) = (ij_para_end(i)-1)/nbp_lon + 1
     164      ii_para_end(i) = MOD(ij_para_end(i)-1,nbp_lon) + 1
    144165
    145166
     
    166187
    167188  SUBROUTINE print_module_data
     189  USE print_control_mod, ONLY: lunout
    168190  IMPLICIT NONE
    169   INCLUDE "iniprint.h"
     191!  INCLUDE "iniprint.h"
    170192 
    171193    WRITE(lunout,*) 'ii_begin =', ii_begin
     
    193215    WRITE(lunout,*) 'mpi_rank =', mpi_rank
    194216    WRITE(lunout,*) 'mpi_size =', mpi_size
    195     WRITE(lunout,*) 'mpi_root =', mpi_root
     217    WRITE(lunout,*) 'mpi_master =', mpi_master
    196218    WRITE(lunout,*) 'is_mpi_root =', is_mpi_root
    197219    WRITE(lunout,*) 'is_north_pole =', is_north_pole
  • LMDZ5/trunk/libf/phy_common/mod_phys_lmdz_mpi_transfert.F90

    r2326 r2351  
    12361236
    12371237  SUBROUTINE bcast_mpi_cgen(var,nb)
    1238     USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
     1238    USE mod_phys_lmdz_mpi_data
    12391239    IMPLICIT NONE
    12401240   
     
    12501250   
    12511251#ifdef CPP_MPI
    1252     CALL MPI_BCAST(Var,nb,MPI_CHARACTER,mpi_root_x,COMM_LMDZ_PHY,ierr)
     1252    CALL MPI_BCAST(Var,nb,MPI_CHARACTER,mpi_master,COMM_LMDZ_PHY,ierr)
    12531253#endif
    12541254       
     
    12581258     
    12591259  SUBROUTINE bcast_mpi_igen(var,nb)
    1260     USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
     1260    USE mod_phys_lmdz_mpi_data
    12611261    IMPLICIT NONE
    12621262   
     
    12721272
    12731273#ifdef CPP_MPI
    1274     CALL MPI_BCAST(Var,nb,MPI_INTEGER,mpi_root_x,COMM_LMDZ_PHY,ierr)
     1274    CALL MPI_BCAST(Var,nb,MPI_INTEGER,mpi_master,COMM_LMDZ_PHY,ierr)
    12751275#endif
    12761276       
     
    12811281 
    12821282  SUBROUTINE bcast_mpi_rgen(var,nb)
    1283     USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
     1283    USE mod_phys_lmdz_mpi_data
    12841284    IMPLICIT NONE
    12851285   
     
    12951295
    12961296#ifdef CPP_MPI
    1297     CALL MPI_BCAST(Var,nb,MPI_REAL_LMDZ,mpi_root_x,COMM_LMDZ_PHY,ierr)
     1297    CALL MPI_BCAST(Var,nb,MPI_REAL_LMDZ,mpi_master,COMM_LMDZ_PHY,ierr)
    12981298#endif
    12991299   
     
    13041304
    13051305  SUBROUTINE bcast_mpi_lgen(var,nb)
    1306     USE mod_phys_lmdz_mpi_data ,  mpi_root_x=>mpi_root
     1306    USE mod_phys_lmdz_mpi_data
    13071307    IMPLICIT NONE
    13081308   
     
    13181318
    13191319#ifdef CPP_MPI
    1320     CALL MPI_BCAST(Var,nb,MPI_LOGICAL,mpi_root_x,COMM_LMDZ_PHY,ierr)
     1320    CALL MPI_BCAST(Var,nb,MPI_LOGICAL,mpi_master,COMM_LMDZ_PHY,ierr)
    13211321#endif
    13221322
     
    13261326
    13271327  SUBROUTINE scatter_mpi_igen(VarIn, VarOut, dimsize)
    1328     USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
     1328    USE mod_phys_lmdz_mpi_data
    13291329    USE mod_grid_phy_lmdz
    13301330    IMPLICIT NONE
     
    13651365#ifdef CPP_MPI
    13661366    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_INTEGER,VarOut,klon_mpi*dimsize,   &
    1367                       MPI_INTEGER,mpi_root_x, COMM_LMDZ_PHY,ierr)
     1367                      MPI_INTEGER,mpi_master, COMM_LMDZ_PHY,ierr)
    13681368#endif
    13691369
     
    13711371
    13721372  SUBROUTINE scatter_mpi_rgen(VarIn, VarOut, dimsize)
    1373     USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
     1373    USE mod_phys_lmdz_mpi_data
    13741374    USE mod_grid_phy_lmdz
    13751375    IMPLICIT NONE
     
    14091409#ifdef CPP_MPI
    14101410    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_REAL_LMDZ,VarOut,klon_mpi*dimsize,   &
    1411                       MPI_REAL_LMDZ,mpi_root_x, COMM_LMDZ_PHY,ierr)
     1411                      MPI_REAL_LMDZ,mpi_master, COMM_LMDZ_PHY,ierr)
    14121412
    14131413#endif
     
    14171417 
    14181418  SUBROUTINE scatter_mpi_lgen(VarIn, VarOut, dimsize)
    1419     USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
     1419    USE mod_phys_lmdz_mpi_data
    14201420    USE mod_grid_phy_lmdz
    14211421    IMPLICIT NONE
     
    14551455#ifdef CPP_MPI
    14561456    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_LOGICAL,VarOut,klon_mpi*dimsize,   &
    1457                       MPI_LOGICAL,mpi_root_x, COMM_LMDZ_PHY,ierr)
     1457                      MPI_LOGICAL,mpi_master, COMM_LMDZ_PHY,ierr)
    14581458#endif
    14591459
     
    14641464
    14651465  SUBROUTINE gather_mpi_igen(VarIn, VarOut, dimsize)
    1466     USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
     1466    USE mod_phys_lmdz_mpi_data
    14671467    USE mod_grid_phy_lmdz
    14681468    IMPLICIT NONE
     
    15001500#ifdef CPP_MPI
    15011501    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_INTEGER,VarTmp,counts,displs,   &
    1502                      MPI_INTEGER,mpi_root_x, COMM_LMDZ_PHY,ierr)
     1502                     MPI_INTEGER,mpi_master, COMM_LMDZ_PHY,ierr)
    15031503#endif
    15041504
     
    15181518
    15191519  SUBROUTINE gather_mpi_rgen(VarIn, VarOut, dimsize)
    1520     USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
     1520    USE mod_phys_lmdz_mpi_data
    15211521    USE mod_grid_phy_lmdz
    15221522    IMPLICIT NONE
     
    15531553#ifdef CPP_MPI
    15541554    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_REAL_LMDZ,VarTmp,counts,displs,   &
    1555                       MPI_REAL_LMDZ,mpi_root_x, COMM_LMDZ_PHY,ierr)
     1555                      MPI_REAL_LMDZ,mpi_master, COMM_LMDZ_PHY,ierr)
    15561556#endif
    15571557                         
     
    15701570
    15711571  SUBROUTINE gather_mpi_lgen(VarIn, VarOut, dimsize)
    1572     USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
     1572    USE mod_phys_lmdz_mpi_data
    15731573    USE mod_grid_phy_lmdz
    15741574    IMPLICIT NONE
     
    16061606#ifdef CPP_MPI
    16071607    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_LOGICAL,VarTmp,counts,displs,   &
    1608                       MPI_LOGICAL,mpi_root_x, COMM_LMDZ_PHY,ierr)
     1608                      MPI_LOGICAL,mpi_master, COMM_LMDZ_PHY,ierr)
    16091609#endif
    16101610                         
     
    16251625
    16261626  SUBROUTINE reduce_sum_mpi_igen(VarIn,VarOut,nb)
    1627     USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
     1627    USE mod_phys_lmdz_mpi_data
    16281628    USE mod_grid_phy_lmdz
    16291629    IMPLICIT NONE
     
    16451645
    16461646#ifdef CPP_MPI
    1647     CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_INTEGER,MPI_SUM,mpi_root_x,COMM_LMDZ_PHY,ierr)
     1647    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_INTEGER,MPI_SUM,mpi_master,COMM_LMDZ_PHY,ierr)
    16481648#endif
    16491649           
     
    16511651 
    16521652  SUBROUTINE reduce_sum_mpi_rgen(VarIn,VarOut,nb)
    1653     USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
     1653    USE mod_phys_lmdz_mpi_data
    16541654    USE mod_grid_phy_lmdz
    16551655
     
    16711671   
    16721672#ifdef CPP_MPI
    1673     CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_REAL_LMDZ,MPI_SUM,mpi_root_x,COMM_LMDZ_PHY,ierr)
     1673    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_REAL_LMDZ,MPI_SUM,mpi_master,COMM_LMDZ_PHY,ierr)
    16741674#endif
    16751675       
     
    19011901
    19021902END MODULE mod_phys_lmdz_mpi_transfert
     1903
  • LMDZ5/trunk/libf/phy_common/mod_phys_lmdz_para.F90

    r2326 r2351  
    1616CONTAINS
    1717
    18   SUBROUTINE Init_phys_lmdz_para(iim,jjp1,nb_proc,distrib)
     18  SUBROUTINE Init_phys_lmdz_para(nbp,nbp_lon,nbp_lat,communicator)
    1919  IMPLICIT NONE
    20     INTEGER,INTENT(in) :: iim
    21     INTEGER,INTENT(in) :: jjp1
    22     INTEGER,INTENT(in) :: nb_proc
    23     INTEGER,INTENT(in) :: distrib(0:nb_proc-1)
     20    INTEGER,INTENT(in) :: nbp
     21    INTEGER,INTENT(in) :: nbp_lon
     22    INTEGER,INTENT(in) :: nbp_lat
     23    INTEGER,INTENT(in) :: communicator
    2424
    25     CALL Init_phys_lmdz_mpi_data(iim,jjp1,nb_proc,distrib)
     25    CALL Init_phys_lmdz_mpi_data(nbp,nbp_lon,nbp_lat,communicator)
    2626!$OMP PARALLEL
    2727    CALL Init_phys_lmdz_omp_data(klon_mpi)
  • LMDZ5/trunk/libf/phy_common/physics_distribution_mod.F90

    r2348 r2351  
    11!
    2 !$Header$
     2!$Id$
    33!
    4 SUBROUTINE Init_Phys_lmdz(iim,jjp1,llm,nb_proc,distrib)
    5   USE mod_phys_lmdz_para, ONLY: Init_phys_lmdz_para, klon_omp
    6   USE mod_grid_phy_lmdz, ONLY: Init_grid_phy_lmdz, nbp_lev
    7   USE dimphy, ONLY : Init_dimphy
    8   USE infotrac_phy, ONLY : type_trac
    9 #ifdef REPROBUS
    10   USE CHEM_REP, ONLY : Init_chem_rep_phys
    11 #endif
    12 
    13   IMPLICIT NONE
    14  
    15     INTEGER,INTENT(in) :: iim
    16     INTEGER,INTENT(in) :: jjp1
    17     INTEGER,INTENT(in) :: llm
    18     INTEGER,INTENT(in) :: nb_proc
    19     INTEGER,INTENT(in) :: distrib(0:nb_proc-1)
     4MODULE physics_distribution_mod
    205
    216
    22     CALL Init_grid_phy_lmdz(iim,jjp1,llm)
    23     CALL Init_phys_lmdz_para(iim,jjp1,nb_proc,distrib)
    24 !$OMP PARALLEL
    25     CALL Init_dimphy(klon_omp,nbp_lev)
     7CONTAINS
    268
    27 ! Initialization of Reprobus
    28     IF (type_trac == 'repr') THEN
    29 #ifdef REPROBUS
    30        CALL Init_chem_rep_phys(klon_omp,nbp_lev)
    31 #endif
    32     END IF
     9  SUBROUTINE init_physics_distribution(grid_type, nvertex, &
     10                                       nbp, nbp_lon, nbp_lat, nbp_lev, &
     11                                       communicator)
     12  USE mod_phys_lmdz_para, ONLY: init_phys_lmdz_para
     13  USE mod_grid_phy_lmdz, ONLY: init_grid_phy_lmdz
     14  IMPLICIT NONE
     15    INTEGER,INTENT(IN) :: grid_type
     16    INTEGER,INTENT(IN) :: nvertex
     17    INTEGER,INTENT(IN) :: nbp           
     18    INTEGER,INTENT(IN) :: nbp_lon
     19    INTEGER,INTENT(IN) :: nbp_lat
     20    INTEGER,INTENT(IN) :: nbp_lev
     21    INTEGER,INTENT(IN) :: communicator
    3322
    34 !$OMP END PARALLEL
     23
     24    CALL init_grid_phy_lmdz(grid_type,nvertex, nbp_lon,nbp_lat,nbp_lev)
     25    CALL init_phys_lmdz_para(nbp,nbp_lon, nbp_lat, communicator)
     26
     27  END SUBROUTINE init_physics_distribution 
     28
     29!SUBROUTINE Init_Phys_lmdz(iim,jjp1,llm,nb_proc,distrib)
     30!  USE mod_phys_lmdz_para, ONLY: Init_phys_lmdz_para!, klon_omp
     31!  USE mod_grid_phy_lmdz, ONLY: Init_grid_phy_lmdz!, nbp_lev
     32!  USE dimphy, ONLY : Init_dimphy
     33!  USE infotrac_phy, ONLY : type_trac
     34!#ifdef REPROBUS
     35!  USE CHEM_REP, ONLY : Init_chem_rep_phys
     36!#endif
     37
     38!  IMPLICIT NONE
     39 
     40!    INTEGER,INTENT(in) :: iim
     41!    INTEGER,INTENT(in) :: jjp1
     42!    INTEGER,INTENT(in) :: llm
     43!    INTEGER,INTENT(in) :: nb_proc
     44!    INTEGER,INTENT(in) :: distrib(0:nb_proc-1)
     45
     46
     47!    CALL Init_grid_phy_lmdz(iim,jjp1,llm)
     48!    CALL Init_phys_lmdz_para(iim,jjp1,nb_proc,distrib)
     49!!$OMP PARALLEL
     50!    CALL Init_dimphy(klon_omp,nbp_lev)
     51!
     52!! Initialization of Reprobus
     53!    IF (type_trac == 'repr') THEN
     54!#ifdef REPROBUS
     55!       CALL Init_chem_rep_phys(klon_omp,nbp_lev)
     56!#endif
     57!    END IF
     58!
     59!!$OMP END PARALLEL
    3560 
    36 END SUBROUTINE Init_Phys_lmdz 
     61!END SUBROUTINE Init_Phys_lmdz 
     62
     63
     64
     65
     66
     67
     68
     69
     70END MODULE physics_distribution_mod
     71
Note: See TracChangeset for help on using the changeset viewer.