The following FORTRAN example demonstrates how to open a file and loop through all the targets to print out their ZA, mass and the total cross-section for each reaction type.
Program ZA Integer i, yi, iZA, nZAs, Date, ReqdMem, ncg, gid, fid, tcType Integer Dummy, IsoErr, ZAs(250) !250 should be large enough for ZAs. Integer C, iC, nC, CList(250) !250 should be large enough for CList Pointer ( pR8, R8 ) !This may not work on all platforms. Real*8 Mass, R8, Q Real*8 cgb(250), cs(250) !250 should be large enough. Character Name*4, Path*256 yi = 1 !Neutron as incident particle. gid = 93 !Group id for collapsing. fid = 0 !Flux id for collapsing. tcType = 1 !Pendlebury/Underhill transport correction Call ndfinit( yi, Name, Date, ReqdMem ) !Open the ndf1 file. Print *, 'Opening ndf file ', Name, ' with date = ', Date Call ndfinfo( Path ) !Get full path of opened ndf file. Print *, 'path = ', Path Call ndf_malloc( pR8, 8 * ReqdMem ) !Get memory (an undocumented routine). Call ndfbuff( pR8 ) !Pass work memory to ndf. Call ndftrcorr( tcType ) !Set the transport correction method. Call ndfidog( gid, cgb, ncg, Dummy ) !Get group from bdfls file. Call ndfgroup( cgb, ncg, fid ) !Set collapsing. Call ndfistab( ZAs, nZAs ) !Get list of targets. Do iZA = 1, nZAs !Loop over target list. Call ndfiso( ZAs(iZA), IsoErr ) !Select next target. Call ndfatw( Mass ) !Get targets mass. Print *, 'Processing ZA = ', ZAs(iZA), '. Mass = ', Mass, ' AMU.' Call ndfreact( CList, nC ) !Get list of reactions for current target. C = -1 Do iC = 1, nC !Loop over reactions. If( C .ne. CList(iC) ) Then !Do only if different C-value. C = CList(iC) Call ndfrxs(C, cs, Q, 0) !Total cross-section for reaction C. Print *, 'C = ', C, ' Q = ', Q Print '( 51pe18.10 )', ( cs(i), i = 1, ncg ) EndIf EndDo EndDo Call ndfclose( ) !Close the ndf file. End
The ndf routine ndf_malloc is used for internal testing and is not guaranteed to work on all systems. The above example uses "Cray pointers" (the statement starting with "Pointer") which are not supported by all FORTRAN compilers. The following FORTRAN code will not work as the routine ndfbuff requires a pointer to a pointer (probably requiring a FORTRAN compiler that supports "Cray pointers").
Real*8 R8(1000000) Call ndfinit( yi, Name, Date, ReqdMem ) Call ndfbuff( R8 ) ! This does not work.