Changeset 594


Ignore:
Timestamp:
10/18/17 18:46:11 (7 years ago)
Author:
dubos
Message:

devel : diagnose energy fluxes

Location:
codes/icosagcm/devel/src
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/devel/src/diagnostics/diagflux.F90

    r593 r594  
    11MODULE diagflux_mod 
    22  USE icosa 
     3  USE omp_para 
    34  IMPLICIT NONE 
    45  SAVE 
    5    
    6   TYPE(t_field),POINTER :: & 
     6  PRIVATE 
     7 
     8  TYPE(t_field), POINTER, PUBLIC :: & 
    79       f_masst(:), f_qmasst(:), & ! time-averaged mass, tracer mass,  
    810       f_massfluxt(:), f_qfluxt(:), & ! time-integrated mass flux and tracer flux 
     
    1315  !$OMP THREADPRIVATE(diagflux_on) 
    1416 
     17  PUBLIC :: diagflux_on, init_diagflux, zero_qfluxt, qflux_centered_lonlat, flux_centered_lonlat, diagflux_energy 
     18 
    1519CONTAINS 
    1620 
     
    2024    diagflux_on = .FALSE. 
    2125    CALL getin("diagflux", diagflux_on) 
    22     ll = MERGE(ll,0,diagflux_on) 
     26    ll = MERGE(llm,1,diagflux_on) 
    2327    CALL allocate_field(f_masst,         field_t,type_real,ll,       name="masst") 
    2428    CALL allocate_field(f_epot,          field_t,type_real,ll,       name="epot") 
     
    3640  END SUBROUTINE init_diagflux 
    3741 
     42#define ZERO2(field) buf2=field(ind) ; buf2(:,ll_begin:ll_end)=0. 
     43#define ZERO3(field) buf3=field(ind) ; buf3(:,ll_begin:ll_end,:)=0. 
     44 
    3845  SUBROUTINE zero_qfluxt 
    39     USE omp_para 
    4046    INTEGER :: ind 
    4147    REAL(rstd), POINTER :: buf2(:,:),buf3(:,:,:) 
     
    4349       IF (.NOT. assigned_domain(ind)) CYCLE 
    4450       CALL swap_dimensions(ind) 
    45        buf2=f_masst(ind) 
    46        buf2(:,ll_begin:ll_end)=0. 
    47        buf2=f_massfluxt(ind) 
    48        buf2(:,ll_begin:ll_end)=0. 
    49        buf3=f_qmasst(ind) 
    50        buf3(:,ll_begin:ll_end,:)=0. 
    51        buf3=f_qfluxt(ind) 
    52        buf3(:,ll_begin:ll_end,:)=0. 
     51       ZERO2(f_masst) 
     52       ZERO2(f_epot) 
     53       ZERO2(f_ekin) 
     54       ZERO2(f_enthalpy) 
     55       ZERO3(f_qmasst) 
     56       ZERO2(f_massfluxt) 
     57       ZERO2(f_epotfluxt) 
     58       ZERO2(f_ekinfluxt) 
     59       ZERO2(f_enthalpyfluxt) 
     60       ZERO3(f_qfluxt) 
    5361    END DO 
    5462  END SUBROUTINE zero_qfluxt 
    5563 
    56   SUBROUTINE flux_centered_lonlat(scale, f_massflux, f_flux, f_massflux_lon, f_massflux_lat, f_flux_lon, f_flux_lat) 
     64!------------------------------------ Reconstruct fluxes at cell centers --------------------------------------- 
     65 
     66  SUBROUTINE qflux_centered_lonlat(scale, f_flux, f_flux_lon, f_flux_lat) 
    5767    REAL(rstd), INTENT(IN) :: scale 
    58     TYPE(t_field),POINTER :: f_flux(:), f_flux_lon(:), f_flux_lat(:), & 
    59          f_massflux(:), f_massflux_lon(:), f_massflux_lat(:) 
    60     REAL(rstd), POINTER :: flux(:,:,:), flux_lon(:,:,:), flux_lat(:,:,:), & 
    61          massflux(:,:), massflux_lon(:,:), massflux_lat(:,:) 
     68    TYPE(t_field),POINTER :: f_flux(:), f_flux_lon(:), f_flux_lat(:) 
     69    REAL(rstd), POINTER :: flux(:,:,:), flux_lon(:,:,:), flux_lat(:,:,:) 
    6270    INTEGER :: ind, itrac 
    6371    DO ind=1,ndomain 
     
    7179          CALL compute_flux_centered_lonlat(scale, flux(:,:,itrac), flux_lon(:,:,itrac), flux_lat(:,:,itrac)) 
    7280       END DO 
    73        massflux=f_massflux(ind) 
    74        massflux_lon=f_massflux_lon(ind) 
    75        massflux_lat=f_massflux_lat(ind) 
    76        CALL compute_flux_centered_lonlat(scale, massflux, massflux_lon, massflux_lat) 
     81    END DO 
     82  END SUBROUTINE qflux_centered_lonlat 
     83   
     84  SUBROUTINE flux_centered_lonlat(scale, f_flux, f_flux_lon, f_flux_lat) 
     85    REAL(rstd), INTENT(IN) :: scale 
     86    TYPE(t_field),POINTER :: f_flux(:), f_flux_lon(:), f_flux_lat(:) 
     87    REAL(rstd), POINTER :: flux(:,:), flux_lon(:,:), flux_lat(:,:) 
     88    INTEGER :: ind 
     89    DO ind=1,ndomain 
     90       IF (.NOT. assigned_domain(ind)) CYCLE 
     91       CALL swap_dimensions(ind) 
     92       CALL swap_geometry(ind) 
     93       flux=f_flux(ind) 
     94       flux_lon=f_flux_lon(ind) 
     95       flux_lat=f_flux_lat(ind) 
     96       CALL compute_flux_centered_lonlat(scale, flux, flux_lon, flux_lat) 
    7797    END DO 
    7898  END SUBROUTINE flux_centered_lonlat 
     
    88108  END SUBROUTINE compute_flux_centered_lonlat 
    89109 
     110!------------------------------------ Compute energy fluxes --------------------------------------- 
     111 
     112  SUBROUTINE diagflux_energy(frac, f_phis,f_rhodz,f_theta_rhodz,f_u, f_geopot,f_theta, f_hfluxt) 
     113    REAL(rstd), INTENT(IN) :: frac 
     114    TYPE(t_field),POINTER :: f_phis(:),f_rhodz(:),f_theta_rhodz(:),f_u(:), f_geopot(:), f_theta(:), f_hfluxt(:) 
     115    REAL(rstd), POINTER :: phis(:), rhodz(:,:), theta_rhodz(:,:,:), u(:,:), & 
     116         geopot(:,:), pk(:,:,:), hfluxt(:,:), & 
     117         epot(:,:), ekin(:,:), enthalpy(:,:), & 
     118         epotflux(:,:), ekinflux(:,:), enthalpyflux(:,:) 
     119    INTEGER :: ind 
     120    DO ind=1,ndomain 
     121       IF (.NOT. assigned_domain(ind)) CYCLE 
     122       CALL swap_dimensions(ind) 
     123       CALL swap_geometry(ind) 
     124       hfluxt = f_hfluxt(ind) 
     125       phis = f_phis(ind) 
     126       rhodz = f_rhodz(ind) 
     127       theta_rhodz = f_theta_rhodz(ind) 
     128       u = f_u(ind) 
     129       geopot = f_geopot(ind) 
     130       pk = f_theta(ind) ! buffer 
     131       epot = f_epot(ind) 
     132       ekin = f_ekin(ind) 
     133       enthalpy = f_enthalpy(ind) 
     134       epotflux = f_epotfluxt(ind) 
     135       ekinflux = f_ekinfluxt(ind) 
     136       enthalpyflux = f_enthalpyfluxt(ind) 
     137       CALL compute_diagflux_energy(frac,hfluxt, phis,rhodz,theta_rhodz,u, geopot,pk, epot,ekin,enthalpy, epotflux, ekinflux, enthalpyflux) 
     138    END DO 
     139  END SUBROUTINE diagflux_energy 
     140 
     141  SUBROUTINE compute_diagflux_energy(frac, massflux, phis,rhodz,theta_rhodz,u, geopot,pk, epot,ekin,enthalpy, epot_flux, ekin_flux, enthalpy_flux) 
     142    USE disvert_mod, ONLY : ptop 
     143    REAL(rstd), INTENT(IN) :: frac 
     144    REAL(rstd), INTENT(IN) :: massflux(3*iim*jjm,llm), u(3*iim*jjm,llm),& 
     145                              phis(iim*jjm), rhodz(iim*jjm,llm), theta_rhodz(iim*jjm,llm,nqtot) 
     146    REAL(rstd), INTENT(INOUT) :: geopot(iim*jjm,llm+1), pk(iim*jjm,llm) ! pk = buffer 
     147    REAL(rstd), INTENT(INOUT), DIMENSION(iim*jjm, llm)   ::  epot, ekin, enthalpy 
     148    REAL(rstd), INTENT(INOUT), DIMENSION(3*iim*jjm, llm) ::  epot_flux, ekin_flux, enthalpy_flux     
     149    REAL(rstd) :: energy, p_ik, theta_ik, temp_ik, gv, Rd  
     150    INTEGER :: ij, l, ij_omp_begin_ext, ij_omp_end_ext 
     151    Rd = kappa*cpp 
     152    CALL distrib_level(ij_end_ext-ij_begin_ext+1,ij_omp_begin_ext,ij_omp_end_ext) 
     153    ij_omp_begin_ext = ij_omp_begin_ext+ij_begin_ext-1 
     154    ij_omp_end_ext = ij_omp_end_ext+ij_begin_ext-1 
     155#include "../kernels/energy_fluxes.k90" 
     156  END SUBROUTINE compute_diagflux_energy 
     157 
    90158END MODULE diagflux_mod 
  • codes/icosagcm/devel/src/diagnostics/observable.f90

    r592 r594  
    163163    IF(.NOT. init) THEN 
    164164       IF(diagflux_on) THEN 
     165          CALL flux_centered_lonlat(1./(itau_out*dt) , f_massfluxt, f_buf_ulon, f_buf_ulat) 
    165166          CALL output_field("mass_t", f_masst) 
    166           CALL output_field("qmass_t", f_qmasst) 
    167           CALL flux_centered_lonlat(1./(itau_out*dt) , f_massfluxt, f_qfluxt, & 
    168                f_buf_ulon, f_buf_ulat, f_qfluxt_lon, f_qfluxt_lat) 
    169167          CALL output_field("massflux_lon",f_buf_ulon) 
    170168          CALL output_field("massflux_lat",f_buf_ulat) 
     169          CALL flux_centered_lonlat(1./(itau_out*dt) , f_epotfluxt, f_buf_ulon, f_buf_ulat) 
     170          CALL output_field("epot_t", f_epot) 
     171          CALL output_field("epotflux_lon",f_buf_ulon) 
     172          CALL output_field("epotflux_lat",f_buf_ulat) 
     173          CALL flux_centered_lonlat(1./(itau_out*dt) , f_ekinfluxt, f_buf_ulon, f_buf_ulat) 
     174          CALL output_field("ekin_t", f_ekin) 
     175          CALL output_field("ekinflux_lon",f_buf_ulon) 
     176          CALL output_field("ekinflux_lat",f_buf_ulat) 
     177          CALL flux_centered_lonlat(1./(itau_out*dt) , f_enthalpyfluxt, f_buf_ulon, f_buf_ulat) 
     178          CALL output_field("enthalpy_t", f_enthalpy) 
     179          CALL output_field("enthalpyflux_lon",f_buf_ulon) 
     180          CALL output_field("enthalpyflux_lat",f_buf_ulat) 
     181          CALL qflux_centered_lonlat(1./(itau_out*dt) , f_qfluxt, f_qfluxt_lon, f_qfluxt_lat) 
     182          CALL output_field("qmass_t", f_qmasst) 
    171183          CALL output_field("qflux_lon",f_qfluxt_lon) 
    172184          CALL output_field("qflux_lat",f_qfluxt_lat) 
  • codes/icosagcm/devel/src/time/timeloop_gcm.f90

    r592 r594  
    273273          CALL HEVI_scheme(it, fluxt_zero) 
    274274       END SELECT 
    275         
     275 
    276276       IF (MOD(it,itau_dissip)==0) THEN 
    277277           
     
    304304        
    305305       IF(MOD(it,itau_adv)==0) THEN 
     306          IF(diagflux_on) CALL diagflux_energy(adv_over_out, f_phis,f_rhodz,f_theta_rhodz,f_u, f_geopot,f_theta, f_hfluxt) 
    306307          CALL advect_tracer(f_hfluxt,f_wfluxt,f_u, f_q,f_rhodz, & ! update q and rhodz after RK step 
    307308               adv_over_out, f_masst,f_qmasst,f_massfluxt, f_qfluxt)  ! accumulate mass and fluxes if diagflux_on 
    308           fluxt_zero=.TRUE. 
    309           ! FIXME : check that rhodz is consistent with ps 
    310           IF (check_rhodz) THEN 
     309          fluxt_zero=.TRUE. ! restart accumulation of hfluxt and qfluxt at next call to explicit_scheme / HEVI_scheme 
     310          IF (check_rhodz) THEN ! check that rhodz is consistent with ps 
    311311             DO ind=1,ndomain 
    312312                IF (.NOT. assigned_domain(ind)) CYCLE 
  • codes/icosagcm/devel/src/transport/advect.F90

    r590 r594  
    444444#include "../kernels/advect_horiz.k90" 
    445445    CALL trace_end("compute_advect_horiz") 
    446   CONTAINS 
    447  
    448     !==================================================================================== 
    449     PURE REAL(rstd) FUNCTION sum2(a1,a2) 
    450       IMPLICIT NONE 
    451       REAL(rstd),INTENT(IN):: a1(3), a2(3) 
    452       sum2 = a1(1)*a2(1)+a1(2)*a2(2)+a1(3)*a2(3) 
    453       ! sum2 = 0. ! Godunov scheme 
    454     END FUNCTION sum2 
    455  
    456446  END SUBROUTINE compute_advect_horiz 
    457447 
Note: See TracChangeset for help on using the changeset viewer.