get_file_details.F90

Go to the documentation of this file.
00001 !------------------------------------------------------------------------
00002 ! Copyright 2006-2010, CERFACS, Toulouse, France.
00003 ! All rights reserved. Use is subject to license terms.
00004 !------------------------------------------------------------------------
00005 !BOP
00006 !
00007 !======================================================================
00008 !
00009   SUBROUTINE get_file_details ( id_XML_doc,  &
00010      cda_xpath,         &
00011      cda_var_name,      &
00012      sd_file,           &
00013      id_error )
00014 ! !DESCRIPTION
00015 ! This routine extracts, from a CIM XML file, the informations about a connection or a coupling
00016 ! at the target endpoint
00017 !
00018 !----------------------------------------------------------------------
00019 !
00020     USE PSMILe_smioc
00021     IMPLICIT NONE
00022 !
00023 !EOP
00024 !----------------------------------------------------------------------
00025 !
00026 ! 0. Declaration
00027 !
00028 ! handle of XML content of the CIM file
00029     INTEGER, INTENT(In) :: id_XML_doc
00030 
00031 ! XPath character string = where to search in the XML document
00032     CHARACTER(len=*), INTENT(In)  :: cda_xpath
00033 
00034 ! NetCDF variable name we are looking for
00035     CHARACTER(len=*), INTENT(In)  :: cda_var_name
00036 
00037 ! Data structure to fill in
00038     TYPE (PSMILe_file_struct), INTENT(InOut) :: sd_file
00039 
00040 ! returned error code
00041     INTEGER, INTENT(Out):: id_error
00042 
00043 ! temporary character string
00044     CHARACTER(LEN=max_name) :: cla_char
00045     INTEGER :: il_test, il_length
00046     DOUBLE PRECISION  :: dl_test
00047     
00048     INTEGER :: sasa_c_get_number_3rd_level 
00049     INTEGER :: sasa_c_get_element_3rd_level_c, sasa_c_get_element_4th_level_c
00050     INTEGER :: sasa_c_get_element_4th_level_i
00051     INTEGER :: sasa_c_get_element_4th_level_d 
00052     INTEGER :: sasa_c_get_attri_3rd_level
00053     INTEGER :: sasa_c_convert_char2int
00054 
00055     ! File name
00056     il_length = 0
00057     ! *** Get the file name
00058     id_error = &
00059         sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0,   &
00060         "storage", 0, "fileStorage", 0, "fileName", 0,              &
00061         cla_char, il_length)
00062     IF (il_length == 0) THEN
00063         PRINT *, '*******************************************'
00064         PRINT *, 'a name must be specified for each file     '
00065         PRINT *, '*******************************************'
00066         CALL PSMILe_Flushstd
00067         CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00068     ELSE
00069        sd_file%cg_file_name = cla_char(1:il_length)
00070     ENDIF
00071 
00072     ! *** Get the file format : if specified, must be NetCDF 
00073     il_length = 0
00074     id_error = &
00075         sasa_c_get_attri_3rd_level (id_XML_doc, cda_xpath, 0,   &
00076         "distribution", 0, "distributionFormat", 0, "value",    &
00077         cla_char, il_length)
00078     IF (cla_char(1:il_length) == "NetCDF") THEN
00079         sd_file%ig_file_format = PSMILe_mpp_netcdf
00080     ELSE
00081         PRINT *, '**********************************************'
00082         PRINT *, ' Distribution format must be NetCDF for file: ', sd_file%cg_file_name
00083         PRINT *, '**********************************************'
00084         CALL PSMILe_Flushstd
00085         CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00086     ENDIF
00087 
00088     ! Read options related to the NetCDF variable whose name is given in "cda_var_name"
00089     ! fot that purpose, look for a child dataObject 
00090     ! with <hierarchyLevelValue> subelement equals to "cda_var_name"
00091     id_error = &
00092         sasa_c_get_number_3rd_level (id_XML_doc, cda_xpath, 0,   &
00093         "childObject", 0,                                        &
00094         'dataObject[normalize-space(hierarchyLevelValue)="'//cda_var_name//'"]', &
00095         il_test)
00096         
00097     ! if there is such an XML element
00098     if (il_test .ne. 0) then
00099         ! Look at content of this XML element
00100     
00101         ! *** Get the suffix option
00102         id_error = &
00103             sasa_c_get_element_4th_level_c (id_XML_doc, cda_xpath, 0,   &
00104             "childObject", 0,                                           &
00105             'dataObject[normalize-space(hierarchyLevelValue)="'//cda_var_name//'"]', 0,    &
00106             'dataProperty[name="suffix"]', 0, "value", 0, cla_char, il_length)
00107         if (il_length .ne. 0) then
00108             sd_file%ig_suffix = sasa_c_convert_char2int(cla_char(1:il_length))
00109             IF (sd_file%ig_suffix .eq. PSMILe_undef)  sd_file%ig_suffix = 0
00110         endif
00111         
00112         ! *** Get the io_mode
00113         id_error = &
00114             sasa_c_get_element_4th_level_c (id_XML_doc, cda_xpath, 0,   &
00115             "childObject", 0,                                           &
00116             'dataObject[normalize-space(hierarchyLevelValue)="'//cda_var_name//'"]', 0,    &
00117             'dataProperty[name="io_mode"]', 0, "value", 0, cla_char, il_length)
00118         if (il_length .ne. 0) then
00119             sd_file%ig_file_iomode = sasa_c_convert_char2int(cla_char(1:il_length))
00120         endif
00121 
00122         ! *** Get the "packing" option
00123         id_error = &
00124             sasa_c_get_element_4th_level_i (id_XML_doc, cda_xpath, 0,   &
00125             "childObject", 0,                                           &
00126             'dataObject[normalize-space(hierarchyLevelValue)="'//cda_var_name//'"]', 0,    &
00127             'dataProperty[name="packing"]', 0, "value", 0, sd_file%ig_file_pack)
00128 
00129         ! *** Get the "scale_factor" option
00130         id_error = &
00131             sasa_c_get_element_4th_level_d (id_XML_doc, cda_xpath, 0,   &
00132             "childObject", 0,                                           &
00133             'dataObject[normalize-space(hierarchyLevelValue)="'//cda_var_name//'"]', 0,    &
00134             'dataProperty[name="scale_factor"]', 0, "value", 0, sd_file%dg_file_scal)
00135 
00136         ! *** Get the "add_offset" option
00137         id_error = &
00138             sasa_c_get_element_4th_level_d (id_XML_doc, cda_xpath, 0,   &
00139             "childObject", 0,                                           &
00140             'dataObject[normalize-space(hierarchyLevelValue)="'//cda_var_name//'"]', 0,    &
00141             'dataProperty[name="add_offset"]', 0, "value", 0, sd_file%dg_file_add)
00142 
00143         ! *** Get the "fill_value" option
00144         id_error = &
00145             sasa_c_get_element_4th_level_d (id_XML_doc, cda_xpath, 0,   &
00146             "childObject", 0,                                           &
00147             'dataObject[normalize-space(hierarchyLevelValue)="'//cda_var_name//'"]', 0,    &
00148             'dataProperty[name="_FillValue"]', 0, "value", 0, sd_file%dg_fill_val)
00149     endif
00150 
00151   END SUBROUTINE get_file_details
00152 
00153 !
00154 !======================================================================

Generated on 1 Dec 2011 for Oasis4 by  doxygen 1.6.1