Ignore:
Timestamp:
Dec 13, 2024, 5:17:13 PM (7 weeks ago)
Author:
emillour
Message:

Generic PCM

Modify iostart routines to take netcdf index as an argument in order to
be used to read/write in other files than startfi.nc (preparing 1D
restart)

MM

Location:
trunk/LMDZ.GENERIC/libf/phystd
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.GENERIC/libf/phystd/iostart.F90

    r3515 r3552  
    44PRIVATE
    55    INTEGER,SAVE :: nid_start ! NetCDF file identifier for startfi.nc file
    6     INTEGER,SAVE :: nid_restart ! NetCDF file identifier for restartfi.nc file
     6    ! INTEGER,SAVE :: nid_restart ! NetCDF file identifier for restartfi.nc file
    77!$OMP THREADPRIVATE(nid_start,nid_restart)
    88   
     
    4949CONTAINS
    5050
    51   SUBROUTINE open_startphy(filename)
     51  SUBROUTINE open_startphy(filename,nid_start)
    5252  USE netcdf, only: NF90_OPEN, NF90_NOERR, NF90_NOWRITE, nf90_strerror
    5353  USE mod_phys_lmdz_para, only: is_master, bcast
    5454  IMPLICIT NONE
    55     CHARACTER(LEN=*) :: filename
    56     INTEGER          :: ierr
     55    CHARACTER(LEN=*)      :: filename
     56    INTEGER,INTENT(INOUT) :: nid_start
     57    INTEGER               :: ierr
    5758
    5859    IF (is_master) THEN
     
    6970  END SUBROUTINE open_startphy
    7071
    71   SUBROUTINE close_startphy
     72  SUBROUTINE close_startphy(nid_start)
    7273  USE netcdf, only: NF90_CLOSE
    7374  USE mod_phys_lmdz_para, only: is_master
    7475  IMPLICIT NONE
    75     INTEGER          :: ierr
     76    INTEGER,INTENT(IN) :: nid_start
     77    INTEGER            :: ierr
    7678
    7779    IF (is_master) THEN
     
    8284
    8385
    84   FUNCTION inquire_field(Field_name)
     86  FUNCTION inquire_field(nid_start,Field_name)
    8587  ! check if a given field is present in the input file
    8688  USE netcdf, only: NF90_INQ_VARID, NF90_NOERR
    8789  USE mod_phys_lmdz_para, only: is_master, bcast
    8890  IMPLICIT NONE
     91    INTEGER,INTENT(IN)          :: nid_start
    8992    CHARACTER(LEN=*),INTENT(IN) :: Field_name
    9093    LOGICAL :: inquire_field
     
    106109
    107110
    108   FUNCTION inquire_field_ndims(Field_name)
     111  FUNCTION inquire_field_ndims(nid_start,Field_name)
    109112  ! give the number of dimensions of "Field_name" stored in the input file
    110113  USE netcdf, only: nf90_inq_varid, nf90_inquire_variable, &
     
    112115  USE mod_phys_lmdz_para, only: is_master, bcast
    113116  IMPLICIT NONE
     117    INTEGER,INTENT(IN)          :: nid_start
    114118    CHARACTER(LEN=*),INTENT(IN) :: Field_name
    115119    INTEGER :: inquire_field_ndims
     
    134138
    135139
    136   FUNCTION inquire_dimension(Field_name)
     140  FUNCTION inquire_dimension(nid_start,Field_name)
    137141  ! check if a given dimension is present in the input file
    138142  USE netcdf, only: nf90_inq_dimid, NF90_NOERR
    139143  USE mod_phys_lmdz_para, only: is_master, bcast
    140144  IMPLICIT NONE
     145    INTEGER,INTENT(IN)          :: nid_start
    141146    CHARACTER(LEN=*),INTENT(IN) :: Field_name
    142147    LOGICAL :: inquire_dimension
     
    157162  END FUNCTION inquire_dimension
    158163
    159   FUNCTION inquire_dimension_length(Field_name)
     164  FUNCTION inquire_dimension_length(nid_start,Field_name)
    160165  ! give the length of the "Field_name" dimension stored in the input file
    161166  USE netcdf, only: nf90_inquire_dimension, nf90_inq_dimid, &
     
    163168  USE mod_phys_lmdz_para, only: is_master, bcast
    164169  IMPLICIT NONE
     170    INTEGER,INTENT(IN)          :: nid_start
    165171    CHARACTER(LEN=*),INTENT(IN) :: Field_name
    166172    INTEGER :: inquire_dimension_length
     
    186192
    187193
    188   SUBROUTINE Get_Field_r1(field_name,field,found,timeindex)
     194  SUBROUTINE Get_Field_r1(nid_start,field_name,field,found,timeindex)
    189195  ! For a surface field
    190196  use mod_grid_phy_lmdz, only: klon_glo ! number of atmospheric columns (full grid)
    191197  IMPLICIT NONE
     198    INTEGER,INTENT(IN)             :: nid_start
    192199    CHARACTER(LEN=*),INTENT(IN)    :: Field_name
    193200    REAL,INTENT(INOUT)               :: Field(:)
     
    205212
    206213    IF (PRESENT(found)) THEN
    207       CALL Get_field_rgen(field_name,field,1,corners,edges,found)
     214      CALL Get_field_rgen(nid_start,field_name,field,1,corners,edges,found)
    208215    ELSE
    209       CALL Get_field_rgen(field_name,field,1,corners,edges)
     216      CALL Get_field_rgen(nid_start,field_name,field,1,corners,edges)
    210217    ENDIF
    211218     
    212219  END SUBROUTINE Get_Field_r1
    213220 
    214   SUBROUTINE Get_Field_r2(field_name,field,found,timeindex)
     221  SUBROUTINE Get_Field_r2(nid_start,field_name,field,found,timeindex)
    215222  ! For a "3D" horizontal-vertical field
    216223  use mod_grid_phy_lmdz, only: klon_glo ! number of atmospheric columns (full grid)
    217224  IMPLICIT NONE
     225    INTEGER,INTENT(IN)             :: nid_start
    218226    CHARACTER(LEN=*),INTENT(IN)    :: Field_name
    219227    REAL,INTENT(INOUT)               :: Field(:,:)
     
    232240   
    233241    IF (PRESENT(found)) THEN
    234       CALL Get_field_rgen(field_name,field,size(field,2),&
     242      CALL Get_field_rgen(nid_start,field_name,field,size(field,2),&
    235243                          corners,edges,found)
    236244    ELSE
    237       CALL Get_field_rgen(field_name,field,size(field,2),&
     245      CALL Get_field_rgen(nid_start,field_name,field,size(field,2),&
    238246                          corners,edges)
    239247    ENDIF
     
    242250  END SUBROUTINE Get_Field_r2
    243251 
    244   SUBROUTINE Get_Field_r3(field_name,field,found,timeindex)
     252  SUBROUTINE Get_Field_r3(nid_start,field_name,field,found,timeindex)
    245253  ! for a "4D" field surf/alt/??
    246254  use mod_grid_phy_lmdz, only: klon_glo ! number of atmospheric columns (full grid)
    247255  IMPLICIT NONE
     256    INTEGER,INTENT(IN)             :: nid_start
    248257    CHARACTER(LEN=*),INTENT(IN)    :: Field_name
    249258    REAL,INTENT(INOUT)               :: Field(:,:,:)
     
    263272   
    264273    IF (PRESENT(found)) THEN
    265       CALL Get_field_rgen(field_name,field,size(field,2)*size(field,3),&
     274      CALL Get_field_rgen(nid_start,field_name,field,size(field,2)*size(field,3),&
    266275                          corners,edges,found)
    267276    ELSE
    268       CALL Get_field_rgen(field_name,field,size(field,2)*size(field,3),&
     277      CALL Get_field_rgen(nid_start,field_name,field,size(field,2)*size(field,3),&
    269278                          corners,edges)
    270279    ENDIF
     
    272281  END SUBROUTINE Get_Field_r3
    273282 
    274   SUBROUTINE Get_field_rgen(field_name,field,field_size, &
     283  SUBROUTINE Get_field_rgen(nid_start,field_name,field,field_size, &
    275284                            corners,edges,found)
    276285  USE netcdf
     
    279288  USE mod_phys_lmdz_para
    280289  IMPLICIT NONE
     290    INTEGER,INTENT(IN) :: nid_start
    281291    CHARACTER(LEN=*) :: Field_name
    282292    INTEGER          :: field_size
     
    296306     
    297307      IF (ierr==NF90_NOERR) THEN
    298         CALL body(field_glo)
     308        CALL body(field_glo,nid_start)
    299309        tmp_found=.TRUE.
    300310      ELSE
     
    322332    CONTAINS
    323333     
    324      SUBROUTINE body(field_glo)
     334     SUBROUTINE body(field_glo,nid_start)
    325335       REAL :: field_glo(klon_glo*field_size)
     336       INTEGER,INTENT(IN) :: nid_start
    326337         ierr=NF90_GET_VAR(nid_start,varid,field_glo,corners,edges)
    327338         IF (ierr/=NF90_NOERR) THEN
     
    349360
    350361
    351   SUBROUTINE get_var_r0(var_name,var,found)
     362  SUBROUTINE get_var_r0(nid_start,var_name,var,found)
    352363  ! Get a scalar from input file
    353364  IMPLICIT NONE 
     365    INTEGER,INTENT(IN)           :: nid_start
    354366    CHARACTER(LEN=*),INTENT(IN)  :: var_name
    355367    REAL,INTENT(INOUT)             :: var
     
    359371   
    360372    IF (PRESENT(found)) THEN
    361       CALL Get_var_rgen(var_name,varout,size(varout),found)
     373      CALL Get_var_rgen(nid_start,var_name,varout,size(varout),found)
    362374    ELSE
    363       CALL Get_var_rgen(var_name,varout,size(varout))
     375      CALL Get_var_rgen(nid_start,var_name,varout,size(varout))
    364376    ENDIF
    365377    var=varout(1)
     
    367379  END SUBROUTINE get_var_r0
    368380
    369   SUBROUTINE get_var_r1(var_name,var,found)
     381  SUBROUTINE get_var_r1(nid_start,var_name,var,found)
    370382  ! Get a vector from input file
    371383  IMPLICIT NONE 
     
    373385    REAL,INTENT(INOUT)             :: var(:)
    374386    LOGICAL,OPTIONAL,INTENT(OUT) :: found
     387    INTEGER,INTENT(IN)           :: nid_start
    375388   
    376389    IF (PRESENT(found)) THEN
    377       CALL Get_var_rgen(var_name,var,size(var),found)
     390      CALL Get_var_rgen(nid_start,var_name,var,size(var),found)
    378391    ELSE
    379       CALL Get_var_rgen(var_name,var,size(var))
     392      CALL Get_var_rgen(nid_start,var_name,var,size(var))
    380393    ENDIF
    381394 
    382395  END SUBROUTINE get_var_r1
    383396
    384   SUBROUTINE get_var_r2(var_name,var,found)
     397  SUBROUTINE get_var_r2(nid_start,var_name,var,found)
    385398  ! Get a 2D field from input file
    386399  IMPLICIT NONE 
     
    388401    REAL,INTENT(OUT)             :: var(:,:)
    389402    LOGICAL,OPTIONAL,INTENT(OUT) :: found
     403    INTEGER,INTENT(IN)           :: nid_start
    390404   
    391405    IF (PRESENT(found)) THEN
    392       CALL Get_var_rgen(var_name,var,size(var),found)
     406      CALL Get_var_rgen(nid_start,var_name,var,size(var),found)
    393407    ELSE
    394       CALL Get_var_rgen(var_name,var,size(var))
     408      CALL Get_var_rgen(nid_start,var_name,var,size(var))
    395409    ENDIF
    396410 
    397411  END SUBROUTINE get_var_r2
    398412
    399   SUBROUTINE get_var_r3(var_name,var,found)
     413  SUBROUTINE get_var_r3(nid_start,var_name,var,found)
    400414  ! Get a 3D field frominput file
    401415  IMPLICIT NONE 
     
    403417    REAL,INTENT(INOUT)             :: var(:,:,:)
    404418    LOGICAL,OPTIONAL,INTENT(OUT) :: found
     419    INTEGER,INTENT(IN)           :: nid_start
    405420   
    406421    IF (PRESENT(found)) THEN
    407       CALL Get_var_rgen(var_name,var,size(var),found)
     422      CALL Get_var_rgen(nid_start,var_name,var,size(var),found)
    408423    ELSE
    409       CALL Get_var_rgen(var_name,var,size(var))
     424      CALL Get_var_rgen(nid_start,var_name,var,size(var))
    410425    ENDIF
    411426 
    412427  END SUBROUTINE get_var_r3
    413428
    414   SUBROUTINE Get_var_rgen(var_name,var,var_size,found)
     429  SUBROUTINE Get_var_rgen(nid_start,var_name,var,var_size,found)
    415430  USE netcdf
    416431  USE dimphy
     
    418433  USE mod_phys_lmdz_para
    419434  IMPLICIT NONE
     435    INTEGER,INTENT(IN) :: nid_start
    420436    CHARACTER(LEN=*) :: var_name
    421437    INTEGER          :: var_size
     
    463479!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    464480
    465   SUBROUTINE create_restartphy(filename)
     481  SUBROUTINE create_restartphy(filename,nid_restart)
    466482  USE netcdf, only: NF90_CREATE, NF90_CLOBBER, NF90_64BIT_OFFSET, &
    467483                    NF90_NOERR, nf90_strerror, &
     
    478494  IMPLICIT NONE
    479495    CHARACTER(LEN=*),INTENT(IN) :: filename
     496    INTEGER,INTENT(INOUT)       :: nid_restart
    480497    INTEGER                     :: ierr
    481498   
     
    580597  END SUBROUTINE create_restartphy
    581598
    582   SUBROUTINE open_restartphy(filename)
     599  SUBROUTINE open_restartphy(filename,nid_restart)
    583600  USE netcdf, only: NF90_OPEN, NF90_NOERR, NF90_WRITE, nf90_strerror
    584601  USE mod_phys_lmdz_para, only: is_master
     
    586603  IMPLICIT NONE
    587604    CHARACTER(LEN=*),INTENT(IN) :: filename
     605    INTEGER,INTENT(INOUT)       :: nid_restart
    588606    INTEGER                     :: ierr
    589607   
     
    599617  END SUBROUTINE open_restartphy
    600618
    601   SUBROUTINE close_restartphy
     619  SUBROUTINE close_restartphy(nid_restart)
    602620  USE netcdf, only: NF90_CLOSE
    603621  USE mod_phys_lmdz_para, only: is_master
    604622  IMPLICIT NONE
    605     INTEGER          :: ierr
     623    INTEGER,INTENT(IN) :: nid_restart
     624    INTEGER            :: ierr
    606625
    607626    IF (is_master) THEN
     
    611630  END SUBROUTINE close_restartphy
    612631
    613   SUBROUTINE put_field_r1(field_name,title,field,time)
     632  SUBROUTINE put_field_r1(nid_restart,field_name,title,field,time)
    614633  ! For a surface field
    615634  IMPLICIT NONE
     635  INTEGER,INTENT(IN)             :: nid_restart
    616636  CHARACTER(LEN=*),INTENT(IN)    :: field_name
    617637  CHARACTER(LEN=*),INTENT(IN)    :: title
     
    621641  IF (present(time)) THEN
    622642    ! if timeindex is present, it is a time-dependent variable
    623     CALL put_field_rgen(field_name,title,field,1,time)
     643    CALL put_field_rgen(nid_restart,field_name,title,field,1,time)
    624644  ELSE
    625     CALL put_field_rgen(field_name,title,field,1)
     645    CALL put_field_rgen(nid_restart,field_name,title,field,1)
    626646  ENDIF
    627647 
    628648  END SUBROUTINE put_field_r1
    629649
    630   SUBROUTINE put_field_r2(field_name,title,field,time)
     650  SUBROUTINE put_field_r2(nid_restart,field_name,title,field,time)
    631651  ! For a "3D" horizontal-vertical field
    632652  IMPLICIT NONE
     653  INTEGER,INTENT(IN)             :: nid_restart
    633654  CHARACTER(LEN=*),INTENT(IN)    :: field_name
    634655  CHARACTER(LEN=*),INTENT(IN)    :: title
     
    638659  IF (present(time)) THEN
    639660    ! if timeindex is present, it is a time-dependent variable
    640     CALL put_field_rgen(field_name,title,field,size(field,2),time)
     661    CALL put_field_rgen(nid_restart,field_name,title,field,size(field,2),time)
    641662  ELSE
    642     CALL put_field_rgen(field_name,title,field,size(field,2))
     663    CALL put_field_rgen(nid_restart,field_name,title,field,size(field,2))
    643664  ENDIF
    644665 
    645666  END SUBROUTINE put_field_r2
    646667
    647   SUBROUTINE put_field_r3(field_name,title,field,time)
     668  SUBROUTINE put_field_r3(nid_restart,field_name,title,field,time)
    648669  ! For a "4D" field surf/alt/??
    649670  IMPLICIT NONE
     671  INTEGER,INTENT(IN)             :: nid_restart
    650672  CHARACTER(LEN=*),INTENT(IN)    :: field_name
    651673  CHARACTER(LEN=*),INTENT(IN)    :: title
     
    655677  IF (present(time)) THEN
    656678    ! if timeindex is present, it is a time-dependent variable
    657     CALL put_field_rgen(field_name,title,field,size(field,2)*size(field,3),&
     679    CALL put_field_rgen(nid_restart,field_name,title,field,size(field,2)*size(field,3),&
    658680                        time)
    659681  ELSE 
    660     CALL put_field_rgen(field_name,title,field,size(field,2)*size(field,3))
     682    CALL put_field_rgen(nid_restart,field_name,title,field,size(field,2)*size(field,3))
    661683  ENDIF
    662684 
    663685  END SUBROUTINE put_field_r3
    664686 
    665   SUBROUTINE put_field_rgen(field_name,title,field,field_size,time)
     687  SUBROUTINE put_field_rgen(nid_restart,field_name,title,field,field_size,time)
    666688  USE netcdf
    667689  USE dimphy
     
    673695
    674696  IMPLICIT NONE
     697  INTEGER,INTENT(IN)             :: nid_restart
    675698  CHARACTER(LEN=*),INTENT(IN)    :: field_name
    676699  CHARACTER(LEN=*),INTENT(IN)    :: title
     
    918941  END SUBROUTINE put_field_rgen 
    919942 
    920   SUBROUTINE put_var_r0(var_name,title,var)
     943  SUBROUTINE put_var_r0(nid_restart,var_name,title,var)
    921944  ! Put a scalar in file
    922945   IMPLICIT NONE
     946     INTEGER,INTENT(IN)          :: nid_restart
    923947     CHARACTER(LEN=*),INTENT(IN) :: var_name
    924948     CHARACTER(LEN=*),INTENT(IN) :: title
     
    928952     varin(1)=var
    929953     
    930      CALL put_var_rgen(var_name,title,varin,size(varin))
     954     CALL put_var_rgen(nid_restart,var_name,title,varin,size(varin))
    931955
    932956  END SUBROUTINE put_var_r0
    933957
    934958
    935   SUBROUTINE put_var_r1(var_name,title,var)
     959  SUBROUTINE put_var_r1(nid_restart,var_name,title,var)
    936960  ! Put a vector in file
    937961   IMPLICIT NONE
     962     INTEGER,INTENT(IN)          :: nid_restart
    938963     CHARACTER(LEN=*),INTENT(IN) :: var_name
    939964     CHARACTER(LEN=*),INTENT(IN) :: title
    940965     REAL,INTENT(IN)             :: var(:)
    941966     
    942      CALL put_var_rgen(var_name,title,var,size(var))
     967     CALL put_var_rgen(nid_restart,var_name,title,var,size(var))
    943968
    944969  END SUBROUTINE put_var_r1
    945970 
    946   SUBROUTINE put_var_r2(var_name,title,var)
     971  SUBROUTINE put_var_r2(nid_restart,var_name,title,var)
    947972  ! Put a 2D field in file
    948973   IMPLICIT NONE
     974     INTEGER,INTENT(IN)          :: nid_restart
    949975     CHARACTER(LEN=*),INTENT(IN) :: var_name
    950976     CHARACTER(LEN=*),INTENT(IN) :: title
    951977     REAL,INTENT(IN)             :: var(:,:)
    952978     
    953      CALL put_var_rgen(var_name,title,var,size(var))
     979     CALL put_var_rgen(nid_restart,var_name,title,var,size(var))
    954980
    955981  END SUBROUTINE put_var_r2     
    956982 
    957   SUBROUTINE put_var_r3(var_name,title,var)
     983  SUBROUTINE put_var_r3(nid_restart,var_name,title,var)
    958984  ! Put a 3D field in file
    959985   IMPLICIT NONE
     986     INTEGER,INTENT(IN)          :: nid_restart
    960987     CHARACTER(LEN=*),INTENT(IN) :: var_name
    961988     CHARACTER(LEN=*),INTENT(IN) :: title
    962989     REAL,INTENT(IN)             :: var(:,:,:)
    963990     
    964      CALL put_var_rgen(var_name,title,var,size(var))
     991     CALL put_var_rgen(nid_restart,var_name,title,var,size(var))
    965992
    966993  END SUBROUTINE put_var_r3
    967994
    968   SUBROUTINE put_var_rgen(var_name,title,var,var_size)
     995  SUBROUTINE put_var_rgen(nid_restart,var_name,title,var,var_size)
    969996  USE netcdf, only: NF90_REDEF, NF90_DEF_VAR, NF90_ENDDEF, NF90_PUT_VAR, &
    970997                    NF90_FLOAT, NF90_DOUBLE, &
     
    9761003  USE ocean_slab_mod, ONLY: nslay
    9771004  IMPLICIT NONE
     1005    INTEGER,INTENT(IN)          :: nid_restart
    9781006     CHARACTER(LEN=*),INTENT(IN) :: var_name
    9791007     CHARACTER(LEN=*),INTENT(IN) :: title
     
    10591087  END SUBROUTINE put_var_rgen     
    10601088
    1061   SUBROUTINE put_var_c1(var_name,title,var)
     1089  SUBROUTINE put_var_c1(nid_restart,var_name,title,var)
    10621090  ! Put a vector of characters in file
    10631091
     
    10691097
    10701098   IMPLICIT NONE
     1099     INTEGER,INTENT(IN)          :: nid_restart
    10711100     CHARACTER(LEN=*),INTENT(IN) :: var_name
    10721101     CHARACTER(LEN=*),INTENT(IN) :: title
  • trunk/LMDZ.GENERIC/libf/phystd/phyetat0_mod.F90

    r3522 r3552  
    44
    55real, save :: tab_cntrl_mod(100)
     6
     7integer,save :: nid_start ! NetCDF file identifier for startfi.nc file
    68
    79!$OMP THREADPRIVATE(tab_cntrl_mod)
     
    109111if (startphy_file) then
    110112  ! open physics initial state file:
    111   call open_startphy(fichnom)
     113  call open_startphy(fichnom,nid_start)
    112114
    113115  ! possibility to modify tab_cntrl in tabfi
     
    124126if (startphy_file) then
    125127  ! Load surface geopotential:
    126   call get_field("phisfi",phisfi,found)
     128  call get_field(nid_start,"phisfi",phisfi,found)
    127129  if (.not.found) then
    128130    call abort_physic(modname,"Failed loading <phisfi>",1)
     
    136138if (startphy_file) then
    137139  ! Load bare ground albedo: (will be stored in surfdat_h)
    138   call get_field("albedodat",albedodat,found)
     140  call get_field(nid_start,"albedodat",albedodat,found)
    139141  if (.not.found) then
    140142    call abort_physic(modname,"Failed loading <albedodat>",1)
     
    152154if (startphy_file) then
    153155  ! Load surface albedo (for now assume it is spectrally homogeneous)
    154   call get_field("albedo",albedo(:,1),found)
     156  call get_field(nid_start,"albedo",albedo(:,1),found)
    155157  if (.not.found) then
    156158    write(*,*) modname//": Failed loading <albedo>"
     
    173175! ZMEA
    174176if (startphy_file) then
    175   call get_field("ZMEA",zmea,found)
     177  call get_field(nid_start,"ZMEA",zmea,found)
    176178  if (.not.found) then
    177179    call abort_physic(modname,"Failed loading <ZMEA>",1)
     
    185187! ZSTD
    186188if (startphy_file) then
    187   call get_field("ZSTD",zstd,found)
     189  call get_field(nid_start,"ZSTD",zstd,found)
    188190  if (.not.found) then
    189191    call abort_physic(modname,"Failed loading <ZSTD>",1)
     
    197199! ZSIG
    198200if (startphy_file) then
    199   call get_field("ZSIG",zsig,found)
     201  call get_field(nid_start,"ZSIG",zsig,found)
    200202  if (.not.found) then
    201203    call abort_physic(modname,"Failed loading <ZSIG>",1)
     
    209211! ZGAM
    210212if (startphy_file) then
    211   call get_field("ZGAM",zgam,found)
     213  call get_field(nid_start,"ZGAM",zgam,found)
    212214  if (.not.found) then
    213215    call abort_physic(modname,"Failed loading <ZGAM>",1)
     
    221223! ZTHE
    222224if (startphy_file) then
    223   call get_field("ZTHE",zthe,found)
     225  call get_field(nid_start,"ZTHE",zthe,found)
    224226  if (.not.found) then
    225227    call abort_physic(modname,"Failed loading <ZTHE>",1)
     
    233235! Surface temperature :
    234236if (startphy_file) then
    235   call get_field("tsurf",tsurf,found,indextime)
     237  call get_field(nid_start,"tsurf",tsurf,found,indextime)
    236238  if (.not.found) then
    237239    call abort_physic(modname,"Failed loading <tsurf>",1)
     
    245247! Surface emissivity
    246248if (startphy_file) then
    247   call get_field("emis",emis,found,indextime)
     249  call get_field(nid_start,"emis",emis,found,indextime)
    248250  if (.not.found) then
    249251    call abort_physic(modname,"Failed loading <emis>",1)
     
    262264if (CLFvarying) then
    263265  if (startphy_file) then
    264     call get_field("cloudfrac",cloudfrac,found,indextime)
     266    call get_field(nid_start,"cloudfrac",cloudfrac,found,indextime)
    265267    if (.not.found) then
    266268      call abort_physic(modname,"Failed loading <cloudfrac>",1)
     
    278280if (CLFvarying) then
    279281  if (startphy_file) then
    280     call get_field("totcloudfrac",totcloudfrac,found,indextime)
     282    call get_field(nid_start,"totcloudfrac",totcloudfrac,found,indextime)
    281283    if (.not.found) then
    282284      call abort_physic(modname,"Failed loading <totcloudfrac>",1)
     
    293295! Height of oceanic ice (added by BC 2010)
    294296if (startphy_file) then
    295   call get_field("hice",hice,found,indextime)
     297  call get_field(nid_start,"hice",hice,found,indextime)
    296298  if (.not.found) then
    297299    write(*,*) "phyetat0: Failed loading <hice>"
     
    308310if (startphy_file) then
    309311  ! nature of the surface
    310   call get_field("rnat",rnat,found,indextime)
     312  call get_field(nid_start,"rnat",rnat,found,indextime)
    311313  if (.not.found) then
    312314    write(*,*) "phyetat0: Failed loading <rnat>"
     
    329331if (startphy_file) then
    330332  ! Pourcentage of sea ice cover
    331   call get_field("pctsrf_sic",pctsrf_sic,found,indextime)
     333  call get_field(nid_start,"pctsrf_sic",pctsrf_sic,found,indextime)
    332334  if (.not.found) then
    333335    write(*,*) "phyetat0: Failed loading <pctsrf_sic>"
     
    342344if (startphy_file) then
    343345  ! Slab ocean temperature (2 layers)
    344   call get_field("tslab",tslab,found,indextime)
     346  call get_field(nid_start,"tslab",tslab,found,indextime)
    345347  if (.not.found) then
    346348    write(*,*) "phyetat0: Failed loading <tslab>"
     
    359361if (startphy_file) then
    360362  ! Oceanic ice temperature
    361   call get_field("tsea_ice",tsea_ice,found,indextime)
     363  call get_field(nid_start,"tsea_ice",tsea_ice,found,indextime)
    362364  if (.not.found) then
    363365    write(*,*) "phyetat0: Failed loading <tsea_ice>"
     
    372374if (startphy_file) then
    373375  ! Oceanic ice temperature
    374   call get_field("tice",tice,found,indextime)
     376  call get_field(nid_start,"tice",tice,found,indextime)
    375377  if (.not.found) then
    376378    write(*,*) "phyetat0: Failed loading <tice>"
     
    385387if (startphy_file) then
    386388  !  Oceanic ice quantity (kg/m^2)
    387   call get_field("sea_ice",sea_ice,found,indextime)
     389  call get_field(nid_start,"sea_ice",sea_ice,found,indextime)
    388390  if (.not.found) then
    389391    write(*,*) "phyetat0: Failed loading <sea_ice>"
     
    399401! pbl wind variance
    400402if (startphy_file) then
    401   call get_field("q2",q2,found,indextime)
     403  call get_field(nid_start,"q2",q2,found,indextime)
    402404  if (.not.found) then
    403405    call abort_physic(modname,"Failed loading <q2>",1)
     
    414416    txt=noms(iq)
    415417    if (startphy_file) then
    416       call get_field(txt,qsurf(:,iq),found,indextime)
     418      call get_field(nid_start,txt,qsurf(:,iq),found,indextime)
    417419      if (.not.found) then
    418420        write(*,*) "phyetat0: Failed loading <",trim(txt),">"
     
    440442! Non-orographic gravity waves
    441443if (startphy_file) then
    442    call get_field("du_nonoro_gwd",du_nonoro_gwd,found,indextime)
     444   call get_field(nid_start,"du_nonoro_gwd",du_nonoro_gwd,found,indextime)
    443445   if (.not.found) then
    444446      write(*,*) "phyetat0: <du_nonoro_gwd> not in file"
     
    451453endif ! of if (startphy_file)
    452454if (startphy_file) then
    453    call get_field("dv_nonoro_gwd",dv_nonoro_gwd,found,indextime)
     455   call get_field(nid_start,"dv_nonoro_gwd",dv_nonoro_gwd,found,indextime)
    454456   if (.not.found) then
    455457      write(*,*) "phyetat0: <dv_nonoro_gwd> not in file"
     
    462464endif ! of if (startphy_file)
    463465if (startphy_file) then
    464    call get_field("east_gwstress",east_gwstress,found,indextime)
     466   call get_field(nid_start,"east_gwstress",east_gwstress,found,indextime)
    465467   if (.not.found) then
    466468      write(*,*) "phyetat0: <east_gwstress> not in file"
     
    473475endif ! of if (startphy_file)
    474476if (startphy_file) then
    475    call get_field("west_gwstress",west_gwstress,found,indextime)
     477   call get_field(nid_start,"west_gwstress",west_gwstress,found,indextime)
    476478   if (.not.found) then
    477479      write(*,*) "phyetat0: <west_gwstress> not in file"
     
    486488! close file:
    487489!
    488 if (startphy_file) call close_startphy
     490if (startphy_file) call close_startphy(nid_start)
    489491
    490492end subroutine phyetat0
  • trunk/LMDZ.GENERIC/libf/phystd/phyredem.F90

    r3515 r3552  
    22
    33implicit none
     4
     5INTEGER,SAVE :: nid_restart ! NetCDF file identifier for restartfi.nc file
    46
    57contains
     
    8284 
    8385  ! Create physics start file
    84   call create_restartphy(filename)
     86  call create_restartphy(filename,nid_restart)
    8587
    8688! tab_cntrl() contains run parameters
     
    135137
    136138  ! Write the controle array
    137   call put_var("controle","Control parameters",tab_cntrl)
     139  call put_var(nid_restart,"controle","Control parameters",tab_cntrl)
    138140 
    139141  ! Write the controle array descriptor
    140   call put_var("controle_descriptor",&
     142  call put_var(nid_restart,"controle_descriptor",&
    141143               "Description of control parameters",dscrpt_tab_cntrl)
    142144 
    143145  ! Write the mid-layer depths
    144   call put_var("soildepth","Soil mid-layer depth",mlayer)
     146  call put_var(nid_restart,"soildepth","Soil mid-layer depth",mlayer)
    145147 
    146148  ! Write longitudes
    147   call put_field("longitude","Longitudes of physics grid",lonfi)
     149  call put_field(nid_restart,"longitude","Longitudes of physics grid",lonfi)
    148150 
    149151  ! Write latitudes
    150   call put_field("latitude","Latitudes of physics grid",latfi)
     152  call put_field(nid_restart,"latitude","Latitudes of physics grid",latfi)
    151153 
    152154  ! Write mesh areas
    153   call put_field("area","Mesh area",cell_area)
     155  call put_field(nid_restart,"area","Mesh area",cell_area)
    154156 
    155157  ! Write surface geopotential
    156   call put_field("phisfi","Geopotential at the surface",phisfi)
     158  call put_field(nid_restart,"phisfi","Geopotential at the surface",phisfi)
    157159 
    158160  ! Write surface albedo
    159   call put_field("albedodat","Albedo of bare ground",alb)
     161  call put_field(nid_restart,"albedodat","Albedo of bare ground",alb)
    160162 
    161163  ! Subgrid topogaphy variables
    162   call put_field("ZMEA","Relief: mean relief",zmea)
    163   call put_field("ZSTD","Relief: standard deviation",zstd)
    164   call put_field("ZSIG","Relief: sigma parameter",zsig)
    165   call put_field("ZGAM","Relief: gamma parameter",zgam)
    166   call put_field("ZTHE","Relief: theta parameter",zthe)
     164  call put_field(nid_restart,"ZMEA","Relief: mean relief",zmea)
     165  call put_field(nid_restart,"ZSTD","Relief: standard deviation",zstd)
     166  call put_field(nid_restart,"ZSIG","Relief: sigma parameter",zsig)
     167  call put_field(nid_restart,"ZGAM","Relief: gamma parameter",zgam)
     168  call put_field(nid_restart,"ZTHE","Relief: theta parameter",zthe)
    167169 
    168170  ! Soil thermal inertia
    169   call put_field("inertiedat","Soil thermal inertia",ith)
     171  call put_field(nid_restart,"inertiedat","Soil thermal inertia",ith)
    170172 
    171173  ! Close file
    172   call close_restartphy
     174  call close_restartphy(nid_restart)
    173175 
    174176end subroutine physdem0
     
    217219 
    218220  ! Open file
    219   call open_restartphy(filename)
     221  call open_restartphy(filename,nid_restart)
    220222
    221223  ! First variable to write must be "Time", in order to correctly
     
    224226 
    225227  ! Surface temperature
    226   call put_field("tsurf","Surface temperature",tsurf)
     228  call put_field(nid_restart,"tsurf","Surface temperature",tsurf)
    227229 
    228230  ! Soil temperature
    229   call put_field("tsoil","Soil temperature",tsoil)
     231  call put_field(nid_restart,"tsoil","Soil temperature",tsoil)
    230232 
    231233  ! Emissivity of the surface
    232   call put_field("emis","Surface emissivity",emis)
     234  call put_field(nid_restart,"emis","Surface emissivity",emis)
    233235 
    234236  ! Surface albedo (assume homegeneous spectral albedo for now)
    235   call put_field("albedo","Surface albedo",albedo(:,1))
     237  call put_field(nid_restart,"albedo","Surface albedo",albedo(:,1))
    236238 
    237239  ! Planetary Boundary Layer
    238   call put_field("q2","pbl wind variance",q2)
     240  call put_field(nid_restart,"q2","pbl wind variance",q2)
    239241 
    240242! cloud fraction and sea ice (NB: these should be optional... to be improved)
    241   call put_field("cloudfrac","Cloud fraction",cloudfrac)
    242   call put_field("totcloudfrac","Total fraction",totcloudfrac)
    243   call put_field("hice","Height of oceanic ice",hice)
     243  call put_field(nid_restart,"cloudfrac","Cloud fraction",cloudfrac)
     244  call put_field(nid_restart,"totcloudfrac","Total fraction",totcloudfrac)
     245  call put_field(nid_restart,"hice","Height of oceanic ice",hice)
    244246
    245247 !Slab ocean
    246248 if(ok_slab_ocean) then
    247    call put_field("rnat","Nature of surface",rnat)
    248    call put_field("pctsrf_sic","Pourcentage sea ice",pctsrf_sic)
    249    call put_field("tslab","Temperature slab ocean",tslab)
    250    call put_field("tsea_ice","Temperature of top layer (seaice or snow)",tsea_ice)
    251    call put_field("tice","Temperature of seaice",tice)
    252    call put_field("sea_ice","Sea ice mass",sea_ice)
     249   call put_field(nid_restart,"rnat","Nature of surface",rnat)
     250   call put_field(nid_restart,"pctsrf_sic","Pourcentage sea ice",pctsrf_sic)
     251   call put_field(nid_restart,"tslab","Temperature slab ocean",tslab)
     252   call put_field(nid_restart,"tsea_ice","Temperature of top layer (seaice or snow)",tsea_ice)
     253   call put_field(nid_restart,"tice","Temperature of seaice",tice)
     254   call put_field(nid_restart,"sea_ice","Sea ice mass",sea_ice)
    253255 endif!(ok_slab_ocean)
    254256
     
    256258  if (nq>0) then
    257259    do iq=1,nq
    258       call put_field(noms(iq),"tracer on surface",qsurf(:,iq))
     260      call put_field(nid_restart,noms(iq),"tracer on surface",qsurf(:,iq))
    259261    enddo
    260262  endif ! of if (nq>0)
     
    262264! Non-orographic gavity waves
    263265if (calllott_nonoro) then
    264    call put_field("du_nonoro_gwd","Zonal wind tendency due to GW",du_nonoro_gwd)
    265    call put_field("dv_nonoro_gwd","Meridional wind tendency due to GW",dv_nonoro_gwd)
    266    call put_field("east_gwstress","Eastward stress profile due to GW",east_gwstress)
    267    call put_field("west_gwstress","Westward stress profile due to GW",west_gwstress)
     266   call put_field(nid_restart,"du_nonoro_gwd","Zonal wind tendency due to GW",du_nonoro_gwd)
     267   call put_field(nid_restart,"dv_nonoro_gwd","Meridional wind tendency due to GW",dv_nonoro_gwd)
     268   call put_field(nid_restart,"east_gwstress","Eastward stress profile due to GW",east_gwstress)
     269   call put_field(nid_restart,"west_gwstress","Westward stress profile due to GW",west_gwstress)
    268270endif
    269271
    270272! close file
    271       CALL close_restartphy
     273      CALL close_restartphy(nid_restart)
    272274!$OMP BARRIER
    273275
  • trunk/LMDZ.GENERIC/libf/phystd/soil_settings.F

    r1538 r3552  
    8181! -------------------
    8282! 1.1 Start by reading how many layers of soil there are
    83         dimlen=inquire_dimension_length("subsurface_layers")
     83        dimlen=inquire_dimension_length(nid,"subsurface_layers")
    8484
    8585        if (dimlen.ne.nsoil) then
     
    9797
    9898        ! check if olmlayer distribution matches current one
    99         call get_var("soildepth",oldmlayer,found)
     99        call get_var(nid,"soildepth",oldmlayer,found)
    100100        if (found) then
    101101          malpha=oldmlayer(2)/oldmlayer(1)
     
    117117       
    118118! 1.2 Find out the # of dimensions <inertiedat> was defined as using
    119       ndims=inquire_field_ndims("inertiedat")
     119      ndims=inquire_field_ndims(nid,"inertiedat")
    120120! 1.3 Read depths values or set olddepthdef flag and values
    121121      if (ndims.eq.1) then ! we know that there is none
     
    138138        ! read <depth> coordinate
    139139        if (interpol) then !put values in oldmlayer
    140           call get_var("soildepth",oldmlayer,found)
     140          call get_var(nid,"soildepth",oldmlayer,found)
    141141          if (.not.found) then
    142142            write(*,*)'soil_settings: Problem while reading <soildepth>'
    143143          endif
    144144        else ! put values in mlayer
    145           call get_var("soildepth",mlayer,found)
     145          call get_var(nid,"soildepth",mlayer,found)
    146146          print*,"mlayer",mlayer
    147147          if (.not.found) then
     
    205205       ! Read Surface thermal inertia
    206206       allocate(surfinertia(ngrid))
    207        call get_field("inertiedat",surfinertia,found)
     207       call get_field(nid,"inertiedat",surfinertia,found)
    208208       if (.not.found) then
    209209         write(*,*) "soil_settings: Failed loading <inertiedat>"
     
    228228           endif
    229229         endif ! of if (.not.allocated(oldinertiedat))
    230         call get_field("inertiedat",oldinertiedat,found)
     230        call get_field(nid,"inertiedat",oldinertiedat,found)
    231231        if (.not.found) then
    232232          write(*,*) "soil_settings: Failed loading <inertiedat>"
     
    234234        endif
    235235       else ! put values in therm_i
    236          call get_field("inertiedat",inertiedat,found)
     236         call get_field(nid,"inertiedat",inertiedat,found)
    237237         if (.not.found) then
    238238           write(*,*) "soil_settings: Failed loading <inertiedat>"
     
    246246! -------------------------
    247247!      ierr=nf90_inq_varid(nid,"tsoil",nvarid)
    248       ok=inquire_field("tsoil")
     248      ok=inquire_field(nid,"tsoil")
    249249!      if (ierr.ne.nf90_noerr) then
    250250      if (.not.ok) then
     
    264264           endif
    265265         endif
    266          call get_field("tsoil",oldtsoil,found)
     266         call get_field(nid,"tsoil",oldtsoil,found)
    267267         if (.not.found) then
    268268           write(*,*) "soil_settings: Failed loading <tsoil>"
     
    270270         endif
    271271       else ! put values in tsoil
    272          call get_field("tsoil",tsoil,found,timeindex=indextime)
     272         call get_field(nid,"tsoil",tsoil,found,
     273     &                  timeindex=indextime)
    273274         if (.not.found) then
    274275           write(*,*) "soil_settings: Failed loading <tsoil>"
  • trunk/LMDZ.GENERIC/libf/phystd/tabfi_mod.F90

    r3515 r3552  
    157157!
    158158
    159        call get_var("controle",tab_cntrl,found)
     159       call get_var(nid,"controle",tab_cntrl,found)
    160160       if (.not.found) then
    161161         call abort_physic(modname,"Failed reading <controle> array",1)
Note: See TracChangeset for help on using the changeset viewer.