Changeset 7646 for trunk/NEMOGCM/NEMO/OPA_SRC/IOM
- Timestamp:
- 2017-02-06T10:25:03+01:00 (7 years ago)
- Location:
- trunk/NEMOGCM/NEMO/OPA_SRC/IOM
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90
r6140 r7646 18 18 PUBLIC 19 19 20 21 !22 20 !!---------------------------------------------------------------------- 23 21 !! namrun namelist parameters … … 46 44 LOGICAL :: ln_clobber !: clobber (overwrite) an existing file 47 45 INTEGER :: nn_chunksz !: chunksize (bytes) for NetCDF file (works only with iom_nf90 routines) 46 48 47 #if defined key_netcdf4 49 48 !!---------------------------------------------------------------------- … … 63 62 ! ! to produce netcdf3-compatible files 64 63 #endif 64 65 65 !$AGRIF_DO_NOT_TREAT 66 66 TYPE(snc4_ctl) :: snc4set !: netcdf4 chunking control structure (always needed for decision making) … … 95 95 !! output monitoring 96 96 !!---------------------------------------------------------------------- 97 LOGICAL :: ln_ctl !: run control for debugging 98 INTEGER :: nn_timing !: run control for timing 99 INTEGER :: nn_diacfl !: flag whether to create CFL diagnostics 100 INTEGER :: nn_print !: level of print (0 no print) 101 INTEGER :: nn_ictls !: Start i indice for the SUM control 102 INTEGER :: nn_ictle !: End i indice for the SUM control 103 INTEGER :: nn_jctls !: Start j indice for the SUM control 104 INTEGER :: nn_jctle !: End j indice for the SUM control 105 INTEGER :: nn_isplt !: number of processors following i 106 INTEGER :: nn_jsplt !: number of processors following j 107 INTEGER :: nn_bench !: benchmark parameter (0/1) 108 INTEGER :: nn_bit_cmp = 0 !: bit reproducibility (0/1) 109 97 LOGICAL :: ln_ctl !: run control for debugging 98 INTEGER :: nn_timing !: run control for timing 99 INTEGER :: nn_diacfl !: flag whether to create CFL diagnostics 100 INTEGER :: nn_print !: level of print (0 no print) 101 INTEGER :: nn_ictls !: Start i indice for the SUM control 102 INTEGER :: nn_ictle !: End i indice for the SUM control 103 INTEGER :: nn_jctls !: Start j indice for the SUM control 104 INTEGER :: nn_jctle !: End j indice for the SUM control 105 INTEGER :: nn_isplt !: number of processors following i 106 INTEGER :: nn_jsplt !: number of processors following j 107 INTEGER :: nn_bench !: benchmark parameter (0/1) 108 INTEGER :: nn_bit_cmp = 0 !: bit reproducibility (0/1) 110 109 ! 111 INTEGER :: nprint, nictls, nictle, njctls, njctle, isplt, jsplt , nbench!: OLD namelist names110 INTEGER :: nprint, nictls, nictle, njctls, njctle, isplt, jsplt !: OLD namelist names 112 111 113 112 INTEGER :: ijsplt = 1 !: nb of local domain = nb of processors … … 138 137 !! Run control 139 138 !!---------------------------------------------------------------------- 139 INTEGER :: no_print = 0 !: optional argument of fld_fill (if present, suppress some control print) 140 140 INTEGER :: nstop = 0 !: error flag (=number of reason for a premature stop run) 141 141 INTEGER :: nwarn = 0 !: warning flag (=number of warning found during the run) -
trunk/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
r6519 r7646 9 9 !! 3.4 ! 2012-12 (R. Bourdalle-Badie and G. Reffray) add C1D case 10 10 !! 3.6 ! 2014-15 DIMG format removed 11 !! 3.6 ! 2015-15 (J. Harle) Added procedure to read REAL attributes 11 12 !!-------------------------------------------------------------------- 12 13 … … 52 53 LOGICAL, PUBLIC, PARAMETER :: lk_iomput = .FALSE. !: iom_put flag 53 54 #endif 54 PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get, iom_gettime, iom_rstput, iom_put 55 PUBLIC iom_getatt, iom_use, iom_context_finalize 55 PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get 56 PUBLIC iom_getatt, iom_putatt, iom_gettime, iom_rstput, iom_put 57 PUBLIC iom_use, iom_context_finalize 56 58 57 59 PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d … … 67 69 END INTERFACE 68 70 INTERFACE iom_getatt 69 MODULE PROCEDURE iom_g0d_intatt 71 MODULE PROCEDURE iom_g0d_iatt, iom_g0d_ratt, iom_g0d_catt 72 END INTERFACE 73 INTERFACE iom_putatt 74 MODULE PROCEDURE iom_p0d_iatt, iom_p0d_ratt, iom_p0d_catt 70 75 END INTERFACE 71 76 INTERFACE iom_rstput … … 93 98 CHARACTER(len=*), INTENT(in) :: cdname 94 99 #if defined key_iomput 95 TYPE(xios_time) :: dtime = xios_time(0, 0, 0, 0, 0, 0) 96 CHARACTER(len=19) :: cldate 100 101 TYPE(xios_duration) :: dtime = xios_duration(0, 0, 0, 0, 0, 0) 102 TYPE(xios_date) :: start_date 97 103 CHARACTER(len=10) :: clname 98 INTEGER :: ji99 ! 100 REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: z _bnds101 !!---------------------------------------------------------------------- 102 103 ALLOCATE( z _bnds(jpk,2) )104 INTEGER :: ji, jkmin 105 ! 106 REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zt_bnds, zw_bnds 107 !!---------------------------------------------------------------------- 108 109 ALLOCATE( zt_bnds(2,jpk), zw_bnds(2,jpk) ) 104 110 105 111 clname = cdname … … 108 114 CALL iom_swap( cdname ) 109 115 110 ! calendar parameters 116 117 ! Calendar type is now defined in xml file 111 118 SELECT CASE ( nleapy ) ! Choose calendar for IOIPSL 112 CASE ( 1) ; CALL xios_set_context_attr(TRIM(clname), calendar_type= "Gregorian") 113 CASE ( 0) ; CALL xios_set_context_attr(TRIM(clname), calendar_type= "NoLeap") 114 CASE (30) ; CALL xios_set_context_attr(TRIM(clname), calendar_type= "D360") 119 CASE ( 1) ; CALL xios_define_calendar( TYPE = "Gregorian", time_origin = xios_date(1900,01,01,00,00,00), & 120 & start_date = xios_date(nyear,nmonth,nday,0,0,0) ) 121 CASE ( 0) ; CALL xios_define_calendar( TYPE = "NoLeap" , time_origin = xios_date(1900,01,01,00,00,00), & 122 & start_date = xios_date(nyear,nmonth,nday,0,0,0) ) 123 CASE (30) ; CALL xios_define_calendar( TYPE = "D360" , time_origin = xios_date(1900,01,01,00,00,00), & 124 & start_date = xios_date(nyear,nmonth,nday,0,0,0) ) 115 125 END SELECT 116 WRITE(cldate,"(i4.4,'-',i2.2,'-',i2.2,' ',i2.2,':',i2.2,':00')") nyear,nmonth,nday,nhour,nminute117 CALL xios_set_context_attr(TRIM(clname), start_date=cldate )118 126 119 127 ! horizontal grid definition … … 169 177 170 178 ! Add vertical grid bounds 171 z_bnds(: ,1) = gdepw_1d(:) 172 z_bnds(1:jpkm1,2) = gdepw_1d(2:jpk) 173 z_bnds(jpk: ,2) = gdepw_1d(jpk) + e3t_1d(jpk) 174 CALL iom_set_axis_attr( "deptht", bounds=z_bnds ) 175 CALL iom_set_axis_attr( "depthu", bounds=z_bnds ) 176 CALL iom_set_axis_attr( "depthv", bounds=z_bnds ) 177 z_bnds(: ,2) = gdept_1d(:) 178 z_bnds(2:jpk,1) = gdept_1d(1:jpkm1) 179 z_bnds(1 ,1) = gdept_1d(1) - e3w_1d(1) 180 CALL iom_set_axis_attr( "depthw", bounds=z_bnds ) 179 jkmin = MIN(2,jpk) ! in case jpk=1 (i.e. sas2D) 180 zt_bnds(2,: ) = gdept_1d(:) 181 zt_bnds(1,jkmin:jpk) = gdept_1d(1:jpkm1) 182 zt_bnds(1,1 ) = gdept_1d(1) - e3w_1d(1) 183 zw_bnds(1,: ) = gdepw_1d(:) 184 zw_bnds(2,1:jpkm1 ) = gdepw_1d(jkmin:jpk) 185 zw_bnds(2,jpk: ) = gdepw_1d(jpk) + e3t_1d(jpk) 186 CALL iom_set_axis_attr( "deptht", bounds=zt_bnds ) 187 CALL iom_set_axis_attr( "depthu", bounds=zt_bnds ) 188 CALL iom_set_axis_attr( "depthv", bounds=zt_bnds ) 189 CALL iom_set_axis_attr( "depthw", bounds=zw_bnds ) 190 181 191 182 192 # if defined key_floats … … 200 210 CALL xios_update_calendar(0) 201 211 202 DEALLOCATE( z _bnds )212 DEALLOCATE( zt_bnds, zw_bnds ) 203 213 204 214 #endif … … 789 799 ENDIF 790 800 IF( PRESENT(pv_r3d) ) THEN 791 IF( idom == jpdom_data ) THEN ; icnt(3) = jpk dta801 IF( idom == jpdom_data ) THEN ; icnt(3) = jpkglo 792 802 ELSE IF( ll_depth_spec .AND. PRESENT(kstart) ) THEN ; istart(3) = kstart(3); icnt(3) = kcount(3) 793 803 ELSE ; icnt(3) = jpk … … 971 981 !! INTERFACE iom_getatt 972 982 !!---------------------------------------------------------------------- 973 SUBROUTINE iom_g0d_i ntatt( kiomid, cdatt, pvar )983 SUBROUTINE iom_g0d_iatt( kiomid, cdatt, pvar, cdvar ) 974 984 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 975 985 CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute 976 986 INTEGER , INTENT( out) :: pvar ! read field 987 CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable 977 988 ! 978 989 IF( kiomid > 0 ) THEN 979 990 IF( iom_file(kiomid)%nfid > 0 ) THEN 980 991 SELECT CASE (iom_file(kiomid)%iolib) 981 CASE (jpnf90 ) ; CALL iom_nf90_getatt( kiomid, cdatt, pvar ) 992 CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN 993 CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar ) 994 ELSE 995 CALL iom_nf90_getatt( kiomid, cdatt, pvar ) 996 ENDIF 982 997 CASE DEFAULT 983 CALL ctl_stop( 'iom_g0d_ att: accepted IO library is only jpnf90' )998 CALL ctl_stop( 'iom_g0d_iatt: accepted IO library is only jpnf90' ) 984 999 END SELECT 985 1000 ENDIF 986 1001 ENDIF 987 END SUBROUTINE iom_g0d_intatt 988 1002 END SUBROUTINE iom_g0d_iatt 1003 1004 SUBROUTINE iom_g0d_ratt( kiomid, cdatt, pvar, cdvar ) 1005 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 1006 CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute 1007 REAL(wp) , INTENT( out) :: pvar ! written field 1008 CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable 1009 ! 1010 IF( kiomid > 0 ) THEN 1011 IF( iom_file(kiomid)%nfid > 0 ) THEN 1012 SELECT CASE (iom_file(kiomid)%iolib) 1013 CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN 1014 CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar ) 1015 ELSE 1016 CALL iom_nf90_getatt( kiomid, cdatt, pvar ) 1017 ENDIF 1018 CASE DEFAULT 1019 CALL ctl_stop( 'iom_g0d_ratt: accepted IO library is only jpnf90' ) 1020 END SELECT 1021 ENDIF 1022 ENDIF 1023 END SUBROUTINE iom_g0d_ratt 1024 1025 SUBROUTINE iom_g0d_catt( kiomid, cdatt, pvar, cdvar ) 1026 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 1027 CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute 1028 CHARACTER(len=*), INTENT( out) :: pvar ! written field 1029 CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable 1030 ! 1031 IF( kiomid > 0 ) THEN 1032 IF( iom_file(kiomid)%nfid > 0 ) THEN 1033 SELECT CASE (iom_file(kiomid)%iolib) 1034 CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN 1035 CALL iom_nf90_getatt( kiomid, cdatt, pvar, cdvar=cdvar ) 1036 ELSE 1037 CALL iom_nf90_getatt( kiomid, cdatt, pvar ) 1038 ENDIF 1039 CASE DEFAULT 1040 CALL ctl_stop( 'iom_g0d_ratt: accepted IO library is only jpnf90' ) 1041 END SELECT 1042 ENDIF 1043 ENDIF 1044 END SUBROUTINE iom_g0d_catt 1045 1046 !!---------------------------------------------------------------------- 1047 !! INTERFACE iom_putatt 1048 !!---------------------------------------------------------------------- 1049 SUBROUTINE iom_p0d_iatt( kiomid, cdatt, pvar, cdvar ) 1050 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 1051 CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute 1052 INTEGER , INTENT(in ) :: pvar ! write field 1053 CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable 1054 ! 1055 IF( kiomid > 0 ) THEN 1056 IF( iom_file(kiomid)%nfid > 0 ) THEN 1057 SELECT CASE (iom_file(kiomid)%iolib) 1058 CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN 1059 CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar ) 1060 ELSE 1061 CALL iom_nf90_putatt( kiomid, cdatt, pvar ) 1062 ENDIF 1063 CASE DEFAULT 1064 CALL ctl_stop( 'iom_p0d_iatt: accepted IO library is only jpnf90' ) 1065 END SELECT 1066 ENDIF 1067 ENDIF 1068 END SUBROUTINE iom_p0d_iatt 1069 1070 SUBROUTINE iom_p0d_ratt( kiomid, cdatt, pvar, cdvar ) 1071 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 1072 CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute 1073 REAL(wp) , INTENT(in ) :: pvar ! write field 1074 CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable 1075 ! 1076 IF( kiomid > 0 ) THEN 1077 IF( iom_file(kiomid)%nfid > 0 ) THEN 1078 SELECT CASE (iom_file(kiomid)%iolib) 1079 CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN 1080 CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar ) 1081 ELSE 1082 CALL iom_nf90_putatt( kiomid, cdatt, pvar ) 1083 ENDIF 1084 CASE DEFAULT 1085 CALL ctl_stop( 'iom_p0d_ratt: accepted IO library is only jpnf90' ) 1086 END SELECT 1087 ENDIF 1088 ENDIF 1089 END SUBROUTINE iom_p0d_ratt 1090 1091 SUBROUTINE iom_p0d_catt( kiomid, cdatt, pvar, cdvar ) 1092 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 1093 CHARACTER(len=*), INTENT(in ) :: cdatt ! Name of the attribute 1094 CHARACTER(len=*), INTENT(in ) :: pvar ! write field 1095 CHARACTER(len=*), INTENT(in ), OPTIONAL :: cdvar ! Name of the variable 1096 ! 1097 IF( kiomid > 0 ) THEN 1098 IF( iom_file(kiomid)%nfid > 0 ) THEN 1099 SELECT CASE (iom_file(kiomid)%iolib) 1100 CASE (jpnf90 ) ; IF( PRESENT(cdvar) ) THEN 1101 CALL iom_nf90_putatt( kiomid, cdatt, pvar, cdvar=cdvar ) 1102 ELSE 1103 CALL iom_nf90_putatt( kiomid, cdatt, pvar ) 1104 ENDIF 1105 CASE DEFAULT 1106 CALL ctl_stop( 'iom_p0d_ratt: accepted IO library is only jpnf90' ) 1107 END SELECT 1108 ENDIF 1109 ENDIF 1110 END SUBROUTINE iom_p0d_catt 989 1111 990 1112 !!---------------------------------------------------------------------- … … 1130 1252 REAL(wp), DIMENSION(:) , OPTIONAL, INTENT(in) :: lonvalue, latvalue 1131 1253 REAL(wp), DIMENSION(:,:) , OPTIONAL, INTENT(in) :: bounds_lon, bounds_lat, area 1132 LOGICAL, DIMENSION(:,:) , OPTIONAL, INTENT(in) :: mask 1254 LOGICAL, DIMENSION(:) , OPTIONAL, INTENT(in) :: mask 1255 1133 1256 1134 1257 IF ( xios_is_valid_domain (cdid) ) THEN 1135 1258 CALL xios_set_domain_attr ( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj, & 1136 1259 & data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj , & 1137 & zoom_ibegin=zoom_ibegin, zoom_jbegin=zoom_jbegin, zoom_ni=zoom_ni, zoom_nj=zoom_nj, & 1138 & lonvalue=lonvalue, latvalue=latvalue, mask=mask, nvertex=nvertex, bounds_lon=bounds_lon, & 1139 & bounds_lat=bounds_lat, area=area ) 1140 ENDIF 1141 1260 & lonvalue_1D=lonvalue, latvalue_1D=latvalue, mask_1D=mask, nvertex=nvertex, bounds_lon_1D=bounds_lon, & 1261 & bounds_lat_1D=bounds_lat, area=area, type='curvilinear') 1262 ENDIF 1142 1263 IF ( xios_is_valid_domaingroup(cdid) ) THEN 1143 1264 CALL xios_set_domaingroup_attr( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj, & 1144 1265 & data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj , & 1145 & zoom_ibegin=zoom_ibegin, zoom_jbegin=zoom_jbegin, zoom_ni=zoom_ni, zoom_nj=zoom_nj,&1146 & lonvalue=lonvalue, latvalue=latvalue, mask=mask, nvertex=nvertex, bounds_lon=bounds_lon, &1147 & bounds_lat=bounds_lat, area=area )1148 ENDIF 1266 & lonvalue_1D=lonvalue, latvalue_1D=latvalue, mask_1D=mask, nvertex=nvertex, bounds_lon_1D=bounds_lon, & 1267 & bounds_lat_1D=bounds_lat, area=area, type='curvilinear' ) 1268 ENDIF 1269 1149 1270 CALL xios_solve_inheritance() 1150 1271 1151 1272 END SUBROUTINE iom_set_domain_attr 1273 1274 1275 SUBROUTINE iom_set_zoom_domain_attr( cdid, ibegin, jbegin, ni, nj) 1276 CHARACTER(LEN=*) , INTENT(in) :: cdid 1277 INTEGER , OPTIONAL, INTENT(in) :: ibegin, jbegin, ni, nj 1278 1279 IF ( xios_is_valid_zoom_domain (cdid) ) THEN 1280 CALL xios_set_zoom_domain_attr ( cdid, ibegin=ibegin, jbegin=jbegin, ni=ni, & 1281 & nj=nj) 1282 ENDIF 1283 END SUBROUTINE iom_set_zoom_domain_attr 1152 1284 1153 1285 … … 1156 1288 REAL(wp), DIMENSION(:) , OPTIONAL, INTENT(in) :: paxis 1157 1289 REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) :: bounds 1290 1158 1291 IF ( PRESENT(paxis) ) THEN 1159 IF ( xios_is_valid_axis (cdid) ) CALL xios_set_axis_attr ( cdid, size=SIZE(paxis), value=paxis )1160 IF ( xios_is_valid_axisgroup(cdid) ) CALL xios_set_axisgroup_attr( cdid, size=SIZE(paxis), value=paxis )1292 IF ( xios_is_valid_axis (cdid) ) CALL xios_set_axis_attr ( cdid, n_glo=SIZE(paxis), value=paxis ) 1293 IF ( xios_is_valid_axisgroup(cdid) ) CALL xios_set_axisgroup_attr( cdid, n_glo=SIZE(paxis), value=paxis ) 1161 1294 ENDIF 1162 1295 IF ( xios_is_valid_axis (cdid) ) CALL xios_set_axis_attr ( cdid, bounds=bounds ) … … 1168 1301 SUBROUTINE iom_set_field_attr( cdid, freq_op, freq_offset ) 1169 1302 CHARACTER(LEN=*) , INTENT(in) :: cdid 1170 CHARACTER(LEN=*),OPTIONAL , INTENT(in) :: freq_op1171 CHARACTER(LEN=*),OPTIONAL , INTENT(in) :: freq_offset1303 TYPE(xios_duration),OPTIONAL , INTENT(in) :: freq_op 1304 TYPE(xios_duration),OPTIONAL , INTENT(in) :: freq_offset 1172 1305 IF ( xios_is_valid_field (cdid) ) CALL xios_set_field_attr & 1173 1306 & ( cdid, freq_op=freq_op, freq_offset=freq_offset ) … … 1189 1322 SUBROUTINE iom_get_file_attr( cdid, name, name_suffix, output_freq ) 1190 1323 CHARACTER(LEN=*) , INTENT(in ) :: cdid 1191 CHARACTER(LEN=*),OPTIONAL , INTENT(out) :: name, name_suffix, output_freq 1324 CHARACTER(LEN=*),OPTIONAL , INTENT(out) :: name, name_suffix 1325 TYPE(xios_duration), OPTIONAL , INTENT(out) :: output_freq 1192 1326 LOGICAL :: llexist1,llexist2,llexist3 1193 1327 !--------------------------------------------------------------------- 1194 1328 IF( PRESENT( name ) ) name = '' ! default values 1195 1329 IF( PRESENT( name_suffix ) ) name_suffix = '' 1196 IF( PRESENT( output_freq ) ) output_freq = ''1330 IF( PRESENT( output_freq ) ) output_freq = xios_duration(0,0,0,0,0,0) 1197 1331 IF ( xios_is_valid_file (cdid) ) THEN 1198 1332 CALL xios_solve_inheritance() … … 1215 1349 CHARACTER(LEN=*) , INTENT(in) :: cdid 1216 1350 LOGICAL, DIMENSION(:,:,:), OPTIONAL, INTENT(in) :: mask 1217 IF ( xios_is_valid_grid (cdid) ) CALL xios_set_grid_attr ( cdid, mask =mask )1218 IF ( xios_is_valid_gridgroup(cdid) ) CALL xios_set_gridgroup_attr( cdid, mask =mask )1351 IF ( xios_is_valid_grid (cdid) ) CALL xios_set_grid_attr ( cdid, mask_3D=mask ) 1352 IF ( xios_is_valid_gridgroup(cdid) ) CALL xios_set_gridgroup_attr( cdid, mask_3D=mask ) 1219 1353 CALL xios_solve_inheritance() 1220 1354 END SUBROUTINE iom_set_grid_attr … … 1258 1392 ni=nlei-nldi+1 ; nj=nlej-nldj+1 1259 1393 1260 CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi- 1, jbegin=njmpp+nldj-1, ni=ni, nj=nj)1394 CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj) 1261 1395 CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) 1262 1396 CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = RESHAPE(plon(nldi:nlei, nldj:nlej),(/ ni*nj /)), & … … 1272 1406 END SELECT 1273 1407 ! 1274 CALL iom_set_domain_attr( "grid_"//cdgrd , mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,1),(/ni ,nj /)) /= 0. )1408 CALL iom_set_domain_attr( "grid_"//cdgrd , mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,1),(/ni*nj /)) /= 0. ) 1275 1409 CALL iom_set_grid_attr ( "grid_"//cdgrd//"_3D", mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,:),(/ni,nj,jpk/)) /= 0. ) 1276 1410 ENDIF … … 1406 1540 ALLOCATE( zlon(ni*nj) ) ; zlon(:) = 0. 1407 1541 1408 CALL iom_set_domain_attr("gznl", ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-1, jbegin=njmpp+nldj-1, ni=ni, nj=nj) 1542 CALL dom_ngb( 180., 90., ix, iy, 'T' ) ! i-line that passes near the North Pole : Reference latitude (used in plots) 1543 CALL iom_set_domain_attr("gznl", ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj) 1409 1544 CALL iom_set_domain_attr("gznl", data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) 1410 1545 CALL iom_set_domain_attr("gznl", lonvalue = zlon, & 1411 1546 & latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /))) 1412 ! 1413 CALL dom_ngb( 180., 90., ix, iy, 'T' ) ! i-line that passes near the North Pole : Reference latitude (used in plots) 1414 CALL iom_set_domain_attr ('ptr', zoom_ibegin=ix, zoom_nj=jpjglo) 1547 CALL iom_set_zoom_domain_attr ("ptr", ibegin=ix-1, jbegin=0, ni=1, nj=jpjglo) 1548 ! 1415 1549 CALL iom_update_file_name('ptr') 1416 1550 ! … … 1426 1560 REAL(wp), DIMENSION(1) :: zz = 1. 1427 1561 !!---------------------------------------------------------------------- 1428 CALL iom_set_domain_attr('scalarpoint', ni_glo=jpnij, nj_glo=1, ibegin=narea, jbegin=1, ni=1, nj=1) 1562 1563 CALL iom_set_domain_attr('scalarpoint', ni_glo=jpnij, nj_glo=1, ibegin=narea-1, jbegin=0, ni=1, nj=1) 1429 1564 CALL iom_set_domain_attr('scalarpoint', data_dim=2, data_ibegin = 1, data_ni = 1, data_jbegin = 1, data_nj = 1) 1430 1565 … … 1455 1590 REAL(wp) ,DIMENSION( 3) :: zlonpira ! longitudes of pirata moorings 1456 1591 REAL(wp) ,DIMENSION( 9) :: zlatpira ! latitudes of pirata moorings 1592 TYPE(xios_duration) :: f_op, f_of 1457 1593 !!---------------------------------------------------------------------- 1458 1594 ! 1459 1595 ! frequency of the call of iom_put (attribut: freq_op) 1460 WRITE(cl1,'(i1)') 1 ; CALL iom_set_field_attr('field_definition', freq_op = cl1//'ts', freq_offset='0ts')1461 WRITE(cl1,'(i1)') nn_fsbc ; CALL iom_set_field_attr('SBC' , freq_op = cl1//'ts', freq_offset='0ts')1462 WRITE(cl1,'(i1)') nn_fsbc ; CALL iom_set_field_attr('SBC_scalar' , freq_op = cl1//'ts', freq_offset='0ts')1463 WRITE(cl1,'(i1)') nn_dttrc ; CALL iom_set_field_attr('ptrc_T' , freq_op = cl1//'ts', freq_offset='0ts')1464 WRITE(cl1,'(i1)') nn_dttrc ; CALL iom_set_field_attr('diad_T' , freq_op = cl1//'ts', freq_offset='0ts')1465 1596 f_op%timestep = 1 ; f_of%timestep = 0 ; CALL iom_set_field_attr('field_definition', freq_op=f_op, freq_offset=f_of) 1597 f_op%timestep = nn_fsbc ; f_of%timestep = 0 ; CALL iom_set_field_attr('SBC' , freq_op=f_op, freq_offset=f_of) 1598 f_op%timestep = nn_fsbc ; f_of%timestep = 0 ; CALL iom_set_field_attr('SBC_scalar' , freq_op=f_op, freq_offset=f_of) 1599 f_op%timestep = nn_dttrc ; f_of%timestep = 0 ; CALL iom_set_field_attr('ptrc_T' , freq_op=f_op, freq_offset=f_of) 1600 f_op%timestep = nn_dttrc ; f_of%timestep = 0 ; CALL iom_set_field_attr('diad_T' , freq_op=f_op, freq_offset=f_of) 1601 1466 1602 ! output file names (attribut: name) 1467 1603 DO ji = 1, 9 … … 1484 1620 ! Equatorial section (attributs: jbegin, ni, name_suffix) 1485 1621 CALL dom_ngb( 0., 0., ix, iy, cl1 ) 1486 CALL iom_set_ domain_attr ('Eq'//cl1, zoom_jbegin=iy, zoom_ni=jpiglo)1622 CALL iom_set_zoom_domain_attr ('Eq'//cl1, jbegin=iy-1, ni=jpiglo) 1487 1623 CALL iom_get_file_attr ('Eq'//cl1, name_suffix = clsuff ) 1488 1624 CALL iom_set_file_attr ('Eq'//cl1, name_suffix = TRIM(clsuff)//'_Eq') … … 1564 1700 ENDIF 1565 1701 clname = TRIM(ADJUSTL(clat))//TRIM(ADJUSTL(clon)) 1566 CALL iom_set_domain_attr (TRIM(clname)//cl1, zoom_ibegin= ix, zoom_jbegin= iy) 1702 CALL iom_set_zoom_domain_attr (TRIM(clname)//cl1, ibegin= ix-1, jbegin= iy-1) 1703 1567 1704 CALL iom_get_file_attr (TRIM(clname)//cl1, name_suffix = clsuff ) 1568 1705 CALL iom_set_file_attr (TRIM(clname)//cl1, name_suffix = TRIM(clsuff)//'_'//TRIM(clname)) … … 1593 1730 REAL(wp) :: zsec 1594 1731 LOGICAL :: llexist 1732 TYPE(xios_duration) :: output_freq 1595 1733 !!---------------------------------------------------------------------- 1596 1734 1597 1735 DO jn = 1,2 1598 1736 1599 IF( jn == 1 ) CALL iom_get_file_attr( cdid, name = clname, output_freq = clfreq ) 1737 output_freq = xios_duration(0,0,0,0,0,0) 1738 IF( jn == 1 ) CALL iom_get_file_attr( cdid, name = clname, output_freq = output_freq ) 1600 1739 IF( jn == 2 ) CALL iom_get_file_attr( cdid, name_suffix = clname ) 1601 1740 … … 1610 1749 idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@') 1611 1750 DO WHILE ( idx /= 0 ) 1612 IF ( TRIM(clfreq) /= '' ) THEN 1613 itrlen = LEN_TRIM(clfreq) 1614 IF ( clfreq(itrlen-1:itrlen) == 'mo' ) clfreq = clfreq(1:itrlen-1) 1615 clname = clname(1:idx-1)//TRIM(clfreq)//clname(idx+6:LEN_TRIM(clname)) 1616 ELSE 1751 IF ( output_freq%timestep /= 0) THEN 1752 WRITE(clfreq,'(I18,A2)')INT(output_freq%timestep),'ts' 1753 itrlen = LEN_TRIM(ADJUSTL(clfreq)) 1754 ELSE IF ( output_freq%hour /= 0 ) THEN 1755 WRITE(clfreq,'(I19,A1)')INT(output_freq%hour),'h' 1756 itrlen = LEN_TRIM(ADJUSTL(clfreq)) 1757 ELSE IF ( output_freq%day /= 0 ) THEN 1758 WRITE(clfreq,'(I19,A1)')INT(output_freq%day),'d' 1759 itrlen = LEN_TRIM(ADJUSTL(clfreq)) 1760 ELSE IF ( output_freq%month /= 0 ) THEN 1761 WRITE(clfreq,'(I19,A1)')INT(output_freq%month),'m' 1762 itrlen = LEN_TRIM(ADJUSTL(clfreq)) 1763 ELSE IF ( output_freq%year /= 0 ) THEN 1764 WRITE(clfreq,'(I19,A1)')INT(output_freq%year),'y' 1765 itrlen = LEN_TRIM(ADJUSTL(clfreq)) 1766 ELSE 1617 1767 CALL ctl_stop('error in the name of file id '//TRIM(cdid), & 1618 1768 & ' attribute output_freq is undefined -> cannot replace @freq@ in '//TRIM(clname) ) 1619 ENDIF 1620 idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@') 1769 ENDIF 1770 clname = clname(1:idx-1)//TRIM(ADJUSTL(clfreq))//clname(idx+6:LEN_TRIM(clname)) 1771 idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@') 1621 1772 END DO 1622 1773 -
trunk/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90
r6140 r7646 18 18 PRIVATE 19 19 20 INTEGER, PARAMETER, PUBLIC :: jpdom_data = 1 !: ( 1 :jpi dta, 1 :jpjdta)20 INTEGER, PARAMETER, PUBLIC :: jpdom_data = 1 !: ( 1 :jpiglo, 1 :jpjglo) !!gm to be suppressed 21 21 INTEGER, PARAMETER, PUBLIC :: jpdom_global = 2 !: ( 1 :jpiglo, 1 :jpjglo) 22 22 INTEGER, PARAMETER, PUBLIC :: jpdom_local = 3 !: One of the 3 following cases … … 39 39 INTEGER, PARAMETER, PUBLIC :: jp_i1 = 204 !: write INTEGER(1) 40 40 41 INTEGER, PARAMETER, PUBLIC :: jpmax_files = 100 42 INTEGER, PARAMETER, PUBLIC :: jpmax_vars = 600!: maximum number of variables in one file41 INTEGER, PARAMETER, PUBLIC :: jpmax_files = 100 !: maximum number of simultaneously opened file 42 INTEGER, PARAMETER, PUBLIC :: jpmax_vars = 1200 !: maximum number of variables in one file 43 43 INTEGER, PARAMETER, PUBLIC :: jpmax_dims = 4 !: maximum number of dimensions for one variable 44 44 INTEGER, PARAMETER, PUBLIC :: jpmax_digits = 5 !: maximum number of digits for the cpu number in the file name -
trunk/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90
r6140 r7646 7 7 !! 9.0 ! 06 02 (S. Masson) Adaptation to NEMO 8 8 !! " ! 07 07 (D. Storkey) Changes to iom_nf90_gettime 9 !! 3.6 ! 2015-15 (J. Harle) Added procedure to read REAL attributes 9 10 !!-------------------------------------------------------------------- 10 11 !!gm caution add !DIR nec: improved performance to be checked as well as no result changes … … 29 30 30 31 PUBLIC iom_nf90_open, iom_nf90_close, iom_nf90_varid, iom_nf90_get, iom_nf90_gettime, iom_nf90_rstput 31 PUBLIC iom_nf90_getatt 32 PUBLIC iom_nf90_getatt, iom_nf90_putatt 32 33 33 34 INTERFACE iom_nf90_get … … 35 36 END INTERFACE 36 37 INTERFACE iom_nf90_getatt 37 MODULE PROCEDURE iom_nf90_intatt 38 MODULE PROCEDURE iom_nf90_giatt, iom_nf90_gratt, iom_nf90_gcatt 39 END INTERFACE 40 INTERFACE iom_nf90_putatt 41 MODULE PROCEDURE iom_nf90_piatt, iom_nf90_pratt, iom_nf90_pcatt 38 42 END INTERFACE 39 43 INTERFACE iom_nf90_rstput … … 252 256 END FUNCTION iom_nf90_varid 253 257 258 !!---------------------------------------------------------------------- 259 !! INTERFACE iom_nf90_get 260 !!---------------------------------------------------------------------- 254 261 255 262 SUBROUTINE iom_nf90_g0d( kiomid, kvid, pvar, kstart ) … … 312 319 END SUBROUTINE iom_nf90_g123d 313 320 314 315 SUBROUTINE iom_nf90_intatt( kiomid, cdatt, pvar ) 316 !!----------------------------------------------------------------------- 317 !! *** ROUTINE iom_nf90_intatt *** 321 !!---------------------------------------------------------------------- 322 !! INTERFACE iom_nf90_getatt 323 !!---------------------------------------------------------------------- 324 325 SUBROUTINE iom_nf90_giatt( kiomid, cdatt, pv_i0d, cdvar) 326 !!----------------------------------------------------------------------- 327 !! *** ROUTINE iom_nf90_giatt *** 318 328 !! 319 329 !! ** Purpose : read an integer attribute with NF90 330 !! (either a global attribute (default) or a variable 331 !! attribute if optional variable name is supplied (cdvar)) 320 332 !!----------------------------------------------------------------------- 321 333 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 322 334 CHARACTER(len=*), INTENT(in ) :: cdatt ! attribute name 323 INTEGER , INTENT( out) :: pvar ! read field 335 INTEGER , INTENT( out) :: pv_i0d ! read field 336 CHARACTER(len=*), INTENT(in ), OPTIONAL & 337 & :: cdvar ! name of the variable 324 338 ! 325 339 INTEGER :: if90id ! temporary integer 340 INTEGER :: ivarid ! NetCDF variable Id 326 341 LOGICAL :: llok ! temporary logical 327 342 CHARACTER(LEN=100) :: clinfo ! info character 328 343 !--------------------------------------------------------------------- 329 ! 344 ! 330 345 if90id = iom_file(kiomid)%nfid 331 llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 346 IF( PRESENT(cdvar) ) THEN 347 ! check the variable exists in the file 348 llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 349 IF( llok ) THEN 350 ! check the variable has the attribute required 351 llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr 352 ELSE 353 CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found') 354 ENDIF 355 ELSE 356 llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 357 ivarid = NF90_GLOBAL 358 ENDIF 359 ! 332 360 IF( llok) THEN 333 clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt)334 CALL iom_nf90_check(NF90_GET_ATT(if90id, NF90_GLOBAL, cdatt, values=pvar), clinfo)361 clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', giatt: '//TRIM(cdatt) 362 CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_i0d), clinfo) 335 363 ELSE 336 364 CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found') 337 pvar = -999 338 ENDIF 339 ! 340 END SUBROUTINE iom_nf90_intatt 365 pv_i0d = -999 366 ENDIF 367 ! 368 END SUBROUTINE iom_nf90_giatt 369 370 SUBROUTINE iom_nf90_gratt( kiomid, cdatt, pv_r0d, cdvar) 371 !!----------------------------------------------------------------------- 372 !! *** ROUTINE iom_nf90_gratt *** 373 !! 374 !! ** Purpose : read a real attribute with NF90 375 !! (either a global attribute (default) or a variable 376 !! attribute if optional variable name is supplied (cdvar)) 377 !!----------------------------------------------------------------------- 378 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 379 CHARACTER(len=*), INTENT(in ) :: cdatt ! attribute name 380 REAL(wp) , INTENT( out) :: pv_r0d ! read field 381 CHARACTER(len=*), INTENT(in ), OPTIONAL & 382 & :: cdvar ! name of the variable 383 ! 384 INTEGER :: if90id ! temporary integer 385 INTEGER :: ivarid ! NetCDF variable Id 386 LOGICAL :: llok ! temporary logical 387 CHARACTER(LEN=100) :: clinfo ! info character 388 !--------------------------------------------------------------------- 389 ! 390 if90id = iom_file(kiomid)%nfid 391 IF( PRESENT(cdvar) ) THEN 392 ! check the variable exists in the file 393 llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 394 IF( llok ) THEN 395 ! check the variable has the attribute required 396 llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr 397 ELSE 398 CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found') 399 ENDIF 400 ELSE 401 llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 402 ivarid = NF90_GLOBAL 403 ENDIF 404 ! 405 IF( llok) THEN 406 clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', gratt: '//TRIM(cdatt) 407 CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_r0d), clinfo) 408 ELSE 409 CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found') 410 pv_r0d = -999._wp 411 ENDIF 412 ! 413 END SUBROUTINE iom_nf90_gratt 414 415 SUBROUTINE iom_nf90_gcatt( kiomid, cdatt, pv_c0d, cdvar) 416 !!----------------------------------------------------------------------- 417 !! *** ROUTINE iom_nf90_gcatt *** 418 !! 419 !! ** Purpose : read a character attribute with NF90 420 !! (either a global attribute (default) or a variable 421 !! attribute if optional variable name is supplied (cdvar)) 422 !!----------------------------------------------------------------------- 423 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 424 CHARACTER(len=*), INTENT(in ) :: cdatt ! attribute name 425 CHARACTER(len=*), INTENT( out) :: pv_c0d ! read field 426 CHARACTER(len=*), INTENT(in ), OPTIONAL & 427 & :: cdvar ! name of the variable 428 ! 429 INTEGER :: if90id ! temporary integer 430 INTEGER :: ivarid ! NetCDF variable Id 431 LOGICAL :: llok ! temporary logical 432 CHARACTER(LEN=100) :: clinfo ! info character 433 !--------------------------------------------------------------------- 434 ! 435 if90id = iom_file(kiomid)%nfid 436 IF( PRESENT(cdvar) ) THEN 437 ! check the variable exists in the file 438 llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 439 IF( llok ) THEN 440 ! check the variable has the attribute required 441 llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr 442 ELSE 443 CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found') 444 ENDIF 445 ELSE 446 llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 447 ivarid = NF90_GLOBAL 448 ENDIF 449 ! 450 IF( llok) THEN 451 clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', gcatt: '//TRIM(cdatt) 452 CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_c0d), clinfo) 453 ELSE 454 CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found') 455 pv_c0d = '!' 456 ENDIF 457 ! 458 END SUBROUTINE iom_nf90_gcatt 459 460 !!---------------------------------------------------------------------- 461 !! INTERFACE iom_nf90_putatt 462 !!---------------------------------------------------------------------- 463 464 SUBROUTINE iom_nf90_piatt( kiomid, cdatt, pv_i0d, cdvar) 465 !!----------------------------------------------------------------------- 466 !! *** ROUTINE iom_nf90_piatt *** 467 !! 468 !! ** Purpose : write an integer attribute with NF90 469 !! (either a global attribute (default) or a variable 470 !! attribute if optional variable name is supplied (cdvar)) 471 !!----------------------------------------------------------------------- 472 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 473 CHARACTER(len=*), INTENT(in ) :: cdatt ! attribute name 474 INTEGER , INTENT(in ) :: pv_i0d ! write field 475 CHARACTER(len=*), INTENT(in ), OPTIONAL & 476 & :: cdvar ! name of the variable 477 ! 478 INTEGER :: if90id ! temporary integer 479 INTEGER :: ivarid ! NetCDF variable Id 480 LOGICAL :: llok ! temporary logical 481 LOGICAL :: lenddef ! temporary logical 482 CHARACTER(LEN=100) :: clinfo ! info character 483 !--------------------------------------------------------------------- 484 ! 485 if90id = iom_file(kiomid)%nfid 486 lenddef = .false. 487 IF( PRESENT(cdvar) ) THEN 488 ! check the variable exists in the file 489 llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 490 IF( .NOT. llok ) THEN 491 CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found') 492 ENDIF 493 ELSE 494 llok = .true. 495 ivarid = NF90_GLOBAL 496 ENDIF 497 ! 498 IF( llok) THEN 499 clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', piatt: '//TRIM(cdatt) 500 IF( iom_file(kiomid)%irec /= -1 ) THEN 501 ! trick: irec used to know if the file is in define mode or not 502 ! if it is not then temporarily put it into define mode 503 CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo) 504 lenddef = .true. 505 ENDIF 506 ! 507 CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_i0d), clinfo) 508 ! 509 IF( lenddef ) THEN 510 ! file was in data mode on entry; put it back in that mode 511 CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo) 512 ENDIF 513 ELSE 514 CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written') 515 ENDIF 516 ! 517 END SUBROUTINE iom_nf90_piatt 518 519 SUBROUTINE iom_nf90_pratt( kiomid, cdatt, pv_r0d, cdvar) 520 !!----------------------------------------------------------------------- 521 !! *** ROUTINE iom_nf90_pratt *** 522 !! 523 !! ** Purpose : write a real attribute with NF90 524 !! (either a global attribute (default) or a variable 525 !! attribute if optional variable name is supplied (cdvar)) 526 !!----------------------------------------------------------------------- 527 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 528 CHARACTER(len=*), INTENT(in ) :: cdatt ! attribute name 529 REAL(wp) , INTENT(in ) :: pv_r0d ! write field 530 CHARACTER(len=*), INTENT(in ), OPTIONAL & 531 & :: cdvar ! name of the variable 532 ! 533 INTEGER :: if90id ! temporary integer 534 INTEGER :: ivarid ! NetCDF variable Id 535 LOGICAL :: llok ! temporary logical 536 LOGICAL :: lenddef ! temporary logical 537 CHARACTER(LEN=100) :: clinfo ! info character 538 !--------------------------------------------------------------------- 539 ! 540 if90id = iom_file(kiomid)%nfid 541 lenddef = .false. 542 IF( PRESENT(cdvar) ) THEN 543 ! check the variable exists in the file 544 llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 545 IF( .NOT. llok ) THEN 546 CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found') 547 ENDIF 548 ELSE 549 llok = .true. 550 ivarid = NF90_GLOBAL 551 ENDIF 552 ! 553 IF( llok) THEN 554 clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pratt: '//TRIM(cdatt) 555 IF( iom_file(kiomid)%irec /= -1 ) THEN 556 ! trick: irec used to know if the file is in define mode or not 557 ! if it is not then temporarily put it into define mode 558 CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo) 559 lenddef = .true. 560 ENDIF 561 ! 562 CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_r0d), clinfo) 563 ! 564 IF( lenddef ) THEN 565 ! file was in data mode on entry; put it back in that mode 566 CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo) 567 ENDIF 568 ELSE 569 CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written') 570 ENDIF 571 ! 572 END SUBROUTINE iom_nf90_pratt 573 574 SUBROUTINE iom_nf90_pcatt( kiomid, cdatt, pv_c0d, cdvar) 575 !!----------------------------------------------------------------------- 576 !! *** ROUTINE iom_nf90_pcatt *** 577 !! 578 !! ** Purpose : write a character attribute with NF90 579 !! (either a global attribute (default) or a variable 580 !! attribute if optional variable name is supplied (cdvar)) 581 !!----------------------------------------------------------------------- 582 INTEGER , INTENT(in ) :: kiomid ! Identifier of the file 583 CHARACTER(len=*), INTENT(in ) :: cdatt ! attribute name 584 CHARACTER(len=*), INTENT(in ) :: pv_c0d ! write field 585 CHARACTER(len=*), INTENT(in ), OPTIONAL & 586 & :: cdvar ! name of the variable 587 ! 588 INTEGER :: if90id ! temporary integer 589 INTEGER :: ivarid ! NetCDF variable Id 590 LOGICAL :: llok ! temporary logical 591 LOGICAL :: lenddef ! temporary logical 592 CHARACTER(LEN=100) :: clinfo ! info character 593 !--------------------------------------------------------------------- 594 ! 595 if90id = iom_file(kiomid)%nfid 596 lenddef = .false. 597 IF( PRESENT(cdvar) ) THEN 598 ! check the variable exists in the file 599 llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 600 IF( .NOT. llok ) THEN 601 CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found') 602 ENDIF 603 ELSE 604 llok = .true. 605 ivarid = NF90_GLOBAL 606 ENDIF 607 ! 608 IF( llok) THEN 609 clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pcatt: '//TRIM(cdatt) 610 IF( iom_file(kiomid)%irec /= -1 ) THEN 611 ! trick: irec used to know if the file is in define mode or not 612 ! if it is not then temporarily put it into define mode 613 CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo) 614 lenddef = .true. 615 ENDIF 616 ! 617 CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_c0d), clinfo) 618 ! 619 IF( lenddef ) THEN 620 ! file was in data mode on entry; put it back in that mode 621 CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo) 622 ENDIF 623 ELSE 624 CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written') 625 ENDIF 626 ! 627 END SUBROUTINE iom_nf90_pcatt 341 628 342 629
Note: See TracChangeset
for help on using the changeset viewer.