Ignore:
Timestamp:
10/31/14 14:52:01 (10 years ago)
Author:
ymipsl
Message:

Merging OpenMP parallisme mode : by subdomain and on vertical level.
This feature is actually experimental but may be retro-compatible with the last method based only on subdomain

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/trunk/src/theta_rhodz.f90

    r186 r295  
    11MODULE theta2theta_rhodz_mod 
     2  USE field_mod 
     3   
     4  TYPE(t_field), POINTER, SAVE  :: f_p(:) 
     5  TYPE(t_field), POINTER, SAVE  :: f_pks(:) 
     6  TYPE(t_field), POINTER, SAVE  :: f_pk(:) 
     7 
     8  PRIVATE :: f_p,f_pk,f_pks  
    29 
    310CONTAINS 
    411   
     12  SUBROUTINE init_theta2theta_rhodz 
     13  USE icosa 
     14  USE field_mod 
     15  IMPLICIT NONE 
     16    CALL allocate_field(f_p,field_t,type_real,llm+1,name='p') 
     17    CALL allocate_field(f_pk,field_t,type_real,llm,name='pk') 
     18    CALL allocate_field(f_pks,field_t,type_real,name='pks') 
     19     
     20  END SUBROUTINE init_theta2theta_rhodz 
     21 
     22 
     23 
    524  SUBROUTINE theta_rhodz2theta(f_ps,f_theta_rhodz,f_theta) 
    625  USE icosa 
     
    1534    INTEGER :: ind 
    1635 
     36!$OMP BARRIER 
    1737    DO ind=1,ndomain 
    1838      IF (.NOT. assigned_domain(ind)) CYCLE 
     
    2444      CALL compute_theta_rhodz2theta(ps, theta_rhodz,theta,0) 
    2545    ENDDO 
     46!$OMP BARRIER 
    2647   
    2748  END SUBROUTINE theta_rhodz2theta 
     
    2950  SUBROUTINE theta_rhodz2temperature(f_ps,f_theta_rhodz,f_temp) 
    3051  USE icosa 
     52  USE pression_mod 
     53  USE exner_mod 
    3154  IMPLICIT NONE 
    3255    TYPE(t_field), POINTER :: f_ps(:) 
     
    3760    REAL(rstd), POINTER :: theta_rhodz(:,:) 
    3861    REAL(rstd), POINTER :: temp(:,:) 
    39     INTEGER :: ind 
    40  
    41     DO ind=1,ndomain 
    42       IF (.NOT. assigned_domain(ind)) CYCLE 
    43       CALL swap_dimensions(ind) 
    44       CALL swap_geometry(ind) 
    45       ps=f_ps(ind) 
     62    REAL(rstd), POINTER :: p(:) 
     63    REAL(rstd), POINTER :: pk(:,:) 
     64    REAL(rstd), POINTER :: pks(:,:) 
     65    INTEGER :: ind 
     66 
     67    DO ind=1,ndomain 
     68      IF (.NOT. assigned_domain(ind)) CYCLE 
     69      CALL swap_dimensions(ind) 
     70      CALL swap_geometry(ind) 
     71      ps=f_ps(ind) 
     72      p=f_p(ind) 
     73      pks=f_pks(ind) 
     74      pk=f_pk(ind) 
    4675      theta_rhodz=f_theta_rhodz(ind) 
    4776      temp=f_temp(ind) 
    48       CALL compute_theta_rhodz2temperature(ps, theta_rhodz,temp,0) 
    49     ENDDO 
     77 
     78!$OMP BARRIER 
     79      CALL compute_pression(ps,p,0) 
     80!$OMP BARRIER 
     81      CALL compute_exner(ps,p,pks,pk,0) 
     82!$OMP BARRIER 
     83      CALL compute_theta_rhodz2temperature(p, pk, theta_rhodz,temp,0) 
     84    ENDDO 
     85!$OMP BARRIER 
    5086   
    5187  END SUBROUTINE theta_rhodz2temperature 
     88  
     89  SUBROUTINE temperature2theta_rhodz(f_ps,f_temp,f_theta_rhodz) 
     90  USE icosa 
     91  USE pression_mod 
     92  USE exner_mod 
     93  IMPLICIT NONE 
     94    TYPE(t_field), POINTER :: f_ps(:) 
     95    TYPE(t_field), POINTER :: f_theta_rhodz(:) 
     96    TYPE(t_field), POINTER :: f_temp(:) 
     97   
     98    REAL(rstd), POINTER :: ps(:) 
     99    REAL(rstd), POINTER :: theta_rhodz(:,:) 
     100    REAL(rstd), POINTER :: temp(:,:) 
     101    REAL(rstd), POINTER :: p(:) 
     102    REAL(rstd), POINTER :: pk(:,:) 
     103    REAL(rstd), POINTER :: pks(:,:) 
     104    INTEGER :: ind 
     105 
     106    DO ind=1,ndomain 
     107      IF (.NOT. assigned_domain(ind)) CYCLE 
     108      CALL swap_dimensions(ind) 
     109      CALL swap_geometry(ind) 
     110      ps=f_ps(ind) 
     111      p=f_p(ind) 
     112      pks=f_pks(ind) 
     113      pk=f_pk(ind) 
     114      theta_rhodz=f_theta_rhodz(ind) 
     115      temp=f_temp(ind) 
     116 
     117!$OMP BARRIER 
     118      CALL compute_pression(ps,p,0) 
     119!$OMP BARRIER 
     120      CALL compute_exner(ps,p,pks,pk,0) 
     121!$OMP BARRIER 
     122      CALL compute_temperature2theta_rhodz(p, pk, temp, theta_rhodz, 0) 
     123    ENDDO 
     124!$OMP BARRIER 
     125   
     126  END SUBROUTINE temperature2theta_rhodz 
     127  
     128  
    52129     
    53130  SUBROUTINE theta2theta_rhodz(f_ps,f_theta,f_theta_rhodz) 
     
    63140    INTEGER :: ind 
    64141 
     142!$OMP BARRIER 
    65143    DO ind=1,ndomain 
    66144      IF (.NOT. assigned_domain(ind)) CYCLE 
     
    72150      CALL compute_theta2theta_rhodz(ps, theta, theta_rhodz,0) 
    73151    ENDDO 
     152!$OMP BARRIER 
    74153   
    75154  END SUBROUTINE theta2theta_rhodz 
     
    77156  SUBROUTINE compute_theta2theta_rhodz(ps,theta, theta_rhodz,offset) 
    78157  USE icosa 
    79   USE pression_mod 
     158  USE disvert_mod 
     159  USE omp_para 
    80160  IMPLICIT NONE 
    81161    REAL(rstd),INTENT(IN) :: ps(iim*jjm) 
     
    84164    INTEGER,INTENT(IN) :: offset 
    85165    INTEGER :: i,j,ij,l 
    86     REAL(rstd),ALLOCATABLE,SAVE :: p(:,:) 
    87 !$OMP THREADPRIVATE(p) 
    88  
    89     ALLOCATE( p(iim*jjm,llm+1)) 
    90     CALL compute_pression(ps,p,offset) 
    91      
    92     DO    l    = 1, llm 
    93       DO j=jj_begin-offset,jj_end+offset 
    94         DO i=ii_begin-offset,ii_end+offset 
    95           ij=(j-1)*iim+i 
    96           theta_rhodz(ij,l) = theta(ij,l) * (p(ij,l)-p(ij,l+1))/g 
    97         ENDDO 
    98       ENDDO 
    99     ENDDO 
    100  
    101     DEALLOCATE( p) 
     166     
     167!$OMP BARRIER 
     168    DO    l    = ll_begin, ll_end 
     169      DO j=jj_begin-offset,jj_end+offset 
     170        DO i=ii_begin-offset,ii_end+offset 
     171          ij=(j-1)*iim+i 
     172          theta_rhodz(ij,l) = theta(ij,l) * ( (ap(l)-ap(l+1)) + ( bp(l)- bp(l+1))* ps(ij) )/g 
     173        ENDDO 
     174      ENDDO 
     175    ENDDO 
     176!$OMP BARRIER 
     177 
    102178 
    103179  END SUBROUTINE compute_theta2theta_rhodz 
     
    105181  SUBROUTINE compute_theta_rhodz2theta(ps,theta_rhodz,theta,offset) 
    106182  USE icosa 
    107   USE pression_mod 
     183  USE disvert_mod 
     184  USE omp_para 
    108185  IMPLICIT NONE 
    109186    REAL(rstd),INTENT(IN) :: ps(iim*jjm) 
     
    112189    INTEGER,INTENT(IN) :: offset 
    113190    INTEGER :: i,j,ij,l 
    114     REAL(rstd),SAVE,ALLOCATABLE :: p(:,:) 
    115 !$OMP THREADPRIVATE(p) 
    116  
    117     ALLOCATE( p(iim*jjm,llm+1)) 
    118  
    119     CALL compute_pression(ps,p,offset) 
    120      
    121     DO    l    = 1, llm 
    122       DO j=jj_begin-offset,jj_end+offset 
    123         DO i=ii_begin-offset,ii_end+offset 
    124           ij=(j-1)*iim+i 
    125           theta(ij,l) = theta_rhodz(ij,l) / ((p(ij,l)-p(ij,l+1))/g) 
    126         ENDDO 
    127       ENDDO 
    128     ENDDO 
    129  
    130     DEALLOCATE( p) 
     191 
     192!$OMP BARRIER 
     193    DO    l    = ll_begin, ll_end 
     194      DO j=jj_begin-offset,jj_end+offset 
     195        DO i=ii_begin-offset,ii_end+offset 
     196          ij=(j-1)*iim+i 
     197          theta(ij,l) = theta_rhodz(ij,l) / ( (ap(l)-ap(l+1)) + ( bp(l)- bp(l+1))* ps(ij) )/g 
     198        ENDDO 
     199      ENDDO 
     200    ENDDO 
     201!$OMP BARRIER 
     202 
    131203     
    132204  END SUBROUTINE compute_theta_rhodz2theta 
    133205 
    134   SUBROUTINE compute_theta_rhodz2temperature(ps,theta_rhodz,temp,offset) 
    135   USE icosa 
    136   USE pression_mod 
    137   USE exner_mod 
    138   IMPLICIT NONE 
    139     REAL(rstd),INTENT(IN) :: ps(iim*jjm) 
     206 
     207 
     208 
     209 
     210 
     211  SUBROUTINE compute_theta_rhodz2temperature(p,pk,theta_rhodz,temp,offset) 
     212  USE icosa 
     213  USE pression_mod 
     214  USE exner_mod 
     215  USE omp_para 
     216  IMPLICIT NONE 
     217    REAL(rstd),INTENT(IN) :: p(iim*jjm,llm+1) 
     218    REAL(rstd),INTENT(IN) :: pk(iim*jjm,llm) 
    140219    REAL(rstd),INTENT(IN) :: theta_rhodz(iim*jjm,llm) 
    141220    REAL(rstd),INTENT(OUT) :: temp(iim*jjm,llm) 
    142221    INTEGER,INTENT(IN) :: offset 
    143222    INTEGER :: i,j,ij,l 
    144     REAL(rstd) :: p(iim*jjm,llm+1) 
    145     REAL(rstd) :: pk(iim*jjm,llm) 
    146     REAL(rstd) :: pks(iim*jjm) 
    147  
    148     CALL compute_pression(ps,p,offset) 
    149     CALL compute_exner(ps,p,pks,pk,offset) 
    150223         
    151     DO    l    = 1, llm 
     224! flush p 
     225!$OMP BARRIER 
     226    DO    l    = ll_begin, ll_end 
    152227      DO j=jj_begin-offset,jj_end+offset 
    153228        DO i=ii_begin-offset,ii_end+offset 
     
    157232      ENDDO 
    158233    ENDDO 
     234!$OMP BARRIER 
     235     
    159236     
    160237  END SUBROUTINE compute_theta_rhodz2temperature 
    161238 
    162   SUBROUTINE compute_temperature2theta_rhodz(ps,temp,theta_rhodz,offset) 
    163   USE icosa 
    164   USE pression_mod 
    165   USE exner_mod 
    166   IMPLICIT NONE 
    167     REAL(rstd),INTENT(IN) :: ps(iim*jjm) 
     239  SUBROUTINE compute_temperature2theta_rhodz(p,pk,temp,theta_rhodz,offset) 
     240  USE icosa 
     241  USE pression_mod 
     242  USE exner_mod 
     243  USE omp_para 
     244  IMPLICIT NONE 
     245    REAL(rstd),INTENT(IN)  :: p(iim*jjm,llm+1) 
     246    REAL(rstd),INTENT(IN)  :: pk(iim*jjm,llm) 
    168247    REAL(rstd),INTENT(OUT) :: theta_rhodz(iim*jjm,llm) 
    169     REAL(rstd),INTENT(IN) :: temp(iim*jjm,llm) 
    170     INTEGER,INTENT(IN) :: offset 
    171     INTEGER :: i,j,ij,l 
    172     REAL(rstd) :: p(iim*jjm,llm+1) 
    173     REAL(rstd) :: pk(iim*jjm,llm) 
    174     REAL(rstd) :: pks(iim*jjm) 
    175  
    176     CALL compute_pression(ps,p,offset) 
    177     CALL compute_exner(ps,p,pks,pk,offset) 
     248    REAL(rstd),INTENT(IN)  :: temp(iim*jjm,llm) 
     249    INTEGER,INTENT(IN) :: offset 
     250    INTEGER :: i,j,ij,l 
     251 
    178252         
    179     DO    l    = 1, llm 
     253! flush p 
     254!$OMP BARRIER 
     255 
     256    DO    l    = ll_begin, ll_end 
    180257      DO j=jj_begin-offset,jj_end+offset 
    181258        DO i=ii_begin-offset,ii_end+offset 
     
    185262      ENDDO 
    186263    ENDDO 
     264!$OMP BARRIER 
    187265     
    188266  END SUBROUTINE compute_temperature2theta_rhodz 
Note: See TracChangeset for help on using the changeset viewer.