forked from nmfs-ost/ss3-source-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SS_write_ssnew.tpl
2689 lines (2549 loc) · 122 KB
/
SS_write_ssnew.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// SS_Label_file #18. **SS_write_ssnew.tpl**
// SS_Label_file # * <u>write_nudata()</u> // produces *starter.ss_new*, *forecast.ss_new*, *data_echo.ss_new*, *data_expval.ss*, bootstraps
// SS_Label_file # * <u>write_nucontrol()</u> // produces *control.ss_new*
// SS_Label_file #
//********************************************************************
/* SS_Label_FUNCTION 38 write_nudata */
FUNCTION void write_nudata()
{
// code for multinomial distribution developed by Ian Stewart, Oct 2005
dvector temp_mult(1, 50000);
dvector temp_probs(1, nlen_bin2);
int compindex = 0;
dvector temp_probs2(1, n_abins2);
int Nudat = 0;
int Nsamp_DM = 0;
// create bootstrap data files; except first file just replicates the input and second is the estimate without error
if (irand_seed < 0)
irand_seed = long(time(&start));
random_number_generator radm(irand_seed);
for (i = 1; i <= 1234; i++)
{
temp = randn(radm);
}
for (Nudat = 1; Nudat <= N_nudata; Nudat++)
{
if (Nudat == 1)
{
anystring = ssnew_pathname + "data_echo.ss_new";
report1.open(anystring);
report1 << version_info(1) << version_info(2) << version_info(3) << endl
<< version_info2 << endl
<< "#_Start_time: " << ctime(&start);
report1 << "#_echo_input_data" << endl;
report1 << Data_Comments << endl;
}
else if (Nudat == 2)
{
anystring = ssnew_pathname + "data_expval.ss";
report1.open(anystring);
report1 << version_info(1) << version_info(2) << version_info(3) << endl
<< version_info2 << endl
<< "#_Start_time: " << ctime(&start);
report1 << "#_expected_values" << endl;
report1 << Data_Comments << endl;
}
else
{
anystring = " ";
sprintf(anystring, "%d", Nudat - 2);
if ((Nudat - 2) < 10)
{
anystring2 = ssnew_pathname + "data_boot_00" + anystring + ".ss";
}
else if ((Nudat - 2) < 100)
{
anystring2 = ssnew_pathname + "data_boot_0" + anystring + ".ss";
}
else
{
anystring2 = ssnew_pathname + "data_boot_" + anystring + ".ss";
}
report1.open(anystring2);
report1 << version_info(1) << version_info(2) << version_info(3) << endl
<< version_info2 << endl
<< "#_Start_time: " << ctime(&start);
report1 << "#_bootdata:_" << Nudat << endl;
report1 << Data_Comments << endl;
report1 << "#_bootstrap file: " << Nudat - 2 << " irand_seed: " << irand_seed << " first rand#: " << randn(radm) << endl;
}
report1 << version_info(1) << version_info(2) << version_info(3) << endl;
report1 << styr << " #_StartYr" << endl;
report1 << endyr << " #_EndYr" << endl;
report1 << nseas << " #_Nseas" << endl;
report1 << 12. * seasdur << " #_months/season" << endl;
report1 << N_subseas << " #_Nsubseasons (even number, minimum is 2)" << endl;
report1 << spawn_month << " #_spawn_month" << endl;
report1 << gender_rd << " #_Ngenders: 1, 2, -1 (use -1 for 1 sex setup with SSB multiplied by female_frac parameter)" << endl;
report1 << nages << " #_Nages=accumulator age, first age is always age 0" << endl;
report1 << pop << " #_Nareas" << endl;
report1 << Nfleet << " #_Nfleets (including surveys)" << endl;
report1 << "#_fleet_type: 1=catch fleet; 2=bycatch only fleet; 3=survey; 4=predator(M2) " << endl;
report1 << "#_sample_timing: -1 for fishing fleet to use season-long catch-at-age for observations, or 1 to use observation month; (always 1 for surveys)" << endl;
report1 << "#_fleet_area: area the fleet/survey operates in " << endl;
report1 << "#_units of catch: 1=bio; 2=num (ignored for surveys; their units read later)" << endl;
report1 << "#_catch_mult: 0=no; 1=yes" << endl;
report1 << "#_rows are fleets" << endl
<< "#_fleet_type fishery_timing area catch_units need_catch_mult fleetname" << endl;
for (f = 1; f <= Nfleet; f++)
{
report1 << fleet_setup(f) << " " << fleetname(f) << " # " << f << endl;
}
report1 << "#Bycatch_fleet_input_goes_next" << endl;
report1 << "#a: fleet index" << endl;
report1 << "#b: 1=include dead bycatch in total dead catch for F0.1 and MSY optimizations and forecast ABC; 2=omit from total catch for these purposes (but still include the mortality)" << endl;
report1 << "#c: 1=Fmult scales with other fleets; 2=bycatch F constant at input value; 3=bycatch F from range of years" << endl;
report1 << "#d: F or first year of range" << endl;
report1 << "#e: last year of range" << endl;
report1 << "#f: not used" << endl;
report1 << "# a b c d e f " << endl;
for (f = 1; f <= Nfleet; f++)
{
if (fleet_type(f) == 2)
report1 << bycatch_setup(f) << " # " << fleetname(f) << endl;
}
if (Nudat == 1) // report back the input data
{
report1 << "#_Catch data: yr, seas, fleet, catch, catch_se" << endl;
report1 << "#_catch_se: standard error of log(catch)" << endl;
report1 << "#_NOTE: catch data is ignored for survey fleets" << endl;
k = 0;
for (f = 1; f <= Nfleet; f++)
{
if (fleet_type(f) <= 2)
{
for (y = styr - 1; y <= endyr; y++)
{
for (s = 1; s <= nseas; s++)
{
k++;
t = styr + (y - styr) * nseas + s - 1;
if (y == styr - 1)
{
g = -999;
}
else
{
g = y;
}
report1 << g << " " << s << " " << f << " " << catch_ret_obs(f, t) << " " << catch_se(t, f) << endl;
}
}
}
}
report1 << "-9999 0 0 0 0" << endl
<< "#" << endl;
report1 << " #_CPUE_and_surveyabundance_observations" << endl;
report1 << "#_Units: 0=numbers; 1=biomass; 2=F; 30=spawnbio; 31=recdev; 32=spawnbio*recdev; 33=recruitment; 34=depletion(&see Qsetup); 35=parm_dev(&see Qsetup)" << endl;
report1 << "#_Errtype: -1=normal; 0=lognormal; >0=T" << endl;
report1 << "#_SD_Report: 0=no sdreport; 1=enable sdreport" << endl;
report1 << "#_Fleet Units Errtype SD_Report" << endl;
for (f = 1; f <= Nfleet; f++)
report1 << f << " " << Svy_units(f) << " " << Svy_errtype(f) << " " << Svy_sdreport(f) << " # " << fleetname(f) << endl;
report1 << "#_yr month fleet obs stderr" << endl;
if (Svy_N > 0)
for (f = 1; f <= Nfleet; f++)
for (i = 1; i <= Svy_N_fleet(f); i++)
{
t = Svy_time_t(f, i);
ALK_time = Svy_ALK_time(f, i);
report1 << Show_Time(t, 1) << " " << Svy_super(f, i) * data_time(ALK_time, f, 1) << " " << f * Svy_use(f, i) << " ";
report1 << Svy_obs(f, i) << " " << Svy_se_rd(f, i) << " #_ " << fleetname(f) << endl;
}
report1 << "-9999 1 1 1 1 # terminator for survey observations " << endl;
report1 << "#" << endl
<< Ndisc_fleets << " #_N_fleets_with_discard" << endl;
report1 << "#_discard_units (1=same_as_catchunits(bio/num); 2=fraction; 3=numbers)" << endl;
report1 << "#_discard_errtype: >0 for DF of T-dist(read CV below); 0 for normal with CV; -1 for normal with se; -2 for lognormal; -3 for trunc normal with CV" << endl;
report1 << "# note: only enter units and errtype for fleets with discard " << endl;
report1 << "# note: discard data is the total for an entire season, so input of month here must be to a month in that season" << endl;
report1 << "#_Fleet units errtype" << endl;
if (Ndisc_fleets > 0)
{
for (f = 1; f <= Nfleet; f++)
if (disc_units(f) > 0)
report1 << f << " " << disc_units(f) << " " << disc_errtype(f) << " # " << fleetname(f) << endl;
report1 << "#_yr month fleet obs stderr" << endl;
for (f = 1; f <= Nfleet; f++)
for (i = 1; i <= disc_N_fleet(f); i++)
{
ALK_time = disc_time_ALK(f, i);
report1 << Show_Time(disc_time_t(f, i), 1) << " " << yr_disc_super(f, i) * data_time(ALK_time, f, 1) << " " << f * yr_disc_use(f, i) << " ";
report1 << obs_disc(f, i) << " " << cv_disc(f, i) << " #_ " << fleetname(f) << endl;
}
}
else
{
report1 << "# ";
}
report1 << "-9999 0 0 0.0 0.0 # terminator for discard data " << endl;
report1 << "#" << endl
<< do_meanbodywt << " #_use meanbodysize_data (0/1)" << endl;
if (nobs_mnwt_rd == 0)
report1 << "#_COND_";
report1 << DF_bodywt << " #_DF_for_meanbodysize_T-distribution_like" << endl;
report1 << "# note: type=1 for mean length; type=2 for mean body weight " << endl;
report1 << "#_yr month fleet part type obs stderr" << endl;
if (nobs_mnwt > 0)
{
for (i = 1; i <= nobs_mnwt; i++)
{
f = abs(mnwtdata(3, i));
report1 << Show_Time(mnwtdata(1, i), 1) << " " << mnwtdata(2, i) << " " << mnwtdata(3, i) << " " << mnwtdata(4, i) << " " << mnwtdata(5, i) << " " << mnwtdata(6, i) << " " << mnwtdata(7, i) - var_adjust(3, f) << " #_ " << fleetname(f) << endl;
}
}
if (do_meanbodywt == 0)
report1 << "# ";
report1 << " -9999 0 0 0 0 0 0 # terminator for mean body size data " << endl;
report1 << "#" << endl
<< "# set up population length bin structure (note - irrelevant if not using size data and using empirical wtatage" << endl;
report1 << LenBin_option << " # length bin method: 1=use databins; 2=generate from binwidth,min,max below; 3=read vector" << endl;
if (LenBin_option == 1)
{
report1 << "# no additional input for option 1" << endl;
report1 << "# read binwidth, minsize, lastbin size for option 2" << endl;
report1 << "# read N poplen bins, then vector of bin lower boundaries, for option 3" << endl;
}
else if (LenBin_option == 2)
{
report1 << binwidth2 << " # binwidth for population size comp " << endl;
report1 << minLread << " # minimum size in the population (lower edge of first bin and size at age 0.00) " << endl;
report1 << maxLread << " # maximum size in the population (lower edge of last bin) " << endl;
}
else
{
report1 << nlength << " # number of population size bins " << endl;
report1 << len_bins << endl;
}
report1 << use_length_data << " # use length composition data (0/1)" << endl;
if (use_length_data > 0)
{
report1 << "#_mintailcomp: upper and lower distribution for females and males separately are accumulated until exceeding this level." << endl;
report1 << "#_addtocomp: after accumulation of tails; this value added to all bins" << endl;
report1 << "#_combM+F: males and females treated as combined gender below this bin number " << endl;
report1 << "#_compressbins: accumulate upper tail by this number of bins; acts simultaneous with mintailcomp; set=0 for no forced accumulation" << endl;
report1 << "#_Comp_Error: 0=multinomial, 1=dirichlet" << endl;
report1 << "#_ParmSelect: parm number for dirichlet" << endl;
report1 << "#_minsamplesize: minimum sample size; set to 1 to match 3.24, minimum value is 0.001" << endl;
report1 << "#" << endl;
report1 << "#_mintailcomp addtocomp combM+F CompressBins CompError ParmSelect minsamplesize" << endl;
for (f = 1; f <= Nfleet; f++)
{
report1 << min_tail_L(f) << " " << min_comp_L(f) << " " << CombGender_L(f) << " " << AccumBin_L(f) << " " << Comp_Err_L(f) << " " << Comp_Err_L2(f) << " " << min_sample_size_L(f) << " #_fleet:" << f << "_" << fleetname(f) << endl;
}
report1 << "# sex codes: 0=combined; 1=use female only; 2=use male only; 3=use both as joint sexxlength distribution" << endl;
report1 << "# partition codes: (0=combined; 1=discard; 2=retained" << endl;
report1 << nlen_bin << " #_N_LengthBins; then enter lower edge of each length bin" << endl
<< len_bins_dat << endl;
// report1<<nobsl_rd<<" #_N_Length_obs"<<endl;
report1 << "#_yr month fleet sex part Nsamp datavector(female-male)" << endl;
if (nobsl_rd > 0)
{
for (i = 0; i <= nobsl_rd - 1; i++)
{
report1 << lendata[i] << endl;
}
}
report1 << -9999. << " ";
for (j = 2; j <= 6 + nlen_bin2; j++)
report1 << "0 ";
report1 << endl;
}
else
{
report1 << "# see manual for format of length composition data " << endl;
}
report1 << "#" << endl
<< n_abins << " #_N_age_bins" << endl;
if (n_abins > 0)
{
report1 << age_bins1 << endl;
}
else
{
report1 << "# ";
}
report1 << N_ageerr << " #_N_ageerror_definitions" << endl;
if (N_ageerr > 0)
report1 << age_err_rd << endl;
report1 << "#_mintailcomp: upper and lower distribution for females and males separately are accumulated until exceeding this level." << endl;
report1 << "#_addtocomp: after accumulation of tails; this value added to all bins" << endl;
report1 << "#_combM+F: males and females treated as combined gender below this bin number " << endl;
report1 << "#_compressbins: accumulate upper tail by this number of bins; acts simultaneous with mintailcomp; set=0 for no forced accumulation" << endl;
report1 << "#_Comp_Error: 0=multinomial, 1=dirichlet" << endl;
report1 << "#_ParmSelect: parm number for dirichlet" << endl;
report1 << "#_minsamplesize: minimum sample size; set to 1 to match 3.24, minimum value is 0.001" << endl;
report1 << "#" << endl;
report1 << "#_mintailcomp addtocomp combM+F CompressBins CompError ParmSelect minsamplesize" << endl;
for (f = 1; f <= Nfleet; f++)
{
if (n_abins <= 0)
report1 << "# ";
report1 << min_tail_A(f) << " " << min_comp_A(f) << " " << CombGender_A(f) << " " << AccumBin_A(f) << " " << Comp_Err_A(f) << " " << Comp_Err_A2(f) << " " << min_sample_size_A(f) << " #_fleet:" << f << "_" << fleetname(f) << endl;
}
if (n_abins <= 0)
report1 << "# ";
report1 << Lbin_method << " #_Lbin_method_for_Age_Data: 1=poplenbins; 2=datalenbins; 3=lengths" << endl;
report1 << "# sex codes: 0=combined; 1=use female only; 2=use male only; 3=use both as joint sexxlength distribution" << endl;
report1 << "# partition codes: (0=combined; 1=discard; 2=retained" << endl;
report1 << "#_yr month fleet sex part ageerr Lbin_lo Lbin_hi Nsamp datavector(female-male)" << endl;
if (nobsa_rd > 0)
{
for (i = 0; i <= nobsa_rd - 1; i++)
{
report1 << Age_Data[i] << endl;
}
}
f = exp_a_temp.size() + 8;
if (n_abins <= 0)
report1 << "# ";
report1 << "-9999 ";
for (i = 1; i <= f; i++)
report1 << " 0";
report1 << endl;
report1 << "#" << endl
<< use_meansizedata << " #_Use_MeanSize-at-Age_obs (0/1)" << endl;
if (use_meansizedata > 0)
{
report1 << "# sex codes: 0=combined; 1=use female only; 2=use male only; 3=use both as joint sexxlength distribution" << endl;
report1 << "# partition codes: (0=combined; 1=discard; 2=retained" << endl;
report1 << "# ageerr codes: positive means mean length-at-age; negative means mean bodywt_at_age" << endl;
report1 << "#_yr month fleet sex part ageerr ignore datavector(female-male)" << endl;
report1 << "# samplesize(female-male)" << endl;
if (nobs_ms_rd > 0)
{
if (finish_starter == 999)
{
for (i = 1; i <= nobs_ms_rd; i++)
{
report1 << sizeAge_Data[i] << endl;
}
}
else
{
for (i = 0; i <= nobs_ms_rd - 1; i++)
{
report1 << sizeAge_Data[i] << endl;
}
}
report1 << "-9999 ";
for (j = 1; j <= 6 + 2 * n_abins2; j++)
report1 << " 0";
report1 << endl;
}
}
report1 << "#" << endl
<< N_envvar << " #_N_environ_variables" << endl;
report1 << "# -2 in yr will subtract mean for that env_var; -1 will subtract mean and divide by stddev (e.g. Z-score)" << endl;
report1 << "#Yr Variable Value" << endl;
if (N_envvar > 0)
{
for (i = 0; i <= N_envdata - 1; i++)
report1 << env_temp[i] << endl;
report1 << "-9999 0 0" << endl;
}
report1 << "#" << endl
<< SzFreq_Nmeth << " # N sizefreq methods to read " << endl;
if (SzFreq_Nmeth > 0)
{
report1 << SzFreq_Nbins << " #Sizefreq N bins per method" << endl;
report1 << SzFreq_units << " #Sizetfreq units(1=bio/2=num) per method" << endl;
report1 << SzFreq_scale << " #Sizefreq scale(1=kg/2=lbs/3=cm/4=inches) per method" << endl;
report1 << SzFreq_mincomp << " #Sizefreq: add small constant to comps, per method " << endl;
report1 << SzFreq_nobs << " #Sizefreq N obs per method" << endl;
report1 << "#_Sizefreq bins " << endl
<< "#Note: negative value for first bin makes it accumulate all smaller fish vs. truncate small fish" << endl;
for (i = 1; i <= SzFreq_Nmeth; i++)
{
report1 << SzFreq_Omit_Small(i) * SzFreq_bins1(i, 1) << SzFreq_bins1(i)(2, SzFreq_Nbins(i)) << endl;
}
report1 << "#_method year month fleet gender partition SampleSize <data> " << endl
<< SzFreq_obs1 << endl;
}
// begin tagging data section #1 (observed data)
report1 << "# " << endl
<< Do_TG_rd << " # do tags (0/1/2); where 2 allows entry of TG_min_recap" << endl;
if (Do_TG_rd > 0)
{
// info on dimensions of tagging data
report1 << N_TG << " # N tag groups" << endl;
report1 << N_TG_recap << " # N recap events" << endl;
report1 << TG_mixperiod << " # TG_mixperiod ## (latency) is the first period in which logL is calculated for this tag group (0 = release period)" << endl;
report1 << TG_maxperiods << " # max periods ## to track recaptures (units=seasons), after which tags are still read into this accumulator period" << endl;
if (Do_TG_rd == 2)
{
report1 << TG_min_recap << " # TG_min_recap ## tag group's N recaps >=mixperiod must be >= min_recap to include tag group in logL)" << endl;
}
else
{
report1 << "# COND: TG_min_recap ## use Do_TG=2 to invoke reading TG_min_recap after TG_maxperiods" << endl;
}
// tag releases
report1 << "# Release data for each tag group. Tags are considered to be released at the beginning of a season (period)" << endl;
report1 << "#<TG> area yr season <tfill> gender age Nrelease (note that the TG and tfill values are placeholders and are replaced by program generated values)" << endl;
report1 << TG_release << endl;
// tag recaptures
report1 << "#_TAG Yr Season Fleet Nrecap" << endl;
for (j = 1; j <= N_TG_recap; j++)
{
// fill in first 4 columns:
for (k = 1; k <= 5; k++)
report1 << TG_recap_data(j, k) << " ";
report1 << endl;
}
}
// end tagging data section #1 (observed data)
report1 << "#" << endl
<< Do_Morphcomp << " # morphcomp data(0/1) " << endl;
if (Do_Morphcomp > 0)
{
report1 << Morphcomp_nobs_rd << " # Nobs" << endl;
report1 << Morphcomp_nmorph << " # Nmorphs" << endl;
report1 << Morphcomp_mincomp << " # add_to_comp" << endl;
report1 << "# yr, month, fleet, null, Nsamp, datavector_by_Nmorphs" << endl;
for (i = 1; i <= Morphcomp_nobs_rd; i++)
{
report1 << Morphcomp_obs_rd << endl;
}
}
else
{
report1 << "# Nobs, Nmorphs, mincomp" << endl;
report1 << "# yr, seas, type, partition, Nsamp, datavector_by_Nmorphs" << endl;
}
report1 << "#" << endl
<< Do_SelexData << " # Do dataread for selectivity priors(0/1)" << endl;
report1 << "# Yr, Seas, Fleet, Age/Size, Bin, selex_prior, prior_sd" << endl;
report1 << "# feature not yet implemented" << endl;
report1 << "#" << endl
<< "999" << endl
<< endl;
}
else if (Nudat == 2) // report expected value with no added error
{
report1 << "#_catch:_columns_are_year,season,fleet,catch,catch_se" << endl;
report1 << "#_Catch data: yr, seas, fleet, catch, catch_se" << endl;
k = 0;
for (f = 1; f <= Nfleet; f++)
{
if (fleet_type(f) <= 2)
{
for (y = styr - 1; y <= endyr; y++)
{
for (s = 1; s <= nseas; s++)
{
k++;
t = styr + (y - styr) * nseas + s - 1;
if (y == styr - 1)
{
report1 << -999 << " " << s << " " << f << " " << est_equ_catch(s, f) << " " << catch_se(t, f) << endl;
}
else
{
report1 << y << " " << s << " " << f << " ";
if (fleet_type(f) == 2 && catch_ret_obs(f, t) > 0.0)
{
report1 << 0.1 << " " << catch_se(t, f) << endl; // for bycatch only fleet
}
else if (catchunits(f) == 1)
{
report1 << catch_fleet(t, f, 3) << " " << catch_se(t, f) << endl;
}
else
{
report1 << catch_fleet(t, f, 6) << " " << catch_se(t, f) << endl;
}
}
}
}
}
}
report1 << "-9999 0 0 0 0" << endl
<< "#" << endl;
report1 << "#" << endl
<< " #_CPUE_and_surveyabundance_observations" << endl;
report1 << "#_Units: 0=numbers; 1=biomass; 2=F; 30=spawnbio; 31=recdev; 32=spawnbio*recdev; 33=recruitment; 34=depletion(&see Qsetup); 35=parm_dev(&see Qsetup)" << endl;
report1 << "#_Errtype: -1=normal; 0=lognormal; >0=T" << endl;
report1 << "#_SD_Report: 0=no sdreport; 1=enable sdreport" << endl;
report1 << "#_Fleet Units Errtype SD_Report" << endl;
for (f = 1; f <= Nfleet; f++)
report1 << f << " " << Svy_units(f) << " " << Svy_errtype(f) << " " << Svy_sdreport(f) << " # " << fleetname(f) << endl;
report1 << "#_year month index obs err" << endl;
if (Svy_N > 0)
for (f = 1; f <= Nfleet; f++)
for (i = 1; i <= Svy_N_fleet(f); i++)
{
t = Svy_time_t(f, i);
ALK_time = Svy_ALK_time(f, i);
report1 << Show_Time(t, 1) << " " << Svy_super(f, i) * data_time(ALK_time, f, 1) << " " << f * Svy_use(f, i) << " ";
if (Svy_errtype(f) >= 0) // lognormal
{
report1 << mfexp(Svy_est(f, i));
}
else if (Svy_errtype(f) == -1) // normal
{
report1 << Svy_est(f, i);
}
report1 << " " << Svy_se_rd(f, i) << " #_orig_obs: " << Svy_obs(f, i) << " " << fleetname(f) << endl;
}
report1 << "-9999 1 1 1 1 # terminator for survey observations " << endl;
report1 << "#" << endl
<< Ndisc_fleets << " #_N_fleets_with_discard" << endl;
report1 << "#_discard_units (1=same_as_catchunits(bio/num); 2=fraction; 3=numbers)" << endl;
report1 << "#_discard_errtype: >0 for DF of T-dist(read CV below); 0 for normal with CV; -1 for normal with se; -2 for lognormal; -3 for trunc normal with CV" << endl;
report1 << "# note: only enter units and errtype for fleets with discard " << endl;
report1 << "# note: discard data is the total for an entire season, so input of month here must be to a month in that season" << endl;
report1 << "#_Fleet units errtype" << endl;
if (Ndisc_fleets > 0)
{
for (f = 1; f <= Nfleet; f++)
if (disc_units(f) > 0)
report1 << f << " " << disc_units(f) << " " << disc_errtype(f) << " # " << fleetname(f) << endl;
report1 << "#_yr month fleet obs stderr" << endl;
for (f = 1; f <= Nfleet; f++)
if (disc_N_fleet(f) > 0)
for (i = 1; i <= disc_N_fleet(f); i++)
{
ALK_time = disc_time_ALK(f, i);
report1 << Show_Time(disc_time_t(f, i), 1) << " " << yr_disc_super(f, i) * data_time(ALK_time, f, 1) << " " << f * yr_disc_use(f, i) << " ";
{
report1 << exp_disc(f, i);
}
report1 << " " << cv_disc(f, i) << " #_orig_obs: " << obs_disc(f, i) << " #_ " << fleetname(f) << endl;
}
}
else
{
report1 << "# ";
}
report1 << "-9999 0 0 0.0 0.0 # terminator for discard data " << endl;
report1 << "#" << endl
<< do_meanbodywt << " #_use meanbodysize_data (0/1)" << endl;
if (nobs_mnwt_rd == 0)
report1 << "#_COND_";
report1 << DF_bodywt << " #_DF_for_meanbodysize_T-distribution_like" << endl;
report1 << "# note: type=1 for mean length; type=2 for mean body weight " << endl;
report1 << "#_yr month fleet part type obs stderr" << endl;
if (nobs_mnwt > 0)
{
for (i = 1; i <= nobs_mnwt; i++)
{
f = abs(mnwtdata(3, i));
report1 << Show_Time(mnwtdata(1, i), 1) << " " << mnwtdata(2, i) << " " << mnwtdata(3, i) << " " << mnwtdata(4, i) << " " << mnwtdata(5, i) << " " << exp_mnwt(i) << " " << mnwtdata(7, i) - var_adjust(3, f) << " #_orig_obs: " << mnwtdata(6, i) << " #_ " << fleetname(f) << endl;
}
}
if (do_meanbodywt == 0)
report1 << "# ";
report1 << " -9999 0 0 0 0 0 0 # terminator for mean body size data " << endl;
report1 << "#" << endl
<< "# set up population length bin structure (note - irrelevant if not using size data and using empirical wtatage" << endl;
report1 << LenBin_option << " # length bin method: 1=use databins; 2=generate from binwidth,min,max below; 3=read vector" << endl;
if (LenBin_option == 1)
{
report1 << "# no additional input for option 1" << endl;
report1 << "# read binwidth, minsize, lastbin size for option 2" << endl;
report1 << "# read N poplen bins, then vector of bin lower boundaries, for option 3" << endl;
}
else if (LenBin_option == 2)
{
report1 << binwidth2 << " # binwidth for population size comp " << endl;
report1 << minLread << " # minimum size in the population (lower edge of first bin and size at age 0.00) " << endl;
report1 << maxLread << " # maximum size in the population (lower edge of last bin) " << endl;
}
else
{
report1 << nlength << " # number of population size bins " << endl;
report1 << len_bins << endl;
}
report1 << use_length_data << " # use length composition data (0/1)" << endl;
if (use_length_data > 0)
{
report1 << "#_mintailcomp: upper and lower distribution for females and males separately are accumulated until exceeding this level." << endl;
report1 << "#_addtocomp: after accumulation of tails; this value added to all bins" << endl;
report1 << "#_combM+F: males and females treated as combined gender below this bin number " << endl;
report1 << "#_compressbins: accumulate upper tail by this number of bins; acts simultaneous with mintailcomp; set=0 for no forced accumulation" << endl;
report1 << "#_Comp_Error: 0=multinomial, 1=dirichlet" << endl;
report1 << "#_ParmSelect: parm number for dirichlet" << endl;
report1 << "#_minsamplesize: minimum sample size; set to 1 to match 3.24, minimum value is 0.001" << endl;
report1 << "#" << endl;
report1 << "#_mintailcomp addtocomp combM+F CompressBins CompError ParmSelect minsamplesize" << endl;
for (f = 1; f <= Nfleet; f++)
{
report1 << min_tail_L(f) << " " << min_comp_L(f) << " " << CombGender_L(f) << " " << AccumBin_L(f) << " " << Comp_Err_L(f) << " " << Comp_Err_L2(f) << " " << min_sample_size_L(f) << " #_fleet:" << f << "_" << fleetname(f) << endl;
}
report1 << "# sex codes: 0=combined; 1=use female only; 2=use male only; 3=use both as joint sexxlength distribution" << endl;
report1 << "# partition codes: (0=combined; 1=discard; 2=retained" << endl;
report1 << nlen_bin << " #_N_LengthBins" << endl
<< len_bins_dat << endl;
// report1<<sum(Nobs_l)<<" #_N_Length_obs"<<endl;
report1 << "#_yr month fleet sex part Nsamp datavector(female-male)" << endl;
for (f = 1; f <= Nfleet; f++)
{
if (Nobs_l(f) > 0)
{
for (i = 1; i <= Nobs_l(f); i++)
{
k = 1000;
if (nsamp_l(f, i) < k)
k = nsamp_l(f, i);
exp_l_temp_dat = nsamp_l(f, i) * value(exp_l(f, i) / sum(exp_l(f, i)));
report1 << header_l_rd(f, i)(1, 3) << " " << gen_l(f, i) << " " << mkt_l(f, i) << " " << nsamp_l(f, i) << " " << exp_l_temp_dat << endl;
}
}
}
report1 << -9999. << " ";
for (j = 2; j <= 6 + nlen_bin2; j++)
report1 << "0 ";
report1 << endl;
}
else
{
report1 << "# see manual for format of length composition data " << endl;
}
report1 << "#" << endl
<< n_abins << " #_N_age_bins" << endl;
if (n_abins > 0)
{
report1 << age_bins1 << endl;
}
else
{
report1 << "# ";
}
report1 << N_ageerr << " #_N_ageerror_definitions" << endl;
if (N_ageerr > 0)
report1 << age_err_rd << endl;
report1 << "#_mintailcomp: upper and lower distribution for females and males separately are accumulated until exceeding this level." << endl;
report1 << "#_addtocomp: after accumulation of tails; this value added to all bins" << endl;
report1 << "#_combM+F: males and females treated as combined gender below this bin number " << endl;
report1 << "#_compressbins: accumulate upper tail by this number of bins; acts simultaneous with mintailcomp; set=0 for no forced accumulation" << endl;
report1 << "#_Comp_Error: 0=multinomial, 1=dirichlet" << endl;
report1 << "#_ParmSelect: parm number for dirichlet" << endl;
report1 << "#_minsamplesize: minimum sample size; set to 1 to match 3.24, minimum value is 0.001" << endl;
report1 << "#" << endl;
report1 << "#_mintailcomp addtocomp combM+F CompressBins CompError ParmSelect minsamplesize" << endl;
for (f = 1; f <= Nfleet; f++)
{
if (n_abins <= 0)
report1 << "# ";
report1 << min_tail_A(f) << " " << min_comp_A(f) << " " << CombGender_A(f) << " " << AccumBin_A(f) << " " << Comp_Err_A(f) << " " << Comp_Err_A2(f) << " " << min_sample_size_A(f) << " #_fleet:" << f << "_" << fleetname(f) << endl;
}
if (n_abins <= 0)
report1 << "# ";
report1 << Lbin_method << " #_Lbin_method_for_Age_Data: 1=poplenbins; 2=datalenbins; 3=lengths" << endl;
report1 << "# sex codes: 0=combined; 1=use female only; 2=use male only; 3=use both as joint sexxlength distribution" << endl;
report1 << "# partition codes: (0=combined; 1=discard; 2=retained" << endl;
report1 << "#_yr month fleet sex part ageerr Lbin_lo Lbin_hi Nsamp datavector(female-male)" << endl;
if (Nobs_a_tot > 0)
for (f = 1; f <= Nfleet; f++)
{
if (Nobs_a(f) >= 1)
{
for (i = 1; i <= Nobs_a(f); i++)
{
k = 1000;
if (nsamp_a(f, i) < k)
k = nsamp_a(f, i); // note that nsamp is adjusted by var_adjust, so var_adjust
// should be reset to 1.0 in control files that read the nudata.dat files
exp_a_temp = nsamp_a(f, i) * value(exp_a(f, i) / sum(exp_a(f, i)));
report1 << header_a(f, i)(1) << " " << header_a_rd(f, i)(2, 3) << " " << header_a(f, i)(4, 8) << " " << nsamp_a(f, i) << " " << exp_a_temp << endl;
}
}
}
f = exp_a_temp.size() + 8;
if (n_abins <= 0)
report1 << "# ";
report1 << "-9999 ";
for (i = 1; i <= f; i++)
report1 << " 0";
report1 << endl;
report1 << "#" << endl
<< use_meansizedata << " #_Use_MeanSize-at-Age_obs (0/1)" << endl;
if (use_meansizedata > 0)
{
report1 << "# sex codes: 0=combined; 1=use female only; 2=use male only; 3=use both as joint sexxlength distribution" << endl;
report1 << "# partition codes: 0=combined; 1=discard; 2=retained" << endl;
report1 << "# ageerr codes: positive means mean length-at-age; negative means mean bodywt_at_age" << endl;
report1 << "#_yr month fleet sex part ageerr ignore datavector(female-male)" << endl;
report1 << "# samplesize(female-male)" << endl;
for (f = 1; f <= Nfleet; f++)
{
if (Nobs_ms(f) > 0)
{
for (i = 1; i <= Nobs_ms(f); i++)
{
report1 << header_ms(f, i)(1) << " " << header_ms_rd(f, i)(2, 3) << " " << header_ms(f, i)(4, 7);
for (a = 1; a <= n_abins2; a++)
{
report1 << " ";
temp = exp_ms(f, i, a);
if (temp <= 0.)
{
temp = 0.0001;
}
report1 << temp;
}
report1 << endl
<< obs_ms_n_read(f, i) << endl;
}
}
}
report1 << "-9999 ";
for (j = 1; j <= 6 + n_abins2; j++)
report1 << " 0";
report1 << endl;
for (j = 1; j <= n_abins2; j++)
report1 << " 0";
report1 << endl;
}
report1 << "#" << endl
<< N_envvar << " #_N_environ_variables" << endl;
report1 << "# -2 in yr will subtract mean for that env_var; -1 will subtract mean and divide by stddev (e.g. Z-score)" << endl;
report1 << "#Yr Variable Value" << endl;
if (N_envvar > 0)
{
for (i = 0; i <= N_envdata - 1; i++)
report1 << env_temp[i] << endl;
report1 << "-9999 0 0" << endl;
}
report1 << "#" << endl
<< SzFreq_Nmeth << " # N sizefreq methods to read " << endl;
if (SzFreq_Nmeth > 0)
{
report1 << SzFreq_Nbins << " #Sizefreq N bins per method" << endl;
report1 << SzFreq_units << " #Sizetfreq units(1=bio/2=num) per method" << endl;
report1 << SzFreq_scale << " #Sizefreq scale(1=kg/2=lbs/3=cm/4=inches) per method" << endl;
report1 << SzFreq_mincomp << " #Sizefreq: add small constant to comps, per method " << endl;
report1 << SzFreq_nobs << " #Sizefreq N obs per method" << endl;
report1 << "#_Sizefreq bins " << endl
<< "#_Note: negative value for first bin makes it accumulate all smaller fish vs. truncate small fish" << endl;
for (i = 1; i <= SzFreq_Nmeth; i++)
{
report1 << SzFreq_Omit_Small(i) * SzFreq_bins1(i, 1) << SzFreq_bins1(i)(2, SzFreq_Nbins(i)) << endl;
}
report1 << "#_method yr month fleet sex partition SampleSize <data> " << endl;
for (iobs = 1; iobs <= SzFreq_totobs; iobs++)
{
report1 << SzFreq_obs1(iobs)(1, 7) << " " << SzFreq_exp(iobs) << endl;
}
}
// begin tagging data section #2 (expected values)
report1 << "#" << endl
<< Do_TG << " # do tags (0/1)" << endl;
if (Do_TG > 0)
{
// info on dimensions of tagging data
report1 << N_TG << " # N tag groups" << endl;
report1 << N_TG_recap << " # N recap events" << endl;
report1 << TG_mixperiod << " # mixing latency period: N periods to delay before comparing observed to expected recoveries (0 = release period)" << endl;
report1 << TG_maxperiods << " # max periods (seasons) to track recoveries, after which tags enter accumulator" << endl;
// tag releases
report1 << "# Release data for each tag group. Tags are considered to be released at the beginning of a season (period)" << endl;
report1 << "#<TG> area yr season <tfill> sex age Nrelease (note that the TG and tfill values are placeholders and are replaced by program generated values)" << endl;
report1 << TG_release << endl;
// tag recaptures
report1 << "#_Note: Expected values for tag recaptures are reported only for the same combinations of" << endl;
report1 << "# group, year, area, and fleet that had observed recaptures. " << endl;
report1 << "#_TAG Yr Season Fleet Nrecap" << endl;
for (j = 1; j <= N_TG_recap; j++)
{
// fill in first 4 columns:
for (k = 1; k <= 4; k++)
report1 << TG_recap_data(j, k) << " ";
// fill in 5th column with bootstrap values
TG = TG_recap_data(j, 1);
overdisp = TG_parm(2 * N_TG + TG);
t = styr + int((TG_recap_data(j, 2) - styr) * nseas + TG_recap_data(j, 3) - 1) - TG_release(TG, 5); // find elapsed time in terms of number of seasons
if (t > TG_maxperiods)
t = TG_maxperiods;
report1 << value(TG_recap_exp(TG, t, 0)) << " #_overdisp: " << value(overdisp) << endl;
}
}
// end tagging data section #2 (expected values)
report1 << "#" << endl
<< Do_Morphcomp << " # morphcomp data(0/1) " << endl;
if (Do_Morphcomp > 0)
{
report1 << "# note that raw data, not bootstrap are reported here " << endl;
report1 << Morphcomp_nobs << " # Nobs" << endl;
report1 << Morphcomp_nmorph << " # Nmorphs" << endl;
report1 << Morphcomp_mincomp << " # add_to_comp" << endl;
report1 << "# yr, month, fleet, null, Nsamp, datavector_by_Nmorphs" << endl;
for (i = 1; i <= Morphcomp_nobs; i++)
{
report1 << Morphcomp_obs(i)(1, 5) << " " << Morphcomp_exp(i) << endl;
}
}
else
{
report1 << "# Nobs, Nmorphs, mincomp" << endl;
report1 << "# yr, seas, type, partition, Nsamp, datavector_by_Nmorphs" << endl;
}
report1 << "#" << endl
<< Do_SelexData << " # Do dataread for selectivity priors(0/1)" << endl;
report1 << "# Yr, Seas, Fleet, Age/Size, Bin, selex_prior, prior_sd" << endl;
report1 << "# feature not yet implemented" << endl;
report1 << "#" << endl
<< "999" << endl
<< endl;
}
else // create bootstrap data
{
report1 << "#_catch_biomass(mtons):_columns_are_fisheries,year,season" << endl;
report1 << "#_catch:_columns_are_year,season,fleet,catch,catch_se" << endl;
report1 << "#_Catch data: yr, seas, fleet, catch, catch_se" << endl;
k = 0;
for (f = 1; f <= Nfleet; f++)
{
if (fleet_type(f) <= 2)
{
for (y = styr - 1; y <= endyr; y++)
{
for (s = 1; s <= nseas; s++)
{
k++;
t = styr + (y - styr) * nseas + s - 1;
if (y == styr - 1)
{
report1 << -999 << " " << s << " " << f << " "
<< est_equ_catch(s, f) * mfexp(randn(radm) * catch_se(styr - 1, f) - 0.5 * catch_se(styr - 1, f) * catch_se(styr - 1, f))
<< " " << catch_se(t, f) << endl;
}
else
{
report1 << y << " " << s << " " << f << " ";
if (fleet_type(f) == 2 && catch_ret_obs(f, t) > 0.0)
{
report1 << 0.1 << " " << catch_se(t, f) << endl; // for bycatch only fleet
}
else if (catchunits(f) == 1)
{
report1 << catch_fleet(t, f, 3) * mfexp(randn(radm) * catch_se(t, f) - 0.5 * catch_se(t, f) * catch_se(t, f))
<< " " << catch_se(t, f) << endl;
}
else
{
report1 << catch_fleet(t, f, 6) * mfexp(randn(radm) * catch_se(t, f) - 0.5 * catch_se(t, f) * catch_se(t, f))
<< " " << catch_se(t, f) << endl;
}
}
}
}
}
}
report1 << "-9999 0 0 0 0" << endl
<< "#" << endl;
report1 << " #_CPUE_and_surveyabundance_observations" << endl;
report1 << "#_Units: 0=numbers; 1=biomass; 2=F; 30=spawnbio; 31=recdev; 32=spawnbio*recdev; 33=recruitment; 34=depletion(&see Qsetup); 35=parm_dev(&see Qsetup)" << endl;
report1 << "#_Errtype: -1=normal; 0=lognormal; >0=T" << endl;
report1 << "#_SD_Report: 0=no sdreport; 1=enable sdreport" << endl;
report1 << "#_Fleet Units Errtype SD_Report" << endl;
for (f = 1; f <= Nfleet; f++)
report1 << f << " " << Svy_units(f) << " " << Svy_errtype(f) << " " << Svy_sdreport(f) << " # " << fleetname(f) << endl;
report1 << "#_year month index obs err" << endl;
if (Svy_N > 0)
for (f = 1; f <= Nfleet; f++)
for (i = 1; i <= Svy_N_fleet(f); i++)
{
t = Svy_time_t(f, i);
ALK_time = Svy_ALK_time(f, i);
double newobs = 0.0;
report1 << Show_Time(t, 1) << " " << Svy_super(f, i) * data_time(ALK_time, f, 1) << " " << f * Svy_use(f, i) << " ";
if (Svy_errtype(f) == -1) // normal error
{
newobs = value(Svy_est(f, i) + randn(radm) * Svy_se_use(f, i)); // uses Svy_se_use, not Svy_se_rd to include both effect of input var_adjust and extra_sd
}
if (Svy_errtype(f) == 0) // lognormal
{
newobs = value(mfexp(Svy_est(f, i) + randn(radm) * Svy_se_use(f, i))); // uses Svy_se_use, not Svy_se_rd to include both effect of input var_adjust and extra_sd
}
else if (Svy_errtype(f) > 0) // lognormal T_dist
{
temp = sqrt((Svy_errtype(f) + 1.) / Svy_errtype(f)); // where df=Svy_errtype(f)
newobs = value(mfexp(Svy_est(f, i) + randn(radm) * Svy_se_use(f, i) * temp)); // adjusts the sd by the df sample size
}
if (Svy_minval(f) >= 0.0 && Svy_errtype(f) != 0)
newobs = max(newobs, 0.5 * Svy_minval(f));
report1 << newobs << " " << Svy_se_rd(f, i) << " #_orig_obs: " << Svy_obs(f, i) << " " << fleetname(f) << endl;
}
report1 << "-9999 1 1 1 1 # terminator for survey observations " << endl;
report1 << "#" << endl
<< Ndisc_fleets << " #_N_fleets_with_discard" << endl;
report1 << "#_discard_units (1=same_as_catchunits(bio/num); 2=fraction; 3=numbers)" << endl;
report1 << "#_discard_errtype: >0 for DF of T-dist(read CV below); 0 for normal with CV; -1 for normal with se; -2 for lognormal; -3 for trunc normal with CV" << endl;
report1 << "# note: only enter units and errtype for fleets with discard " << endl;
report1 << "# note: discard data is the total for an entire season, so input of month here must be to a month in that season" << endl;
report1 << "#_Fleet units errtype" << endl;
if (Ndisc_fleets > 0)
{
for (f = 1; f <= Nfleet; f++)
if (disc_units(f) > 0)
report1 << f << " " << disc_units(f) << " " << disc_errtype(f) << " # " << fleetname(f) << endl;
report1 << "#_yr month fleet obs stderr" << endl;
for (f = 1; f <= Nfleet; f++)
for (i = 1; i <= disc_N_fleet(f); i++)
{
ALK_time = disc_time_ALK(f, i);
report1 << Show_Time(disc_time_t(f, i), 1) << " " << yr_disc_super(f, i) * data_time(ALK_time, f, 1) << " " << f * yr_disc_use(f, i) << " ";
if (disc_errtype(f) >= 1)
{
temp = exp_disc(f, i) + randn(radm) * sd_disc(f, i) * sqrt((disc_errtype(f) + 1.) / disc_errtype(f)) * exp_disc(f, i);
if (temp < 0.001)
temp = 0.001;
}
else if (disc_errtype(f) == 0)
{
temp = exp_disc(f, i) + randn(radm) * sd_disc(f, i);
if (temp < 0.001)
temp = 0.001;
}
else if (disc_errtype(f) == -1)
{
temp = exp_disc(f, i) + randn(radm) * sd_disc(f, i);
if (temp < 0.001)
temp = 0.001;
}
else if (disc_errtype(f) == -2)
{
temp = exp_disc(f, i) * mfexp(randn(radm) * sd_disc(f, i));
}
else if (disc_errtype(f) == -3)
{
temp = exp_disc(f, i) + randn(radm) * (sd_disc(f, i) / sqrt(cumd_norm((1 - exp_disc(f, i)) / sd_disc(f, i)) - cumd_norm((0 - exp_disc(f, i)) / sd_disc(f, i))));
if (temp < 0.001)
temp = 0.001;
}
if (disc_minval(f) >= 0.0)
temp = max(value(temp), 0.5 * disc_minval(f));
report1 << " " << temp << " " << cv_disc(f, i) << " #_orig_obs: " << obs_disc(f, i) << " #_ " << fleetname(f) << endl;
}
}
else
{
report1 << "# ";
}
report1 << "-9999 0 0 0.0 0.0 # terminator for discard data " << endl;
report1 << "#" << endl
<< do_meanbodywt << " #_use meanbodysize_data (0/1)" << endl;
if (do_meanbodywt == 0)
report1 << "#_COND_";
report1 << DF_bodywt << " #_DF_for_meanbodysize_T-distribution_like" << endl;
report1 << "# note: type=1 for mean length; type=2 for mean body weight " << endl;
report1 << "#_yr month fleet part type obs stderr" << endl;
// NOTE, the se stored in mnwtdata(7,i) was adjusted in prelim calc to include the input var_adjustment
// so var_adjust is subtracted here when the observation is written
if (nobs_mnwt > 0)
{
for (i = 1; i <= nobs_mnwt; i++)
{
temp = exp_mnwt(i) + randn(radm) * mnwtdata(7, i) * sqrt((DF_bodywt + 1.) / DF_bodywt) * exp_mnwt(i);
if (temp <= 0.0)
{
temp = 0.0001;
}
f = abs(mnwtdata(3, i));
report1 << Show_Time(mnwtdata(1, i), 1) << " " << mnwtdata(2, i) << " " << mnwtdata(3, i) << " " << mnwtdata(4, i) << " " << mnwtdata(5, i) << " " << temp << " " << mnwtdata(7, i) - var_adjust(3, f) << " #_orig_obs: " << mnwtdata(6, i) << " #_ " << fleetname(f) << endl;
}
}
if (do_meanbodywt == 0)