Changeset 4259


Ignore:
Timestamp:
Sep 20, 2022, 4:09:50 PM (20 months ago)
Author:
lguez
Message:

Replace nf_put_vara_type by nf90_put_var

The immediate motivation is a bug fix: nf_put_vara_type was called
with scalar instead of array actual arguments for dummy array
arguments start and count. Correcting this, we might as well take the
opportunity to use nf90_put_var, so we no longer need to test
NC_DOUBLE and we have half as many calls.

Location:
LMDZ6/trunk/libf
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/dyn3d_common/grilles_gcm_netcdf_sub.F90

    r4258 r4259  
    1111  USE comconst_mod, ONLY: cpp, kappa, g, omeg, daysec, rad, pi
    1212  USE comvert_mod, ONLY: presnivs, preff, pa
    13   use netcdf, only: nf90_def_var, nf90_int, nf90_float
     13  use netcdf, only: nf90_def_var, nf90_int, nf90_float, nf90_put_var
    1414 
    1515  IMPLICIT NONE
     
    147147  ! rajoute l'ecriture de la grille
    148148
    149 #ifdef NC_DOUBLE
    150   status=NF_PUT_VARA_DOUBLE(ncid_out,out_lonuid,1,iim+1,rlonudeg)
    151   CALL handle_err(status)
    152   status=NF_PUT_VARA_DOUBLE(ncid_out,out_lonvid,1,iim+1,rlonvdeg)
    153   CALL handle_err(status)
    154   status=NF_PUT_VARA_DOUBLE(ncid_out,out_latuid,1,jjm+1,rlatudeg)
    155   CALL handle_err(status)
    156   status=NF_PUT_VARA_DOUBLE(ncid_out,out_latvid,1,jjm,rlatvdeg)
    157   CALL handle_err(status)
    158 #else
    159   status=NF_PUT_VARA_REAL(ncid_out,out_lonuid,1,iim+1,rlonudeg)
    160   CALL handle_err(status)
    161   status=NF_PUT_VARA_REAL(ncid_out,out_lonvid,1,iim+1,rlonvdeg)
    162   CALL handle_err(status)
    163   status=NF_PUT_VARA_REAL(ncid_out,out_latuid,1,jjm+1,rlatudeg)
    164   CALL handle_err(status)
    165   status=NF_PUT_VARA_REAL(ncid_out,out_latvid,1,jjm,rlatvdeg)
    166   CALL handle_err(status)
    167 #endif
     149  status=NF90_PUT_VAR(ncid_out,out_lonuid,rlonudeg,[1],[iim+1])
     150  CALL handle_err(status)
     151  status=NF90_PUT_VAR(ncid_out,out_lonvid,rlonvdeg,[1],[iim+1])
     152  CALL handle_err(status)
     153  status=NF90_PUT_VAR(ncid_out,out_latuid,rlatudeg,[1],[jjm+1])
     154  CALL handle_err(status)
     155  status=NF90_PUT_VAR(ncid_out,out_latvid,rlatvdeg,[1],[jjm])
     156  CALL handle_err(status)
    168157
    169158  start(1)=1
     
    183172  ENDDO
    184173
    185 #ifdef NC_DOUBLE
    186   status=NF_PUT_VARA_DOUBLE(ncid_out,out_varid,start, count,temp)
    187   CALL handle_err(status)
    188 #else
    189   status=NF_PUT_VARA_REAL(ncid_out,out_varid,start, count,temp)
    190   CALL handle_err(status)
    191 #endif
     174  status=NF90_PUT_VAR(ncid_out,out_varid,temp,start, count)
     175  CALL handle_err(status)
    192176
    193177  ! On re-ouvre le fichier pour rajouter 4 nouvelles variables necessaire pour INCA
     
    221205
    222206  ! ecriture des variables
    223 #ifdef NC_DOUBLE
    224   status=NF_PUT_VARA_DOUBLE(ncid_out,presnivs_id,1,llm,rlevdeg)
    225   CALL handle_err(status)
    226 #else
    227   status=NF_PUT_VARA_REAL(ncid_out,presnivs_id,1,llm,rlevdeg)
    228   CALL handle_err(status)
    229 #endif
     207  status=NF90_PUT_VAR(ncid_out,presnivs_id,rlevdeg,[1],[llm])
     208  CALL handle_err(status)
    230209
    231210  start(1)=1
     
    238217  COUNT(4)=0
    239218
    240   status = nf_put_vara_double(ncid_out, phis_id,start,count, phis_loc)
    241   CALL handle_err(status)
    242   status = nf_put_vara_double(ncid_out, area_id,start,count, aire)
     219  status = nf90_put_var(ncid_out, phis_id, phis_loc,start,count)
     220  CALL handle_err(status)
     221  status = nf90_put_var(ncid_out, area_id, aire,start,count)
    243222  CALL handle_err(status)
    244223  masque_int(:,:) = nINT(masque(:,:))
    245   status = nf_put_vara_int(ncid_out, mask_id,start,count,masque_int)
     224  status = nf90_put_var(ncid_out, mask_id,masque_int,start,count)
    246225  CALL handle_err(status)
    247226 
  • LMDZ6/trunk/libf/phylmd/iotd_ecrit.F90

    r3978 r4259  
    2222!=================================================================
    2323 
     24      use netcdf, only: nf90_put_var
    2425      implicit none
    2526
     
    108109
    109110
    110            ierr= NF_PUT_VARA_REAL(nid,varid,ntime,1,date)
     111           ierr= NF90_PUT_VAR(nid,varid,date,[ntime])
    111112
    112113!          print*,'date ',date,ierr,nid
     
    172173
    173174
    174       ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,zx)
     175      ierr= NF90_PUT_VAR(nid,varid,zx,corner,edges)
    175176
    176177      if (ierr.ne.NF_NOERR) then
Note: See TracChangeset for help on using the changeset viewer.