Ignore:
Timestamp:
Jul 22, 2024, 9:29:09 PM (4 months ago)
Author:
abarral
Message:

Replace most uses of CPP_DUST by the corresponding logical defined in lmdz_cppkeys_wrapper.F90
Convert several files from .F to .f90 to allow Dust to compile w/o rrtm/ecrad
Create lmdz_yoerad.f90
(lint) Remove "!" on otherwise empty line

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cpl_mod.F90

    r4640 r5099  
    1 !
     1
    22MODULE cpl_mod
    3 !
     3
    44! This module excahanges and transforms all fields that should be recieved or sent to
    55! coupler. The transformation of the fields are done from the grid 1D-array in phylmd
    66! to the regular 2D grid accepted by the coupler. Cumulation of the fields for each
    77! timestep is done in here.
    8 !
     8
    99! Each type of surface that recevie fields from the coupler have a subroutine named
    1010! cpl_receive_XXX_fields and each surface that have fields to be sent to the coupler
    1111! have a subroutine named cpl_send_XXX_fields.
    12 !
     12
    1313!*************************************************************************************
    1414
     
    129129 
    130130CONTAINS
    131 !
     131
    132132!************************************************************************************
    133 !
     133
    134134  SUBROUTINE cpl_init(dtime, rlon, rlat)
    135135    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_ocn_day
     
    178178!*************************************************************************************
    179179! Calculate coupling period
    180 !
     180
    181181!*************************************************************************************
    182182     
     
    191191!*************************************************************************************
    192192! Allocate variables
    193 !
     193
    194194!*************************************************************************************
    195195    error = 0
     
    324324!*************************************************************************************
    325325! Initialize the allocated varaibles
    326 !
     326
    327327!*************************************************************************************
    328328    DO ig = 1, klon
     
    332332!*************************************************************************************
    333333! Initialize coupling
    334 !
     334
    335335!*************************************************************************************
    336336    idtime = INT(dtime)
     
    341341!*************************************************************************************
    342342! initialize NetCDF output
    343 !
     343
    344344!*************************************************************************************
    345345    IF (is_sequential) THEN
     
    390390!*************************************************************************************
    391391! compatibility test
    392 !
     392
    393393!*************************************************************************************
    394394    IF (carbon_cycle_cpl .AND. version_ocean=='opa8') THEN
     
    398398
    399399  END SUBROUTINE cpl_init
    400  
    401 !
    402 !*************************************************************************************
    403 !
    404  
     400
     401!*************************************************************************************
     402
    405403  SUBROUTINE cpl_receive_frac(itime, dtime, pctsrf, is_modified)
    406404! This subroutine receives from coupler for both ocean and seaice
     
    442440! Start calculation
    443441! Get fields from coupler
    444 !
     442
    445443!*************************************************************************************
    446444
     
    510508!  Transform seaice fraction (read_sic : ocean-seaice mask) into global
    511509!  fraction (pctsrf : ocean-seaice-land-landice mask)
    512 !
     510
    513511!*************************************************************************************
    514512       CALL cpl2gath(read_sic, read_sic1D, klon, unity)
     
    530528  END SUBROUTINE cpl_receive_frac
    531529
    532 !
    533 !*************************************************************************************
    534 !
     530!*************************************************************************************
    535531
    536532  SUBROUTINE cpl_receive_ocean_fields(knon, knindex, tsurf_new, u0_new, &
    537533       v0_new, sss)
    538 !
     534
    539535! This routine returns the field for the ocean that has been read from the coupler
    540536! (done earlier with cpl_receive_frac). The field is the temperature.
    541537! The temperature is transformed into 1D array with valid points from index 1 to knon.
    542 !
     538
    543539    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_ocn_day
    544540    USE indice_sol_mod
     
    568564!*************************************************************************************
    569565! Transform read_sst into compressed 1D variable tsurf_new
    570 !
     566
    571567!*************************************************************************************
    572568    CALL cpl2gath(read_sst, tsurf_new, knon, knindex)
     
    579575! Transform read_co2 into uncompressed 1D variable fco2_ocn_day added directly in
    580576! the module carbon_cycle_mod
    581 !
     577
    582578!*************************************************************************************
    583579    IF (carbon_cycle_cpl) THEN
     
    591587! The fields received from the coupler have to be weighted with the fraction of ocean
    592588! in relation to the total sea-ice+ocean
    593 !
     589
    594590!*************************************************************************************
    595591    DO i=1, knon
     
    599595  END SUBROUTINE cpl_receive_ocean_fields
    600596
    601 !
    602 !*************************************************************************************
    603 !
     597!*************************************************************************************
    604598
    605599  SUBROUTINE cpl_receive_seaice_fields(knon, knindex, &
    606600       tsurf_new, alb_new, u0_new, v0_new)
    607 !
     601
    608602! This routine returns the fields for the seaice that have been read from the coupler
    609603! (done earlier with cpl_receive_frac). These fields are the temperature and
    610604! albedo at sea ice surface and fraction of sea ice.
    611605! The fields are transformed into 1D arrays with valid points from index 1 to knon.
    612 !
    613606
    614607! Input arguments
     
    631624!*************************************************************************************
    632625! Transform fields read from coupler from 2D into compressed 1D variables
    633 !
     626
    634627!*************************************************************************************
    635628    CALL cpl2gath(read_sit, tsurf_new, knon, knindex)
     
    642635! The fields received from the coupler have to be weighted with the sea-ice
    643636! concentration (in relation to the total sea-ice + ocean).
    644 !
     637
    645638!*************************************************************************************
    646639    DO i= 1, knon
     
    651644  END SUBROUTINE cpl_receive_seaice_fields
    652645
    653 !
    654 !*************************************************************************************
    655 !
     646!*************************************************************************************
    656647
    657648  SUBROUTINE cpl_send_ocean_fields(itime, knon, knindex, &
     
    715706! Start calculation
    716707! The ocean points are saved with second array index=1
    717 !
     708
    718709!*************************************************************************************
    719710    cpl_index = 1
     
    721712!*************************************************************************************
    722713! Reset fields to zero in the beginning of a new coupling period
    723 !
     714
    724715!*************************************************************************************
    725716    IF (MOD(itime, nexca) == 1) THEN
     
    751742!*************************************************************************************
    752743! Cumulate at each time-step
    753 !
     744
    754745!*************************************************************************************   
    755746    DO ig = 1, knon
     
    802793! fields are transformed to the 2D grid.
    803794! No sending to the coupler (it is done from cpl_send_seaice_fields).
    804 !
     795
    805796!*************************************************************************************
    806797    IF (MOD(itime, nexca) == 0) THEN
     
    915906  END SUBROUTINE cpl_send_ocean_fields
    916907
    917 !
    918 !*************************************************************************************
    919 !
     908!*************************************************************************************
    920909
    921910  SUBROUTINE cpl_send_seaice_fields(itime, dtime, knon, knindex, &
     
    924913       precip_rain, precip_snow, evap, tsurf, fder, albsol, taux, tauy,&
    925914       sens_prec_liq, sens_prec_sol, lat_prec_liq, lat_prec_sol)
    926 !
     915
    927916! This subroutine cumulates some fields for each time-step during a coupling
    928917! period. At last time-step in a coupling period the fields are transformed to the
    929918! grid accepted by the coupler. All fields for all types of surfaces are sent to
    930919! the coupler.
    931 !
     920
    932921    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl
    933922    USE indice_sol_mod
     
    962951! Start calulation
    963952! The sea-ice points are saved with second array index=2
    964 !
     953
    965954!*************************************************************************************
    966955    cpl_index = 2
     
    968957!*************************************************************************************
    969958! Reset fields to zero in the beginning of a new coupling period
    970 !
     959
    971960!*************************************************************************************
    972961    IF (MOD(itime, nexca) == 1) THEN
     
    988977!*************************************************************************************
    989978! Cumulate at each time-step
    990 !
     979
    991980!*************************************************************************************   
    992981    DO ig = 1, knon
     
    10221011! If the time-step corresponds to the end of coupling period the
    10231012! fields are transformed to the 2D grid and all fields are sent to coupler.
    1024 !
     1013
    10251014!*************************************************************************************
    10261015    IF (MOD(itime, nexca) == 0) THEN
     
    11191108  END SUBROUTINE cpl_send_seaice_fields
    11201109
    1121 !
    1122 !*************************************************************************************
    1123 !
     1110!*************************************************************************************
    11241111
    11251112  SUBROUTINE cpl_send_land_fields(itime, knon, knindex, rriv_in, rcoa_in)
    1126 !
     1113
    11271114! This subroutine cumulates some fields for each time-step during a coupling
    11281115! period. At last time-step in a coupling period the fields are transformed to the
    11291116! grid accepted by the coupler. No sending to the coupler will be done from here
    11301117! (it is done in cpl_send_seaice_fields).
    1131 !
     1118
    11321119    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
    11331120
     
    11481135! Rearrange fields in 2D variables
    11491136! First initialize to zero to avoid unvalid points causing problems
    1150 !
     1137
    11511138!*************************************************************************************
    11521139!$OMP MASTER
     
    11591146!*************************************************************************************
    11601147! Reset cumulated fields to zero in the beginning of a new coupling period
    1161 !
     1148
    11621149!*************************************************************************************
    11631150    IF (MOD(itime, nexca) == 1) THEN
     
    11701157!*************************************************************************************
    11711158! Cumulate : Following fields should be cumulated at each time-step
    1172 !
     1159
    11731160!*************************************************************************************   
    11741161!$OMP MASTER
     
    11791166  END SUBROUTINE cpl_send_land_fields
    11801167
    1181 !
    1182 !*************************************************************************************
    1183 !
     1168!*************************************************************************************
    11841169
    11851170  SUBROUTINE cpl_send_landice_fields(itime, knon, knindex, rlic_in, rlic_in_frac)
     
    11871172! during a coupling period. This routine will not send to coupler. Sending
    11881173! will be done in cpl_send_seaice_fields.
    1189 !
    11901174
    11911175    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
     
    12081192! Rearrange field in a 2D variable
    12091193! First initialize to zero to avoid unvalid points causing problems
    1210 !
     1194
    12111195!*************************************************************************************
    12121196!$OMP MASTER
     
    12171201!*************************************************************************************
    12181202! Reset field to zero in the beginning of a new coupling period
    1219 !
     1203
    12201204!*************************************************************************************
    12211205    IF (MOD(itime, nexca) == 1) THEN
     
    12271211!*************************************************************************************
    12281212! Cumulate : Melting ice should be cumulated at each time-step
    1229 !
     1213
    12301214!*************************************************************************************   
    12311215!$OMP MASTER
     
    12351219  END SUBROUTINE cpl_send_landice_fields
    12361220
    1237 !
    1238 !*************************************************************************************
    1239 !
     1221!*************************************************************************************
    12401222
    12411223  SUBROUTINE cpl_send_all(itime, dtime, pctsrf, lafin, rlon, rlat)
     
    12431225! This subroutine should be executed after calculations by the last surface(sea-ice),
    12441226! all calculations at the different surfaces have to be done before.
    1245 !   
     1227
    12461228    USE surface_data
    12471229    USE carbon_cycle_mod, ONLY : carbon_cycle_cpl
     
    12531235
    12541236! Some includes
    1255 !   
     1237
    12561238! Input arguments
    12571239!*************************************************************************************
     
    12951277! All fields are stored in a table tab_flds(:,:,:)
    12961278! First store the fields which are already on the right format
    1297 !
     1279
    12981280!*************************************************************************************
    12991281!$OMP MASTER
     
    13291311!*************************************************************************************
    13301312! Transform the fraction of sub-surfaces from 1D to 2D array
    1331 !
     1313
    13321314!*************************************************************************************
    13331315    pctsrf2D(:,:,:) = 0.
     
    13421324! Calculate the average calving per latitude
    13431325! Store calving in tab_flds(:,:,19)
    1344 !
     1326
    13451327!*************************************************************************************     
    13461328    IF (is_omp_root) THEN
     
    14031385! Calculate total flux for snow, rain and wind with weighted addition using the
    14041386! fractions of ocean and seaice.
    1405 !
     1387
    14061388!*************************************************************************************   
    14071389       ! fraction oce+seaice
     
    15071489!*************************************************************************************
    15081490! NetCDF output of all fields just before sending to coupler.
    1509 !
     1491
    15101492!*************************************************************************************
    15111493    IF (is_sequential) THEN
     
    15171499!*************************************************************************************
    15181500! Send the table of all fields
    1519 !
     1501
    15201502!*************************************************************************************
    15211503    time_sec=(itime-1)*dtime
     
    15281510!*************************************************************************************
    15291511! Finish with some dellocate
    1530 !
     1512
    15311513!************************************************************************************* 
    15321514    sum_error=0
     
    15551537   
    15561538  END SUBROUTINE cpl_send_all
    1557 !
    1558 !*************************************************************************************
    1559 !
     1539
     1540!*************************************************************************************
     1541
    15601542  SUBROUTINE cpl2gath(champ_in, champ_out, knon, knindex)
    15611543  USE mod_phys_lmdz_para
    15621544! Cette routine transforme un champs de la grille 2D recu du coupleur sur la grille
    15631545! 'gathered' (la grille physiq comprime).
    1564 !
    1565 !
     1546
     1547
    15661548! input:         
    15671549!   champ_in     champ sur la grille 2D
    15681550!   knon         nombre de points dans le domaine a traiter
    15691551!   knindex      index des points de la surface a traiter
    1570 !
     1552
    15711553! output:
    15721554!   champ_out    champ sur la grille 'gatherd'
    1573 !
     1555
    15741556    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
    15751557
     
    15881570
    15891571!*************************************************************************************
    1590 !
    1591    
    15921572
    15931573! Transform from 2 dimensions (nbp_lon,jj_nb) to 1 dimension (klon)
     
    16051585
    16061586  END SUBROUTINE cpl2gath
    1607 !
    1608 !*************************************************************************************
    1609 !
     1587
     1588!*************************************************************************************
     1589
    16101590  SUBROUTINE gath2cpl(champ_in, champ_out, knon, knindex)
    16111591  USE mod_phys_lmdz_para
    16121592! Cette routine ecrit un champ 'gathered' sur la grille 2D pour le passer
    16131593! au coupleur.
    1614 !
     1594
    16151595! input:         
    16161596!   champ_in     champ sur la grille gathere       
    16171597!   knon         nombre de points dans le domaine a traiter
    16181598!   knindex      index des points de la surface a traiter
    1619 !
     1599
    16201600! output:
    16211601!   champ_out    champ sur la grille 2D
    1622 !
     1602
    16231603    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
    16241604   
     
    16581638   
    16591639  END SUBROUTINE gath2cpl
    1660 !
    1661 !*************************************************************************************
    1662 !
     1640
     1641!*************************************************************************************
     1642
    16631643END MODULE cpl_mod
    16641644
Note: See TracChangeset for help on using the changeset viewer.