53 USE cellml_model_definition
208 INTEGER(INTG),
INTENT(OUT) :: ERR
211 INTEGER(INTG) :: derivativeNumber,dofIdx,dofType,dof2ParamIdx,elementNumber,gaussNumber,gridNumber,map_idx,modelIdx, &
212 & nodeNumber,versionNumber
213 INTEGER(INTG),
POINTER :: MODELS_DATA(:)
222 enters(
"CELLML_CELLML_TO_FIELD_UPDATE",err,error,*999)
226 IF(
ASSOCIATED(cellml))
THEN 227 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 228 field_maps=>cellml%FIELD_MAPS
229 IF(
ASSOCIATED(field_maps))
THEN 232 model_maps=>field_maps%MODEL_MAPS(cellml%MODELS_FIELD%ONLY_ONE_MODEL_INDEX)%PTR
233 IF(
ASSOCIATED(model_maps))
THEN 238 & only_one_model_index,err,error,*999)
240 & number_of_fields_mapped_to,err,error,*999)
243 DO map_idx=1,model_maps%NUMBER_OF_FIELDS_MAPPED_FROM
244 model_map=>model_maps%FIELDS_MAPPED_FROM(map_idx)%PTR
245 IF(
ASSOCIATED(model_map))
THEN 246 SELECT CASE(model_map%CELLML_FIELD_TYPE)
248 CALL flagerror(
"Cannot map models field.",err,error,*999)
250 IF(
ASSOCIATED(cellml%STATE_FIELD))
THEN 251 CALL field_parameterstofieldparameterscopy(cellml%STATE_FIELD%STATE_FIELD, &
252 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER, &
253 & model_map%FIELD,model_map%VARIABLE_TYPE,model_map%FIELD_PARAMETER_SET,model_map%COMPONENT_NUMBER, &
256 CALL flagerror(
"CellML environment state field is not associated.",err,error,*999)
259 IF(
ASSOCIATED(cellml%INTERMEDIATE_FIELD))
THEN 260 CALL field_parameterstofieldparameterscopy(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
261 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER,model_map%FIELD, &
262 & model_map%VARIABLE_TYPE,model_map%FIELD_PARAMETER_SET,model_map%COMPONENT_NUMBER,err,error,*999)
264 CALL flagerror(
"CellML environment intermediate field is not associated.",err,error,*999)
267 IF(
ASSOCIATED(cellml%PARAMETERS_FIELD))
THEN 268 CALL field_parameterstofieldparameterscopy(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
269 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER,model_map%FIELD, &
270 & model_map%VARIABLE_TYPE,model_map%FIELD_PARAMETER_SET,model_map%COMPONENT_NUMBER,err,error,*999)
272 CALL flagerror(
"CellML environment parameters field is not associated.",err,error,*999)
275 local_error=
"The CellML to field model map CellML field type of "// &
277 &
" is invalid for map index "//
trim(
number_to_vstring(map_idx,
"*",err,error))//
" of model index "// &
280 CALL flagerror(local_error,err,error,*999)
283 local_error=
"The CellML to field map is not associated for map index "// &
287 CALL flagerror(local_error,err,error,*999)
308 local_error=
"The CellML field maps models map is not associated for model index "// &
311 CALL flagerror(local_error,err,error,*999)
315 models_field=>cellml%MODELS_FIELD%MODELS_FIELD
316 IF(
ASSOCIATED(models_field))
THEN 317 NULLIFY(models_variable)
318 CALL field_variable_get(models_field,field_u_variable_type,models_variable,err,error,*999)
320 CALL field_parameter_set_data_get(models_field,field_u_variable_type,field_values_set_type, &
321 & models_data,err,error,*999)
327 DO dofidx=1,models_variable%TOTAL_NUMBER_OF_DOFS
328 modelidx=models_data(dofidx)
330 model_maps=>field_maps%MODEL_MAPS(modelidx)%PTR
331 IF(
ASSOCIATED(model_maps))
THEN 332 doftype=models_variable%DOF_TO_PARAM_MAP%DOF_TYPE(1,dofidx)
333 dof2paramidx=models_variable%DOF_TO_PARAM_MAP%DOF_TYPE(2,dofidx)
335 CASE(field_constant_interpolation)
337 CASE(field_element_based_interpolation)
338 elementnumber=models_variable%DOF_TO_PARAM_MAP%ELEMENT_DOF2PARAM_MAP(1,dof2paramidx)
339 CASE(field_node_based_interpolation)
340 versionnumber=models_variable%DOF_TO_PARAM_MAP%NODE_DOF2PARAM_MAP(1,dof2paramidx)
341 derivativenumber=models_variable%DOF_TO_PARAM_MAP%NODE_DOF2PARAM_MAP(2,dof2paramidx)
342 nodenumber=models_variable%DOF_TO_PARAM_MAP%NODE_DOF2PARAM_MAP(3,dof2paramidx)
343 CASE(field_grid_point_based_interpolation)
344 gridnumber=models_variable%DOF_TO_PARAM_MAP%GRID_POINT_DOF2PARAM_MAP(1,dof2paramidx)
345 CASE(field_gauss_point_based_interpolation)
346 gaussnumber=models_variable%DOF_TO_PARAM_MAP%GAUSS_POINT_DOF2PARAM_MAP(1,dof2paramidx)
347 elementnumber=models_variable%DOF_TO_PARAM_MAP%GAUSS_POINT_DOF2PARAM_MAP(2,dof2paramidx)
351 CALL flagerror(local_error,err,error,*999)
358 CASE(field_constant_interpolation)
360 CASE(field_element_based_interpolation)
362 CASE(field_node_based_interpolation)
367 CASE(field_grid_point_based_interpolation)
369 CASE(field_gauss_point_based_interpolation)
375 CALL flagerror(local_error,err,error,*999)
378 & number_of_fields_mapped_to,err,error,*999)
381 DO map_idx=1,model_maps%NUMBER_OF_FIELDS_MAPPED_FROM
382 model_map=>model_maps%FIELDS_MAPPED_FROM(map_idx)%PTR
383 IF(
ASSOCIATED(model_map))
THEN 385 SELECT CASE(model_map%CELLML_FIELD_TYPE)
387 CALL flagerror(
"Cannot map models field.",err,error,*999)
389 IF(
ASSOCIATED(cellml%STATE_FIELD))
THEN 391 CASE(field_constant_interpolation)
392 CALL field_parameter_set_get_constant(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
393 & model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
394 CASE(field_element_based_interpolation)
395 CALL field_parameter_set_get_element(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
396 & model_map%CELLML_PARAMETER_SET,elementnumber,model_map%CELLML_VARIABLE_NUMBER,dofvalue, &
398 CASE(field_node_based_interpolation)
399 CALL field_parametersetgetlocalnode(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
400 & model_map%CELLML_PARAMETER_SET,versionnumber,derivativenumber,nodenumber, &
401 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
402 CASE(field_grid_point_based_interpolation)
403 CALL flagerror(
"Not implemented.",err,error,*999)
404 CASE(field_gauss_point_based_interpolation)
405 CALL field_parametersetgetlocalgausspoint(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
406 & model_map%CELLML_PARAMETER_SET,gaussnumber,elementnumber,model_map%CELLML_VARIABLE_NUMBER, &
407 & dofvalue,err,error,*999)
411 CALL flagerror(local_error,err,error,*999)
414 CALL flagerror(
"CellML environment state field is not associated.",err,error,*999)
417 IF(
ASSOCIATED(cellml%INTERMEDIATE_FIELD))
THEN 419 CASE(field_constant_interpolation)
420 CALL field_parameter_set_get_constant(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
421 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER, &
422 & dofvalue,err,error,*999)
423 CASE(field_element_based_interpolation)
424 CALL field_parameter_set_get_element(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
425 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,elementnumber, &
426 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
427 CASE(field_node_based_interpolation)
428 CALL field_parametersetgetlocalnode(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
429 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,versionnumber,derivativenumber,nodenumber, &
430 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
431 CASE(field_grid_point_based_interpolation)
432 CALL flagerror(
"Not implemented.",err,error,*999)
433 CASE(field_gauss_point_based_interpolation)
434 CALL field_parametersetgetlocalgausspoint(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
435 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,gaussnumber,elementnumber, &
436 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
440 CALL flagerror(local_error,err,error,*999)
443 CALL flagerror(
"CellML environment intermediate field is not associated.",err,error,*999)
446 IF(
ASSOCIATED(cellml%PARAMETERS_FIELD))
THEN 448 CASE(field_constant_interpolation)
449 CALL field_parameter_set_get_constant(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
450 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER, &
451 & dofvalue,err,error,*999)
452 CASE(field_element_based_interpolation)
453 CALL field_parameter_set_get_element(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,field_u_variable_type, &
454 & model_map%CELLML_PARAMETER_SET,elementnumber,model_map%CELLML_VARIABLE_NUMBER,dofvalue, &
456 CASE(field_node_based_interpolation)
457 CALL field_parametersetgetlocalnode(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,field_u_variable_type, &
458 & model_map%CELLML_PARAMETER_SET,versionnumber,derivativenumber,nodenumber, &
459 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
460 CASE(field_grid_point_based_interpolation)
461 CALL flagerror(
"Not implemented.",err,error,*999)
462 CASE(field_gauss_point_based_interpolation)
463 CALL field_parametersetgetlocalgausspoint(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
464 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,gaussnumber,elementnumber, &
465 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
469 CALL flagerror(local_error,err,error,*999)
472 CALL flagerror(
"CellML environment parameters field is not associated.",err,error,*999)
475 local_error=
"The CellML to field model map CellML field type of "// &
477 &
" is invalid for map index "//
trim(
number_to_vstring(map_idx,
"*",err,error))//
" of model index "// &
480 CALL flagerror(local_error,err,error,*999)
484 CASE(field_constant_interpolation)
485 CALL field_parameter_set_update_constant(model_map%FIELD,model_map%VARIABLE_TYPE, &
486 & model_map%FIELD_PARAMETER_SET,model_map%COMPONENT_NUMBER,dofvalue,err,error,*999)
487 CASE(field_element_based_interpolation)
488 CALL field_parameter_set_update_element(model_map%FIELD,model_map%VARIABLE_TYPE, &
489 & model_map%FIELD_PARAMETER_SET,elementnumber,model_map%COMPONENT_NUMBER,dofvalue, &
491 CASE(field_node_based_interpolation)
492 CALL field_parameter_set_update_local_node(model_map%FIELD,model_map%VARIABLE_TYPE, &
493 & model_map%FIELD_PARAMETER_SET,versionnumber,derivativenumber,nodenumber, &
494 & model_map%COMPONENT_NUMBER,dofvalue,err,error,*999)
495 CASE(field_grid_point_based_interpolation)
496 CALL flagerror(
"Not implemented.",err,error,*999)
497 CASE(field_gauss_point_based_interpolation)
498 CALL field_parametersetupdategausspoint(model_map%FIELD,model_map%VARIABLE_TYPE, &
499 & model_map%FIELD_PARAMETER_SET,gaussnumber,elementnumber,model_map%COMPONENT_NUMBER, &
500 & dofvalue,err,error,*999)
504 CALL flagerror(local_error,err,error,*999)
507 local_error=
"The CellML to field map is not associated for map index "// &
511 CALL flagerror(local_error,err,error,*999)
516 & model_map%CELLML_FIELD_TYPE,err,error,*999)
518 & model_map%CELLML_PARAMETER_SET,err,error,*999)
520 & model_map%CELLML_VARIABLE_NUMBER,err,error,*999)
522 & model_map%FIELD%USER_NUMBER,err,error,*999)
524 & model_map%VARIABLE_TYPE,err,error,*999)
526 & model_map%FIELD_PARAMETER_SET,err,error,*999)
528 & model_map%COMPONENT_NUMBER,err,error,*999)
532 local_error=
"The CellML field maps models map is not associated for model index "// &
535 CALL flagerror(local_error,err,error,*999)
539 CALL field_parameter_set_data_restore(models_field,field_u_variable_type,field_values_set_type, &
540 & models_data,err,error,*999)
542 CALL flagerror(
"CellML environment models field models field is not associated.",err,error,*999)
546 CALL flagerror(
"CellML environment field maps is not associated.",err,error,*999)
549 CALL flagerror(
"CellML models field is not associated.",err,error,*999)
552 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
557 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
561 exits(
"CELLML_CELLML_TO_FIELD_UPDATE")
563 999 errorsexits(
"CELLML_CELLML_TO_FIELD_UPDATE",err,error)
576 INTEGER(INTG),
INTENT(IN) :: CELLML_USER_NUMBER
579 INTEGER(INTG),
INTENT(OUT) :: ERR
582 INTEGER(INTG) :: cellml_idx
590 enters(
"CELLML_CREATE_START",err,error,*999)
594 IF(
ASSOCIATED(region))
THEN 595 IF(
ASSOCIATED(cellml))
THEN 596 CALL flagerror(
"CellML is already associated.",err,error,*999)
600 IF(
ASSOCIATED(cellml))
THEN 601 local_error=
"CellML environment number "//
trim(
number_to_vstring(cellml_user_number,
"*",err,error))// &
602 &
" has already been created on region number "//
trim(
number_to_vstring(region%USER_NUMBER,
"*",err,error))//
"." 603 CALL flagerror(local_error,err,error,*999)
605 cellml_environments=>region%CELLML_ENVIRONMENTS
606 IF(
ASSOCIATED(cellml_environments))
THEN 611 new_cellml%USER_NUMBER = cellml_user_number
612 new_cellml%GLOBAL_NUMBER = cellml_environments%NUMBER_OF_ENVIRONMENTS+1
613 new_cellml%ENVIRONMENTS => cellml_environments
614 new_cellml%REGION => region
616 ALLOCATE(new_cellml_environments(cellml_environments%NUMBER_OF_ENVIRONMENTS+1),stat=err)
617 IF(err/=0)
CALL flagerror(
"Could not allocate new CellML environments.",err,error,*999)
618 DO cellml_idx=1,cellml_environments%NUMBER_OF_ENVIRONMENTS
619 new_cellml_environments(cellml_idx)%PTR=>cellml_environments%ENVIRONMENTS(cellml_idx)%PTR
621 new_cellml_environments(cellml_environments%NUMBER_OF_ENVIRONMENTS+1)%PTR=>new_cellml
622 CALL move_alloc(new_cellml_environments,cellml_environments%ENVIRONMENTS)
623 cellml_environments%NUMBER_OF_ENVIRONMENTS=cellml_environments%NUMBER_OF_ENVIRONMENTS+1
626 CALL flagerror(
"Region CellML environments is not associated.",err,error,*999)
631 CALL flagerror(
"Region is not associated.",err,error,*999)
636 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
640 exits(
"CELLML_CREATE_START")
642 999
IF(
ALLOCATED(new_cellml_environments))
DEALLOCATE(new_cellml_environments)
643 errorsexits(
"CELLML_CREATE_START",err,error)
657 INTEGER(INTG),
INTENT(OUT) :: ERR
661 INTEGER(C_INT) :: ERROR_CODE
662 INTEGER(INTG) :: model_idx
665 enters(
"CELLML_CREATE_FINISH",err,error,*999)
669 IF(
ASSOCIATED(cellml))
THEN 670 IF(cellml%CELLML_FINISHED)
THEN 671 CALL flagerror(
"CellML environment has already been finished.",err,error,*999)
674 IF(cellml%NUMBER_OF_MODELS>0)
THEN 675 DO model_idx=1,cellml%NUMBER_OF_MODELS
677 cellml_model => cellml%MODELS(model_idx)%PTR
679 error_code = cellml_model_definition_instantiate(cellml_model%PTR)
680 IF(error_code /= 0)
THEN 681 local_error=
"Error instantiating CellML model index "//
trim(
number_to_vstring(model_idx,
"*",err,error))//
"." 682 CALL flagerror(local_error,err,error,*999)
684 cellml_model%NUMBER_OF_STATE = cellml_model_definition_get_n_rates(cellml_model%PTR)
685 IF(cellml_model%NUMBER_OF_STATE>cellml%MAXIMUM_NUMBER_OF_STATE) &
686 & cellml%MAXIMUM_NUMBER_OF_STATE=cellml_model%NUMBER_OF_STATE
687 cellml_model%NUMBER_OF_PARAMETERS = cellml_model_definition_get_n_constants(cellml_model%PTR)
688 IF(cellml_model%NUMBER_OF_PARAMETERS>cellml%MAXIMUM_NUMBER_OF_PARAMETERS) &
689 & cellml%MAXIMUM_NUMBER_OF_PARAMETERS=cellml_model%NUMBER_OF_PARAMETERS
690 cellml_model%NUMBER_OF_INTERMEDIATE = cellml_model_definition_get_n_algebraic(cellml_model%PTR)
691 IF(cellml_model%NUMBER_OF_INTERMEDIATE>cellml%MAXIMUM_NUMBER_OF_INTERMEDIATE) &
692 & cellml%MAXIMUM_NUMBER_OF_INTERMEDIATE=cellml_model%NUMBER_OF_INTERMEDIATE
694 cellml%CELLML_FINISHED = .true.
696 CALL flagerror(
"Invalid setup. No models have been imported into the CellML environment.",err,error,*999)
700 CALL flagerror(
"CellML is not associated.",err,error,*999)
705 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
709 exits(
"CELLML_CREATE_FINISH")
711 999 errorsexits(
"CELLML_CREATE_FINISH",err,error)
722 INTEGER(INTG),
INTENT(OUT) :: ERR
725 INTEGER(INTG) :: cellml_idx,cellml_position
729 enters(
"CELLML_DESTROY",err,error,*999)
733 IF(
ASSOCIATED(cellml))
THEN 735 cellml_environments=>cellml%ENVIRONMENTS
736 IF(
ASSOCIATED(cellml_environments))
THEN 737 cellml_position=cellml%GLOBAL_NUMBER
739 IF(cellml_environments%NUMBER_OF_ENVIRONMENTS>1)
THEN 740 ALLOCATE(new_cellml_environments(cellml_environments%NUMBER_OF_ENVIRONMENTS-1),stat=err)
741 IF(err/=0)
CALL flagerror(
"Could not allocated new CellML environments.",err,error,*999)
742 DO cellml_idx=1,cellml_environments%NUMBER_OF_ENVIRONMENTS
743 IF(cellml_idx<cellml_position)
THEN 744 new_cellml_environments(cellml_idx)%PTR=>cellml_environments%ENVIRONMENTS(cellml_idx)%PTR
745 ELSE IF(cellml_idx>cellml_position)
THEN 746 cellml_environments%ENVIRONMENTS(cellml_idx)%PTR%GLOBAL_NUMBER=cellml_environments%ENVIRONMENTS(cellml_idx)% &
747 &
ptr%GLOBAL_NUMBER-1
748 new_cellml_environments(cellml_idx-1)%PTR=>cellml_environments%ENVIRONMENTS(cellml_idx)%PTR
751 CALL move_alloc(new_cellml_environments,cellml_environments%ENVIRONMENTS)
752 cellml_environments%NUMBER_OF_ENVIRONMENTS=cellml_environments%NUMBER_OF_ENVIRONMENTS-1
754 IF(
ALLOCATED(cellml_environments%ENVIRONMENTS))
DEALLOCATE(cellml_environments%ENVIRONMENTS)
755 cellml_environments%NUMBER_OF_ENVIRONMENTS=0
758 CALL flagerror(
"CellML environments is not associated.",err,error,*999)
761 CALL flagerror(
"CellML is not associated.",err,error,*999)
766 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
770 exits(
"CELLML_DESTROY")
772 999
IF(
ALLOCATED(new_cellml_environments))
DEALLOCATE(new_cellml_environments)
773 errorsexits(
"CELLML_DESTROY",err,error)
787 INTEGER(INTG),
INTENT(OUT) :: ERR
790 INTEGER(INTG) :: derivativeNumber,dofIdx,dofType,dof2ParamIdx,elementNumber,gaussNumber,gridNumber,map_idx,modelIdx, &
791 & nodeNumber,versionNumber
792 INTEGER(INTG),
POINTER :: MODELS_DATA(:)
801 enters(
"CELLML_FIELD_TO_CELLML_UPDATE",err,error,*999)
805 IF(
ASSOCIATED(cellml))
THEN 806 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 807 field_maps=>cellml%FIELD_MAPS
808 IF(
ASSOCIATED(field_maps))
THEN 811 model_maps=>field_maps%MODEL_MAPS(cellml%MODELS_FIELD%ONLY_ONE_MODEL_INDEX)%PTR
812 IF(
ASSOCIATED(model_maps))
THEN 817 & only_one_model_index,err,error,*999)
819 & number_of_fields_mapped_to,err,error,*999)
822 DO map_idx=1,model_maps%NUMBER_OF_FIELDS_MAPPED_TO
823 model_map=>model_maps%FIELDS_MAPPED_TO(map_idx)%PTR
824 IF(
ASSOCIATED(model_map))
THEN 825 SELECT CASE(model_map%CELLML_FIELD_TYPE)
827 CALL flagerror(
"Cannot map models field.",err,error,*999)
829 IF(
ASSOCIATED(cellml%STATE_FIELD))
THEN 830 CALL field_parameterstofieldparameterscopy(model_map%FIELD,model_map%VARIABLE_TYPE, &
831 & model_map%FIELD_PARAMETER_SET,model_map%COMPONENT_NUMBER,cellml%STATE_FIELD%STATE_FIELD, &
832 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER,err,error,*999)
834 CALL flagerror(
"CellML environment state field is not associated.",err,error,*999)
837 IF(
ASSOCIATED(cellml%INTERMEDIATE_FIELD))
THEN 838 CALL field_parameterstofieldparameterscopy(model_map%FIELD,model_map%VARIABLE_TYPE, &
839 & model_map%FIELD_PARAMETER_SET,model_map%COMPONENT_NUMBER,cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
840 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER,err,error,*999)
842 CALL flagerror(
"CellML environment intermediate field is not associated.",err,error,*999)
845 IF(
ASSOCIATED(cellml%PARAMETERS_FIELD))
THEN 846 CALL field_parameterstofieldparameterscopy(model_map%FIELD,model_map%VARIABLE_TYPE, &
847 & model_map%FIELD_PARAMETER_SET,model_map%COMPONENT_NUMBER,cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
848 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER,err,error,*999)
850 CALL flagerror(
"CellML environment parameters field is not associated.",err,error,*999)
853 local_error=
"The CellML to field model map CellML field type of "// &
855 &
" is invalid for map index "//
trim(
number_to_vstring(map_idx,
"*",err,error))//
" of model index "// &
858 CALL flagerror(local_error,err,error,*999)
861 local_error=
"The CellML to field map is not associated for map index "// &
865 CALL flagerror(local_error,err,error,*999)
886 local_error=
"The CellML field maps models map is not associated for model index "// &
889 CALL flagerror(local_error,err,error,*999)
893 models_field=>cellml%MODELS_FIELD%MODELS_FIELD
894 IF(
ASSOCIATED(models_field))
THEN 895 NULLIFY(models_variable)
896 CALL field_variable_get(models_field,field_u_variable_type,models_variable,err,error,*999)
898 CALL field_parameter_set_data_get(models_field,field_u_variable_type,field_values_set_type, &
899 & models_data,err,error,*999)
905 DO dofidx=1,models_variable%TOTAL_NUMBER_OF_DOFS
906 modelidx=models_data(dofidx)
908 model_maps=>field_maps%MODEL_MAPS(modelidx)%PTR
909 IF(
ASSOCIATED(model_maps))
THEN 910 doftype=models_variable%DOF_TO_PARAM_MAP%DOF_TYPE(1,dofidx)
911 dof2paramidx=models_variable%DOF_TO_PARAM_MAP%DOF_TYPE(2,dofidx)
913 CASE(field_constant_interpolation)
915 CASE(field_element_based_interpolation)
916 elementnumber=models_variable%DOF_TO_PARAM_MAP%ELEMENT_DOF2PARAM_MAP(1,dof2paramidx)
917 CASE(field_node_based_interpolation)
918 versionnumber=models_variable%DOF_TO_PARAM_MAP%NODE_DOF2PARAM_MAP(1,dof2paramidx)
919 derivativenumber=models_variable%DOF_TO_PARAM_MAP%NODE_DOF2PARAM_MAP(2,dof2paramidx)
920 nodenumber=models_variable%DOF_TO_PARAM_MAP%NODE_DOF2PARAM_MAP(3,dof2paramidx)
921 CASE(field_grid_point_based_interpolation)
922 gridnumber=models_variable%DOF_TO_PARAM_MAP%GRID_POINT_DOF2PARAM_MAP(1,dof2paramidx)
923 CASE(field_gauss_point_based_interpolation)
924 gaussnumber=models_variable%DOF_TO_PARAM_MAP%GAUSS_POINT_DOF2PARAM_MAP(1,dof2paramidx)
925 elementnumber=models_variable%DOF_TO_PARAM_MAP%GAUSS_POINT_DOF2PARAM_MAP(2,dof2paramidx)
929 CALL flagerror(local_error,err,error,*999)
936 CASE(field_constant_interpolation)
938 CASE(field_element_based_interpolation)
940 CASE(field_node_based_interpolation)
945 CASE(field_grid_point_based_interpolation)
947 CASE(field_gauss_point_based_interpolation)
953 CALL flagerror(local_error,err,error,*999)
956 & number_of_fields_mapped_to,err,error,*999)
959 DO map_idx=1,model_maps%NUMBER_OF_FIELDS_MAPPED_TO
960 model_map=>model_maps%FIELDS_MAPPED_TO(map_idx)%PTR
961 IF(
ASSOCIATED(model_map))
THEN 964 CASE(field_constant_interpolation)
965 CALL field_parameter_set_get_constant(model_map%FIELD,model_map%VARIABLE_TYPE, &
966 & model_map%FIELD_PARAMETER_SET,model_map%COMPONENT_NUMBER,dofvalue,err,error,*999)
967 CASE(field_element_based_interpolation)
968 CALL field_parameter_set_get_element(model_map%FIELD,model_map%VARIABLE_TYPE, &
969 & model_map%FIELD_PARAMETER_SET,elementnumber,model_map%COMPONENT_NUMBER,dofvalue, &
971 CASE(field_node_based_interpolation)
972 CALL field_parametersetgetlocalnode(model_map%FIELD,model_map%VARIABLE_TYPE, &
973 & model_map%FIELD_PARAMETER_SET,versionnumber,derivativenumber,nodenumber, &
974 & model_map%COMPONENT_NUMBER,dofvalue,err,error,*999)
975 CASE(field_grid_point_based_interpolation)
976 CALL flagerror(
"Not implemented.",err,error,*999)
977 CASE(field_gauss_point_based_interpolation)
978 CALL field_parametersetgetlocalgausspoint(model_map%FIELD,model_map%VARIABLE_TYPE, &
979 & model_map%FIELD_PARAMETER_SET,gaussnumber,elementnumber, &
980 & model_map%COMPONENT_NUMBER,dofvalue,err,error,*999)
984 CALL flagerror(local_error,err,error,*999)
987 SELECT CASE(model_map%CELLML_FIELD_TYPE)
989 CALL flagerror(
"Cannot map models field.",err,error,*999)
991 IF(
ASSOCIATED(cellml%STATE_FIELD))
THEN 993 CASE(field_constant_interpolation)
994 CALL field_parameter_set_update_constant(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
995 & model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
996 CASE(field_element_based_interpolation)
997 CALL field_parameter_set_update_element(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
998 & model_map%CELLML_PARAMETER_SET,elementnumber,model_map%CELLML_VARIABLE_NUMBER,dofvalue, &
1000 CASE(field_node_based_interpolation)
1001 CALL field_parameter_set_update_local_node(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
1002 & model_map%CELLML_PARAMETER_SET,versionnumber,derivativenumber,nodenumber, &
1003 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
1004 CASE(field_grid_point_based_interpolation)
1005 CALL flagerror(
"Not implemented.",err,error,*999)
1006 CASE(field_gauss_point_based_interpolation)
1007 CALL field_parametersetupdategausspoint(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
1008 & model_map%CELLML_PARAMETER_SET,gaussnumber,elementnumber,model_map%CELLML_VARIABLE_NUMBER, &
1009 & dofvalue,err,error,*999)
1013 CALL flagerror(local_error,err,error,*999)
1016 CALL flagerror(
"CellML environment state field is not associated.",err,error,*999)
1019 IF(
ASSOCIATED(cellml%INTERMEDIATE_FIELD))
THEN 1020 SELECT CASE(doftype)
1021 CASE(field_constant_interpolation)
1022 CALL field_parameter_set_update_constant(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
1023 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER, &
1024 & dofvalue,err,error,*999)
1025 CASE(field_element_based_interpolation)
1026 CALL field_parameter_set_update_element(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
1027 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,elementnumber, &
1028 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
1029 CASE(field_node_based_interpolation)
1030 CALL field_parameter_set_update_local_node(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
1031 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,versionnumber,derivativenumber,nodenumber, &
1032 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
1033 CASE(field_grid_point_based_interpolation)
1034 CALL flagerror(
"Not implemented.",err,error,*999)
1035 CASE(field_gauss_point_based_interpolation)
1036 CALL field_parametersetupdategausspoint(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
1037 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,gaussnumber,elementnumber, &
1038 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
1042 CALL flagerror(local_error,err,error,*999)
1045 CALL flagerror(
"CellML environment intermediate field is not associated.",err,error,*999)
1048 IF(
ASSOCIATED(cellml%PARAMETERS_FIELD))
THEN 1049 SELECT CASE(doftype)
1050 CASE(field_constant_interpolation)
1051 CALL field_parameter_set_update_constant(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
1052 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,model_map%CELLML_VARIABLE_NUMBER, &
1053 & dofvalue,err,error,*999)
1054 CASE(field_element_based_interpolation)
1055 CALL field_parameter_set_update_element(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
1056 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,elementnumber, &
1057 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
1058 CASE(field_node_based_interpolation)
1059 CALL field_parameter_set_update_local_node(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
1060 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,versionnumber,derivativenumber,nodenumber, &
1061 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
1062 CASE(field_grid_point_based_interpolation)
1063 CALL flagerror(
"Not implemented.",err,error,*999)
1064 CASE(field_gauss_point_based_interpolation)
1065 CALL field_parametersetupdategausspoint(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
1066 & field_u_variable_type,model_map%CELLML_PARAMETER_SET,gaussnumber,elementnumber, &
1067 & model_map%CELLML_VARIABLE_NUMBER,dofvalue,err,error,*999)
1071 CALL flagerror(local_error,err,error,*999)
1074 CALL flagerror(
"CellML environment parameters field is not associated.",err,error,*999)
1077 local_error=
"The CellML to field model map CellML field type of "// &
1079 &
" is invalid for map index "//
trim(
number_to_vstring(map_idx,
"*",err,error))//
" of model index "// &
1082 CALL flagerror(local_error,err,error,*999)
1085 local_error=
"The CellML to field map is not associated for map index "// &
1089 CALL flagerror(local_error,err,error,*999)
1094 & model_map%CELLML_FIELD_TYPE,err,error,*999)
1096 & model_map%CELLML_PARAMETER_SET,err,error,*999)
1098 & model_map%CELLML_VARIABLE_NUMBER,err,error,*999)
1100 & model_map%FIELD%USER_NUMBER,err,error,*999)
1102 & model_map%VARIABLE_TYPE,err,error,*999)
1104 & model_map%FIELD_PARAMETER_SET,err,error,*999)
1106 & model_map%COMPONENT_NUMBER,err,error,*999)
1110 local_error=
"The CellML field maps models map is not associated for model index "// &
1113 CALL flagerror(local_error,err,error,*999)
1117 CALL field_parameter_set_data_restore(models_field,field_u_variable_type,field_values_set_type, &
1118 & models_data,err,error,*999)
1120 CALL flagerror(
"CellML environment models field models field is not associated.",err,error,*999)
1124 CALL flagerror(
"CellML environment field maps is not associated.",err,error,*999)
1127 CALL flagerror(
"CellML environment models field is not associated.",err,error,*999)
1130 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
1135 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1139 exits(
"CELLML_FIELD_TO_CELLML_UPDATE")
1141 999 errorsexits(
"CELLML_FIELD_TO_CELLML_UPDATE",err,error)
1153 INTEGER(INTG),
INTENT(OUT) :: ERR
1156 INTEGER(INTG) :: model_idx
1158 enters(
"CELLML_FINALISE",err,error,*999)
1162 IF(
ASSOCIATED(cellml))
THEN 1163 IF(
ALLOCATED(cellml%MODELS))
THEN 1164 DO model_idx=1,
SIZE(cellml%MODELS,1)
1167 DEALLOCATE(cellml%MODELS)
1179 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1183 exits(
"CELLML_FINALISE")
1185 999 errorsexits(
"CELLML_FINALISE",err,error)
1197 INTEGER(INTG),
INTENT(OUT) :: ERR
1200 INTEGER(INTG) :: DUMMY_ERR
1203 enters(
"CELLML_INITIALISE",err,error,*998)
1207 IF(
ASSOCIATED(cellml))
THEN 1208 CALL flagerror(
"CellML environment is already associated.",err,error,*998)
1210 ALLOCATE(cellml,stat=err)
1211 IF(err/=0)
CALL flagerror(
"Could not allocate CellML environment.",err,error,*999)
1212 cellml%GLOBAL_NUMBER=0
1213 cellml%USER_NUMBER=0
1214 NULLIFY(cellml%REGION)
1215 NULLIFY(cellml%ENVIRONMENTS)
1216 cellml%CELLML_FINISHED=.false.
1217 cellml%NUMBER_OF_MODELS=0
1218 cellml%MAXIMUM_NUMBER_OF_STATE=0
1219 cellml%MAXIMUM_NUMBER_OF_PARAMETERS=0
1220 cellml%MAXIMUM_NUMBER_OF_INTERMEDIATE=0
1221 NULLIFY(cellml%FIELD_MAPS)
1222 NULLIFY(cellml%MODELS_FIELD)
1223 NULLIFY(cellml%STATE_FIELD)
1224 NULLIFY(cellml%INTERMEDIATE_FIELD)
1225 NULLIFY(cellml%PARAMETERS_FIELD)
1226 cellml%CELLML_GENERATED=.false.
1231 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*998)
1235 exits(
"CELLML_INITIALISE")
1238 998 errorsexits(
"CELLML_INITIALISE",err,error)
1251 INTEGER(INTG),
INTENT(OUT) :: ERR
1254 INTEGER(INTG) :: model_idx
1258 enters(
"CELLML_FIELD_MAPS_CREATE_FINISH",err,error,*999)
1262 IF(
ASSOCIATED(cellml))
THEN 1263 IF(cellml%CELLML_FINISHED)
THEN 1264 IF(
ASSOCIATED(cellml%FIELD_MAPS))
THEN 1265 IF(cellml%FIELD_MAPS%CELLML_FIELD_MAPS_FINISHED)
THEN 1266 CALL flagerror(
"The CellML environment field maps have already been finished.",err,error,*999)
1269 DO model_idx=1,cellml%NUMBER_OF_MODELS
1270 cellml_model_maps=>cellml%FIELD_MAPS%MODEL_MAPS(model_idx)%PTR
1271 IF(
ASSOCIATED(cellml_model_maps))
THEN 1272 IF(cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_TO==0.AND.cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_FROM==0)
THEN 1273 local_error=
"Invalid setup. CellML model index "//
trim(
number_to_vstring(model_idx,
"*",err,error))// &
1274 &
" does not have any mappings to or from a field." 1275 CALL flagerror(local_error,err,error,*999)
1278 local_error=
"CellML field maps model maps is not associated for model index "// &
1280 CALL flagerror(local_error,err,error,*999)
1283 cellml%FIELD_MAPS%CELLML_FIELD_MAPS_FINISHED=.true.
1286 CALL flagerror(
"CellML environment field maps is not associated.",err,error,*999)
1289 CALL flagerror(
"CellML environment has not been finished.",err,error,*999)
1292 CALL flagerror(
"CellML is not associated.",err,error,*999)
1297 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1301 exits(
"CELLML_FIELD_MAPS_CREATE_FINISH")
1303 999 errorsexits(
"CELLML_FIELD_MAPS_CREATE_FINISH",err,error)
1316 INTEGER(INTG),
INTENT(OUT) :: ERR
1320 enters(
"CELLML_FIELD_MAPS_CREATE_START",err,error,*999)
1324 IF(
ASSOCIATED(cellml))
THEN 1325 IF(cellml%CELLML_FINISHED)
THEN 1329 CALL flagerror(
"CellML environment has not been finished.",err,error,*999)
1332 CALL flagerror(
"CellML is not associated.",err,error,*999)
1337 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1341 exits(
"CELLML_FIELD_MAPS_CREATE_START")
1343 999 errorsexits(
"CELLML_FIELD_MAPS_CREATE_START",err,error)
1355 INTEGER(INTG),
INTENT(OUT) :: ERR
1358 INTEGER(INTG) :: model_idx
1360 enters(
"CELLML_FIELD_MAPS_FINALISE",err,error,*999)
1364 IF(
ASSOCIATED(cellml_field_maps))
THEN 1365 IF(
ALLOCATED(cellml_field_maps%MODEL_MAPS))
THEN 1366 DO model_idx=1,
SIZE(cellml_field_maps%MODEL_MAPS,1)
1369 DEALLOCATE(cellml_field_maps%MODEL_MAPS)
1371 DEALLOCATE(cellml_field_maps)
1376 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1380 exits(
"CELLML_FIELD_MAPS_FINALISE")
1382 999 errorsexits(
"CELLML_FIELD_MAPS_FINALISE",err,error)
1395 INTEGER(INTG),
INTENT(OUT) :: ERR
1398 INTEGER(INTG) :: DUMMY_ERR,model_idx
1401 enters(
"CELLML_FIELD_MAPS_INITIALISE",err,error,*998)
1405 IF(
ASSOCIATED(cellml))
THEN 1406 IF(
ASSOCIATED(cellml%FIELD_MAPS))
THEN 1407 CALL flagerror(
"CellML environment field maps is already associated.",err,error,*999)
1409 IF(cellml%CELLML_FINISHED)
THEN 1410 ALLOCATE(cellml%FIELD_MAPS,stat=err)
1411 IF(err/=0)
CALL flagerror(
"Could not allocate CellML field maps.",err,error,*999)
1412 cellml%FIELD_MAPS%CELLML=>cellml
1413 cellml%FIELD_MAPS%CELLML_FIELD_MAPS_FINISHED=.false.
1414 NULLIFY(cellml%FIELD_MAPS%SOURCE_GEOMETRIC_FIELD)
1415 NULLIFY(cellml%FIELD_MAPS%SOURCE_FIELD_VARIABLE)
1416 NULLIFY(cellml%FIELD_MAPS%SOURCE_FIELD_DOMAIN)
1417 cellml%FIELD_MAPS%SOURCE_FIELD_INTERPOLATION_TYPE=0
1421 ALLOCATE(cellml%FIELD_MAPS%MODEL_MAPS(cellml%NUMBER_OF_MODELS),stat=err)
1422 IF(err/=0)
CALL flagerror(
"Could not allocate CellML environment field maps model maps.",err,error,*999)
1423 DO model_idx=1,cellml%NUMBER_OF_MODELS
1424 NULLIFY(cellml%FIELD_MAPS%MODEL_MAPS(model_idx)%PTR)
1428 CALL flagerror(
"CellML environment has not been finished.",err,error,*999)
1432 CALL flagerror(
"CellML environement is not associated.",err,error,*999)
1437 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*998)
1441 exits(
"CELLML_FIELD_MAPS_INITIALISE")
1444 998 errorsexits(
"CELLML_FIELD_MAPS_INITIALISE",err,error)
1456 INTEGER(INTG),
INTENT(OUT) :: ERR
1460 enters(
"CELLML_MODEL_FINALISE",err,error,*999)
1464 IF(
ASSOCIATED(cellml_model))
THEN 1465 IF(c_associated(cellml_model%PTR))
CALL destroy_cellml_model_definition(cellml_model%PTR)
1466 cellml_model%MODEL_ID=
"" 1467 DEALLOCATE(cellml_model)
1472 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1476 exits(
"CELLML_MODEL_FINALISE")
1478 999 errorsexits(
"CELLML_MODEL_FINALISE",err,error)
1491 INTEGER(INTG),
INTENT(OUT) :: ERR
1494 INTEGER(INTG) :: DUMMY_ERR
1497 enters(
"CELLML_MODEL_INITIALISE",err,error,*998)
1501 IF(
ASSOCIATED(cellml_model))
THEN 1502 CALL flagerror(
"CellML model is already associated.",err,error,*998)
1504 ALLOCATE(cellml_model,stat=err)
1505 IF(err/=0)
CALL flagerror(
"Could not allocate CellML model.",err,error,*999)
1506 NULLIFY(cellml_model%CELLML)
1507 cellml_model%GLOBAL_NUMBER=0
1508 cellml_model%MODEL_ID=
"" 1509 cellml_model%PTR = c_null_ptr
1510 cellml_model%NUMBER_OF_STATE=0
1511 cellml_model%NUMBER_OF_INTERMEDIATE=0
1512 cellml_model%NUMBER_OF_PARAMETERS=0
1517 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*998)
1521 exits(
"CELLML_MODEL_INITIALISE")
1524 998 errorsexits(
"CELLML_MODEL_INITIALISE",err,error)
1536 INTEGER(INTG),
INTENT(OUT) :: ERR
1540 enters(
"CELLML_MODEL_MAP_FINALISE",err,error,*999)
1544 IF(
ASSOCIATED(cellml_model_map))
THEN 1545 CALL erase(cellml_model_map%VARIABLE_ID)
1546 DEALLOCATE(cellml_model_map)
1551 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1555 exits(
"CELLML_MODEL_MAP_FINALISE")
1557 999 errorsexits(
"CELLML_MODEL_MAP_FINALISE",err,error)
1570 INTEGER(INTG),
INTENT(OUT) :: ERR
1573 INTEGER(INTG) :: DUMMY_ERR
1576 enters(
"CELLML_MODEL_MAP_INITIALISE",err,error,*998)
1580 IF(
ASSOCIATED(cellml_model_map))
THEN 1581 CALL flagerror(
"CellML model map field is already associated.",err,error,*998)
1583 ALLOCATE(cellml_model_map,stat=err)
1584 IF(err/=0)
CALL flagerror(
"Could not allocate CellML model map.",err,error,*999)
1585 cellml_model_map%CELLML_MAP_TYPE = 0
1586 NULLIFY(cellml_model_map%FIELD)
1587 cellml_model_map%VARIABLE_TYPE=0
1588 cellml_model_map%COMPONENT_NUMBER=0
1589 cellml_model_map%FIELD_PARAMETER_SET=0
1590 cellml_model_map%VARIABLE_ID=
"" 1591 cellml_model_map%CELLML_FIELD_TYPE=0
1592 cellml_model_map%CELLML_VARIABLE_NUMBER=0
1593 cellml_model_map%CELLML_PARAMETER_SET=0
1598 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*998)
1602 exits(
"CELLML_MODEL_MAP_INITIALISE")
1605 998 errorsexits(
"CELLML_MODEL_MAP_INITIALISE",err,error)
1617 INTEGER(INTG),
INTENT(OUT) :: ERR
1620 INTEGER(INTG) :: map_idx
1622 enters(
"CELLML_MODEL_MAPS_FINALISE",err,error,*999)
1626 IF(
ASSOCIATED(cellml_model_maps))
THEN 1627 IF(
ALLOCATED(cellml_model_maps%FIELDS_MAPPED_TO))
THEN 1628 DO map_idx=1,
SIZE(cellml_model_maps%FIELDS_MAPPED_TO,1)
1631 DEALLOCATE(cellml_model_maps%FIELDS_MAPPED_TO)
1633 IF(
ALLOCATED(cellml_model_maps%FIELDS_MAPPED_FROM))
THEN 1634 DO map_idx=1,
SIZE(cellml_model_maps%FIELDS_MAPPED_FROM,1)
1637 DEALLOCATE(cellml_model_maps%FIELDS_MAPPED_FROM)
1639 DEALLOCATE(cellml_model_maps)
1644 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1648 exits(
"CELLML_MODEL_MAPS_FINALISE")
1650 999 errorsexits(
"CELLML_MODEL_MAPS_FINALISE",err,error)
1663 INTEGER(INTG),
INTENT(OUT) :: ERR
1666 INTEGER(INTG) :: DUMMY_ERR
1669 enters(
"CELLML_MODEL_MAPS_INITIALISE",err,error,*998)
1673 IF(
ASSOCIATED(cellml_model_maps))
THEN 1674 CALL flagerror(
"CellML model maps is already associated.",err,error,*998)
1676 ALLOCATE(cellml_model_maps,stat=err)
1677 IF(err/=0)
CALL flagerror(
"Could not allocate CellML model maps.",err,error,*999)
1678 cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_TO=0
1679 cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_FROM=0
1684 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*998)
1688 exits(
"CELLML_MODEL_MAPS_INITIALISE")
1691 998 errorsexits(
"CELLML_MODEL_MAPS_INITIALISE",err,error)
1703 CHARACTER(LEN=*) :: URI
1704 INTEGER(INTG),
INTENT(OUT) :: MODEL_INDEX
1705 INTEGER(INTG),
INTENT(OUT) :: ERR
1708 INTEGER(INTG) :: cellml_idx
1713 CHARACTER(256) :: C_URI
1714 INTEGER(INTG) :: C_URI_L
1716 enters(
"CELLML_MODEL_IMPORT_C",err,error,*999)
1723 IF(
ASSOCIATED(cellml))
THEN 1729 WRITE(c_uri,
'(A,A)') uri(1:c_uri_l),c_null_char
1730 new_model%PTR = create_cellml_model_definition(c_uri)
1731 IF(c_associated(new_model%PTR))
THEN 1732 new_model%GLOBAL_NUMBER = cellml%NUMBER_OF_MODELS+1
1733 new_model%MODEL_ID=uri(1:c_uri_l)
1735 ALLOCATE(new_models(cellml%NUMBER_OF_MODELS+1),stat=err)
1736 IF(err/=0)
CALL flagerror(
"Could not allocate new CellML models array.",err,error,*999)
1737 DO cellml_idx=1,cellml%NUMBER_OF_MODELS
1738 new_models(cellml_idx)%PTR=>cellml%MODELS(cellml_idx)%PTR
1740 new_models(cellml%NUMBER_OF_MODELS+1)%PTR=>new_model
1741 CALL move_alloc(new_models,cellml%MODELS)
1742 cellml%NUMBER_OF_MODELS = cellml%NUMBER_OF_MODELS+1
1743 model_index=cellml%NUMBER_OF_MODELS
1745 CALL flagerror(
"Error instantiating CellML model.",err,error,*999)
1748 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
1753 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1757 exits(
"CELLML_MODEL_IMPORT_C")
1759 999 errorsexits(
"CELLML_MODEL_IMPORT_C",err,error)
1772 INTEGER(INTG),
INTENT(OUT) :: MODEL_INDEX
1773 INTEGER(INTG),
INTENT(OUT) :: ERR
1777 enters(
"CELLML_MODEL_IMPORT_VS",err,error,*999)
1785 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1789 exits(
"CELLML_MODEL_IMPORT_VS")
1791 999 errorsexits(
"CELLML_MODEL_IMPORT_VS",err,error)
1804 INTEGER(INTG),
INTENT(IN) :: MODEL_INDEX
1805 CHARACTER(LEN=*),
INTENT(IN) :: VARIABLE_ID
1806 INTEGER(INTG),
INTENT(OUT) :: ERR
1809 CHARACTER(LEN=MAXSTRLEN) :: C_NAME
1810 INTEGER(INTG) :: C_NAME_L
1811 INTEGER(C_INT) :: ERROR_CODE
1815 enters(
"CELLML_VARIABLE_SET_AS_KNOWN_C",err,error,*999)
1819 IF(
ASSOCIATED(cellml))
THEN 1820 IF(cellml%CELLML_FINISHED)
THEN 1821 CALL flagerror(
"CellML environment has already been finished.",err,error,*999)
1823 IF(model_index>0.AND.model_index<=cellml%NUMBER_OF_MODELS)
THEN 1824 cellml_model=>cellml%MODELS(model_index)%PTR
1825 IF(
ASSOCIATED(cellml_model))
THEN 1828 WRITE(c_name,
'(A,A)') variable_id(1:c_name_l),c_null_char
1829 error_code = cellml_model_definition_set_variable_as_known(cellml_model%PTR,c_name)
1830 IF(error_code /= 0)
THEN 1831 local_error=
"The specified variable can not be set as known: "//variable_id
1832 CALL flagerror(local_error,err,error,*999)
1835 CALL flagerror(
"CellML model is not associated.",err,error,*999)
1839 &
" is invalid. The modex index should be >= 1 and <= "// &
1841 CALL flagerror(local_error,err,error,*999)
1845 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
1850 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1854 exits(
"CELLML_VARIABLE_SET_AS_KNOWN_C")
1856 999 errorsexits(
"CELLML_VARIABLE_SET_AS_KNOWN_C",err,error)
1869 INTEGER(INTG),
INTENT(IN) :: MODEL_USER_NUMBER
1871 INTEGER(INTG),
INTENT(OUT) :: ERR
1875 enters(
"CELLML_VARIABLE_SET_AS_KNOWN_VS",err,error,*999)
1883 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1887 exits(
"CELLML_VARIABLE_SET_AS_KNOWN_VS")
1889 999 errorsexits(
"CELLML_VARIABLE_SET_AS_KNOWN_VS",err,error)
1902 INTEGER(INTG),
INTENT(IN) :: MODEL_INDEX
1903 CHARACTER(LEN=*),
INTENT(IN) :: VARIABLE_ID
1904 INTEGER(INTG),
INTENT(OUT) :: ERR
1907 CHARACTER(LEN=MAXSTRLEN) :: C_NAME
1908 INTEGER(INTG) :: C_NAME_L
1909 INTEGER(C_INT) :: ERROR_CODE
1913 enters(
"CELLML_VARIABLE_SET_AS_WANTED_C",err,error,*999)
1917 IF(
ASSOCIATED(cellml))
THEN 1918 IF(cellml%CELLML_FINISHED)
THEN 1919 CALL flagerror(
"CellML environment has already been finished.",err,error,*999)
1921 IF(model_index>0.AND.model_index<=cellml%NUMBER_OF_MODELS)
THEN 1922 cellml_model=>cellml%MODELS(model_index)%PTR
1923 IF(
ASSOCIATED(cellml_model))
THEN 1926 WRITE(c_name,
'(A,A)') variable_id(1:c_name_l),c_null_char
1927 error_code = cellml_model_definition_set_variable_as_wanted(cellml_model%PTR,c_name)
1928 IF(error_code .NE. 0)
THEN 1929 local_error=
"The specified variable can not be set as wanted: "//variable_id
1930 CALL flagerror(local_error,err,error,*999)
1933 CALL flagerror(
"CellML model is not associated.",err,error,*999)
1937 &
" is invalid. The model index should be >= 1 and <= "// &
1939 CALL flagerror(local_error,err,error,*999)
1943 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
1948 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1952 exits(
"CELLML_VARIABLE_SET_AS_WANTED_C")
1954 999 errorsexits(
"CELLML_VARIABLE_SET_AS_WANTED_C",err,error)
1967 INTEGER(INTG),
INTENT(IN) :: MODEL_USER_NUMBER
1969 INTEGER(INTG),
INTENT(OUT) :: ERR
1973 enters(
"CELLML_VARIABLE_SET_AS_WANTED_VS",err,error,*999)
1981 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1985 exits(
"CELLML_VARIABLE_SET_AS_WANTED_VS")
1987 999 errorsexits(
"CELLML_VARIABLE_SET_AS_WANTED_VS",err,error)
1997 & field,variable_type,component_number,field_parameter_set,err,error,*)
2001 INTEGER(INTG),
INTENT(IN) :: MODEL_INDEX
2002 CHARACTER(LEN=*),
INTENT(IN) :: VARIABLE_ID
2003 INTEGER(INTG),
INTENT(IN) :: CELLML_PARAMETER_SET
2004 TYPE(
field_type),
POINTER,
INTENT(IN) :: FIELD
2005 INTEGER(INTG),
INTENT(IN) :: VARIABLE_TYPE
2006 INTEGER(INTG),
INTENT(IN) :: COMPONENT_NUMBER
2007 INTEGER(INTG),
INTENT(IN) :: FIELD_PARAMETER_SET
2008 INTEGER(INTG),
INTENT(OUT) :: ERR
2011 CHARACTER(LEN=1,KIND=C_CHAR) :: C_NAME(maxstrlen)
2013 INTEGER(C_INT) :: ERROR_C
2014 INTEGER(INTG) :: CELLML_VARIABLE_TYPE,CELLML_FIELD_TYPE,CELLML_VARIABLE_NUMBER,map_idx
2024 enters(
"CELLML_CREATE_CELLML_TO_FIELD_MAP_C",err,error,*999)
2028 IF(
ASSOCIATED(cellml))
THEN 2030 IF(cellml%CELLML_FINISHED)
THEN 2031 cellml_field_maps=>cellml%FIELD_MAPS
2032 IF(
ASSOCIATED(cellml_field_maps))
THEN 2033 IF(cellml_field_maps%CELLML_FIELD_MAPS_FINISHED)
THEN 2034 CALL flagerror(
"CellML field maps have already been finished.",err,error,*999)
2036 NULLIFY(field_variable)
2037 CALL field_variable_get(field,variable_type,field_variable,err,error,*999)
2038 NULLIFY(parameter_set)
2039 CALL field_parameter_set_get(field,variable_type,field_parameter_set,parameter_set,err,error,*999)
2040 IF(component_number>0.AND.component_number<=field_variable%NUMBER_OF_COMPONENTS)
THEN 2041 IF(model_index>0.AND.model_index<=cellml%NUMBER_OF_MODELS)
THEN 2042 cellml_model=>cellml%MODELS(model_index)%PTR
2043 IF(
ASSOCIATED(cellml_model))
THEN 2044 cellml_model_maps=>cellml_field_maps%MODEL_MAPS(model_index)%PTR
2045 IF(
ASSOCIATED(cellml_model_maps))
THEN 2048 error_c = cellml_model_definition_get_variable_type(cellml_model%PTR,c_name,cellml_variable_type)
2049 IF(error_c /= 0)
THEN 2050 local_error=
"Failed to get the type of CellML variable: "// &
2052 &
"; with the error code: "// &
2054 CALL flagerror(local_error,err,error,*999)
2063 IF(
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD))
THEN 2064 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD,field%GEOMETRIC_FIELD))
THEN 2065 local_error=
"The geometric field for field user number "// &
2067 &
" does not match the geometric field for other field variable components mapped" // &
2068 &
" in the CellML environment." 2069 CALL flagerror(local_error,err,error,*999)
2071 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_FIELD_DOMAIN, &
2072 & field_variable%COMPONENTS(component_number)%DOMAIN))
THEN 2073 local_error=
"The domain for component number "//
trim(
number_to_vstring(component_number,
"*",err,error))// &
2076 &
" does not match the domain for other field variable components mapped in the CellML environment." 2077 CALL flagerror(local_error,err,error,*999)
2079 IF(cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE/= &
2080 & field_variable%COMPONENTS(component_number)%INTERPOLATION_TYPE)
THEN 2081 local_error=
"The interpolation type of "// &
2083 &
"*",err,error))//
" for component number "//
trim(
number_to_vstring(component_number,
"*",err,error))// &
2086 &
" does not match the interpolation type of "// &
2088 &
" used in other field variable components mapped in the CellML environment." 2089 CALL flagerror(local_error,err,error,*999)
2092 cellml_field_maps%SOURCE_GEOMETRIC_FIELD=>field%GEOMETRIC_FIELD
2093 cellml_field_maps%SOURCE_FIELD_VARIABLE=>field_variable
2094 cellml_field_maps%SOURCE_FIELD_DOMAIN=>field_variable%COMPONENTS(component_number)%DOMAIN
2095 cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE=field_variable%COMPONENTS(component_number)% &
2096 & interpolation_type
2100 error_c = cellml_model_definition_get_variable_type(cellml_model%PTR,c_name,cellml_variable_type)
2101 IF(error_c /= 0)
THEN 2102 local_error=
"Failed to get the type of CellML variable: "// &
2104 &
"; with the error code: "// &
2106 CALL flagerror(local_error,err,error,*999)
2111 NULLIFY(new_cellml_model_map)
2114 new_cellml_model_map%FIELD=>field
2115 new_cellml_model_map%VARIABLE_TYPE=variable_type
2116 new_cellml_model_map%COMPONENT_NUMBER=component_number
2117 new_cellml_model_map%FIELD_PARAMETER_SET=field_parameter_set
2118 new_cellml_model_map%VARIABLE_ID=variable_id
2119 new_cellml_model_map%CELLML_FIELD_TYPE=cellml_field_type
2120 new_cellml_model_map%CELLML_VARIABLE_NUMBER=cellml_variable_number
2121 new_cellml_model_map%CELLML_PARAMETER_SET=cellml_parameter_set
2123 ALLOCATE(new_fields_mapped_from(cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_FROM+1),stat=err)
2124 IF(err/=0)
CALL flagerror(
"Could not allocate new fields mapped from.",err,error,*999)
2125 DO map_idx=1,cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_FROM
2126 new_fields_mapped_from(map_idx)%PTR=>cellml_model_maps%FIELDS_MAPPED_FROM(map_idx)%PTR
2128 new_fields_mapped_from(cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_FROM+1)%PTR=>new_cellml_model_map
2129 CALL move_alloc(new_fields_mapped_from,cellml_model_maps%FIELDS_MAPPED_FROM)
2130 cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_FROM=cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_FROM+1
2156 CALL flagerror(
"CellML field maps model maps is not associated.",err,error,*999)
2159 CALL flagerror(
"CellML model is not associated.",err,error,*999)
2163 &
" is invalid. The modex index should be >= 1 and <= "// &
2165 CALL flagerror(local_error,err,error,*999)
2173 CALL flagerror(local_error,err,error,*999)
2177 CALL flagerror(
"CellML environment field maps is not associated.",err,error,*999)
2180 CALL flagerror(
"CellML environment has not been finished.",err,error,*999)
2183 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
2188 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2192 exits(
"CELLML_CREATE_CELLML_TO_FIELD_MAP_C")
2194 999 errorsexits(
"CELLML_CREATE_CELLML_TO_FIELD_MAP_C",err,error)
2204 & field,variable_type,component_number,field_parameter_set,err,error,*)
2208 INTEGER(INTG),
INTENT(IN) :: MODEL_USER_NUMBER
2210 INTEGER(INTG),
INTENT(IN) :: CELLML_PARAMETER_SET
2211 TYPE(
field_type),
POINTER,
INTENT(IN) :: FIELD
2212 INTEGER(INTG),
INTENT(IN) :: VARIABLE_TYPE
2213 INTEGER(INTG),
INTENT(IN) :: COMPONENT_NUMBER
2214 INTEGER(INTG),
INTENT(IN) :: FIELD_PARAMETER_SET
2215 INTEGER(INTG),
INTENT(OUT) :: ERR
2219 enters(
"CELLML_CREATE_CELLML_TO_FIELD_MAP_VS",err,error,*999)
2224 & field,variable_type,component_number,field_parameter_set,err,error,*999)
2228 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2232 exits(
"CELLML_CREATE_CELLML_TO_FIELD_MAP_VS")
2234 999 errorsexits(
"CELLML_CREATE_CELLML_TO_FIELD_MAP_VS",err,error)
2244 & model_index,variable_id,cellml_parameter_set,err,error,*)
2248 TYPE(
field_type),
POINTER,
INTENT(IN) :: FIELD
2249 INTEGER(INTG),
INTENT(IN) :: VARIABLE_TYPE
2250 INTEGER(INTG),
INTENT(IN) :: COMPONENT_NUMBER
2251 INTEGER(INTG),
INTENT(IN) :: FIELD_PARAMETER_SET
2252 INTEGER(INTG),
INTENT(IN) :: MODEL_INDEX
2253 CHARACTER(LEN=*),
INTENT(IN) :: VARIABLE_ID
2254 INTEGER(INTG),
INTENT(IN) :: CELLML_PARAMETER_SET
2255 INTEGER(INTG),
INTENT(OUT) :: ERR
2258 INTEGER(INTG) :: CELLML_FIELD_TYPE,CELLML_VARIABLE_NUMBER,map_idx
2267 CHARACTER(LEN=1,KIND=C_CHAR) :: C_NAME(maxstrlen)
2269 INTEGER(C_INT) :: ERROR_C
2270 INTEGER(INTG) :: CELLML_VARIABLE_TYPE
2272 enters(
"CELLML_CREATE_FIELD_TO_CELLML_MAP_C",err,error,*999)
2276 IF(
ASSOCIATED(cellml))
THEN 2278 IF(cellml%CELLML_FINISHED)
THEN 2279 cellml_field_maps=>cellml%FIELD_MAPS
2280 IF(
ASSOCIATED(cellml_field_maps))
THEN 2281 IF(cellml_field_maps%CELLML_FIELD_MAPS_FINISHED)
THEN 2282 CALL flagerror(
"CellML field maps have already been finished.",err,error,*999)
2284 NULLIFY(field_variable)
2285 CALL field_variable_get(field,variable_type,field_variable,err,error,*999)
2286 NULLIFY(parameter_set)
2287 CALL field_parameter_set_get(field,variable_type,field_parameter_set,parameter_set,err,error,*999)
2288 IF(component_number>0.AND.component_number<=field_variable%NUMBER_OF_COMPONENTS)
THEN 2289 IF(model_index>0.AND.model_index<=cellml%NUMBER_OF_MODELS)
THEN 2290 cellml_model=>cellml%MODELS(model_index)%PTR
2291 IF(
ASSOCIATED(cellml_model))
THEN 2292 cellml_model_maps=>cellml_field_maps%MODEL_MAPS(model_index)%PTR
2293 IF(
ASSOCIATED(cellml_model_maps))
THEN 2296 error_c = cellml_model_definition_get_variable_type(cellml_model%PTR,c_name,cellml_variable_type)
2297 IF(error_c /= 0)
THEN 2298 local_error=
"Failed to get the type of CellML variable: "// &
2300 &
"; with the error code: "// &
2302 CALL flagerror(local_error,err,error,*999)
2311 IF(
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD))
THEN 2312 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD,field%GEOMETRIC_FIELD))
THEN 2313 local_error=
"The geometric field for field user number "// &
2315 &
" does not match the geometric field for other field variable components mapped in the" // &
2316 &
" CellML environment." 2317 CALL flagerror(local_error,err,error,*999)
2319 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_FIELD_DOMAIN, &
2320 & field_variable%COMPONENTS(component_number)%DOMAIN))
THEN 2321 local_error=
"The domain for component number "//
trim(
number_to_vstring(component_number,
"*",err,error))// &
2324 &
" does not match the domain for other field variable components mapped in the CellML environment." 2325 CALL flagerror(local_error,err,error,*999)
2327 IF(cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE/= &
2328 & field_variable%COMPONENTS(component_number)%INTERPOLATION_TYPE)
THEN 2329 local_error=
"The interpolation type of "// &
2331 &
"*",err,error))//
" for component number "//
trim(
number_to_vstring(component_number,
"*",err,error))// &
2334 &
" does not match the interpolation type of "// &
2336 &
" used in other field variable components mapped in the CellML environment." 2337 CALL flagerror(local_error,err,error,*999)
2340 cellml_field_maps%SOURCE_FIELD_DOMAIN=>field_variable%COMPONENTS(component_number)%DOMAIN
2341 cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE=field_variable%COMPONENTS(component_number)% &
2342 & interpolation_type
2345 NULLIFY(new_cellml_model_map)
2348 new_cellml_model_map%FIELD=>field
2349 new_cellml_model_map%VARIABLE_TYPE=variable_type
2350 new_cellml_model_map%COMPONENT_NUMBER=component_number
2351 new_cellml_model_map%FIELD_PARAMETER_SET=field_parameter_set
2352 new_cellml_model_map%VARIABLE_ID=variable_id
2353 new_cellml_model_map%CELLML_FIELD_TYPE=cellml_field_type
2354 new_cellml_model_map%CELLML_VARIABLE_NUMBER=cellml_variable_number
2355 new_cellml_model_map%CELLML_PARAMETER_SET=cellml_parameter_set
2357 ALLOCATE(new_fields_mapped_to(cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_TO+1),stat=err)
2358 IF(err/=0)
CALL flagerror(
"Could not allocate new fields mapped to.",err,error,*999)
2359 DO map_idx=1,cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_TO
2360 new_fields_mapped_to(map_idx)%PTR=>cellml_model_maps%FIELDS_MAPPED_TO(map_idx)%PTR
2362 new_fields_mapped_to(cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_TO+1)%PTR=>new_cellml_model_map
2363 CALL move_alloc(new_fields_mapped_to,cellml_model_maps%FIELDS_MAPPED_TO)
2364 cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_TO=cellml_model_maps%NUMBER_OF_FIELDS_MAPPED_TO+1
2389 CALL flagerror(
"CellML field maps model maps is not associated.",err,error,*999)
2392 CALL flagerror(
"CellML model is not associated.",err,error,*999)
2396 &
" is invalid. The modex index should be >= 1 and <= "// &
2398 CALL flagerror(local_error,err,error,*999)
2407 CALL flagerror(local_error,err,error,*999)
2411 CALL flagerror(
"CellML environment field maps is not associated.",err,error,*999)
2414 CALL flagerror(
"CellML environment has not been finished.",err,error,*999)
2417 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
2422 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2426 exits(
"CELLML_CREATE_FIELD_TO_CELLML_MAP_C")
2428 999 errorsexits(
"CELLML_CREATE_FIELD_TO_CELLML_MAP_C",err,error)
2438 & model_user_number,variable_id,cellml_parameter_set,err,error,*)
2442 TYPE(
field_type),
POINTER,
INTENT(IN) :: FIELD
2443 INTEGER(INTG),
INTENT(IN) :: VARIABLE_TYPE
2444 INTEGER(INTG),
INTENT(IN) :: COMPONENT_NUMBER
2445 INTEGER(INTG),
INTENT(IN) :: FIELD_PARAMETER_SET
2446 INTEGER(INTG),
INTENT(IN) :: MODEL_USER_NUMBER
2448 INTEGER(INTG),
INTENT(IN) :: CELLML_PARAMETER_SET
2449 INTEGER(INTG),
INTENT(OUT) :: ERR
2453 enters(
"CELLML_CREATE_FIELD_TO_CELLML_MAP_VS",err,error,*999)
2458 & model_user_number,
char(variable_id),cellml_parameter_set,err,error,*999)
2462 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2466 exits(
"CELLML_CREATE_FIELD_TO_CELLML_MAP_VS")
2468 999 errorsexits(
"CELLML_CREATE_FIELD_TO_CELLML_MAP_VS",err,error)
2477 SUBROUTINE cellml_fieldmodeldofset(modelVariable,modelDofIdx,field,variableType,parameterSetIdx,componentIdx, &
2482 INTEGER(INTG),
INTENT(IN) :: modelDofIdx
2484 INTEGER(INTG),
INTENT(IN) :: variableType
2485 INTEGER(INTG),
INTENT(IN) :: parameterSetIdx
2486 INTEGER(INTG),
INTENT(IN) :: componentIdx
2487 REAL(DP),
INTENT(IN) ::
value 2488 INTEGER(INTG),
INTENT(OUT) :: err
2491 INTEGER(INTG) :: derivativeNumber,dofParamIdx,dofType,elementNumber,gaussNumber,gridNumber,nodeNumber,versionNumber
2494 enters(
"CellML_FieldModelDofSet",err,error,*999)
2498 IF(
ASSOCIATED(modelvariable))
THEN 2499 IF(modeldofidx>0.AND.modeldofidx<=modelvariable%NUMBER_OF_DOFS)
THEN 2500 doftype=modelvariable%DOF_TO_PARAM_MAP%DOF_TYPE(1,modeldofidx)
2501 dofparamidx=modelvariable%DOF_TO_PARAM_MAP%DOF_TYPE(2,modeldofidx)
2502 SELECT CASE(doftype)
2503 CASE(field_constant_dof_type)
2504 CALL field_parameter_set_update_constant(field,variabletype,parametersetidx,componentidx,
VALUE,err,error,*999)
2505 CASE(field_element_dof_type)
2506 elementnumber=modelvariable%DOF_TO_PARAM_MAP%ELEMENT_DOF2PARAM_MAP(1,dofparamidx)
2507 CALL field_parameter_set_update_element(field,variabletype,parametersetidx,elementnumber,componentidx,
value, &
2509 CASE(field_node_dof_type)
2510 versionnumber=modelvariable%DOF_TO_PARAM_MAP%NODE_DOF2PARAM_MAP(1,dofparamidx)
2511 derivativenumber=modelvariable%DOF_TO_PARAM_MAP%NODE_DOF2PARAM_MAP(2,dofparamidx)
2512 nodenumber=modelvariable%DOF_TO_PARAM_MAP%NODE_DOF2PARAM_MAP(3,dofparamidx)
2513 CALL field_parameter_set_update_local_node(field,variabletype,parametersetidx,versionnumber,derivativenumber,nodenumber, &
2514 & componentidx,
VALUE,err,error,*999)
2515 CASE(field_grid_point_dof_type)
2516 gridnumber=modelvariable%DOF_TO_PARAM_MAP%GRID_POINT_DOF2PARAM_MAP(1,dofparamidx)
2517 CALL flagerror(
"Not implemented.",err,error,*999)
2518 CASE(field_gauss_point_dof_type)
2519 gaussnumber=modelvariable%DOF_TO_PARAM_MAP%GAUSS_POINT_DOF2PARAM_MAP(1,dofparamidx)
2520 elementnumber=modelvariable%DOF_TO_PARAM_MAP%GAUSS_POINT_DOF2PARAM_MAP(2,dofparamidx)
2521 CALL field_parametersetupdategausspoint(field,variabletype,parametersetidx,gaussnumber,elementnumber,componentidx, &
2522 &
VALUE,err,error,*999)
2526 CALL flagerror(localerror,err,error,*999)
2530 &
" is invalid. The DOF index needs to be > 0 and <= "// &
2532 CALL flagerror(localerror,err,error,*999)
2535 CALL flagerror(
"Model variable is not asssociated.",err,error,*999)
2540 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2544 exits(
"CellML_FieldModelDofSet")
2546 999 errorsexits(
"CellML_FieldModelDofSet",err,error)
2559 INTEGER(INTG),
INTENT(OUT) :: ERR
2562 INTEGER(INTG) :: model_idx,source_dof_idx,first_dof_idx
2563 INTEGER(INTG),
POINTER :: MODELS_DATA(:)
2568 enters(
"CELLML_MODELS_FIELD_CHECK",err,error,*999)
2572 IF(
ASSOCIATED(models_field))
THEN 2573 IF(models_field%MODELS_FIELD_FINISHED)
THEN 2575 cellml=>models_field%CELLML
2576 IF(
ASSOCIATED(cellml))
THEN 2578 NULLIFY(models_variable)
2579 CALL field_variable_get(models_field%MODELS_FIELD,field_u_variable_type,models_variable,err,error,*999)
2580 IF(models_variable%NUMBER_OF_DOFS>0)
THEN 2581 NULLIFY(models_data)
2582 CALL field_parameter_set_data_get(models_field%MODELS_FIELD,field_u_variable_type,field_values_set_type, &
2583 & models_data,err,error,*999)
2587 DO source_dof_idx=1,models_variable%TOTAL_NUMBER_OF_DOFS
2588 model_idx=models_data(source_dof_idx)
2589 IF(model_idx>=0)
THEN 2590 models_field%ONLY_ONE_MODEL_INDEX=model_idx
2591 first_dof_idx=source_dof_idx
2592 IF(model_idx>0)
THEN 2597 &
" is invalid for source DOF 1. The model index must be >= 0 and <= "// &
2599 CALL flagerror(
"The models field has not been set for DOF 1.",err,error,*999)
2602 IF(model_idx>=0.AND.model_idx<=cellml%NUMBER_OF_MODELS)
THEN 2603 DO source_dof_idx=(first_dof_idx+1),models_variable%TOTAL_NUMBER_OF_DOFS
2604 model_idx=models_data(source_dof_idx)
2605 IF(model_idx>=0.AND.model_idx<=cellml%NUMBER_OF_MODELS)
THEN 2606 IF(model_idx/=models_field%ONLY_ONE_MODEL_INDEX.AND.model_idx/=0)
THEN 2613 &
". The model index must be >= 0 and <= "// &
2615 CALL flagerror(local_error,err,error,*999)
2618 IF(models_field%ONLY_ONE_MODEL_INDEX==0) &
2619 &
CALL flagerror(
"Models field does not have any models set.",err,error,*999)
2622 &
" is invalid for source DOF 1. The model index must be >= 0 and <= "// &
2624 CALL flagerror(
"The models field has not been set for DOF 1.",err,error,*999)
2628 CALL field_parameter_set_data_restore(models_field%MODELS_FIELD,field_u_variable_type,field_values_set_type, &
2629 & models_data,err,error,*999)
2631 CALL flagerror(
"CellML models field variable does not have any DOFs.",err,error,*999)
2634 CALL flagerror(
"The models field CellML environment is not associated.",err,error,*999)
2638 CALL flagerror(
"Models field has not been finished.",err,error,*999)
2641 CALL flagerror(
"Models field is not associated.",err,error,*999)
2646 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2650 exits(
"CELLML_MODELS_FIELD_CHECK")
2652 999 errorsexits(
"CELLML_MODELS_FIELD_CHECK",err,error)
2663 INTEGER(INTG),
INTENT(IN) :: MODEL_FIELD_USER_NUMBER
2666 INTEGER(INTG),
INTENT(OUT) :: ERR
2671 TYPE(
region_type),
POINTER :: REGION,MODELS_FIELD_REGION
2674 enters(
"CELLML_MODELS_FIELD_CREATE_START",err,error,*999)
2678 IF(
ASSOCIATED(cellml))
THEN 2679 cellml_field_maps=>cellml%FIELD_MAPS
2680 IF(
ASSOCIATED(cellml_field_maps))
THEN 2681 IF(cellml_field_maps%CELLML_FIELD_MAPS_FINISHED)
THEN 2682 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 2683 CALL flagerror(
"The CellML environment models field is already associated.",err,error,*999)
2685 region=>cellml%REGION
2686 IF(
ASSOCIATED(region))
THEN 2687 IF(
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD))
THEN 2688 IF(
ASSOCIATED(cellml_field_maps%SOURCE_FIELD_DOMAIN))
THEN 2689 IF(
ASSOCIATED(models_field))
THEN 2691 IF(models_field%FIELD_FINISHED)
THEN 2693 IF(model_field_user_number/=models_field%USER_NUMBER)
THEN 2694 local_error=
"The specified models field user number of "// &
2696 &
" does not match the user number of the specified models field of "// &
2698 CALL flagerror(local_error,err,error,*999)
2700 models_field_region=>models_field%REGION
2701 IF(
ASSOCIATED(models_field_region))
THEN 2703 IF(models_field_region%USER_NUMBER/=region%USER_NUMBER)
THEN 2704 local_error=
"Invalid region setup. The specified models field has been created on region number "// &
2706 &
" and the specified CellML environment has been created on region number "// &
2708 CALL flagerror(local_error,err,error,*999)
2711 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD,models_field%GEOMETRIC_FIELD))
THEN 2712 CALL flagerror(
"The specified models field does not have the same geometric field as the "// &
2713 &
"geometric field for the specified CellML environment.",err,error,*999)
2716 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_FIELD_DOMAIN%DECOMPOSITION,models_field%DECOMPOSITION))
THEN 2717 CALL flagerror(
"The specified models field does not have the same decomposition as the source "// &
2718 &
"domain decomposition for the specified CellML environment.",err,error,*999)
2721 CALL flagerror(
"The specified models field region is not associated.",err,error,*999)
2724 CALL flagerror(
"The specified models field has not been finished.",err,error,*999)
2729 CALL field_user_number_find(model_field_user_number,region,field,err,error,*999)
2730 IF(
ASSOCIATED(field))
THEN 2731 local_error=
"The specified models field user number of "// &
2733 &
"has already been used to create a field on region number "// &
2735 CALL flagerror(local_error,err,error,*999)
2739 IF(
ASSOCIATED(models_field))
THEN 2741 CALL field_data_type_check(models_field,field_u_variable_type,field_intg_type,err,error,*999)
2742 CALL field_type_check(models_field,field_general_type,err,error,*999)
2743 CALL field_number_of_variables_check(models_field,1,err,error,*999)
2744 CALL field_variable_types_check(models_field,[field_u_variable_type],err,error,*999)
2745 CALL field_number_of_components_check(models_field,field_u_variable_type,1,err,error,*999)
2746 CALL field_component_mesh_component_check(models_field,field_u_variable_type,1, &
2747 & cellml_field_maps%SOURCE_FIELD_DOMAIN%MESH_COMPONENT_NUMBER,err,error,*999)
2748 CALL field_component_interpolation_check(models_field,field_u_variable_type,1, &
2749 & cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE,err,error,*999)
2751 cellml%MODELS_FIELD%MODELS_FIELD_AUTO_CREATED=.true.
2753 CALL field_create_start(model_field_user_number,region,cellml%MODELS_FIELD%MODELS_FIELD,err,error,*999)
2754 CALL field_data_type_set_and_lock(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type,field_intg_type, &
2756 CALL field_label_set(cellml%MODELS_FIELD%MODELS_FIELD,
"CellMLModelsField",err,error,*999)
2757 CALL field_type_set_and_lock(cellml%MODELS_FIELD%MODELS_FIELD,field_general_type,err,error,*999)
2758 CALL field_mesh_decomposition_set_and_lock(cellml%MODELS_FIELD%MODELS_FIELD, &
2759 & cellml_field_maps%SOURCE_FIELD_DOMAIN%DECOMPOSITION,err,error,*999)
2760 CALL field_geometric_field_set_and_lock(cellml%MODELS_FIELD%MODELS_FIELD,cellml_field_maps% &
2761 & source_geometric_field,err,error,*999)
2762 CALL field_number_of_variables_set_and_lock(cellml%MODELS_FIELD%MODELS_FIELD,1,err,error,*999)
2763 CALL field_variable_types_set_and_lock(cellml%MODELS_FIELD%MODELS_FIELD,[field_u_variable_type],err,error,*999)
2764 CALL field_variable_label_set(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type,
"ModelMap",err,error,*999)
2765 CALL field_dof_order_type_set(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type, &
2766 & field_contiguous_component_dof_order,err,error,*999)
2767 CALL field_number_of_components_set_and_lock(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type,1, &
2769 CALL field_component_label_set(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type,1,
"ModelUserNumber", &
2771 CALL field_component_mesh_component_set_and_lock(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type,1, &
2772 & cellml_field_maps%SOURCE_FIELD_DOMAIN%MESH_COMPONENT_NUMBER,err,error,*999)
2773 CALL field_component_interpolation_set_and_lock(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type,1, &
2774 & cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE,err,error,*999)
2777 IF(cellml%MODELS_FIELD%MODELS_FIELD_AUTO_CREATED)
THEN 2778 models_field=>cellml%MODELS_FIELD%MODELS_FIELD
2780 cellml%MODELS_FIELD%MODELS_FIELD=>models_field
2783 CALL flagerror(
"CellML fields map source field domain is not associated.",err,error,*999)
2786 CALL flagerror(
"CellML fields map source geometric field is not associated.",err,error,*999)
2789 CALL flagerror(
"CellML environment region is not associated.",err,error,*999)
2793 CALL flagerror(
"The CellML environment fields map has not been finished.",err,error,*999)
2796 CALL flagerror(
"CellML environment fields map is not associated. You must create the CellML field maps first.", &
2800 CALL flagerror(
"CellML environment is not associated",err,error,*999)
2805 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2809 exits(
"CELLML_MODELS_FIELD_CREATE_START")
2811 999 errorsexits(
"CELLML_MODELS_FIELD_CREATE_START",err,error)
2823 INTEGER(INTG),
INTENT(OUT) :: ERR
2827 enters(
"CELLML_MODELS_FIELD_CREATE_FINISH",err,error,*999)
2831 IF(
ASSOCIATED(cellml))
THEN 2832 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 2833 IF(cellml%MODELS_FIELD%MODELS_FIELD_FINISHED)
THEN 2834 CALL flagerror(
"CellML models field has already been finished.",err,error,*999)
2837 IF(cellml%MODELS_FIELD%MODELS_FIELD_AUTO_CREATED) &
2838 &
CALL field_create_finish(cellml%MODELS_FIELD%MODELS_FIELD,err,error,*999)
2839 cellml%MODELS_FIELD%MODELS_FIELD_FINISHED=.true.
2843 CALL field_component_values_initialise(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type, &
2844 & field_values_set_type,1,1,err,error,*999)
2847 CALL flagerror(
"CellML environment models field is not associated.",err,error,*999)
2850 CALL flagerror(
"CellML environement is not associated.",err,error,*999)
2855 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2859 exits(
"CELLML_MODELS_FIELD_CREATE_FINISH")
2861 999 errorsexits(
"CELLML_MODELS_FIELD_CREATE_FINISH",err,error)
2873 INTEGER(INTG),
INTENT(OUT) :: ERR
2877 enters(
"CELLML_MODELS_FIELD_FINALISE",err,error,*999)
2881 IF(
ASSOCIATED(models_field))
THEN 2882 DEALLOCATE(models_field)
2887 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2891 exits(
"CELLML_MODELS_FIELD_FINALISE")
2893 999 errorsexits(
"CELLML_MODELS_FIELD_FINALISE",err,error)
2907 INTEGER(INTG),
INTENT(OUT) :: ERR
2911 enters(
"CELLML_MODELS_FIELD_GET",err,error,*999)
2915 IF(
ASSOCIATED(cellml))
THEN 2916 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 2917 IF(cellml%MODELS_FIELD%MODELS_FIELD_FINISHED)
THEN 2918 IF(
ASSOCIATED(models_field))
THEN 2919 CALL flagerror(
"Models field is already associated.",err,error,*999)
2921 models_field=>cellml%MODELS_FIELD%MODELS_FIELD
2924 CALL flagerror(
"CellML environment models field has not been finished.",err,error,*999)
2927 CALL flagerror(
"CellML environment models field is not associated. Create the models field first.",err,error,*999)
2930 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
2935 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2939 exits(
"CELLML_MODELS_FIELD_GET")
2941 999 errorsexits(
"CELLML_MODELS_FIELD_GET",err,error)
2953 INTEGER(INTG),
INTENT(OUT) :: ERR
2956 INTEGER(INTG) :: DUMMY_ERR
2959 enters(
"CELLML_MODELS_FIELD_INITIALISE",err,error,*998)
2963 IF(
ASSOCIATED(cellml))
THEN 2964 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 2965 CALL flagerror(
"CellML environment models field is already associated.",err,error,*998)
2967 ALLOCATE(cellml%MODELS_FIELD,stat=err)
2968 IF(err/=0)
CALL flagerror(
"Could not allocate CellML environment models field.",err,error,*999)
2969 cellml%MODELS_FIELD%CELLML=>cellml
2970 cellml%MODELS_FIELD%MODELS_FIELD_FINISHED=.false.
2971 cellml%MODELS_FIELD%MODELS_FIELD_AUTO_CREATED=.false.
2972 NULLIFY(cellml%MODELS_FIELD%MODELS_FIELD)
2976 CALL flagerror(
"CellML environment is not associated.",err,error,*998)
2981 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*998)
2985 exits(
"CELLML_MODELS_FIELD_INITIALISE")
2988 998 errorsexits(
"CELLML_MODELS_FIELD_INITIALISE",err,error)
2999 INTEGER(INTG),
INTENT(IN) :: STATE_FIELD_USER_NUMBER
3002 INTEGER(INTG),
INTENT(OUT) :: ERR
3005 INTEGER(INTG) :: component_idx
3008 TYPE(
region_type),
POINTER :: REGION,STATE_FIELD_REGION
3011 enters(
"CELLML_STATE_FIELD_CREATE_START",err,error,*999)
3015 IF(
ASSOCIATED(cellml))
THEN 3016 cellml_field_maps=>cellml%FIELD_MAPS
3017 IF(
ASSOCIATED(cellml_field_maps))
THEN 3018 IF(cellml_field_maps%CELLML_FIELD_MAPS_FINISHED)
THEN 3019 IF(
ASSOCIATED(cellml%STATE_FIELD))
THEN 3020 CALL flagerror(
"The CellML environment models field is already associated.",err,error,*999)
3022 region=>cellml%REGION
3023 IF(
ASSOCIATED(region))
THEN 3024 IF(
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD))
THEN 3025 IF(
ASSOCIATED(cellml_field_maps%SOURCE_FIELD_DOMAIN))
THEN 3026 IF(
ASSOCIATED(state_field))
THEN 3028 IF(state_field%FIELD_FINISHED)
THEN 3030 IF(state_field_user_number/=state_field%USER_NUMBER)
THEN 3031 local_error=
"The specified state field user number of "// &
3033 &
" does not match the user number of the specified state field of "// &
3035 CALL flagerror(local_error,err,error,*999)
3037 state_field_region=>state_field%REGION
3038 IF(
ASSOCIATED(state_field_region))
THEN 3040 IF(state_field_region%USER_NUMBER/=region%USER_NUMBER)
THEN 3041 local_error=
"Invalid region setup. The specified state field has been created on region number "// &
3043 &
" and the CellML environment has been created on region number "// &
3045 CALL flagerror(local_error,err,error,*999)
3048 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD,state_field%GEOMETRIC_FIELD))
THEN 3049 CALL flagerror(
"The specified state field does not have the same geometric field as the "// &
3050 &
"geometric field for the specified CellML environment.",err,error,*999)
3053 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_FIELD_DOMAIN%DECOMPOSITION,state_field%DECOMPOSITION))
THEN 3054 CALL flagerror(
"The specified state field does not have the same decomposition as the source "// &
3055 &
"domain decomposition for the specified CellML environment.",err,error,*999)
3058 CALL flagerror(
"The specified state field region is not associated.",err,error,*999)
3061 CALL flagerror(
"The specified state field has not been finished.",err,error,*999)
3066 CALL field_user_number_find(state_field_user_number,region,field,err,error,*999)
3067 IF(
ASSOCIATED(field))
THEN 3068 local_error=
"The specified state field user number of "// &
3070 &
"has already been used to create a field on region number "// &
3072 CALL flagerror(local_error,err,error,*999)
3076 IF(
ASSOCIATED(state_field))
THEN 3078 CALL field_data_type_check(state_field,field_u_variable_type,field_dp_type,err,error,*999)
3079 CALL field_type_check(state_field,field_general_type,err,error,*999)
3080 CALL field_number_of_variables_check(state_field,1,err,error,*999)
3081 CALL field_variable_types_check(state_field,[field_u_variable_type],err,error,*999)
3082 CALL field_number_of_components_check(state_field,field_u_variable_type,cellml%MAXIMUM_NUMBER_OF_STATE, &
3084 DO component_idx=1,cellml%MAXIMUM_NUMBER_OF_STATE
3085 CALL field_component_mesh_component_check(state_field,field_u_variable_type, &
3086 & component_idx,cellml_field_maps%SOURCE_FIELD_DOMAIN%MESH_COMPONENT_NUMBER,err,error,*999)
3087 CALL field_component_interpolation_check(state_field,field_u_variable_type, &
3088 & component_idx,cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE,err,error,*999)
3091 cellml%STATE_FIELD%STATE_FIELD_AUTO_CREATED=.true.
3093 CALL field_create_start(state_field_user_number,region,cellml%STATE_FIELD%STATE_FIELD,err,error,*999)
3094 CALL field_data_type_set_and_lock(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type,field_dp_type, &
3096 CALL field_label_set(cellml%STATE_FIELD%STATE_FIELD,
"CellMLStateField",err,error,*999)
3097 CALL field_type_set_and_lock(cellml%STATE_FIELD%STATE_FIELD,field_general_type,err,error,*999)
3098 CALL field_mesh_decomposition_set_and_lock(cellml%STATE_FIELD%STATE_FIELD, &
3099 & cellml_field_maps%SOURCE_FIELD_DOMAIN%DECOMPOSITION,err,error,*999)
3100 CALL field_geometric_field_set_and_lock(cellml%STATE_FIELD%STATE_FIELD,cellml_field_maps% &
3101 & source_geometric_field,err,error,*999)
3102 CALL field_number_of_variables_set_and_lock(cellml%STATE_FIELD%STATE_FIELD,1,err,error,*999)
3103 CALL field_variable_types_set_and_lock(cellml%STATE_FIELD%STATE_FIELD,[field_u_variable_type],err,error,*999)
3104 CALL field_variable_label_set(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type,
"StateVariable", &
3106 CALL field_dof_order_type_set(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
3107 & field_contiguous_component_dof_order,err,error,*999)
3108 CALL field_number_of_components_set_and_lock(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type,&
3109 & cellml%MAXIMUM_NUMBER_OF_STATE,err,error,*999)
3110 DO component_idx=1,cellml%MAXIMUM_NUMBER_OF_STATE
3111 CALL field_component_mesh_component_set_and_lock(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
3112 & component_idx,cellml_field_maps%SOURCE_FIELD_DOMAIN%MESH_COMPONENT_NUMBER,err,error,*999)
3113 CALL field_component_interpolation_set_and_lock(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
3114 & component_idx,cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE,err,error,*999)
3118 IF(cellml%STATE_FIELD%STATE_FIELD_AUTO_CREATED)
THEN 3119 state_field=>cellml%STATE_FIELD%STATE_FIELD
3121 cellml%STATE_FIELD%STATE_FIELD=>state_field
3124 CALL flagerror(
"CellML field maps source field domain is not associated.",err,error,*999)
3127 CALL flagerror(
"CellML field mapssource geometric field is not associated.",err,error,*999)
3130 CALL flagerror(
"CellML environment region is not associated.",err,error,*999)
3134 CALL flagerror(
"The CellML environment fields map has not been finished.",err,error,*999)
3137 CALL flagerror(
"CellML environment fields map is not associated. You must create the CellML field maps first.", &
3141 CALL flagerror(
"CellML environment is not associated",err,error,*999)
3146 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
3150 exits(
"CELLML_STATE_FIELD_CREATE_START")
3152 999 errorsexits(
"CELLML_STATE_FIELD_CREATE_START",err,error)
3166 INTEGER(INTG),
INTENT(OUT) :: ERR
3169 INTEGER(INTG) :: model_idx,models_dof_idx,state_component_idx,CELLML_VARIABLE_TYPE
3170 INTEGER(INTG),
POINTER :: MODELS_DATA(:)
3171 REAL(DP) :: INITIAL_VALUE
3176 enters(
"CELLML_STATE_FIELD_CREATE_FINISH",err,error,*999)
3180 IF(
ASSOCIATED(cellml))
THEN 3181 IF(
ASSOCIATED(cellml%STATE_FIELD))
THEN 3182 IF(cellml%STATE_FIELD%STATE_FIELD_FINISHED)
THEN 3183 CALL flagerror(
"CellML state field has already been finished.",err,error,*999)
3185 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 3186 IF(cellml%MODELS_FIELD%MODELS_FIELD_FINISHED)
THEN 3189 IF(cellml%STATE_FIELD%STATE_FIELD_AUTO_CREATED) &
3190 &
CALL field_create_finish(cellml%STATE_FIELD%STATE_FIELD,err,error,*999)
3196 model=>cellml%MODELS(cellml%MODELS_FIELD%ONLY_ONE_MODEL_INDEX)%PTR
3197 IF(
ASSOCIATED(model))
THEN 3198 DO state_component_idx=1,model%NUMBER_OF_STATE
3200 err = cellml_model_definition_get_initial_value_by_index(model%PTR,cellml_variable_type,&
3201 & state_component_idx,initial_value)
3204 local_error=
"Failed to get an initial value for state variable with index "//&
3206 CALL flagerror(local_error,err,error,*999)
3210 CALL field_component_values_initialise(cellml%STATE_FIELD%STATE_FIELD,field_u_variable_type, &
3211 & field_values_set_type,state_component_idx,initial_value,err,error,*999)
3214 local_error=
"The model is not associated for model index "// &
3216 CALL flagerror(local_error,err,error,*999)
3220 IF(
ASSOCIATED(cellml%FIELD_MAPS))
THEN 3221 NULLIFY(models_variable)
3222 CALL field_variable_get(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type,models_variable,err,error,*999)
3223 NULLIFY(models_data)
3224 CALL field_parameter_set_data_get(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type, &
3225 & field_values_set_type,models_data,err,error,*999)
3226 DO models_dof_idx=1,models_variable%NUMBER_OF_DOFS
3227 model_idx=models_data(models_dof_idx)
3228 IF(model_idx>0)
THEN 3229 model=>cellml%MODELS(model_idx)%PTR
3230 IF(
ASSOCIATED(model))
THEN 3231 DO state_component_idx=1,model%NUMBER_OF_STATE
3234 err = cellml_model_definition_get_initial_value_by_index(model%PTR,cellml_variable_type,&
3235 & state_component_idx,initial_value)
3238 local_error=
"Failed to get an initial value for state variable with index "//&
3240 CALL flagerror(local_error,err,error,*999)
3245 & field_u_variable_type,field_values_set_type,state_component_idx,initial_value,err,error,*999)
3248 local_error=
"The model is not associated for model index "// &
3250 CALL flagerror(local_error,err,error,*999)
3254 CALL field_parameter_set_data_restore(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type, &
3255 & field_values_set_type,models_data,err,error,*999)
3257 CALL flagerror(
"CellML environment field maps is not associated.",err,error,*999)
3260 cellml%STATE_FIELD%STATE_FIELD_FINISHED=.true.
3262 CALL flagerror(
"CellML environment models field has not been finished.",err,error,*999)
3265 CALL flagerror(
"CellML environment models field is not associated.",err,error,*999)
3269 CALL flagerror(
"CellML environment state field is not associated.",err,error,*999)
3272 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
3277 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
3281 exits(
"CELLML_STATE_FIELD_CREATE_FINISH")
3283 999 errorsexits(
"CELLML_STATE_FIELD_CREATE_FINISH",err,error)
3295 INTEGER(INTG),
INTENT(OUT) :: ERR
3299 enters(
"CELLML_STATE_FIELD_FINALISE",err,error,*999)
3303 IF(
ASSOCIATED(state_field))
THEN 3304 DEALLOCATE(state_field)
3309 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
3313 exits(
"CELLML_STATE_FIELD_FINALISE")
3315 999 errorsexits(
"CELLML_STATE_FIELD_FINALISE",err,error)
3329 INTEGER(INTG),
INTENT(OUT) :: ERR
3333 enters(
"CELLML_STATE_FIELD_GET",err,error,*999)
3337 IF(
ASSOCIATED(cellml))
THEN 3338 IF(
ASSOCIATED(cellml%STATE_FIELD))
THEN 3339 IF(cellml%STATE_FIELD%STATE_FIELD_FINISHED)
THEN 3340 IF(
ASSOCIATED(state_field))
THEN 3341 CALL flagerror(
"State field is already associated.",err,error,*999)
3343 state_field=>cellml%STATE_FIELD%STATE_FIELD
3346 CALL flagerror(
"CellML environment state field has not been finished.",err,error,*999)
3349 CALL flagerror(
"CellML environment state field is not associated. Create the state field first.",err,error,*999)
3352 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
3357 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
3361 exits(
"CELLML_STATE_FIELD_GET")
3363 999 errorsexits(
"CELLML_STATE_FIELD_GET",err,error)
3375 INTEGER(INTG),
INTENT(OUT) :: ERR
3378 INTEGER(INTG) :: DUMMY_ERR
3381 enters(
"CELLML_STATE_FIELD_INITIALISE",err,error,*998)
3385 IF(
ASSOCIATED(cellml))
THEN 3386 IF(
ASSOCIATED(cellml%STATE_FIELD))
THEN 3387 CALL flagerror(
"CellML environment state field is already associated.",err,error,*998)
3389 ALLOCATE(cellml%STATE_FIELD,stat=err)
3390 IF(err/=0)
CALL flagerror(
"Could not allocate CellML environment state field.",err,error,*999)
3391 cellml%STATE_FIELD%CELLML=>cellml
3392 cellml%STATE_FIELD%STATE_FIELD_FINISHED=.false.
3393 cellml%STATE_FIELD%STATE_FIELD_AUTO_CREATED=.false.
3394 NULLIFY(cellml%STATE_FIELD%STATE_FIELD)
3397 CALL flagerror(
"CellML environment is not associated.",err,error,*998)
3402 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*998)
3406 exits(
"CELLML_STATE_FIELD_INITIALISE")
3409 998 errorsexits(
"CELLML_STATE_FIELD_INITIALISE",err,error)
3425 INTEGER(INTG),
INTENT(IN) :: MODEL_INDEX
3426 INTEGER(INTG),
INTENT(IN) :: CELLML_FIELD_TYPE
3427 CHARACTER(LEN=*),
INTENT(IN) :: VARIABLE_ID
3428 INTEGER(INTG),
INTENT(OUT) :: COMPONENT_USER_NUMBER
3429 INTEGER(INTG),
INTENT(OUT) :: ERR
3432 INTEGER(INTG) :: CELLML_VARIABLE_INDEX
3433 INTEGER(C_INT) :: ERROR_C
3436 CHARACTER(LEN=1,KIND=C_CHAR) :: C_NAME(maxstrlen)
3439 enters(
"CELLML_FIELD_COMPONENT_GET_C",err,error,*999)
3443 IF(
ASSOCIATED(cellml))
THEN 3444 cellml_model=>cellml%MODELS(model_index)%PTR
3445 IF(
ASSOCIATED(cellml_model))
THEN 3447 error_c = cellml_model_definition_get_variable_index(cellml_model%PTR,c_name,cellml_variable_index)
3448 IF(error_c /= 0)
THEN 3449 local_error=
"Failed to get the index for CellML variable: "// &
3451 CALL flagerror(local_error,err,error,*999)
3453 component_user_number=cellml_variable_index
3456 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
3461 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
3465 exits(
"CELLML_FIELD_COMPONENT_GET_C")
3467 999 errorsexits(
"CELLML_FIELD_COMPONENT_GET_C",err,error)
3481 INTEGER(INTG),
INTENT(IN) :: MODEL_INDEX
3482 INTEGER(INTG),
INTENT(IN) :: CELLML_FIELD_TYPE
3484 INTEGER(INTG),
INTENT(OUT) :: COMPONENT_USER_NUMBER
3485 INTEGER(INTG),
INTENT(OUT) :: ERR
3489 enters(
"CELLML_FIELD_COMPONENT_GET_VS",err,error,*999)
3497 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
3501 exits(
"CELLML_FIELD_COMPONENT_GET_VS")
3503 999 errorsexits(
"CELLML_FIELD_COMPONENT_GET_VS",err,error)
3514 INTEGER(INTG),
INTENT(IN) :: INTERMEDIATE_FIELD_USER_NUMBER
3516 TYPE(
field_type),
POINTER :: INTERMEDIATE_FIELD
3517 INTEGER(INTG),
INTENT(OUT) :: ERR
3520 INTEGER(INTG) :: component_idx
3523 TYPE(
region_type),
POINTER :: REGION,INTERMEDIATE_FIELD_REGION
3526 enters(
"CELLML_INTERMEDIATE_FIELD_CREATE_START",err,error,*999)
3530 IF(
ASSOCIATED(cellml))
THEN 3531 cellml_field_maps=>cellml%FIELD_MAPS
3532 IF(
ASSOCIATED(cellml_field_maps))
THEN 3533 IF(cellml_field_maps%CELLML_FIELD_MAPS_FINISHED)
THEN 3534 IF(
ASSOCIATED(cellml%INTERMEDIATE_FIELD))
THEN 3535 CALL flagerror(
"The CellML environment models field is already associated.",err,error,*999)
3537 region=>cellml%REGION
3538 IF(
ASSOCIATED(region))
THEN 3539 IF(
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD))
THEN 3540 IF(
ASSOCIATED(cellml_field_maps%SOURCE_FIELD_DOMAIN))
THEN 3541 IF(
ASSOCIATED(intermediate_field))
THEN 3543 IF(intermediate_field%FIELD_FINISHED)
THEN 3545 IF(intermediate_field_user_number/=intermediate_field%USER_NUMBER)
THEN 3546 local_error=
"The specified intermediate field user number of "// &
3548 &
" does not match the user number of the specified intermediate field of "// &
3550 CALL flagerror(local_error,err,error,*999)
3552 intermediate_field_region=>intermediate_field%REGION
3553 IF(
ASSOCIATED(intermediate_field_region))
THEN 3555 IF(intermediate_field_region%USER_NUMBER/=region%USER_NUMBER)
THEN 3556 local_error=
"Invalid region setup. The specified intermediate field has been created on region"// &
3558 &
" and the specified CellML environment has been created on region number "// &
3560 CALL flagerror(local_error,err,error,*999)
3563 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD,intermediate_field%GEOMETRIC_FIELD))
THEN 3564 CALL flagerror(
"The specified intermediate field does not have the same geometric field as the "// &
3565 &
"geometric field for the specified CellML environment.",err,error,*999)
3568 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_FIELD_DOMAIN%DECOMPOSITION, &
3569 & intermediate_field%DECOMPOSITION))
THEN 3570 CALL flagerror(
"The specified intermediate field does not have the same decomposition as the source "// &
3571 &
"domain decomposition for the specified CellML environment.",err,error,*999)
3574 CALL flagerror(
"The specified intermediate field region is not associated.",err,error,*999)
3577 CALL flagerror(
"The specified intermediate field has not been finished.",err,error,*999)
3582 CALL field_user_number_find(intermediate_field_user_number,region,field,err,error,*999)
3583 IF(
ASSOCIATED(field))
THEN 3584 local_error=
"The specified intermediate field user number of "// &
3586 &
"has already been used to create a field on region number "// &
3588 CALL flagerror(local_error,err,error,*999)
3592 IF(
ASSOCIATED(intermediate_field))
THEN 3594 CALL field_data_type_check(intermediate_field,field_u_variable_type,field_dp_type,err,error,*999)
3595 CALL field_type_check(intermediate_field,field_general_type,err,error,*999)
3596 CALL field_number_of_variables_check(intermediate_field,1,err,error,*999)
3597 CALL field_variable_types_check(intermediate_field,[field_u_variable_type],err,error,*999)
3598 CALL field_number_of_components_check(intermediate_field,field_u_variable_type, &
3599 & cellml%MAXIMUM_NUMBER_OF_INTERMEDIATE,err,error,*999)
3600 DO component_idx=1,cellml%MAXIMUM_NUMBER_OF_INTERMEDIATE
3601 CALL field_component_mesh_component_check(intermediate_field,field_u_variable_type,component_idx, &
3602 & cellml_field_maps%SOURCE_FIELD_DOMAIN%MESH_COMPONENT_NUMBER,err,error,*999)
3603 CALL field_component_interpolation_check(intermediate_field,field_u_variable_type,component_idx, &
3604 & cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE,err,error,*999)
3607 cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD_AUTO_CREATED=.true.
3609 CALL field_create_start(intermediate_field_user_number,region,cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
3611 CALL field_data_type_set_and_lock(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD,field_u_variable_type, &
3612 & field_dp_type,err,error,*999)
3613 CALL field_label_set(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD,
"CellMLIntermediateField",err,error,*999)
3614 CALL field_type_set_and_lock(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD,field_general_type,err,error,*999)
3615 CALL field_mesh_decomposition_set_and_lock(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
3616 & cellml_field_maps%SOURCE_FIELD_DOMAIN%DECOMPOSITION,err,error,*999)
3617 CALL field_geometric_field_set_and_lock(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD,cellml_field_maps% &
3618 & source_geometric_field,err,error,*999)
3619 CALL field_number_of_variables_set_and_lock(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD,1,err,error,*999)
3620 CALL field_variable_types_set_and_lock(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD,[field_u_variable_type], &
3622 CALL field_variable_label_set(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD,field_u_variable_type, &
3623 &
"IntermediateVariable",err,error,*999)
3624 CALL field_dof_order_type_set(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD,field_u_variable_type, &
3625 & field_contiguous_component_dof_order,err,error,*999)
3626 CALL field_number_of_components_set_and_lock(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
3627 & field_u_variable_type,cellml%MAXIMUM_NUMBER_OF_INTERMEDIATE,err,error,*999)
3628 DO component_idx=1,cellml%MAXIMUM_NUMBER_OF_INTERMEDIATE
3629 CALL field_component_mesh_component_set_and_lock(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
3630 & field_u_variable_type,component_idx,cellml_field_maps%SOURCE_FIELD_DOMAIN%MESH_COMPONENT_NUMBER, &
3632 CALL field_component_interpolation_set_and_lock(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD, &
3633 & field_u_variable_type,component_idx,cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE,err,error,*999)
3637 IF(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD_AUTO_CREATED)
THEN 3638 intermediate_field=>cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD
3640 cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD=>intermediate_field
3643 CALL flagerror(
"CellML field maps source field domain is not associated.",err,error,*999)
3646 CALL flagerror(
"CellML field maps source geometric field is not associated.",err,error,*999)
3649 CALL flagerror(
"CellML environment region is not associated.",err,error,*999)
3653 CALL flagerror(
"The CellML environment fields map has not been finished.",err,error,*999)
3656 CALL flagerror(
"CellML environment fields map is not associated. You must create the CellML field maps first.", &
3660 CALL flagerror(
"CellML environment is not associated",err,error,*999)
3665 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
3669 exits(
"CELLML_INTERMEDIATE_FIELD_CREATE_START")
3671 999 errorsexits(
"CELLML_INTERMEDIATE_FIELD_CREATE_START",err,error)
3686 INTEGER(INTG),
INTENT(OUT) :: ERR
3690 enters(
"CELLML_INTERMEDIATE_FIELD_CREATE_FINISH",err,error,*999)
3694 IF(
ASSOCIATED(cellml))
THEN 3695 IF(
ASSOCIATED(cellml%INTERMEDIATE_FIELD))
THEN 3696 IF(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD_FINISHED)
THEN 3697 CALL flagerror(
"CellML intermediate field has already been finished.",err,error,*999)
3699 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 3700 IF(cellml%MODELS_FIELD%MODELS_FIELD_FINISHED)
THEN 3705 IF(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD_AUTO_CREATED) &
3706 &
CALL field_create_finish(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD,err,error,*999)
3708 cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD_FINISHED=.true.
3710 CALL flagerror(
"CellML environment models field has not been finished.",err,error,*999)
3713 CALL flagerror(
"CellML environment models field is not associated.",err,error,*999)
3717 CALL flagerror(
"CellML environment intermediate field is not associated.",err,error,*999)
3720 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
3725 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
3729 exits(
"CELLML_INTERMEDIATE_FIELD_CREATE_FINISH")
3731 999 errorsexits(
"CELLML_INTERMEDIATE_FIELD_CREATE_FINISH",err,error)
3743 INTEGER(INTG),
INTENT(OUT) :: ERR
3747 enters(
"CELLML_INTERMEDIATE_FIELD_FINALISE",err,error,*999)
3751 IF(
ASSOCIATED(intermediate_field))
THEN 3752 DEALLOCATE(intermediate_field)
3757 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
3761 exits(
"CELLML_INTERMEDIATE_FIELD_FINALISE")
3763 999 errorsexits(
"CELLML_INTERMEDIATE_FIELD_FINALISE",err,error)
3775 TYPE(
field_type),
POINTER :: INTERMEDIATE_FIELD
3776 INTEGER(INTG),
INTENT(OUT) :: ERR
3780 enters(
"CELLML_INTERMEDIATE_FIELD_GET",err,error,*999)
3784 IF(
ASSOCIATED(cellml))
THEN 3785 IF(
ASSOCIATED(cellml%INTERMEDIATE_FIELD))
THEN 3786 IF(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD_FINISHED)
THEN 3787 IF(
ASSOCIATED(intermediate_field))
THEN 3788 CALL flagerror(
"Intermediate field is already associated.",err,error,*999)
3790 intermediate_field=>cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD
3793 CALL flagerror(
"CellML environment intermediate field has not been finished.",err,error,*999)
3796 CALL flagerror(
"CellML environment intermediate field is not associated. Create the intermediate field first.", &
3800 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
3805 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
3809 exits(
"CELLML_INTERMEDIATE_FIELD_GET")
3811 999 errorsexits(
"CELLML_INTERMEDIATE_FIELD_GET",err,error)
3823 INTEGER(INTG),
INTENT(OUT) :: ERR
3826 INTEGER(INTG) :: DUMMY_ERR
3829 enters(
"CELLML_INTERMEDIATE_FIELD_INITIALISE",err,error,*998)
3833 IF(
ASSOCIATED(cellml))
THEN 3834 IF(
ASSOCIATED(cellml%INTERMEDIATE_FIELD))
THEN 3835 CALL flagerror(
"CellML environment intermediate field is already associated.",err,error,*998)
3837 ALLOCATE(cellml%INTERMEDIATE_FIELD,stat=err)
3838 IF(err/=0)
CALL flagerror(
"Could not allocate CellML environment intermediate field.",err,error,*999)
3839 cellml%INTERMEDIATE_FIELD%CELLML=>cellml
3840 cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD_FINISHED=.false.
3841 cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD_AUTO_CREATED=.false.
3842 NULLIFY(cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD)
3845 CALL flagerror(
"CellML environment is not associated.",err,error,*998)
3850 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*998)
3854 exits(
"CELLML_INTERMEDIATE_FIELD_INITIALISE")
3857 998 errorsexits(
"CELLML_INTERMEDIATE_FIELD_INITIALISE",err,error)
3868 INTEGER(INTG),
INTENT(IN) :: PARAMETERS_FIELD_USER_NUMBER
3870 TYPE(
field_type),
POINTER :: PARAMETERS_FIELD
3871 INTEGER(INTG),
INTENT(OUT) :: ERR
3874 INTEGER(INTG) :: component_idx
3877 TYPE(
region_type),
POINTER :: REGION,PARAMETERS_FIELD_REGION
3880 enters(
"CELLML_PARAMETERS_FIELD_CREATE_START",err,error,*999)
3884 IF(
ASSOCIATED(cellml))
THEN 3885 cellml_field_maps=>cellml%FIELD_MAPS
3886 IF(
ASSOCIATED(cellml_field_maps))
THEN 3887 IF(cellml_field_maps%CELLML_FIELD_MAPS_FINISHED)
THEN 3888 IF(
ASSOCIATED(cellml%PARAMETERS_FIELD))
THEN 3889 CALL flagerror(
"The CellML environment parameters field is already associated.",err,error,*999)
3891 region=>cellml%REGION
3892 IF(
ASSOCIATED(region))
THEN 3893 IF(
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD))
THEN 3894 IF(
ASSOCIATED(cellml_field_maps%SOURCE_FIELD_DOMAIN))
THEN 3895 IF(
ASSOCIATED(parameters_field))
THEN 3897 IF(parameters_field%FIELD_FINISHED)
THEN 3899 IF(parameters_field_user_number/=parameters_field%USER_NUMBER)
THEN 3900 local_error=
"The specified parameters field user number of "// &
3902 &
" does not match the user number of the specified parameters field of "// &
3904 CALL flagerror(local_error,err,error,*999)
3906 parameters_field_region=>parameters_field%REGION
3907 IF(
ASSOCIATED(parameters_field_region))
THEN 3909 IF(parameters_field_region%USER_NUMBER/=region%USER_NUMBER)
THEN 3910 local_error=
"Invalid region setup. The specified parameters field has been created on region number "// &
3912 &
" and the specified CellML environment has been created on region number "// &
3914 CALL flagerror(local_error,err,error,*999)
3917 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_GEOMETRIC_FIELD,parameters_field%GEOMETRIC_FIELD))
THEN 3918 CALL flagerror(
"The specified parameters field does not have the same geometric field as the "// &
3919 &
"geometric field for the specified CellML environment.",err,error,*999)
3922 IF(.NOT.
ASSOCIATED(cellml_field_maps%SOURCE_FIELD_DOMAIN%DECOMPOSITION,parameters_field%DECOMPOSITION))
THEN 3923 CALL flagerror(
"The specified parameters field does not have the same decomposition as the source "// &
3924 &
"domain decomposition for the specified CellML environment.",err,error,*999)
3927 CALL flagerror(
"The specified parameters field region is not associated.",err,error,*999)
3930 CALL flagerror(
"The specified parameters field has not been finished.",err,error,*999)
3935 CALL field_user_number_find(parameters_field_user_number,region,field,err,error,*999)
3936 IF(
ASSOCIATED(field))
THEN 3937 local_error=
"The specified parameters field user number of "// &
3939 &
"has already been used to create a field on region number "// &
3941 CALL flagerror(local_error,err,error,*999)
3945 IF(
ASSOCIATED(parameters_field))
THEN 3947 CALL field_data_type_check(parameters_field,field_u_variable_type,field_dp_type,err,error,*999)
3948 CALL field_type_check(parameters_field,field_general_type,err,error,*999)
3949 CALL field_number_of_variables_check(parameters_field,1,err,error,*999)
3950 CALL field_variable_types_check(parameters_field,[field_u_variable_type],err,error,*999)
3951 CALL field_number_of_components_check(parameters_field,field_u_variable_type, &
3952 & cellml%MAXIMUM_NUMBER_OF_PARAMETERS,err,error,*999)
3953 DO component_idx=1,cellml%MAXIMUM_NUMBER_OF_PARAMETERS
3954 CALL field_component_mesh_component_check(parameters_field,field_u_variable_type,component_idx, &
3955 & cellml_field_maps%SOURCE_FIELD_DOMAIN%MESH_COMPONENT_NUMBER,err,error,*999)
3956 CALL field_component_interpolation_check(parameters_field,field_u_variable_type,component_idx, &
3957 & cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE,err,error,*999)
3960 cellml%PARAMETERS_FIELD%PARAMETERS_FIELD_AUTO_CREATED=.true.
3962 CALL field_create_start(parameters_field_user_number,region,cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
3964 CALL field_data_type_set_and_lock(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,field_u_variable_type, &
3965 & field_dp_type,err,error,*999)
3966 CALL field_label_set(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,
"CellMLParametersField",err,error,*999)
3967 CALL field_type_set_and_lock(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,field_general_type,err,error,*999)
3968 CALL field_mesh_decomposition_set_and_lock(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
3969 & cellml_field_maps%SOURCE_FIELD_DOMAIN%DECOMPOSITION,err,error,*999)
3970 CALL field_geometric_field_set_and_lock(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
3971 & cellml_field_maps%SOURCE_GEOMETRIC_FIELD,err,error,*999)
3972 CALL field_number_of_variables_set_and_lock(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,1,err,error,*999)
3973 CALL field_variable_types_set_and_lock(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,[field_u_variable_type], &
3975 CALL field_variable_label_set(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,field_u_variable_type, &
3976 &
"ParametersVariable",err,error,*999)
3977 CALL field_dof_order_type_set(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,field_u_variable_type, &
3978 & field_contiguous_component_dof_order,err,error,*999)
3979 CALL field_number_of_components_set_and_lock(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,field_u_variable_type, &
3980 & cellml%MAXIMUM_NUMBER_OF_PARAMETERS,err,error,*999)
3981 DO component_idx=1,cellml%MAXIMUM_NUMBER_OF_PARAMETERS
3982 CALL field_component_mesh_component_set_and_lock(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
3983 & field_u_variable_type,component_idx,cellml_field_maps%SOURCE_FIELD_DOMAIN%MESH_COMPONENT_NUMBER, &
3985 CALL field_component_interpolation_set_and_lock(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD, &
3986 & field_u_variable_type,component_idx,cellml_field_maps%SOURCE_FIELD_INTERPOLATION_TYPE,err,error,*999)
3990 IF(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD_AUTO_CREATED)
THEN 3991 parameters_field=>cellml%PARAMETERS_FIELD%PARAMETERS_FIELD
3993 cellml%PARAMETERS_FIELD%PARAMETERS_FIELD=>parameters_field
3996 CALL flagerror(
"CellML field maps source field domain is not associated.",err,error,*999)
3999 CALL flagerror(
"CellML field maps source geometric field is not associated.",err,error,*999)
4002 CALL flagerror(
"CellML environment region is not associated.",err,error,*999)
4006 CALL flagerror(
"The CellML environment fields map has not been finished.",err,error,*999)
4009 CALL flagerror(
"CellML environment fields map is not associated. You must create the CellML field maps first.", &
4013 CALL flagerror(
"CellML environment is not associated",err,error,*999)
4018 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
4022 exits(
"CELLML_PARAMETERS_FIELD_CREATE_START")
4024 999 errorsexits(
"CELLML_PARAMETERS_FIELD_CREATE_START",err,error)
4036 INTEGER(INTG),
INTENT(OUT) :: ERR
4039 INTEGER(INTG) :: model_idx,models_dof_idx,parameter_component_idx,CELLML_VARIABLE_TYPE
4040 INTEGER(INTG),
POINTER :: MODELS_DATA(:)
4041 REAL(DP) :: INITIAL_VALUE
4046 enters(
"CELLML_PARAMETERS_FIELD_CREATE_FINISH",err,error,*999)
4050 IF(
ASSOCIATED(cellml))
THEN 4051 IF(
ASSOCIATED(cellml%PARAMETERS_FIELD))
THEN 4052 IF(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD_FINISHED)
THEN 4053 CALL flagerror(
"CellML parameters field has already been finished.",err,error,*999)
4055 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 4056 IF(cellml%MODELS_FIELD%MODELS_FIELD_FINISHED)
THEN 4059 IF(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD_AUTO_CREATED) &
4060 &
CALL field_create_finish(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,err,error,*999)
4065 model=>cellml%MODELS(cellml%MODELS_FIELD%ONLY_ONE_MODEL_INDEX)%PTR
4066 IF(
ASSOCIATED(model))
THEN 4067 DO parameter_component_idx=1,model%NUMBER_OF_PARAMETERS
4069 err = cellml_model_definition_get_initial_value_by_index(model%PTR,cellml_variable_type,&
4070 & parameter_component_idx,initial_value)
4073 local_error=
"Failed to get an initial value for parameter variable with index "//&
4075 CALL flagerror(local_error,err,error,*999)
4079 CALL field_component_values_initialise(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD,field_u_variable_type, &
4080 & field_values_set_type,parameter_component_idx,initial_value,err,error,*999)
4083 local_error=
"The model is not associated for model index "// &
4085 CALL flagerror(local_error,err,error,*999)
4089 IF(
ASSOCIATED(cellml%FIELD_MAPS))
THEN 4090 NULLIFY(models_variable)
4091 CALL field_variable_get(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type,models_variable, &
4093 NULLIFY(models_data)
4094 CALL field_parameter_set_data_get(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type, &
4095 & field_values_set_type,models_data,err,error,*999)
4096 DO models_dof_idx=1,models_variable%NUMBER_OF_DOFS
4097 model_idx=models_data(models_dof_idx)
4098 IF(model_idx==0)
THEN 4100 ELSE IF(model_idx > 0 .AND. model_idx <= cellml%NUMBER_OF_MODELS)
THEN 4101 model=>cellml%MODELS(model_idx)%PTR
4102 IF(
ASSOCIATED(model))
THEN 4103 DO parameter_component_idx=1,model%NUMBER_OF_PARAMETERS
4105 err = cellml_model_definition_get_initial_value_by_index(model%PTR,cellml_variable_type,&
4106 & parameter_component_idx,initial_value)
4109 local_error=
"Failed to get an initial value for parameter variable with index "//&
4111 CALL flagerror(local_error,err,error,*999)
4116 & field_u_variable_type,field_values_set_type,parameter_component_idx,initial_value,err,error,*999)
4119 local_error=
"The model is not associated for model index "// &
4121 CALL flagerror(local_error,err,error,*999)
4124 local_error=
"Invalid CellML model index: "// &
4125 &
trim(
number_to_vstring(model_idx,
"*",err,error))//
". The specified index should be between 1 and "// &
4127 CALL flagerror(local_error,err,error,*999)
4130 CALL field_parameter_set_data_restore(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type, &
4131 & field_values_set_type,models_data,err,error,*999)
4133 CALL flagerror(
"CellML environment field maps is not associated.",err,error,*999)
4136 cellml%PARAMETERS_FIELD%PARAMETERS_FIELD_FINISHED=.true.
4138 CALL flagerror(
"CellML environment models field has not been finished.",err,error,*999)
4141 CALL flagerror(
"CellML environment models field is not associated.",err,error,*999)
4145 CALL flagerror(
"CellML environment parameters field is not associated.",err,error,*999)
4148 CALL flagerror(
"CellML environement is not associated.",err,error,*999)
4153 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
4157 exits(
"CELLML_PARAMETERS_FIELD_CREATE_FINISH")
4159 999 errorsexits(
"CELLML_PARAMETERS_FIELD_CREATE_FINISH",err,error)
4171 INTEGER(INTG),
INTENT(OUT) :: ERR
4175 enters(
"CELLML_PARAMETERS_FIELD_FINALISE",err,error,*999)
4179 IF(
ASSOCIATED(parameters_field))
THEN 4180 DEALLOCATE(parameters_field)
4185 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
4189 exits(
"CELLML_PARAMETERS_FIELD_FINALISE")
4191 999 errorsexits(
"CELLML_PARAMETERS_FIELD_FINALISE",err,error)
4203 TYPE(
field_type),
POINTER :: PARAMETERS_FIELD
4204 INTEGER(INTG),
INTENT(OUT) :: ERR
4208 enters(
"CELLML_PARAMETERS_FIELD_GET",err,error,*999)
4212 IF(
ASSOCIATED(cellml))
THEN 4213 IF(
ASSOCIATED(cellml%PARAMETERS_FIELD))
THEN 4214 IF(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD_FINISHED)
THEN 4215 IF(
ASSOCIATED(parameters_field))
THEN 4216 CALL flagerror(
"Parameters field is already associated.",err,error,*999)
4218 parameters_field=>cellml%PARAMETERS_FIELD%PARAMETERS_FIELD
4221 CALL flagerror(
"CellML environment parameters field has not been finished.",err,error,*999)
4224 CALL flagerror(
"CellML environment parameters field is not associated. Create the parameters field first.",err,error,*999)
4227 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
4232 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
4236 exits(
"CELLML_PARAMETERS_FIELD_GET")
4238 999 errorsexits(
"CELLML_PARAMETERS_FIELD_GET",err,error)
4250 INTEGER(INTG),
INTENT(OUT) :: ERR
4253 INTEGER(INTG) :: DUMMY_ERR
4256 enters(
"CELLML_PARAMETERS_FIELD_INITIALISE",err,error,*998)
4260 IF(
ASSOCIATED(cellml))
THEN 4261 IF(
ASSOCIATED(cellml%PARAMETERS_FIELD))
THEN 4262 CALL flagerror(
"CellML environment parameters field is already associated.",err,error,*998)
4264 ALLOCATE(cellml%PARAMETERS_FIELD,stat=err)
4265 IF(err/=0)
CALL flagerror(
"Could not allocate CellML environment parameters field.",err,error,*999)
4266 cellml%PARAMETERS_FIELD%CELLML=>cellml
4267 cellml%PARAMETERS_FIELD%PARAMETERS_FIELD_FINISHED=.false.
4268 cellml%PARAMETERS_FIELD%PARAMETERS_FIELD_AUTO_CREATED=.false.
4269 NULLIFY(cellml%PARAMETERS_FIELD%PARAMETERS_FIELD)
4272 CALL flagerror(
"CellML environment is not associated.",err,error,*998)
4277 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*998)
4281 exits(
"CELLML_PARAMETERS_FIELD_INITIALISE")
4284 998 errorsexits(
"CELLML_PARAMETERS_FIELD_INITIALISE",err,error)
4301 INTEGER(INTG),
INTENT(OUT) :: ERR
4305 enters(
"CELLML_GENERATE",err,error,*999)
4309 IF(
ASSOCIATED(cellml))
THEN 4310 IF(cellml%CELLML_FINISHED)
THEN 4312 cellml%CELLML_GENERATED=.true.
4314 CALL flagerror(
"CellML environment has not been finished.",err,error,*999)
4317 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
4322 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
4326 exits(
"CELLML_GENERATE")
4328 999 errorsexits(
"CELLML_GENERATE",err,error)
4340 INTEGER(INTG),
INTENT(IN) :: USER_NUMBER
4343 INTEGER(INTG),
INTENT(OUT) :: ERR
4346 INTEGER(INTG) :: cellml_idx
4349 enters(
"CELLML_USER_NUMBER_FIND",err,error,*999)
4353 IF(
ASSOCIATED(region))
THEN 4354 IF(
ASSOCIATED(cellml))
THEN 4355 CALL flagerror(
"CellML is already associated.",err,error,*999)
4358 cellml_environments=>region%CELLML_ENVIRONMENTS
4359 IF(
ASSOCIATED(cellml_environments))
THEN 4361 DO WHILE(cellml_idx<=cellml_environments%NUMBER_OF_ENVIRONMENTS.AND..NOT.
ASSOCIATED(cellml))
4362 IF(cellml_environments%ENVIRONMENTS(cellml_idx)%PTR%USER_NUMBER==user_number)
THEN 4363 cellml=>cellml_environments%ENVIRONMENTS(cellml_idx)%PTR
4365 cellml_idx=cellml_idx+1
4369 CALL flagerror(
"Region CellML environments is not associated.",err,error,*999)
4373 CALL flagerror(
"Region is not associated.",err,error,*999)
4378 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
4382 exits(
"CELLML_USER_NUMBER_FIND")
4384 999 errorsexits(
"CELLML_USER_NUMBER_FIND",err,error)
4397 INTEGER(INTG),
INTENT(OUT) :: ERR
4400 INTEGER(INTG) :: cellml_idx
4402 enters(
"CELLML_ENVIRONMENTS_FINALISE",err,error,*999)
4404 IF(
ASSOCIATED(cellml_environments))
THEN 4405 IF(
ALLOCATED(cellml_environments%ENVIRONMENTS))
THEN 4406 DO cellml_idx=1,
SIZE(cellml_environments%ENVIRONMENTS,1)
4407 CALL cellml_finalise(cellml_environments%ENVIRONMENTS(cellml_idx)%PTR,err,error,*999)
4409 DEALLOCATE(cellml_environments%ENVIRONMENTS)
4411 DEALLOCATE(cellml_environments)
4414 exits(
"CELLML_ENVIRONMENTS_FINALISE")
4416 999 errorsexits(
"CELLML_ENVIRONMENTS_FINALISE",err,error)
4429 INTEGER(INTG),
INTENT(OUT) :: ERR
4432 INTEGER(INTG) :: DUMMY_ERR
4435 enters(
"CELLML_ENVIRONMENTS_INITIALISE",err,error,*998)
4437 IF(
ASSOCIATED(region))
THEN 4438 IF(
ASSOCIATED(region%CELLML_ENVIRONMENTS))
THEN 4439 CALL flagerror(
"Region CellML environments is already associated.",err,error,*998)
4441 ALLOCATE(region%CELLML_ENVIRONMENTS,stat=err)
4442 IF(err/=0)
CALL flagerror(
"Could not allocate region CellML environments.",err,error,*999)
4443 region%CELLML_ENVIRONMENTS%REGION=>region
4444 region%CELLML_ENVIRONMENTS%NUMBER_OF_ENVIRONMENTS=0
4447 CALL flagerror(
"Region is not associated.",err,error,*998)
4450 exits(
"CELLML_ENVIRONMENTS_INITIALISE")
4453 998 errorsexits(
"CELLML_ENVIRONMENTS_INITIALISE",err,error)
4465 INTEGER(INTG),
INTENT(IN) :: CELLML_VARIABLE_TYPE
4466 INTEGER(INTG),
INTENT(OUT) :: ERR
4469 INTEGER(INTG) :: MAP_CELLML_VARIABLE_TYPE_TO_FIELD_TYPE_INTG
4476 enters(
"MAP_CELLML_VARIABLE_TYPE_TO_FIELD_TYPE_INTG",err,error,*999)
4478 SELECT CASE(cellml_variable_type)
4487 &
" (independent variable) support not yet implemented" 4488 CALL flagerror(local_error,err,error,*999)
4491 &
" is invalid or not implemented." 4492 CALL flagerror(local_error,err,error,*999)
4495 exits(
"MAP_CELLML_VARIABLE_TYPE_TO_FIELD_TYPE_INTG")
4497 999 errorsexits(
"MAP_CELLML_VARIABLE_TYPE_TO_FIELD_TYPE_INTG",err,error)
4509 INTEGER(INTG),
INTENT(IN) :: CELLML_FIELD_TYPE
4510 INTEGER(INTG),
INTENT(OUT) :: ERR
4513 INTEGER(INTG) :: MAP_CELLML_FIELD_TYPE_TO_VARIABLE_TYPE_INTG
4520 enters(
"MAP_CELLML_FIELD_TYPE_TO_VARIABLE_TYPE_INTG",err,error,*999)
4521 SELECT CASE(cellml_field_type)
4523 map_cellml_field_type_to_variable_type_intg=1
4525 map_cellml_field_type_to_variable_type_intg=2
4527 map_cellml_field_type_to_variable_type_intg=3
4534 &
" is invalid or not implemented" 4535 CALL flagerror(local_error,err,error,*999)
4537 exits(
"MAP_CELLML_FIELD_TYPE_TO_VARIABLE_TYPE_INTG")
4539 999 errorsexits(
"MAP_CELLML_FIELD_TYPE_TO_VARIABLE_TYPE_INTG",err,error)
subroutine, public enters(NAME, ERR, ERROR,)
Records the entry into the named procedure and initialises the error code.
subroutine, public cellml_parameters_field_create_finish(CELLML, ERR, ERROR,)
Finish the creation of the parameters field for the given CellML environment.
integer, parameter ptr
Pointer integer kind.
subroutine, public cellml_intermediate_field_get(CELLML, INTERMEDIATE_FIELD, ERR, ERROR,)
Returns the intermediate field for the given CellML environment.
subroutine, public cellml_field_to_cellml_update(CELLML, ERR, ERROR,)
Updates any cellml fields from the mapped fields.
Contains information for a region.
subroutine cellml_field_maps_initialise(CELLML, ERR, ERROR,)
Initialise a CellML field mpas.
subroutine cellml_parameters_field_finalise(PARAMETERS_FIELD, ERR, ERROR,)
Finalise a CellML environment parameters field and deallocate all memory.
Contains information on the maps between a CellML model and external OpenCMISS fields.
subroutine cellml_model_map_finalise(CELLML_MODEL_MAP, ERR, ERROR,)
Finalise a CellML model map and deallocate all memory.
subroutine cellml_variable_set_as_wanted_c(CELLML, MODEL_INDEX, VARIABLE_ID, ERR, ERROR,)
Sets a CellML model variable to be wanted - i.e., the variable's value will used by an OpenCMISS fiel...
Converts a number to its equivalent varying string representation.
Map a CellML field type to a CellML variable type from OpenCMISS(cellml).
subroutine cellml_models_field_finalise(MODELS_FIELD, ERR, ERROR,)
Finalise a CellML environment models field and deallocate all memory.
subroutine, public cellml_field_maps_create_start(CELLML, ERR, ERROR,)
Start the creation of field maps for a CellML environment.
This module contains all Fortran and C data conversion routines.
subroutine cellml_state_field_initialise(CELLML, ERR, ERROR,)
Initialise a CellML environment models field.
subroutine cellml_field_maps_finalise(CELLML_FIELD_MAPS, ERR, ERROR,)
Finalise a CellML maps and deallocate all memory.
subroutine, public cellml_intermediate_field_create_finish(CELLML, ERR, ERROR,)
Finialse the creation of the intermediate field for the given CellML environment. Finish creating the...
subroutine, public cellml_create_start(CELLML_USER_NUMBER, REGION, CELLML, ERR, ERROR,)
Set up the CellML environment in the given region. For a given region, create a CellML environment th...
Buffer type to allow an array of pointers to CELLML_MODEL_MAP_FIELD_TYPE.
subroutine cellml_models_field_initialise(CELLML, ERR, ERROR,)
Initialise a CellML environment models field.
subroutine cellml_model_finalise(CELLML_MODEL, ERR, ERROR,)
Finalise a CellML model and deallocate all memory.
This module contains all string manipulation and transformation routines.
subroutine, public cellml_user_number_find(USER_NUMBER, REGION, CELLML, ERR, ERROR,)
Finds and returns in CELLML a pointer to the CellML environment identified by USER_NUMBER on a region...
subroutine, public cellml_cellml_to_field_update(CELLML, ERR, ERROR,)
Updates any mapped fields from the cellml fields.
subroutine cellml_model_import_vs(CELLML, URI, MODEL_INDEX, ERR, ERROR,)
Import the specified CellML model into the given CellML environment object.
Contains information on the parameters field for a CellML environment.
subroutine, public cellml_parameters_field_get(CELLML, PARAMETERS_FIELD, ERR, ERROR,)
Returns the parameters field for the given CellML environment.
subroutine, public cellml_intermediate_field_create_start(INTERMEDIATE_FIELD_USER_NUMBER, CELLML, INTERMEDIATE_FIELD, ERR, ERROR,)
Create a field used to store intermediate variables of interest.
Contains information for a field defined on a region.
integer(intg), parameter, public cellml_parameters_field
CellML parameters field.
subroutine cellml_field_component_get_c(CELLML, MODEL_INDEX, CELLML_FIELD_TYPE, VARIABLE_ID, COMPONENT_USER_NUMBER, ERR, ERROR,)
Find the component ID in the given field for the variable defined by the given variable ID in the pro...
Contains information on the maps between CellML and external OpenCMISS fields.
subroutine, public cellml_environments_finalise(CELLML_ENVIRONMENTS, ERR, ERROR,)
Finalises the CellML environments and deallocates all memory.
This module provides an iso_varying_string module, conformant to the API specified in ISO/IEC 1539-2:...
subroutine cellml_variable_set_as_wanted_vs(CELLML, MODEL_USER_NUMBER, VARIABLE_ID, ERR, ERROR,)
Sets a CellML model variable to be wanted - i.e., the variable's value will be used by an OpenCMISS f...
subroutine cellml_create_cellml_to_field_map_c(CELLML, MODEL_INDEX, VARIABLE_ID, CELLML_PARAMETER_SET, FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, FIELD_PARAMETER_SET, ERR, ERROR,)
Create a CellML model variable to field variable component map.
subroutine cellml_intermediate_field_finalise(INTERMEDIATE_FIELD, ERR, ERROR,)
Finalise a CellML environment models field and deallocate all memory.
subroutine, public cellml_state_field_create_start(STATE_FIELD_USER_NUMBER, CELLML, STATE_FIELD, ERR, ERROR,)
Start the creation of the state field for the given CellML environment.
subroutine, public cellml_field_maps_create_finish(CELLML, ERR, ERROR,)
Finish creating the field maps for a CellML environment.
subroutine, public cellml_generate(CELLML, ERR, ERROR,)
Validate and instantiate the specified CellML environment. Users should call this routine once they h...
subroutine, public cellml_models_field_create_finish(CELLML, ERR, ERROR,)
Finish the creation of the models field for the given CellML environment.
subroutine cellml_create_field_to_cellml_map_vs(CELLML, FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, FIELD_PARAMETER_SET, MODEL_USER_NUMBER, VARIABLE_ID, CELLML_PARAMETER_SET, ERR, ERROR,)
Create a field variable component to CellML model variable map.
subroutine cellml_state_field_finalise(STATE_FIELD, ERR, ERROR,)
Finalise a CellML environment state field and deallocate all memory.
subroutine, public exits(NAME)
Records the exit out of the named procedure.
This module contains all type definitions in order to avoid cyclic module references.
Map a CellML variable type from OpenCMISS(cellml) to a CellML field type.
subroutine cellml_intermediate_field_initialise(CELLML, ERR, ERROR,)
Initialise a CellML environment intermediate field.
This module contains all the low-level base routines e.g., all debug, control, and low-level communic...
integer(intg), parameter, public cellml_models_field
CellML models field.
integer(intg) function map_cellml_field_type_to_variable_type_intg(CELLML_FIELD_TYPE, ERR, ERROR)
Maps a CellML field type to a CellML variable type (.
subroutine, public cellml_models_field_get(CELLML, MODELS_FIELD, ERR, ERROR,)
Returns the models field for the given CellML environment.
subroutine cellml_create_field_to_cellml_map_c(CELLML, FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, FIELD_PARAMETER_SET, MODEL_INDEX, VARIABLE_ID, CELLML_PARAMETER_SET, ERR, ERROR,)
Create a field variable component to CellML model variable map.
Contains information on the state field for a CellML environment.
integer(intg), parameter cellml_map_to_field_type
A CellML to field mapping type.
integer(intg), parameter, public cellml_models_field_not_constant
The CellML environement models field is not constant.
subroutine cellml_model_maps_initialise(CELLML_MODEL_MAPS, ERR, ERROR,)
Initialise a CellML model maps.
subroutine, public cellml_environments_initialise(REGION, ERR, ERROR,)
Initialises the CellML environments.
subroutine, public cellml_state_field_get(CELLML, STATE_FIELD, ERR, ERROR,)
Returns the state field for the given CellML environment.
Contains information on the mapping between CellML fields and OpenCMISS fields and vise versa...
subroutine, public cmissf2cstring(Fstring, Cstring)
Copys/converts a Fortran String (length of characters) to a C string (array of characters) ...
logical, save, public diagnostics1
.TRUE. if level 1 diagnostic output is active in the current routine
subroutine cellml_models_field_check(MODELS_FIELD, ERR, ERROR,)
Checks a CellML environment models field for correctness.
Contains information on the models field for a CellML environment.
subroutine cellml_model_import_c(CELLML, URI, MODEL_INDEX, ERR, ERROR,)
Import the specified CellML model into the given CellML environment object.
This module is a OpenCMISS(cm) buffer module to OpenCMISS(cellml).
subroutine cellml_variable_set_as_known_c(CELLML, MODEL_INDEX, VARIABLE_ID, ERR, ERROR,)
Sets a CellML model variable to be known - i.e., the variable's value will be set by an OpenCMISS fie...
Contains information on the CellML environments defined.
A type to hold the parameter sets for a field.
A buffer type to allow for an array of pointers to a CELLML_TYPE.
integer(intg), parameter, public diagnostic_output_type
Diagnostic output type.
subroutine, public cellml_destroy(CELLML, ERR, ERROR,)
Destroys the given CellML environment.
Contains information for a field variable defined on a field.
A buffer type to allow for an array of pointers to a CELLML_MODEL_TYPE.
This type is a wrapper for the C_PTR which references the actual CellML model definition object...
subroutine, public cellml_state_field_create_finish(CELLML, ERR, ERROR,)
Finialse the creation of the state field for the given CellML environment. Finish creating the state ...
integer(intg), parameter cellml_map_from_field_type
A field to CellML mapping type.
subroutine, public cellml_models_field_create_start(MODEL_FIELD_USER_NUMBER, CELLML, MODELS_FIELD, ERR, ERROR,)
Start the creation of the models field for the given CellML environment.
subroutine, public cellml_fieldmodeldofset(modelVariable, modelDofIdx, field, variableType, parameterSetIdx, componentIdx, value, err, error,)
Set the dof in a field specified by a model DOF and component to a value.
subroutine cellml_variable_set_as_known_vs(CELLML, MODEL_USER_NUMBER, VARIABLE_ID, ERR, ERROR,)
Sets a CellML model variable to be known - i.e., the variable's value will be set by an OpenCMISS fie...
integer(intg), parameter, public cellml_state_field
CellML state field.
subroutine, public cellml_parameters_field_create_start(PARAMETERS_FIELD_USER_NUMBER, CELLML, PARAMETERS_FIELD, ERR, ERROR,)
Start the creation of the parameters field for the given CellML environment.
subroutine cellml_create_cellml_to_field_map_vs(CELLML, MODEL_USER_NUMBER, VARIABLE_ID, CELLML_PARAMETER_SET, FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, FIELD_PARAMETER_SET, ERR, ERROR,)
Create a CellML model variable to field variable component map.
subroutine, public cellml_create_finish(CELLML, ERR, ERROR,)
Finish creating the CellML environment. At this point we know all the variables that are known and wa...
subroutine cellml_initialise(CELLML, ERR, ERROR,)
Initialise a CellML environment and deallocate all memory.
integer(intg), parameter, public cellml_intermediate_field
CellML intermediate field.
integer(intg), parameter cellml_models_field_not_checked
The CellML environment models field has not been checked.
subroutine cellml_parameters_field_initialise(CELLML, ERR, ERROR,)
Initialise a CellML environment parameters field.
Flags an error condition.
subroutine cellml_field_component_get_vs(CELLML, MODEL_INDEX, CELLML_FIELD_TYPE, VARIABLE_ID, COMPONENT_USER_NUMBER, ERR, ERROR,)
Find the component ID in the given field for the variable defined by the given variable ID in the pro...
Contains information for a CellML environment.
subroutine cellml_finalise(CELLML, ERR, ERROR,)
Finalise a CellML environment and deallocate all memory.
This module contains all kind definitions.
integer(intg) function map_cellml_variable_type_to_field_type_intg(CELLML_VARIABLE_TYPE, ERR, ERROR)
Maps a CellML variable type to a CellML field type (.
subroutine cellml_model_map_initialise(CELLML_MODEL_MAP, ERR, ERROR,)
Initialise a CellML model map.
subroutine cellml_model_initialise(CELLML_MODEL, ERR, ERROR,)
Initialise a CellML model.
subroutine cellml_model_maps_finalise(CELLML_MODEL_MAPS, ERR, ERROR,)
Finalise a CellML model maps and deallocate all memory.