Ignore:
Timestamp:
Aug 3, 2024, 2:56:58 PM (3 months ago)
Author:
abarral
Message:

Put .h into modules

File:
1 copied

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Amaury_dev/libf/phy_common/lmdz_phys_constants.f90

    r5131 r5160  
     1! Amaury 08/24: I created this module to declare some constants that were previously duplicated in several places
     2! Feel free to move this to another better-suited module.
     3MODULE lmdz_phys_constants
     4  IMPLICIT NONE; PRIVATE
     5  PUBLIC dobson_u
    16
    2 ! $Id$
    3 
    4 MODULE lmdz_phys_para
    5   USE lmdz_phys_transfert_para
    6   USE lmdz_phys_mpi_data
    7   USE lmdz_phys_omp_data
     7  REAL, PARAMETER :: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
     8END MODULE lmdz_phys_constants
    89   
    9   INTEGER,SAVE :: klon_loc
    10   LOGICAL,SAVE :: is_sequential
    11   LOGICAL,SAVE :: is_parallel
    12   LOGICAL,SAVE :: is_master
    13 
    14  
    15 !$OMP THREADPRIVATE(klon_loc,is_master)
    16  
    17 CONTAINS
    18 
    19   SUBROUTINE Init_phys_lmdz_para(nbp,nbp_lon,nbp_lat,nbp_lev,grid_type, nvertex,communicator)
    20   IMPLICIT NONE
    21     INTEGER,INTENT(IN) :: nbp
    22     INTEGER,INTENT(IN) :: nbp_lon
    23     INTEGER,INTENT(IN) :: nbp_lat
    24     INTEGER,INTENT(IN) :: nbp_lev
    25     INTEGER,INTENT(IN) :: communicator
    26     INTEGER,INTENT(IN) :: grid_type
    27     INTEGER,INTENT(IN) :: nvertex
    28 
    29     CALL Init_phys_lmdz_mpi_data(nbp,nbp_lon,nbp_lat,nbp_lev, grid_type, nvertex,communicator)
    30 !$OMP PARALLEL
    31     CALL Init_phys_lmdz_omp_data(klon_mpi)
    32     klon_loc=klon_omp
    33     IF (is_mpi_root .AND. is_omp_root) THEN
    34        is_master=.TRUE.
    35      ELSE
    36        is_master=.FALSE.
    37      ENDIF
    38 !ym     CALL Test_transfert
    39 !$OMP END PARALLEL   
    40      IF (is_using_mpi .OR. is_using_omp) THEN
    41        is_sequential=.FALSE.
    42        is_parallel=.TRUE.
    43      ELSE
    44        is_sequential=.TRUE.
    45        is_parallel=.FALSE.
    46      ENDIF
    47 
    48 
    49      
    50   END SUBROUTINE Init_phys_lmdz_para
    51 
    52   SUBROUTINE Test_transfert
    53   USE lmdz_grid_phy
    54   USE lmdz_print_control, ONLY: lunout
    55   IMPLICIT NONE
    56     REAL :: Test_Field1d_glo(klon_glo,nbp_lev)
    57     REAL :: tmp1d_glo(klon_glo,nbp_lev)
    58     REAL :: Test_Field2d_glo(nbp_lon,nbp_lat,nbp_lev)
    59     REAL :: tmp2d_glo(nbp_lon,nbp_lat,nbp_lev)
    60     REAL :: Test_Field1d_loc(klon_loc,nbp_lev)
    61     REAL :: Test_Field2d_loc(nbp_lon,jj_nb,nbp_lev)
    62     REAL :: CheckSum
    63    
    64     INTEGER :: i,l
    65  
    66     Test_Field1d_glo = 0.
    67     Test_Field2d_glo = 0.
    68     Test_Field1d_loc = 0.
    69     Test_Field2d_loc = 0.
    70  
    71     IF (is_mpi_root) THEN
    72 !$OMP MASTER
    73       DO l=1,nbp_lev
    74         DO i=1,klon_glo
    75 !          Test_Field1d_glo(i,l)=MOD(i,10)+10*(l-1)
    76            Test_Field1d_glo(i,l)=1
    77         ENDDO
    78       ENDDO
    79 !$OMP END MASTER 
    80     ENDIF
    81  
    82     CALL Scatter(Test_Field1d_glo,Test_Field1d_loc)
    83     CALL Gather(Test_Field1d_loc,tmp1d_glo)
    84  
    85     IF (is_mpi_root) THEN
    86 !$OMP MASTER 
    87       Checksum=sum(Test_Field1d_glo-tmp1d_glo)
    88       WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0"
    89 !$OMP END MASTER
    90     ENDIF
    91    
    92     CALL grid1dTo2d_glo(Test_Field1d_glo,Test_Field2d_glo)
    93     CALL scatter2D(Test_Field2d_glo,Test_Field1d_loc)
    94     CALL gather2d(Test_Field1d_loc,Test_Field2d_glo)
    95     CALL grid2dTo1d_glo(Test_Field2d_glo,tmp1d_glo)
    96 
    97     IF (is_mpi_root) THEN
    98 !$OMP MASTER 
    99       Checksum=sum(Test_Field1d_glo-tmp1d_glo)
    100       WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0"
    101 !$OMP END MASTER
    102     ENDIF
    103 
    104     CALL bcast(Test_Field1d_glo)
    105     CALL reduce_sum(Test_Field1d_glo,tmp1d_glo)
    106 
    107     IF (is_mpi_root) THEN
    108 !$OMP MASTER 
    109       Checksum=sum(Test_Field1d_glo*omp_size*mpi_size-tmp1d_glo)
    110       WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0"
    111 !$OMP END MASTER
    112     ENDIF
    113    
    114      
    115    END SUBROUTINE Test_transfert
    116  
    117 END MODULE lmdz_phys_para
    118    
Note: See TracChangeset for help on using the changeset viewer.