Changeset 13369 for utils/tools/SIREN/src/attribute.f90
- Timestamp:
- 2020-07-31T10:50:52+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
utils/tools/SIREN/src/attribute.f90
r12080 r13369 4 4 ! 5 5 ! DESCRIPTION: 6 !> @brief 6 !> @brief 7 7 !> This module manage attribute of variable or file. 8 8 !> … … 28 28 !> to print attribute information of one or array of attribute structure:<br/> 29 29 !> @code 30 !> CALL att_print(td_att) 30 !> CALL att_print(td_att) 31 31 !> @endcode 32 32 !> 33 33 !> to clean attribute structure:<br/> 34 34 !> @code 35 !> CALL att_clean(td_att) 35 !> CALL att_clean(td_att) 36 36 !> @endcode 37 37 !> 38 38 !> to copy attribute structure in another one (using different memory cell):<br/> 39 39 !> @code 40 !> tl_att2=att_copy(tl_att1) 40 !> tl_att2=att_copy(tl_att1) 41 41 !> @endcode 42 42 !> @note as we use pointer for the value array of the attribute structure, 43 !> the use of the assignment operator (=) to copy attribute structure 44 !> create a pointer on the same array. 43 !> the use of the assignment operator (=) to copy attribute structure 44 !> create a pointer on the same array. 45 45 !> This is not the case with this copy function. 46 46 !> … … 51 51 !> - td_att array of attribute structure 52 52 !> - cd_name attribute name 53 !> 53 !> 54 54 !> to get attribute id, read from a file:<br/> 55 55 !>@code … … 61 61 !> to get attribute name 62 62 !> - tl_att\%c_name 63 !> 63 !> 64 64 !> to get character length or the number of value store in attribute 65 65 !> - tl_att\%i_len … … 68 68 !> - tl_att\%c_value (for character attribute) 69 69 !> - tl_att\%d_value(i) (otherwise) 70 !> 71 !> to get the type number (based on NETCDF type constants) of the 70 !> 71 !> to get the type number (based on NETCDF type constants) of the 72 72 !> attribute:<br/> 73 73 !> - tl_att\%i_type … … 79 79 !> 80 80 !> @date November, 2013 - Initial Version 81 !> @date November, 2014 81 !> @date November, 2014 82 82 !> - Fix memory leaks bug 83 83 !> @date September, 2015 … … 149 149 150 150 INTERFACE att_init 151 MODULE PROCEDURE att__init_c 151 MODULE PROCEDURE att__init_c 152 152 MODULE PROCEDURE att__init_dp 153 153 MODULE PROCEDURE att__init_dp_0d … … 170 170 171 171 INTERFACE att_clean 172 MODULE PROCEDURE att__clean_unit 173 MODULE PROCEDURE att__clean_arr 172 MODULE PROCEDURE att__clean_unit 173 MODULE PROCEDURE att__clean_arr 174 174 END INTERFACE 175 175 … … 182 182 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 183 183 FUNCTION att__copy_arr(td_att) & 184 & RESULT(tf_att) 184 & RESULT(tf_att) 185 185 !------------------------------------------------------------------- 186 186 !> @brief 187 187 !> This subroutine copy a array of attribute structure in another one 188 !> @details 188 !> @details 189 189 !> see att__copy_unit 190 190 !> … … 192 192 !> attribute (ex: tl_att=att_copy(att_init()) is forbidden). 193 193 !> This will create memory leaks. 194 !> @warning to avoid infinite loop, do not use any function inside 194 !> @warning to avoid infinite loop, do not use any function inside 195 195 !> this subroutine 196 196 !> … … 198 198 !> @date November, 2013 - Initial Version 199 199 !> @date November, 2014 200 !> - use function instead of overload assignment operator 201 !> (to avoid memory leak) 202 ! 200 !> - use function instead of overload assignment operator 201 !> (to avoid memory leak) 202 !> 203 203 !> @param[in] td_att array of attribute structure 204 204 !> @return copy of input array of attribute structure … … 228 228 !> @brief 229 229 !> This subroutine copy an attribute structure in another one. 230 !> @details 230 !> @details 231 231 !> attribute value are copied in a temporary array, so input and output 232 232 !> attribute structure value do not point on the same "memory cell", and so 233 !> on are independant. 233 !> on are independant. 234 234 !> 235 235 !> @warning do not use on the output of a function who create or read an 236 236 !> attribute (ex: tl_att=att_copy(att_init()) is forbidden). 237 237 !> This will create memory leaks. 238 !> @warning to avoid infinite loop, do not use any function inside 238 !> @warning to avoid infinite loop, do not use any function inside 239 239 !> this subroutine 240 240 !> … … 242 242 !> @date November, 2013 - Initial Version 243 243 !> @date November, 2014 244 !> - use function instead of overload assignment operator (to avoid memory leak) 244 !> - use function instead of overload assignment operator (to avoid memory leak) 245 245 !> 246 246 !> @param[in] td_att attribute structure … … 333 333 !> @author J.Paul 334 334 !> @date November, 2013 - Initial Version 335 !> @date September, 2014 335 !> @date September, 2014 336 336 !> - bug fix with use of id read from attribute structure 337 337 !> … … 372 372 !------------------------------------------------------------------- 373 373 !> @brief This function initialize an attribute structure with character 374 !> value. 374 !> value. 375 375 !> 376 376 !> @author J.Paul … … 391 391 TYPE(TATT) :: tf_att 392 392 !---------------------------------------------------------------- 393 393 394 394 ! clean attribute 395 395 CALL att_clean(tf_att) … … 410 410 & RESULT (tf_att) 411 411 !------------------------------------------------------------------- 412 !> @brief This function initialize an attribute structure with array 412 !> @brief This function initialize an attribute structure with array 413 413 !> of real(8) value. 414 414 !> @details … … 479 479 & RESULT (tf_att) 480 480 !------------------------------------------------------------------- 481 !> @brief This function initialize an attribute structure with 482 !> real(8) value 481 !> @brief This function initialize an attribute structure with 482 !> real(8) value 483 483 !> @details 484 484 !> Optionaly you could specify the type of the variable to be saved. … … 509 509 ! clean attribute 510 510 CALL att_clean(tf_att) 511 511 512 512 cl_value="(/"//TRIM(fct_str(dd_value))//"/)" 513 513 … … 537 537 & RESULT (tf_att) 538 538 !------------------------------------------------------------------- 539 !> @brief This function initialize an attribute structure with array 539 !> @brief This function initialize an attribute structure with array 540 540 !> of real(4) value. 541 541 !> @details … … 571 571 ! clean attribute 572 572 CALL att_clean(tf_att) 573 573 574 574 ! array size 575 575 il_len=size(rd_value(:)) … … 586 586 CALL logger_trace( & 587 587 & " ATT INIT: attribute name: "//TRIM(ADJUSTL(cd_name))//& 588 & " attribute value "//TRIM(ADJUSTL(cl_value)) ) 588 & " attribute value "//TRIM(ADJUSTL(cl_value)) ) 589 589 590 590 tf_att%c_name=TRIM(ADJUSTL(cd_name)) … … 609 609 & RESULT (tf_att) 610 610 !------------------------------------------------------------------- 611 !> @brief This function initialize an attribute structure with 612 !> real(4) value. 611 !> @brief This function initialize an attribute structure with 612 !> real(4) value. 613 613 !> @details 614 614 !> Optionaly you could specify the type of the variable to be saved. … … 639 639 ! clean attribute 640 640 CALL att_clean(tf_att) 641 641 642 642 cl_value="(/"//TRIM(fct_str(rd_value))//"/)" 643 643 644 644 CALL logger_trace( & 645 645 & " ATT INIT: attribute name: "//TRIM(ADJUSTL(cd_name))//& 646 & " attribute value "//TRIM(ADJUSTL(cl_value)) ) 646 & " attribute value "//TRIM(ADJUSTL(cl_value)) ) 647 647 648 648 tf_att%c_name=TRIM(ADJUSTL(cd_name)) … … 667 667 & RESULT (tf_att) 668 668 !------------------------------------------------------------------- 669 !> @brief This function initialize an attribute structure with array 669 !> @brief This function initialize an attribute structure with array 670 670 !> of integer(1) value. 671 671 !> @details … … 701 701 ! clean attribute 702 702 CALL att_clean(tf_att) 703 703 704 704 ! array size 705 705 il_len=size(bd_value(:)) … … 713 713 CALL logger_trace( & 714 714 & " ATT INIT: attribute name: "//TRIM(ADJUSTL(cd_name))//& 715 & " attribute value "//TRIM(ADJUSTL(cl_value)) ) 715 & " attribute value "//TRIM(ADJUSTL(cl_value)) ) 716 716 717 717 tf_att%c_name=TRIM(ADJUSTL(cd_name)) … … 736 736 & RESULT (tf_att) 737 737 !------------------------------------------------------------------- 738 !> @brief This function initialize an attribute structure with 739 !> integer(1) value. 738 !> @brief This function initialize an attribute structure with 739 !> integer(1) value. 740 740 !> @details 741 741 !> Optionaly you could specify the type of the variable to be saved. … … 766 766 ! clean attribute 767 767 CALL att_clean(tf_att) 768 768 769 769 cl_value="(/"//TRIM(fct_str(bd_value))//"/)" 770 770 771 771 CALL logger_trace( & 772 772 & " ATT INIT: attribute name: "//TRIM(ADJUSTL(cd_name))//& 773 & " attibute value "//TRIM(ADJUSTL(cl_value)) ) 773 & " attibute value "//TRIM(ADJUSTL(cl_value)) ) 774 774 775 775 tf_att%c_name=TRIM(ADJUSTL(cd_name)) … … 779 779 ELSE 780 780 tf_att%i_type=NF90_BYTE 781 ENDIF 781 ENDIF 782 782 783 783 IF( ASSOCIATED(tf_att%d_value) )THEN … … 794 794 & RESULT (tf_att) 795 795 !------------------------------------------------------------------- 796 !> @brief This function initialize an attribute structure with array 796 !> @brief This function initialize an attribute structure with array 797 797 !> of integer(2) value. 798 798 !> @details … … 828 828 ! clean attribute 829 829 CALL att_clean(tf_att) 830 830 831 831 ! array size 832 832 il_len=size(sd_value(:)) … … 840 840 CALL logger_trace( & 841 841 & " ATT INIT: attribute name: "//TRIM(ADJUSTL(cd_name))//& 842 & " attribute value "//TRIM(ADJUSTL(cl_value)) ) 842 & " attribute value "//TRIM(ADJUSTL(cl_value)) ) 843 843 844 844 tf_att%c_name=TRIM(ADJUSTL(cd_name)) … … 863 863 & RESULT (tf_att) 864 864 !------------------------------------------------------------------- 865 !> @brief This function initialize an attribute structure with 866 !> integer(2) value. 865 !> @brief This function initialize an attribute structure with 866 !> integer(2) value. 867 867 !> @details 868 868 !> Optionaly you could specify the type of the variable to be saved. … … 893 893 ! clean attribute 894 894 CALL att_clean(tf_att) 895 895 896 896 cl_value="(/"//TRIM(fct_str(sd_value))//"/)" 897 897 898 898 CALL logger_trace( & 899 899 & " ATT INIT: attribute name: "//TRIM(ADJUSTL(cd_name))//& 900 & " attibute value "//TRIM(ADJUSTL(cl_value)) ) 900 & " attibute value "//TRIM(ADJUSTL(cl_value)) ) 901 901 902 902 tf_att%c_name=TRIM(ADJUSTL(cd_name)) … … 921 921 & RESULT(tf_att) 922 922 !------------------------------------------------------------------- 923 !> @brief This function initialize an attribute structure with array 923 !> @brief This function initialize an attribute structure with array 924 924 !> of integer(4) value. 925 925 !> @details … … 955 955 ! clean attribute 956 956 CALL att_clean(tf_att) 957 957 958 958 ! array size 959 959 il_len=size(id_value(:)) … … 967 967 CALL logger_trace( & 968 968 & " ATT INIT: attribute name: "//TRIM(ADJUSTL(cd_name))//& 969 & " attribute value "//TRIM(ADJUSTL(cl_value)) ) 969 & " attribute value "//TRIM(ADJUSTL(cl_value)) ) 970 970 971 971 tf_att%c_name=TRIM(ADJUSTL(cd_name)) … … 990 990 & RESULT (tf_att) 991 991 !------------------------------------------------------------------- 992 !> @brief This function initialize an attribute structure with 993 !> integer(4) value. 992 !> @brief This function initialize an attribute structure with 993 !> integer(4) value. 994 994 !> @details 995 995 !> Optionaly you could specify the type of the variable to be saved. … … 1020 1020 ! clean attribute 1021 1021 CALL att_clean(tf_att) 1022 1022 1023 1023 cl_value="(/"//TRIM(fct_str(id_value))//"/)" 1024 1024 1025 1025 CALL logger_trace( & 1026 1026 & " ATT INIT: attribute name: "//TRIM(ADJUSTL(cd_name))//& 1027 & " attibute value "//TRIM(ADJUSTL(cl_value)) ) 1027 & " attibute value "//TRIM(ADJUSTL(cl_value)) ) 1028 1028 1029 1029 tf_att%c_name=TRIM(ADJUSTL(cd_name)) … … 1048 1048 & RESULT (tf_att) 1049 1049 !------------------------------------------------------------------- 1050 !> @brief This function initialize an attribute structure with array 1050 !> @brief This function initialize an attribute structure with array 1051 1051 !> of integer(8) value. 1052 1052 !> @details … … 1082 1082 ! clean attribute 1083 1083 CALL att_clean(tf_att) 1084 1084 1085 1085 ! array size 1086 1086 il_len=size(kd_value(:)) … … 1094 1094 CALL logger_trace( & 1095 1095 & " ATT INIT: attribute name: "//TRIM(ADJUSTL(cd_name))//& 1096 & " attibute value "//TRIM(ADJUSTL(cl_value)) ) 1096 & " attibute value "//TRIM(ADJUSTL(cl_value)) ) 1097 1097 1098 1098 tf_att%c_name=TRIM(ADJUSTL(cd_name)) … … 1117 1117 & RESULT (tf_att) 1118 1118 !------------------------------------------------------------------- 1119 !> @brief This function initialize an attribute structure with 1120 !> integer(8) value. 1119 !> @brief This function initialize an attribute structure with 1120 !> integer(8) value. 1121 1121 !> @details 1122 1122 !> Optionaly you could specify the type of the variable to be saved. … … 1147 1147 ! clean attribute 1148 1148 CALL att_clean(tf_att) 1149 1149 1150 1150 cl_value="(/"//TRIM(fct_str(kd_value))//"/)" 1151 1151 1152 1152 CALL logger_trace( & 1153 1153 & " ATT INIT: attribute name: "//TRIM(ADJUSTL(cd_name))//& 1154 & " attibute value "//TRIM(ADJUSTL(cl_value)) ) 1154 & " attibute value "//TRIM(ADJUSTL(cl_value)) ) 1155 1155 1156 1156 tf_att%c_name=TRIM(ADJUSTL(cd_name)) … … 1174 1174 SUBROUTINE att__print_arr(td_att) 1175 1175 !------------------------------------------------------------------- 1176 !> @brief This subroutine print informations of an array of attribute. 1176 !> @brief This subroutine print informations of an array of attribute. 1177 1177 !> 1178 1178 !> @author J.Paul … … 1184 1184 IMPLICIT NONE 1185 1185 1186 ! Argument 1186 ! Argument 1187 1187 TYPE(TATT), DIMENSION(:), INTENT(IN) :: td_att 1188 1188 … … 1203 1203 !> @author J.Paul 1204 1204 !> @date November, 2013 - Initial Version 1205 !> @date September, 2014 1205 !> @date September, 2014 1206 1206 !> - take into account type of attribute. 1207 1207 ! … … 1211 1211 IMPLICIT NONE 1212 1212 1213 ! Argument 1213 ! Argument 1214 1214 TYPE(TATT), INTENT(IN) :: td_att 1215 1215 … … 1253 1253 cl_value=td_att%c_value 1254 1254 1255 CASE(NF90_BYTE) 1255 CASE(NF90_BYTE) 1256 1256 IF( td_att%i_len > 1 )THEN 1257 1257 cl_value='(/' … … 1266 1266 ENDIF 1267 1267 1268 CASE(NF90_SHORT) 1268 CASE(NF90_SHORT) 1269 1269 IF( td_att%i_len > 1 )THEN 1270 1270 cl_value='(/' … … 1279 1279 ENDIF 1280 1280 1281 CASE(NF90_INT) 1281 CASE(NF90_INT) 1282 1282 IF( td_att%i_len > 1 )THEN 1283 1283 cl_value='(/' … … 1292 1292 ENDIF 1293 1293 1294 CASE(NF90_FLOAT) 1294 CASE(NF90_FLOAT) 1295 1295 IF( td_att%i_len > 1 )THEN 1296 1296 cl_value='(/' … … 1305 1305 ENDIF 1306 1306 1307 CASE(NF90_DOUBLE) 1307 CASE(NF90_DOUBLE) 1308 1308 IF( td_att%i_len > 1 )THEN 1309 1309 cl_value='(/' … … 1333 1333 SUBROUTINE att__clean_unit(td_att) 1334 1334 !------------------------------------------------------------------- 1335 !> @brief 1335 !> @brief 1336 1336 !> This subroutine clean attribute strcuture. 1337 1337 ! 1338 1338 !> @author J.Paul 1339 1339 !> @date November, 2013 - Initial Version 1340 !> @date January, 2019 1340 !> @date January, 2019 1341 1341 !> - nullify array inside attribute structure 1342 1342 !> … … 1369 1369 SUBROUTINE att__clean_arr(td_att) 1370 1370 !------------------------------------------------------------------- 1371 !> @brief 1371 !> @brief 1372 1372 !> This subroutine clean array of attribute strcuture. 1373 1373 ! … … 1403 1403 !> - close file (bugfix) 1404 1404 !> @date May, 2019 1405 !> - read number of dummy element 1405 !> - read number of dummy element 1406 1406 !> 1407 1407 !> @param[in] cd_dummy dummy configuration file … … 1442 1442 INQUIRE(FILE=TRIM(cd_dummy), EXIST=ll_exist) 1443 1443 IF( ll_exist )THEN 1444 1444 1445 1445 il_fileid=fct_getunit() 1446 1446 1447 1447 OPEN( il_fileid, FILE=TRIM(cd_dummy), & 1448 1448 & FORM='FORMATTED', & … … 1455 1455 CALL logger_fatal("DIM GET DUMMY: opening "//TRIM(cd_dummy)) 1456 1456 ENDIF 1457 1457 1458 1458 READ( il_fileid, NML = namdum ) 1459 1459 im_ndumatt = in_ndumatt … … 1469 1469 1470 1470 ENDIF 1471 1471 1472 1472 END SUBROUTINE att_get_dummy 1473 1473 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 1489 1489 IMPLICIT NONE 1490 1490 1491 ! Argument 1491 ! Argument 1492 1492 TYPE(TATT), INTENT(IN) :: td_att 1493 1493 1494 1494 ! function 1495 1495 LOGICAL :: lf_dummy 1496 1496 1497 1497 ! loop indices 1498 1498 INTEGER(i4) :: ji
Note: See TracChangeset
for help on using the changeset viewer.