Ignore:
Timestamp:
04/09/18 15:22:10 (6 years ago)
Author:
dubos
Message:

devel/unstructured : select double or single precision for physical quantities

File:
1 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/devel/src/unstructured/data_unstructured.F90

    r683 r688  
    55  SAVE 
    66 
    7 #define BINDC_(thename) BIND(C, name=#thename) 
    8 #define BINDC(thename) BINDC_(dynamico_ ## thename) 
    9  
    10 #define DBL REAL(C_DOUBLE) 
    11 #define DOUBLE1(m) DBL, DIMENSION(m) 
    12 #define DOUBLE2(m,n) DBL, DIMENSION(m,n) 
    13 #define DOUBLE3(m,n,p) DBL, DIMENSION(m,n,p) 
    14 #define DOUBLE4(m,n,p,q) DBL, DIMENSION(m,n,p,q) 
    15 #define INDEX INTEGER(C_INT) 
     7  #include "unstructured.h90" 
    168 
    179  INTEGER, PARAMETER :: eta_mass=1, eta_lag=2, & 
     
    3426  ! circulation is positive when going from down to up 
    3527 
    36   DBL, BIND(C) :: elapsed, g, ptop, cpp, cppv, Rd, Rv, preff, Treff, & 
    37       pbot, Phi_bot, rho_bot 
    38   DBL :: kappa 
    39   DOUBLE1(max_nb_stage), BIND(C)              :: tauj       ! diagonal of fast Butcher tableau 
    40   DOUBLE2(max_nb_stage,max_nb_stage), BIND(C) :: cslj, cflj ! slow and fast modified Butcher tableaus 
    41   DOUBLE1(:), ALLOCATABLE            :: le_de, fv, Av, Ai 
    42   DOUBLE2(:,:), ALLOCATABLE          :: Riv2, wee, ap,bp, mass_bl, mass_dak, mass_dbk 
     28  TIME, BIND(C) :: elapsed 
     29  NUM, BIND(C) :: g, ptop, cpp, cppv, Rd, Rv, preff, Treff, pbot, Phi_bot, rho_bot 
     30  NUM :: kappa 
     31  NUM1(max_nb_stage), BIND(C)              :: tauj       ! diagonal of fast Butcher tableau 
     32  NUM2(max_nb_stage,max_nb_stage), BIND(C) :: cslj, cflj ! slow and fast modified Butcher tableaus 
     33  NUM1(:), ALLOCATABLE            :: le_de, fv, Av, Ai 
     34  NUM2(:,:), ALLOCATABLE          :: Riv2, wee, ap,bp, mass_bl, mass_dak, mass_dbk 
    4335 
    4436  INTEGER(C_INT), BIND(C) :: comm_icosa 
     
    4739       id_pvort_only=3, id_slow_hydro=4, id_fast=5, id_coriolis=6, id_theta=7, id_geopot=8, id_vert=9, & 
    4840       id_solver=10, id_slow_NH=11, id_NH_geopot=12, id_vert_NH=13, id_update=14, nb_routines=14  
    49   DBL, PRIVATE :: start_time, time_spent(nb_routines) ! time spent in each kernel 
     41  TIME, PRIVATE :: start_time, time_spent(nb_routines) ! time spent in each kernel 
    5042  INTEGER, PRIVATE :: current_id, nb_calls(nb_routines) 
    5143  INTEGER(KIND=8), PRIVATE :: bytes(nb_routines) ! bytes read or written by each kernel 
     
    6153          num(:), & ! number of cells to send to / receive from other MPI ranks 
    6254          cells(:) ! local indices of cells to send/receive 
    63      DBL, ALLOCATABLE :: buf2(:,:) 
     55     NUM, ALLOCATABLE :: buf2(:,:) 
    6456  END TYPE Halo_transfer 
    6557  TYPE(Halo_transfer), TARGET :: send_info(transfer_max), recv_info(transfer_max) 
     
    7971  SUBROUTINE print_trace() 
    8072    INTEGER :: id 
    81     DBL :: total_spent 
     73    TIME :: total_spent 
    8274    !$OMP MASTER 
    8375    total_spent=SUM(time_spent) 
     
    10698 
    10799  SUBROUTINE exit_trace() 
    108     DBL :: elapsed 
     100    TIME :: elapsed 
    109101    !$OMP MASTER 
    110102    elapsed = OMP_GET_WTIME()-start_time 
     
    180172  END SUBROUTINE init_mesh 
    181173 
     174  ! Input arrays to init_metric and init_hybrid are declared DBL 
     175  ! => always float64 on the Python side 
     176  ! They are copied to Fortran arrays of type NUM (float or double) 
     177 
    182178  SUBROUTINE init_metric(Ai_, Av_, fv_, le_de_, Riv2_, wee_) BINDC(init_metric) 
    183     DOUBLE1(primal_num) :: Ai_ 
    184     DOUBLE1(dual_num)   :: Av_, fv_ 
    185     DOUBLE1(edge_num)   :: le_de_ 
    186     DOUBLE2(max_dual_deg,dual_num) :: Riv2_ 
    187     DOUBLE2(max_trisk_deg,edge_num) :: wee_ 
     179    DBL :: Ai_(primal_num), Av_(dual_num), fv_(dual_num), le_de_(edge_num), & 
     180         Riv2_(max_dual_deg,dual_num), wee_(max_trisk_deg,edge_num) 
    188181    PRINT *, 'init_metric ...' 
    189182    ALLOC1(Ai,primal_num) 
     
    235228  ! 
    236229  SUBROUTINE init_hybrid(bl,dak,dbk) BINDC(init_hybrid) 
    237     DOUBLE2(llm+1, primal_num) :: bl 
    238     DOUBLE2(llm, primal_num) :: dak,dbk 
     230    DBL :: bl(llm+1, primal_num), & 
     231         dak(llm, primal_num), dbk(llm, primal_num) 
    239232    PRINT *, 'Setting hybrid coefficients ...' 
    240233    ALLOC2(mass_bl, llm+1, primal_num) 
Note: See TracChangeset for help on using the changeset viewer.