Update to command 'wrnodev':

Prevent crash if tran is not (yet) run.
Open output file only when data are available.
Enhanced comment and warning message.
This commit is contained in:
Holger Vogt 2023-09-28 10:05:31 +02:00
parent e449c894ce
commit 28b495318d
1 changed files with 13 additions and 5 deletions

View File

@ -18,6 +18,8 @@ void com_wric(wordlist* wl);
/* Print the current node status to a file with format
.ic V(node) = value
during a transient simulation which has been stopped,
by command 'stop' and which may continue by 'resume'.
*/
void
com_wric(wordlist* wl) {
@ -32,11 +34,6 @@ com_wric(wordlist* wl) {
else
file = "dot_ic_out.txt";
if ((fp = fopen(file, "w")) == NULL) {
perror(file);
return;
}
if (!ft_curckt) {
fprintf(cp_err, "Error: there aren't any circuits loaded.\n");
return;
@ -48,6 +45,17 @@ com_wric(wordlist* wl) {
ckt = ft_curckt->ci_ckt;
if (!ckt->CKTrhsOld) {
fprintf(stderr, "\nWarning: Command wrnodev is ignored!\n");
fprintf(stderr, " You need to execute stop ... tran ... resume\n\n");
return;
}
if ((fp = fopen(file, "w")) == NULL) {
perror(file);
return;
}
fprintf(fp, "* Intermediate Transient Solution\n");
fprintf(fp, "* Circuit: %s\n", ft_curckt->ci_name);
fprintf(fp, "* Recorded at simulation time: %g\n", ckt->CKTtime);