@@ -429,6 +429,35 @@ caf_runtime_error (const char *message, ...)
429
429
exit (EXIT_FAILURE );
430
430
}
431
431
432
+ /* Error handling is similar everytime. Keep in sync with single.c, too. */
433
+ static void
434
+ caf_internal_error (const char * msg , int * stat , char * errmsg ,
435
+ size_t errmsg_len , ...)
436
+ {
437
+ va_list args ;
438
+ va_start (args , errmsg_len );
439
+ if (stat )
440
+ {
441
+ * stat = 1 ;
442
+ if (errmsg_len > 0 )
443
+ {
444
+ int len = snprintf (errmsg , errmsg_len , msg , args );
445
+ if (len >= 0 && errmsg_len > (size_t ) len )
446
+ memset (& errmsg [len ], ' ' , errmsg_len - len );
447
+ }
448
+ va_end (args );
449
+ return ;
450
+ }
451
+ else
452
+ {
453
+ fprintf (stderr , "Fortran runtime error on image %d: " , caf_this_image );
454
+ vfprintf (stderr , msg , args );
455
+ fprintf (stderr , "\n" );
456
+ }
457
+ va_end (args );
458
+ exit (EXIT_FAILURE );
459
+ }
460
+
432
461
/* Forward declaration of the feature unsupported message for failed images
433
462
* functions. */
434
463
static void
@@ -4705,7 +4734,7 @@ case kind: \
4705
4734
KINDCASE (16 , __int128 );
4706
4735
#endif
4707
4736
default :
4708
- caf_runtime_error (vecrefunknownkind , stat , NULL , 0 );
4737
+ caf_internal_error (vecrefunknownkind , stat , NULL , 0 );
4709
4738
return ;
4710
4739
}
4711
4740
#undef KINDCASE
@@ -4751,7 +4780,7 @@ case kind: \
4751
4780
* in a dimension. */
4752
4781
break ;
4753
4782
default :
4754
- caf_runtime_error (unknownarrreftype , stat , NULL , 0 );
4783
+ caf_internal_error (unknownarrreftype , stat , NULL , 0 );
4755
4784
return ;
4756
4785
}
4757
4786
dprint ("i = %zd, array_ref = %s, delta = %ld\n" , i ,
@@ -4763,7 +4792,7 @@ case kind: \
4763
4792
if (delta > 1 && dst_rank == 0 )
4764
4793
{
4765
4794
/* No, an array is required, but not provided. */
4766
- caf_runtime_error (extentoutofrange , stat , NULL , 0 );
4795
+ caf_internal_error (extentoutofrange , stat , NULL , 0 );
4767
4796
return ;
4768
4797
}
4769
4798
/* When dst is an array. */
@@ -4773,7 +4802,7 @@ case kind: \
4773
4802
* only by scalar data. */
4774
4803
if (dst_cur_dim >= dst_rank && delta != 1 )
4775
4804
{
4776
- caf_runtime_error (rankoutofrange , stat , NULL , 0 );
4805
+ caf_internal_error (rankoutofrange , stat , NULL , 0 );
4777
4806
return ;
4778
4807
}
4779
4808
/* Do further checks, when the source is not scalar. */
@@ -4811,7 +4840,7 @@ case kind: \
4811
4840
}
4812
4841
else
4813
4842
{
4814
- caf_runtime_error (doublearrayref , stat , NULL , 0 );
4843
+ caf_internal_error (doublearrayref , stat , NULL , 0 );
4815
4844
return ;
4816
4845
}
4817
4846
}
@@ -4826,7 +4855,7 @@ case kind: \
4826
4855
/* Check whether dst is reallocatable. */
4827
4856
if (unlikely (!dst_reallocatable ))
4828
4857
{
4829
- caf_runtime_error (nonallocextentmismatch , stat ,
4858
+ caf_internal_error (nonallocextentmismatch , stat ,
4830
4859
NULL , 0 , delta ,
4831
4860
GFC_DESCRIPTOR_EXTENT (dst , dst_cur_dim ));
4832
4861
return ;
@@ -4835,7 +4864,7 @@ case kind: \
4835
4864
* which is not allowed. */
4836
4865
else if (!dst_reallocatable && extent_mismatch )
4837
4866
{
4838
- caf_runtime_error (extentoutofrange , stat , NULL , 0 );
4867
+ caf_internal_error (extentoutofrange , stat , NULL , 0 );
4839
4868
return ;
4840
4869
}
4841
4870
realloc_needed = true;
@@ -4893,7 +4922,7 @@ case kind: \
4893
4922
KINDCASE (16 , __int128 );
4894
4923
#endif
4895
4924
default :
4896
- caf_runtime_error (vecrefunknownkind , stat , NULL , 0 );
4925
+ caf_internal_error (vecrefunknownkind , stat , NULL , 0 );
4897
4926
return ;
4898
4927
}
4899
4928
#undef KINDCASE
@@ -4924,7 +4953,7 @@ case kind: \
4924
4953
* not occur here. */
4925
4954
case CAF_ARR_REF_OPEN_START :
4926
4955
default :
4927
- caf_runtime_error (unknownarrreftype , stat , NULL , 0 );
4956
+ caf_internal_error (unknownarrreftype , stat , NULL , 0 );
4928
4957
return ;
4929
4958
}
4930
4959
dprint ("i = %zd, array_ref = %s, delta = %ld\n" ,
@@ -4936,7 +4965,7 @@ case kind: \
4936
4965
if (delta > 1 && dst_rank == 0 )
4937
4966
{
4938
4967
/* No, an array is required, but not provided. */
4939
- caf_runtime_error (extentoutofrange , stat , NULL , 0 );
4968
+ caf_internal_error (extentoutofrange , stat , NULL , 0 );
4940
4969
return ;
4941
4970
}
4942
4971
/* When dst is an array. */
@@ -4946,7 +4975,7 @@ case kind: \
4946
4975
* only by scalar data. */
4947
4976
if (dst_cur_dim >= dst_rank && delta != 1 )
4948
4977
{
4949
- caf_runtime_error (rankoutofrange , stat , NULL , 0 );
4978
+ caf_internal_error (rankoutofrange , stat , NULL , 0 );
4950
4979
return ;
4951
4980
}
4952
4981
/* Do further checks, when the source is not scalar. */
@@ -4967,7 +4996,7 @@ case kind: \
4967
4996
}
4968
4997
else
4969
4998
{
4970
- caf_runtime_error (doublearrayref , stat , NULL , 0 );
4999
+ caf_internal_error (doublearrayref , stat , NULL , 0 );
4971
5000
return ;
4972
5001
}
4973
5002
}
@@ -4982,7 +5011,7 @@ case kind: \
4982
5011
/* Check whether dst is reallocatable. */
4983
5012
if (unlikely (!dst_reallocatable ))
4984
5013
{
4985
- caf_runtime_error (nonallocextentmismatch , stat ,
5014
+ caf_internal_error (nonallocextentmismatch , stat ,
4986
5015
NULL , 0 , delta ,
4987
5016
GFC_DESCRIPTOR_EXTENT (dst , dst_cur_dim ));
4988
5017
return ;
@@ -4991,7 +5020,7 @@ case kind: \
4991
5020
* which is not allowed. */
4992
5021
else if (!dst_reallocatable && extent_mismatch )
4993
5022
{
4994
- caf_runtime_error (extentoutofrange , stat , NULL , 0 );
5023
+ caf_internal_error (extentoutofrange , stat , NULL , 0 );
4995
5024
return ;
4996
5025
}
4997
5026
realloc_needed = true;
@@ -5025,7 +5054,7 @@ case kind: \
5025
5054
}
5026
5055
break ;
5027
5056
default :
5028
- caf_runtime_error (unknownreftype , stat , NULL , 0 );
5057
+ caf_internal_error (unknownreftype , stat , NULL , 0 );
5029
5058
return ;
5030
5059
}
5031
5060
src_size = riter -> item_size ;
@@ -5053,7 +5082,7 @@ case kind: \
5053
5082
dst -> base_addr = malloc (size * GFC_DESCRIPTOR_SIZE (dst ));
5054
5083
if (unlikely (dst -> base_addr == NULL ))
5055
5084
{
5056
- caf_runtime_error (cannotallocdst , stat , size * GFC_DESCRIPTOR_SIZE (dst ));
5085
+ caf_internal_error (cannotallocdst , stat , NULL , 0 , size * GFC_DESCRIPTOR_SIZE (dst ));
5057
5086
return ;
5058
5087
}
5059
5088
}
@@ -5912,7 +5941,7 @@ case kind: \
5912
5941
KINDCASE (16 , __int128 );
5913
5942
#endif
5914
5943
default :
5915
- caf_runtime_error (vecrefunknownkind , stat , NULL , 0 );
5944
+ caf_internal_error (vecrefunknownkind , stat , NULL , 0 );
5916
5945
return ;
5917
5946
}
5918
5947
#undef KINDCASE
@@ -5958,7 +5987,7 @@ case kind: \
5958
5987
* a dimension. */
5959
5988
break ;
5960
5989
default :
5961
- caf_runtime_error (unknownarrreftype , stat , NULL , 0 );
5990
+ caf_internal_error (unknownarrreftype , stat , NULL , 0 );
5962
5991
return ;
5963
5992
} // switch
5964
5993
dprint ("i = %zd, array_ref = %s, delta = %ld\n" ,
@@ -5972,7 +6001,7 @@ case kind: \
5972
6001
if (delta > 1 && dst_rank == 0 )
5973
6002
{
5974
6003
/* No, an array is required, but not provided. */
5975
- caf_runtime_error (extentoutofrange , stat , NULL , 0 );
6004
+ caf_internal_error (extentoutofrange , stat , NULL , 0 );
5976
6005
return ;
5977
6006
}
5978
6007
/* When dst is an array. */
@@ -5982,7 +6011,7 @@ case kind: \
5982
6011
* only by scalar data. */
5983
6012
if (src_cur_dim >= dst_rank && delta != 1 )
5984
6013
{
5985
- caf_runtime_error (rankoutofrange , stat , NULL , 0 );
6014
+ caf_internal_error (rankoutofrange , stat , NULL , 0 );
5986
6015
return ;
5987
6016
}
5988
6017
/* Do further checks, when the source is not scalar. */
@@ -5999,7 +6028,7 @@ case kind: \
5999
6028
/* Check whether dst is reallocatable. */
6000
6029
if (unlikely (!dst_reallocatable ))
6001
6030
{
6002
- caf_runtime_error (nonallocextentmismatch , stat ,
6031
+ caf_internal_error (nonallocextentmismatch , stat ,
6003
6032
NULL , 0 , delta ,
6004
6033
GFC_DESCRIPTOR_EXTENT (dst , src_cur_dim ));
6005
6034
return ;
@@ -6008,7 +6037,7 @@ case kind: \
6008
6037
* modified, which is not allowed. */
6009
6038
else if (!dst_reallocatable && extent_mismatch )
6010
6039
{
6011
- caf_runtime_error (extentoutofrange , stat , NULL , 0 );
6040
+ caf_internal_error (extentoutofrange , stat , NULL , 0 );
6012
6041
return ;
6013
6042
}
6014
6043
dprint ("extent(dst, %d): %zd != delta: %ld.\n" , src_cur_dim ,
@@ -6048,7 +6077,7 @@ case kind: \
6048
6077
KINDCASE (16 , __int128 );
6049
6078
#endif
6050
6079
default :
6051
- caf_runtime_error (vecrefunknownkind , stat , NULL , 0 );
6080
+ caf_internal_error (vecrefunknownkind , stat , NULL , 0 );
6052
6081
return ;
6053
6082
}
6054
6083
#undef KINDCASE
@@ -6078,7 +6107,7 @@ case kind: \
6078
6107
* can not occur here. */
6079
6108
case CAF_ARR_REF_OPEN_START :
6080
6109
default :
6081
- caf_runtime_error (unknownarrreftype , stat , NULL , 0 );
6110
+ caf_internal_error (unknownarrreftype , stat , NULL , 0 );
6082
6111
return ;
6083
6112
} // switch
6084
6113
dprint ("i = %zd, array_ref = %s, delta = %ld\n" ,
@@ -6092,7 +6121,7 @@ case kind: \
6092
6121
if (delta > 1 && dst_rank == 0 )
6093
6122
{
6094
6123
/* No, an array is required, but not provided. */
6095
- caf_runtime_error (extentoutofrange , stat , NULL , 0 );
6124
+ caf_internal_error (extentoutofrange , stat , NULL , 0 );
6096
6125
return ;
6097
6126
}
6098
6127
/* When dst is an array. */
@@ -6102,7 +6131,7 @@ case kind: \
6102
6131
* only by scalar data. */
6103
6132
if (src_cur_dim >= dst_rank && delta != 1 )
6104
6133
{
6105
- caf_runtime_error (rankoutofrange , stat , NULL , 0 );
6134
+ caf_internal_error (rankoutofrange , stat , NULL , 0 );
6106
6135
return ;
6107
6136
}
6108
6137
/* Do further checks, when the source is not scalar. */
@@ -6116,7 +6145,7 @@ case kind: \
6116
6145
* the extent does not match the needed one. */
6117
6146
if (realloc_dst || extent_mismatch )
6118
6147
{
6119
- caf_runtime_error (unabletoallocdst , stat );
6148
+ caf_internal_error (unabletoallocdst , stat , NULL , 0 );
6120
6149
return ;
6121
6150
}
6122
6151
}
@@ -6128,7 +6157,7 @@ case kind: \
6128
6157
in_array_ref = false;
6129
6158
break ;
6130
6159
default :
6131
- caf_runtime_error (unknownreftype , stat , NULL , 0 );
6160
+ caf_internal_error (unknownreftype , stat , NULL , 0 );
6132
6161
return ;
6133
6162
}
6134
6163
dst_size = riter -> item_size ;
@@ -6143,7 +6172,7 @@ case kind: \
6143
6172
6144
6173
if (realloc_dst )
6145
6174
{
6146
- caf_runtime_error (unabletoallocdst , stat );
6175
+ caf_internal_error (unabletoallocdst , stat , NULL , 0 );
6147
6176
return ;
6148
6177
}
6149
6178
@@ -6178,7 +6207,7 @@ case kind: \
6178
6207
temp_src .base .base_addr = malloc (cap );
6179
6208
if (temp_src .base .base_addr == NULL )
6180
6209
{
6181
- caf_runtime_error (cannotallocdst , stat , NULL , cap );
6210
+ caf_internal_error (cannotallocdst , stat , NULL , cap );
6182
6211
return ;
6183
6212
}
6184
6213
}
0 commit comments