00001
00002
00003
00004
00005
00006
00007
00008 MODULE PSMILe_cim
00009
00010
00011 USE PRISM_Constants
00012 USE PSMILe_common
00013
00014 IMPLICIT NONE
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 SAVE
00029
00030 INTEGER ig_CIM_handle
00031
00032 INTEGER ig_rank_driver
00033
00034
00035
00036
00037 CONTAINS
00038
00039
00040
00041
00042
00043
00044 SUBROUTINE open_cim_file (il_error)
00045
00046 INTEGER, INTENT (Out) :: il_error
00047
00048 INTEGER :: sasa_c_read_file
00049
00050 ig_CIM_handle = sasa_c_read_file ('cim.xml', 7)
00051 if (ig_CIM_handle .eq. -1) then
00052 il_error = 1
00053 else
00054 il_error = 0
00055 endif
00056
00057 END SUBROUTINE open_cim_file
00058
00059
00060
00061
00062
00063
00064 SUBROUTINE close_cim_file ()
00065
00066 INTEGER :: sasa_c_close
00067 INTEGER :: il_err
00068
00069 il_err = sasa_c_close (ig_CIM_handle)
00070
00071 END SUBROUTINE close_cim_file
00072
00073
00074
00075
00076
00077
00078
00079 SUBROUTINE get_execution_mode (execution_mode, error)
00080
00081 INTEGER, INTENT (Out) :: execution_mode
00082 INTEGER, INTENT (Out) :: error
00083
00084
00085 INTEGER :: sasa_c_convert_char2int
00086 INTEGER :: sasa_c_get_element_xpath_c
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_element_xpath_c( ig_CIM_handle, &
00093
00094
00095 "//simulationComposite/child/simulationRun/model/modelComponent/& &childComponent/processorComponent/componentProperties/componentProperty/& &value[preceding-sibling::shortName = 'start_mode' ]", &
00096 cla_char, il_length)
00097
00098 error = 0
00099 cla_execution_mode = ' '
00100 cla_execution_mode = cla_char(1:il_length)
00101 execution_mode = sasa_c_convert_char2int(TRIM(cla_execution_mode))
00102
00103 END SUBROUTINE get_execution_mode
00104
00105
00106
00107
00108
00109
00110
00111 SUBROUTINE get_transformer_pes (transf_pes, error)
00112
00113 INTEGER, INTENT (Out) :: transf_pes
00114 INTEGER, INTENT (Out) :: error
00115 CHARACTER(LEN=max_name) :: cla_char
00116 INTEGER :: il_length
00117
00118 INTEGER :: sasa_c_get_element_xpath_i
00119
00120
00121 error = sasa_c_get_element_xpath_i( ig_CIM_handle, &
00122
00123 "/simulationComposite/child/simulationRun/model/modelComponent/& &childComponent/processorComponent/deployment/parallelisation/processes", &
00124 transf_pes)
00125
00126 END SUBROUTINE get_transformer_pes
00127
00128
00129
00130
00131
00132
00133
00134 SUBROUTINE get_dates ( experiment_start_date, &
00135 experiment_end_date, &
00136 run_start_date, &
00137 run_end_date, &
00138 error)
00139
00140 TYPE(PRISM_Time_Struct), INTENT (InOut) :: experiment_start_date
00141 TYPE(PRISM_Time_Struct), INTENT (InOut) :: experiment_end_date
00142 TYPE(PRISM_Time_Struct), INTENT (InOut) :: run_start_date
00143 TYPE(PRISM_Time_Struct), INTENT (InOut) :: run_end_date
00144
00145 INTEGER, INTENT (Out) :: error
00146
00147 INTEGER :: sasa_c_get_element_xpath_c
00148
00149 CHARACTER(LEN=max_name) :: cla_char
00150 INTEGER :: il_length
00151
00152 CHARACTER :: x1, x2, x3, x4, x5, x6
00153 INTEGER :: seconds, centiseconds
00154
00155
00156 error = sasa_c_get_element_xpath_c( ig_CIM_handle, &
00157 "/simulationComposite/startPoint", &
00158 cla_char, il_length)
00159
00160
00161 cla_char = ADJUSTL(cla_char)
00162 seconds = 0
00163 centiseconds = 0
00164 read (cla_char, "(I4,A1,I2,A1,I2,A1,I2,A1,I2,A1,I2,A1,I2)", err=900) &
00165 experiment_start_date%year, x1, experiment_start_date%month, x2, experiment_start_date%day, x3, &
00166 experiment_start_date%hour, x4, experiment_start_date%minute, x5, seconds, x6, centiseconds
00167 900 continue
00168
00169
00170 experiment_start_date%second = seconds + centiseconds / 100.0
00171 #ifdef VERBOSE
00172 write (*,905) "experiment start date: ", &
00173 experiment_start_date%year, experiment_start_date%month, experiment_start_date%day, &
00174 experiment_start_date%hour, experiment_start_date%minute, experiment_start_date%second
00175 905 format (A,I4,"-",I2,"-",I2," ",I2,":",I2,":",F5.2)
00176 #endif
00177
00178
00179 error = sasa_c_get_element_xpath_c( ig_CIM_handle, &
00180 "/simulationComposite/endPoint", &
00181 cla_char, il_length)
00182
00183 cla_char = ADJUSTL(cla_char)
00184 seconds = 0
00185 centiseconds = 0
00186 read (cla_char, "(I4,A1,I2,A1,I2,A1,I2,A1,I2,A1,I2,A1,I2)", err=910) &
00187 experiment_end_date%year, x1, experiment_end_date%month, x2, experiment_end_date%day, x3, &
00188 experiment_end_date%hour, x4, experiment_end_date%minute, x5, seconds, x6, centiseconds
00189 910 continue
00190
00191 experiment_end_date%second = seconds + centiseconds / 100.0
00192 #ifdef VERBOSE
00193 write (*,915) "experiment end date: ", &
00194 experiment_end_date%year, experiment_end_date%month, experiment_end_date%day, &
00195 experiment_end_date%hour, experiment_end_date%minute, experiment_end_date%second
00196 915 format (A,I4,"-",I2,"-",I2," ",I2,":",I2,":",F5.2)
00197 #endif
00198
00199
00200 error = sasa_c_get_element_xpath_c( ig_CIM_handle, &
00201 "/simulationComposite/child/simulationRun/startPoint", &
00202 cla_char, il_length)
00203 seconds = 0
00204 centiseconds = 0
00205
00206 cla_char = ADJUSTL(cla_char)
00207 read (cla_char, "(I4,A1,I2,A1,I2,A1,I2,A1,I2,A1,I2,A1,I2)", err=920) &
00208 run_start_date%year, x1, run_start_date%month, x2, run_start_date%day, x3, &
00209 run_start_date%hour, x4, run_start_date%minute, x5, seconds, x6, centiseconds
00210 920 continue
00211
00212 run_start_date%second = seconds + centiseconds / 100.0
00213 #ifdef VERBOSE
00214 write (*,925) "run start date: ", &
00215 run_start_date%year, run_start_date%month, run_start_date%day, &
00216 run_start_date%hour, run_start_date%minute, run_start_date%second
00217 925 format (A,I4,"-",I2,"-",I2," ",I2,":",I2,":",F5.2)
00218 #endif
00219
00220
00221 error = sasa_c_get_element_xpath_c( ig_CIM_handle, &
00222 "/simulationComposite/child/simulationRun/endPoint", &
00223 cla_char, il_length)
00224 seconds = 0
00225 centiseconds = 0
00226
00227 cla_char = ADJUSTL(cla_char)
00228 read (cla_char, "(I4,A1,I2,A1,I2,A1,I2,A1,I2,A1,I2,A1,I2)", err=930) &
00229 run_end_date%year, x1, run_end_date%month, x2, run_end_date%day, x3, &
00230 run_end_date%hour, x4, run_end_date%minute, x5, seconds, x6, centiseconds
00231 930 continue
00232
00233 run_end_date%second = seconds + centiseconds / 100.0
00234 #ifdef VERBOSE
00235 write (*,935) "run end date: ", &
00236 run_end_date%year, run_end_date%month, run_end_date%day, &
00237 run_end_date%hour, run_end_date%minute, run_end_date%second
00238 935 format (A,I4,"-",I2,"-",I2," ",I2,":",I2,":",F5.2)
00239 #endif
00240
00241 END SUBROUTINE get_dates
00242
00243
00244
00245
00246
00247
00248
00249 SUBROUTINE get_appli_number (appli_number, error)
00250
00251 INTEGER, INTENT (Out) :: appli_number
00252 INTEGER, INTENT (Out) :: error
00253
00254 INTEGER :: sasa_c_get_number_6th_level
00255
00256
00257
00258 error = sasa_c_get_number_6th_level (ig_CIM_handle, &
00259 "simulationComposite", 0, "child", 0, "simulationRun", 0, "model", 0, &
00260 "modelComponent", 0, "childComponent[modelComponent]", appli_number)
00261
00262 END SUBROUTINE get_appli_number
00263
00264
00265
00266
00267
00268
00269
00270 SUBROUTINE get_appli_details ( appli_number, &
00271 appli_names, appli_exe_names, appli_nb_hosts, &
00272 appli_redirect, appli_nb_comps, appli_nb_args, &
00273 error)
00274
00275 INTEGER, INTENT (In) :: appli_number
00276
00277 CHARACTER(LEN=max_name),DIMENSION(0:appli_number),INTENT (Out) ::
00278 appli_names
00279
00280 CHARACTER(LEN=max_name),DIMENSION(0:appli_number),INTENT (Out) ::
00281 appli_exe_names
00282
00283 INTEGER, DIMENSION(0:appli_number), INTENT (Out) ::
00284 appli_redirect
00285
00286 INTEGER, DIMENSION(0:appli_number), INTENT (Out) ::
00287 appli_nb_hosts
00288
00289 INTEGER, DIMENSION(0:appli_number), INTENT (Out) ::
00290 appli_nb_comps
00291
00292 INTEGER, DIMENSION(0:appli_number), INTENT (Out) ::
00293 appli_nb_args
00294
00295 INTEGER, INTENT (Out) :: error
00296
00297 CHARACTER(LEN=max_name) :: cla_char
00298
00299 INTEGER :: sasa_c_get_number_8th_level, sasa_c_get_number_9th_level
00300 INTEGER :: sasa_c_get_element_4th_level_c, sasa_c_get_element_8th_level_c
00301
00302 INTEGER :: i, i_host, il_length
00303
00304 if (appli_names(0) .NE. 'Stand alone') then
00305 appli_names(0) = "oasis4"
00306 appli_exe_names(0) = "../../../bin/prismdrv_main"
00307 appli_nb_hosts(0) = 1
00308 appli_nb_args(0) = 0
00309 appli_nb_comps(0) = 1
00310 endif
00311
00312 DO i = 1, appli_number
00313
00314
00315
00316 error = sasa_c_get_number_8th_level (ig_CIM_handle, &
00317 "simulationComposite", 0, "child", 0, "simulationRun", 0, "model", 0, "modelComponent", 0, &
00318 "childComponent[modelComponent]", i, "modelComponent", 0, "deployment", appli_nb_hosts(i))
00319
00320
00321
00322
00323
00324 appli_nb_args(i) = 0
00325 appli_exe_names(i) = ' '
00326 i_host = 1
00327
00328 DO WHILE (appli_exe_names(i) == ' ' .AND. i_host <= appli_nb_hosts(i))
00329
00330 error = sasa_c_get_element_8th_level_c (ig_CIM_handle, &
00331 "simulationComposite", 0, "child", 0, "simulationRun", 0, "model", 0, &
00332 "modelComponent", 0, "childComponent[modelComponent]", i, "modelComponent", &
00333 0, "deployment", i_host, "executableName", 0, cla_char, il_length)
00334
00335
00336 if (error == 0) then
00337 appli_exe_names(i) = cla_char(1:il_length)
00338
00339
00340 error = sasa_c_get_number_9th_level (ig_CIM_handle, &
00341 "simulationComposite", 0, "child", 0, "simulationRun", 0, "model", 0, &
00342 "modelComponent", 0, "childComponent[modelComponent]", i, &
00343 "modelComponent", 0, "deployment", i_host, "executableArgument", &
00344 appli_nb_args(i))
00345 endif
00346
00347 i_host = i_host + 1
00348 ENDDO
00349
00350
00351
00352 error = sasa_c_get_number_8th_level (ig_CIM_handle, &
00353 "simulationComposite", 0, "child", 0, "simulationRun", 0, "model", 0, "modelComponent", 0, &
00354 "childComponent[modelComponent]", i, "modelComponent", 0, "childComponent", appli_nb_comps(i))
00355
00356
00357 error = sasa_c_get_element_4th_level_c ( &
00358 ig_CIM_handle, "model", 0, "modelComponent", 0, &
00359 "childComponent[modelComponent]", i, "modelComponent", 0, "shortName", 0, cla_char, il_length)
00360 appli_names(i) = ' '
00361 appli_names(i) = cla_char(1:il_length)
00362
00363
00364 appli_redirect(i) = 1
00365
00366 END DO
00367
00368 END SUBROUTINE get_appli_details
00369
00370
00371
00372
00373
00374
00375
00376 SUBROUTINE get_appliarg_details ( id_appli_number, &
00377 id_appli_nb_args, &
00378 cda_appli_args, &
00379 error )
00380
00381 INTEGER, INTENT (In) ::
00382 id_appli_number
00383
00384 INTEGER, INTENT (In) ::
00385 id_appli_nb_args
00386
00387 CHARACTER(LEN=max_name),DIMENSION(id_appli_nb_args),INTENT(Out)::
00388 cda_appli_args
00389
00390 INTEGER, INTENT (Out) :: error
00391
00392 INTEGER :: sasa_c_get_number_8th_level, sasa_c_get_element_8th_level_c
00393
00394 CHARACTER(LEN=max_name) :: cla_exe_name
00395 INTEGER :: ib, i_host, il_nb_hosts, il_length
00396
00397 cda_appli_args = " "
00398 IF (id_appli_nb_args .ne. 0) THEN
00399
00400
00401
00402 error = sasa_c_get_number_8th_level (ig_CIM_handle, &
00403 "simulationComposite", 0, "child", 0, "simulationRun", 0, "model", 0, &
00404 "modelComponent", 0, "childComponent[modelComponent]", id_appli_number, &
00405 "modelComponent", 0, "deployment", il_nb_hosts)
00406
00407
00408 i_host = 1
00409 error = 1
00410 cla_exe_name = ' '
00411 DO WHILE (cla_exe_name == ' ' .AND. i_host <= il_nb_hosts)
00412
00413 error = sasa_c_get_element_8th_level_c (ig_CIM_handle, &
00414 "simulationComposite", 0, "child", 0, "simulationRun", 0, "model", 0, &
00415 "modelComponent", 0, "childComponent[modelComponent]", id_appli_number, &
00416 "modelComponent", 0, "deployment", i_host, "executableName", 0, &
00417 cla_exe_name, il_length)
00418
00419 if (cla_exe_name == ' ') i_host = i_host + 1
00420 ENDDO
00421
00422 DO ib = 1, id_appli_nb_args
00423
00424
00425 error = sasa_c_get_element_8th_level_c (ig_CIM_handle, "simulationComposite", &
00426 0, "child", 0, "simulationRun", 0, "model", 0, "modelComponent", 0, &
00427 "childComponent[modelComponent]", id_appli_number, "modelComponent", 0, &
00428 "deployment", i_host, "executableArgument", ib, cda_appli_args(ib), il_length)
00429
00430 END DO
00431 END IF
00432
00433 END SUBROUTINE get_appliarg_details
00434
00435
00436
00437
00438
00439
00440
00441 SUBROUTINE get_applihost_details ( id_appli_number, &
00442 id_appli_nb_hosts, &
00443 cda_appli_hostnames, &
00444 ida_appli_hostnbprocs, &
00445 error )
00446
00447 INTEGER, INTENT (In) ::
00448 id_appli_number
00449
00450 INTEGER, INTENT (In) ::
00451 id_appli_nb_hosts
00452
00453 CHARACTER(LEN=max_name), DIMENSION(id_appli_nb_hosts), INTENT(Out) ::
00454 cda_appli_hostnames
00455
00456 INTEGER, DIMENSION(id_appli_nb_hosts), INTENT (Out) ::
00457 ida_appli_hostnbprocs
00458
00459 INTEGER, INTENT (Out) :: error
00460
00461 INTEGER :: sasa_c_get_element_9th_level_c, sasa_c_get_element_9th_level_i
00462
00463 INTEGER :: ib, il_length
00464
00465 CHARACTER(LEN=max_name) :: cla_char
00466
00467 cda_appli_hostnames = " "
00468
00469 DO ib =1, id_appli_nb_hosts
00470
00471 error = sasa_c_get_element_9th_level_c (ig_CIM_handle, &
00472 "simulationComposite", 0, "child", 0, "simulationRun", 0, "model", 0, "modelComponent", 0, &
00473 "childComponent[modelComponent]", id_appli_number, "modelComponent", 0, "deployment", ib, &
00474 "platform", 0, "shortName", 0, cla_char, il_length)
00475 if (il_length .ne. 0) then
00476 cda_appli_hostnames(ib) = cla_char(1:il_length)
00477 endif
00478
00479 error = sasa_c_get_element_9th_level_i (ig_CIM_handle, &
00480 "simulationComposite", 0, "child", 0, "simulationRun", 0, "model", 0, "modelComponent", 0, &
00481 "childComponent[modelComponent]", id_appli_number, "modelComponent", 0, "deployment", ib, &
00482 "parallelisation", 0, "processes", 0, ida_appli_hostnbprocs(ib))
00483
00484 END DO
00485
00486 END SUBROUTINE get_applihost_details
00487
00488
00489
00490
00491
00492
00493
00494 SUBROUTINE get_applicomp_details ( id_appli_number, &
00495 id_appli_nb_comps, &
00496 cda_appli_compnames, &
00497 ida_appli_compnbranksets, &
00498 error )
00499
00500 INTEGER, INTENT (In) ::
00501 id_appli_number
00502
00503 INTEGER, INTENT (In) ::
00504 id_appli_nb_comps
00505
00506 CHARACTER(LEN=max_name), DIMENSION(id_appli_nb_comps),INTENT(Out) ::
00507 cda_appli_compnames
00508
00509 INTEGER, DIMENSION(id_appli_nb_comps), INTENT (Out) ::
00510 ida_appli_compnbranksets
00511
00512
00513 INTEGER, INTENT (Out) :: error
00514
00515 INTEGER :: sasa_c_get_element_9th_level_c, sasa_c_get_number_10th_level
00516
00517 INTEGER :: ib, il_length
00518
00519 CHARACTER(LEN=max_name) :: cla_char
00520
00521 cda_appli_compnames = " "
00522
00523 DO ib = 1, id_appli_nb_comps
00524
00525 error = sasa_c_get_element_9th_level_c (ig_CIM_handle, &
00526 "simulationComposite", 0, "child", 0, "simulationRun", 0, "model", 0, "modelComponent", 0, &
00527 "childComponent[modelComponent]", id_appli_number, "modelComponent", 0, "childComponent", ib, &
00528 "modelComponent", 0, "shortName", 0, cla_char, il_length)
00529 cda_appli_compnames(ib) = ' '
00530 cda_appli_compnames(ib) = cla_char(1:il_length)
00531
00532
00533 error = sasa_c_get_number_10th_level (ig_CIM_handle, &
00534 "simulationComposite/child/simulationRun", 0, "model", 0, "modelComponent", 0, &
00535 "childComponent[modelComponent]", id_appli_number, "modelComponent", 0, "childComponent", ib, &
00536 "modelComponent", 0, "deployment", 0, "parallelisation", 0, "rank", ida_appli_compnbranksets(ib))
00537
00538 END DO
00539
00540 END SUBROUTINE get_applicomp_details
00541
00542
00543
00544
00545
00546
00547
00548 SUBROUTINE get_applicomprk_detls (id_appli_number, &
00549 id_appli_nbtot_rankset, &
00550 ida_appli_compranks, &
00551 error )
00552
00553 INTEGER, INTENT (In) ::
00554 id_appli_number
00555
00556 INTEGER, INTENT (In) ::
00557 id_appli_nbtot_rankset
00558
00559 INTEGER, DIMENSION(id_appli_nbtot_rankset,3), INTENT (Out) ::
00560 ida_appli_compranks
00561
00562
00563 INTEGER, INTENT (Out) :: error
00564
00565 INTEGER :: sasa_c_get_number_8th_level, sasa_c_get_number_10th_level
00566 INTEGER :: sasa_c_get_element_10th_level_i
00567
00568 INTEGER :: il_nb_comp, il_nb_comprksets, il_length
00569 INTEGER :: ib, ib_bis, ib_ter
00570 CHARACTER(LEN=max_name) :: cla_char
00571
00572 call psmile_flushstd
00573
00574 IF (id_appli_nbtot_rankset .ne. 0) THEN
00575
00576 error = sasa_c_get_number_8th_level (ig_CIM_handle, &
00577 "simulationComposite", 0, "child", 0, "simulationRun", 0, "model", 0, "modelComponent", 0, &
00578 "childComponent[modelComponent]", id_appli_number, "modelComponent", 0, "childComponent", il_nb_comp)
00579
00580 ib_ter = 0
00581 DO ib =1, il_nb_comp
00582
00583
00584 error = sasa_c_get_number_10th_level (ig_CIM_handle, &
00585 "simulationComposite/child/simulationRun", 0, "model", 0, "modelComponent", 0, &
00586 "childComponent[modelComponent]", id_appli_number, "modelComponent", 0, "childComponent", ib, &
00587 "modelComponent", 0, "deployment", 0, "parallelisation", 0, "rank", il_nb_comprksets)
00588
00589 DO ib_bis = 1, il_nb_comprksets
00590
00591 ib_ter = ib_ter + 1
00592 error = sasa_c_get_element_10th_level_i (ig_CIM_handle, &
00593 "simulationComposite/child/simulationRun", 0, "model", 0, "modelComponent", 0, &
00594 "childComponent[modelComponent]", id_appli_number, "modelComponent", 0, "childComponent", ib, &
00595 "modelComponent", 0, "deployment", 0, "parallelisation", 0, "rank", ib_bis, 'rankMin', 0, &
00596 ida_appli_compranks(ib_ter,1))
00597
00598 error = sasa_c_get_element_10th_level_i (ig_CIM_handle, &
00599 "simulationComposite/child/simulationRun", 0, "model", 0, "modelComponent", 0, &
00600 "childComponent[modelComponent]", id_appli_number, "modelComponent", 0, "childComponent", ib, &
00601 "modelComponent", 0, "deployment", 0, "parallelisation", 0, "rank", ib_bis, 'rankMax', 0, &
00602 ida_appli_compranks(ib_ter,2))
00603
00604 error = sasa_c_get_element_10th_level_i (ig_CIM_handle, &
00605 "simulationComposite/child/simulationRun", 0, "model", 0, "modelComponent", 0, &
00606 "childComponent[modelComponent]", id_appli_number, "modelComponent", 0, "childComponent", ib, &
00607 "modelComponent", 0, "deployment", 0, "parallelisation", 0, "rank", ib_bis, 'rankIncrement', 0, &
00608 ida_appli_compranks(ib_ter,3))
00609 if (ida_appli_compranks(ib_ter,3) .eq. 0) ida_appli_compranks(ib_ter,3) = 1
00610
00611 END DO
00612
00613 END DO
00614
00615 END IF
00616
00617 END SUBROUTINE get_applicomprk_detls
00618
00619
00620 END MODULE PSMILe_cim