get_cnct_target_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_cnct_target_details ( id_XML_doc,  &
00010      cda_xpath,         &
00011      ld_coupling,       &
00012      ld_source_is_file, &
00013      sd_target,         &
00014      id_error )
00015 ! !DESCRIPTION
00016 ! This routine extracts, from a CIM XML file, the informations about a connection or a coupling
00017 ! at the target endpoint
00018 !
00019 !----------------------------------------------------------------------
00020 !
00021     USE PSMILe_smioc
00022     IMPLICIT NONE
00023 !
00024 !EOP
00025 !----------------------------------------------------------------------
00026 !
00027 ! 0. Declaration
00028 !
00029 ! handle of XML content of the CIM file
00030     INTEGER, INTENT(In) :: id_XML_doc
00031 
00032 ! XPath character string
00033     CHARACTER(len=*), INTENT(In)  :: cda_xpath
00034 
00035 ! Flag for coupling (true) or connection (false)
00036     LOGICAL, INTENT(In) :: ld_coupling
00037 
00038 ! Flag for when the source of coupling is a file
00039     LOGICAL, INTENT(In) :: ld_source_is_file
00040 ! Data structure to fill in
00041     TYPE(transient_in), INTENT(InOut) :: sd_target
00042 
00043 ! returned error code
00044     INTEGER, INTENT(Out):: id_error
00045 
00046 ! Target as character string = "couplingTarget" or "connectionTarget"
00047     CHARACTER(len=16) cla_target
00048 
00049 ! Property as character string = "couplingProperty" or "connectionProperty"
00050     CHARACTER(len=18) cla_property
00051 
00052 ! temporary character string
00053     CHARACTER(LEN=max_name) :: cla_char
00054     INTEGER :: il_test, il_length
00055     INTEGER :: il_exchange_rate
00056     DOUBLE PRECISION  :: dl_test
00057     
00058     INTEGER :: sasa_c_get_element_2nd_level_i
00059     INTEGER :: sasa_c_get_element_3rd_level_c
00060     INTEGER :: sasa_c_get_element_2nd_level_d 
00061     INTEGER :: sasa_c_get_attri_2nd_level, sasa_c_get_attri_3rd_level
00062     INTEGER :: sasa_c_convert_char2int
00063 
00064 ! Character string = "Coupling" or "connection"
00065     IF (ld_coupling) THEN
00066         cla_target   = "couplingTarget"
00067         cla_property = "couplingProperty"
00068     ELSE
00069         cla_target   = "connectionTarget"
00070         cla_property = "connectionProperty"
00071     ENDIF
00072 
00073     ! Get the exchange period
00074     il_exchange_rate = -1
00075     id_error = &
00076         sasa_c_get_element_2nd_level_i (id_XML_doc, cda_xpath, 0,   &
00077         "timeProfile", 0, "rate", 0, il_exchange_rate)
00078 
00079 print *, "il_exchange_rate", il_exchange_rate
00080     ! If there is an exchange period specified
00081     if (il_exchange_rate .ne. -1 .and. il_exchange_rate .ne. PSMILe_undef) then
00082     
00083         ! When a connection connects two component fields (or transients),
00084         ! the exchange period is analysed twice : for the source and the target
00085         ! This is too bad.
00086         ! Because the CIM file is analysed several times : once for each component
00087         
00088         sd_target%ig_exch_date_type = PSMILe_period
00089 
00090         ! Get the exchange period units
00091         cla_char = ' '
00092         id_error = &
00093             sasa_c_get_attri_2nd_level (id_XML_doc, cda_xpath, 0,   &
00094             "timeProfile", 0, "units", cla_char, il_length)
00095         if (il_length .ne. 0) then
00096           if (cla_char .eq."seconds") then
00097               sd_target%sg_exch_date%sg_period%second = il_exchange_rate
00098           else if (cla_char .eq."minutes") then
00099               sd_target%sg_exch_date%sg_period%minute = il_exchange_rate
00100           else if (cla_char .eq."hours") then
00101               sd_target%sg_exch_date%sg_period%hour = il_exchange_rate
00102           else if (cla_char .eq."days") then
00103               sd_target%sg_exch_date%sg_period%day = il_exchange_rate
00104           else if (cla_char .eq."months") then
00105               sd_target%sg_exch_date%sg_period%month = il_exchange_rate
00106           else if (cla_char .eq."years") then
00107               sd_target%sg_exch_date%sg_period%year = il_exchange_rate
00108           else 
00109               PRINT *, '***************************************************'
00110               PRINT *, 'Unsupported timeProfile units in XML data:', cla_char
00111               PRINT *, '***************************************************'
00112               CALL PSMILe_Flushstd
00113 
00114               CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00115           endif
00116         else
00117             PRINT *, '*****************************************'
00118             PRINT *, 'Unspecified timeProfile units in XML data'
00119             PRINT *, '*****************************************'
00120             CALL PSMILe_Flushstd
00121 
00122             CALL MPI_Abort(MPI_COMM_WORLD, 1, id_error)
00123         endif
00124     endif
00125 
00126     IF (ld_source_is_file) THEN
00127         ! *** Get the target local transformation for add scalar
00128         id_error = &
00129             sasa_c_get_element_2nd_level_d (id_XML_doc, cda_xpath, 0,   &
00130             TRIM(cla_property)//'[name="add_scalar"]', 0,               &
00131             "value", 0, dl_test)
00132         IF ( dl_test /= PSMILe_dundef ) THEN
00133             sd_target%sg_tgt_local_trans%dg_add_scalar = dl_test
00134         ENDIF
00135 
00136         ! *** Get the target local transformation for mult scalar
00137         id_error = &
00138             sasa_c_get_element_2nd_level_d (id_XML_doc, cda_xpath, 0,    &
00139             TRIM(cla_property)//'[name="mult_scalar"]', 0,               &
00140             "value", 0, dl_test)
00141         IF ( dl_test /= PSMILe_dundef ) THEN
00142             sd_target%sg_tgt_local_trans%dg_mult_scalar = dl_test
00143         ENDIF
00144     ENDIF
00145 
00146     ! *** Get the target time operation
00147     id_error = &
00148         sasa_c_get_attri_3rd_level (id_XML_doc, cda_xpath, 0,                     &
00149         "timeTransformation", 0, "mappingType", 0, "value", cla_char, il_length)
00150     if (il_length > 0) then
00151       if (cla_char .eq. "TimeInterpolation") then
00152         sd_target%ig_tgt_timeop = PSMILe_time_linear
00153       else
00154         sd_target%ig_tgt_timeop = PSMILe_time_nnghbr
00155       endif
00156     endif
00157 
00158     ! *** Get the target "non-masked point gathering" operation
00159     id_error = &
00160         sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0,            &
00161         TRIM(cla_target), 0, TRIM(cla_property)//'[name="gathering"]', 0,    &
00162         "value", 0, cla_char, il_length)
00163     if (il_length > 0) then
00164         ! cla_char is "true" or "false"
00165         sd_target%sg_tgt_local_trans%ig_gather = sasa_c_convert_char2int(cla_char(1:il_length))
00166     endif
00167 
00168     ! *** Get the target statistics options
00169     id_error = &
00170         sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0,                           &
00171         TRIM(cla_target), 0, TRIM(cla_property)//'[name="statistics_masked_points"]', 0,    &
00172         "value", 0, cla_char, il_length)
00173     if (il_length > 0) then
00174         ! cla_char is "true" or "false"
00175         sd_target%iga_stats(1) = sasa_c_convert_char2int(cla_char(1:il_length))
00176     endif
00177     
00178     id_error = &
00179         sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0,                              &
00180         TRIM(cla_target), 0, TRIM(cla_property)//'[name="statistics_notmasked_points"]', 0,    &
00181         "value", 0, cla_char, il_length)
00182     if (il_length > 0) then
00183         ! cla_char is "true" or "false"
00184         sd_target%iga_stats(2) = sasa_c_convert_char2int(cla_char(1:il_length))
00185     endif
00186     
00187     id_error = &
00188         sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0,                        &
00189         TRIM(cla_target), 0, TRIM(cla_property)//'[name="statistics_all_points"]', 0,    &
00190         "value", 0, cla_char, il_length)
00191     if (il_length > 0) then
00192         ! cla_char is "true" or "false"
00193         sd_target%iga_stats(3) = sasa_c_convert_char2int(cla_char(1:il_length))
00194     endif
00195 
00196     ! *** Get the target debug mode
00197     id_error = &
00198         sasa_c_get_element_3rd_level_c (id_XML_doc, cda_xpath, 0,             &
00199         TRIM(cla_target), 0, TRIM(cla_property)//'[name="debug_mode"]', 0,    &
00200         "value", 0, cla_char, il_length)
00201     if (il_length > 0) then
00202         ! cla_char is "true" or "false"
00203         sd_target%ig_debugmode = sasa_c_convert_char2int(cla_char(1:il_length))
00204     endif
00205 
00206 
00207   END SUBROUTINE get_cnct_target_details
00208 
00209 !
00210 !======================================================================

Generated on 1 Dec 2011 for Oasis4 by  doxygen 1.6.1