Taxsim as a libary routine

Traditionally Taxsim has read its input from in ASCII from standard in and written the results in ASCII to standard out. This has provided portability and ease of diagnostics. But sometimes it may be inconvenient or slow, so we are experimenting with a fast library interface. This eliminates the ASCII to binary and back conversions. This page documents how to use that version.

Note that the fortran code has no way to report errors other than to abend, as fortran i/o is incompatible with c or Python i/o. If this becomes a problem, we can perhaps address it with stop codes and global variables. I am certainly willing to work with anyone wishing to use Taxsim as a library routine - it isn't efficient to duplicate all the error checking of income.

Source for the library is normally distributed as taxsimdll.f

The library source code differs from the executable program in only 4 lines.The source code contains several references to "isexe" which needs to be set .false. in block data dllexe. Three other changes need to be made to taxsim.f to get taxsimdll.f: sed -e "s/program taxsim/subroutine taxsim/" taxsim.f \ | sed "s/c return/ return/" \ | sed "s@isexe/.true./@isexe/.false./@" >taxsimdll.f input and output are via Fortran common blocks. There is information about accessing common blocks from Python is at: https://numpy.org/doc/stable/f2py/python-usage.html#common-blocks The input vector is common block "xcom" with 55 doublewords (sorry it is numbered from 1): 1 taxsimid 2 year 3 state 4 mstat 5 page 6 sage 7 depx 8 dep13 9 dep17 10 dep18 11 pwages 12 swages 13 dividends 14 intrec 15 stcg 16 ltcg 17 otherprop 18 nonprop 19 pensions 20 gssi 21 ui 22 transfers 23 rentpaid 24 proptax 25 otheritem 26 childcare 27 mortgage 28 scorp 29 pbusinc 30 pprofinc 31 sbusinc 32 sprofinc 33 idtl 34 mtr 35 pui 36 sui 37 dep6 38 dep19 39 opt1 40 opt1v 41 opt2 42 opt2v 43 age1 44 age2 45 age3 46 age4 47 age5 48 age6 49 age7 50 age8 51 age9 52 age10 53 psemp 54 ssemp 55 statefip The federal tax output goes to common block "newshr" with length 255 doublewords. To start with, here are two important locations in newshr: 1 fiitax 74 siitax For the rest of the federal results, consult the last few pages of https://taxsim.nber.org/taxsim-ndx.txt where "comnew" is documented.

The state tax intermediate values are in common block "calc", with elements:

1 household income 2 rent paid 3 state agi 4 state personal exemptions 5 standard deduction 6 itemized deductions 7 taxable income 8 property tax cred 9 child care credit 10 earned income credit 11 total credits 12 bracket rate 13 tax before credits 14 rebate 15 fuel/energy credit 16 child tax credit 17 general credit 18 alternative minimum tax 19 deduction for federal taxf 20 rent credit 21 refundablecredits 22 primary taxable income 23 secondary taxable income 24 primary tax 25 secondary tax If you want to use this code, please do not hesitate to contact me. Daniel Feenberg
617-682-6204 feenberg@nber.org
last update 27 Sep 2024