Changeset 5270 for LMDZ6/trunk/libf/dyn3d_common
- Timestamp:
- Oct 24, 2024, 1:55:38 PM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/trunk/libf/dyn3d_common/grilles_gcm_netcdf_sub.f90
r5268 r5270 14 14 USE comconst_mod, ONLY: cpp, kappa, g, omeg, daysec, rad, pi 15 15 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 17 18 18 19 IMPLICIT NONE … … 21 22 INCLUDE "paramet.h" 22 23 INCLUDE "comgeom.h" 23 INCLUDE "netcdf.inc"24 24 25 25 !======================== … … 102 102 ! OPEN output netcdf file 103 103 !------------------------- 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) 105 105 CALL handle_err(status) 106 106 107 107 ! DEFINE output dimensions 108 108 !------------------------- 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) 119 119 CALL handle_err(status) 120 120 … … 124 124 status=NF90_DEF_VAR(ncid_out,'lonu',NF90_FLOAT,out_lonudim, out_lonuid) 125 125 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') 128 128 ! Longitudes on "v" dynamical grid 129 129 status=NF90_DEF_VAR(ncid_out,'lonv',NF90_FLOAT,out_lonvdim, out_lonvid) 130 130 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') 133 133 ! Latitudes on "u" dynamical grid 134 134 status=NF90_DEF_VAR(ncid_out,'latu',NF90_FLOAT,out_latudim, out_latuid) 135 135 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') 138 138 ! Latitudes on "v" dynamical grid 139 139 status=NF90_DEF_VAR(ncid_out,'latv',NF90_FLOAT,out_latvdim, out_latvid) 140 140 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') 143 143 ! "u" lat/lon dynamical grid 144 144 out_dim(1)=out_lonudim … … 146 146 status=NF90_DEF_VAR(ncid_out,'grille_u',NF90_FLOAT,out_dim, out_uid) 147 147 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') 150 150 ! "v" lat/lon dynamical grid 151 151 out_dim(1)=out_lonvdim … … 153 153 status=NF90_DEF_VAR(ncid_out,'grille_v',NF90_FLOAT,out_dim, out_vid) 154 154 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') 157 157 ! "s" (scalar) lat/lon dynamical grid 158 158 out_dim(1)=out_lonvdim … … 160 160 status=NF90_DEF_VAR(ncid_out,'grille_s',NF90_FLOAT,out_dim, out_tempid) 161 161 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') 164 164 ! 165 165 ! for INCA : … … 167 167 status=NF90_DEF_VAR(ncid_out,'presnivs',NF90_FLOAT,out_levdim, presnivs_id) 168 168 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') 171 171 ! surface geopotential height: named "phis" as the sfc geopotential, is actually phis/g 172 172 out_dim(1)=out_lonvdim … … 174 174 status = nf90_def_var(ncid_out,'phis',NF90_FLOAT,out_dim,phis_id) 175 175 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') 178 178 ! gridcell area 179 179 status = nf90_def_var(ncid_out,'aire',NF90_FLOAT,out_dim,area_id) 180 180 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') 183 183 ! land-sea mask (nearest integer approx) 184 184 status = nf90_def_var(ncid_out,'mask',NF90_INT,out_dim,mask_id) 185 185 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)') 187 187 188 188 ! END the 'define' mode in netCDF file 189 status= NF_ENDDEF(ncid_out)189 status=nf90_enddef(ncid_out) 190 190 CALL handle_err(status) 191 191 … … 232 232 233 233 SUBROUTINE handle_err(status) 234 INCLUDE "netcdf.inc" 234 USE netcdf, ONLY: nf90_noerr, nf90_strerror 235 IMPLICIT NONE 235 236 236 237 INTEGER status 237 IF (status.NE.nf _noerr) THEN238 PRINT *, NF_STRERROR(status)238 IF (status.NE.nf90_noerr) THEN 239 PRINT *,nf90_strerror(status) 239 240 CALL abort_gcm('grilles_gcm_netcdf','netcdf error',1) 240 241 ENDIF
Note: See TracChangeset
for help on using the changeset viewer.