Changeset 668


Ignore:
Timestamp:
01/27/18 00:10:07 (6 years ago)
Author:
dubos
Message:

trunk : compute and output physics tendencies on the dynamics side

Location:
codes/icosagcm/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/trunk/src/diagnostics/observable.f90

    r605 r668  
    1515  TYPE(t_field),POINTER, SAVE :: f_theta(:) 
    1616 
    17   PUBLIC init_observable, write_output_fields_basic, f_theta, f_buf_i 
     17  PUBLIC init_observable, write_output_fields_basic, &  
     18       f_theta, f_buf_i, f_buf_ulon, f_buf_ulat 
    1819 
    1920CONTAINS 
  • codes/icosagcm/trunk/src/diagnostics/wind.F90

    r599 r668  
    1212CONTAINS 
    1313 
    14   SUBROUTINE un2ulonlat(f_u, f_ulon, f_ulat) 
     14  SUBROUTINE un2ulonlat(f_u, f_ulon, f_ulat, scale_) 
    1515    TYPE(t_field), POINTER :: f_u(:) ! IN  : normal velocity components on edges 
    1616    TYPE(t_field), POINTER :: f_ulon(:), f_ulat(:) ! OUT : velocity reconstructed at hexagons     
    17     REAL(rstd),POINTER :: u(:,:),  ulon(:,:), ulat(:,:) 
     17    REAL(rstd),POINTER     :: u(:,:),  ulon(:,:), ulat(:,:) 
     18    REAL(rstd), OPTIONAL   :: scale_  
     19    REAL(rstd)             :: scale 
    1820    INTEGER :: ind 
    19  
     21    scale = MERGE(scale_, 1., PRESENT(scale_)) 
    2022    DO ind=1,ndomain 
    2123       IF (.NOT. assigned_domain(ind)) CYCLE 
     
    2527       ulon=f_ulon(ind) 
    2628       ulat=f_ulat(ind) 
    27        CALL compute_un2ulonlat(u,ulon, ulat) 
     29       CALL compute_un2ulonlat(u,ulon, ulat, scale) 
    2830    END DO 
    2931 
     
    4951  END SUBROUTINE ulonlat2un 
    5052  
    51   SUBROUTINE compute_wind_centered(ue,ucenter) 
     53  SUBROUTINE compute_wind_centered(ue,ucenter,scale_) 
    5254  REAL(rstd) :: ue(3*iim*jjm,llm) 
    5355  REAL(rstd) :: ucenter(iim*jjm,llm,3) 
     56  REAL(rstd), INTENT(IN), OPTIONAL :: scale_ 
    5457  INTEGER :: ij,l 
    55   REAL(rstd), PARAMETER :: scale=1. 
    56   REAL(rstd) :: fac, ue_le, cx,cy,cz, ux,uy,uz 
     58  REAL(rstd) :: scale,fac, ue_le, cx,cy,cz, ux,uy,uz 
     59  scale = MERGE(scale_, 1., PRESENT(scale_)) 
    5760#include "../kernels/wind_centered.k90" 
    5861 END SUBROUTINE compute_wind_centered 
     
    328331 
    329332 
    330  SUBROUTINE compute_un2ulonlat(un, ulon, ulat) 
     333 SUBROUTINE compute_un2ulonlat(un, ulon, ulat, scale) 
    331334  REAL(rstd),INTENT(IN)  :: un(3*iim*jjm,llm) 
    332335  REAL(rstd),INTENT(OUT) :: ulon(iim*jjm,llm) 
    333336  REAL(rstd),INTENT(OUT) :: ulat(iim*jjm,llm) 
    334  
    335337  REAL(rstd)             :: uc(iim*jjm,llm,3) 
    336      
    337   CALL compute_wind_centered(un,uc 
     338  REAL(rstd)             :: scale 
     339  CALL compute_wind_centered(un,uc,scale) 
    338340  CALL compute_wind_centered_lonlat_compound(uc, ulon, ulat) 
    339341  
  • codes/icosagcm/trunk/src/icosa_init.f90

    r667 r668  
    5858 
    5959    CALL init_diagflux 
     60    CALL zero_du_phys 
    6061    CALL timeloop 
    6162    CALL switch_omp_no_distrib_level 
  • codes/icosagcm/trunk/src/physics/physics.f90

    r599 r668  
    11MODULE physics_mod 
    2  
     2  USE icosa 
    33  USE field_mod 
    4  
     4  USE physics_interface_mod 
     5  USE omp_para 
     6  IMPLICIT NONE 
    57  PRIVATE 
    68 
     
    1416  TYPE(t_field),POINTER,SAVE :: f_p(:), f_pk(:) 
    1517  TYPE(t_field),POINTER,SAVE :: f_temp(:) 
     18  TYPE(t_field),POINTER,SAVE :: f_du_phys(:) 
    1619 
    1720  CHARACTER(LEN=255),SAVE :: physics_type 
    1821!$OMP THREADPRIVATE(physics_type) 
    1922 
    20   PUBLIC :: physics, init_physics 
     23  PUBLIC :: physics, init_physics, zero_du_phys 
    2124 
    2225CONTAINS 
     
    2528    USE mpipara 
    2629    USE etat0_mod 
    27     USE icosa 
    28     USE physics_interface_mod 
    2930    USE physics_dcmip_mod, ONLY : init_physics_dcmip=>init_physics 
    3031    USE physics_dcmip2016_mod, ONLY : init_physics_dcmip2016=>init_physics 
     
    3233    USE physics_lmdz_generic_mod, ONLY : init_physics_lmdz_generic=>init_physics 
    3334    USE physics_external_mod, ONLY : init_physics_external=>init_physics 
    34     IMPLICIT NONE 
    3535 
    3636    physics_inout%dt_phys = dt*itau_physics 
     
    8484    END SELECT 
    8585 
     86    CALL allocate_field(f_du_phys,field_u,type_real,llm, name='du_phys') 
     87 
    8688    IF(is_mpi_root) PRINT *, 'phys_type = ',phys_type 
    8789  END SUBROUTINE init_physics 
    8890 
     91  SUBROUTINE zero_du_phys() 
     92    REAL(rstd), DIMENSION(:,:), POINTER :: du 
     93    INTEGER :: ind 
     94    DO ind=1,ndomain 
     95       IF (.NOT. assigned_domain(ind)) CYCLE 
     96       CALL swap_dimensions(ind) 
     97       CALL swap_geometry(ind) 
     98       du=f_du_phys(ind) 
     99       du(:,ll_begin:ll_end) = 0. 
     100    END DO 
     101  END SUBROUTINE zero_du_phys 
     102 
     103  SUBROUTINE add_du_phys(coef, f_u) 
     104    REAL(rstd), INTENT(IN) :: coef  ! -1 before physics, +1 after physics 
     105    TYPE(t_field),POINTER :: f_u(:) ! velocity field before/after call to physics 
     106    REAL(rstd), DIMENSION(:,:), POINTER :: u, du 
     107    INTEGER :: ind 
     108    DO ind=1,ndomain 
     109       IF (.NOT. assigned_domain(ind)) CYCLE 
     110       CALL swap_dimensions(ind) 
     111       CALL swap_geometry(ind) 
     112       du=f_du_phys(ind) 
     113       u=f_u(ind) 
     114       du(:,ll_begin:ll_end) = du(:,ll_begin:ll_end) + coef*u(:,ll_begin:ll_end) 
     115    END DO 
     116  END SUBROUTINE add_du_phys 
     117 
    89118  SUBROUTINE physics(it,f_phis, f_ps, f_theta_rhodz, f_ue, f_wflux, f_q) 
    90     USE icosa 
    91     USE physics_interface_mod 
    92119    USE physics_lmdz_generic_mod, ONLY : physics_lmdz_generic => physics 
    93120    USE physics_external_mod, ONLY : physics_external => physics 
     
    96123    USE etat0_heldsz_mod 
    97124    USE etat0_venus_mod, ONLY : phys_venus => physics 
    98     IMPLICIT NONE 
    99125    INTEGER, INTENT(IN)   :: it 
    100126    TYPE(t_field),POINTER :: f_phis(:) 
     
    109135    TYPE(t_physics_inout) :: args 
    110136 
    111     IF(MOD(it,itau_physics)==0) THEN 
    112      
     137    IF(MOD(it,itau_physics)==0 .AND. phys_type/=phys_none) THEN 
     138 
     139       ! as a result of the the two calls to add_du_phys, 
     140       ! du_phys increases by u(after physics) - u (before physics) 
     141       CALL add_du_phys(-1., f_ue) 
     142 
    113143       SELECT CASE(phys_type) 
    114        CASE (phys_none) 
    115           ! No physics, do nothing 
    116144       CASE(phys_HS94) 
    117145          CALL held_suarez(f_ps,f_theta_rhodz,f_ue)  
     
    129157       CALL transfert_request(f_ue,req_e0_vect) 
    130158       CALL transfert_request(f_q,req_i0) 
     159 
     160       CALL add_du_phys(1., f_ue) 
    131161    END IF 
    132162 
    133163    IF (mod(it,itau_out)==0 ) THEN 
     164       CALL write_physics_tendencies 
     165       CALL zero_du_phys 
    134166       SELECT CASE(phys_type) 
    135167       CASE (phys_DCMIP) 
     
    142174  END SUBROUTINE physics 
    143175 
     176  SUBROUTINE write_physics_tendencies 
     177    USE observable_mod, ONLY : f_buf_ulon, f_buf_ulat 
     178    USE wind_mod 
     179    USE output_field_mod 
     180    CALL transfert_request(f_du_phys,req_e1_vect) 
     181    CALL un2ulonlat(f_du_phys, f_buf_ulon, f_buf_ulat, (1./(dt*itau_out))) 
     182    CALL output_field("dulon_phys",f_buf_ulon) 
     183    CALL output_field("dulat_phys",f_buf_ulat) 
     184  END SUBROUTINE write_physics_tendencies 
     185     
    144186  SUBROUTINE physics_column(it, f_phis, f_ps, f_theta_rhodz, f_ue, f_q) 
    145     USE icosa 
    146     USE physics_interface_mod 
    147187    USE physics_dcmip_mod, ONLY : full_physics_dcmip => full_physics 
    148188    USE physics_dcmip2016_mod, ONLY : full_physics_dcmip2016 => full_physics 
    149189    USE theta2theta_rhodz_mod 
    150190    USE mpipara 
    151     USE omp_para 
    152191    USE checksum_mod 
    153     IMPLICIT NONE 
    154192    TYPE(t_field),POINTER :: f_phis(:) 
    155193    TYPE(t_field),POINTER :: f_ps(:) 
     
    229267 
    230268  SUBROUTINE pack_physics(info, phis, ps, temp, ue, q, p, pk, ulon, ulat ) 
    231     USE icosa 
    232269    USE wind_mod 
    233270    USE pression_mod 
    234271    USE theta2theta_rhodz_mod 
    235     USE physics_interface_mod 
    236272    USE exner_mod 
    237     USE omp_para 
    238     IMPLICIT NONE 
    239273    TYPE(t_pack_info) :: info 
    240274    REAL(rstd) :: phis(iim*jjm) 
     
    272306 
    273307  SUBROUTINE unpack_physics(info, ps,temp, q, dulon, dulat) 
    274     USE icosa 
    275     USE physics_interface_mod 
    276308    USE theta2theta_rhodz_mod 
    277     USE omp_para 
    278     IMPLICIT NONE 
    279309    TYPE(t_pack_info) :: info 
    280310    REAL(rstd) :: ps(iim*jjm) 
     
    303333 
    304334  SUBROUTINE compute_update_velocity(dulon, dulat, ue) 
    305     USE icosa 
    306     USE physics_interface_mod 
    307335    USE wind_mod 
    308     USE omp_para 
    309     IMPLICIT NONE 
    310336    REAL(rstd) :: dulon(iim*jjm,llm) 
    311337    REAL(rstd) :: dulat(iim*jjm,llm) 
Note: See TracChangeset for help on using the changeset viewer.