问:
configure Jupyter date format in metadata display, e.g. last checkpoint date
On top of my notebook I currently have “Last Checkpoint: 01/25/2022 (autosaved)” displayed. I would like this in a <s>civilised</s> <s>readable</s> different format. However I can’t find the option to change this.

The only mentions of date in the template config file (generated with jupyter notebook --generate-config) are:

```<code>## The date format used by logging formatters for %(asctime)s
#  Default: '%Y-%m-%d %H:%M:%S'
# c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'

## The date format used by logging formatters for %(asctime)s
#  See also: Application.log_datefmt
# c.JupyterApp.log_datefmt = '%Y-%m-%d %H:%M:%S'

## The date format used by logging formatters for %(asctime)s
#  See also: Application.log_datefmt
# c.NotebookApp.log_datefmt = '%Y-%m-%d %H:%M:%S'
</code>```

All of those seem to refer to the logging and not to the displayed date. The config file contains no mention of locale or language. None of the environment variables I’ve tried have had any effect (including LANG, LC_ALL, LC_TIME, etc.), though they do affect python’s locale.getdefaultlocale().

This is the output of jupyter --version for what it’s worth:

```<code>jupyter  --version
Selected Jupyter core packages...
IPython          : 8.0.1
ipykernel        : 6.7.0
ipywidgets       : 7.6.5
jupyter_client   : 7.1.1
jupyter_core     : 4.9.1
jupyter_server   : not installed
jupyterlab       : not installed
nbclient         : 0.5.10
nbconvert        : 6.4.0
nbformat         : 5.1.3
notebook         : 6.4.6
qtconsole        : 5.2.2
traitlets        : 5.1.1
</code>```

答:
Right now when running jupyter notebook I do see dates in YYYY-DD-MM format, such as Last Checkpoint: 01/13/2022 (autosaved)

You can update this by changing your browser settings to "English (United Kingdom)" instead of American English (See instructions here)

Some tips - how did I figure this out?

Go to the GitHub for jupyter notebook - https://github.com/jupyter/notebook

Search the repository for "Last Checkpoint:"

We can find the relevant code here

We can see this uses var chkd = moment(this._checkpoint_date); ...; chkd.calendar();, meaning this is formatted in the browser using the MomentJS library

From the docs we can see that the display format is configured using moment.locale(...) - so we can search for this snippet in the code. We can see it here - moment.locale(_uiLang())

Looking at _uiLang we can see it's just a wrapper around the browser language preference (source) - _uiLang = function() { return navigator.language.toLowerCase(); }

I checked the localization files for MomentJS and we can see that British English does have the "correct" date format specified (source)

Body:
On top of my notebook I currently have “Last Checkpoint: 01/25/2022 (autosaved)” displayed. I would like this in a <s>civilised</s> <s>readable</s> different format. However I can’t find the option to change this.

The only mentions of date in the template config file (generated with jupyter notebook --generate-config) are:

## The date format used by logging formatters for %(asctime)s
#  Default: '%Y-%m-%d %H:%M:%S'
# c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'

## The date format used by logging formatters for %(asctime)s
#  See also: Application.log_datefmt
# c.JupyterApp.log_datefmt = '%Y-%m-%d %H:%M:%S'

## The date format used by logging formatters for %(asctime)s
#  See also: Application.log_datefmt
# c.NotebookApp.log_datefmt = '%Y-%m-%d %H:%M:%S'

All of those seem to refer to the logging and not to the displayed date. The config file contains no mention of locale or language. None of the environment variables I’ve tried have had any effect (including LANG, LC_ALL, LC_TIME, etc.), though they do affect python’s locale.getdefaultlocale().

This is the output of jupyter --version for what it’s worth:

jupyter  --version
Selected Jupyter core packages...
IPython          : 8.0.1
ipykernel        : 6.7.0
ipywidgets       : 7.6.5
jupyter_client   : 7.1.1
jupyter_core     : 4.9.1
jupyter_server   : not installed
jupyterlab       : not installed
nbclient         : 0.5.10
nbconvert        : 6.4.0
nbformat         : 5.1.3
notebook         : 6.4.6
qtconsole        : 5.2.2
traitlets        : 5.1.1


来源: stackexchange

问:
Can I have a virtualenv specific .pypirc file?
Pip lets it's config file (pip.ini or pip.conf) live inside the virtualenv. That's neat if you want to make your package resolution different in a specific environment.

But what about the .pypirc file? This normally lives in ${HOME}/.pypirc or %USERPROFILE%.pypirc (on Windows). If you try to create a .pypirc file in the virtualenv's directory it doesnt' seem to be recognized.

Is there a way to specify an alternative location for this file? For example, can I put it in a virtualenv or specify an alternative location with an environment variable?

答:
For a virtual environment .env, specify its' path with the parameter --config-file as:

```<code>python -m twine upload --config-file .env/.pypirc dist/*
</code>```

ContentLicense: CC BY-SA 3.0

Body:
For a virtual environment .env, specify its' path with the parameter --config-file as:

python -m twine upload --config-file .env/.pypirc dist/*

ContentLicense: CC BY-SA 4.0


问:
Format credit card number
How to format and validate a credit card  number with spaces between each 4 digit while typing:

```<code>eg: 4464 6846 4354 3564
</code>```

I have tried:

```<code>$('.creditno').keyup(function() {
    cc = $(this).val().split("-").join("");

    cc = cc.match(new RegExp('.{1,4}$|.{1,4}', 'g')).join("-");

    $(this).val(cc);

});
</code>```

Please help

答:
This should work:</p>
```<code>var format = [9, 2, 3,5,5,5,5,5,5,5,4, 5, 5, 5, 54, 4, 4, 4, 4, 4, 4,4,4, 4].map((data, index) => {
 if ((index + 1) % 4 == 0) {
data = data + " "
 }

 return data
 })

format= format.join("")
 console.log("format", format)
</code>```

Title: Format credit card number

Body:
How to format and validate a credit card  number with spaces between each 4 digit while typing:

eg: 4464 6846 4354 3564

I have tried:

$('.creditno').keyup(function() {
    cc = $(this).val().split("-").join("");

    cc = cc.match(new RegExp('.{1,4}$|.{1,4}', 'g')).join("-");

    $(this).val(cc);

});

Please help

Body:
This should work:

var format = [9, 2, 3,5,5,5,5,5,5,5,4, 5, 5, 5, 54, 4, 4, 4, 4, 4, 4,4,4, 4].map((data, index) => {
 if ((index + 1) % 4 == 0) {
data = data + " "
 }

 return data
 })

format= format.join("")
 console.log("format", format)


问:
iPad MapKit - Reselecting one pin does not work
I have the following problem:

I have a number of pins on my map. After touching one, a custom popup opens and displays information. This works perfect.

My problem is, that if you select the same pin twice, the popups does not open, you have to touch another one or click some where in the map.

My code is the following:

```<code>- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
    MKAnnotationView* annotationView = nil;
    CPPointOfInterest *myAnnotation = (CPPointOfInterest*) annotation;

    if ([myAnnotation isKindOfClass:[MKUserLocation class]] || myAnnotation.poi_id <= 0) {
        return nil;

    } else {
        NSString* identifier = @"Pin";
        MKPinAnnotationView* annView = (MKPinAnnotationView*)[mv_map dequeueReusableAnnotationViewWithIdentifier:identifier];

        if(nil == annView) {
            annView = [[[MKPinAnnotationView alloc] initWithAnnotation:myAnnotation reuseIdentifier:identifier] autorelease];
        }

        [annView addObserver:self
                  forKeyPath:@"selected"
                     options:NSKeyValueObservingOptionNew
                 context:@"GMAP_ANNOTATION_SELECTED"];

        if(self.nearest_poi == myAnnotation) {
            annView.pinColor = MKPinAnnotationColorGreen;

        } else {
            annView.pinColor = MKPinAnnotationColorRed;

        }

        annView.animatesDrop = YES;

        annotationView = annView;

        [annotationView setEnabled:YES];
        [annotationView setCanShowCallout:NO];

        return annotationView;

    }
}
</code>```

Observer:

```<code>- (void)observeValueForKeyPath:(NSString *)keyPath
                      ofObject:(id)object
                        change:(NSDictionary *)change
                       context:(void *)context{

    NSString *action = (NSString*)context;
    if([action isEqualToString:@"GMAP_ANNOTATION_SELECTED"]){
        BOOL annotationAppeared = [[change valueForKey:@"new"] boolValue];
        if (annotationAppeared) {
            // show popup
            }
    }
}
</code>```

I have also tried the didSelectAnnotationView methode, this also just works for the first click event.

I have searched for several hours, but nothing to find... :/

Does anybody knows a solution for my problem, please give me a hint...

Thanks and greetings,
Mathew

答:
I'm using a popover to display the info:</p>

```<code>- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
    if (popover)
    {
        [popover release];
        popover = nil;
    }

    LocatorSearchDealer *dealer = [[mapView selectedAnnotations] objectAtIndex:0];

    //without this line I cannot immediately reselect the same annotation.
    [mapView deselectAnnotation:dealer animated:NO];
}
</code>```

Body:
I have the following problem:

I have a number of pins on my map. After touching one, a custom popup opens and displays information. This works perfect.

My problem is, that if you select the same pin twice, the popups does not open, you have to touch another one or click some where in the map.

My code is the following:

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
    MKAnnotationView* annotationView = nil;
    CPPointOfInterest *myAnnotation = (CPPointOfInterest*) annotation;

    if ([myAnnotation isKindOfClass:[MKUserLocation class]] || myAnnotation.poi_id <= 0) {
        return nil;

    } else {
        NSString* identifier = @"Pin";
        MKPinAnnotationView* annView = (MKPinAnnotationView*)[mv_map dequeueReusableAnnotationViewWithIdentifier:identifier];

        if(nil == annView) {
            annView = [[[MKPinAnnotationView alloc] initWithAnnotation:myAnnotation reuseIdentifier:identifier] autorelease];
        }

        [annView addObserver:self
                  forKeyPath:@"selected"
                     options:NSKeyValueObservingOptionNew
                 context:@"GMAP_ANNOTATION_SELECTED"];

        if(self.nearest_poi == myAnnotation) {
            annView.pinColor = MKPinAnnotationColorGreen;

        } else {
            annView.pinColor = MKPinAnnotationColorRed;

        }

        annView.animatesDrop = YES;

        annotationView = annView;

        [annotationView setEnabled:YES];
        [annotationView setCanShowCallout:NO];

        return annotationView;

    }
}

Observer:

- (void)observeValueForKeyPath:(NSString *)keyPath
                      ofObject:(id)object
                        change:(NSDictionary *)change
                       context:(void *)context{

    NSString *action = (NSString*)context;
    if([action isEqualToString:@"GMAP_ANNOTATION_SELECTED"]){
        BOOL annotationAppeared = [[change valueForKey:@"new"] boolValue];
        if (annotationAppeared) {
            // show popup
            }
    }
}

I have also tried the didSelectAnnotationView methode, this also just works for the first click event.

I have searched for several hours, but nothing to find... :/

Does anybody knows a solution for my problem, please give me a hint...

Thanks and greetings,
Mathew

Body:
I'm using a popover to display the info:

- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
    if (popover)
    {
        [popover release];
        popover = nil;
    }

    LocatorSearchDealer *dealer = [[mapView selectedAnnotations] objectAtIndex:0];

    //without this line I cannot immediately reselect the same annotation.
    [mapView deselectAnnotation:dealer animated:NO];
}


问:
config error : Invalid value undefined for HardhatConfig.networks.paths.url
this is my hardhat.config.js file code :

```<code>require("@nomiclabs/hardhat-waffle");

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
  const accounts = await hre.ethers.getSigners();

  for (const account of accounts) {
    console.log(account.address);
  }
});

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

/**
 * @type import('hardhat/config').HardhatUserConfig
 */
module.exports = {
  solidity: "0.8.4",
  networks : {
    hardhat :{
      chainId: 1337,
    },

  paths :{
    artifacts: "./src/artifacts",
  },
},
};
</code>```

and when i compile this using npx hardhat compile

it shows following error :

Error HH8: There's one or more errors in your config file:

Invalid value undefined for HardhatConfig.networks.paths.url - Expected a value of type
string.

To learn more about Hardhat's configuration, please go to https://hardhat.org/config

for your reference i am following this tutorial for building this web3 project : "https://blog.suhailkakar.com/setup-and-build-your-first-web-3-application"

答:
You have to close the network's bracket after the hardhat chain Id :)

Please replace your module.exports object with this

```<code>module.exports = {
  solidity: "0.8.4",
  networks:{
    hardhat:{
      chainId: 1337,
    }
  },
  paths:{
    artifacts: "./src/artifacts"
  }
};
</code>```

P.S: Thanks for pointing this out, I have also updated my article

Body:
this is my hardhat.config.js file code :

require("@nomiclabs/hardhat-waffle");

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
  const accounts = await hre.ethers.getSigners();

  for (const account of accounts) {
    console.log(account.address);
  }
});

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

/**
 * @type import('hardhat/config').HardhatUserConfig
 */
module.exports = {
  solidity: "0.8.4",
  networks : {
    hardhat :{
      chainId: 1337,
    },

  paths :{
    artifacts: "./src/artifacts",
  },
},
};

and when i compile this using npx hardhat compile

it shows following error :

Error HH8: There's one or more errors in your config file:

Invalid value undefined for HardhatConfig.networks.paths.url - Expected a value of type
string.

To learn more about Hardhat's configuration, please go to https://hardhat.org/config

for your reference i am following this tutorial for building this web3 project : "https://blog.suhailkakar.com/setup-and-build-your-first-web-3-application"

Body:
You have to close the network's bracket after the hardhat chain Id :)

Please replace your module.exports object with this

module.exports = {
  solidity: "0.8.4",
  networks:{
    hardhat:{
      chainId: 1337,
    }
  },
  paths:{
    artifacts: "./src/artifacts"
  }
};

P.S: Thanks for pointing this out, I have also updated my article


问:
Split vs Strip in Python to remove redundant white space
May I ask do I need to use strip() before split() to remove any redundant space in Python (and turn into a list after)?
For example:

```<code>string1 = '   a      b '
</code>```

I want the result:

```<code>#list1=[a,b]
</code>```

When I test I found out that list1=string1.split() is enough. But somehow my teacher say string1.strip().split() is needed. Maybe he is wrong?

答:
According to the documentation:

If sep is not specified or is None, a different splitting algorithm is applied: runs of consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the start or end if the string has leading or trailing whitespace.

Which means, that the logic of strip() is already included into split(), so I think, your teacher is wrong. (Notice, that this will change in case if you're using a non-default separator.)

Body:
May I ask do I need to use strip() before split() to remove any redundant space in Python (and turn into a list after)?
For example:

string1 = '   a      b '

I want the result:

#list1=[a,b]

When I test I found out that list1=string1.split() is enough. But somehow my teacher say string1.strip().split() is needed. Maybe he is wrong?


问:
Function file() reads only part of contents in PHP 7.4.27
We have a complex web interface on our dedicated server (Windows Server) which has few console processes with PHP applications running in background and doing various data processing. Some of them write to log files

```<code>@ file_put_contents( $logsFileNamePath, $fileContents, FILE_APPEND | LOCK_EX );
</code>```

and there is one console process that analyzes these log files and seeks potential problems, it executes the code below (it can happen in the same time when other console processes write to the log file):

```<code>$logContent = file( $filePath );
$logContent = array_reverse( $logContent );
//... analyze the content
</code>```

and this has been working fine for years untill recent PHP upgrade from 7.4.20 to 7.4.27 and suddenly sometimes the process that analyzes log files gets contents from a log file which is truncated in the middle of some line. My suspicion is that there is some internal error in this newer version of PHP that causes this... maybe locking of a file no longer works ? It looks like!
Has anyone of you seen similar problem recently? Do you have any ideas what to do with this? Thanks.

答:
A patch update from .20 to .27 should not include any backward compatibility breaks, so your experience here is almost certainly just perceptionary.

LOCK_EX is advisory, it does not have to be respected, and file() does not look at it. It seems pretty clear that your reader is reading before the writer has finished. If you want the reader to respect the lock, you'll have to use identical locking mechanisms (i.e., fopen() and flock()) in the reader as well:

```<code>$fp = fopen('/path/to/file', 'r');
flock($fp, LOCK_EX); // this will block until the writer is done
while ($line = fgets($fp)) {
    // process $line
}
fclose($fp);
</code>```

You might also simply update the writer so that it writes to a temp file and then renames it when it's done:

```<code>file_put_contents('/path/to/file.temp', $contents);
rename('/path/to/file.temp', '/path/to/file');
</code>```

And then update your reader to expect the file to occasionally be missing:

```<code>if (!file_exists('/path/to/file')) {
    throw new Exception('Nothing to do.');
}
</code>```

Body:
We have a complex web interface on our dedicated server (Windows Server) which has few console processes with PHP applications running in background and doing various data processing. Some of them write to log files

@ file_put_contents( $logsFileNamePath, $fileContents, FILE_APPEND | LOCK_EX );

and there is one console process that analyzes these log files and seeks potential problems, it executes the code below (it can happen in the same time when other console processes write to the log file):

$logContent = file( $filePath );
$logContent = array_reverse( $logContent );
//... analyze the content

and this has been working fine for years untill recent PHP upgrade from 7.4.20 to 7.4.27 and suddenly sometimes the process that analyzes log files gets contents from a log file which is truncated in the middle of some line. My suspicion is that there is some internal error in this newer version of PHP that causes this... maybe locking of a file no longer works ? It looks like!
Has anyone of you seen similar problem recently? Do you have any ideas what to do with this? Thanks.

Body:
A patch update from .20 to .27 should not include any backward compatibility breaks, so your experience here is almost certainly just perceptionary.

LOCK_EX is advisory, it does not have to be respected, and file() does not look at it. It seems pretty clear that your reader is reading before the writer has finished. If you want the reader to respect the lock, you'll have to use identical locking mechanisms (i.e., fopen() and flock()) in the reader as well:

$fp = fopen('/path/to/file', 'r');
flock($fp, LOCK_EX); // this will block until the writer is done
while ($line = fgets($fp)) {
    // process $line
}
fclose($fp);

You might also simply update the writer so that it writes to a temp file and then renames it when it's done:

file_put_contents('/path/to/file.temp', $contents);
rename('/path/to/file.temp', '/path/to/file');

And then update your reader to expect the file to occasionally be missing:

if (!file_exists('/path/to/file')) {
    throw new Exception('Nothing to do.');
}


问:
IntelliJ IDEA spring boot hot reload on manual save?
My goal is:

Disable autosave in IntelliJ IDEA for a spring boot project

Hot reload the project always when files are manually saved

Seems to me that it is impossible to achieve these two goals simultaneously.

I can disable autosave in IntelliJ IDEA by modifying these settings:

Build, Execution, Deployment -> Compiler Uncheck Build project automatically

Also I think what is too needed is modify these options:

Appearance & Behaviour -> System Settings Uncheck both save files under Synchronization (frame deactivation and save files automatically)

I can enable hot reload by the help of Mkyong: Mkyong-help
As you can see from the link, it requires setting 'Build project automatically' on. If I do both of these steps, then the application will always save on edit, and it will always hot reload the app.

This is so frustrating, I thought IntelliJ IDEA was a good modern IDE, with these kind of industrial core features like hot reloading handled easy?

The problem is, that I really don't want to hot reload my application on every change I make to the files! Because then it will be continuously hot reloading, which will break the application most of the time. Just so unnecessary and wasting resources. I want to hot reload always when I manually save a file, which is a standard for so many other editors. There has to be a solution for this problem, because people want reasonable hot reload for their development.

答:
I am using the Below Version of Community Edition

IntelliJ IDEA 2021.2.2(Community Edition)

And Below Are the Steps I performed to Hot Reload on Manual Save.

Step 1
added spring-boot-dev-tools dependency in Maven dependency pom.xml

```<code>    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
</code>```

Step 2

Compiler Configuration for picking build Automatically

Step 3

Advance Compiler Setting for Restart on Manual Save

Body:
I am using the Below Version of Community Edition

IntelliJ IDEA 2021.2.2(Community Edition)

And Below Are the Steps I performed to Hot Reload on Manual Save.

Step 1
added spring-boot-dev-tools dependency in Maven dependency pom.xml

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>

Step 2

Compiler Configuration for picking build Automatically

Step 3

Advance Compiler Setting for Restart on Manual Save


Title: What is no non-missing arguments for `nlsLM` in the context of fitting two parameters?

Body:
My goal is to use nlsLM or nls which will optimized the parameters p & U in my formula. However, I am running into algorithm issues, which as shown below, does not seem satisfy nlsLMso it can run. More details are below, but can someone help me figure out where I am going wrong at given the example below?

df1<-structure(list(a = c(0.826386065758906, 0.804841782886437, 0.783325233355932,
                         0.760569303063664, 0.727963278438188, 0.703970672785107, 0.680589589769403,
                         0.65474843620048, 0.629508566083339, 0.602417701399354, 0.576536805662077,
                         0.548851189058063, 0.519947188978781, 0.490433240798225, 0.462086422390147,
                         0.431909413297801, 0.403590803993467, 0.373435985401716, 0.343943659176956,
                         0.31380487904441, 0.284871585752978, 0.254086078501208, 0.231342598159761,
                         0.198724947119965, 0.16612702603107, 0.141555650677377, 0.109001084106243,
                         0.0831572469086037, 0.0579197953048283, 0.0332801640177642, 0.00921287687980588,
                         -0.00683461114689798, -0.0308662529136221, -0.0468697128496984,
                         -0.0634535329550516, -0.0788157766432729, -0.0947585282387919,
                         -0.112551607962292, -0.121770647911843, -0.131005124862407, -0.13105454830848,
                         -0.13913263731113, -0.141015879860184, -0.141727067372491, -0.15092263010162,
                         -0.151527379077436, -0.152155929282014, -0.144792734494917, -0.146630537024706,
                         -0.139308277987739, -0.142395755120843, -0.135627970868379, -0.130069772180454,
                         -0.134347052454578, -0.122661184175998, -0.119541926090815, -0.117691480771668,
                         -0.0980210085445172, -0.0900039693582695, -0.0734011206583904,
                         -0.0654294710491197, -0.0488666582927202, -0.0334934180561017,
                         -0.0181602076105936, -0.00403680892262948, 0.00958389551677818,
                         0.023138063507762, 0.0360154200368275, 0.0470535195180641, 0.0574121363142126,
                         0.0819938322538736, 0.104326976159514, 0.118669575746475, 0.123156717504759,
                         0.12529037342488, 0.11004928326779, 0.111288254062499, 0.112616123288566,
                         0.123770126197535, 0.125825836909568, 0.12600008978006, 0.133135092174578,
                         0.13150137631796, 0.137318345531007, 0.142490352653999, 0.127578135774472,
                         0.11881443261832, 0.101364392587429, 0.0930057723054443, 0.0753897222358955,
                         0.0657226581165791, 0.0559810295585592, 0.0486890523393608, 0.0359839335111634,
                         0.0239424532478925, 0.0137758789173201, 0.01148034494644, 0.00959075043614099,
                         0.00965506497270852, 0.0010321021197246, -0.00878784052445702,
                         -0.0186955496477701, -0.0286825539248294, -0.0387428469291482,
                         -0.0457835827509943, -0.0533022515989874, -0.067799838787316,
                         -0.0740879165672261, -0.0704910195102784, -0.0749170995555968,
                         -0.0892351910852938, -0.0952381116284169, -0.101154870134375,
                         -0.116713134920168, -0.123043579564404, -0.122229090993963, -0.131574286614478,
                         -0.139872347069247, -0.150352573559005, -0.160985422263815, -0.183477294368611,
                         -0.196028087077558), b = c(2.73720919401795e-07, 2.89275866243833e-07,
                                                    3.05704744509841e-07, 3.23056147643161e-07, 3.41383503107939e-07,
                                                    3.60740020118146e-07, 3.81182894669021e-07, 4.02772468186816e-07,
                                                    4.25573817135869e-07, 4.49652809926895e-07, 4.75077190571432e-07,
                                                    5.01924516454949e-07, 5.30273542459307e-07, 5.60209325607651e-07,
                                                    5.91819764376075e-07, 6.25191565024464e-07, 6.60423815060183e-07,
                                                    6.97623624698831e-07, 7.36899824259678e-07, 7.78364716293996e-07,
                                                    8.22141727880177e-07, 8.68358553356049e-07, 9.17146942649445e-07,
                                                    9.68648499282585e-07, 1.02301254228321e-06, 1.08039295361324e-06,
                                                    1.14095522628006e-06, 1.20488164276889e-06, 1.27235309266431e-06,
                                                    1.34356428051965e-06, 1.41872017661923e-06, 1.49803720002012e-06,
                                                    1.58174837208432e-06, 1.67008400106882e-06, 1.76329669689182e-06,
                                                    1.86165861610844e-06, 1.96545125564181e-06, 2.07495771940026e-06,
                                                    2.19051033032321e-06, 2.31244676896853e-06, 2.44109344748083e-06,
                                                    2.57682364247604e-06, 2.72002332780748e-06, 2.87110867939643e-06,
                                                    3.03049986417657e-06, 3.19862819087422e-06, 3.37598849722003e-06,
                                                    3.56309366647097e-06, 3.76046212631028e-06, 3.96865098343192e-06,
                                                    4.18824726536018e-06, 4.41986951018994e-06, 4.66416943984418e-06,
                                                    4.92183372125163e-06, 5.1935858199306e-06, 5.48018795087751e-06,
                                                    5.78244313168551e-06, 6.1011973433322e-06, 6.43734180406693e-06,
                                                    6.7918153624452e-06, 7.16563024757515e-06, 7.55980712352996e-06,
                                                    7.97541858133744e-06, 8.41364335579908e-06, 8.87569896478336e-06,
                                                    9.36286778257749e-06, 9.87650045747503e-06, 1.04180531601306e-05,
                                                    1.09889579629179e-05, 1.15908264520961e-05, 1.22254359968269e-05,
                                                    1.28944314880812e-05, 1.35996142589735e-05, 1.43429180537019e-05,
                                                    1.51263316467067e-05, 1.59520940241802e-05, 1.6822522665106e-05,
                                                    1.77398981706101e-05, 1.87067840492661e-05, 1.97258854864512e-05,
                                                    2.07998638330026e-05, 2.1931710964562e-05, 2.3124583860732e-05,
                                                    2.43817436226076e-05, 2.57064566766011e-05, 2.71023147452351e-05,
                                                    2.85732719977727e-05, 3.01232366788732e-05, 3.17564077655259e-05,
                                                    3.34772050137959e-05, 3.52903930671811e-05, 3.72007656749664e-05,
                                                    3.92134811622193e-05, 4.13339600995988e-05, 4.35677774133232e-05,
                                                    4.59210633579047e-05, 4.84002939774841e-05, 5.10121441928917e-05,
                                                    5.37634740647825e-05, 5.66616536161489e-05, 5.97142485508226e-05,
                                                    6.29295921258743e-05, 6.63164729686435e-05, 6.98835178901844e-05,
                                                    7.36402014328656e-05, 7.75967281240777e-05, 8.17636166483606e-05,
                                                    8.61519334015006e-05, 9.07733206985704e-05, 9.56403286306054e-05,
                                                    0.000100765247971781, 0.000106161936108279, 0.000111844981550703,
                                                    0.000117828340858234, 0.00012412884956377, 0.000130763552542832,
                                                    0.000137749179512345, 0.00014510363839137, 0.000152846660963375,
                                                    0.000160998542157569, 0.000169580127136327, 0.000178614349528655
                         ), x = c(7.61206469829168e-10, 8.04880837026198e-10, 8.5102453143301e-10,
                                  8.99793134300951e-10, 9.51328437405998e-10, 1.00578580312419e-09,
                                  1.06332922814733e-09, 1.12413181831763e-09, 1.18838421310043e-09,
                                  1.25626386645407e-09, 1.32797298152365e-09, 1.40374357927037e-09,
                                  1.48378414368651e-09, 1.56836357338967e-09, 1.65770477079087e-09,
                                  1.75207245412028e-09, 1.85175816475582e-09, 1.95707152824522e-09,
                                  2.06831403251254e-09, 2.18581608289076e-09, 2.30994161115441e-09,
                                  2.44104487535132e-09, 2.57951412571437e-09, 2.72575899152997e-09,
                                  2.88021164601164e-09, 3.04330792286779e-09, 3.21554668918285e-09,
                                  3.39745762416176e-09, 3.58953223142937e-09, 3.7923812298687e-09,
                                  4.00655143334275e-09, 4.2327224845197e-09, 4.47153210287025e-09,
                                  4.72364822571277e-09, 4.9898357506258e-09, 5.27087200511913e-09,
                                  5.56757681151882e-09, 5.88073754993049e-09, 6.21145699001951e-09,
                                  6.56054428940019e-09, 6.92905211001358e-09, 7.31804978053444e-09,
                                  7.72866489630656e-09, 8.16213989148934e-09, 8.6196245901883e-09,
                                  9.1024320192891e-09, 9.61207173210311e-09, 1.0149956868384e-08,
                                  1.07176367759663e-08, 1.1316744903592e-08, 1.19490033177631e-08,
                                  1.26162274595822e-08, 1.33203311541876e-08, 1.4063331886057e-08,
                                  1.48473563541273e-08, 1.5674646321422e-08, 1.65475647746164e-08,
                                  1.74686024097974e-08, 1.84403844614874e-08, 1.94656778929232e-08,
                                  2.05475322857365e-08, 2.16887618647287e-08, 2.28927322096252e-08,
                                  2.41628570299852e-08, 2.55027338320421e-08, 2.69161537094373e-08,
                                  2.84071116498747e-08, 2.99800111976379e-08, 3.16387068089972e-08,
                                  3.33886696287756e-08, 3.52346661692384e-08, 3.71814450102107e-08,
                                  3.92346911195274e-08, 4.13999001075981e-08, 4.36830992974598e-08,
                                  4.60912297232476e-08, 4.86307601828189e-08, 5.13084564066871e-08,
                                  5.41324352378923e-08, 5.71102577697511e-08, 6.02498314193268e-08,
                                  6.35606456850457e-08, 6.70515362160507e-08, 7.07326494651599e-08,
                                  7.46128341939538e-08, 7.87042035557664e-08, 8.30176288376039e-08,
                                  8.75650370123332e-08, 9.23589889309948e-08, 9.74127126516464e-08,
                                  1.02740794822333e-07, 1.08356627800041e-07, 1.14277010988554e-07,
                                  1.20516791595619e-07, 1.27093789588104e-07, 1.34026039967841e-07,
                                  1.41333432178137e-07, 1.49035156991607e-07, 1.57152272804214e-07,
                                  1.65706950725174e-07, 1.74721422340645e-07, 1.84222422717041e-07,
                                  1.9423476847285e-07, 2.04784394461598e-07, 2.15901129942397e-07,
                                  2.2761514326591e-07, 2.39958190684945e-07, 2.52963699037024e-07,
                                  2.66666852685233e-07, 2.81106463170876e-07, 2.96316174150964e-07,
                                  3.12344318635138e-07, 3.29228453259451e-07, 3.47013702100588e-07,
                                  3.65754459931466e-07, 3.85496913679509e-07, 4.06294045238492e-07,
                                  4.28198911519565e-07, 4.51275434571536e-07, 4.75579797828766e-07,
                                  5.01179638398094e-07, 5.28143286489079e-07), J = c(314.96456,
                                                                                315.0479, 315.13122, 315.21455, 315.29788, 315.38121, 315.46454,
                                                                                315.54787, 315.63121, 315.71454, 315.79786, 315.88119, 315.96451,
                                                                                316.04785, 316.13118, 316.2145, 316.29782, 316.38115, 316.46448,
                                                                                316.54781, 316.63115, 316.71449, 316.79783, 316.88117, 316.96451,
                                                                                317.04784, 317.13117, 317.21451, 317.29784, 317.38118, 317.46451,
                                                                                317.54785, 317.63119, 317.71452, 317.79785, 317.88118, 317.96451,
                                                                                318.04782, 318.13116, 318.21449, 318.29782, 318.38115, 318.46448,
                                                                                318.54782, 318.63115, 318.71447, 318.7978, 318.88113, 318.96446,
                                                                                319.04779, 319.13112, 319.21445, 319.29778, 319.38111, 319.46444,
                                                                                319.54777, 319.6311, 319.71443, 319.79776, 319.88109, 319.96443,
                                                                                320.04776, 320.13109, 320.21442, 320.29775, 320.38108, 320.46441,
                                                                                320.54775, 320.63107, 320.71441, 320.79776, 320.8811, 320.96444,
                                                                                321.04777, 321.13109, 321.21442, 321.29775, 321.38107, 321.4644,
                                                                                321.54773, 321.63105, 321.71438, 321.79771, 321.88105, 321.96437,
                                                                                322.0477, 322.13103, 322.21436, 322.29769, 322.38102, 322.46436,
                                                                                322.54769, 322.63103, 322.71436, 322.79769, 322.88102, 322.96436,
                                                                                323.0477, 323.13104, 323.21438, 323.29771, 323.38105, 323.46439,
                                                                                323.54772, 323.63105, 323.71438, 323.79771, 323.88104, 323.96437,
                                                                                324.04771, 324.13103, 324.21437, 324.2977, 324.38102, 324.46436,
                                                                                324.5477, 324.63104, 324.71437, 324.79771, 324.88104, 324.96437,
                                                                                325.0477)), class = "data.frame", row.names = c(NA, 122L))

  # package(s):
library("minpack.lm")# used for nlsLM()

    # objects:
    U <-550
    K <- 273.15
    p<-77+K
    R <- 0.00831

    # used to fix diff() complications in formula:
    a1<-df1$a[-1]
    b1<-df1$b[-1]
    J2<-df1$J[-1]
    J1<-df1$J[-nrow(df1)]
# try , apparently succeeded if GGrothendieck's answer uses it.
  df2 <- data.frame(a1,b1,J2,J1)
    # optimizing parameters U & p to fit a1:
     summary(nlsLM(formula=a1 ~U *(
      (1/ (1 + exp((U/ R)*((1/J2) - (1/p)))))
      -(1/ (1 + exp((U/ R)*((1/ J1) - (1/p)))))
      /(J2-J1)),
      data = df2,
      start = list(U=550),p=list(p),
      lower=c(300,50),upper=c(600,85),
      control= nls.lm.control(maxiter=1000),
      trace = F))

Error:

Error in model.frame.default(formula = ~a1 + J2 + J1, data = df1, p = list(p)) :
  invalid type (NULL) for variable 'J2'
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

Attempted to fix this with upper and lower limits with algorithm="port":

summary(nlsLM(formula=a1 ~U *(
  (1/ (1 + exp((U/ R)*((1/J2) - (1/p)))))
  -(1/ (1 + exp((U/ R)*((1/ J1) - (1/p)))))
  /(J2-J1)),
  data = df1,
  start = list(U=550),p=list(p),
  algorithm = "port",
  lower=c(300,365),upper=c(600,324),
  control= nls.lm.control(maxiter=1000),
  trace = F))

However, I achieve this error:

Error in upper(600, 324) : could not find function "upper"
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

However in an alternative formula, which is not equivalent to the one up top, I nlsLM runs fine without an algorithm=:

summary(nls(formula= a1~U*(diff(x)/diff(J-K)),
            data=d, start=list(U=552),
            control=nls.control(maxiter=1000),trace=F))

Body:
Fixing the syntax errors, note that only nls algorithm = "port" supports upper and lower and furthermore the problem is insensitive to the value of p.  If we run nls repeatedly fixing p to each integer value between 50 and 85 and optimize over U we get the same result (same U, same residual sum of squares) each time.

res <- lapply(50:85, function(p) {
  fo <- a1 ~U *(
    (1/ (1 + exp((U/ R)*((1/J2) - (1/p)))))-
    (1/ (1 + exp((U/ R)*((1/ J1) - (1/p))))) / (J2-J1))
  nls(fo, df2, start = list(U = 550),
    lower = 300, upper = 600, algorithm = "port")
})

# all iterations converged
all(sapply(res, function(x) x$convInfo$isConv))
##  [1] TRUE

# same U regardless of p
unname(sapply(res, coef))
## [1] 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300

# same residual sum of squares regardless of p
unname(sapply(res, deviance))
##  [1] 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551
## [15] 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551
## [29] 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551 1317808551

so we can fix p to any value between the limits that we wish and optimize over U, i.e. we can choose any component of res or use some other model in light of the the large residual sum of squares and the fact that J1 nearly equals J2

with(df2, var(J2 - J1))
## [1] 4.279614e-11

Even a simple linear model gives far lower residual sum of squares:

fm2 <- lm(a1 ~ b1 + I(J1 - J2) + 0, df2)
deviance(fm2)
## [1] 6.015689

Note

R <-  0.00831

df2 <-
structure(list(a1 = c(0.804841782886437, 0.783325233355932, 0.760569303063664,
0.727963278438188, 0.703970672785107, 0.680589589769403, 0.65474843620048,
0.629508566083339, 0.602417701399354, 0.576536805662077, 0.548851189058063,
0.519947188978781, 0.490433240798225, 0.462086422390147, 0.431909413297801,
0.403590803993467, 0.373435985401716, 0.343943659176956, 0.31380487904441,
0.284871585752978, 0.254086078501208, 0.231342598159761, 0.198724947119965,
0.16612702603107, 0.141555650677377, 0.109001084106243, 0.0831572469086037,
0.0579197953048283, 0.0332801640177642, 0.00921287687980588,
-0.00683461114689798, -0.0308662529136221, -0.0468697128496984,
-0.0634535329550516, -0.0788157766432729, -0.0947585282387919,
-0.112551607962292, -0.121770647911843, -0.131005124862407, -0.13105454830848,
-0.13913263731113, -0.141015879860184, -0.141727067372491, -0.15092263010162,
-0.151527379077436, -0.152155929282014, -0.144792734494917, -0.146630537024706,
-0.139308277987739, -0.142395755120843, -0.135627970868379, -0.130069772180454,
-0.134347052454578, -0.122661184175998, -0.119541926090815, -0.117691480771668,
-0.0980210085445172, -0.0900039693582695, -0.0734011206583904,
-0.0654294710491197, -0.0488666582927202, -0.0334934180561017,
-0.0181602076105936, -0.00403680892262948, 0.00958389551677818,
0.023138063507762, 0.0360154200368275, 0.0470535195180641, 0.0574121363142126,
0.0819938322538736, 0.104326976159514, 0.118669575746475, 0.123156717504759,
0.12529037342488, 0.11004928326779, 0.111288254062499, 0.112616123288566,
0.123770126197535, 0.125825836909568, 0.12600008978006, 0.133135092174578,
0.13150137631796, 0.137318345531007, 0.142490352653999, 0.127578135774472,
0.11881443261832, 0.101364392587429, 0.0930057723054443, 0.0753897222358955,
0.0657226581165791, 0.0559810295585592, 0.0486890523393608, 0.0359839335111634,
0.0239424532478925, 0.0137758789173201, 0.01148034494644, 0.00959075043614099,
0.00965506497270852, 0.0010321021197246, -0.00878784052445702,
-0.0186955496477701, -0.0286825539248294, -0.0387428469291482,
-0.0457835827509943, -0.0533022515989874, -0.067799838787316,
-0.0740879165672261, -0.0704910195102784, -0.0749170995555968,
-0.0892351910852938, -0.0952381116284169, -0.101154870134375,
-0.116713134920168, -0.123043579564404, -0.122229090993963, -0.131574286614478,
-0.139872347069247, -0.150352573559005, -0.160985422263815, -0.183477294368611,
-0.196028087077558), b1 = c(2.89275866243833e-07, 3.05704744509841e-07,
3.23056147643161e-07, 3.41383503107939e-07, 3.60740020118146e-07,
3.81182894669021e-07, 4.02772468186816e-07, 4.25573817135869e-07,
4.49652809926895e-07, 4.75077190571432e-07, 5.01924516454949e-07,
5.30273542459307e-07, 5.60209325607651e-07, 5.91819764376075e-07,
6.25191565024464e-07, 6.60423815060183e-07, 6.97623624698831e-07,
7.36899824259678e-07, 7.78364716293996e-07, 8.22141727880177e-07,
8.68358553356049e-07, 9.17146942649445e-07, 9.68648499282585e-07,
1.02301254228321e-06, 1.08039295361324e-06, 1.14095522628006e-06,
1.20488164276889e-06, 1.27235309266431e-06, 1.34356428051965e-06,
1.41872017661923e-06, 1.49803720002012e-06, 1.58174837208432e-06,
1.67008400106882e-06, 1.76329669689182e-06, 1.86165861610844e-06,
1.96545125564181e-06, 2.07495771940026e-06, 2.19051033032321e-06,
2.31244676896853e-06, 2.44109344748083e-06, 2.57682364247604e-06,
2.72002332780748e-06, 2.87110867939643e-06, 3.03049986417657e-06,
3.19862819087422e-06, 3.37598849722003e-06, 3.56309366647097e-06,
3.76046212631028e-06, 3.96865098343192e-06, 4.18824726536018e-06,
4.41986951018994e-06, 4.66416943984418e-06, 4.92183372125163e-06,
5.1935858199306e-06, 5.48018795087751e-06, 5.78244313168551e-06,
6.1011973433322e-06, 6.43734180406693e-06, 6.7918153624452e-06,
7.16563024757515e-06, 7.55980712352996e-06, 7.97541858133744e-06,
8.41364335579908e-06, 8.87569896478336e-06, 9.36286778257749e-06,
9.87650045747503e-06, 1.04180531601306e-05, 1.09889579629179e-05,
1.15908264520961e-05, 1.22254359968269e-05, 1.28944314880812e-05,
1.35996142589735e-05, 1.43429180537019e-05, 1.51263316467067e-05,
1.59520940241802e-05, 1.6822522665106e-05, 1.77398981706101e-05,
1.87067840492661e-05, 1.97258854864512e-05, 2.07998638330026e-05,
2.1931710964562e-05, 2.3124583860732e-05, 2.43817436226076e-05,
2.57064566766011e-05, 2.71023147452351e-05, 2.85732719977727e-05,
3.01232366788732e-05, 3.17564077655259e-05, 3.34772050137959e-05,
3.52903930671811e-05, 3.72007656749664e-05, 3.92134811622193e-05,
4.13339600995988e-05, 4.35677774133232e-05, 4.59210633579047e-05,
4.84002939774841e-05, 5.10121441928917e-05, 5.37634740647825e-05,
5.66616536161489e-05, 5.97142485508226e-05, 6.29295921258743e-05,
6.63164729686435e-05, 6.98835178901844e-05, 7.36402014328656e-05,
7.75967281240777e-05, 8.17636166483606e-05, 8.61519334015006e-05,
9.07733206985704e-05, 9.56403286306054e-05, 0.000100765247971781,
0.000106161936108279, 0.000111844981550703, 0.000117828340858234,
0.00012412884956377, 0.000130763552542832, 0.000137749179512345,
0.00014510363839137, 0.000152846660963375, 0.000160998542157569,
0.000169580127136327, 0.000178614349528655), J2 = c(315.0479,
315.13122, 315.21455, 315.29788, 315.38121, 315.46454, 315.54787,
315.63121, 315.71454, 315.79786, 315.88119, 315.96451, 316.04785,
316.13118, 316.2145, 316.29782, 316.38115, 316.46448, 316.54781,
316.63115, 316.71449, 316.79783, 316.88117, 316.96451, 317.04784,
317.13117, 317.21451, 317.29784, 317.38118, 317.46451, 317.54785,
317.63119, 317.71452, 317.79785, 317.88118, 317.96451, 318.04782,
318.13116, 318.21449, 318.29782, 318.38115, 318.46448, 318.54782,
318.63115, 318.71447, 318.7978, 318.88113, 318.96446, 319.04779,
319.13112, 319.21445, 319.29778, 319.38111, 319.46444, 319.54777,
319.6311, 319.71443, 319.79776, 319.88109, 319.96443, 320.04776,
320.13109, 320.21442, 320.29775, 320.38108, 320.46441, 320.54775,
320.63107, 320.71441, 320.79776, 320.8811, 320.96444, 321.04777,
321.13109, 321.21442, 321.29775, 321.38107, 321.4644, 321.54773,
321.63105, 321.71438, 321.79771, 321.88105, 321.96437, 322.0477,
322.13103, 322.21436, 322.29769, 322.38102, 322.46436, 322.54769,
322.63103, 322.71436, 322.79769, 322.88102, 322.96436, 323.0477,
323.13104, 323.21438, 323.29771, 323.38105, 323.46439, 323.54772,
323.63105, 323.71438, 323.79771, 323.88104, 323.96437, 324.04771,
324.13103, 324.21437, 324.2977, 324.38102, 324.46436, 324.5477,
324.63104, 324.71437, 324.79771, 324.88104, 324.96437, 325.0477
), J1 = c(314.96456, 315.0479, 315.13122, 315.21455, 315.29788,
315.38121, 315.46454, 315.54787, 315.63121, 315.71454, 315.79786,
315.88119, 315.96451, 316.04785, 316.13118, 316.2145, 316.29782,
316.38115, 316.46448, 316.54781, 316.63115, 316.71449, 316.79783,
316.88117, 316.96451, 317.04784, 317.13117, 317.21451, 317.29784,
317.38118, 317.46451, 317.54785, 317.63119, 317.71452, 317.79785,
317.88118, 317.96451, 318.04782, 318.13116, 318.21449, 318.29782,
318.38115, 318.46448, 318.54782, 318.63115, 318.71447, 318.7978,
318.88113, 318.96446, 319.04779, 319.13112, 319.21445, 319.29778,
319.38111, 319.46444, 319.54777, 319.6311, 319.71443, 319.79776,
319.88109, 319.96443, 320.04776, 320.13109, 320.21442, 320.29775,
320.38108, 320.46441, 320.54775, 320.63107, 320.71441, 320.79776,
320.8811, 320.96444, 321.04777, 321.13109, 321.21442, 321.29775,
321.38107, 321.4644, 321.54773, 321.63105, 321.71438, 321.79771,
321.88105, 321.96437, 322.0477, 322.13103, 322.21436, 322.29769,
322.38102, 322.46436, 322.54769, 322.63103, 322.71436, 322.79769,
322.88102, 322.96436, 323.0477, 323.13104, 323.21438, 323.29771,
323.38105, 323.46439, 323.54772, 323.63105, 323.71438, 323.79771,
323.88104, 323.96437, 324.04771, 324.13103, 324.21437, 324.2977,
324.38102, 324.46436, 324.5477, 324.63104, 324.71437, 324.79771,
324.88104, 324.96437)), class = "data.frame", row.names = c(NA,
-121L))


问:
Add blank option to top of select and make it the selected option in IE
HTML:

```<code><select id="dropdown">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>
</code>```

jQuery:

```<code>$("#dropdown").prepend("<option value='' selected='selected'></option>");
</code>```

When I run this in FireFox or Chrome, the drop down has the newly inserted blank option selected. When I run it in IE8, it still has Volvo selected. Any ideas?

http://jsfiddle.net/YFu2h/

答:
I'm not sure why your code is not working (maybe it has something to do with the fact that in IE, selectedIndex is readonly) but, doing this works in IE:

```<code>$("#dropdown").prepend("<option value='' selected='selected'></option>");
$("#dropdown")[0].options[0].selected = true;
</code>```

Body:
HTML:

<select id="dropdown">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

jQuery:

$("#dropdown").prepend("<option value='' selected='selected'></option>");

When I run this in FireFox or Chrome, the drop down has the newly inserted blank option selected. When I run it in IE8, it still has Volvo selected. Any ideas?

http://jsfiddle.net/YFu2h/

Body:
I'm not sure why your code is not working (maybe it has something to do with the fact that in IE, selectedIndex is readonly) but, doing this works in IE:

$("#dropdown").prepend("<option value='' selected='selected'></option>");
$("#dropdown")[0].options[0].selected = true;


答:
https://docs.python.org/3/library/stdtypes.html#str.split

If sep is not specified or is None, a different splitting algorithm is applied: runs of consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the start or end if the string has leading or trailing whitespace.

You are right (at least for the case of using the default split by whitespace). Leading and trailing as well as consecutive whitescapes are ignored, and since .strip() does nothing else than remove leading and trailing whitespaces, it will result in the same output here.

Title: Split vs Strip in Python to remove redundant white space


问:
Remove cookie problems JS-COOKIE
JS Cookies remove cookie, undefined

Hi Guys, I have trying to remove a cookie from a domain but I can't, the console return undefined.

When I log in the cookie is set up in .dev.books.com but after that the URL change to platform.dev.books.com and keep the same cookies.  The name of the cookie I want to remove is bookId, here is my try:

```<code>Cookies.set('bookId', ' ');
</code>```

But instead to change the cookie value, create a new one with the domain platform.dev.books.com

If I use

```<code>Cookie.remove('bookId')
</code>```

the console return undefined

Thanks, any help will be helpful

答:
Delete a cookie valid to the path of the current page:

```<code>Cookies.set('name', 'value', { path: '' })
Cookies.remove('name') // fail!
Cookies.remove('name', { path: '' }) // removed!
</code>```

IMPORTANT! When deleting a cookie and you're not relying on the default attributes, you must pass the exact same path and domain attributes that were used to set the cookie:

```<code>Cookies.remove('name', { path: '', domain: '.yourdomain.com' })

Note: Removing a nonexistent cookie neither raises any exception nor returns any value.
</code>```

I'll advice you always try to go through the readme of any package you use, thank me latter, lol.  https://www.npmjs.com/package/js-cookie

Title: Remove cookie problems JS-COOKIE

Body:
JS Cookies remove cookie, undefined

Hi Guys, I have trying to remove a cookie from a domain but I can't, the console return undefined.

When I log in the cookie is set up in .dev.books.com but after that the URL change to platform.dev.books.com and keep the same cookies.  The name of the cookie I want to remove is bookId, here is my try:

Cookies.set('bookId', ' ');

But instead to change the cookie value, create a new one with the domain platform.dev.books.com

If I use

Cookie.remove('bookId')

the console return undefined

Thanks, any help will be helpful

Body:
Delete a cookie valid to the path of the current page:

Cookies.set('name', 'value', { path: '' })
Cookies.remove('name') // fail!
Cookies.remove('name', { path: '' }) // removed!

IMPORTANT! When deleting a cookie and you're not relying on the default attributes, you must pass the exact same path and domain attributes that were used to set the cookie:

Cookies.remove('name', { path: '', domain: '.yourdomain.com' })

Note: Removing a nonexistent cookie neither raises any exception nor returns any value.

I'll advice you always try to go through the readme of any package you use, thank me latter, lol.  https://www.npmjs.com/package/js-cookie


问:
Entity manager error on the server?
Hi I have developed my java application on glassfish server with EJB 3.0 persistance. On my local machine the application was running fine and was persisting the data perfectly. However, When I deployed it on the linux server, whenever I persist any data it gives me this EJB exception error:

```<code>Caused by: Java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManagerFactory.
</code>```

And here is my persistence.xml file:

```<code><?xml version="1.0" encoding="UTF-8" ?>
  <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="MyPU" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>jdbc/security</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.ddl-generation" value="create-tables" />
        </properties>
    </persistence-unit>
  </persistence>
</code>```

what could possbily cause this?

PS: Im using Glassfish 3.1.43, EJB 3.0

答: I have managed to solve it finally!! The problem was in the database connection that was not set properly!! Now I have connected to the database and the data are persisted!!</p>

Title: Entity manager error on the server?

Body:
Hi I have developed my java application on glassfish server with EJB 3.0 persistance. On my local machine the application was running fine and was persisting the data perfectly. However, When I deployed it on the linux server, whenever I persist any data it gives me this EJB exception error:

Caused by: Java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManagerFactory.

And here is my persistence.xml file:

<?xml version="1.0" encoding="UTF-8" ?>
  <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="MyPU" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>jdbc/security</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.ddl-generation" value="create-tables" />
        </properties>
    </persistence-unit>
  </persistence>

what could possbily cause this?

PS: Im using Glassfish 3.1.43, EJB 3.0


问:
How pass parcelable argument with new version of compose navigation?
I had an app made with jetpack compose that worked fine until I upgraded the compose navigation library
from version 2.4.0-alpha07 to version 2.4.0-alpha08
In the alpha08 version it seems to me that the arguments attribute of the NavBackStackEntry class is a val, so it can't be reassigned as we did in the 2.4.0-alpha07 version.
How to solve this problem in version 2.4.0-alpha08?

My navigation component is this:

```<code>@Composable
private fun NavigationComponent(navController: NavHostController) {
    NavHost(navController = navController, startDestination = "home") {
        composable("home") { HomeScreen(navController) }
        composable("details") {
            val planet = navController
                .previousBackStackEntry
                ?.arguments
                ?.getParcelable<Planet>("planet")
            planet?.let {
                DetailsScreen(it, navController)
            }
        }
    }
}
</code>```

The part where I try to make the navigation happen to the details page is in this function:

```<code>private fun navigateToPlanet(navController: NavHostController, planet: Planet) {
    navController.currentBackStackEntry?.arguments = Bundle().apply {
        putParcelable("planet", planet)
    }
    navController.navigate("details")
}
</code>```

I've already tried simply applying to the recurring arguments of the navigateToPlanet function using apply but it doesn't work, the screen opens blank without any information. This is the code for my failed attempt:

```<code>private fun navigateToPlanet(navController: NavHostController, planet: Planet) {
    navController.currentBackStackEntry?.arguments?.apply {
        putParcelable("planet", planet)
    }
    navController.navigate("details")
}
</code>```

答:
A very simple and basic way to do is as below

1.First create the parcelable object that you want to pass e.g

```<code>@Parcelize
data class User(
    val name: String,
    val phoneNumber:String
) : Parcelable
</code>```

2.Then in the current composable that you are in e.g main screen

```<code> val userDetails = UserDetails(
                            name = "emma",
                             phoneNumber = "1234"
                            )
                        )
navController.currentBackStackEntry?.arguments?.apply {
                            putParcelable("userDetails",userDetails)
                        }
                        navController.navigate(Destination.DetailsScreen.route)
</code>```

3.Then in the details composable, make sure you pass to it a navcontroller as an parameter e.g.

```<code>@Composable
fun Details (navController:NavController){
val data = remember {
        mutableStateOf(navController.previousBackStackEntry?.arguments?.getParcelable<UserDetails>("userDetails")!!)
    }
}
</code>```

N.B:  If the parcelable is not passed into state, you will receive an error when navigating back

Body:
I had an app made with jetpack compose that worked fine until I upgraded the compose navigation library
from version 2.4.0-alpha07 to version 2.4.0-alpha08
In the alpha08 version it seems to me that the arguments attribute of the NavBackStackEntry class is a val, so it can't be reassigned as we did in the 2.4.0-alpha07 version.
How to solve this problem in version 2.4.0-alpha08?

My navigation component is this:

@Composable
private fun NavigationComponent(navController: NavHostController) {
    NavHost(navController = navController, startDestination = "home") {
        composable("home") { HomeScreen(navController) }
        composable("details") {
            val planet = navController
                .previousBackStackEntry
                ?.arguments
                ?.getParcelable<Planet>("planet")
            planet?.let {
                DetailsScreen(it, navController)
            }
        }
    }
}

The part where I try to make the navigation happen to the details page is in this function:

private fun navigateToPlanet(navController: NavHostController, planet: Planet) {
    navController.currentBackStackEntry?.arguments = Bundle().apply {
        putParcelable("planet", planet)
    }
    navController.navigate("details")
}

I've already tried simply applying to the recurring arguments of the navigateToPlanet function using apply but it doesn't work, the screen opens blank without any information. This is the code for my failed attempt:

private fun navigateToPlanet(navController: NavHostController, planet: Planet) {
    navController.currentBackStackEntry?.arguments?.apply {
        putParcelable("planet", planet)
    }
    navController.navigate("details")
}

Body:
A very simple and basic way to do is as below

1.First create the parcelable object that you want to pass e.g

@Parcelize
data class User(
    val name: String,
    val phoneNumber:String
) : Parcelable

2.Then in the current composable that you are in e.g main screen

 val userDetails = UserDetails(
                            name = "emma",
                             phoneNumber = "1234"
                            )
                        )
navController.currentBackStackEntry?.arguments?.apply {
                            putParcelable("userDetails",userDetails)
                        }
                        navController.navigate(Destination.DetailsScreen.route)

3.Then in the details composable, make sure you pass to it a navcontroller as an parameter e.g.

@Composable
fun Details (navController:NavController){
val data = remember {
        mutableStateOf(navController.previousBackStackEntry?.arguments?.getParcelable<UserDetails>("userDetails")!!)
    }
}

N.B:  If the parcelable is not passed into state, you will receive an error when navigating back


问:
How can i get a specific data from my dataset using SQL and PHPmyadmin?
I'm new to sql.
I have 3 datasets ,
patient (columns : id age Zip_Code, size, weight, sex)
blood_tests (columns : test_ID, test_date, blood_sugar, laboratory_ID, patient_ID)
laboratory (columns : id, name, Zip_code, departments)

how can i get the number of patients per center ?
i did this code but it doesnt give the number per

```<code>select DISTINCT patient_ID, laboratory_ID from patient,blood_tests where patient.id = blood_tests.patient_ID AND blood_tests.laboratory_ID = laboratory.id;
</code>```

but i don't know how to get the total number of patients per center, because some of them did more than one exam in the same center and they have done tests in many labs?

For the second question. he aks us to get the 4 tests that a specific patient carried out in a laboratory called 'NWB'.
and i did this and noticed that he is patient with and ID = 25 but how can i get that without specifying that the id is 25.

```<code>select patient_ID, laboratory.name from patient, blood_tests,laboratory where patient_ID = blood_tests.patient_ID AND blood_tests.laboratory_ID = laboratory.id HAVING laboratory.name = "NWB";
</code>```

Thank You in advance.

答:
You need to use COUNT(DISTINCT ~ ) and GROUP BY. We don't need to use the table patients because we have patient_ID in blood_tests.

```<code>SELECT
   COUNT( DISTINCT bt.patient_ID) number_patients ,
   bt.laboratory_ID
FROM
    blood_tests bt
JOIN
    laboratory l
ON bt.laboratory_ID = l.id
GROUP BY
    laboratory_ID;
</code>```

For the second request:

```<code>SELECT
   GROUP_CONCAT(
      bt.test_ID
      SEPARATOR CHAR(10)
      )               test_IDs,
   bt.patient_ID      patientID,
   bt.laboratory_ID.  labo_ID,
   l.name             lab_name,
   l.Zip_code.        lab_zip,
   l.departments.     lab_dept
FROM
   blood_tests bt
JOIN
   laboratory l
ON
   bt.laboratory_ID = l.id
WHERE
   l.name = 'NWB'
GROUP BY
   bt.patient_ID ,
   bt.laboratory_ID,
   l.name lab_name,
   l.Zip_code,
   l.departments
HAVING
   COUNT(bt.test_ID) = 4;
</code>```

Body:
I'm new to sql.
I have 3 datasets ,
patient (columns : id age Zip_Code, size, weight, sex)
blood_tests (columns : test_ID, test_date, blood_sugar, laboratory_ID, patient_ID)
laboratory (columns : id, name, Zip_code, departments)

how can i get the number of patients per center ?
i did this code but it doesnt give the number per

select DISTINCT patient_ID, laboratory_ID from patient,blood_tests where patient.id = blood_tests.patient_ID AND blood_tests.laboratory_ID = laboratory.id;

but i don't know how to get the total number of patients per center, because some of them did more than one exam in the same center and they have done tests in many labs?

For the second question. he aks us to get the 4 tests that a specific patient carried out in a laboratory called 'NWB'.
and i did this and noticed that he is patient with and ID = 25 but how can i get that without specifying that the id is 25.

select patient_ID, laboratory.name from patient, blood_tests,laboratory where patient_ID = blood_tests.patient_ID AND blood_tests.laboratory_ID = laboratory.id HAVING laboratory.name = "NWB";

Thank You in advance.

Body:
You need to use COUNT(DISTINCT ~ ) and GROUP BY. We don't need to use the table patients because we have patient_ID in blood_tests.

SELECT
   COUNT( DISTINCT bt.patient_ID) number_patients ,
   bt.laboratory_ID
FROM
    blood_tests bt
JOIN
    laboratory l
ON bt.laboratory_ID = l.id
GROUP BY
    laboratory_ID;

For the second request:

SELECT
   GROUP_CONCAT(
      bt.test_ID
      SEPARATOR CHAR(10)
      )               test_IDs,
   bt.patient_ID      patientID,
   bt.laboratory_ID.  labo_ID,
   l.name             lab_name,
   l.Zip_code.        lab_zip,
   l.departments.     lab_dept
FROM
   blood_tests bt
JOIN
   laboratory l
ON
   bt.laboratory_ID = l.id
WHERE
   l.name = 'NWB'
GROUP BY
   bt.patient_ID ,
   bt.laboratory_ID,
   l.name lab_name,
   l.Zip_code,
   l.departments
HAVING
   COUNT(bt.test_ID) = 4;


问:
I want to change the compiler of a makefile from pgi to gfortran and I was wondering how I should change the FC and FFLAGS to make it work
I have 5 makefiles which are designed for pgi compiler. However, my system is working with gfortran and I do not how to make them work with my system and how should I change FC and FFLAGS. I am new to Linux operating system and I am using Ubuntu 20.04.
Here are what the files contain:

```<code>SHELL=/bin/sh
FC= pgf90
FFLAGS= -O -Mvect=sse -Mextend -Msecond_underscore -Mlfs -Bstatic

PROGRAM= mgn2mech
LIBS =   -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
         -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lnetcdf
INCLUDE = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
          -I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include \
          -I$(CURDIR)/INCLDIR

OBJS = \
     checkmem.o \
     growseason.o \
     $(PROGRAM).o

MODULES= *mod.f

#-----------------------------------------------------------------------
# line to allow file.mod files to be recognised by GNU make
%.o : %.mod
#-----------------------------------------------------------------------

.SUFFIXES : .f .f .o

.f.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<
.F.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<

#-----------------------------------------------------------------------

$(PROGRAM): $(OBJS)
    $(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(OBJS) $(LIBS)

#-----------------------------------------------------------------------

clean:
    rm -f $(PROGRAM) *.o *.mod *.core
#-----------------------------------------------------------------------
</code>```

Next one:

```<code>FC = /usr/local/pgi/linux86/bin/pgf90
FCFLGS = -O -Mextend -Mbounds -Mlfs -Msecond_underscore
FCFLGS2 = -O -Mbyteswapio -Mextend -Mbounds -Mlfs -Msecond_underscore
LNKFLGS = -Bstatic

OBJCTS = \
met2mgn.o \
readpar.o \
readmcip.o \
micromet.o \
caldate.o \
lcpgeo.o \
interp_lcp.o \
procmm5.o \
readmm5.o \
xtod.o \
vertmap.o \
juldate.o \
utmgeo.o

LIBS = -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
 -L/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/lib -lnetcdf -lpthread
INC = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
      -I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include

met2mgn: $(OBJCTS)
    $(FC) -o met2mgn $(LNKFLGS) $(OBJCTS) $(LIBS)
met2mgn.o:
    $(FC) -c $(FCFLGS2) $(INC) met2mgn.f
readpar.o:
    $(FC) -c $(FCFLGS) $(INC) readpar.f
readmcip.o:
    $(FC) -c $(FCFLGS2) $(INC) readmcip.f
micromet.o:
    $(FC) -c $(FCFLGS2) $(INC) micromet.f
caldate.o:
    $(FC) -c $(FCFLGS2) $(INC) caldate.f
lcpgeo.o:
    $(FC) -c $(FCFLGS2) ${INC} lcpgeo.f
interp_lcp.o:
    $(FC) -c $(FCFLGS2) ${INC} interp_lcp.f
procmm5.o:
    $(FC) -c $(FCFLGS2) ${INC} procmm5.f
readmm5.o:
    $(FC) -c $(FCFLGS2) ${INC} readmm5.f
xtod.o:
    $(FC) -c $(FCFLGS2) ${INC} xtod.f
vertmap.o:
    $(FC) -c $(FCFLGS2) ${INC} vertmap.f
juldate.o:
    $(FC) -c $(FCFLGS2) ${INC} juldate.f
utmgeo.o:
    $(FC) -c $(FCFLGS2) ${INC} utmgeo.f
clean:
    rm -rf *.o met2mgn
</code>```

Next one:

```<code>SHELL = /bin/sh
FC = pgf90
FFLAGS = -O2 -Mdalign -Mnoframe -byteswapio -Mlfs -Bstatic
PROGRAM = ioapi2uam
LIBS = -L/models/MEGAN/MEGANv2.03a/lib/ioapi_3/Linux2_x86pg -lioapi \
       -L/models/MEGAN/MEGANv2.03a/lib/netCDF/lib -lnetcdf
INCLUDE = -I/models/MEGAN/MEGANv2.03a/lib/ioapi_3/fixed_src

RAW = $(PROGRAM).o

.f.o:
    $(FC) $(FFLAGS) $(INCLUDE) -c -o $@ $<

.F.o:
    $(FC) $(FFLAGS) $(INCLUDE) -c -o $@ $<

$(PROGRAM):     $(RAW)
    $(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(RAW) $(LIBS)

clean:
    rm -f $(PROGRAM)
</code>```

Next one:

```<code>SHELL=/bin/sh
FC= pgf90
FFLAGS= -O -Mvect=sse -Mextend -Msecond_underscore -Mlfs -Bstatic

PROGRAM= emproc
LIBS =   -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
         -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lnetcdf
INCLUDE = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
          -I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include \
          -I$(CURDIR)/INCLDIR

OBJS = \
     gamma_etc.o \
     checkmem.o \
     canopy.o \
     solarangle.o \
     findlai.o \
     soilnox_fx.o \
     soilnox.o \
     $(PROGRAM).o

MODULES= *mod.f

#-----------------------------------------------------------------------
# line to allow file.mod files to be recognised by GNU make
%.o : %.mod
#-----------------------------------------------------------------------

.SUFFIXES : .f .f .o

.f.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<
.F.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<

#-----------------------------------------------------------------------

$(PROGRAM): $(OBJS)
    $(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(OBJS) $(LIBS)

#-----------------------------------------------------------------------

clean:
    rm -f $(PROGRAM) *.o *.mod *.core
#-----------------------------------------------------------------------
</code>```

Last one:

```<code>SHELL=/bin/sh
FC= pgf90
FFLAGS= -O -Mvect=sse -Mextend -Msecond_underscore -Mlfs -Bstatic

PROGRAM= emproc
LIBS =   -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
         -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lnetcdf
INCLUDE = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
          -I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include \
          -I$(CURDIR)/INCLDIR

OBJS = \
     gamma_etc.o \
     checkmem.o \
     canopy.o \
     solarangle.o \
     findlai.o \
     soilnox_fx.o \
     soilnox.o \
     $(PROGRAM).o

MODULES= *mod.f

#-----------------------------------------------------------------------
# line to allow file.mod files to be recognised by GNU make
%.o : %.mod
#-----------------------------------------------------------------------

.SUFFIXES : .f .f .o

.f.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<
.F.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<

#-----------------------------------------------------------------------

$(PROGRAM): $(OBJS)
    $(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(OBJS) $(LIBS)

#-----------------------------------------------------------------------

clean:
    rm -f $(PROGRAM) *.o *.mod *.core
#-----------------------------------------------------------------------
</code>```

答:
Have a look at the I/O API M3Tools Makefile template.

Note that the ioapi/Makeinclude.${BIN} files for the various types -- in this case, $BIN=Linux2_x86_64gfort for gfortran before version 10, or $BIN=Linux2_x86_64gfort10 for gfortran versions 10 or later will give you the flags you need.

Note also that this m3tools/Makefile.template is much better integrated with the underlying Models-3 I/O API than the one the code-author gives you....

Body:
I have 5 makefiles which are designed for pgi compiler. However, my system is working with gfortran and I do not how to make them work with my system and how should I change FC and FFLAGS. I am new to Linux operating system and I am using Ubuntu 20.04.
Here are what the files contain:

SHELL=/bin/sh
FC= pgf90
FFLAGS= -O -Mvect=sse -Mextend -Msecond_underscore -Mlfs -Bstatic

PROGRAM= mgn2mech
LIBS =   -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
         -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lnetcdf
INCLUDE = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
          -I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include \
          -I$(CURDIR)/INCLDIR

OBJS = \
     checkmem.o \
     growseason.o \
     $(PROGRAM).o

MODULES= *mod.f

#-----------------------------------------------------------------------
# line to allow file.mod files to be recognised by GNU make
%.o : %.mod
#-----------------------------------------------------------------------

.SUFFIXES : .f .f .o

.f.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<
.F.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<

#-----------------------------------------------------------------------

$(PROGRAM): $(OBJS)
    $(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(OBJS) $(LIBS)

#-----------------------------------------------------------------------

clean:
    rm -f $(PROGRAM) *.o *.mod *.core
#-----------------------------------------------------------------------

Next one:

FC = /usr/local/pgi/linux86/bin/pgf90
FCFLGS = -O -Mextend -Mbounds -Mlfs -Msecond_underscore
FCFLGS2 = -O -Mbyteswapio -Mextend -Mbounds -Mlfs -Msecond_underscore
LNKFLGS = -Bstatic

OBJCTS = \
met2mgn.o \
readpar.o \
readmcip.o \
micromet.o \
caldate.o \
lcpgeo.o \
interp_lcp.o \
procmm5.o \
readmm5.o \
xtod.o \
vertmap.o \
juldate.o \
utmgeo.o

LIBS = -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
 -L/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/lib -lnetcdf -lpthread
INC = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
      -I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include

met2mgn: $(OBJCTS)
    $(FC) -o met2mgn $(LNKFLGS) $(OBJCTS) $(LIBS)
met2mgn.o:
    $(FC) -c $(FCFLGS2) $(INC) met2mgn.f
readpar.o:
    $(FC) -c $(FCFLGS) $(INC) readpar.f
readmcip.o:
    $(FC) -c $(FCFLGS2) $(INC) readmcip.f
micromet.o:
    $(FC) -c $(FCFLGS2) $(INC) micromet.f
caldate.o:
    $(FC) -c $(FCFLGS2) $(INC) caldate.f
lcpgeo.o:
    $(FC) -c $(FCFLGS2) ${INC} lcpgeo.f
interp_lcp.o:
    $(FC) -c $(FCFLGS2) ${INC} interp_lcp.f
procmm5.o:
    $(FC) -c $(FCFLGS2) ${INC} procmm5.f
readmm5.o:
    $(FC) -c $(FCFLGS2) ${INC} readmm5.f
xtod.o:
    $(FC) -c $(FCFLGS2) ${INC} xtod.f
vertmap.o:
    $(FC) -c $(FCFLGS2) ${INC} vertmap.f
juldate.o:
    $(FC) -c $(FCFLGS2) ${INC} juldate.f
utmgeo.o:
    $(FC) -c $(FCFLGS2) ${INC} utmgeo.f
clean:
    rm -rf *.o met2mgn

Next one:

SHELL = /bin/sh
FC = pgf90
FFLAGS = -O2 -Mdalign -Mnoframe -byteswapio -Mlfs -Bstatic
PROGRAM = ioapi2uam
LIBS = -L/models/MEGAN/MEGANv2.03a/lib/ioapi_3/Linux2_x86pg -lioapi \
       -L/models/MEGAN/MEGANv2.03a/lib/netCDF/lib -lnetcdf
INCLUDE = -I/models/MEGAN/MEGANv2.03a/lib/ioapi_3/fixed_src

RAW = $(PROGRAM).o

.f.o:
    $(FC) $(FFLAGS) $(INCLUDE) -c -o $@ $<

.F.o:
    $(FC) $(FFLAGS) $(INCLUDE) -c -o $@ $<

$(PROGRAM):     $(RAW)
    $(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(RAW) $(LIBS)

clean:
    rm -f $(PROGRAM)

Next one:

SHELL=/bin/sh
FC= pgf90
FFLAGS= -O -Mvect=sse -Mextend -Msecond_underscore -Mlfs -Bstatic

PROGRAM= emproc
LIBS =   -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
         -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lnetcdf
INCLUDE = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
          -I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include \
          -I$(CURDIR)/INCLDIR

OBJS = \
     gamma_etc.o \
     checkmem.o \
     canopy.o \
     solarangle.o \
     findlai.o \
     soilnox_fx.o \
     soilnox.o \
     $(PROGRAM).o

MODULES= *mod.f

#-----------------------------------------------------------------------
# line to allow file.mod files to be recognised by GNU make
%.o : %.mod
#-----------------------------------------------------------------------

.SUFFIXES : .f .f .o

.f.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<
.F.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<

#-----------------------------------------------------------------------

$(PROGRAM): $(OBJS)
    $(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(OBJS) $(LIBS)

#-----------------------------------------------------------------------

clean:
    rm -f $(PROGRAM) *.o *.mod *.core
#-----------------------------------------------------------------------

Last one:

SHELL=/bin/sh
FC= pgf90
FFLAGS= -O -Mvect=sse -Mextend -Msecond_underscore -Mlfs -Bstatic

PROGRAM= emproc
LIBS =   -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lioapi \
         -L/models/CMAQ/lib/ioapi_3.mulcahy/Linux2_x86pg -lnetcdf
INCLUDE = -I/models/CMAQ/lib/ioapi_3.mulcahy/ioapi/fixed_src \
          -I/models/CMAQ/lib/netcdf-3.6.0-p1.mulcahy/include \
          -I$(CURDIR)/INCLDIR

OBJS = \
     gamma_etc.o \
     checkmem.o \
     canopy.o \
     solarangle.o \
     findlai.o \
     soilnox_fx.o \
     soilnox.o \
     $(PROGRAM).o

MODULES= *mod.f

#-----------------------------------------------------------------------
# line to allow file.mod files to be recognised by GNU make
%.o : %.mod
#-----------------------------------------------------------------------

.SUFFIXES : .f .f .o

.f.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<
.F.o:
    $(FC) -c $(FFLAGS) $(INCLUDE) $<

#-----------------------------------------------------------------------

$(PROGRAM): $(OBJS)
    $(FC) $(FFLAGS) $(INCLUDE) -o $(@) $(OBJS) $(LIBS)

#-----------------------------------------------------------------------

clean:
    rm -f $(PROGRAM) *.o *.mod *.core
#-----------------------------------------------------------------------