@@ -892,86 +892,101 @@ bool IONAME(InputInteger)(Cookie cookie, std::int64_t &n, int kind) {
892
892
return false ;
893
893
}
894
894
895
- bool IONAME (OutputReal32)(Cookie cookie, float x) {
895
+ template <int PREC, typename REAL>
896
+ static bool OutputReal (Cookie cookie, REAL x) {
896
897
IoStatementState &io{*cookie};
897
898
if (!io.get_if <OutputStatementState>()) {
898
899
io.GetIoErrorHandler ().Crash (
899
- " OutputReal32 () called for a non-output I/O statement" );
900
+ " OutputReal () called for a non-output I/O statement" );
900
901
return false ;
901
902
}
902
903
if (auto edit{io.GetNextDataEdit ()}) {
903
- return RealOutputEditing<24 >{io, x}.Edit (*edit);
904
+ return RealOutputEditing<PREC >{io, x}.Edit (*edit);
904
905
}
905
906
return false ;
906
907
}
907
908
908
- bool IONAME (InputReal32)(Cookie cookie, float &x) {
909
- IoStatementState &io{*cookie};
910
- if (!io.get_if <InputStatementState>()) {
911
- io.GetIoErrorHandler ().Crash (
912
- " InputReal32() called for a non-input I/O statement" );
913
- return false ;
914
- }
915
- if (auto edit{io.GetNextDataEdit ()}) {
916
- if (edit->descriptor == DataEdit::ListDirectedNullValue) {
917
- return true ;
918
- }
919
- return EditRealInput<24 >(io, *edit, reinterpret_cast <void *>(&x));
920
- }
921
- return false ;
909
+ bool IONAME (OutputReal32)(Cookie cookie, float x) {
910
+ return OutputReal<24 , float >(cookie, x);
922
911
}
923
912
924
913
bool IONAME (OutputReal64)(Cookie cookie, double x) {
925
- IoStatementState &io{*cookie};
926
- if (!io.get_if <OutputStatementState>()) {
927
- io.GetIoErrorHandler ().Crash (
928
- " OutputReal64() called for a non-output I/O statement" );
929
- return false ;
930
- }
931
- if (auto edit{io.GetNextDataEdit ()}) {
932
- return RealOutputEditing<53 >{io, x}.Edit (*edit);
933
- }
934
- return false ;
914
+ return OutputReal<53 , double >(cookie, x);
935
915
}
936
916
937
- bool IONAME (InputReal64)(Cookie cookie, double &x) {
917
+ template <int PREC, typename REAL>
918
+ static bool InputReal (Cookie cookie, REAL &x) {
938
919
IoStatementState &io{*cookie};
939
920
if (!io.get_if <InputStatementState>()) {
940
921
io.GetIoErrorHandler ().Crash (
941
- " InputReal64 () called for a non-input I/O statement" );
922
+ " InputReal () called for a non-input I/O statement" );
942
923
return false ;
943
924
}
944
925
if (auto edit{io.GetNextDataEdit ()}) {
945
926
if (edit->descriptor == DataEdit::ListDirectedNullValue) {
946
927
return true ;
947
928
}
948
- return EditRealInput<53 >(io, *edit, reinterpret_cast <void *>(&x));
929
+ return EditRealInput<PREC >(io, *edit, reinterpret_cast <void *>(&x));
949
930
}
950
931
return false ;
951
932
}
952
933
953
- bool IONAME (OutputComplex32)(Cookie cookie, float r, float z) {
934
+ bool IONAME (InputReal32)(Cookie cookie, float &x) {
935
+ return InputReal<24 , float >(cookie, x);
936
+ }
937
+
938
+ bool IONAME (InputReal64)(Cookie cookie, double &x) {
939
+ return InputReal<53 , double >(cookie, x);
940
+ }
941
+
942
+ template <int PREC, typename REAL>
943
+ static bool OutputComplex (Cookie cookie, REAL r, REAL z) {
954
944
IoStatementState &io{*cookie};
955
945
if (io.get_if <ListDirectedStatementState<Direction::Output>>()) {
956
946
DataEdit real, imaginary;
957
947
real.descriptor = DataEdit::ListDirectedRealPart;
958
948
imaginary.descriptor = DataEdit::ListDirectedImaginaryPart;
959
- return RealOutputEditing<24 >{io, r}.Edit (real) &&
960
- RealOutputEditing<24 >{io, z}.Edit (imaginary);
949
+ return RealOutputEditing<PREC >{io, r}.Edit (real) &&
950
+ RealOutputEditing<PREC >{io, z}.Edit (imaginary);
961
951
}
962
- return IONAME (OutputReal32)(cookie, r) && IONAME (OutputReal32)(cookie, z);
952
+ return OutputReal<PREC, REAL>(cookie, r) && OutputReal<PREC, REAL>(cookie, z);
953
+ }
954
+
955
+ bool IONAME (OutputComplex32)(Cookie cookie, float r, float z) {
956
+ return OutputComplex<24 , float >(cookie, r, z);
963
957
}
964
958
965
959
bool IONAME (OutputComplex64)(Cookie cookie, double r, double z) {
960
+ return OutputComplex<53 , double >(cookie, r, z);
961
+ }
962
+
963
+ template <int PREC, typename REAL>
964
+ static bool InputComplex (Cookie cookie, REAL x[2 ]) {
966
965
IoStatementState &io{*cookie};
967
- if (io.get_if <ListDirectedStatementState<Direction::Output>>()) {
968
- DataEdit real, imaginary;
969
- real.descriptor = DataEdit::ListDirectedRealPart;
970
- imaginary.descriptor = DataEdit::ListDirectedImaginaryPart;
971
- return RealOutputEditing<53 >{io, r}.Edit (real) &&
972
- RealOutputEditing<53 >{io, z}.Edit (imaginary);
966
+ if (!io.get_if <InputStatementState>()) {
967
+ io.GetIoErrorHandler ().Crash (
968
+ " InputComplex() called for a non-input I/O statement" );
969
+ return false ;
970
+ }
971
+ for (int j{0 }; j < 2 ; ++j) {
972
+ if (auto edit{io.GetNextDataEdit ()}) {
973
+ if (edit->descriptor == DataEdit::ListDirectedNullValue) {
974
+ return true ;
975
+ }
976
+ if (!EditRealInput<PREC>(io, *edit, reinterpret_cast <void *>(&x[j]))) {
977
+ return false ;
978
+ }
979
+ }
973
980
}
974
- return IONAME (OutputReal64)(cookie, r) && IONAME (OutputReal64)(cookie, z);
981
+ return true ;
982
+ }
983
+
984
+ bool IONAME (InputComplex32)(Cookie cookie, float x[2 ]) {
985
+ return InputComplex<24 , float >(cookie, x);
986
+ }
987
+
988
+ bool IONAME (InputComplex64)(Cookie cookie, double x[2 ]) {
989
+ return InputComplex<53 , double >(cookie, x);
975
990
}
976
991
977
992
bool IONAME (OutputAscii)(Cookie cookie, const char *x, std::size_t length) {
0 commit comments