Ignore:
Timestamp:
07/15/19 12:29:31 (5 years ago)
Author:
adurocher
Message:

trunk : GPU implementation with OpenACC ( merge from glcp.idris.fr )

File:
1 moved

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/trunk/src/time/timeloop_gcm.F90

    r933 r953  
    9494    END SELECT 
    9595     
     96    IF (scheme_family /= hevi) THEN 
     97       CALL abort_acc("scheme_family /= hevi") 
     98    END IF 
     99 
    96100    ! Time-independant orography 
    97101    CALL allocate_field(f_phis,field_t,type_real,name='phis') 
     
    103107    CALL allocate_field(f_u,field_u,type_real,llm,name='u') 
    104108    CALL allocate_field(f_geopot,field_t,type_real,llm+1,name='geopot') 
    105     CALL allocate_field(f_W,field_t,type_real,llm+1,name='W') 
     109    CALL allocate_field(f_W,field_t,type_real,llm+1,name='W') ! used only if .not. hydrostatic 
    106110    CALL allocate_field(f_q,field_t,type_real,llm,nqtot,'q') 
    107111    ! Mass fluxes 
    108     CALL allocate_field(f_hflux,field_u,type_real,llm)    ! instantaneous mass fluxes 
    109     CALL allocate_field(f_hfluxt,field_u,type_real,llm)   ! mass "fluxes" accumulated in time 
     112    CALL allocate_field(f_hflux,field_u,type_real,llm, ondevice=.TRUE.)    ! instantaneous mass fluxes 
     113    CALL allocate_field(f_hfluxt,field_u,type_real,llm,ondevice=.TRUE.)   ! mass "fluxes" accumulated in time 
    110114    CALL allocate_field(f_wflux,field_t,type_real,llm+1)  ! vertical mass fluxes 
    111     CALL allocate_field(f_wfluxt,field_t,type_real,llm+1,name='wfluxt') 
     115    CALL allocate_field(f_wfluxt,field_t,type_real,llm+1,name='wfluxt',ondevice=.TRUE.) 
    112116     
    113117    SELECT CASE(scheme_family) 
     
    125129    CASE(hevi) 
    126130       ! Trends 
    127        CALL allocate_fields(nb_stage,f_dps_slow, field_t,type_real,name='dps_slow') 
    128        CALL allocate_fields(nb_stage,f_dmass_slow, field_t,type_real,llm, name='dmass_slow') 
    129        CALL allocate_fields(nb_stage,f_dtheta_rhodz_slow, field_t,type_real,llm,nqdyn,name='dtheta_rhodz_fast') 
    130        CALL allocate_fields(nb_stage,f_du_slow, field_u,type_real,llm,name='du_slow') 
    131        CALL allocate_fields(nb_stage,f_du_fast, field_u,type_real,llm,name='du_fast') 
     131       CALL allocate_fields(nb_stage,f_dps_slow, field_t,type_real,name='dps_slow', ondevice=.TRUE.) 
     132       CALL allocate_fields(nb_stage,f_dmass_slow, field_t,type_real,llm, name='dmass_slow', ondevice=.TRUE.) 
     133       CALL allocate_fields(nb_stage,f_dtheta_rhodz_slow, field_t,type_real,llm,nqdyn,name='dtheta_rhodz_fast', ondevice=.TRUE.) 
     134       CALL allocate_fields(nb_stage,f_du_slow, field_u,type_real,llm,name='du_slow', ondevice=.TRUE.) 
     135       CALL allocate_fields(nb_stage,f_du_fast, field_u,type_real,llm,name='du_fast', ondevice=.TRUE.) 
    132136       CALL allocate_fields(nb_stage,f_dW_slow, field_t,type_real,llm+1,name='dW_slow') 
    133137       CALL allocate_fields(nb_stage,f_dW_fast, field_t,type_real,llm+1,name='dW_fast') 
     
    172176   
    173177  SUBROUTINE timeloop 
     178    USE abort_mod 
    174179    USE dissip_gcm_mod 
    175180    USE sponge_mod 
     
    211216       rhodz=f_rhodz(ind); mass=f_mass(ind); ps=f_ps(ind) 
    212217       IF(caldyn_eta==eta_mass) THEN 
    213           CALL compute_rhodz(.TRUE., ps, rhodz) ! save rhodz for transport scheme before dynamics update ps 
     218          CALL compute_rhodz(.TRUE., ps, rhodz, ondevice=.FALSE.) ! save rhodz for transport scheme before dynamics update ps 
    214219       ELSE 
    215220          DO l=ll_begin,ll_end 
     
    244249    CALL SYSTEM_CLOCK(start_clock, rate_clock) 
    245250    !$OMP END MASTER    
     251    call update_device_field(f_ps) 
     252    call update_device_field(f_mass) 
     253    CALL update_device_field(f_theta_rhodz) 
     254    CALL update_device_field(f_u) 
     255    CALL update_device_field(f_q) 
     256    CALL update_device_field(f_geopot) 
     257    CALL update_device_field(f_wflux) 
     258    CALL update_device_field(f_rhodz) 
     259 
    246260 
    247261    DO it=itau0+1,itau0+itaumax 
     
    263277          CALL wait_message(req_mass0) 
    264278          CALL send_message(f_theta_rhodz,req_theta_rhodz0)  
    265           CALL wait_message(req_theta_rhodz0)  
     279          CALL wait_message(req_theta_rhodz0) 
    266280          CALL send_message(f_u,req_u0) 
    267281          CALL wait_message(req_u0) 
     
    281295       SELECT CASE(scheme_family) 
    282296       CASE(explicit) 
     297          CALL abort_acc("explicit_scheme") 
    283298          CALL explicit_scheme(it, fluxt_zero) 
    284299       CASE(hevi) 
     
    298313                CALL swap_geometry(ind) 
    299314                mass=f_mass(ind); ps=f_ps(ind); 
    300                 CALL compute_rhodz(.TRUE., ps, mass) 
     315                CALL compute_rhodz(.TRUE., ps, mass, ondevice=.TRUE.) 
    301316             END DO 
    302317          ENDIF 
     
    311326          CALL euler_scheme(.FALSE.)  ! update only u, theta 
    312327          IF (iflag_sponge > 0) THEN 
     328             CALL abort_acc("iflag_sponge>0") 
    313329             CALL sponge(f_u,f_du,f_theta_rhodz,f_dtheta_rhodz) 
    314330             CALL euler_scheme(.FALSE.)  ! update only u, theta 
     
    321337       END IF 
    322338       CALL exit_profile(id_dissip) 
    323         
     339 
    324340       CALL enter_profile(id_adv) 
    325341       IF(MOD(it,itau_adv)==0) THEN 
     
    329345          ! At this point advect_tracer has obtained the halos of u and rhodz, 
    330346          ! needed for correct computation of kinetic energy 
     347          IF(diagflux_on) CALL abort_acc("diagflux_on") 
    331348          IF(diagflux_on) CALL diagflux_energy(adv_over_out, f_phis,f_rhodz,f_theta_rhodz,f_u, f_geopot,f_theta,f_buf_i, f_hfluxt) 
    332349 
     
    340357             END DO 
    341358          ENDIF 
     359          IF(positive_theta) CALL abort_acc("positive_theta") 
    342360          IF(positive_theta) CALL copy_q_to_theta(f_theta_rhodz,f_rhodz,f_q) 
    343361       END IF 
    344362       CALL exit_profile(id_adv) 
    345         
     363 
    346364       CALL enter_profile(id_diags) 
    347365!       IF (MOD(it,itau_physics)==0) THEN 
     
    360378 
    361379       IF (MOD(it,itau_check_conserv)==0) THEN 
     380          CALL update_host_field(f_ps) 
     381          CALL update_host_field(f_theta_rhodz) 
     382          CALL update_host_field(f_u) 
     383          CALL update_host_field(f_dps) 
     384          CALL update_host_field(f_q) 
    362385          CALL check_conserve_detailed(it, AAM_dyn, & 
    363386               f_ps,f_dps,f_u,f_theta_rhodz,f_phis) 
     
    367390       IF (mod(it,itau_out)==0 ) THEN 
    368391          CALL transfert_request(f_u,req_e1_vect) 
     392          CALL update_host_field(f_ps)               
     393          CALL update_host_field(f_mass) 
     394          CALL update_host_field(f_theta_rhodz) 
     395          CALL update_host_field(f_geopot) 
     396          CALL update_host_field(f_u) 
     397          CALL update_host_field(f_q) 
    369398          CALL write_output_fields_basic(.FALSE.,f_phis, f_ps, f_mass, f_geopot, f_theta_rhodz, f_u, f_W, f_q) 
    370399       ENDIF 
     
    374403    END DO 
    375404     
     405    CALL update_host_field(f_ps) 
     406    CALL update_host_field(f_theta_rhodz) 
     407    CALL update_host_field(f_u) 
     408    CALL update_host_field(f_q) 
     409    CALL update_host_field(f_geopot) 
     410 
    376411!    CALL write_etat0(itau0+itaumax,f_ps, f_phis,f_theta_rhodz,f_u,f_q)  
    377412    CALL write_etat0(itau0+itaumax,f_ps, f_phis,f_theta_rhodz,f_u,f_q, f_geopot, f_W)  
    378      
     413 
     414    CALL update_host_field(f_dps)     
    379415    CALL check_conserve_detailed(it, AAM_dyn, & 
    380416         f_ps,f_dps,f_u,f_theta_rhodz,f_phis) 
Note: See TracChangeset for help on using the changeset viewer.