Ignore:
Timestamp:
Feb 10, 2020 8:32:41 PM (4 years ago)
Author:
suehring
Message:

Revision of the virtual-measurement module: data input from NetCDF file; removed binary output - instead parallel NetCDF output using the new data-output module; variable attributes added; further variables added that can be sampled, file connections added; Functions for coordinate transformation moved to basic_constants_and_equations; netcdf_data_input_mod: unused routines netcdf_data_input_att and netcdf_data_input_var removed; new routines to inquire fill values added; Preprocessing script (palm_cvd) to setup virtual-measurement input files provided; postprocessor combine_virtual_measurements deleted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/netcdf_data_input_mod.f90

    r4392 r4400  
    2525! -----------------
    2626! $Id$
     27! - Routine to inquire default fill values added
     28! - netcdf_data_input_att and netcdf_data_input_var routines removed
     29!
     30! 4392 2020-01-31 16:14:57Z pavelkrc
    2731! (resler) Decrease length of reading buffer (fix problem of ifort/icc compilers)
    2832!
     
    542546       INTEGER(iwp) ::  version              !< version of data set
    543547
     548       REAL(wp) ::  fillvalue = -9999.0      !< default fill value
    544549       REAL(wp) ::  origin_lat               !< latitude of lower left corner
    545550       REAL(wp) ::  origin_lon               !< longitude of lower left corner
     
    652657    LOGICAL ::  collective_read = .FALSE.      !< Enable NetCDF collective read
    653658
     659    REAL(wp), DIMENSION(8) ::  crs_list        !< list of coord_ref_sys values
     660
    654661    TYPE(global_atts_type) ::  input_file_atts !< global attributes of input file
    655662
     
    666673    END INTERFACE netcdf_data_input_check_static
    667674
    668     INTERFACE netcdf_data_input_chemistry_data                       
     675    INTERFACE netcdf_data_input_chemistry_data
    669676       MODULE PROCEDURE netcdf_data_input_chemistry_data
    670677    END INTERFACE netcdf_data_input_chemistry_data
    671    
    672     INTERFACE get_dimension_length                       
     678
     679    INTERFACE get_dimension_length
    673680       MODULE PROCEDURE get_dimension_length
    674681    END INTERFACE get_dimension_length
     682
     683    INTERFACE inquire_fill_value
     684       MODULE PROCEDURE inquire_fill_value_int
     685       MODULE PROCEDURE inquire_fill_value_real
     686    END INTERFACE inquire_fill_value
    675687
    676688    INTERFACE netcdf_data_input_inquire_file
     
    681693       MODULE PROCEDURE netcdf_data_input_init
    682694    END INTERFACE netcdf_data_input_init
    683    
    684     INTERFACE netcdf_data_input_att
    685        MODULE PROCEDURE netcdf_data_input_att_int8
    686        MODULE PROCEDURE netcdf_data_input_att_int32
    687        MODULE PROCEDURE netcdf_data_input_att_real
    688        MODULE PROCEDURE netcdf_data_input_att_string
    689     END INTERFACE netcdf_data_input_att
    690695
    691696    INTERFACE netcdf_data_input_init_3d
     
    696701       MODULE PROCEDURE netcdf_data_input_surface_data
    697702    END INTERFACE netcdf_data_input_surface_data
    698 
    699     INTERFACE netcdf_data_input_var
    700        MODULE PROCEDURE netcdf_data_input_var_char
    701        MODULE PROCEDURE netcdf_data_input_var_real_1d
    702        MODULE PROCEDURE netcdf_data_input_var_real_2d
    703     END INTERFACE netcdf_data_input_var
    704703
    705704    INTERFACE netcdf_data_input_uvem
     
    752751           chem_emis, chem_emis_att, chem_emis_att_type, chem_emis_val_type,   &
    753752           coord_ref_sys,                                                      &
     753           crs_list,                                                           &
    754754           init_3d, init_model, input_file_atts,                               &
    755755           input_file_dynamic,                                                 &
     
    781781           netcdf_data_input_init,                                             &
    782782           netcdf_data_input_init_3d,                                          &
    783            netcdf_data_input_att,                                              &
    784783           netcdf_data_input_surface_data,                                     &
    785784           netcdf_data_input_topo,                                             &
    786            netcdf_data_input_var,                                              &
    787785           get_attribute,                                                      &
    788786           get_variable,                                                       &
     
    790788           open_read_file,                                                     &
    791789           check_existence,                                                    &
     790           inquire_fill_value,                                                 &
    792791           inquire_num_variables,                                              &
    793792           inquire_variable_names,                                             &
     
    817816       INQUIRE( FILE = TRIM( input_file_chem )    // TRIM( coupling_char ),    &
    818817                EXIST = input_pids_chem )
    819        INQUIRE( FILE = TRIM( input_file_uvem ) // TRIM( coupling_char ),       &
     818       INQUIRE( FILE = TRIM( input_file_uvem )    // TRIM( coupling_char ),    &
    820819                EXIST = input_pids_uvem  )
    821820       INQUIRE( FILE = TRIM( input_file_vm )      // TRIM( coupling_char ),    &
     
    962961       init_model%origin_z        = input_file_atts%origin_z 
    963962       init_model%rotation_angle  = input_file_atts%rotation_angle 
    964            
     963
     964!
     965!--    Define list of crs attributes. This is required for coordinate
     966!--    transformation.
     967       crs_list = (/ coord_ref_sys%semi_major_axis,                            &
     968                     coord_ref_sys%inverse_flattening,                         &
     969                     coord_ref_sys%longitude_of_prime_meridian,                &
     970                     coord_ref_sys%longitude_of_central_meridian,              &
     971                     coord_ref_sys%scale_factor_at_central_meridian,           &
     972                     coord_ref_sys%latitude_of_projection_origin,              &
     973                     coord_ref_sys%false_easting,                              &
     974                     coord_ref_sys%false_northing /)
    965975!
    966976!--    In case of nested runs, each model domain might have different longitude
     
    977987
    978988    END SUBROUTINE netcdf_data_input_init
    979    
    980 !------------------------------------------------------------------------------!
    981 ! Description:
    982 ! ------------
    983 !> Read an array of characters.
    984 !------------------------------------------------------------------------------!
    985     SUBROUTINE netcdf_data_input_var_char( val, search_string, id_mod )
    986 
    987        IMPLICIT NONE
    988 
    989        CHARACTER(LEN=*) ::  search_string     !< name of the variable
    990        CHARACTER(LEN=*), DIMENSION(:) ::  val !< variable which should be read
    991        
    992        INTEGER(iwp) ::  id_mod   !< NetCDF id of input file
    993 
    994 #if defined ( __netcdf )
    995 !
    996 !--    Read variable
    997        CALL get_variable( id_mod, search_string, val )
    998 #endif           
    999 
    1000     END SUBROUTINE netcdf_data_input_var_char
    1001    
    1002 !------------------------------------------------------------------------------!
    1003 ! Description:
    1004 ! ------------
    1005 !> Read an 1D array of REAL values.
    1006 !------------------------------------------------------------------------------!
    1007     SUBROUTINE netcdf_data_input_var_real_1d( val, search_string, id_mod )
    1008 
    1009        IMPLICIT NONE
    1010 
    1011        CHARACTER(LEN=*) ::  search_string     !< name of the variable     
    1012        
    1013        INTEGER(iwp) ::  id_mod        !< NetCDF id of input file
    1014        
    1015        REAL(wp), DIMENSION(:) ::  val !< variable which should be read
    1016 
    1017 #if defined ( __netcdf )
    1018 !
    1019 !--    Read variable
    1020        CALL get_variable( id_mod, search_string, val )
    1021 #endif           
    1022 
    1023     END SUBROUTINE netcdf_data_input_var_real_1d
    1024    
    1025 !------------------------------------------------------------------------------!
    1026 ! Description:
    1027 ! ------------
    1028 !> Read an 1D array of REAL values.
    1029 !------------------------------------------------------------------------------!
    1030     SUBROUTINE netcdf_data_input_var_real_2d( val, search_string,              &
    1031                                               id_mod, d1s, d1e, d2s, d2e )
    1032 
    1033        IMPLICIT NONE
    1034 
    1035        CHARACTER(LEN=*) ::  search_string     !< name of the variable     
    1036        
    1037        INTEGER(iwp) ::  id_mod  !< NetCDF id of input file
    1038        INTEGER(iwp) ::  d1e     !< end index of first dimension to be read
    1039        INTEGER(iwp) ::  d2e     !< end index of second dimension to be read
    1040        INTEGER(iwp) ::  d1s     !< start index of first dimension to be read
    1041        INTEGER(iwp) ::  d2s     !< start index of second dimension to be read
    1042        
    1043        REAL(wp), DIMENSION(:,:) ::  val !< variable which should be read
    1044 
    1045 #if defined ( __netcdf )
    1046 !
    1047 !--    Read character variable
    1048        CALL get_variable( id_mod, search_string, val, d1s, d1e, d2s, d2e )
    1049 #endif           
    1050 
    1051     END SUBROUTINE netcdf_data_input_var_real_2d
    1052    
    1053 !------------------------------------------------------------------------------!
    1054 ! Description:
    1055 ! ------------
    1056 !> Read a global string attribute
    1057 !------------------------------------------------------------------------------!
    1058     SUBROUTINE netcdf_data_input_att_string( val, search_string, id_mod,       &
    1059                                              input_file, global, openclose,    &
    1060                                              variable_name )
    1061 
    1062        IMPLICIT NONE
    1063 
    1064        CHARACTER(LEN=*) ::  search_string !< name of the attribue
    1065        CHARACTER(LEN=*) ::  val           !< attribute
    1066        
    1067        CHARACTER(LEN=*) ::  input_file    !< name of input file
    1068        CHARACTER(LEN=*) ::  openclose     !< string indicating whether NetCDF needs to be opend or closed
    1069        CHARACTER(LEN=*) ::  variable_name !< string indicating whether NetCDF needs to be opend or closed 
    1070        
    1071        INTEGER(iwp) ::  id_mod   !< NetCDF id of input file
    1072        
    1073        LOGICAL ::  global                 !< flag indicating a global or a variable's attribute
    1074 
    1075 #if defined ( __netcdf )
    1076 !
    1077 !--    Open file in read-only mode if necessary
    1078        IF ( openclose == 'open' )  THEN
    1079           CALL open_read_file( TRIM( input_file ) // TRIM( coupling_char ), &
    1080                                   id_mod )
    1081        ENDIF
    1082 !
    1083 !--    Read global attribute
    1084        IF ( global )  THEN
    1085           CALL get_attribute( id_mod, search_string, val, global )
    1086 !
    1087 !--    Read variable attribute
    1088        ELSE
    1089           CALL get_attribute( id_mod, search_string, val, global, variable_name )
    1090        ENDIF
    1091 !
    1092 !--    Close input file
    1093        IF ( openclose == 'close' )  CALL close_input_file( id_mod )
    1094 #endif           
    1095 
    1096     END SUBROUTINE netcdf_data_input_att_string
    1097    
    1098 !------------------------------------------------------------------------------!
    1099 ! Description:
    1100 ! ------------
    1101 !> Read a global 8-bit integer attribute
    1102 !------------------------------------------------------------------------------!
    1103     SUBROUTINE netcdf_data_input_att_int8( val, search_string, id_mod,         &
    1104                                            input_file, global, openclose,      &
    1105                                            variable_name )
    1106 
    1107        IMPLICIT NONE
    1108 
    1109        CHARACTER(LEN=*) ::  search_string !< name of the attribue
    1110        
    1111        CHARACTER(LEN=*) ::  input_file    !< name of input file
    1112        CHARACTER(LEN=*) ::  openclose     !< string indicating whether NetCDF needs to be opend or closed
    1113        CHARACTER(LEN=*) ::  variable_name !< string indicating whether NetCDF needs to be opend or closed
    1114        
    1115        INTEGER(iwp) ::  id_mod   !< NetCDF id of input file
    1116        INTEGER(KIND=1) ::  val      !< value of the attribute
    1117        
    1118        LOGICAL ::  global        !< flag indicating a global or a variable's attribute
    1119 
    1120 #if defined ( __netcdf )
    1121 !
    1122 !--    Open file in read-only mode
    1123        IF ( openclose == 'open' )  THEN
    1124           CALL open_read_file( TRIM( input_file ) // TRIM( coupling_char ), &
    1125                                   id_mod )
    1126        ENDIF
    1127 !
    1128 !--    Read global attribute
    1129        IF ( global )  THEN
    1130           CALL get_attribute( id_mod, search_string, val, global )
    1131 !
    1132 !--    Read variable attribute
    1133        ELSE
    1134           CALL get_attribute( id_mod, search_string, val, global, variable_name )
    1135        ENDIF
    1136 !
    1137 !--    Finally, close input file
    1138        IF ( openclose == 'close' )  CALL close_input_file( id_mod )
    1139 #endif           
    1140 
    1141     END SUBROUTINE netcdf_data_input_att_int8
    1142    
    1143 !------------------------------------------------------------------------------!
    1144 ! Description:
    1145 ! ------------
    1146 !> Read a global 32-bit integer attribute
    1147 !------------------------------------------------------------------------------!
    1148     SUBROUTINE netcdf_data_input_att_int32( val, search_string, id_mod,        &
    1149                                             input_file, global, openclose,     &
    1150                                             variable_name )
    1151 
    1152        IMPLICIT NONE
    1153 
    1154        CHARACTER(LEN=*) ::  search_string !< name of the attribue
    1155        
    1156        CHARACTER(LEN=*) ::  input_file    !< name of input file
    1157        CHARACTER(LEN=*) ::  openclose     !< string indicating whether NetCDF needs to be opend or closed
    1158        CHARACTER(LEN=*) ::  variable_name !< string indicating whether NetCDF needs to be opend or closed
    1159        
    1160        INTEGER(iwp) ::  id_mod   !< NetCDF id of input file
    1161        INTEGER(iwp) ::  val      !< value of the attribute
    1162        
    1163        LOGICAL ::  global        !< flag indicating a global or a variable's attribute
    1164 
    1165 #if defined ( __netcdf )
    1166 !
    1167 !--    Open file in read-only mode
    1168        IF ( openclose == 'open' )  THEN
    1169           CALL open_read_file( TRIM( input_file ) // TRIM( coupling_char ), &
    1170                                   id_mod )
    1171        ENDIF
    1172 !
    1173 !--    Read global attribute
    1174        IF ( global )  THEN
    1175           CALL get_attribute( id_mod, search_string, val, global )
    1176 !
    1177 !--    Read variable attribute
    1178        ELSE
    1179           CALL get_attribute( id_mod, search_string, val, global, variable_name )
    1180        ENDIF
    1181 !
    1182 !--    Finally, close input file
    1183        IF ( openclose == 'close' )  CALL close_input_file( id_mod )
    1184 #endif           
    1185 
    1186     END SUBROUTINE netcdf_data_input_att_int32
    1187    
    1188 !------------------------------------------------------------------------------!
    1189 ! Description:
    1190 ! ------------
    1191 !> Read a global real attribute
    1192 !------------------------------------------------------------------------------!
    1193     SUBROUTINE netcdf_data_input_att_real( val, search_string, id_mod,         &
    1194                                            input_file, global, openclose,      &
    1195                                            variable_name )
    1196 
    1197        IMPLICIT NONE
    1198 
    1199        CHARACTER(LEN=*) ::  search_string !< name of the attribue
    1200        
    1201        CHARACTER(LEN=*) ::  input_file    !< name of input file
    1202        CHARACTER(LEN=*) ::  openclose     !< string indicating whether NetCDF needs to be opend or closed
    1203        CHARACTER(LEN=*) ::  variable_name !< string indicating whether NetCDF needs to be opend or closed
    1204        
    1205        INTEGER(iwp) ::  id_mod            !< NetCDF id of input file
    1206        
    1207        LOGICAL ::  global                 !< flag indicating a global or a variable's attribute
    1208        
    1209        REAL(wp) ::  val                   !< value of the attribute
    1210 
    1211 #if defined ( __netcdf )
    1212 !
    1213 !--    Open file in read-only mode
    1214        IF ( openclose == 'open' )  THEN
    1215           CALL open_read_file( TRIM( input_file ) // TRIM( coupling_char ), &
    1216                                   id_mod )
    1217        ENDIF
    1218 !
    1219 !--    Read global attribute
    1220        IF ( global )  THEN
    1221           CALL get_attribute( id_mod, search_string, val, global )
    1222 !
    1223 !--    Read variable attribute
    1224        ELSE
    1225           CALL get_attribute( id_mod, search_string, val, global, variable_name )
    1226        ENDIF
    1227 !
    1228 !--    Finally, close input file
    1229        IF ( openclose == 'close' )  CALL close_input_file( id_mod )
    1230 #endif           
    1231 
    1232     END SUBROUTINE netcdf_data_input_att_real
     989
    1233990
    1234991!------------------------------------------------------------------------------!
     
    58235580! Description:
    58245581! ------------
     5582!> Inquires the _FillValue settings of an integer variable.
     5583!------------------------------------------------------------------------------!
     5584    SUBROUTINE inquire_fill_value_int( id, var_name, nofill, fill_value )
     5585#if defined( __netcdf )
     5586       CHARACTER(LEN=*), INTENT(IN) ::  var_name    !< variable name
     5587
     5588       INTEGER(iwp), INTENT(IN)  ::  id          !< file id
     5589       INTEGER(iwp)              ::  nofill      !< flag indicating whether fill values are set or not
     5590       INTEGER(iwp)              ::  fill_value  !< fill value
     5591       INTEGER(iwp)              ::  id_var      !< netCDF variable id (varid)
     5592
     5593       nc_stat = NF90_INQ_VARID( id, TRIM( var_name ), id_var )
     5594       nc_stat = NF90_INQ_VAR_FILL(id, id_var, no_fill, fill_value )
     5595#endif
     5596!
     5597!--    Further line is just to avoid compiler warnings. nofill might be used
     5598!--    in future.
     5599       IF ( nofill == 0  .OR.  nofill /= 0 )  CONTINUE
     5600
     5601    END SUBROUTINE inquire_fill_value_int
     5602
     5603!------------------------------------------------------------------------------!
     5604! Description:
     5605! ------------
     5606!> Inquires the _FillValue settings of a real variable.
     5607!------------------------------------------------------------------------------!
     5608    SUBROUTINE inquire_fill_value_real( id, var_name, nofill, fill_value )
     5609#if defined( __netcdf )
     5610       CHARACTER(LEN=*), INTENT(IN) ::  var_name    !< variable name
     5611
     5612       INTEGER(iwp), INTENT(IN)  ::  id          !< file id
     5613       INTEGER(iwp)              ::  nofill      !< flag indicating whether fill values are set or not
     5614       INTEGER(iwp)              ::  id_var      !< netCDF variable id (varid)
     5615
     5616       REAL(wp), INTENT(OUT)     ::  fill_value  !< fill value
     5617
     5618       nc_stat = NF90_INQ_VARID( id, TRIM( var_name ), id_var )
     5619       nc_stat = NF90_INQ_VAR_FILL(id, id_var, no_fill, fill_value )
     5620#endif
     5621!
     5622!--    Further line is just to avoid compiler warnings. nofill might be used
     5623!--    in future.
     5624       IF ( nofill == 0  .OR.  nofill /= 0 )  CONTINUE
     5625
     5626    END SUBROUTINE inquire_fill_value_real
     5627
     5628!------------------------------------------------------------------------------!
     5629! Description:
     5630! ------------
    58255631!> Prints out a text message corresponding to the current status.
    58265632!------------------------------------------------------------------------------!
Note: See TracChangeset for help on using the changeset viewer.