Import statements and type renames

Hi,
I have some errors compiling this code with sunf95.
I'm not sure if the code have something wrong, but I understand this correspond to the 2003 standard.
I hope someone can tell me something about this.
thanks
------- print_coord.f90 -------
subroutine print_coord(coord)
real(8), dimension(3), intent(in) :: coord
print*,coord
end subroutine print_coord
------- print_data_type.i90 -------
!module DATA_TYPE_mod
!use data_type_module, only: data_type => point_t
private
interface print_type_coord
subroutine print_coord(point)
import:: data_type
type(data_type), intent(in) :: point
end subroutine print_coord
end interface print_type_coord
public:: print_type_coord
!end module DATA_TYPE_mod
------- test.f90 -------
module types
public
type point_t
real(8), dimension(3) :: coord
integer :: id
end type point_t
type sphere_t
real(8), dimension(3) :: coord
real(8) :: radius
integer :: id
end type sphere_t
end module types
module point_mod
use types, only: data_type => point_t
include "print_data_type.i90"
end module point_mod
module sphere_mod
use types, only: data_type => sphere_t
include "print_data_type.i90"
end module sphere_mod
program test
use types
use point_mod, only: print_point_coord => print_type_coord
use sphere_mod, only: print_sphere_coord => print_type_coord
type(point_t) :: point
type(sphere_t) :: sphere
point = point_t( (/0.0,0.0,0.0/) , 1 )
sphere = sphere_t( (/1.0,1.0,1.0/), 0.5, 2 )
call print_point_coord(point)
call print_sphere_coord(sphere)
end program test
---------------------------------

>
My mistake, is not an error, is a warning. But it is correct?Yes. The warning message is correctly reporting a violation of the requirements of the Fortran standard. The code as written will work on almost all existing Fortran implementations, but it is not required to work. For example, the Fortran standard allows implementations to reorder the components of a derived type that is not a sequence type. I know of only one compiler that ever took advantage of that freedom, and it did not for very long. The code would fail on any implementation that moved a component of the derived types ahead of the component named coord.
So, the code is not standard conforming, it will work as is on almost all implementations, but it could fail on a standard-conforming Fortran implementation.
I define the procedure print_coord, but is an external procedure, then it is not a problem the use of different types in the interface definition. I rename the types to data_type, but never are both public with the same name. So, the warning is just a comment about the situation or a possible problem when I run the code?The warning is both a comment about problem with the code and a possible problem. The chances of the problem occurring in practice are small.
Bob Corbett

Similar Messages

  • Import statement and directory structure

    First of all, sorry for such a long post, I believe part of it is because I am unsure of the concept of importing in Java. Secondly, Thanks to anyone who can ultimately enlighten me to the concept of import. I did ask this question before in the "erorr and error handling" forum, and the people who have helped me there did a great job. But, I believe I require a little more clarification and thus have decided to post here.
    Anyhow, my question..
    Could someone explain to me the concept of the import statement, or direct me to a webpage with sort of explanation for newbies? For some reason, I am having a hard time grasping the concept.
    As I understand it, the import statement in Java, is very similar to the namespace keyword in C. That is to say, import doesn't actually "import" any source code, the way that the #include statement does in C.
    So I suppose what my question is, say I have a java class file like below:
    //filename: sentence.java
    //located: c:\school\csc365
    package csc365;
    class sentence
    //some variables here..
    //some constructor here..
    //some methods here..
    And some sample program like the one below which implements the above..
    //filename: test.java
    //located: c:\school\csc365
    import csc365.*;
    import java.io.*;
    class test.java
    //creates some sentence object
    //uses the object's methods
    //some other things.
    As I understand it, the test.java file should not compile because the csc365 package is not in the correct directory. (assuming of course, the classpath is like c:\school\csc365;c:\school )
    But, ... where then should the sentence.java be located? In a subdirectory of c:\school called csc365 (i.e c:\school\csc365\) ?
    And thus that would mean the test.java file could be located anywhere on the hard drive?
    I suppose, I just need a little clarification on the correlation between a package's "name" (i.e package csc365; ) and its corresponding directory's name, and also how the javac compiler searches the classpath for java classes.
    ..So, theoretically if I were to set the classpath to look in every conceivable directory(provided the directory names were all unique) of the harddrive, then I could compile a test.java anywhere?
    As a note: I have been able to get the test.java file to compile, by leaving out the import statement in the test.java file, and also leaving out the package statement for the sentence class, but I assume this is because the files are defaulted to the same package?

    Hi Mary,
    No, import isn't analogous to C++ namespace - Java package is closer to the namespace mark.
    import is just a convenience for the programmer. You can go your whole Java career without ever writing an import statement if you wish. All that means is that you'll have to type out the fully-resolved class name every time you want to use a class that's in a package other than java.lang. Example:
    // NOTE: No import statements
    public class Family
       // NOTE: fully-resolved class names
       private java.util.List children = new java.util.ArrayList();
    }If you use the import statement, you can save yourself from typing:
    import java.util.ArrayList;
    import java.util.List;
    public class Family
       // NOTE: fully-resolved class names
       private List children = new ArrayList();
    }import isn't the same as class loader. It does not bring in any source code at all.
    import comes into play when you're compiling or running your code. Java will check to make sure that any "shorthand" class names you give it live in one of the packages you've imported. If it can't find a matching fully-resolved class name, it'll give you a message like "Symbol not found" or something like that.
    I arrange Java source in a directory structure that matches the package structure in the .class files.
    If I've got a Java source file like this:
    package foo.bar;
    public class Baz
       public static void main(String [] args)
            Baz baz = new Baz();
            System.out.println(baz);
       public String toString()
           return "I am a Baz";
    }I'll store it in a directory structure like this:
    root
    +---classes
    +---src
          +---foo
               +---bar
                    +---Baz.javaWhen I compile, I go to root and compile by typing this:
    javac -d classes foo/bar/*.javaI can run the code from root by typing:
    java -classpath classes foo.bar.BazI hope this wasn't patronizing or beneath you. I don't mean to be insulting. - MOD

  • Introspecting import statements

    Sir
    How to introspect import statements of the input class.

    Hi,
    As far as I know, there is no way using introspection or reflection to determine what (if any) classes have been imported in a source file.
    As far as I know, when the source code is compiled (using javac) to a byte code .class file, no reference remains of the import lines, but rather, all type names are rewritten as fully-qualified names.
    One option you could look into (although it isn't a very good one), is to read in the source .java file, if it's available, and use regular expressions (or whatever text matching method you prefer), to locate the import statements and determine what classes are being imported in this way.
    Beyond that, I don't know what else to tell you. I don't think it's possible using reflection (and hence by extension, using introspection). On the other hand, I don't really know what you wish to accomplish with this, either. The import keyword simply allows you to take a short-cut when writing the code, by allowing you to use the cannonical name of a class, rather than the fully-qualified version. It doesn't really add functionality to the class itself. This in itself raises an issue to attempting to determine the import lines, because these lines may or may not be present without changing the functionallity.
    For example, if you are attempting to determine what types a method with parameter of type Object can recieve by determining which classes are imported, these may not be listed as imports at all.
    On the other hand, if you wish to determine which types a class is using for it's declared fields, this can be done by reflecting on the class for DeclaredFields, and determine the type of each one, to make a list.
    Again, I'm really not sure what you're trying to do here. Perhaps if you explained that, I (or somebody else here) may be able to suggest an alternative that would help you get the functionality you want.

  • Auto created import statements

    I create a var of some type and the builder adds the import
    statement and then if I change the type later on it adds another
    import statement, is there a way to cleanup the unused import
    statements?
    Thanks,
    Mike

    Sadly, no.
    There are a couple of different ways we might do this in
    future. If we are able to get to an "organize imports" feature in
    the next release, we could attempt to identify and remove obsolute
    imports in addition to putting the imports in order.
    Alternatively, if we can talk the compiler team into adding a
    compiler warning for unused imports (which I don't believe it does
    this currently), then we could make a quick fix that targets the
    problem directly.
    I'll make sure there's an enhancement request filed for this.
    Rebecca Hyatt
    Adobe

  • Import statement in JSP

              Hi
              I am maintaining a system done by one of our vendors.
              Application is deployed in WLS 7.0.
              When I imported the Jsp's into my IDE , I got errors where java.util classes are
              used in the JSP's and the import statement is missing.
              Most of the Jsp's are like this,
              It is working fine in the production server.
              In the IDE i am forced to put the import statement and that is what I expect.
              But how can it work in the production server without any issue.
              Can someone advise me on this
              Thanks
              DN
              

    <%@page import="java.util.calendar" %>
    Oops... forgot the "page" in there ...That's what I get for using GUI's too much!!! :)

  • Import statement *not* required?

    Can someone explain this to me? I was following along a
    simple AS3 example (in the design video workshop) where a "Power
    Button" has some MouseEven CLICK event handling applied to it with
    a trace statement as the resulting handled function. Really simple
    basic example. The import statement is import
    flash.events.MouseEvent.
    How come removing the import statement does not produce an
    error?
    Reference:
    import flash.events.MouseEvent;
    myButton.addEventListener(MouseEvent.CLICK, myButtonClicked);
    function myButtonClicked(event:MouseEvent):void {
    trace('do Something');
    }

    midimidi,
    > So to be clear...if the AS is on the main timeline,
    import statements
    > are not needed, and if the AS is external and imported,
    import
    > statements are needed.
    That's a general rule of thumb, but not 100% applicable.
    > Are there any other exceptions to that, or does that go
    for all AS3
    > classes?
    There are exceptions, and the easiest way to find them is to
    leave out
    your import statements and plug away ... sooner or later,
    you'll get a
    compiler error, and then you'll know. :)
    >> It did strike me *** odd though, an imported .as
    file uses the same
    >> publish settings as code on the timeline. So why
    treat them differently?
    FLA files have publish settings, but AS files don't. They're
    just text
    files. I hear what you're saying ... they end up getting
    compiled along
    with / into the some FLA anyway -- and that FLA does have
    classpaths
    listed -- but those same AS files might be compiled in Flex
    Builder 2 or
    some 3rd party compiler. It would probably make good sense to
    require the
    import statement for inline FLA code, but not everyone is a
    hardcore
    programmer, and Adobe knows it. Nothing is *hurt* by using
    import in FLAs,
    but for folks who just want to do light programming, the
    convenience of not
    having to use it is nice.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Importing does not properly rename all files

    I am running into a problem where I do not get all my photos renamed as they are imported.
    I start an import from a memory card that has 350 Canon raw files. I have set the option to automatically write changes to XMP. I have specified a rename mask so that they have my name, followed by YYMMDD date, then an incrementing sequence number. The first file comes in as "Dazey_071021_0001.cr2", for instance.
    After the import is done, I have 350 files, but three of them are copied over with their original filenames, like IMG_0193.CR2. I look in Lightroom and it says that there are 3 missing files. In Lightroom the missing files have the proper "Dazey_" name that they should have, but the files by those names do not exist in the folder because they still have their IMG_ names. It looks like Lightroom copied them to the folder with their original names but didn't correctly rename them.
    I have run this import several times with similar results. I also tried copying the files to disk from the card first then choosing the option to Move them during import and ran into the same problem.
    Is this a known problem? This is my first attempt to use LR, and I've run into this problem right off the bat.

    I forgot to mention, this is on Windows XP Pro, fully up to date with all service packs and updates, and I am using LR 1.2.
    I did another test. I took the three IMG_nnnn.JPG files that Lightroom didn't handle correctly and copied them to the incoming folder and imported/renamed just the three of them into a test catalog. All three imported properly and were renamed as they were supposed to be. So Lightroom can handle these particular files ok, the problem is just when it has a larger number of files to import that it begins choking on some.
    Is the forum here an appropriate place to ask for technical support or is there a more formal/tracked way? As it stands, I can't use LR if it won't properly import even a few hundred images from a shoot. :(

  • Import statement in .java files and .jsp files

    Guys I have few mysteries about this import statement.
    Please correct me if I am wrong.
    1)Suppose if I have a folder c:\SourceFolder it has one.java and two.java files.If I compile one.java then one.class files is created in c:\ClassFolder .Now two.java uses one of the method of one.java,and without using import statement I am able to compile two.java, and two.class file is created in c:\ClassFolder.I assume that the path of one.class was taken from the CLASSPATH environment variable,hence I there was no need for import statement .........am i right ?
    BUT... in My.jsp,which is in C:\JspFolder, if I want to use one.class,then I have to specifically import the class I want to use.That is i have to say
    <%@page import="one"%>
    and since the classpath is C:\ClassFolder ,it finds one.class in the C:\ClassFolder.(Note that My.class is created in a folder different from c:\ClassFolder )
    But I am wondering why was there no need for me to import one.class in two.java.
    (Note I am using JDeveloper and Apache server)
    Please help.
    In this case the pSo I am wondering in JSP why it doesn't take the class I am looking for from the classpath .
    Help.

    You have to understand Java scoping rules. In the 1st scenario with the two Java files I am guessing neither one of them begins with a package statement. This means that they belong to the default package. When you compile the compiler uses the classpath to resolve method calls looking in the default package since there was no import statement specified in two.java. JSP is a little different. Now I just read this here in these forums a couple of days ago. Since the classfiles generated from the JSP files are not in the CLASSPATH they are loaded by a different classloader. This is why you have to import all references to all classes in the default package.

  • Import statement in .java files and .jsp files ..correction

    Guys I have few mysteries about this import statement.
    Please correct me if I am wrong.
    1)Suppose if I have a folder c:\SourceFolder it has one.java and two.java files.If I compile one.java then one.class files is created in c:\ClassFolder .Now two.java uses one of the method of one.java,and without using import statement in two.java I am able to compile two.java, and two.class file is created in c:\ClassFolder.I assume that the path of one.class was taken from the CLASSPATH environment variable,hence I there was no need for import statement .........am i right ?
    BUT... in My.jsp,which is in C:\JspFolder, if I want to use one.class,then I have to specifically import one.class in My.jsp .That is i have to say
    <%@page import="one"%>
    in My.jsp.
    and since the classpath is C:\ClassFolder ,it finds one.class in the C:\ClassFolder and MyJsp is compiled sucessfully.(Note that My.class is created in a folder different from c:\ClassFolder )
    But I am wondering why was there no need for me to import one.class in two.java.
    (Note I am using JDeveloper and Apache server)
    Please help.

    It has to do with packages. Most java classes are in a package, the name of which must conform to its place on the filesystem relative to the classpath. By that I mean that if you have com.mystuff.One.java, it must be in a folder com/mystuff where com is located somewhere in the classpath.
    What you've done is a little different. I'm assuming a couple of things:
    1. you have no package declaration at the top of one.java or two.java
    2. you have the current directory "." in your classpath.
    Java has the concept of the "default package", which covers classes without a declared package, and in your case is the current directory.
    So when you're in c:\sourcefolder and run the compiler, then "."="c:\sourcefolder", and that directory is part of the default package. No import statements are necessary for classes that are in the same package. This is why two.java can call methods in one.java without an import statement.
    When you run your jsp, the "current directory" part of your classpath is not c:\sourcefolder, but some other value (probably the directory you start your jsp engine from) You will have to import all non-java-library classes because the jsp itself becomes a java class, with a package that is determined by the jsp engine.

  • Starting in 2015 I get the following error when I try to import my photos. "The following files were not imported because they could not be read"  -DSC8416.NEF  I've been importing the same type of photos with no errors then 2015 came along and now I can

    Starting in 2015 I get the following error when I try to import my photos. "The following files were not imported because they could not be read"  -DSC8416.NEF  I've been importing the same type of photos with no errors then 2015 came along and now I can no longer import.

    The error message is misleading, the problem is that you need WRITE privileges added to the destination directory tree.
    Assuming you are using the "date" structure that LR defaults to, find the directory that contains the 2014 folder (the one that works) and add WRITE rights to the parent of "2014".
    While you are there, if you want, add "2015" folder to beside "2014" and add READ and WRITE rights to that new directory.

  • Confused about CLASSPATH and how java handles import statements...

    Hello,
    I must admit I don't get it. I read the articles about setting CLASSPATH etc. but I still wonder:
    If you use an import statement, what does the compiler do? I.e. where does it look for the specified classes? I find it confusing because I see in different locations different .jar files:
    C:\jdk1.3.1_03\lib\dt.jar
    C:\jdk1.3.1_03\lib\htmlconvertor.jar
    C:\jdk1.3.1_03\lib\tools.jar
    and also
    C:\jdk1.3.1_03\jre\lib\i18n.jar
    C:\jdk1.3.1_03\jre\lib\rt.jar
    C:\jdk1.3.1_03\jre\lib\jaws.jar
    C:\jdk1.3.1_03\jre\lib\sunrassign.jar
    Can someone explain me what the purpose is of these files?
    And why do I have the same contents in
    C:\Program Files\JavaSoft\JRE\1.3.1_03\lib
    and in
    C:\jdk1.3.1_03\jre\lib
    Why is that?
    Thanks for answering my questions!
    -mike

    Thanx for the answers, but I still wonder, everyone
    here says I need to set the classpath, but I don't.Probably because your classes are already in the class path. The compiler/jvm also look for classes by themselves not just in jar files, when just a directory is supplied in the class path. And a period (".") is a valid directory.
    Programs importing different classes compile with no
    problem. So what's up with that?
    Presumably you are referring to your own code - because they are in the class path.
    Second, I still don't understand why the runtime needs
    the .jar files. The runtime uses classes, like String, that have to come from somewhere.
    This would also mean that end-users
    need to set the classpath to the .jar files in their
    JRE directory to be able to run programs that import
    classes from these .jars. But this is not true, right?No it is true. The end-users will have to set the class path. There are variations on this which make it seem like no class path is set. For instance applets in a browser are java but the end-user does not need to set a class path. That is because the browser knows how to download classes/jars and how to set it up so it uses them. (Actually it uses a class loader, but that is probably more information that you need.)
    Because if I make some nice classes myself and import
    them, how can I expect my end-user to install these
    classes and make a classpath for them?That would be between you and you end-user.
    First installation is not part of java. For installation you will have to find something outside of java to accomplish the goal.
    Additionally how the class path gets set is OS specific. Java does not deal with that. You will also have to find some way to deal with this (most likely part of the installation.)
    There are also variations on this. For example the browser example I gave above. Or using the ext directory. Or creating an executable jar. Or simply setting the class path.
    In my understanding it should only be needed in the JDK, not
    in the JRE. True or am I mistaken?Mistaken. The class path is needed in the JRE as well. You will need to set it.

  • Jsp declaration and import statement

    Hi All
    I have some problems with JSP.
    I have wrtten a declaration in jsp like this.....
    <%@ page language="java"%>
    <%!
    Date date = new Date();
    List al new ArrayList();
    public List getList(){
    al.add("Hi");
    return al;
    %>
    The List is-> <%= getList()%>
    Note that i did not import anything, it gives the output without any compile time/runtime error. How it is happening?
    If i write any thing in scriplets.......like List, Date, it is giving compile time error asking to import this.
    I am using weblogic8.1
    May i get the correct answer for this ASAP?
    Thanks and Regards
    Kasim
    [b]

    weblogic includes certain import statements in the JSP page when it is compiled.
    That is why u r not getting an error some times!!
    Check your weblogic documentation to find more details abt that
    But it is better to include the import statements , so the code will work in any server.

  • Compare system state (number and types of objects in memory)

    We have 2 exactly identical servers running our application talking to the same database.
    When some obejct from server 1 is deleted, a message is passed to server 2 to delete the object from its cache too.
    Forget the database, I want to design a testing system which compares the system-state (number and type of live-objects) in memory for server 1 and server 2 after the operation and the message, and reports any discrepancy.
    Any ideas ?

    Are you trying to debug a distributed cache implementation?
    If you want to inspect the state of your application on multiple servers creating a JMX bean might be a solution.
    http://java.sun.com/developer/technicalArticles/J2SE/jmx.html

  • LIKE and Type in abap statements

    Hello  All ,
    I have a question regarding the 'Like' and' Type' 
    I have created a badi XXX , The method has a changing parameter 'A'  which is referenced to a structure .
    The typing method I have mentioned in the method ( in the parameter list ) is TYPE .( I feel it should  have been Like ). Can this cause an issue while writing abap statements in the method ?
    Thanks in advance .
    Best Regards,
    swetha

    Hi Swetha,
    Check out the below link for your question.
    what is the difference between type and like
    Re: what is the difference between type and like
    Re: what is the difference between type and like
    Thanks,
    Chidanand

  • Statement and ResultSet Interface type of Object

    Hi,
    Can any one explains me where exactly (in which Class) the implementation of the Statement and ResultSet Interface type of Object Instance be created
    Regards
    Krishna

    I dont really understand what you are trying to ask but:
    Your JDBC driver has concrete implementations of Statement and Resultset. If you want to know what classes are being used try something like:Connection con = ??;
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery( "???" );
    System.out.println( "Connection class: " + con.getClass().getName() );
    System.out.println( "Statement  class: " + st.getClass().getName() );
    System.out.println( "ResultSet  class: " + rs.getClass().getName() );

Maybe you are looking for

  • Global Temp table with BLOB causing session crash

    Hi, i have a table as follows: create global temporary table spg_file_import ( name varchar2 (128) constraint sfi_nam_ck not null, mime_type varchar2 (128), doc_size number, dad_charset varchar2 (128), last_updated date, content_type varchar2 (128),

  • File will not open

    I have a file that a user is trying to open and could open them fine a few weeks ago. She now gets a error that it is either an unsupported file type or is corrupt, she can even go back through her email and attempt to open ones from months ago that

  • Losing quality when saving for web after using Multiply

    I have a normal photograph, with a red layer on top set to Multiply/Darken. When I save it for web, regardless of what pixel size, or what uploader I use the quality is terrible. Have tried uploading to different services, from difference devices wit

  • IPOD  VIDEO WITH NO VIDEOS!!!!!!!!

    I AM AT WITS END WITH TRYING TO GET VIDEOS ON MY IPOD I CANNOT FIGURE IT OUT. MP4, MPG, .AVI, I CANNOT ADD ANYTHING TO MY LIBRARY OR TRANSFER TO IPOD. PLEASE HELPP!!!!!!   Mac OS X (10.4.5)  

  • Say no to the cashier's "Would you like to save $20.00 today"

    Hi "Derek" can you explain to me and the other customers what happens when a cashier at BB asks "Would you like to save $20.00 today" ...if you say yes, your friendly cashier pushs a button on the computer that does a pull on your credit report (and