@@ -50,6 +50,28 @@ array_1d<double, props_size> MakePropsVector(const Vector& rUMatParameters)
5050 return result;
5151}
5252
53+ std::vector<std::string> GFortranNamesOf (const std::vector<std::string>& rFunctionNames)
54+ {
55+ auto result = std::vector<std::string>{};
56+ result.reserve (rFunctionNames.size ());
57+ auto append_underscore = [](const auto & rFunctionName) { return rFunctionName + ' _' ; };
58+ std::transform (rFunctionNames.begin (), rFunctionNames.end (), std::back_inserter (result), append_underscore);
59+ return result;
60+ }
61+
62+ const std::vector<std::string>& UserModFunctionNames ()
63+ {
64+ auto generate_names = []() {
65+ using namespace std ::string_literals;
66+ auto result = std::vector<std::string>{" User_Mod" s, " User_mod" s, " USER_MOD" s, " user_mod" s};
67+ const auto gfortran_names = GFortranNamesOf (result);
68+ result.insert (result.end (), gfortran_names.begin (), gfortran_names.end ());
69+ return result;
70+ };
71+ static const auto result = generate_names ();
72+ return result;
73+ }
74+
5375} // namespace
5476
5577namespace Kratos
@@ -471,16 +493,15 @@ bool SmallStrainUDSMLaw::loadUDSMLinux(const Properties& rMaterialProperties)
471493 // resolve function GetStateVarCount address
472494 mpGetStateVarCount = (f_GetStateVarCount)dlsym (lib_handle, " getstatevarcount" );
473495
474- mpUserMod = (f_UserMod)dlsym (lib_handle, " user_mod" );
496+ for (const auto & r_function_name : UserModFunctionNames ()) {
497+ mpUserMod = (f_UserMod)dlsym (lib_handle, r_function_name.c_str ());
498+
499+ if (mpUserMod) break ;
500+ }
501+
475502 if (!mpUserMod) {
476- mpUserMod = (f_UserMod)dlsym (lib_handle, " user_mod_" );
477- if (!mpUserMod) {
478- KRATOS_INFO (" Error in loadUDSMLinux" )
479- << " cannot load function User_Mod in the specified UDSM: " << rMaterialProperties[UDSM_NAME]
480- << std::endl;
481- KRATOS_ERROR << " cannot load function User_Mod in the specified UDSM "
482- << rMaterialProperties[UDSM_NAME] << std::endl;
483- }
503+ KRATOS_ERROR << " Cannot load function 'User_Mod' in the specified UDSM "
504+ << rMaterialProperties[UDSM_NAME] << std::endl;
484505 }
485506
486507 return true ;
@@ -533,18 +554,17 @@ bool SmallStrainUDSMLaw::loadUDSMWindows(const Properties& rMaterialProperties)
533554 // resolve function GetStateVarCount address
534555 mpGetStateVarCount = (f_GetStateVarCount)GetProcAddress (hGetProcIDDLL, " getstatevarcount" );
535556
536- mpUserMod = (f_UserMod)GetProcAddress (hGetProcIDDLL, " user_mod" );
557+ for (const auto & r_function_name : UserModFunctionNames ()) {
558+ mpUserMod = (f_UserMod)GetProcAddress (hGetProcIDDLL, r_function_name.c_str ());
559+
560+ if (mpUserMod) break ;
561+ }
562+
537563 if (!mpUserMod) {
538- // check if the dll is compiled with gfortran
539- mpUserMod = (f_UserMod)GetProcAddress (hGetProcIDDLL, " user_mod_" );
540- if (!mpUserMod) {
541- KRATOS_INFO (" Error in loadUDSMWindows" )
542- << " cannot load function User_Mod in the specified UDSM: " << rMaterialProperties[UDSM_NAME]
543- << std::endl;
544- KRATOS_ERROR << " cannot load function User_Mod in the specified UDSM "
545- << rMaterialProperties[UDSM_NAME] << std::endl;
546- }
564+ KRATOS_ERROR << " Cannot load function 'User_Mod' in the specified UDSM "
565+ << rMaterialProperties[UDSM_NAME] << std::endl;
547566 }
567+
548568 return true ;
549569#else
550570 KRATOS_ERROR << " loadUDSMWindows should be called in Windows applications"
0 commit comments