Ignore:
Timestamp:
Oct 24, 2024, 1:55:38 PM (5 weeks ago)
Author:
abarral
Message:

Replace F77 netcdf library by F90 netcdf library

File:
1 edited

Legend:

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

    r5268 r5270  
    1414  USE comconst_mod, ONLY: cpp, kappa, g, omeg, daysec, rad, pi
    1515  USE comvert_mod, ONLY: presnivs, preff, pa
    16   use netcdf, only: nf90_def_var, nf90_int, nf90_float, nf90_put_var
     16  USE netcdf, ONLY: nf90_def_var, nf90_int, nf90_float, nf90_put_var, nf90_clobber, nf90_64bit_offset, nf90_def_dim, &
     17          nf90_put_att, nf90_enddef, nf90_create
    1718 
    1819  IMPLICIT NONE
     
    2122  INCLUDE "paramet.h"
    2223  INCLUDE "comgeom.h"
    23   INCLUDE "netcdf.inc"
    2424
    2525!========================
     
    102102  ! OPEN output netcdf file
    103103  !-------------------------
    104   status=NF_CREATE('grilles_gcm.nc',IOR(NF_CLOBBER,NF_64BIT_OFFSET),ncid_out)
     104  status=nf90_create('grilles_gcm.nc',IOR(nf90_clobber,nf90_64bit_offset),ncid_out)
    105105  CALL handle_err(status)
    106106 
    107107  ! DEFINE output dimensions
    108108  !-------------------------
    109   status=NF_DEF_DIM(ncid_out,'lonu',iim+1,out_lonudim)
    110   CALL handle_err(status)
    111   status=NF_DEF_DIM(ncid_out,'lonv',iim+1,out_lonvdim)
    112   CALL handle_err(status)
    113   status=NF_DEF_DIM(ncid_out,'latu',jjm+1,out_latudim)
    114   CALL handle_err(status)
    115   status=NF_DEF_DIM(ncid_out,'latv',jjm,out_latvdim)
    116   CALL handle_err(status)
    117   !
    118   status=NF_DEF_DIM(ncid_out,'lev',llm,out_levdim)
     109  status=nf90_def_dim(ncid_out,'lonu',iim+1,out_lonudim)
     110  CALL handle_err(status)
     111  status=nf90_def_dim(ncid_out,'lonv',iim+1,out_lonvdim)
     112  CALL handle_err(status)
     113  status=nf90_def_dim(ncid_out,'latu',jjm+1,out_latudim)
     114  CALL handle_err(status)
     115  status=nf90_def_dim(ncid_out,'latv',jjm,out_latvdim)
     116  CALL handle_err(status)
     117  !
     118  status=nf90_def_dim(ncid_out,'lev',llm,out_levdim)
    119119  CALL handle_err(status)
    120120 
     
    124124  status=NF90_DEF_VAR(ncid_out,'lonu',NF90_FLOAT,out_lonudim, out_lonuid)
    125125  CALL handle_err(status)
    126   status=NF_PUT_ATT_TEXT(ncid_out,out_lonuid,'units', 12,'degrees_east')
    127   status=NF_PUT_ATT_TEXT(ncid_out,out_lonuid,'long_name',19,'Longitude on u grid')
     126  status=nf90_put_att(ncid_out,out_lonuid,'units','degrees_east')
     127  status=nf90_put_att(ncid_out,out_lonuid,'long_name','Longitude on u grid')
    128128  !   Longitudes on "v" dynamical grid
    129129  status=NF90_DEF_VAR(ncid_out,'lonv',NF90_FLOAT,out_lonvdim, out_lonvid)
    130130  CALL handle_err(status)
    131   status=NF_PUT_ATT_TEXT(ncid_out,out_lonvid,'units', 12,'degrees_east')
    132   status=NF_PUT_ATT_TEXT(ncid_out,out_lonvid,'long_name', 19,'Longitude on v grid')
     131  status=nf90_put_att(ncid_out,out_lonvid,'units','degrees_east')
     132  status=nf90_put_att(ncid_out,out_lonvid,'long_name','Longitude on v grid')
    133133  !   Latitudes on "u" dynamical grid
    134134  status=NF90_DEF_VAR(ncid_out,'latu',NF90_FLOAT,out_latudim, out_latuid)
    135135  CALL handle_err(status)
    136   status=NF_PUT_ATT_TEXT(ncid_out,out_latuid,'units', 13,'degrees_north')
    137   status=NF_PUT_ATT_TEXT(ncid_out,out_latuid,'long_name', 18,'Latitude on u grid')
     136  status=nf90_put_att(ncid_out,out_latuid,'units','degrees_north')
     137  status=nf90_put_att(ncid_out,out_latuid,'long_name','Latitude on u grid')
    138138  !  Latitudes on "v" dynamical grid
    139139  status=NF90_DEF_VAR(ncid_out,'latv',NF90_FLOAT,out_latvdim, out_latvid)
    140140  CALL handle_err(status)
    141   status=NF_PUT_ATT_TEXT(ncid_out,out_latvid,'units', 13,'degrees_north')
    142   status=NF_PUT_ATT_TEXT(ncid_out,out_latvid,'long_name', 18,'Latitude on v grid')
     141  status=nf90_put_att(ncid_out,out_latvid,'units','degrees_north')
     142  status=nf90_put_att(ncid_out,out_latvid,'long_name','Latitude on v grid')
    143143  !  "u" lat/lon dynamical grid
    144144  out_dim(1)=out_lonudim
     
    146146  status=NF90_DEF_VAR(ncid_out,'grille_u',NF90_FLOAT,out_dim, out_uid)
    147147  CALL handle_err(status)
    148   status=NF_PUT_ATT_TEXT(ncid_out,out_uid,'units', 3,'m/s')
    149   status=NF_PUT_ATT_TEXT(ncid_out,out_uid,'long_name', 21,'u-wind dynamical grid')
     148  status=nf90_put_att(ncid_out,out_uid,'units','m/s')
     149  status=nf90_put_att(ncid_out,out_uid,'long_name','u-wind dynamical grid')
    150150  !  "v" lat/lon dynamical grid
    151151  out_dim(1)=out_lonvdim
     
    153153  status=NF90_DEF_VAR(ncid_out,'grille_v',NF90_FLOAT,out_dim, out_vid)
    154154  CALL handle_err(status)
    155   status=NF_PUT_ATT_TEXT(ncid_out,out_vid,'units', 3,'m/s')
    156   status=NF_PUT_ATT_TEXT(ncid_out,out_vid,'long_name', 21,'v-wind dynamical grid')
     155  status=nf90_put_att(ncid_out,out_vid,'units','m/s')
     156  status=nf90_put_att(ncid_out,out_vid,'long_name','v-wind dynamical grid')
    157157  !  "s" (scalar) lat/lon dynamical grid
    158158  out_dim(1)=out_lonvdim
     
    160160  status=NF90_DEF_VAR(ncid_out,'grille_s',NF90_FLOAT,out_dim, out_tempid)
    161161  CALL handle_err(status)
    162   status=NF_PUT_ATT_TEXT(ncid_out,out_tempid,'units', 6,'Kelvin')
    163   status=NF_PUT_ATT_TEXT(ncid_out,out_tempid,'long_name',21,'scalar dynamical grid')
     162  status=nf90_put_att(ncid_out,out_tempid,'units','Kelvin')
     163  status=nf90_put_att(ncid_out,out_tempid,'long_name','scalar dynamical grid')
    164164  !
    165165  ! for INCA :
     
    167167  status=NF90_DEF_VAR(ncid_out,'presnivs',NF90_FLOAT,out_levdim, presnivs_id)
    168168  CALL handle_err(status)
    169   status=NF_PUT_ATT_TEXT(ncid_out,presnivs_id,'units', 2,'Pa')
    170   status=NF_PUT_ATT_TEXT(ncid_out,presnivs_id,'long_name',15,'Vertical levels')
     169  status=nf90_put_att(ncid_out,presnivs_id,'units','Pa')
     170  status=nf90_put_att(ncid_out,presnivs_id,'long_name','Vertical levels')
    171171  ! surface geopotential height: named "phis" as the sfc geopotential, is actually phis/g
    172172  out_dim(1)=out_lonvdim
     
    174174  status = nf90_def_var(ncid_out,'phis',NF90_FLOAT,out_dim,phis_id)
    175175  CALL handle_err(status)
    176   status=NF_PUT_ATT_TEXT(ncid_out,phis_id,'units', 1,'m')
    177   status=NF_PUT_ATT_TEXT(ncid_out,phis_id,'long_name',27,'surface geopotential height')
     176  status=nf90_put_att(ncid_out,phis_id,'units','m')
     177  status=nf90_put_att(ncid_out,phis_id,'long_name','surface geopotential height')
    178178  ! gridcell area
    179179  status = nf90_def_var(ncid_out,'aire',NF90_FLOAT,out_dim,area_id)
    180180  CALL handle_err(status)
    181   status=NF_PUT_ATT_TEXT(ncid_out,area_id,'units', 2,'m2')
    182   status=NF_PUT_ATT_TEXT(ncid_out,area_id,'long_name',13,'gridcell area')
     181  status=nf90_put_att(ncid_out,area_id,'units','m2')
     182  status=nf90_put_att(ncid_out,area_id,'long_name','gridcell area')
    183183  ! land-sea mask (nearest integer approx)
    184184  status = nf90_def_var(ncid_out,'mask',NF90_INT,out_dim,mask_id)
    185185  CALL handle_err(status)
    186   status=NF_PUT_ATT_TEXT(ncid_out,mask_id,'long_name',27,'land-sea mask (nINT approx)')
     186  status=nf90_put_att(ncid_out,mask_id,'long_name','land-sea mask (nINT approx)')
    187187 
    188188  ! END the 'define' mode in netCDF file
    189   status=NF_ENDDEF(ncid_out) 
     189  status=nf90_enddef(ncid_out)
    190190  CALL handle_err(status)
    191191 
     
    232232
    233233SUBROUTINE handle_err(status)
    234   INCLUDE "netcdf.inc"
     234  USE netcdf, ONLY: nf90_noerr, nf90_strerror
     235  IMPLICIT NONE
    235236
    236237  INTEGER status
    237   IF (status.NE.nf_noerr) THEN
    238      PRINT *,NF_STRERROR(status)
     238  IF (status.NE.nf90_noerr) THEN
     239     PRINT *,nf90_strerror(status)
    239240     CALL abort_gcm('grilles_gcm_netcdf','netcdf error',1)
    240241  ENDIF
Note: See TracChangeset for help on using the changeset viewer.