Changeset 2227 for trunk/LMDZ.MARS/util/localtime.F90
- Timestamp:
- Jan 27, 2020, 7:40:05 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.MARS/util/localtime.F90
r2215 r2227 27 27 !character (len=1) :: ccopy 28 28 ! ccpy: 'y' or 'n' answer 29 integer :: nid,ierr,miss 29 30 character (len=50) :: altlong_name,altunits,altpositive 31 ! altlong_name(): [netcdf] altitude "long_name" attribute 32 ! altunits(): [netcdf] altitude "units" attribute 33 ! altpositive(): [netcdf] altitude "positive" attribute 34 35 integer :: nid,ierr,miss,validr 30 36 ! nid: [netcdf] file ID # 31 37 ! ierr: [netcdf] subroutine returned error code … … 346 352 stop 347 353 endif 354 ! Get altitude attributes to handle files with any altitude type 355 ierr=nf_get_att_text(nid,altvar,'long_name',altlong_name) 356 ierr=nf_get_att_text(nid,altvar,'units',altunits) 357 ierr=nf_get_att_text(nid,altvar,'positive',altpositive) 348 358 349 359 if (ctllen .ne. 0) then … … 489 499 ! Initialize output file's lat,lon,alt and time dimensions 490 500 call initiate(filename,lat,lon,alt,ctl,latlen,lonlen,altlen,ctllen,& 501 altlong_name,altunits,altpositive,& 491 502 nout,latdimout,londimout,altdimout,timedimout,timevarout) 492 503 … … 602 613 ierr = NF_GET_VAR_DOUBLE(nid,varid,var3d) 603 614 miss=NF_GET_ATT_DOUBLE(nid,varid,"missing_value",missing) 604 miss=NF_GET_ATT_DOUBLE(nid,varid,"valid_range",valid_range)615 validr=NF_GET_ATT_DOUBLE(nid,varid,"valid_range",valid_range) 605 616 #else 606 617 ierr = NF_GET_VAR_REAL(nid,varid,var3d) 607 618 miss=NF_GET_ATT_REAL(nid,varid,"missing_value",missing) 608 miss=NF_GET_ATT_REAL(nid,varid,"valid_range",valid_range)619 validr=NF_GET_ATT_REAL(nid,varid,"valid_range",valid_range) 609 620 #endif 610 621 … … 679 690 ! Write "valid_range" and "missing_value" attributes in output file 680 691 if (miss.eq.NF_NOERR) then 681 call missing_value(nout,varidout,valid _range,missing)692 call missing_value(nout,varidout,validr,miss,valid_range,missing) 682 693 endif 683 694 … … 704 715 !****************************************************************************** 705 716 Subroutine initiate(filename,lat,lon,alt,ctl,latlen,lonlen,altlen,ctllen,& 717 altlong_name,altunits,altpositive,& 706 718 nout,latdimout,londimout,altdimout,timedimout,timevarout) 707 719 !============================================================================== … … 731 743 real, intent(in):: ctl(ctllen) 732 744 ! ctl(): controle 745 character (len=*), intent(in) :: altlong_name 746 ! altlong_name(): [netcdf] altitude "long_name" attribute 747 character (len=*), intent(in) :: altunits 748 ! altunits(): [netcdf] altitude "units" attribute 749 character (len=*), intent(in) :: altpositive 750 ! altpositive(): [netcdf] altitude "positive" attribute 733 751 integer, intent(out):: nout 734 752 ! nout: [netcdf] file ID … … 866 884 #endif 867 885 868 ierr = NF_PUT_ATT_TEXT (nout,nvarid, "long_name",8,"altitude")869 ierr = NF_PUT_ATT_TEXT (nout,nvarid,'units', 2,"km")870 ierr = NF_PUT_ATT_TEXT (nout,nvarid,'positive', 2,"up")886 ierr = NF_PUT_ATT_TEXT (nout,nvarid,'long_name',len_trim(adjustl(altlong_name)),adjustl(altlong_name)) 887 ierr = NF_PUT_ATT_TEXT (nout,nvarid,'units',len_trim(adjustl(altunits)),adjustl(altunits)) 888 ierr = NF_PUT_ATT_TEXT (nout,nvarid,'positive',len_trim(adjustl(altpositive)),adjustl(altpositive)) 871 889 872 890 ! End netcdf define mode … … 921 939 !============================================================================== 922 940 ! Purpose: 923 ! Copy aps(), bps() and phisinit() from input file to outp out file941 ! Copy aps(), bps() and phisinit() from input file to output file 924 942 !============================================================================== 925 943 ! Remarks: … … 1164 1182 end subroutine def_var 1165 1183 !****************************************************************************** 1166 subroutine missing_value(nout,nvarid,valid _range,missing)1184 subroutine missing_value(nout,nvarid,validr,miss,valid_range,missing) 1167 1185 !============================================================================== 1168 1186 ! Purpose: … … 1186 1204 integer, intent(in) :: nvarid 1187 1205 ! varid: [netcdf] variable ID # 1206 integer, intent(in) :: validr 1207 ! validr : [netcdf] routines return code for "valid_range" attribute 1208 integer, intent(in) :: miss 1209 ! miss : [netcdf] routines return code for "missing_value" attribute 1188 1210 real, dimension(2), intent(in) :: valid_range 1189 1211 ! valid_range(2): [netcdf] "valid_range" attribute (min and max) … … 1208 1230 1209 1231 ! Write valid_range() attribute 1210 #ifdef NC_DOUBLE 1211 ierr=NF_PUT_ATT_DOUBLE(nout,nvarid,'valid_range',NF_DOUBLE,2,valid_range) 1212 #else 1213 ierr=NF_PUT_ATT_REAL(nout,nvarid,'valid_range',NF_FLOAT,2,valid_range) 1214 #endif 1215 1216 if (ierr.ne.NF_NOERR) then 1217 print*,'missing_value: valid_range attribution failed' 1218 print*, NF_STRERROR(ierr) 1219 !write(*,*) 'NF_NOERR', NF_NOERR 1220 !CALL abort 1221 stop "" 1232 if (validr.eq.NF_NOERR) then 1233 #ifdef NC_DOUBLE 1234 ierr=NF_PUT_ATT_DOUBLE(nout,nvarid,'valid_range',NF_DOUBLE,2,valid_range) 1235 #else 1236 ierr=NF_PUT_ATT_REAL(nout,nvarid,'valid_range',NF_FLOAT,2,valid_range) 1237 #endif 1238 1239 if (ierr.ne.NF_NOERR) then 1240 print*,'missing_value: valid_range attribution failed' 1241 print*, NF_STRERROR(ierr) 1242 !write(*,*) 'NF_NOERR', NF_NOERR 1243 !CALL abort 1244 stop "" 1245 endif 1222 1246 endif 1223 1247 1224 1248 ! Write "missing_value" attribute 1225 #ifdef NC_DOUBLE 1226 ierr= NF_PUT_ATT_DOUBLE(nout,nvarid,'missing_value',NF_DOUBLE,1,missing) 1227 #else 1228 ierr= NF_PUT_ATT_REAL(nout,nvarid,'missing_value',NF_FLOAT,1,missing) 1229 #endif 1230 1231 if (ierr.NE.NF_NOERR) then 1232 print*, 'missing_value: missing value attribution failed' 1233 print*, NF_STRERROR(ierr) 1234 ! WRITE(*,*) 'NF_NOERR', NF_NOERR 1235 ! CALL abort 1236 stop "" 1249 if (miss.eq.NF_NOERR) then 1250 #ifdef NC_DOUBLE 1251 ierr= NF_PUT_ATT_DOUBLE(nout,nvarid,'missing_value',NF_DOUBLE,1,missing) 1252 #else 1253 ierr= NF_PUT_ATT_REAL(nout,nvarid,'missing_value',NF_FLOAT,1,missing) 1254 #endif 1255 1256 if (ierr.NE.NF_NOERR) then 1257 print*, 'missing_value: missing value attribution failed' 1258 print*, NF_STRERROR(ierr) 1259 ! WRITE(*,*) 'NF_NOERR', NF_NOERR 1260 ! CALL abort 1261 stop "" 1262 endif 1237 1263 endif 1238 1264
Note: See TracChangeset
for help on using the changeset viewer.