Ignore:
Timestamp:
Nov 8, 2024, 4:59:55 PM (2 weeks ago)
Author:
jbclement
Message:

Dynamic + Mars PCM:
Addition of the description for the 'controle' array in the "start.nc" and "startfi.nc" files. It is given by the variable 'controle_descriptor' whose the element 'controle_descriptor(i)' explains 'controle(i)'.
JBC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/libf/phymars/iostart.F90

    r2952 r3509  
    88   
    99    ! restartfi.nc file dimension identifiers: (see open_restartphy())
    10     INTEGER,SAVE :: idim1 ! "index" dimension
    11     INTEGER,SAVE :: idim2 ! "physical_points" dimension
    12     INTEGER,SAVE :: idim3 ! "subsurface_layers" dimension
    13     INTEGER,SAVE :: idim4 ! "nlayer_plus_1" dimension
    14     INTEGER,SAVE :: idim5 ! "number_of_advected_fields" dimension
    15     INTEGER,SAVE :: idim6 ! "nlayer" dimension
    16     INTEGER,SAVE :: idim7 ! "Time" dimension
    17     INTEGER,SAVE :: idim8 ! "nslope" dimension
    18     INTEGER,SAVE :: idim9 ! "nslope_plus_1" dimension
     10    INTEGER,SAVE :: idim1  ! "index" dimension
     11    INTEGER,SAVE :: idim2  ! "physical_points" dimension
     12    INTEGER,SAVE :: idim3  ! "subsurface_layers" dimension
     13    INTEGER,SAVE :: idim4  ! "nlayer_plus_1" dimension
     14    INTEGER,SAVE :: idim5  ! "number_of_advected_fields" dimension
     15    INTEGER,SAVE :: idim6  ! "nlayer" dimension
     16    INTEGER,SAVE :: idim7  ! "Time" dimension
     17    INTEGER,SAVE :: idim8  ! "nslope" dimension
     18    INTEGER,SAVE :: idim9  ! "nslope_plus_1" dimension
     19    INTEGER,SAVE :: idim10 ! "descriptor" dimension
     20    INTEGER,SAVE :: idim11 ! "description_size" dimension
    1921    INTEGER,SAVE :: timeindex ! current time index (for time-dependent fields)
    20     INTEGER,PARAMETER :: length=100 ! size of tab_cntrl array
    21    
     22    INTEGER,PARAMETER :: length = 100 ! size of tab_cntrl array
     23    INTEGER,PARAMETER :: ldscrpt = 35 ! size of dscrpt_tab_cntrl array
     24    INTEGER,PARAMETER :: ndscrpt = 50 ! size of characters in dscrpt_tab_cntrl array
     25
    2226    INTERFACE get_field
    2327      MODULE PROCEDURE Get_field_r1,Get_field_r2,Get_field_r3
    2428    END INTERFACE get_field
    25    
     29
    2630    INTERFACE get_var
    2731      MODULE PROCEDURE get_var_r0,Get_var_r1,Get_var_r2,Get_var_r3
     
    3337
    3438    INTERFACE put_var
    35       MODULE PROCEDURE put_var_r0,put_var_r1,put_var_r2,put_var_r3
     39      MODULE PROCEDURE put_var_r0,put_var_r1,put_var_r2,put_var_r3, put_var_c1
    3640    END INTERFACE put_var
    3741
    38     PUBLIC nid_start, length
     42    PUBLIC nid_start, length, ldscrpt, ndscrpt
    3943    PUBLIC get_field,get_var,put_field,put_var
    4044    PUBLIC inquire_dimension, inquire_dimension_length
    4145    PUBLIC inquire_field, inquire_field_ndims
    4246    PUBLIC open_startphy,close_startphy,open_restartphy,close_restartphy
    43    
     47
    4448CONTAINS
    4549
     
    178182
    179183  END FUNCTION inquire_dimension_length
    180 
    181 
    182184
    183185  SUBROUTINE Get_Field_r1(field_name,field,found,timeindex)
     
    566568      ierr=NF90_DEF_DIM(nid_restart,"nslope",nslope,idim8)
    567569      IF (ierr/=NF90_NOERR) THEN
    568         write(*,*)'phyredem: problem defining nslope dimension'
    569         write(*,*)trim(nf90_strerror(ierr))
    570         CALL ABORT
     570        write(*,*)'open_restartphy: problem defining nslope dimension'
     571        write(*,*)trim(nf90_strerror(ierr))
     572        CALL abort_physic("open_restartphy","Failed defining nslope",1)
    571573      ENDIF
    572574
    573575      ierr=NF90_DEF_DIM(nid_restart,"inter_slope",nslope+1,idim9)
    574576      IF (ierr/=NF90_NOERR) THEN
    575         write(*,*)'phyredem: problem defining inter slope dimension'
    576         write(*,*)trim(nf90_strerror(ierr))
    577         CALL ABORT
     577        write(*,*)'open_restartphy: problem defining inter_slope dimension'
     578        write(*,*)trim(nf90_strerror(ierr))
     579        CALL abort_physic("open_restartphy","Failed defining inter_slope",1)
     580      ENDIF
     581     
     582      ierr=NF90_DEF_DIM(nid_restart,"descriptor",ldscrpt,idim10)
     583      IF (ierr/=NF90_NOERR) THEN
     584        write(*,*)'open_restartphy: problem defining descriptor dimension '
     585        write(*,*)trim(nf90_strerror(ierr))
     586        CALL abort_physic("open_restartphy","Failed defining descriptor",1)
     587      ENDIF
     588     
     589      ierr=NF90_DEF_DIM(nid_restart,"description_size",ndscrpt,idim11)
     590      IF (ierr/=NF90_NOERR) THEN
     591        write(*,*)'open_restartphy: problem defining description_size dimension '
     592        write(*,*)trim(nf90_strerror(ierr))
     593        CALL abort_physic("open_restartphy","Failed defining description_size",1)
    578594      ENDIF
    579595
     
    946962  END SUBROUTINE put_var_r0
    947963
    948 
    949964  SUBROUTINE put_var_r1(var_name,title,var)
    950965  ! Put a vector in file
     
    967982     CALL put_var_rgen(var_name,title,var,size(var))
    968983
    969   END SUBROUTINE put_var_r2     
     984  END SUBROUTINE put_var_r2
    970985 
    971986  SUBROUTINE put_var_r3(var_name,title,var)
     
    10291044          write(*,*)'put_var_rgen: problem writing Time'
    10301045          write(*,*)trim(nf90_strerror(ierr))
    1031           CALL abort_physic("get_var_rgen","Failed to write Time",1)
     1046          CALL abort_physic("put_var_rgen","Failed to write Time",1)
    10321047        ENDIF
    10331048        return ! nothing left to do
     
    10361051        idim1d=idim1
    10371052      ELSEIF (var_size==nsoilmx) THEN
    1038         ! We know it is an  "mlayer" kind of 1D array
     1053        ! We know it is an "mlayer" kind of 1D array
    10391054        idim1d=idim3
    10401055      ELSEIF (var_size==nslope+1) THEN
    1041         ! We know it is an  "inter slope" kind of 1D array
     1056        ! We know it is an "inter slope" kind of 1D array
    10421057        idim1d=idim9
    10431058      ELSE
    10441059        PRINT *, "put_var_rgen error : wrong dimension"
    10451060        write(*,*) "  var_size =",var_size
    1046         CALL abort_physic("get_var_rgen","Wrong variable dimension",1)
     1061        CALL abort_physic("put_var_rgen","Wrong variable dimension",1)
    10471062
    10481063      ENDIF ! of IF (var_size==length) THEN
     
    10701085    ENDIF ! of IF (is_master)
    10711086   
    1072   END SUBROUTINE put_var_rgen     
     1087  END SUBROUTINE put_var_rgen
     1088
     1089  SUBROUTINE put_var_c1(var_name,title,var)
     1090  ! Put a vector of characters in file
     1091
     1092  USE netcdf, only: NF90_REDEF, NF90_DEF_VAR, NF90_ENDDEF, NF90_PUT_VAR, &
     1093                    NF90_CHAR, &
     1094                    NF90_PUT_ATT, NF90_NOERR, nf90_strerror, &
     1095                    nf90_inq_dimid, nf90_inquire_dimension, NF90_INQ_VARID
     1096  USE comsoil_h, only: nsoilmx
     1097  USE comslope_mod, only: nslope
     1098  USE mod_phys_lmdz_para, only: is_master
     1099
     1100   IMPLICIT NONE
     1101     CHARACTER(LEN=*),INTENT(IN) :: var_name
     1102     CHARACTER(LEN=*),INTENT(IN) :: title
     1103     CHARACTER(LEN=*),INTENT(IN) :: var(:)
     1104
     1105     INTEGER :: ierr
     1106     INTEGER :: nvarid
     1107     INTEGER :: idim1d_1, idim1d_2
     1108     INTEGER :: var_size
     1109     logical,save :: firsttime=.true.
     1110
     1111    IF (is_master) THEN
     1112
     1113      var_size = size(var)
     1114      IF (var_size==ldscrpt) THEN
     1115        ! We know it is a "controle descriptor" kind of 1D array
     1116        idim1d_1=idim11
     1117        idim1d_2=idim10
     1118      ELSE
     1119        PRINT *, "put_var_cgen error : wrong dimension"
     1120        write(*,*) "  var_size =",var_size
     1121        CALL abort_physic("put_var_cgen","Wrong variable dimension",1)
     1122
     1123      ENDIF ! of IF (var_size==length) THEN
     1124
     1125      ! Swich to NetCDF define mode
     1126      ierr=NF90_REDEF (nid_restart)
     1127      ! Define the variable
     1128      ierr=NF90_DEF_VAR(nid_restart,var_name,NF90_CHAR,(/idim1d_1,idim1d_2/),nvarid)
     1129      ! Add a "title" attribute
     1130      IF (LEN_TRIM(title)>0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
     1131      ! Swich out of define mode
     1132      ierr=NF90_ENDDEF(nid_restart)
     1133      ! Write variable to file
     1134      ierr=NF90_PUT_VAR(nid_restart,nvarid,var)
     1135      IF (ierr/=NF90_NOERR) THEN
     1136        write(*,*)'put_var_cgen: problem writing '//trim(var_name)
     1137        write(*,*)trim(nf90_strerror(ierr))
     1138        CALL abort_physic("put_var_cgen","Failed writing variable",1)
     1139      ENDIF
     1140    ENDIF ! of IF (is_master)
     1141
     1142  END SUBROUTINE put_var_c1
    10731143
    10741144END MODULE iostart
Note: See TracChangeset for help on using the changeset viewer.