From 0129b87f3b730aae55ae83477ea0ccca947cecfa Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Mon, 21 Nov 2022 06:19:30 -0500 Subject: [PATCH] Fix realloc --- base/modules/auxil/psb_c_realloc_mod.F90 | 42 +++++++++++++++++++++++ base/modules/auxil/psb_d_realloc_mod.F90 | 42 +++++++++++++++++++++++ base/modules/auxil/psb_e_realloc_mod.F90 | 42 +++++++++++++++++++++++ base/modules/auxil/psb_i2_realloc_mod.F90 | 42 +++++++++++++++++++++++ base/modules/auxil/psb_m_realloc_mod.F90 | 42 +++++++++++++++++++++++ base/modules/auxil/psb_s_realloc_mod.F90 | 42 +++++++++++++++++++++++ base/modules/auxil/psb_z_realloc_mod.F90 | 42 +++++++++++++++++++++++ 7 files changed, 294 insertions(+) diff --git a/base/modules/auxil/psb_c_realloc_mod.F90 b/base/modules/auxil/psb_c_realloc_mod.F90 index 504f19f7..9e6af5a8 100644 --- a/base/modules/auxil/psb_c_realloc_mod.F90 +++ b/base/modules/auxil/psb_c_realloc_mod.F90 @@ -991,7 +991,48 @@ Contains goto 9999 end if +!!$ If (len > psb_size(v)) Then +!!$ if (present(newsz)) then +!!$ isz = (max(len+1,newsz)) +!!$ else +!!$ if (present(addsz)) then +!!$ isz = len+max(1,addsz) +!!$ else +!!$ isz = max(len+10, int(1.25*len)) +!!$ endif +!!$ endif +!!$ +!!$ call psb_realloc(isz,v,info,pad=pad) +!!$ if (info /= psb_success_) then +!!$ info=psb_err_from_subroutine_ +!!$ call psb_errpush(info,name,a_err='psb_realloc') +!!$ goto 9999 +!!$ End If +!!$ end If If (len > psb_size(v)) Then +#if defined(OPENMP) + !$OMP CRITICAL + if (len > psb_size(v)) then + if (present(newsz)) then + isz = (max(len+1,newsz)) + else + if (present(addsz)) then + isz = len+max(1,addsz) + else + isz = max(len+10, int(1.25*len)) + endif + endif + + call psb_realloc(isz,v,info,pad=pad) + end if + !$OMP END CRITICAL + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_realloc') + goto 9999 + end if +#else if (present(newsz)) then isz = (max(len+1,newsz)) else @@ -1008,6 +1049,7 @@ Contains call psb_errpush(info,name,a_err='psb_realloc') goto 9999 End If +#endif end If call psb_erractionrestore(err_act) diff --git a/base/modules/auxil/psb_d_realloc_mod.F90 b/base/modules/auxil/psb_d_realloc_mod.F90 index 588a4e4d..672b4677 100644 --- a/base/modules/auxil/psb_d_realloc_mod.F90 +++ b/base/modules/auxil/psb_d_realloc_mod.F90 @@ -991,7 +991,48 @@ Contains goto 9999 end if +!!$ If (len > psb_size(v)) Then +!!$ if (present(newsz)) then +!!$ isz = (max(len+1,newsz)) +!!$ else +!!$ if (present(addsz)) then +!!$ isz = len+max(1,addsz) +!!$ else +!!$ isz = max(len+10, int(1.25*len)) +!!$ endif +!!$ endif +!!$ +!!$ call psb_realloc(isz,v,info,pad=pad) +!!$ if (info /= psb_success_) then +!!$ info=psb_err_from_subroutine_ +!!$ call psb_errpush(info,name,a_err='psb_realloc') +!!$ goto 9999 +!!$ End If +!!$ end If If (len > psb_size(v)) Then +#if defined(OPENMP) + !$OMP CRITICAL + if (len > psb_size(v)) then + if (present(newsz)) then + isz = (max(len+1,newsz)) + else + if (present(addsz)) then + isz = len+max(1,addsz) + else + isz = max(len+10, int(1.25*len)) + endif + endif + + call psb_realloc(isz,v,info,pad=pad) + end if + !$OMP END CRITICAL + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_realloc') + goto 9999 + end if +#else if (present(newsz)) then isz = (max(len+1,newsz)) else @@ -1008,6 +1049,7 @@ Contains call psb_errpush(info,name,a_err='psb_realloc') goto 9999 End If +#endif end If call psb_erractionrestore(err_act) diff --git a/base/modules/auxil/psb_e_realloc_mod.F90 b/base/modules/auxil/psb_e_realloc_mod.F90 index 87561777..0f2431fd 100644 --- a/base/modules/auxil/psb_e_realloc_mod.F90 +++ b/base/modules/auxil/psb_e_realloc_mod.F90 @@ -991,7 +991,48 @@ Contains goto 9999 end if +!!$ If (len > psb_size(v)) Then +!!$ if (present(newsz)) then +!!$ isz = (max(len+1,newsz)) +!!$ else +!!$ if (present(addsz)) then +!!$ isz = len+max(1,addsz) +!!$ else +!!$ isz = max(len+10, int(1.25*len)) +!!$ endif +!!$ endif +!!$ +!!$ call psb_realloc(isz,v,info,pad=pad) +!!$ if (info /= psb_success_) then +!!$ info=psb_err_from_subroutine_ +!!$ call psb_errpush(info,name,a_err='psb_realloc') +!!$ goto 9999 +!!$ End If +!!$ end If If (len > psb_size(v)) Then +#if defined(OPENMP) + !$OMP CRITICAL + if (len > psb_size(v)) then + if (present(newsz)) then + isz = (max(len+1,newsz)) + else + if (present(addsz)) then + isz = len+max(1,addsz) + else + isz = max(len+10, int(1.25*len)) + endif + endif + + call psb_realloc(isz,v,info,pad=pad) + end if + !$OMP END CRITICAL + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_realloc') + goto 9999 + end if +#else if (present(newsz)) then isz = (max(len+1,newsz)) else @@ -1008,6 +1049,7 @@ Contains call psb_errpush(info,name,a_err='psb_realloc') goto 9999 End If +#endif end If call psb_erractionrestore(err_act) diff --git a/base/modules/auxil/psb_i2_realloc_mod.F90 b/base/modules/auxil/psb_i2_realloc_mod.F90 index b348d9c4..22e85d36 100644 --- a/base/modules/auxil/psb_i2_realloc_mod.F90 +++ b/base/modules/auxil/psb_i2_realloc_mod.F90 @@ -991,7 +991,48 @@ Contains goto 9999 end if +!!$ If (len > psb_size(v)) Then +!!$ if (present(newsz)) then +!!$ isz = (max(len+1,newsz)) +!!$ else +!!$ if (present(addsz)) then +!!$ isz = len+max(1,addsz) +!!$ else +!!$ isz = max(len+10, int(1.25*len)) +!!$ endif +!!$ endif +!!$ +!!$ call psb_realloc(isz,v,info,pad=pad) +!!$ if (info /= psb_success_) then +!!$ info=psb_err_from_subroutine_ +!!$ call psb_errpush(info,name,a_err='psb_realloc') +!!$ goto 9999 +!!$ End If +!!$ end If If (len > psb_size(v)) Then +#if defined(OPENMP) + !$OMP CRITICAL + if (len > psb_size(v)) then + if (present(newsz)) then + isz = (max(len+1,newsz)) + else + if (present(addsz)) then + isz = len+max(1,addsz) + else + isz = max(len+10, int(1.25*len)) + endif + endif + + call psb_realloc(isz,v,info,pad=pad) + end if + !$OMP END CRITICAL + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_realloc') + goto 9999 + end if +#else if (present(newsz)) then isz = (max(len+1,newsz)) else @@ -1008,6 +1049,7 @@ Contains call psb_errpush(info,name,a_err='psb_realloc') goto 9999 End If +#endif end If call psb_erractionrestore(err_act) diff --git a/base/modules/auxil/psb_m_realloc_mod.F90 b/base/modules/auxil/psb_m_realloc_mod.F90 index 536ff219..c81ed83a 100644 --- a/base/modules/auxil/psb_m_realloc_mod.F90 +++ b/base/modules/auxil/psb_m_realloc_mod.F90 @@ -991,7 +991,48 @@ Contains goto 9999 end if +!!$ If (len > psb_size(v)) Then +!!$ if (present(newsz)) then +!!$ isz = (max(len+1,newsz)) +!!$ else +!!$ if (present(addsz)) then +!!$ isz = len+max(1,addsz) +!!$ else +!!$ isz = max(len+10, int(1.25*len)) +!!$ endif +!!$ endif +!!$ +!!$ call psb_realloc(isz,v,info,pad=pad) +!!$ if (info /= psb_success_) then +!!$ info=psb_err_from_subroutine_ +!!$ call psb_errpush(info,name,a_err='psb_realloc') +!!$ goto 9999 +!!$ End If +!!$ end If If (len > psb_size(v)) Then +#if defined(OPENMP) + !$OMP CRITICAL + if (len > psb_size(v)) then + if (present(newsz)) then + isz = (max(len+1,newsz)) + else + if (present(addsz)) then + isz = len+max(1,addsz) + else + isz = max(len+10, int(1.25*len)) + endif + endif + + call psb_realloc(isz,v,info,pad=pad) + end if + !$OMP END CRITICAL + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_realloc') + goto 9999 + end if +#else if (present(newsz)) then isz = (max(len+1,newsz)) else @@ -1008,6 +1049,7 @@ Contains call psb_errpush(info,name,a_err='psb_realloc') goto 9999 End If +#endif end If call psb_erractionrestore(err_act) diff --git a/base/modules/auxil/psb_s_realloc_mod.F90 b/base/modules/auxil/psb_s_realloc_mod.F90 index 252a2b9c..0b2873e3 100644 --- a/base/modules/auxil/psb_s_realloc_mod.F90 +++ b/base/modules/auxil/psb_s_realloc_mod.F90 @@ -991,7 +991,48 @@ Contains goto 9999 end if +!!$ If (len > psb_size(v)) Then +!!$ if (present(newsz)) then +!!$ isz = (max(len+1,newsz)) +!!$ else +!!$ if (present(addsz)) then +!!$ isz = len+max(1,addsz) +!!$ else +!!$ isz = max(len+10, int(1.25*len)) +!!$ endif +!!$ endif +!!$ +!!$ call psb_realloc(isz,v,info,pad=pad) +!!$ if (info /= psb_success_) then +!!$ info=psb_err_from_subroutine_ +!!$ call psb_errpush(info,name,a_err='psb_realloc') +!!$ goto 9999 +!!$ End If +!!$ end If If (len > psb_size(v)) Then +#if defined(OPENMP) + !$OMP CRITICAL + if (len > psb_size(v)) then + if (present(newsz)) then + isz = (max(len+1,newsz)) + else + if (present(addsz)) then + isz = len+max(1,addsz) + else + isz = max(len+10, int(1.25*len)) + endif + endif + + call psb_realloc(isz,v,info,pad=pad) + end if + !$OMP END CRITICAL + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_realloc') + goto 9999 + end if +#else if (present(newsz)) then isz = (max(len+1,newsz)) else @@ -1008,6 +1049,7 @@ Contains call psb_errpush(info,name,a_err='psb_realloc') goto 9999 End If +#endif end If call psb_erractionrestore(err_act) diff --git a/base/modules/auxil/psb_z_realloc_mod.F90 b/base/modules/auxil/psb_z_realloc_mod.F90 index 220637ff..e6eeac2f 100644 --- a/base/modules/auxil/psb_z_realloc_mod.F90 +++ b/base/modules/auxil/psb_z_realloc_mod.F90 @@ -991,7 +991,48 @@ Contains goto 9999 end if +!!$ If (len > psb_size(v)) Then +!!$ if (present(newsz)) then +!!$ isz = (max(len+1,newsz)) +!!$ else +!!$ if (present(addsz)) then +!!$ isz = len+max(1,addsz) +!!$ else +!!$ isz = max(len+10, int(1.25*len)) +!!$ endif +!!$ endif +!!$ +!!$ call psb_realloc(isz,v,info,pad=pad) +!!$ if (info /= psb_success_) then +!!$ info=psb_err_from_subroutine_ +!!$ call psb_errpush(info,name,a_err='psb_realloc') +!!$ goto 9999 +!!$ End If +!!$ end If If (len > psb_size(v)) Then +#if defined(OPENMP) + !$OMP CRITICAL + if (len > psb_size(v)) then + if (present(newsz)) then + isz = (max(len+1,newsz)) + else + if (present(addsz)) then + isz = len+max(1,addsz) + else + isz = max(len+10, int(1.25*len)) + endif + endif + + call psb_realloc(isz,v,info,pad=pad) + end if + !$OMP END CRITICAL + + if (info /= psb_success_) then + info=psb_err_from_subroutine_ + call psb_errpush(info,name,a_err='psb_realloc') + goto 9999 + end if +#else if (present(newsz)) then isz = (max(len+1,newsz)) else @@ -1008,6 +1049,7 @@ Contains call psb_errpush(info,name,a_err='psb_realloc') goto 9999 End If +#endif end If call psb_erractionrestore(err_act)