Changeset 2528


Ignore:
Timestamp:
May 27, 2021, 9:41:55 AM (4 years ago)
Author:
cmathe
Message:

MARS: update zrecast utility

Location:
trunk/LMDZ.MARS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/README

    r2527 r2528  
    33873387== 26/05/2021 == JN
    33883388Bug correction in testphys1d.F, when calling "phys_start_var_init"
     3389
     3390== 27/05/2021 == FF+CM
     3391Update zrecast utility:
     3392 - conversion to pressure coordinate possible even if temperature is not available
     3393 - phisinit added to the output file
     3394 - vertical interpolation in log coordinates for variable with name starting with "num_"
     3395 - mode 3 (above local surface): set to missing value when z > z_range
  • trunk/LMDZ.MARS/util/zrecast.F90

    r2432 r2528  
    6262! TN 10/2013 : Read and write controle field, if available
    6363! FF 10/2020 : Force interpolation in log space for variable starting by "rho"
     64! FF 05/2021 : Force interpolation in log space for variable starting by "num_"
     65! FF 05/2021 : "phisinit" added to the putput file
     66! FF 05/2021 : Conversion to pressure coordinate possible even if temperature
     67!              not available
    6468!
    6569implicit none
     
    8488integer outfid ! NetCDF output file ID
    8589integer lon_dimid,lat_dimid,alt_dimid,time_dimid,ctl_dimid ! NetCDF dimension IDs
    86 integer lon_varid,lat_varid,alt_varid,time_varid,ctl_varid
     90integer lon_varid,lat_varid,alt_varid,time_varid,ctl_varid,phis_varid
    8791integer gcm_layers_dimid ! NetCDF dimension ID for # of layers in GCM
    8892integer sigma_varid,aps_varid,bps_varid
     
    9498integer,dimension(4) :: datashape ! shape of 4D datasets
    9599integer,dimension(3) :: surfdatashape ! shape of 3D (surface+time) datasets
     100integer,dimension(2) :: phisdatashape ! shape of 2D (surface) datasets
    96101
    97102real :: miss_val= 1.E+20 ! special "missing value" to specify missing data
     
    140145real,dimension(:),allocatable :: zradius ! distance to center of planet
    141146logical :: have_rho ! Flag: true if density 'rho' is available
     147logical :: have_temp ! Flag: true if temperature is available in some way
    142148logical :: have_sigma ! Flag: true if sigma levels are known (false if hybrid
    143149                      !       coordinates are used)
     
    937943     ierr=NF_INQ_VARID(infid,"teta",tmpvarid)
    938944     if (ierr.ne.NF_NOERR) then
    939        stop "Error: Failed to get t or teta ID"
     945       write(*,*) "Error: Failed to get temp, t or teta ID"
     946       have_temp=.false.
     947       if (ztype.ne.1) stop
    940948     endif
    941949       ierr=NF_GET_VAR_REAL(infid,tmpvarid,teta)
    942950       if (ierr.ne.NF_NOERR) then
    943          stop "Error: Failed reading atmospheric temperature"
     951         write(*,*) "Failed reading atmospheric temperature"
     952         if (ztype.ne.1) stop
    944953       endif
    945954     
     
    953962    enddo
    954963  enddo
     964  have_temp=.true.
    955965
    956966  endif
     
    960970    stop "Error: Failed reading atmospheric temperature"
    961971  endif
     972  have_temp=.true.
    962973endif
    963974
     
    13581369endif
    13591370
     1371! Add phisinit in outputfile
     1372phisdatashape(1)=lon_dimid
     1373phisdatashape(2)=lat_dimid
     1374ierr=NF_DEF_VAR(outfid,"phisinit",NF_REAL,2,phisdatashape,phis_varid)
     1375text='Geopotential at the surface'
     1376ierr=NF_PUT_ATT_TEXT(outfid,phis_varid,'long_name',len_trim(text),text)
     1377if (ierr.ne.NF_NOERR) then
     1378  stop "Error: Problem writing long_name for phisinit"
     1379endif
     1380text='m2.s2'
     1381ierr=NF_PUT_ATT_TEXT(outfid,phis_varid,'units',len_trim(text),text)
     1382if (ierr.ne.NF_NOERR) then
     1383  stop "Error: Problem writing units for geopotential phisinit"
     1384endif
     1385
     1386
     1387
    13601388! 3.3.2 Define 3D variables (ie: surface+time variables)
    13611389
     
    13861414
    13871415! add pressure or zareoid
    1388 if (ztype.eq.1) then ! pressure vertical coordinate
     1416if ((ztype.eq.1).and.(have_temp)) then ! pressure vertical coordinate
    13891417  ! zareoid dataset
    13901418  ierr=NF_DEF_VAR(outfid,"zareoid",NF_REAL,4,datashape,za_varid)
     
    16711699endif
    16721700
     1701! write phisinit
     1702  ierr=NF_PUT_VAR_REAL(outfid,phis_varid,phisinit)
     1703  if (ierr.ne.NF_NOERR) then
     1704    write(*,*) "Error: Could not write phisinit to output file"
     1705    write(*,*) NF_STRERROR(ierr)
     1706    stop
     1707  endif
     1708
    16731709!===============================================================================
    16741710! 3.5 Write 3D variables
     
    18101846  ! interpolate dataset onto new grid
    18111847  ! check if variable is "rho" (to set flag for interpolation below)
    1812   if (var(i)(1:3).eq.'rho') then
     1848  if ((var(i)(1:3).eq.'rho').or.(var(i)(1:4).eq.'num_')) then
    18131849    j=1
    18141850    write(*,*) trim(var(i)), ' is interpolated in log scale'
     
    18661902    ! interpolate dataset onto new grid
    18671903    ! check if variable is "rho" (to set flag for interpolation below)
    1868     if (var(i)(1:3).eq.'rho') then
     1904    if ((var(i)(1:3).eq.'rho').or.(var(i)(1:4).eq.'num_')) then
    18691905      j=1
    18701906      write(*,*) trim(var(i)), ' is interpolated in log scale'
     
    19221958  ! interpolate dataset onto new grid
    19231959  ! check if variable is "rho" (to set flag for interpolation below)
    1924   if (var(i)(1:3).eq.'rho') then
     1960  if ((var(i)(1:3).eq.'rho').or.(var(i)(1:4).eq.'num_')) then
    19251961    j=1
    19261962    write(*,*) trim(var(i)), ' is interpolated in log scale'
     
    28392875        else if (z_new(kloop).gt.z_gcm(iloop,jloop,altlen,tloop)) then
    28402876          ! z_new(kloop) is above highest GCM level
    2841           newdata(iloop,jloop,kloop,tloop)=gcmdata(iloop,jloop,altlen,tloop)
     2877        !  newdata(iloop,jloop,kloop,tloop)=gcmdata(iloop,jloop,altlen,tloop)
     2878          newdata(iloop,jloop,kloop,tloop)=missing
    28422879        else ! z_new(kloop) is within range
    28432880          x=z_new(kloop)
Note: See TracChangeset for help on using the changeset viewer.