psmile_scc.F90

Go to the documentation of this file.
00001 !------------------------------------------------------------------------
00002 ! Copyright 2006-2010, CERFACS, Toulouse, France.
00003 ! All rights reserved. Use is subject to OASIS4 license terms.
00004 !-----------------------------------------------------------------------
00005 !BOP
00006 !
00007 ! !MODULE PSMILe_scc
00008 MODULE PSMILe_scc
00009 
00010 ! !PUBLIC TYPES
00011   USE PRISM_Constants
00012   USE PSMILe_common
00013 
00014   IMPLICIT NONE
00015 
00016 ! !DESCRIPTION
00017 ! This module gathers the routines used to extract the information form SCC
00018 !
00019 ! !REVISED HISTORY
00020 !   Date        Programmer     Description
00021 ! ----------    ----------     -----------
00022 ! 13/05/2003   Declat-Valcke    Creation
00023 !
00024 !EOP
00025 !----------------------------------------------------------------------
00026 ! $Id: psmile_scc.F90 2687 2010-10-28 15:15:52Z coquart $
00027 ! $Author: coquart $
00028 !----------------------------------------------------------------------
00029 !
00030 !  Global variable
00031 SAVE
00032 ! Handle to open SCC XML document
00033   INTEGER ig_SCC_handle
00034 !
00035 !======================================================================
00036 !
00037 ! 
00038 CONTAINS
00039 
00040 !-----------------------------------------------------------------------
00041 !-----------------------------------------------------------------------
00042 !
00043 ! open the scc.xml file
00044 !
00045   SUBROUTINE open_scc_file (il_error)
00046 
00047     INTEGER, INTENT (Out) :: il_error
00048 
00049     INTEGER :: sasa_c_read_file  ! external C function
00050 
00051     ig_SCC_handle = sasa_c_read_file ('scc.xml', 7)
00052     if (ig_SCC_handle .eq. -1) then
00053        il_error = 1
00054     else
00055        il_error = 0
00056     endif
00057 
00058   END SUBROUTINE open_scc_file
00059 
00060 !-----------------------------------------------------------------------
00061 !-----------------------------------------------------------------------
00062 !
00063 ! close the scc.xml file
00064 !
00065   SUBROUTINE close_scc_file ()
00066 
00067     INTEGER :: sasa_c_close  ! external C function
00068     INTEGER :: il_err
00069 
00070     il_err = sasa_c_close (ig_SCC_handle)
00071 
00072   END SUBROUTINE close_scc_file
00073 
00074 !-----------------------------------------------------------------------
00075 !-----------------------------------------------------------------------
00076 !
00077 ! Does the simulation use the spawn feature or not ?
00078 !
00079 
00080   SUBROUTINE get_execution_mode (execution_mode, error)
00081 
00082     INTEGER, INTENT (Out) :: execution_mode ! (1 : not_spawn | 2 : spawn)
00083     INTEGER, INTENT (Out) :: error
00084 
00085     INTEGER :: sasa_c_get_attri_1st_level  ! external C function
00086     INTEGER :: sasa_c_convert_char2int  ! external C function
00087 
00088     CHARACTER(LEN=max_name) :: cla_char
00089     CHARACTER(LEN=max_name) :: cla_execution_mode
00090     INTEGER                 :: il_length
00091 
00092     error = sasa_c_get_attri_1st_level( ig_SCC_handle, &
00093        'experiment', 0, 'start_mode', cla_char, il_length)
00094     cla_execution_mode = ' '
00095     cla_execution_mode = cla_char(1:il_length)
00096     execution_mode = sasa_c_convert_char2int(TRIM(cla_execution_mode))
00097 
00098   END SUBROUTINE get_execution_mode
00099 
00100 !-----------------------------------------------------------------------
00101 !-----------------------------------------------------------------------
00102 !
00103 ! How many pes for the driver/transformer
00104 !
00105 
00106   SUBROUTINE get_transformer_pes (transf_pes, error)
00107 
00108     INTEGER, INTENT (Out) :: transf_pes
00109     INTEGER, INTENT (Out) :: error
00110 
00111     INTEGER :: sasa_c_get_element_2nd_level_i
00112 
00113 ! number of transformer pes
00114     error = &
00115        sasa_c_get_element_2nd_level_i (ig_SCC_handle, &
00116        'experiment', 0, 'driver', 0, 'nbr_procs', 0,  &
00117        transf_pes)
00118 
00119   END SUBROUTINE get_transformer_pes
00120 
00121 !-----------------------------------------------------------------------
00122 !-----------------------------------------------------------------------
00123 !
00124 ! Collect the dates used in the simulation
00125 !
00126 
00127   SUBROUTINE get_dates ( experiment_start_date, &
00128      experiment_end_date,   &
00129      run_start_date,        &
00130      run_end_date,          &
00131      error)
00132 
00133     TYPE(PRISM_Time_Struct), INTENT (InOut) :: experiment_start_date
00134     TYPE(PRISM_Time_Struct), INTENT (InOut) :: experiment_end_date 
00135     TYPE(PRISM_Time_Struct), INTENT (InOut) :: run_start_date
00136     TYPE(PRISM_Time_Struct), INTENT (InOut) :: run_end_date
00137 
00138     INTEGER, INTENT (Out) :: error
00139 
00140     INTEGER :: sasa_c_get_element_3rd_level_i, sasa_c_get_element_3rd_level_d 
00141 
00142 !!$    experiment_start_date%second = 0
00143 !!$    experiment_end_date%second = 0
00144 !!$    run_start_date%second = 0
00145 !!$    run_end_date%second = 0
00146 
00147 ! experiment_start_date collection
00148     error = &
00149        sasa_c_get_element_3rd_level_d (ig_SCC_handle, &
00150        'experiment', 0, 'start_date', 0, 'date', 0,   &
00151        'second', 0, experiment_start_date%second)
00152     error = &
00153        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00154        'experiment', 0, 'start_date', 0, 'date', 0,   &
00155        'minute', 0, experiment_start_date%minute)
00156     error = &
00157        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00158        'experiment', 0, 'start_date', 0, 'date', 0,   &
00159        'hour', 0, experiment_start_date%hour)
00160     error = &
00161        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00162        'experiment', 0, 'start_date', 0, 'date', 0,   &
00163        'day', 0, experiment_start_date%day)
00164     error = &
00165        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00166        'experiment', 0, 'start_date', 0, 'date', 0,   &
00167        'month', 0, experiment_start_date%month)
00168     error = &
00169        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00170        'experiment', 0, 'start_date', 0, 'date', 0,   &
00171        'year', 0, experiment_start_date%year)
00172 
00173 ! experiment_end_date collection
00174     error = &
00175        sasa_c_get_element_3rd_level_d (ig_SCC_handle, &
00176        'experiment', 0, 'end_date', 0, 'date', 0,   &
00177        'second', 0, experiment_end_date%second)
00178     error = &
00179        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00180        'experiment', 0, 'end_date', 0, 'date', 0,     &
00181        'minute', 0, experiment_end_date%minute)
00182     error = &
00183        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00184        'experiment', 0, 'end_date', 0, 'date', 0,     &
00185        'hour', 0, experiment_end_date%hour)
00186     error = &
00187        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00188        'experiment', 0, 'end_date', 0, 'date', 0,     &
00189        'day', 0, experiment_end_date%day)
00190     error = &
00191        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00192        'experiment', 0, 'end_date', 0, 'date', 0,     &
00193        'month', 0, experiment_end_date%month)
00194     error = &
00195        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00196        'experiment', 0, 'end_date', 0, 'date', 0,     &
00197        'year', 0, experiment_end_date%year)
00198 
00199 ! run_start_date collection
00200     error = &
00201        sasa_c_get_element_3rd_level_d (ig_SCC_handle, &
00202        'run', 0, 'start_date', 0, 'date', 0,          &
00203        'second', 0,  run_start_date%second)
00204     error = &
00205        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00206        'run', 0, 'start_date', 0, 'date', 0,          &
00207        'minute', 0,  run_start_date%minute)
00208     error = &
00209        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00210        'run', 0, 'start_date', 0, 'date', 0,          &
00211        'hour', 0, run_start_date%hour)
00212     error = &
00213        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00214        'run', 0, 'start_date', 0, 'date', 0,          &
00215        'day', 0, run_start_date%day)
00216     error = &
00217        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00218        'run', 0, 'start_date', 0, 'date', 0,          &
00219        'month', 0, run_start_date%month)
00220     error = &
00221        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00222        'run', 0, 'start_date', 0, 'date', 0,          &
00223        'year', 0, run_start_date%year)
00224 
00225 ! run_end_date collection
00226     error = &
00227        sasa_c_get_element_3rd_level_d (ig_SCC_handle, &
00228        'run', 0, 'end_date', 0, 'date', 0,          &
00229        'second', 0, run_end_date%second)
00230     error = &
00231        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00232        'run', 0, 'end_date', 0, 'date', 0,            &
00233        'minute', 0, run_end_date%minute)
00234     error = &
00235        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00236        'run', 0, 'end_date', 0, 'date', 0,            &
00237        'hour', 0, run_end_date%hour)
00238     error = &
00239        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00240        'run', 0, 'end_date', 0, 'date', 0,            &
00241        'day', 0, run_end_date%day)
00242     error = &
00243        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00244        'run', 0, 'end_date', 0, 'date', 0,            &
00245        'month', 0, run_end_date%month)
00246     error = &
00247        sasa_c_get_element_3rd_level_i (ig_SCC_handle, &
00248        'run', 0, 'end_date', 0, 'date', 0,            &
00249        'year', 0, run_end_date%year)
00250 
00251   END SUBROUTINE get_dates
00252 
00253 !-----------------------------------------------------------------------
00254 !-----------------------------------------------------------------------
00255 !
00256 ! Get the number of applications
00257 !
00258 
00259   SUBROUTINE get_appli_number (appli_number, error)
00260 
00261     INTEGER, INTENT (Out) :: appli_number ! nb of applications
00262     INTEGER, INTENT (Out) :: error
00263 
00264     INTEGER :: sasa_c_get_number_1st_level
00265 
00266     error = sasa_c_get_number_1st_level (ig_SCC_handle, &
00267             'application', appli_number)
00268 
00269     IF (error .eq. 2) error = 0
00270 
00271   END SUBROUTINE get_appli_number
00272 
00273 !-----------------------------------------------------------------------
00274 !-----------------------------------------------------------------------
00275 !
00276 ! Get the names, exe_names, nb of hosts and nb of comps for all the appli
00277 !
00278 
00279   SUBROUTINE get_appli_details ( appli_number,         &
00280      appli_names, appli_exe_names, appli_nb_hosts,     &
00281      appli_redirect, appli_nb_comps, appli_nb_args,    &
00282      error)
00283 
00284     INTEGER, INTENT (In) :: appli_number
00285 
00286     CHARACTER(LEN=max_name),DIMENSION(0:appli_number),INTENT (Out) :: 
00287        appli_names ! names of the different applications
00288 
00289     CHARACTER(LEN=max_name),DIMENSION(0:appli_number),INTENT (Out) :: 
00290        appli_exe_names ! names of the different application executables
00291 
00292     INTEGER, DIMENSION(0:appli_number), INTENT (Out) :: 
00293        appli_redirect ! stdout redirected or not for all applications
00294 
00295     INTEGER, DIMENSION(0:appli_number), INTENT (Out) :: 
00296        appli_nb_hosts ! number of hosts for each application
00297 
00298     INTEGER, DIMENSION(0:appli_number), INTENT (Out) :: 
00299        appli_nb_comps ! number of components for each application
00300 
00301     INTEGER, DIMENSION(0:appli_number), INTENT (Out) :: 
00302        appli_nb_args ! number of arguments for each application
00303 
00304     INTEGER, INTENT (Out) :: error
00305 
00306     CHARACTER(LEN=max_name) :: cla_char
00307     CHARACTER(LEN=max_name) :: cla_appli_redirect
00308 
00309     INTEGER :: sasa_c_get_number_2nd_level, sasa_c_get_attri_1st_level
00310     INTEGER :: sasa_c_convert_char2int
00311 
00312     INTEGER :: i, il_length  
00313 
00314     appli_names     = " "
00315     appli_exe_names     = " "
00316     cla_appli_redirect = " "
00317 
00318    if (appli_names(0) .NE. 'Stand alone') then
00319       appli_names(0)     = "oasis4"
00320       appli_exe_names(0) = "../../../bin/prismdrv_main"
00321       appli_nb_hosts(0) = 1
00322       appli_nb_args(0) = 0
00323       appli_nb_comps(0) = 1
00324     endif
00325 
00326     DO i = 1, appli_number
00327 
00328       error = &
00329          sasa_c_get_number_2nd_level(      &
00330          ig_SCC_handle, 'application', i,  &
00331          'host', appli_nb_hosts(i))
00332 
00333       error = &
00334          sasa_c_get_number_2nd_level(      &
00335          ig_SCC_handle, 'application', i,  &
00336          'argument', appli_nb_args(i))
00337 
00338       error = &
00339          sasa_c_get_number_2nd_level(      &
00340          ig_SCC_handle, 'application', i,  &
00341          'component', appli_nb_comps(i))
00342 
00343       error = &
00344          sasa_c_get_attri_1st_level(       &
00345          ig_SCC_handle, 'application', i,  &
00346          'local_name', cla_char, il_length)
00347       appli_names(i) = ' '
00348       appli_names(i) = cla_char(1:il_length)
00349       
00350       error = &
00351          sasa_c_get_attri_1st_level(       &
00352          ig_SCC_handle, 'application', i,  &
00353          'executable_name', cla_char, il_length)
00354       appli_exe_names(i) = ' '
00355       appli_exe_names(i) = cla_char(1:il_length)
00356 
00357       error = &
00358          sasa_c_get_attri_1st_level(       &
00359          ig_SCC_handle, 'application', i,  &
00360          'redirect', cla_char, il_length)
00361       cla_appli_redirect = ' '
00362       cla_appli_redirect = cla_char(1:il_length)
00363 
00364       appli_redirect(i) = sasa_c_convert_char2int(TRIM(cla_appli_redirect))    
00365 
00366       IF (error .eq. 2) error = 0
00367 
00368     END DO
00369 
00370   END SUBROUTINE get_appli_details
00371 !-----------------------------------------------------------------------
00372 !-----------------------------------------------------------------------
00373 !
00374 ! Get the arguments for all one appli
00375 ! 
00376 
00377   SUBROUTINE get_appliarg_details ( id_appli_number,   &
00378      id_appli_nb_args,  &
00379      cda_appli_args,    &
00380      error )
00381 
00382     INTEGER, INTENT (In)  :: 
00383        id_appli_number ! application number
00384 
00385     INTEGER, INTENT (In)             :: 
00386        id_appli_nb_args ! nb of arguments for the appli
00387 
00388     CHARACTER(LEN=max_name),DIMENSION(id_appli_nb_args),INTENT(Out):: 
00389        cda_appli_args ! arguments for the application
00390 
00391     INTEGER, INTENT (Out) :: error
00392 
00393     INTEGER :: sasa_c_get_element_1st_level_c
00394 
00395     INTEGER :: ib, il_length
00396 
00397     cda_appli_args = " "
00398 
00399     IF (id_appli_nb_args .ne. 0) THEN
00400         DO ib = 1, id_appli_nb_args
00401 
00402           error = &
00403              sasa_c_get_element_1st_level_c (               &
00404              ig_SCC_handle, 'application', id_appli_number, &
00405              'argument', ib, cda_appli_args(ib), il_length)
00406 
00407         END DO
00408     END IF
00409 
00410   END SUBROUTINE get_appliarg_details
00411 
00412 !-----------------------------------------------------------------------
00413 !-----------------------------------------------------------------------
00414 !
00415 ! Get the names and the numbers of processes for all hosts of one appli
00416 ! 
00417 
00418   SUBROUTINE get_applihost_details ( id_appli_number,        &
00419      id_appli_nb_hosts,      &
00420      cda_appli_hostnames,    &
00421      ida_appli_hostnbprocs,  &
00422      error )
00423 
00424     INTEGER, INTENT (In)  :: 
00425        id_appli_number ! application number
00426 
00427     INTEGER, INTENT (In)             :: 
00428        id_appli_nb_hosts ! nb of hosts for the appli
00429 
00430     CHARACTER(LEN=max_name), DIMENSION(id_appli_nb_hosts), INTENT(Out) ::
00431        cda_appli_hostnames ! names of the hosts for the application
00432 
00433     INTEGER, DIMENSION(id_appli_nb_hosts), INTENT (Out) :: 
00434        ida_appli_hostnbprocs ! numbers of procs of the hosts for the appli
00435 
00436     INTEGER, INTENT (Out) :: error
00437 
00438     INTEGER :: sasa_c_get_attri_2nd_level, sasa_c_get_element_2nd_level_i
00439 
00440     INTEGER :: ib, il_length
00441 
00442     CHARACTER(LEN=max_name) :: cla_char
00443 
00444     cda_appli_hostnames = " "
00445 
00446     DO ib =1, id_appli_nb_hosts
00447 
00448       error = &
00449          sasa_c_get_attri_2nd_level(ig_SCC_handle,           &
00450          'application', id_appli_number, 'host', ib,         &
00451          'local_name', cla_char, il_length)
00452       cda_appli_hostnames(ib) = ' '
00453       cda_appli_hostnames(ib) = cla_char(1:il_length)
00454 
00455       error = &
00456          sasa_c_get_element_2nd_level_i(ig_SCC_handle,       &
00457          'application', id_appli_number, 'host', ib,         &
00458          'nbr_procs', 0, ida_appli_hostnbprocs(ib))
00459 
00460     END DO
00461 
00462   END SUBROUTINE get_applihost_details
00463 
00464 !-----------------------------------------------------------------------
00465 !-----------------------------------------------------------------------
00466 !
00467 ! Get the names and the active processes for all comps of one appli
00468 ! 
00469 
00470   SUBROUTINE get_applicomp_details ( id_appli_number,           &
00471      id_appli_nb_comps,         &
00472      cda_appli_compnames,       &
00473      ida_appli_compnbranksets,  &
00474      error )
00475 
00476     INTEGER, INTENT (In)  :: 
00477        id_appli_number ! application number
00478 
00479     INTEGER, INTENT (In)             :: 
00480        id_appli_nb_comps ! nb of comps for the appli
00481 
00482     CHARACTER(LEN=max_name), DIMENSION(id_appli_nb_comps),INTENT(Out) :: 
00483        cda_appli_compnames ! names of the comps for the application
00484 
00485     INTEGER, DIMENSION(id_appli_nb_comps), INTENT (Out) :: 
00486        ida_appli_compnbranksets ! numbers of rank sets 
00487 ! for all components of the application
00488 
00489     INTEGER, INTENT (Out) :: error
00490 
00491     INTEGER :: sasa_c_get_attri_2nd_level, sasa_c_get_number_3rd_level
00492 
00493     INTEGER :: ib, il_length
00494 
00495     CHARACTER(LEN=max_name) :: cla_char
00496 
00497     cda_appli_compnames = " "
00498 
00499     DO ib = 1, id_appli_nb_comps
00500 
00501       error = &
00502          sasa_c_get_attri_2nd_level(ig_SCC_handle,           &
00503          'application', id_appli_number, 'component', ib,    &
00504          'local_name', cla_char, il_length)
00505       cda_appli_compnames(ib) = ' '
00506       cda_appli_compnames(ib) = cla_char(1:il_length)
00507 
00508       error = &
00509          sasa_c_get_number_3rd_level(ig_SCC_handle,          &
00510          'application', id_appli_number, 'component', ib,    &
00511          'rank', ida_appli_compnbranksets(ib))
00512 
00513     END DO
00514 
00515     IF (error .eq. 2) error = 0
00516 
00517   END SUBROUTINE get_applicomp_details
00518 
00519 !-----------------------------------------------------------------------
00520 !-----------------------------------------------------------------------
00521 !
00522 ! Get the rank sets (min-max-inc) for all components of one applications
00523 ! 
00524 
00525   SUBROUTINE get_applicomprk_detls (id_appli_number,         &
00526      id_appli_nbtot_rankset,  &
00527      ida_appli_compranks,     &
00528      error )
00529 
00530     INTEGER, INTENT (In)  :: 
00531        id_appli_number ! application number
00532 
00533     INTEGER, INTENT (In)             :: 
00534        id_appli_nbtot_rankset ! total nb of rank sets for the application
00535 
00536     INTEGER, DIMENSION(id_appli_nbtot_rankset,3), INTENT (Out) :: 
00537        ida_appli_compranks ! array of active ranks 
00538 ! for all components for the application (min, max, inc)
00539 
00540     INTEGER, INTENT (Out) :: error
00541 
00542     INTEGER :: sasa_c_get_number_2nd_level, sasa_c_get_number_3rd_level
00543     INTEGER :: sasa_c_get_element_3rd_level_i
00544 
00545     INTEGER :: il_nb_comp, il_nb_comprksets
00546     INTEGER :: ib, ib_bis, ib_ter
00547 
00548     IF (id_appli_nbtot_rankset .ne. 0) THEN
00549 
00550         error = &
00551            sasa_c_get_number_2nd_level (ig_SCC_handle,  &
00552            'application', id_appli_number,              &
00553            'component', il_nb_comp)
00554 
00555         ib_ter = 0
00556 
00557         DO ib =1, il_nb_comp
00558 
00559           error = &
00560              sasa_c_get_number_3rd_level (ig_SCC_handle,       &
00561              'application', id_appli_number, 'component', ib,  &
00562              'rank', il_nb_comprksets)
00563 
00564           DO ib_bis = 1, il_nb_comprksets
00565 
00566             ib_ter = ib_ter + 1
00567             error = &
00568                sasa_c_get_element_3rd_level_i (ig_SCC_handle,       &
00569                'application', id_appli_number, 'component', ib,     &
00570                'rank', ib_bis, 'min_value', 0,                      &
00571                ida_appli_compranks(ib_ter,1))
00572             error = &
00573                sasa_c_get_element_3rd_level_i (ig_SCC_handle,       &
00574                'application', id_appli_number, 'component', ib,     &
00575                'rank', ib_bis, 'max_value', 0,                      &
00576                ida_appli_compranks(ib_ter,2))
00577             error = &
00578                sasa_c_get_element_3rd_level_i (ig_SCC_handle,       &
00579                'application', id_appli_number, 'component', ib,     &
00580                'rank', ib_bis, 'increment', 0,                      &
00581                ida_appli_compranks(ib_ter,3))
00582 
00583           END DO
00584 
00585         END DO
00586 
00587     END IF
00588 
00589     IF (error .eq. 2) error = 0
00590 
00591   END SUBROUTINE get_applicomprk_detls
00592 
00593 
00594 END MODULE PSMILe_scc

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1