Autocode with UCB in Fortran

Hi,
I use a schema for modeling a system and I use some UCB blocks inside. The source codes are written in C and Fortran languages. In Xmath environment there are no problerms: I can do the simulation; Matrixx compiles and links all the codes.
I have a problem when I make the autocode: I do this by autocode tool in the block browser, and the code generated is in C.
All the name of the Fortran procedures are written in lower case but the Fortran wants the procedures's names in higher case (it is case sensitive) so there is an error when these procedures are called.
Also, the TIME parameter is passed by value and not by address: I have to put the '&' before the parameter. I use the C compiler with '_stdcall' mode for parameters pass
ing.
I don't use a particular template to make the autocode: I use the standard function in the graphic tool.
If there is a way to do this automatically, please tell me.
Thanks,
Francesco

When using a UCB in SystemBuild both a Fortran template (usr01.f) and a C template (usr01.c) are available in the SystemBuild\src directory. To use a UCB in SystemBuild and in AutoCode a different UCB template is needed. This is the sa_user.c file in case\acc\src. There is no template for Fortran so I would recommend creating a wrapper c file based on the UCB template that in turn calls your Fortran code.
Joseph D.
National Instruments

Similar Messages

  • Is C-source files always needed when simulating with UCB?

    Hi!
    I have a C-file with sensitive information inside. I would like to distribute this to another company and still no let them see the contents of the file. This file is not the only external C-code that is used in the model. Some files will be edited by the other company. Can I in some way only distribute the *.obj-file? I have tried to have the obj-file in the working directory and then remove the source file but then have Xmath complained :
    ***F*** Could not access file:fadecfiles_AS.c
    Error checking contents of new UCB shared library
    Does anyone have an answer?
    /Torbjörn

    I am not sure how this would work with this version but what one could do in the past is go through and run the simulation so that the code compiles into object code then go back and put an empty file in the directory with the same name as the source file but with a date/time that is older than the object code file. In this way the code will not be recompiled and they can't see the source because the source file you provide is empty. You will have to confirm operation of this yourself and if there are other files that need to be recompiled that it does not recompile all f them but just the ones that change.
    Garrett
    Garrett Thurston
    [email protected]
    Phone: 781.993.5540

  • [SOLVED] Intel Fortran Compiler v11.1.072 installation failed

    hi everyone!
    i have some problems with the intel fortran installation. i try to install both ia32 and intel64 version, but without success. i launch from the shell the file "install.sh" and i follow the instructions on the screen, it says that i have missing optional pre-requisites, but also in other linux distribution such as ubuntu or debian, i always skip missing optional pre-requisites and go on. so i do that, but in the step no. 6 when the installation begins, there are a lot of errors:
    Installing Intel(R) Fortran Compiler for applications running on IA-32
    component...
    Intel(R) Fortran Compiler for applications running on IA-32 component
    installation failed.
    Installing Intel(R) Math Kernel Library for applications running on IA-32
    component...
    Intel(R) Math Kernel Library for applications running on IA-32 component
    installation failed.
    what happens?
    thanks all for your replies, i'm here for other infos if you want.
    Last edited by zeruel85 (2010-06-28 07:56:26)

    ok, i solved the problem, but with another ifort version. first of all, install these required packages:
    sudo pacman -S glibc libstdc++5
    then download from aur the package "intel-compilers-common 11.0.074-2" and extract it. now:
    cd /PATH/intel-compilers-common
    makepkg
    sudo pacman -U intel-compilers-common-11.0.074-2-x86_64.pkg.tar.xz
    always from aur, download "ifort" and extract it. before compiling it, copy the file "l_cprof_p_11.0.074_intel64.tgz" from the "intel-compilers-common" folder into the "ifort" folder. now we must have the license file. we can get it from the official intel site:
    https://registrationcenter.intel.com/Re … NCOM&lang=
    just insert your email, select your country and click "Continue". we'll receive an email with the license key attached. now copy the file into the "ifort" folder. open a shell and do this:
    cd /PATH/ifort
    md5sum LICENSE.lic
    where "LICENSE.lic" is the name of your license key. after that, we have to modify the "PKGBUILD" file, always into the "ifort" folder. in line 19, write the correct license file name. in line 24 write the correct md5sum result. save and exit. now we can compile:
    cd /PATH/ifort
    makepkg
    sudo pacman -U ifort-11.0.074-2-x86_64.pkg.tar.xz
    now we have ifort installed! just logout/login to complete the installation! then type:
    ifort -help
    to verify if ifort was correctly installed. if the ifort guide appears, well done!

  • Launch Acrobat Reader with Runtime.exec() under WINNT4, without absolut pat

    Hi,
    I would like to launch Acrobat Reader from a Swing application. This works fine with Runtime.exec() as long as I provide the full path to the AcroRd32.exe. The problem is that I cannot predict the location of this exe on the systems of the users. Athough is in the Windows PATH, since I can launch from the windows execute-dialog, the Runtime.exec() is not able to locate the file.
    How can I solve this problem?
    Thanks a lot!
    Horst

    hey BIJ, thank you so much man. start really does wonders!! i was stuck with invoking a fortran program for last couple of days and now i went through your postings and tried with start. it did work!!
    thanks again,
    bhairampally

  • Writing Namelist with DELIM option

    Greetings Programmers of Fortran:
    I am in some confusion about using Sun f95 to compile code to write out the contents of a namelist. I note that I am unable to compile the WRITE statement using the DELIM='APOSTROPHE' option in order to place apostrophes on either side of strings. I note that this appears to be allowed with Intel's fortran (ifort) and other compilers. Am I missing a Sun compiler directive or something else here?
    Here's a little example:
    PROGRAM test
    IMPLICIT NONE
    CHARACTER(LEN=10) :: Name
    NAMELIST /A/ Name
    Name='Obama'
    WRITE(*,NML=A,DELIM='APOSTROPHE')
    END PROGRAM test
    The compiler output looks like this:
    f95 test.f95WRITE(*,NML=A,DELIM='APOSTROPHE')
    ^
    "test.f95", Line = 11, Column = 19: ERROR: This control item specifier is not allowed for this I/O statement.
    f90comp: 15 SOURCE LINES
    f90comp: 1 ERRORS, 0 WARNINGS, 0 OTHER MESSAGES, 0 ANSI
    (Note that column 19 refers to the DELIM specifier - the font may not appear fixed here.)
    It compiles and runs without the DELIM specifier:
    ./a.out&A
    NAME = Obama
    I would like to be able to enclose any character strings in apostrophes or quotes. I appreciate anybody's help with this matter. Thank you.

    I want to clarify that things did not copy well into my original post. The * symbol is missing for some reason. It really is there. Here's the code again:
    PROGRAM test
    IMPLICIT NONE
    CHARACTER(LEN=10) :: Name
    NAMELIST /A/ Name
    Name='Obama'
    WRITE(*,NML=A,DELIM='APOSTROPHE')
    END PROGRAM test
    And here is the compiler output again for
    f95 test.f95WRITE(*,NML=A,DELIM='APOSTROPHE')
    ^
    "test.f95", Line = 6, Column = 19: ERROR: This control item specifier is not allowed for this I/O statement.
    f90comp: 9 SOURCE LINES
    f90comp: 1 ERRORS, 0 WARNINGS, 0 OTHER MESSAGES, 0 ANSI
    As I write this on the forum screen I can see the * symbol in the WRITE statement. I hope the previous does not cause confusion.

  • Can't find nmake.exe

    I'm currently running MatrixX 6.2.2 on Windows XP SP2.  When I try an run a simulation I get an error message, "Can't find nmake.exe" or something like that.
    I've viewed some previous posts and the suggestions where dealing with VC compiler and running vcvars32.bat.  I've searched for this file on my PC and it doesn't exist.  It appears I don't have VC++ installed on my computer.  Does a version of this compiler get installed with the MatrixX install?
    Where should I go from here?

    Hi Jim,
    nmake.exe is part of Microsoft Visual Studio 6.0. So in order to run you simulation (probably with UCB are C code) to need to have Visual Studio installed and be sure that you register the environment variables when installing. In the help of the software, you can find the recommended compilers. We have try we a free bordland compiler and another make and it was not working. Visual Studio is the best.
    Charles-Etienne
    NGC Aerospace
    Recommended Compilers
    If you want to link your own C or FORTRAN code to
    Xmath or SystemBuild, you must purchase and insta...
    Compiler/OS
    Solaris 7
    Windows
    XP/NT/2000/98/95
    C
    SC4.2
    Microsoft Visual 6.0
    C++
    SC4.2
    Microsoft Visual 6.0
    FORTRAN
    SC4.2
    Digital Visual Fortran 6.0
    WARNING: Other compilers might work in some cases, but they are
    not supported. National Instruments recommends against using unsupported
    compilers.

  • Initialisation of iinfo table when using states

    Hi, I'm running into someting weird today and I'm not sure I understand well what to do. Right now what I'm triing to do is to run my software autocoded with part of it autocoded as a UCB.
    1- When I'm running the whole software autocoded, everything is fine. Case close!!!!
    Then I try to breakup stuff!
    2- I toke part of the code and autocoded it using the UCB templates
    3- Create a small UCB in the whole code that call the autocoded done in number 2
    So in the big software, I have this call to the UCB :
        NAVFAST_DLL_7_sr.STATES = 1;
        NAVFAST_DLL_7_sr.OUTPUTS = 1;
        /* USRxx(INFO,T,U,NU,X,XDOT,NX,Y,NY,RP,IP) */
        NAVFAST_DLL(&NAVFAST_DLL_7_sr, TIME, NAVFAST_DLL_7_u, 83, &X->
                                  NAVfast_7_S1[0], &XD->NAVfast_7_S1[0], 325, NAVFAST_DLL_7_y, 62, &
                                  dummy_f[0], &dummy_i[0]);
    In the UCB (NAVFAST_DLL), I have the call of the INIT part :
        int iinfo[] = {0, INFO->INIT, INFO->STATES, INFO->OUTPUTS};
        double rinfo[] = {T, TSAMP};
        if(INFO->INIT)
            NAVfast2_ucbhook(iinfo, rinfo, U, &NU, X, XDOT ,&NX, Y, &NY, RP, IP);
            INFO->INIT = FALSE;
            return;
    After that we got the code that I have autocoded in part 2 :
        void NAVfast2_ucbhook(iinfo, rinfo, U, NU, X, XD ,NX, Y, NY, R_P, I_P)
                   int     iinfo[], I_P[], *NU, *NX, *NY;
                   double  rinfo[], R_P[], U[], X[], XD[], Y[];
           //... Struct declaration
        if( (*NU != 83) || (*NY != 62) || (*NX != 325) ) {
              iinfo[0] = UCB_ERROR; goto EXEC_ERROR;
        if( iinfo[1] == 1 ) {
          Init_Application_Data();
          if( iinfo[3] == 1 && *NX != 0 ) {
             return;
        //... Rest of the code
    So as you can see here, the first time I inter into the INIT part, the call to Init_Application_Data() and it will exit directly because the iinfo[3] (outputs flag) is equal to 1 and my number of states is different that 0. So it means that all my sub functions are not initialise! After that, I look in the documentation (SystemBuild User Guide 14-4) and found you that I need to call the INIT part twice ?!?!?
        "INIT Mode
        INIT mode is performed once at the start of a simulation. During the INIT
        mode call, the value of the IINFO(2) flag is set to 1. If the UCB reference
        has states, the UCB is called in INIT mode twice.
            • Once while executing OUTPUT mode
            • Again while executing STATE mode"
    So does it mean that I have to call the ubchook function with the iinfo[3] = 1 and iinfo[2] = 0 once and then recall this fucntion with iinfo[3] = 0 and iinfo[2] = 1 under the INIT part of the UCB ?
    Do like this :
        int iinfo[] = {0, INFO->INIT, 0, INFO->OUTPUTS};
        double rinfo[] = {T, TSAMP};
        if(INFO->INIT)
            NAVfast2_ucbhook(iinfo, rinfo, U, &NU, X, XDOT ,&NX, Y, &NY, RP, IP);
            iinfo[2] = INFO->STATES;
            iinfo[3] = 0;
            NAVfast2_ucbhook(iinfo, rinfo, U, &NU, X, XDOT ,&NX, Y, &NY, RP, IP);
            INFO->INIT = FALSE;
            return;
    Thanks
    Charles-Etienne
    NGC Aerospace

    This is an interesting observation about some of details required to implement the 'model of computation' of a SystemBuild model within the generated code.
    Before I continue, may I make a suggestion that if you intend to use procedure code outside of a complete autocode-generated system, you might want to consider using the SDK interfaces. Briefly, the SDK is a template-based solution to generate APIs (C, C++ or Ada) to properly call procedure SuperBlocks from 'other' code. It's very easy to use and implements all the necessary details. Consult your version's documentaion for more as the mechanism to activate the SDK have changed between versions but the structure of the APIs are the same.
    Now, on to the post...
    The most important detail regarding this question is the context of the generated code. In this case, you're using the UCBHOOK mechanism and trying to call that API from other code.
    The problem is that the UCBHOOK is designed to be used as "wrapper code" around an autocode procedure and the 'hook' code is intended to be linked back into the simulator as a UCB for simulation purposes. It was not intended to be a general-purpose API call, that's why we created the SDK!
    Because the UCBHOOK is designed for use with the Simulator, that code must conform to the requirements of a hand-written SystemBuild UCB. And it is in attempting to match the autocode-generated implementation with what the Simulator does results in some odd code.
    What's happening is the code is reflecting a difference in how states are initialized within the Simulator's UCB context and the generated code. Briefly, the simulator must be very generic in how it calls UCB code. The simulator makes many separate calls to a UCB to perform match distinct operations, thus the complexity of the iinfo structure.
    Now autocode generated code is not generic, it is optimized. So, in the case of a procedure, a procedure is a form of a discrete superblock with inherited timing attributes. Autocode optimize discrete superblock initialization by initializing it at the same time as the output computation at T=0.0. Therefore, for autocode discrete-based superblocks, there is only ONE init phase and it's coupled with the first OUTPUT phase.
    So, since the Simulator does not perform such optimization, the Simulator calls the UCBHOOK several times, as it is documented. This is incompatable with the autocode code, therefore there's code in the UCBHOOK (as you've hilighted) to prevent extra initialization as to match the autocode implementation.
    Like I said, the UCBHOOK is designed as a UCB that conforms to the Simulator's 'model of computation'.
    If you intend to have your 'outside' code use the ucbhook, you will have to match how the simulator calls UCBs. In the case you describe, calling the UCBHOOK multiple times for initialization is required.
    In general, I'd not recommend using the UCBHOOK called from 'outside' code, I'd prefer you use the SDK as the complexity of the simulator's calls to UCBs is not trivial.
    Regards,
    Bob Pizzi
    MATRIXx R&D - AutoCode

  • How to build and run enterprise client application in SJS

    Hello
    I need to create client application (not web component) for some Entity Beans in SJS, but I don't know how. In projects menu, when I choose Enterprise Application I can add only EJB, when I choose Application - I don't have access to Bean objects. What should I do? Thanks for any help.

    I think you've posted this question to the wrong forum. This is the Sun Studio forum, which deals with C, C++, Fortran, and related tools.
    Better check with http://developers.sun.com/forums/ to find the right forum for your question.

  • Calling DLL using "Call library function"

    I am trying to combine labview with my previous fortran functions using Intel Visual Fortran 12.1 and labview 2012 by below steps.
     1. Compile Fortran functions as DLL file.
     2. Call Fortran function from LabView via "Call library function"
    In step 2, DLL file without linker option "/DLL delayimp.lib" cannot be loaded. That is "delay load" is needed for DLL file.
    Are there any limitation or constraint in Call library function?

    Hi Vishnu,
    There's no problem using the Malloc function in C and call it as a DLL in LabVIEW.
    But LabVIEW has a different memory management than C.
    It is probably not recommended to allocate array memory in C for labVIEW arrays
    You can use initialize array in LabVIEW instead.
    Good luck
    Van L
    NI Applications Engineer

  • Passing a string as an object name...how?

    I've searched all over the place for a solution to this to no avail.
    I have a program that reads input from a text file. The text file holds information on student IDs, so it look something like this:
    "ID_1234"
    "ID_1235"
    "ID_1236"
    So, every line of the text file has a student ID.
    I have a class called Student, that takes the student ID as a parameter, so I can create a Student object pretty easily by going, for example:
    Student newStudent = new Student("ID_1234");
    Now, my problem is that I want to read the contents of the text file that is given to me and create an object for each student, and use as a name for that object the student's ID. I have the program reading the data from the text file no problem, it's just the object name assignment I'm having trouble with.
    //Start code
    private void readInStudents(String fileName){
    BufferedReader reader = new BufferedReader (new FileReader (studentIDFile.txt));
    String line = reader.readLine();
    while(line != null)
    Student line = new Student(line);
    //End code
    Ideally I would like this to crate three Student objects, with the names "ID_1234", "ID_1235", and "ID_1236" respectively.
    However, this is not the case as I get an error when assigning "line" as the object name in the line within the while loop.
    Any help would be much appreciated!!!!!!
    Many thanks.

    elsombreron wrote:
    Thanks to all for your quick replies. I ended up using an ArraList to store the objects without needing to give them all a dynamic name.
    I come from a purely procedural programming background where the sort of assignment I was trying to do would work, so still have to get used to OO style.
    Thanks again.Huh? I don't see what procedural vs object oriented has to do with it.
    FORTRAN, COBOL, C and Ada (pre 95) are all procedural languages and as far as I can remember, you could not do that in any of them.
    Perhaps many scripting languages allow this. The various *nix shells come to mind.
    What languages are you referring to that have tis feature?

  • Wisely Manage GUI's in LabVIEW

    I would like some recommendations on how to manage GUI controls and indicators wisely in LabVIEW. The Front Panel in my application is fairly simple:
    Depending on which device the user chooses, only certain tests and the corresponding controls and indicators should be enabled. However, my Front Panel to control this got somewhat complicated:
    LabVIEW crashes frequently when I edit my VI and sometimes the application terminates right after I start to execute it. I am starting to think that there must be a much better approach (I can't create a sub-VI because it is limited to 28 connector pane connections) and would greatly appreciate any advice on how to make my software development easier and less frustrating.

    Hi Arnold,
    state machines are one of the nicest/easiest structures programmable in LV And they are quite scalable and flexible - if you create them properly
    And in LV8.5 you find also a "State chart" module allowing you to create LV-code by drawing state charts (I haven't worked with LV8.5 so far, I guess you need a little bit more work than just drawing a chart).
    Well, would you mix C(#) with Pascal/Basic/Fortran to create a GUI? I would stick to LV to control the GUI provided by LV...Message Edited by GerdW on 09-24-2007 02:13 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Speed comparison (AMD64) between sunf95, ifort, gfortran and NAG f95

    Hello,
    I compared the current GCC Fortran Compiler (gfortran; 4.3.0-trunk) with the Sunstudio Fortran Compiler (sunf95), the Intel Fortran Compiler (ifort) and the NAG f95 compiler using the Polyhedron Fortran Benchmark suite.
    http://physik.fu-berlin.de/~tburnus/gcc-trunk/benchmark/
    sunf95 is approximately as fast as ifort, 10% faster than gfortran and 15% faster than NAG f95.
    Comparing with the Polyhedron page [which does not state which gfortran version was used and does not include sunf95], sunf95 is about 7% slower than the fastest compilers.
    http://www.polyhedron.co.uk/pb05/linux/f90bench_AMD.html
    For my compilers, for "fatigue" it is 30% faster than ifort and 60% faster than gfortran. This is quite impressive. On the other hand for gas_dyn it is 35% slower than ifort and 20% than gfortran.
    (Which shows that one can not really say, which compiler is the fastest - it really depends also on the program, the platform and the exact compiler options.)
    Thanks to Sun for making such a nice compiler available free of charge!
    Tobias

    An interesting comparison - thank you for sharing it with us.
    If you get bored, I'd be interested in seeing how the Sun performance library compares against the AMD acml (can you even use acml with Sun Studio?). I'm running on an Opteron system (soon to be an opteron cluster) and am trying to decide which compiler to go with. I suppose doing application specific benchmarking is what I will need to do.

  • Problem concerning the -U flag

    There is a problem concerning the -U Fortran compiler flag in SS12. I use the -U flag in all my projects because, using that flag, capitalization matters (so that, e.g., the compiler treats "foo" and "Foo" as different variables). However, in some projects, although the compiler builds the project correctly, when I try to execute the resulting executable from within SS2, I get the following error message:
    make[2]: m2c: Command not found
    make[2]: *** [project name] Error 127
    make[2]: Leaving directory `[working directory]'
    *** Error code 2
    ..................Note that I can execute it directly (from a terminal window) without any problem. I just cannot execute it by pressing <F6> in SS2. The strange thing is that it does not happen to all my projects, although all of them are based on similar Makefiles. Note also that when I remove the -U flag and rebuild, all projects can be executed from within SS2.

    With my own Fortran Makefiles (on any platform), I use '.SUFFIXES:' rules to get rid of
    any built-in .mod rules for Modula. You have to put a blank .SUFFIXES to flush the
    built-in rules, then add your actual suffixes.In fact, a single blank .SUFFIXES solves the problem. Thank you very much for the hint.
    However, I still cannot understand why this .SUFFIXES blank line is necessary in some projects while it is not in other (similar) projects.
    By default Sun Studio IDE uses GNU make on Linux only. On Solaris
    it is using "dmake". Which platform do you use, Linux or Solaris?I use Linux (Debian 4 x64 version).

  • Half way pixel between two pixels

    hi there guys,
    i'm new in this forum
    i'm working on this aLife simulation and i need to find co-ordinates of a pixel between two others on an image.
    so, pixel A(x1,y1) and pixel B(x2,y2) and suppose there's a line between them
    i would need the pixel C(x3,y3) that lies in the exact middle of the distance between these two pixels
    i have a function that determines the distance between them but no way of finding out what that half way pixel is
    please help cause this is somewhat urgent
    thanks in advance for your time

    I am sorry, but I took programming in college. What you are asking for is the distance equation, which you should have learned in high school algebra. That equation is simply as follows:
    d = sqrt((x2 - x1)^2 + (y2-y1)^2)
    where:
    "sqrt" means take the square root
    d is the distance between the points
    The points are (x1,y1) and (x2,y2)
    "^2" means to square that portion of the equation
    When you are doing a line in a 3-dimensional space, the distance equation becomes the following:
    d = sqrt((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)
    where:
    the points are (x1,y1,z1) and (x2,y2,z2)
    This is a basic computer programming problem, and if you need to ask on a forum like this for help, maybe you should consider changing majors. (I am not trying to be cruel, but let's face it, there are much more difficult problems you will be presented with in your studies than this one. It does not matter whether you are writing this code with JAI, or without, or with Java, C++, Fortran, COBOL, Perl, or any other language. The logic is the same for this calculation regardless of languages and/or libraries used.)

  • A program named Winteracter is giving RPC_S_SERVER_UNAVAILABLE (0x6ba) error after I downloaded Firefox 4.

    Winteracter is a set of fortran subroutines to access windows IPC's. I was calling a subroutine called "WSelectDir" which produces a dialog with a directory tree for selection of a path. The program was compiled with a Lahey fortran 95 compiler. I am using Windows 7 Ultimate operating system. Needless to say, the program worked before I switched to Firefox 4.

    Thanks for your help! I tried your suggestion but only switched off the firewall (although just swichting-off of the firewall may not help). This did not solve the problem.
    But! I was able to solve it! A friend came up with the idea. It was a profile problem. Somehow, the profile information must be damaged (and he explained me, that this ocures sometimes when updating from firefox 3 to 5). I dont know what is going on there. However, after creating a new profile everything was alright and firefox 5 works now!
    If firefox does not open and you want to create a new profile:
    -right click on the firefox icon
    -properties
    -shortcuts
    -check if the "target" is correct (the exe.file is at this place on your machine)
    -if yes: add after the target: [space]-p
    -apply and ok
    -now start firefox, this will open the profile manager
    -create a new profile
    -apply
    -open firefox again and it will work (at least in may case).
    Hope this is a help for all who have the same problem. I am very happy now and looking forward to enjoy firefox 5.
    Thanks a lot! And good luck for everybody trying to solve computer problems!

Maybe you are looking for