Ignore:
Timestamp:
Apr 11, 2025, 3:56:08 PM (2 months ago)
Author:
emillour
Message:

Venus PCM:
Add reindexing of columns when reading/writing (re)startphy files. This is not
necessary with the lon-lat (LMDZ.COMMON) dynamical core, but required when
using DYNAMICO (where correspondance between dynamics and physics column
indexes changes with number of computing cores).
In addition cleaned up phyetat0: put comments in English, added "only" clauses
to used modules and turned it into a module.
EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.VENUS/libf/phyvenus/phyetat0.F90

    r3451 r3719  
    1 !
    2 ! $Id $
    3 !
     1module phyetat0_mod
     2
     3implicit none
     4
     5contains
     6
    47subroutine phyetat0(fichnom)
    58! Load initial state for the physics
    69! and do some resulting initializations
    710
    8       USE dimphy
    9       USE mod_grid_phy_lmdz
    10       USE mod_phys_lmdz_para
    11       USE iophy
    12       USE phys_state_var_mod
    13       USE iostart
    14       use geometry_mod, only: longitude_deg, latitude_deg
    15       USE time_phylmdz_mod, only: itau_phy, raz_date, pdtphys
    16       USE ioipsl_getin_p_mod, only: getin_p
     11  use dimphy, only: klon
     12  use iophy, only: init_iophy_new
     13  use phys_state_var_mod, only: ftsol, ftsoil, age, dlw, falbe, fder, q2, &
     14                                radsol, sollw, sollwdown, solsw, &
     15                                ancien_ok, t_ancien, &
     16                                zmea, zgam, zpic, zsig, zstd, zthe, zval
     17  use iostart, only: get_var, get_field, open_startphy, close_startphy
     18  use geometry_mod, only: longitude_deg, latitude_deg
     19  use time_phylmdz_mod, only: itau_phy, raz_date, pdtphys
     20  use ioipsl_getin_p_mod, only: getin_p
    1721  use nonoro_gwd_ran_mod, only: du_nonoro_gwd, dv_nonoro_gwd, &
    1822                                east_gwstress, west_gwstress
     
    2024implicit none
    2125!======================================================================
    22 ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
    23 ! Objet: Lecture de l'etat initial pour la physique
    24 !======================================================================
    25 !include "netcdf.inc"
    2626include "dimsoil.h"
    2727include "clesphys.h"
     
    3636REAL :: lon_startphy(klon), lat_startphy(klon)
    3737REAL :: surface_albedo
    38 
    39 ! les variables globales lues dans le fichier restart
     38character(len=8) :: modname="phyetat0"
     39
     40! global variables read in startphy.nc file
    4041
    4142! open physics initial state file:
     
    5051  CALL get_var("controle",tab_cntrl,found)
    5152  IF (.not.found) THEN
    52     PRINT*, 'phyetat0: Le champ <controle> est absent'
    53     CALL abort
     53    write(*,*) modname//': Field <controle> is missing'
     54    call abort_physic(modname,"Missing <controle>",1)
    5455  ENDIF
    5556       
     
    6364  itau_phy = tab_cntrl(15)
    6465
    65 ! Attention si raz_date est active :
    66 ! il faut remettre a zero itau_phy apres phyetat0 !
     66! Warning, if raz_date is active :
     67! itau_phy must be re-set to zero after phyetat0 !
    6768  IF (raz_date.eq.1) THEN
    6869    itau_phy=0
     
    8182  call get_field("latitude",lat_startphy,found)
    8283  IF (.not.found) THEN
    83     PRINT*, 'phyetat0: Le champ <latitude> est absent'
    84     CALL abort
     84    write(*,*) modname//':: Field <latitude> is missing'
     85    call abort_physic(modname,"Missing <latitude>",1)
    8586  ENDIF
    8687  DO i=1,klon
    8788    IF (ABS(lat_startphy(i)-latitude_deg(i))>=0.01) THEN
    88       WRITE(*,*) "phyetat0: Warning! Latitude discrepancy wrt startphy file:",&
     89      WRITE(*,*) modname//": Warning! Latitude discrepancy wrt startphy file:",&
    8990                 " i=",i," lat_startphy(i)=",lat_startphy(i),&
    9091                 " latitude_deg(i)=",latitude_deg(i)
    91       CALL abort
     92      call abort_physic(modname,"<latitude> values discrepency",1)
    9293    ENDIF
    9394  ENDDO
     
    9697  call get_field("longitude",lon_startphy,found)
    9798  IF (.not.found) THEN
    98     PRINT*, 'phyetat0: Le champ <longitude> est absent'
    99     CALL abort
     99    write(*,*)'phyetat0: Field <longitude> is missing'
     100    call abort_physic(modname,"Missing <longitude>",1)
    100101  ENDIF
    101102  DO i=1,klon
    102103    IF (ABS(lon_startphy(i)-longitude_deg(i))>=0.01) THEN
    103       WRITE(*,*) "phyetat0: Warning! Longitude discrepancy wrt startphy file:",&
     104      WRITE(*,*) modname//": Warning! Longitude discrepancy wrt startphy file:",&
    104105                 " i=",i," lon_startphy(i)=",lon_startphy(i),&
    105106                 " longitude_deg(i)=",longitude_deg(i)
    106       CALL abort
     107      call abort_physic(modname,"<latitude> values discrepency",1)
    107108    ENDIF
    108109  ENDDO
     
    115116  CALL get_field("TS",ftsol(:),found)
    116117  IF (.not.found) THEN
    117     PRINT*, 'phyetat0: Le champ <TS> est absent'
    118     PRINT*, "phyetat0: Lecture echouee pour <TS>"
    119     CALL abort
     118    WRITE(*,*) modname//": Field <TS> is missing"
     119    call abort_physic(modname,"Missing <TS>",1)
    120120  ELSE
    121     PRINT*, 'phyetat0: Le champ <TS> est present'
    122     PRINT*,'Temperature du sol <TS>', minval(ftsol), maxval(ftsol)
     121    WRITE(*,*) modname//": Field <TS> is present"
     122    WRITE(*,*) 'Surface temperature <TS>', minval(ftsol), maxval(ftsol)
    123123  ENDIF
    124124ELSE
     
    131131  DO isoil=1, nsoilmx
    132132    IF (isoil.GT.99) THEN
    133        PRINT*, "Trop de couches"
    134        CALL abort
     133       WRITE(*,*) "Too many layers!"
     134       call abort_physic(modname,"Too many subsurface layers",1)
    135135    ENDIF
    136136    WRITE(str2,'(i2.2)') isoil
    137137    CALL get_field('Tsoil'//str2,ftsoil(:,isoil),found)
    138138    IF (.not.found) THEN
    139       PRINT*, "phyetat0: Le champ <Tsoil"//str2//"> est absent"
    140       PRINT*, "          Il prend donc la valeur de surface"
     139      WRITE(*,*) modname//": Field <Tsoil"//str2//"> is missing"
     140      WRITE(*,*) "           it will be nitialized with surface value"
    141141      DO i=1, klon
    142142             ftsoil(i,isoil)=ftsol(i)
     
    153153  CALL get_field("ALBE", falbe,found)
    154154  IF (.not.found) THEN
    155     PRINT*, 'phyetat0: Le champ <ALBE> est absent'
    156     PRINT*, "phyetat0: Lecture echouee pour <ALBE>"
    157     CALL abort
     155    WRITE(*,*) modname//": Field <ALBE> is missing"
     156    call abort_physic(modname,"Missing <ALBE>",1)
    158157  ENDIF
    159158ELSE
     
    163162  falbe(:)=surface_albedo
    164163ENDIF ! of IF (startphy_file)
    165 PRINT*,'Albedo du sol <ALBE>', minval(falbe), maxval(falbe)
    166 
    167 IF (startphy_file) THEN
    168   ! Lecture rayonnement solaire au sol:
     164WRITE(*,*) 'Surface albedo <ALBE>', minval(falbe), maxval(falbe)
     165
     166IF (startphy_file) THEN
     167  ! Solar flux to the surface:
    169168  CALL get_field("solsw",solsw,found)
    170169  IF (.not.found) THEN
    171     PRINT*, 'phyetat0: Le champ <solsw> est absent'
    172     PRINT*, 'mis a zero'
     170    WRITE(*,*) modname//": Field <solsw> is missing"
     171    WRITE(*,*) "set to zero"
    173172    solsw = 0.
    174173  ENDIF
     
    177176  solsw(:)=0
    178177ENDIF ! of IF (startphy_file)
    179 PRINT*,'Rayonnement solaire au sol solsw:', minval(solsw), maxval(solsw)
    180 
    181 IF (startphy_file) THEN
    182   ! Lecture rayonnement IR au sol:
     178WRITE(*,*) 'Solar flux to the surface solsw:', minval(solsw), maxval(solsw)
     179
     180IF (startphy_file) THEN
     181  ! IR flux to the surface:
    183182  CALL get_field("sollw",sollw,found)
    184183  IF (.not.found) THEN
    185     PRINT*, 'phyetat0: Le champ <sollw> est absent'
    186     PRINT*, 'mis a zero'
     184    WRITE(*,*) modname//": Field <sollw> is missing"
     185    WRITE(*,*) "set to zero"
    187186    sollw = 0.
    188187  ENDIF
     
    191190  sollw(:)=0
    192191ENDIF ! of IF (startphy_file)
    193 PRINT*,'Rayonnement IR au sol sollw:', minval(sollw), maxval(solsw)
    194 
    195 IF (startphy_file) THEN
    196   ! Lecture derive des flux:
     192WRITE(*,*) 'IR flux to the surface sollw:', minval(sollw), maxval(solsw)
     193
     194IF (startphy_file) THEN
     195  ! Derivative of the sensible and latent fluxes:
    197196  CALL get_field("fder",fder,found)
    198197  IF (.not.found) THEN
    199     PRINT*, 'phyetat0: Le champ <fder> est absent'
    200     PRINT*, 'mis a zero'
     198    WRITE(*,*) modname//": Field <fder> is missing"
     199    WRITE(*,*) "set to zero"
    201200    fder = 0.
    202201  ENDIF
     
    205204  fder(:)=0
    206205ENDIF ! of IF (startphy_file)
    207 PRINT*,'Derive des flux fder:', minval(fder), maxval(fder)
    208 
    209 IF (startphy_file) THEN
    210   ! Lecture derive flux IR:
     206WRITE(*,*) 'Derivative of the flux fder:', minval(fder), maxval(fder)
     207
     208IF (startphy_file) THEN
     209  ! Derivative of the IR flux:
    211210  CALL get_field("dlw",dlw,found)
    212211  IF (.not.found) THEN
    213     PRINT*, 'phyetat0: Le champ <dlw> est absent'
    214     PRINT*, 'mis a zero'
     212    WRITE(*,*) modname//": Field <dlw> is missing"
     213    WRITE(*,*) "set to zero"
    215214    dlw = 0.
    216215  ENDIF
     
    219218  dlw(:)=0
    220219ENDIF ! of IF (startphy_file)
    221 PRINT*,'Derive flux IR dlw:', minval(dlw), maxval(dlw)
    222 
    223 IF (startphy_file) THEN
    224   ! Lecture rayonnement IR vers le bas au sol:
     220WRITE(*,*) 'Derivative of the IR flux dlw:', minval(dlw), maxval(dlw)
     221
     222IF (startphy_file) THEN
     223  ! Downward IR flux at the surface:
    225224  CALL get_field("sollwdown",sollwdown,found)
    226225  IF (.not.found) THEN
    227     PRINT*, 'phyetat0: Le champ <sollwdown> est absent'
    228     PRINT*, 'mis a zero'
     226    WRITE(*,*) modname//": Field <sollwdown> is missing"
     227    WRITE(*,*) "set to zero"
    229228    sollwdown = 0.
    230229  ENDIF
     
    233232  sollwdown(:)=0
    234233ENDIF ! of IF (startphy_file)
    235 PRINT*,'Flux IR vers le bas au sol sollwdown:', minval(sollwdown), maxval(sollwdown)
    236 
    237 IF (startphy_file) THEN
    238   ! Lecture du rayonnement net au sol:
     234WRITE(*,*) 'Downward IR flux at the surface sollwdown:', minval(sollwdown), maxval(sollwdown)
     235
     236IF (startphy_file) THEN
     237  ! Net flux at the surface:
    239238  CALL get_field("RADS",radsol,found)
    240239  IF (.not.found) THEN
    241     PRINT*, 'phyetat0: Le champ <RADS> est absent'
    242     CALL abort
     240    WRITE(*,*) modname//": Field <RADS> is missing"
     241    call abort_physic(modname,"Missing <RADS>",1)
    243242  ENDIF
    244243ELSE
     
    246245  radsol(:)=0
    247246ENDIF ! of IF (startphy_file)
    248 PRINT*,'Rayonnement net au sol radsol:', minval(radsol), maxval(radsol)
     247WRITE(*,*) 'Net flux at the surface radsol:', minval(radsol), maxval(radsol)
    249248
    250249IF (startphy_file) THEN
     
    252251  CALL get_field("ZMEA",zmea,found)
    253252  IF (.not.found) THEN
    254     PRINT*, 'phyetat0: Le champ <ZMEA> est absent'
    255     PRINT*, 'mis a zero'
     253    WRITE(*,*) modname//": Field <ZMEA> is missing"
     254    WRITE(*,*) "set to zero"
    256255    zmea=0.
    257256  ENDIF
     
    259258  zmea(:)=0
    260259ENDIF ! of IF (startphy_file)
    261 PRINT*,'OROGRAPHIE SOUS-MAILLE zmea:', minval(zmea), maxval(zmea)
     260WRITE(*,*) 'Subgrid scale orography zmea:', minval(zmea), maxval(zmea)
    262261
    263262IF (startphy_file) THEN
     
    265264  CALL get_field("ZSTD",zstd,found)
    266265  IF (.not.found) THEN
    267     PRINT*, 'phyetat0: Le champ <ZSTD> est absent'
    268     PRINT*, 'mis a zero'
     266    WRITE(*,*) modname//": Field <ZSTD> is missing"
     267    WRITE(*,*) "set to zero"
    269268    zstd=0.
    270269  ENDIF
     
    272271  zstd(:)=0
    273272ENDIF ! of IF (startphy_file)
    274 PRINT*,'OROGRAPHIE SOUS-MAILLE zstd:', minval(zstd), maxval(zstd)
     273WRITE(*,*) 'Subgrid scale orography zstd:', minval(zstd), maxval(zstd)
    275274
    276275IF (startphy_file) THEN
     
    278277  CALL get_field("ZSIG",zsig,found)
    279278  IF (.not.found) THEN
    280     PRINT*, 'phyetat0: Le champ <ZSIG> est absent'
    281     PRINT*, 'mis a zero'
     279    WRITE(*,*) modname//": Field <ZSIG> is missing"
     280    WRITE(*,*) "set to zero"
    282281    zsig=0.
    283282  ENDIF
     
    285284  zsig(:)=0
    286285ENDIF ! of IF (startphy_file)
    287 PRINT*,'OROGRAPHIE SOUS-MAILLE zsig:', minval(zsig), maxval(zsig)
     286WRITE(*,*) 'Subgrid scale orography zsig:', minval(zsig), maxval(zsig)
    288287
    289288IF (startphy_file) THEN
     
    291290  CALL get_field("ZGAM",zgam,found)
    292291  IF (.not.found) THEN
    293     PRINT*, 'phyetat0: Le champ <ZGAM> est absent'
    294     PRINT*, 'mis a zero'
     292    WRITE(*,*) modname//": Field <ZGAM> is missing"
     293    WRITE(*,*) "set to zero"
    295294    zgam=0.
    296295  ENDIF
     
    298297  zgam(:)=0
    299298ENDIF ! of IF (startphy_file)
    300 PRINT*,'OROGRAPHIE SOUS-MAILLE zgam:', minval(zgam), maxval(zgam)
     299WRITE(*,*) 'Subgrid scale orography zgam:', minval(zgam), maxval(zgam)
    301300
    302301IF (startphy_file) THEN
     
    304303  CALL get_field("ZTHE",zthe,found)
    305304  IF (.not.found) THEN
    306     PRINT*, 'phyetat0: Le champ <ZTHE> est absent'
    307     PRINT*, 'mis a zero'
     305    WRITE(*,*) modname//": Field <ZTHE> is missing"
     306    WRITE(*,*) "set to zero"
    308307    zthe=0.
    309308  ENDIF
     
    311310  zthe(:)=0
    312311ENDIF ! of IF (startphy_file)
    313 PRINT*,'OROGRAPHIE SOUS-MAILLE zthe:', minval(zthe), maxval(zthe)
     312WRITE(*,*) 'Subgrid scale orography zthe:', minval(zthe), maxval(zthe)
    314313
    315314IF (startphy_file) THEN
     
    317316  CALL get_field("ZPIC",zpic,found)
    318317  IF (.not.found) THEN
    319     PRINT*, 'phyetat0: Le champ <ZPIC> est absent'
    320     PRINT*, 'mis a zero'
     318    WRITE(*,*) modname//": Field <ZPIC> is missing"
     319    WRITE(*,*) "set to zero"
    321320    zpic=0.
    322321  ENDIF
     
    324323  zpic(:)=0
    325324ENDIF ! of IF (startphy_file)
    326 PRINT*,'OROGRAPHIE SOUS-MAILLE zpic:', minval(zpic), maxval(zpic)
     325WRITE(*,*) 'Subgrid scale orography zpic:', minval(zpic), maxval(zpic)
    327326
    328327IF (startphy_file) THEN
     
    330329  CALL get_field("ZVAL",zval,found)
    331330  IF (.not.found) THEN
    332     PRINT*, 'phyetat0: Le champ <ZVAL> est absent'
    333     PRINT*, 'mis a zero'
     331    WRITE(*,*) modname//": Field <ZVAL> is missing"
     332    WRITE(*,*) "set to zero"
    334333    zval=0.
    335334  ENDIF
     
    337336  zval(:)=0
    338337ENDIF ! of IF (startphy_file)
    339 PRINT*,'OROGRAPHIE SOUS-MAILLE zval:', minval(zval), maxval(zval)
     338WRITE(*,*) 'Subgrid scale orography zval:', minval(zval), maxval(zval)
    340339
    341340IF (startphy_file) THEN
     
    345344  CALL get_field("TANCIEN",t_ancien,found)
    346345  IF (.not.found) THEN
    347     PRINT*, "phyetat0: Le champ <TANCIEN> est absent"
    348     PRINT*, "Depart legerement fausse. Mais je continue"
     346    WRITE(*,*) modname//": Field <TANCIEN> is missing"
     347    WRITE(*,*) "Slightly biaised start. But let's keep going."
    349348    ancien_ok = .FALSE.
    350349  ENDIF
     
    368367  CALL get_field("Q2",q2,found)
    369368  IF (.not.found) THEN
    370     PRINT*, 'phyetat0: Le champ <Q2> est absent'
    371     PRINT*, 'mis a zero'
     369    WRITE(*,*) modname//": Field <Q2> is missing"
     370    WRITE(*,*) "set to zero"
    372371    q2(:,:)=0.
    373372  ENDIF
     
    376375  q2(:,:)=0
    377376ENDIF ! of IF (startphy_file)
    378 PRINT*,'Turbulent Kinetic Energy', minval(q2), maxval(q2)
     377WRITE(*,*) 'Turbulent Kinetic Energy', minval(q2), maxval(q2)
    379378
    380379! Non-orographic gravity waves
     
    415414
    416415end subroutine phyetat0
     416
     417end module phyetat0_mod
Note: See TracChangeset for help on using the changeset viewer.